Files
gstack/test/workflow-judge-input.test.ts
T
Garry TanandOpenAI Codex 9f81911136 v1.86.0.0 feat: route outside reviews by harness (#2850)
* 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>
2026-09-14 14:32:45 -07:00

251 lines
14 KiB
TypeScript

/** Free regression coverage for the file bundle sent to workflow judges. */
import { afterEach, describe, expect, test } from 'bun:test';
import { mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { dirname, join, resolve } from 'node:path';
import { readWorkflowJudgeInput } from './helpers/workflow-judge-input';
const ROOT = resolve(import.meta.dir, '..');
const scratchRoots: string[] = [];
afterEach(() => {
for (const root of scratchRoots.splice(0)) rmSync(root, { recursive: true, force: true });
});
function fixture(files: Record<string, string>): string {
const root = mkdtempSync(join(tmpdir(), 'gstack-workflow-judge-'));
scratchRoots.push(root);
for (const [path, content] of Object.entries(files)) {
mkdirSync(dirname(join(root, path)), { recursive: true });
writeFileSync(join(root, path), content);
}
return root;
}
function occurrences(text: string, needle: string): number {
return text.split(needle).length - 1;
}
function sectionPaths(skill: string): string[] {
return readdirSync(join(ROOT, skill, 'sections'))
.filter(name => name.endsWith('.md'))
.sort()
.map(name => `${skill}/sections/${name}`);
}
describe('workflow judge file bundle', () => {
test('preserves the exact entrypoint excerpt and each complete section in sorted named files', () => {
const entrypoint = 'excluded preamble\n## Begin\nRead sections/z-last.md when directed.\n## End\nexcluded epilogue';
const sections = {
'example/sections/z-last.md': 'Z section prefix\nZ section suffix',
'example/sections/a-first.md': 'A section prefix\nA section suffix',
};
const root = fixture({
'example/SKILL.md': entrypoint,
...sections,
'example/sections/ignored.md.tmpl': 'DO NOT EVALUATE TEMPLATE',
'example/sections/manifest.json': '{"ignored": true}',
});
const input = readWorkflowJudgeInput({ root, skillPath: 'example/SKILL.md', startMarker: '## Begin', endMarker: '## End' });
expect(input.files).toEqual([
{ path: 'example/SKILL.md', kind: 'entrypoint', content: '## Begin\nRead sections/z-last.md when directed.\n', startLine: 2, endLine: 3 },
{ path: 'example/sections/a-first.md', kind: 'section', content: sections['example/sections/a-first.md'], startLine: 1, endLine: 2 },
{ path: 'example/sections/z-last.md', kind: 'section', content: sections['example/sections/z-last.md'], startLine: 1, endLine: 2 },
]);
expect(input.text).not.toContain('excluded preamble');
expect(input.text).not.toContain('excluded epilogue');
expect(input.text).not.toContain('DO NOT EVALUATE TEMPLATE');
expect(input.text).not.toContain('manifest.json');
for (const file of input.files) {
expect(occurrences(input.text, file.content)).toBe(1);
const begin = input.text.split('\n').filter(line => line.includes('BEGIN FILE') && line.includes(file.path));
const end = input.text.split('\n').filter(line => line.includes('END FILE') && line.includes(file.path));
expect(begin).toHaveLength(1);
expect(end).toHaveLength(1);
expect(begin[0]).toContain(`${file.startLine}-${file.endLine}`);
}
});
test('describes lazy file loading without presenting bundle order as execution order', () => {
const root = fixture({
'example/SKILL.md': '## Begin\nSTOP and read sections/step.md.\n## End',
'example/sections/step.md': 'Run the separately loaded step.',
});
const { text } = readWorkflowJudgeInput({ root, skillPath: 'example/SKILL.md', startMarker: '## Begin', endMarker: '## End' });
const header = text.slice(0, text.indexOf('BEGIN FILE'));
expect(header).toMatch(/bundle/i);
expect(header).toMatch(/file/i);
expect(header).toMatch(/separate|separately/i);
expect(header).toMatch(/lazy|on-demand/i);
expect(header).toMatch(/directives|instructions/i);
expect(header).toMatch(/(?:not|isn't|does not)[^.\n]*execution order/i);
expect(text).toContain('STOP and read sections/step.md.');
});
test('retains section prelude and suffix exactly once when both markers are inside a section', () => {
// Generated comments made the old 120-character prefix heuristic append
// this whole file after its partial slice, duplicating every review pass.
const section = [
'<!-- AUTO-GENERATED from review-sections.md.tmpl — do not edit directly -->',
'<!-- Regenerate: bun run gen:skill-docs -->',
'section context before the selected marker',
'## Review Sections',
'### Pass 1: Information Architecture',
'Evaluate the first pass.',
'## CRITICAL RULE',
'section context after the selected marker',
].join('\n');
const root = fixture({
'example/SKILL.md': 'Entrypoint preamble.\nSTOP and read sections/review-sections.md.',
'example/sections/review-sections.md': section,
});
const input = readWorkflowJudgeInput({ root, skillPath: 'example/SKILL.md', startMarker: '## Review Sections', endMarker: '## CRITICAL RULE' });
expect(input.files).toEqual([
{ path: 'example/sections/review-sections.md', kind: 'section', content: section, startLine: 1, endLine: 8 },
]);
expect(occurrences(input.text, '### Pass 1: Information Architecture')).toBe(1);
expect(occurrences(input.text, 'section context before the selected marker')).toBe(1);
expect(occurrences(input.text, 'section context after the selected marker')).toBe(1);
expect(occurrences(input.text, section)).toBe(1);
expect(input.text).not.toContain('Entrypoint preamble.');
});
test('handles marker windows spanning files without losing section prefixes or suffixes', () => {
const root = fixture({
'example/SKILL.md': 'omitted\n## Begin\nEntrypoint tail',
'example/sections/a.md': 'First section prefix\nFirst section body\nFirst section suffix',
'example/sections/b.md': 'Second section prefix\n## End\nSecond section suffix',
});
const input = readWorkflowJudgeInput({ root, skillPath: 'example/SKILL.md', startMarker: '## Begin', endMarker: '## End' });
expect(input.files[0]).toEqual({
path: 'example/SKILL.md', kind: 'entrypoint', content: '## Begin\nEntrypoint tail', startLine: 2, endLine: 3,
});
expect(input.files.slice(1).map(file => file.content)).toEqual([
'First section prefix\nFirst section body\nFirst section suffix',
'Second section prefix\n## End\nSecond section suffix',
]);
expect(occurrences(input.text, 'Second section prefix')).toBe(1);
expect(occurrences(input.text, 'Second section suffix')).toBe(1);
});
test('keeps separate files even when their generated preludes and contents match', () => {
const body = '<!-- AUTO-GENERATED -->\nShared instruction';
const root = fixture({
'example/SKILL.md': '## Begin\nRead both sections.\n## End',
'example/sections/a.md': body,
'example/sections/b.md': body,
});
const input = readWorkflowJudgeInput({ root, skillPath: 'example/SKILL.md', startMarker: '## Begin', endMarker: '## End' });
expect(input.files.filter(file => file.kind === 'section').map(file => file.path)).toEqual([
'example/sections/a.md', 'example/sections/b.md',
]);
expect(occurrences(input.text, body)).toBe(2);
});
test('supports an uncarved workflow and an open-ended slice', () => {
const root = fixture({ 'example/SKILL.md': 'omitted\n## Begin\nRetain this final line' });
const input = readWorkflowJudgeInput({ root, skillPath: 'example/SKILL.md', startMarker: '## Begin', endMarker: null });
expect(input.files).toEqual([
{ path: 'example/SKILL.md', kind: 'entrypoint', content: '## Begin\nRetain this final line', startLine: 2, endLine: 3 },
]);
});
test('rejects missing start markers, missing end markers, and end markers preceding the start', () => {
const root = fixture({ 'example/SKILL.md': '## Earlier\n## Begin\nBody' });
expect(() => readWorkflowJudgeInput({ root, skillPath: 'example/SKILL.md', startMarker: '## Missing', endMarker: null })).toThrow(/Start marker not found/);
expect(() => readWorkflowJudgeInput({ root, skillPath: 'example/SKILL.md', startMarker: '## Begin', endMarker: '## Missing' })).toThrow(/End marker not found/);
expect(() => readWorkflowJudgeInput({ root, skillPath: 'example/SKILL.md', startMarker: '## Begin', endMarker: '## Earlier' })).toThrow(/End marker not found/);
});
test('generated ship includes base-branch initialization and every lazy section once', () => {
const skillPath = 'ship/SKILL.md';
const source = readFileSync(join(ROOT, skillPath), 'utf8');
// Read the paid caller's actual slice so changing its marker back to the
// title cannot silently drop initialization while this helper test passes.
const caller = readFileSync(join(ROOT, 'test/skill-llm-eval.test.ts'), 'utf8');
const markers = caller.match(/skillPath: 'ship\/SKILL\.md',\s+startMarker: '([^']+)',\s+endMarker: '([^']+)'/);
expect(markers).not.toBeNull();
const [, startMarker, endMarker] = markers!;
expect(startMarker).toBe('## Step 0: Detect platform and base branch');
const input = readWorkflowJudgeInput({ root: ROOT, skillPath, startMarker, endMarker });
const entrypoint = input.files.find(file => file.kind === 'entrypoint');
expect(entrypoint?.content).toBe(source.slice(source.indexOf(startMarker), source.indexOf(endMarker, source.indexOf(startMarker))));
expect(entrypoint?.content).toContain('git remote get-url origin');
expect(entrypoint?.content).toContain('gh pr view --json baseRefName');
expect(entrypoint?.content).toContain('Print the detected base branch name.');
expect(occurrences(input.text, startMarker)).toBe(1);
const sections = input.files.filter(file => file.kind === 'section');
expect(sections.map(file => file.path)).toEqual(sectionPaths('ship'));
for (const file of sections) {
const source = readFileSync(join(ROOT, file.path), 'utf8');
expect(file.content).toBe(source);
expect(occurrences(input.text, source)).toBe(1);
expect(file.startLine).toBe(1);
}
});
test('generated engineering review includes the scope choices and readiness probe its steps reference', () => {
const skillPath = 'plan-eng-review/SKILL.md';
const caller = readFileSync(join(ROOT, 'test/skill-llm-eval.test.ts'), 'utf8');
const markers = caller.match(/skillPath: 'plan-eng-review\/SKILL\.md',\s+startMarker: '([^']+)',\s+endMarker: '([^']+)'/);
expect(markers).not.toBeNull();
const [, startMarker, endMarker] = markers!;
const input = readWorkflowJudgeInput({ root: ROOT, skillPath, startMarker, endMarker });
const entrypoint = input.files.find(file => file.kind === 'entrypoint')!;
expect(entrypoint.content).toContain('B) A plan or design doc');
expect(entrypoint.content).toContain('## Scope gate');
expect(entrypoint.content.indexOf('## Scope gate')).toBeLessThan(entrypoint.content.indexOf('### Step 0: Scope Challenge'));
expect(entrypoint.content).toContain('## Web research runs in Aside');
expect(entrypoint.content).toContain('echo "READY: aside');
expect(entrypoint.content.indexOf('echo "READY: aside')).toBeLessThan(entrypoint.content.indexOf('4. **Search check:**'));
expect(occurrences(input.text, '## Scope gate')).toBe(1);
expect(occurrences(input.text, '### 1. Architecture review')).toBe(1);
const sections = input.files.filter(file => file.kind === 'section');
expect(sections.map(file => file.path)).toEqual(sectionPaths('plan-eng-review'));
for (const file of sections) {
const source = readFileSync(join(ROOT, file.path), 'utf8');
expect(file.content).toBe(source);
expect(occurrences(input.text, source)).toBe(1);
}
});
test('generated design consultation includes the prechecks its proposal and preview reference', () => {
const skillPath = 'design-consultation/SKILL.md';
const caller = readFileSync(join(ROOT, 'test/skill-llm-eval.test.ts'), 'utf8');
const markers = caller.match(/skillPath: 'design-consultation\/SKILL\.md',\s+startMarker: '([^']+)',\s+endMarker: '([^']+)'/);
expect(markers).not.toBeNull();
const [, startMarker, endMarker] = markers!;
const input = readWorkflowJudgeInput({ root: ROOT, skillPath, startMarker, endMarker });
const entrypoint = input.files.find(file => file.kind === 'entrypoint')!;
for (const prerequisite of ['## Phase 0: Pre-checks', 'DESIGN_MD_FORMAT:', 'DESIGN_READY', 'DESIGN_NOT_AVAILABLE']) {
expect(entrypoint.content).toContain(prerequisite);
}
expect(entrypoint.content.indexOf('## Phase 0:')).toBeLessThan(entrypoint.content.indexOf('## Phase 1:'));
expect(occurrences(input.text, '## Phase 0: Pre-checks')).toBe(1);
const sections = input.files.filter(file => file.kind === 'section');
expect(sections.map(file => file.path)).toEqual(sectionPaths('design-consultation'));
for (const file of sections) {
const source = readFileSync(join(ROOT, file.path), 'utf8');
expect(file.content).toBe(source);
expect(occurrences(input.text, source)).toBe(1);
}
});
test('generated plan-design passes retain their full section without duplicating Pass 1', () => {
const input = readWorkflowJudgeInput({
root: ROOT, skillPath: 'plan-design-review/SKILL.md', startMarker: '## Review Sections', endMarker: '## CRITICAL RULE',
});
expect(input.files.filter(file => file.kind === 'entrypoint')).toHaveLength(0);
expect(input.files.map(file => file.path)).toEqual(sectionPaths('plan-design-review'));
const section = input.files.find(file => file.path === 'plan-design-review/sections/review-sections.md');
expect(section?.content).toBe(readFileSync(join(ROOT, 'plan-design-review/sections/review-sections.md'), 'utf8'));
expect(section?.content).toStartWith('<!-- AUTO-GENERATED');
expect(section?.content).toContain('## CRITICAL RULE');
expect(section?.content).toContain('## Formatting Rules');
expect(occurrences(input.text, '### Pass 1: Information Architecture')).toBe(1);
});
});