Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"email": "hi@okis.dev"
},
"description": "Multi-model orchestration marketplace for Claude Code.",
"version": "0.0.35",
"version": "0.0.36",
"plugins": [
{
"name": "grok",
"source": "./plugins/grok",
"displayName": "Grok Companion",
"description": "Local Grok CLI delegation: task, review, resumable history, best-of-n tournaments, background jobs, stats, and setup health checks.",
"version": "0.0.35",
"version": "0.0.36",
"author": {
"name": "Harry Yep"
},
Expand All @@ -34,7 +34,7 @@
"source": "./plugins/codex",
"displayName": "Codex Companion",
"description": "First party local Codex CLI delegation for tasks, reviews, resumable threads, and durable background jobs.",
"version": "0.0.35",
"version": "0.0.36",
"author": {
"name": "Harry Yep"
},
Expand All @@ -55,7 +55,7 @@
"source": "./plugins/fusion",
"displayName": "Fusion Orchestrator",
"description": "Multi-model orchestration: tier agents, routing rules, blind panel, ultra fleet, model config, and drift doctor.",
"version": "0.0.35",
"version": "0.0.36",
"author": {
"name": "Harry Yep"
},
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# changelog

## 0.0.36

- peer transport wrappers get their own completion contract: 0.0.35's SubagentStop matcher expansion routed `codex:codex-rescue`, `grok:grok-rescue`, and `grok:grok-review-runner` through the claude worker deliverable gate, whose `verification` contract demands a final message ending in `delivery: complete` plus `verification: passed`; a verbatim companion relay ends with the engine envelope (`job:`, `state:`) instead, so every foreground peer delivery burned its single truncation recovery retry arguing with the gate, took a false `failureKind: delivery`, and terminalized as `incomplete`, which the notification reconcile guard skips, breaking notification driven auto collection and forcing a stop collection block on every peer package (observed two of two in the first 0.0.35 session against twenty nine of twenty nine clean on 0.0.34 the same day); dispatches now record a `transport` contract, `completedReport` accepts a relay whose footer parses through `peerJobIdFromCollectedResult` (the same parser settlement identity backfill uses, with `grok:grok-review-runner` always deliverable because its terminal output may be raw json validated by the review consumer), a matching transport retry message covers genuinely truncated relays, and the guards also match the agent type so records created before the fix settle correctly after a hot deploy

## 0.0.35

- codex adapts to cli 0.145.0: task runs forward `--output-schema <path>` end to end (rescue raw args, exec argv, structured output capture, and a `structured: parsed/invalid/unavailable` footer in the render), adversarial review gains a json schema verdict contract at `plugins/codex/schemas/adversarial-review-verdict.schema.json`, native `review` rejects `--output-schema` because tested versions silently ignore it there, and the 0.144.4 models cache schema drift workaround is deleted with the tested interval moving to 0.145.0 to 0.146.0
Expand Down
2 changes: 1 addition & 1 deletion plugins/codex/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json",
"name": "codex",
"displayName": "Codex Companion",
"version": "0.0.35",
"version": "0.0.36",
"description": "First party local Codex CLI delegation for tasks, reviews, resumable threads, and durable background jobs.",
"author": {
"name": "Harry Yep"
Expand Down
2 changes: 1 addition & 1 deletion plugins/fusion/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json",
"name": "fusion",
"displayName": "Fusion Orchestrator",
"version": "0.0.35",
"version": "0.0.36",
"description": "Multi-model orchestration: tier agents, routing rules, blind panel, ultra fleet, model config, and drift doctor.",
"author": {
"name": "Harry Yep"
Expand Down
9 changes: 9 additions & 0 deletions plugins/fusion/scripts/worker-lifecycle.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ function completionContract(agentType, prompt) {
if (canonical === "fusion:job-collector") {
return "collector";
}
if (PEER_JOB_FOOTER_AGENTS.has(agentType)) {
return "transport";
}
if (canonical === "fusion:deep-reasoner" || (!/^verification:\s*\S/im.test(prompt) && /^acceptance:\s*\S/im.test(prompt))) {
return "coverage";
}
Expand Down Expand Up @@ -392,6 +395,9 @@ function completedReport(record, message) {
if (record.completionContract === "collector" || canonicalWorkerAgentType(record.agentType) === "fusion:job-collector") {
return COLLECTOR_END_MARKER.test(normalized);
}
if (record.completionContract === "transport" || PEER_JOB_FOOTER_AGENTS.has(record.agentType)) {
return record.agentType === "grok:grok-review-runner" || peerJobIdFromCollectedResult(normalized) != null;
}
if (record.completionContract === "coverage" || canonicalWorkerAgentType(record.agentType) === "fusion:deep-reasoner") {
return COVERAGE_END_MARKER.test(normalized);
}
Expand Down Expand Up @@ -428,6 +434,9 @@ function retryInstruction(record) {
if (record.completionContract === "collector" || canonicalWorkerAgentType(record.agentType) === "fusion:job-collector") {
return "Return the exact collector command output, including its terminal `collector:` marker. This is the only retry.";
}
if (record.completionContract === "transport" || PEER_JOB_FOOTER_AGENTS.has(record.agentType)) {
return "The transport relay is incomplete. Return the companion output verbatim, including its `job:` and `state:` footer lines. This is the only retry.";
}
if (record.completionContract === "coverage" || canonicalWorkerAgentType(record.agentType) === "fusion:deep-reasoner") {
return "The task is not deliverable yet. Complete the requested coverage check and return the actual result. End with `delivery: complete` plus `coverage: complete`. This is the only retry.";
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/grok/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json",
"name": "grok",
"displayName": "Grok Companion",
"version": "0.0.35",
"version": "0.0.36",
"description": "Local Grok CLI delegation: task, review, resumable history, background jobs, stats, and setup health checks.",
"author": {
"name": "Harry Yep"
Expand Down
168 changes: 168 additions & 0 deletions tests/fusion-worker-lifecycle.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2218,6 +2218,174 @@ test("an acceptance brief uses the analysis completion contract", (t) => {
assert.strictEqual(record(box).transportStatus, "done");
});

test("peer transport dispatches record the transport completion contract", (t) => {
for (const agentType of ["codex:codex-rescue", "grok:grok-rescue"]) {
const box = sandbox(t);
const peerDispatch = dispatch(box, { subagent_type: agentType, prompt: "bounded peer brief" });
run(box, peerDispatch);
run(box, {
...peerDispatch,
hook_event_name: "PostToolUse",
tool_response: { isAsync: true, status: "async_launched", agentId: "transport-contract-" + agentType }
});
assert.strictEqual(record(box).completionContract, "transport");
}
});

test("a codex peer relay footer completes without a retry and backfills its job id", (t) => {
const box = sandbox(t);
const peerJobId = "a".repeat(32);
const peerDispatch = dispatch(box, { subagent_type: "codex:codex-rescue", prompt: "bounded peer brief" });
run(box, peerDispatch);
run(box, {
...peerDispatch,
hook_event_name: "PostToolUse",
tool_response: { isAsync: true, status: "async_launched", agentId: "codex-transport-relay" }
});

const stopped = run(box, {
hook_event_name: "SubagentStop",
session_id: "session-1",
cwd: box.cwd,
transcript_path: box.transcript,
agent_id: "codex-transport-relay",
agent_type: "codex:codex-rescue",
stop_hook_active: false,
last_assistant_message: ["```text", "companion result prose", "job: " + peerJobId, "delivery: foreground", "semantic: unverified", "state: done", "```", "relay commentary after the envelope"].join("\n")
});

assert.strictEqual(stopped.stdout, "");
const completed = record(box);
assert.strictEqual(completed.retryCount, 0);
assert.strictEqual(completed.failureKind, null);
assert.strictEqual(completed.peerJobId, peerJobId);
assert.strictEqual(completed.transportStatus, "ready_uncollected");
});

test("a grok peer relay footer completes without a retry and captures its job id", (t) => {
const box = sandbox(t);
const peerJobId = "b".repeat(32);
const peerDispatch = dispatch(box, { subagent_type: "grok:grok-rescue", prompt: "bounded peer brief" });
run(box, peerDispatch);
run(box, {
...peerDispatch,
hook_event_name: "PostToolUse",
tool_response: { isAsync: true, status: "async_launched", agentId: "grok-transport-relay" }
});

const stopped = run(box, {
hook_event_name: "SubagentStop",
session_id: "session-1",
cwd: box.cwd,
transcript_path: box.transcript,
agent_id: "grok-transport-relay",
agent_type: "grok:grok-rescue",
stop_hook_active: false,
last_assistant_message: ["companion result prose", "grok-session: grok-session-123", "job: " + peerJobId, "state: done"].join("\n")
});

assert.strictEqual(stopped.stdout, "");
const completed = record(box);
assert.strictEqual(completed.retryCount, 0);
assert.strictEqual(completed.failureKind, null);
assert.strictEqual(completed.peerJobId, peerJobId);
assert.strictEqual(completed.transportStatus, "ready_uncollected");
});

test("an incomplete peer relay receives one transport retry before terminal delivery failure", (t) => {
const box = sandbox(t);
const peerDispatch = dispatch(box, { subagent_type: "codex:codex-rescue", prompt: "bounded peer brief" });
run(box, peerDispatch);
run(box, {
...peerDispatch,
hook_event_name: "PostToolUse",
tool_response: { isAsync: true, status: "async_launched", agentId: "codex-incomplete-relay" }
});
const stopPayload = {
hook_event_name: "SubagentStop",
session_id: "session-1",
cwd: box.cwd,
transcript_path: box.transcript,
agent_id: "codex-incomplete-relay",
agent_type: "codex:codex-rescue",
stop_hook_active: false,
last_assistant_message: "companion result prose\nstate: done"
};

const retried = run(box, stopPayload);
assert.strictEqual(retried.stdout.trim().split("\n").length, 1);
const retryOutput = JSON.parse(retried.stdout);
assert.strictEqual(retryOutput.decision, "block");
assert.strictEqual(retryOutput.reason, "The transport relay is incomplete. Return the companion output verbatim, including its `job:` and `state:` footer lines. This is the only retry.");
assert.strictEqual(record(box).retryCount, 1);

const exhausted = run(box, stopPayload);
assert.strictEqual(exhausted.stdout, "");
const incomplete = record(box);
assert.strictEqual(incomplete.transportStatus, "incomplete");
assert.strictEqual(incomplete.failureKind, "delivery");
assert.strictEqual(incomplete.retryCount, 1);
});

test("a stale verification contract still accepts a codex peer relay footer", (t) => {
const box = sandbox(t);
const peerJobId = "c".repeat(32);
const peerDispatch = dispatch(box, { subagent_type: "codex:codex-rescue", prompt: "bounded peer brief" });
run(box, peerDispatch);
run(box, {
...peerDispatch,
hook_event_name: "PostToolUse",
tool_response: { isAsync: true, status: "async_launched", agentId: "codex-stale-contract" }
});
updateWorkerRecord(record(box).taskId, envFor(box), (current) => ({ ...current, completionContract: "verification" }));

const stopped = run(box, {
hook_event_name: "SubagentStop",
session_id: "session-1",
cwd: box.cwd,
transcript_path: box.transcript,
agent_id: "codex-stale-contract",
agent_type: "codex:codex-rescue",
stop_hook_active: false,
last_assistant_message: ["companion result prose", "job: " + peerJobId, "state: done"].join("\n")
});

assert.strictEqual(stopped.stdout, "");
const completed = record(box);
assert.strictEqual(completed.completionContract, "verification");
assert.strictEqual(completed.retryCount, 0);
assert.strictEqual(completed.peerJobId, peerJobId);
assert.strictEqual(completed.transportStatus, "ready_uncollected");
});

test("a grok review runner raw JSON result completes without a transport retry", (t) => {
const box = sandbox(t);
const worker = createWorkerRecord({
taskId: "fusion-" + "d".repeat(24),
sessionId: "session-1",
agentType: "grok:grok-review-runner",
workspaceRoot: box.cwd
}, envFor(box));
updateWorkerRecord(worker.taskId, envFor(box), (current) => ({ ...current, agentId: "grok-review-json", transportStatus: "running" }));

const stopped = run(box, {
hook_event_name: "SubagentStop",
session_id: "session-1",
cwd: box.cwd,
transcript_path: box.transcript,
agent_id: "grok-review-json",
agent_type: "grok:grok-review-runner",
stop_hook_active: false,
last_assistant_message: "{\"review\":\"accepted\",\"findings\":[]}"
});

assert.strictEqual(stopped.stdout, "");
const completed = record(box);
assert.strictEqual(completed.retryCount, 0);
assert.strictEqual(completed.failureKind, null);
assert.strictEqual(completed.transportStatus, "done");
});

test("job collector completion requires a terminal marker and fails closed on the legacy unstructured marker", (t) => {
const box = sandbox(t);
const peerJobId = "a".repeat(32);
Expand Down
Loading