refactor(dbus): replace dbus-send CLI with in-process dbus-python#23
Open
isac322 wants to merge 3 commits into
Open
refactor(dbus): replace dbus-send CLI with in-process dbus-python#23isac322 wants to merge 3 commits into
isac322 wants to merge 3 commits into
Conversation
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
📝 Docs & SEO ReviewSource files changed in this PR: Consistency check results:
|
- Add dbus_args.py: full dbus-send recursive-descent parser (12 basic
types + array/dict/variant containers) returning dbus-python types.
- Add typed-JSON args dispatcher: args list now accepts both legacy
'type:value' strings and {type, value} dicts, mixed in one call.
Schema widened (additive): list[str] -> list[str | dict].
- core.py:dbus_call now uses dbus.bus.BusConnection + Interface in-process
(no subprocess). Errors surface as 'D-Bus error: <name>: <msg>'.
- _format_dbus_result: void -> empty, primitive -> bare, container -> JSON.
- 80 unit tests for the parser; 6 integration tests against virtual KWin.
- docs/design/dbus-call-call-sites.md documents the public-tool contract.
Pre-commit: ruff/ty clean, ci_guards pass, 87 tests green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The
dbus_callMCP tool ransubprocess.run(["dbus-send", ...])for every call. Spawn overhead, fd-passing limitations, no structured error handling.What
src/kwin_mcp/dbus_args.py(NEW, 482L): full dbus-send syntax recursive-descent parserstring,int16/32/64,uint*,byte,double,boolean,objpath,signature)array:T:v1,v2,dict:K:V:k1:v1,k2:v2,variant:T:v) + nestingdbus.types.*(no parallel type system){"type":"int32","value":42}) dispatcher + round-trip safety (to_dbus_send_string)src/kwin_mcp/core.py:dbus_call:dbus.bus.BusConnection(addr).get_object().get_dbus_method(method)(*parsed_args). Zero subprocess.src/kwin_mcp/server.py:dbus_callschema:args: list[str | dict] | None(additive widening; legacy["string:hello"]remains compatible)tests/test_dbus_args.py: 80 unit tests (all basic types + containers + nesting + edge cases)tests/integration/test_dbus_call_compat.py: 6 integration tests (legacy / typed / mixed / error formats)docs/design/dbus-call-call-sites.md: call-site mapCompatibility
["string:hello", "int32:42"]continue to work[Internal]in CHANGELOG)Verify
Series: Stacked on top of PR 0. Base =
overhaul/pr0-tests-ci-guards. Once PR 0 merges, GitHub will automatically retarget this PR's base tomain.