Skip to content

Commit eb3239a

Browse files
committed
refactor(workspace): generalize worktree session-attribution schema
Replace the vendor-specific kimaki_*/opencode_* field names in the worktree origin_session envelope with a runtime-agnostic shape: { "primary_id": "<opaque or null>", "ids": { "<runtime-id>": { "<subkey>": "<opaque or null>", ... } } } DMC no longer enumerates runtime IDs or env-var names. The integration layer registers what to capture via the new filter 'datamachine_code_worktree_runtime_signatures', mirroring the pattern established by CliChannelTransport (v0.44.0). Changes: - inc/Abilities/WorkspaceAbilities.php: replace branded schema properties with primary_id + ids (free-form additionalProperties map). - inc/Workspace/WorktreeContextInjector.php: * Document the filter contract and envelope shape in the file header. * resolve_origin_session() iterates registered runtimes generically and drops non-URL values for *_url subkeys. * summarize_session() normalizes ids, supports an explicit primary_id on stored envelopes, and falls back to runtime-precedence scanning. * migrate_legacy_origin_session() transparently projects pre-#416 branded top-level keys (<runtime>_<subkey>) into the new envelope on read. The helper is isolated, structural (prefix/suffix split — no enumerated allowlist), and gated for future deletion via the documented 'datamachine_code_worktree_attribution_legacy_migrated_v2' option. - inc/Environment.php: drop the enumerated brand list from the file header docblock per RULES.md layer-purity prose guidance. Refs #416
1 parent 55946d8 commit eb3239a

3 files changed

Lines changed: 314 additions & 68 deletions

File tree

inc/Abilities/WorkspaceAbilities.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,14 +1544,17 @@ private function registerAbilities(): void {
15441544
),
15451545
'session' => array(
15461546
'type' => 'object',
1547-
'description' => 'Captured session identifiers (kimaki/opencode). Fields default to null when the corresponding env was not present at worktree creation.',
1547+
'description' => 'Captured session identifiers in a runtime-agnostic envelope. `primary_id` is the single renderer-friendly identifier downstream surfaces display. `ids` is a free-form map keyed by runtime ID (a string the integration layer chooses, e.g. via the `datamachine_code_worktree_runtime_signatures` filter); each entry is a string-map of subkeys (e.g. session_id, thread_id, thread_url, run_id) the integration chose to capture. DMC enumerates no runtime IDs and no subkeys.',
15481548
'properties' => array(
1549-
'primary_id' => array( 'type' => array( 'string', 'null' ) ),
1550-
'kimaki_session_id' => array( 'type' => array( 'string', 'null' ) ),
1551-
'kimaki_thread_id' => array( 'type' => array( 'string', 'null' ) ),
1552-
'kimaki_thread_url' => array( 'type' => array( 'string', 'null' ) ),
1553-
'opencode_session_id' => array( 'type' => array( 'string', 'null' ) ),
1554-
'opencode_run_id' => array( 'type' => array( 'string', 'null' ) ),
1549+
'primary_id' => array( 'type' => array( 'string', 'null' ) ),
1550+
'ids' => array(
1551+
'type' => 'object',
1552+
'description' => 'Map of runtime-id => { subkey => string|null }. Keys are opaque; DMC does not validate against a closed set.',
1553+
'additionalProperties' => array(
1554+
'type' => 'object',
1555+
'additionalProperties' => array( 'type' => array( 'string', 'null' ) ),
1556+
),
1557+
),
15551558
),
15561559
),
15571560
'task' => array(

inc/Environment.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
*
55
* Public signal that a co-located coding agent runtime exists on this host.
66
*
7-
* Data Machine Code is the bridge between WordPress and an external coding
8-
* agent runtime (Claude Code, OpenCode, kimaki, etc.). Its mere activation
9-
* is the declarative answer to "is there a coding agent here?" — there is
10-
* no separate marker file or constant to declare.
7+
* Data Machine Code is the bridge between WordPress and an external
8+
* coding-agent runtime. Its mere activation is the declarative answer to
9+
* "is there a coding agent here?" — there is no separate marker file or
10+
* constant to declare.
1111
*
1212
* Other plugins that ship disk-side artifacts for a coding agent (e.g.
1313
* Intelligence's SKILL.md sync, MEMORY.md disk writes, MCP bridges) should

0 commit comments

Comments
 (0)