Repository navigation
Hooks judge the programs that run, not shell text (T815, part 1: core and the Claude hook) - #463
Merged
Merged
Conversation
By the owner's decision of 2026-11-07, the shell-text heuristics are cut. The rules judge the programs that a command line runs, as core's command reader sees them, and the literal paths in their words. Core (one function each, used by both hooks): - mergeRun replaces mergeIn: the one merge form, else any run of gh pr merge, or gh api, curl or wget with a pulls/<n>/merge path or a GraphQL merge mutation, at any depth that the reader sees (A5). - pushProblem judges every git push that the reader finds and refuses one that is not a command of its own (F1); push text given to another program and the gh destination fallback are gone (A7, A10). - logbookWrite (command-runs.mjs): the literal part of each written word, key=value and --option=value value and redirection target, resolved through links, into the sage root or the shared root (C2, C3). - stateToolRun: node or direct runs of sage.mjs and sage-pr.mjs, node -e/-p code and -r/--import modules; a read command passes in a pipe or a chain. - ghRuns and AGENT_GH: gh's own words and method; agents also get pr diff, list and status, issue list, run view, list and watch, and repo view. - The push rules read git and gh with core's readers (no copies). - An unreadable line is refused only when it names a merge or a push. Claude hook: the near-logbook rule, the scratch exemption (C5), the name rule (C6), the early verdict copy (C7, keeping the lead's gap rule), the gh identity and alias inference (H4), the board pattern inference (H6) and the copied write classifier are deleted. The rules read the fields that run, not the description. The crash fallback keeps its text check. Codex gate: the merge call site and the reader swap only (part 2 is T903). Tests: scripts/keep-matrix.test.mjs runs the KEEP set through both hooks, with a fake gh outside /tmp first on PATH; old tests of the removed families are deleted or flipped to the documented limits. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Rules held in code: the agent and chief logbook rows describe the literal-path rule, the scratch row goes with the rule, and the limits of the hook list the documented limits (standing order 49): a variable, a substitution or a pattern in a program word or a path, a gh alias or a renamed copy, code and scripts, text piped into a shell, a folder known only at run time, gh settings, and the wrapped verdict form. SECURITY.md names the same limits. changes/T815.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
T901's owner check of sage-pr create and merge stays: sessionBar first, fail closed when the check cannot finish, the SAGE_PROJECT= and env -u NODE_OPTIONS forms, and no logbook read for a legacy push. Its unreadPr text rule goes with T815's cut (F-T901-7): unreadPr now judges the programs that a line runs (core's stateToolRun), so text that only names the PR script passes; a line that the reader cannot read is refused when its bare text names the script and create or merge. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…passes it (F-T901-7) An echo or a history search that names the PR script and a merge or create verb passes; a run from node's code and a line that the reader cannot read still refuse with the plain form. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t (F-T901-7) Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test script line keeps both new files: keep-matrix.test.mjs (T815) and merge-carry.test.mjs (T805). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…k (F-T815-2) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…'s texts and the docs - F-T815-4: a remove, move or recursive lock (rm, mv but its last word, rsync --delete, find -delete or -exec rm, chmod -R and the like) of a root or a folder above one is refused, also by a pattern in it (~/*). - F-T815-5: an option before or between gh's first two command words is refused (other than -R or --repo and its value), with the option and the plain form. - F-T815-16: the reader follows a literal pushd and popd as cd; both fallbacks too. - F-T815-9: an unread line's refusal leads with the cause and the way forward, in the same words for every rule (core's unreadable). - F-T815-6: one gh api method reader (ghApiMethod) for the push rules and ghRuns, with cobra's bundled -iX. - F-T815-7: the REST merges endpoint is a merge. - F-T815-10: the expansion refusal names its word. - F-T815-14: a long word shows its start and end; the read form's suffix is fixed. - F-T815-17: command -v and -V run nothing. - F-T815-1, -11, -12, -13: SKILL.md, SECURITY.md, rules-in-code, the change note and core's pages say what the hooks do now. - Tests: keep-matrix rows for each refusal, a core test in both bundles, hook tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…i's value options (F-T815-27) ghApiMethod read -XGET after -t, -p or -H as the method, so gh api -X PATCH .../git/refs/heads/main -t -XGET passed the push rule, and an agent's gh api -X DELETE ... -t -XGET passed the agent gh rule; gh gives -XGET to -t and sends PATCH or DELETE. Core now has one list of gh api's value options (GH_API_VALUE, from gh api --help), and both ghApiMethod and the push rule's apiWritesMain skip the word after each of them. Tests: three keep-matrix push rows (-t -XGET, -p -XGET, -H --method=GET) that refuse in both hooks, one agent row, and ghRuns method cases in both bundles. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tHub writes, cd ~ (F-T815-30, 31, 33) - F-T815-30: core's programAmong reads gh, curl, wget and node in the words of a run, so a merge behind arch -arm64, op run --, script -q /dev/null, direnv exec, unbuffer, flock or mise exec is refused in both hooks; the agent's state tool rule reads node there too, and its gh rule reads gh there when a gh command name follows it. - F-T815-31: the command reader resolves a literal cd ~ and cd ~/<path> (and pushd) to the home folder. On a line that the reader cannot read, the push rule still refuses a gh api write of main or the default branch, gh repo sync, gh repo edit --default-branch and a literal git subcommand that the hook does not know. - F-T815-33: the merge paths match one or more slashes, as GitHub reads them. - keep-matrix rows for each form, and pass rows for ordinary wrapper and cd ~ work. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a word (F-T815-39, F-T815-42) - One reader in core, gitOrGh: the git or gh run of a run, also behind a wrapper that the command reader does not know (programAmong). gh counts there when one of gh's command groups and another word follow it; git counts when a subcommand name follows it. programAmong takes that test as an optional third argument; gh joins its text programs. - F-T815-39: the push rule's readable loop reads wrapped git and gh too (not in a shell function's call), so arch -arm64 gh api PATCH of main, op run -- gh repo sync, cd ~ && op run -- gh repo sync and arch -arm64 git -C <tree> frobnicate origin are refused for the chief, the agent and the Codex chief. unreadableSend and the Codex gate's gh commands use the same reader. - F-T815-42: an agent's gh rule reads gh behind a wrapper only before a gh command, so brew install gh jq, find . -name gh -type f, du -sh gh node_modules, cp gh backup, man gh pr, tree gh src, rm -rf gh build, tar -czf out.tgz gh docs and npm view gh version pass again. - keep-matrix rows for each wrapper (now also chronic and ionice -c3) before a gh api write of main, gh repo sync, gh repo edit --default-branch and an unknown git subcommand; pass rows for the F-T815-42 forms. Hook and Codex gate tests for both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
Part 1 of T815. By the owner's decision of 2026-11-07, the hooks' shell-text heuristics are cut. A hook now judges only the programs that a command line runs, as core's command reader sees them, and the literal paths in their words, never free text. These heuristics caused about 96% of agent refusals, almost all false alarms. A deliberate forgery by a variable, code, a pattern after its literal part or a gh alias is a documented limit (standing order 49); the sandbox is the full guard. Part 2 (T903) cuts the Codex gate's own text rules.
What changes
Core, one function each, exported from the public entry point. The Claude hook uses all of them; the Codex gate uses mergeRun and the push readers until T903.
Claude hook: the near-logbook rule (C2, C3), the scratch exemption (C5), the name rule (C6), the early verdict copy (C7; the lead's gap rule stays, F3), the gh identity, alias and copy inference (H4), the board pattern inference (H6) and the copied write classifier are deleted (sage-hook.mjs: 2986 to about 1950 lines). The rules read the fields that run, not the tool call's description; the first-upload prompt still counts every field (T196). The crash fallback keeps its text check (F5).
Kept unchanged: the merge form and the merge check, the push form and the owner's push rule, the known git subcommands, the hooks path and .git rules, the file-tool rule, autopilot only by the owner's phrases, the board rule by literal paths, the process and stash rules, and the PowerShell checks.
Codex gate: only the merge call site and the reader swap. The Codex native runtime's one merge call follows the rename.
Evidence (cycle 1, head 98c375d)
Merges of main
main is merged in twice, with merge commits: T901 (PR 462) and then T805 (PR 458). After the T901 merge, the hook, chiefs, shared-root, board-shared, providers, codex-gates, sage and merge-carry tests pass, each file alone. The package.json test line keeps both new files (keep-matrix and merge-carry). git merge-tree against main is clean.
Repair round 1 (cycle 1 findings)
Head c83eba1. main did not move past 774845d, so there is no new merge.
rm,rmdir,unlink,shred,mv(but its last word),rsyncwith a delete option,chmod/chown/chgrp/chflags -R, and the start folders offind -deleteor-exec rm, counts when it names a root or a folder above one. For a pattern or a variable, the folder of its literal part counts (~/*). For the chief too.rm -rf <shared>,mv,rm -rf ~/..,rm -rf ~/../*,find <base> -delete,chmod -R); core test in both bundles; R5-DOLLARQUOTE-R/--repoand its value; after a command with no subcommand, such asapiorstatus, only the options before it). The refusal names the option and the plain form.gh pr -b view merge 12,gh pr -c view close 12,gh --color always pr merge ...); core testpushd <dir>ascd, andpopdback to it; another form leaves the folder unknown. Both fallbacks (logbook and board) treatpopdas unknown.unreadable): the cause, the way forward, what the text names, then the rule. Used by the merge, push, gh, stash, process and state tool rules.ghApiMethod) for ghRuns and the push rules, with cobra's bundled-iX.repos/<o>/<r>/merges(andrepositories/<id>/merges) for gh api, curl and wget.command -v/-Vas no run;command gh ...stays a run.verdictBackingand its exports are removed.Evidence on c83eba1: build and check pass. keep-matrix: Claude chief 70 of 70, Claude agent 77 of 77, Codex chief 64 of 64 refused rows refuse; 17 plain rows pass. Hook parts 1 to 6, providers, chiefs, shared-root, codex-gates, codex-server, verdict-backing and hooks pass, each file alone. Each new test fails on 98c375d (detached worktree). Replay of 459 refused agent calls: 388 of 399 T815-family refusals pass (97.2%), 0 outside a kept rule; against 98c375d, 6 more calls pass (all
command -v) and none newly refuses.Not fixed here, on the polish list: F-T815-3, F-T815-8, F-T815-15.
Folds
T708, T709, T714 and T801 each patch a heuristic that this cut removes; the chief abandons them after the merge.
🤖 Generated with Claude Code