mirror of
https://github.com/garrytan/gstack.git
synced 2026-10-31 14:06:50 +01:00
* feat(codex): --effort <level> sets GSTACK_CODEX_EFFORT for one run /codex review --effort medium (or --effort=medium) prefixes each run-with-timeout dispatch with GSTACK_CODEX_EFFORT=<level>, which outranks codex_effort and the per-mode default; --xhigh becomes shorthand for --effort xhigh. The probe keeps owning validation. A missing value, a value that is not one lowercase word, or conflicting flags stop instead of falling back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(codex): per-run effort prefix reaches the rendered /codex review dispatch Runs the rendered review fence against the fake codex: no prefix uses codex_effort, GSTACK_CODEX_EFFORT=medium|xhigh wins over it, an unknown level never reaches codex. Step 1 check pins --effort tokens and the stop rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(codex): document codex_effort and --effort; Challenge runs at high, not xhigh Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(changelog): [Unreleased] entry for /codex --effort Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(codex): --effort reaches the probe as an allowlisted request level, parsed before the mode and checked before the paid probe The level now travels as run-with-timeout --request-effort '<effort-level>' (placeholder grammar ^[a-z]*$) instead of an agent-built env prefix, and the probe names /codex --effort when it rejects one. Effort flags count only right after /codex or its mode word and are removed before mode detection. Step 0.5 runs check-effort before probe-model, so a bad level makes no Codex call even on a cold cache. Tests cover all five dispatch fences and the zero-call cases. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(codex): per-request --effort in model-policy, CHANGELOG behavior changes, TODOS follow-ups Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * chore: stamp v1.91.93.0 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(codex): effort flags sit among /codex's leading flags; the probe names an unfilled '<effort-level>' placeholder Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(codex): per-request row in the effort precedence table, in-tool help names /codex --effort, late-flag notice Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test(codex): binding tripwire sees the request-effort dispatch; valid and unfilled levels through Step 0.5 and every fence; doc accuracy Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: John Nunemaker <nunemaker@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
71 lines
3.5 KiB
TypeScript
71 lines
3.5 KiB
TypeScript
/**
|
|
* #2847: a nested gstack Codex call is a one-shot review, but Codex injects every
|
|
* installed skill (gstack's own `review` included) into its context, and the
|
|
* reviewer re-ran whole skill workflows inside its timeout. A read-only sandbox
|
|
* does not stop that. Verified against codex-cli 0.152.0 and 0.160.0 with a local
|
|
* Responses API stub: without `skills.include_instructions=false` the request
|
|
* carried the full gstack catalog; with it, none (exec and native review alike).
|
|
* Every gstack-owned Codex call therefore carries the isolation flag, and the
|
|
* prompt boundary names the Codex skill roots.
|
|
*/
|
|
import { describe, expect, test } from 'bun:test';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import { CODEX_MODEL_CONFIG_FLAG, CODEX_REVIEW_MODEL_CONFIG_FLAG, CODEX_SKILLS_ISOLATION_FLAG } from '../scripts/resolvers/constants';
|
|
import { expectMentions } from './helpers/prompt-structure';
|
|
|
|
const ROOT = path.join(import.meta.dir, '..');
|
|
|
|
function renderedSkillFiles(): string[] {
|
|
const files: string[] = [];
|
|
const pending = [ROOT];
|
|
const excluded = new Set(['node_modules', '.git', '.context', '.claude', 'fixtures']);
|
|
while (pending.length) {
|
|
const dir = pending.pop()!;
|
|
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
if (excluded.has(entry.name)) continue;
|
|
const full = path.join(dir, entry.name);
|
|
if (entry.isDirectory()) pending.push(full);
|
|
else if (entry.name.endsWith('.md') && !entry.name.endsWith('.tmpl')) files.push(full);
|
|
}
|
|
}
|
|
return files;
|
|
}
|
|
|
|
describe('Codex skill isolation (#2847)', () => {
|
|
test('the model flags carry the isolation flag, so every model-flag site is isolated', () => {
|
|
expect(CODEX_SKILLS_ISOLATION_FLAG).toBe('-c skills.include_instructions=false');
|
|
expect(CODEX_MODEL_CONFIG_FLAG).toContain(CODEX_SKILLS_ISOLATION_FLAG);
|
|
expect(CODEX_REVIEW_MODEL_CONFIG_FLAG).toContain(CODEX_SKILLS_ISOLATION_FLAG);
|
|
});
|
|
|
|
test('every wrapped Codex exec/review call in generated skills disables the skill catalog', () => {
|
|
const calls: string[] = [];
|
|
for (const file of renderedSkillFiles()) {
|
|
for (const line of fs.readFileSync(file, 'utf8').split('\n')) {
|
|
if (/run-with-timeout\s+(?:--user-invoked\s+)?(?:--effort\s+\w+\s+(?:--request-effort\s+'[^']*'\s+)?)?\d+\s+codex\s+(exec|review)\b/.test(line)) calls.push(`${path.relative(ROOT, file)}: ${line}`);
|
|
}
|
|
}
|
|
expect(calls.length).toBeGreaterThan(10);
|
|
expect(calls.filter(call => !call.includes("skills.include_instructions=false"))).toEqual([]);
|
|
});
|
|
|
|
test('the probe round trip does not pay for the skill catalog either', () => {
|
|
const probe = fs.readFileSync(path.join(ROOT, 'bin', 'gstack-codex-probe'), 'utf8');
|
|
const roundTrip = probe.split('\n').find(line => line.includes('"reply OK"'));
|
|
expect(roundTrip).toContain("skills.include_instructions=false");
|
|
});
|
|
|
|
test('outside-voice and /codex prompt boundaries name the Codex skill roots and forbid skill use', () => {
|
|
const sources = ['scripts/resolvers/outside-voice-steps.ts', ...['review-mode', 'challenge-mode', 'consult-mode'].map(m => `codex/sections/${m}.md.tmpl`)];
|
|
for (const rel of sources) {
|
|
const text = fs.readFileSync(path.join(ROOT, rel), 'utf8');
|
|
const boundaries = text.split('\n').filter(line => /do not read or execute any files under/i.test(line));
|
|
expect(boundaries.length, rel).toBeGreaterThan(0);
|
|
for (const line of boundaries) {
|
|
expectMentions(line, [['do not', 'installed', 'invoke']], 'line');
|
|
}
|
|
}
|
|
});
|
|
});
|