diff --git a/bin/gstack-outside-voice b/bin/gstack-outside-voice index 381fbcd0a..68af3a6cb 100755 --- a/bin/gstack-outside-voice +++ b/bin/gstack-outside-voice @@ -4,7 +4,7 @@ * * gstack-outside-voice run --runner codex-cli|api|host-subagent --prompt --out * [--model ] [--result ] [--native-model ] [--fallback ] - * [--gate review|structured|spec|proposal] [--timeout-ms N] [--max-tokens N] [--cwd ] [--json] + * [--gate review|structured|spec|proposal|autoplan] [--timeout-ms N] [--max-tokens N] [--cwd ] [--json] * gstack-outside-voice runners [--model ] [--json] the runner table: capabilities and availability here * gstack-outside-voice family the model's family (same-family rule) * @@ -17,6 +17,7 @@ import * as fs from 'node:fs'; import * as path from 'node:path'; import { EXIT, exitTableHelp } from '../lib/headless-artifacts'; +import { RESULT_FORMAT_HEADER } from '../lib/autoplan-reconcile'; import { findingsLabel, type OutsideGate } from '../lib/outside-review-result'; import { RUNNER_IDS, createRunner, familyConflict, modelFamily, outsideStatusLine, runnerTable, selectRunner, type RunnerId } from '../lib/outside-voice-runner'; import { outsideConsent } from '../lib/outside-consent'; @@ -26,7 +27,7 @@ import { resultLine } from '../lib/result-codes'; const HELP = `gstack-outside-voice — one outside voice, three runners (docs/unattended.md) run --runner --prompt --out [--model ] [--result ] [--native-model ] - [--fallback ] [--gate review|structured|spec|proposal] [--timeout-ms N] [--max-tokens N] [--cwd ] [--json] + [--fallback ] [--gate review|structured|spec|proposal|autoplan] [--timeout-ms N] [--max-tokens N] [--cwd ] [--json] runners [--model ] [--json] the runner table: id, capabilities, available here family print the model family (anthropic, openai, google, ...) @@ -35,10 +36,14 @@ OPENAI_API_KEY/ANTHROPIC_API_KEY; needs --model), host-subagent (binds --result cross-family subagent the host ran; needs --model). --max-tokens caps the api runner's output (Anthropic default 16384; its default time limit grows with it); a response cut off at the limit is unavailable (truncated). --native-model enforces the same-family -rule. GSTACK_OUTSIDE_RUNNER names the fallback when --fallback is absent. -Prints OUTSIDE_STATUS: provider= model= family= and writes .meta.json. -codex_reviews=disabled (or an unreadable config) refuses every runner before it starts: -OUTSIDE_STATUS: not_run reason=consent_missing, exit 3. Enable: gstack-config set codex_reviews enabled. +rule. GSTACK_OUTSIDE_RUNNER names the fallback when --fallback is absent. --gate defaults to +autoplan (its INPUT receipt and gstack-findings fence) when the prompt carries gstack-autoplan's +RESULT FORMAT, else review. Writes .meta.json and prints a status line, for example + OUTSIDE_STATUS: provider= model= family= +codex_reviews=disabled (or an unreadable config) refuses every runner before it starts, exit 3, +with the status line + OUTSIDE_STATUS: not_run reason=consent_missing +Enable: gstack-config set codex_reviews enabled. ${exitTableHelp()}`; function flag(args: string[], name: string): string | undefined { @@ -76,8 +81,8 @@ async function main(argv: string[]): Promise { if (!isRunner(requested)) return usage(`--runner must be one of ${RUNNER_IDS.join(', ')}`); if (!promptFile || !outFile) return usage('run needs --prompt --out '); if (!fs.existsSync(promptFile)) return usage(`prompt file not found: ${promptFile}`); - const gate = (flag(rest, '--gate') ?? 'review') as OutsideGate; - if (!['review', 'structured', 'spec', 'proposal'].includes(gate)) return usage('--gate must be review, structured, spec or proposal'); + const gate = (flag(rest, '--gate') ?? (fs.readFileSync(promptFile, 'utf8').includes(RESULT_FORMAT_HEADER) ? 'autoplan' : 'review')) as OutsideGate; + if (!['review', 'structured', 'spec', 'proposal', 'autoplan'].includes(gate)) return usage('--gate must be review, structured, spec, proposal or autoplan'); const maxTokensText = flag(rest, '--max-tokens'); const maxTokens = maxTokensText === undefined ? undefined : Number(maxTokensText); if (maxTokens !== undefined && (!Number.isInteger(maxTokens) || maxTokens <= 0)) return usage('--max-tokens needs a positive integer'); diff --git a/changelog.d/capy-autoplan-second-model-review-not-unavailable.md b/changelog.d/capy-autoplan-second-model-review-not-unavailable.md new file mode 100644 index 000000000..3bc3e442b --- /dev/null +++ b/changelog.d/capy-autoplan-second-model-review-not-unavailable.md @@ -0,0 +1 @@ +- **A second-model plan review in `/autoplan` is no longer reported as unavailable when it actually ran (GST-3051).** `gstack-outside-voice run` judged autoplan's reviews by `/review`'s rule, which wants a `Recommendation: ... because ...` line autoplan never asks for, so a finished review printed `VERDICT: unavailable` (`missing_markers`) and sessions paid to re-run it or dropped it. A prompt that carries autoplan's result format is now checked against that format (its `INPUT:` line and `gstack-findings` fence; `--gate autoplan` asks for it explicitly), and a reply without them, or an empty one, is still unavailable. `gstack-outside-voice --help` also no longer prints a line that starts with `OUTSIDE_STATUS:`, which logs and models read as a real consent refusal. diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index ee35ecf7b..c58bf2564 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -386,7 +386,12 @@ it; `gstack-outside-voice run` sends that default to Anthropic only. **Meaning.** The answer did not contain what the gate checks: a `Recommendation: ... because ...` line (or a `## Recommendation` heading whose next non-blank line is a plain sentence with a `because` reason), a -`SCORE:`/`AMBIGUITIES:` pair, or severity tags. +`SCORE:`/`AMBIGUITIES:` pair, autoplan's `INPUT: ` line and +`gstack-findings` fence, or severity tags. `gstack-outside-voice run` judges a +prompt that carries autoplan's RESULT FORMAT by that format (`--gate autoplan`), +so an autoplan second-model review that reports `missing review completion +recommendation` came from a gstack older than that fix: read its result file +before re-running it. **Fix.** Re-run the review. diff --git a/lib/autoplan-prompts.ts b/lib/autoplan-prompts.ts index fc136627f..1abd7e09e 100644 --- a/lib/autoplan-prompts.ts +++ b/lib/autoplan-prompts.ts @@ -13,6 +13,7 @@ import * as fs from 'node:fs'; import * as path from 'node:path'; import { bunIsolationArgs } from './bun-isolation'; import { detectDocsOnly, readScopeMarker, scopeMarker, scopeTokens, type ScopeFlags, type UiEvidence } from './autoplan-scope'; +import { RESULT_FORMAT_HEADER } from './autoplan-reconcile'; import { COORDINATOR_CONTRACT } from './coordinator-contract'; import { capyBootstrapCommand } from './doctor-components'; import { DX_ERROR_COMPACT } from './dx-error-contract'; @@ -117,7 +118,7 @@ export function extractHeading(text: string, heading: string): string | undefine export const RESULT_FORMAT = (phase: string, sha256: string, resultPath: string) => ` --- -RESULT FORMAT (required by gstack-autoplan; the parent binds your file by this contract): +${RESULT_FORMAT_HEADER} 1. The first line of your result is exactly: INPUT: ${phase} ${sha256} 2. Write the complete review as prose, then END with one fenced block of canonical findings, one JSON object per line: \`\`\`gstack-findings diff --git a/lib/autoplan-reconcile.ts b/lib/autoplan-reconcile.ts index 9a7ed459d..45044e7d3 100644 --- a/lib/autoplan-reconcile.ts +++ b/lib/autoplan-reconcile.ts @@ -15,6 +15,8 @@ import type { FindingRow, Severity, Voice } from './headless-artifacts'; export const SEVERITIES: readonly Severity[] = ['Critical', 'High', 'Medium', 'Low', 'Informational']; +/** The RESULT FORMAT block's opening words (lib/autoplan-prompts.ts); a prompt that carries them asks for this contract. */ +export const RESULT_FORMAT_HEADER = 'RESULT FORMAT (required by gstack-autoplan; the parent binds your file by this contract):'; const SEVERITY_ALIASES: Record = { critical: 'Critical', p0: 'Critical', blocker: 'Critical', high: 'High', p1: 'High', major: 'High', @@ -49,8 +51,8 @@ export function severityOf(value: unknown): Severity | undefined { return SEVERITY_ALIASES[value.trim().toLowerCase()]; } -/** Parse a reviewer's result: the INPUT receipt for this phase and snapshot, then the canonical findings fence(s). */ -export function parseReviewResult(text: string, expected: { phase: string; sha256: string }): ParsedReviewResult { +/** Parse a reviewer's result: the INPUT receipt for this phase and snapshot (any, without expected), then the canonical findings fence(s). */ +export function parseReviewResult(text: string, expected?: { phase: string; sha256: string }): ParsedReviewResult { const errors: string[] = []; const receipt = parseReceipt(text, expected); if (!receipt.ok) errors.push(receipt.error!); @@ -59,12 +61,13 @@ export function parseReviewResult(text: string, expected: { phase: string; sha25 return { receipt, findings, fenceFound, errors }; } -/** The full-read receipt: `INPUT: ` in the first five non-empty lines, matching this phase and snapshot. */ -export function parseReceipt(text: string, expected: { phase: string; sha256: string }): ParsedReviewResult['receipt'] & { present: boolean; error?: string } { +/** The full-read receipt: `INPUT: ` in the first five non-empty lines, matching this phase and snapshot when expected is given. */ +export function parseReceipt(text: string, expected?: { phase: string; sha256: string }): ParsedReviewResult['receipt'] & { present: boolean; error?: string } { const head = text.split('\n').map(l => l.trim()).filter(Boolean).slice(0, 5); const receiptLine = head.find(l => /^INPUT:\s*\S+\s+[0-9a-f]{64}\b/i.test(l)); const m = receiptLine ? /^INPUT:\s*(\S+)\s+([0-9a-f]{64})/i.exec(receiptLine) : null; if (!m) return { ok: false, present: false, error: 'no INPUT: line in the first five lines' }; + if (!expected) return { ok: true, present: true, phase: m[1]!.toLowerCase(), sha256: m[2]!.toLowerCase(), line: receiptLine }; const ok = m[1]!.toLowerCase() === expected.phase && m[2]!.toLowerCase() === expected.sha256.toLowerCase(); return { ok, present: true, phase: m[1]!.toLowerCase(), sha256: m[2]!.toLowerCase(), line: receiptLine, ...(ok ? {} : { error: `receipt names ${m[1]} ${m[2]!.slice(0, 12)}…, expected ${expected.phase} ${expected.sha256.slice(0, 12)}…` }) }; diff --git a/lib/claude-code-migration.ts b/lib/claude-code-migration.ts index 31c7da30f..1c04fd4de 100644 --- a/lib/claude-code-migration.ts +++ b/lib/claude-code-migration.ts @@ -11,7 +11,7 @@ const BANNER = '