* feat(#2584): Phase 2 — worktree create verb + orchestrator-exec resolver
Phase 2 of the negotiated executor-isolation feature (ADR-1239 Codex-binding amendment). Two building blocks for `dispatch.isolation: orchestrator-worktree` hosts, both unconsumed — no scheduler wires them yet (that is Phase 3), so no runtime behavior changes.
worktree create verb (planWorktreeCreate / executeWorktreeCreatePlan / cmdWorktreeCreate in worktree-safety.cts, routed via routeWorktree in gsd-tools.cjs): validates the wave base, creates a bounded branch+worktree, records it in the run manifest reusing record-agent 4-field entry shape, returns the executor working directory. Bounded git (10s timeout, degrade-not-throw); all manifest read/parse/validate/dedupe precedes the single git side effect (no unmanifested-orphan on a bad manifest); timeout-only best-effort partial rollback (a clean collision-exit never removes a live peer worktree); fail-closed on bad base, unsafe leading-dash / .. inputs, and malformed/mis-shaped manifest.
resolveOrchestratorExec (host-integration.cts): pure descriptor->argv resolver reading the new runtime.orchestratorExec descriptor field (codex/opencode/kimi/kimi-code), fail-closed on missing/invalid shape. Validator (capability-validator.cjs) + a parity guard asserting every orchestrator-worktree host declares a resolvable orchestratorExec.
Adding the create route edits the installed gsd-core/bin/gsd-tools.cjs, so the golden-install-parity fixtures for all 19 runtimes are regenerated (npm run gen:golden) — the only changed hash is gsd-tools.cjs. CONTEXT.md glossary updated; capability-registry regenerated. Behavioral tests (worktree-safety + host-integration) incl. a fast-check property test and the parity sweep.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore: rebuild tracked state-transition.cjs to match #2400 source
The tracked compiled artifact drifted from src/state-transition.cts: #2400 (commit 2bcfaa2e2) added the progress.total_plans frontmatter sync to source but the tracked bin/lib/state-transition.cjs was never rebuilt, so the fix was not shipping to consumers of the compiled artifact. The mandatory build:lib step for Phase 2 surfaced the drift; recompiling makes the already-merged, already-changelogged #2400 fix effective. Artifact-only resync (no source/test change); drift class tracked by #2591.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1505,8 +1505,10 @@ function dispatchOverlayCapabilityCommand({ command, args, cwd, raw, error, load
|
||||
require('./lib/worktree-base-ref.cjs').cmdWorktreeBaseCheck(cwd, args.slice(2));
|
||||
} else if (subcommand === 'set-baseref') {
|
||||
require('./lib/worktree-base-ref.cjs').cmdWorktreeSetBaseRef(cwd, args.slice(2));
|
||||
} else if (subcommand === 'create') {
|
||||
worktreeSafety.cmdWorktreeCreate(cwd, args.slice(2));
|
||||
} else {
|
||||
error('Unknown worktree subcommand. Available: cleanup-wave, record-agent, reap-orphans, base-check, set-baseref', ERROR_REASON.SDK_UNKNOWN_COMMAND);
|
||||
error('Unknown worktree subcommand. Available: cleanup-wave, record-agent, reap-orphans, base-check, set-baseref, create', ERROR_REASON.SDK_UNKNOWN_COMMAND);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -950,6 +950,13 @@ const capabilities = {
|
||||
"runtime": "node",
|
||||
"effortSurface": "argv"
|
||||
},
|
||||
"orchestratorExec": {
|
||||
"command": "codex",
|
||||
"args": [
|
||||
"exec"
|
||||
],
|
||||
"cwdFlag": "--cd"
|
||||
},
|
||||
"hostBehaviors": {
|
||||
"reapplyCommand": "$gsd-update --reapply",
|
||||
"tomlConfigInstall": true,
|
||||
@@ -1753,6 +1760,11 @@ const capabilities = {
|
||||
"runtime": "python",
|
||||
"effortSurface": "undocumented"
|
||||
},
|
||||
"orchestratorExec": {
|
||||
"command": "kimi",
|
||||
"args": [],
|
||||
"cwdFlag": "--work-dir"
|
||||
},
|
||||
"hostBehaviors": {
|
||||
"reapplyCommand": "/skill:gsd-update --reapply",
|
||||
"localInstallDeferred": true,
|
||||
@@ -1838,6 +1850,11 @@ const capabilities = {
|
||||
"transport": "mcp",
|
||||
"runtime": "node"
|
||||
},
|
||||
"orchestratorExec": {
|
||||
"command": "kimi-code",
|
||||
"args": [],
|
||||
"cwdFlag": null
|
||||
},
|
||||
"hostBehaviors": {
|
||||
"reapplyCommand": "/skill:gsd-update --reapply",
|
||||
"localInstallDeferred": true,
|
||||
@@ -2162,6 +2179,13 @@ const capabilities = {
|
||||
"runtime": "bun",
|
||||
"effortSurface": "argv"
|
||||
},
|
||||
"orchestratorExec": {
|
||||
"command": "opencode",
|
||||
"args": [
|
||||
"run"
|
||||
],
|
||||
"cwdFlag": "--dir"
|
||||
},
|
||||
"hostBehaviors": {
|
||||
"reapplyCommand": "/gsd-update --reapply",
|
||||
"attributionConfigResolver": "opencode",
|
||||
@@ -4674,6 +4698,13 @@ const runtimes = {
|
||||
"runtime": "node",
|
||||
"effortSurface": "argv"
|
||||
},
|
||||
"orchestratorExec": {
|
||||
"command": "codex",
|
||||
"args": [
|
||||
"exec"
|
||||
],
|
||||
"cwdFlag": "--cd"
|
||||
},
|
||||
"hostBehaviors": {
|
||||
"reapplyCommand": "$gsd-update --reapply",
|
||||
"tomlConfigInstall": true,
|
||||
@@ -5182,6 +5213,11 @@ const runtimes = {
|
||||
"runtime": "python",
|
||||
"effortSurface": "undocumented"
|
||||
},
|
||||
"orchestratorExec": {
|
||||
"command": "kimi",
|
||||
"args": [],
|
||||
"cwdFlag": "--work-dir"
|
||||
},
|
||||
"hostBehaviors": {
|
||||
"reapplyCommand": "/skill:gsd-update --reapply",
|
||||
"localInstallDeferred": true,
|
||||
@@ -5267,6 +5303,11 @@ const runtimes = {
|
||||
"transport": "mcp",
|
||||
"runtime": "node"
|
||||
},
|
||||
"orchestratorExec": {
|
||||
"command": "kimi-code",
|
||||
"args": [],
|
||||
"cwdFlag": null
|
||||
},
|
||||
"hostBehaviors": {
|
||||
"reapplyCommand": "/skill:gsd-update --reapply",
|
||||
"localInstallDeferred": true,
|
||||
@@ -5367,6 +5408,13 @@ const runtimes = {
|
||||
"runtime": "bun",
|
||||
"effortSurface": "argv"
|
||||
},
|
||||
"orchestratorExec": {
|
||||
"command": "opencode",
|
||||
"args": [
|
||||
"run"
|
||||
],
|
||||
"cwdFlag": "--dir"
|
||||
},
|
||||
"hostBehaviors": {
|
||||
"reapplyCommand": "/gsd-update --reapply",
|
||||
"attributionConfigResolver": "opencode",
|
||||
|
||||
@@ -1316,6 +1316,59 @@ function validateRuntimeBody(cap) {
|
||||
}
|
||||
}
|
||||
|
||||
// orchestratorExec — ADR-1239 Codex-binding amendment (#2584), Phase 2.
|
||||
// OPTIONAL top-level field (sibling of hostBehaviors), like hookEvents:
|
||||
// only hosts whose hostIntegration.dispatch.isolation is
|
||||
// 'orchestrator-worktree' need it, so it is not required on every runtime
|
||||
// descriptor. When present it must be a well-formed exec descriptor for
|
||||
// src/host-integration.cts's resolveOrchestratorExec.
|
||||
if (r.orchestratorExec !== undefined) {
|
||||
if (typeof r.orchestratorExec !== 'object' || r.orchestratorExec === null || Array.isArray(r.orchestratorExec)) {
|
||||
errors.push(
|
||||
'runtime.orchestratorExec must be an object (got: ' +
|
||||
(r.orchestratorExec === null ? 'null' : (Array.isArray(r.orchestratorExec) ? 'array' : typeof r.orchestratorExec)) + ')',
|
||||
);
|
||||
} else {
|
||||
const oe = r.orchestratorExec;
|
||||
|
||||
// S2b: reserved-OWN-KEY guard (CodeQL barrier — inline literal comparisons)
|
||||
if (Object.prototype.hasOwnProperty.call(oe, '__proto__')) {
|
||||
errors.push('runtime.orchestratorExec must not contain reserved key "__proto__"');
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(oe, 'constructor')) {
|
||||
errors.push('runtime.orchestratorExec must not contain reserved key "constructor"');
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(oe, 'prototype')) {
|
||||
errors.push('runtime.orchestratorExec must not contain reserved key "prototype"');
|
||||
}
|
||||
|
||||
// command — required non-empty string; reserved-name guard (CodeQL barrier)
|
||||
if (oe.command === '__proto__' || oe.command === 'constructor' || oe.command === 'prototype') {
|
||||
errors.push('runtime.orchestratorExec.command "' + oe.command + '" is a reserved name');
|
||||
} else if (typeof oe.command !== 'string' || oe.command.length === 0) {
|
||||
errors.push(
|
||||
'runtime.orchestratorExec.command must be a non-empty string (got: ' + JSON.stringify(oe.command) + ')',
|
||||
);
|
||||
}
|
||||
|
||||
// args — optional array of strings
|
||||
if (oe.args !== undefined) {
|
||||
if (!Array.isArray(oe.args) || !oe.args.every((a) => typeof a === 'string')) {
|
||||
errors.push(
|
||||
'runtime.orchestratorExec.args must be an array of strings (got: ' + JSON.stringify(oe.args) + ')',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// cwdFlag — optional; string or null
|
||||
if (oe.cwdFlag !== undefined && oe.cwdFlag !== null && typeof oe.cwdFlag !== 'string') {
|
||||
errors.push(
|
||||
'runtime.orchestratorExec.cwdFlag must be a string or null (got: ' + JSON.stringify(oe.cwdFlag) + ')',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GATE A: installSurface ↔ hooksSurface consistency (DEFECT.GENERATIVE-FIX)
|
||||
// Only check if both fields are valid strings (individual field validators above report type errors).
|
||||
if (typeof r.installSurface === 'string' && typeof r.hooksSurface === 'string') {
|
||||
|
||||
@@ -831,6 +831,18 @@ function plannedPhaseCore(content, intent, deps) {
|
||||
}, statusDefaults, lastActivityDefaults);
|
||||
if (body !== beforePos)
|
||||
updated.push('Current Position');
|
||||
// #2400 Bug B: sync progress.total_plans to the frontmatter when a plan count
|
||||
// is given. This writes the explicitly-provided count — it is NOT a re-derivation
|
||||
// from disk (#500 RC1 is about deriving from a half-planned snapshot, not about
|
||||
// refusing to write an explicitly-passed argument).
|
||||
if (intent.planCount !== null && intent.planCount !== undefined && hasFrontmatter) {
|
||||
const fmProgress = existingFm['progress'] || {};
|
||||
if (fmProgress['total_plans'] !== intent.planCount) {
|
||||
fmProgress['total_plans'] = intent.planCount;
|
||||
existingFm['progress'] = fmProgress;
|
||||
updated.push('progress.total_plans');
|
||||
}
|
||||
}
|
||||
return { content: reassemble(body), updated };
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user