From a64f8241a219d4470508c94382e5f5fd8fad56c2 Mon Sep 17 00:00:00 2001 From: w4ffl35 <25737761+w4ffl35@users.noreply.github.com> Date: Sat, 5 Dec 2026 14:59:09 -0700 Subject: [PATCH 1/4] Add --quiet-skills flag to silence known-unusable skill warnings (#170) terminalMain printed every skill discovery problem on every launch with no way to acknowledge a known-unusable skill. --quiet-skills (alias --no-skill-warnings) suppresses the per-launch diagnostics; default behavior unchanged. Snapshot-error path attribution to the skill directory (not SKILL.md) landed earlier in fb770297. --- src/terminal/__tests__/chat.test.ts | 11 +++++- src/terminal/__tests__/runtime.test.ts | 49 ++++++++++++++++++++++++++ src/terminal/chat.ts | 30 +++++++++++++--- src/terminal/cli.ts | 7 +++- 4 files changed, 91 insertions(+), 6 deletions(-) diff --git a/src/terminal/__tests__/chat.test.ts b/src/terminal/__tests__/chat.test.ts index caadc64e..5fc7cade 100644 --- a/src/terminal/__tests__/chat.test.ts +++ b/src/terminal/__tests__/chat.test.ts @@ -87,6 +87,14 @@ async function testArgsAndSlashParsing(): Promise { assert.throws(() => parseSlashCommand('/import claude "unfinished'), /Unclosed quote/) } +async function testQuietSkillsFlagParsing(): Promise { + assert.equal(parseChatArgs([], workspaceRoot).quietSkills, undefined) + const quiet = parseChatArgs(["--quiet-skills"], workspaceRoot) + assert.equal(quiet.quietSkills, true) + const silent = parseChatArgs(["--no-skill-warnings"], workspaceRoot) + assert.equal(silent.quietSkills, true) +} + async function testTurnsPersistAndResume(): Promise { const store = new MemoryStore() const pipes = streams("first turn\nsecond turn\n") @@ -609,6 +617,7 @@ async function testSecondInterruptForceQuitsHungTurn(): Promise { async function main(): Promise { await testArgsAndSlashParsing() + await testQuietSkillsFlagParsing() await testTurnsPersistAndResume() await testResumeUsesSelectedWorktree() await testModeValidation() @@ -622,7 +631,7 @@ async function main(): Promise { await testDecisionBlockedPromptsInline() await testReadlineCtrlCInPseudoTerminal() await testSecondInterruptForceQuitsHungTurn() - console.log("All 14 terminal chat tests passed") + console.log("All 15 terminal chat tests passed") } main().catch((error) => { console.error(error); process.exitCode = 1 }) diff --git a/src/terminal/__tests__/runtime.test.ts b/src/terminal/__tests__/runtime.test.ts index c9d22066..c7229b80 100644 --- a/src/terminal/__tests__/runtime.test.ts +++ b/src/terminal/__tests__/runtime.test.ts @@ -66,6 +66,55 @@ try { assert.equal(await stopped, 1) assert.equal(process.listenerCount("SIGTERM"), before) console.log("PASS supervisor stop aborts active inference and removes terminal process handler"); count++ + const noisy: SkillRegistry = { + skills: [], + problems: [{ + path: "/skills/symlinked/SKILL.md", + message: "skill directories cannot be symlinks", + }], + get: () => undefined, + activate: () => undefined, + readReference: () => { + throw new Error("no skills") + }, + } + const loud = new PassThrough() + let loudText = "" + loud.on("data", (chunk: Buffer) => { loudText += chunk.toString() }) + assert.equal(await terminalMain( + ["--workspace", workspace], + { + ...common, + skillRegistry: noisy, + output: loud, + errorOutput: loud, + input: Readable.from(["/exit\n"]), + }, + ), 0) + assert.match(loudText, /skill directories cannot be symlinks/) + const hushed = new PassThrough() + let hushedText = "" + hushed.on("data", (chunk: Buffer) => { hushedText += chunk.toString() }) + assert.equal(await terminalMain( + ["--workspace", workspace, "--quiet-skills"], + { + ...common, + skillRegistry: noisy, + output: hushed, + errorOutput: hushed, + input: Readable.from(["/exit\n"]), + }, + ), 0) + assert.doesNotMatch(hushedText, /skill directories cannot be symlinks/) + console.log("PASS --quiet-skills silences warnings"); count++ + for (const command of ["chat", "skills", "sessions"]) { + const help = execFileSync( + process.execPath, + ["--import", "tsx", "src/cli.ts", command, "--help"], + { cwd: process.cwd(), env: process.env, encoding: "utf8" }, + ) + assert.ok(help.includes(`headlesscode ${command}`)) + } for (const command of ["chat", "skills", "sessions"]) { const help = execFileSync(process.execPath, ["--import", "tsx", "src/cli.ts", command, "--help"], { cwd: process.cwd(), env: process.env, encoding: "utf8" }) assert.ok(help.includes(`headlesscode ${command}`)) diff --git a/src/terminal/chat.ts b/src/terminal/chat.ts index 8ca91be4..39e0d112 100644 --- a/src/terminal/chat.ts +++ b/src/terminal/chat.ts @@ -51,7 +51,14 @@ export interface ChatCliDependencies { forceExit: (code: number) => never } -export interface ChatCliOptions { workspaceRoot: string; resumeId?: string; model?: string; mode?: string; help: boolean } +export interface ChatCliOptions { + workspaceRoot: string + resumeId?: string + model?: string + mode?: string + quietSkills?: boolean + help: boolean +} const DEFAULT_MODE = "code" const MAX_SESSION_MESSAGES = 50_000 @@ -146,11 +153,17 @@ export function parseChatArgs(argv: string[], cwd = process.cwd()): ChatCliOptio let resumeId: string | undefined let model: string | undefined let mode: string | undefined + let quietSkills = false let help = false for (let index = 0; index < argv.length; index++) { const arg = argv[index] if (arg === "--help" || arg === "-h") help = true - else if (["--workspace", "--resume", "--model", "--mode"].includes(arg)) { + else if ( + arg === "--quiet-skills" + || arg === "--no-skill-warnings" + ) { + quietSkills = true + } else if (["--workspace", "--resume", "--model", "--mode"].includes(arg)) { const value = argv[++index] if (!value || value.startsWith("--")) throw new Error(`${arg} requires a value`) if (arg === "--workspace") workspaceRoot = path.resolve(cwd, value) @@ -159,7 +172,14 @@ export function parseChatArgs(argv: string[], cwd = process.cwd()): ChatCliOptio else mode = value } else throw new Error(`Unknown chat option: ${arg}`) } - return { workspaceRoot, ...(resumeId ? { resumeId } : {}), ...(model ? { model } : {}), ...(mode ? { mode } : {}), help } + return { + workspaceRoot, + ...(resumeId ? { resumeId } : {}), + ...(model ? { model } : {}), + ...(mode ? { mode } : {}), + ...(quietSkills ? { quietSkills } : {}), + help, + } } export async function chatMain(argv: string[], deps: ChatCliDependencies): Promise { @@ -555,7 +575,9 @@ export function parseSlashCommand(line: string): { name: string; args: string[] } export function chatUsage(): string { - return "Usage: headlesscode chat [--workspace ] [--resume ] [--model ] [--mode ]" + return "Usage: headlesscode chat [--workspace ]" + + " [--resume ] [--model ] [--mode ]" + + " [--quiet-skills]" } export function chatHelp(): string { diff --git a/src/terminal/cli.ts b/src/terminal/cli.ts index e29e291d..6522ddec 100644 --- a/src/terminal/cli.ts +++ b/src/terminal/cli.ts @@ -58,7 +58,12 @@ export async function terminalMain(argv: string[], runtime: TerminalRuntimeOptio includeProjectRoot: enabledRoots.includes(path.resolve(options.workspaceRoot, ".agents", "skills")), }) } - for (const problem of registry.problems) errorOutput.write(`skills: ${sanitizeTerminalText(`${problem.path}: ${problem.message}`)}\n`) + for (const problem of registry.problems) { + if (options.quietSkills) continue + const line = + `skills: ${sanitizeTerminalText(`${problem.path}: ${problem.message}`)}\n` + errorOutput.write(line) + } const frozenRegistry = registry const runTurn = createChatTurnRunner({ llmClient: runtime.llmClient, skillRegistry: frozenRegistry, extraArgs: runtime.extraArgs }) return await chatMain(argv, { From 6c079b6c70f61395f44f0bf8347d54cd7b5c15d3 Mon Sep 17 00:00:00 2001 From: w4ffl35 <25737761+w4ffl35@users.noreply.github.com> Date: Sat, 5 Dec 2026 14:59:09 -0700 Subject: [PATCH 2/4] Burn down check-standards for execution-provider.test.ts (#183) Extract the oversized provider-mapping test into per-case helpers so the 26-line function complies with the 20-line limit; wrapped verbatim with no behavior change. Regenerated both baselines with the checkers' --write-baseline mode. --- scripts/architecture-baseline.json | 165 +- scripts/code-standards-baseline.json | 4580 +++++++++++++++-- .../__tests__/execution-provider.test.ts | 97 +- 3 files changed, 4310 insertions(+), 532 deletions(-) diff --git a/scripts/architecture-baseline.json b/scripts/architecture-baseline.json index 0d53602c..78687ee2 100644 --- a/scripts/architecture-baseline.json +++ b/scripts/architecture-baseline.json @@ -16,8 +16,10 @@ "clone 05d4573a34dd src/codesearch/embedder.ts,src/memory/embed.ts", "clone 05f9940a16d5 src/decision-proxy/cli.ts,src/orchestrator/cli.ts,src/orchestrator/resume.ts", "clone 0654c838248c src/llm/muse.ts,src/llm/openrouter.ts", + "clone 068b26dbf27a src/orchestrator/__tests__/execution-provider.test.ts,src/watcher/__tests__/webhook.test.ts", "clone 06b27f6a49e2 src/orchestrator/__tests__/analyze-cli.test.ts", "clone 06c2ac64ec1e src/engine/__tests__/condense.test.ts", + "clone 06ebd0315b35 src/orchestrator/cli.ts,src/watcher/cli.ts", "clone 070bf0935a24 src/engine/loop.ts", "clone 07265d684c1d src/orchestrator/task-files.ts", "clone 079e0ea3d837 src/engine/__tests__/loop.test.ts", @@ -28,6 +30,7 @@ "clone 08693511f4f2 src/orchestrator/task-files.ts", "clone 08a6c01fdb2d src/orchestrator/__tests__/analyze-cli.test.ts", "clone 093e5318134f src/codesearch/embedder.ts,src/memory/embed.ts", + "clone 095592bc0528 src/engine/loop.ts", "clone 097bb86875ad src/llm/openrouter.ts", "clone 097dbebdafaf src/github/__tests__/installations.test.ts,src/github/__tests__/pr.test.ts", "clone 0a8cd67b23bf src/cloud/__tests__/openshell-provider.test.ts", @@ -48,6 +51,7 @@ "clone 0e6b600196f9 src/dashboard/trend-cli.ts,src/orchestrator/cleanup.ts", "clone 0e7b8affcb4e src/control/emergency-controller.ts", "clone 0ebf70f447c1 src/orchestrator/__tests__/cli.test.ts", + "clone 0ed76e539e89 src/orchestrator/cli.ts,src/watcher/cli.ts", "clone 0ee13df4a9d1 src/orchestrator/__tests__/cli.test.ts,src/orchestrator/__tests__/resume.test.ts", "clone 0f15b072ce99 src/llm/preflight.ts", "clone 0f285c2dd858 src/engine/loop.ts", @@ -90,7 +94,6 @@ "clone 1ab283ab6f33 src/rsi/controller.ts", "clone 1ad74508c766 src/orchestrator/task-files.ts", "clone 1b0114e0a60e src/orchestrator/__tests__/cli.test.ts", - "clone 1b2b48c0199b src/orchestrator/cli.ts,src/watcher/cli.ts", "clone 1b404c3cbfae src/llm/__tests__/muse.test.ts,src/llm/__tests__/openrouter.test.ts", "clone 1b48355447df src/llm/__tests__/muse.test.ts,src/llm/__tests__/openrouter.test.ts", "clone 1bac564acc3f src/engine/loop.ts", @@ -102,6 +105,7 @@ "clone 1d93450ce46b src/dashboard/server.ts", "clone 1e9f5c07bbb1 src/dashboard/__tests__/cost-history-routes.test.ts,src/orchestrator/__tests__/cost-history-cli.test.ts", "clone 1ea2ad860baf src/codesearch/files.ts,src/engine/stacks.ts", + "clone 1ea674a9a736 src/budget/__tests__/concurrency.test.ts,src/watcher/__tests__/webhook.test.ts", "clone 1ec65e3ed9d8 src/orchestrator/task-files.ts", "clone 1ed752dc9308 src/engine/local-explore.ts,src/llm/ollama.ts", "clone 1ee2355c21d5 src/llm/openrouter.ts", @@ -121,6 +125,7 @@ "clone 231bc945ff50 src/control/emergency-controller.ts", "clone 232f1b0a8918 src/engine/__tests__/loop.test.ts", "clone 2359b270d07f src/orchestrator/cli.ts", + "clone 23a462f7391e src/dashboard/server.ts", "clone 243c8df9399b src/engine/__tests__/switch-mode.test.ts", "clone 244ddb70203e src/dashboard/server.ts", "clone 245b47905e93 src/tools/__tests__/edit_file.test.ts,src/tools/__tests__/search_replace.test.ts", @@ -143,7 +148,9 @@ "clone 2a4b419aec2b src/orchestrator/cli.ts,src/watcher/cli.ts", "clone 2a9b5951d312 src/orchestrator/cli.ts", "clone 2abafe013158 src/rsi/__tests__/postgres-queue.test.ts", + "clone 2ac41b306f94 src/dashboard/__tests__/session-launch.test.ts", "clone 2ad2527b58e1 src/orchestrator/task-files.ts", + "clone 2b01ec694b8d src/dashboard/server.ts", "clone 2b45bb8b2f1b src/llm/openrouter.ts", "clone 2b6012a60134 src/orchestrator/__tests__/spawn-model.test.ts,src/orchestrator/__tests__/spawn-state-reset.test.ts", "clone 2bc69a3f560c src/llm/muse.ts,src/llm/openrouter.ts", @@ -151,6 +158,7 @@ "clone 2c83ed0d1788 src/engine/__tests__/condense-async.test.ts,src/engine/__tests__/condense.test.ts,src/engine/__tests__/events.test.ts", "clone 2c9f8493e38e src/llm/muse.ts,src/llm/openrouter.ts", "clone 2cb1493c835d src/orchestrator/__tests__/main-tree-tripwire.test.ts,src/orchestrator/__tests__/review-gates.test.ts", + "clone 2d8d82390328 src/dashboard/server.ts", "clone 2e4f5c004508 src/init/__tests__/cli.test.ts,src/orchestrator/__tests__/cost-history-cli.test.ts", "clone 2ef48d0cbf0f src/engine/__tests__/new-task.test.ts,src/engine/__tests__/switch-mode.test.ts", "clone 2efe67471984 src/orchestrator/cli.ts", @@ -161,6 +169,7 @@ "clone 306495c80c24 src/dashboard/server.ts", "clone 3095fa9d16ed src/github/cli.ts", "clone 3154ae4205ef src/orchestrator/cli.ts", + "clone 31c13ed95db0 src/dashboard/server.ts", "clone 326ecda164bf src/llm/muse.ts,src/llm/openrouter.ts", "clone 3276aaa5ade8 src/orchestrator/__tests__/resume.test.ts", "clone 32c7764d5938 src/engine/__tests__/condense.test.ts", @@ -168,6 +177,7 @@ "clone 3341cac7ce47 src/orchestrator/task-files.ts", "clone 338cc9087bf2 src/dashboard/__tests__/cost-history-routes.test.ts,src/orchestrator/__tests__/cost-history-cli.test.ts,src/orchestrator/__tests__/cost-history.test.ts", "clone 33c630390d21 src/rsi/__tests__/controller-candidates.test.ts,src/rsi/__tests__/controller-integrity.test.ts", + "clone 33c8bc11b4d3 src/orchestrator/cli.ts,src/watcher/cli.ts", "clone 33e68b8dfd03 src/llm/muse.ts,src/llm/openrouter.ts", "clone 3437313b4dfa src/llm/__tests__/muse.test.ts,src/llm/__tests__/openrouter.test.ts", "clone 34f0de1797fc src/orchestrator/task-files.ts", @@ -187,12 +197,14 @@ "clone 39b1afb85d1e src/codesearch/files.ts,src/engine/stacks.ts", "clone 39ee211357f1 src/orchestrator/__tests__/cli.test.ts,src/orchestrator/__tests__/resume.test.ts", "clone 3a54a1ee64ba src/orchestrator/__tests__/cli.test.ts", + "clone 3a8bc46875cf src/orchestrator/cli.ts,src/watcher/cli.ts", "clone 3adac262add7 src/orchestrator/cli.ts,src/orchestrator/resume.ts", "clone 3afdde6c5b0d src/orchestrator/task-files.ts", "clone 3b8db89c6d9f src/engine/__tests__/condense.test.ts", "clone 3bd848fdccd6 src/orchestrator/__tests__/spawn-model.test.ts,src/orchestrator/__tests__/spawn-state-reset.test.ts", "clone 3d0068ebfcec src/engine/__tests__/condense.test.ts", "clone 3d081917c13c src/orchestrator/__tests__/reviewer.test.ts,src/qa/__tests__/qa.test.ts", + "clone 3d44072e4378 src/orchestrator/cli.ts,src/watcher/cli.ts", "clone 3db2ffdde10b src/rsi/__tests__/controller-candidates.test.ts,src/rsi/__tests__/controller-fleet-results.test.ts", "clone 3dc5be5d75d0 src/orchestrator/task-files.ts", "clone 3dce629a0b04 src/dashboard/cli.ts,src/dashboard/trend-cli.ts", @@ -243,8 +255,10 @@ "clone 49f6208f6e8a src/engine/__tests__/loop.test.ts", "clone 49f715172224 src/codeintel/__tests__/call-graph.test.ts,src/codeintel/__tests__/find-references.test.ts,src/codeintel/__tests__/hover.test.ts,src/codeintel/__tests__/import-graph.test.ts,src/codeintel/__tests__/outline.test.ts,src/codeintel/__tests__/registration.test.ts,src/codeintel/__tests__/rename-symbol.test.ts,src/tools/__tests__/run-tests.test.ts", "clone 4a1be289d96e src/codesearch/cli.ts,src/dashboard/cli.ts,src/dashboard/trend-cli.ts", + "clone 4a1ea4c791ec src/engine/loop.ts", "clone 4b526509ca91 src/orchestrator/resume.ts", "clone 4b94ae93ab09 src/codeintel/__tests__/call-graph.test.ts,src/codeintel/__tests__/find-references.test.ts,src/codeintel/__tests__/hover.test.ts,src/codeintel/__tests__/import-graph.test.ts,src/codeintel/__tests__/outline.test.ts,src/codeintel/__tests__/registration.test.ts,src/codeintel/__tests__/rename-symbol.test.ts,src/tools/__tests__/run-tests.test.ts", + "clone 4b95f1687b30 src/engine/loop.ts", "clone 4c52d635b095 src/cloud/docker-provider.ts,src/cloud/provider.ts", "clone 4d4b7ced132f src/orchestrator/cli.ts", "clone 4d70161ff45e src/checkpoints/cli.ts,src/decision-proxy/cli.ts", @@ -260,6 +274,7 @@ "clone 511a4682fc24 src/llm/preflight.ts", "clone 518063685cd6 src/orchestrator/resume.ts", "clone 51838e15e74c src/dashboard/__tests__/server.test.ts,src/dashboard/__tests__/session-launch.test.ts", + "clone 51b96bc3dfca src/orchestrator/cli.ts,src/watcher/cli.ts", "clone 51c2328bdc20 src/engine/__tests__/new-task.test.ts,src/engine/__tests__/switch-mode.test.ts", "clone 5250c49d4c27 src/llm/preflight.ts", "clone 525de60909f7 src/cloud/__tests__/openshell-provider.test.ts", @@ -297,6 +312,7 @@ "clone 595bf2c5c404 src/checkpoints/cli.ts,src/decision-proxy/cli.ts", "clone 5966e99a548a src/engine/__tests__/new-task.test.ts,src/engine/__tests__/switch-mode.test.ts", "clone 5a796949a774 src/orchestrator/__tests__/status-cli.test.ts,src/orchestrator/__tests__/stop-cli.test.ts,src/orchestrator/__tests__/watch.test.ts", + "clone 5ae87962b838 src/dashboard/server.ts", "clone 5b3751abf8f7 src/engine/loop.ts", "clone 5b6a4398768d src/orchestrator/cli.ts,src/orchestrator/resume.ts", "clone 5bb4c726aedb src/engine/local-explore.ts,src/llm/ollama.ts", @@ -306,6 +322,7 @@ "clone 5cf8dfcbd0ac src/engine/__tests__/new-task.test.ts,src/engine/__tests__/switch-mode.test.ts", "clone 5d18e7fdb79d src/orchestrator/__tests__/spawn-model.test.ts,src/orchestrator/__tests__/spawn-state-reset.test.ts", "clone 5da675b1bbe8 src/llm/muse.ts,src/llm/openrouter.ts", + "clone 5dacd8daf260 src/dashboard/server.ts", "clone 5dd618396540 src/engine/__tests__/condense.test.ts", "clone 5dd736534e02 src/orchestrator/__tests__/resume.test.ts", "clone 5de8b4ab539a src/llm/__tests__/muse.test.ts,src/llm/__tests__/openrouter.test.ts", @@ -314,6 +331,7 @@ "clone 5e9eb7a40cd3 src/engine/__tests__/condense.test.ts", "clone 5f09b011f3c9 src/engine/__tests__/condense.test.ts", "clone 5f2ee4383718 src/github/pr.ts", + "clone 5f4183042bff src/rsi/fleet-repository-budget-ledger.ts", "clone 5f66e587d856 src/engine/local-explore.ts,src/llm/ollama.ts", "clone 5f6b2a16f10d src/checkpoints/cli.ts,src/cli.ts,src/codemap/cli.ts,src/codesearch/cli.ts,src/dashboard/cli.ts,src/dashboard/trend-cli.ts,src/decision-proxy/cli.ts,src/github/cli.ts,src/init/cli.ts,src/orchestrator/cleanup.ts,src/watcher/cli.ts", "clone 5fff6e3ebed7 src/dashboard/__tests__/cost-history-routes.test.ts,src/orchestrator/__tests__/cost-history-cli.test.ts", @@ -324,6 +342,7 @@ "clone 6376e4c9bfd3 src/github/__tests__/provision.test.ts", "clone 63fb58a6271f src/orchestrator/__tests__/cli.test.ts", "clone 6433777a2a28 src/orchestrator/__tests__/spawn-model.test.ts,src/orchestrator/__tests__/spawn-state-reset.test.ts", + "clone 6455405e5434 src/dashboard/server.ts", "clone 6466c80a5290 src/github/pr.ts", "clone 64820517d48e src/llm/__tests__/muse.test.ts,src/llm/__tests__/openrouter.test.ts", "clone 6489529d68a1 src/dashboard/server.ts", @@ -359,6 +378,7 @@ "clone 6cade99be57e src/rsi/__tests__/controller-candidates.test.ts,src/rsi/__tests__/controller-fleet-results.test.ts", "clone 6cc5e85990d1 src/orchestrator/__tests__/spawn-model.test.ts,src/orchestrator/__tests__/spawn-state-reset.test.ts", "clone 6cd34638ecf4 src/codesearch/airunner-embedder.ts,src/codesearch/ollama-embedder.ts", + "clone 6cfb982e01f4 src/dashboard/server.ts", "clone 6da4bb48c44f src/dashboard/__tests__/projects-routes.test.ts,src/projects/__tests__/cli.test.ts", "clone 6db5dcb809a6 src/orchestrator/task-files.ts", "clone 6dd12297a203 src/rsi/__tests__/worker.test.ts", @@ -367,7 +387,7 @@ "clone 6e3afc8af712 src/codesearch/files.ts,src/engine/stacks.ts", "clone 6ec154ac699f src/llm/preflight.ts", "clone 700ed9396d5d src/orchestrator/cli.ts", - "clone 70f80df8706f src/orchestrator/cli.ts,src/watcher/cli.ts", + "clone 708f80ae3deb src/orchestrator/__tests__/execution-provider.test.ts,src/watcher/__tests__/webhook.test.ts", "clone 7104c725be6f src/llm/preflight.ts", "clone 71567db6af5d src/dashboard/server.ts", "clone 719d5a6b953f src/dashboard/__tests__/session-launch.test.ts", @@ -398,6 +418,7 @@ "clone 77f73cc7bae5 src/cli.ts,src/dashboard/cli.ts,src/dashboard/trend-cli.ts,src/orchestrator/cleanup.ts,src/watcher/cli.ts", "clone 782fcf6fa16a src/orchestrator/resume.ts", "clone 785455958a9c src/orchestrator/__tests__/cli.test.ts,src/orchestrator/__tests__/resume.test.ts", + "clone 7891ba603853 src/orchestrator/cli.ts,src/watcher/cli.ts", "clone 78b388a03d57 src/orchestrator/resume.ts", "clone 78c6f725a4b4 src/watcher/watch.ts", "clone 78e46c4f5e90 src/engine/__tests__/new-task.test.ts,src/engine/__tests__/switch-mode.test.ts", @@ -407,6 +428,7 @@ "clone 797b3d3a97db src/engine/__tests__/condense.test.ts,src/engine/__tests__/events.test.ts", "clone 799bf418925d src/engine/__tests__/new-task.test.ts,src/engine/__tests__/switch-mode.test.ts", "clone 79f47b3164f1 src/orchestrator/resume.ts", + "clone 7a0875b54a53 src/budget/__tests__/concurrency.test.ts,src/watcher/__tests__/webhook.test.ts", "clone 7a154a1f1f61 src/rsi/__tests__/worker.test.ts", "clone 7a1b9f629554 src/engine/__tests__/new-task.test.ts,src/engine/__tests__/switch-mode.test.ts", "clone 7a53d4a3fcc7 src/codesearch/files.ts,src/engine/stacks.ts", @@ -450,6 +472,7 @@ "clone 84fe1e0bacea src/orchestrator/__tests__/spawn-model.test.ts,src/orchestrator/__tests__/spawn-state-reset.test.ts", "clone 85b97c9d7f1a src/orchestrator/resume.ts", "clone 85c4b4effe66 src/engine/local-explore.ts,src/llm/ollama.ts", + "clone 85e087684baa src/dashboard/server.ts", "clone 85ea6e800321 src/orchestrator/task-files.ts", "clone 85f188b0bc7f src/orchestrator/task-files.ts", "clone 85f56ac89584 src/cloud/docker-provider.ts,src/cloud/provider.ts", @@ -473,6 +496,7 @@ "clone 8b1b3fe137c3 src/llm/openrouter.ts", "clone 8b4721c34bf4 src/engine/loop.ts", "clone 8b665567608f src/orchestrator/__tests__/spawn-model.test.ts,src/orchestrator/__tests__/spawn-state-reset.test.ts", + "clone 8c08a3092b1b src/campaigncontrol/__tests__/server.test.ts", "clone 8c15aef04331 src/orchestrator/task-files.ts", "clone 8cbf4767d294 src/engine/local-explore.ts,src/llm/ollama.ts", "clone 8d24cff0cf64 src/engine/__tests__/loop.test.ts", @@ -491,6 +515,7 @@ "clone 8fe789c46bc4 src/orchestrator/__tests__/reviewer.test.ts,src/qa/__tests__/qa.test.ts", "clone 9003da86dcf3 src/codesearch/files.ts,src/engine/stacks.ts", "clone 90309d08a06e src/engine/local-explore.ts,src/llm/ollama.ts", + "clone 9042878f011a src/dashboard/server.ts", "clone 90919b289545 src/engine/__tests__/loop.test.ts,src/tools/__tests__/execute_command.test.ts", "clone 90ad7e210e7a src/engine/__tests__/condense.test.ts,src/engine/__tests__/loop.test.ts", "clone 90c851702fad src/llm/muse.ts,src/llm/openrouter.ts", @@ -517,6 +542,7 @@ "clone 96d294f3a39d src/orchestrator/resume.ts", "clone 96d730011cef src/llm/openrouter.ts", "clone 9716d28923cf src/dashboard/trend-cli.ts,src/orchestrator/cleanup.ts", + "clone 971fa2bd92f9 src/dashboard/server.ts", "clone 978d30338b0a src/engine/__tests__/loop.test.ts", "clone 97ce5883e245 src/orchestrator/task-files.ts", "clone 97f2197071b1 src/orchestrator/task-files.ts", @@ -529,9 +555,11 @@ "clone 98e64d6f23d8 src/checkpoints/cli.ts,src/decision-proxy/cli.ts", "clone 993a1632940a src/llm/muse.ts,src/llm/openrouter.ts", "clone 998a739cc867 src/engine/__tests__/new-task.test.ts,src/engine/__tests__/switch-mode.test.ts", + "clone 998d7ea7f382 src/orchestrator/cli.ts,src/watcher/cli.ts", "clone 99b150e9e3dc src/codesearch/__tests__/airunner-embedder.test.ts,src/codesearch/__tests__/ollama-embedder.test.ts", "clone 99ba2224e54b src/llm/muse.ts,src/llm/openrouter.ts", "clone 99ebebf858ee src/codesearch/__tests__/airunner-embedder.test.ts,src/codesearch/__tests__/ollama-embedder.test.ts", + "clone 9a0b84ed686e src/dashboard/session-pids.ts,src/engine/usage.ts", "clone 9a2d9c8ece5a src/rsi/__tests__/controller-candidates.test.ts,src/rsi/__tests__/controller-integrity.test.ts", "clone 9a34727f0f71 src/engine/__tests__/condense.test.ts", "clone 9a5822d78a2b src/orchestrator/task-files.ts", @@ -556,8 +584,8 @@ "clone 9eb6afa5c7cc src/llm/preflight.ts", "clone 9ecd27cf445b src/orchestrator/cli.ts", "clone 9ed4248bc98d src/engine/local-explore.ts,src/llm/ollama.ts", - "clone 9ee98e35bf15 src/orchestrator/cli.ts,src/watcher/cli.ts", "clone 9f5a1c3e6be5 src/orchestrator/resume.ts", + "clone 9fc1588659d4 src/engine/loop.ts", "clone 9fd2184a9f18 src/rsi/__tests__/controller-candidates.test.ts,src/rsi/__tests__/controller-integrity.test.ts", "clone a003fde0f022 src/llm/muse.ts,src/llm/openrouter.ts", "clone a100929d0996 src/codesearch/__tests__/airunner-embedder.test.ts,src/codesearch/__tests__/ollama-embedder.test.ts", @@ -569,6 +597,7 @@ "clone a21a36c1e0f2 src/engine/__tests__/new-task.test.ts,src/engine/__tests__/switch-mode.test.ts", "clone a24e8a7cfdb1 src/codesearch/files.ts,src/engine/stacks.ts", "clone a267947846ee src/dashboard/server.ts", + "clone a27f8b2f4e8c src/engine/loop.ts", "clone a2856ade0b68 src/llm/muse.ts,src/llm/openrouter.ts", "clone a290c29733ab src/codeintel/__tests__/call-graph.test.ts,src/codeintel/__tests__/find-references.test.ts,src/codeintel/__tests__/hover.test.ts,src/codeintel/__tests__/import-graph.test.ts,src/codeintel/__tests__/outline.test.ts,src/codeintel/__tests__/registration.test.ts,src/codeintel/__tests__/rename-symbol.test.ts,src/tools/__tests__/run-tests.test.ts", "clone a331eb790bd5 src/orchestrator/resume.ts", @@ -628,7 +657,6 @@ "clone b2fe932140ce src/dashboard/server.ts", "clone b32ef8233ec1 src/orchestrator/resume.ts", "clone b34afefdc113 src/engine/local-explore.ts,src/llm/ollama.ts", - "clone b379dde1bfa2 src/orchestrator/cli.ts,src/watcher/cli.ts", "clone b419866f1da4 src/engine/local-explore.ts,src/llm/ollama.ts", "clone b42ecdd2a660 src/engine/__tests__/loop.test.ts", "clone b4fcee4dede8 src/cloud/docker-provider.ts,src/cloud/provider.ts", @@ -641,6 +669,7 @@ "clone b6a5d7b4b224 src/codesearch/__tests__/airunner-embedder.test.ts,src/codesearch/__tests__/ollama-embedder.test.ts", "clone b6b3e45c1aa6 src/cloud/docker-provider.ts,src/cloud/provider.ts", "clone b6f659cd7539 src/llm/openrouter.ts", + "clone b778583caf32 src/campaigncontrol/__tests__/server.test.ts", "clone b7d860dc5f58 src/llm/muse.ts,src/llm/openrouter.ts", "clone b7e81904dc41 src/dashboard/__tests__/projects-routes.test.ts", "clone b80a526400a0 src/cloud/docker-provider.ts,src/cloud/provider.ts", @@ -686,6 +715,7 @@ "clone c4ffe9d533ad src/orchestrator/cli.ts", "clone c514b8a70ac1 src/engine/__tests__/condense.test.ts", "clone c5206c729975 src/dashboard/__tests__/cost-history-routes.test.ts,src/orchestrator/__tests__/cost-history-cli.test.ts", + "clone c5b3c278b073 src/dashboard/server.ts", "clone c5f99dad818d src/engine/__tests__/new-task.test.ts,src/engine/__tests__/switch-mode.test.ts", "clone c5fae546f069 src/watcher/watch.ts", "clone c68a90c711b3 src/codesearch/files.ts,src/engine/stacks.ts", @@ -700,10 +730,12 @@ "clone c9648e69e45e src/orchestrator/__tests__/cli.test.ts", "clone c9726dcfaf3b src/engine/local-explore.ts,src/llm/ollama.ts", "clone ca31b6bb0f50 src/budget/__tests__/concurrency.test.ts,src/watcher/__tests__/watch.test.ts", + "clone cae212f9d1dd src/orchestrator/cli.ts,src/watcher/cli.ts", "clone cb208607f464 src/dashboard/server.ts", "clone cb54ce2ca134 src/orchestrator/__tests__/cli.test.ts,src/orchestrator/__tests__/resume.test.ts", "clone cb96538b6cf5 src/engine/__tests__/condense-async.test.ts,src/engine/__tests__/events.test.ts", "clone cc26ee01ab63 src/orchestrator/task-files.ts", + "clone cc27b6783af0 src/dashboard/__tests__/session-launch.test.ts", "clone cc3b18fef474 src/orchestrator/task-files.ts", "clone ccb15663db25 src/cloud/docker-provider.ts,src/cloud/provider.ts", "clone ccec483cd00c src/llm/muse.ts,src/llm/openrouter.ts", @@ -715,6 +747,7 @@ "clone cdff5c34ea22 src/orchestrator/task-files.ts", "clone ce27f097c90c src/rsi/__tests__/controller-candidates.test.ts,src/rsi/__tests__/controller-fleet-results.test.ts", "clone ce4455f3e99f src/orchestrator/task-files.ts", + "clone ce982fcde544 src/orchestrator/cli.ts,src/watcher/cli.ts", "clone cee648fd9d03 src/engine/__tests__/new-task.test.ts,src/engine/__tests__/switch-mode.test.ts", "clone cfbc5b2083c1 src/engine/local-explore.ts,src/llm/ollama.ts", "clone d07fbc6b767f src/tools/__tests__/edit_file.test.ts,src/tools/__tests__/search_replace.test.ts", @@ -737,6 +770,7 @@ "clone d4cdc1c2c168 src/checkpoints/cli.ts,src/cli.ts,src/codemap/cli.ts,src/codesearch/cli.ts,src/dashboard/cli.ts,src/dashboard/trend-cli.ts,src/decision-proxy/cli.ts,src/github/cli.ts,src/init/cli.ts,src/orchestrator/cleanup.ts,src/watcher/cli.ts", "clone d4f6305e2c9c src/llm/__tests__/muse.test.ts,src/llm/__tests__/openrouter.test.ts", "clone d51f1a5afd2a src/orchestrator/resume.ts", + "clone d53bbdb7c8cf src/dashboard/server.ts", "clone d59611db1320 src/orchestrator/task-files.ts", "clone d5bedf6eac9d src/orchestrator/__tests__/cli.test.ts,src/orchestrator/__tests__/resume.test.ts", "clone d5e4c8592f25 src/orchestrator/__tests__/cli.test.ts", @@ -774,6 +808,7 @@ "clone ddf5d3691b74 src/checkpoints/cli.ts,src/cli.ts,src/codemap/cli.ts,src/codesearch/cli.ts,src/dashboard/cli.ts,src/dashboard/trend-cli.ts,src/decision-proxy/cli.ts,src/github/cli.ts,src/init/cli.ts,src/orchestrator/cleanup.ts,src/watcher/cli.ts", "clone de0450878713 src/llm/muse.ts,src/llm/openrouter.ts", "clone de13d7c2dbd3 src/engine/local-explore.ts,src/llm/ollama.ts", + "clone de75aa21712b src/engine/loop.ts", "clone de8f0e7dadef src/github/pr.ts", "clone decb081dffd5 src/orchestrator/cli.ts,src/orchestrator/resume.ts", "clone df1817b85acf src/dashboard/timeline.ts,src/engine/tool-classes.ts", @@ -782,6 +817,7 @@ "clone e010fc53c9f4 src/engine/loop.ts", "clone e0baba4315c3 src/orchestrator/cli.ts,src/orchestrator/resume.ts,src/watcher/cli.ts", "clone e0f1e0a708cc src/orchestrator/__tests__/spawn-model.test.ts,src/orchestrator/__tests__/spawn-state-reset.test.ts", + "clone e10297074a77 src/dashboard/__tests__/session-launch.test.ts", "clone e1591587b296 src/engine/local-explore.ts,src/llm/ollama.ts", "clone e1fb18fbd91a src/orchestrator/cli.ts", "clone e20b21c40e41 src/orchestrator/cli.ts,src/orchestrator/resume.ts", @@ -796,6 +832,7 @@ "clone e3677d2289a3 src/rsi/__tests__/controller-candidates.test.ts,src/rsi/__tests__/controller-fleet-results.test.ts", "clone e37c0c4b3387 src/orchestrator/cli.ts,src/watcher/cli.ts", "clone e3a4e8050308 src/codesearch/files.ts,src/engine/stacks.ts", + "clone e3bf70c6150c src/orchestrator/cli.ts,src/watcher/cli.ts", "clone e3d13fb47c32 src/orchestrator/__tests__/reviewer.test.ts,src/qa/__tests__/qa.test.ts", "clone e416c30b4843 src/llm/preflight.ts", "clone e498eb38bb29 src/orchestrator/resume.ts", @@ -821,6 +858,7 @@ "clone ea84c951ecaa src/llm/preflight.ts", "clone ea87d3664530 src/llm/preflight.ts", "clone eb1f923409cf src/tools/__tests__/describe_image.test.ts,src/vision/__tests__/describe.test.ts", + "clone eb2bcc27e8de src/dashboard/server.ts", "clone ec1ebb8ca755 src/cloud/docker-provider.ts,src/cloud/provider.ts", "clone ec284ffedf87 src/rsi/controller.ts", "clone ec2949b2c9e9 src/engine/local-explore.ts,src/llm/ollama.ts", @@ -835,8 +873,10 @@ "clone ef26fdd9523d src/llm/preflight.ts", "clone ef55d3fea271 src/dashboard/__tests__/cost-history-routes.test.ts,src/orchestrator/__tests__/cost-history-cli.test.ts", "clone ef70ff0a9386 src/engine/local-explore.ts,src/llm/ollama.ts", + "clone f01d82461060 src/dashboard/server.ts", "clone f01f54f65b50 src/codesearch/files.ts,src/engine/stacks.ts", "clone f075d1e0c08a src/orchestrator/resume.ts", + "clone f0a2724e02c2 src/campaigncontrol/__tests__/server.test.ts", "clone f0ce557b48e0 src/watcher/watch.ts", "clone f0f979cf4060 src/llm/muse.ts,src/llm/openrouter.ts", "clone f14b65dc96ac src/engine/__tests__/loop.test.ts,src/tools/__tests__/execute_command.test.ts", @@ -890,11 +930,79 @@ "clone ff5ec5779c4d src/engine/__tests__/loop.test.ts,src/tools/__tests__/execute_command.test.ts", "clone ff6f42902423 src/orchestrator/cli.ts", "clone ffea56e47c93 src/llm/muse.ts", + "cycle src/cloud/docker-provider.ts void +} + async function testResolveExecutionProviderName(): Promise { assert.equal(resolveExecutionProviderName("docker"), "docker") assert.equal(resolveExecutionProviderName("openshell"), "openshell") @@ -27,31 +32,81 @@ async function testResolveExecutionProviderName(): Promise { assert.equal(resolveExecutionProviderName("bogus"), "local") } -async function testCreateCloudProviderMapping(): Promise { - const docker = createCloudProvider("docker", { - docker: { - run: () => ({ exitCode: 0, output: "" }), - listContainers: () => [], +function dockerMappingCase(): MappingCase { + return { + label: "docker is mapped", + run: () => { + const docker = createCloudProvider("docker", { + docker: { + run: () => ({ exitCode: 0, output: "" }), + listContainers: () => [], + }, + }) + assert.ok( + docker instanceof DockerSessionProvider, + "docker is mapped", + ) + assert.equal(docker.name, "docker") }, - }) - assert.ok(docker instanceof DockerSessionProvider, "docker is mapped") - assert.equal(docker.name, "docker") + } +} + +function localMappingCase(): MappingCase { + return { + label: "local is kept", + run: () => { + const local = createCloudProvider( + "local", + { local: { dryRun: true } }, + ) + assert.ok( + local instanceof LocalProcessProvider, + "local is kept", + ) + assert.equal(local.name, "local") + }, + } +} - const local = createCloudProvider("local", { local: { dryRun: true } }) - assert.ok(local instanceof LocalProcessProvider, "local is kept") - assert.equal(local.name, "local") +function defaultMappingCase(): MappingCase { + return { + label: "defaults map without the environment", + run: () => { + const docker = createCloudProvider("docker") + assert.ok( + docker instanceof DockerSessionProvider, + "docker default maps", + ) + const local = createCloudProvider("local") + assert.ok( + local instanceof LocalProcessProvider, + "local default maps", + ) + }, + } +} - // The default (no options) also maps without touching the environment. - assert.ok(createCloudProvider("docker") instanceof DockerSessionProvider) - assert.ok(createCloudProvider("local") instanceof LocalProcessProvider) +function openshellMappingCase(): MappingCase { + return { + label: "openshell refuses its own path", + run: () => { + assert.throws( + () => createCloudProvider("openshell"), + /openshell-provider\.ts/, + "openshell routes to its own path", + ) + }, + } +} - // openshell keeps its own construction path — the factory refuses rather - // than silently dropping OpenShellSessionProviderOptions. - assert.throws( - () => createCloudProvider("openshell"), - /openshell-provider\.ts/, - "openshell routes to its own provider path", - ) +async function testCreateCloudProviderMapping(): Promise { + const entries = [ + dockerMappingCase(), + localMappingCase(), + defaultMappingCase(), + openshellMappingCase(), + ] + for (const entry of entries) entry.run() } async function testDockerPreflightHealthy(): Promise { From 733646e83dbcd9d581b54364aa02e0d8ccd01310 Mon Sep 17 00:00:00 2001 From: w4ffl35 <25737761+w4ffl35@users.noreply.github.com> Date: Sat, 5 Dec 2026 15:37:09 -0700 Subject: [PATCH 3/4] #200 resolve Tier 3 gate tools against harness root runTypeAndTests and runCheckerGates used worktree-relative tool paths (node_modules/...tsc, scripts/run-tests.mjs); on the dependency-free e2e fixture every gate died with MODULE_NOT_FOUND. All tool paths now resolve against HARNESS_ROOT (from reviewer.ts) and run with the harness root as cwd. tsc -p points at the harness root (the target may have no tsconfig). JS-only trees with no tsconfig/jsconfig are not type-testable, so greet.js-style fixtures skip tsc/tests and run the baseline-free harness checkers only. Unit tests assert harness-absolute paths, harness cwd, and the bare-JS skip; 7/7 green. --- .../__tests__/review-gates.test.ts | 42 +++++++++++---- src/orchestrator/review-gates.ts | 54 ++++++++++++++----- 2 files changed, 75 insertions(+), 21 deletions(-) diff --git a/src/orchestrator/__tests__/review-gates.test.ts b/src/orchestrator/__tests__/review-gates.test.ts index 27f0efe8..d0dc9088 100644 --- a/src/orchestrator/__tests__/review-gates.test.ts +++ b/src/orchestrator/__tests__/review-gates.test.ts @@ -6,7 +6,7 @@ import * as path from "node:path" import type { CodeIntel } from "../../codeintel/program.js" import type { GateRunner } from "../review-gates.js" -import { runReviewGates } from "../review-gates.js" +import { HARNESS_ROOT as HARNESS_CWD, runReviewGates } from "../review-gates.js" import { hasRealWorktreeChanges } from "../verification-gate.js" import { runMain } from "../../test-runner.js" @@ -57,8 +57,8 @@ function stubIntel(): CodeIntel { } function greenRunner(calls: string[][]): GateRunner { - return (cmd: string, args: string[], _cwd: string, _timeout: number) => { - calls.push([cmd, ...args]) + return (cmd: string, args: string[], cwd: string, _timeout: number) => { + calls.push([cmd, ...args, cwd]) return { status: 0, output: "(stubbed)" } } } @@ -78,15 +78,21 @@ async function writeCoveredSource(wt: string, base: string): Promise { await fsp.writeFile(path.join(wt, "src", `${base}.ts`), "export const v = 1\n") const test = path.join(dir, `${base}.test.ts`) await fsp.writeFile(test, "void 0\n") + await fsp.writeFile(path.join(wt, "tsconfig.json"), "{}\n") } -function assertAllGatesRan(calls: string[][]): void { - assert.ok(calls.some((c) => c[1].includes("typescript/bin/tsc"))) - assert.ok(calls.some((c) => c[1] === "scripts/run-tests.mjs")) +function assertHarnessGatesRan(calls: string[][]): void { + const tscSeg = "typescript/bin/tsc" + assert.ok(calls.some((c) => String(c[1]).includes(tscSeg))) + const runner = "scripts/run-tests.mjs" + assert.ok(calls.some((c) => String(c[1]).endsWith(runner))) const std = "scripts/check-code-standards.mjs" - assert.ok(calls.some((c) => c[1] === std)) + assert.ok(calls.some((c) => String(c[1]).endsWith(std))) const arch = "scripts/check-architecture.mjs" - assert.ok(calls.some((c) => c[2] === arch)) + assert.ok(calls.some((c) => String(c[2]).endsWith(arch))) + for (const c of calls) { + assert.equal(c[c.length - 1], HARNESS_CWD) + } } async function changesNeedFixtureFiles(wt: string): Promise { @@ -115,7 +121,7 @@ async function coveredSourcePasses(wt: string): Promise { }) assert.equal(result.ok, true) assert.equal(intelCalls, 0) - assertAllGatesRan(calls) + assertHarnessGatesRan(calls) } async function redGateFailsClosed(wt: string): Promise { @@ -145,6 +151,7 @@ async function uncoveredSourceFlagged(wt: string): Promise { await fsp.mkdir(path.join(wt, "src"), { recursive: true }) const file = path.join(wt, "src", "lonely.ts") await fsp.writeFile(file, "export const x = 1\n") + await fsp.writeFile(path.join(wt, "tsconfig.json"), "{}\n") const result = runReviewGates(wt, { loadIntel: stubIntel, run: greenRunner([]), @@ -154,6 +161,22 @@ async function uncoveredSourceFlagged(wt: string): Promise { assert.ok(result.summary.includes(want)) } +async function bareJsFixtureSkipsTypeTests(wt: string): Promise { + await fsp.mkdir(path.join(wt, "src"), { recursive: true }) + await fsp.writeFile(path.join(wt, "src", "greet.js"), "void 0\n") + const calls: string[][] = [] + const result = runReviewGates(wt, { + loadIntel: stubIntel, + run: greenRunner(calls), + }) + assert.equal(result.ok, true) + assert.ok(result.output.includes("tsc/tests skipped: no testable")) + assert.ok(!calls.some((c) => String(c[1]).includes("tsc"))) + assert.ok(!calls.some((c) => String(c[1]).endsWith("run-tests.mjs"))) + const std = "scripts/check-code-standards.mjs" + assert.ok(calls.some((c) => String(c[1]).endsWith(std))) +} + const tests: Array<[string, () => Promise]> = [ ["changes track fixture files", () => withFixture(changesNeedFixtureFiles)], ["bookkeeping files ignored", () => withFixture(bookkeepingIsIgnored)], @@ -161,6 +184,7 @@ const tests: Array<[string, () => Promise]> = [ ["red gate fails closed", () => withFixture(redGateFailsClosed)], ["docs-only skips tsc/tests", () => withFixture(docsOnlySkipsTypeTests)], ["uncovered sources flagged", () => withFixture(uncoveredSourceFlagged)], + ["bare JS skips type/tests", () => withFixture(bareJsFixtureSkipsTypeTests)], ] runMain("review-gates", tests) diff --git a/src/orchestrator/review-gates.ts b/src/orchestrator/review-gates.ts index d7308e1c..230a723f 100644 --- a/src/orchestrator/review-gates.ts +++ b/src/orchestrator/review-gates.ts @@ -2,6 +2,8 @@ import { execFileSync } from "node:child_process" import * as fs from "node:fs" import * as path from "node:path" +import { HARNESS_ROOT } from "./reviewer.js" +export { HARNESS_ROOT } // tests assert gates resolve tools here import { getCodeIntelCache, type CodeIntel } from "../codeintel/program.js" import { directTestMatch, @@ -37,6 +39,13 @@ export interface ReviewGateDeps { const GATE_TIMEOUT_MS = 300_000 const GATE_OUTPUT_CAP = 1500 +// Tier 3 tools resolve against HARNESS_ROOT, never the target +// worktree (#200: worktree-relative node_modules paths die with +// MODULE_NOT_FOUND on a dependency-free fixture). +function harnessBin(...segs: string[]): string { + return path.join(HARNESS_ROOT, ...segs) +} + function defaultGateRunner( command: string, args: string[], @@ -87,13 +96,29 @@ function truncateOutput(output: string): string { return `${trimmed.slice(-GATE_OUTPUT_CAP)}\n… (truncated, tail kept)` } -/** Changed files the type/test gates apply to: test files themselves plus - * sources with a direct-test convention (TS/JS). Docs, config, and scripts - * outside the convention get checkers only. */ -function gateTestableFiles(changed: string[]): string[] { +/** Testable inputs: test files plus TS sources in a TS project. + * JS-only fixtures get checkers only (no tsconfig for tsc, #200). */ +function gateTestableFiles(changed: string[], wtPath: string): string[] { + if (!hasTsConfig(wtPath)) { + return changed.filter((f) => isTestFile(f)) + } return changed.filter((f) => isTestFile(f) || directTestMatch(f) !== undefined) } +/** True when the target tree is a TS project tsc can typecheck. */ +function hasTsConfig(wtPath: string): boolean { + for (const name of ["tsconfig.json", "jsconfig.json"]) { + try { + if (fs.statSync(path.join(wtPath, name)).isFile()) { + return true + } + } catch { + // Missing — keep looking. + } + } + return false +} + function directCovered(root: string, rel: string): boolean { if (isTestFile(rel)) return true const direct = directTestMatch(rel) @@ -132,7 +157,7 @@ interface GateContext { } function gatePlan(wtPath: string, deps: ReviewGateDeps): GatePlan { - const testable = gateTestableFiles(worktreeChangedFiles(wtPath)) + const testable = gateTestableFiles(worktreeChangedFiles(wtPath), wtPath) const needsIntel = testable.some((f) => !directCovered(wtPath, f)) const loadIntel = deps.loadIntel ?? (() => getCodeIntelCache(wtPath).get()) const intel = needsIntel ? loadIntel() : undefined @@ -157,7 +182,7 @@ function runGate( ): void { let result: GateCommandResult try { - result = ctx.run(process.execPath, args, ctx.wtPath, GATE_TIMEOUT_MS) + result = ctx.run(process.execPath, args, HARNESS_ROOT, GATE_TIMEOUT_MS) } catch (error) { result = { status: 1, output: `gate runner threw: ${String(error)}` } } @@ -168,6 +193,12 @@ function runGate( } } +const TSC_BIN = harnessBin("node_modules", "typescript", "bin", "tsc") +const RUN_TESTS = harnessBin("scripts", "run-tests.mjs") +const CHECK_STANDARDS = harnessBin("scripts", "check-code-standards.mjs") +const TSX_BIN = harnessBin("node_modules", "tsx", "dist", "cli.mjs") +const CHECK_ARCH = harnessBin("scripts", "check-architecture.mjs") + function runTypeAndTests( plan: GatePlan, ctx: GateContext, @@ -177,18 +208,17 @@ function runTypeAndTests( state.outputs.push("tsc/tests skipped: no testable files") return } - const tsc = ["node_modules/typescript/bin/tsc", "--noEmit"] + const tsc = [TSC_BIN, "--noEmit", "-p", HARNESS_ROOT] runGate(ctx, "tsc --noEmit", tsc, state) for (const test of plan.tests) { - const args = ["scripts/run-tests.mjs", "--filter", test] - runGate(ctx, `tests ${test}`, args, state) + runGate(ctx, `tests ${test}`, [RUN_TESTS, "--filter", test], state) } } +// Baselined runs: only NEW violations fail (#200). function runCheckerGates(ctx: GateContext, state: GateRun): void { - runGate(ctx, "check-standards", ["scripts/check-code-standards.mjs"], state) - runGate(ctx, "check-architecture", - ["node_modules/tsx/dist/cli.mjs", "scripts/check-architecture.mjs"], state) + runGate(ctx, "check-standards", [CHECK_STANDARDS], state) + runGate(ctx, "check-arch", [TSX_BIN, CHECK_ARCH], state) } function gateSummary(plan: GatePlan, failures: string[]): string { From 38901b23a093478f118d7564065e4ce18405b4d9 Mon Sep 17 00:00:00 2001 From: w4ffl35 <25737761+w4ffl35@users.noreply.github.com> Date: Sat, 5 Dec 2026 17:25:21 -0700 Subject: [PATCH 4/4] Add operator --retry-failed / --retry-group resume flag for failed groups (#201) --- src/orchestrator/__tests__/resume.test.ts | 228 ++++++++++++++++++++++ src/orchestrator/cli.ts | 25 ++- src/orchestrator/resume.ts | 137 +++++++++++-- 3 files changed, 374 insertions(+), 16 deletions(-) diff --git a/src/orchestrator/__tests__/resume.test.ts b/src/orchestrator/__tests__/resume.test.ts index 6574479b..edbf8cac 100644 --- a/src/orchestrator/__tests__/resume.test.ts +++ b/src/orchestrator/__tests__/resume.test.ts @@ -35,6 +35,7 @@ import { runReviewStep, runReworkStep, resolveTargetGroups, + type ResumeGroupResult, type ResumeTarget, } from "../resume.js" import { defaultState, loadStateSync, saveStateSync, type OrchestratorGroup, type OrchestratorState } from "../state.js" @@ -1091,6 +1092,228 @@ async function testResumeMainDryRunPlansContinuation(): Promise { } } +// ─── operator retry --retry-failed / --retry-group (issue #201) ─────── + +async function testParseResumeArgsRetryFlags(): Promise { + const target = ["--repo", "/tmp/x", "--group", "w8"] + const repoArgs = (fl: string[]): string[] => [...target, ...fl] + const retry = parseResumeArgs(repoArgs(["--retry-failed"])) + assert.equal(retry.error, undefined) + assert.equal(retry.options.retryFailed, true) + assert.equal(retry.options.forceRetry, false) + const alias = parseResumeArgs(repoArgs(["--retry-group"])) + assert.equal(alias.error, undefined) + assert.equal(alias.options.retryFailed, true) + const force = parseResumeArgs(repoArgs(["--retry-failed", "--force-retry"])) + assert.equal(force.error, undefined) + assert.equal(force.options.retryFailed, true) + assert.equal(force.options.forceRetry, true) +} + +/** `git -C ` with output ignored. */ +function gitQuiet(repo: string, args: string[]): void { + execFileSync("git", ["-C", repo, ...args], { stdio: "ignore" }) +} + +/** Commit a file on the current branch of `repo`, then add a linked + * worktree for `branch` — the real worktree shape the review/resume + * gates resolve git state against (no bare-subdir fixtures). */ +async function setupRepoWithBranchWorktree( + repo: string, + branch: string, + workFiles: Array<[string, string, string]>, +): Promise { + initGitRepo(repo) + configureGit(repo) + await fs.writeFile(path.join(repo, "base.txt"), "base\n", "utf-8") + commitFile(repo, "base.txt", "base\n", "base") + gitQuiet(repo, ["checkout", "-qb", branch]) + for (const [rel, content, message] of workFiles) { + await fs.writeFile(path.join(repo, rel), content, "utf-8") + commitFile(repo, rel, content, message) + } + gitQuiet(repo, ["checkout", "-q", "main"]) + const wtPath = path.join(repo, ".worktrees", "w1") + gitQuiet(repo, ["worktree", "add", "-q", wtPath, branch]) + return wtPath +} + +/** Fake the tracked upstream a linked worktree resolves in a real round + * (a bare fixture repo has no origin): committed progress is then + * salvageable via the committed-diff leg of hasRealWorktreeChanges. */ +function fakeWorktreeUpstream( + repo: string, + wtPath: string, + branch: string, +): void { + const fetchspec = "+refs/heads/*:refs/remotes/origin/*" + gitQuiet(repo, ["update-ref", "refs/remotes/origin/master", "main"]) + gitQuiet(repo, ["config", "remote.origin.url", repo]) + gitQuiet(repo, ["config", "remote.origin.fetch", fetchspec]) + gitQuiet(wtPath, ["config", `branch.${branch}.remote`, "origin"]) + gitQuiet(wtPath, ["config", `branch.${branch}.merge`, "refs/heads/master"]) +} + +async function runRetryMain( + repo: string, + args: string[], +): Promise<{ exit: number; stdout: string }> { + return withCapturedStdout(() => resumeMain(["--repo", repo, ...args])) +} + +async function writeFailedGroup( + repo: string, + branch: string, + summary: string, +): Promise { + const group = baseGroup({ branch, status: "failed", exit_code: 1, summary }) + writeState(repo, [group]) +} + +/** A failed group through runRetryMain, asserting the planned outcome. */ +async function expectRetryMain( + repo: string, + args: string[], + exit: number, + needles: string[], +): Promise { + const { exit: got, stdout } = await runRetryMain(repo, args) + assert.equal(got, exit) + for (const needle of needles) { + assert.ok(stdout.includes(needle), `expected ${needle}, got: ${stdout}`) + } + return stdout +} + +/** Plain resume refuses a generic failure; --retry-failed plans it. */ +async function assertRetryPlansContinuation( + repo: string, + branch: string, + wt: string, +): Promise { + fakeWorktreeUpstream(repo, wt, branch) + // A generic failure (NOT iteration exhaustion, NOT a provider + // failure) with salvageable progress: plain resume refuses it, but + // --retry-failed forces the continuation spawn plan. + await writeFailedGroup(repo, branch, "headlesscode: task failed") + const plainArgs = ["--issue", "14", "--dry-run"] + await expectRetryMain(repo, plainArgs, 1, ["not continuable"]) + const retryArgs = [...plainArgs, "--retry-failed"] + const wants = ["continuation 1", "run-worker.sh", "operator retry"] + await expectRetryMain(repo, retryArgs, 0, wants) +} + +async function testRetryFailedPlansContinuation(): Promise { + const repo = await tmpRepo() + const branch = "issues/w1-2026-08-28" + type WorkFile = [string, string, string] + const work: WorkFile[] = [["work.md", "partial work\n", "salvage"]] + const wt = await setupRepoWithBranchWorktree(repo, branch, work) + try { + await assertRetryPlansContinuation(repo, branch, wt) + } finally { + await fs.rm(repo, { recursive: true, force: true }) + } +} + +async function testRefusesEmptyWorktree(): Promise { + const repo = await tmpRepo() + const branch = "issues/w1-2026-08-28" + await setupRepoWithBranchWorktree(repo, branch, []) + try { + // Empty worktree: checked out on its own branch with no divergence + // from base — the retry is refused instead of spawning a worker + // that would start from scratch. + await writeFailedGroup(repo, branch, "headlesscode: boom") + const noProgress = ["no salvageable progress", "--force-retry"] + const wantsOne = ["continuation 1"] + const issueArgs = ["--issue", "14"] + const retryArgs = [...issueArgs, "--retry-failed", "--dry-run"] + await expectRetryMain(repo, retryArgs, 1, noProgress) + await expectRetryMain(repo, [...retryArgs, "--force-retry"], 0, wantsOne) + } finally { + await fs.rm(repo, { recursive: true, force: true }) + } +} + +/** Minimal resumeGroup call: the caller sets status + retry flags. */ +type RetryFlags = { retryFailed?: boolean; forceRetry?: boolean } +interface RetryCall { + repo: string + statePath: string + group: OrchestratorGroup + extra: RetryFlags +} +function retryCallFor( + repo: string, + group: OrchestratorGroup, + extra: RetryFlags, +): RetryCall { + return { repo, statePath: writeState(repo, [group]), group, extra } +} +type RetryOutcome = Pick +/** Shared resumeGroup options for the --retry-failed tests. */ +const RETRY_GROUP_BASE = { + reviewMode: "deepseek-reviewer", + qaMode: "qa-agent", + reviewEnabled: false, + qaEnabled: false, + mode: "code", + maxReworkCycles: 3, + maxContinuations: 3, + forceReview: false, + dryRun: true, +} as const +async function runRetryGroup(c: RetryCall): Promise { + const lines: string[] = [] + const { repo, statePath, group } = c + const { retryFailed, forceRetry } = c.extra + const result = await resumeGroup({ + ...RETRY_GROUP_BASE, + repo, + statePath, + group, + retryFailed, + forceRetry, + write: (t) => lines.push(t), + }) + return { outcome: result.outcome, message: result.message } +} + +async function testRefusesDoneGroup(): Promise { + const repo = await tmpRepo() + try { + initGitRepo(repo) + const group = baseGroup({ status: "done" }) + const call = retryCallFor(repo, group, { retryFailed: true }) + const result = await runRetryGroup(call) + assert.equal(result.outcome, "error") + const msg = result.message + const note = `explicit refusal, got: ${msg}` + assert.ok(msg.includes("not terminal-failed"), note) + } finally { + await fs.rm(repo, { recursive: true, force: true }) + } +} + +async function testMissingWorktreeNeverSpawns(): Promise { + const repo = await tmpRepo() + try { + initGitRepo(repo) + // No worktree dir at all and no recorded branch that could be + // re-checked out: the retry must refuse, never spawn into the void. + const boom = "headlesscode: boom" + const group = baseGroup({ status: "failed", exit_code: 1, summary: boom }) + const branchless = { ...group, branch: undefined } + const flags = { retryFailed: true, forceRetry: true } + const call = retryCallFor(repo, branchless, flags) + const result = await runRetryGroup(call) + assert.equal(result.outcome, "orphaned") + } finally { + await fs.rm(repo, { recursive: true, force: true }) + } +} + // ─── resumeGroup real (non-dry-run) rebuild + cost recording (no LLM) ──────── async function testResumeGroupRebuildsAndRecordsCostWithoutReview(): Promise { @@ -1335,6 +1558,11 @@ const tests: Array<[string, () => Promise]> = [ ["resumeMain --dry-run: rebuild then review plan", testResumeMainDryRunRebuildThenReviewPlan], ["resumeMain --dry-run: reworks a recorded finding without re-review", testResumeMainDryRunReworksRecordedFinding], ["resumeMain --dry-run: plans a continuation on iteration exhaustion", testResumeMainDryRunPlansContinuation], + ["parseRetryFlags (#201)", testParseResumeArgsRetryFlags], + ["retryGenericFailure (#201)", testRetryFailedPlansContinuation], + ["retryEmptyWorktree (#201)", testRefusesEmptyWorktree], + ["retryDoneGroup (#201)", testRefusesDoneGroup], + ["retryMissingWorktree (#201)", testMissingWorktreeNeverSpawns], ["resumeGroup (real): rebuilds stale running → done and records cost", testResumeGroupRebuildsAndRecordsCostWithoutReview], ["resumeGroup --dry-run leaves state untouched", testResumeGroupDryRunLeavesStateUntouched], ["resumeGroup reports in-flight for a genuinely running group", testResumeGroupInFlightWhenWorkerRunning], diff --git a/src/orchestrator/cli.ts b/src/orchestrator/cli.ts index 42e16f7a..d7ec5729 100644 --- a/src/orchestrator/cli.ts +++ b/src/orchestrator/cli.ts @@ -1070,6 +1070,21 @@ export interface ContinuationDecision { * - At the cap: no spawn; the group is marked `needs-human` (a TERMINAL state, * deliberately distinct from `failed`). */ +export function continuationNote(forced: boolean, count: number): string { + const cause = forced + ? "operator retry" + : "previous session hit the iteration cap" + return `continuation ${count}: ${cause}; re-spawned worker on same worktree` +} + +export function canAutoContinue(group: OrchestratorGroup): boolean { + if (group.exit_code === 0) { + return false + } + return isIterationExhaustion(group.summary) + || isProviderFailure(group.summary) +} + export function handleIterationExhaustion( group: OrchestratorGroup, repo: string, @@ -1077,9 +1092,10 @@ export function handleIterationExhaustion( mode: string, model?: string, maxIterations?: number, + force?: boolean, ): ContinuationDecision { const current = typeof group.continuationCount === "number" ? group.continuationCount : 0 - if (group.exit_code === 0 || !(isIterationExhaustion(group.summary) || isProviderFailure(group.summary))) { + if (!force && !canAutoContinue(group)) { // Real failure — budget stops and every other exit reason stay // terminal. No patch: the watcher's "failed" stands. return { shouldSpawn: false, newContinuationCount: current, patch: {} } @@ -1116,7 +1132,7 @@ export function handleIterationExhaustion( continuationCount: newContinuationCount, // Fresh spawned timestamp: the stall guard must measure the // continuation worker, not the (possibly hours-old) attempt - // that hit the cap. + // behind it. spawned: now, // A fresh session starts clean: drop the previous attempt's // completion artifacts, review/QA records and stall flag. @@ -1132,7 +1148,10 @@ export function handleIterationExhaustion( // handleReviewVerdict's patch above. cost_recorded: undefined, last_activity: { - note: `continuation ${newContinuationCount}: previous session hit the iteration cap; re-spawned worker on the same worktree`, + note: continuationNote( + force === true, + newContinuationCount, + ), }, }, } diff --git a/src/orchestrator/resume.ts b/src/orchestrator/resume.ts index e937a5ee..9771a34d 100644 --- a/src/orchestrator/resume.ts +++ b/src/orchestrator/resume.ts @@ -34,6 +34,7 @@ import * as path from "node:path" import { createArgCursor } from "./arg-cursor.js" import { handleIterationExhaustion, + canAutoContinue, handleQaSessionError, handleQaVerdict, handleReviewSessionError, @@ -322,6 +323,7 @@ Options: --issue Resume the group(s) handling issue --pr Resume the group(s) for PR (state pr or branch match) --group Resume the group named (e.g. w1) + --retry-group Alias of --retry-failed --review-mode Review session mode (default: deepseek-reviewer) --no-review Skip the review step (QA/cost only) --qa Run a headless QA session after a clean review @@ -333,6 +335,19 @@ Options: --max-iterations Per-session iteration cap for spawned workers --memory-dir Phase 3 memory dir forwarded to spawned workers --force-review Re-review a group even if it already has a verdict + --retry-failed Operator retry (#201): force a continuation + spawn on terminal-failed groups (summary "not + feasible" or another non-exhaustion failure) even + when the failure is not the iteration cap or a + known provider failure. Known provider failures + (#121) auto-retry without this flag. A done group + or one with no salvageable progress (empty diff vs + the tracked upstream, no uncommitted changes) is + refused unless --force-retry is also given: retrying + a group that already settled spawns a worker that + repeats done work, and respawning an empty worktree + starts a continuation from scratch. + --force-retry Skip the salvageable-progress gate for --retry-failed --dry-run Print the pipeline plan, change nothing --help Show this help and exit ` @@ -351,6 +366,12 @@ export interface ResumeCliOptions { maxIterations?: number memoryDir?: string forceReview: boolean + /** Operator retry (#201): force a continuation spawn on + * terminal-failed groups even when the failure is not the + * iteration cap or a known provider failure. */ + retryFailed?: boolean + /** Skip the salvageable-progress gate for operator retries. */ + forceRetry?: boolean dryRun: boolean help: boolean } @@ -369,6 +390,8 @@ export function parseResumeArgs(argv: string[]): { options: ResumeCliOptions; er dryRun: false, forceReview: false, help: false, + retryFailed: false, + forceRetry: false, } const { rest, target, error } = parseTargetArgs(argv) if (error) { @@ -464,6 +487,13 @@ export function parseResumeArgs(argv: string[]): { options: ResumeCliOptions; er case "--force-review": options.forceReview = true break + case "--retry-failed": + case "--retry-group": + options.retryFailed = true + break + case "--force-retry": + options.forceRetry = true + break case "--dry-run": options.dryRun = true break @@ -1086,6 +1116,13 @@ export interface ResumeGroupOptions { maxIterations?: number memoryDir?: string forceReview: boolean + /** Operator override (#201): force a continuation spawn on a + * terminal-failed group even when its summary matches neither the + * iteration cap nor a known provider failure. The salvageable-progress + * gate still applies unless forceRetry is also set. */ + retryFailed?: boolean + /** Skip the salvageable-progress gate (explicit operator override). */ + forceRetry?: boolean dryRun: boolean write: (text: string) => void } @@ -1236,9 +1273,60 @@ export async function resumeGroup(opts: ResumeGroupOptions): Promise g.name === group.name) ?? group - return { outcome: "in-flight", group: updated, message: `continuation ${decision.newContinuationCount} spawned on ${group.name}` } + const spawned = `continuation ${decision.newContinuationCount} ` + + `spawned on ${group.name}` + return { outcome: "in-flight", group: updated, message: spawned } } if (decision.patch.status === "needs-human") { if (!dryRun) { @@ -1289,12 +1395,15 @@ export async function resumeGroup(opts: ResumeGroupOptions): Promise