Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autoplan/bin/phase-publication-hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const SCHEMA_STRIPPED: Record<string, readonly string[]> = { Agent: ['run
/** The reviewer dispatch input the guard accepts; snapshot manifests are unchanged by it. */
export const AGENT_KEYS: readonly string[] = ['prompt', 'description', 'subagent_type', 'run_in_background'];
/** The newest Claude Code release the pinned PTY runs and the schema canary have checked. */
export const CHECKED_CLAUDE_CODE = '2.1.292';
export const CHECKED_CLAUDE_CODE = '2.1.326';
/**
* Claude records the model's raw input in the journal but hands PreToolUse its
* schema-parsed form: file_path resolved (C:\x/y becomes C:\x\y) and keys the
Expand Down
16 changes: 16 additions & 0 deletions bin/gstack-codex-probe
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,21 @@ _gstack_codex_role_ready() {
return 0
}

_gstack_codex_exclude_scratch() {
# Plan reviews write their Codex prompt in the working directory's .gstack/tmp/
# (#4851). Keep that folder out of git through git's own exclude path, which a
# linked worktree shares with its main checkout. Idempotent; a no-op outside
# git, without the folder, or when .gstack or .gstack/tmp is a symlink.
local _ex _ig
[ -d .gstack/tmp ] && [ ! -L .gstack ] && [ ! -L .gstack/tmp ] || return 0
_ex=$(git rev-parse --git-path info/exclude 2>/dev/null) && [ -n "$_ex" ] || return 0
_ig="/$(git rev-parse --show-prefix 2>/dev/null | sed 's/[][*?\\]/\\&/g').gstack/tmp/"
grep -qsxF "$_ig" "$_ex" && return 0
mkdir -p "${_ex%/*}" 2>/dev/null || return 0
{ [ ! -s "$_ex" ] || [ -z "$(tail -c1 "$_ex")" ] || echo; printf '%s\n' "$_ig"; } >>"$_ex" 2>/dev/null
return 0
}

# --- Sandbox (B1) -----------------------------------------------------------

_gstack_codex_sandbox_mode() {
Expand Down Expand Up @@ -1002,6 +1017,7 @@ _gstack_codex_main() {
return "$_rc" ;;
role-ready)
_gstack_codex_role_args ready "$@" || { _gstack_codex_usage >&2; return 64; }
_gstack_codex_exclude_scratch
_gstack_codex_role_ready "$_GSTACK_CODEX_ARG_KIND" "$_GSTACK_CODEX_ARG_CWD" "$_GSTACK_CODEX_ARG_MODEL" >&2
_rc=$?
[ "$_rc" -eq 0 ] || return "$_rc"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**A test that copies its own `bun` binary no longer stops `/gstack-ship` with a fetch violation.** The review's fetch check now recognizes a new large file that is an exact copy of the Bun runtime it runs on (same size and SHA-256) and prints it as `FETCH_IGNORED: … reason=host-runtime`; a file named `bun` with any byte changed is still a fetch. Also: the Codex prompt files `/plan-ceo-review` and `/plan-eng-review` write in `.gstack/tmp/` are now kept out of git, from a subdirectory or a linked worktree too; the `/autoplan` guard treats Claude Code 2.1.326, the version CI runs, as checked, from a fresh capture of its hook payload; and `docs/skills.md` says `/review` always runs the Codex second-model review when Codex is ready and the Red Team on diffs over 200 lines.
5 changes: 5 additions & 0 deletions docs/review-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,11 @@ The checkout's own build output is not a fetch either: a new big native executab
`FETCH_IGNORED: … reason=build-output`. A big file under an ignored directory or a
glob, a non-executable at that path, or a path only an uncommitted `.gitignore`
edit names still counts as a download.
A copy of the runtime the sweep itself runs on (`process.execPath`, such as a test
that copies its own `bun` into the temp dir) is not a fetch either: a new big file
with exactly that binary's size and SHA-256 prints
`FETCH_IGNORED: … reason=host-runtime`. A file named `bun` with any byte changed,
added or removed, or a copy of any other binary, still counts as a download.
A `Bun.spawn` child given no `env` keeps the temp dir its test process started
with, so its fixtures land outside the marked root and still count.

Expand Down
6 changes: 5 additions & 1 deletion docs/skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Detailed guides for every gstack skill — philosophy, workflow, and examples.
| [`/plan-eng-review`](#plan-eng-review) | **Eng Manager** | Lock in architecture, data flow, diagrams, edge cases, and tests. Forces hidden assumptions into the open. |
| [`/plan-design-review`](#plan-design-review) | **Senior Designer** | Interactive plan-mode design review. Rates each dimension 0-10, explains what a 10 looks like, fixes the plan. Works in plan mode. |
| [`/design-consultation`](#design-consultation) | **Design Partner** | Build a complete design system from scratch. Knows the landscape, proposes creative risks, generates realistic product mockups. Design at the heart of all other phases. |
| [`/review`](#review) | **Staff Engineer** | Looks for the bugs that pass CI but blow up in production. Auto-fixes the obvious ones. Flags completeness gaps. Advisory simplification lens flags over-built code — never blocks, never auto-applies. |
| [`/review`](#review) | **Staff Engineer** | Looks for the bugs that pass CI but blow up in production. Auto-fixes the obvious ones. Flags completeness gaps. Advisory simplification lens flags over-built code — never blocks, never auto-applies. Always runs the Codex second-model review when Codex is ready (or its check is inconclusive), and the Red Team on every diff over 200 lines. |
| [`/build-check`](#build-check) | **Build Loop** | Run the repo's checks and the tests `/gstack-ship`'s pre-gate would pick for your change, fix, repeat until green, then hand off to `/gstack-ship`. Never green on an unmapped change. |
| [`/design-review`](#design-review) | **Designer Who Codes** | Live-site visual audit + fix loop. 80-item audit, then fixes what it finds. Atomic commits, before/after screenshots. |
| [`/design-shotgun`](#design-shotgun) | **Design Explorer** | Generate multiple AI design variants, open a comparison board in your browser, and iterate until you approve a direction. Taste memory biases toward your preferences. |
Expand Down Expand Up @@ -626,6 +626,10 @@ This is a structural audit, not a style nitpick pass. I want the model to look f

Findings get action, not just listed. Obvious mechanical fixes (dead code, stale comments, N+1 queries) are applied automatically — you see `[AUTO-FIXED] file:line Problem → what was done` for each one. Genuinely ambiguous issues (security, race conditions, design decisions) get surfaced for your call.

### Second-model review and Red Team

Standalone `/review` always runs a Codex second-model review when Codex is ready or its check is inconclusive, through `gstack-outside-voice`, and always runs the Red Team pass when the diff is over 200 lines (a smaller diff can still get one when a specialist finds something critical). The end-of-skill check refuses to finish without both. If Codex isn't installed or reviews are turned off, that is recorded as a skip and the review still finishes; a skip the model just claims in its own words does not count.

### Completeness gaps

`/review` now flags shortcut implementations where the complete version costs less than 30 minutes of CC time. If you chose the 80% solution and the 100% solution is a lake, not an ocean, the review will call it out.
Expand Down
5 changes: 3 additions & 2 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -4253,8 +4253,9 @@ leave `merged.jsonl`, and it never reaches the Red Team, the judge, the
returned output or PR text. `verify` prints `FETCH_VIOLATION:` and refuses
until the stage has rerun and swept clean. A test run's fixtures (a root
carrying `.gstack-test-fixture`, or a repository whose remote resolves to a local
path through `url.<base>.insteadOf`) and the checkout's own native build output at a
path its committed root `.gitignore` names exactly print
path through `url.<base>.insteadOf`), the checkout's own native build output at a
path its committed root `.gitignore` names exactly, and a byte-identical copy
(size and SHA-256) of the runtime the sweep runs on print
`FETCH_IGNORED:` and never count.
Capy's `~/.capy/drive` is never walked, and the drive sync database under
`~/.capy/drive-engine` (`state.db` and its `-wal`, `-shm` and `-journal` files)
Expand Down
42 changes: 38 additions & 4 deletions lib/review-sweep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
*
* Two kinds of new directory are not fetches and print FETCH_IGNORED instead (GST-1695): a test fixture root below a sweep
* root that carries FIXTURE_MARKER (test-setup.ts puts every test's temp paths under one), and a repository whose every
* network remote resolves to a local path through url.<base>.insteadOf (the ship fixtures' fake GitHub origin).
* network remote resolves to a local path through url.<base>.insteadOf (the ship fixtures' fake GitHub origin). A new big file
* that is a byte-identical copy of the runtime running the sweep is not one either (FETCH_IGNORED host-runtime, GST-3959).
*/
import { spawnSync } from 'node:child_process';
import { createHash } from 'node:crypto';
import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
Expand All @@ -34,7 +36,7 @@ const SCP = /^(?:[\w.-]+@)?[\w.-]+:(?!\/\/)[\w./-]+$/;
export interface Inventory { at: number; roots: string[]; repos: Record<string, string[]>; big: Record<string, number>; ignored?: Record<string, Omit<Ignored, 'path'>>; partial?: string }
export interface Found { path: string; kind: 'repo' | 'download'; remote?: string; bytes: number | null }
/** A new directory the sweep saw and did not count: a marked test fixture root, or a repository whose remote resolves locally. */
export interface Ignored { path: string; reason: 'fixture-marker' | 'local-remote' | 'build-output'; remote?: string }
export interface Ignored { path: string; reason: 'fixture-marker' | 'local-remote' | 'build-output' | 'host-runtime'; remote?: string }
export type SweepVerdict = 'clean' | 'violation' | 'partial';
export interface StageSweep {
attempt: number;
Expand Down Expand Up @@ -139,7 +141,17 @@ export function inventory(roots: readonly string[], checkout: string, skip: read
}
for (const d of list) {
const p = path.join(dir, d.name);
if (d.isFile()) { if (ENGINE_DB.test(d.name) && dir.startsWith(engine)) continue; try { const s = fs.statSync(p); if (s.size >= BIG_BYTES) { if (buildOutput(home, p)) inv.ignored![p] = { reason: 'build-output' }; else inv.big[p] = s.size; } } catch { /* gone */ } continue; }
if (d.isFile()) {
if (ENGINE_DB.test(d.name) && dir.startsWith(engine)) continue;
try {
const s = fs.statSync(p);
if (s.size < BIG_BYTES) continue;
if (buildOutput(home, p)) inv.ignored![p] = { reason: 'build-output' };
else if (Date.now() <= deadline && hostRuntimeCopy(p, s.size)) inv.ignored![p] = { reason: 'host-runtime' };
else inv.big[p] = s.size;
} catch { /* gone */ }
continue;
}
if (d.isDirectory() && !SKIP.has(d.name) && depth < SWEEP_DEPTH) walk(p, depth + 1);
}
};
Expand Down Expand Up @@ -168,6 +180,27 @@ function buildOutput(checkout: string, file: string): boolean {
try { const fd = fs.openSync(file, 'r'); try { fs.readSync(fd, head, 0, 4, 0); } finally { fs.closeSync(fd); } } catch { return false; }
return NATIVE_MAGIC.some(m => m.every((b, i) => head[i] === b));
}
function sha256File(file: string): string {
const hash = createHash('sha256'), buf = Buffer.alloc(1 << 20), fd = fs.openSync(file, 'r');
try { for (let n; (n = fs.readSync(fd, buf, 0, buf.length, null)) > 0;) hash.update(buf.subarray(0, n)); } finally { fs.closeSync(fd); }
return hash.digest('hex');
}

let hostRuntime: { exe: string; size: number; sha256?: string } | null | undefined;
/**
* A copy of a binary already on the machine, not a fetch (GST-3959: gstack-evals#463's tests copy their own `bun` into /tmp):
* a file with exactly the size and SHA-256 of the runtime running this sweep (process.execPath, hashed at most once per process
* and only when a file of its size turns up). A name, a path, or any other binary never counts, and past the sweep's time budget
* no file is hashed, so it stays a download.
*/
function hostRuntimeCopy(file: string, size: number): boolean {
if (hostRuntime === undefined) {
try { const exe = fs.realpathSync(process.execPath); hostRuntime = { exe, size: fs.statSync(exe).size }; } catch { hostRuntime = null; }
}
if (!hostRuntime || size !== hostRuntime.size) return false;
try { hostRuntime.sha256 ??= sha256File(hostRuntime.exe); return sha256File(file) === hostRuntime.sha256; } catch { return false; }
}

function du(p: string): number | null {
const r = spawnSync('du', ['-sk', p], { encoding: 'utf8', timeout: 10_000 });
const kb = Number(/^(\d+)/.exec(r.stdout ?? '')?.[1]);
Expand Down Expand Up @@ -226,7 +259,8 @@ export function foundLines(stage: Stage, attempt: number, found: readonly Found[
export function ignoredLines(stage: Stage, attempt: number, ignored: readonly Ignored[]): string[] {
return ignored.map(i => {
const remote = i.remote ? ` remote=${control(i.remote) ? JSON.stringify(i.remote) : i.remote}` : '';
const why = i.reason === 'fixture-marker' ? `a test fixture root carrying ${FIXTURE_MARKER}` : i.reason === 'build-output' ? 'a native executable the checkout\'s committed .gitignore names exactly, which its own build writes' : 'its remote resolves to a local path through url.<base>.insteadOf';
const why = i.reason === 'fixture-marker' ? `a test fixture root carrying ${FIXTURE_MARKER}` : i.reason === 'build-output' ? 'a native executable the checkout\'s committed .gitignore names exactly, which its own build writes'
: i.reason === 'host-runtime' ? 'a byte-identical copy (size and SHA-256) of the runtime running this sweep, already on the machine' : 'its remote resolves to a local path through url.<base>.insteadOf';
return `FETCH_IGNORED: stage=${stage} attempt=${attempt} path=${shownPath(i.path)} reason=${i.reason}${remote} (${why}, so not a fetch; docs/review-policy.md#what-readers-may-fetch)`;
});
}
Expand Down
4 changes: 2 additions & 2 deletions test/autoplan-guard-reasons.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ describe('guard reason inventory', () => {

test('no denial advises a retry; transients say what to wait for; fallbacks print the runnable fallback', () => {
for (const [code, reason] of Object.entries(REASONS)) {
const text = reasonText(code, sample, '2.1.292');
const text = reasonText(code, sample, '2.1.292'); // pregate-literal: CHECKED_CLAUDE_CODE='2.1.292' a sample version string for the reason text, not the checked pin
expect({ code, retry: /\bretry/i.test(text) }).toEqual({ code, retry: false });
expect(text).toContain(`(code ${code}, Claude Code 2.1.292)`);
expect(text).toContain(`(code ${code}, Claude Code 2.1.292)`); // pregate-literal: CHECKED_CLAUDE_CODE='2.1.292' echoes the sample version passed in above
expect(text).toContain(`${GUIDE}#${anchor(code)}`);
if (reason.disposition === 'transient') expect(text).toMatch(/\bWait for\b/);
if (reason.disposition === 'fallback') expect(text).toContain(FALLBACK);
Expand Down
Loading
Loading