diff --git a/bin/gstack-review-dispatch b/bin/gstack-review-dispatch index 4b96e12be..551b61005 100755 --- a/bin/gstack-review-dispatch +++ b/bin/gstack-review-dispatch @@ -23,7 +23,8 @@ import * as fs from 'node:fs'; import * as path from 'node:path'; import { EXIT, exitTableHelp } from '../lib/headless-artifacts'; import { BRIEF_ROLES, BriefError, briefFile, checkReviewedTree, checkoutRoot, checkoutTree, promptHash, renderBrief, sectionTexts, sliceDiff, sliceNote, withWorkspace, type BriefRole, type Slots, type TreeCheck } from '../lib/review-brief'; -import { cleanMarkers, collect, fixableRaises, mayBeUnavailable, parseReply, readJsonl, readLedger, readerKey, recordJudgment, recordSent, appendEvent, verify, type JudgedLine, type MergedLine, type VerdictCheck, type VerifyRow } from '../lib/review-ledger'; +import { cleanMarkers, collect, fixableRaises, mayBeUnavailable, outsideVoiceRecord, parseReply, readJsonl, readLedger, readerKey, recordJudgment, recordSent, appendEvent, verify, type JudgedLine, type MergedLine, type VerdictCheck, type VerifyRow } from '../lib/review-ledger' +import { outsideProvenance, sameFamily } from '../lib/outside-voice-record'; import { SLICE_CAP, listSha, planNote, planSlices, selectionNames, sliceMembers, sliceOf, sliceSelection, verifySlices } from '../lib/review-slices'; import { buildManifest, checklistFile, chunkCount, chunkOf, manifestPath, markReader, planCyberRetry, readManifest, renderStage, withAuditModel, writeManifest, STAGES, type Extra, type Manifest, type PassReader, type ReaderState, type Stage } from '../lib/review-pass'; import { classifyOutsideReview } from '../lib/outside-review-result'; @@ -61,6 +62,10 @@ const HELP = `gstack-review-dispatch — verbatim reviewer briefs and loss-free sent --ledger --role [--name ] --sent the exact prompt a dispatch passed: BRIEF_SENT: … match, or BRIEF_MISMATCH: … (exit 1; the pass is not reviewed) collect --ledger --role [--name ] --output --merged [--manifest ] + [--outside-model --outside-provider

--native-model ] (the outside voice only) + the outside voice's provenance comes from those flags or else its reply's closing OUTSIDE_STATUS: line (model=, provider=); + the family always comes from the model id. A read in the native model's family is COLLECT_SAME_FAMILY (exit 1, nothing + merged): never outside coverage (GST-4140) the reader's raw output: hashes it and appends each finding to merged.jsonl with its label as written. A reply with no finding must carry its brief's clean marker (NO FINDINGS; the Recommendation: line for the voices); without one it is COLLECT_NOT_REVIEWED (exit 1): a refusal, an empty reply or a reader that never saw the diff, and verify reports NOT_COLLECTED @@ -75,6 +80,10 @@ const HELP = `gstack-review-dispatch — verbatim reviewer briefs and loss-free JUDGMENT_REJECTED: dropped=… downgraded=… (exit 1). An empty merged.jsonl needs no judged file: judge writes an empty one and prints JUDGMENT: ok nothing to judge; a merge with findings and no judged file is refused (exit 2) verify --ledger [--targeted-out ] + on a clean ledger prints OUTSIDE_VOICE_RECORD: {"status","provider","model","family"[,"native_family"][,"reason"]} for the last + collected outside voice (gstack-ship-receipt write --outside-voice takes it; completed only for a recognized family beside a + different recognized native family, else unavailable with the reason); a dirty ledger prints OUTSIDE_VOICE_RECORD_WITHHELD + instead. A same-family outside read is OUTSIDE SAME_FAMILY, dirty BRIEF, OUTPUT and JUDGE rows from the ledger alone, then VERIFY: clean (exit 0), VERIFY: dirty (exit 1) or VERIFY: no brief records (exit 3: this run's ledger kept no prompts). A ledger with a targeted brief also prints TARGETED_RECORD: and --targeted-out writes it as the JSON gstack-ship-receipt write --review-targeted reads; under @@ -669,6 +678,14 @@ function main(): number { const unavailable = flag('--unavailable'); if (unavailable !== undefined && !mayBeUnavailable(reader)) { process.stderr.write(`gstack-review-dispatch collect: --unavailable is for the outside voice only; ${reader}'s missing coverage leaves the review incomplete, never clean\n`); return EXIT.usage; } if (unavailable !== undefined && !unavailable.trim()) { process.stderr.write('gstack-review-dispatch collect: --unavailable needs a reason\n'); return EXIT.usage; } + const voiceFlags = ['--outside-model', '--outside-provider', '--native-model'].filter(f => flag(f) !== undefined); + if (voiceFlags.length && !mayBeUnavailable(reader)) { process.stderr.write(`gstack-review-dispatch collect: ${voiceFlags.join(', ')} record the outside voice's provenance; ${reader} is not the outside voice\n`); return EXIT.usage; } + const outside = mayBeUnavailable(reader) ? outsideProvenance({ model: flag('--outside-model'), provider: flag('--outside-provider'), nativeModel: flag('--native-model'), output }) : undefined; + const same = outside && unavailable === undefined ? sameFamily(outside) : undefined; + if (same) { + process.stdout.write(`COLLECT_SAME_FAMILY: reader=${reader} model=${outside!.model} family=${outside!.family} native=${outside!.native_model} (${same}: a same-family fallback is one voice, never outside coverage; nothing was merged. Rerun the outside voice on another family. When no other family can read it, record the missing second-model read by collecting a file that holds only the reason, not this reply (--unavailable refuses output that holds findings), with --unavailable '')\n`); + return EXIT.fail; + } const asked = readLedger(ledger).filter(e => e.event === 'rendered' && e.reader === reader).at(-1)?.verdict === 1; const held = () => parseReply(reader, output, true, asked).findings.length; if (unavailable !== undefined && held()) { process.stderr.write(`gstack-review-dispatch collect: ${reader}'s output holds findings; collect it without --unavailable so none is lost\n`); return EXIT.usage; } @@ -676,14 +693,14 @@ function main(): number { const tree = unavailable === undefined && rendered && 'tree' in rendered ? checkReviewedTree(output, typeof rendered.tree === 'string' ? rendered.tree : null) : undefined; if (tree && !tree.ok && mayBeUnavailable(reader) && !held()) { const why = `reviewed another tree: reported ${tree.reported}, expected ${tree.expected}`; - const r = collect(ledger, reader, output, merged, path.resolve(outFile!), why); + const r = collect(ledger, reader, output, merged, path.resolve(outFile!), why, undefined, true, outside); process.stdout.write(`COLLECT_UNAVAILABLE: reader=${reader} sha256=${r.sha} reason=${JSON.stringify(why)} (missing outside coverage: unavailable, never clean)\n`); return EXIT.ok; } const mf = flag('--manifest'); let plan: ReturnType | undefined; try { plan = mf ? readManifest(mf) : undefined; } catch (e) { process.stderr.write(`gstack-review-dispatch collect: ${(e as Error).message}; native FIXABLE collects as CRITICAL\n`); } - const r = collect(ledger, reader, output, merged, path.resolve(outFile!), unavailable, tree, fixableRaises(plan && path.resolve(plan.ledger) === path.resolve(ledger) ? plan.plan_lines : undefined)); + const r = collect(ledger, reader, output, merged, path.resolve(outFile!), unavailable, tree, fixableRaises(plan && path.resolve(plan.ledger) === path.resolve(ledger) ? plan.plan_lines : undefined), outside); if (tree && !tree.ok) { if (mf && plan) { markReader(plan, reader, 'failed', { output: outFile, error: `reviewed another tree: ${tree.reported}` }); writeManifest(mf, plan); } process.stdout.write(wrongTree(reader, tree)); @@ -734,6 +751,8 @@ function main(): number { if (sel && 'mixed' in sel) process.stdout.write(`REVIEW_EXCLUDE_RECORD: mixed digests=${sel.mixed.join(',')} (readers read different review_exclude_paths selections; rerun the review so every reader reads HEAD's)\n`); for (const r of slices) process.stdout.write(`${r.kind} ${r.reader} ${r.status} ${r.detail}\n`); const clean = v.clean && !(sel && 'mixed' in sel) && slices.every(r => r.status === 'MATCH'); + const voice = outsideVoiceRecord(ledger); + if (voice) process.stdout.write(clean ? `OUTSIDE_VOICE_RECORD: ${JSON.stringify(voice)}\n` : 'OUTSIDE_VOICE_RECORD_WITHHELD: VERIFY is dirty, so the outside voice\'s record does not bind; fix the rows above and verify again\n'); if (v.verdicts.asked) process.stdout.write(`VERIFY_VERDICT: agree=${v.verdicts.agree} asked=${v.verdicts.asked} (informational: a disagreeing count already counts its blockers; docs/review-policy.md#verdict-line)\n`); process.stdout.write(`VERIFY: ${clean ? 'clean' : 'dirty'} briefs=${v.briefs} outputs=${v.rows.filter(r => r.kind === 'OUTPUT').length} voided=${v.voided}${v.unavailable ? ` unavailable=${v.unavailable}` : ''}\n`); return clean ? EXIT.ok : EXIT.fail; diff --git a/bin/gstack-ship-receipt b/bin/gstack-ship-receipt index 326944111..6d69cce72 100755 --- a/bin/gstack-ship-receipt +++ b/bin/gstack-ship-receipt @@ -7,7 +7,7 @@ * [--session-kind ] [--artifacts-consumed /] [--run ] [--thread ] * [--receipt ] [--policy

]... - * [--base-red ] + * [--base-red ] [--outside-voice ] * [--out ] [--body ] [--json] * gstack-ship-receipt read --pr [--repo ] [--check-prose] [--json] * gstack-ship-receipt read --body [--json] @@ -161,6 +161,10 @@ write flags: --pr --head --base --version --gated-tree --predecessor --gate (a JSON array of {class, reason, evidence}: each routine stop the run recorded and went on past, class one of test-timeout-fix, pregate-flake-rerun, autoplan-regate; gstack-no-stop refuses the retired scoped-fix-check); recorded as no_stop. + --outside-voice (gstack-review-dispatch verify's OUTSIDE_VOICE_RECORD: {status, provider, model, family}, its JSON or + text holding the line, such as verify's whole output): recorded as outside_voice; status completed, unavailable or skipped. A + completed read needs a recognized family and a different recognized native_family; anything else completed is RECEIPT_INVALID. + Missing coverage is unavailable or skipped, never blocking (GST-4140). --declare-risk (the same list gstack-review-plan --declare-risk took): joins review_depth's risk and only raises its depth; review_depth.declared and .detected record both lists (GST-1129). An unknown class is RECEIPT_INVALID. --platform-review (NEXT: platform's PLATFORM_REVIEW: id): records review_depth platform with capy-ai[bot]'s review at HEAD; @@ -193,6 +197,19 @@ function jsonArg(raw: string | undefined): Record | undefined { if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) throw new Error('expected a JSON object'); return parsed; } +/** + * --outside-voice: verify's OUTSIDE_VOICE_RECORD: JSON (one line or pretty-printed), or text holding its OUTSIDE_VOICE_RECORD: line + * such as verify's whole output, or @ holding either (GST-4140); validateReceipt checks it. + */ +function outsideVoiceArg(raw: string | undefined): ShipReceipt['outside_voice'] { + if (raw === undefined) return undefined; + const text = (raw.startsWith('@') ? fs.readFileSync(raw.slice(1), 'utf8') : raw).trim(); + const parse = (s: string) => { try { return { v: JSON.parse(s) }; } catch { return undefined; } }; + const line = text.split('\n').map(l => l.trim()).filter(l => l.startsWith('OUTSIDE_VOICE_RECORD:')).at(-1); + const got = parse(text) ?? (line === undefined ? undefined : parse(line.slice('OUTSIDE_VOICE_RECORD:'.length).trim())); + if (got) return got.v; + throw new Error(`--outside-voice expects the JSON gstack-review-dispatch verify prints after OUTSIDE_VOICE_RECORD: ({"status","provider","model","family"}), or text holding that line; verify prints it only when VERIFY is clean. Got ${JSON.stringify(text.slice(0, 120))}`); +} /** --no-stop : the routine stops this run recorded and went on past (K1), a JSON array of {class, reason, evidence}. */ function noStopArg(raw: string | undefined): ShipReceipt['no_stop'] { if (raw === undefined) return undefined; @@ -411,6 +428,7 @@ async function cmdWrite(rest: string[], json: boolean): Promise { review_exclude_fallback: receiptExcludeFallback(review.exclude), docs_audit_read: excludeBound.read, no_stop: noStopArg(flag(rest, '--no-stop')), + outside_voice: outsideVoiceArg(flag(rest, '--outside-voice')), }; } catch (e: any) { process.stderr.write(`gstack-ship-receipt write: ${e.message}\n`); return EXIT.usage; } if (input.pr !== undefined && !Number.isInteger(input.pr)) { process.stderr.write('gstack-ship-receipt write: --pr must be an integer\n'); return EXIT.usage; } diff --git a/changelog.d/second-model-review-final-fixes-gst4140.md b/changelog.d/second-model-review-final-fixes-gst4140.md new file mode 100644 index 000000000..c32f6bba6 --- /dev/null +++ b/changelog.d/second-model-review-final-fixes-gst4140.md @@ -0,0 +1 @@ +**A code or gate pull request now gets a second-model review of the code its fixes changed, and every second-model review records which model family did it.** Before, once `/gstack-ship`'s first second-model review had run, a later full review pass and the read-only final review skipped it, so a pull request whose first pass took fixes could ship with no second-model read of its final head. Now a later full pass on code or gate changes lists the second-model review again (unless its fixes changed no runtime lines), and the read-only final review lists both the native adversarial review and the second-model review. `gstack-review-dispatch collect` refuses a second-model review from the author's own model family (for example a Claude reader checking Claude's work) and records the provider, model and family of every one; a review counts as completed only when its model's family and the author's family are both recognized and differ. `verify` prints `OUTSIDE_VOICE_RECORD:` only when the review record is clean, and `gstack-ship-receipt write --outside-voice` can record it in the receipt, refusing a same-family completed review (`/gstack-ship` does not pass that flag yet). A second-model review that could not run (Codex down, disabled, rate-limited or refused) is still recorded as unavailable and never blocks shipping. Docs and tests changes and light reviews are unchanged. diff --git a/docs/review-policy.md b/docs/review-policy.md index 77dcb7e79..da3355a91 100644 --- a/docs/review-policy.md +++ b/docs/review-policy.md @@ -238,7 +238,7 @@ rows, `claim`) was removed in GST-3562 part 4. | none | full pass 1 on the whole diff | | a full pass with no edits | done | | a full pass (`--last full`) with no fix flag, when the PR has its own unreviewed runtime commits since `--range-base` | stop: `review_required_no_readers` (exit 3), not done; see [troubleshooting](troubleshooting.md#review-required-no-readers) | -| a full pass that fixed a blocking finding, below the cap, on a diff below full depth with a fix range of at most 150 runtime lines | full pass on the range (never a scoped pass, GST-3562), with the Red Team and, when the range changes runtime lines, the native adversarial pass again | +| a full pass that fixed a blocking finding, below the cap, on a diff below full depth with a fix range of at most 150 runtime lines | full pass on the range (never a scoped pass, GST-3562), with the Red Team and, when the range changes runtime lines, the native adversarial pass again and, on code or gate class, the outside voice (GST-4140) | | a full pass that fixed a blocking finding, below the cap (full depth, a larger range, or a range or depth it could not read) | full pass on the range | | a full pass whose fix touched a gate-class path, below the cap | full pass on the range | | a full pass that fixed only below-floor findings | full pass on the range (round 2; GST-3562 A plans no new fix-check) | @@ -271,7 +271,8 @@ as the depth counts them: `gstack-review-plan --range-base $PASS_HEAD` prints scoped pass ran: a full-effort Red Team that excludes nothing, the native adversarial pass again when the range changes runtime lines (even after Step 11 ran it), every force-included specialist, the outside voice when published -numbers changed, and Step 11's voices that have not run yet. The driver's +numbers changed (and, on code or gate class, whenever the range changes runtime +lines, GST-4140), and Step 11's voices that have not run yet. The driver's `--diff-base RANGE_BASE` sets every reader's base except the targeted reader's and, before Step 11 has run (no `--adversarial-ran`), the native adversarial's and the outside voice's, which keep the merge base and read the whole PR. The range holds only @@ -562,11 +563,29 @@ counts and score, rate or speed claims (`NUMBERS: yes`). The claims' fingerprint (`fingerprint=`) is passed back as `--reviewed-numbers`; when a later fix changes a claim, only the outside voice reruns, on the numbers. It always reads the whole diff. -**The adversarial and outside voices run once per invocation** (Step 11, on the -final tree), as the last full-pass plan lists them; after they ran, decision 2 -passes `--adversarial-ran` so a repeat lists them no more. Later full passes rerun the -specialists on the range only. Step 11.5 binds a planned skip through the Step 9 -record's `CURRENT` freshness instead of a native record. +**The adversarial and outside voices run in Step 11** (on the final tree), as the +last full-pass plan lists them; after they ran, decision 2 passes `--adversarial-ran`. +What a later full pass lists then depends on the class (GST-4140), so a code or gate +PR never ships with no second-model read of the code its fixes changed: + +- **Code or gate class at standard or full depth, pass 2 and later:** the outside + voice is listed again, because the fixes changed code it has not read. The native + adversarial is not, unless the pass reads the readers of a small fix range + (`rangeReaders`, a range with runtime lines). A fix range with no runtime lines + keeps the earlier outside read (`SKIP: outside-voice (run once per invocation: the + fix range changes no runtime lines)`), and changed published numbers still add it. +- **Code or gate class, the read-only final review** (R51's one full review of the + whole PR diff at the final head): both voices are listed again. +- **Docs or tests class, and light depth:** unchanged. The voices are not listed + again (`run once per invocation`); the outside voice reruns only when a published + number changes. + +Later full passes rerun the specialists on the range only. Step 11.5 binds a planned +skip through the Step 9 record's `CURRENT` freshness instead of a native record. +An outside voice from the lane's own model family is never outside coverage: +`gstack-review-dispatch collect` refuses it and records the family of every +outside read, and on a clean ledger `verify` prints `OUTSIDE_VOICE_RECORD:` for the receipt +([ship-policy.md](ship-policy.md#the-ship-receipt)). **Effort.** The core checklist, the Red Team, the native adversarial pass and fix-checks run at `full` effort (the lane's reasoning); specialists run at @@ -1211,7 +1230,12 @@ ones, and the arm lost blockers. `bin/gstack-review-dispatch` closes both ends: as missing coverage (`COLLECT_UNAVAILABLE`); an empty reason or an output that holds findings is refused (exit 2), so a partial answer is collected normally and loses nothing. Verify prints its brief and output `UNAVAILABLE` and `unavailable=N` on the verdict line, and its coverage is logged `unavailable` in the review-log row; any other reader is refused (exit 2), because its - missing coverage leaves the review incomplete. A mismatched send re-sent + missing coverage leaves the review incomplete. Collect also records who read the outside voice (GST-4140): the model and + provider from `--outside-model` and `--outside-provider`, or else from the reply's closing `OUTSIDE_STATUS:` line, the lane's + model from `--native-model`, and each family from its model id. A read in the native model's family is `COLLECT_SAME_FAMILY` + (exit 1, nothing merged), and a ledger that holds one anyway prints an `OUTSIDE SAME_FAMILY` row and is dirty. On a + clean ledger verify prints `OUTSIDE_VOICE_RECORD:` for `gstack-ship-receipt write --outside-voice` + ([ship-policy.md](ship-policy.md#the-ship-receipt)), and `OUTSIDE_VOICE_RECORD_WITHHELD:` instead on a dirty one. A mismatched send re-sent byte-exact before anything was collected is void and counted (`voided=N` on the verdict line); one that produced an output stays `MISMATCH`. Then output hashes against the merged lines they produced, and each merged line against the finding collect diff --git a/docs/ship-policy.md b/docs/ship-policy.md index ca6f2ae42..cad039c11 100644 --- a/docs/ship-policy.md +++ b/docs/ship-policy.md @@ -1334,7 +1334,7 @@ The ```` ```gstack-ship-receipt ```` block is the handoff record: identifiers first (`pr`, `head`, `version`, `base`), then the evidence (`gate`, `ci`, `head_tree`, `product_patch_id`, `gstack_version`, `review_depth`, `pregate`, `issues`, `approval`, `docs`, `review_loop`, `review_loop_exception`, `design`, -`carry`, `no_stop`), validated +`carry`, `no_stop`, `outside_voice`), validated against the `ship-receipt` schema (`gstack-artifact schema ship-receipt`) and read back by `gstack-ship-receipt read`, `result`, `carry` and the queue. Since GST-3562 (H), write and the queue's binding check need none of the @@ -1356,6 +1356,30 @@ and `read`, `result`, `gstack-ship-queue ready`, `train build` and `verify but no version source records no `version` at all (the audit still says what it looked for); pass `--version` to name one. +**`outside_voice`.** The second-model read the review ran, from +`gstack-ship-receipt write --outside-voice ''`, where the JSON is the line +`gstack-review-dispatch verify` prints after `OUTSIDE_VOICE_RECORD:` (the line +itself is accepted too, as is `@`): `{ status, provider, model, family }`, with +`native_family` when the lane's family is known and `reason` for missing coverage. +`status` is `completed` (a review the outside model returned), `unavailable` +(Codex or the host reader was down, disabled, rate-limited or refused under +`cyber_policy` on every attempt) or `skipped` (the review plan listed no outside +voice). A `completed` record needs the family its model id names (a bare router +prefix such as `bedrock/` names none) and a recognized `native_family` that +differs; a same-family fallback (a Claude reader beside a Claude lane), an +unrecognized family or a missing native family is `RECEIPT_INVALID` and nothing +is written. Missing coverage never blocks: record it as `unavailable` or +`skipped`, never as a completed read by the lane's own family. `verify` itself +reports an outside read it cannot prove cross-family (no model from +`--outside-model` or the reply's closing `OUTSIDE_STATUS:` line, or no +`--native-model`) as `unavailable`, so its record always binds, and it prints +the record only when `VERIFY` is clean (`OUTSIDE_VOICE_RECORD_WITHHELD:` +otherwise). `--outside-voice` also takes pretty-printed JSON or `verify`'s whole +output. The field is +optional, so receipts written before it stay valid, and `/gstack-ship`'s Step 19 +write does not pass `--outside-voice` yet: a receipt carries it only when the run +passes the flag (GST-4140). + **`design`.** On a rendered-UI diff (`gstack-diff-scope` reports `SCOPE_FRONTEND=true` for the committed range, which counts CSS, views, components and, since GST-1718, Lit or htm tagged templates in .ts/.js files diff --git a/lib/capy-review-pass.js b/lib/capy-review-pass.js index defc9e290..01b0c9bf5 100644 --- a/lib/capy-review-pass.js +++ b/lib/capy-review-pass.js @@ -103,7 +103,11 @@ const briefText = async (r) => { }; const roleArgs = (r) => ' --role ' + q(r.role) + (r.name ? ' --name ' + q(r.name) : '') + (r.slice ? ' --slice ' + r.slice.index + '/' + r.slice.total : ''); const REASONING = { medium: 'medium', light: 'low' }; -const family = (id) => (typeof id === 'string' && id.includes('/') ? id.slice(0, id.indexOf('/')).toLowerCase() : ''); +const FAMILY_ALIASES = { particle: 'deepseek', 'particle-ai': 'deepseek', moonshotai: 'moonshot', 'meta-llama': 'meta', mistralai: 'mistral', alibaba: 'qwen' }; +const family = (id) => { + const prefix = typeof id === 'string' && id.includes('/') ? id.slice(0, id.indexOf('/')).toLowerCase() : ''; + return FAMILY_ALIASES[prefix] || prefix; +}; const DEFAULT_OUTSIDE = { model_id: 'openai/gpt-6.2-sol', reasoning_mode: 'medium' }; const voiceFile = input.out.replace(/\/+$/, '') + '/voice-models.json'; let voices = { laneModel: null, readers: {} }; @@ -132,12 +136,19 @@ const familyStop = (readers) => { } return null; }; +const voiceArgs = (m, r) => { + if (r.role !== 'outside-voice') return ''; + const native = m.readers.find((x) => x.role === 'adversarial-native'); + const nm = voices.laneModel || input.laneModel || (native && modelOf(native) ? modelOf(native).model_id : undefined); + const om = modelOf(r); + return (om ? ' --outside-model ' + q(om.model_id) + ' --outside-provider host-subagent' : '') + (nm ? ' --native-model ' + q(nm) : ''); +}; const safe = (s) => s.replace(/[^a-zA-Z0-9._-]/g, '_'); const UNAVAILABLE = 'unavailable: '; const recordUnavailable = async (m, r, why) => { const file = m.out + '/out/' + safe(r.reader) + '.unavailable.txt'; await tools.capy.write({ path: file, content: 'outside voice (' + modelOf(r).model_id + ') ' + why + '\n' }); - const c = await sh(bin + ' collect --ledger ' + q(m.ledger) + roleArgs(r) + ' --output ' + q(file) + ' --merged ' + q(m.merged) + ' --manifest ' + q(mf) + ' --unavailable ' + q(why)); + const c = await sh(bin + ' collect --ledger ' + q(m.ledger) + roleArgs(r) + voiceArgs(m, r) + ' --output ' + q(file) + ' --merged ' + q(m.merged) + ' --manifest ' + q(mf) + ' --unavailable ' + q(why)); if (c.code !== 0) return stop('collect --unavailable ' + r.reader + ' exited ' + c.code + ': ' + c.out.slice(-500)); lines.push(c.out.trim()); await mark(r.reader, 'collected', { output: file, error: UNAVAILABLE + why }); @@ -272,7 +283,7 @@ try { await tools.capy.write({ path: file, content: g.summary }); if (ended) { const why = (hostError && cyberWhy(hostError)) || t.status + ' before finishing its review'; - const u = await sh(bin + ' collect --ledger ' + q(m.ledger) + roleArgs(r) + ' --output ' + q(file) + ' --merged ' + q(m.merged) + ' --manifest ' + q(mf) + ' --unavailable ' + q(why)); + const u = await sh(bin + ' collect --ledger ' + q(m.ledger) + roleArgs(r) + voiceArgs(m, r) + ' --output ' + q(file) + ' --merged ' + q(m.merged) + ' --manifest ' + q(mf) + ' --unavailable ' + q(why)); if (u.code === 0) { if (hostError) await refusal(m, r, hostError); lines.push(u.out.trim()); @@ -281,7 +292,7 @@ try { } } const c = await sh(r.prompt_file ? bin + ' mark --manifest ' + q(mf) + ' --reader ' + q(r.reader) + ' --state collected --output ' + q(file) - : bin + ' collect --ledger ' + q(m.ledger) + roleArgs(r) + ' --output ' + q(file) + ' --merged ' + q(m.merged) + ' --manifest ' + q(mf)); + : bin + ' collect --ledger ' + q(m.ledger) + roleArgs(r) + voiceArgs(m, r) + ' --output ' + q(file) + ' --merged ' + q(m.merged) + ' --manifest ' + q(mf)); if (c.code !== 0) return stop((r.prompt_file ? 'mark ' : 'collect ') + r.reader + ' exited ' + c.code + ': ' + c.out.slice(-500)); if (!r.prompt_file) { lines.push(c.out.trim()); diff --git a/lib/headless-artifacts.ts b/lib/headless-artifacts.ts index 63404a634..53f7b5e8e 100644 --- a/lib/headless-artifacts.ts +++ b/lib/headless-artifacts.ts @@ -152,6 +152,8 @@ export interface ShipReceipt { docs_audit_read?: { paths: string[]; reviewer: string; packet_sha256: string }; /** Routine stops the run recorded and went on past instead of waiting for a Captain (plan K1; GSTA-258 L5 writes them): one record per stop. */ no_stop?: Array<{ class: NoStopClass; reason: string; evidence: string }>; + /** The second-model read (lib/outside-voice-record.ts, GST-4140): completed only by a recognized family other than native_family; missing coverage is unavailable or skipped. */ + outside_voice?: { status: 'completed' | 'unavailable' | 'skipped'; provider: string; model: string; family: string; native_family?: string; reason?: string }; } export const NO_STOP_CLASSES = ['scoped-fix-check', 'test-timeout-fix', 'pregate-flake-rerun', 'autoplan-regate'] as const; export type NoStopClass = typeof NO_STOP_CLASSES[number]; @@ -290,6 +292,7 @@ export const ARTIFACT_SCHEMAS = { review_exclude: { type: 'object', required: ['source', 'patterns', 'applied', 'excluded', 'excluded_bytes', 'kept', 'gate_tagged', 'patterns_sha256', 'list_sha256', 'digest'], properties: { source: str, patterns: strList, applied: strList, excluded: { type: 'integer', minimum: 0 }, excluded_bytes: { type: 'integer', minimum: 0 }, kept: { type: 'integer', minimum: 0 }, gate_tagged: strList, patterns_sha256: str, list_sha256: str, digest: str } }, review_exclude_fallback: { type: 'object', required: ['source', 'errors'], properties: { source: str, errors: strList } }, docs_audit_read: { type: 'object', required: ['paths', 'reviewer', 'packet_sha256'], properties: { paths: strList, reviewer: str, packet_sha256: str } }, + outside_voice: { type: 'object', required: ['status', 'provider', 'model', 'family'], properties: { status: { enum: ['completed', 'unavailable', 'skipped'] }, provider: str, model: str, family: str, native_family: str, reason: str } }, // Legacy (GST-3562 part 4): receipts written before fix-check and round grants were removed may carry these; nothing reads them. review_loop_exception: { type: 'object' }, review_round_grants: { type: 'array' }, cleared_by_grant: { type: 'object' }, cleared_by_trailer: { type: 'array', items: { type: 'object', required: ['id', 'commit', 'review'], properties: { id: str, commit: str, review: str } } }, diff --git a/lib/outside-voice-record.ts b/lib/outside-voice-record.ts new file mode 100644 index 000000000..2d86ae3ec --- /dev/null +++ b/lib/outside-voice-record.ts @@ -0,0 +1,82 @@ +/** + * The outside voice's record (GST-4140): which provider and model read the diff, its family, and whether that read counts as + * second-model coverage. gstack-review-dispatch collect records it on the outside voice's output event and refuses a + * same-family read, verify prints it as OUTSIDE_VOICE_RECORD:, and gstack-ship-receipt write binds it as the receipt's + * outside_voice. A same-family fallback is one voice, never outside coverage; missing coverage is recorded as unavailable or + * skipped and never blocks. + */ +import { familyConflict, modelFamily, type ModelFamily } from './outside-voice-runner'; + +/** The reason verify records a completed outside read whose model family was never recorded: not proven second-model coverage. */ +export const UNPROVEN_FAMILY = 'the outside read recorded no recognizable model family, so it is not proven second-model coverage'; +/** The reason verify records a completed outside read with no recognized native family to compare it to: not proven a second family. */ +export const UNPROVEN_NATIVE = 'the outside read recorded no recognizable native model family (collect --native-model), so it is not proven a second family'; + +export const OUTSIDE_VOICE_STATUSES = ['completed', 'unavailable', 'skipped'] as const; +export type OutsideVoiceStatus = typeof OUTSIDE_VOICE_STATUSES[number]; +export interface OutsideVoiceRecord { status: OutsideVoiceStatus; provider: string; model: string; family: ModelFamily | string; native_family?: ModelFamily | string; reason?: string } +/** Who read: recorded on a collected outside voice's output event. */ +export interface OutsideProvenance { provider: string; model: string; family: ModelFamily | string; native_model?: string; native_family?: ModelFamily | string } + +/** + * A model id's family: lib/outside-voice-runner.ts's rules on the whole id, then on its last path segment (a router prefix such as + * `openrouter/anthropic/claude-…` keeps Claude's family); `unknown` otherwise. A bare provider prefix never names a family: a router + * (`bedrock/anthropic.claude-…`) would read as a second family. + */ +export function familyOf(model: string | undefined | null): string { + const id = (model ?? '').trim().toLowerCase(); + const own = modelFamily(id); + return own !== 'unknown' ? own : modelFamily(id.split('/').at(-1)); +} + +/** + * The reply's closing `OUTSIDE_STATUS: provider=

model= …` line (bin/gstack-outside-voice prints it last); undefined + * when the last non-empty line is anything else, so a status line quoted inside the review text never counts. + */ +export function parseOutsideStatus(text: string): { status: string; provider?: string; model?: string } | undefined { + const line = text.replace(/\r\n/g, '\n').split('\n').map(l => l.trim()).filter(Boolean).at(-1); + if (!line?.startsWith('OUTSIDE_STATUS: ')) return undefined; + const [status = '', ...rest] = line.slice('OUTSIDE_STATUS: '.length).split(/\s+/); + const kv = Object.fromEntries(rest.map(p => p.split('=')).filter(p => p.length === 2 && p[1]) as [string, string][]); + return { status, provider: kv.provider, model: kv.model && kv.model !== 'unknown' ? kv.model : undefined }; +} + +/** + * The provenance collect records, from its flags or else the reply's closing OUTSIDE_STATUS line; undefined when neither is there. + * The family always comes from the model id (familyOf), never from a printed `family=`; a model that names none is `unknown`. + */ +export function outsideProvenance(o: { model?: string; provider?: string; nativeModel?: string; output: string }): OutsideProvenance | undefined { + const status = parseOutsideStatus(o.output); + if (!o.model && !o.provider && !status) return undefined; + const model = o.model ?? status?.model ?? 'unknown'; + const family = familyOf(model); + const native = o.nativeModel ? familyOf(o.nativeModel) : undefined; + return { provider: o.provider ?? status?.provider ?? 'unknown', model, family, ...(o.nativeModel ? { native_model: o.nativeModel, native_family: native } : {}) }; +} + +/** Why a read with this provenance is not outside coverage: the same family as the lane's native model. undefined when it may count. */ +export function sameFamily(p: OutsideProvenance): string | undefined { + if (!p.native_model || p.family === 'unknown' || !p.native_family || p.native_family === 'unknown') return undefined; + return p.family === p.native_family ? (familyConflict(p.model, p.native_model) ?? `outside ${p.model} and native ${p.native_model} are both ${p.family}`) : undefined; +} + +/** + * Why a read by `model` is not proven second-model coverage: its family is unrecognized or not the model's own, the native family is + * missing or unrecognized, or the two are the same. undefined only for a recognized family beside a different recognized native family. + */ +export function unprovenCoverage(r: { model: string; family: string; native_family?: string }): string | undefined { + if (r.family === 'unknown' || familyOf(r.model) !== r.family) return UNPROVEN_FAMILY; + if (!r.native_family || r.native_family === 'unknown') return UNPROVEN_NATIVE; + return r.native_family === r.family ? `the outside read by ${r.model} is the ${r.family} family, the same as the lane's native family: a same-family fallback is never outside coverage` : undefined; +} + +/** The receipt-side check: a completed record needs a recognized family and a different recognized native_family; every record needs a known status. */ +export function outsideVoiceProblem(r: unknown): string | undefined { + if (!r || typeof r !== 'object' || Array.isArray(r)) return 'outside_voice must be an object { status, provider, model, family }'; + const v = r as Record; + if (!(OUTSIDE_VOICE_STATUSES as readonly unknown[]).includes(v.status)) return `outside_voice.status must be one of ${OUTSIDE_VOICE_STATUSES.join(', ')}, got ${JSON.stringify(v.status)}`; + for (const k of ['provider', 'model', 'family'] as const) if (typeof v[k] !== 'string' || !v[k]) return `outside_voice.${k} must be a non-empty string`; + if (v.status !== 'completed') return undefined; + const why = unprovenCoverage({ model: String(v.model), family: String(v.family), native_family: typeof v.native_family === 'string' ? v.native_family : undefined }); + return why && `outside_voice records a completed read by ${v.model} (family ${v.family}, native_family ${typeof v.native_family === 'string' ? v.native_family : 'none'}), but ${why}; record it as unavailable`; +} diff --git a/lib/review-depth.ts b/lib/review-depth.ts index 0f04134ae..0ce74112d 100644 --- a/lib/review-depth.ts +++ b/lib/review-depth.ts @@ -412,7 +412,9 @@ export interface History { * keepReader (GST-3562 A): this step stands where main's table planned a fix-check, or is the read-only final review, so its * dispatch keeps one full-effort reader that excludes nothing (the reader the fix-check was). The table sets it; prCapped's * spreads carry it; the dispatch reads it, never the reason text. readOnly marks the read-only final review: the dispatcher - * stages it on the PR's merge base whatever --diff-base the driver passes, and Step 3's edit guard applies no fix on it. + * stages it on the PR's merge base whatever --diff-base the driver passes, and Step 3's edit guard applies no fix on it. On + * code and gate class it lists both Step 11 voices again, and every later full pass lists the outside voice again, after + * Step 11 ran (GST-4140): the final head is never shipped without a second-model read of it. * rangeReaders (GST-3562 part 3): this full pass stands where main planned a scoped pass after a small blocking fix, so it * also dispatches the readers that pass ran: the Red Team, and the native adversarial when the fix range has runtime lines, * even after Step 11 ran it. @@ -647,6 +649,7 @@ export function planReviewAt(i: PlanInput, table: (h: History, depth: Depth) => const docsAndOutputs = i.paths.filter(p => !i.excluded?.has(p) && ((pathClass(i, p) === 'docs' && !(i.numbers.publishes && DOC_PATH.test(p))) || isOutput(i, p))).map(excludeSpec); const numbersChanged = i.numbers.publishes && i.reviewedNumbers !== undefined && i.reviewedNumbers !== i.numbers.fingerprint; const firstVoices = h.fullPasses === 0 || !i.adversarialRan; + let finalAdversarial = false; const specialist: Effort = i.tiers === false ? 'host' : ROLE_EFFORT.specialist; if (next.step === 'full' && stepDepth === 'light') { const forced = forcedBy(i); @@ -682,6 +685,13 @@ export function planReviewAt(i: PlanInput, table: (h: History, depth: Depth) => else skipped.push(`adversarial-native (${dcls} class)`); if (codeLike || i.numbers.publishes) add('outside-voice', 'outside-voice', 'host'); else skipped.push(`outside-voice (${dcls} class, no numeric claims)`); + } else if (codeLike) { + if (rangeAdversarial) add('adversarial-native', 'adversarial', 'full'); + else if (next.readOnly) finalAdversarial = true; + else skipped.push('adversarial-native (run once per invocation)'); + if (next.readOnly || h.rangeRuntimeLines !== 0) add('outside-voice', 'outside-voice', 'host'); + else if (numbersChanged) add('outside-voice', 'outside-voice (numbers changed)', 'host'); + else skipped.push('outside-voice (run once per invocation: the fix range changes no runtime lines)'); } else { if (rangeAdversarial) add('adversarial-native', 'adversarial', 'full'); skipped.push(rangeAdversarial ? 'outside-voice (run once per invocation)' : 'adversarial-native and outside-voice (run once per invocation)'); @@ -707,6 +717,7 @@ export function planReviewAt(i: PlanInput, table: (h: History, depth: Depth) => add('outside-voice', 'outside-voice', 'host'); } if (next.keepReader && !dispatches.some(d => d.effort === 'full' && d.exclude.length === (x?.specs.length ?? 0))) add('red-team', 'red-team', 'full'); + if (finalAdversarial) add('adversarial-native', 'adversarial', 'full'); if (i.targeted?.classes.length && ['full', 'scoped', 'fix-check', 'voices'].includes(next.step)) { if (i.targeted.ran) skipped.push('targeted (already read this product patch)'); else add('targeted', 'targeted', ROLE_EFFORT.targeted); diff --git a/lib/review-ledger.ts b/lib/review-ledger.ts index 658bff94f..08dacd9a4 100644 --- a/lib/review-ledger.ts +++ b/lib/review-ledger.ts @@ -19,6 +19,7 @@ import * as fs from 'node:fs'; import * as path from 'node:path'; import { checkReviewedTree, isReviewedTreeLine, promptHash, type TreeCheck } from './review-brief'; import { parseVerdict, withoutVerdictLines } from './review-verdict'; +import { UNPROVEN_FAMILY, unprovenCoverage, type OutsideProvenance, type OutsideVoiceRecord } from './outside-voice-record'; export interface LedgerEvent { event: 'rendered' | 'sent' | 'output' | 'judgment' | 'judge' | 'program' | 'quarantined' | 'fetch-sweep'; [k: string]: unknown } export const readerKey = (role: string, name?: string, slice?: { index: number; total: number }) => `${name ? `${role}/${name}` : role}${slice ? `#${slice.index}/${slice.total}` : ''}`; @@ -434,7 +435,7 @@ const hasCleanMarker = (reader: string, output: string) => output.replace(/\r\n/ * review: false. With unavailable (the outside voice only) the output is its failure text, recorded as missing coverage. With a * failed tree check (GST-482: the reply reviewed another checkout, or names none) nothing is merged and the output is no review. */ -export function collect(ledger: string, reader: string, output: string, mergedFile: string, outputFile?: string, unavailable?: string, tree?: TreeCheck, raises = true): { sha: string; lines: MergedLine[]; review: boolean; verdict?: VerdictCheck } { +export function collect(ledger: string, reader: string, output: string, mergedFile: string, outputFile?: string, unavailable?: string, tree?: TreeCheck, raises = true, outside?: OutsideProvenance): { sha: string; lines: MergedLine[]; review: boolean; verdict?: VerdictCheck } { const sha = promptHash(output); const events = readLedger(ledger); const prior = events.filter(e => e.event === 'output' && e.reader === reader).length; @@ -449,12 +450,32 @@ export function collect(ledger: string, reader: string, output: string, mergedFi const review = !unavailable && !wrongTree && (lines.length > 0 || hasCleanMarker(reader, output)); fs.appendFileSync(mergedFile, lines.map(l => JSON.stringify(l) + '\n').join(''), { mode: 0o600 }); appendEvent(ledger, { event: 'output', reader, sha256: sha, file: outputFile ? path.resolve(outputFile) : null, merged: path.resolve(mergedFile), ids: lines.map(l => l.id), review, ...(unavailable ? { unavailable } : {}), ...(raises ? {} : { fixable_raises: false }), - ...(tree && !unavailable ? { tree: tree.expected, reported_tree: tree.reported, tree_ok: tree.ok } : {}), ...('verdict' in reply && reply.verdict ? { verdict: reply.verdict } : {}) }); + ...(tree && !unavailable ? { tree: tree.expected, reported_tree: tree.reported, tree_ok: tree.ok } : {}), ...('verdict' in reply && reply.verdict ? { verdict: reply.verdict } : {}), ...(outside ? { outside } : {}) }); return { sha, lines, review, ...('verdict' in reply && reply.verdict ? { verdict: reply.verdict } : {}) }; } /** The outside voice may fail without blocking (ship/sections/adversarial.md): its failure is recorded as unavailable coverage, never as a review. */ export const mayBeUnavailable = (reader: string) => roleOf(reader) === 'outside-voice'; const unavailableOutput = (o: LedgerEvent) => typeof o.unavailable === 'string' && mayBeUnavailable(String(o.reader)); +const provenance = (o: LedgerEvent) => (o.outside && typeof o.outside === 'object' ? o.outside as OutsideProvenance : undefined); +/** A collected read by the lane's own family (GST-4140): never outside coverage, so verify fails it. */ +const sameFamilyOutput = (o: LedgerEvent) => { const p = provenance(o); return !unavailableOutput(o) && !!p?.native_family && p.native_family !== 'unknown' && p.family !== 'unknown' && p.family === p.native_family; }; + +/** + * The outside voice's record for the receipt (GST-4140): its last collected output, a review (completed) or missing coverage + * (unavailable), with the provider, model and family collect recorded. A review is completed only when its recognized family differs + * from a recognized native family (unprovenCoverage); any other review is unavailable with the reason, never a completed read the + * receipt would refuse. undefined when no outside voice output was collected; the plan that skipped it is recorded as skipped by the + * caller. verify prints it only on a clean ledger. + */ +export function outsideVoiceRecord(ledger: string): OutsideVoiceRecord | undefined { + const o = readLedger(ledger).filter(e => e.event === 'output' && mayBeUnavailable(String(e.reader)) && (e.review === true || unavailableOutput(e))).at(-1); + if (!o) return undefined; + const p = provenance(o); + const family = p?.family ?? 'unknown'; + const reason = unavailableOutput(o) ? String(o.unavailable) : p ? unprovenCoverage(p) : UNPROVEN_FAMILY; + return { status: reason ? 'unavailable' : 'completed', provider: p?.provider ?? 'unknown', model: p?.model ?? 'unknown', family, + ...(p?.native_family ? { native_family: p.native_family } : {}), ...(reason ? { reason } : {}) }; +} export function readJsonl(file: string): T[] { return fs.readFileSync(file, 'utf8').split('\n').filter(l => l.trim()).map(l => JSON.parse(l) as T); @@ -600,7 +621,7 @@ const collectedIds = (events: LedgerEvent[]) => { return events.filter(e => e.event === 'output').flatMap(idsOf).filter(id => !gone.has(id)); }; -export interface VerifyRow { kind: 'BRIEF' | 'OUTPUT' | 'JUDGE' | 'FETCH' | 'VERDICT' | 'SLICE'; reader: string; status: string; detail: string } +export interface VerifyRow { kind: 'BRIEF' | 'OUTPUT' | 'JUDGE' | 'FETCH' | 'VERDICT' | 'SLICE' | 'OUTSIDE'; reader: string; status: string; detail: string } /** Replay every check from a finished run's ledger: briefs dispatched as rendered, outputs merged as returned, judgment without loss. */ export function verify(ledger: string): { rows: VerifyRow[]; clean: boolean; briefs: number; voided: number; unavailable: number; verdicts: { asked: number; agree: number } } { @@ -735,6 +756,10 @@ export function verify(ledger: string): { rows: VerifyRow[]; clean: boolean; bri const found = Array.isArray(s.found) ? (s.found as Array<{ path: string }>) : []; rows.push({ kind: 'FETCH', reader: `${String(s.pass)}/${String(s.stage)}#${String(s.attempt)}`, status: s.verdict === 'violation' ? (resolved ? 'RESOLVED' : 'VIOLATION') : String(s.verdict).toUpperCase(), detail: `found=${found.length}${found.length ? ` paths=${JSON.stringify(found.map(x => x.path))}` : ''}${s.partial ? ` partial=${JSON.stringify(s.partial)}` : ''}` }); } + for (const o of events.filter(e => e.event === 'output' && sameFamilyOutput(e))) { + const p = provenance(o)!; + rows.push({ kind: 'OUTSIDE', reader: String(o.reader), status: 'SAME_FAMILY', detail: `model=${p.model} family=${p.family} native_family=${p.native_family} (a same-family read is never outside coverage)` }); + } const clean = episodes.length > 0 && rows.every(r => ['MATCH', 'OK', 'VOIDED', 'UNAVAILABLE', 'SUPERSEDED', 'CLEAN', 'PARTIAL', 'RESOLVED'].includes(r.status)); rows.push(...verdicts); return { rows, clean, briefs: episodes.length, voided, unavailable: rows.filter(r => r.kind === 'BRIEF' && r.status === 'UNAVAILABLE').length, diff --git a/lib/ship-receipt.ts b/lib/ship-receipt.ts index 1597939f6..01472ca13 100644 --- a/lib/ship-receipt.ts +++ b/lib/ship-receipt.ts @@ -19,6 +19,7 @@ import { laneExceptionBodyLines } from './test-lane-exception'; import { rerunMarker } from './run-evidence'; import { stampFileKind, versionStampOnly } from './pregate/stamp-only'; import { stampOnlyLine, type BranchSide } from './stamp-only'; +import { outsideVoiceProblem } from './outside-voice-record'; export const RECEIPT_FENCE = 'gstack-ship-receipt'; @@ -54,7 +55,7 @@ const KEY_ORDER: Array = [ 'schema_version', 'pr', 'head', 'version', 'base', 'gated_tree', 'predecessor', 'tree', 'gate_reuse', 'gate', 'ci', 'ci_carried', 'spend_usd', 'calls', 'session_kind', 'artifacts_consumed', 'run', 'thread', 'policy', 'queue_mode', 'preregistration', 'history', 'head_tree', 'product_patch_id', 'gstack_version', 'review_depth', 'pregate', 'requires_remote', 'issues', 'approval', 'docs', 'review_loop', - 'cleared_by_trailer', 'cleared_by_review', 'ruled_notes', 'gate_dispositions', 'mechanical', 'review_targeted', 'design', 'review_exclude', 'review_exclude_fallback', 'docs_audit_read', 'carry', 'base_red', 'flaky_exception', 'no_stop', + 'cleared_by_trailer', 'cleared_by_review', 'ruled_notes', 'gate_dispositions', 'mechanical', 'review_targeted', 'outside_voice', 'design', 'review_exclude', 'review_exclude_fallback', 'docs_audit_read', 'carry', 'base_red', 'flaky_exception', 'no_stop', ]; /** Keys in the fixed order so identifiers lead; undefined values are dropped. */ @@ -68,6 +69,9 @@ export function orderReceipt(input: Partial & { docs?: unknown }): export function validateReceipt(receipt: unknown): ValidationError[] { const errors: ValidationError[] = []; checkSchema(receipt, ARTIFACT_SCHEMAS['ship-receipt'], '', errors, 'ship-receipt'); + const voice = receipt && typeof receipt === 'object' ? (receipt as Record).outside_voice : undefined; + const problem = voice === undefined || errors.some(e => e.path.includes('outside_voice')) ? undefined : outsideVoiceProblem(voice); + if (problem) errors.push({ code: 'RECEIPT_INVALID', path: 'ship-receipt.outside_voice', message: problem }); return errors; } diff --git a/test/fixtures/review-pins/files/lib/review-depth.ts.json b/test/fixtures/review-pins/files/lib/review-depth.ts.json index 3e57f09dd..7cca86c1e 100644 --- a/test/fixtures/review-pins/files/lib/review-depth.ts.json +++ b/test/fixtures/review-pins/files/lib/review-depth.ts.json @@ -1 +1 @@ -{"sha":"d6f474b5320d9b94715e79400647ab215942ed2f5c60636ea8a82e890ab21b6f","replay":"GSTA-861"} +{"sha":"e474e1fc2e33997b420c54527b749108552243ced44370f4b94e53e056414f64","replay":"GST-4140"} diff --git a/test/fixtures/review-pins/replays/GST-4140.json b/test/fixtures/review-pins/replays/GST-4140.json new file mode 100644 index 000000000..33d2264cf --- /dev/null +++ b/test/fixtures/review-pins/replays/GST-4140.json @@ -0,0 +1 @@ +{"replay":"GST-4140","justification":"GST-4140 deterministic no-loss replay, no paid run (CREW rule 13/15): lib/review-depth.ts only adds readers. After Step 11 ran (--adversarial-ran), a full pass at standard or full depth on code or gate class lists the outside voice again (unless its fix range changes no runtime lines), and the read-only final review of such a diff lists the native adversarial again too (appended after the keepReader Red Team, so that reader is kept). Docs, tests, light depth, lean mode, scoped, fix-check and voices steps keep main's dispatches and skip lines byte for byte. test/helpers/gst4140-replay.ts asserts every added reader is exactly one of these and reads the plan back as main's: the GST-967 grid (1,440 cases; 104 add the outside voice), the GST-972 grids (132 and 56) and the GST-1350 grids (398 and 388) keep their frozen main hashes, and the GST-3562 replays (test/review-depth.test.ts, test/review-depth-lean.test.ts, test/review-risk-token-paths.test.ts) keep every case's kind and step. No brief body, effort, depth rule (rules= is unchanged) or History field changes."} diff --git a/test/helpers/gst4140-replay.ts b/test/helpers/gst4140-replay.ts new file mode 100644 index 000000000..b2a880b87 --- /dev/null +++ b/test/helpers/gst4140-replay.ts @@ -0,0 +1,39 @@ +/** + * GST-4140's no-loss replay. After Step 11 ran (--adversarial-ran), a later full pass on a code or gate diff at standard or full + * depth lists the outside voice again, and the read-only final review of such a diff lists the native adversarial again too, so + * the final head never ships without a second-model read. Main dropped both as "run once per invocation". The change only adds + * readers: asMainBeforeGst4140 checks each added reader is exactly one of these and reads the plan back as main's, so every grid + * frozen to an older main keeps its hash. + * outside: the full pass lists `outside-voice` at the host effort where main listed none, or listed it only as + * `outside-voice (numbers changed)` (read back under that name). A pass 2 whose fix range changes no runtime lines adds no + * outside voice: it plans main's readers and only words its skip line apart. + * adversarial: the read-only final review lists one more `adversarial-native` at full effort, after every reader main listed. + */ +import { expect } from 'bun:test'; +import type { PlanInput, ReviewPlan } from '../../lib/review-depth'; + +export type Gst4140Kind = 'outside' | 'outside+adversarial'; + +export function asMainBeforeGst4140(input: PlanInput, plan: ReviewPlan): { plan: ReviewPlan; kind?: Gst4140Kind } { + const h = input.history; + const dcls = plan.stepDepth === 'full' ? 'gate' : plan.class; + if (!(plan.mode === 'panel' && plan.next.step === 'full' && plan.stepDepth !== 'light' && h.fullPasses > 0 && input.adversarialRan && (dcls === 'code' || dcls === 'gate'))) return { plan }; + const range = !!plan.next.rangeReaders && (h.rangeRuntimeLines ?? 0) > 0; + const final = !!plan.next.readOnly && !range; + const numbersChanged = input.numbers.publishes && input.reviewedNumbers !== undefined && input.reviewedNumbers !== input.numbers.fingerprint; + const added = final || h.rangeRuntimeLines !== 0; + const outside = plan.dispatches.filter(d => d.role === 'outside-voice'); + expect([h, outside.map(d => `${d.name}:${d.effort}`)]).toEqual([h, added ? ['outside-voice:host'] : numbersChanged ? ['outside-voice (numbers changed):host'] : []]); + let dispatches = !added ? plan.dispatches : plan.dispatches.flatMap(d => d.role !== 'outside-voice' ? [d] : numbersChanged ? [{ ...d, name: 'outside-voice (numbers changed)' }] : []); + if (final) { + const last = dispatches.map(d => d.role).lastIndexOf('adversarial-native'); + expect([h, dispatches.filter(d => d.role === 'adversarial-native').length, dispatches[last]?.effort, dispatches.slice(last + 1).every(d => d.role === 'targeted')]).toEqual([h, 1, 'full', true]); + dispatches = [...dispatches.slice(0, last), ...dispatches.slice(last + 1)]; + } + const quiet = 'outside-voice (run once per invocation: the fix range changes no runtime lines)'; + const skipped = plan.skipped.filter(s => s !== 'adversarial-native (run once per invocation)' && s !== quiet); + expect([h, plan.skipped.length - skipped.length]).toEqual([h, (range || final ? 0 : 1) + (!added && !numbersChanged ? 1 : 0)]); + const at = skipped.indexOf('targeted (already read this product patch)'); + const was = range ? 'outside-voice (run once per invocation)' : 'adversarial-native and outside-voice (run once per invocation)'; + return { plan: { ...plan, dispatches, skipped: at < 0 ? [...skipped, was] : [...skipped.slice(0, at), was, ...skipped.slice(at)] }, ...(added ? { kind: final ? 'outside+adversarial' as const : 'outside' as const } : {}) }; +} diff --git a/test/outside-voice-family.test.ts b/test/outside-voice-family.test.ts new file mode 100644 index 000000000..c40bf1fb4 --- /dev/null +++ b/test/outside-voice-family.test.ts @@ -0,0 +1,205 @@ +/** + * GST-4140: an outside voice from the lane's own model family is one voice, never outside coverage. gstack-review-dispatch collect + * refuses it and records the provider, model and family of every outside read; verify prints OUTSIDE_VOICE_RECORD: for the + * receipt; gstack-ship-receipt write records it as outside_voice and refuses a same-family completed read. Missing coverage + * stays unavailable or skipped and never blocks. + */ +import { afterAll, afterEach, describe, expect, test } from 'bun:test'; +import * as fs from 'node:fs'; +import * as os from 'node:os'; +import * as path from 'node:path'; +import { spawnSync } from 'node:child_process'; +import { runScriptSync } from '../lib/script-invocation'; +import { appendEvent, outsideVoiceRecord, readLedger, verify } from '../lib/review-ledger'; +import { familyOf, outsideProvenance, outsideVoiceProblem, parseOutsideStatus, sameFamily, UNPROVEN_FAMILY, UNPROVEN_NATIVE } from '../lib/outside-voice-record'; +import { validateReceipt } from '../lib/ship-receipt'; + +const ROOT = path.resolve(import.meta.dir, '..'); +const DISPATCH = path.join(ROOT, 'bin', 'gstack-review-dispatch'); +const RECEIPT = path.join(ROOT, 'bin', 'gstack-ship-receipt'); +const dirs: string[] = []; +afterEach(() => { while (dirs.length) fs.rmSync(dirs.pop()!, { recursive: true, force: true }); }); +const tmp = (p: string) => { const d = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), p))); dirs.push(d); return d; }; +const dispatch = (args: string[]) => runScriptSync(DISPATCH, args, { cwd: ROOT, encoding: 'utf8', timeout: 60_000 }); +const REPLY = 'No blocking issue in the retry path.\nRecommendation: ship because the fix holds\n'; + +function pass() { + const out = tmp('outside-family-'); + const ledger = path.join(out, 'review-ledger.jsonl'), merged = path.join(out, 'merged.jsonl'); + const w = (n: string, t: string) => { const f = path.join(out, n); fs.writeFileSync(f, t); return f; }; + const file = /file=(\S+)/.exec(dispatch(['render', '--role', 'specialist', '--name', 'testing', '--out', out, '--diff-base', 'a'.repeat(40)]).stdout)?.[1] ?? ''; + expect(dispatch(['sent', '--ledger', ledger, '--role', 'specialist', '--name', 'testing', '--sent', file]).status).toBe(0); + const outside = (extra: string[], reply = REPLY) => dispatch(['collect', '--ledger', ledger, '--role', 'outside-voice', '--output', w(`o${Math.random()}.txt`, reply), '--merged', merged, ...extra]); + return { out, ledger, merged, w, outside }; +} + +let worktree = ''; +afterAll(() => { if (worktree) spawnSync('git', ['-C', ROOT, 'worktree', 'remove', '--force', worktree], { encoding: 'utf8', timeout: 60_000 }); }); +const gitIn = (cwd: string, args: string[]) => spawnSync('git', ['-C', cwd, ...args], { encoding: 'utf8', timeout: 30_000 }).stdout.trim(); +/** + * A clean ledger holding only the outside voice: its brief rendered in a clean checkout of HEAD and sent verbatim, a reply that + * names that checkout's REVIEWED_TREE, then judge. verify prints OUTSIDE_VOICE_RECORD only on a ledger like this. + */ +function cleanVoice(extra: string[], reply = REPLY) { + if (!worktree) { + worktree = path.join(fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'outside-family-wt-'))), 'wt'); + const add = spawnSync('git', ['-C', ROOT, 'worktree', 'add', '--detach', worktree, 'HEAD'], { encoding: 'utf8', timeout: 120_000 }); + expect(add.status, add.stderr).toBe(0); + } + const out = tmp('outside-clean-'); + const ledger = path.join(out, 'review-ledger.jsonl'), merged = path.join(out, 'merged.jsonl'), output = path.join(out, 'outside.txt'); + const inTree = (args: string[]) => runScriptSync(DISPATCH, args, { cwd: worktree, encoding: 'utf8', timeout: 60_000 }); + const file = /file=(\S+)/.exec(inTree(['render', '--role', 'outside-voice', '--out', out, '--diff-base', gitIn(worktree, ['rev-parse', 'HEAD'])]).stdout)?.[1] ?? ''; + expect(dispatch(['sent', '--ledger', ledger, '--role', 'outside-voice', '--sent', file]).status).toBe(0); + fs.writeFileSync(output, `REVIEWED_TREE: ${gitIn(worktree, ['rev-parse', 'HEAD^{tree}'])} ${worktree}\n` + reply); + const c = inTree(['collect', '--ledger', ledger, '--role', 'outside-voice', '--output', output, '--merged', merged, ...extra]); + expect([c.status, c.stdout + c.stderr]).toEqual([0, expect.stringContaining('COLLECT: reader=outside-voice')]); + expect(dispatch(['judge', '--ledger', ledger, '--merged', merged, '--judged', path.join(out, 'judged.jsonl')]).status).toBe(0); + const v = dispatch(['verify', '--ledger', ledger]); + expect([v.status, v.stdout]).toEqual([0, expect.stringContaining('VERIFY: clean')]); + return v.stdout.split('\n').find(l => l.startsWith('OUTSIDE_VOICE_RECORD:')); +} + +describe('the outside voice record (lib/outside-voice-record.ts)', () => { + // Value: protects=R38/R129's second family: a same-family fallback never reads as outside coverage; fails_when=a Claude reader beside a + // Claude lane, by flag or by its OUTSIDE_STATUS line, passes as cross-family, or a cross-family pair is refused; seam=outsideProvenance, sameFamily + test('flags win over the OUTSIDE_STATUS line; the same family is refused and another family is not', () => { + expect(parseOutsideStatus('x\nOUTSIDE_STATUS: completed provider=codex-cli model=gpt-6.2-astra family=openai pass=2\n')).toEqual({ status: 'completed', provider: 'codex-cli', model: 'gpt-6.2-astra' }); + expect(parseOutsideStatus('OUTSIDE_STATUS: completed provider=codex host=claude')).toEqual({ status: 'completed', provider: 'codex', model: undefined }); + for (const model of ['claude-opus-4', 'anthropic/claude-opus-5-5']) expect(sameFamily(outsideProvenance({ model, nativeModel: 'anthropic/claude-opus-5-5', output: '' })!)).toContain('both anthropic'); + const status = outsideProvenance({ nativeModel: 'claude-opus-5-5', output: 'OUTSIDE_STATUS: completed provider=host-subagent model=anthropic/claude-opus-4-8 family=anthropic' })!; + expect([status.provider, status.family, !!sameFamily(status)]).toEqual(['host-subagent', 'anthropic', true]); + const cross = outsideProvenance({ model: 'openai/gpt-6.2-sol', provider: 'host-subagent', nativeModel: 'anthropic/claude-opus-5-5', output: 'OUTSIDE_STATUS: completed provider=x model=claude-opus-4 family=anthropic' })!; + expect([cross, sameFamily(cross)]).toEqual([{ provider: 'host-subagent', model: 'openai/gpt-6.2-sol', family: 'openai', native_model: 'anthropic/claude-opus-5-5', native_family: 'anthropic' }, undefined]); + expect(outsideProvenance({ output: REPLY })).toBeUndefined(); + expect(['openrouter/anthropic/claude-opus-5-5', 'tencent/hy4', 'gpt-6.2-astra', 'mystery-model', 'bedrock/anthropic.claude-opus-5'].map(familyOf)).toEqual(['anthropic', 'unknown', 'openai', 'unknown', 'unknown']); + }); + // Value: protects=only the provider's own closing status line and the model id name the family; fails_when=a status line quoted inside the + // review text, or a printed family= with no model, proves a second family (Step 11 outside-voice#1, adversarial-native#2 on #4886); seam=parseOutsideStatus, outsideProvenance + test('a status line that is not the reply\'s last line, and a printed family= without a model, prove nothing', () => { + expect(parseOutsideStatus('OUTSIDE_STATUS: completed provider=host-subagent model=openai/gpt-6.2-sol\nNo blocking issue.\n')).toBeUndefined(); + expect(outsideProvenance({ nativeModel: 'anthropic/claude-opus-5-5', output: 'Recommendation: ship\nOUTSIDE_STATUS: completed provider=codex family=openai\n' })).toMatchObject({ model: 'unknown', family: 'unknown' }); + }); + // Value: protects=a completed record always proves a recognized family beside a different recognized native family; fails_when=collect without + // --native-model, or a family the model id doesn't name, records or binds a completed second-model read (Step 11 outside-voice#1 on #4886); seam=outsideVoiceRecord, outsideVoiceProblem + test('a read with no native family, or an unrecognized family, is unavailable, and write refuses it as completed', () => { + const p = pass(); + expect(p.outside(['--outside-model', 'openai/gpt-6.2-sol', '--outside-provider', 'host-subagent']).status).toBe(0); + expect(outsideVoiceRecord(p.ledger)).toEqual({ status: 'unavailable', provider: 'host-subagent', model: 'openai/gpt-6.2-sol', family: 'openai', reason: UNPROVEN_NATIVE }); + const ok = { status: 'completed', provider: 'host-subagent', model: 'openai/gpt-6.2-sol', family: 'openai', native_family: 'anthropic' }; + expect(outsideVoiceProblem(ok)).toBeUndefined(); + for (const bad of [{ ...ok, native_family: undefined }, { ...ok, native_family: 'unknown' }, { ...ok, model: 'tencent/hy4', family: 'tencent' }]) expect(outsideVoiceProblem(bad)).toContain('record it as unavailable'); + }, 60_000); +}); + +describe('gstack-review-dispatch collect and verify: the outside voice\'s family (GST-4140)', () => { + // Value: protects=the ledger never records a same-family outside read as coverage, and verify hands the receipt who read; fails_when=collect + // merges a claude-opus-4 or anthropic/claude-opus-5-5 outside read on an Anthropic lane, records no family, or verify prints no record; seam=the bin + test('a same-family outside read is COLLECT_SAME_FAMILY and merges nothing; a cross-family read is recorded and verify prints its record', () => { + const p = pass(); + for (const model of ['claude-opus-4', 'anthropic/claude-opus-5-5']) { + const same = p.outside(['--outside-model', model, '--outside-provider', 'host-subagent', '--native-model', 'anthropic/claude-opus-5-5']); + expect([same.status, same.stdout]).toEqual([1, expect.stringContaining(`COLLECT_SAME_FAMILY: reader=outside-voice model=${model} family=anthropic native=anthropic/claude-opus-5-5`)]); + expect(same.stdout).toContain('a file that holds only the reason, not this reply (--unavailable refuses output that holds findings)'); + } + const viaStatus = p.outside(['--native-model', 'claude-opus-5-5'], REPLY + 'OUTSIDE_STATUS: completed provider=host-subagent model=claude-opus-4 family=anthropic\n'); + expect([viaStatus.status, viaStatus.stdout]).toEqual([1, expect.stringContaining('COLLECT_SAME_FAMILY')]); + expect(readLedger(p.ledger).filter(e => e.event === 'output' && e.reader === 'outside-voice')).toEqual([]); + const ok = p.outside(['--outside-model', 'openai/gpt-6.2-sol', '--outside-provider', 'host-subagent', '--native-model', 'anthropic/claude-opus-5-5']); + expect([ok.status, ok.stdout]).toEqual([0, expect.stringContaining('COLLECT: reader=outside-voice')]); + const record = { status: 'completed', provider: 'host-subagent', model: 'openai/gpt-6.2-sol', family: 'openai', native_family: 'anthropic' }; + expect(outsideVoiceRecord(p.ledger)).toEqual(record as never); + const v = dispatch(['verify', '--ledger', p.ledger]); + expect([v.status, v.stdout]).toEqual([1, expect.stringContaining('OUTSIDE_VOICE_RECORD_WITHHELD: VERIFY is dirty')]); + expect(v.stdout).not.toContain('OUTSIDE_VOICE_RECORD: '); + expect(v.stdout).not.toContain('SAME_FAMILY'); + expect(cleanVoice(['--outside-model', 'openai/gpt-6.2-sol', '--outside-provider', 'host-subagent', '--native-model', 'anthropic/claude-opus-5-5'])).toBe(`OUTSIDE_VOICE_RECORD: ${JSON.stringify(record)}`); + }, 120_000); + test('missing coverage is recorded as unavailable with its provenance; a same-family read written into a ledger makes verify dirty; the flags are the outside voice\'s only', () => { + const p = pass(); + const lost = p.outside(['--outside-model', 'claude-opus-4', '--native-model', 'anthropic/claude-opus-5-5', '--unavailable', 'no other family online'], 'outside voice failed\n'); + expect([lost.status, lost.stdout]).toEqual([0, expect.stringContaining('COLLECT_UNAVAILABLE: reader=outside-voice')]); + expect(outsideVoiceRecord(p.ledger)).toMatchObject({ status: 'unavailable', model: 'claude-opus-4', family: 'anthropic', reason: 'no other family online' }); + expect(verify(p.ledger).rows.some(r => r.kind === 'OUTSIDE')).toBe(false); + appendEvent(p.ledger, { event: 'output', reader: 'outside-voice', sha256: 'x', file: null, merged: p.merged, ids: [], review: true, outside: { provider: 'host-subagent', model: 'claude-opus-4', family: 'anthropic', native_model: 'claude-opus-5-5', native_family: 'anthropic' } }); + const v = verify(p.ledger); + expect([v.clean, v.rows.find(r => r.kind === 'OUTSIDE')]).toEqual([false, { kind: 'OUTSIDE', reader: 'outside-voice', status: 'SAME_FAMILY', detail: expect.stringContaining('family=anthropic native_family=anthropic') }]); + const spec = dispatch(['collect', '--ledger', p.ledger, '--role', 'specialist', '--name', 'testing', '--output', p.w('s.txt', 'NO FINDINGS\n'), '--merged', p.merged, '--outside-model', 'openai/gpt-6.2-sol']); + expect([spec.status, spec.stderr]).toEqual([2, expect.stringContaining('is not the outside voice')]); + }, 60_000); +}); + +describe('gstack-ship-receipt write: outside_voice (GST-4140)', () => { + let repo = '', env: NodeJS.ProcessEnv = {}; + const setup = () => { + const t = tmp('gstack-receipt-outside-'); + repo = path.join(t, 'repo'); + fs.mkdirSync(repo); + const gitconfig = path.join(t, 'gitconfig'); + fs.writeFileSync(gitconfig, ''); + env = { ...process.env, HOME: t, USERPROFILE: t, GSTACK_STATE_ROOT: path.join(t, 'state'), GSTACK_HOME: path.join(t, 'state'), GSTACK_SESSION_KIND: 'attended', + GIT_CONFIG_GLOBAL: gitconfig, GIT_CONFIG_NOSYSTEM: '1', GIT_DIR: undefined, GIT_WORK_TREE: undefined, GIT_INDEX_FILE: undefined }; + const git = (...args: string[]) => expect(spawnSync('git', args, { cwd: repo, env, encoding: 'utf8', timeout: 30_000 }).status).toBe(0); + git('init', '-q', '-b', 'main'); + fs.writeFileSync(path.join(repo, 'a.txt'), 'a\n'); + git('add', 'a.txt'); + git('-c', 'user.email=fixture@example.test', '-c', 'user.name=Fixture', '-c', 'commit.gpgsign=false', 'commit', '-qm', 'fixture'); + git('update-ref', 'refs/remotes/origin/main', 'HEAD'); + git('switch', '-q', '-c', 'feat'); + return t; + }; + const write = (voice: string) => runScriptSync(RECEIPT, ['write', '--base', 'main', '--json', '--outside-voice', voice], { cwd: repo, env, encoding: 'utf8', timeout: 60_000 }); + // Value: protects=the receipt names the second-model read and its family, and a same-family completed read never binds; fails_when=write drops + // outside_voice, accepts a same-family or unknown-family completed read, or refuses honest unavailable or skipped coverage; seam=the bin and validateReceipt + test('records a cross-family completed read, explicit unavailable and skipped coverage; refuses a same-family or unrecognized completed read', () => { + const t = setup(); + const ok = { status: 'completed', provider: 'host-subagent', model: 'openai/gpt-6.2-sol', family: 'openai', native_family: 'anthropic' }; + const w = write(`OUTSIDE_VOICE_RECORD: ${JSON.stringify(ok)}`); + expect(w.status, w.stderr).toBe(0); + expect(JSON.parse(w.stdout).outside_voice).toEqual(ok); + const file = path.join(t, 'verify.txt'); + fs.writeFileSync(file, `VERIFY: clean briefs=3 outputs=3 voided=0\nOUTSIDE_VOICE_RECORD: ${JSON.stringify({ status: 'unavailable', provider: 'codex-cli', model: 'unknown', family: 'unknown', reason: 'rate limited' })}\n`); + const lost = write('@' + file); + expect([lost.status, JSON.parse(lost.stdout || '{}').outside_voice?.status]).toEqual([0, 'unavailable']); + const skipped = write(JSON.stringify({ status: 'skipped', provider: 'none', model: 'none', family: 'unknown', reason: 'the review plan listed no outside voice' })); + expect([skipped.status, JSON.parse(skipped.stdout || '{}').outside_voice?.status]).toEqual([0, 'skipped']); + const pretty = path.join(t, 'pretty.json'); + fs.writeFileSync(pretty, JSON.stringify(ok, null, 2) + '\n'); + const full = path.join(t, 'verify-full.txt'); + fs.writeFileSync(full, `OUTPUT outside-voice MATCH sha=abc findings=0\nOUTSIDE_VOICE_RECORD: ${JSON.stringify(ok)}\nVERIFY: clean briefs=1 outputs=1 voided=0\n`); + for (const f of [pretty, full]) { + const r = write('@' + f); + expect([r.status, JSON.parse(r.stdout || '{}').outside_voice], r.stderr).toEqual([0, ok]); + } + const empty = path.join(t, 'empty.txt'); + fs.writeFileSync(empty, ''); + const withheld = path.join(t, 'withheld.txt'); + fs.writeFileSync(withheld, "OUTSIDE_VOICE_RECORD_WITHHELD: VERIFY is dirty, so the outside voice's record does not bind\nVERIFY: dirty briefs=1 outputs=1 voided=0\n"); + for (const f of [empty, withheld]) { + const r = write('@' + f); + expect([r.status, r.stderr]).toEqual([2, expect.stringContaining('verify prints it only when VERIFY is clean')]); + } + for (const bad of [{ ...ok, model: 'claude-opus-4', family: 'anthropic' }, { ...ok, model: 'anthropic/claude-opus-5-5', family: 'anthropic' }, { ...ok, family: 'unknown' }, { ...ok, model: 'claude-opus-4' }, { ...ok, native_family: undefined }, { ...ok, model: 'tencent/hy4', family: 'tencent' }]) { + const r = write(JSON.stringify(bad)); + expect([bad.model, bad.family, r.status, r.stderr]).toEqual([bad.model, bad.family, 1, expect.stringContaining('RECEIPT_INVALID')]); + } + expect(write('not json').status).toBe(2); + }, 120_000); + // Value: protects=verify's record always binds: a cross-family read whose family was never recorded (the Codex block's + // OUTSIDE_STATUS line names no model) is missing coverage, never a completed read write refuses; fails_when=verify prints a + // record write rejects, or calls an unproven read completed; seam=collect, verify and write end to end + test('verify reports an outside read with no recorded family as unavailable, and write binds that record', () => { + setup(); + const line = cleanVoice([], REPLY + 'OUTSIDE_STATUS: completed provider=codex host=claude\n')!; + expect(JSON.parse(line.slice('OUTSIDE_VOICE_RECORD:'.length))).toEqual({ status: 'unavailable', provider: 'codex', model: 'unknown', family: 'unknown', reason: UNPROVEN_FAMILY }); + const w = write(line); + expect([w.status, JSON.parse(w.stdout || '{}').outside_voice?.status]).toEqual([0, 'unavailable']); + }, 120_000); + test('a receipt without outside_voice stays valid; validateReceipt rejects a same-family completed record', () => { + const base = { schema_version: 1, head: 'a'.repeat(40), base: 'main' }; + expect(validateReceipt(base)).toEqual([]); + expect(validateReceipt({ ...base, outside_voice: { status: 'completed', provider: 'host-subagent', model: 'claude-opus-4', family: 'anthropic', native_family: 'anthropic' } }).map(e => e.code)).toEqual(['RECEIPT_INVALID']); + expect(outsideVoiceProblem({ status: 'unavailable', provider: 'codex-cli', model: 'unknown', family: 'unknown' })).toBeUndefined(); + expect(outsideVoiceProblem({ status: 'done', provider: 'x', model: 'y', family: 'z' })).toContain('status must be one of'); + }); +}); diff --git a/test/review-depth.test.ts b/test/review-depth.test.ts index df27754cc..88d546471 100644 --- a/test/review-depth.test.ts +++ b/test/review-depth.test.ts @@ -8,6 +8,7 @@ import { summarizeReviewLoop } from '../lib/review-scope'; import { sectionTexts } from '../lib/review-brief'; import { createHash } from 'node:crypto'; import { asMainBeforeGst3562 } from './helpers/gst3562-replay'; +import { asMainBeforeGst4140 } from './helpers/gst4140-replay'; const ROOT = path.join(import.meta.dir, '..'); const none = scanNumbers({}); @@ -183,6 +184,11 @@ const R51_CASES = 28; * step was a fix-check are histories gstack-review-plan no longer accepts (GST-3562 part 4) and read back as main's plan. */ const GST3562_967_CASES = { a: 20, d: 10, e: 60, h: 480 }; +/** + * GST-4140 adds readers and drops none (test/helpers/gst4140-replay.ts): after Step 11 ran, a full pass at standard or full depth + * on code or gate class lists the outside voice again, and the read-only final review lists the native adversarial again too. + */ +const GST4140_967_CASES = { 'gate:outside': 38, 'light:outside': 28, 'standard:outside': 38 }; const MAIN_SECTIONS = '0608589f33d7cc47f27ccf98538d1c76edc1a475075b419de12c76ba9c433518'; describe('GST-967 dispatch-superset no-loss check', () => { // Value: protects=the no-loss rule for review-depth changes: GST-967 drops, renames and re-efforts no reviewer main dispatches on any grid case, changes no brief body, and GST-3562 A changes only the kinds its replay allows; fails_when=a non-stop plan changes outside those kinds, a voices step appears off gate class or after Step 11, it dispatches anything but the three voices, or a brief body moves; @@ -201,11 +207,14 @@ describe('GST-967 dispatch-superset no-loss check', () => { let r51 = 0; const gst3187: Record = {}; const gst3562: Record = {}; + const gst4140: Record = {}; for (const [name, f] of Object.entries(fixtures)) for (const fullPasses of [0, 1, 2]) for (const last of ['none', 'full', 'fix-check'] as const) for (let bits = 0; bits < 16; bits++) for (const adversarialRan of [false, true]) { const history = { fullPasses, last, fixedBlocking: !!(bits & 1), fixedBelow: !!(bits & 2), blockingOpen: !!(bits & 4), touchedGate: !!(bits & 8) }; const input = { ...f, numbers: none, history, adversarialRan } as PlanInput; - const { plan: main0408128, kind } = asMainBeforeGst3562(input, planReview(input)); + const { plan: branch, kind } = asMainBeforeGst3562(input, planReview(input)); if (kind) gst3562[kind] = (gst3562[kind] ?? 0) + 1; + const { plan: main0408128, kind: added } = asMainBeforeGst4140(input, branch); + if (added) gst4140[`${name}:${added}`] = (gst4140[`${name}:${added}`] ?? 0) + 1; const { plan: p, changed } = asMainBeforeGst3187(input, main0408128); if (changed) gst3187[`${name}:${changed}`] = (gst3187[`${name}:${changed}`] ?? 0) + 1; let { step, reason } = p.next; @@ -224,6 +233,7 @@ describe('GST-967 dispatch-superset no-loss check', () => { 'docs:full': 4, 'docs:stop': 2, 'gate:full': 4, 'gate:stop': 1, 'gate:voices': 1, 'light:full': 4, 'light:stop': 2, 'standard:full': 4, 'standard:stop': 2, 'tests:full': 4, 'tests:stop': 2, }); expect(gst3562).toEqual(GST3562_967_CASES); + expect(gst4140).toEqual(GST4140_967_CASES); expect(sha(sectionTexts(ROOT))).toBe(MAIN_SECTIONS); }); }); @@ -279,13 +289,16 @@ describe('GST-972 follow-up no-loss check', () => { pin: [['scripts/harness-pins/scripts/lib/paid-plan.ts.json'], ['scripts/lib/paid-plan.ts.json'], {}], }; const gst3562: Record = {}; + const gst4140: Record = {}; const grid = (pick: 0 | 1) => { const rows: { name: string; fullPasses: number; last: string; bits: number; adversarialRan: boolean; class: string; depth: string; step: string; dispatches: { role: string; name: string; effort: string; checklists: string[] }[] }[] = []; for (const [name, c] of Object.entries(cases)) for (const fullPasses of [0, 1, 2]) for (const last of ['none', 'full', 'fix-check'] as const) for (let bits = 0; bits < 16; bits++) for (const adversarialRan of [false, true]) { const history = { fullPasses, last, fixedBlocking: !!(bits & 1), fixedBelow: !!(bits & 2), blockingOpen: !!(bits & 4), touchedGate: !!(bits & 8) }; const input = { paths: c[pick], scope: c[2], gateTagged: 0, diffLines: 40, consumed: [], numbers: none, history, adversarialRan } as PlanInput; - const { plan: main0408128, kind } = asMainBeforeGst3562(input, planReview(input)); + const { plan: branch, kind } = asMainBeforeGst3562(input, planReview(input)); if (kind) gst3562[`${pick}:${kind}`] = (gst3562[`${pick}:${kind}`] ?? 0) + 1; + const { plan: main0408128, kind: added } = asMainBeforeGst4140(input, branch); + if (added) gst4140[`${pick}:${added}`] = (gst4140[`${pick}:${added}`] ?? 0) + 1; const p = pick ? asMainBeforeGst3187(input, main0408128).plan : main0408128; rows.push({ name, fullPasses, last, bits, adversarialRan, class: p.class, depth: p.depth, step: p.next.step, dispatches: (pick ? asMainBeforeR51(p).dispatches : p.dispatches).map(d => ({ role: d.role, name: d.name, effort: d.effort, checklists: d.checklists ?? [] })) }); } @@ -314,6 +327,7 @@ describe('GST-972 follow-up no-loss check', () => { 'review-exclude: code/light -> gate/full': 288, 'default-base: code/light -> gate/full': 288, 'helper+pin: tests/light -> code/light': 288, 'pin: docs/light -> code/light': 288, }]); expect(gst3562).toEqual(GST3562_972_CASES); + expect(gst4140).toEqual({ '0:outside': 132, '1:outside': 56 }); }); }); @@ -412,10 +426,39 @@ describe('planReview', () => { expect(gated.skipped).toContain('state-machines (gated by hit rate)'); expect(planReview(base({ diffLines: 20 })).dispatches.filter(d => d.role === 'specialist').map(d => d.name)).toEqual(['batched']); }); - test('pass 2 reruns the army on the range but not the adversarial or outside voice once Step 11 ran', () => { + // Value: protects=R51's second-model read of the final head (GST-4140): code that fixes changed after Step 11 ran is read again + // by the outside voice; fails_when=a code or gate full pass 2 or read-only final review drops the outside voice after + // --adversarial-ran, the read-only review drops the native adversarial, or a light docs or tests diff without numbers gains one; seam=planReview + test('pass 2 reruns the army on the range and the outside voice, but not the native adversarial, once Step 11 ran (GST-4140)', () => { const p = planReview(base({ adversarialRan: true, history: { fullPasses: 1, last: 'full', fixedBlocking: true } })); - expect(p.next.step).toBe('full'); - expect(roles(p).some(r => r.startsWith('outside-voice') || r.startsWith('adversarial'))).toBe(false); + expect([p.next.step, p.stepDepth, p.class]).toEqual(['full', 'standard', 'code']); + expect(roles(p).filter(r => r.startsWith('outside-voice') || r.startsWith('adversarial'))).toEqual(['outside-voice:outside-voice:host']); + expect(p.skipped).toContain('adversarial-native (run once per invocation)'); + expect(p.skipped.some(s => s.includes('outside-voice'))).toBe(false); + }); + test('a gate-class pass 2 lists the outside voice again after Step 11 ran (GST-4140)', () => { + const p = planReview(base({ gateTagged: 1, adversarialRan: true, history: { fullPasses: 1, last: 'full', fixedBelow: true } })); + expect([p.next.step, p.class]).toEqual(['full', 'gate']); + expect(roles(p)).toContain('outside-voice:outside-voice:host'); + }); + test('the read-only final review of a code or gate diff lists both voices again after Step 11 ran (GST-4140)', () => { + for (const o of [{}, { gateTagged: 1 }]) { + const p = planReview(base({ ...o, adversarialRan: true, history: { fullPasses: 2, last: 'full', fixedBlocking: true } })); + expect([p.next.step, p.next.readOnly]).toEqual(['full', true]); + expect(roles(p)).toEqual(expect.arrayContaining(['adversarial-native:adversarial:full', 'outside-voice:outside-voice:host'])); + expect(p.skipped.some(s => s.includes('run once per invocation'))).toBe(false); + } + const priorFull = planReview(base({ gateTagged: 1, adversarialRan: true, history: { fullPasses: 0, last: 'none', priorFull: 2 } })); + expect([priorFull.next.readOnly, roles(priorFull)]).toEqual([true, expect.arrayContaining(['adversarial-native:adversarial:full', 'outside-voice:outside-voice:host'])]); + }); + test('a pass 2 whose fix range changes no runtime lines keeps the earlier outside read; light docs and tests diffs without numbers never gain one (GST-4140)', () => { + const quiet = planReview(base({ adversarialRan: true, history: { fullPasses: 1, last: 'full', fixedBlocking: true, touchedGate: true, rangeRuntimeLines: 0 } })); + expect([quiet.next.step, roles(quiet).some(r => r.startsWith('outside-voice'))]).toEqual(['full', false]); + expect(quiet.skipped).toContain('outside-voice (run once per invocation: the fix range changes no runtime lines)'); + for (const paths of [['docs/a.md'], ['test/a.test.ts']]) for (const history of [{ fullPasses: 1, last: 'full', fixedBelow: true }, { fullPasses: 2, last: 'full', fixedBlocking: true }] as const) { + const p = planReview(base({ paths, scope: {}, diffLines: 30, adversarialRan: true, history })); + expect([paths, history.fullPasses, roles(p).some(r => r.startsWith('outside-voice'))]).toEqual([paths, history.fullPasses, false]); + } }); test('a repeat that became code class keeps the adversarial pass Step 11 has not run yet', () => { const p = planReview(base({ history: { fullPasses: 1, last: 'full', fixedBlocking: true } })); @@ -644,7 +687,7 @@ describe('D6 retired: round 2 after a small blocking fix is a full pass, never a test('the #19 shape plans a full pass with the full-effort Red Team and the native adversarial again, never a fix-check', () => { const p = planReview(n19()); expect(p.next).toMatchObject({ step: 'full', keepReader: true, rangeReaders: true, reason: expect.stringContaining('24 runtime lines in the fix range: full pass on the range, never a scoped pass') }); - expect(roles(p)).toEqual(['specialist:batched:medium', 'red-team:red-team:full', 'adversarial-native:adversarial:full']); + expect(roles(p)).toEqual(['specialist:batched:medium', 'red-team:red-team:full', 'adversarial-native:adversarial:full', 'outside-voice:outside-voice:host']); expect(fixCheck(p)).toBe(false); expect(p.dispatches.some(d => d.role === 'red-team' && d.effort === 'full' && d.exclude.length === 0)).toBe(true); }); @@ -667,7 +710,7 @@ describe('D6 retired: round 2 after a small blocking fix is a full pass, never a test('a force-included specialist and changed published numbers keep their reviewers', () => { expect(batch(planReview(n19({ force: ['security'] })))).toContain('security'); const numbers = scanNumbers({ 'docs/bench.md': ['3x faster'] }); - expect(roles(planReview(n19({ numbers, reviewedNumbers: 'old' })))).toContain('outside-voice:outside-voice (numbers changed):host'); + expect(roles(planReview(n19({ numbers, reviewedNumbers: 'old' })))).toContain('outside-voice:outside-voice:host'); expect(roles(planReview(n19({ numbers, reviewedNumbers: numbers.fingerprint })))).not.toContain('outside-voice:outside-voice (numbers changed):host'); }); // Value: protects=main's scoped pass dispatched a forced specialist on its own with no exclusion, so a forced checklist keeps reading the docs and outputs the batched reader would exclude; fails_when=a docs-only blocking fix with --force security plans a batched security reader that excludes the docs it should read; @@ -692,7 +735,7 @@ describe('D6 retired: round 2 after a small blocking fix is a full pass, never a test('a light diff with a fixed blocker gets the full pass at standard: the raise adds the Red Team', () => { const p = planReview(mixed({ perPath: per({ 'src/app.ts': 30 }), history: fixed(12), adversarialRan: true })); expect([p.next.step, p.stepDepth, fixCheck(p)]).toEqual(['full', 'standard', false]); - expect(roles(p)).toEqual(['specialist:batched:medium', 'red-team:red-team:full', 'adversarial-native:adversarial:full']); + expect(roles(p)).toEqual(['specialist:batched:medium', 'red-team:red-team:full', 'adversarial-native:adversarial:full', 'outside-voice:outside-voice:host']); }); test('the full round 2 counts toward the cap: a fix after it gets the read-only full review, a blocker it leaves stops for the owner, and an old scoped row still counts as a round', () => { expect(nextStep(fixed(10, { fullPasses: FULL_PASS_CAP }), 'standard')).toMatchObject({ step: 'full', reason: expect.stringContaining('read-only final review (R51)') }); diff --git a/test/review-pass-step11.test.ts b/test/review-pass-step11.test.ts index eccff7fe0..4c1dc40cc 100644 --- a/test/review-pass-step11.test.ts +++ b/test/review-pass-step11.test.ts @@ -76,7 +76,7 @@ describe('Capy pass program (fake host, real bins)', () => { expect(h.creates.find(c => c.title === 'ship x7p1 adversarial-native')!.model).toEqual(models['adversarial-native']); }, 240_000); - // Value: protects=Step 11's outside voice is never the native voice's or the lane's model family; fails_when=the STOP checks only that some model was given (lib/capy-review-pass.js before GSTA-167 PR B), so a Claude outside voice beside a Claude native voice runs as "outside"; + // Value: protects=Step 11's outside voice is never the native voice's or the lane's model family; fails_when=the STOP checks only that some model was given (lib/capy-review-pass.js before GSTA-167 PR B), so a Claude outside voice beside a Claude native voice runs as "outside", or an alias prefix collect reads as the same family (particle/ is deepseek) runs and is then refused at collect (Step 11 outside-voice#3 on #4886); // why_new=GSTA-167 plan R2 (autoplan-20261031135232); seam=none; no_claim=which family pairs find more test('a same-family explicit outside voice STOPs before either voice is created', async () => { const { dir, env } = repo(); @@ -87,6 +87,8 @@ describe('Capy pass program (fake host, real bins)', () => { .toContain("STOP: the outside voice anthropic/claude-sonnet-5-5 is the anthropic family, the same as the lane model; Step 11 needs input.models['outside-voice'] from another family"); expect(await runPass(h, { ...base, stage: 'voices', models: { 'outside-voice': { model_id: 'openai/gpt-6.2-sol', reasoning_mode: 'medium' }, 'adversarial-native': { model_id: 'openai/gpt-6-astra', reasoning_mode: 'high' } } })) .toContain('STOP: the outside voice openai/gpt-6.2-sol is the openai family, the same as the native voice'); + expect(await runPass(h, { ...base, stage: 'voices', laneModel: 'deepseek/deepseek-v4-pro', models: { 'outside-voice': { model_id: 'particle/particle-1' }, 'adversarial-native': { model_id: 'deepseek/deepseek-v4-pro' } } })) + .toContain('STOP: the outside voice particle/particle-1 is the deepseek family, the same as the native voice'); expect(h.creates.some(c => /^ship x14p1 (adversarial-native|outside-voice)$/.test(c.title))).toBe(false); }, 240_000); diff --git a/test/review-pass.test.ts b/test/review-pass.test.ts index 687dcd955..cd777c5cc 100644 --- a/test/review-pass.test.ts +++ b/test/review-pass.test.ts @@ -284,7 +284,7 @@ describe('round 2 after a small blocker fix is a full pass in the manifest (GST- test('after Step 11 ran (--adversarial-ran), the driver\'s --diff-base RANGE_BASE stages every reader on the fix range, the native adversarial included', () => { const s = round2(['--adversarial-ran'], 'range'); expect(s.m.diff_base).toBe(s.rangeBase); - expect(s.m.readers.map(r => [r.reader, r.diff_base ?? null])).toEqual([['specialist-batched', null], ['red-team', null], ['adversarial-native', null], ['audit/plan', null]]); + expect(s.m.readers.map(r => [r.reader, r.diff_base ?? null])).toEqual([['specialist-batched', null], ['red-team', null], ['adversarial-native', null], ['outside-voice', null], ['audit/plan', null]]); }, 120_000); // Value: protects=an explicit --diff-base reaches every reader, the Red Team included; fails_when=a round 2 asked to read the whole branch still stages its Red Team on the fix range; why_new=GST-738 (outside voice); seam=none; no_claim=none diff --git a/test/review-plan-cli.test.ts b/test/review-plan-cli.test.ts index 6dde86d3b..ffa74d856 100644 --- a/test/review-plan-cli.test.ts +++ b/test/review-plan-cli.test.ts @@ -151,7 +151,7 @@ describe('gstack-review-plan', () => { expect(spawnSync(BIN, [], { encoding: 'utf8', timeout: 10_000 }).status).toBe(2); expect(run(repo({ 'a.md': 'x' }), ['--last', 'later']).status).toBe(2); }); - test('scratch under .gstack/tmp/ is ignored, a subdirectory run plans the whole repository, and --adversarial-ran drops the repeat adversarial pass', () => { + test('scratch under .gstack/tmp/ is ignored, a subdirectory run plans the whole repository, and --adversarial-ran drops the repeat adversarial pass but keeps the outside voice on code (GST-4140)', () => { const r = repo({ 'docs/a.md': '# a\n' }); fs.mkdirSync(path.join(r.dir, '.gstack', 'tmp'), { recursive: true }); fs.writeFileSync(path.join(r.dir, '.gstack', 'tmp', 'fix-check-list.ts'), 'export const x = 1;\n'); @@ -165,7 +165,8 @@ describe('gstack-review-plan', () => { expect(run(code, repeat).stdout).toContain('DISPATCH: adversarial-native adversarial effort=full'); const ran = run(code, [...repeat, '--adversarial-ran']).stdout; expect(ran).not.toContain('DISPATCH: adversarial-native'); - expect(ran).toContain('SKIP: adversarial-native and outside-voice (run once per invocation)'); + expect(ran).toContain('SKIP: adversarial-native (run once per invocation)'); + expect(ran).toContain('DISPATCH: outside-voice outside-voice effort=host'); }); }); @@ -228,10 +229,11 @@ describe('gstack-review-plan: the full round 2 on a small fix range (GSTA-152 D6 } const pass2 = ['--pass', '1', '--last', 'full', '--fixed-blocking', '--adversarial-ran', '--pass1-depth', 'standard']; const full1 = ['--pass', '1', '--last', 'full', '--fixed-blocking', '--adversarial-ran', '--pass1-depth', 'full']; - test('--range-base with a small fix range plans a full pass 2 with the batched specialist, the Red Team and the native adversarial, and no fix-check', () => { + test('--range-base with a small fix range plans a full pass 2 with the batched specialist, the Red Team, the native adversarial and the outside voice, and no fix-check', () => { const { r, rangeBase } = fixed(24); const out = run(r, [...pass2, '--range-base', rangeBase]).stdout; - expect(out).toMatch(/^REVIEW_PLAN: class=code pass=2 next=full dispatches=3 /m); + expect(out).toMatch(/^REVIEW_PLAN: class=code pass=2 next=full dispatches=4 /m); + expect(out).toContain('DISPATCH: outside-voice outside-voice effort=host'); expect(out).toContain(`FIX_RANGE: runtime_lines=24 base=${rangeBase}`); expect(out).toMatch(/^NEXT: full \(a blocking finding was fixed on a light diff with 24 runtime lines in the fix range: full pass on the range, never a scoped pass, so every reader is in the pass record \(GST-3562\)\)$/m); expect(out).not.toContain('DISPATCH: fix-check'); diff --git a/test/review-risk-token-paths.test.ts b/test/review-risk-token-paths.test.ts index 90f942235..754ab006d 100644 --- a/test/review-risk-token-paths.test.ts +++ b/test/review-risk-token-paths.test.ts @@ -15,6 +15,7 @@ import { depthOfCommitInput, isGatePath, planReview, ROLE_EFFORT, scanNumbers } import { matchRisk, secretPath } from '../lib/review-risk'; import { targetedClasses } from '../lib/review-targeted'; import { asMainBeforeGst3562 } from './helpers/gst3562-replay'; +import { asMainBeforeGst4140 } from './helpers/gst4140-replay'; const GODOT_TOKENS = ['class_name UIToken', 'extends RefCounted', 'const COLOR_PRIMARY := Color("#ff6a00")', 'const SPACING_MD := 12', 'const LABEL_PLAY := "Play"']; const BENIGN: Record = { @@ -158,6 +159,7 @@ describe('GST-1350 no-loss check', () => { 'tokens-db': ['cache/tokens.db', 'cache/tokens.db', []], }; const gst3562: Record = {}; + const gst4140: Record = {}; type Row = { name: string; fullPasses: number; last: string; bits: number; adversarialRan: boolean; targeted: string[]; class: string; depth: string; step: string; dispatches: { role: string; name: string; effort: string; checklists: string[] }[] }; const grid = (pick: 0 | 1) => { const rows: Row[] = []; @@ -170,7 +172,9 @@ describe('GST-1350 no-loss check', () => { const input = { paths, added, removed: {}, scope: {}, gateTagged: 0, diffLines: 40, consumed: [], numbers: none, history, adversarialRan, targeted: { classes: t } }; const replay = asMainBeforeGst3562(input, planReview(input)); if (replay.kind) gst3562[`${pick}:${replay.kind}`] = (gst3562[`${pick}:${replay.kind}`] ?? 0) + 1; - let p = replay.plan; + const back = asMainBeforeGst4140(input, replay.plan); + if (back.kind) gst4140[`${pick}:${back.kind}`] = (gst4140[`${pick}:${back.kind}`] ?? 0) + 1; + let p = back.plan; if (pick && last === 'full' && bits === 8) { expect(['full', 'stop', 'voices']).toContain(p.next.step); p = planReview({ ...input, history: { ...history, touchedGate: false } }); @@ -209,5 +213,6 @@ describe('GST-1350 no-loss check', () => { 'token-json: gate/full -> gate/full': 288, 'tokens-db: gate/full -> gate/full': 288, }]); expect(gst3562).toEqual(GST3562_1350_CASES); + expect(gst4140).toEqual({ '0:outside': 398, '1:outside': 388 }); }); });