Final phase of #2584 (ADR-1239 Codex-binding amendment). execute-phase now negotiates dispatch.isolation and dispatches through the matching adapter, so a wave's independent plans run concurrently on six runtimes instead of one — with no runtime=== branch in the scheduler. harness-worktree passes the host's declared isolation flag (claude, cursor); orchestrator-worktree creates the worktree via the Phase-2 verb and spawns the executor into it with the resolved argv/cwd (codex, opencode, kimi, kimi-code); none stays sequential. Undeclared/unknown/unresolvable isolation degrades to none — never an unisolated parallel run. Fixes two shipped Phase-2 descriptors that per-host research found would fail at spawn: kimi lacked its headless flag (would launch the interactive TUI and hang the orchestrator), and kimi-code named a non-existent binary (Kimi Code installs as 'kimi'). Adds the worktree-path root confinement Phase 2 deferred here, and leading-dash guards on the resolver's prompt/cwd matching the existing git-argument guard. Closes #2627 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1187,6 +1187,96 @@ function dispatchOverlayCapabilityCommand({ command, args, cwd, raw, error, load
|
||||
}
|
||||
}
|
||||
|
||||
function routeDispatchIsolation({ args, cwd, raw, error }) {
|
||||
// #2584 Phase 3 (#2627): typed query exposing the negotiated
|
||||
// `dispatch.isolation` to the execute-phase wave scheduler, so the
|
||||
// scheduler branches on a declared capability instead of on a runtime id.
|
||||
// Direct sibling of `dispatch-should-flatten` above, which exists (#1708 /
|
||||
// #853) for exactly this reason — it replaced a `RUNTIME === 'codex'`
|
||||
// prose rule.
|
||||
//
|
||||
// Resolves the current runtime (GSD_RUNTIME > config.runtime > 'claude'),
|
||||
// reads registry.runtimes[id].runtime.hostIntegration.dispatch.isolation,
|
||||
// and validates it against the closed vocabulary.
|
||||
//
|
||||
// Fail-closed: unknown runtime, missing/undeclared/out-of-vocabulary value,
|
||||
// or any thrown error yields `none` — sequential execution, never an
|
||||
// unsafe parallel path (ADR-1239, "Fail-closed").
|
||||
//
|
||||
// Output:
|
||||
// --raw → prints exactly harness-worktree | orchestrator-worktree | none
|
||||
// --json → prints { runtime, isolation, exec }
|
||||
// default → same as --raw
|
||||
//
|
||||
// `exec` is the resolved orchestratorExec argv/cwd shape, present only for
|
||||
// `orchestrator-worktree`. It requires `--cwd-target` (the GSD-created
|
||||
// worktree path) and optionally `--prompt`; without a target there is
|
||||
// nothing to bind, so `exec` is null.
|
||||
const VALID_ISOLATION = new Set(['harness-worktree', 'orchestrator-worktree', 'none']);
|
||||
let isolation = 'none';
|
||||
let runtimeId = null;
|
||||
let exec = null;
|
||||
let harnessFlag = null;
|
||||
try {
|
||||
const { resolveRuntime } = require('./lib/runtime-slash.cjs');
|
||||
runtimeId = resolveRuntime(cwd);
|
||||
|
||||
const registry = require('./lib/capability-registry.cjs');
|
||||
const runtimeEntry = registry.runtimes != null
|
||||
? registry.runtimes[runtimeId]
|
||||
: null;
|
||||
const declared = runtimeEntry?.runtime?.hostIntegration?.dispatch?.isolation ?? null;
|
||||
if (typeof declared === 'string' && VALID_ISOLATION.has(declared)) {
|
||||
isolation = declared;
|
||||
}
|
||||
|
||||
if (isolation === 'harness-worktree') {
|
||||
const declaredFlag = runtimeEntry?.runtime?.harnessIsolationFlag ?? null;
|
||||
// A host claiming harness isolation with no declared flag gives the
|
||||
// scheduler nothing to pass — degrade to sequential rather than
|
||||
// dispatch unisolated executors believing they are isolated.
|
||||
if (typeof declaredFlag === 'string' && declaredFlag.length > 0) {
|
||||
harnessFlag = declaredFlag;
|
||||
} else {
|
||||
isolation = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
if (isolation === 'orchestrator-worktree') {
|
||||
const cwdIdx = args.indexOf('--cwd-target');
|
||||
const cwdTarget = cwdIdx !== -1 ? args[cwdIdx + 1] : '';
|
||||
if (cwdTarget) {
|
||||
const promptIdx = args.indexOf('--prompt');
|
||||
const promptArg = promptIdx !== -1 ? args[promptIdx + 1] : undefined;
|
||||
const hostIntegration = require('./lib/host-integration.cjs');
|
||||
const resolution = hostIntegration.resolveOrchestratorExec(
|
||||
runtimeEntry?.runtime?.orchestratorExec,
|
||||
cwdTarget,
|
||||
promptArg,
|
||||
);
|
||||
// A host declaring orchestrator-worktree whose exec descriptor does
|
||||
// not resolve cannot be spawned — degrade to sequential rather than
|
||||
// hand the scheduler an unusable command.
|
||||
if (resolution.ok) {
|
||||
exec = { command: resolution.command, args: resolution.args, cwd: resolution.cwd };
|
||||
} else {
|
||||
isolation = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
isolation = 'none';
|
||||
exec = null;
|
||||
harnessFlag = null;
|
||||
}
|
||||
|
||||
if (args.indexOf('--json') !== -1) {
|
||||
output({ runtime: runtimeId, isolation, exec, harnessFlag }, raw);
|
||||
} else {
|
||||
process.stdout.write(isolation);
|
||||
}
|
||||
}
|
||||
|
||||
function routeResolveDispatchType({ args, cwd, raw, error }) {
|
||||
// #2508 Phase 4 Option A: resolve a requested GSD subagent name to the
|
||||
// type an Agent() call should use on the current runtime. On
|
||||
@@ -2121,6 +2211,7 @@ const HOST_COMMAND_ROUTERS = {
|
||||
'quick-tasks-append': routeQuickTasksAppend,
|
||||
'normalize-test-command': routeNormalizeTestCommand,
|
||||
'dispatch-should-flatten': routeDispatchShouldFlatten,
|
||||
'dispatch-isolation': routeDispatchIsolation,
|
||||
'resolve-dispatch-type': routeResolveDispatchType,
|
||||
'agent-skills': routeAgentSkills,
|
||||
'skill-manifest': routeSkillManifest,
|
||||
|
||||
@@ -517,6 +517,7 @@ const capabilities = {
|
||||
"runtime": "node",
|
||||
"effortSurface": "argv"
|
||||
},
|
||||
"harnessIsolationFlag": "isolation=\"worktree\"",
|
||||
"hostBehaviors": {
|
||||
"attributionSource": "settings-json-commit",
|
||||
"authorsCanonicalWorkflow": true,
|
||||
@@ -955,7 +956,8 @@ const capabilities = {
|
||||
"args": [
|
||||
"exec"
|
||||
],
|
||||
"cwdFlag": "--cd"
|
||||
"cwdFlag": "--cd",
|
||||
"promptFlag": null
|
||||
},
|
||||
"hostBehaviors": {
|
||||
"reapplyCommand": "$gsd-update --reapply",
|
||||
@@ -1165,6 +1167,7 @@ const capabilities = {
|
||||
"runtime": "node",
|
||||
"effortSurface": "undocumented"
|
||||
},
|
||||
"harnessIsolationFlag": "--worktree",
|
||||
"hostBehaviors": {
|
||||
"reapplyCommand": "gsd-update --reapply (mention the skill name)",
|
||||
"frontmatterDialect": "cursor",
|
||||
@@ -1762,8 +1765,11 @@ const capabilities = {
|
||||
},
|
||||
"orchestratorExec": {
|
||||
"command": "kimi",
|
||||
"args": [],
|
||||
"cwdFlag": "--work-dir"
|
||||
"args": [
|
||||
"--print"
|
||||
],
|
||||
"cwdFlag": "--work-dir",
|
||||
"promptFlag": "--prompt"
|
||||
},
|
||||
"hostBehaviors": {
|
||||
"reapplyCommand": "/skill:gsd-update --reapply",
|
||||
@@ -1851,9 +1857,10 @@ const capabilities = {
|
||||
"runtime": "node"
|
||||
},
|
||||
"orchestratorExec": {
|
||||
"command": "kimi-code",
|
||||
"command": "kimi",
|
||||
"args": [],
|
||||
"cwdFlag": null
|
||||
"cwdFlag": null,
|
||||
"promptFlag": "--prompt"
|
||||
},
|
||||
"hostBehaviors": {
|
||||
"reapplyCommand": "/skill:gsd-update --reapply",
|
||||
@@ -2184,7 +2191,8 @@ const capabilities = {
|
||||
"args": [
|
||||
"run"
|
||||
],
|
||||
"cwdFlag": "--dir"
|
||||
"cwdFlag": "--dir",
|
||||
"promptFlag": null
|
||||
},
|
||||
"hostBehaviors": {
|
||||
"reapplyCommand": "/gsd-update --reapply",
|
||||
@@ -4414,6 +4422,7 @@ const runtimes = {
|
||||
"runtime": "node",
|
||||
"effortSurface": "argv"
|
||||
},
|
||||
"harnessIsolationFlag": "isolation=\"worktree\"",
|
||||
"hostBehaviors": {
|
||||
"attributionSource": "settings-json-commit",
|
||||
"authorsCanonicalWorkflow": true,
|
||||
@@ -4703,7 +4712,8 @@ const runtimes = {
|
||||
"args": [
|
||||
"exec"
|
||||
],
|
||||
"cwdFlag": "--cd"
|
||||
"cwdFlag": "--cd",
|
||||
"promptFlag": null
|
||||
},
|
||||
"hostBehaviors": {
|
||||
"reapplyCommand": "$gsd-update --reapply",
|
||||
@@ -4913,6 +4923,7 @@ const runtimes = {
|
||||
"runtime": "node",
|
||||
"effortSurface": "undocumented"
|
||||
},
|
||||
"harnessIsolationFlag": "--worktree",
|
||||
"hostBehaviors": {
|
||||
"reapplyCommand": "gsd-update --reapply (mention the skill name)",
|
||||
"frontmatterDialect": "cursor",
|
||||
@@ -5215,8 +5226,11 @@ const runtimes = {
|
||||
},
|
||||
"orchestratorExec": {
|
||||
"command": "kimi",
|
||||
"args": [],
|
||||
"cwdFlag": "--work-dir"
|
||||
"args": [
|
||||
"--print"
|
||||
],
|
||||
"cwdFlag": "--work-dir",
|
||||
"promptFlag": "--prompt"
|
||||
},
|
||||
"hostBehaviors": {
|
||||
"reapplyCommand": "/skill:gsd-update --reapply",
|
||||
@@ -5304,9 +5318,10 @@ const runtimes = {
|
||||
"runtime": "node"
|
||||
},
|
||||
"orchestratorExec": {
|
||||
"command": "kimi-code",
|
||||
"command": "kimi",
|
||||
"args": [],
|
||||
"cwdFlag": null
|
||||
"cwdFlag": null,
|
||||
"promptFlag": "--prompt"
|
||||
},
|
||||
"hostBehaviors": {
|
||||
"reapplyCommand": "/skill:gsd-update --reapply",
|
||||
@@ -5413,7 +5428,8 @@ const runtimes = {
|
||||
"args": [
|
||||
"run"
|
||||
],
|
||||
"cwdFlag": "--dir"
|
||||
"cwdFlag": "--dir",
|
||||
"promptFlag": null
|
||||
},
|
||||
"hostBehaviors": {
|
||||
"reapplyCommand": "/gsd-update --reapply",
|
||||
|
||||
@@ -1366,9 +1366,31 @@ function validateRuntimeBody(cap) {
|
||||
'runtime.orchestratorExec.cwdFlag must be a string or null (got: ' + JSON.stringify(oe.cwdFlag) + ')',
|
||||
);
|
||||
}
|
||||
|
||||
// promptFlag — optional; string or null (#2627, Phase 3). `null`/absent
|
||||
// means the host takes the executor prompt positionally (codex, opencode);
|
||||
// a string names the flag that carries it (kimi/kimi-code: --prompt).
|
||||
if (oe.promptFlag !== undefined && oe.promptFlag !== null && typeof oe.promptFlag !== 'string') {
|
||||
errors.push(
|
||||
'runtime.orchestratorExec.promptFlag must be a string or null (got: ' + JSON.stringify(oe.promptFlag) + ')',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// harnessIsolationFlag — ADR-1239 Codex-binding amendment (#2584), Phase 3
|
||||
// (#2627). OPTIONAL top-level field: the counterpart of orchestratorExec for
|
||||
// `dispatch.isolation: 'harness-worktree'` hosts, naming the host's OWN
|
||||
// isolation flag that GSD passes on dispatch (claude: isolation="worktree";
|
||||
// cursor: --worktree). Descriptor data so the scheduler passes a declared
|
||||
// token instead of branching on a runtime id (ADR-1239: "the per-host
|
||||
// dispatch invocation ... is descriptor data, not a scheduler branch").
|
||||
if (r.harnessIsolationFlag !== undefined && (typeof r.harnessIsolationFlag !== 'string' || r.harnessIsolationFlag.length === 0)) {
|
||||
errors.push(
|
||||
'runtime.harnessIsolationFlag must be a non-empty string (got: ' + JSON.stringify(r.harnessIsolationFlag) + ')',
|
||||
);
|
||||
}
|
||||
|
||||
// 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') {
|
||||
|
||||
Reference in New Issue
Block a user