Skip to content

Codex gate judges the programs that run, not shell text (T903, part 2 of the cut) - #464

Merged
erickb336 merged 3 commits into
mainfrom
sage/t903-codex-cut-heuristics
Nov 8, 2026
Merged

erickb336 merged 3 commits into
mainfrom
sage/t903-codex-cut-heuristics

Conversation

@erickb336

Copy link
Copy Markdown
Owner

What this is. Part 2 of the shell-text cut (T903). PR 463 (T815) made core and the Claude hook judge only the programs that a command line runs and the literal paths in their words. This PR does the same for the Codex-only rules of packages/sage-codex/hooks/gate-hook.mjs, by the PE plan R2786 (J7 and F7). A deliberate forgery by a variable, a pattern or an alias is a documented limit (owner 2026-11-07); Codex's sandbox is the full guard.

Removed (each with its flipped tests in scripts/codex-gates.test.mjs, one T903: reason line each):

Rule Old place Now
gh from a variable or a substitution, and a setting before gh (GH_PAGER, EDITOR, BROWSER, HOME, GH_CONFIG_DIR and the like) ghProblem (GH_LITERAL, GH_SETTINGS) pass; GH_PATHS unchanged
$HOME, $SAGE_HOME, $SAGE_SHARED_HOME, $CODEX_HOME forms of the sage folder and config file rules, and $ words counted as leaving the project namesSageFolder, names, leavingPaths, namesCodexSettings literal paths only, also from ~
A logbook file's name (tasks.tsv, config.json ...) refused anywhere outside the project in sage mode namesLogbookFile, 4 call sites gone, shell and patch
Any shell write with an uncertain target (> $DEST, > out*) parsedWrites?.uncertain refusal gone

Added in their place: core's logbookWrite with the Codex sage folder and the shared root, in every mode and thread: a literal write into a root (also through a link, after cd, from ~), and a remove, move or recursive lock of a folder that holds one (rm -rf ~/.., find <dir> -delete, mv <Codex home> x).

Kept, unchanged in effect: GH_PATHS; the merge rule and sage's merge command; the push rule and its owning chief; the .git write rule (core's push policy still refuses .git writes from ~ and with a pattern, now keep-matrix rows); the state tool rule; the owner record and merge permit of autopilot; the .codex folder, Codex run and read-only role rules; the .hooks/codex and .sage name parts of the sage folder rule.

Evidence (each file alone, scratch homes):

  • scripts/keep-matrix.test.mjs 4/4: refused rows by role {"claude chief":157,"claude agent":169,"codex chief":158} of 173 rows; every Codex chief row refuses (158 of 158), and Codex logbook rows refuse by their own words.
  • The same keep matrix against main's gate: Codex chief 146 refused, 2 tests fail. rm -rf ~/.., rm -rf ~/../*, find <base> -delete, mv <Codex home> ... and cd <link> && rm -rf .hooks passed there.
  • scripts/codex-gates.test.mjs 130/130; scripts/fixtures/codex-native/autopilot-{change,gate,merge,record}.test.mjs 1, 18, 13, 28 pass; chiefs 130, codex-plugin 10, codex-state-mcp 40, providers 261 pass.
  • npm run build and npm run check pass.

Docs: docs/design/rules-in-code.md, SECURITY.md and docs/guide/codex.md say that the Codex gate follows the same rule; changes/T903.md.

Not in this PR: T906, T907, T908. The Codex gate still has no board, process or stash rule (it had none before).

🤖 Generated with Claude Code

erickb336 and others added 3 commits November 8, 2026 13:02
… of the cut)

As T815 did for core and the Claude hook, the Codex gate's own shell-text
heuristics are cut (PE R2786, J7 and F7):
- The gh path rule no longer refuses gh from a variable or a substitution,
  or a setting before gh (pager, editor, browser, HOME, config folder):
  documented limits. GH_PATHS is unchanged.
- The sage folder and config file rules read literal paths (also from ~),
  not $HOME, $SAGE_HOME, $SAGE_SHARED_HOME or $CODEX_HOME.
- The logbook name rule (tasks.tsv and the like refused anywhere outside
  the project) is gone, for the shell and for patches.
- The refusal of any shell write with an uncertain target is gone.
- In their place, core's logbookWrite with the Codex sage folder and the
  shared root: a literal write into a root, also through a link, and a
  remove, move or recursive lock of a folder that holds one, refuse in
  every mode.

Tests: keep-matrix rows for the Codex chief (logbookWrite forms, the Codex
sage folder through a link, .git writes from ~ and with a pattern), with the
Codex logbook refusal checked by its own words. codex-gates tests of the
removed rules are flipped, each with a T903 reason line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rules-in-code.md, SECURITY.md and the Codex guide say what the Codex gate
judges now and which forms are documented limits; core's notes name the
Codex gate as a caller of logbookWrite. changes/T903.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ex workflow reference, a test title, LOGBOOK_FILES removed

- docs/guide/codex.md: the gate check names the guarded folder by its absolute path or a ~ path, not by $SAGE_HOME, and covers CODEX_HOME too (F-T903-4).
- The Codex workflow reference says what the shell guard reads now: literal paths; a variable or pattern form is a documented limit (F-T903-5).
- The T594 worktree test title matches its body (F-T903-3).
- LOGBOOK_FILES and its export go: the Codex gate was its last caller (F-T903-1).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@erickb336
erickb336 merged commit 5b2e201 into main Nov 8, 2026
1 check passed
@erickb336
erickb336 deleted the sage/t903-codex-cut-heuristics branch November 8, 2026 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant