mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-27 07:01:54 +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>
497 lines
28 KiB
TypeScript
497 lines
28 KiB
TypeScript
/**
|
||
* SDK-based AUQ capture — the reliable way to grade AskUserQuestion content.
|
||
*
|
||
* Real-PTY capture is lossy for plan-mode AUQs: they render every option on one
|
||
* cursor-positioned logical line that stripAnsi can't reconstruct, so format
|
||
* predicates (ELI10:, Net:, ✅) silently miss even when the question is
|
||
* well-formed. This helper instead uses the `claude -p` SDK path (the same one
|
||
* skill-e2e-plan-format uses): the agent is told to WRITE the verbatim text of
|
||
* the AskUserQuestion it would have asked to a file. That captures exactly what
|
||
* the model GENERATES — the surface where carving could degrade quality — with
|
||
* zero rendering loss. The TTY rendering layer is identical for fat and slim
|
||
* skills, so it is not where token-reduction degradation can hide.
|
||
*/
|
||
import { resolveEvalModel } from '../../lib/eval-model';
|
||
import * as fs from 'node:fs';
|
||
import * as os from 'node:os';
|
||
import * as path from 'node:path';
|
||
import { spawnSync } from 'node:child_process';
|
||
import { runSkillTest, type SkillTestResult } from './session-runner';
|
||
|
||
const ROOT = path.resolve(__dirname, '..', '..');
|
||
|
||
/**
|
||
* Existing long section-loader work budget (v1.71): complete workflows can
|
||
* load their sections quickly, then need 300–450s to generate the full report.
|
||
* Keep 120s of the CAPTURE_LONG_MS outer budget for setup and reporting.
|
||
* Ordinary captureSectionReads callers retain the 300s default below.
|
||
*/
|
||
export const LONG_SECTION_CAPTURE_MS = 480_000;
|
||
|
||
/** The 7 decision-brief format elements graded on the captured AUQ text. */
|
||
export const AUQ_FORMAT_ELEMENTS: Array<{ field: string; re: RegExp }> = [
|
||
{ field: 'ELI10:', re: /ELI10\s*:/i },
|
||
{ field: 'Recommendation:', re: /Recommendation\s*:/i },
|
||
{ field: 'Pros / cons:', re: /Pros\s*\/\s*cons/i },
|
||
{ field: '✅', re: /✅/ },
|
||
{ field: '❌', re: /❌/ },
|
||
{ field: 'Net:', re: /Net\s*:/i },
|
||
{ field: '(recommended)', re: /\(recommended\)/i },
|
||
];
|
||
|
||
export function scoreAuqFormat(text: string): { present: number; total: number; missing: string[] } {
|
||
const missing = AUQ_FORMAT_ELEMENTS.filter(e => !e.re.test(text)).map(e => e.field);
|
||
return { present: AUQ_FORMAT_ELEMENTS.length - missing.length, total: AUQ_FORMAT_ELEMENTS.length, missing };
|
||
}
|
||
|
||
/**
|
||
* Grade recommendation substance ROBUST to the connective. judgeRecommendation()
|
||
* keys on the literal "because" (correct for the spec, pinned by
|
||
* llm-judge-recommendation.test.ts), but skills routinely write equally
|
||
* substantive reasons as "Recommendation: A. <reason>" / "A — <reason>" /
|
||
* "A: <reason>". Grading those as substance-1 would make the matrix cry wolf on
|
||
* genuinely good recommendations. So we normalize a non-"because" connective to
|
||
* "because" purely for grading, then call the shared judge. We also report
|
||
* whether the ORIGINAL used the literal "because" — a soft style signal, since
|
||
* the format spec prefers it and the voice rule forbids the em-dash form.
|
||
*
|
||
* This does NOT touch judgeRecommendation or its pinned fixtures.
|
||
*/
|
||
export async function gradeAuqRecommendation(
|
||
text: string,
|
||
): Promise<{ substance: number; present: boolean; hadLiteralBecause: boolean; reason: string }> {
|
||
const { judgeRecommendation } = await import('./llm-judge');
|
||
const recLine = text.match(/^[*_]*\s*recommendation\s*[*_]*\s*:\s*(.+)$/im);
|
||
const hadLiteralBecause = !!recLine && /\bbecause\s+\S/i.test(recLine[1]);
|
||
|
||
let graded = text;
|
||
if (recLine && !hadLiteralBecause) {
|
||
// Rewrite "Recommendation: <choice><sep><reason>" → "...<choice> because <reason>"
|
||
// sep ∈ {". ", " — ", " - ", ": "} right after a short choice token.
|
||
const normalizedLine = recLine[1].replace(
|
||
/^([^.:—-]{1,40}?)\s*(?:\.\s+|\s*[—-]\s+|:\s+)(\S.+)$/,
|
||
'$1 because $2',
|
||
);
|
||
if (normalizedLine !== recLine[1]) {
|
||
graded = text.replace(recLine[0], `Recommendation: ${normalizedLine}`);
|
||
}
|
||
}
|
||
|
||
try {
|
||
const r = await judgeRecommendation(graded);
|
||
return { substance: r.reason_substance, present: r.present, hadLiteralBecause, reason: r.reason_text };
|
||
} catch {
|
||
return { substance: 0, present: !!recLine, hadLiteralBecause, reason: '' };
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Build a throwaway plan dir holding a SPECIFIC plan-ceo-review SKILL.md (so we
|
||
* can pit the carved skeleton against the verbose monolith). `sectionsFrom`, if
|
||
* given, copies that dir's sections/ alongside (for the carved variant).
|
||
*/
|
||
export function setupPlanCeoDir(opts: {
|
||
skillMd: string;
|
||
sectionsFrom?: string | null;
|
||
tmpPrefix?: string;
|
||
}): string {
|
||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), opts.tmpPrefix ?? 'auq-sdk-'));
|
||
const run = (cmd: string, args: string[]) => spawnSync(cmd, args, { cwd: dir, stdio: 'pipe', timeout: 5000 });
|
||
run('git', ['init', '-b', 'main']);
|
||
run('git', ['config', 'user.email', 'test@test.com']);
|
||
run('git', ['config', 'user.name', 'Test']);
|
||
fs.writeFileSync(
|
||
path.join(dir, 'plan.md'),
|
||
[
|
||
'# Plan: Launch a "developer-friendly" pricing tier',
|
||
'',
|
||
'## Goal',
|
||
'Increase developer adoption.',
|
||
'',
|
||
'## Success metric',
|
||
'More signups.',
|
||
'',
|
||
'## Premise',
|
||
"We haven't talked to any developers about whether the current pricing is a",
|
||
'barrier. The team agreed it "feels like" it should be cheaper.',
|
||
].join('\n'),
|
||
);
|
||
fs.mkdirSync(path.join(dir, 'plan-ceo-review'), { recursive: true });
|
||
fs.writeFileSync(path.join(dir, 'plan-ceo-review', 'SKILL.md'), opts.skillMd);
|
||
if (opts.sectionsFrom && fs.existsSync(opts.sectionsFrom)) {
|
||
fs.cpSync(opts.sectionsFrom, path.join(dir, 'plan-ceo-review', 'sections'), { recursive: true });
|
||
}
|
||
run('git', ['add', '.']);
|
||
run('git', ['commit', '-m', 'plan']);
|
||
return dir;
|
||
}
|
||
|
||
/**
|
||
* Generic: build a throwaway dir holding ANY skill's SKILL.md (+ optional
|
||
* sections) plus arbitrary fixture files, so the matrix can drive each skill to
|
||
* its first AUQ. Mirrors setupPlanCeoDir but skill-agnostic.
|
||
*/
|
||
export function setupSkillDir(opts: {
|
||
skillName: string;
|
||
skillMd: string;
|
||
sectionsFrom?: string | null;
|
||
fixtures?: Record<string, string>;
|
||
tmpPrefix?: string;
|
||
}): string {
|
||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), opts.tmpPrefix ?? `auq-${opts.skillName}-`));
|
||
const run = (cmd: string, args: string[]) => spawnSync(cmd, args, { cwd: dir, stdio: 'pipe', timeout: 5000 });
|
||
run('git', ['init', '-b', 'main']);
|
||
run('git', ['config', 'user.email', 'test@test.com']);
|
||
run('git', ['config', 'user.name', 'Test']);
|
||
for (const [name, content] of Object.entries(opts.fixtures ?? {})) {
|
||
const p = path.join(dir, name);
|
||
fs.mkdirSync(path.dirname(p), { recursive: true });
|
||
fs.writeFileSync(p, content);
|
||
}
|
||
fs.mkdirSync(path.join(dir, opts.skillName), { recursive: true });
|
||
fs.writeFileSync(path.join(dir, opts.skillName, 'SKILL.md'), opts.skillMd);
|
||
if (opts.sectionsFrom && fs.existsSync(opts.sectionsFrom)) {
|
||
fs.cpSync(opts.sectionsFrom, path.join(dir, opts.skillName, 'sections'), { recursive: true });
|
||
}
|
||
run('git', ['add', '.']);
|
||
run('git', ['commit', '-m', 'fixture']);
|
||
return dir;
|
||
}
|
||
|
||
/** Read any skill's current (worktree) SKILL.md + its sections dir if present. */
|
||
export function skillFromWorktree(skillName: string): { skillMd: string; sectionsFrom: string | null } {
|
||
const sec = path.join(ROOT, skillName, 'sections');
|
||
return {
|
||
skillMd: fs.readFileSync(path.join(ROOT, skillName, 'SKILL.md'), 'utf-8'),
|
||
sectionsFrom: fs.existsSync(sec) ? sec : null,
|
||
};
|
||
}
|
||
|
||
/**
|
||
* Generic: drive ANY skill to its FIRST AskUserQuestion and capture the
|
||
* verbatim decision-brief text the model would have shown. `scenario` is the
|
||
* per-skill prose that triggers a real AUQ (e.g. "review plan.md", "audit
|
||
* vuln.ts for security"). Absolute skill path + Read/Write-only so the agent
|
||
* cannot wander to the global install.
|
||
*/
|
||
export async function captureFirstAuq(opts: {
|
||
planDir: string;
|
||
skillName: string;
|
||
scenario: string;
|
||
testName: string;
|
||
runId?: string;
|
||
model?: string;
|
||
}): Promise<string> {
|
||
const outFile = path.join(opts.planDir, 'ask-capture.md');
|
||
const skillPath = path.join(opts.planDir, opts.skillName, 'SKILL.md');
|
||
const prompt = `You are running a format-capture test. The ONLY skill file you may read is this absolute path: ${skillPath}. Do NOT search for, Glob, find, or read any other SKILL.md anywhere — especially nothing under ~/.claude or /Users.
|
||
|
||
Read ${skillPath} and follow its workflow for this scenario:
|
||
|
||
${opts.scenario}
|
||
|
||
This is a capture test, not an interactive session. Skip any system-audit / environment-setup / codebase-exploration steps. When you reach the FIRST point where the skill would call AskUserQuestion, write the verbatim full decision-brief text of that question (title, ELI10, stakes, recommendation, every option with its ✅/❌ pros/cons bullets, and the Net line) to ${outFile}. Do NOT call any tool to ask the user. Do NOT paraphrase. After writing the file, STOP.`;
|
||
|
||
await runSkillTest({
|
||
prompt,
|
||
workingDirectory: opts.planDir,
|
||
allowedTools: ['Read', 'Write'],
|
||
maxTurns: 14,
|
||
timeout: 240_000,
|
||
testName: opts.testName,
|
||
runId: opts.runId,
|
||
model: resolveEvalModel('capture', opts.model),
|
||
});
|
||
|
||
try {
|
||
return fs.readFileSync(outFile, 'utf-8');
|
||
} catch {
|
||
return '';
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Drive ANY carved skill through a real `claude -p` run and detect, LOSSLESSLY,
|
||
* which `sections/<file>.md` files the agent actually Read — from the tool-use
|
||
* stream, not the ANSI screen buffer. This is the reliable replacement for the
|
||
* real-PTY `visibleSince()` screen-scraping the section-loading tests used to do
|
||
* (which silently saw nothing in a Conductor PTY: cursor-positioned renders and
|
||
* an unanswered Step 0 question loop both defeat the regex).
|
||
*
|
||
* The skill under test is the planted copy in `planDir` (pin the absolute path so
|
||
* the agent cannot wander to the global install). AskUserQuestion is declared
|
||
* unavailable so the agent auto-picks the recommended option and proceeds far
|
||
* enough to hit the post-Step-0 STOP-Read directives; Read is the tool a STOP-Read
|
||
* resolves to, so Read/Grep/Glob/Write/Edit cover local artifacts (no Bash → it cannot
|
||
* `find /` its way out, nor run git/gh mutations).
|
||
*/
|
||
export function hasDisabledOutsideReview(output: string): boolean {
|
||
const headings = [...output.matchAll(/^## GSTACK REVIEW REPORT[ \t]*\r?$/gm)];
|
||
const heading = headings.at(-1);
|
||
if (!heading) return false;
|
||
const section = output.slice(heading.index! + heading[0].length).split(/^##[ \t]+/m, 1)[0];
|
||
const plain = (cell: string) => cell.replace(/[*_`]/g, '').trim().replace(/\s+/g, ' ').toLowerCase();
|
||
for (const line of section.split('\n')) {
|
||
if (!line.trimStart().startsWith('|')) continue;
|
||
const cells = line.split('|').map(plain);
|
||
if (cells[1] === 'outside review') {
|
||
return /^disabled(?:$|\s|[(:—–-])/.test(cells[5] ?? '');
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
export async function captureSectionReads(opts: {
|
||
planDir: string;
|
||
skillName: string;
|
||
/** Fixture-authorized local artifact commands. */
|
||
artifactCommands?: string;
|
||
scenario: string;
|
||
/** The fixture actor's decision authority; defaults to recommended choices. */
|
||
decisionPolicy?: string;
|
||
/** Relative filename the agent writes its final output to (terminal signal). */
|
||
reportFile?: string;
|
||
/** Marker proving a real report/plan was produced (default: any non-empty text). */
|
||
reportMarker?: RegExp;
|
||
testName: string;
|
||
runId?: string;
|
||
model?: string;
|
||
maxTurns?: number;
|
||
timeout?: number;
|
||
/** Measure native section loading with the documented extra-review opt-out. */
|
||
nativeReviewOnly?: boolean;
|
||
}): Promise<{ readSections: Set<string>; reportProduced: boolean; reportWritten: boolean;
|
||
exitReason: SkillTestResult['exitReason']; toolCalls: SkillTestResult['toolCalls'];
|
||
transcript: SkillTestResult['transcript']; output: string }> {
|
||
const outFile = path.join(opts.planDir, opts.reportFile ?? 'REPORT.md');
|
||
const timeout = opts.timeout ?? 300_000;
|
||
const fullPlanReview = opts.skillName === 'plan-ceo-review' || opts.skillName === 'plan-eng-review';
|
||
// The Eng actor may run local review writers. Reject foreign destinations
|
||
// before creating its state or starting a child, including symlink escapes.
|
||
// Tool approval is not a filesystem sandbox; this checks fixture ownership.
|
||
if (opts.skillName === 'plan-eng-review' && opts.nativeReviewOnly && opts.artifactCommands) {
|
||
if (fs.lstatSync(opts.planDir).isSymbolicLink()) throw new Error('Eng section fixture root must not be a symlink');
|
||
const owner = fs.realpathSync(opts.planDir);
|
||
const isInside = (root: string, target: string) => {
|
||
const relative = path.relative(root, target);
|
||
return relative !== '..' && !relative.startsWith('..' + path.sep) && !path.isAbsolute(relative);
|
||
};
|
||
if (path.resolve(outFile) === path.resolve(opts.planDir) || !isInside(path.resolve(opts.planDir), path.resolve(outFile))) {
|
||
throw new Error('Eng section report must stay inside its fixture root');
|
||
}
|
||
let existing = path.resolve(outFile);
|
||
for (;;) {
|
||
try { fs.lstatSync(existing); break; }
|
||
catch (error) {
|
||
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;
|
||
existing = path.dirname(existing);
|
||
}
|
||
}
|
||
if (!isInside(owner, fs.realpathSync(existing))) throw new Error('Eng section report must stay inside its fixture root');
|
||
}
|
||
const readReport = (): Buffer | undefined => {
|
||
try { return fs.readFileSync(outFile); }
|
||
catch (error) {
|
||
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;
|
||
return undefined;
|
||
}
|
||
};
|
||
const beforeReport = readReport();
|
||
const skillPath = path.join(opts.planDir, opts.skillName, 'SKILL.md');
|
||
// Outside-review dispatch has separate behavioral coverage. Native-only
|
||
// captures use the real supported control in state owned by this call;
|
||
// never mutate the operator's or another capture's gstack configuration.
|
||
// Keep the model-facing config path relative to the fixture's working directory.
|
||
const stateDir = opts.nativeReviewOnly
|
||
? fs.mkdtempSync(path.join(path.resolve(opts.planDir), '.gstack-section-state-')) : null;
|
||
const nativeReviewRule = stateDir
|
||
? `\n- Read ${path.relative(path.resolve(opts.planDir), path.join(stateDir, 'config.yaml'))}, the isolated gstack configuration for this capture. It sets codex_reviews: disabled. Follow that documented control: skip the entire extra outside-review step, including its native fallback, and report outside coverage as disabled. Complete all native review sections and the full required report.`
|
||
: '';
|
||
// The actor needs the same execution window as the runner to allocate work.
|
||
// Pacing does not change the review's required content or completion gates.
|
||
const planReviewWritingRule = fullPlanReview
|
||
? `\n- Native execution window: ${timeout / 1000} seconds. Use the system notice's runner-bound deadline and the observed clock to reserve the final ${timeout / 4000} seconds for assembling and verifying completion outputs. Bash may additionally run exactly \`date -u +%Y-%m-%dT%H:%M:%SZ\` for a read-only clock check, including when other Bash commands are restricted. Every required section, finding, approval and output still has to be completed; this is pacing guidance, not permission to skip work.
|
||
1. Read the required skill and source material, then resolve Step 0 under the supplied author policy. ${opts.skillName === 'plan-eng-review' ? 'When Scope Challenge finishes, save its outcome. Check the Write/Edit result and Read the saved outcome before advancing.' : 'Follow each workflow save/readback checkpoint as it occurs; do not defer all persistence to one final Write.'} Preserve original requirements and accepted plan amendments throughout.
|
||
2. Whenever Step 0 or a section needs an independent choice, give it one ID and one authoritative decision record; findings may reference several choice IDs. Before auto-selecting, save its full currentDecision question/header, every labeled option and full description, commitment comparison and source citations. Read back and verify those fields against the drafted decision and cited source; fix mismatches first. Then record the authorized auto-decision and exact scope, apply answers and amendments with scoped Edit operations, and Read back before taking another row. Keep the complete question and every option before selecting, as the skill requires.
|
||
3. Work through ${opts.skillName === 'plan-ceo-review' ? 'all 11 sections, giving each an explicit outcome (including no issues or justified skips)' : 'all four review sections, including an explicit "No issues found" when applicable'}. ${opts.skillName === 'plan-eng-review' ? 'After each completed review section, save its complete findings and disposition with concrete evidence, the selected remedy, residual risks, and verification. Check the Write/Edit result and Read the saved outcome before advancing to the next section; these checkpoints also apply when no new choice needs approval.' : 'As sections finish, add each finding once with concrete evidence, the selected remedy, residual risks, and verification.'} Use compact outcomes, short option bullets and table cells. Execute checklists without copying their questions or narrating every check. Cross-reference saved IDs instead of repeating findings, option deliberations, diagrams or registries; do not regenerate unchanged records or repeat their briefs in the final report. Do not write full implementation or test code unless needed to specify an accepted change.
|
||
4. Use the completion reserve to assemble ${opts.skillName === 'plan-ceo-review' ? 'the complete required registries, applicable diagrams, tasks, completion summary, and exact GSTACK REVIEW REPORT table' : 'the required diagrams, test-plan artifact, tasks, TODOS dispositions, completion summary and GSTACK REVIEW REPORT'}. Preserve every finding and original requirement, required decision fields and comparisons, exact approvals and verification; every diagram must retain its specified format. Read back the assembled plan and verify the full required outputs. Finish missing required outputs with scoped Edits, without rewriting unchanged records, then perform the skill's full final Read-back gate. Complete every required artifact and verification before returning.`
|
||
: '';
|
||
const prompt = `You are running an automated skill-execution test. No human is present, so AskUserQuestion is unavailable. The ONLY skill file you may read is this absolute path: ${skillPath}. Do NOT Glob/find/search for any other SKILL.md anywhere — especially nothing under ~/.claude or /Users.
|
||
|
||
Read ${skillPath} and EXECUTE its workflow for this scenario:
|
||
|
||
${opts.scenario}
|
||
|
||
Rules for this run:
|
||
- Skip system-audit, environment-setup, telemetry, and unrelated codebase exploration. Read the supplied plan's referenced fixture files when its review requires them.
|
||
${opts.decisionPolicy ?? "- At any decision point that would call AskUserQuestion, silently pick the skill's recommended option and continue. Do NOT stop to ask."}
|
||
- This skill's body has been carved into on-demand sections/. When the skill gives a STOP-Read directive (for example "Read \`.../sections/<file>\` and execute it in full"), you MUST actually Read that sections/ file with the Read tool BEFORE doing the work it covers. Do not work from memory.
|
||
- Resolve installed-root paths for section and companion Markdown files under ${opts.planDir}, where this fixture's skill package is copied.
|
||
- Do NOT run git, gh, commit, push, or any mutating command${opts.artifactCommands ? ' except the local artifact commands explicitly authorized below' : ''}.${opts.artifactCommands ? `\n- ${opts.artifactCommands}` : ''}
|
||
${fullPlanReview ? `- Save the evolving plan and review outputs to ${outFile} with Write/Edit at the workflow checkpoints below.` : `- When the workflow is complete, write the skill's final output (the full review report / ship plan, including any required report table) to ${outFile}.`}${nativeReviewRule}${planReviewWritingRule}
|
||
- After all required writes are complete, return a brief completion message and STOP. Do not reproduce the full report in the final response.`;
|
||
|
||
let result: SkillTestResult;
|
||
try {
|
||
if (stateDir) fs.writeFileSync(path.join(stateDir, 'config.yaml'), 'codex_reviews: disabled\n');
|
||
result = await runSkillTest({
|
||
prompt,
|
||
workingDirectory: opts.planDir,
|
||
allowedTools: ['Read', 'Grep', 'Glob', 'Write', 'Edit', ...(opts.nativeReviewOnly ? [] : ['Agent']), ...(opts.artifactCommands || fullPlanReview ? ['Bash'] : [])],
|
||
tools: ['Read', 'Grep', 'Glob', 'Write', 'Edit', ...(opts.nativeReviewOnly ? [] : ['Agent']), ...(opts.artifactCommands || fullPlanReview ? ['Bash'] : [])],
|
||
publicStreamDiagnostics: true,
|
||
...(fullPlanReview ? { completionReserveMs: timeout / 4 } : {}),
|
||
maxTurns: opts.maxTurns ?? 25,
|
||
timeout,
|
||
testName: opts.testName,
|
||
runId: opts.runId,
|
||
model: resolveEvalModel('capture', opts.model),
|
||
...(stateDir ? { env: { GSTACK_HOME: stateDir, GSTACK_STATE_ROOT: stateDir } } : {}),
|
||
});
|
||
} finally {
|
||
if (stateDir) fs.rmSync(stateDir, { recursive: true, force: true });
|
||
}
|
||
|
||
const readSections = new Set<string>();
|
||
for (const c of result.toolCalls) {
|
||
if (c.tool !== 'Read') continue;
|
||
const fp = String(c.input?.file_path ?? '');
|
||
const m = fp.match(/(?:^|[\\/])sections[\\/]([A-Za-z0-9._-]+\.md)(?=$|[?#])/);
|
||
if (m) readSections.add(m[1]);
|
||
}
|
||
|
||
const afterReport = readReport();
|
||
const reportWritten = afterReport !== undefined
|
||
&& (beforeReport === undefined || !afterReport.equals(beforeReport));
|
||
// An unchanged seed (including a same-byte rewrite) is not this attempt's report.
|
||
const output = reportWritten ? afterReport!.toString('utf-8') : result.output ?? '';
|
||
const reportProduced = result.exitReason === 'success'
|
||
&& (opts.reportMarker ? opts.reportMarker.test(output) : output.trim().length > 0);
|
||
|
||
// Keep successful terminal-output captures, but a draft left by a failed run
|
||
// must never satisfy callers that use reportProduced as their completion gate.
|
||
return { readSections, reportProduced, reportWritten, exitReason: result.exitReason, toolCalls: result.toolCalls, transcript: result.transcript, output };
|
||
}
|
||
|
||
/** A completed CEO review needs its artifact and every summary outcome. */
|
||
export function validateCeoReviewCompletion(capture: {
|
||
exitReason: string;
|
||
reportWritten: boolean;
|
||
output: string;
|
||
}): void {
|
||
if (capture.exitReason !== 'success') {
|
||
throw new Error(`CEO review execution failed: ${capture.exitReason}`);
|
||
}
|
||
if (!capture.reportWritten) throw new Error('CEO review did not write REPORT.md');
|
||
const lines = capture.output.split(/\r?\n/);
|
||
const summaryStart = lines.findIndex(line =>
|
||
/^(?:#{1,6}\s+(?:\d+[.)]\s+)?)?(?:\|\s*)?(?:MEGA PLAN REVIEW\s*[—–-]\s*)?COMPLETION SUMMARY(?:\s*\|)?$/i
|
||
.test(line.trim().replace(/\*\*/g, '')),
|
||
);
|
||
if (summaryStart === -1) throw new Error('CEO report is missing its Completion Summary');
|
||
const summaryLines = lines.slice(summaryStart + 1);
|
||
const nextHeading = summaryLines.findIndex(line => /^#{1,6}\s+\S/.test(line));
|
||
const summary = nextHeading === -1 ? summaryLines : summaryLines.slice(0, nextHeading);
|
||
const outcomes = new Map<number, string>();
|
||
for (const line of summary) {
|
||
const row = line.replace(/\*\*/g, '').match(/^\s*\|\s*Section\s+(\d{1,2})\b[^|]*\|\s*(.*?)\s*\|\s*$/i);
|
||
if (row) outcomes.set(Number(row[1]), row[2].replace(/\*\*/g, '').trim());
|
||
}
|
||
for (let section = 1; section <= 11; section++) {
|
||
const outcome = outcomes.get(section) ?? '';
|
||
const placeholder = !outcome || /___/.test(outcome)
|
||
|| /^(?:TBD|TODO|pending|not reviewed|done|complete(?:d)?|reviewed|[-—]+)[.!]?$/i.test(outcome);
|
||
const skipped = /^(?:skip(?:ped)?|N\/A|not applicable)\b/i.test(outcome);
|
||
const noUi = section === 11 && /\bno UI\b/i.test(outcome);
|
||
if (placeholder || (skipped && !noUi)) {
|
||
throw new Error(`CEO Completion Summary is missing a completed Section ${section} outcome`);
|
||
}
|
||
}
|
||
}
|
||
|
||
/** Read the carved (current worktree) plan-ceo SKILL.md + its sections dir. */
|
||
export function carvedSkill(): { skillMd: string; sectionsFrom: string | null } {
|
||
const sec = path.join(ROOT, 'plan-ceo-review', 'sections');
|
||
return {
|
||
skillMd: fs.readFileSync(path.join(ROOT, 'plan-ceo-review', 'SKILL.md'), 'utf-8'),
|
||
sectionsFrom: fs.existsSync(sec) ? sec : null,
|
||
};
|
||
}
|
||
|
||
/** Read the pre-carve verbose monolith plan-ceo SKILL.md.
|
||
* VENDORED fixture (v1.75 precedent), not a git ref: the old default
|
||
* `git show ab66193e^:...` pinned a BRANCH-LOCAL commit — it dies the day
|
||
* that branch is pruned and already fails on shallow clones. The fixture
|
||
* is the frozen pre-cut render; test/git-ref-fixture-tripwire.test.ts
|
||
* keeps this class from coming back. */
|
||
export function verboseSkill(): string {
|
||
return fs.readFileSync(
|
||
path.join(ROOT, 'test', 'fixtures', 'auq-pre-cut-plan-ceo-review-SKILL.md'),
|
||
'utf-8',
|
||
);
|
||
}
|
||
|
||
function execGit(args: string[]): string {
|
||
const r = spawnSync('git', args, { cwd: ROOT, encoding: 'utf-8', maxBuffer: 64 * 1024 * 1024, timeout: 30_000 });
|
||
if (r.status !== 0) throw new Error(`git ${args.join(' ')} failed: ${r.stderr}`);
|
||
return r.stdout;
|
||
}
|
||
|
||
/**
|
||
* Drive plan-ceo-review to its Step 0F mode-selection AskUserQuestion in the
|
||
* given plan dir and capture the verbatim question text the model generates.
|
||
* Returns the captured text ('' if the agent never wrote the file).
|
||
*/
|
||
export async function captureModeSelectionAuq(opts: {
|
||
planDir: string;
|
||
testName: string;
|
||
runId?: string;
|
||
model?: string;
|
||
}): Promise<string> {
|
||
const outFile = path.join(opts.planDir, 'ask-capture.md');
|
||
const skillPath = path.join(opts.planDir, 'plan-ceo-review', 'SKILL.md');
|
||
const planPath = path.join(opts.planDir, 'plan.md');
|
||
// CRITICAL: pin the EXACT skill file. Without this the agent runs
|
||
// `find / -name SKILL.md` / Glob and reads the GLOBAL install
|
||
// (~/.claude/skills/...) instead of the version-under-test in the temp dir —
|
||
// which silently invalidates a carved-vs-verbose A/B (both sides end up
|
||
// reading the same global skill). Absolute path + no-wander instruction +
|
||
// Bash disallowed (so `find /` is impossible) locks it to the planted file.
|
||
const prompt = `You are running a format-capture test. Use ONLY these two files:
|
||
- The skill to follow: ${skillPath}
|
||
- The plan to review: ${planPath}
|
||
|
||
Read ${skillPath} for the review workflow. Do NOT search for, Glob, find, or read any OTHER SKILL.md anywhere on the system — especially nothing under ~/.claude or /Users. The ONLY skill file you may read is the absolute path above.
|
||
|
||
Read ${planPath} — that is the plan to review. It is a standalone plan document, not a codebase. Skip any codebase exploration or system-audit steps.
|
||
|
||
Proceed to Mode Selection, where the skill presents the 4 review-mode options to the user via AskUserQuestion.
|
||
|
||
Write the verbatim text of that AskUserQuestion (the full decision brief: title, ELI10, stakes, recommendation, every option with its pros/cons bullets, and the Net line) to ${outFile}. Do NOT call any tool to ask the user. Do NOT paraphrase. After writing the file, stop.`;
|
||
|
||
await runSkillTest({
|
||
prompt,
|
||
workingDirectory: opts.planDir,
|
||
// Read + Write only: no Bash means the agent cannot `find /` its way to the
|
||
// global install, and the skill's preamble bash blocks (irrelevant to format
|
||
// capture) can't run and wander.
|
||
allowedTools: ['Read', 'Write'],
|
||
maxTurns: 12,
|
||
timeout: 240_000,
|
||
testName: opts.testName,
|
||
runId: opts.runId,
|
||
model: resolveEvalModel('capture', opts.model),
|
||
});
|
||
|
||
try {
|
||
const text = fs.readFileSync(outFile, 'utf-8');
|
||
// Defense in depth: verify the agent actually read the planted skill, not a
|
||
// global one. If the captured run somehow read elsewhere we can't detect it
|
||
// from the output file alone, so callers should also confirm via the run
|
||
// log; this guard at least catches an empty/placeholder capture.
|
||
return text;
|
||
} catch {
|
||
return '';
|
||
}
|
||
}
|