mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-18 06:04:33 +01:00
* WIP plain PR bodies and squash messages Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Fold PR bodies to three plain lines and land every PR as one plainly titled commit Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Expect the plain commit body in the train land tests Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Count the new policy keys in the floor tests and record the ship size change Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Let older, generated and Dependabot PRs pass the body check, and keep comments posting The opening check now follows the same date and branch exemption as the rest of the body check, Dependabot branches are exempt, the exemption only counts for branches in this repository, a merge that cannot read the PR waits instead of refusing, and a broken policy file no longer stops comments. Review-Finding: p1/specialist-batched#1 reader=testing Review-Finding: p1/specialist-batched#2 reader=testing Review-Finding: p1/red-team#1 reader=red-team Review-Finding: p1/red-team#2 reader=red-team Review-Finding: p1/red-team#4 reader=red-team Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Stop re-posted PR bodies from duplicating sections, and let file names through the word check Posting an already-folded body now replaces each section once instead of keeping the old copy beside it, and listed words inside file paths or file names, such as a test file in the Tests section, no longer count as prose. Review-Finding: v2/outside-voice#3 reader=outside-voice Review-Finding: v2/adversarial-native#2 reader=adversarial-native Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Describe the folded three-line PR body in the skills guide and the prose lint help Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
111 lines
5.6 KiB
TypeScript
111 lines
5.6 KiB
TypeScript
import { expect, test } from 'bun:test';
|
|
import * as fs from 'node:fs';
|
|
import * as os from 'node:os';
|
|
import * as path from 'node:path';
|
|
import { CALLBACK_TEST_MS, callbackBudgetMs } from './helpers/docsync-fault-callbacks';
|
|
|
|
test('actual registered documentation callbacks stage the generated report contract and consume their builders', () => {
|
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'docs-report-interface-'));
|
|
const root = path.resolve(import.meta.dir, '..');
|
|
try {
|
|
const script = path.join(dir, 'capture.test.ts');
|
|
fs.writeFileSync(script, `
|
|
import { expect, mock, test } from 'bun:test';
|
|
import * as fs from 'node:fs';
|
|
import * as path from 'node:path';
|
|
const root = ${JSON.stringify(root)};
|
|
const fixtureModule = path.join(root, 'test/helpers/docsync-fixture.ts');
|
|
const observerModule = path.join(root, 'test/helpers/docsync-observer.ts');
|
|
const fixtures = { ...await import(fixtureModule) };
|
|
const observers = { ...await import(observerModule) };
|
|
const callbacks = new Map();
|
|
const stopped = new Error('stopped before model launch');
|
|
let fixture, launched = 0;
|
|
mock.module(fixtureModule, () => ({ ...fixtures,
|
|
fixtureDocs(scenario) { fixture = fixtures.fixtureDocs(scenario); return fixture; },
|
|
preserveDocsEvidence() {},
|
|
}));
|
|
mock.module(observerModule, () => ({ ...observers,
|
|
docsSessionOptions(input) {
|
|
const options = observers.docsSessionOptions(input);
|
|
return { ...options, prompt: options.prompt + '\\nOPTIONS_BUILDER_USED' };
|
|
},
|
|
docsShipPhase(...args) { return observers.docsShipPhase(...args) + '\\nPHASE_BUILDER_USED'; },
|
|
docsBoundedStageInterface(...args) { return observers.docsBoundedStageInterface(...args) + '\\nBOUNDED_BUILDER_USED'; },
|
|
}));
|
|
mock.module(path.join(root, 'test/helpers/e2e-gate.ts'), () => ({
|
|
describeE2ETier: () => (_name, body) => body(),
|
|
}));
|
|
mock.module(path.join(root, 'test/helpers/e2e-helpers.ts'), () => ({
|
|
runId: 'free-docsync-interface',
|
|
describeIfSelected: (_name, _names, body) => body(),
|
|
testConcurrentIfSelected: (name, body) => callbacks.set(name, body),
|
|
createEvalCollector: () => ({}),
|
|
finalizeEvalCollector() {},
|
|
recordE2E() { throw new Error('no model result may be recorded'); },
|
|
logCost() { throw new Error('no model result may be graded'); },
|
|
}));
|
|
mock.module(path.join(root, 'test/helpers/session-runner.ts'), () => ({
|
|
async runSkillTest(options) {
|
|
launched++;
|
|
if (options.testName === 'ship-docsync-failure') {
|
|
expect(options.prompt).toContain('BOUNDED_BUILDER_USED');
|
|
expect(options.prompt).toContain('Execute the actual next phase from ' + path.join(fixture.home, 'phase.md'));
|
|
expect(options.prompt).toContain('deterministic child transport instead of Agent/Task');
|
|
expect(options.prompt).toContain('no user risk exception or risky edit is approved');
|
|
expect(options.allowedTools).toEqual(['Bash', 'Read', 'Write', 'Edit', 'Glob', 'Grep']);
|
|
} else {
|
|
expect(options.prompt).toContain('OPTIONS_BUILDER_USED');
|
|
expect(options.prompt).toContain('Execute the next phase from ' + path.join(fixture.home, 'phase.md'));
|
|
expect(options.prompt).toContain('No real PR, push, store action or later ship phase is authorized.');
|
|
expect(options.prompt).toContain('no risk exception is granted');
|
|
expect(options.allowedTools).toEqual(['Bash', 'Read', 'Grep', 'Glob', 'Write', 'Edit', 'Agent', 'Task']);
|
|
}
|
|
expect(options.workingDirectory).toBe(fixture.repo);
|
|
expect(options.maxTurns).toBe(30);
|
|
expect(options.timeout).toBeGreaterThan(0);
|
|
expect(fs.readFileSync(path.join(fixture.skills, 'document-release/SKILL.md'), 'utf8')).not.toContain('This fixture child returns a deliberately obsolete completion');
|
|
const phase = fs.readFileSync(path.join(fixture.home, 'phase.md'), 'utf8');
|
|
expect(phase).toContain('PHASE_BUILDER_USED');
|
|
if (options.testName === 'ship-docsync-store') {
|
|
expect(phase).toContain('**Documentation preflight:**');
|
|
expect(phase).not.toContain('## Documentation');
|
|
} else {
|
|
const prBody = fs.readFileSync(path.join(fixture.skills, 'ship/sections/pr-body.md'), 'utf8');
|
|
const start = prBody.indexOf('## Documentation');
|
|
const end = prBody.indexOf('## Tests', start);
|
|
expect(start).toBeGreaterThan(0);
|
|
expect(end).toBeGreaterThan(start);
|
|
expect(phase).toContain(prBody.slice(start, end));
|
|
expect(phase).toContain('documentation_section');
|
|
expect(phase).not.toContain('## Step 15: Commit');
|
|
expect(phase).not.toContain('#### Redaction scan');
|
|
}
|
|
throw stopped;
|
|
},
|
|
}));
|
|
await import(path.join(root, 'test/skill-e2e-ship-docsync.test.ts'));
|
|
expect(callbacks.size).toBe(12);
|
|
for (const name of ['ship-docsync-completion', 'ship-docsync-current', 'ship-docsync-failure', 'ship-docsync-store']) {
|
|
test(name + ' constructs its real native request without launching it', async () => {
|
|
const before = launched;
|
|
await expect(callbacks.get(name)()).rejects.toBe(stopped);
|
|
expect(launched).toBe(before + 1);
|
|
expect(fs.existsSync(fixture.home)).toBe(false);
|
|
}, ${CALLBACK_TEST_MS});
|
|
}
|
|
`);
|
|
const result = Bun.spawnSync([process.execPath, 'test', script], {
|
|
env: { ...process.env, EVALS: '', EVALS_TIER: '', EVALS_ALL: '', EVALS_RUN_ID: 'free-docsync-interface',
|
|
GSTACK_EVAL_DIR: path.join(dir, 'evidence'), GSTACK_HOME: path.join(dir, 'state') },
|
|
stdout: 'pipe', stderr: 'pipe', timeout: callbackBudgetMs(4),
|
|
});
|
|
const output = result.stdout.toString() + result.stderr.toString();
|
|
expect(result.exitCode, output).toBe(0);
|
|
expect(output).toContain('4 pass');
|
|
expect(output).toContain('0 fail');
|
|
} finally {
|
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
}, callbackBudgetMs(4) + 10_000);
|