feat(runtimes): register kimaki + opencode worktree runtime signatures#132
Merged
Conversation
Mirror lib/cli-channel.sh's marker-delimited mu-plugin pattern for a second filter consumer: datamachine_code_worktree_runtime_signatures (Extra-Chill/data-machine-code#416). Each runtime gets an idempotent BEGIN/END block in wp-coding-agents-runtimes.php; register/unregister mutate just that runtime's block and leave siblings intact. Includes tests/runtime-signature.sh covering scaffold, idempotency, mutation, unregister, and end-to-end filter shape.
Wire each runtime/bridge to publish its env-var signature into the new mu-plugin on install and on upgrade-time refresh: - bridges/kimaki.sh registers session_id/thread_id/thread_url against KIMAKI_SESSION_ID/KIMAKI_THREAD_ID/KIMAKI_THREAD_URL from bridge_install and bridge_sync_config, alongside the existing CLI-channel registration. - runtimes/opencode.sh registers session_id/run_id against OPENCODE_SESSION_ID/OPENCODE_RUN_ID from runtime_install. upgrade.sh refreshes it from the existing remove_legacy_opencode_wrapper_phase (the upgrade-time entry point that already sources runtimes/opencode.sh). Brand names live here intentionally — wp-coding-agents is the integration layer that knows about kimaki and opencode. DMC consumes the registered filter map generically (Extra-Chill/data-machine-code#416).
New 'Worktree Session Attribution' section after Outbound Dispatch: - Explains why the brand names (kimaki, opencode, KIMAKI_*, OPENCODE_*) live in wp-coding-agents and not in DMC (layer purity per RULES.md). - Documents the mu-plugin file and marker-delimited block layout. - Lists each registered runtime, subkey, env var, and what it identifies. - Calls out that DMC shipping kimaki/opencode-specific code is a layer violation to be filed against DMC, not patched here.
8 tasks
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.
Summary
Publishes wp-coding-agents' knowledge of kimaki + opencode env-var conventions as a Data Machine Code filter callback (
datamachine_code_worktree_runtime_signatures), so DMC can capture worktree origin-session metadata generically — without naming any specific coding-agent runtime in its own source.Sibling to Extra-Chill/data-machine-code#416 and direct execution of Extra-Chill/wp-coding-agents#131.
Chosen mechanism: B (new dedicated mu-plugin file)
The issue's
## Mechanism choicelisted three options; I picked B (new mu-plugin filewp-coding-agents-runtimes.php) rather than the issue's preferred C (wp option patch insert). Rationale:apply_filters( 'datamachine_code_worktree_runtime_signatures', [] )) with noget_optionfallback. Writing towp_optionswould land data DMC never reads. The issue body explicitly allows the C → B fallback when "DMC#416 ships filter-only" — that's the case here.lib/cli-channel.sh:21documents the prior rejection ofwp optionwrites for the parallel CLI-channel registry: "DB writes there race against multisite + Redis caching and have been a source of intermittent install failures historically." The same constraint applies to install-time signature writes.-channels.phpfilename. Worktree attribution is not a CLI channel; it's an env-var contract for a different filter consumer with different lifecycle. Folding them in would make the file name lie.lib/cli-channel.shpattern exactly — marker-delimited blocks, idempotent register/unregister, dry-run support, same scaffold style — so future maintainers find one shared mental model.The mu-plugins/ surface growth is a real-but-small paper cut. Consolidating the two wp-coding-agents mu-plugins into one shared file is a clean follow-up that does not need to ride this PR.
Per-runtime changes
bridges/kimaki.sh_kimaki_register_runtime_signaturebridge_install+bridge_sync_config(alongside the existing_kimaki_register_cli_channel){"session_id":"KIMAKI_SESSION_ID","thread_id":"KIMAKI_THREAD_ID","thread_url":"KIMAKI_THREAD_URL"}runtimes/opencode.sh_opencode_register_runtime_signatureruntime_install+upgrade.sh::remove_legacy_opencode_wrapper_phase(the existing upgrade-time entry point that already sourcesruntimes/opencode.sh){"session_id":"OPENCODE_SESSION_ID","run_id":"OPENCODE_RUN_ID"}Shared helper
New
lib/runtime-signature.shmirrorslib/cli-channel.sh:runtime_signature_register <runtime_id> <signature_json>— upsert a runtime's marker-delimited block in$SITE_PATH/wp-content/mu-plugins/wp-coding-agents-runtimes.php.runtime_signature_unregister <runtime_id>— remove a runtime's block, preserving siblings.runtime_signature_ensure_mu_plugin_file/runtime_signature_mu_plugin_path— scaffold + path helpers.Sourced from both
setup.shandupgrade.sh(added to the existingfor lib in …; do source …; doneloops).Layer purity
No DMC-specific naming leaks into the registration:
datamachine_code_worktree_runtime_signaturesis the filter name DMC#416 defines, not a DMC implementation detail. The signatures themselves are pure runtime-vendor data —kimakiandopencodeare the brand names this layer is supposed to own per the platform's layer-purity rule (codified inRULES.md). The mu-plugin scaffold's only DMC reference is a single comment citing the issue number for traceability; nothing in the executable PHP couples wp-coding-agents to DMC internals.Confirmation:
grep -riE 'datamachine_code|DMC' lib/runtime-signature.sh bridges/kimaki.sh runtimes/opencode.shreturns only the filter name + comment citations, no implementation coupling.Documentation
New "Worktree Session Attribution (Runtime Signatures)" section in
README.mdafter "Outbound Dispatch":Verification
bash -nparses cleanly on all modified scripts (lib/runtime-signature.sh,lib/cli-channel.sh,bridges/kimaki.sh,runtimes/opencode.sh,setup.sh,upgrade.sh).tests/runtime-signature.shcovers: scaffold creation,php -llint of the generated PHP, idempotent re-register, sibling registration, mutation-replaces-just-the-runtime's-block, unregister-preserves-siblings, and a php-execution end-to-end assertion thatapply_filters( 'datamachine_code_worktree_runtime_signatures', [] )returns the expected shape. All 14 assertions pass.tests/datamachine-kimaki-adapter.sh,tests/homeboy-components.sh,tests/kimaki-session-helper-smoke.sh,tests/opencode-local-plugin-path.sh,tests/opencode-wrapper-removal.sh,tests/path-helpers.sh,tests/post-upgrade-restore.sh,tests/repair-opencode-json.sh).SITE_PATHis unset or the file is missing.CHANGELOG.mdorVERSIONedits.Pre-existing snapshot drift (unrelated to this PR)
tests/bridge-render.shshowskimaki-launchdsnapshot drift on this branch — but also on baremain(verified withgit stash && bash tests/bridge-render.sh). It is a PATH-ordering artifact in the launchd plist<PATH>element, sensitive to the test environment's PATH at render time. Not caused by this PR; flagging only so the PR review does not block on it.Dependency note
This PR depends on Extra-Chill/data-machine-code#416 landing first. The filter
datamachine_code_worktree_runtime_signaturesmust exist in DMC before this registration is functional.The DMC PR is not yet open at the time of writing (verified via
gh pr list --repo Extra-Chill/data-machine-code --state all). Both PRs can open and be reviewed in parallel — this PR is mergeable independently because the registration is a harmlessadd_filtercallback on a host without a consuming filter. It is just not functional until a DMC release containing #416 deploys.The signature shapes registered here match #416's
## Proposed shapeexample payload verbatim:{ "kimaki": { "session_id": "KIMAKI_SESSION_ID", "thread_id": "KIMAKI_THREAD_ID", "thread_url": "KIMAKI_THREAD_URL" }, "opencode": { "session_id": "OPENCODE_SESSION_ID", "run_id": "OPENCODE_RUN_ID" } }Closes #131
cc <@532385681268408341>