mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-26 14:50:55 +02:00
* fix: acknowledge seeded plans before invoking review skills * fix: distinguish current plan input from conversation history * fix: keep hermetic plan reviews on manual permissions * fix: distinguish tool discovery from file permission ownership * fix: preserve initial plan mode in observation tests * fix: wait for scope decisions before writing review findings * fix: carry autoplan decisions consistently into review artifacts * test: retain native failure context in periodic assertions * fix: advance active file permissions before queued questions * fix: finish red-team attempts before retry and cleanup * fix: finalize plan format captures and judges before retry * fix: cancel setup-gbrain SDK attempts before fixture cleanup * test: select periodic consumers of the bounded attempt helper * fix native Bash permission cards and queued questions * fix: preserve independent decisions and review scope Keep CEO approach, engineering scope and outside-review choices from approving independent remedies together. Carry declared contracts through DX polish and resolve new gaps before editing the plan. Regenerate every host and retain existing stop boundaries. Validation: 654 focused tests passed across nine files; all-host generation passed. Full free and periodic validation pending. Co-Authored-By: OpenAI Codex <noreply@openai.com> * fix: require approval before design plan amendments Align the Design review philosophy and rating recipe with its section protocol: resolve one proposed fix, then apply only that approved decision and retain honest scores for declined fixes. Validation: 469 focused tests passed across four files; all-host generation passed. Co-Authored-By: OpenAI Codex <noreply@openai.com> * fix: observe native question completion before transcript persistence Match owned completion hooks to submitted choices, reject conflicting or late answers, and retain bounded failure evidence. * test: recognize review posture in acknowledged native questions Require the selected mode acknowledgement, a completed follow-up question, and its current decoded display while preserving existing posture assertions. * fix: preserve settled CEO choices and isolate pending remedies Resolve established approach gates with cited authority and keep independent fixes out of unrelated option commitments and plan amendments. * fix: carry approved DX choices through later review steps Choose documentation approaches within the accepted scope and map resolved confusion points without reopening them through a bulk menu. * test: handle native settings-file edit prompts Keep one-time owned-file approvals and retain the actual sampled Autoplan permission frame with its matching barrier state. * test: accept standard CEO reply directives with tuning footers Recognize the exact trailing preference footer and letter-list directive while preserving current-display and exact acknowledgement checks. * test: scope split reviewers to their generated plan artifacts * test: observe native Bash permissions and invocation results * test: handle owned Bash prompts during mode preference checks * test: preserve synchronous subprocess rejection in Codex fixture * Fix periodic review handoff navigation Recognize review-first and explicit manual-next-step labels while preserving exact action families, manual preference, and ambiguous-menu rejection. Co-authored-by: OpenAI Codex <noreply@openai.com> * Bind pending file permissions to distinct current targets Allow one captured file request to own the complete current dialog while unrelated file work is pending. Preserve same-path ambiguity, exact input ownership, and one-time grant checks. Co-authored-by: OpenAI Codex <noreply@openai.com> * Make paired CEO verification choices genuinely unresolved Start the positive control with proposed manual checks so its unchanged oracle measures two new coverage decisions. Preserve runtime contracts, targets, count bounds, and all assertions. Co-authored-by: OpenAI Codex <noreply@openai.com> * Keep CEO review options and verification within approved scope Audit every offered option for independent add-ons and keep new verification depth pending until accepted. Preserve already requested coverage and trace plan changes to the actual decision. Co-authored-by: OpenAI Codex <noreply@openai.com> * Assemble DX review artifacts before appending the final report Keep early DX evidence above decisions, update artifact sections in place, and append the report using the actual current file suffix. Re-read after deleting an existing report before choosing the append anchor. Co-authored-by: OpenAI Codex <noreply@openai.com> * Keep outside plan reviews exclusive and invocation-owned Follow one preflight-selected backend, terminate failed Codex work before fallback, and allocate extra prompt/output files uniquely. Consume only the current invocation’s completed output. Co-authored-by: OpenAI Codex <noreply@openai.com> * Select periodic completion evaluations for report writer changes Register the shared review resolver for eight missing consumers and regress selection for all nine completion cases without changing their IDs or tiers. Co-authored-by: OpenAI Codex <noreply@openai.com> * Keep permission ambiguity fixtures on the same normalized target Use distinct raw spellings of one target in the four negative fixtures so they exercise the normalized duplicate-owner guard after exact current-file disambiguation. Preserve the existing exception, no-input, diagnostic and cleanup assertions. Co-authored-by: OpenAI Codex <noreply@openai.com> * Clarify preserved contracts in engineering review fixture Co-authored-by: OpenAI Codex <noreply@openai.com> * Recognize the offered DX follow-up handoff Co-authored-by: OpenAI Codex <noreply@openai.com> * Check independent commitments before presenting review options Co-authored-by: OpenAI Codex <noreply@openai.com> * Keep Codex review output and status in one shell invocation Co-authored-by: OpenAI Codex <noreply@openai.com> * Distinguish seeded plans from reports written by a test attempt Co-authored-by: OpenAI Codex <noreply@openai.com> * Recover clipped Autoplan file approvals with bounded viewport resizing Co-authored-by: OpenAI Codex <noreply@openai.com> * Recover clipped Bash approvals before binding the complete command Co-authored-by: OpenAI Codex <noreply@openai.com> * Isolate setup message tests from the shared checkout Run the real installer in a temporary payload with private config, require successful completion, and guard source and binary contents and mtimes. Co-authored-by: OpenAI Codex <noreply@openai.com> * Fix periodic native permission and report completion handling Match the pinned CLI's soft wraps and clipped headings without granting from incomplete frames. Retire completed file requests, retain mode annotations, and ask section captures for a short final acknowledgement after their full report is saved. Co-authored-by: OpenAI Codex <noreply@openai.com> * Preserve review approvals and validate DX comparison artifacts Keep independent remedies and approved amendments explicit. Give the synthetic DX review its existing documentation and validate peer comparison as required analysis alongside four native decisions. Add positive and negative semantic calibrations while preserving review counts, model budgets and prompt size limits. Co-authored-by: OpenAI Codex <noreply@openai.com> * Make the five-finding CEO fixture's application boundary explicit Materialize the request adapter and service composition used by the synthetic payment application. Explicitly declare the revised unregistered-event and mail-telemetry assumptions while preserving uncaught handler errors, the original invoice path and all five unresolved findings. Co-authored-by: OpenAI Codex <noreply@openai.com> * Keep CEO state-path checks scoped to directory preparation Co-authored-by: OpenAI Codex <noreply@openai.com> * Use checked ports and bounded cleanup in pair-agent tests Discover the daemon port from its owned state file, retain startup diagnostics, and await failed-start cleanup. Add occupied-port, early-exit, deadline, and foreign-state regressions while preserving the existing HTTP assertions and hook budgets. Co-authored-by: Codex <noreply@openai.com> * Preserve queued edit identity and recover clipped Bash permissions Distinguish separately queued unfinished edits from mutation of one native tool ID. Keep grants bound to an exact owned request and reject reused IDs, ambiguous inputs, and competing owners. Support the pinned renderer's literal em dash and request a repaint when only the Bash card's top rule is clipped. Grants still require the complete fresh card and an exact native acknowledgment. Validation: 413 integrated parser/event tests passed; private repaint controls and joint source review passed. Full canonical suite and native periodic rerun remain pending. Co-authored-by: Codex <noreply@openai.com> * Keep periodic reviews within their approved contracts and deliverables Carry exact approvals through engineering review, preserve declared contracts when amending CEO plans, and keep prioritization at the requested decision level. Materialize the revised synthetic SDK reference contract while retaining the five original documentation gaps. Accept the observed semicolon in the finite DX handoff menu and register the direct source dependencies used by the engineering cases. Regenerate canonical review documents without changing model budgets, retries, count bands, or native completion assertions. Validation: all-host generation and 275 review, fixture, selection and parity tests passed. Full free-suite and native periodic validation remain pending. Co-authored-by: Codex <noreply@openai.com> * Keep Eng approval cadence and independence guards explicit * Accept ordinary punctuation in manual review handoffs * Recover file permissions alongside queued Bash calls * Carry approved DX work through later review findings * Clarify the synthetic auth internal failure decision * Bound the periodic DX fixture to onboarding changes * Recognize native Design review handoff labels * Hold scope in the integration-choice review fixture * Carry approved Design decisions through review evidence * Capture listener state when feedback reload fails * Exclude workspace caches before checking deprecated flags * Verify Design UI scope against a seeded review plan * Clarify plan review decisions and outside-voice approval flow * Reject setup menus in the Design UI gate * docs: require focused repair validation before final acceptance * fix: separate review commitments within existing prompt budgets * docs: align generation and contributor validation guidance * fix: advance native review prompts and count acknowledged findings * chore: bump version and changelog (v1.87.1.0) Co-Authored-By: OpenAI Codex <noreply@openai.com> * chore: enforce cheap checks and side-effect-free validation previews * fix: handle owned Fetch permissions and oversized native cards * test: ground review fixtures in independent executable contracts * fix: preserve review decisions and verify reports before completion * test: construct the synthetic credential URL without a scanner false positive * test: materialize DX examples and verify their actual local behavior * fix: clarify CEO review decisions and execution order * fix: clarify review workflow ordering and select Design quality checks * Fix review decision gates and incomplete evaluation fixtures Persist CEO and engineering commitment ledgers before menus, preserve exact approvals, and distinguish implementation structure from feature scope. Route Autoplan through the canonical CEO Step 0 ordering. Classify DX findings before requesting approval and ground runtime claims in actual evidence. Complete neutral non-target fixture contracts and accept the captured Design handoff purpose without relaxing its ownership or acknowledgment checks. Record runtime-capability verification in AGENTS.md validation discipline. Validation: 1,335 focused tests passed across 21 files; build, all-host freshness, skill validation (647 artifacts / 107 tracked), and credential checks passed. Prior paid failures are preserved; behavioral acceptance remains pending. * Fix review decision boundaries and owned Read prompts Preserve exact approvals across review options, compare consistent DX milestones, and keep proposed implementation separate from review evidence. Bind modern Read prompts to one immutable native request and wait for its result. Retain captured regression verdicts, correct fixture error names, improve import probe diagnostics, and record focused-first validation discipline in AGENTS.md. * Clarify CEO and engineering review decisions Use explicit decision steps, one engineering ledger, and clear scope/write transitions. Preserve exact approvals and distinguish pending test requirements. Keep unrelated generated content unchanged. * Fix review decision ordering and native evaluation interactions * Clarify engineering decisions and test artifact order * Clarify pending choices and approvals in CEO reviews * Make CEO review phases sequential and clarify completion * Fix Design board submission intent matching * Seed an existing browser test baseline for Autoplan * Document decision-log payloads before state initialization * Preserve exact review scope and decide one change before drafting options * Require input identity before repeating passing model judges * Honor permitted storage throughout CEO review completion * Match complete native permission text within the pinned renderer contract * Align review approvals, independent choices, and bounded validation * fix: preserve reopened approvals and declare fixture interfaces * fix: isolate review artifacts and audit complete questions * fix: match detector artifact permissions to configured storage * fix: complete native permissions and review fixture workflows * fix: order CEO review work and separate engineering guarantees * fix: preserve native validation and separate review choices * fix: clarify review decisions and judge complete report context * fix: constrain review judgments and retain parse failures * fix: compare each affected value before review decisions * fix: make engineering review decisions and completion order explicit * fix: give the complete Autoplan evaluation a bounded chain budget * fix(cso): diagnose forbidden Docker endpoints before tool lookup * fix(reviews): reconcile workflow contracts and generated artifacts after main integration * fix(evals): migrate retained regressions to the native review harness * fix(tests): close native harness and workflow integration regressions * fix(evals): preserve complete permission context and native menu contracts * fix(tests): capture synchronous command output without pipe drain stalls * fix(reviews): clarify decision and completion ordering * fix(reviews): separate decision readiness from final completion checks * refactor(reviews): consolidate decision rules and completion branches * fix(plan-eng-review): order preparation and clarify decision routing * fix(plan-eng-review): restore size and question-format guard parity * fix(plan-eng-review): clarify scope phases and blocked completion * fix(plan-eng-review): unify review flow and report destination * fix(plan-eng-review): define bootstrap and question stage ownership * fix(plan-eng-review): clarify review structure and design lookup * fix(plan-eng-review): render report examples and show saved decisions * fix: consolidate Eng review decisions and select their evaluations * test: cover overlapping terminal attachments and clean merged runner type * fix: preserve Office Hours relationship closings during review updates * fix: retain pasted review targets across slash invocations * docs: preserve validation traces and correct release scope * test: cover pasted targets in both review skills * fix: validate report artifacts before recording success * fix: redact source roots at CSO report boundaries * fix: bind native Design questions before answering * test: select report privacy and native recovery regressions * test: bind rejection predicate in extracted observers * fix: bind complete boxed native questions * test: keep the Design UI fixture on native review * fix: preserve review decisions and evaluation completion outcomes * fix: clarify CEO approval and report completion order * fix: align native review evaluation ownership and completion * fix: bind review evaluators to native decisions and owned artifacts * fix: validate review decisions against native outcomes * fix: preserve review evidence and Autoplan phase handoffs * test: bind review evidence to owned decisions and completion * fix: retain owned native history across compaction * fix(evals): validate current review decisions and setup choices * fix: bind Autoplan reviews and phase completion to current amended input * fix: reconcile native review evidence and close Autoplan phases * test: recognize owned whole-candidate complexity decisions * test: preserve report freshness for approved investigation handoffs * fix: recognize scoped review findings and isolate dual voice fixtures * fix: make review handoffs and question dispatch self-contained * test: recognize complete CEO decisions and procedural pauses * fix: bind current CEO comparison options and risk intervals * test: bind engineering decisions and completion to owned evidence * fix: publish Autoplan phase reports before continuing tools * test: verify actual Autoplan dual-review dispatch evidence * test: select dual review when shared evidence fixtures change * fix: clarify plan review decisions and completion gates * fix: make CEO review decisions and return paths explicit * test: keep Autoplan prompt files inside attempt state * test: preserve source whitespace across permission dialog wraps * fix: publish Autoplan phase reports before continuing * test: recognize current CEO comparisons and reject inactive records * fix: reconcile engineering decision states before completion * test: recognize complete Design decisions and reports * test: verify current engineering decisions before navigation * Recognize source-owned component reduction choices * fix: recognize current CEO ledger and commitment grids * test: supply RequestPolicy context to Eng count fixture * fix: save complete engineering decisions before asking * fix: bind Autoplan publication to the complete phase readback * chore: prepare 1.87.5.0 reliability release * fix: clarify engineering review completion and preserve log failures * fix: bind CEO saved choices and current section ancestry * fix(evals): bind review execution and completion evidence * fix(plan-ceo-review): verify complete decisions before asking * fix(evals): preserve complete engineering choice records * fix(evals): preserve complete review outcomes and bounded fixtures * fix(autoplan): publish phase reports before advancing * fix(plan-ceo-review): validate option fields before asking * fix(plan-eng-review): verify current decisions after answers * fix(evals): bind review decisions and bound fixture scope * fix(plan-ceo-review): verify decision rows and edit saved checkpoints * fix(evals): bind review evidence and scope document lookup * fix(plan-eng-review): update resolution state with its answer * fix(reviews): preserve complete questions through dispatch * fix(evals): recognize completed mode declarations * fix(evals): define cache consistency at wrapper completion * fix(evals): validate owned initial scope and completed review handoffs * fix: assemble complete CEO decision fields before saving * fix: authenticate automatic mode decisions without guessing selectors * fix: bind engineering coverage to approved regression contracts * fix(evals): supply review helpers to native Eng capture * fix(plan-eng-review): preserve the full selected option scope * fix(evals): recognize owned engineering seed and regression evidence * fix(evals): bind engineering retry reports to native approvals * docs: clarify release guarantees (v1.87.5.0) Co-Authored-By: OpenAI Codex <noreply@openai.com> * fix(evals): recognize owned engineering decisions and handoffs * fix(evals): bind engineering decisions and completion evidence * fix(tests): align review contracts and selection fixtures * fix(skills): restore review prompt size limits * fix(plan-eng-review): clarify review execution and completion * fix(evals): preserve configured retries through all supervision layers * Clarify Engineering decisions and report completion * Keep native decision assertions within their source boundary * fix: recognize owned engineering decisions and completed navigation * fix: bind completed auto decisions to their current review * fix: recognize explicit CEO source attribution * fix: dispatch verified CEO decisions without recomposing fields * test: expose existing execution deadlines to review actors * fix: distinguish CEO decision records from incidental headings * test: bind split-scope choices to the registered native actor * test: connect reviewed regressions to required evaluation coverage * Clarify CEO decision routing and completion stages * test: expose existing section review deadlines to fixture actors * test: recognize complete native CEO pacing inventories * test: exclude answered history from current CEO payloads * test: detect phase entry through owned skill HOME aliases * test: validate native review completion and owned report permissions * fix: make Autoplan close packets carry the parent handoff steps * test: assess source-bound HOLD decisions within the existing deadline * fix: keep CEO native decision fields under one formatting authority * test: register integrated review and permission dependencies * test: align native review adapters and finding coverage Preserve explicit AUTO decisions, apply native single-select defaults, and bind complete cropped questions and report permissions to their owned requests. Require seeded review findings instead of crediting setup menus. Keep captured failure controls and additive selection dependencies. The integrated candidate passed 3,099 focused tests across 65 files; affected paid validation remains required before publication. * fix(autoplan): require phase reports before advancing * fix(evals): bind setup and evidence to complete attempts * fix(evals): bind native answers and pending writes to fixture scope Preserve complete option rows when native descriptions wrap, retain current owned Write arguments before journal publication, and keep engineering and DX answers within their declared fixture interfaces. Add captured free regressions without increasing model budgets or relaxing completion checks. * fix(autoplan): verify phase reports across native tool paths Guard owned methodology reads and reviewer dispatches, detect complete driver loads through Bash, and distinguish report-only edits from implementation changes. Follow authenticated native UUID ancestry when journal writes arrive out of order and verify earlier native content for cached phase reads. Keep current close acknowledgment and parent publication in order, require CEO entry before later phases, and register captured failure regressions. * fix(evals): honor native input and collection lifecycles Match complete native Edit panes and truncated question borders, reject stderr close before EOF, and stop the CEO split fixture once its acknowledged scope decisions are collected. Keep semantic validation, process failures, report requirements, and absolute deadlines authoritative. Add captured-event and real-process regressions with selection dependencies. Focused checks pass; final integrated paid and full-suite acceptance remain pending. * fix(autoplan): retain native session ownership across directory changes Recover missed native UUID ancestry through the existing strict graph while preserving ordinary event order and legacy scoping. Bind publication hooks to Claude's original project directory while retaining current cwd for requested file paths. Captured public-event regressions, existing caller checks, and a pinned native CLI loopback verify both fixes. Preserve failed attempts and require fresh paid and final full-suite acceptance. * docs: align evaluation limits and completion version * fix(autoplan): allow authenticated phase reads during journal streaming * fix(evals): bind clipped native questions and owned edit dialogs * fix: preserve overlay retries and bounded cleanup * fix: recognize owned planning preludes in native questions * docs: explain overlay scheduling and cleanup guarantees * fix: require fresh publication after Autoplan phase reruns * Release gstack 1.87.6 * fix: preserve CI paths, process identity, and test deadlines * fix: keep informational setup commands independent of install probes * fix: clarify plan review decisions and bound source audit reports * Fix remaining Windows identity and native path CI failures * Clarify CEO review decision and reviewer-result routing * test: accept no-install planner in retry supervision * fix(ceo-review): make review decisions and report completion explicit * perf(test): add fast PR gates, input-keyed judge reuse and isolated free shards * fix(test): start isolated CEO smoke from its existing project plan * fix(test): repair CI fixture races and preserve retry evidence * fix(ceo-review): clarify approvals, depth and saved completion --------- Co-authored-by: OpenAI Codex <noreply@openai.com>
1023 lines
68 KiB
TypeScript
1023 lines
68 KiB
TypeScript
/** Native completion/report regression; no model/API calls. */
|
||
import { 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 { pathToFileURL } from 'node:url';
|
||
import { hasNativePlanCompletion, hasNativePlanTerminal, isPlanReadyVisible, classifyPlanCountFrame, isNumberedOptionListVisible, isPermissionDialogVisible, isProseAUQVisible, assertReviewReportAtBottom } from './helpers/claude-pty-runner';
|
||
import type { PlanCountTranscript } from './helpers/plan-count-transcript';
|
||
import capturedL from './fixtures/devex-review-l-calls.json';
|
||
import designStatusCapture from './fixtures/design-count-native-issue-fields.json';
|
||
import designEnvelope from './fixtures/design-completion-envelope-90f.json';
|
||
|
||
describe('captured Design completion envelope', () => {
|
||
function completedEnvelope() {
|
||
const dir=fs.mkdtempSync(path.join(os.tmpdir(),'design-completion-envelope-'));
|
||
const file=path.join(dir,'design-review.md');
|
||
const transcript=structuredClone(designEnvelope.transcript) as PlanCountTranscript;
|
||
const final=transcript.assistantMessages.at(-1)!;
|
||
final.text=final.text.replaceAll(designEnvelope.originalPlanPath,file);
|
||
const write=(report=designEnvelope.report)=>{fs.writeFileSync(file,report);fs.utimesSync(file,designEnvelope.reportMtimeMs/1000,designEnvelope.reportMtimeMs/1000);};write();
|
||
const check=()=>hasNativePlanTerminal(transcript,file,designEnvelope.startedAt,'completion_summary');
|
||
return {file,transcript,final,write,check,cleanup:()=>fs.rmSync(dir,{recursive:true,force:true})};
|
||
}
|
||
test('saved report annotation and punctuated DONE retain the manual plan-mode handoff',()=>{
|
||
const f=completedEnvelope();try {
|
||
expect(classifyPlanCountFrame(designEnvelope.screen)).toBeNull();
|
||
expect(hasNativePlanCompletion(f.transcript,f.file,designEnvelope.startedAt)).toBe(false);
|
||
expect(f.check()).toBe(true);
|
||
expect(hasNativePlanTerminal(f.transcript,f.file,designEnvelope.startedAt,'plan_ready')).toBe(false);
|
||
}finally{f.cleanup();}
|
||
});
|
||
test('the actual runner branch recognizes the idle native envelope without answering an exit gate',()=>{
|
||
const f=completedEnvelope();try {
|
||
const source=fs.readFileSync(path.join(import.meta.dir,'helpers/claude-pty-runner.ts'),'utf8');
|
||
const expression=/const nativeSummary = ([\s\S]+?);\n const terminalFrame/.exec(source)?.[1];expect(expression).toBeTruthy();
|
||
const evaluate=new Function('opts','nativeCompletion','renderedFrame','visible','transcript','startedAt','administrative',
|
||
'isNumberedOptionListVisible','isPermissionDialogVisible','isProseAUQVisible','hasNativePlanTerminal',`return (${expression});`);
|
||
const screen=designEnvelope.screen.replaceAll(designEnvelope.originalPlanPath,f.file);
|
||
const check=()=>evaluate({expectedPlanPath:f.file},hasNativePlanCompletion(f.transcript,f.file,designEnvelope.startedAt),classifyPlanCountFrame(screen),screen,f.transcript,
|
||
designEnvelope.startedAt,new Set(),isNumberedOptionListVisible,isPermissionDialogVisible,isProseAUQVisible,hasNativePlanTerminal);
|
||
expect(check()).toBe(true);
|
||
const paid=fs.readFileSync(path.join(import.meta.dir,'skill-e2e-plan-design-finding-count.test.ts'),'utf8');
|
||
const start=paid.indexOf(" if (!['plan_ready', 'completion_summary', 'ceiling_reached'].includes(obs.outcome))");
|
||
const end=paid.indexOf('\n } finally {',start);expect(start).toBeGreaterThan(0);expect(end).toBeGreaterThan(start);
|
||
const validate=new Function('fs','planPath','obs','FLOOR','CEILING','assertReviewReportAtBottom',new Bun.Transpiler({loader:'ts'}).transformSync(paid.slice(start,end)));
|
||
const obs={outcome:'completion_summary',reviewCount:5,step0Count:3,elapsedMs:0,fingerprints:[],evidence:screen};
|
||
expect(()=>validate(fs,f.file,obs,4,7,assertReviewReportAtBottom)).not.toThrow();
|
||
expect(()=>validate(fs,f.file,{...obs,outcome:'timed_out'},4,7,assertReviewReportAtBottom)).toThrow('finding-count FAILED');
|
||
expect(()=>validate(fs,f.file,{...obs,reviewCount:3},4,7,assertReviewReportAtBottom)).toThrow('BAND FAIL');
|
||
expect(()=>validate(fs,f.file,{...obs,reviewCount:8},4,7,assertReviewReportAtBottom)).toThrow('BAND FAIL');
|
||
f.transcript.calls[0]!.answered=false;expect(check()).toBe(false);
|
||
}finally{f.cleanup();}
|
||
});
|
||
for(const [name,edit] of Object.entries({
|
||
'exclamation status':(s:string)=>s.replace('STATUS: DONE.','STATUS: DONE!'),
|
||
'status without extra closure':(s:string)=>s.replace(/\*\*STATUS: DONE\.\*\*[^\n]+/,'STATUS: DONE.'),
|
||
'equivalent read-only closure':(s:string)=>s.replace('No unresolved decisions. Staying in plan mode; nothing outside the plan file was edited.','No open design findings. Remaining in plan mode; no implementation has been started.'),
|
||
'equivalent persisted annotation':(s:string)=>s.replace('report is the last section, read-back verified','saved; review report is the final heading; verified by readback'),
|
||
'report field':(s:string)=>s.replace('- Plan: ','- Report: '),
|
||
}))test('completion envelope accepts '+name,()=>{
|
||
const f=completedEnvelope();try{f.final.text=edit(f.final.text);expect(f.check()).toBe(true);}finally{f.cleanup();}
|
||
});
|
||
for(const [name,edit] of Object.entries({
|
||
'foreign path':(s:string)=>s.replace('design-review.md','other-review.md'),
|
||
'path in quoted prose':(s:string)=>s.replace(/(- Plan: )(.+)/,'$1"$2"'),
|
||
'second path':(s:string)=>s.replace('(report is the last section, read-back verified)','(report is the last section, read-back verified) /other/plan.md'),
|
||
'second artifact field':(s:string)=>s+'\n- Report: /other/plan.md (saved)',
|
||
'historical annotation':(s:string)=>s.replace('read-back verified','historical example'),
|
||
'conditional annotation':(s:string)=>s.replace('read-back verified','read-back verified if approved'),
|
||
'pending read-back':(s:string)=>s.replace('read-back verified','read-back pending'),
|
||
'negated save':(s:string)=>s.replace('report is the last section, read-back verified','not saved'),
|
||
'quoted annotation':(s:string)=>s.replace('report is the last section, read-back verified','"saved"'),
|
||
'pending status':(s:string)=>s.replace('STATUS: DONE.','STATUS: PENDING.'),
|
||
'quoted status':(s:string)=>s.replace('**STATUS: DONE.**','`STATUS: DONE.`'),
|
||
'conditional status':(s:string)=>s.replace('STATUS: DONE.','STATUS: DONE if approved.'),
|
||
'pending native action':(s:string)=>s.replace('No unresolved decisions. Staying in plan mode; nothing outside the plan file was edited.','Please approve the remaining design choice.'),
|
||
'implementation action':(s:string)=>s.replace('Staying in plan mode','Starting implementation now'),
|
||
'conditional plan-mode closure':(s:string)=>s.replace('Staying in plan mode','Staying in plan mode until you approve the remaining decision'),
|
||
'unresolved qualifier':(s:string)=>s.replace('No unresolved decisions.','No unresolved decisions except the contrast issue.'),
|
||
'current reopened report':(s:string)=>s+'\nThe report is withdrawn.',
|
||
'current pending design':(s:string)=>s+'\nDesign review remains unresolved.',
|
||
'current quoted failure':(s:string)=>s+'\nThe report is "failed".',
|
||
'quoted full envelope':(s:string)=>'> '+s.replaceAll('\n','\n> '),
|
||
'historical envelope':(s:string)=>'Historical example:\n\n'+s,
|
||
'repeated status':(s:string)=>s+'\nSTATUS: BLOCKED',
|
||
}))test('completion envelope rejects '+name,()=>{
|
||
const f=completedEnvelope();try{f.final.text=edit(f.final.text);expect(f.check()).toBe(false);}finally{f.cleanup();}
|
||
});
|
||
test('the real envelope still requires completed owned calls and its fresh completed Design report',()=>{
|
||
const f=completedEnvelope();try {
|
||
const original=structuredClone(f.transcript);
|
||
for(const edit of [(t:PlanCountTranscript)=>{t.calls[0]!.answered=false;},(t:PlanCountTranscript)=>{t.calls[0]!.failed=true;},
|
||
(t:PlanCountTranscript)=>{t.calls[0]!.sessionId='foreign';},(t:PlanCountTranscript)=>{t.calls.at(-1)!.answeredAt=f.final.timestamp;},
|
||
(t:PlanCountTranscript)=>{t.assistantMessages.at(-1)!.timestamp='2999-01-01T00:00:00Z';},
|
||
(t:PlanCountTranscript)=>{t.planReadyRequests=[{sessionId:t.calls[0]!.sessionId,toolUseId:'failed-exit',timestamp:f.final.timestamp,failed:true}];}]){
|
||
Object.assign(f.transcript,structuredClone(original));edit(f.transcript);expect(f.check()).toBe(false);
|
||
}
|
||
Object.assign(f.transcript,structuredClone(original));
|
||
for(const body of ['# Draft',designEnvelope.report+'\n## Further work',designEnvelope.report.replace('DESIGN CLEARED','NOT CLEARED'),
|
||
designEnvelope.report.replace('NO UNRESOLVED DECISIONS','**UNRESOLVED DECISIONS:**\n- Missing decision')]){f.write(body);expect(f.check()).toBe(false);}
|
||
f.write();fs.utimesSync(f.file,1,1);expect(f.check()).toBe(false);
|
||
fs.utimesSync(f.file,Date.parse(f.final.timestamp)/1000+1,Date.parse(f.final.timestamp)/1000+1);expect(f.check()).toBe(false);
|
||
fs.rmSync(f.file);expect(f.check()).toBe(false);
|
||
}finally{f.cleanup();}
|
||
});
|
||
});
|
||
|
||
const CAPTURED_CALL = {
|
||
"sessionId": "b5c582af-870e-48ac-ac1e-c85458932136",
|
||
"toolUseId": "toolu_017PNDKgKXk1VyxRT9BVdDbt",
|
||
"answered": true,
|
||
"failed": false,
|
||
"answeredAt": "2026-09-08T17:45:31.244Z",
|
||
"questions": [
|
||
{
|
||
"header": "P5: v1\u2192v2 break",
|
||
"question": "D7 \u2014 Pass 5, Finding 6: The v1\u2192v2 upgrade removes `Client.evaluate()` immediately with zero migration support, guaranteeing broken production installs on pip upgrade. <gstack-qid:plan-devex-review-v1-v2-migration>",
|
||
"options": [
|
||
{
|
||
"label": "A \u2014 Migration guide + deprecation alias (Recommended)",
|
||
"description": "Plan must include: (1) migration guide in changelog ('replace .evaluate() with .run()'), (2) v2 ships a .evaluate() compatibility alias that raises DeprecationWarning('use Client.run() instead'), (3) one-paragraph upgrade section in README. Upgrade is boring, not scary. (human: ~2h / CC: ~20min)"
|
||
},
|
||
{
|
||
"label": "B \u2014 Migration guide only (no alias)",
|
||
"description": "Add a migration guide in the changelog with the one-line fix. No compatibility alias \u2014 v1 users who miss the guide still break. Better than nothing but still relies on developers reading the changelog."
|
||
},
|
||
{
|
||
"label": "C \u2014 Accept immediate removal, document in release notes",
|
||
"description": "Keep the current plan (immediate removal, no alias). Add a prominent breaking-change banner to release notes. Honest about the break, but production projects that auto-upgrade still break silently."
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"answers": {
|
||
"D7 \u2014 Pass 5, Finding 6: The v1\u2192v2 upgrade removes `Client.evaluate()` immediately with zero migration support, guaranteeing broken production installs on pip upgrade. <gstack-qid:plan-devex-review-v1-v2-migration>": "A \u2014 Migration guide + deprecation alias (Recommended)"
|
||
}
|
||
};
|
||
const CAPTURED_FINAL = {
|
||
"sessionId": "b5c582af-870e-48ac-ac1e-c85458932136",
|
||
"text": "DX review complete. Here's what was found and resolved:\n\n**6 findings across 5 review passes \u2014 all resolved interactively:**\n\n| # | Pass | Issue | Fix |\n|---|------|-------|-----|\n| D2 | Getting Started | `examples/first_eval.py` referenced in README but absent from package | Remove reference; make terminal demo the single path |\n| D3 | Getting Started | Demo triggers mandatory 5-min CI gate despite using bundled offline data; TTHW 6 min vs <2 min target | Exempt `evalkit.demo` from CI gate; TTHW drops to ~1-2 min |\n| D4 | API Design | `run_eval(dataset, evaluator)` and `run_batch(evaluator, dataset)` have reversed positional order \u2014 silent wrong-result bugs | Enforce keyword-only args on both functions |\n| D5 | Error Messages | `AuthError(\"request failed\")` \u2014 no code, no cause, no fix | Replace with `AuthError(\"Invalid API key \u2014 check EVALKIT_API_KEY or visit ...\", code=\"auth_invalid_key\")` |\n| D6 | Documentation | No expected output shown after demo command | Add expected output block to README |\n| D7 | Upgrade Path | `Client.evaluate()` removed immediately with no migration path | Ship deprecation shim + migration guide + README upgrade section |\n\n**Score:** 4/10 \u2192 8/10. TTHW: 6 min \u2192 ~1-2 min (Champion tier).\n\n**Critical blocker:** The CI gate finding (D3) is architecturally non-trivial \u2014 the plan currently says \"retains this gate\" but the TTHW target requires exempting demo mode. `/plan-eng-review` should validate the gate bypass implementation before this ships.\n\nPlan written to: `/tmp/gstack-paid-shard-qDnJUI/tmp/gstack-e2e-plan-devex-VWDg0F/gstack-test-plan-devex.md`",
|
||
"timestamp": "2026-09-08T17:49:33.033Z"
|
||
};
|
||
const CAPTURED_PATH = "/tmp/gstack-paid-shard-qDnJUI/tmp/gstack-e2e-plan-devex-VWDg0F/gstack-test-plan-devex.md";
|
||
const REPORT = '# Reviewed plan\n\n## GSTACK REVIEW REPORT\n\n' +
|
||
'| Review | Status | Findings |\n|---|---|---|\n| DX Review | clean | resolved |\n\n' +
|
||
'VERDICT: DX CLEARED — eng review required\n\nNO UNRESOLVED DECISIONS\n';
|
||
|
||
describe('typed native Design completion with a separately pending Eng gate', () => {
|
||
function capturedFixture() {
|
||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'design-status-completion-'));
|
||
const file = path.join(dir, 'plan.md');
|
||
const transcript: PlanCountTranscript = {
|
||
status: 'ready', calls: structuredClone(designStatusCapture.calls),
|
||
assistantMessages: structuredClone(designStatusCapture.assistantMessages),
|
||
};
|
||
const final = transcript.assistantMessages.at(-1)!;
|
||
const originalPath = /Plan written to `([^`]+)`/.exec(final.text)![1]!;
|
||
final.text = final.text.replace(originalPath, file);
|
||
const lastAnswer = Math.max(...transcript.calls.map(c => Date.parse(c.answeredAt!)));
|
||
const modified = (lastAnswer + 1_000) / 1_000;
|
||
// The original report file was not retained. This is an explicitly
|
||
// synthetic valid report; only the native calls/summary above are replayed.
|
||
const report = REPORT.replaceAll('DX', 'Design').replace('Design CLEARED', 'DESIGN CLEARED');
|
||
const write = (content = report) => { fs.writeFileSync(file, content); fs.utimesSync(file, modified, modified); };
|
||
write();
|
||
const startedAt = Date.parse(transcript.assistantMessages[0]!.timestamp) - 1_000;
|
||
const check = () => hasNativePlanTerminal(transcript, file, startedAt, 'completion_summary');
|
||
return { file, transcript, final, report, write, check, cleanup: () => fs.rmSync(dir, { recursive: true, force: true }) };
|
||
}
|
||
|
||
test('captured standalone STATUS: DONE binds to the fresh Design report without completing Eng', () => {
|
||
const f = capturedFixture();
|
||
try {
|
||
expect(f.final.text).toContain('VERDICT: NOT CLEARED — Eng Review missing');
|
||
expect(f.final.text).toContain('**STATUS: DONE**');
|
||
expect(f.check()).toBe(true);
|
||
const original = f.final.text;
|
||
for (const text of [
|
||
original.replace('## Completion', '### Completion summary').replace('**STATUS: DONE**', 'STATUS: DONE'),
|
||
original.replace('Plan written to', 'Plan saved to'),
|
||
'## Completion\n\nSTATUS: DONE\n\n- Plan saved to `' + f.file + '`.\n- Design results are in the report; Eng review remains pending.',
|
||
]) { f.final.text = text; expect(f.check()).toBe(true); }
|
||
} finally { f.cleanup(); }
|
||
});
|
||
|
||
test('completion needs its own current status and persisted path, not quoted or provisional prose', () => {
|
||
const f = capturedFixture();
|
||
try {
|
||
const original = f.final.text;
|
||
for (const text of [
|
||
original.replace('**STATUS: DONE**', '**STATUS: BLOCKED**'),
|
||
original.replace('**STATUS: DONE**', '**STATUS: DONE if approved**'),
|
||
original.replace('**STATUS: DONE**', '> STATUS: DONE'),
|
||
original.replace('**STATUS: DONE**', '`STATUS: DONE`'),
|
||
original.replace('**STATUS: DONE**', '```text\nSTATUS: DONE\n```'),
|
||
original.replace('## Completion', '## Example of Completion'),
|
||
original.replace('## Completion', 'Source example:\n\n## Completion'),
|
||
original.replace('Plan written to', 'Plan will be written to'),
|
||
original.replace('- Plan written to', '> Plan written to'),
|
||
original.replace(f.file, f.file + '.other'),
|
||
original + '\n\n## Completion\nSTATUS: DONE',
|
||
original + '\n\nSTATUS: BLOCKED',
|
||
original + '\n\nDesign review remains unresolved.',
|
||
original + '\n\nThe report is withdrawn.',
|
||
original + '\n\nThe Design review requires approval.',
|
||
original + '\n\nPlease confirm?',
|
||
]) { f.final.text = text; expect(f.check(), text).toBe(false); }
|
||
} finally { f.cleanup(); }
|
||
});
|
||
|
||
test('typed status preserves native answer ownership, timestamps and required Design report validation', () => {
|
||
const f = capturedFixture();
|
||
try {
|
||
const original = structuredClone(f.transcript);
|
||
for (const change of [
|
||
(t: PlanCountTranscript) => { t.calls[0]!.answered = false; },
|
||
(t: PlanCountTranscript) => { t.calls[0]!.failed = true; },
|
||
(t: PlanCountTranscript) => { t.calls[0]!.sessionId = 'foreign'; },
|
||
(t: PlanCountTranscript) => { t.assistantMessages.at(-1)!.timestamp = '2999-01-01T00:00:00Z'; },
|
||
(t: PlanCountTranscript) => { t.calls.at(-1)!.answeredAt = t.assistantMessages.at(-1)!.timestamp; },
|
||
(t: PlanCountTranscript) => { t.assistantMessages.push({ ...t.assistantMessages.at(-1)!, timestamp: '2026-09-15T08:46:00Z', text: 'Still reviewing.' }); },
|
||
]) {
|
||
Object.assign(f.transcript, structuredClone(original)); change(f.transcript);
|
||
expect(f.check()).toBe(false);
|
||
}
|
||
Object.assign(f.transcript, structuredClone(original));
|
||
for (const content of [
|
||
'# Draft', f.report + '\n## Unreviewed tail\n', REPORT,
|
||
f.report.replace('clean', 'pending'), f.report.replace('DESIGN CLEARED', 'NOT CLEARED'),
|
||
f.report.replace('NO UNRESOLVED DECISIONS', '**UNRESOLVED DECISIONS:**\n- Missing contrast decision'),
|
||
]) { f.write(content); expect(f.check()).toBe(false); }
|
||
f.write(); fs.utimesSync(f.file, 1, 1); expect(f.check()).toBe(false);
|
||
fs.rmSync(f.file); expect(f.check()).toBe(false);
|
||
} finally { f.cleanup(); }
|
||
});
|
||
});
|
||
|
||
function fixture() {
|
||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'native-plan-completion-'));
|
||
const file = path.join(dir, 'review.md');
|
||
const startedAt = Date.parse('2026-09-08T17:39:30.000Z');
|
||
fs.writeFileSync(file, REPORT);
|
||
const modified = Date.parse('2026-09-08T17:48:30.000Z') / 1000;
|
||
fs.utimesSync(file, modified, modified);
|
||
const transcript: PlanCountTranscript = {
|
||
status: 'ready', calls: [structuredClone(CAPTURED_CALL)],
|
||
assistantMessages: [{ ...CAPTURED_FINAL, text: CAPTURED_FINAL.text.replace(CAPTURED_PATH, file) }],
|
||
};
|
||
return { dir, file, startedAt, transcript, cleanup: () => fs.rmSync(dir, { recursive: true, force: true }) };
|
||
}
|
||
|
||
describe('Design manual completion binds its current exit gate to the fresh report', () => {
|
||
const designFixture = () => {
|
||
const f = fixture();
|
||
fs.writeFileSync(f.file, REPORT.replaceAll('DX', 'Design').replace('Design CLEARED', 'DESIGN CLEARED'));
|
||
const time = Date.parse('2026-09-08T17:48:30Z') / 1000; fs.utimesSync(f.file, time, time);
|
||
return f;
|
||
};
|
||
// AZ's final public declaration; detailed score/decision tables are omitted.
|
||
const done = (file: string) => 'Exit gate passed: every issue has its own recorded decision, the plan file\'s last heading is the review report, it has the table and VERDICT, and the final line is the unbolded sentinel.\n\n' +
|
||
' **STATUS: DONE.** Design review of PLAN.md is complete. The reviewed plan is at `' + file + '`.';
|
||
test('recognizes the bound Design declaration independently of terminal layout or ExitPlanMode', () => {
|
||
const f = designFixture();
|
||
try {
|
||
for (const text of [
|
||
done(f.file), done(f.file).replace('**STATUS: DONE.** ', '').replace('Design review of PLAN.md is complete', 'The Design review has been completed')
|
||
.replace('The reviewed plan is at', 'The review report was written to'),
|
||
done(f.file) + '\n\nEng review is pending. Implementation should not start until you leave plan mode.',
|
||
done(f.file) + '\n\n"Design review is pending."',
|
||
done(f.file) + '\n\n"This report is historical."',
|
||
]) {
|
||
f.transcript.assistantMessages[0]!.text = text;
|
||
expect(hasNativePlanTerminal(f.transcript, f.file, f.startedAt, 'completion_summary'), text).toBe(true);
|
||
expect(hasNativePlanTerminal(f.transcript, f.file, f.startedAt, 'plan_ready')).toBe(false);
|
||
}
|
||
} finally {f.cleanup();}
|
||
});
|
||
test('rejects unbound, quoted, historical, provisional and conflicting current completion', () => {
|
||
const f = designFixture();
|
||
try {
|
||
const complete = done(f.file);
|
||
for (const text of [
|
||
complete.replace('Design review of PLAN.md is complete.', 'Everything is done.'),
|
||
complete.replaceAll('Design review', 'Eng review'),
|
||
complete.replace('PLAN.md', 'OTHER.md'), complete.replace(f.file, f.file + '.other'),
|
||
complete.replace('Exit gate passed:', 'Exit gate pending:'), complete.replace('Exit gate passed:', 'Exit gate did not pass:'),
|
||
complete.replace('is complete.', 'is not complete.'), complete.replace('is complete.', 'will be complete.'),
|
||
complete.replace('is complete.', 'is complete if approved.'),
|
||
complete.replace('Exit gate passed:', 'If approved, exit gate passed:'),
|
||
complete.replace('**STATUS:', 'Historical example:\n**STATUS:'),
|
||
complete.replace('The reviewed plan', '\n\nThe reviewed plan'),
|
||
'> ' + complete.replaceAll('\n', '\n> '), '```text\n' + complete + '\n```',
|
||
'An example follows:\n\n"' + complete.replaceAll('\n', ' ') + '"',
|
||
'Source example:\n\n' + complete,
|
||
complete.replace('Design review of PLAN.md is complete.', '"Design review of PLAN.md is complete."'),
|
||
complete + '\n\nThe reviewed plan is at `' + f.file + '.other`.',
|
||
complete + '\n\nDesign review is pending.',
|
||
complete + '\n\nDesign review is "still pending".',
|
||
complete + '\n\nDesign review is complete only if approved.',
|
||
complete + '\n\nThis review is subject to approval.',
|
||
complete + '\n\nThe exit gate failed.',
|
||
complete + '\n\nThe Design review is cancelled.',
|
||
complete + '\n\nThis report is historical.',
|
||
complete.replace('Exit gate passed:', 'This gate belongs to a different plan. Exit gate passed:'),
|
||
complete + '\n\nThis gate belongs to a different plan.',
|
||
complete + '\n\nThe exit gate has been "failed".',
|
||
complete + '\n\nThe exit gate did not pass.',
|
||
complete + '\n\nThe exit gate has not passed.',
|
||
complete + '\n\nThis report is ‘withdrawn’.',
|
||
complete + '\n\nOne design decision remains unresolved.',
|
||
complete + '\n\nThis review requires approval.',
|
||
complete + '\n\nIf approved, this review is complete.',
|
||
complete + '\n\nWaiting for your decision.',
|
||
complete + '\n\nPlease confirm?',
|
||
]) {
|
||
f.transcript.assistantMessages[0]!.text = text;
|
||
expect(hasNativePlanTerminal(f.transcript, f.file, f.startedAt, 'completion_summary'), text).toBe(false);
|
||
}
|
||
} finally {f.cleanup();}
|
||
});
|
||
test('the Design route preserves native ownership, answer order and artifact readiness', () => {
|
||
const f = designFixture();
|
||
try {
|
||
f.transcript.assistantMessages[0]!.text = done(f.file);
|
||
for (const change of [
|
||
(t: any) => {t.status = 'missing';}, (t: any) => {t.calls = [];},
|
||
(t: any) => {t.calls[0].answered = false;}, (t: any) => {t.calls[0].failed = true;},
|
||
(t: any) => {t.calls[0].sessionId = 'foreign';}, (t: any) => {t.calls[0].answeredAt = '2026-09-08T17:50:00Z';},
|
||
(t: any) => {t.calls[0].answeredAt = undefined;},
|
||
(t: any) => {t.assistantMessages[0].timestamp = '2999-01-01T00:00:00Z';},
|
||
(t: any) => {t.planReadyRequests = [{sessionId: CAPTURED_CALL.sessionId, toolUseId: 'exit', timestamp: '2026-09-08T17:49:40Z', failed: true}];},
|
||
(t: any) => {t.assistantMessages.push({...t.assistantMessages[0], timestamp: '2026-09-08T17:50:00Z', text: 'Still reviewing.'});},
|
||
]) {
|
||
const t = structuredClone(f.transcript); change(t);
|
||
expect(hasNativePlanTerminal(t, f.file, f.startedAt, 'completion_summary'), change.toString()).toBe(false);
|
||
}
|
||
for (const timestamp of ['2026-09-08T17:44:00Z', '2026-09-08T17:50:00Z']) {
|
||
const time = Date.parse(timestamp) / 1000; fs.utimesSync(f.file, time, time);
|
||
expect(hasNativePlanTerminal(f.transcript, f.file, f.startedAt, 'completion_summary')).toBe(false);
|
||
}
|
||
for (const report of ['# Draft\n', REPORT + '\n## Still editing\n', REPORT,
|
||
REPORT.replaceAll('DX', 'Design').replace('Design CLEARED', 'DESIGN CLEARED').replace('clean', 'pending'),
|
||
REPORT.replaceAll('DX', 'Design').replace('Design CLEARED', 'DESIGN CLEARED')
|
||
.replace('NO UNRESOLVED DECISIONS', 'VERDICT: NOT CLEARED\n\nNO UNRESOLVED DECISIONS'),
|
||
]) {
|
||
fs.writeFileSync(f.file, report);
|
||
const time = Date.parse('2026-09-08T17:48:30Z') / 1000; fs.utimesSync(f.file, time, time);
|
||
expect(hasNativePlanTerminal(f.transcript, f.file, f.startedAt, 'completion_summary')).toBe(false);
|
||
}
|
||
fs.rmSync(f.file);
|
||
expect(hasNativePlanTerminal(f.transcript, f.file, f.startedAt, 'completion_summary')).toBe(false);
|
||
} finally {f.cleanup();}
|
||
});
|
||
test('a cleared prefix cannot hide a conditional, historical, cancelled or foreign report verdict', () => {
|
||
const f = designFixture();
|
||
try {
|
||
f.transcript.assistantMessages[0]!.text = done(f.file);
|
||
const report = fs.readFileSync(f.file, 'utf8');
|
||
for (const verdict of [
|
||
'DESIGN CLEARED only if approval is granted',
|
||
'DESIGN CLEARED is not the current verdict; review remains incomplete',
|
||
'DESIGN CLEARED is historical; this report has been cancelled',
|
||
'DESIGN CLEARED. This report is "historical".',
|
||
'DESIGN CLEARED. This report belongs to a different plan.',
|
||
'DESIGN CLEARED?', 'DESIGN CLEARED is a placeholder verdict',
|
||
]) {
|
||
fs.writeFileSync(f.file, report.replace('DESIGN CLEARED — eng review required', verdict));
|
||
const time = Date.parse('2026-09-08T17:48:30Z') / 1000; fs.utimesSync(f.file, time, time);
|
||
expect(hasNativePlanTerminal(f.transcript, f.file, f.startedAt, 'completion_summary'), verdict).toBe(false);
|
||
}
|
||
fs.writeFileSync(f.file, report.replace('DESIGN CLEARED — eng review required',
|
||
'DESIGN CLEARED (2026-09-11, commit 1a3f728) — eng review required. "This report is historical."'));
|
||
const time = Date.parse('2026-09-08T17:48:30Z') / 1000; fs.utimesSync(f.file, time, time);
|
||
expect(hasNativePlanTerminal(f.transcript, f.file, f.startedAt, 'completion_summary')).toBe(true);
|
||
} finally {f.cleanup();}
|
||
});
|
||
});
|
||
|
||
describe('native plan completion and final report', () => {
|
||
test('recognizes captured completed native DevEx prose despite a nonmatching terminal heading', () => {
|
||
const f = fixture();
|
||
try {
|
||
const visible = '●' + f.transcript.assistantMessages[0]!.text.replace(/ /g, '') + '\nCrunched for 10m 9s ·done 5:49PM\n❯ ';
|
||
expect(classifyPlanCountFrame(visible)).toBeNull();
|
||
expect(hasNativePlanCompletion(f.transcript, f.file, f.startedAt)).toBe(true);
|
||
} finally { f.cleanup(); }
|
||
});
|
||
|
||
test('rejects pending, failed, missing, mixed-session and untimestamped native coverage', () => {
|
||
const f = fixture();
|
||
try {
|
||
for (const change of [
|
||
(t: any) => { t.status = 'missing'; },
|
||
(t: any) => { t.status = 'error'; },
|
||
(t: any) => { t.calls = []; },
|
||
(t: any) => { t.calls[0].answered = false; },
|
||
(t: any) => { t.calls[0].failed = true; },
|
||
(t: any) => { t.calls[0].answeredAt = undefined; },
|
||
(t: any) => { t.calls[0].sessionId = 'foreign'; },
|
||
(t: any) => { t.assistantMessages.push({ ...t.assistantMessages[0], sessionId: 'foreign' }); },
|
||
(t: any) => { t.assistantMessages = []; },
|
||
]) {
|
||
const t = structuredClone(f.transcript); change(t);
|
||
expect(hasNativePlanCompletion(t, f.file, f.startedAt)).toBe(false);
|
||
}
|
||
} finally { f.cleanup(); }
|
||
});
|
||
|
||
test('requires the latest native announcement to follow every answer', () => {
|
||
const f = fixture();
|
||
try {
|
||
f.transcript.calls[0]!.answeredAt = '2026-09-08T17:50:00.000Z';
|
||
expect(hasNativePlanCompletion(f.transcript, f.file, f.startedAt)).toBe(false);
|
||
f.transcript.calls[0]!.answeredAt = CAPTURED_CALL.answeredAt;
|
||
f.transcript.assistantMessages.push({ ...CAPTURED_FINAL, text: 'Please answer the remaining question.', timestamp: '2026-09-08T17:50:00.000Z' });
|
||
expect(hasNativePlanCompletion(f.transcript, f.file, f.startedAt)).toBe(false);
|
||
} finally { f.cleanup(); }
|
||
});
|
||
|
||
test('quoted completions, refusals, provisional writes, wrong paths and waiting questions are not done', () => {
|
||
const f = fixture();
|
||
try {
|
||
const complete = f.transcript.assistantMessages[0]!.text;
|
||
for (const text of [
|
||
'> ' + complete, '```text\n' + complete + '\n```',
|
||
'Example completion:\n' + complete,
|
||
"I cannot complete this review.\nPlan written to: `" + f.file + '`',
|
||
'Now writing the complete plan file with all resolved findings and the review report.',
|
||
complete.replace(f.file, f.file + '.other'),
|
||
complete.replace('Plan written to:', 'Should I proceed?\nPlan written to:'),
|
||
complete.replace('Plan written to:', 'Waiting for your decision.\nPlan written to:'),
|
||
]) {
|
||
f.transcript.assistantMessages[0]!.text = text;
|
||
expect(hasNativePlanCompletion(f.transcript, f.file, f.startedAt), text).toBe(false);
|
||
}
|
||
} finally { f.cleanup(); }
|
||
});
|
||
|
||
test('missing, stale, changed-after-announcement and provisional reports cannot complete', () => {
|
||
const f = fixture();
|
||
try {
|
||
for (const date of ['2026-09-08T17:38:00Z', '2026-09-08T17:44:00Z', '2026-09-08T17:50:00Z']) {
|
||
const time = Date.parse(date) / 1000; fs.utimesSync(f.file, time, time);
|
||
expect(hasNativePlanCompletion(f.transcript, f.file, f.startedAt)).toBe(false);
|
||
}
|
||
for (const report of ['# Draft\n', '## GSTACK REVIEW REPORT\n', REPORT + '\n## Still editing\n']) {
|
||
fs.writeFileSync(f.file, report); const time = Date.parse('2026-09-08T17:48:30Z') / 1000; fs.utimesSync(f.file, time, time);
|
||
expect(hasNativePlanCompletion(f.transcript, f.file, f.startedAt)).toBe(false);
|
||
}
|
||
fs.rmSync(f.file);
|
||
expect(hasNativePlanCompletion(f.transcript, f.file, f.startedAt)).toBe(false);
|
||
expect(hasNativePlanCompletion(f.transcript, 'review.md', f.startedAt)).toBe(false);
|
||
} finally { f.cleanup(); }
|
||
});
|
||
|
||
test('a fenced report example or an unclosed fence never supplies completion markers', () => {
|
||
const f = fixture();
|
||
try {
|
||
for (const report of [
|
||
'# Plan\nExample report:\n```markdown\n' + REPORT + '\n```\n',
|
||
'# Plan\nExample report:\n~~~markdown\n' + REPORT + '\n~~~\n',
|
||
'```markdown\n' + REPORT,
|
||
'~~~markdown\n' + REPORT,
|
||
// An apparent shorter/mismatched/annotated close leaves the report
|
||
// inside the original code fence, rather than making it a real report.
|
||
'````markdown\n```\n' + REPORT + '\n````\n',
|
||
'~~~markdown\n```\n' + REPORT + '\n~~~\n',
|
||
'```markdown\n```still-code\n' + REPORT + '\n```\n',
|
||
' ~~~~markdown\n ~~~\n' + REPORT + '\n ~~~~\n',
|
||
REPORT + '\n```unclosed\n',
|
||
]) {
|
||
fs.writeFileSync(f.file, report);
|
||
const time = Date.parse('2026-09-08T17:48:30Z') / 1000;
|
||
fs.utimesSync(f.file, time, time);
|
||
expect(hasNativePlanCompletion(f.transcript, f.file, f.startedAt), report).toBe(false);
|
||
}
|
||
} finally { f.cleanup(); }
|
||
});
|
||
|
||
test('real code fences before the final report do not hide that report', () => {
|
||
const f = fixture();
|
||
try {
|
||
for (const prefix of [
|
||
'```typescript\nconst answer = 42;\n```\n',
|
||
'~~~typescript\nconst answer = 42;\n~~~~~\n',
|
||
' ````typescript\n```still-code\n ````` \t\n',
|
||
'```markdown\n' + REPORT + '\n```\n',
|
||
]) {
|
||
fs.writeFileSync(f.file, '# Plan\n' + prefix + '\n' + REPORT);
|
||
const time = Date.parse('2026-09-08T17:48:30Z') / 1000;
|
||
fs.utimesSync(f.file, time, time);
|
||
expect(hasNativePlanCompletion(f.transcript, f.file, f.startedAt), prefix).toBe(true);
|
||
}
|
||
} finally { f.cleanup(); }
|
||
});
|
||
|
||
test.skipIf(process.platform === 'win32')('real PTY completes from a native report without a display alias', async () => {
|
||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'native-completion-pty-'));
|
||
const fake = path.join(dir, 'fake-claude');
|
||
const worker = path.join(dir, 'worker.ts');
|
||
const output = path.join(dir, 'plan.md');
|
||
const record = path.join(dir, 'inputs.jsonl');
|
||
const result = path.join(dir, 'result.json');
|
||
const runner = pathToFileURL(path.join(import.meta.dir, 'helpers/claude-pty-runner.ts')).href;
|
||
fs.writeFileSync(fake, `#!${process.execPath}\n` + String.raw`
|
||
import * as fs from 'node:fs';
|
||
import * as path from 'node:path';
|
||
const sessionId = 'native-completion-fixture';
|
||
const project = path.join(process.env.CLAUDE_CONFIG_DIR, 'projects', sessionId);
|
||
fs.mkdirSync(project, { recursive: true });
|
||
const file = path.join(project, sessionId + '.jsonl');
|
||
const native = (role, content, extra = {}) => fs.appendFileSync(file, JSON.stringify({
|
||
cwd: process.cwd(), sessionId, isSidechain: false,
|
||
timestamp: new Date().toISOString(), message: { role, content }, ...extra,
|
||
}) + '\n');
|
||
let sent = false;
|
||
process.stdin.setRawMode?.(true);
|
||
process.stdin.on('data', data => {
|
||
fs.appendFileSync(process.env.PROBE_INPUTS, JSON.stringify(data.toString()) + '\n');
|
||
if (sent) return; sent = true;
|
||
const q = { header: 'Error quality', question: 'D1 — Fix the missing error recovery path?', options: [{ label: 'Add recovery hint' }, { label: 'Keep vague message' }] };
|
||
native('assistant', [{ type: 'tool_use', id: 'finding', name: 'AskUserQuestion', input: { questions: [q] } }]);
|
||
const answeredAt = new Date(Date.now() - 100).toISOString();
|
||
native('user', [{ type: 'tool_result', tool_use_id: 'finding', content: 'Answered.' }], {
|
||
timestamp: answeredAt, toolUseResult: { answers: { [q.question]: q.options[0].label } },
|
||
});
|
||
fs.writeFileSync(process.env.PROBE_PLAN, process.env.PROBE_REPORT);
|
||
const text = 'DX review complete. One finding resolved interactively.\n\nPlan written to: ' + String.fromCharCode(96) + process.env.PROBE_PLAN + String.fromCharCode(96);
|
||
native('assistant', [{ type: 'text', text }], { timestamp: new Date(Date.now() + 5).toISOString() });
|
||
process.stdout.write('407 +NO UNRESOLVED DECISIONS\n●' + text.replace(/ /g, '') + '\nCrunched for 10m 9s ·done 5:49PM\n❯ ');
|
||
});
|
||
process.stdin.resume();
|
||
process.stdout.write('PTY_READY:'+process.env.PROBE_INPUTS+'\x1b[2J\x1b[H');
|
||
`);
|
||
fs.chmodSync(fake, 0o755);
|
||
fs.writeFileSync(worker, `import { runPlanSkillCounting } from ${JSON.stringify(runner)};\n` +
|
||
`const result = await runPlanSkillCounting({skillName:'plan-devex-review',slashCommand:'/plan-devex-review',followUpPrompt:'# Native completion fixture',expectedPlanPath:${JSON.stringify(output)},isLastStep0AUQ:()=>false,isReviewAUQ:()=>true,reviewCountCeiling:8,timeoutMs:33000,startupReadyMarker:${JSON.stringify('PTY_READY:'+record)},env:${JSON.stringify({PROBE_PLAN:output,PROBE_INPUTS:record,PROBE_REPORT:REPORT})}});\n` +
|
||
`await Bun.write(${JSON.stringify(result)},JSON.stringify(result));\n`);
|
||
const child = Bun.spawn([process.execPath, worker], {
|
||
env: { ...process.env, EVALS_HERMETIC: '1', EVALS_RUN_ID: '', BROWSE_TERMINAL_BINARY: fake },
|
||
stdout: 'pipe', stderr: 'pipe',
|
||
});
|
||
const timer = setTimeout(() => child.kill('SIGKILL'), 35000);
|
||
try {
|
||
const [code, stdout, stderr] = await Promise.all([child.exited, new Response(child.stdout).text(), new Response(child.stderr).text()]);
|
||
expect(code, stdout + stderr).toBe(0);
|
||
const observation = JSON.parse(fs.readFileSync(result, 'utf8'));
|
||
expect(observation.outcome).toBe('completion_summary');
|
||
expect(observation.summary).toContain('native review completion and final report verified');
|
||
expect(observation.reviewCount).toBe(1);
|
||
expect(observation.step0Count).toBe(0);
|
||
expect(observation.transcript.calls).toHaveLength(1);
|
||
expect(fs.readFileSync(record, 'utf8').trim().split('\n').map(line => JSON.parse(line))).toEqual(['/plan-devex-review\r']);
|
||
expect(fs.existsSync(output)).toBe(true);
|
||
} finally { clearTimeout(timer); child.kill('SIGKILL'); fs.rmSync(dir, { recursive: true, force: true }); }
|
||
}, 40000);
|
||
});
|
||
|
||
// Last answered call and last finalized native text at the exact G soft-terminal race.
|
||
const CAPTURED_ENG_STREAM = {
|
||
"status": "ready",
|
||
"calls": [
|
||
{
|
||
"sessionId": "4c3d29fb-2a00-4e5d-b3c6-9b584986e340",
|
||
"toolUseId": "toolu_011KrMyU6fjW7RQ7aAVJ4DfA",
|
||
"questions": [
|
||
{
|
||
"question": "D7 — Performance: 5 sequential IDP calls that could be Promise.all'd\nProject/branch/task: Multi-tenant Auth Refactor on main\nELI10: During token validation, the code makes 5 API calls to the identity provider (IDP) one at a time. But the calls are independent — none uses the result of the previous one. Changing from sequential to Promise.all([…]) takes one line of code and cuts auth latency by ~5x. At 100ms per call, sequential = ~500ms; parallel = ~100ms. This matters most under load: auth is on the critical path of every authenticated request.\nStakes if we pick wrong: Every authenticated request pays a 400ms tax that could be eliminated with one line. Under load, slow auth creates timeout cascades — auth is typically among the first things to degrade.\nRecommendation: A — trivially fix it now. The plan itself says “calls are independent” and “trivially” parallelizable. The only reason not to is if there’s a hidden ordering dependency the plan doesn’t mention.\nCompleteness: Note: options differ in kind, not coverage — no completeness score.\nPros / cons:\nA) Parallelize the 5 IDP calls with Promise.all in this PR (recommended)\n ✅ 5x latency reduction on the auth critical path for free — one line change\n ✅ Under load, parallel calls bound latency to the slowest single call instead of sum of all\n ❌ If any hidden ordering dependency exists (not mentioned in the plan), it will surface as a test failure — easily caught\nB) Defer parallelization to a follow-up performance PR\n ✅ Keeps this PR focused on the refactor\n ❌ The plan already flagged this as trivial; deferring creates a PR that self-documents debt without resolving it\nNet: The plan already identified this as trivial. Doing it now costs 5 minutes and makes the auth path meaningfully faster for all users. <gstack-qid:plan-eng-review-perf-idp-sequential-calls>",
|
||
"header": "Performance",
|
||
"options": [
|
||
{
|
||
"label": "A) Parallelize IDP calls now (Recommended)",
|
||
"description": "Promise.all the 5 independent calls. ~5 min, 5x auth latency improvement."
|
||
},
|
||
{
|
||
"label": "B) Defer to a follow-up PR",
|
||
"description": "Keeps this PR focused on refactor; acknowledged debt."
|
||
}
|
||
],
|
||
"multiSelect": false
|
||
}
|
||
],
|
||
"answered": true,
|
||
"failed": false,
|
||
"answers": {
|
||
"D7 — Performance: 5 sequential IDP calls that could be Promise.all'd\nProject/branch/task: Multi-tenant Auth Refactor on main\nELI10: During token validation, the code makes 5 API calls to the identity provider (IDP) one at a time. But the calls are independent — none uses the result of the previous one. Changing from sequential to Promise.all([…]) takes one line of code and cuts auth latency by ~5x. At 100ms per call, sequential = ~500ms; parallel = ~100ms. This matters most under load: auth is on the critical path of every authenticated request.\nStakes if we pick wrong: Every authenticated request pays a 400ms tax that could be eliminated with one line. Under load, slow auth creates timeout cascades — auth is typically among the first things to degrade.\nRecommendation: A — trivially fix it now. The plan itself says “calls are independent” and “trivially” parallelizable. The only reason not to is if there’s a hidden ordering dependency the plan doesn’t mention.\nCompleteness: Note: options differ in kind, not coverage — no completeness score.\nPros / cons:\nA) Parallelize the 5 IDP calls with Promise.all in this PR (recommended)\n ✅ 5x latency reduction on the auth critical path for free — one line change\n ✅ Under load, parallel calls bound latency to the slowest single call instead of sum of all\n ❌ If any hidden ordering dependency exists (not mentioned in the plan), it will surface as a test failure — easily caught\nB) Defer parallelization to a follow-up performance PR\n ✅ Keeps this PR focused on the refactor\n ❌ The plan already flagged this as trivial; deferring creates a PR that self-documents debt without resolving it\nNet: The plan already identified this as trivial. Doing it now costs 5 minutes and makes the auth path meaningfully faster for all users. <gstack-qid:plan-eng-review-perf-idp-sequential-calls>": "A) Parallelize IDP calls now (Recommended)"
|
||
},
|
||
"unansweredQuestionIndices": [],
|
||
"answeredAt": "2026-09-08T18:46:43.934Z"
|
||
}
|
||
],
|
||
"assistantMessages": [
|
||
{
|
||
"sessionId": "4c3d29fb-2a00-4e5d-b3c6-9b584986e340",
|
||
"text": "Tests decision: add characterization tests for legacyAuthFlow() before rewriting. Moving to Section 4: Performance Review.\n\n**Finding 4 [P2] (confidence: 9/10):** The plan states: \"Token validation issues 5 sequential API calls to the IDP; they could be parallelized via Promise.all trivially (calls are independent).\"\n\nThis is a free 5x latency improvement being left on the table. At 100ms per IDP call (typical), sequential = ~500ms per auth validation. Parallel via Promise.all = ~100ms.",
|
||
"timestamp": "2026-09-08T18:46:30.531Z"
|
||
}
|
||
]
|
||
};
|
||
const CAPTURED_DX_HANDOFF = {
|
||
"sessionId": "cc1b321f-f306-4086-a236-34dd30f457be",
|
||
"toolUseId": "toolu_01AGy3uosDrjJJUv1aKGkhRY",
|
||
"questions": [
|
||
{
|
||
"question": "DX review done. 5 findings resolved, 7 implementation tasks written. What's next?\n\nEvalKit SDK / DX POLISH review / main\nThe DX review found API design issues (argument order, auth error), a broken getting-started path, a TTHW gap, and a cliff-edge upgrade. All resolved with user decisions. The full output is at gstack-test-plan-devex.md. Eng review is the required gate before shipping.\n<gstack-qid:devex-next-steps>",
|
||
"header": "Next step",
|
||
"multiSelect": false,
|
||
"options": [
|
||
{
|
||
"label": "Run /plan-eng-review (Recommended)",
|
||
"description": "Required gate. The arg-order fix and --skip-ci flag both have architectural implications that eng review should validate."
|
||
},
|
||
{
|
||
"label": "Ready to implement",
|
||
"description": "Start building the 7 tasks. Run /devex-review after shipping to measure actual TTHW vs the <2-min target."
|
||
},
|
||
{
|
||
"label": "Skip, handle manually",
|
||
"description": "You'll manage next steps outside this session."
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"answered": true,
|
||
"failed": false,
|
||
"answers": {
|
||
"DX review done. 5 findings resolved, 7 implementation tasks written. What's next?\n\nEvalKit SDK / DX POLISH review / main\nThe DX review found API design issues (argument order, auth error), a broken getting-started path, a TTHW gap, and a cliff-edge upgrade. All resolved with user decisions. The full output is at gstack-test-plan-devex.md. Eng review is the required gate before shipping.\n<gstack-qid:devex-next-steps>": "Run /plan-eng-review (Recommended)"
|
||
},
|
||
"unansweredQuestionIndices": [],
|
||
"answeredAt": "2026-09-08T18:46:16.771Z"
|
||
};
|
||
|
||
describe('guarded native terminal and report lifecycle', () => {
|
||
test('G Eng streamed summary cannot finish while native text/file is still pending', () => {
|
||
const f = fixture();
|
||
try {
|
||
const visible = '● Performance decision: parallelize the 5 IDP calls. All 4 review sections complete.\n\nCompletionSummary:\n- Step 0: Scope reduced\n- Architecture Review:1 issue found\n- Code Quality Review:1 issue found\n';
|
||
expect(classifyPlanCountFrame(visible)).toBe('completion_summary');
|
||
const t: PlanCountTranscript = structuredClone(CAPTURED_ENG_STREAM);
|
||
const answerTime = Math.max(...t.calls.map(c => Date.parse(c.answeredAt!)));
|
||
fs.utimesSync(f.file, (answerTime + 1) / 1000, (answerTime + 1) / 1000);
|
||
expect(hasNativePlanTerminal(t, f.file, f.startedAt, 'completion_summary')).toBe(false);
|
||
t.assistantMessages.push({ sessionId: t.calls[0]!.sessionId, timestamp: new Date(answerTime + 2).toISOString(),
|
||
text: 'Completion Summary:\n- Architecture Review: 1 issue resolved\n- Code Quality Review: 1 issue resolved\n- Test Review: 1 gap resolved\n- Performance Review: 1 issue resolved\n' });
|
||
for (const content of ['', '# Draft\n', '## GSTACK REVIEW REPORT\n', REPORT.replace('NO UNRESOLVED DECISIONS', ''), REPORT.replace('| DX Review | clean | resolved |\n', '')]) {
|
||
fs.writeFileSync(f.file, content); fs.utimesSync(f.file, (answerTime + 3) / 1000, (answerTime + 3) / 1000);
|
||
expect(hasNativePlanTerminal(t, f.file, f.startedAt, 'completion_summary'), content).toBe(false);
|
||
}
|
||
fs.writeFileSync(f.file, REPORT); fs.utimesSync(f.file, (answerTime + 3) / 1000, (answerTime + 3) / 1000);
|
||
expect(hasNativePlanTerminal(t, f.file, f.startedAt, 'completion_summary')).toBe(true);
|
||
} finally { f.cleanup(); }
|
||
});
|
||
|
||
test('the actual post-report DX handoff does not require rewriting an unchanged report', () => {
|
||
const f = fixture();
|
||
try {
|
||
const t: PlanCountTranscript = structuredClone(f.transcript);
|
||
const sessionId = t.calls[0]!.sessionId;
|
||
t.calls.push({ ...structuredClone(CAPTURED_DX_HANDOFF), sessionId });
|
||
t.planReadyRequests = [{ sessionId, toolUseId: 'exit', timestamp: '2026-09-08T18:46:27.000Z', failed: false }];
|
||
expect(hasNativePlanTerminal(t, f.file, f.startedAt, 'plan_ready')).toBe(true);
|
||
// Unknown, free-form, partly unanswered and substantive menus remain
|
||
// freshness boundaries, even if they reuse the same next-step header.
|
||
for (const mutate of [
|
||
(c: any) => { c.questions[0].question = c.questions[0].question.replace('devex-next-steps', 'new-change'); },
|
||
(c: any) => { c.answers[c.questions[0].question] = 'Also change the SDK auth behavior'; },
|
||
(c: any) => { c.questions[0].options.push({ label: 'Change the error message now' }); },
|
||
(c: any) => { c.unansweredQuestionIndices = [1]; },
|
||
]) {
|
||
const changed = structuredClone(t); mutate(changed.calls[1]);
|
||
expect(hasNativePlanTerminal(changed, f.file, f.startedAt, 'plan_ready')).toBe(false);
|
||
}
|
||
t.planReadyRequests[0]!.failed = true;
|
||
expect(hasNativePlanTerminal(t, f.file, f.startedAt, 'plan_ready')).toBe(false);
|
||
} finally { f.cleanup(); }
|
||
});
|
||
|
||
test('pending/refused/mixed calls, stale or incomplete reports and quoted summaries cannot complete', () => {
|
||
const f = fixture();
|
||
try {
|
||
const t = structuredClone(f.transcript);
|
||
t.planReadyRequests = [{ sessionId: t.calls[0]!.sessionId, toolUseId: 'exit', timestamp: CAPTURED_FINAL.timestamp, failed: false }];
|
||
expect(hasNativePlanTerminal(t, f.file, f.startedAt, 'plan_ready')).toBe(true);
|
||
const retried = structuredClone(t);
|
||
retried.calls.unshift({ ...structuredClone(retried.calls[0]!), toolUseId: 'failed-before-retry', answered: false, failed: true, answers: undefined });
|
||
expect(hasNativePlanTerminal(retried, f.file, f.startedAt, 'plan_ready')).toBe(true);
|
||
retried.calls[0]!.questions[0]!.question = 'A different unresolved question';
|
||
expect(hasNativePlanTerminal(retried, f.file, f.startedAt, 'plan_ready')).toBe(false);
|
||
for (const mutate of [
|
||
(t: any) => { t.calls[0].answered = false; },
|
||
(t: any) => { t.calls[0].failed = true; },
|
||
(t: any) => { t.calls[0].sessionId = 'other'; },
|
||
(t: any) => { t.planReadyRequests[0].failed = true; },
|
||
(t: any) => { t.planReadyRequests[0].timestamp = t.calls[0].answeredAt; },
|
||
(t: any) => { t.planReadyRequests = []; },
|
||
(t: any) => { t.status = 'missing'; },
|
||
]) { const changed = structuredClone(t); mutate(changed); expect(hasNativePlanTerminal(changed, f.file, f.startedAt, 'plan_ready')).toBe(false); }
|
||
const summary = 'Completion Summary:\n- Review: 4 findings resolved\n';
|
||
for (const text of ['> ' + summary, 'Example:\n' + summary, '```text\n' + summary + '```', 'Here is an example:\n\n' + summary, 'Here is a quoted result:\n```text\n' + summary + '```', 'I cannot complete the review.\n' + summary, 'Completion Summary:\n', summary + 'Waiting for your answer.']) {
|
||
t.assistantMessages[0]!.text = text;
|
||
expect(hasNativePlanTerminal(t, f.file, f.startedAt, 'completion_summary'), text).toBe(false);
|
||
}
|
||
const old = Date.parse('2026-09-08T17:40:00Z') / 1000; fs.utimesSync(f.file, old, old);
|
||
expect(hasNativePlanTerminal(t, f.file, f.startedAt, 'plan_ready')).toBe(false);
|
||
} finally { f.cleanup(); }
|
||
});
|
||
});
|
||
|
||
test.skipIf(process.platform === 'win32')('real PTY waits through streamed summary, another question and partial report writes', async () => {
|
||
await Promise.all(['completion_summary', 'plan_ready', 'compact_plan_ready', 'ready_with_unsanctioned_write'].map(async (terminal) => {
|
||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'guarded-terminal-pty-'));
|
||
const fake = path.join(dir, 'fake-claude');
|
||
const worker = path.join(dir, 'worker.ts');
|
||
const output = path.join(dir, 'plan.md');
|
||
const record = path.join(dir, 'inputs.jsonl');
|
||
const events = path.join(dir, 'events.jsonl');
|
||
const result = path.join(dir, 'result.json');
|
||
const runner = pathToFileURL(path.join(import.meta.dir, 'helpers/claude-pty-runner.ts')).href;
|
||
fs.writeFileSync(fake, `#!${process.execPath}\n` + String.raw`
|
||
import * as fs from 'node:fs';
|
||
import * as path from 'node:path';
|
||
const sessionId = 'guarded-terminal-fixture';
|
||
const project = path.join(process.env.CLAUDE_CONFIG_DIR, 'projects', sessionId);
|
||
fs.mkdirSync(project, { recursive: true });
|
||
const file = path.join(project, sessionId + '.jsonl');
|
||
const native = (role, content, extra = {}) => fs.appendFileSync(file, JSON.stringify({
|
||
cwd: process.cwd(), sessionId, isSidechain: false, timestamp: new Date().toISOString(), message: { role, content }, ...extra,
|
||
}) + '\n');
|
||
const event = name => fs.appendFileSync(process.env.PROBE_EVENTS, JSON.stringify({ name, at: Date.now() }) + '\n');
|
||
const q = { header: 'Tests', question: 'D2 — Test “Would you like to proceed?” <gstack-qid:plan-eng-test-retry>', options: [{ label: 'Add retry assertion' }, { label: 'Leave untested' }] };
|
||
const ask = id => native('assistant', [{ type: 'tool_use', id, name: 'AskUserQuestion', input: { questions: [q] } }]);
|
||
const answer = id => native('user', [{ type: 'tool_result', tool_use_id: id, content: 'Answered.' }], { toolUseResult: { answers: { [q.question]: q.options[0].label } } });
|
||
const summary = 'Completion Summary:\n- Architecture Review: 1 issue resolved\n- Test Review: 1 missing test resolved\n';
|
||
const compact = process.env.PROBE_TERMINAL === 'compact_plan_ready';
|
||
const ready = () => process.stdout.write(process.env.PROBE_TERMINAL === 'ready_with_unsanctioned_write'
|
||
? '\x1b[2J\x1b[H⏺ Write(src/unreviewed.ts)\nClaude has written up a plan and is ready to execute.\n'
|
||
: compact
|
||
? '\x1b[2J\x1b[HExit plan mode?\n\nClaude wants to exit plan mode\n\n❯ 1. Yes, and switch to default (ask each time) for this session\n 2. No\n'
|
||
: '\nClaude has written up a plan and is ready to execute. Would you like to proceed?\n❯ 1. Yes, and use auto mode\n 2. Yes, manually approve edits\n 3. Tell Claude what to change\n');
|
||
let stage = 0;
|
||
process.stdin.setRawMode?.(true);
|
||
process.stdin.on('data', data => {
|
||
fs.appendFileSync(process.env.PROBE_INPUTS, JSON.stringify(data.toString()) + '\n');
|
||
if (stage === 0) {
|
||
stage = 1; ask('first'); answer('first');
|
||
event('streamed-heading'); process.stdout.write('● Completion Summary:\n- Architecture Review: 1 issue resolved\n');
|
||
if (compact) {
|
||
// Native metadata for an unrelated question and a prior permission
|
||
// cannot authorize this ExitPlanMode menu. No report exists yet.
|
||
ask('second');
|
||
process.stdout.write('Do you want to make this edit to plan.md?\n❯ 1. Yes\n 2. Yes, and allow all edits\n 3. No\nEsc to cancel · Tab to amend\n⎿ Added 1 line\n');
|
||
event('unverified-compact-gate'); ready();
|
||
}
|
||
setTimeout(() => {
|
||
if (!compact) ask('second'); event('pending-question');
|
||
process.stdout.write('\n☐ Tests\n' + q.question + '\n❯ 1. Add retry assertion\n 2. Leave untested\nEnter to select · ↑/↓ to navigate · Esc to cancel\n');
|
||
}, 3500);
|
||
return;
|
||
}
|
||
if (stage === 1 && data.toString().includes('1')) {
|
||
stage = 2; answer('second'); event('answered-second');
|
||
fs.writeFileSync(process.env.PROBE_PLAN, '# Draft\n');
|
||
// A finalized summary plus the finished report is itself a valid terminal.
|
||
// Keep approval-only cases streamed until their native approval arrives.
|
||
if (process.env.PROBE_TERMINAL === 'completion_summary')
|
||
native('assistant', [{ type: 'text', text: summary }], { timestamp: new Date(Date.now() + 1).toISOString() });
|
||
process.stdout.write('\n● ' + summary);
|
||
if (compact) ready();
|
||
setTimeout(() => {
|
||
event('partial-report'); fs.writeFileSync(process.env.PROBE_PLAN, process.env.PROBE_REPORT.split('VERDICT:')[0]);
|
||
}, 3000);
|
||
setTimeout(() => {
|
||
event('complete-report'); fs.writeFileSync(process.env.PROBE_PLAN, process.env.PROBE_REPORT);
|
||
if (process.env.PROBE_TERMINAL !== 'completion_summary') {
|
||
native('assistant', [{ type: 'tool_use', id: 'rejected-ready', name: 'ExitPlanMode', input: {} }]);
|
||
native('user', [{ type: 'tool_result', tool_use_id: 'rejected-ready', is_error: true, content: 'Gate not ready' }]);
|
||
ready();
|
||
setTimeout(() => {
|
||
event('valid-native-ready'); native('assistant', [{ type: 'tool_use', id: 'valid-ready', name: 'ExitPlanMode', input: {} }]); ready();
|
||
}, 2500);
|
||
}
|
||
}, 6000);
|
||
} else if (stage === 2) event('unexpected-plan-approval-input');
|
||
});
|
||
process.stdin.resume();
|
||
process.stdout.write('PTY_READY:'+process.env.PROBE_INPUTS+'\x1b[2J\x1b[H');
|
||
`);
|
||
fs.chmodSync(fake, 0o755);
|
||
fs.writeFileSync(worker, `import { runPlanSkillCounting } from ${JSON.stringify(runner)};\n` +
|
||
`const result = await runPlanSkillCounting({skillName:'plan-eng-review',slashCommand:'/plan-eng-review',followUpPrompt:'# Completion fixture',expectedPlanPath:${JSON.stringify(output)},isLastStep0AUQ:()=>false,isReviewAUQ:()=>true,reviewCountCeiling:8,timeoutMs:43000,startupReadyMarker:${JSON.stringify('PTY_READY:'+record)},env:${JSON.stringify({PROBE_PLAN:output,PROBE_INPUTS:record,PROBE_EVENTS:events,PROBE_REPORT:REPORT,PROBE_TERMINAL:terminal})}});\n` +
|
||
`await Bun.write(${JSON.stringify(result)},JSON.stringify(result));\n`);
|
||
const child = Bun.spawn([process.execPath, worker], { env: { ...process.env,
|
||
EVALS_HERMETIC: '1', EVALS_RUN_ID: '', BROWSE_TERMINAL_BINARY: fake }, stdout: 'pipe', stderr: 'pipe' });
|
||
const timer = setTimeout(() => child.kill('SIGKILL'), 45000);
|
||
try {
|
||
const [code, stdout, stderr] = await Promise.all([child.exited, new Response(child.stdout).text(), new Response(child.stderr).text()]);
|
||
expect(code, stdout + stderr).toBe(0);
|
||
const observation = JSON.parse(fs.readFileSync(result, 'utf8'));
|
||
expect(fs.existsSync(output), `D19: report must exist before stopping; ${observation.summary}`).toBe(true);
|
||
expect(observation.outcome, JSON.stringify(observation)).toBe(
|
||
terminal === 'ready_with_unsanctioned_write' ? 'silent_write' :
|
||
terminal === 'compact_plan_ready' ? 'plan_ready' : terminal,
|
||
);
|
||
expect(observation.reviewCount).toBe(2);
|
||
expect(fs.readFileSync(output, 'utf8')).toBe(REPORT);
|
||
const recorded = fs.readFileSync(events, 'utf8').trim().split('\n').map(line => JSON.parse(line));
|
||
expect(recorded.map(e => e.name)).toEqual(['streamed-heading', ...(terminal === 'compact_plan_ready' ? ['unverified-compact-gate'] : []), 'pending-question', 'answered-second', 'partial-report', 'complete-report', ...(terminal !== 'completion_summary' ? ['valid-native-ready'] : [])]);
|
||
expect(fs.readFileSync(record, 'utf8').trim().split('\n').map(line => JSON.parse(line))).toEqual(['/plan-eng-review\r', '1']);
|
||
if (terminal !== 'completion_summary') expect(observation.transcript.planReadyRequests.map(r => r.failed)).toEqual([true, false]);
|
||
} finally { clearTimeout(timer); child.kill('SIGKILL'); await child.exited; fs.rmSync(dir, { recursive: true, force: true }); }
|
||
}));
|
||
}, 50000);
|
||
|
||
// Actual finalized CEO prose uses a relative output name, not the DevEx fallback's
|
||
// exact “Plan written to:” sentence. Its caller-owned file is checked independently.
|
||
test('captured completed CEO prose supports the ordinary summary path', () => {
|
||
const f = fixture();
|
||
try {
|
||
f.transcript.assistantMessages = [{
|
||
sessionId: f.transcript.calls[0]!.sessionId,
|
||
timestamp: "2026-09-08T17:58:52.319Z",
|
||
text: "CEO review complete. Here's the summary:\n\n**Plan:** Payment Processing — Test Coverage\n**Mode:** HOLD SCOPE | **Verdict:** CLEARED (with 4 additions)\n\n**4 gaps found and resolved through interactive review:**\n\n1. **CRITICAL** — \"assert correct receipt is generated\" is too vague. Spec: assert `charge_id`, `amount`, `currency` (at minimum) match the charge response.\n2. **WARNING** — \"fails clean\" doesn't name what's raised. Spec: `assert raises <PaymentFailedError>` (resolve exact class from error hierarchy at implementation).\n3. **WARNING** — Retry count is implicit. Spec: `assert len(mock_stripe_call_history) == 2` explicitly in Test 2.\n4. **WARNING** — No test file path. Spec: resolve by convention-matching existing test structure.\n\nEverything else (architecture, security, data flow, performance, observability, deployment, trajectory) is clean. Section 11 skipped — no UI scope. Review output written to `gstack-test-plan-ceo-paired.md`."
|
||
}];
|
||
expect(hasNativePlanCompletion(f.transcript, f.file, f.startedAt)).toBe(false);
|
||
expect(hasNativePlanTerminal(f.transcript, f.file, f.startedAt, 'completion_summary')).toBe(true);
|
||
f.transcript.calls = [];
|
||
expect(hasNativePlanTerminal(f.transcript, f.file, f.startedAt, 'completion_summary')).toBe(false);
|
||
} finally { f.cleanup(); }
|
||
});
|
||
|
||
|
||
const CAPTURED_NUMBERED_DX_HANDOFF = {
|
||
"sessionId": "0b7d664e-8d15-4c0e-8be2-d03a833d5d33",
|
||
"toolUseId": "toolu_01RgoUjV9vFRaSFoySjm5QqY",
|
||
"questions": [
|
||
{
|
||
"question": "D8 — DX review complete. 5 friction points resolved, DX score 4/10 → 8/10, TTHW target achievable. What’s next? <gstack-qid:devex-next-steps>",
|
||
"header": "Next steps",
|
||
"options": [
|
||
{
|
||
"label": "Run /plan-eng-review next (recommended)",
|
||
"description": "Three of the five fixes (CI skip flag, auth error upgrade, deprecated alias) have architectural implications. Eng review validates the contracts before implementation."
|
||
},
|
||
{
|
||
"label": "Ready to implement — run /devex-review after shipping",
|
||
"description": "Skip eng review for now. Implement the five recommendations, then run /devex-review on the live beta to verify TTHW <2 min is achieved."
|
||
},
|
||
{
|
||
"label": "Skip — I'll handle next steps manually",
|
||
"description": "No further review automation. You have the five recommendations; implementation is up to you."
|
||
}
|
||
],
|
||
"multiSelect": false
|
||
}
|
||
],
|
||
"answered": true,
|
||
"failed": false,
|
||
"answers": {
|
||
"D8 — DX review complete. 5 friction points resolved, DX score 4/10 → 8/10, TTHW target achievable. What’s next? <gstack-qid:devex-next-steps>": "Run /plan-eng-review next (recommended)"
|
||
},
|
||
"unansweredQuestionIndices": [],
|
||
"answeredAt": "2026-09-08T20:49:56.950Z"
|
||
};
|
||
|
||
|
||
describe('numbered completed DX handoff preserves native report freshness', () => {
|
||
function completedHandoffTranscript(f: ReturnType<typeof fixture>): PlanCountTranscript {
|
||
const transcript = structuredClone(f.transcript);
|
||
const sessionId = transcript.calls[0]!.sessionId;
|
||
transcript.calls.push({ ...structuredClone(CAPTURED_NUMBERED_DX_HANDOFF), sessionId });
|
||
transcript.planReadyRequests = [{
|
||
sessionId,
|
||
toolUseId: 'toolu_01QwXDuSELZNrgexVf88bQxG',
|
||
timestamp: '2026-09-08T20:50:30.273Z',
|
||
failed: false,
|
||
}];
|
||
return transcript;
|
||
}
|
||
|
||
test('the captured three-choice handoff changes orchestration without requiring another report write', () => {
|
||
const f = fixture();
|
||
try {
|
||
const transcript = completedHandoffTranscript(f);
|
||
expect(hasNativePlanTerminal(transcript, f.file, f.startedAt, 'plan_ready')).toBe(true);
|
||
transcript.planReadyRequests![0]!.failed = true;
|
||
expect(hasNativePlanTerminal(transcript, f.file, f.startedAt, 'plan_ready')).toBe(false);
|
||
transcript.planReadyRequests = [];
|
||
expect(hasNativePlanTerminal(transcript, f.file, f.startedAt, 'plan_ready')).toBe(false);
|
||
} finally {
|
||
f.cleanup();
|
||
}
|
||
});
|
||
|
||
test('substantive, incomplete, unanswered and mixed menus remain report freshness boundaries', () => {
|
||
const f = fixture();
|
||
try {
|
||
for (const mutate of [
|
||
(call: any) => { call.questions[0].question = call.questions[0].question.replace('review complete.', 'review still has unresolved auth behavior.'); },
|
||
(call: any) => { call.questions[0].question = call.questions[0].question.replace('devex-next-steps', 'devex-auth-finding'); },
|
||
(call: any) => { call.questions[0].header = 'Auth policy'; },
|
||
(call: any) => { call.questions[0].options.push({ label: 'Add retry support to the SDK now' }); },
|
||
(call: any) => { call.questions[0].options[1].label = 'Ready to implement — change authentication first'; },
|
||
(call: any) => { call.questions[0].options[2].label = 'Skip — keep the broken authentication'; },
|
||
(call: any) => { call.answers[call.questions[0].question] = 'First implement the missing retry fix'; },
|
||
(call: any) => { call.unansweredQuestionIndices = [0]; },
|
||
(call: any) => { call.questions.push(structuredClone(CAPTURED_CALL.questions[0])); },
|
||
]) {
|
||
const transcript = completedHandoffTranscript(f);
|
||
mutate(transcript.calls[1]);
|
||
expect(hasNativePlanTerminal(transcript, f.file, f.startedAt, 'plan_ready')).toBe(false);
|
||
}
|
||
} finally {
|
||
f.cleanup();
|
||
}
|
||
});
|
||
|
||
test('a later actual review answer still requires a fresh complete report', () => {
|
||
const f = fixture();
|
||
try {
|
||
const transcript = completedHandoffTranscript(f);
|
||
transcript.calls.splice(1, 0, {
|
||
...structuredClone(CAPTURED_CALL),
|
||
toolUseId: 'later-review-decision',
|
||
answeredAt: '2026-09-08T20:49:00.000Z',
|
||
});
|
||
expect(hasNativePlanTerminal(transcript, f.file, f.startedAt, 'plan_ready')).toBe(false);
|
||
fs.utimesSync(f.file, Date.parse('2026-09-08T20:49:20Z') / 1000, Date.parse('2026-09-08T20:49:20Z') / 1000);
|
||
expect(hasNativePlanTerminal(transcript, f.file, f.startedAt, 'plan_ready')).toBe(true);
|
||
fs.writeFileSync(f.file, '## GSTACK REVIEW REPORT\n');
|
||
expect(hasNativePlanTerminal(transcript, f.file, f.startedAt, 'plan_ready')).toBe(false);
|
||
} finally {
|
||
f.cleanup();
|
||
}
|
||
});
|
||
});
|
||
|
||
|
||
// Source-I Eng displayed this compact native approval after ExitPlanMode.
|
||
// Its classification must not itself claim a completed review/report.
|
||
const CAPTURED_COMPACT_PLAN_GATE = `Exit plan mode?
|
||
|
||
Claude wants to exit plan mode
|
||
|
||
❯ 1. Yes, and switch to default (ask each time) for this session
|
||
2. No`;
|
||
|
||
test('the captured compact ExitPlanMode menu is an approval gate, not an ordinary answer', () => {
|
||
expect(isPlanReadyVisible(CAPTURED_COMPACT_PLAN_GATE)).toBe(true);
|
||
expect(classifyPlanCountFrame(CAPTURED_COMPACT_PLAN_GATE)).toBe('plan_ready');
|
||
const f = fixture();
|
||
try {
|
||
expect(hasNativePlanTerminal(f.transcript, f.file, f.startedAt, 'plan_ready')).toBe(false);
|
||
f.transcript.planReadyRequests = [{ sessionId: f.transcript.calls[0]!.sessionId,
|
||
toolUseId: 'exit', timestamp: CAPTURED_FINAL.timestamp, failed: false }];
|
||
fs.writeFileSync(f.file, '# Draft\n');
|
||
expect(hasNativePlanTerminal(f.transcript, f.file, f.startedAt, 'plan_ready')).toBe(false);
|
||
} finally { f.cleanup(); }
|
||
});
|
||
|
||
test('compact approval recognition rejects quoted, incomplete and superseded menus', () => {
|
||
for (const visible of [
|
||
'Should the application show an Exit plan mode? confirmation?',
|
||
'> ' + CAPTURED_COMPACT_PLAN_GATE.replaceAll('\n', '\n> '),
|
||
CAPTURED_COMPACT_PLAN_GATE.replace('Claude wants to exit plan mode', 'The documentation mentions exiting plan mode'),
|
||
CAPTURED_COMPACT_PLAN_GATE.replace(' 2. No', ''),
|
||
CAPTURED_COMPACT_PLAN_GATE + '\nTests\nAdd retry coverage?\n❯ 1. Add test\n 2. Skip\nEnter to select · Esc to cancel',
|
||
]) expect(isPlanReadyVisible(visible), visible).toBe(false);
|
||
});
|
||
|
||
describe('untagged completed DX handoff', () => {
|
||
function nativeHandoff(f: ReturnType<typeof fixture>) {
|
||
const transcript = structuredClone(f.transcript);
|
||
const handoff = { ...structuredClone(capturedL.calls[1]!), sessionId: transcript.calls[0]!.sessionId };
|
||
transcript.calls.push(handoff);
|
||
transcript.planReadyRequests = [{sessionId: handoff.sessionId, toolUseId: 'L-native-exit',
|
||
timestamp: new Date(Date.parse(handoff.answeredAt) + 1000).toISOString(), failed: false}];
|
||
return transcript;
|
||
}
|
||
test('actual completed navigation does not make the existing report stale', () => {
|
||
const f = fixture();
|
||
try {
|
||
expect(hasNativePlanTerminal(nativeHandoff(f), f.file, f.startedAt, 'plan_ready')).toBe(true);
|
||
} finally { f.cleanup(); }
|
||
});
|
||
test('missing identity needs positive completion and resolved findings, with native approval and a fresh report', () => {
|
||
const f = fixture();
|
||
try {
|
||
for (const mutate of [
|
||
(t: PlanCountTranscript) => { const q=t.calls[1]!.questions[0]!; q.question += ' <gstack-qid:devex-auth-finding>'; },
|
||
(t: PlanCountTranscript) => { t.calls[1]!.questions[0]!.question += ' <gstack-qid:devex-next-steps> <gstack-qid:broken'; },
|
||
(t: PlanCountTranscript) => { const q=t.calls[1]!.questions[0]!; q.question=q.question.replace('is complete.', 'is not complete.'); },
|
||
(t: PlanCountTranscript) => { const q=t.calls[1]!.questions[0]!; q.question=q.question.replace('Five issues found and resolved', 'Five issues need decisions'); },
|
||
(t: PlanCountTranscript) => { const q=t.calls[1]!.questions[0]!; q.question=q.question.replace('Five issues found and resolved', 'No issues resolved'); },
|
||
(t: PlanCountTranscript) => { const q=t.calls[1]!.questions[0]!; q.question=q.question.replace('Five issues found and resolved', 'Not five issues found and resolved'); },
|
||
(t: PlanCountTranscript) => { const q=t.calls[1]!.questions[0]!; q.question=q.question.replace('What next?', 'One gap remains. What next?'); },
|
||
(t: PlanCountTranscript) => { t.calls[1]!.questions[0]!.options.push({label:'Add a new authentication policy'}); },
|
||
(t: PlanCountTranscript) => { t.calls[1]!.answered=false; },
|
||
(t: PlanCountTranscript) => { t.calls[1]!.failed=true; },
|
||
(t: PlanCountTranscript) => { t.calls[1]!.answers={}; },
|
||
(t: PlanCountTranscript) => { t.planReadyRequests=[]; },
|
||
(t: PlanCountTranscript) => { t.planReadyRequests![0]!.failed=true; },
|
||
]) {
|
||
const t=nativeHandoff(f);
|
||
const originalQuestion=t.calls[1]!.questions[0]!.question;
|
||
const originalAnswer=t.calls[1]!.answers?.[originalQuestion];
|
||
mutate(t);
|
||
const nextQuestion=t.calls[1]!.questions[0]!.question;
|
||
if (nextQuestion !== originalQuestion && originalAnswer && t.calls[1]!.answers?.[originalQuestion]) {
|
||
delete t.calls[1]!.answers![originalQuestion];
|
||
t.calls[1]!.answers![nextQuestion]=originalAnswer;
|
||
}
|
||
expect(hasNativePlanTerminal(t, f.file, f.startedAt, 'plan_ready')).toBe(false);
|
||
}
|
||
const t=nativeHandoff(f);
|
||
t.calls.splice(1,0,{...structuredClone(t.calls[0]!),toolUseId:'new-late-finding',
|
||
answeredAt:new Date(Date.parse(t.calls[1]!.answeredAt!) - 1000).toISOString()});
|
||
expect(hasNativePlanTerminal(t,f.file,f.startedAt,'plan_ready')).toBe(false);
|
||
fs.writeFileSync(f.file,'## GSTACK REVIEW REPORT\n');
|
||
expect(hasNativePlanTerminal(nativeHandoff(f),f.file,f.startedAt,'plan_ready')).toBe(false);
|
||
} finally {f.cleanup();}
|
||
});
|
||
});
|