mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-16 18:05:31 +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
13 KiB
TypeScript
214 lines
13 KiB
TypeScript
import { describe, expect, test } from 'bun:test';
|
|
import { readWorkflowExcerpt } from './helpers/workflow-excerpt';
|
|
import { LLM_JUDGE_TOUCHFILES, selectTests } from './helpers/touchfiles';
|
|
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'fs';
|
|
import { tmpdir } from 'os';
|
|
import { join } from 'path';
|
|
import { spawnSync } from 'child_process';
|
|
|
|
function expectOutsideReviewControlFlow(text: string, promptHeading: string): void {
|
|
const markers = ['**Disabled is a terminal branch', promptHeading, '**If `CODEX_MODE: ready`', '**Native fallback'];
|
|
const indices = markers.map(marker => text.indexOf(marker));
|
|
expect(indices.every(index => index >= 0)).toBe(true);
|
|
expect(indices).toEqual([...indices].sort((a, b) => a - b));
|
|
const disabled = text.slice(indices[0], indices[1]);
|
|
expect(disabled).toContain('persist `outside_status: disabled`');
|
|
expect(disabled.replace(/\s+/g, ' ')).toMatch(/Do not construct a (?:review prompt|challenge), invoke an outside CLI, dispatch an Agent\/Task fallback/);
|
|
expect(text.slice(indices[1], indices[2])).toContain('(skip only on `disabled`)');
|
|
|
|
const fallback = text.slice(indices[3]);
|
|
expect(fallback).toContain('The disabled branch never reaches this fallback.');
|
|
expect(fallback.replace(/\s+/g, ' ')).toContain('Otherwise, use this fallback for missing/broken CLI, failed authentication/model selection, a failed preflight, or a failed outside invocation.');
|
|
const dispatch = fallback.indexOf('Dispatch via the Agent tool');
|
|
expect(dispatch).toBeGreaterThan(0);
|
|
const recheck = fallback.slice(0, dispatch);
|
|
expect(recheck).toContain('Immediately before dispatching, check the preflight result again.');
|
|
expect(recheck).toContain('`CODEX_MODE: disabled`, finish this section with `outside_status: disabled`;');
|
|
expect(recheck).toContain('do not dispatch.');
|
|
expect(fallback).toContain('CLI availability or a native fallback does not count as outside completion.');
|
|
}
|
|
|
|
describe('workflow judge excerpts', () => {
|
|
test('helper changes select all dependent workflow judges', () => {
|
|
const selected = selectTests(['test/helpers/workflow-excerpt.ts'], LLM_JUDGE_TOUCHFILES, []).selected;
|
|
expect(selected).toHaveLength(14);
|
|
expect(selected).toContain('ship/SKILL.md workflow');
|
|
expect(selected).toContain('plan-design-review/SKILL.md passes');
|
|
});
|
|
|
|
test('expands ship sections in execution order, not alphabetical order', () => {
|
|
const text = readWorkflowExcerpt('ship/SKILL.md', '# Ship:', '## Important Rules');
|
|
const headings = ['## Step 3:', '## Step 4:', '## Step 7:', '## Step 8:', '## Step 9:', '## Step 10:', '## Step 11:', '## Step 12:', '## Step 13:', '## Step 14:'];
|
|
const indices = headings.map(heading => text.indexOf(heading));
|
|
expect(indices.every(index => index >= 0)).toBe(true);
|
|
expect(indices).toEqual([...indices].sort((a, b) => a - b));
|
|
});
|
|
|
|
test('ship uses project-native commands and never jumps over mandatory gates', () => {
|
|
const text = readWorkflowExcerpt('ship/SKILL.md', '# Ship:', '## Important Rules');
|
|
expect(text).toContain("Use the project's test commands discovered in Step 4");
|
|
expect(text).toContain("Use the project's documented eval selection");
|
|
expect(text).not.toMatch(/skipping evals[^\n]*Step 9/);
|
|
const reviewAndTriage = text.slice(text.indexOf('## Step 9:'), text.indexOf('## Step 11:'));
|
|
expect(reviewAndTriage.match(/continue to Step 12/i)).toBeNull();
|
|
expect(text).not.toContain('Steps 4-6:');
|
|
expect(text).toContain('During pre-flight, read the existing review log');
|
|
expect(text).toContain('Save the JSON `baseVersion` as `BASE_VERSION`');
|
|
expect(text).toContain("GIT_SEQUENCE_EDITOR='cp");
|
|
expect(text).not.toContain("--exec 'true'");
|
|
expect(text).not.toContain('-X ours');
|
|
expect(text).toContain('````text\nYou are running a ship-workflow');
|
|
});
|
|
|
|
test('a sliced section is not appended again with its generated header', () => {
|
|
const text = readWorkflowExcerpt('plan-design-review/SKILL.md', '## Review Sections', '## CRITICAL RULE');
|
|
expect(text.match(/## Review Sections/g)).toHaveLength(1);
|
|
expect(text).not.toContain('## CRITICAL RULE');
|
|
expect(text).not.toContain('AUTO-GENERATED');
|
|
});
|
|
|
|
test('ship publishes existing PRs only after shared body composition and scan', () => {
|
|
const text = readWorkflowExcerpt('ship/SKILL.md', '# Ship:', '## Important Rules');
|
|
const publish = text.slice(text.indexOf('## Step 19:'), text.indexOf('## Step 20:'));
|
|
const compose = publish.indexOf('PR_BODY_FILE=$(mktemp)');
|
|
const scan = publish.indexOf('gstack-redact --from-file "$PR_BODY_FILE"');
|
|
const edit = publish.indexOf('gh pr edit --body-file');
|
|
expect(compose).toBeGreaterThan(0);
|
|
expect(scan).toBeGreaterThan(compose);
|
|
expect(edit).toBeGreaterThan(scan);
|
|
expect(publish.indexOf('Print the existing URL')).toBeGreaterThan(edit);
|
|
expect(text).not.toContain('Phase 8e.5');
|
|
expect(text).toContain('never create an empty commit');
|
|
const review = text.slice(text.indexOf('## Step 9:'), text.indexOf('## Step 10:'));
|
|
expect(review.indexOf('## Confidence Calibration')).toBeLessThan(review.indexOf('1. Read'));
|
|
expect(review).toContain('only continue to Step 10 after item 9');
|
|
});
|
|
|
|
test('ship approval gates stay outside the subagent prompts', () => {
|
|
const text = readWorkflowExcerpt('ship/SKILL.md', '# Ship:', '## Important Rules');
|
|
for (const [step, next, gate] of [[7, 8, '**7. Coverage gate:**'], [8, 9, '### Gate Logic']] as const) {
|
|
const section = text.slice(text.indexOf(`## Step ${step}:`), text.indexOf(`## Step ${next}:`));
|
|
const prompt = section.match(/````text\n([\s\S]*?)\n````/)![1];
|
|
expect(prompt).not.toContain(gate);
|
|
expect(prompt).not.toContain('Use AskUserQuestion:');
|
|
expect(prompt).not.toContain('commit as');
|
|
expect(section.indexOf(gate)).toBeGreaterThan(section.indexOf('\n````\n'));
|
|
}
|
|
expect(text).toContain('"partial":N,"not_done":N');
|
|
expect(text).toContain('each Y response\'s evidence and each D response\'s dropped item');
|
|
});
|
|
|
|
test('expands a body before the end marker in the skeleton', () => {
|
|
const text = readWorkflowExcerpt('document-release/SKILL.md', '# Document Release:', '## Important Rules');
|
|
expect(text).toContain('## Step 2:');
|
|
expect(text).toContain('## Step 9:');
|
|
});
|
|
|
|
test('documentation review precedes publication and keeps changelog protection', () => {
|
|
const text = readWorkflowExcerpt('document-release/SKILL.md', '# Document Release:', '## Important Rules');
|
|
expect(text).toContain('DOC_DIFF_BASE=$(git merge-base origin/<base> HEAD 2>/dev/null || git merge-base <base> HEAD) || exit 1');
|
|
const reviewStart = text.indexOf('## Codex Documentation Review');
|
|
const commit = text.indexOf('## Step 9:');
|
|
expect(reviewStart).toBeGreaterThanOrEqual(0);
|
|
expect(commit).toBeGreaterThan(reviewStart);
|
|
const review = text.slice(reviewStart, commit);
|
|
expectOutsideReviewControlFlow(review, '**Construct the doc-review prompt**');
|
|
expect(review).toContain('Skip the apply gate, persist `status: unavailable`, `outside_status: unavailable`, and `source: none`');
|
|
expect(review).toContain('present the findings, then use AskUserQuestion ONCE:');
|
|
expect(review).toContain('On A or per-finding approvals, make the approved edits yourself');
|
|
expect(text).toContain('Step 9 then commits and pushes those edits');
|
|
expect(text).toContain('Entries scoring <2 need attention, not replacement');
|
|
expect(text).not.toContain('Flag and rewrite');
|
|
expect(text).toContain('if VERSION is absent, use the completion date only');
|
|
});
|
|
|
|
test('plan review evidence and design approval rules precede their use', () => {
|
|
const eng = readWorkflowExcerpt('plan-eng-review/SKILL.md', '## Review Sections', '## CRITICAL RULE');
|
|
expect(eng.indexOf('## Confidence Calibration')).toBeLessThan(eng.indexOf('### 1. Architecture review'));
|
|
expect(eng).toContain('quote the motivating plan requirement');
|
|
expectOutsideReviewControlFlow(eng, '**Construct the plan review prompt**');
|
|
expect(eng).toContain('Do NOT auto-incorporate outside voice recommendations into the plan.');
|
|
expect(eng).toContain('MUST NOT apply the change without\nexplicit user approval.');
|
|
const design = readWorkflowExcerpt('plan-design-review/SKILL.md', '## Review Sections', '## CRITICAL RULE');
|
|
expect(design).toContain('wait for approval, then edit the plan and re-rate');
|
|
const pass4 = design.slice(design.indexOf('### Pass 4:'), design.indexOf('### Pass 5:'));
|
|
expect(pass4.indexOf('### Design Hard Rules')).toBeLessThan(pass4.indexOf('FIX TO 10:'));
|
|
expect(pass4).toContain('caps this pass below 8');
|
|
});
|
|
|
|
test('fails closed for missing excerpt markers', () => {
|
|
expect(() => readWorkflowExcerpt('ship/SKILL.md', '# missing', null)).toThrow('Start marker not found');
|
|
expect(() => readWorkflowExcerpt('ship/SKILL.md', '# Ship:', '# missing')).toThrow('End marker not found');
|
|
});
|
|
|
|
test('retro judge includes compare semantics and unambiguous report inputs', () => {
|
|
const text = readWorkflowExcerpt('retro/SKILL.md', '## Instructions', '## Tone');
|
|
expect(text).toContain('## Compare Mode');
|
|
expect(text).toContain('does not require saved history');
|
|
expect(text).toContain('one second before the current start');
|
|
expect(text).toContain('PRs referenced');
|
|
expect(text).toContain('prs_merged: null');
|
|
expect(text).toContain('not newly added test cases');
|
|
expect(text).toContain('`streak_days` is the live **team** streak');
|
|
expect(text).toContain('draft the tweetable summary using the format in Step 14, then save');
|
|
expect(text).toContain('### Shipping Streaks');
|
|
expect(text).toContain('### Shortcut Debt');
|
|
expect(text.indexOf('## Capture Learnings')).toBeGreaterThan(text.indexOf('### Step 14:'));
|
|
expect(text).not.toContain('$(date');
|
|
expect(text.match(/today="<today>"/g)).toHaveLength(2);
|
|
const judge = readFileSync(join(import.meta.dir, 'skill-llm-eval.test.ts'), 'utf8');
|
|
expect(judge).toMatch(/skillPath: 'retro\/SKILL.md',[\s\S]*?endMarker: '## Tone'/);
|
|
});
|
|
|
|
test('deploy gates and navigation timing formulas are executable as documented', () => {
|
|
const land = readFileSync(join(import.meta.dir, '../land-and-deploy/SKILL.md.tmpl'), 'utf8');
|
|
expect(land).not.toContain('Skip Step 3, go to Step 4');
|
|
expect(land).toContain('continue to Step 3.4, then Step 3.5 before merging');
|
|
const benchmark = readFileSync(join(import.meta.dir, '../benchmark/SKILL.md.tmpl'), 'utf8');
|
|
const timings = { startTime: 0, domInteractive: 600, domComplete: 1200, loadEventEnd: 1400 };
|
|
for (const [label, expected] of [['DOM Interactive', 600], ['DOM Complete', 1200], ['Full Load', 1400]] as const) {
|
|
const formula = benchmark.match(new RegExp(`\\*\\*${label}\\*\\*: \x60([^\x60]+)\x60`))![1];
|
|
const actual = new Function(...Object.keys(timings), `return ${formula}`)(...Object.values(timings));
|
|
expect(actual).toBe(expected);
|
|
}
|
|
});
|
|
|
|
test('WIP squash example consumes the prepared todo and preserves file contents', () => {
|
|
const cwd = mkdtempSync(join(tmpdir(), 'ship-wip-example-'));
|
|
const env = {
|
|
...process.env, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1',
|
|
GIT_AUTHOR_NAME: 'Test', GIT_AUTHOR_EMAIL: 'test@example.com',
|
|
GIT_COMMITTER_NAME: 'Test', GIT_COMMITTER_EMAIL: 'test@example.com',
|
|
};
|
|
const git = (...args: string[]) => {
|
|
const result = spawnSync('git', args, { cwd, env, encoding: 'utf8', timeout: 10_000 });
|
|
if (result.status !== 0) throw new Error(result.stderr || String(result.error));
|
|
return result.stdout.trim();
|
|
};
|
|
try {
|
|
git('init', '-b', 'main');
|
|
writeFileSync(join(cwd, 'file'), 'base\n');
|
|
git('add', 'file');
|
|
git('commit', '-m', 'base');
|
|
git('switch', '-c', 'feature');
|
|
for (const message of ['logical change', 'WIP: finish change', 'other logical change']) {
|
|
writeFileSync(join(cwd, 'file'), message + '\n');
|
|
git('commit', '-am', message);
|
|
}
|
|
const commits = git('rev-list', '--reverse', 'main..HEAD').split('\n');
|
|
const todo = join(cwd, '.git', 'prepared-todo');
|
|
writeFileSync(todo, commits.map((sha, i) => `${i === 1 ? 'fixup' : 'pick'} ${sha}`).join('\n') + '\n');
|
|
const source = readFileSync(join(import.meta.dir, '../ship/SKILL.md.tmpl'), 'utf8');
|
|
const snippet = source.match(/```bash\n(export WIP_TODO=[\s\S]*?)\n```/)![1]
|
|
.replace('<absolute path to prepared todo>', todo).replaceAll('origin/<base>', 'main');
|
|
const originalTree = git('rev-parse', 'HEAD^{tree}');
|
|
const result = spawnSync('bash', ['-c', snippet], { cwd, env, encoding: 'utf8', timeout: 10_000 });
|
|
expect(result.status, result.stderr).toBe(0);
|
|
expect(git('rev-list', '--count', 'main..HEAD')).toBe('2');
|
|
expect(git('rev-parse', 'HEAD^{tree}')).toBe(originalTree);
|
|
} finally {
|
|
rmSync(cwd, { recursive: true, force: true });
|
|
}
|
|
});
|
|
});
|