diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 3130d92..23cb087 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -6,14 +6,14 @@ "email": "hi@okis.dev" }, "description": "Multi-model orchestration marketplace for Claude Code.", - "version": "0.0.85", + "version": "0.0.86", "plugins": [ { "name": "grok", "source": "./plugins/grok", "displayName": "Grok Companion", "description": "Local Grok CLI delegation: task, review, resumable history, background jobs, stats, and setup health checks.", - "version": "0.0.85", + "version": "0.0.86", "author": { "name": "Harry Yep" }, @@ -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.85", + "version": "0.0.86", "author": { "name": "Harry Yep" }, @@ -55,7 +55,7 @@ "source": "./plugins/cursor", "displayName": "Cursor Companion", "description": "Local Cursor Agent CLI delegation: multi family consults, Composer implementation in owned worktrees, review, resumable history, background jobs, and setup health checks.", - "version": "0.0.85", + "version": "0.0.86", "author": { "name": "Harry Yep" }, @@ -76,7 +76,7 @@ "source": "./plugins/devin", "displayName": "Devin Companion", "description": "Local Devin CLI delegation: multi family consults, SWE implementation in owned worktrees, review, resumable history, background jobs, and setup health checks.", - "version": "0.0.85", + "version": "0.0.86", "author": { "name": "Harry Yep" }, @@ -97,7 +97,7 @@ "source": "./plugins/agy", "displayName": "Antigravity Companion", "description": "Local Antigravity CLI delegation: Google family consults, large context reading, edit only implementation in owned worktrees, review, resumable history, background jobs, and setup health checks.", - "version": "0.0.85", + "version": "0.0.86", "author": { "name": "Harry Yep" }, @@ -118,7 +118,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.85", + "version": "0.0.86", "author": { "name": "Harry Yep" }, diff --git a/CHANGELOG.md b/CHANGELOG.md index 46fd08a..2e0c004 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # changelog +## 0.0.86 + +- a peer wrapper that hands its report back through `SubagentHandback` no longer gets a relay retry when SubagentStop runs before the handback reaches the wrapper transcript. the PostToolUse hook keeps the handback text on the worker record and SubagentStop uses it when the transcript has nothing yet, so the task completes with its job footer instead of staying `pending_async` with no peer job. the 0.0.85 smoke wave left the Antigravity probe uncollected this way on a host running auto mode (#113). +- a Devin run whose effort setting moves the model to another variant now records the variant Devin serves, so `muse-wonder` at `xhigh` reports `muse-wonder-1-0-xhigh` with no false `model_mismatch` (#114). +- the `/fusion:smoke` worker probe and the ultra skill name the `claude-fallback:` line the dispatch hook requires, so the smoke wave no longer burns a blocked dispatch before its worker probe (#115). +- the model table tests no longer read the host's real Devin model cache, which made two routing default tests fail once a Devin run had refreshed it. + ## 0.0.85 - quota is now a routing input. the codex companion answers `quota --json` from the `rate_limits` in its rollout log, every shared companion answers the same contract, and session start plus the fleet report name any pool that is over pace. while Codex is over pace, quick and volume packages go to the breadth engine's prepaid `burst` pool before a second Codex worktree, and no rule picks a metered pool unless the user named it. one host had burned 79 percent of its Codex weekly window in two days while its Devin plan sat almost unused (72 jobs and 2.6M tokens in three weeks against 3291 Codex jobs). diff --git a/plugins/agy/.claude-plugin/plugin.json b/plugins/agy/.claude-plugin/plugin.json index a8ec0ac..299828a 100644 --- a/plugins/agy/.claude-plugin/plugin.json +++ b/plugins/agy/.claude-plugin/plugin.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json", "name": "agy", "displayName": "Antigravity Companion", - "version": "0.0.85", + "version": "0.0.86", "engines": { "claude-code": ">=2.1.300" }, diff --git a/plugins/codex/.claude-plugin/plugin.json b/plugins/codex/.claude-plugin/plugin.json index 333247c..de21299 100644 --- a/plugins/codex/.claude-plugin/plugin.json +++ b/plugins/codex/.claude-plugin/plugin.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json", "name": "codex", "displayName": "Codex Companion", - "version": "0.0.85", + "version": "0.0.86", "engines": { "claude-code": ">=2.1.300" }, diff --git a/plugins/cursor/.claude-plugin/plugin.json b/plugins/cursor/.claude-plugin/plugin.json index 41788fd..ac3ebc8 100644 --- a/plugins/cursor/.claude-plugin/plugin.json +++ b/plugins/cursor/.claude-plugin/plugin.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json", "name": "cursor", "displayName": "Cursor Companion", - "version": "0.0.85", + "version": "0.0.86", "engines": { "claude-code": ">=2.1.300" }, diff --git a/plugins/devin/.claude-plugin/plugin.json b/plugins/devin/.claude-plugin/plugin.json index d671102..98f6c57 100644 --- a/plugins/devin/.claude-plugin/plugin.json +++ b/plugins/devin/.claude-plugin/plugin.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json", "name": "devin", "displayName": "Devin Companion", - "version": "0.0.85", + "version": "0.0.86", "engines": { "claude-code": ">=2.1.300" }, diff --git a/plugins/devin/scripts/devin-companion.mjs b/plugins/devin/scripts/devin-companion.mjs index ef23dba..a054240 100644 --- a/plugins/devin/scripts/devin-companion.mjs +++ b/plugins/devin/scripts/devin-companion.mjs @@ -53,15 +53,12 @@ async function runJob({ record, source, dataDir, brief, signal, timeoutMs, exitG const { homeDir } = ensurePrivateHome({ dataDir, realHome: realUserHome() }); buildJobConfig({ configDir: record.configDir, mode: record.mode, cwd: record.cwd, realHome: realUserHome(), homeDir, gitDirs: record.mode === "write" ? worktreeGitDirs(record.cwd) : {} }); const resolver = record.request?.model ? createSelectionResolver({ family: record.request.family, effort: record.request.effort }) : createSpeedResolver(); - let selectedDisplayName = null; let billingPool = record.billingPool; const selection = (context) => { const changes = resolver(context); - if (context.stage === "model" && changes[0]) { - selectedDisplayName = context.configOptions.find((item) => item.id === "model")?.options?.find((item) => item.value === changes[0].value)?.name ?? null; - if ([record.request.family.slug, ...record.request.family.aliases].some((name) => name.toLowerCase() === record.request.model.toLowerCase())) { - billingPool = billingPoolForModel({ families: [record.request.family] }, changes[0].value); - } + if (context.stage === "model" && changes[0] + && [record.request.family.slug, ...record.request.family.aliases].some((name) => name.toLowerCase() === record.request.model.toLowerCase())) { + billingPool = billingPoolForModel({ families: [record.request.family] }, changes[0].value); } return changes; }; @@ -69,7 +66,7 @@ async function runJob({ record, source, dataDir, brief, signal, timeoutMs, exitG env: buildDevinChildEnv({ homeDir, configDir: record.configDir, mode: record.mode }), brief, mode: record.mode, resumeSessionId: source?.sessionId, resolveSelection: selection, signal, timeoutMs, exitGraceMs, onSpawn: (child) => onProcess(child.pid), launchProcess }); - return { ...outcome, effortApplied: resolver?.effortApplied ?? false, selectedDisplayName, billingPool }; + return { ...outcome, effortApplied: resolver?.effortApplied ?? false, billingPool }; } function outcomeFields(outcome) { diff --git a/plugins/devin/scripts/lib/devin-exec.mjs b/plugins/devin/scripts/lib/devin-exec.mjs index 9ec6011..a72effa 100644 --- a/plugins/devin/scripts/lib/devin-exec.mjs +++ b/plugins/devin/scripts/lib/devin-exec.mjs @@ -172,6 +172,11 @@ async function initializeSession(run) { run.outcome.sessionId = sessionId; run.configOptions = session.configOptions; await configureSession(run); + const modelOption = run.configOptions?.find((option) => option?.id === "model"); + if (modelOption?.currentValue && Object.hasOwn(run.outcome.appliedOptions, "model")) { + run.outcome.appliedOptions.model = modelOption.currentValue; + run.outcome.selectedDisplayName = modelOption.options?.find((option) => option?.value === modelOption.currentValue)?.name ?? null; + } run.outcome.resolvedEffort = run.configOptions?.find((option) => option?.id === "thought_level")?.currentValue ?? null; await requestDevin(run, "session/prompt", { sessionId: run.outcome.sessionId, prompt: [{ type: "text", text: brief ?? "" }] }); } diff --git a/plugins/fusion/.claude-plugin/plugin.json b/plugins/fusion/.claude-plugin/plugin.json index 6c6a6e9..cf5e3e3 100644 --- a/plugins/fusion/.claude-plugin/plugin.json +++ b/plugins/fusion/.claude-plugin/plugin.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json", "name": "fusion", "displayName": "Fusion Orchestrator", - "version": "0.0.85", + "version": "0.0.86", "engines": { "claude-code": ">=2.1.300" }, diff --git a/plugins/fusion/scripts/lib/lifecycle/subagents.mjs b/plugins/fusion/scripts/lib/lifecycle/subagents.mjs index eea237f..118d6b9 100644 --- a/plugins/fusion/scripts/lib/lifecycle/subagents.mjs +++ b/plugins/fusion/scripts/lib/lifecycle/subagents.mjs @@ -62,7 +62,8 @@ function handleSubagentStop(input, env) { let refreshed = refreshRecord(record, input, env); const lastMessage = typeof input.last_assistant_message === "string" && input.last_assistant_message.trim() ? input.last_assistant_message : ""; const recoverHandback = !lastMessage || HANDBACK_PLACEHOLDER_PATTERN.test(lastMessage) || HANDBACK_ALREADY_DELIVERED_PATTERN.test(lastMessage) || !completedReport(refreshed, lastMessage) || refreshed.transcriptOffset !== record.transcriptOffset; - const report = recoverHandback ? finalReportFromTranscript(refreshed.transcriptPath) : null; + const transcriptReport = recoverHandback ? finalReportFromTranscript(refreshed.transcriptPath) : null; + const report = recoverHandback && !transcriptReport && refreshed.handbackReport ? { text: refreshed.handbackReport, handback: true } : transcriptReport; const handedBack = report?.handback === true; const stranded = recoverHandback && !handedBack && strandedHandbackFromTranscript(refreshed.transcriptPath); const message = handedBack || (stranded && report?.text) ? report.text : [lastMessage, report?.text].find((text) => typeof text === "string" && text.trim() && !HANDBACK_PLACEHOLDER_PATTERN.test(text)) ?? ""; diff --git a/plugins/fusion/scripts/lib/lifecycle/tools.mjs b/plugins/fusion/scripts/lib/lifecycle/tools.mjs index 01f4932..6c39745 100644 --- a/plugins/fusion/scripts/lib/lifecycle/tools.mjs +++ b/plugins/fusion/scripts/lib/lifecycle/tools.mjs @@ -11,7 +11,7 @@ import { reconcileTaskNotifications, taskNotificationTransition } from "./notifi import { denyTool, hookOutput, writeOutput } from "./output.mjs"; import { activeSessionRecords, clearContinuationRequest, findSessionWorkerRecord, isAttributedTranscriptPath, parentTranscriptByteSize, recordForAgent, refreshRecord, sendMessageResumed, updateLifecycleWorkerRecord } from "./records.mjs"; import { canonicalToolResponseUsage } from "./usage.mjs"; -import { CODEX_WRITE_SIZING_ADVISORY_BYTES, HANDBACK_PLACEHOLDER_PATTERN, READ_ONLY_TOOLS, SIZING_ADVISORY_BYTES, SUBAGENT_HANDBACK_TOOL } from "./constants.mjs"; +import { CODEX_WRITE_SIZING_ADVISORY_BYTES, FINAL_TEXT_MAX_BYTES, HANDBACK_PLACEHOLDER_PATTERN, READ_ONLY_TOOLS, SIZING_ADVISORY_BYTES, SUBAGENT_HANDBACK_TOOL } from "./constants.mjs"; function handlePreToolUse(input, env) { return withEngineHealthRecords(() => preToolUse(input, env)); @@ -424,6 +424,7 @@ function handlePostToolUse(input, env, failed = false) { return; } const now = new Date().toISOString(); + const handbackMessage = !failed && input.tool_name === SUBAGENT_HANDBACK_TOOL && typeof input.tool_input?.message === "string" && input.tool_input.message.trim() && !HANDBACK_PLACEHOLDER_PATTERN.test(input.tool_input.message) ? input.tool_input.message.slice(-FINAL_TEXT_MAX_BYTES) : null; let emitTurnWindDown = false; let emitTokenWindDown = false; let emitUncachedWindDown = false; @@ -447,6 +448,7 @@ function handlePostToolUse(input, env, failed = false) { inFlightSince: undefined, ...(!failed ? { lastLivenessAt: now } : {}), ...(progress ? { lastProgressAt: now, progressEvents: (refreshed.progressEvents ?? 0) + 1 } : {}), + ...(handbackMessage ? { handbackReport: handbackMessage } : {}), ...(emitTurnWindDown ? { windDownContextSentAt: now } : {}), ...(emitTokenWindDown ? { tokenWindDownSentAt: now } : {}), ...(emitUncachedWindDown ? { uncachedWindDownSentAt: now } : {}) diff --git a/plugins/fusion/scripts/lib/worker-state.mjs b/plugins/fusion/scripts/lib/worker-state.mjs index 385839f..55b1abd 100644 --- a/plugins/fusion/scripts/lib/worker-state.mjs +++ b/plugins/fusion/scripts/lib/worker-state.mjs @@ -388,6 +388,7 @@ export function reopenWorkerContinuation(record, at = new Date().toISOString(), collectedAt: null, collectionMethod: null, awaitingBackgroundCommand: undefined, + handbackReport: undefined, outputFile: null, transcriptPath: fusionWorker ? record.transcriptPath ?? null : null, transcriptOffset: fusionWorker ? record.transcriptOffset ?? 0 : 0, diff --git a/plugins/fusion/skills/smoke/SKILL.md b/plugins/fusion/skills/smoke/SKILL.md index 2b61f9c..ebb3b2c 100644 --- a/plugins/fusion/skills/smoke/SKILL.md +++ b/plugins/fusion/skills/smoke/SKILL.md @@ -14,7 +14,7 @@ Verify the update landed, then prove the dispatch chain end to end with five tin - a `grok:grok-rescue` task whose direct prompt passes `--effort low --cwd "" --` followed by a brief whose header line is `grok-role: burst | effort low | read only | acceptance: exact marker line` and whose body asks for exactly the line FUSION-SMOKE-GROK-OK; - an `agy:agy-rescue` task whose direct prompt passes `--cwd "" --` followed by a brief whose header line is `agy-role: independence | read only | acceptance: exact marker line` and whose body asks for exactly the line FUSION-SMOKE-AGY-OK; - a selected `:-rescue` task whose direct prompt passes `--cwd "" --` followed by a brief whose header line is `-role: diversity | acceptance: exact marker line` and whose body asks for exactly the line FUSION-SMOKE-CURSOR-OK or FUSION-SMOKE-DEVIN-OK, according to the selected breadth engine; - - a `fusion:trivial-worker` brief in the `fusion-brief: v1` envelope with `context-mode: isolated`, a goal of returning exactly the line FUSION-SMOKE-WORKER-OK, a scope of no file access, and an acceptance of the exact marker line. + - a `fusion:trivial-worker` brief in the `fusion-brief: v1` envelope with `context-mode: isolated` and `claude-fallback: claude-surface`, a goal of returning exactly the line FUSION-SMOKE-WORKER-OK, a scope of no file access, and an acceptance of the exact marker line. 3. Collect all five, then settle them in one `/fusion:stats` call carrying one `--record =` flag per probe: accepted only when the exact marker line came back, rejected otherwise. 4. Report one PASS or FAIL line per gate: version parity, codex dispatch and envelope, grok dispatch and sandbox handshake, agy dispatch and private Gemini directory, breadth dispatch and private home, worker dispatch and deliverable, settlement write. The codex, grok, agy, and breadth gates also require the lane default notice naming the filled model, and the breadth gate also requires the selected engine's isolation evidence: Cursor job records have `homeDir` under its `runs/` directory; Devin job records have `configDir` under its `runs/` directory and `devinVersion`. The agy gate requires `agyVersion`, `resolvedModel` from the Google family, `resolvedEffort`, `billingPool: subscription`, and private `gemini/agy/settings.json` and empty `gemini/config/mcp_config.json` under its data directory while keychain authentication uses the real `HOME`. A FAIL names the failing surface and advises holding real dispatches on that lane until repaired. diff --git a/plugins/fusion/skills/ultra/SKILL.md b/plugins/fusion/skills/ultra/SKILL.md index 10d1604..7c51bc2 100644 --- a/plugins/fusion/skills/ultra/SKILL.md +++ b/plugins/fusion/skills/ultra/SKILL.md @@ -19,7 +19,7 @@ Size gate first (cheap, in the main loop): Compose one self contained brief per facet: -- Each brief states its facet's goal, the shared context needed to work it alone, the relevant paths, and what a good result must cover. Claude worker facets use the `fusion-brief: v1` isolated envelope. Implementation facets carry a verification command. Consult and research facets instead carry explicit coverage or acceptance criteria, with collection review as their verification. A facet brief never depends on another facet's output. Pass every brief directly as the Agent prompt; do not write transport files. Companion adapters own any private staging required by their transports. +- Each brief states its facet's goal, the shared context needed to work it alone, the relevant paths, and what a good result must cover. Claude worker facets use the `fusion-brief: v1` isolated envelope with the required `claude-fallback: ` line. Implementation facets carry a verification command. Consult and research facets instead carry explicit coverage or acceptance criteria, with collection review as their verification. A facet brief never depends on another facet's output. Pass every brief directly as the Agent prompt; do not write transport files. Companion adapters own any private staging required by their transports. - Every Grok facet brief begins with a single routing header line containing exactly one `grok-role: ` field, choosing one of `burst`, `independence`, `live-web`, or `large-context` from the facet's actual purpose. Do not include a second Grok role anywhere in that brief. - Every Antigravity facet brief starts with `agy-role: independence`, `agy-role: large-context`, or `agy-role: burst`. Consult roles are read only; burst edits files only in an orchestrator owned worktree, with verification in the main session. - Every breadth engine facet brief begins with a single routing header line containing exactly one `-role: ` field: `diversity` for a read only consult that needs a model family no other lane carries, or `burst` for a bounded implementation facet in its own orchestrator owned worktree. diff --git a/plugins/grok/.claude-plugin/plugin.json b/plugins/grok/.claude-plugin/plugin.json index a3e4b3b..3232b36 100644 --- a/plugins/grok/.claude-plugin/plugin.json +++ b/plugins/grok/.claude-plugin/plugin.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json", "name": "grok", "displayName": "Grok Companion", - "version": "0.0.85", + "version": "0.0.86", "engines": { "claude-code": ">=2.1.300" }, diff --git a/tests/devin-companion.test.mjs b/tests/devin-companion.test.mjs index d9f9f85..e0e0761 100644 --- a/tests/devin-companion.test.mjs +++ b/tests/devin-companion.test.mjs @@ -43,7 +43,11 @@ function harness(t, scenario = "success", extraEnv = {}, variants = null) { { model_uid: "fusion-gpt-6-sol-sidekick-swe-2-high", label: "GPT-6 Sol + SWE-2 High", cost_tier: "free" }, { model_uid: "fusion-claude-opus-5-sidekick-swe-2-high", label: "Claude Opus 5 + SWE-2 High", cost_tier: "free" }, { model_uid: "kimi-k3-high", label: "Kimi K3" } - ] } + ] }, + ...(scenario === "model_switch" ? [{ family_label: "Muse Wonder", family_uid: "muse-wonder", slug: "muse-wonder", aliases: [], variants: [ + { model_uid: "muse-wonder-1-0-high", label: "Muse Wonder High", cost_tier: "free" }, + { model_uid: "muse-wonder-1-0-xhigh", label: "Muse Wonder XHigh", cost_tier: "free" } + ] }] : []) ] }; const review = { verdict: "request_changes", summary: "Needs a fix.", findings: [{ severity: "high", file: "sample.txt", line: 1, title: "Bad value", body: "Use the expected value." }] }; const code = `#!/usr/bin/env node @@ -51,7 +55,7 @@ import fs from "node:fs"; const args = process.argv.slice(2); if (args.join(" ") === "models list --format json") { process.stdout.write(${JSON.stringify(JSON.stringify(catalog) + "\n")}); process.exit(0); } if (args.join(" ") === "auth status") { process.stdout.write("Authenticated\\nPlan: Pro\\n"); process.exit(0); } -process.env.FAKE_DEVIN_SCENARIO = ${JSON.stringify(scenario === "review_ok" || scenario === "review_invalid" ? "success" : scenario)}; +process.env.FAKE_DEVIN_SCENARIO = ${JSON.stringify(["review_ok", "review_invalid", "model_switch"].includes(scenario) ? "success" : scenario)}; process.env.FAKE_DEVIN_LOG = ${JSON.stringify(log)}; ${extraEnv.FAKE_DEVIN_SESSION_ID ? `process.env.FAKE_DEVIN_SESSION_ID = ${JSON.stringify(extraEnv.FAKE_DEVIN_SESSION_ID)};` : ""} ${extraEnv.FAKE_DEVIN_REJECT_CONFIG ? `process.env.FAKE_DEVIN_REJECT_CONFIG = ${JSON.stringify(extraEnv.FAKE_DEVIN_REJECT_CONFIG)};` : ""} @@ -72,6 +76,33 @@ if (args[0] === "acp") { } return original(fd, data, ...rest); };` : ""} + ${scenario === "model_switch" ? `let liveModel = "muse-wonder-1-0-high"; + let liveOptions = null; + const museOptions = [{ value: "muse-wonder-1-0-high", name: "Muse Wonder High" }, { value: "muse-wonder-1-0-xhigh", name: "Muse Wonder XHigh" }]; + const realWriteSync = fs.writeSync; + fs.writeSync = (fd, data, ...rest) => { + if (fd === 1 && typeof data === "string") { + try { + const event = JSON.parse(data); + if (Array.isArray(event.result?.configOptions)) { + liveOptions = event.result.configOptions.map((option) => option.id === "model" ? { ...option, currentValue: liveModel, options: museOptions } : option); + data = JSON.stringify({ ...event, result: { ...event.result, configOptions: liveOptions } }) + "\\n"; + } else if (event.error && liveOptions) { + const invalid = /^Invalid value '([^']+)' for config option '([^']+)'$/.exec(String(event.error.data)); + if (invalid && (invalid[2] === "model" && invalid[1] === liveModel || invalid[2] === "thought_level" && invalid[1] === "xhigh")) { + if (invalid[2] === "model") { + liveOptions = [...liveOptions.filter((option) => option.id !== "thought_level"), { id: "thought_level", type: "select", currentValue: "high", options: ["minimal", "low", "medium", "high", "xhigh", "max"].map((value) => ({ value })) }]; + } else { + liveModel = "muse-wonder-1-0-xhigh"; + liveOptions = liveOptions.map((option) => option.id === "thought_level" ? { ...option, currentValue: "xhigh" } : option.id === "model" ? { ...option, currentValue: liveModel } : option); + } + data = JSON.stringify({ jsonrpc: "2.0", id: event.id, result: { configOptions: liveOptions } }) + "\\n"; + } + } + } catch {} + } + return realWriteSync(fd, data, ...rest); + };` : ""} } await import(${JSON.stringify(fileURLToPath(new URL("./fake-devin", import.meta.url)))}); `; @@ -161,6 +192,25 @@ test("a turn served by another model renders model_mismatch", (t) => { assert.match(result.stdout, /warning: model_mismatch\nstate: done\n$/); }); +test("an effort driven variant switch resolves the served model and only real drift warns", (t) => { + const h = harness(t, "model_switch", { FAKE_DEVIN_MODEL_LABEL: "Muse Wonder XHigh" }); + const result = h.run(["task", "--model", "muse-wonder", "--effort", "xhigh", "--", "inspect"]); + assertDone(result); + const [record] = h.jobs(); + assert.equal(record.resolvedModel, "muse-wonder-1-0-xhigh"); + assert.equal(record.resolvedEffort, "xhigh"); + assert.equal(record.effortApplied, true); + assert.equal(record.observedModel, "Muse Wonder XHigh"); + assert.equal(record.modelDrift, null); + assert.deepEqual(record.warnings, []); + const drifted = harness(t, "model_switch", { FAKE_DEVIN_MODEL_LABEL: "SWE-2 High" }); + assertDone(drifted.run(["task", "--model", "muse-wonder", "--effort", "xhigh", "--", "inspect"])); + const [drift] = drifted.jobs(); + assert.equal(drift.resolvedModel, "muse-wonder-1-0-xhigh"); + assert.deepEqual(drift.modelDrift, { requested: "muse-wonder-1-0-xhigh", observed: "SWE-2 High" }); + assert.deepEqual(drift.warnings, ["model_mismatch"]); +}); + for (const model of ["swe-2", "swe"]) { for (const [uid, pool, label] of [["swe-2-high", "free", "SWE-2 High"], ["kimi-k3-high", "credits", "Kimi K3"]]) { test(`${model} records the ${pool} pool of the offered variant`, (t) => { diff --git a/tests/fixtures/agy-handback/wrapper-transcript.jsonl b/tests/fixtures/agy-handback/wrapper-transcript.jsonl new file mode 100644 index 0000000..3c0d693 --- /dev/null +++ b/tests/fixtures/agy-handback/wrapper-transcript.jsonl @@ -0,0 +1,4 @@ +{"type":"assistant","message":{"content":[{"type":"tool_use","id":"toolu_01VWg4qtLCaGLgbybTLtadzG","name":"Bash","input":{"command":"node \"/home/user/.claude/plugins/cache/claude-code-fusion/agy/0.0.85/scripts/agy-companion.mjs\" await-output --file \"/private/tmp/claude-501/-Users-Shared-GitHub-claude-code-fusion/00000000-0000-4000-8000-000000000000/tasks/b773i15se.output\"","timeout":120000}}]}} +{"type":"user","message":{"content":[{"type":"tool_result","tool_use_id":"toolu_01VWg4qtLCaGLgbybTLtadzG","content":"FUSION-SMOKE-AGY-OK\n\nagy-session: 00000000-0000-4000-8000-000000000000\njob: 9ada8fbc97cf39480be3cb47c8df1808\nsandbox: /home/shared/GitHub/claude-code-fusion\ndelivery: foreground\nsemantic: unverified\nstate: done"}]}} +{"type":"assistant","message":{"content":[{"type":"tool_use","id":"toolu_0129jQYwo9mdqtVjoKJM6obc","name":"SubagentHandback","input":{"message":"```\nFUSION-SMOKE-AGY-OK\n\nagy-session: 00000000-0000-4000-8000-000000000000\njob: 9ada8fbc97cf39480be3cb47c8df1808\nsandbox: /home/shared/GitHub/claude-code-fusion\ndelivery: foreground\nsemantic: unverified\nstate: done\n```"}}]}} +{"type":"user","message":{"content":[{"type":"tool_result","tool_use_id":"toolu_0129jQYwo9mdqtVjoKJM6obc","content":[{"type":"text","text":"{\"success\":true,\"message\":\"Report delivered to your caller.\"}"}]}]}} diff --git a/tests/fusion-worker-lifecycle.test.mjs b/tests/fusion-worker-lifecycle.test.mjs index cba69c1..61515cb 100644 --- a/tests/fusion-worker-lifecycle.test.mjs +++ b/tests/fusion-worker-lifecycle.test.mjs @@ -3683,6 +3683,37 @@ test("a placeholder handed back by a peer rescue wrapper is not collected and th } }); +test("a peer handback recorded at PostToolUse settles at SubagentStop while the wrapper transcript lags", (t) => { + const fixture = fs.readFileSync(path.join(import.meta.dirname, "fixtures", "agy-handback", "wrapper-transcript.jsonl"), "utf8").trimEnd().split("\n"); + const report = JSON.parse(fixture[2]).message.content[0].input.message; + for (const agentType of ["agy:agy-rescue", "codex:codex-rescue", "grok:grok-rescue", "devin:devin-rescue", "cursor:cursor-rescue"]) { + const box = sandbox(t); + const agentId = `lag-${agentType.split(":")[0]}`; + const workerTranscript = handbackWorker(box, agentId, "transport", agentType); + fs.writeFileSync(workerTranscript, `${fixture.slice(0, 2).join("\n")}\n`); + const posted = run(box, { hook_event_name: "PostToolUse", session_id: "session-1", cwd: box.cwd, transcript_path: box.transcript, agent_transcript_path: workerTranscript, agent_id: agentId, agent_type: agentType, tool_name: "SubagentHandback", tool_input: { message: report }, tool_response: { success: true, message: "Report delivered to your caller." } }); + assert.strictEqual(posted.status, 0, posted.stderr); + + const stopped = handbackStop(box, agentId, workerTranscript, agentType); + assert.strictEqual(stopped.status, 0, stopped.stderr); + assert.strictEqual(stopped.stdout, "", agentType); + const settled = record(box); + assert.strictEqual(settled.retryCount, 0, agentType); + assert.strictEqual(settled.relayFooterMissing, undefined, agentType); + assert.strictEqual(settled.transportStatus, "ready_uncollected", agentType); + assert.strictEqual(settled.peerJobId, "9ada8fbc97cf39480be3cb47c8df1808", agentType); + + fs.writeFileSync(workerTranscript, `${fixture.join("\n")}\n`); + fs.appendFileSync(box.transcript, `${JSON.stringify({ type: "user", message: { content: `\n${agentId}\ncompleted\nAgent "probe" finished\nThis agent's report was delivered to you as a message from "${agentId}" (its SubagentHandback call).\n` } })}\n`); + assert.doesNotMatch(stop(box).stdout, /"decision":"block"/, agentType); + const collected = record(box); + assert.strictEqual(collected.transportStatus, "done", agentType); + assert.strictEqual(collected.collectionMethod, "task_notification", agentType); + assert.strictEqual(collected.peerJobId, "9ada8fbc97cf39480be3cb47c8df1808", agentType); + assert.strictEqual(fs.readFileSync(collected.outputFile, "utf8"), report); + } +}); + test("a completed notification collects a SubagentHandback report that SubagentStop never settled", (t) => { const box = sandbox(t); const workerTranscript = handbackWorker(box, "handback-notified", "coverage"); diff --git a/tests/model-table.test.mjs b/tests/model-table.test.mjs index d78a15e..7466b66 100644 --- a/tests/model-table.test.mjs +++ b/tests/model-table.test.mjs @@ -25,6 +25,10 @@ const ROUTING = { ] }; +const isolatedHome = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), "fusion-model-table-home-"))); +process.env.HOME = isolatedHome; +process.on("exit", () => fs.rmSync(isolatedHome, { recursive: true, force: true })); + function sandbox(t) { const dir = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), "fusion-model-table-test-"))); t.after(() => fs.rmSync(dir, { recursive: true, force: true }));