mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-16 09:55:29 +02:00
* feat: add a restricted and supervised Claude Code runner Preserve configured authentication and models while enforcing tool access, strict completion JSON, bounded output and process cleanup. Cover argv, failure handling, session metadata and Windows process containment. * feat: route outside reviews by harness and migrate wrapper installs Use Claude Code from Codex and Codex from other supported hosts, with shared invocation rendering, positive gate validation and per-phase provenance. Rename /claude to /claude-code, repair managed shared and copied installations safely, and generate native Kiro skills. Add installed-workflow, failure-injection and live cross-harness regression coverage. * test: recognize CEO mode labels without terminal spacing The paid workflow rendered SCOPEEXPANSION at option 4, but its driver required a literal space. Match the leading mode title without cursor-spacing artifacts and ignore adjacent preview text. Preserve missing-target failures and downstream posture assertions. * test: isolate plan-count fixtures before starting review workflows Seed the complete test plan in a private git repository before launching Claude, so a bare slash command cannot review the live workspace while a delayed fixture message remains queued. Preserve count thresholds, parsers and budgets. Add initial-context and installed-discovery tests, and retain startup/terminal diagnostics on failed evaluations. * test: stabilize review fixtures and Claude eval startup Preserve source boundaries in workflow judge inputs, isolate CEO mode plans, and wait for interactive trust input readiness. Keep startup failure evidence and retain existing models, budgets, and assertions. Co-Authored-By: OpenAI Codex <noreply@openai.com> * test: classify collapsed review modes and isolate seeded findings Keep review questions out of the setup count when terminal cursor positioning removes spaces. State existing webhook safeguards so the five-finding control measures its seeded defects without accidental extra security and concurrency gaps. Preserve question bands and the paired control. Co-Authored-By: OpenAI Codex <noreply@openai.com> * test: isolate browser daemon state across free shards Co-Authored-By: OpenAI Codex <noreply@openai.com> * test: stabilize native review counting and interactive navigation Co-Authored-By: OpenAI Codex <noreply@openai.com> * chore: prepare v1.82.0.0 release Co-Authored-By: OpenAI Codex <noreply@openai.com> * fix: eliminate browser and process-cleanup test flakes Pin every CI surface to Bun 1.4.0 to avoid extra-stdio finalizers closing reused live sockets. Add an isolated GC/listener regression that fails on Bun 1.3.13, and prevent coordinated rollback to an affected CI runtime. Check renderer cleanup against the render's own staging directory so concurrent renders cannot invalidate the assertion. Make the no-pgrep process-tree walk tolerate disappearing /proc entries, and synchronize its test fixture through child readiness and pipe EOF instead of sleeps. Validation: 9,157 passed, 31 skipped, zero failures across 556 files with retries disabled. Build, all-host generation freshness, and skill checks passed. All three races have failing-before/passing-after regressions. * fix: count completed native review questions in evals * fix: drive review navigation from confirmed native choices * fix: require complete section-loading eval reports * test: isolate telemetry HTTP transport from local assertions * fix: keep review input on the active native question * test: let tunnel revocation daemon choose an available port * test: allocate available ports for pairing and watchdog fixtures * fix: stabilize planning eval navigation and phase reporting * test: isolate installed runtime paths in planning evals * test: stabilize review evidence and concurrent refresh fixtures * fix: resolve design findings before editing the plan * fix: honor and persist disabled outside plan reviews * fix: preserve planning decisions and terminal evidence Load installed host reviews at autoplan phase entry and wait for completed reviewers and saved artifacts. Reuse approved remedies while preserving individual finding decisions. Drive interactive evals from the current terminal viewport, bind native questions across scrolling, and require complete native report evidence. Cover captured stale menus, permission lifecycles, setup classification, and disabled-review tool availability with deterministic regressions. Advance release metadata and the upgrade migration to the unclaimed 1.83.0.0 slot. * fix: drive native review questions and preserve current plans Use the native single-choice keyboard protocol and current terminal viewport, with per-question navigation inside packets and completed-call coverage. Keep permissions, multi-select menus, and Submit controls distinct. Send Autoplan reviewers the amended implementation plan, keep its review record separate, and supply retained application contracts in the chain fixture. Clarify individual DevEx decisions and complete CEO fix options; use one active plan destination for the section-loading report. * fix: preserve complete plan-review decisions * fix: recognize native plan dialogs and reviewer controls * fix: preserve review decisions and phase completion * fix: recognize completed reviews without losing findings * fix: preserve review continuity and native eval completion * test: fix native review completion and eval retry isolation * test: handle native review menus and complete eval fixtures * test: fix native review setup, completion, and isolation failures * test: limit native skill discovery to runtime assets * fix: bind Autoplan reviews to full ordered phase inputs * test: fix planning eval routing, counting, and timeout handling * chore: advance queued release to v1.84.0.0 * fix: preserve complete review inputs and planning decisions * fix: reconcile review approvals and preserve phase obligations * fix: preserve review obligations and unblock eval permissions Carry recorded Autoplan requirements into blind phase inputs, require Eng review approvals before exit, and exercise combined asynchronous flows in CEO reviews. Correct native finding and handoff classification and unblock repeated report edits using scoped request identities. * fix: retain plan requirements and complete native review dialogs * fix: complete native review prompts and retain plan references * fix: preserve review inputs and classify native eval evidence * fix: check competing completion orders in CEO reviews * fix: recognize review decisions and require phase methodology Require the current phase methodology before Autoplan snapshots. Correct substantive decision, closed handoff, and cache-finding classification, and honor the recommended implementation approach in native review dialogs. Add captured-transcript regressions without changing review thresholds, provider models, retries, or deadlines. * test: bind native review decisions and close completed handoffs * fix: complete review dialogs and verify methodology delivery * fix: preserve review evidence and unblock native eval prompts * fix: handle native review question completions * fix: recognize native review narration and controls * fix: count native review decisions and isolate eval fixtures * test: verify seeded review coverage and current artifact permissions * test: isolate model and brain-aware skill renders * fix: repair native workflow evaluation and clarify review steps * fix: stabilize workflow eval evidence and review guidance * test: repair native workflow observation and fixture isolation * fix: recognize completed workflow evidence and owned skill reads * test: repair seeded workflow delivery and completion evidence * test: recognize current review evidence across native forms * test: handle native review variants and permission redraws * fix: honor review preferences and recognize native eval evidence * test: recognize completed review decisions and queued permissions * test: match current review contracts and partial-line edits * test: recognize completed workflow evidence and bounded human waits * fix: preserve review entry gates and native eval interactions * fix: recognize native workflow evidence and preserve review gates * test: recognize current review evidence and preconfigure workflow fixtures * test: recognize completed review findings and scoped artifact permissions * fix: stabilize native workflow review and permission evidence * fix: recognize current review evidence and scoped edit confirmations Clarify Design and engineering review entry instructions and Design scoring. Recognize required legacy coverage and public Autoplan completion recaps. Bind the pending Edit confirmation to its exact file, ordered digest, and one-request approval when a preceding command display remains visible. Keep reviews within their existing size limits and preserve scope gates when extracting workflow fixtures from either supported preamble header. Keep failure outcomes, review thresholds, provider choices, and eval budgets. * fix: recover review workflow progress and eval evidence * fix: recognize valid review evidence and scope selection * test: fix review evidence parsing and repeated artifact prompts * test: recognize valid review decisions and pending native cards * fix(plan-eng-review): keep final navigation consistent with approved tasks * test: recognize valid review evidence and bind legacy diff requests * fix: stabilize review eval evidence and harness repair guidance * docs: update project documentation for v1.85.0.0 Co-Authored-By: OpenAI Codex <noreply@openai.com> * test: fix Windows CI fixtures and credential scan Rebase captured JSON values and filesystem evidence using the appropriate path convention. Compile native fake CLIs on Windows and synchronize pipe holder readiness, with cleanup retained when assertions fail. Assemble synthetic credential fixtures at runtime so the added-line scan keeps enforcing the same gate without flagging its own rejection controls. Discover generated skills directly for the empty-find regression check, avoiding a recursive scan through saved evaluation artifacts and dependencies. * fix: preserve source renders on Windows Compare canonical generator paths using native separators so an output sidecar pointing at the source cannot overwrite its skill or metadata. Keep the regression fixture isolated from the real checkout and expose freshness diagnostics before asserting subprocess status. Detach Windows drain-test pipe holders from the fake provider's automatic child cleanup while preserving the enclosing runner job and its assertions. * fix: clarify outside review fallback and CEO decisions Render one applicable own-harness fallback path and retain native review, disabled policy, and missing-coverage semantics. Align report field names and mode labels, and make the existing per-cut scope approval explicit. Regenerate skill outputs and keep the workflow judge's model, thresholds, and retry policy unchanged. * chore: move release to free version slot (v1.86.0.0) PR #2852 now claims v1.85.0.0. Align the release metadata and rename migration so upgrades from that version still receive it. Co-Authored-By: OpenAI Codex <noreply@openai.com> * fix: include engineering review prerequisites and restore branch context * fix: recognize coverage diagrams and clarify design review instructions * fix: preserve file identities and join Windows test processes --------- Co-authored-by: OpenAI Codex <noreply@openai.com>
214 lines
10 KiB
TypeScript
214 lines
10 KiB
TypeScript
/**
|
|
* /office-hours Phase 4 alternatives gate regression (periodic, paid, SDK-based).
|
|
*
|
|
* Reproduces the bug seen in production: agent in builder mode reaches Phase 4,
|
|
* presents 3 architectural alternatives (A/B/C), writes "Recommendation: C" in
|
|
* chat prose, and starts editing the design doc immediately — never calls
|
|
* AskUserQuestion. The fix is the STOP gate added to office-hours/SKILL.md.tmpl
|
|
* Phase 4 footer.
|
|
*
|
|
* Test approach: SDK + captureInstruction (same proven pattern as
|
|
* skill-e2e-plan-format.test.ts). Pre-seed builder mode + "skip Phase 1/2/3,
|
|
* I have already accepted all premises" so the agent reaches Phase 4 directly.
|
|
* captureInstruction tells the agent to dump the verbatim Phase 4 AskUserQuestion
|
|
* to a file. We then assert on the captured text (regex + Haiku judge) rather
|
|
* than on tool-call observability — the captured file IS the Phase 4 question.
|
|
*
|
|
* Why periodic (not gate): Phase 4 requires the agent to invent 2-3 distinct
|
|
* architectures, which is more open-ended than the 4 plan-format cases. Closer
|
|
* to a quality benchmark than a deterministic format check. Reclassify if the
|
|
* test turns out stable.
|
|
*/
|
|
import { expect, beforeAll, afterAll } from 'bun:test';
|
|
import { CAPTURE_MS, CAPTURE_LONG_MS } from './helpers/eval-budgets';
|
|
import { runSkillTest } from './helpers/session-runner';
|
|
import type { EvalTestEntry } from './helpers/eval-store';
|
|
import {
|
|
ROOT, runId,
|
|
describeIfSelected, testConcurrentIfSelected,
|
|
logCost, recordE2E, assertRecommendationQuality,
|
|
createEvalCollector, finalizeEvalCollector,
|
|
} from './helpers/e2e-helpers';
|
|
import { spawnSync } from 'child_process';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import * as os from 'os';
|
|
|
|
const evalCollector = createEvalCollector('e2e-office-hours-phase4');
|
|
|
|
// Format predicates. The strict `Recommendation:[*\s]*Choose` regex used by
|
|
// skill-e2e-plan-format pins down a specific template-example wording ("Choose
|
|
// [X]"). The format spec at scripts/resolvers/preamble/generate-ask-user-format.ts
|
|
// only requires `Recommendation: <choice> because <reason>` — `<choice>` can
|
|
// be the bare option label. judgeRecommendation.present (deterministic) checks
|
|
// this canonical shape correctly; we don't need a redundant strict regex here.
|
|
const BECAUSE_RE = /\bbecause\b/i;
|
|
// At least 2 numbered/lettered options (A/B or 1/2). Office-hours Phase 4 says
|
|
// "2-3 distinct alternatives," so 2+ is the minimum bar.
|
|
function hasTwoAlternatives(text: string): boolean {
|
|
const options: Array<{ indent: number; label: string }> = [];
|
|
let fence: { char: string; length: number } | undefined;
|
|
for (const line of text.split('\n')) {
|
|
const marker = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(line);
|
|
if (fence) {
|
|
if (marker && marker[1]![0] === fence.char && marker[1]!.length >= fence.length && !marker[2]!.trim()) fence = undefined;
|
|
continue;
|
|
}
|
|
if (marker) { fence = { char: marker[1]![0]!, length: marker[1]!.length }; continue; }
|
|
const option = /^( {0,3})([A-Z]|[1-9]\d*)\)\s+\S/.exec(line);
|
|
if (option) options.push({ indent: option[1]!.length, label: option[2]! });
|
|
}
|
|
// Only the outer option list counts; numbered steps inside one option and
|
|
// Markdown source/quoted blocks do not supply another alternative.
|
|
const outerIndent = Math.min(...options.map(option => option.indent));
|
|
const labels = options.filter(option => option.indent === outerIndent).map(option => option.label);
|
|
return new Set(labels.filter(label => /^[A-Z]$/.test(label))).size >= 2 ||
|
|
new Set(labels.filter(label => /^\d+$/.test(label))).size >= 2;
|
|
}
|
|
// Phase-4-specific: at least one of these tokens should appear in the captured
|
|
// question. Without this, a captured AskUserQuestion from an earlier phase
|
|
// would false-pass.
|
|
const PHASE4_VOCAB_RE = /approach|alternative|architectur(?:e|al)|implementation/i;
|
|
|
|
function setupOfficeHoursDir(): string {
|
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-office-hours-phase4-'));
|
|
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']);
|
|
|
|
// Seed a tiny project context so the skill has something to reason about.
|
|
fs.writeFileSync(path.join(dir, 'README.md'), `# gbrain-retrieval
|
|
|
|
We're building a retrieval surface for gbrain so cross-skill memory works
|
|
end-to-end. There are three architectural shapes worth considering: server-side
|
|
(gbrain ships the smarts), client-side (gstack ships the smarts), and a hybrid
|
|
that ships V1 client-side and promotes to gbrain in V1.5.
|
|
`);
|
|
run('git', ['add', '.']);
|
|
run('git', ['commit', '-m', 'seed']);
|
|
|
|
// Extract only the AskUserQuestion Format spec + Phase 4 section from
|
|
// office-hours/SKILL.md per CLAUDE.md "extract, don't copy" rule. Copying
|
|
// the full ~2000-line SKILL.md burns Opus tokens on irrelevant phases and
|
|
// risks turn-limit timeouts. The format spec teaches the agent the
|
|
// Recommendation/because/options shape; Phase 4 is what we're testing.
|
|
fs.mkdirSync(path.join(dir, 'office-hours'), { recursive: true });
|
|
const fullSkill = fs.readFileSync(path.join(ROOT, 'office-hours', 'SKILL.md'), 'utf-8');
|
|
const fmtStart = fullSkill.indexOf('## AskUserQuestion Format');
|
|
const fmtEnd = fullSkill.indexOf('\n## ', fmtStart + 1);
|
|
const phase4Start = fullSkill.indexOf('## Phase 4: Alternatives Generation');
|
|
const phase4End = fullSkill.indexOf('\n## Phase 4.5', phase4Start);
|
|
if (fmtStart < 0 || phase4Start < 0 || phase4End < 0) {
|
|
throw new Error('skill-e2e-office-hours-phase4: failed to slice SKILL.md — section markers not found.');
|
|
}
|
|
const slice = [
|
|
'# office-hours (Phase 4 slice for E2E test)\n',
|
|
fullSkill.slice(fmtStart, fmtEnd > fmtStart ? fmtEnd : fmtStart + 4000),
|
|
'\n',
|
|
fullSkill.slice(phase4Start, phase4End),
|
|
].join('\n');
|
|
fs.writeFileSync(path.join(dir, 'office-hours', 'SKILL.md'), slice);
|
|
|
|
return dir;
|
|
}
|
|
|
|
function captureInstruction(outFile: string): string {
|
|
return `Write the verbatim text of the Phase 4 (Alternatives Generation) AskUserQuestion you would have made to ${outFile} (full text including all option labels, recommendation line with because-clause, and net-line). Do NOT call any tool to ask the user. Do NOT paraphrase — include the exact prose you would have shown. This is a format-capture test, not an interactive session.`;
|
|
}
|
|
|
|
describeIfSelected('Office Hours Phase 4 — Architectural fork must surface AskUserQuestion', ['office-hours-phase4-fork'], () => {
|
|
let workDir: string;
|
|
let outFile: string;
|
|
|
|
beforeAll(() => {
|
|
workDir = setupOfficeHoursDir();
|
|
outFile = path.join(workDir, 'phase4-capture.md');
|
|
});
|
|
|
|
afterAll(() => {
|
|
// workDir is only set if beforeAll ran (i.e. describe wasn't skipped).
|
|
// The previous empty-catch pattern silently swallowed `fs.rmSync(undefined)`
|
|
// when the test was skipped, hiding the latent bug.
|
|
if (!workDir) return;
|
|
try { fs.rmSync(workDir, { recursive: true, force: true }); } catch {}
|
|
});
|
|
|
|
testConcurrentIfSelected('office-hours-phase4-fork', async () => {
|
|
const result = await runSkillTest({
|
|
prompt: `Read office-hours/SKILL.md for the workflow.
|
|
|
|
Context: this is BUILDER MODE (Path B). The project is gbrain-retrieval — see README.md. I have a fully-formed plan and have already accepted all your Phase 3 premises. Skip Phase 1, Phase 2, and Phase 3 entirely.
|
|
|
|
Proceed directly to Phase 4 (Alternatives Generation). Generate 2-3 distinct architectural approaches that differ in KIND (not in coverage). Realistic shapes for this project:
|
|
A) Server-side: gbrain ships the retrieval smarts as new MCP tools (e.g. get_recent_salience, find_anomalies).
|
|
B) Client-side: gstack ships a helper (bin/gstack-brain-context-load) that composes salience client-side from existing MCP tools.
|
|
C) Hybrid: V1 client-side in gstack; V1.5 promotes to gbrain server-side once the salience signal is validated.
|
|
|
|
Do not skip Phase 4 — the test depends on you reaching it.
|
|
|
|
${captureInstruction(outFile)}
|
|
|
|
After writing the file with that ONE Phase 4 question, stop. Do not continue to Phase 4.5 or Phase 5.`,
|
|
workingDirectory: workDir,
|
|
maxTurns: 12,
|
|
timeout: CAPTURE_MS,
|
|
testName: 'office-hours-phase4-fork',
|
|
runId,
|
|
model: 'claude-opus-4-7',
|
|
});
|
|
|
|
logCost('/office-hours Phase 4 fork', result);
|
|
let passed = false;
|
|
let failure: string | undefined;
|
|
let judgedEntry: EvalTestEntry | undefined;
|
|
// The quality helper records before asserting. Defer that entry so its
|
|
// final verdict includes both structural and recommendation assertions.
|
|
const deferredCollector = evalCollector && Object.assign(Object.create(evalCollector), {
|
|
addTest(entry: EvalTestEntry) { judgedEntry = entry; },
|
|
});
|
|
try {
|
|
expect(['success', 'error_max_turns']).toContain(result.exitReason);
|
|
|
|
expect(fs.existsSync(outFile)).toBe(true);
|
|
const captured = fs.readFileSync(outFile, 'utf-8');
|
|
expect(captured.length).toBeGreaterThan(100);
|
|
|
|
// Format-spec compliance. judgeRecommendation below covers the
|
|
// Recommendation: line itself; these regexes catch cheap structural shape.
|
|
expect(captured).toMatch(BECAUSE_RE);
|
|
expect(hasTwoAlternatives(captured)).toBe(true);
|
|
// Phase-4 specificity: prevents a stray earlier-phase AUQ from false-passing.
|
|
expect(captured).toMatch(PHASE4_VOCAB_RE);
|
|
|
|
// Recommendation-quality judge: same threshold as plan-format tests.
|
|
await assertRecommendationQuality({
|
|
captured,
|
|
evalCollector: deferredCollector,
|
|
evalId: '/office-hours-phase4-fork',
|
|
evalTitle: 'Office Hours Phase 4 — Architectural fork must surface AskUserQuestion',
|
|
result,
|
|
passed: ['success', 'error_max_turns'].includes(result.exitReason),
|
|
});
|
|
passed = true;
|
|
} catch (error) {
|
|
failure = error instanceof Error ? error.message : String(error);
|
|
throw error;
|
|
} finally {
|
|
if (judgedEntry) {
|
|
evalCollector?.addTest({ ...judgedEntry, passed, ...(failure ? { error: failure } : {}) });
|
|
} else {
|
|
recordE2E(evalCollector, '/office-hours-phase4-fork',
|
|
'Office Hours Phase 4 — Architectural fork must surface AskUserQuestion', result,
|
|
{ passed: false, error: failure ?? 'Recommendation assessment did not complete' });
|
|
}
|
|
}
|
|
}, CAPTURE_LONG_MS);
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await finalizeEvalCollector(evalCollector);
|
|
});
|