Skip to content

fork-kit/agent-guards: the machine's agent guard hooks as a kit (#834 G4) - #847

Merged
scuttletoby merged 14 commits into
mainfrom
fork/kit-agent-guards
Nov 22, 2026
Merged

scuttletoby merged 14 commits into
mainfrom
fork/kit-agent-guards

Conversation

@scuttletoby

@scuttletoby scuttletoby commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Part of #834 (item G4, first half). The Claude Code hooks that guard every agent on a shared machine move into the
fork as one kit, fork-kit/agent-guards, laid out like fork-kit/model-guard. A project keeps only its facts
in the machine file. Agents see the same messages and the same exit codes as before, except where the lens fixes
below say otherwise.

Hooks

Hook Event (matcher), timeout Refuses Missing or failing hook
actions-disable-guard PreToolUse (Bash|Monitor), 10 s, onFailure: block Disabling a workflow, Actions itself, or branch protection or rulesets (enforcement disabled or evaluate) on any repo; refuseScripts from the machine file; a nested agent session without this machine's hooks Refuses (exit 2, and on a timeout) and says so
capacity-pipe-guard PreToolUse (Bash|Monitor), 10 s A pipe out of a capacity check, which hides its NOT OK exit Exit 1, "hook skipped, commands are NOT checked"
memory-index-guard PreToolUse (Write|Edit|MultiEdit), PostToolUse (Write|Edit|MultiEdit|Bash|Monitor), 5 s An auto-memory index over its budget (Pre: the write; Post: once per change, any tool) Exit 1 with a line
bg-guard Stop, 5 s A stop while a background Bash command still runs (at most maxBlocks per session) Exit 1 with a line
agent-slots UserPromptSubmit, Stop, 5 s Only for listed orchestrator sessions: a context line of slots and the ready queue; blocks a stop once while slots are free and items are ready Exit 1 with a line

bin/agent-guards adds four commands:

  • hooks prints the settings entries;
  • self-check checks the whole machine file section strictly, the hook files and their /usr/local/bin links, the
    drop-in, an open approval, and warns when the agents' user can become root without a password;
  • check [--settings F] runs every wired command the way Claude Code does (Bash and Monitor cases), with one case
    it must refuse and one it must pass, under a temporary HOME, and changes nothing on the machine. As root it
    reads F only when it is root-owned and not writable by others;
  • approve [--hours N] [--cwd DIR] --command '<cmd>' | --revoke (root only): the owner's approval of one command,
    below.

sbin/agent-guards-install is on the shared kit_install.py. The shared bootstrap accepts it with
--kit agent-guards [--settings | --no-settings]. --settings writes a managed settings drop-in,
/etc/claude-code/managed-settings.d/agent-guards.json. It is written after the hook links and never written over
a drop-in of that name the installer did not write. The rollback is --no-settings (keeps the hook files).

Config keys (machine file, "agent-guards" section; all optional, defaults = the old values)

Key Default
actionsDisable.stateDir ~/.local/state/actions-disable-guard
actionsDisable.refuseScripts [] ({"name", "flag", "why"})
capacityPipe.commands ["t3-capacity"]
memoryIndex.maxChars / maxLine / stateDir 6000 / 160 / ~/.cache/memory-index-guard
bgGuard.skipSessionsFiles / maxBlocks / stateDir [] / 3 / ~/.local/state/bg-guard
agentSlots.sessionsFile / queue / readyHeading / maxAlive / processName / note "" (off) / "" / "## Ready" / 10 / "claude" / ""

The machine file must be owned by root and not writable by others; otherwise it is not used. Each hook reads only
its own part: a bad key keeps its default, an unknown key is ignored, a bad refuseScripts row is dropped and the
good rows kept. The hook tells the agent (a systemMessage, plus context for PreToolUse) and stderr. Another hook's
part, or an unknown top-level key (a later G4b section), changes nothing for it. self-check names every problem.

Lens round 1 fixes

Approval: a root-owned file, not an environment variable (lens B major). Options were (a) refuse any command
that names or sets the variable, or (b) a root-owned approval file. (a) cannot work: the variable is set when the
owner starts a session, so every nested claude -p or codex exec inherits it without any command naming it. (b)
is the root fix: sudo agent-guards approve --hours N writes /etc/fork-kit/agent-guards-approval.json (root-owned,
0644, atomic) with only the SHA-256 of a random code and an end time (at most 24 h), and prints the code. (Round 2
binds it to one command, one folder and one use: see below.)
The command carries #owner-approved:actions-disable:<code>. An agent cannot write the file and cannot guess the code;
a nested session gets nothing it did not already have. The file is read under the machine file's rules (owner,
mode, no links); anything wrong is no approval. The old variable is not read any more. Who can become root without
a password (sudo NOPASSWD, the docker group) can still write it: self-check warns about both and the README says so.

Nested sessions (lens B minor). Managed hooks run in a nested claude -p even with disableAllHooks in a user or
--settings file, so those pass. claude --bare / --safe-mode / CLAUDE_CODE_SIMPLE and codex (except login,
logout, help, completion, version) run no managed hooks, so starting one is refused (the owner's approval opens it). Round 2 widens this and says what
it is not: see below.

Finding Fix
B major: Monitor bypasses actions-disable-guard Matcher Bash|Monitor; the guard reads Monitor events; check has a Monitor case and reports a Bash-only wiring as MISSING
B major: approval variable inherited by nested sessions Root-owned approval file + code (above; bound to one command in round 2)
B minor: memory-index PostToolUse misses Monitor Matcher Write|Edit|MultiEdit|Bash|Monitor
B minor: a timeout fails open onFailure: block on the closed hook; a missing or empty hook file refuses too
B minor: nested --bare, CLAUDE_CODE_SIMPLE, codex exec Refused (above)
B minor: check --settings as root Reads the file only when root-owned, not group/other-writable, no link
B minor: ruleset enforcement=evaluate Refused like disabled (fields, JSON body, GraphQL)
B minor: sudo NOPASSWD / docker group self-check warning + README
A+B minor: uninstall removes hooks a foreign settings file names; rollback Uninstall refuses while a settings file the kit did not write names a hook, then removes the drop-in, then refuses while a session started before that still runs; rollback documented as --no-settings
A major: an unknown sibling key drops the whole machine file Each hook reads only its own part; strict check in self-check
A major: one bad refuseScripts row drops all Bad rows dropped one by one, named
A minor: fallback not visible to the agent systemMessage (and PreToolUse context) on stdout as well as stderr
B nit: vp check Formatted
B nit: self-check checks the version folder, not the links Links checked
A+B nit: ensure_dir chmods an existing /etc/claude-code Only missing managed folders are made; a group/other-writable one is refused
B nit: wiring.ours is loose Anchored to the kit's own command form
A nit: check writes the real log and cache Hooks run with a temporary HOME
A nit: an empty guard file exits 0 Refuses ([ -s ])

Not fixed (nits):

  • The default capacity command name t3-capacity is one machine's name. It is the old value the hooks had; a
    machine sets its own in capacityPipe.commands. Changing the default would silently turn the guard off where it
    runs today.
  • The old (pre-kit) bg-guard has no lock in the short window while both copies are wired during the switch; the
    README says to remove the old entries soon after. Worst case is one extra block.
  • Old state "an older kit's files": no earlier release of this kit exists, so there is no older layout to migrate.

Lens round 2 fixes

One commit per finding; each new test is named after its finding (test_r2_<finding>_...) and fails on the
round-2 head 6d5047d (19 of 19: run there with the new test files copied in).

Finding Fix Commit Tests
B major 2: the code is not one-time; any command can use it until it ends sudo agent-guards approve --command '<cmd>' [--cwd DIR] keeps the SHA-256 of the normalised command (marker off, runs of blanks as one) and the real folder next to the code's hash (approval file version 2). The guard passes only that command, in that folder, once: the first run records the use (approval-used-<hash> in the guard's state folder, written as a temp file then linked, so two runs at once cannot both win); a second run, or any other command with the code, is refused. A code seen in a transcript, the app's database or ps opens nothing else. README, docstring and this body no longer say "one-time code" for the old behaviour 239c710 test_r2_major2_* (6 in actions-disable, 1 in wiring)
B major 1: hookless nested sessions by other forms (a) Wider detection: claude and codex by their real program path (.../claude/versions/<v>, the @anthropic-ai/claude-code and @openai/codex packages), a link to or a copy of the installed program, npx / bunx / pnpm dlx / npm exec / bun x / node <cli>, $(which claude), a name the same command gives one (ln -s), and inside python -c, node -e, perl -e, at, systemd-run (the same token layer as for gh). CLAUDE_CODE_SIMPLE in the command, through env -S, in a sourced file, in BASH_ENV / --rcfile, and in the user's shell start files. (b) The threat model below, in the README ("What the guards are and are not") and the guard's docstring d249b38 test_r2_major1_* (4)
B minor 1: GraphQL ruleset update with EVALUATE in a variable The variable values (-F, -f, --raw-field, --field=, i[enforcement], a JSON --input file) are read like the REST fields, so EVALUATE is refused like DISABLED 280d289 test_r2_minor1_*
B minor 2 + A minors 1 and 2: uninstall's running-session check Sessions are found by the real path of their program (/proc/<pid>/exe, the script node runs, an installed claude), not the name. The uninstall's own parent session is no longer skipped: run from inside a session that has the hooks, it refuses ("run uninstall from a terminal"). A refusal for a hand-wired entry is remembered (/etc/agent-guards/hand-wired-seen.json, removed with /etc/agent-guards), so the next run still counts every session older than itself; so does a run where the drop-in was never on. The project .claude/settings*.json of each running session's folder (and the folders above) is searched too 2dffcfc, a90b854 (boot time read only when a session runs; found by the shared kit_install tests) test_r2_minorB2_*, test_r2_minorA1_*, test_r2_minorA2_* (3), test_r2_state_*
A nit: codex arguments Read option by option: codex -m o3 exec x is refused as codex exec; codex mcp list passes (MCP setup, no session); npx -y @openai/codex exec x is refused; codex mcp-server stays refused 325132b test_r2_nit_codex_*
B nit 1: which Claude Code honours onFailure README: 2.1.295 and later; older ones ignore it and let a failed or timed-out hook's call run aec5b9f (docs)
B nit 2: --safe-mode refusal Kept: safe mode runs managed hooks, but not hooks wired by hand in user settings (the README's agent-guards hooks route). The reason is in the README and docstring d249b38 in test_r2_major1_*
A nit: the machine-file note repeats Kept loud on purpose; README says it shows on every call each hook with a problem handles (so one Bash call can show it once per hook) aec5b9f (docs)

Also: origin/main merged twice (seam check fork-seam-check.cjs --config-ref origin/main origin/main HEAD = 0).

What the guards are and are not (threat model)

The guards stop mistakes and casual misuse by an agent: a command typed from habit, a step copied from an old
note, a short cut it was told not to take. Each refusal says why. They are not a security boundary against a
hostile agent
: they read shell text before it runs, and text can be built so that no reader sees what it does
until it runs (words made at run time, a program the guard does not know, an MCP tool that starts a session, a file
read by a file the command sources).

The real boundary is the GitHub permissions of the token the agent holds. Recommended setup: agents get a
fine-grained token for their repos without Actions (write) and Administration (write), so turning off a workflow,
Actions or a ruleset fails at GitHub whatever command asks for it; the token that can do that stays with the owner.
The guards then catch the mistake earlier, with a reason, and the token holds when they miss one.

Not covered (known, by design of a text check): other agent programs; an MCP tool or app that starts a session
(another provider's child, for example); command words built at run time with no claude / codex in the text;
files read in turn by a sourced or start file; a copy of the Claude Code program under another name in a folder
uninstall does not know (uninstall matches the program's real path, the package path and installed claude
links, not file contents). The approval's use record is in the agents' user's state folder: an agent that sets out
to can delete it, and can then only repeat the one approved command, in the approved folder, until the end time.

Unfixed nits: the machine-file note is not merged across hooks within one call (each hook is its own process;
merging needs shared per-call state, not worth it for a note meant to be fixed quickly).

Round 2 state question

  • Runs again: approve twice: the second replaces the first (the first code stops working). The approved
    command run twice: the second run is refused ("used already"); a second hook run for the same tool call passes.
    Uninstall again after any refusal: the drop-in stays gone, the hand-wired record stays, the session check runs again.
  • Stops half-way: approve killed: a stray temp file at worst, never a half approval file (temp, fsync, rename).
    The guard killed while recording a use: no use record and no half file (temp then link), so the approval is still
    unused, never half used. Uninstall killed after writing the hand-wired record: the next run counts more sessions
    as older, never fewer.
  • Old or empty state: an approval file of the round-1 format (version 1, no command) is no approval; a broken
    or empty hand-wired record counts as seen now; no machine file gives the defaults.

Round 2 test run (this head, each file through heavy after t3-capacity 1536 said OK)

actions-disable 115, agent-slots 6, bg-guard 9, capacity-pipe 22, config 15, install 20, memory-index 14, wiring
21, common/free_contract 17, common/kit_install 127, common/machine_file 27: all OK.

Tests (state question included)

New and changed tests are failing-first against the head before this round. They cover:

  • refuse and pass cases per hook, for Bash and Monitor;
  • the approval: a valid code, no code, another code, a longer or shorter code, the old variable and marker, revoked,
    over, a group-writable file, a link, broken JSON, more than 24 h;
  • nested sessions: claude -p, claude --bare, disableAllHooks, CLAUDE_CODE_SIMPLE, codex exec, and
    mentions that only name them;
  • a machine file that is missing, empty, garbled, of another version, group-writable, with an unknown sibling key or
    a G4b section, a broken key of another hook, a bad refuseScripts row;
  • a timeout (onFailure), an empty or missing guard file;
  • install run twice, stopped at every step, then run again; uninstall with a foreign settings file, with an older
    session running, stopped after the drop-in is gone; the rollback; a managed folder others can write;
  • check --settings as root with a group-writable file and a link; check leaves the real HOME untouched.

General vs project

General (this PR): all hook code, the settings entries, the installer, the approval, the checks and the tests.
Nothing in it names a project, a person or a machine path.

Project or machine (not in this PR): the facts in the machine file section. These are the capacity command's
name, the memory budget, the orchestrator's sessions file and queue, and a project script that must not run with a
given flag. A project's own copies of these hooks are deleted in a follow-up on that project's side, after the
machine switches to the kit. This kit's agent-slots is unrelated to the T3 app's own agentSlots setting.

Not in this PR (G4b): new hooks for further rules (no CI-skip marker in commit messages, no git stash in
worktrees, no bare CLI against a live database).

🤖 Generated with Claude Code

…G4)

Five Claude Code hooks that guard every agent on a shared machine, as one kit with one
installer, facts from the machine file and the same messages and exit codes as before:

- actions-disable-guard (PreToolUse Bash): no disabling of workflows, Actions or branch
  protection; fails closed (a missing or failing hook refuses, and says so)
- capacity-pipe-guard (PreToolUse Bash|Monitor): no pipe out of a capacity check
- memory-index-guard (Pre/PostToolUse): the auto-memory index stays inside its budget
- bg-guard (Stop): no stop while a background Bash command still runs
- agent-slots (UserPromptSubmit, Stop): slot and ready-queue context for orchestrators

The others fail open with a visible line. `agent-guards check` runs each wired command
with a case it must refuse and one it must pass; `--settings` writes a managed settings
drop-in. Shared bootstrap and kit_install contract tests cover the new kit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: B · reviewer: lens agent (security boundary and fail-safe) · read at: f64f2c7
verdict: not safe to merge
covered: all of fork-kit/agent-guards (bin, lib, sbin, README), the bootstrap and machine.example.json changes, and a line-by-line diff of each hook against the copies the machine runs today (the hook logic is the same; only the config source, the shebang, the refuseScripts rule and doc text changed). Also the private swap plan (order, rollback, half-done states).
checks: fed about 95 hand-written PreToolUse events straight into bin/actions-disable-guard (HOME in a scratch folder, nothing wired): -X/--method/-XPUT/--method=PUT, POST to /disable, query strings, a full URL, //, a trailing /, %2F, upper case, --field, --input file and heredoc, a method-override header, GraphQL delete/update mutations, -F query=@file, -R before and after the subcommand, eval, bash -c, variables, $(..), $'\x64..', split quotes, a backslash, alias, env/command/sudo/timeout/nohup/setsid/stdbuf/watch/parallel, find -exec, xargs (also from gh workflow list), a script written then run, at -f, make -f /dev/stdin, tmux, script -c, a git -c alias.x='!..', python -c. All refused. What passes is listed below. The PR's tests were not run here: t3-capacity 1536 said NOT OK on every try (load), so I relied on CI on this same head, where Fork kit tests 1, 2 and 3 pass. Lint (vp check) is red with "Formatting issues found".
state: runs again: the installer rewrites nothing when the text and mode are the same, and the drop-in is written after the links, so a second run, or a run after a stop at any step, ends in the same state. Stopped half-way: a temp file and a rename (with fsync) for the drop-in and the config file, so there is never a half-written drop-in. The saved settings choice means a stop after config and a later bare run still writes the drop-in. Old or empty state: a missing, empty, garbled, foreign-owned or group-writable machine file, or a broken section, gives the built-in defaults plus one stderr line. The guards never become weaker than the defaults. The one exception: refuseScripts defaults to [], so a broken section drops that extra rule (documented). Running sessions: Claude Code keeps the hooks it loaded at start, so uninstalling while sessions that loaded the drop-in are alive makes every Bash call in them refused (see minor 1). The swap plan's order (install, then check, then wire both, then prove with a fresh claude -p, then remove the old entries) never leaves a session unguarded. Its rollback (restore the user entries first, then remove the drop-in) is right. Use --no-settings for that, not uninstall.
blocker: none
major: 1. The Monitor tool runs shell commands with no actions-disable check (fork-kit/agent-guards/lib/agent_guards/wiring.py:180, bin/actions-disable-guard:3166). The matcher is Bash only, and the guard itself returns 0 for any tool_name that is not Bash. A Monitor call with gh workflow disable 1 -R o/r, or gh api -X PUT repos/o/r/actions/permissions -F enabled=false, passes. I fed it directly: pass for Monitor, REFUSE for the same text as Bash. Monitor poll loops that call gh are a normal agent pattern, and capacity-pipe-guard already covers Bash|Monitor, so this gap is easy to fall into. Fix: matcher Bash|Monitor for actions-disable-guard, read tool_input.command for both tools in answer(), and add a test plus a check case for a Monitor event.
major: 2. The owner escape hatch opens from inside a session through a nested session (bin/actions-disable-guard:3071-3085, docstring lines 116-120). The docstring says "a command prefix or export in the Bash tool never reaches this hook". That is true for this session's own hook, but not for a claude -p the command starts: the nested session inherits the variable, and its hooks read it. CLAUDE_GUARD_OWNER_ALLOW_ACTIONS_DISABLE=$(date -u +%F) claude -p "$(cat p.txt)", with #owner-approved:actions-disable and the disable call in p.txt, passes the outer guard. The nested guard then lets the call through. The refusal text itself tells the agent the variable and the marker. Fix (text level, cheap): refuse any Bash/Monitor command whose text names the variable (MARK_ENV) in any form: assignment, export, env VAR=, or a file it writes. Better: take the approval from a root-owned place (a dated line in the machine file, or a root-owned file) instead of the environment.
minor: 1. uninstall (and the swap plan's rollback "or uninstall") removes /usr/local/bin/actions-disable-guard while running sessions still call it from the hooks they loaded. Each of those sessions then refuses every Bash call until it restarts. in_use() does not see this, because no hook process is running at that moment (sbin/agent-guards-install:104-113). Fix: README and the plan say "roll back with --no-settings; uninstall only after every session started with the drop-in has ended". Or keep the hook links for one more release after the drop-in goes.
minor: 2. Root ownership is the whole boundary for the drop-in and the machine file (README "only root can change it", the PR body "agents can no longer change a guard's facts"). Where the user the agents run as can become root without a password (sudo NOPASSWD, membership of the docker group), that boundary does not exist. self-check could warn when sudo -n true succeeds, or when the user is in docker. A text rule could also refuse Bash/Write/Edit that target /etc/claude-code, /etc/fork-kit or /usr/local/bin/. Today neither is done, and the README states the boundary without that condition.
minor: 3. Nested sessions and other agents are outside every hook here. claude --bare -p "$(cat p.txt)", claude -p --settings '{"disableAllHooks":true}' .. and codex exec "$(cat p.txt)" all pass actions-disable-guard (a prompt from a file is unread text). Whether bare mode or a user/--settings disableAllHooks also turns off MANAGED hooks is not tested by the PR or by the swap plan. The Claude Code binary has separate messages for "hooks off (bare mode)" and "switched off in your user settings or --settings file". Agents of other providers do not read Claude Code settings at all. Fix: in the swap plan's step 3/5 proofs, also run the bad case under --bare and under --settings '{"disableAllHooks":true}', and record the answer. If managed hooks fall, set the managed key that holds them, or add a text rule against those flags. The README's "every agent on a machine" should say "every Claude Code session".
minor: 4. A hook that hangs past its timeout lets the call through, also for the fail-closed hook (README line 38). actions-disable-guard limits itself to 5 s from its process start, but a process that is not scheduled for 10 s on a machine under heavy load gets ended by Claude Code, and the command runs unchecked. If Claude Code's hook entries accept a failure mode (the README names onFailure), set it to refuse for actions-disable-guard. If not, say plainly that a timeout fails open.
minor: 5. memory-index-guard's PostToolUse matcher (Write|Edit|MultiEdit|Bash, wiring.py:182) leaves out Monitor, so a Monitor command that rewrites MEMORY.md is not checked afterwards. Add Monitor, as for capacity-pipe-guard.
minor: 6. agent-guards check --settings F runs every command in F through /bin/sh -c as the caller (lib/agent_guards/check.py:144-155). Run as root on a user's settings file (the README shows --settings ~/.claude/settings.json), that runs commands the user (or an agent) wrote, as root. Fix: as root, refuse an F that is not root-owned and not writable by others.
minor: 7. Some ruleset and protection writes still pass: gh api -X PATCH orgs/o/rulesets/5 -f enforcement=evaluate (evaluate is also "not enforced"), -F rules[]= (rules emptied), -X DELETE repos/o/r/environments/<env>/deployment-branch-policies/<id>, and the GraphQL updateBranchProtectionRule with checks off. Most of this is the documented owner decision ("other changes to protection with PUT/PATCH/POST pass"). enforcement=evaluate is the one that is the same act as the refused enforcement=disabled: add it to RULESET_OFF.
nit: 1. CI Lint (vp check) is red on this head: "Formatting issues found" (probably the new README tables or machine.example.json).
nit: 2. agent-guards self-check checks the hook files in its own version folder (bin/agent-guards:63), not the /usr/local/bin links that the drop-in names. A missing link shows only in agent-guards-install self-check.
nit: 3. ensure_dir chmods an existing /etc/claude-code and managed-settings.d to 0755 (common/kit_install.py:190). That changes a folder another tool may own. wiring.ours takes any drop-in as the kit's when every command contains /<hook name>.

@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: code · reviewer: lens agent (A: correctness and parity) · read at: f64f2c7
verdict: not safe to merge
covered: each of the five bin/ hooks, diffed line by line against the host copies it replaces (the ones wired in both accounts' settings today); lib/agent_guards (config, wiring, check), bin/agent-guards, sbin/agent-guards-install, the bootstrap and kit_install contract changes, machine.example.json, README, all 8 test files
checks: ran every test file of the PR and the shared kit_install contract (actions-disable 98, agent-slots 6, bg-guard 9, capacity-pipe 22, config 11, install 9, memory-index 14, wiring 12, kit_install 127: all OK). Parity is by diff, not by running old against new: the command-reading code of actions-disable-guard and capacity-pipe-guard is unchanged. The only decision changes are the refuseScripts loop (same match as the old fork_garden rule; the fast-exit key it builds gives the same "forkgarden" word), the configurable check names, and the stateDir paths. So quoting, && ; | chains, subshells, env prefixes, heredocs, Monitor input and multi-line commands get the same refuse or pass answer. The refusal texts are unchanged except the documented run_tests.py hint. Refusals still go out as a JSON deny with exit 0, so the new || exit 2 wrapper never adds a second message to a normal refusal. Also checked in the installed Claude Code that managed-settings.d reads only non-dot .json files, so a temp file left by a killed write is never loaded.
state: runs again: the installer finds the same drop-in and changes nothing (write_file compares first); old and new hooks wired at once give 2 bg-guard counts per stop, a doubled context line and a doubled memory refusal (as the swap plan says); the old bg-guard writes the count file without the lock (see nit). Stops half-way: the drop-in is written by temp file + rename after the links, and the tests stop at every step, then run again. Old or empty state: no machine file or no section gives the kit defaults with no stderr. A broken section gives the defaults plus one stderr line that agents never see (exit 0). But a section that is fine for its own hook and only has a key this release does not know drops every hook's settings (major below). Uninstall can leave a fail-closed entry pointing at a removed file (minor below).
blocker: none
major: fork-kit/agent-guards/lib/agent_guards/config.py:114 checks the whole "agent-guards" section against this release's five hook names before it reads one hook's own keys, and machine_file.fields refuses unknown keys. So one key this release does not know drops ALL five hooks to their defaults. That key can be a new hook's subsection written ahead of the kit upgrade (the swap plan's own order is machine file first, then install), the same file left in place after a kit rollback, or a typo. Failure scenario: G4b adds "commitMarker": {...} to /etc/fork-kit/machine.json before the new kit is installed. Then actions-disable-guard has no refuseScripts, so python3 ./fork_garden.py --fix runs. bg-guard loses skipSessionsFiles, so orchestrators get stop-blocked. agent-slots goes silent. Each hook only writes a stderr line on exit 0, which agents never see. A bad entry inside one hook's subsection does the same to that hook's other keys: one bad refuseScripts row drops all rows. Fix: in load(hook), read only section.get(hook) with fields() and skip the sibling check. Report unknown sibling keys in agent-guards self-check only. Add a test: a section with an unknown sibling key still gives actionsDisable its refuseScripts.
minor: sbin/agent-guards-install:104-113 (with kit_install _remove): uninstall removes /usr/local/bin/actions-disable-guard even when a settings file the kit did not write still names it. Examples: a hand-edited drop-in (ours() is then False, so it is kept), another managed drop-in, or a user settings entry pasted from agent-guards hooks, which the README offers. That entry fails closed, so every Bash call of every new session is refused until root removes it. Fix: before removing the links, refuse the uninstall (or keep the links) when any file in /etc/claude-code/managed-settings.json or managed-settings.d/
.json other than an ours() drop-in names a kit hook path. Say in the README that hand-wired entries must go first.
minor: the fallbacks do not give today's live values, as the brief asked. With a missing or broken file the kit defaults apply: refuseScripts [], skipSessionsFiles [], agentSlots off. The README says so for refuseScripts (line 48), so this is a documentation and visibility gap, not a parity bug. Suggest that agent-guards self-check (or the daily report) flags a section problem loudly, because a hook only writes it to stderr on exit 0, which agents never see.
nit: lib/agent_guards/check.py:92: agent-guards check says it "changes nothing on the machine", but its refuse case for actions-disable-guard appends a line to the real user's /log, and the cache file is updated. Say so, or point stateDir at the temp folder for the check run.
nit: sbin/agent-guards-install:90-91: ensure_dir chmods an existing /etc/claude-code (and managed-settings.d) to 0755, even when an admin set another mode. Only create the folder when it is missing; leave an existing folder's mode alone.
nit: lib/agent_guards/config.py:80: the default capacity check name t3-capacity is one machine's tool name inside the public kit. It is harmless (it only matches that word), but a neutral default (none, so the hook does nothing until configured) would fit "facts in the machine file" better.
nit: wiring.py:47 with wiring.test.py:106: an empty actions-disable-guard file exits 0 and passes every command. The old hook behaved the same, and the kit's manifest check makes this unlikely, but the test pins it as wanted. Consider failing closed when the hook prints no answer and its file is empty.
nit: during the swap plan's both-wired window, the old ~/.local/bin/bg-guard truncates and rewrites the same count file without the flock. The new one can then read an empty file as 0, so maxBlocks can be passed during that window. Keep the window short, as the plan says. No code change needed in the PR.

scuttletoby and others added 3 commits November 22, 2026 03:03
- actions-disable-guard and capacity-pipe-guard match Bash|Monitor; the
  memory-index after-call check matches Monitor too; check reports a
  guard wired for Bash only as missing.
- The owner's approval is a root-owned file with the hash of a one-time
  code (agent-guards approve); the session variable is no longer read,
  since nested sessions inherited it.
- Refuse starting a nested session without this machine's hooks
  (claude --bare/--safe-mode, CLAUDE_CODE_SIMPLE, codex).
- The closed hook sets onFailure block; an empty guard file refuses.
- A ruleset set to evaluate is refused like disabled.
- Each hook reads only its own part of the machine file section; bad
  keys and refuseScripts rows are dropped one by one and named to the
  agent; self-check does the strict check.
- Uninstall refuses while a foreign settings file names a hook or an
  older session runs; rollback is --no-settings.
- check --settings as root reads only a root-owned file; check runs
  hooks under a temporary HOME; self-check checks links, an open
  approval and passwordless ways to root.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: code r2 · reviewer: lens agent (A: correctness and parity) · read at: 6d5047d
verdict: safe to merge
covered: the fix commit 268c218 since my round-1 head f64f2c7 (all of fork-kit/agent-guards: the five hooks, lib/agent_guards config, wiring, check and the new approval.py, bin/agent-guards, sbin/agent-guards-install, README, the tests). From the merge of main, only .github/fork-ci-tests.txt: the kit's 8 test lines are back in the new format (each ends in unittest, ~45s and ~20s kept), and the kit has no other test file. Parity: the five hook copies the machine runs today, and the hook entries in both accounts' settings files.
checks: ran all 8 kit test files and the shared kit_install test on this head through heavy: actions-disable 103, agent-slots 6, bg-guard 9, capacity-pipe 22, config 15, install 14, memory-index 14, wiring 20, kit_install 127, all OK. Failing-first: the same test files on the round-1 code fail 26+4 in actions-disable, 9+15 in config, 10+1 in install and 6+20 in wiring. That covers each round-1 finding: unknown sibling key, bad refuseScripts row, the fallback named to the agent, foreign settings at uninstall, the empty guard file, the managed folder others can write, and check under a temporary HOME. Claude Code 2.1.325's own hook schema has onFailure on each command hook, next to timeout and statusMessage. A timeout there counts as a block ("timed out; blocking because onFailure is block"), so the kit's entry is in the right place. Fed about 25 extra commands to the hook as Bash and as Monitor (nested agents, mentions, codex subcommands, the approval marker with no file). Results are in the nits.
state: runs again: install twice changes nothing. --no-settings twice: the second run finds no drop-in, and settingsOff stays the time of the first. Uninstall after a refused uninstall: the drop-in is already gone, so only the session and foreign checks run again. Stops half-way: settingsOff is written as "pending" before the drop-in is unlinked and becomes the time afterwards. A stop in between leaves "pending", and the next run writes its own (later) time. A later time counts more sessions as older, never fewer. The tests stop the install at every step. Old or empty state: with no machine file, every hook gets its defaults without a notice. A broken part of one hook changes only that hook, and only the bad key or row, and the hook names it to the agent. A key no hook knows is silent for the hooks and named by self-check. That makes the swap order "machine file first, then kit" safe for a later G4b section. Old settings: the host still wires ~/.local/bin copies, which the kit neither reads nor removes. Sessions started before uninstall: covered for the drop-in, but not for two cases (minors 1 and 2).
blocker: none
major: none
minor: 1. fork-kit/agent-guards/sbin/agent-guards-install:186-197: older_sessions leaves out the uninstall's own ancestors. A claude ancestor that would otherwise be listed started before the drop-in was removed, so it is exactly the kind of session that loses its hooks. A newer one is not listed anyway. Failure scenario: the owner runs sudo agent-guards-install uninstall from the Bash tool of a session that loaded the drop-in. The uninstall passes and removes the links, and that session then refuses every Bash and Monitor call until it restarts. Fix: keep claude processes out of mine (or refuse with "run uninstall from a terminal, not from a session that has the hooks"), and add a test with the fake claude as the parent.
minor: 2. fork-kit/agent-guards/sbin/agent-guards-install:216-232: the older-session check runs only against settingsOff, the time the kit's drop-in went. Hand-wired entries get no such check. The README offers them through agent-guards hooks. Failure scenario: a user's settings file names /usr/local/bin/actions-disable-guard. Uninstall refuses and says to remove the entries by hand and run again. The owner does that, and no drop-in was ever written, so settingsOff is unset. The second uninstall removes the links, and every session that started with the hand entries refuses every Bash call. foreign_settings also does not look at a project's own .claude/settings*.json. Fix: when foreign entries were seen, or settingsOff is unset, refuse while any claude process older than this uninstall runs (or record the time of the last foreign-entry refusal and compare against that). Add one line to the README.
nit: actions-disable-guard:2660: the codex subcommand is the first word that does not start with "-", so a flag's value is taken as the subcommand. codex -m o3 exec x is refused as "codex o3" (still refused, but the text is wrong). codex mcp list (configuration, not a session) is refused. npx -y @openai/codex exec x passes. The PR body's "not covered: other agent programs" may be meant to include that last one; if so, name the npx and bunx form there.
nit: README:55 and the PR body say "one-time code", but approval.approved accepts the code for any number of commands until its end time. approve prints this correctly ("Every command carrying it passes ... until then"). Say "a code for N hours".
nit: with one hook's part broken, the same notice goes into every tool call's context, once per hook that has a problem. A Bash call can carry it up to three times (actions-disable Pre, capacity-pipe Pre, memory-index Post). It is loud on purpose; note it in the README so the owner fixes the file quickly.
nit: round 1, fixed: the unknown-sibling-key major (config.py _own/load read only the hook's own part, key by key), the bad refuseScripts row (dropped one by one and named), the silent fallback (config.notice: systemMessage, plus additionalContext where the event takes it), uninstall with a foreign settings file, check writing the real HOME, ensure_dir changing an existing folder, and the empty guard file (now [ -s ]). The t3-capacity default nit no longer applies, because main now ships fork-kit/heavy/bin/t3-capacity, so the name is the fork's own tool. Parity: the host copies are the same files as in round 1. The kit differs from them only where the PR body says. These changes are the Monitor matcher (host: Bash only), onFailure: block (host: a timeout lets the call run), an empty file refuses (host: python3 -I of an empty file exits 0 and passes; a missing file exits 2 and refuses, as the kit does), PostToolUse with Monitor, ruleset evaluate, nested agents and the approval file. Ruleset bodies are also now read without the cue words (canon(cue=False)), which is needed for "enforcement": "evaluate". It can only add refusals, and a "disabled" body file is refused on both heads. Nothing personal or project-specific is in the kit.

@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: B r2 · reviewer: lens agent (security boundary and fail-safe) · read at: 6d5047d
verdict: not safe to merge
covered: the fix commit 268c218 since my round-1 head f64f2c7 (main merges ignored): bin/actions-disable-guard, lib/agent_guards/approval.py, bin/agent-guards (approve, self-check, check --settings), check.py, wiring.py, config.py, sbin/agent-guards-install (settings_off, uninstall_guard, older_sessions), README, the tests. Also the Claude Code 2.1.325 binary's own text for onFailure, bare mode, safe mode and disableAllHooks.
checks: ran every agent-guards test and the fork-kit/common tests at this head through heavy: all 11 files OK. Fed about 130 PreToolUse events straight into bin/actions-disable-guard (scratch HOME, nothing wired). Refused, as they should be: Monitor gh workflow disable and a Monitor poll loop with PUT .../actions/permissions; claude --bare in any flag position, --bare=, quoted or split --ba""re, $x, $c, alias, bash -c, sh -c, eval, a script written then run, xargs, find -exec, timeout, nohup, sudo, tmux, script -c, a pipe into it; CLAUDE_CODE_SIMPLE=1 claude, env/env -i/export forms; codex exec, codex e, codex resume, codex mcp-server, a full codex path; enforcement=evaluate by -f/-F/--raw-field/--field=, upper case, split quotes, $'\x65', %65, --input file, here-string, heredoc split over lines, curl -d/--data-raw/--json/-d @file, GraphQL inline EVALUATE and -F query=@file; the old variable plus the old marker; a made-up code. Passed, as they should: claude -p, codex login, codex --version, mentions in echo/grep/commit messages, enforcement=active, POST of a new ruleset. Read the binary: onFailure is a per-hook key of command hooks (the kit puts it there), and bare mode / CLAUDE_CODE_SIMPLE drop "settings-file, flag, policy, and plugin hooks", while a user or --settings disableAllHooks alone does not stop managed hooks (both checks need the policy value), so claude -p and disableAllHooks are still guarded.
state: runs again: approve writes a new code each time and replaces the file whole (temp file, fsync, rename), so the last code wins and older codes stop working; --revoke twice says "there was no approval". install twice ends the same. uninstall again after a refusal: the drop-in is already gone, settingsOff holds the time, and the older-session check runs again. Stopped half-way: approve leaves at worst a stray .agent-guards-approval.* temp file and no approval (fails closed); a stop between "pending" and the drop-in removal leaves "pending", and the next run takes a later time (counts more sessions as older, never fewer). Old or empty state: no approval file, a link, wrong owner or mode, bad JSON, another version, a time over or a file without until are all "no approval"; a clock that moves back makes an open approval last longer (only root can move it). The old CLAUDE_GUARD_OWNER_ALLOW_ACTIONS_DISABLE variable is not read anywhere outside the tests.
round 1, fixed: Monitor now reaches actions-disable-guard (matcher Bash|Monitor, TOOLS, and check reports a Bash-only wiring as MISSING).
round 1, fixed: the session variable is gone; an agent cannot write, forge or extend the root-owned approval file, and a nested session gets no approval it was not handed.
round 1, fixed: memory-index PostToolUse covers Monitor; onFailure: "block" on the closed hook; an empty or missing guard file refuses; check --settings as root reads only a root-owned file root alone can write; uninstall refuses while a foreign settings file names a hook, removes the drop-in first, then refuses while an older session runs; sudo NOPASSWD and docker group warned in self-check; ensure_dir no longer chmods existing folders; wiring.ours anchored.
blocker: none
major: 1. A nested session without this machine's hooks still starts by many one-line forms, so the closed guard can be walked around in two steps (start a hookless session, run gh workflow disable there). nested_agent (fork-kit/agent-guards/bin/actions-disable-guard:2647-2663) only matches the command word's basename claude or codex, and CLAUDE_CODE_SIMPLE only as literal text of this same command. All of these pass: the installed binary by its real path (~/.local/share/claude/versions/<version> --bare -p x, which is where ~/.local/bin/claude points on a native install), a link or copy (ln -s ... ./cc && ./cc --bare), $(which claude) --bare, "$(command -v claude)" --bare, exec -a foo claude --bare, npx/bunx/pnpm dlx @anthropic-ai/claude-code --bare, node .../cli.js --bare, npx @openai/codex exec, python3 -c 'os.system("claude --bare ..")', node -e, perl -e, at now <<< 'claude --bare ..', systemd-run --user claude --bare, and the env from a file: printf 'CLAUDE_CODE_SIMPLE=1\n' > e.env then . ./e.env; claude -p x, set -a; . ./e.env, env $(cat e.env) claude -p x, env -S 'CLAUDE_CODE_SIMPLE=1 claude -p x', or export CLAUDE_CODE_SIMPLE=1 written to ~/.bashrc then bash -ic 'claude -p x'. For gh the same guard refuses python -c, at and systemd-run (I checked), so the gap is that the nested-agent rule is not part of the text layer that reads unreadable programs (CUES, bin/actions-disable-guard:2009). Fix at the root: (a) recognise the program by what it is, not its name: a word whose realpath is under a claude/versions/ folder, a @anthropic-ai/claude-code or @openai/codex package word after npx/bunx/pnpm dlx/node, and a command word the guard cannot read ($(..), backticks, exec -a) followed by --bare; (b) add --bare, CLAUDE_CODE_SIMPLE and the codex start words to the cue layer, so text that flows into a program the guard cannot read is refused as gh text is; (c) refuse claude/codex in a command that sources a file or reads env from one (., source, set -a, env $(..), env -S, bash -i/-l) unless the guard reads that file. A tool call that starts a session of another provider (for example an MCP tool that delegates to a codex child) is outside every PreToolUse:Bash rule; the README's "Not covered" should name that and say the wall is the token's scope.
major: 2. The owner's code is not one-time: any agent that sees it can run any disable, on any repo, until the approval ends (up to 24 h). approval.approved (fork-kit/agent-guards/lib/agent_guards/approval.py:59-71) accepts the code in any command, any number of times, and nothing ties it to the repo, workflow or act the owner approved. The code travels in the command text, so it lands in the session transcript, the app's database and ps, all readable by every agent of the same user; one that was refused can search them for #owner-approved:actions-disable: and reuse a live code. README.md:55, the guard docstring (bin/actions-disable-guard:116) and the PR body call it a one-time code, and approval.py:1 says "for one ... refusal"; only the approve output says every command passes. Fix: bind the approval to the act: sudo agent-guards approve [--hours N] -- '<the exact command>' (or repo plus workflow/endpoint) and keep the SHA-256 of that normalised command next to the code's hash, so a replay can only repeat the act the owner approved; the hook cannot use up a root-owned file, so binding is the way to make it single-purpose. At least, fix the "one-time" wording and keep the default window short.
minor: 1. GraphQL updateRepositoryRuleset with enforcement EVALUATE in a variable passes: gh api graphql -f query='mutation($e: RuleEnforcement!) { updateRepositoryRuleset(input:{repositoryRulesetId:"x", enforcement: $e}) {..} }' -F e=EVALUATE, and -F i[enforcement]=EVALUATE with input:$i. The same with DISABLED is refused. Cause: seen is built with canon(x) (bin/actions-disable-guard:1398), which blanks text with no cue word, so "e=EVALUATE" is '' before OFF_WORD looks at it (:1417); the REST path got cue=False, this one did not. Fix: test OFF_WORD on canon(x, cue=False) for the GraphQL update, and add these two cases to the tests.
minor: 2. uninstall's older-session check (sbin/agent-guards-install, older_sessions) finds Claude Code only by an argv basename claude or @anthropic-ai/claude-code. A session started by the versioned binary path or a renamed link is not seen, so uninstall can remove the hooks under it and every Bash and Monitor call there is refused until it restarts (fails closed: availability only). Fix: also read /proc/<pid>/exe and match its realpath (a claude/versions/ folder).
nit: 1. onFailure is honoured only by recent Claude Code; the binary's own text says older CLIs "ignore it (a failed callback set to block lets the action run)". The README should name the first version that honours it, or self-check could print the CLI's version.
nit: 2. The binary says safe mode keeps managed hooks ("Only managed hooks run on this machine (an org policy, or safe mode)"), so refusing claude --safe-mode is not needed (harmless); the docstring and README should not list it as hookless.

scuttletoby and others added 9 commits November 22, 2026 03:55
…able is refused (lens B r2 minor 1)

The off word of updateRepositoryRuleset was looked for in canon() text, which blanks text with no cue
word, so `-F e=EVALUATE` (or a JSON variables block) was '' before OFF_WORD saw it. It is now read
without the cue words, as the REST ruleset body already was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…older, once (lens B r2 major 2)

`sudo agent-guards approve --command '<cmd>' [--cwd DIR]` now stores the hash of the
normalised command and the folder next to the code's hash (approval file version 2).
The guard passes only that command, ending in the marker, run in that folder, and
records the use in its state folder (O_EXCL link; the same tool_use_id passes again),
so the approval is used up. A code seen in a transcript, the app database or ps opens
no other command. A version 1 file counts as no approval.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e and wrapper, and say what the guards are not (lens B r2 major 1)

A list of strings cannot be complete, so this does both things the review asked for:

(a) Wider detection where it is cheap and reliable. claude and codex now count by name, by their real
program path (.../claude/versions/<v>, the @anthropic-ai/claude-code and @openai/codex packages), as a
link to or a copy of the installed program, through npx, bunx, pnpm dlx, npm exec, bun x and
`node <their cli>`, behind `$(which claude)`, and inside python -c, node -e, perl -e, at, systemd-run
and the other wrappers already read for gh. CLAUDE_CODE_SIMPLE counts in the command, through env -S,
in a sourced file, in BASH_ENV/--rcfile and in the user's shell start files.

(b) The threat model, written plainly in the README ("What the guards are and are not") and the guard's
docstring: the guards stop mistakes and casual misuse; they are not a boundary against a hostile agent;
the boundary is the GitHub permissions of the agent's token (a fine-grained token without Actions and
Administration write is the recommended setup).

Codex arguments are now read option by option (an option's value is not taken for the subcommand),
because the new path and package forms need it; the separate codex nits follow in their own commit.

Tests: LensSecurityR2Test.test_r2_major1_* (each fails on 6d5047d).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ex mcp passes (lens A r2 nit)

`codex -m o3 exec x` is now refused as `codex exec` (the option's value is no longer taken for the
subcommand), `codex mcp list` (MCP setup, no session) passes, and `npx -y @openai/codex exec x` is refused
(the package form came with the major-1 commit). `codex mcp-server` stays refused.

Test: LensSecurityR2Test.test_r2_nit_codex_arguments_name_the_right_subcommand_mcp_passes_npx_refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ses inside a hooked session, remembers hand-wired entries (lens B r2 minor 2, lens A r2 minors 1 and 2)

- Sessions are found by the real path of their program (/proc/<pid>/exe: the native build in
  .../claude/versions/<v> under any name, the @anthropic-ai/claude-code script node runs through any
  link, an installed `claude`), not by the process name alone.
- The uninstall's own ancestors are no longer skipped: run from inside a Claude Code session that has
  the hooks, it refuses and says to run it from a terminal.
- A refusal for a hand-wired entry is remembered (/etc/agent-guards/hand-wired-seen.json, removed with
  /etc/agent-guards); the next run then counts every session older than itself, as does a run where the
  drop-in was never on. A broken record counts as seen now.
- The project .claude/settings*.json of each running session's working folder (and the folders above
  it) is searched too.

Tests: Install.test_r2_minorB2_*, test_r2_minorA1_*, test_r2_minorA2_* and test_r2_state_* (each fails on
6d5047d).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s onFailure, and how often a machine-file note shows (r2 nits)

- onFailure: "block" is honoured from Claude Code 2.1.295 on; older versions ignore it and let a
  failed or timed-out hook's call run (lens B r2 nit 1).
- A broken part of the machine file is named on every call the hook handles, once per hook with a
  problem, so a Bash call can carry it up to three times: kept loud on purpose, now said in the README
  (lens A r2 nit).
- The --safe-mode refusal is kept, with its reason in the README since the major-1 commit: safe mode
  runs managed hooks but not hooks wired by hand in user settings (lens B r2 nit 2).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…de Code session runs (follow-up to the session-check commit)

The session check now runs on every uninstall, so it must not refuse for a /proc/stat it does not need:
the boot time is read only once a Claude Code process is found, and an unreadable process list still
refuses with "cannot be read". Found by the shared fork-kit/common/tests/kit_install.test.py run (its
fake /proc has no stat file).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scuttletoby

Copy link
Copy Markdown
Owner Author

override for head a90b854: the round 2 fix diff (6d5047d..a90b854) checked against lens B r2 and lens A r2. The lens rounds are used up (2 of 2), so the orchestrator checked the fixes itself.

  • B major 2 (the approval is not one-time): fixed at the root (239c710). approval.py binds the approval to the hash of one normalised command and one folder, requires the marker to end the command, and records the one use with a temp file and os.link (it fails when the name is taken; the same tool_use_id passes again). A version 1 file counts as no approval. Known limit, written in the README: the use record lives in the agents' user's folder, so an agent that removes it can only repeat the approved command in that folder until the end time.
  • B major 1 (hookless nested sessions): the forms named in the finding are now refused (d249b38): real program path, link or copy, npx/bunx/pnpm dlx/npm exec/bun x/node cli, $(which ...), python/node/perl/ruby one-liners, at, systemd-run, exec -a, CLAUDE_CODE_SIMPLE through env -S, sourced files, BASH_ENV/--rcfile and shell start files. The README section "What the guards are and are not" says plainly that a list of forms is not complete and that the token's GitHub permissions are the real boundary. That plan is owner question Owner question: agent guards as a safety net, GitHub permissions as the hard limit #916.
  • B minor 1 (EVALUATE in a variable) (280d289), and B minor 2 with A minors 1 and 2 (uninstall finds sessions by program path, refuses inside a hooked session, remembers hand-wired entries, reads project settings) (2dffcfc, a90b854): fixed.
  • Tests: 19 new tests, all failing on 6d5047d; 393 agent-guards and common tests pass on the head. The merge chain merges only when fork-ci-result is green on this head.

🤖 Generated with Claude Code

@scuttletoby
scuttletoby merged commit 50b5d20 into main Nov 22, 2026
30 checks passed
scuttletoby added a commit that referenced this pull request Nov 28, 2026
…G4) (#847)

* fork-kit/agent-guards: the machine's agent guard hooks as a kit (#834 G4)

Five Claude Code hooks that guard every agent on a shared machine, as one kit with one
installer, facts from the machine file and the same messages and exit codes as before:

- actions-disable-guard (PreToolUse Bash): no disabling of workflows, Actions or branch
  protection; fails closed (a missing or failing hook refuses, and says so)
- capacity-pipe-guard (PreToolUse Bash|Monitor): no pipe out of a capacity check
- memory-index-guard (Pre/PostToolUse): the auto-memory index stays inside its budget
- bg-guard (Stop): no stop while a background Bash command still runs
- agent-slots (UserPromptSubmit, Stop): slot and ready-queue context for orchestrators

The others fail open with a visible line. `agent-guards check` runs each wired command
with a case it must refuse and one it must pass; `--settings` writes a managed settings
drop-in. Shared bootstrap and kit_install contract tests cover the new kit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: lens round 1 fixes for G4a

- actions-disable-guard and capacity-pipe-guard match Bash|Monitor; the
  memory-index after-call check matches Monitor too; check reports a
  guard wired for Bash only as missing.
- The owner's approval is a root-owned file with the hash of a one-time
  code (agent-guards approve); the session variable is no longer read,
  since nested sessions inherited it.
- Refuse starting a nested session without this machine's hooks
  (claude --bare/--safe-mode, CLAUDE_CODE_SIMPLE, codex).
- The closed hook sets onFailure block; an empty guard file refuses.
- A ruleset set to evaluate is refused like disabled.
- Each hook reads only its own part of the machine file section; bad
  keys and refuseScripts rows are dropped one by one and named to the
  agent; self-check does the strict check.
- Uninstall refuses while a foreign settings file names a hook or an
  older session runs; rollback is --no-settings.
- check --settings as root reads only a root-owned file; check runs
  hooks under a temporary HOME; self-check checks links, an open
  approval and passwordless ways to root.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: GraphQL ruleset update with EVALUATE in a variable is refused (lens B r2 minor 1)

The off word of updateRepositoryRuleset was looked for in canon() text, which blanks text with no cue
word, so `-F e=EVALUATE` (or a JSON variables block) was '' before OFF_WORD saw it. It is now read
without the cue words, as the REST ruleset body already was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: an owner approval passes one command, in one folder, once (lens B r2 major 2)

`sudo agent-guards approve --command '<cmd>' [--cwd DIR]` now stores the hash of the
normalised command and the folder next to the code's hash (approval file version 2).
The guard passes only that command, ending in the marker, run in that folder, and
records the use in its state folder (O_EXCL link; the same tool_use_id passes again),
so the approval is used up. A code seen in a transcript, the app database or ps opens
no other command. A version 1 file counts as no approval.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: refuse hookless agent sessions by path, package and wrapper, and say what the guards are not (lens B r2 major 1)

A list of strings cannot be complete, so this does both things the review asked for:

(a) Wider detection where it is cheap and reliable. claude and codex now count by name, by their real
program path (.../claude/versions/<v>, the @anthropic-ai/claude-code and @openai/codex packages), as a
link to or a copy of the installed program, through npx, bunx, pnpm dlx, npm exec, bun x and
`node <their cli>`, behind `$(which claude)`, and inside python -c, node -e, perl -e, at, systemd-run
and the other wrappers already read for gh. CLAUDE_CODE_SIMPLE counts in the command, through env -S,
in a sourced file, in BASH_ENV/--rcfile and in the user's shell start files.

(b) The threat model, written plainly in the README ("What the guards are and are not") and the guard's
docstring: the guards stop mistakes and casual misuse; they are not a boundary against a hostile agent;
the boundary is the GitHub permissions of the agent's token (a fine-grained token without Actions and
Administration write is the recommended setup).

Codex arguments are now read option by option (an option's value is not taken for the subcommand),
because the new path and package forms need it; the separate codex nits follow in their own commit.

Tests: LensSecurityR2Test.test_r2_major1_* (each fails on 6d5047d).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: codex arguments are read option by option; codex mcp passes (lens A r2 nit)

`codex -m o3 exec x` is now refused as `codex exec` (the option's value is no longer taken for the
subcommand), `codex mcp list` (MCP setup, no session) passes, and `npx -y @openai/codex exec x` is refused
(the package form came with the major-1 commit). `codex mcp-server` stays refused.

Test: LensSecurityR2Test.test_r2_nit_codex_arguments_name_the_right_subcommand_mcp_passes_npx_refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: uninstall finds sessions by program path, refuses inside a hooked session, remembers hand-wired entries (lens B r2 minor 2, lens A r2 minors 1 and 2)

- Sessions are found by the real path of their program (/proc/<pid>/exe: the native build in
  .../claude/versions/<v> under any name, the @anthropic-ai/claude-code script node runs through any
  link, an installed `claude`), not by the process name alone.
- The uninstall's own ancestors are no longer skipped: run from inside a Claude Code session that has
  the hooks, it refuses and says to run it from a terminal.
- A refusal for a hand-wired entry is remembered (/etc/agent-guards/hand-wired-seen.json, removed with
  /etc/agent-guards); the next run then counts every session older than itself, as does a run where the
  drop-in was never on. A broken record counts as seen now.
- The project .claude/settings*.json of each running session's working folder (and the folders above
  it) is searched too.

Tests: Install.test_r2_minorB2_*, test_r2_minorA1_*, test_r2_minorA2_* and test_r2_state_* (each fails on
6d5047d).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: README names the first Claude Code that honours onFailure, and how often a machine-file note shows (r2 nits)

- onFailure: "block" is honoured from Claude Code 2.1.295 on; older versions ignore it and let a
  failed or timed-out hook's call run (lens B r2 nit 1).
- A broken part of the machine file is named on every call the hook handles, once per hook with a
  problem, so a Bash call can carry it up to three times: kept loud on purpose, now said in the README
  (lens A r2 nit).
- The --safe-mode refusal is kept, with its reason in the README since the major-1 commit: safe mode
  runs managed hooks but not hooks wired by hand in user settings (lens B r2 nit 2).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: uninstall reads the boot time only when a Claude Code session runs (follow-up to the session-check commit)

The session check now runs on every uninstall, so it must not refuse for a /proc/stat it does not need:
the boot time is read only once a Claude Code process is found, and an unreadable process list still
refuses with "cannot be read". Found by the shared fork-kit/common/tests/kit_install.test.py run (its
fake /proc has no stat file).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
scuttletoby added a commit that referenced this pull request Nov 28, 2026
…G4) (#847)

* fork-kit/agent-guards: the machine's agent guard hooks as a kit (#834 G4)

Five Claude Code hooks that guard every agent on a shared machine, as one kit with one
installer, facts from the machine file and the same messages and exit codes as before:

- actions-disable-guard (PreToolUse Bash): no disabling of workflows, Actions or branch
  protection; fails closed (a missing or failing hook refuses, and says so)
- capacity-pipe-guard (PreToolUse Bash|Monitor): no pipe out of a capacity check
- memory-index-guard (Pre/PostToolUse): the auto-memory index stays inside its budget
- bg-guard (Stop): no stop while a background Bash command still runs
- agent-slots (UserPromptSubmit, Stop): slot and ready-queue context for orchestrators

The others fail open with a visible line. `agent-guards check` runs each wired command
with a case it must refuse and one it must pass; `--settings` writes a managed settings
drop-in. Shared bootstrap and kit_install contract tests cover the new kit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: lens round 1 fixes for G4a

- actions-disable-guard and capacity-pipe-guard match Bash|Monitor; the
  memory-index after-call check matches Monitor too; check reports a
  guard wired for Bash only as missing.
- The owner's approval is a root-owned file with the hash of a one-time
  code (agent-guards approve); the session variable is no longer read,
  since nested sessions inherited it.
- Refuse starting a nested session without this machine's hooks
  (claude --bare/--safe-mode, CLAUDE_CODE_SIMPLE, codex).
- The closed hook sets onFailure block; an empty guard file refuses.
- A ruleset set to evaluate is refused like disabled.
- Each hook reads only its own part of the machine file section; bad
  keys and refuseScripts rows are dropped one by one and named to the
  agent; self-check does the strict check.
- Uninstall refuses while a foreign settings file names a hook or an
  older session runs; rollback is --no-settings.
- check --settings as root reads only a root-owned file; check runs
  hooks under a temporary HOME; self-check checks links, an open
  approval and passwordless ways to root.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: GraphQL ruleset update with EVALUATE in a variable is refused (lens B r2 minor 1)

The off word of updateRepositoryRuleset was looked for in canon() text, which blanks text with no cue
word, so `-F e=EVALUATE` (or a JSON variables block) was '' before OFF_WORD saw it. It is now read
without the cue words, as the REST ruleset body already was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: an owner approval passes one command, in one folder, once (lens B r2 major 2)

`sudo agent-guards approve --command '<cmd>' [--cwd DIR]` now stores the hash of the
normalised command and the folder next to the code's hash (approval file version 2).
The guard passes only that command, ending in the marker, run in that folder, and
records the use in its state folder (O_EXCL link; the same tool_use_id passes again),
so the approval is used up. A code seen in a transcript, the app database or ps opens
no other command. A version 1 file counts as no approval.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: refuse hookless agent sessions by path, package and wrapper, and say what the guards are not (lens B r2 major 1)

A list of strings cannot be complete, so this does both things the review asked for:

(a) Wider detection where it is cheap and reliable. claude and codex now count by name, by their real
program path (.../claude/versions/<v>, the @anthropic-ai/claude-code and @openai/codex packages), as a
link to or a copy of the installed program, through npx, bunx, pnpm dlx, npm exec, bun x and
`node <their cli>`, behind `$(which claude)`, and inside python -c, node -e, perl -e, at, systemd-run
and the other wrappers already read for gh. CLAUDE_CODE_SIMPLE counts in the command, through env -S,
in a sourced file, in BASH_ENV/--rcfile and in the user's shell start files.

(b) The threat model, written plainly in the README ("What the guards are and are not") and the guard's
docstring: the guards stop mistakes and casual misuse; they are not a boundary against a hostile agent;
the boundary is the GitHub permissions of the agent's token (a fine-grained token without Actions and
Administration write is the recommended setup).

Codex arguments are now read option by option (an option's value is not taken for the subcommand),
because the new path and package forms need it; the separate codex nits follow in their own commit.

Tests: LensSecurityR2Test.test_r2_major1_* (each fails on 6d5047d).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: codex arguments are read option by option; codex mcp passes (lens A r2 nit)

`codex -m o3 exec x` is now refused as `codex exec` (the option's value is no longer taken for the
subcommand), `codex mcp list` (MCP setup, no session) passes, and `npx -y @openai/codex exec x` is refused
(the package form came with the major-1 commit). `codex mcp-server` stays refused.

Test: LensSecurityR2Test.test_r2_nit_codex_arguments_name_the_right_subcommand_mcp_passes_npx_refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: uninstall finds sessions by program path, refuses inside a hooked session, remembers hand-wired entries (lens B r2 minor 2, lens A r2 minors 1 and 2)

- Sessions are found by the real path of their program (/proc/<pid>/exe: the native build in
  .../claude/versions/<v> under any name, the @anthropic-ai/claude-code script node runs through any
  link, an installed `claude`), not by the process name alone.
- The uninstall's own ancestors are no longer skipped: run from inside a Claude Code session that has
  the hooks, it refuses and says to run it from a terminal.
- A refusal for a hand-wired entry is remembered (/etc/agent-guards/hand-wired-seen.json, removed with
  /etc/agent-guards); the next run then counts every session older than itself, as does a run where the
  drop-in was never on. A broken record counts as seen now.
- The project .claude/settings*.json of each running session's working folder (and the folders above
  it) is searched too.

Tests: Install.test_r2_minorB2_*, test_r2_minorA1_*, test_r2_minorA2_* and test_r2_state_* (each fails on
6d5047d).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: README names the first Claude Code that honours onFailure, and how often a machine-file note shows (r2 nits)

- onFailure: "block" is honoured from Claude Code 2.1.295 on; older versions ignore it and let a
  failed or timed-out hook's call run (lens B r2 nit 1).
- A broken part of the machine file is named on every call the hook handles, once per hook with a
  problem, so a Bash call can carry it up to three times: kept loud on purpose, now said in the README
  (lens A r2 nit).
- The --safe-mode refusal is kept, with its reason in the README since the major-1 commit: safe mode
  runs managed hooks but not hooks wired by hand in user settings (lens B r2 nit 2).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: uninstall reads the boot time only when a Claude Code session runs (follow-up to the session-check commit)

The session check now runs on every uninstall, so it must not refuse for a /proc/stat it does not need:
the boot time is read only once a Claude Code process is found, and an unreadable process list still
refuses with "cannot be read". Found by the shared fork-kit/common/tests/kit_install.test.py run (its
fake /proc has no stat file).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@scuttletoby
scuttletoby deleted the fork/kit-agent-guards branch November 29, 2026 20:12
scuttletoby added a commit that referenced this pull request Nov 30, 2026
…port) (#1174)

* pc-agents tests: fake processes get PIDs no real process can have (#783)

update.test.py's fake work process had PID 4002, while T3's main PID in the
fake distro is a real one: the fake systemctl's own ($$). The kit skips T3's
main PID as T3 itself, so when the kernel gave that systemctl PID 4002 (on a
fresh CI machine, where PIDs are still near 4000 when this file's first test
runs), the work read as T3, nothing was busy, and the cut rollback finished
instead of waiting for a quiet point. Not a timing race, and not the kit: real
PIDs are unique.

The fake processes now take PIDs above Linux's PID_MAX_LIMIT (2^22), and
process() refuses any lower PID, so a test cannot bring the collision back.

Fixes #766

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork seams: announce the t3_environment_read facts lines (placement P3, step 1) (#779)

List only (step 1 of "Adding a seam line"). Placement design row P3 (facts out)
makes t3_environment_read return this machine's facts beside upstream's fields:
hostResources (the result field of upstream PR #34293) and the fork's placement
(labels, available and reason, running agents, slots free, memory floor, facts
time). The logic lives in the fork file apps/server/src/fork/environmentFacts.ts;
each of upstream's two environment toolkit files takes its import and one line.

- environment/handlers.ts: the read spreads EnvironmentFacts.read into its result.
- environment/tools.ts: the success schema takes EnvironmentFacts.ResultFields
  (both optional, so an older linked machine that leaves them out still decodes).

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Fork seams: list slotObserve as a fork file (dynamic slots D4, step 1) (#788)

packages/shared/src/slotObserve.ts and its test came with the slot gate's
observe mode; upstream does not have them, but the name does not mark them as
fork files, so a pull request's seam check takes them for upstream files.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fix(secret-sweep): a reset run's re-run goes on from its own record; gates held by behaviour (#703) (#782)

Follow-ups to the sweep record after #720 (its lens B minors 1-5):
- A re-run of a reset_record run reads its own first attempt's record
  (written after the reset) and no older run's; without one, the empty
  record; a failed read of it keeps nothing, so attempt 1's stays.
- A re-run reads its own run only in a run of fork-secret-sweep.yml
  (GITHUB_WORKFLOW_REF), not in another workflow's run.
- Tests: a failed read, then a failed runs lookup or the time limit,
  keeps no partial record (each gate alone now goes red when removed);
  a contract ties the 20-minute lookup limit to the job's time-out.
- fork-secret-sweep.yml: a sweep that runs during a reset run undoes it.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork-kit/review: general review skill, adoption guide, gate comment format and eval harness (#790)

A new kit folder with the general review rules a project adopts instead of keeping its own copy:
- SKILL.md: lenses picked by changed path from the repo's `review` config (the gate's own judge), the state
  question every time, two independent lenses for critical paths and one for normal, at most two lens rounds
  and then the orchestrator checks the fix diff, minors into one follow-up issue, root-cause fixes, attacks
  that leave failing tests.
- REVIEW.md: how a project adopts it (review block in shadow first, lens prompt files, the gate, kit settings).
- COMMENTS.md: the lens comment format, every example stated with how the gate reads it; a test feeds each
  example through the gate's real parser, so the doc cannot drift.
- lib/review_kit.py: `plan` (weight, lenses, runners, rounds from the gate's rules and the kit settings),
  `check` (how the gate reads a comment, plus a state line), `doc` (the doc check).
- lib/review_eval.py and eval/: the model and effort eval, every project fact from one config file.

Runners are kit settings with defaults (.github/review-kit.json), not rules text. No change to fork-ci.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* placement P5: pure rule engine, hard rules H1 to H9 and upstream's rank (#787)

* placement P5: pure rule engine, hard rules H1 to H9 and upstream's rank

A pure function in packages/shared that picks the machine a delegated
task runs on: the nine hard rules of the placement design, each with a
plain reason, then upstream's load-balancing score for the order. No I/O,
no server wiring, no setting: P2, P3 and P6 map into its plain types.

Upstream's score stays in packages/client-runtime/src/load-balancing.ts,
unchanged. Moving it would change upstream lines (and grow the pending
packages/shared/package.json), so the engine calls it instead.

Table tests for every rule (pass and fail with its reason) and for every
row of design section 7 that needs no I/O.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* placement P5: fix round from the #787 reviews

- A named machine without facts now meets every rule that needs no facts:
  H1, H3, H7 (the pick-time lookup, not a fact; a lookup that did not run
  fails) and H9 (a placed child no longer places onward through it).
- Facts fail closed on NaN, infinite or negative numbers: cores, total and
  free memory, receipt time (counts as too old), free slots, memory floor,
  free memory, CPU use, and the link's expiry time. Each has a plain reason.
- H3 passes only known modes, so an unknown access value or an unresolved
  task mode is refused.
- Labels, needs and never groups are compared trimmed and lower-cased,
  blanks and repeats dropped (canonicalLabels, for P2 to store the same
  way). A blank need is never met; a blank group member is dropped.
- At the memory floor is available, as the slot gate and P3. A floor of 0
  keeps nothing back.
- Duplicate machine ids give a plain refusal.
- The unranked reason names a weight word this build does not know, and
  says "free memory 5 % or less" only when that is the cause.
- Comments match P3's slot answer; the module header repeats the P6
  follow-up.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Review rules: T3 side of findings, scans and rounds on shared vectors (#781)

* Review rules: T3 side of findings, scans and rounds on shared vectors

A pure TypeScript copy of the CI gate's review rules (path plan, lens
comment headers and scan, findings, rounds) under
apps/server/src/fork/reviewRules, so T3 tools and the gate agree. Both
sides replay review.vectors.json, which gains findings, scans and rounds
sections; each side fails on a section or field it does not run. The
Python findings tables move into the vectors file (one source).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Review rules: port lens_problem, linear-time table rows, fork-owned vectors

- fork-owned-paths: the shared review vectors and the lens corpus are not
  fork-owned, so a change to the gate and its vectors runs the server's
  review-rules test (its Lint check reads them).
- lensComment.ts ports lens_problem: a report whose first line is a valid
  header but which holds a second lens header (quoted, fenced, plain or
  loose) reads nothing, exactly as the gate judges it. 18 new shared scan
  vectors, generated from the gate's answers.
- Gate and TS copy: a table row is plain-folded once per row and the
  "first non-empty cell after j" is one backward pass, so a wide row reads
  in linear time (was quadratic in cells). Same answers; timing tests on
  both sides.
- Gate: a number reference past int's 4,300-digit limit no longer raises
  in html.unescape; it reads as its value (or U+FFFD past Unicode), as the
  TS copy already did. Two shared vectors.
- README: how a vector is made.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork-ci: review rules guide "release, pin, then config" and gate caller notes (#778)

* fork-ci: review rules guide "release, pin, then config" and gate caller notes

The pr-queue README gets one section on turning the review rules on: the
release, the pin in every caller, the config in shadow, reading the shadow
rows, enforce, roll back, and what each half-way state does. The gate caller
example names the pull_request_target policy and when the required-lenses
input may be emptied. The release notes list #740 (findings, rounds,
override_authors) for the first release after ci/v20.

review_guide.test.py ties the guide to the code: links resolve, the steps
keep their order, the release names match the tags, the quoted summary rows
are what head_check writes, and the half-way states behave as described.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-ci: review rules guide: owner step, the empty input's floor, and tests tied to the guide

Fix round for the two reviews of this pull request:
- the two states only an owner gets out of (input emptied under shadow, a ci/v14
  gate meeting the block) now say so, with the owner step: revert by hand, then
  dispatch the backfill; a gate on ci/v15+ refuses the block pull request itself
- emptying required-lenses drops the one-lens floor: said in step 5 and the
  example caller, with a rule that keeps AGENTS.md/CLAUDE.md at one lens
- the enforce pull request does not need the critical lenses yet; the pin back
  is a review rule; arm nothing between enforce and the backfill
- the pin step names actions/pinned pin configs; step 4 lists unreadable lens
  comments and the findings row's approach and findings: false parts
- tests: releases checked against the ci/vN tags where the clone has them, each
  half-way test reads the guide's words, the never-failing same-inputs test is
  gone, merged-config refusal tested on a throwaway repository

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* review guide test: declare the two tag-only ReleaseTags tests as may-skip

CI checks out without the ci/vN tags, so these two skip there; fork-ci now
requires every skip to be declared.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork contracts: pin review_guide's two tag-only ReleaseTags skips (MAY_SKIP)

The review guide test declares two `may skip` lines (ReleaseTags needs the
ci/vN tags, which CI's checkout does not fetch), but the pinned table was not
changed with them, so the record check found a skip set it did not pin.
The LauncherAsRoot entries were already equal on both sides.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Model policy: an effort must be under the id the row's driver reads, on both sides of a link (#780) (#793)

* Model policy: an effort must be under the id the row's driver reads, on both sides of a link (#780)

A pick whose effort sat only under an id the running driver does not read
(an ACP `thought_level` for a Claude row, `reasoning` for Claude, `effort`
for an ACP agent) counted as naming an effort, so the driver ran its own
default level unchecked. Each row with efforts now needs the effort under
its driver's own id: the fixed id of a built-in driver, else the control
the checking machine's own catalog marks for the model on that driver's
instances. A driver whose id is not known there refuses (fail closed).
The receiving machine checks a linked agent's pick with its own catalog;
the sending machine checks every row's driver with its catalog.

Minors: a remote pick reads a catalog's ultracode default both ways and
gets the full-id alias hint; Settings reads each machine's lists apart,
flags names Claude Code resolves by itself, and reads an instance's
catalog effort control for its marks; tests for "an id is never an
alias"; a stale test comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Model policy: refuse an option the policy cannot read, keep the guard's driver ids in step (#793 review)

- While a policy is on, a pick may name only options this machine's model list
  describes for the model (the instance's list; any list here for a call sent to
  a linked machine), effort ids the policy reads, or ultracode. A driver can still
  apply any other option after the checked ones: Kiro's effortLevel, Grok's native
  thought_level, an ACP agent's hidden _t3/session-mode, or a model option written
  after the model. Enforce refuses it with the fix; advise reports it.
- The "effort id not known here" refusal now says how to fix it (and drops the
  "a acpRegistry" typo).
- The model guard's sync test compares the server's driver effort ids with the
  guard's DRIVER_EFFORT_IDS entry for entry, both ways.
- Docs: the "a second effort option cannot hide a higher effort" sentence is now
  true, and says how.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork seams: announce the Codex MCP profile lines (MCP profiles part 5, step 1) (#801)

Announces the two lines in CodexAdapterV2.ts that wrap its app-server
client factory with apps/server/src/fork/codexMcpProfile.ts. No code.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork seams: announce the tool_search filter lines (MCP profile design PR 4, step 1) (#806)

Step 1 of "Adding a seam line" in docs/fork/updates.md: the list only,
no code. A new entry for apps/server/src/mcp/McpToolExposure.ts with
"added": [] and two announced lines: the import of searchableT3Tool from
fork/mcpT3ToolFilter.ts, and one .filter(searchableT3Tool) step in
tool_search's ranking chain. The code follows on its own branch.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork seams: announce the unsigned macOS ad-hoc signing line (#822, step 1) (#832)

List only. Announces the one scripts/build-desktop-artifact.ts line that sets identity "-" and the
sign hook scripts/fork-codesign.cjs for macOS builds without signing secrets; the pull request
that closes #822 adds it.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fix(server): a child that already exited keeps its exit code when its stdin write breaks (#840)

The process runner writes a program's stdin while the program starts. A program that exits at
once (the handoff's missing program under `timeout` exits 127) can close the pipe before that
write, which then fails with EPIPE. The runner reported that as a stdin error ("its output could
not be read") and dropped the exit code, so the handoff test failed in a few CI runs of a hundred.

A broken pipe on stdin is now ignored: the exit code and output say how the program ended. Any
other stdin error is still an error. The check lives in fork/processRunnerFork.ts, with the fork's
output-tail collector moved there too, so processRunner.ts's pending ceiling drops from 35 to 8.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* placement P2: placement and placementNeeds setting contracts (#798)

* fork placement P2: placement and placementNeeds setting contracts

`placement` (mode off/advise/enforce, labels, factsCommand, never groups,
weights per linked machine) and `placementNeeds` (server value, and a
project override), added the way the fork's other settings are: fields,
patch fields, patch rules and pin rows in forkSettings.ts/forkDefaults.ts.

- An old or empty settings file reads as off with no needs.
- A bad placement value reads as off with the reason in `problem`; the
  person's text is kept in `unreadable` and written back until the key
  is saved (as modelPolicy). The rest of the file still loads.
- A save is strict (bad field or unknown key refused); a field left out
  keeps its value; a save over a kept unreadable value starts from off.
- Both keys are person-only (derived); a project's needs are kept when an
  older client's save leaves them out, and only null clears them.
- A managed policy locks placement as a whole value.

Contracts only: nothing reads the settings yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork placement P2: fail closed on bad placementNeeds, whole saves over bad placement

- A bad placementNeeds (server or project) now reads as broken: the work fits
  no machine (readPlacementNeeds gives the plain reason), the problem is kept,
  and the person's text is written back unchanged by other saves until the
  key is saved. A project save may send the kept text back only unchanged.
- Over an unreadable placement, a save that names only some fields is
  refused ("placement is not valid; save the whole setting"); a whole save
  replaces it.
- factsCommand must be a full path on the server's OS (playtest's check):
  a save of another OS's path is refused, and one in the file reads as off,
  kept, with its problem. Control characters are refused.
- Labels are stored trimmed, lower-cased and without repeats (so
  ["GPU", "gpu"] is no never group); weight keys with spaces are refused.
- Tests for each, a policy lock row for placementNeeds, and the docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork placement P2: read factsCommand on this OS where placing reads it

The load and normalize lines added to upstream's serverSettings.ts are
gone (no pinned seam line runs after a save's normalize, so the same
result could not go through one). Placement code now reads placement
through apps/server/src/fork/placementRead.ts (readPlacementForThisOs):
a factsCommand this OS cannot run reads as off, kept as written, with
its problem. The save check that refuses setting one stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork placement P2: manage placement and placementNeeds only as a whole

Main now names the fork settings that read null in one list (WHOLE_ONLY), and
the pin test requires it to match exactly. Both placement settings read a bad
value, null included, as off/unset, so both join the list: a policy locks
placement as a whole, a path inside it is refused, and the manageable-settings
list shows placement as one path instead of its fields.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork placement P2: type the server's placementNeeds patch as the settings hold it

The web settings code builds a save from part of the settings, so a held
placementNeeds value (a kept bad value included) must fit the patch type.
The patch field was typed as plain labels, which broke the web typecheck.
PlacementNeedsPatch is now typed as PlacementNeeds while its decode stays
strict: only labels are taken, and a save replaces a kept bad value whole.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork test: read the MCP profile record at once in the scheduled-task tests

A webhook run is forked and reads the record file, and these tests give
forked work a fixed number of event-loop turns. On a loaded machine a read
on Node's thread pool can outlast them ("never: the owner's task ran"), on
main as well as on branches. The service in these tests now reads whole
files synchronously, so a run takes the same number of turns on any machine.
With the thread pool kept busy the test failed before and passes now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork placement P2: check only placementNeeds in the patch-type test

Since the merge of main, a whole Partial<ServerSettings> no longer fits a
patch (another field is nullable in settings only). The test checks the
placementNeeds field it is about.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* feat(playtest): the playtest MCP tool (start, push, status, end) (#809)

* feat(playtest): add the playtest MCP tool (start, push, status, end)

One tool in the waits toolkit over the playtest service. The thread is the
caller's own, from its MCP credential; the tool takes no thread and no
setting. Refusals (playtest off, busy, no session) come from the service
with what to do next. Docs: playtest.md gains the tool section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(fork): list the playtest tool in FORK_CHANGES (#809)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(playtest): own tool group; start and push need a full-access thread (#809)

- `playtest` is its own MCP tool group (MCP_T3_TOOL_GROUPS gains "playtest";
  MCP_T3_TOOL_OWN_GROUPS pins the tool in the waits toolkit to it), so a
  profile that keeps `waits` does not get it. Test: every T3 tool is in
  exactly one known group, and playtest alone in its own.
- `start` and `push` refuse a thread that is not full-access or is in plan
  mode, by the thread's modes as the server records them at each call.
  `status` and `end` stay open, so a restricted thread can release its target.
- Status tells the agent to call end for a claim cut off by a stop and for a
  release that has not worked yet.
- The waits tools share one calling-thread helper.
- `start` joins the unknown thread-argument test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork: report a linked child's pending prompts to its parent (#808 row 1) (#815)

* fork: report a linked child's pending prompts to its parent (#808 row 1)

A delegated task on a linked machine always reported
hasPendingQuestion false and pendingApproval null, so its parent never
learned the child was waiting.

- New fork route GET /api/fork/task-prompts on each machine: the open
  questions, approval and secret requests (label and reason only, never
  a value) of one of its threads. Link token only.
- task_status, delegate_task and their waits read it over the existing
  link through the fork seat remotePrompts (one spread line in the
  remote read). An unreachable or older machine reads as unknown in
  next, never as "not waiting".
- A watcher wakes the parent once per prompt, the way a local child's
  question does: it ends a blocking wait if there is one, else it queues
  one wake message, and cancels that message if the prompt is answered
  there first. Wake ids are fixed, so a restart sends no second wake.
- OrchestratorMcpService.ts is a pending file and may not gain a fork
  line: the Effect.scoped comment moves onto the (already fork) line it
  explains, which frees the line the seat takes. Still 35 fork lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* FORK_CHANGES: link #815

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork: quote a remote child's words; a wait has a prompt only while its run lasts (#815 fix round)

- Text and ids from the linked machine: ids only on a strict pattern (else
  unknown, "refused"), at most 50 prompts, a secret's label and reason
  folded to one line, capped (80/300) and quoted as the child's words.
- A secret never goes to a blocking wait; it is always a queued message.
  A question or approval handed to a wait counts only while the parent's
  run lasts; after it, one message if it is still open there.
- The receipt of a sent wake is read before a slot is taken; a machine
  that does not answer is asked once per round; "older" also names a link
  no longer accepted.
- The remote read's spread line carries its // Fork: marker (no new line).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* host tools: per-OS path layer (real-path resolve, Windows and macOS oddities) (#816)

* host tools: per-OS path layer (real-path resolve, Windows and macOS oddities)

resolveHostPath(input, {platform, fs}) follows every link, junction and
mount point to the real target and returns that path plus the compare key
the policy core will match reach kinds and secret patterns against, or a
plain refusal. Platform and file-system calls are injected, so the Windows,
macOS and Linux cases all run on any CI machine; nodeHostPathFs is the thin
real adapter. Nothing is wired yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* host tools path layer: fix round for both lenses

- Map macOS firmlinks on the walked path and on the OS answer; full list.
- Refuse /.vol, /dev, Linux /proc, /sys, the document portal, and devices,
  pipes and sockets.
- Add secretKey, always folded (full case map, NFKC, ignorables dropped);
  compareKey stays exact per OS.
- Cross-check the walk with the native realpath and refuse a different answer.
- Win32 collapses typed ".." first; cap the walk at 4096 steps.
- Header states the contract for 1.2 and 1.4.
- Tests: an independent fake file system, a regex case-fold oracle, state
  cases, real-adapter checks, and Windows/macOS tests skipped elsewhere.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* test(cleaner): one clock for report test stamps, so a mark's line stays the same (#819)

The report's mark names the last counted log line by its exact text. Three
Freed tests wrote the log twice and rebuilt an already-counted line with a
fresh stamp; when the clock crossed a second between the two, that line no
longer matched the mark, the report treated the log as trimmed and counted
the old delete again ("at least 5.0 GB (2 deletes)").

The real log is append-only, so the report code is right; the tests now
build each line once and reuse it, and stamp() reads one clock for the run.
Forcing a second boundary (time.time() moving one second per call) fails
the three old tests every time and passes the new file.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* heavy facts: per-kind fits from the kernel ledger; kit capacity evaluator and callers (#786)

* heavy facts: per-kind fits from the kernel ledger; kit capacity evaluator and callers

Dynamic slots design row D6. The kit gets a Python evaluator of the shared
capacity rule (lib/capacity_rule.py) that passes every vector and format case
the TypeScript tests read, and `heavy facts [--kind K] [--mb N]`: one free/v1
object with per-kind "fits" from a ledger read from the kernel (heavy's live
tickets plus T3's agent scopes, unlabelled = writer), a 5 s cache, the Basic
tier, unreadable signals as elevated, and per-folder reservations.
bin/t3-capacity and bin/agent-slots are thin callers of it that keep the older
output and exit codes; a facts call that is slow (5 s) or fails is never free.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* heavy facts: every ticket is a job, folders match exactly, basic tier and other users fail closed

Fix round for the two D6 reviews.

- A heavy ticket whose kind the rule does not know (tsc, gradle, a project's
  own) is the rule's unknownKinds.job, never an agent; heavy facts --kind
  with an unknown name asks for that job too.
- A reservation folder matches itself and what is below it, with or without
  a trailing '/', never a sibling sharing its first letters; its real path
  matches too. The caller's own folder is its real working folder only.
- Basic tier (no cgroup v2 or no user manager) is never free and fits 0.
  Full tier also counts every other user's heavy jobs and agent scopes
  from their user managers' cgroups; a folder that cannot be listed is
  basic. Without a cache folder every call starts "elevated".
- lib/capacity_readings.py: the shared reader's port. It runs every
  capacity-readings.json case and the "a failed reading never admits more"
  check; memory, PSI, cores and container limits now come from it, a box
  with a live piece but no folder is unreadable, a cut-short memory.stat
  owes in full.
- The cache has version 2 and a key of its settings; t3-capacity takes the
  rule's whole hold; a fill count of 2.5 asks three times, as in TypeScript.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* heavy facts: kit tests check out the capacity rule; its JSON names no kit path

The heavy kit's evaluator, its tests and heavy-install read the capacity rule
from its one source, packages/shared/src/capacity, but the sparse checkouts of
the workflows, action_tests and kit_tests jobs left that folder out, so
install.test.py and facts.test.py found no capacity-rule.json. The folder is
now in the three lists (and in the `workflows` comment that says why each app
file is there).

The "//" notes of capacity-rule.json and capacity-readings.json named the
kit's Python files, which the fork-owned-reads lint counts as app code reading
a fork-owned path; they now point to README.md beside them, which names them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork seams: announce the thread menu's MCP profile lines (MCP profile design PR 3, step 1); also restores the HO5 announcement lost in #777 (#807)

* fork seams: announce the thread menu's MCP profile lines (MCP profile design PR 3, step 1)

List only. The thread menu gets the MCP profile entry: the thread's
effective profile, and the owner's pick or clear for a client that may
change settings. Its logic and runtime are fork files
(apps/web/src/components/fork/mcpProfile/); upstream's menu files need
four lines in threadActionMenu.logic.ts and three each in
useThreadActionMenu.ts and Sidebar.tsx, announced here. The code is on a
branch pushed without a pull request until this merges.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fork seams: also restore the HO5 announcement lost in #777

The squash merge of #777 dropped every HO5 announced line from
.github/fork-seams.json. Restore them exactly as they were, inside the
same per-file entries as this PR's MCP profile lines (one key per file).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* handoff HO4: source `agent` (write turn, marker, cap, joined check) (#824)

* handoff HO4: source `agent` (write turn, marker, cap, joined check)

The old session gets one normal turn on its own thread with the
setting's instructions; its reply is part 2 of the handoff when the
turn completed, no other message joined it, the reply starts with the
marker line and is within the command source's 32 KB cap. A reply that
does not count falls back like the command source (size: parts 1, 3, 4;
idle: nothing). A stopped, failed, joined or timed-out write turn means
no handoff: the old session carries on. Fixed ids per source run, so a
run never writes or hands off twice; the write run is no turn end and
stays out of the transcript. Default stays off; no migration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* handoff HO4 fix round: write turn never lost, stopped at its timeout, quiet

- A late update of the source run, or a restart, no longer drops part 2:
  any loop that finds a write turn as the latest run carries it on to its
  handoff (fixed ids, so at most once).
- A message steered into a write turn stays in later handoffs' part 3; only
  the write turn's prompt and marked reply are left out.
- A failed or timed-out write turn at the size backstop sends parts 1, 3
  and 4 (idle: nothing), as the command source does.
- Notes lines that could pass for the message's own lines are quoted.
- T3 stops a write turn at its timeout (run.interrupt, its own reason);
  after one such stop the next size handoff uses the fallback at once.
- A completed write turn is marked quiet, as the handoff run is.
- New source `none` is the default, so a saved handoff setting keeps its
  old behaviour; `agent` only when set.
- The last reply that starts with the marker is used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* handoff command test: "could not start" without the stdin race

A missing program under `timeout` can exit before the empty stdin is
written, so the reason sometimes read as an output error. The case now
uses a spawn that fails (its project folder is gone); exit codes 126 and
127 stay covered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork-kit/gh-apps: call forms and GH_REPO check of the older per-user gh-as (#835)

* fork-kit/gh-apps: call forms and GH_REPO check of the older per-user gh-as

gh-as now also takes `gh-as NAME -- gh ...`, `--repo=`/`--app=` and `--help`, and refuses a GH_REPO in the
caller's environment that names another repository instead of silently ignoring it. New parity.test.py covers
these and the state cases: an expired, half-written or empty token cache, a killed run's temp file, config
missing or empty, two gh-mint runs at once (one mint), cache modes, and no token in any message.

Fork audit #834, item G1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/gh-apps: lens nits for the gh-as parity PR

- wrapper: a refused GH_REPO is masked before it is cut, so no start of a
  token is ever quoted; GH_HOST other than github.com is refused too
  (README says which variables are checked and which are only dropped).
- admin add-key: refuses the app name "gh" (gh-as gh -- gh ... reads it as
  the gh command, so it could not be picked by name).
- privileged gh-as: a repeated --app or --repo is a usage error, as in the
  wrapper, not last-wins.
- README: the new key is piped straight into root, never stored where an
  agent can read it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/gh-apps: root test expects the wrapper to refuse a foreign GH_HOST

The wrapper now refuses GH_HOST other than github.com, so the environment
test checks that refusal, sends the rest of the attack environment through
the wrapper, and still sends all of it (GH_HOST too) to a direct sudo call.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork release: SHA256SUMS covers the desktop files; unsigned macOS apps are ad-hoc signed last (#822) (#833)

* fork release: SHA256SUMS covers the desktop files; unsigned macOS apps are ad-hoc signed last (#822)

SHA256SUMS now lists every file a person downloads: the server archives and the desktop apps
(macOS dmg and zip, Windows exe, Linux AppImage), written in assemble after all desktop builds.

Without signing secrets electron-builder found no identity and signed nothing, so the macOS app
kept only the linker signature of Electron's executable and `codesign --verify --deep --strict`
failed on it. Unsigned macOS builds now set identity "-" with the sign hook
scripts/fork-codesign.cjs, which runs `codesign --force --deep --sign -` as electron-builder's last
change to the bundle, before the zip and dmg. A new verify_mac_signature job, which assemble waits
for, unpacks each shipped zip and dmg and runs `codesign --verify --deep --strict`.

The one line in scripts/build-desktop-artifact.ts is recorded in .github/fork-seams.json.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork release: review fixes for the desktop SHA256SUMS and ad hoc signing (#822)

- SHA256SUMS: `sha256sum --` (bare names kept) and compgen presence checks,
  so actionlint passes; a step before the upload checks every file the
  publish job uploads (less blockmaps and manifests) has a matching line.
- verify_mac_signature: no token, each dmg detached on any exit, the
  signature's Identifier/Signature/Authority in the step summary, and the
  hashes of the four checked files as an output; assemble fails when the
  macOS lines of SHA256SUMS differ from them.
- fork-codesign.cjs refuses any identity but "-" and says why entitlements
  and hardened runtime are ignored; scripts/fork-codesign.test.ts tests the
  hook and createBuildConfig's signed and unsigned macOS config.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* docs/fork/agent-rules.md + fork-ci doc-check: general agent rules, once (#874)

* docs/fork/agent-rules.md + fork-ci doc-check: general agent rules, once

docs/fork/agent-rules.md holds the agent rules that hold in every project
and on every machine, each once with a one-line why. Machine and project
facts stay in their own instruction files and config; review rules link
to the review skill instead of being copied.

fork-ci/actions/doc-check is a general port of a project's doc check:
size budgets and a no-history rule for instruction files, broken relative
links in changed Markdown, and no dated report files added. Budgets and
patterns come from an optional project config read at the base commit,
with defaults; a missing or empty config means the defaults, a broken one
exits 2.

Part of #834

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* git-clean test: doc-check is an action that runs the git check first

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork seams: announce the settled provider thread lines (#846, step 1) (#907)

List only (step 1 of "Adding a seam line"). Fixes the race behind the
flaky Kiro turn_interrupt replay test (#846): at a turn's end the ACP and
Cursor adapters cache the provider thread as active, and usage or shell
updates that arrive after the turn re-send that snapshot session-scoped,
which the server writes without a run guard. When that write lands after
the run's final idle write, the ended thread stays active.

The fix adds one override line (and a comment) after upstream's status
line in each adapter, so the cached snapshot is idle like the server's
final write, and one check in each adapter's existing test. No upstream
line changes, so no lost-line count is needed.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fix(acp,cursor): a turn's cached provider thread is settled, so late updates cannot mark it busy (#909)

* fork seams: announce the settled provider thread lines (#846, step 1)

List only (step 1 of "Adding a seam line"). Fixes the race behind the
flaky Kiro turn_interrupt replay test (#846): at a turn's end the ACP and
Cursor adapters cache the provider thread as active, and usage or shell
updates that arrive after the turn re-send that snapshot session-scoped,
which the server writes without a run guard. When that write lands after
the run's final idle write, the ended thread stays active.

The fix adds one override line (and a comment) after upstream's status
line in each adapter, so the cached snapshot is idle like the server's
final write, and one check in each adapter's existing test. No upstream
line changes, so no lost-line count is needed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(acp,cursor): a turn's cached provider thread is settled, so late updates cannot mark it busy

Fixes #846. At a turn's end the ACP adapter (Kiro, Kimi, Grok, fx and the
ACP registry agents) and the Cursor adapter cache the provider thread as
active. Usage or session info that Kiro sends after the cancelled prompt
(and Cursor's background-shell updates) re-send that cached snapshot as a
session-scoped update, which the server writes without a run guard. When
that write lands after the run's final idle write, the ended thread stays
active for good; the turn_interrupt Kiro replay test caught it now and
then.

The cached snapshot is now settled (idle, or error for a broken thread)
like the server's final write. One override line after upstream's status
line in each adapter, announced in .github/fork-seams.json.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork CI: each listed Python test declares its format, judged by it alone (#702) (#784)

- .github/fork-ci-tests.txt: a Python test's line ends in "unittest" or "ok lines". A Python
  line with neither is refused with what to write; either word on a non-Python test is refused.
  All 87 listed Python tests now say theirs (78 unittest, 9 ok lines).
- countTests: a Python test with no declared format counts nothing; it is never read as either.
- fork-contracts.test.py: its record fixtures pass the format the list would give.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* MCP profiles: Settings section and thread pick logic (design PR 3) (#804)

* MCP profiles: Settings section, thread picks and the menu entry's logic (design PR 3)

Settings → Fork gets its MCP profiles section (McpProfileSettings.tsx):
the built-ins all and t3-only read-only; add, edit and delete named
profiles (servers all or a list, t3Tools all or a list of the shared
MCP_T3_TOOL_GROUPS); the default profile and the sub-agent rule with the
usual project-override control; each thread's pick, changed or cleared.

Every patch names only what it changes: one mcpProfiles entry, or one
thread's mcpThreadProfiles key (null clears), and a pick or clear that
changes nothing writes nothing. A built-in name cannot be taken; a
profile something names cannot be deleted (the panel says who, and offers
to clear the thread picks). An entry with fields from a newer build shows
as broken, never as a profile; one with unknown tool groups as from a
newer version; neither is editable. Rows follow ForkRow's lock, so a
client that cannot write settings gets inert controls.

The pure resolver moves to packages/contracts/src/mcpProfileResolve.ts
(re-exported by the server's fork/mcpProfile.ts, unchanged behaviour) so
the app reads entries by readMcpProfileEntry and shows a thread's
effective profile from resolveMcpProfile, a child's cut down to its
parent's. The thread menu entry's logic is in
components/fork/mcpProfile/threadMcpProfile.logic.ts; wiring it into the
upstream thread menu needs seam lines, announced separately.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* MCP profiles: read the client's thread shells (delegatedFrom null) and a carried profile

The app's thread shells hold delegatedFrom: null for a thread nobody
delegated; the menu logic now takes that shape. Test: a task another
machine delegated is cut down to the profile it carried, and a shell
with delegatedFrom null is a top-level thread.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* MCP profile settings: add a thread pick only with a chosen profile

- "Add thread" opens a form with the thread id and a profile picker next
  to it; one save writes that thread's key with the chosen profile.
  Nothing is written for a typed id alone, on Enter without a profile,
  or on cancel.
- The form and each pick row say what the pick gives the thread, and
  warn when that is more than the parent's cut-down set (a pick is never
  cut down to the parent's).
- The server refuses deleting a profile that the default, the sub-agent
  rule, a project or a thread pick still names, with the same rule and
  wording source as the panel (mcpProfileUses).
- "Clear the thread picks that use it" checks the lock of
  mcpThreadProfiles, the setting it writes.
- A blank pick hand-edited into settings.json shows as broken (it is
  ignored) and can be cleared.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork-kit/heavy: machine-file holds for heavy facts / t3-capacity (stacked on #786) (#843)

* heavy facts: per-kind fits from the kernel ledger; kit capacity evaluator and callers

Dynamic slots design row D6. The kit gets a Python evaluator of the shared
capacity rule (lib/capacity_rule.py) that passes every vector and format case
the TypeScript tests read, and `heavy facts [--kind K] [--mb N]`: one free/v1
object with per-kind "fits" from a ledger read from the kernel (heavy's live
tickets plus T3's agent scopes, unlabelled = writer), a 5 s cache, the Basic
tier, unreadable signals as elevated, and per-folder reservations.
bin/t3-capacity and bin/agent-slots are thin callers of it that keep the older
output and exit codes; a facts call that is slow (5 s) or fails is never free.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* heavy facts: every ticket is a job, folders match exactly, basic tier and other users fail closed

Fix round for the two D6 reviews.

- A heavy ticket whose kind the rule does not know (tsc, gradle, a project's
  own) is the rule's unknownKinds.job, never an agent; heavy facts --kind
  with an unknown name asks for that job too.
- A reservation folder matches itself and what is below it, with or without
  a trailing '/', never a sibling sharing its first letters; its real path
  matches too. The caller's own folder is its real working folder only.
- Basic tier (no cgroup v2 or no user manager) is never free and fits 0.
  Full tier also counts every other user's heavy jobs and agent scopes
  from their user managers' cgroups; a folder that cannot be listed is
  basic. Without a cache folder every call starts "elevated".
- lib/capacity_readings.py: the shared reader's port. It runs every
  capacity-readings.json case and the "a failed reading never admits more"
  check; memory, PSI, cores and container limits now come from it, a box
  with a live piece but no folder is unreadable, a cut-short memory.stat
  owes in full.
- The cache has version 2 and a key of its settings; t3-capacity takes the
  rule's whole hold; a fill count of 2.5 asks three times, as in TypeScript.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* heavy facts: kit tests check out the capacity rule; its JSON names no kit path

The heavy kit's evaluator, its tests and heavy-install read the capacity rule
from its one source, packages/shared/src/capacity, but the sparse checkouts of
the workflows, action_tests and kit_tests jobs left that folder out, so
install.test.py and facts.test.py found no capacity-rule.json. The folder is
now in the three lists (and in the `workflows` comment that says why each app
file is there).

The "//" notes of capacity-rule.json and capacity-readings.json named the
kit's Python files, which the fork-owned-reads lint counts as app code reading
a fork-owned path; they now point to README.md beside them, which names them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/heavy: machine-file holds for heavy facts (t3-capacity), on top of the kit capacity check

Built on the kit's `heavy facts` and its thin `t3-capacity` caller (#786) instead of a second capacity
evaluator. What the older host check had that the kit's did not:

- heavy.capacity.holds in the machine file: a cgroup outside the user managers (a CI runners' slice) that
  is in use keeps its budget less its use, as a reservation, for every user but its own. Missing file,
  section or key: no holds; a broken one: no answer (t3-capacity NOT OK naming the key); a changed one
  is read again at once (cache key).
- The sweep and the queue accept the new `capacity` key.
- Tests for the state question: holds in use or idle, own users, missing cgroup, unreadable memory.max or
  memory.stat, machine file missing/empty/garbled/writable by others/unknown key, a changed file within
  the cache's 5 s, a reservation file cut short, a reservation whose processes are gone; one red check.

Part of #834 (G2, first half).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork-kit/review: one general review skill; tiers, failure table, nit-only check and a drift test (#845)

* fork-kit/review: one general review skill; tiers, failure table, nit-only check and a drift test

The kit's SKILL.md becomes the one general review skill, so a project keeps only its facts (review block, lens
prompts, kit settings) and a thin adapter. Merged in from the project skill: the tier table as the gate's weights,
the author's failure table, nit-only quick check, batch per area, twin lens names, focus lenses, covered rule, the
extra general lenses, and a concurrency part in the eval lens. Conflicts go to what the gate parses: the state answer
on a `state:` line and `blocker:`/`major:`/`minor:` lines.

New test (comments.test.py, SkillFormat): every report shape the skill, the eval lens and COMMENTS.md tell a lens to
write reads as a clean read with a state line through the gate's own parser; the skill's tiers match the gate's
weights and recommended min_lenses; the state question is word for word in the skill, the eval lens and REVIEW.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/review: skill matches the gate on rounds, protected paths and check exits

- A quick check is a lens read of a new head, so the gate counts it as a
  round; the skill names rounds.approach_at / approach_lens / max, how to run
  the approach lens, and that only an override by a listed override_authors
  login waives it.
- The tier table names the gate's always-critical paths (queue config, lens
  prompts, .github/workflows/**); the light row no longer says config is light.
- focus: removed (nothing reads it); twin lenses described in general terms.
- check exits 1 for a real blocker or major by design; never soften a finding.
- not a lens: also needs no read-at sha outside a quote (COMMENTS.md rule).
- Drift test reads the round keys and recommended approach_at through the
  gate's parser and judge_rounds, the protected paths from review_judge, and
  the runner defaults from review_kit.DEFAULTS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/review: the override passes a nit-only fix head, a quick check never does

The gate passes a head only when every lens's newest read names it or a newer
override covers them (lens.Review.reviewed_head). A quick check is one lens on
the fix head while the earlier lenses still name the old head, so it alone
holds the head. SKILL.md step 7 now says which head passes and that on
`nit-only: yes` the orchestrator still posts the override; COMMENTS.md says the
same. The round count says "whichever is higher", as review_round does.

Tests: a history (code at A, code r2 at B, fix C with a quick check) through the
gate's real reviewed_head and judge_rounds, pinned to the skill's words; the
protected-paths test now compares is_protected's answer with the skill's list
on every tracked file and on probe paths, so an inline rule fails it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Fix #911: a delivery refused for its profile leaves its place in line (#912)

A stored webhook delivery keeps its place in the slot gate's line from its
first, direct ask. When its worker run was refused for its MCP profile as it
started (before it reached its slot wait), the place stayed until the next
sweep, so for up to a sweep a free slot was refused to another run: that
run was stored for the worker instead of starting.

The flaky test hit this path only when the worker's run lagged behind a
fixed three worker rounds, so the widening landed before the slot wait it
meant to test. It now waits for that slot wait itself, and a new test
covers the start-time refusal, which leaves the place at once now.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Review rules T3a: lens_start plan, prompt, refusals and request ids (pure logic) (#825)

* Review rules T3a: lens_start's plan, prompt, refusals and request ids (pure logic)

New fork files next to the review-rules logic of #781. Nothing registers a tool yet.

- planLensStart: per pull request and batch plan. Required lenses come from planReview and
  requiredLenses, the round from judgeRounds (the gate's own rules), so lens_start cannot
  require fewer lenses than the gate. A lens whose newest report already read the head (or the
  same change) is not started again. A batch gives one child per lens that reads every pull
  request needing it and posts one report per pull request, each with that pull request's head.
- Refusals: rules off (unset, empty, off, unreadable), a bad call, an unknown, closed or merged
  pull request, a caller head GitHub does not name, no plan (unreadable change, no rule, a lens
  prompt not read), round past the cap, a person's override already on the head.
- confirmLensStart: just before starting, a child whose pull request moved or closed is refused.
- lensRequestId: same lens and heads = same id, in any order; fits delegate_task's 256 chars.
- The server builds the prompt: read only, the lens text, the state question word for word with
  a `state:` line, finding prefixes, report size, round and earlier reads.
- Tests replay every shared case, round and scan vector (counts checked) and answer the state
  question: same start twice, head moved, old/empty settings, round at the cap, partial batch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Review rules T3a: lens_start plans what the gate reads (fix round A+B)

- Restart every lens entry that does not name the head once anything must
  start, required or not: the gate needs every lens comment on one head.
  An entry lens_start cannot start (no header, unknown lens) is refused
  with what a person does. A newer override the gate counts is honoured.
- Read the gate's required-lenses input and the review block's mode;
  without a block the input names the lenses (built-in prompt), and an
  empty input outside enforce, a bad name or a bad mode is refused.
- Plan each pull request of a batch with its own base branch's rules.
- Earlier lens children: an ended one restarts as the next attempt
  (replaces + note), a running one is returned, never started twice.
- Repo and heads read lower-case; the approach lens runs on the approach
  runner by its role; lone-surrogate lens keys get a distinct id.
- Tests: both lens-A scenarios, a property test over every shared vector
  state (the gate's verdict, modelled from its code, passes after the plan
  is carried out, or a person must act), and a test per new refusal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Slot gate: enforce the capacity rule by default (dynamic slots D4) (#823)

* Slot gate: enforce the capacity rule by default (dynamic slots D4)

The capacity rule now decides agent starts (mode "enforce", the default when
agentSlots has no mode and is switched off):
- owed term: every agent still starting, held slot or waiter ahead owes its
  full cost, so two starts in one second both count;
- kinds from the task role: research, review and design are light, anything
  else or no role is a writer; a light agent that grows past the light cost
  counts as a writer, so a wrong role cannot hide one;
- floors (2 agents, 1 job) and derived ceilings (3 agents per core, at most 64);
- fallback to the fixed ceilings (10 agents, 4 jobs) with start costs raised
  25% per trip after an OOM kill (oom_kill in /proc/vmstat rises) or swap under
  10% free; it lifts after 10 minutes of calm, whole readings. A restart starts
  in the fallback and at "elevated"; unreadable readings are never calm.
Typed limits still apply while enabled; "mode": "fixed" turns the rule off.
The delegate_task route passes its role to the slot gate with the target.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Slot gate: fix round after lenses A and B (D4)

- floor always starts, also with failed, hung or out-of-range readings;
  after 2 minutes unread the fixed 10 counts alone
- a restart lifts on calm for this host: swap counts by trend, the first
  calm needs the margin only; a 30 s timer takes readings
- costs from the rule file (light 384, writer 768); light cost clamped
- only agent-slice OOM kills raise costs; untold kills raise at most 2;
  each calm spell lowers one raise
- basic tier (no scopes or no oom_kill) keeps the fixed 10; unread
  running agents count once as writers
- unreadable settings use the fixed limits; true counts in refusals
- tests for the held slot, the role line, no OOM counter

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Slot gate: kit evaluator follows the swap-trend rule; scheduled-run tests build the gate at START

The merge of main brought the heavy kit's Python evaluator of the capacity
rule (#786), written for the rule before this PR. This PR's rule counts swap
by its trend (pressure.swapFillingMb; calm.swapFreeAtLeastPercent gone), so
the kit read a key the shared rule no longer has (KeyError in
capacity_rule.test.py and every heavy facts call).

- lib/capacity_rule.py mirrors capacityPressure.ts and pressureOf: raw_level
  takes the last read's swap free (filling = it fell by more than
  swapFillingMb; nearly full counts only while filling; filling is never
  calm; no previous swap read = trend unknown), next_pressure keeps or starts
  the calm wait on an unknown trend but never ends it, and the kept state
  carries swapFreeMb for the next read (heavy facts' cache carries it).
  The shared capacity-vectors.json swap-trend cases and the facts carry test
  fail when any part is undone.
- capacity_rule.test.py: a kit copy of the rule from before the swap trend is
  refused by name; an empty or missing rule file raises (heavy facts then
  answers "not available", never free).
- agentSlotRoutes.test.ts: the gate's 30 s enforce sampler starts when the
  gate is built. Built at the test clock's 0, the tests' move to START ran
  every sample in the 56 years between (about 59 million): Test Server 5 hung
  until its 20 min cancel. boot now sets the clock to START first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* MCP profiles part 5: Codex threads apply their profile's outside servers (#826)

* MCP profiles part 5: Codex threads apply their profile's outside servers

Each Codex thread T3 loads on the shared app-server gets
mcp_servers.<name>.enabled = false in its own per-request config for
every server config/read lists for its folder that the profile leaves
out (launch-argument and project servers included; T3's own entries
stay). Each turn first reads the thread's live servers and refuses,
saying why and the fix, when one outside the profile is still on. A
missing or broken profile, a server list T3 cannot read, or a thread T3
cannot match is refused, never started with every server. Logic in
apps/server/src/fork/codexMcpProfile.ts; two seam lines in the Codex
adapter (announced in step 1). Remote delegation stays Claude-only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* MCP profiles part 5, fix round: check Codex-started turns, sub-agents and connectors

- Watch turn/started: a turn Codex starts on its own (a goal's next turn, a
  sub-agent's turn) gets the same check as turn/start; one that fails is
  stopped (goal paused, turn interrupted) and ends failed with the reason.
- Count Codex sub-agents as their parent's T3 thread (they copy the parent's
  loaded config, codex-rs child_config.rs), so their turns are checked too.
- Send features.apps=false when a narrowed profile leaves out codex_apps,
  which config/read never lists.
- A refused resume no longer becomes a fresh Codex session: the fallback
  start is refused once, so the history is kept.
- Tests for each, with Codex's real status words; docs updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* heavy holds: #913 follow-ups and neutral example names (#917)

- A hold cgroup that is there without a memory controller (no memory.stat)
  holds its whole budgetMb with a note, instead of nothing.
- The room a hold keeps is its budget less the RAM it uses: memory.max
  limits RAM only, so swap is left out (in use still counts swap).
- Holds in or the same as another hold's cgroup are refused (the same
  room held twice); a reservation file named like a hold gives a note.
- Tests that fail without the code: at most 8 holds (9 distinct labels),
  memory.max "max" gives no "cannot be read" note, and one mutation check
  per fix.
- Neutral example names in the reservation-folder docs and test.

Fixes #913

Co-authored-by: Claude Opus 5.5 <[email protected]>

* MCP profiles: T3 tool groups on T3's MCP server, for every provider (#827)

* MCP profiles: T3 tool groups on T3's MCP server, for every provider

MCP profile design PR 4. A profile's t3Tools now applies: one global
rule on T3's MCP server hides a T3 tool outside the calling thread's
groups from tools/list, refuses it on tools/call with a plain reason and
its fix, and keeps it out of tool_search. The groups are fixed as each
turn starts (Claude: as its query opens; other providers: the turn
check), so a running turn keeps its set and a change applies from the
next turn. A profile that cannot be worked out, or a thread T3 cannot
read, keeps only request_secret, send_to_user and tool_search.

Claude no longer refuses a profile whose t3Tools is a list, and a group
change gives its next turn a fresh process. Off Claude, a turn now
refuses only a profile that leaves out an outside server.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* MCP profiles: guard the T3 tool table against drift; a tool in no group is refused as a T3 bug

- personOnlySettings.test.ts: the T3 tool filter's table must hold exactly the toolkit folders'
  tools, each in its folder's group, and every group of MCP_T3_TOOL_GROUPS must have a tool there.
  Dropping a toolkit from the filter's hand list, or adding a group with no toolkit, fails CI.
- A tool in no group is still refused by any profile but all, but its refusal now says it is a T3
  bug to report, not a setting to change.
- docs/fork: profiles are not a sandbox (requests with no thread, such as the t3 thread CLI, are not
  filtered); the sets live per thread, not per credential.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* FORK_CHANGES: shorten the MCP profiles row so the table keeps main's widths

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: the machine's agent guard hooks as a kit (#834 G4) (#847)

* fork-kit/agent-guards: the machine's agent guard hooks as a kit (#834 G4)

Five Claude Code hooks that guard every agent on a shared machine, as one kit with one
installer, facts from the machine file and the same messages and exit codes as before:

- actions-disable-guard (PreToolUse Bash): no disabling of workflows, Actions or branch
  protection; fails closed (a missing or failing hook refuses, and says so)
- capacity-pipe-guard (PreToolUse Bash|Monitor): no pipe out of a capacity check
- memory-index-guard (Pre/PostToolUse): the auto-memory index stays inside its budget
- bg-guard (Stop): no stop while a background Bash command still runs
- agent-slots (UserPromptSubmit, Stop): slot and ready-queue context for orchestrators

The others fail open with a visible line. `agent-guards check` runs each wired command
with a case it must refuse and one it must pass; `--settings` writes a managed settings
drop-in. Shared bootstrap and kit_install contract tests cover the new kit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: lens round 1 fixes for G4a

- actions-disable-guard and capacity-pipe-guard match Bash|Monitor; the
  memory-index after-call check matches Monitor too; check reports a
  guard wired for Bash only as missing.
- The owner's approval is a root-owned file with the hash of a one-time
  code (agent-guards approve); the session variable is no longer read,
  since nested sessions inherited it.
- Refuse starting a nested session without this machine's hooks
  (claude --bare/--safe-mode, CLAUDE_CODE_SIMPLE, codex).
- The closed hook sets onFailure block; an empty guard file refuses.
- A ruleset set to evaluate is refused like disabled.
- Each hook reads only its own part of the machine file section; bad
  keys and refuseScripts rows are dropped one by one and named to the
  agent; self-check does the strict check.
- Uninstall refuses while a foreign settings file names a hook or an
  older session runs; rollback is --no-settings.
- check --settings as root reads only a root-owned file; check runs
  hooks under a temporary HOME; self-check checks links, an open
  approval and passwordless ways to root.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: GraphQL ruleset update with EVALUATE in a variable is refused (lens B r2 minor 1)

The off word of updateRepositoryRuleset was looked for in canon() text, which blanks text with no cue
word, so `-F e=EVALUATE` (or a JSON variables block) was '' before OFF_WORD saw it. It is now read
without the cue words, as the REST ruleset body already was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: an owner approval passes one command, in one folder, once (lens B r2 major 2)

`sudo agent-guards approve --command '<cmd>' [--cwd DIR]` now stores the hash of the
normalised command and the folder next to the code's hash (approval file version 2).
The guard passes only that command, ending in the marker, run in that folder, and
records the use in its state folder (O_EXCL link; the same tool_use_id passes again),
so the approval is used up. A code seen in a transcript, the app database or ps opens
no other command. A version 1 file counts as no approval.

Co-Au…
scuttletoby added a commit that referenced this pull request Nov 30, 2026
… its timer (#1157 phase 2b) (#1188)

* Model policy: an effort must be under the id the row's driver reads, on both sides of a link (#780) (#793)

* Model policy: an effort must be under the id the row's driver reads, on both sides of a link (#780)

A pick whose effort sat only under an id the running driver does not read
(an ACP `thought_level` for a Claude row, `reasoning` for Claude, `effort`
for an ACP agent) counted as naming an effort, so the driver ran its own
default level unchecked. Each row with efforts now needs the effort under
its driver's own id: the fixed id of a built-in driver, else the control
the checking machine's own catalog marks for the model on that driver's
instances. A driver whose id is not known there refuses (fail closed).
The receiving machine checks a linked agent's pick with its own catalog;
the sending machine checks every row's driver with its catalog.

Minors: a remote pick reads a catalog's ultracode default both ways and
gets the full-id alias hint; Settings reads each machine's lists apart,
flags names Claude Code resolves by itself, and reads an instance's
catalog effort control for its marks; tests for "an id is never an
alias"; a stale test comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Model policy: refuse an option the policy cannot read, keep the guard's driver ids in step (#793 review)

- While a policy is on, a pick may name only options this machine's model list
  describes for the model (the instance's list; any list here for a call sent to
  a linked machine), effort ids the policy reads, or ultracode. A driver can still
  apply any other option after the checked ones: Kiro's effortLevel, Grok's native
  thought_level, an ACP agent's hidden _t3/session-mode, or a model option written
  after the model. Enforce refuses it with the fix; advise reports it.
- The "effort id not known here" refusal now says how to fix it (and drops the
  "a acpRegistry" typo).
- The model guard's sync test compares the server's driver effort ids with the
  guard's DRIVER_EFFORT_IDS entry for entry, both ways.
- Docs: the "a second effort option cannot hide a higher effort" sentence is now
  true, and says how.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork seams: announce the Codex MCP profile lines (MCP profiles part 5, step 1) (#801)

Announces the two lines in CodexAdapterV2.ts that wrap its app-server
client factory with apps/server/src/fork/codexMcpProfile.ts. No code.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork seams: announce the tool_search filter lines (MCP profile design PR 4, step 1) (#806)

Step 1 of "Adding a seam line" in docs/fork/updates.md: the list only,
no code. A new entry for apps/server/src/mcp/McpToolExposure.ts with
"added": [] and two announced lines: the import of searchableT3Tool from
fork/mcpT3ToolFilter.ts, and one .filter(searchableT3Tool) step in
tool_search's ranking chain. The code follows on its own branch.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork seams: announce the unsigned macOS ad-hoc signing line (#822, step 1) (#832)

List only. Announces the one scripts/build-desktop-artifact.ts line that sets identity "-" and the
sign hook scripts/fork-codesign.cjs for macOS builds without signing secrets; the pull request
that closes #822 adds it.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fix(server): a child that already exited keeps its exit code when its stdin write breaks (#840)

The process runner writes a program's stdin while the program starts. A program that exits at
once (the handoff's missing program under `timeout` exits 127) can close the pipe before that
write, which then fails with EPIPE. The runner reported that as a stdin error ("its output could
not be read") and dropped the exit code, so the handoff test failed in a few CI runs of a hundred.

A broken pipe on stdin is now ignored: the exit code and output say how the program ended. Any
other stdin error is still an error. The check lives in fork/processRunnerFork.ts, with the fork's
output-tail collector moved there too, so processRunner.ts's pending ceiling drops from 35 to 8.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* placement P2: placement and placementNeeds setting contracts (#798)

* fork placement P2: placement and placementNeeds setting contracts

`placement` (mode off/advise/enforce, labels, factsCommand, never groups,
weights per linked machine) and `placementNeeds` (server value, and a
project override), added the way the fork's other settings are: fields,
patch fields, patch rules and pin rows in forkSettings.ts/forkDefaults.ts.

- An old or empty settings file reads as off with no needs.
- A bad placement value reads as off with the reason in `problem`; the
  person's text is kept in `unreadable` and written back until the key
  is saved (as modelPolicy). The rest of the file still loads.
- A save is strict (bad field or unknown key refused); a field left out
  keeps its value; a save over a kept unreadable value starts from off.
- Both keys are person-only (derived); a project's needs are kept when an
  older client's save leaves them out, and only null clears them.
- A managed policy locks placement as a whole value.

Contracts only: nothing reads the settings yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork placement P2: fail closed on bad placementNeeds, whole saves over bad placement

- A bad placementNeeds (server or project) now reads as broken: the work fits
  no machine (readPlacementNeeds gives the plain reason), the problem is kept,
  and the person's text is written back unchanged by other saves until the
  key is saved. A project save may send the kept text back only unchanged.
- Over an unreadable placement, a save that names only some fields is
  refused ("placement is not valid; save the whole setting"); a whole save
  replaces it.
- factsCommand must be a full path on the server's OS (playtest's check):
  a save of another OS's path is refused, and one in the file reads as off,
  kept, with its problem. Control characters are refused.
- Labels are stored trimmed, lower-cased and without repeats (so
  ["GPU", "gpu"] is no never group); weight keys with spaces are refused.
- Tests for each, a policy lock row for placementNeeds, and the docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork placement P2: read factsCommand on this OS where placing reads it

The load and normalize lines added to upstream's serverSettings.ts are
gone (no pinned seam line runs after a save's normalize, so the same
result could not go through one). Placement code now reads placement
through apps/server/src/fork/placementRead.ts (readPlacementForThisOs):
a factsCommand this OS cannot run reads as off, kept as written, with
its problem. The save check that refuses setting one stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork placement P2: manage placement and placementNeeds only as a whole

Main now names the fork settings that read null in one list (WHOLE_ONLY), and
the pin test requires it to match exactly. Both placement settings read a bad
value, null included, as off/unset, so both join the list: a policy locks
placement as a whole, a path inside it is refused, and the manageable-settings
list shows placement as one path instead of its fields.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork placement P2: type the server's placementNeeds patch as the settings hold it

The web settings code builds a save from part of the settings, so a held
placementNeeds value (a kept bad value included) must fit the patch type.
The patch field was typed as plain labels, which broke the web typecheck.
PlacementNeedsPatch is now typed as PlacementNeeds while its decode stays
strict: only labels are taken, and a save replaces a kept bad value whole.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork test: read the MCP profile record at once in the scheduled-task tests

A webhook run is forked and reads the record file, and these tests give
forked work a fixed number of event-loop turns. On a loaded machine a read
on Node's thread pool can outlast them ("never: the owner's task ran"), on
main as well as on branches. The service in these tests now reads whole
files synchronously, so a run takes the same number of turns on any machine.
With the thread pool kept busy the test failed before and passes now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork placement P2: check only placementNeeds in the patch-type test

Since the merge of main, a whole Partial<ServerSettings> no longer fits a
patch (another field is nullable in settings only). The test checks the
placementNeeds field it is about.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* feat(playtest): the playtest MCP tool (start, push, status, end) (#809)

* feat(playtest): add the playtest MCP tool (start, push, status, end)

One tool in the waits toolkit over the playtest service. The thread is the
caller's own, from its MCP credential; the tool takes no thread and no
setting. Refusals (playtest off, busy, no session) come from the service
with what to do next. Docs: playtest.md gains the tool section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(fork): list the playtest tool in FORK_CHANGES (#809)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(playtest): own tool group; start and push need a full-access thread (#809)

- `playtest` is its own MCP tool group (MCP_T3_TOOL_GROUPS gains "playtest";
  MCP_T3_TOOL_OWN_GROUPS pins the tool in the waits toolkit to it), so a
  profile that keeps `waits` does not get it. Test: every T3 tool is in
  exactly one known group, and playtest alone in its own.
- `start` and `push` refuse a thread that is not full-access or is in plan
  mode, by the thread's modes as the server records them at each call.
  `status` and `end` stay open, so a restricted thread can release its target.
- Status tells the agent to call end for a claim cut off by a stop and for a
  release that has not worked yet.
- The waits tools share one calling-thread helper.
- `start` joins the unknown thread-argument test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork: report a linked child's pending prompts to its parent (#808 row 1) (#815)

* fork: report a linked child's pending prompts to its parent (#808 row 1)

A delegated task on a linked machine always reported
hasPendingQuestion false and pendingApproval null, so its parent never
learned the child was waiting.

- New fork route GET /api/fork/task-prompts on each machine: the open
  questions, approval and secret requests (label and reason only, never
  a value) of one of its threads. Link token only.
- task_status, delegate_task and their waits read it over the existing
  link through the fork seat remotePrompts (one spread line in the
  remote read). An unreachable or older machine reads as unknown in
  next, never as "not waiting".
- A watcher wakes the parent once per prompt, the way a local child's
  question does: it ends a blocking wait if there is one, else it queues
  one wake message, and cancels that message if the prompt is answered
  there first. Wake ids are fixed, so a restart sends no second wake.
- OrchestratorMcpService.ts is a pending file and may not gain a fork
  line: the Effect.scoped comment moves onto the (already fork) line it
  explains, which frees the line the seat takes. Still 35 fork lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* FORK_CHANGES: link #815

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork: quote a remote child's words; a wait has a prompt only while its run lasts (#815 fix round)

- Text and ids from the linked machine: ids only on a strict pattern (else
  unknown, "refused"), at most 50 prompts, a secret's label and reason
  folded to one line, capped (80/300) and quoted as the child's words.
- A secret never goes to a blocking wait; it is always a queued message.
  A question or approval handed to a wait counts only while the parent's
  run lasts; after it, one message if it is still open there.
- The receipt of a sent wake is read before a slot is taken; a machine
  that does not answer is asked once per round; "older" also names a link
  no longer accepted.
- The remote read's spread line carries its // Fork: marker (no new line).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* host tools: per-OS path layer (real-path resolve, Windows and macOS oddities) (#816)

* host tools: per-OS path layer (real-path resolve, Windows and macOS oddities)

resolveHostPath(input, {platform, fs}) follows every link, junction and
mount point to the real target and returns that path plus the compare key
the policy core will match reach kinds and secret patterns against, or a
plain refusal. Platform and file-system calls are injected, so the Windows,
macOS and Linux cases all run on any CI machine; nodeHostPathFs is the thin
real adapter. Nothing is wired yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* host tools path layer: fix round for both lenses

- Map macOS firmlinks on the walked path and on the OS answer; full list.
- Refuse /.vol, /dev, Linux /proc, /sys, the document portal, and devices,
  pipes and sockets.
- Add secretKey, always folded (full case map, NFKC, ignorables dropped);
  compareKey stays exact per OS.
- Cross-check the walk with the native realpath and refuse a different answer.
- Win32 collapses typed ".." first; cap the walk at 4096 steps.
- Header states the contract for 1.2 and 1.4.
- Tests: an independent fake file system, a regex case-fold oracle, state
  cases, real-adapter checks, and Windows/macOS tests skipped elsewhere.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* test(cleaner): one clock for report test stamps, so a mark's line stays the same (#819)

The report's mark names the last counted log line by its exact text. Three
Freed tests wrote the log twice and rebuilt an already-counted line with a
fresh stamp; when the clock crossed a second between the two, that line no
longer matched the mark, the report treated the log as trimmed and counted
the old delete again ("at least 5.0 GB (2 deletes)").

The real log is append-only, so the report code is right; the tests now
build each line once and reuse it, and stamp() reads one clock for the run.
Forcing a second boundary (time.time() moving one second per call) fails
the three old tests every time and passes the new file.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* heavy facts: per-kind fits from the kernel ledger; kit capacity evaluator and callers (#786)

* heavy facts: per-kind fits from the kernel ledger; kit capacity evaluator and callers

Dynamic slots design row D6. The kit gets a Python evaluator of the shared
capacity rule (lib/capacity_rule.py) that passes every vector and format case
the TypeScript tests read, and `heavy facts [--kind K] [--mb N]`: one free/v1
object with per-kind "fits" from a ledger read from the kernel (heavy's live
tickets plus T3's agent scopes, unlabelled = writer), a 5 s cache, the Basic
tier, unreadable signals as elevated, and per-folder reservations.
bin/t3-capacity and bin/agent-slots are thin callers of it that keep the older
output and exit codes; a facts call that is slow (5 s) or fails is never free.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* heavy facts: every ticket is a job, folders match exactly, basic tier and other users fail closed

Fix round for the two D6 reviews.

- A heavy ticket whose kind the rule does not know (tsc, gradle, a project's
  own) is the rule's unknownKinds.job, never an agent; heavy facts --kind
  with an unknown name asks for that job too.
- A reservation folder matches itself and what is below it, with or without
  a trailing '/', never a sibling sharing its first letters; its real path
  matches too. The caller's own folder is its real working folder only.
- Basic tier (no cgroup v2 or no user manager) is never free and fits 0.
  Full tier also counts every other user's heavy jobs and agent scopes
  from their user managers' cgroups; a folder that cannot be listed is
  basic. Without a cache folder every call starts "elevated".
- lib/capacity_readings.py: the shared reader's port. It runs every
  capacity-readings.json case and the "a failed reading never admits more"
  check; memory, PSI, cores and container limits now come from it, a box
  with a live piece but no folder is unreadable, a cut-short memory.stat
  owes in full.
- The cache has version 2 and a key of its settings; t3-capacity takes the
  rule's whole hold; a fill count of 2.5 asks three times, as in TypeScript.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* heavy facts: kit tests check out the capacity rule; its JSON names no kit path

The heavy kit's evaluator, its tests and heavy-install read the capacity rule
from its one source, packages/shared/src/capacity, but the sparse checkouts of
the workflows, action_tests and kit_tests jobs left that folder out, so
install.test.py and facts.test.py found no capacity-rule.json. The folder is
now in the three lists (and in the `workflows` comment that says why each app
file is there).

The "//" notes of capacity-rule.json and capacity-readings.json named the
kit's Python files, which the fork-owned-reads lint counts as app code reading
a fork-owned path; they now point to README.md beside them, which names them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork seams: announce the thread menu's MCP profile lines (MCP profile design PR 3, step 1); also restores the HO5 announcement lost in #777 (#807)

* fork seams: announce the thread menu's MCP profile lines (MCP profile design PR 3, step 1)

List only. The thread menu gets the MCP profile entry: the thread's
effective profile, and the owner's pick or clear for a client that may
change settings. Its logic and runtime are fork files
(apps/web/src/components/fork/mcpProfile/); upstream's menu files need
four lines in threadActionMenu.logic.ts and three each in
useThreadActionMenu.ts and Sidebar.tsx, announced here. The code is on a
branch pushed without a pull request until this merges.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fork seams: also restore the HO5 announcement lost in #777

The squash merge of #777 dropped every HO5 announced line from
.github/fork-seams.json. Restore them exactly as they were, inside the
same per-file entries as this PR's MCP profile lines (one key per file).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* handoff HO4: source `agent` (write turn, marker, cap, joined check) (#824)

* handoff HO4: source `agent` (write turn, marker, cap, joined check)

The old session gets one normal turn on its own thread with the
setting's instructions; its reply is part 2 of the handoff when the
turn completed, no other message joined it, the reply starts with the
marker line and is within the command source's 32 KB cap. A reply that
does not count falls back like the command source (size: parts 1, 3, 4;
idle: nothing). A stopped, failed, joined or timed-out write turn means
no handoff: the old session carries on. Fixed ids per source run, so a
run never writes or hands off twice; the write run is no turn end and
stays out of the transcript. Default stays off; no migration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* handoff HO4 fix round: write turn never lost, stopped at its timeout, quiet

- A late update of the source run, or a restart, no longer drops part 2:
  any loop that finds a write turn as the latest run carries it on to its
  handoff (fixed ids, so at most once).
- A message steered into a write turn stays in later handoffs' part 3; only
  the write turn's prompt and marked reply are left out.
- A failed or timed-out write turn at the size backstop sends parts 1, 3
  and 4 (idle: nothing), as the command source does.
- Notes lines that could pass for the message's own lines are quoted.
- T3 stops a write turn at its timeout (run.interrupt, its own reason);
  after one such stop the next size handoff uses the fallback at once.
- A completed write turn is marked quiet, as the handoff run is.
- New source `none` is the default, so a saved handoff setting keeps its
  old behaviour; `agent` only when set.
- The last reply that starts with the marker is used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* handoff command test: "could not start" without the stdin race

A missing program under `timeout` can exit before the empty stdin is
written, so the reason sometimes read as an output error. The case now
uses a spawn that fails (its project folder is gone); exit codes 126 and
127 stay covered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork-kit/gh-apps: call forms and GH_REPO check of the older per-user gh-as (#835)

* fork-kit/gh-apps: call forms and GH_REPO check of the older per-user gh-as

gh-as now also takes `gh-as NAME -- gh ...`, `--repo=`/`--app=` and `--help`, and refuses a GH_REPO in the
caller's environment that names another repository instead of silently ignoring it. New parity.test.py covers
these and the state cases: an expired, half-written or empty token cache, a killed run's temp file, config
missing or empty, two gh-mint runs at once (one mint), cache modes, and no token in any message.

Fork audit #834, item G1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/gh-apps: lens nits for the gh-as parity PR

- wrapper: a refused GH_REPO is masked before it is cut, so no start of a
  token is ever quoted; GH_HOST other than github.com is refused too
  (README says which variables are checked and which are only dropped).
- admin add-key: refuses the app name "gh" (gh-as gh -- gh ... reads it as
  the gh command, so it could not be picked by name).
- privileged gh-as: a repeated --app or --repo is a usage error, as in the
  wrapper, not last-wins.
- README: the new key is piped straight into root, never stored where an
  agent can read it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/gh-apps: root test expects the wrapper to refuse a foreign GH_HOST

The wrapper now refuses GH_HOST other than github.com, so the environment
test checks that refusal, sends the rest of the attack environment through
the wrapper, and still sends all of it (GH_HOST too) to a direct sudo call.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork release: SHA256SUMS covers the desktop files; unsigned macOS apps are ad-hoc signed last (#822) (#833)

* fork release: SHA256SUMS covers the desktop files; unsigned macOS apps are ad-hoc signed last (#822)

SHA256SUMS now lists every file a person downloads: the server archives and the desktop apps
(macOS dmg and zip, Windows exe, Linux AppImage), written in assemble after all desktop builds.

Without signing secrets electron-builder found no identity and signed nothing, so the macOS app
kept only the linker signature of Electron's executable and `codesign --verify --deep --strict`
failed on it. Unsigned macOS builds now set identity "-" with the sign hook
scripts/fork-codesign.cjs, which runs `codesign --force --deep --sign -` as electron-builder's last
change to the bundle, before the zip and dmg. A new verify_mac_signature job, which assemble waits
for, unpacks each shipped zip and dmg and runs `codesign --verify --deep --strict`.

The one line in scripts/build-desktop-artifact.ts is recorded in .github/fork-seams.json.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork release: review fixes for the desktop SHA256SUMS and ad hoc signing (#822)

- SHA256SUMS: `sha256sum --` (bare names kept) and compgen presence checks,
  so actionlint passes; a step before the upload checks every file the
  publish job uploads (less blockmaps and manifests) has a matching line.
- verify_mac_signature: no token, each dmg detached on any exit, the
  signature's Identifier/Signature/Authority in the step summary, and the
  hashes of the four checked files as an output; assemble fails when the
  macOS lines of SHA256SUMS differ from them.
- fork-codesign.cjs refuses any identity but "-" and says why entitlements
  and hardened runtime are ignored; scripts/fork-codesign.test.ts tests the
  hook and createBuildConfig's signed and unsigned macOS config.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* docs/fork/agent-rules.md + fork-ci doc-check: general agent rules, once (#874)

* docs/fork/agent-rules.md + fork-ci doc-check: general agent rules, once

docs/fork/agent-rules.md holds the agent rules that hold in every project
and on every machine, each once with a one-line why. Machine and project
facts stay in their own instruction files and config; review rules link
to the review skill instead of being copied.

fork-ci/actions/doc-check is a general port of a project's doc check:
size budgets and a no-history rule for instruction files, broken relative
links in changed Markdown, and no dated report files added. Budgets and
patterns come from an optional project config read at the base commit,
with defaults; a missing or empty config means the defaults, a broken one
exits 2.

Part of #834

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* git-clean test: doc-check is an action that runs the git check first

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork seams: announce the settled provider thread lines (#846, step 1) (#907)

List only (step 1 of "Adding a seam line"). Fixes the race behind the
flaky Kiro turn_interrupt replay test (#846): at a turn's end the ACP and
Cursor adapters cache the provider thread as active, and usage or shell
updates that arrive after the turn re-send that snapshot session-scoped,
which the server writes without a run guard. When that write lands after
the run's final idle write, the ended thread stays active.

The fix adds one override line (and a comment) after upstream's status
line in each adapter, so the cached snapshot is idle like the server's
final write, and one check in each adapter's existing test. No upstream
line changes, so no lost-line count is needed.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fix(acp,cursor): a turn's cached provider thread is settled, so late updates cannot mark it busy (#909)

* fork seams: announce the settled provider thread lines (#846, step 1)

List only (step 1 of "Adding a seam line"). Fixes the race behind the
flaky Kiro turn_interrupt replay test (#846): at a turn's end the ACP and
Cursor adapters cache the provider thread as active, and usage or shell
updates that arrive after the turn re-send that snapshot session-scoped,
which the server writes without a run guard. When that write lands after
the run's final idle write, the ended thread stays active.

The fix adds one override line (and a comment) after upstream's status
line in each adapter, so the cached snapshot is idle like the server's
final write, and one check in each adapter's existing test. No upstream
line changes, so no lost-line count is needed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(acp,cursor): a turn's cached provider thread is settled, so late updates cannot mark it busy

Fixes #846. At a turn's end the ACP adapter (Kiro, Kimi, Grok, fx and the
ACP registry agents) and the Cursor adapter cache the provider thread as
active. Usage or session info that Kiro sends after the cancelled prompt
(and Cursor's background-shell updates) re-send that cached snapshot as a
session-scoped update, which the server writes without a run guard. When
that write lands after the run's final idle write, the ended thread stays
active for good; the turn_interrupt Kiro replay test caught it now and
then.

The cached snapshot is now settled (idle, or error for a broken thread)
like the server's final write. One override line after upstream's status
line in each adapter, announced in .github/fork-seams.json.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork CI: each listed Python test declares its format, judged by it alone (#702) (#784)

- .github/fork-ci-tests.txt: a Python test's line ends in "unittest" or "ok lines". A Python
  line with neither is refused with what to write; either word on a non-Python test is refused.
  All 87 listed Python tests now say theirs (78 unittest, 9 ok lines).
- countTests: a Python test with no declared format counts nothing; it is never read as either.
- fork-contracts.test.py: its record fixtures pass the format the list would give.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* MCP profiles: Settings section and thread pick logic (design PR 3) (#804)

* MCP profiles: Settings section, thread picks and the menu entry's logic (design PR 3)

Settings → Fork gets its MCP profiles section (McpProfileSettings.tsx):
the built-ins all and t3-only read-only; add, edit and delete named
profiles (servers all or a list, t3Tools all or a list of the shared
MCP_T3_TOOL_GROUPS); the default profile and the sub-agent rule with the
usual project-override control; each thread's pick, changed or cleared.

Every patch names only what it changes: one mcpProfiles entry, or one
thread's mcpThreadProfiles key (null clears), and a pick or clear that
changes nothing writes nothing. A built-in name cannot be taken; a
profile something names cannot be deleted (the panel says who, and offers
to clear the thread picks). An entry with fields from a newer build shows
as broken, never as a profile; one with unknown tool groups as from a
newer version; neither is editable. Rows follow ForkRow's lock, so a
client that cannot write settings gets inert controls.

The pure resolver moves to packages/contracts/src/mcpProfileResolve.ts
(re-exported by the server's fork/mcpProfile.ts, unchanged behaviour) so
the app reads entries by readMcpProfileEntry and shows a thread's
effective profile from resolveMcpProfile, a child's cut down to its
parent's. The thread menu entry's logic is in
components/fork/mcpProfile/threadMcpProfile.logic.ts; wiring it into the
upstream thread menu needs seam lines, announced separately.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* MCP profiles: read the client's thread shells (delegatedFrom null) and a carried profile

The app's thread shells hold delegatedFrom: null for a thread nobody
delegated; the menu logic now takes that shape. Test: a task another
machine delegated is cut down to the profile it carried, and a shell
with delegatedFrom null is a top-level thread.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* MCP profile settings: add a thread pick only with a chosen profile

- "Add thread" opens a form with the thread id and a profile picker next
  to it; one save writes that thread's key with the chosen profile.
  Nothing is written for a typed id alone, on Enter without a profile,
  or on cancel.
- The form and each pick row say what the pick gives the thread, and
  warn when that is more than the parent's cut-down set (a pick is never
  cut down to the parent's).
- The server refuses deleting a profile that the default, the sub-agent
  rule, a project or a thread pick still names, with the same rule and
  wording source as the panel (mcpProfileUses).
- "Clear the thread picks that use it" checks the lock of
  mcpThreadProfiles, the setting it writes.
- A blank pick hand-edited into settings.json shows as broken (it is
  ignored) and can be cleared.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork-kit/heavy: machine-file holds for heavy facts / t3-capacity (stacked on #786) (#843)

* heavy facts: per-kind fits from the kernel ledger; kit capacity evaluator and callers

Dynamic slots design row D6. The kit gets a Python evaluator of the shared
capacity rule (lib/capacity_rule.py) that passes every vector and format case
the TypeScript tests read, and `heavy facts [--kind K] [--mb N]`: one free/v1
object with per-kind "fits" from a ledger read from the kernel (heavy's live
tickets plus T3's agent scopes, unlabelled = writer), a 5 s cache, the Basic
tier, unreadable signals as elevated, and per-folder reservations.
bin/t3-capacity and bin/agent-slots are thin callers of it that keep the older
output and exit codes; a facts call that is slow (5 s) or fails is never free.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* heavy facts: every ticket is a job, folders match exactly, basic tier and other users fail closed

Fix round for the two D6 reviews.

- A heavy ticket whose kind the rule does not know (tsc, gradle, a project's
  own) is the rule's unknownKinds.job, never an agent; heavy facts --kind
  with an unknown name asks for that job too.
- A reservation folder matches itself and what is below it, with or without
  a trailing '/', never a sibling sharing its first letters; its real path
  matches too. The caller's own folder is its real working folder only.
- Basic tier (no cgroup v2 or no user manager) is never free and fits 0.
  Full tier also counts every other user's heavy jobs and agent scopes
  from their user managers' cgroups; a folder that cannot be listed is
  basic. Without a cache folder every call starts "elevated".
- lib/capacity_readings.py: the shared reader's port. It runs every
  capacity-readings.json case and the "a failed reading never admits more"
  check; memory, PSI, cores and container limits now come from it, a box
  with a live piece but no folder is unreadable, a cut-short memory.stat
  owes in full.
- The cache has version 2 and a key of its settings; t3-capacity takes the
  rule's whole hold; a fill count of 2.5 asks three times, as in TypeScript.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* heavy facts: kit tests check out the capacity rule; its JSON names no kit path

The heavy kit's evaluator, its tests and heavy-install read the capacity rule
from its one source, packages/shared/src/capacity, but the sparse checkouts of
the workflows, action_tests and kit_tests jobs left that folder out, so
install.test.py and facts.test.py found no capacity-rule.json. The folder is
now in the three lists (and in the `workflows` comment that says why each app
file is there).

The "//" notes of capacity-rule.json and capacity-readings.json named the
kit's Python files, which the fork-owned-reads lint counts as app code reading
a fork-owned path; they now point to README.md beside them, which names them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/heavy: machine-file holds for heavy facts (t3-capacity), on top of the kit capacity check

Built on the kit's `heavy facts` and its thin `t3-capacity` caller (#786) instead of a second capacity
evaluator. What the older host check had that the kit's did not:

- heavy.capacity.holds in the machine file: a cgroup outside the user managers (a CI runners' slice) that
  is in use keeps its budget less its use, as a reservation, for every user but its own. Missing file,
  section or key: no holds; a broken one: no answer (t3-capacity NOT OK naming the key); a changed one
  is read again at once (cache key).
- The sweep and the queue accept the new `capacity` key.
- Tests for the state question: holds in use or idle, own users, missing cgroup, unreadable memory.max or
  memory.stat, machine file missing/empty/garbled/writable by others/unknown key, a changed file within
  the cache's 5 s, a reservation file cut short, a reservation whose processes are gone; one red check.

Part of #834 (G2, first half).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork-kit/review: one general review skill; tiers, failure table, nit-only check and a drift test (#845)

* fork-kit/review: one general review skill; tiers, failure table, nit-only check and a drift test

The kit's SKILL.md becomes the one general review skill, so a project keeps only its facts (review block, lens
prompts, kit settings) and a thin adapter. Merged in from the project skill: the tier table as the gate's weights,
the author's failure table, nit-only quick check, batch per area, twin lens names, focus lenses, covered rule, the
extra general lenses, and a concurrency part in the eval lens. Conflicts go to what the gate parses: the state answer
on a `state:` line and `blocker:`/`major:`/`minor:` lines.

New test (comments.test.py, SkillFormat): every report shape the skill, the eval lens and COMMENTS.md tell a lens to
write reads as a clean read with a state line through the gate's own parser; the skill's tiers match the gate's
weights and recommended min_lenses; the state question is word for word in the skill, the eval lens and REVIEW.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/review: skill matches the gate on rounds, protected paths and check exits

- A quick check is a lens read of a new head, so the gate counts it as a
  round; the skill names rounds.approach_at / approach_lens / max, how to run
  the approach lens, and that only an override by a listed override_authors
  login waives it.
- The tier table names the gate's always-critical paths (queue config, lens
  prompts, .github/workflows/**); the light row no longer says config is light.
- focus: removed (nothing reads it); twin lenses described in general terms.
- check exits 1 for a real blocker or major by design; never soften a finding.
- not a lens: also needs no read-at sha outside a quote (COMMENTS.md rule).
- Drift test reads the round keys and recommended approach_at through the
  gate's parser and judge_rounds, the protected paths from review_judge, and
  the runner defaults from review_kit.DEFAULTS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/review: the override passes a nit-only fix head, a quick check never does

The gate passes a head only when every lens's newest read names it or a newer
override covers them (lens.Review.reviewed_head). A quick check is one lens on
the fix head while the earlier lenses still name the old head, so it alone
holds the head. SKILL.md step 7 now says which head passes and that on
`nit-only: yes` the orchestrator still posts the override; COMMENTS.md says the
same. The round count says "whichever is higher", as review_round does.

Tests: a history (code at A, code r2 at B, fix C with a quick check) through the
gate's real reviewed_head and judge_rounds, pinned to the skill's words; the
protected-paths test now compares is_protected's answer with the skill's list
on every tracked file and on probe paths, so an inline rule fails it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Fix #911: a delivery refused for its profile leaves its place in line (#912)

A stored webhook delivery keeps its place in the slot gate's line from its
first, direct ask. When its worker run was refused for its MCP profile as it
started (before it reached its slot wait), the place stayed until the next
sweep, so for up to a sweep a free slot was refused to another run: that
run was stored for the worker instead of starting.

The flaky test hit this path only when the worker's run lagged behind a
fixed three worker rounds, so the widening landed before the slot wait it
meant to test. It now waits for that slot wait itself, and a new test
covers the start-time refusal, which leaves the place at once now.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Review rules T3a: lens_start plan, prompt, refusals and request ids (pure logic) (#825)

* Review rules T3a: lens_start's plan, prompt, refusals and request ids (pure logic)

New fork files next to the review-rules logic of #781. Nothing registers a tool yet.

- planLensStart: per pull request and batch plan. Required lenses come from planReview and
  requiredLenses, the round from judgeRounds (the gate's own rules), so lens_start cannot
  require fewer lenses than the gate. A lens whose newest report already read the head (or the
  same change) is not started again. A batch gives one child per lens that reads every pull
  request needing it and posts one report per pull request, each with that pull request's head.
- Refusals: rules off (unset, empty, off, unreadable), a bad call, an unknown, closed or merged
  pull request, a caller head GitHub does not name, no plan (unreadable change, no rule, a lens
  prompt not read), round past the cap, a person's override already on the head.
- confirmLensStart: just before starting, a child whose pull request moved or closed is refused.
- lensRequestId: same lens and heads = same id, in any order; fits delegate_task's 256 chars.
- The server builds the prompt: read only, the lens text, the state question word for word with
  a `state:` line, finding prefixes, report size, round and earlier reads.
- Tests replay every shared case, round and scan vector (counts checked) and answer the state
  question: same start twice, head moved, old/empty settings, round at the cap, partial batch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Review rules T3a: lens_start plans what the gate reads (fix round A+B)

- Restart every lens entry that does not name the head once anything must
  start, required or not: the gate needs every lens comment on one head.
  An entry lens_start cannot start (no header, unknown lens) is refused
  with what a person does. A newer override the gate counts is honoured.
- Read the gate's required-lenses input and the review block's mode;
  without a block the input names the lenses (built-in prompt), and an
  empty input outside enforce, a bad name or a bad mode is refused.
- Plan each pull request of a batch with its own base branch's rules.
- Earlier lens children: an ended one restarts as the next attempt
  (replaces + note), a running one is returned, never started twice.
- Repo and heads read lower-case; the approach lens runs on the approach
  runner by its role; lone-surrogate lens keys get a distinct id.
- Tests: both lens-A scenarios, a property test over every shared vector
  state (the gate's verdict, modelled from its code, passes after the plan
  is carried out, or a person must act), and a test per new refusal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Slot gate: enforce the capacity rule by default (dynamic slots D4) (#823)

* Slot gate: enforce the capacity rule by default (dynamic slots D4)

The capacity rule now decides agent starts (mode "enforce", the default when
agentSlots has no mode and is switched off):
- owed term: every agent still starting, held slot or waiter ahead owes its
  full cost, so two starts in one second both count;
- kinds from the task role: research, review and design are light, anything
  else or no role is a writer; a light agent that grows past the light cost
  counts as a writer, so a wrong role cannot hide one;
- floors (2 agents, 1 job) and derived ceilings (3 agents per core, at most 64);
- fallback to the fixed ceilings (10 agents, 4 jobs) with start costs raised
  25% per trip after an OOM kill (oom_kill in /proc/vmstat rises) or swap under
  10% free; it lifts after 10 minutes of calm, whole readings. A restart starts
  in the fallback and at "elevated"; unreadable readings are never calm.
Typed limits still apply while enabled; "mode": "fixed" turns the rule off.
The delegate_task route passes its role to the slot gate with the target.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Slot gate: fix round after lenses A and B (D4)

- floor always starts, also with failed, hung or out-of-range readings;
  after 2 minutes unread the fixed 10 counts alone
- a restart lifts on calm for this host: swap counts by trend, the first
  calm needs the margin only; a 30 s timer takes readings
- costs from the rule file (light 384, writer 768); light cost clamped
- only agent-slice OOM kills raise costs; untold kills raise at most 2;
  each calm spell lowers one raise
- basic tier (no scopes or no oom_kill) keeps the fixed 10; unread
  running agents count once as writers
- unreadable settings use the fixed limits; true counts in refusals
- tests for the held slot, the role line, no OOM counter

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Slot gate: kit evaluator follows the swap-trend rule; scheduled-run tests build the gate at START

The merge of main brought the heavy kit's Python evaluator of the capacity
rule (#786), written for the rule before this PR. This PR's rule counts swap
by its trend (pressure.swapFillingMb; calm.swapFreeAtLeastPercent gone), so
the kit read a key the shared rule no longer has (KeyError in
capacity_rule.test.py and every heavy facts call).

- lib/capacity_rule.py mirrors capacityPressure.ts and pressureOf: raw_level
  takes the last read's swap free (filling = it fell by more than
  swapFillingMb; nearly full counts only while filling; filling is never
  calm; no previous swap read = trend unknown), next_pressure keeps or starts
  the calm wait on an unknown trend but never ends it, and the kept state
  carries swapFreeMb for the next read (heavy facts' cache carries it).
  The shared capacity-vectors.json swap-trend cases and the facts carry test
  fail when any part is undone.
- capacity_rule.test.py: a kit copy of the rule from before the swap trend is
  refused by name; an empty or missing rule file raises (heavy facts then
  answers "not available", never free).
- agentSlotRoutes.test.ts: the gate's 30 s enforce sampler starts when the
  gate is built. Built at the test clock's 0, the tests' move to START ran
  every sample in the 56 years between (about 59 million): Test Server 5 hung
  until its 20 min cancel. boot now sets the clock to START first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* MCP profiles part 5: Codex threads apply their profile's outside servers (#826)

* MCP profiles part 5: Codex threads apply their profile's outside servers

Each Codex thread T3 loads on the shared app-server gets
mcp_servers.<name>.enabled = false in its own per-request config for
every server config/read lists for its folder that the profile leaves
out (launch-argument and project servers included; T3's own entries
stay). Each turn first reads the thread's live servers and refuses,
saying why and the fix, when one outside the profile is still on. A
missing or broken profile, a server list T3 cannot read, or a thread T3
cannot match is refused, never started with every server. Logic in
apps/server/src/fork/codexMcpProfile.ts; two seam lines in the Codex
adapter (announced in step 1). Remote delegation stays Claude-only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* MCP profiles part 5, fix round: check Codex-started turns, sub-agents and connectors

- Watch turn/started: a turn Codex starts on its own (a goal's next turn, a
  sub-agent's turn) gets the same check as turn/start; one that fails is
  stopped (goal paused, turn interrupted) and ends failed with the reason.
- Count Codex sub-agents as their parent's T3 thread (they copy the parent's
  loaded config, codex-rs child_config.rs), so their turns are checked too.
- Send features.apps=false when a narrowed profile leaves out codex_apps,
  which config/read never lists.
- A refused resume no longer becomes a fresh Codex session: the fallback
  start is refused once, so the history is kept.
- Tests for each, with Codex's real status words; docs updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* heavy holds: #913 follow-ups and neutral example names (#917)

- A hold cgroup that is there without a memory controller (no memory.stat)
  holds its whole budgetMb with a note, instead of nothing.
- The room a hold keeps is its budget less the RAM it uses: memory.max
  limits RAM only, so swap is left out (in use still counts swap).
- Holds in or the same as another hold's cgroup are refused (the same
  room held twice); a reservation file named like a hold gives a note.
- Tests that fail without the code: at most 8 holds (9 distinct labels),
  memory.max "max" gives no "cannot be read" note, and one mutation check
  per fix.
- Neutral example names in the reservation-folder docs and test.

Fixes #913

Co-authored-by: Claude Opus 5.5 <[email protected]>

* MCP profiles: T3 tool groups on T3's MCP server, for every provider (#827)

* MCP profiles: T3 tool groups on T3's MCP server, for every provider

MCP profile design PR 4. A profile's t3Tools now applies: one global
rule on T3's MCP server hides a T3 tool outside the calling thread's
groups from tools/list, refuses it on tools/call with a plain reason and
its fix, and keeps it out of tool_search. The groups are fixed as each
turn starts (Claude: as its query opens; other providers: the turn
check), so a running turn keeps its set and a change applies from the
next turn. A profile that cannot be worked out, or a thread T3 cannot
read, keeps only request_secret, send_to_user and tool_search.

Claude no longer refuses a profile whose t3Tools is a list, and a group
change gives its next turn a fresh process. Off Claude, a turn now
refuses only a profile that leaves out an outside server.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* MCP profiles: guard the T3 tool table against drift; a tool in no group is refused as a T3 bug

- personOnlySettings.test.ts: the T3 tool filter's table must hold exactly the toolkit folders'
  tools, each in its folder's group, and every group of MCP_T3_TOOL_GROUPS must have a tool there.
  Dropping a toolkit from the filter's hand list, or adding a group with no toolkit, fails CI.
- A tool in no group is still refused by any profile but all, but its refusal now says it is a T3
  bug to report, not a setting to change.
- docs/fork: profiles are not a sandbox (requests with no thread, such as the t3 thread CLI, are not
  filtered); the sets live per thread, not per credential.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* FORK_CHANGES: shorten the MCP profiles row so the table keeps main's widths

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: the machine's agent guard hooks as a kit (#834 G4) (#847)

* fork-kit/agent-guards: the machine's agent guard hooks as a kit (#834 G4)

Five Claude Code hooks that guard every agent on a shared machine, as one kit with one
installer, facts from the machine file and the same messages and exit codes as before:

- actions-disable-guard (PreToolUse Bash): no disabling of workflows, Actions or branch
  protection; fails closed (a missing or failing hook refuses, and says so)
- capacity-pipe-guard (PreToolUse Bash|Monitor): no pipe out of a capacity check
- memory-index-guard (Pre/PostToolUse): the auto-memory index stays inside its budget
- bg-guard (Stop): no stop while a background Bash command still runs
- agent-slots (UserPromptSubmit, Stop): slot and ready-queue context for orchestrators

The others fail open with a visible line. `agent-guards check` runs each wired command
with a case it must refuse and one it must pass; `--settings` writes a managed settings
drop-in. Shared bootstrap and kit_install contract tests cover the new kit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: lens round 1 fixes for G4a

- actions-disable-guard and capacity-pipe-guard match Bash|Monitor; the
  memory-index after-call check matches Monitor too; check reports a
  guard wired for Bash only as missing.
- The owner's approval is a root-owned file with the hash of a one-time
  code (agent-guards approve); the session variable is no longer read,
  since nested sessions inherited it.
- Refuse starting a nested session without this machine's hooks
  (claude --bare/--safe-mode, CLAUDE_CODE_SIMPLE, codex).
- The closed hook sets onFailure block; an empty guard file refuses.
- A ruleset set to evaluate is refused like disabled.
- Each hook reads only its own part of the machine file section; bad
  keys and refuseScripts rows are dropped one by one and named to the
  agent; self-check does the strict check.
- Uninstall refuses while a foreign settings file names a hook or an
  older session runs; rollback is --no-settings.
- check --settings as root reads only a root-owned file; check runs
  hooks under a temporary HOME; self-check checks links, an open
  approval and passwordless ways to root.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: GraphQL ruleset update with EVALUATE in a variable is refused (lens B r2 minor 1)

The off word of updateRepositoryRuleset was looked for in canon() text, which blanks text with no cue
word, so `-F e=EVALUATE` (or a JSON variables block) was '' before OFF_WORD saw it. It is now read
without the cue words, as the REST ruleset body already was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: an owner approval passes one command, in one folder, once (lens B r2 major 2)

`sudo agent-guards approve --command '<cmd>' [--cwd DIR]` now stores the hash of the
normalised command and the folder next to the code's hash (approval file version 2).
The guard passes only that command, ending in the marker, run in that folder, and
records the use in its state folder (O_EXCL link; the same tool_use_id passes again),
so the approval is used up. A code seen in a transcript, the app database or ps opens
no other command. A version 1 file counts as no approval.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: refuse hookless agent sessions by path, package and wrapper, and say what the guards are not (lens B r2 major 1)

A list of strings cannot be complete, so this does both things the review asked for:

(a) Wider detection where it is cheap and reliable. claude and codex now count by name, by their real
program path (.../claude/versions/<v>, the @anthropic-ai/claude-code and @openai/codex packages), as a
link to or a copy of the installed program, through npx, bunx, pnpm dlx, npm exec, bun x and
`node <their cli>`, behind `$(which claude)`, and inside python -c, node -e, perl -e, at, systemd-run
and the other wrappers already read for gh. CLAUDE_CODE_SIMPLE counts in the command, through env -S,
in a sourced file, in BASH_ENV/--rcfile and in the user's shell start files.

(b) The threat model, written plainly in the README ("What the guards are and are not") and the guard's
docstring: the guards stop mistakes and casual misuse; they are not a boundary against a hostile agent;
the boundary is the GitHub permissions of the agent's token (a fine-grained token without Actions and
Administration write is the recommended setup).

Codex arguments are now read option by option (an option's value is not taken for the subcommand),
because the new path and package forms need it; the separate codex nits follow in their own commit.

Tests: LensSecurityR2Test.test_r2_major1_* (each fails on 6d5047d4).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: codex arguments are read option by option; codex mcp passes (lens A r2 nit)

`codex -m o3 exec x` is now refused as `codex exec` (the option's value is no longer taken for the
subcommand), `codex mcp list` (MCP setup, no session) passes, and `npx -y @openai/codex exec x` is refused
(the package form came with the major-1 commit). `codex mcp-server` stays refused.

Test: LensSecurityR2Test.test_r2_nit_codex_arguments_name_the_right_subcommand_mcp_passes_npx_refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: uninstall finds sessions by program path, refuses inside a hooked session, remembers hand-wired entries (lens B r2 minor 2, lens A r2 minors 1 and 2)

- Sessions are found by the real path of their program (/proc/<pid>/exe: the native build in
  .../claude/versions/<v> under any name, the @anthropic-ai/claude-code script node runs through any
  link, an installed `claude`), not by the process name alone.
- The uninstall's own ancestors are no longer skipped: run from inside a Claude Code session that has
  the hooks, it refuses and says to run it from a terminal.
- A refusal for a hand-wired entry is remembered (/etc/agent-guards/hand-wired-seen.json, removed with
  /etc/agent-guards); the next run then counts every session older than itself, as does a run where the
  drop-in was never on. A broken record counts as seen now.
- The project .claude/settings*.json of each running session's working folder (and the folders above
  it) is searched too.

Tests: Install.test_r2_minorB2_*, test_r2_minorA1_*, test_r2_minorA2_* and test_r2_state_* (each fails on
6d5047d4).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: README names the first Claude Code that honours onFailure, and how often a machine-file note shows (r2 nits)

- onFailure: "block" is honoured from Claude Code 2.1.295 on; older versions ignore it and let a
  failed or timed-out hook's call run (lens B r2 nit 1).
- A broken part of the machine file is named on every call the hook handles, once per hook with a
  problem, so a Bash call can carry it up to three times: kept loud on purpose, now said in the README
  (lens A r2 nit).
- The --safe-mode refusal is kept, with its reason in the README since the major-1 commit: safe mode
  runs managed hooks but not hooks wired by hand in user settings (lens B r2 nit 2).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: uninstall reads the boot time only when a Claude Code session runs (follow-up to the session-check commit)

The session check now runs on every uninstall, so it must not refuse for a /proc/stat it does not need:
the boot time is read only once a Claude Code process is found, and an unreadable process list still
refuses with "cannot be read". Found by the shared fork-kit/common/tests/kit_install.test.py run (its
fake /proc has no stat file).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork-ci release: carry the files the heavy and desk kit installers read, and test every kit against the release (#920)

* fork-ci release: test that every kit installer finds its files in the release (desk: missing_sources)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-ci release: carry the files the desk and heavy kits read (capacity rule, fleet desk scripts)

heavy-install reads capacity-rule.json, capacity-format.json and capacity-vectors.json from
packages/shared/src/capacity, and desk-install reads the fleet desk scripts, units and
.github/fork-fleet.json; none were in the release paths, so both refused on every release.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Placement P3 (facts out): t3_environment_read returns hostResources and placement (#820)

t3_environment_read now returns two optional fields beside upstream's, for this
machine and for a linked one (the read is forwarded there as before):

- hostResources: CPU, cores and memory from HostResources, the result field of
  upstream PR #34293 (closed upstream without merging), same name and schema.
  Its export in McpHttpServer.ts, its lines in upstream test files and its new
  tool description are not carried: the fork adds no lines there. The fork file
  finds the sampler with Effect.serviceOption instead of a new tool dependency,
  so no upstream test needs a new mock. Its tests moved to fork test files.
- placement: labels (empty: no setting holds them yet, P2 adds it), available
  and reason, runningAgents, slotsFree, memoryFloorMb, freeMemoryMb from the
  slot gate's existing status read (SlotGate.usage), and factsAt.

A slot gate that cannot be read (fails, dies, takes longer than its own count
limit, is not running, or the settings cannot be read) gives available: false
with a reason and no count. A linked machine on an older T3 leaves both fields
out: no facts, not a failed read. Nothing is stored; each read measures again.
Result fields are not in the measured tool list, so the budget files are
unchanged.

The two environment toolkit files take the four lines announced in #779, moved
from announced to added.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* heavy-install: link t3-capacity to the kit's copy; self-check warns on another (#919) (#922)

* heavy-install: link t3-capacity to the kit's copy; self-check warns on another (#919)

heavy-install now also links /usr/local/bin/t3-capacity to
current/bin/t3-capacity, so the command has one source: the release in
use. A plain old file there (a host's own copy) is kept in
/usr/local/libexec/heavy/replaced-capacity/ (not replaced/: an older
installer's uninstall restores the newest file of replaced/ as heavy) and
stays in place until its link replaces it in one rename; uninstall puts it
back. A link elsewhere or a folder there is refused before anything is
written. heavy --self-check warns when the t3-capacity found on PATH is
not this kit's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* heavy-install: a host's own plain t3-capacity is replaced only with --replace-t3-capacity

A host's installer may write its own t3-capacity to /usr/local/bin and its
scripts may read or compare that file, so the installer now leaves such a
plain file alone (with a note, and no installed.tsv row for it) unless it is
run with --replace-t3-capacity. With nothing there, or the kit's link, it
links as before; once linked, later runs keep the link without the option.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* heavy-install: keep a host's t3-capacity outside the folders an uninstall deletes

- The kept copy moves to /usr/local/libexec/heavy-kept/: every released uninstall
  (ci/v6 to ci/v22) deletes /usr/local/libexec/heavy and /etc/heavy whole, so a copy
  kept inside them was lost. This release's uninstall puts it back (also after an
  older uninstall left the t3-capacity link broken) and then removes the folder.
- A link at /usr/local/bin/t3-capacity that the kit did not make is left alone with
  a note when --replace-t3-capacity is not given (refused with it, as before).
- The closing install line repeats that the host still uses its own t3-capacity.
- Tests: an older release's install and uninstall (ci/v22, from git) over this
  state; the same deletes without git; a foreign link; the closing-line warning.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* heavy tests: declare the older-installer test's skip in CI's shallow checkout

CI's clone has no ci/v22 tag, so the test skips there; fork-ci refuses an
undeclared skip (round-2 code lens on #922).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-contracts: pin the heavy install test's declared CI skip in MAY_SKIP

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Slot gate: a stored delivery leaves the line when its worker removes it (#938)

A stored webhook delivery whose worker run ended before it asked for a
slot (task paused, trigger changed, blocked by policy, or the run failed
before its ask) kept its place in the slot gate's waiting line until the
5 s sweep. Another task's delivery that came in meanwhile was stored and
delayed instead of run.

keepStored, the fork hook the worker already calls after each run and
right before it removes the row, now frees that row's place whenever it
does not keep the row. No new lines in upstream files. Tests: paused,
trigger changed, and a run that fails before its ask.

Fixes #915

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Seam check: count pending-file text changes from upstream; refuse duplicate keys and dropped announcements (#796, #813) (#939)

* Seam check: count pending-file text changes from upstream; refuse duplicate keys and dropped announcements (#796, #813)

- A pull request that changes a pending file's text is now counted from
  upstream in its run, against main's ceiling and lost entry, even with its…
scuttletoby added a commit that referenced this pull request Nov 30, 2026
…al, here or over a link (#808) (#1254)

* fix(secret-sweep): a reset run's re-run goes on from its own record; gates held by behaviour (#703) (#782)

Follow-ups to the sweep record after #720 (its lens B minors 1-5):
- A re-run of a reset_record run reads its own first attempt's record
  (written after the reset) and no older run's; without one, the empty
  record; a failed read of it keeps nothing, so attempt 1's stays.
- A re-run reads its own run only in a run of fork-secret-sweep.yml
  (GITHUB_WORKFLOW_REF), not in another workflow's run.
- Tests: a failed read, then a failed runs lookup or the time limit,
  keeps no partial record (each gate alone now goes red when removed);
  a contract ties the 20-minute lookup limit to the job's time-out.
- fork-secret-sweep.yml: a sweep that runs during a reset run undoes it.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork-kit/review: general review skill, adoption guide, gate comment format and eval harness (#790)

A new kit folder with the general review rules a project adopts instead of keeping its own copy:
- SKILL.md: lenses picked by changed path from the repo's `review` config (the gate's own judge), the state
  question every time, two independent lenses for critical paths and one for normal, at most two lens rounds
  and then the orchestrator checks the fix diff, minors into one follow-up issue, root-cause fixes, attacks
  that leave failing tests.
- REVIEW.md: how a project adopts it (review block in shadow first, lens prompt files, the gate, kit settings).
- COMMENTS.md: the lens comment format, every example stated with how the gate reads it; a test feeds each
  example through the gate's real parser, so the doc cannot drift.
- lib/review_kit.py: `plan` (weight, lenses, runners, rounds from the gate's rules and the kit settings),
  `check` (how the gate reads a comment, plus a state line), `doc` (the doc check).
- lib/review_eval.py and eval/: the model and effort eval, every project fact from one config file.

Runners are kit settings with defaults (.github/review-kit.json), not rules text. No change to fork-ci.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* placement P5: pure rule engine, hard rules H1 to H9 and upstream's rank (#787)

* placement P5: pure rule engine, hard rules H1 to H9 and upstream's rank

A pure function in packages/shared that picks the machine a delegated
task runs on: the nine hard rules of the placement design, each with a
plain reason, then upstream's load-balancing score for the order. No I/O,
no server wiring, no setting: P2, P3 and P6 map into its plain types.

Upstream's score stays in packages/client-runtime/src/load-balancing.ts,
unchanged. Moving it would change upstream lines (and grow the pending
packages/shared/package.json), so the engine calls it instead.

Table tests for every rule (pass and fail with its reason) and for every
row of design section 7 that needs no I/O.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* placement P5: fix round from the #787 reviews

- A named machine without facts now meets every rule that needs no facts:
  H1, H3, H7 (the pick-time lookup, not a fact; a lookup that did not run
  fails) and H9 (a placed child no longer places onward through it).
- Facts fail closed on NaN, infinite or negative numbers: cores, total and
  free memory, receipt time (counts as too old), free slots, memory floor,
  free memory, CPU use, and the link's expiry time. Each has a plain reason.
- H3 passes only known modes, so an unknown access value or an unresolved
  task mode is refused.
- Labels, needs and never groups are compared trimmed and lower-cased,
  blanks and repeats dropped (canonicalLabels, for P2 to store the same
  way). A blank need is never met; a blank group member is dropped.
- At the memory floor is available, as the slot gate and P3. A floor of 0
  keeps nothing back.
- Duplicate machine ids give a plain refusal.
- The unranked reason names a weight word this build does not know, and
  says "free memory 5 % or less" only when that is the cause.
- Comments match P3's slot answer; the module header repeats the P6
  follow-up.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Review rules: T3 side of findings, scans and rounds on shared vectors (#781)

* Review rules: T3 side of findings, scans and rounds on shared vectors

A pure TypeScript copy of the CI gate's review rules (path plan, lens
comment headers and scan, findings, rounds) under
apps/server/src/fork/reviewRules, so T3 tools and the gate agree. Both
sides replay review.vectors.json, which gains findings, scans and rounds
sections; each side fails on a section or field it does not run. The
Python findings tables move into the vectors file (one source).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Review rules: port lens_problem, linear-time table rows, fork-owned vectors

- fork-owned-paths: the shared review vectors and the lens corpus are not
  fork-owned, so a change to the gate and its vectors runs the server's
  review-rules test (its Lint check reads them).
- lensComment.ts ports lens_problem: a report whose first line is a valid
  header but which holds a second lens header (quoted, fenced, plain or
  loose) reads nothing, exactly as the gate judges it. 18 new shared scan
  vectors, generated from the gate's answers.
- Gate and TS copy: a table row is plain-folded once per row and the
  "first non-empty cell after j" is one backward pass, so a wide row reads
  in linear time (was quadratic in cells). Same answers; timing tests on
  both sides.
- Gate: a number reference past int's 4,300-digit limit no longer raises
  in html.unescape; it reads as its value (or U+FFFD past Unicode), as the
  TS copy already did. Two shared vectors.
- README: how a vector is made.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork-ci: review rules guide "release, pin, then config" and gate caller notes (#778)

* fork-ci: review rules guide "release, pin, then config" and gate caller notes

The pr-queue README gets one section on turning the review rules on: the
release, the pin in every caller, the config in shadow, reading the shadow
rows, enforce, roll back, and what each half-way state does. The gate caller
example names the pull_request_target policy and when the required-lenses
input may be emptied. The release notes list #740 (findings, rounds,
override_authors) for the first release after ci/v20.

review_guide.test.py ties the guide to the code: links resolve, the steps
keep their order, the release names match the tags, the quoted summary rows
are what head_check writes, and the half-way states behave as described.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-ci: review rules guide: owner step, the empty input's floor, and tests tied to the guide

Fix round for the two reviews of this pull request:
- the two states only an owner gets out of (input emptied under shadow, a ci/v14
  gate meeting the block) now say so, with the owner step: revert by hand, then
  dispatch the backfill; a gate on ci/v15+ refuses the block pull request itself
- emptying required-lenses drops the one-lens floor: said in step 5 and the
  example caller, with a rule that keeps AGENTS.md/CLAUDE.md at one lens
- the enforce pull request does not need the critical lenses yet; the pin back
  is a review rule; arm nothing between enforce and the backfill
- the pin step names actions/pinned pin configs; step 4 lists unreadable lens
  comments and the findings row's approach and findings: false parts
- tests: releases checked against the ci/vN tags where the clone has them, each
  half-way test reads the guide's words, the never-failing same-inputs test is
  gone, merged-config refusal tested on a throwaway repository

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* review guide test: declare the two tag-only ReleaseTags tests as may-skip

CI checks out without the ci/vN tags, so these two skip there; fork-ci now
requires every skip to be declared.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork contracts: pin review_guide's two tag-only ReleaseTags skips (MAY_SKIP)

The review guide test declares two `may skip` lines (ReleaseTags needs the
ci/vN tags, which CI's checkout does not fetch), but the pinned table was not
changed with them, so the record check found a skip set it did not pin.
The LauncherAsRoot entries were already equal on both sides.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Model policy: an effort must be under the id the row's driver reads, on both sides of a link (#780) (#793)

* Model policy: an effort must be under the id the row's driver reads, on both sides of a link (#780)

A pick whose effort sat only under an id the running driver does not read
(an ACP `thought_level` for a Claude row, `reasoning` for Claude, `effort`
for an ACP agent) counted as naming an effort, so the driver ran its own
default level unchecked. Each row with efforts now needs the effort under
its driver's own id: the fixed id of a built-in driver, else the control
the checking machine's own catalog marks for the model on that driver's
instances. A driver whose id is not known there refuses (fail closed).
The receiving machine checks a linked agent's pick with its own catalog;
the sending machine checks every row's driver with its catalog.

Minors: a remote pick reads a catalog's ultracode default both ways and
gets the full-id alias hint; Settings reads each machine's lists apart,
flags names Claude Code resolves by itself, and reads an instance's
catalog effort control for its marks; tests for "an id is never an
alias"; a stale test comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Model policy: refuse an option the policy cannot read, keep the guard's driver ids in step (#793 review)

- While a policy is on, a pick may name only options this machine's model list
  describes for the model (the instance's list; any list here for a call sent to
  a linked machine), effort ids the policy reads, or ultracode. A driver can still
  apply any other option after the checked ones: Kiro's effortLevel, Grok's native
  thought_level, an ACP agent's hidden _t3/session-mode, or a model option written
  after the model. Enforce refuses it with the fix; advise reports it.
- The "effort id not known here" refusal now says how to fix it (and drops the
  "a acpRegistry" typo).
- The model guard's sync test compares the server's driver effort ids with the
  guard's DRIVER_EFFORT_IDS entry for entry, both ways.
- Docs: the "a second effort option cannot hide a higher effort" sentence is now
  true, and says how.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork seams: announce the Codex MCP profile lines (MCP profiles part 5, step 1) (#801)

Announces the two lines in CodexAdapterV2.ts that wrap its app-server
client factory with apps/server/src/fork/codexMcpProfile.ts. No code.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork seams: announce the tool_search filter lines (MCP profile design PR 4, step 1) (#806)

Step 1 of "Adding a seam line" in docs/fork/updates.md: the list only,
no code. A new entry for apps/server/src/mcp/McpToolExposure.ts with
"added": [] and two announced lines: the import of searchableT3Tool from
fork/mcpT3ToolFilter.ts, and one .filter(searchableT3Tool) step in
tool_search's ranking chain. The code follows on its own branch.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork seams: announce the unsigned macOS ad-hoc signing line (#822, step 1) (#832)

List only. Announces the one scripts/build-desktop-artifact.ts line that sets identity "-" and the
sign hook scripts/fork-codesign.cjs for macOS builds without signing secrets; the pull request
that closes #822 adds it.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fix(server): a child that already exited keeps its exit code when its stdin write breaks (#840)

The process runner writes a program's stdin while the program starts. A program that exits at
once (the handoff's missing program under `timeout` exits 127) can close the pipe before that
write, which then fails with EPIPE. The runner reported that as a stdin error ("its output could
not be read") and dropped the exit code, so the handoff test failed in a few CI runs of a hundred.

A broken pipe on stdin is now ignored: the exit code and output say how the program ended. Any
other stdin error is still an error. The check lives in fork/processRunnerFork.ts, with the fork's
output-tail collector moved there too, so processRunner.ts's pending ceiling drops from 35 to 8.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* placement P2: placement and placementNeeds setting contracts (#798)

* fork placement P2: placement and placementNeeds setting contracts

`placement` (mode off/advise/enforce, labels, factsCommand, never groups,
weights per linked machine) and `placementNeeds` (server value, and a
project override), added the way the fork's other settings are: fields,
patch fields, patch rules and pin rows in forkSettings.ts/forkDefaults.ts.

- An old or empty settings file reads as off with no needs.
- A bad placement value reads as off with the reason in `problem`; the
  person's text is kept in `unreadable` and written back until the key
  is saved (as modelPolicy). The rest of the file still loads.
- A save is strict (bad field or unknown key refused); a field left out
  keeps its value; a save over a kept unreadable value starts from off.
- Both keys are person-only (derived); a project's needs are kept when an
  older client's save leaves them out, and only null clears them.
- A managed policy locks placement as a whole value.

Contracts only: nothing reads the settings yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork placement P2: fail closed on bad placementNeeds, whole saves over bad placement

- A bad placementNeeds (server or project) now reads as broken: the work fits
  no machine (readPlacementNeeds gives the plain reason), the problem is kept,
  and the person's text is written back unchanged by other saves until the
  key is saved. A project save may send the kept text back only unchanged.
- Over an unreadable placement, a save that names only some fields is
  refused ("placement is not valid; save the whole setting"); a whole save
  replaces it.
- factsCommand must be a full path on the server's OS (playtest's check):
  a save of another OS's path is refused, and one in the file reads as off,
  kept, with its problem. Control characters are refused.
- Labels are stored trimmed, lower-cased and without repeats (so
  ["GPU", "gpu"] is no never group); weight keys with spaces are refused.
- Tests for each, a policy lock row for placementNeeds, and the docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork placement P2: read factsCommand on this OS where placing reads it

The load and normalize lines added to upstream's serverSettings.ts are
gone (no pinned seam line runs after a save's normalize, so the same
result could not go through one). Placement code now reads placement
through apps/server/src/fork/placementRead.ts (readPlacementForThisOs):
a factsCommand this OS cannot run reads as off, kept as written, with
its problem. The save check that refuses setting one stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork placement P2: manage placement and placementNeeds only as a whole

Main now names the fork settings that read null in one list (WHOLE_ONLY), and
the pin test requires it to match exactly. Both placement settings read a bad
value, null included, as off/unset, so both join the list: a policy locks
placement as a whole, a path inside it is refused, and the manageable-settings
list shows placement as one path instead of its fields.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork placement P2: type the server's placementNeeds patch as the settings hold it

The web settings code builds a save from part of the settings, so a held
placementNeeds value (a kept bad value included) must fit the patch type.
The patch field was typed as plain labels, which broke the web typecheck.
PlacementNeedsPatch is now typed as PlacementNeeds while its decode stays
strict: only labels are taken, and a save replaces a kept bad value whole.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork test: read the MCP profile record at once in the scheduled-task tests

A webhook run is forked and reads the record file, and these tests give
forked work a fixed number of event-loop turns. On a loaded machine a read
on Node's thread pool can outlast them ("never: the owner's task ran"), on
main as well as on branches. The service in these tests now reads whole
files synchronously, so a run takes the same number of turns on any machine.
With the thread pool kept busy the test failed before and passes now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork placement P2: check only placementNeeds in the patch-type test

Since the merge of main, a whole Partial<ServerSettings> no longer fits a
patch (another field is nullable in settings only). The test checks the
placementNeeds field it is about.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* feat(playtest): the playtest MCP tool (start, push, status, end) (#809)

* feat(playtest): add the playtest MCP tool (start, push, status, end)

One tool in the waits toolkit over the playtest service. The thread is the
caller's own, from its MCP credential; the tool takes no thread and no
setting. Refusals (playtest off, busy, no session) come from the service
with what to do next. Docs: playtest.md gains the tool section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(fork): list the playtest tool in FORK_CHANGES (#809)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(playtest): own tool group; start and push need a full-access thread (#809)

- `playtest` is its own MCP tool group (MCP_T3_TOOL_GROUPS gains "playtest";
  MCP_T3_TOOL_OWN_GROUPS pins the tool in the waits toolkit to it), so a
  profile that keeps `waits` does not get it. Test: every T3 tool is in
  exactly one known group, and playtest alone in its own.
- `start` and `push` refuse a thread that is not full-access or is in plan
  mode, by the thread's modes as the server records them at each call.
  `status` and `end` stay open, so a restricted thread can release its target.
- Status tells the agent to call end for a claim cut off by a stop and for a
  release that has not worked yet.
- The waits tools share one calling-thread helper.
- `start` joins the unknown thread-argument test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork: report a linked child's pending prompts to its parent (#808 row 1) (#815)

* fork: report a linked child's pending prompts to its parent (#808 row 1)

A delegated task on a linked machine always reported
hasPendingQuestion false and pendingApproval null, so its parent never
learned the child was waiting.

- New fork route GET /api/fork/task-prompts on each machine: the open
  questions, approval and secret requests (label and reason only, never
  a value) of one of its threads. Link token only.
- task_status, delegate_task and their waits read it over the existing
  link through the fork seat remotePrompts (one spread line in the
  remote read). An unreachable or older machine reads as unknown in
  next, never as "not waiting".
- A watcher wakes the parent once per prompt, the way a local child's
  question does: it ends a blocking wait if there is one, else it queues
  one wake message, and cancels that message if the prompt is answered
  there first. Wake ids are fixed, so a restart sends no second wake.
- OrchestratorMcpService.ts is a pending file and may not gain a fork
  line: the Effect.scoped comment moves onto the (already fork) line it
  explains, which frees the line the seat takes. Still 35 fork lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* FORK_CHANGES: link #815

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork: quote a remote child's words; a wait has a prompt only while its run lasts (#815 fix round)

- Text and ids from the linked machine: ids only on a strict pattern (else
  unknown, "refused"), at most 50 prompts, a secret's label and reason
  folded to one line, capped (80/300) and quoted as the child's words.
- A secret never goes to a blocking wait; it is always a queued message.
  A question or approval handed to a wait counts only while the parent's
  run lasts; after it, one message if it is still open there.
- The receipt of a sent wake is read before a slot is taken; a machine
  that does not answer is asked once per round; "older" also names a link
  no longer accepted.
- The remote read's spread line carries its // Fork: marker (no new line).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* host tools: per-OS path layer (real-path resolve, Windows and macOS oddities) (#816)

* host tools: per-OS path layer (real-path resolve, Windows and macOS oddities)

resolveHostPath(input, {platform, fs}) follows every link, junction and
mount point to the real target and returns that path plus the compare key
the policy core will match reach kinds and secret patterns against, or a
plain refusal. Platform and file-system calls are injected, so the Windows,
macOS and Linux cases all run on any CI machine; nodeHostPathFs is the thin
real adapter. Nothing is wired yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* host tools path layer: fix round for both lenses

- Map macOS firmlinks on the walked path and on the OS answer; full list.
- Refuse /.vol, /dev, Linux /proc, /sys, the document portal, and devices,
  pipes and sockets.
- Add secretKey, always folded (full case map, NFKC, ignorables dropped);
  compareKey stays exact per OS.
- Cross-check the walk with the native realpath and refuse a different answer.
- Win32 collapses typed ".." first; cap the walk at 4096 steps.
- Header states the contract for 1.2 and 1.4.
- Tests: an independent fake file system, a regex case-fold oracle, state
  cases, real-adapter checks, and Windows/macOS tests skipped elsewhere.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* test(cleaner): one clock for report test stamps, so a mark's line stays the same (#819)

The report's mark names the last counted log line by its exact text. Three
Freed tests wrote the log twice and rebuilt an already-counted line with a
fresh stamp; when the clock crossed a second between the two, that line no
longer matched the mark, the report treated the log as trimmed and counted
the old delete again ("at least 5.0 GB (2 deletes)").

The real log is append-only, so the report code is right; the tests now
build each line once and reuse it, and stamp() reads one clock for the run.
Forcing a second boundary (time.time() moving one second per call) fails
the three old tests every time and passes the new file.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* heavy facts: per-kind fits from the kernel ledger; kit capacity evaluator and callers (#786)

* heavy facts: per-kind fits from the kernel ledger; kit capacity evaluator and callers

Dynamic slots design row D6. The kit gets a Python evaluator of the shared
capacity rule (lib/capacity_rule.py) that passes every vector and format case
the TypeScript tests read, and `heavy facts [--kind K] [--mb N]`: one free/v1
object with per-kind "fits" from a ledger read from the kernel (heavy's live
tickets plus T3's agent scopes, unlabelled = writer), a 5 s cache, the Basic
tier, unreadable signals as elevated, and per-folder reservations.
bin/t3-capacity and bin/agent-slots are thin callers of it that keep the older
output and exit codes; a facts call that is slow (5 s) or fails is never free.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* heavy facts: every ticket is a job, folders match exactly, basic tier and other users fail closed

Fix round for the two D6 reviews.

- A heavy ticket whose kind the rule does not know (tsc, gradle, a project's
  own) is the rule's unknownKinds.job, never an agent; heavy facts --kind
  with an unknown name asks for that job too.
- A reservation folder matches itself and what is below it, with or without
  a trailing '/', never a sibling sharing its first letters; its real path
  matches too. The caller's own folder is its real working folder only.
- Basic tier (no cgroup v2 or no user manager) is never free and fits 0.
  Full tier also counts every other user's heavy jobs and agent scopes
  from their user managers' cgroups; a folder that cannot be listed is
  basic. Without a cache folder every call starts "elevated".
- lib/capacity_readings.py: the shared reader's port. It runs every
  capacity-readings.json case and the "a failed reading never admits more"
  check; memory, PSI, cores and container limits now come from it, a box
  with a live piece but no folder is unreadable, a cut-short memory.stat
  owes in full.
- The cache has version 2 and a key of its settings; t3-capacity takes the
  rule's whole hold; a fill count of 2.5 asks three times, as in TypeScript.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* heavy facts: kit tests check out the capacity rule; its JSON names no kit path

The heavy kit's evaluator, its tests and heavy-install read the capacity rule
from its one source, packages/shared/src/capacity, but the sparse checkouts of
the workflows, action_tests and kit_tests jobs left that folder out, so
install.test.py and facts.test.py found no capacity-rule.json. The folder is
now in the three lists (and in the `workflows` comment that says why each app
file is there).

The "//" notes of capacity-rule.json and capacity-readings.json named the
kit's Python files, which the fork-owned-reads lint counts as app code reading
a fork-owned path; they now point to README.md beside them, which names them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork seams: announce the thread menu's MCP profile lines (MCP profile design PR 3, step 1); also restores the HO5 announcement lost in #777 (#807)

* fork seams: announce the thread menu's MCP profile lines (MCP profile design PR 3, step 1)

List only. The thread menu gets the MCP profile entry: the thread's
effective profile, and the owner's pick or clear for a client that may
change settings. Its logic and runtime are fork files
(apps/web/src/components/fork/mcpProfile/); upstream's menu files need
four lines in threadActionMenu.logic.ts and three each in
useThreadActionMenu.ts and Sidebar.tsx, announced here. The code is on a
branch pushed without a pull request until this merges.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fork seams: also restore the HO5 announcement lost in #777

The squash merge of #777 dropped every HO5 announced line from
.github/fork-seams.json. Restore them exactly as they were, inside the
same per-file entries as this PR's MCP profile lines (one key per file).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* handoff HO4: source `agent` (write turn, marker, cap, joined check) (#824)

* handoff HO4: source `agent` (write turn, marker, cap, joined check)

The old session gets one normal turn on its own thread with the
setting's instructions; its reply is part 2 of the handoff when the
turn completed, no other message joined it, the reply starts with the
marker line and is within the command source's 32 KB cap. A reply that
does not count falls back like the command source (size: parts 1, 3, 4;
idle: nothing). A stopped, failed, joined or timed-out write turn means
no handoff: the old session carries on. Fixed ids per source run, so a
run never writes or hands off twice; the write run is no turn end and
stays out of the transcript. Default stays off; no migration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* handoff HO4 fix round: write turn never lost, stopped at its timeout, quiet

- A late update of the source run, or a restart, no longer drops part 2:
  any loop that finds a write turn as the latest run carries it on to its
  handoff (fixed ids, so at most once).
- A message steered into a write turn stays in later handoffs' part 3; only
  the write turn's prompt and marked reply are left out.
- A failed or timed-out write turn at the size backstop sends parts 1, 3
  and 4 (idle: nothing), as the command source does.
- Notes lines that could pass for the message's own lines are quoted.
- T3 stops a write turn at its timeout (run.interrupt, its own reason);
  after one such stop the next size handoff uses the fallback at once.
- A completed write turn is marked quiet, as the handoff run is.
- New source `none` is the default, so a saved handoff setting keeps its
  old behaviour; `agent` only when set.
- The last reply that starts with the marker is used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* handoff command test: "could not start" without the stdin race

A missing program under `timeout` can exit before the empty stdin is
written, so the reason sometimes read as an output error. The case now
uses a spawn that fails (its project folder is gone); exit codes 126 and
127 stay covered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork-kit/gh-apps: call forms and GH_REPO check of the older per-user gh-as (#835)

* fork-kit/gh-apps: call forms and GH_REPO check of the older per-user gh-as

gh-as now also takes `gh-as NAME -- gh ...`, `--repo=`/`--app=` and `--help`, and refuses a GH_REPO in the
caller's environment that names another repository instead of silently ignoring it. New parity.test.py covers
these and the state cases: an expired, half-written or empty token cache, a killed run's temp file, config
missing or empty, two gh-mint runs at once (one mint), cache modes, and no token in any message.

Fork audit #834, item G1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/gh-apps: lens nits for the gh-as parity PR

- wrapper: a refused GH_REPO is masked before it is cut, so no start of a
  token is ever quoted; GH_HOST other than github.com is refused too
  (README says which variables are checked and which are only dropped).
- admin add-key: refuses the app name "gh" (gh-as gh -- gh ... reads it as
  the gh command, so it could not be picked by name).
- privileged gh-as: a repeated --app or --repo is a usage error, as in the
  wrapper, not last-wins.
- README: the new key is piped straight into root, never stored where an
  agent can read it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/gh-apps: root test expects the wrapper to refuse a foreign GH_HOST

The wrapper now refuses GH_HOST other than github.com, so the environment
test checks that refusal, sends the rest of the attack environment through
the wrapper, and still sends all of it (GH_HOST too) to a direct sudo call.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork release: SHA256SUMS covers the desktop files; unsigned macOS apps are ad-hoc signed last (#822) (#833)

* fork release: SHA256SUMS covers the desktop files; unsigned macOS apps are ad-hoc signed last (#822)

SHA256SUMS now lists every file a person downloads: the server archives and the desktop apps
(macOS dmg and zip, Windows exe, Linux AppImage), written in assemble after all desktop builds.

Without signing secrets electron-builder found no identity and signed nothing, so the macOS app
kept only the linker signature of Electron's executable and `codesign --verify --deep --strict`
failed on it. Unsigned macOS builds now set identity "-" with the sign hook
scripts/fork-codesign.cjs, which runs `codesign --force --deep --sign -` as electron-builder's last
change to the bundle, before the zip and dmg. A new verify_mac_signature job, which assemble waits
for, unpacks each shipped zip and dmg and runs `codesign --verify --deep --strict`.

The one line in scripts/build-desktop-artifact.ts is recorded in .github/fork-seams.json.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork release: review fixes for the desktop SHA256SUMS and ad hoc signing (#822)

- SHA256SUMS: `sha256sum --` (bare names kept) and compgen presence checks,
  so actionlint passes; a step before the upload checks every file the
  publish job uploads (less blockmaps and manifests) has a matching line.
- verify_mac_signature: no token, each dmg detached on any exit, the
  signature's Identifier/Signature/Authority in the step summary, and the
  hashes of the four checked files as an output; assemble fails when the
  macOS lines of SHA256SUMS differ from them.
- fork-codesign.cjs refuses any identity but "-" and says why entitlements
  and hardened runtime are ignored; scripts/fork-codesign.test.ts tests the
  hook and createBuildConfig's signed and unsigned macOS config.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* docs/fork/agent-rules.md + fork-ci doc-check: general agent rules, once (#874)

* docs/fork/agent-rules.md + fork-ci doc-check: general agent rules, once

docs/fork/agent-rules.md holds the agent rules that hold in every project
and on every machine, each once with a one-line why. Machine and project
facts stay in their own instruction files and config; review rules link
to the review skill instead of being copied.

fork-ci/actions/doc-check is a general port of a project's doc check:
size budgets and a no-history rule for instruction files, broken relative
links in changed Markdown, and no dated report files added. Budgets and
patterns come from an optional project config read at the base commit,
with defaults; a missing or empty config means the defaults, a broken one
exits 2.

Part of #834

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* git-clean test: doc-check is an action that runs the git check first

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork seams: announce the settled provider thread lines (#846, step 1) (#907)

List only (step 1 of "Adding a seam line"). Fixes the race behind the
flaky Kiro turn_interrupt replay test (#846): at a turn's end the ACP and
Cursor adapters cache the provider thread as active, and usage or shell
updates that arrive after the turn re-send that snapshot session-scoped,
which the server writes without a run guard. When that write lands after
the run's final idle write, the ended thread stays active.

The fix adds one override line (and a comment) after upstream's status
line in each adapter, so the cached snapshot is idle like the server's
final write, and one check in each adapter's existing test. No upstream
line changes, so no lost-line count is needed.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fix(acp,cursor): a turn's cached provider thread is settled, so late updates cannot mark it busy (#909)

* fork seams: announce the settled provider thread lines (#846, step 1)

List only (step 1 of "Adding a seam line"). Fixes the race behind the
flaky Kiro turn_interrupt replay test (#846): at a turn's end the ACP and
Cursor adapters cache the provider thread as active, and usage or shell
updates that arrive after the turn re-send that snapshot session-scoped,
which the server writes without a run guard. When that write lands after
the run's final idle write, the ended thread stays active.

The fix adds one override line (and a comment) after upstream's status
line in each adapter, so the cached snapshot is idle like the server's
final write, and one check in each adapter's existing test. No upstream
line changes, so no lost-line count is needed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(acp,cursor): a turn's cached provider thread is settled, so late updates cannot mark it busy

Fixes #846. At a turn's end the ACP adapter (Kiro, Kimi, Grok, fx and the
ACP registry agents) and the Cursor adapter cache the provider thread as
active. Usage or session info that Kiro sends after the cancelled prompt
(and Cursor's background-shell updates) re-send that cached snapshot as a
session-scoped update, which the server writes without a run guard. When
that write lands after the run's final idle write, the ended thread stays
active for good; the turn_interrupt Kiro replay test caught it now and
then.

The cached snapshot is now settled (idle, or error for a broken thread)
like the server's final write. One override line after upstream's status
line in each adapter, announced in .github/fork-seams.json.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork CI: each listed Python test declares its format, judged by it alone (#702) (#784)

- .github/fork-ci-tests.txt: a Python test's line ends in "unittest" or "ok lines". A Python
  line with neither is refused with what to write; either word on a non-Python test is refused.
  All 87 listed Python tests now say theirs (78 unittest, 9 ok lines).
- countTests: a Python test with no declared format counts nothing; it is never read as either.
- fork-contracts.test.py: its record fixtures pass the format the list would give.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* MCP profiles: Settings section and thread pick logic (design PR 3) (#804)

* MCP profiles: Settings section, thread picks and the menu entry's logic (design PR 3)

Settings → Fork gets its MCP profiles section (McpProfileSettings.tsx):
the built-ins all and t3-only read-only; add, edit and delete named
profiles (servers all or a list, t3Tools all or a list of the shared
MCP_T3_TOOL_GROUPS); the default profile and the sub-agent rule with the
usual project-override control; each thread's pick, changed or cleared.

Every patch names only what it changes: one mcpProfiles entry, or one
thread's mcpThreadProfiles key (null clears), and a pick or clear that
changes nothing writes nothing. A built-in name cannot be taken; a
profile something names cannot be deleted (the panel says who, and offers
to clear the thread picks). An entry with fields from a newer build shows
as broken, never as a profile; one with unknown tool groups as from a
newer version; neither is editable. Rows follow ForkRow's lock, so a
client that cannot write settings gets inert controls.

The pure resolver moves to packages/contracts/src/mcpProfileResolve.ts
(re-exported by the server's fork/mcpProfile.ts, unchanged behaviour) so
the app reads entries by readMcpProfileEntry and shows a thread's
effective profile from resolveMcpProfile, a child's cut down to its
parent's. The thread menu entry's logic is in
components/fork/mcpProfile/threadMcpProfile.logic.ts; wiring it into the
upstream thread menu needs seam lines, announced separately.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* MCP profiles: read the client's thread shells (delegatedFrom null) and a carried profile

The app's thread shells hold delegatedFrom: null for a thread nobody
delegated; the menu logic now takes that shape. Test: a task another
machine delegated is cut down to the profile it carried, and a shell
with delegatedFrom null is a top-level thread.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* MCP profile settings: add a thread pick only with a chosen profile

- "Add thread" opens a form with the thread id and a profile picker next
  to it; one save writes that thread's key with the chosen profile.
  Nothing is written for a typed id alone, on Enter without a profile,
  or on cancel.
- The form and each pick row say what the pick gives the thread, and
  warn when that is more than the parent's cut-down set (a pick is never
  cut down to the parent's).
- The server refuses deleting a profile that the default, the sub-agent
  rule, a project or a thread pick still names, with the same rule and
  wording source as the panel (mcpProfileUses).
- "Clear the thread picks that use it" checks the lock of
  mcpThreadProfiles, the setting it writes.
- A blank pick hand-edited into settings.json shows as broken (it is
  ignored) and can be cleared.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork-kit/heavy: machine-file holds for heavy facts / t3-capacity (stacked on #786) (#843)

* heavy facts: per-kind fits from the kernel ledger; kit capacity evaluator and callers

Dynamic slots design row D6. The kit gets a Python evaluator of the shared
capacity rule (lib/capacity_rule.py) that passes every vector and format case
the TypeScript tests read, and `heavy facts [--kind K] [--mb N]`: one free/v1
object with per-kind "fits" from a ledger read from the kernel (heavy's live
tickets plus T3's agent scopes, unlabelled = writer), a 5 s cache, the Basic
tier, unreadable signals as elevated, and per-folder reservations.
bin/t3-capacity and bin/agent-slots are thin callers of it that keep the older
output and exit codes; a facts call that is slow (5 s) or fails is never free.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* heavy facts: every ticket is a job, folders match exactly, basic tier and other users fail closed

Fix round for the two D6 reviews.

- A heavy ticket whose kind the rule does not know (tsc, gradle, a project's
  own) is the rule's unknownKinds.job, never an agent; heavy facts --kind
  with an unknown name asks for that job too.
- A reservation folder matches itself and what is below it, with or without
  a trailing '/', never a sibling sharing its first letters; its real path
  matches too. The caller's own folder is its real working folder only.
- Basic tier (no cgroup v2 or no user manager) is never free and fits 0.
  Full tier also counts every other user's heavy jobs and agent scopes
  from their user managers' cgroups; a folder that cannot be listed is
  basic. Without a cache folder every call starts "elevated".
- lib/capacity_readings.py: the shared reader's port. It runs every
  capacity-readings.json case and the "a failed reading never admits more"
  check; memory, PSI, cores and container limits now come from it, a box
  with a live piece but no folder is unreadable, a cut-short memory.stat
  owes in full.
- The cache has version 2 and a key of its settings; t3-capacity takes the
  rule's whole hold; a fill count of 2.5 asks three times, as in TypeScript.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* heavy facts: kit tests check out the capacity rule; its JSON names no kit path

The heavy kit's evaluator, its tests and heavy-install read the capacity rule
from its one source, packages/shared/src/capacity, but the sparse checkouts of
the workflows, action_tests and kit_tests jobs left that folder out, so
install.test.py and facts.test.py found no capacity-rule.json. The folder is
now in the three lists (and in the `workflows` comment that says why each app
file is there).

The "//" notes of capacity-rule.json and capacity-readings.json named the
kit's Python files, which the fork-owned-reads lint counts as app code reading
a fork-owned path; they now point to README.md beside them, which names them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/heavy: machine-file holds for heavy facts (t3-capacity), on top of the kit capacity check

Built on the kit's `heavy facts` and its thin `t3-capacity` caller (#786) instead of a second capacity
evaluator. What the older host check had that the kit's did not:

- heavy.capacity.holds in the machine file: a cgroup outside the user managers (a CI runners' slice) that
  is in use keeps its budget less its use, as a reservation, for every user but its own. Missing file,
  section or key: no holds; a broken one: no answer (t3-capacity NOT OK naming the key); a changed one
  is read again at once (cache key).
- The sweep and the queue accept the new `capacity` key.
- Tests for the state question: holds in use or idle, own users, missing cgroup, unreadable memory.max or
  memory.stat, machine file missing/empty/garbled/writable by others/unknown key, a changed file within
  the cache's 5 s, a reservation file cut short, a reservation whose processes are gone; one red check.

Part of #834 (G2, first half).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork-kit/review: one general review skill; tiers, failure table, nit-only check and a drift test (#845)

* fork-kit/review: one general review skill; tiers, failure table, nit-only check and a drift test

The kit's SKILL.md becomes the one general review skill, so a project keeps only its facts (review block, lens
prompts, kit settings) and a thin adapter. Merged in from the project skill: the tier table as the gate's weights,
the author's failure table, nit-only quick check, batch per area, twin lens names, focus lenses, covered rule, the
extra general lenses, and a concurrency part in the eval lens. Conflicts go to what the gate parses: the state answer
on a `state:` line and `blocker:`/`major:`/`minor:` lines.

New test (comments.test.py, SkillFormat): every report shape the skill, the eval lens and COMMENTS.md tell a lens to
write reads as a clean read with a state line through the gate's own parser; the skill's tiers match the gate's
weights and recommended min_lenses; the state question is word for word in the skill, the eval lens and REVIEW.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/review: skill matches the gate on rounds, protected paths and check exits

- A quick check is a lens read of a new head, so the gate counts it as a
  round; the skill names rounds.approach_at / approach_lens / max, how to run
  the approach lens, and that only an override by a listed override_authors
  login waives it.
- The tier table names the gate's always-critical paths (queue config, lens
  prompts, .github/workflows/**); the light row no longer says config is light.
- focus: removed (nothing reads it); twin lenses described in general terms.
- check exits 1 for a real blocker or major by design; never soften a finding.
- not a lens: also needs no read-at sha outside a quote (COMMENTS.md rule).
- Drift test reads the round keys and recommended approach_at through the
  gate's parser and judge_rounds, the protected paths from review_judge, and
  the runner defaults from review_kit.DEFAULTS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/review: the override passes a nit-only fix head, a quick check never does

The gate passes a head only when every lens's newest read names it or a newer
override covers them (lens.Review.reviewed_head). A quick check is one lens on
the fix head while the earlier lenses still name the old head, so it alone
holds the head. SKILL.md step 7 now says which head passes and that on
`nit-only: yes` the orchestrator still posts the override; COMMENTS.md says the
same. The round count says "whichever is higher", as review_round does.

Tests: a history (code at A, code r2 at B, fix C with a quick check) through the
gate's real reviewed_head and judge_rounds, pinned to the skill's words; the
protected-paths test now compares is_protected's answer with the skill's list
on every tracked file and on probe paths, so an inline rule fails it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Fix #911: a delivery refused for its profile leaves its place in line (#912)

A stored webhook delivery keeps its place in the slot gate's line from its
first, direct ask. When its worker run was refused for its MCP profile as it
started (before it reached its slot wait), the place stayed until the next
sweep, so for up to a sweep a free slot was refused to another run: that
run was stored for the worker instead of starting.

The flaky test hit this path only when the worker's run lagged behind a
fixed three worker rounds, so the widening landed before the slot wait it
meant to test. It now waits for that slot wait itself, and a new test
covers the start-time refusal, which leaves the place at once now.

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Review rules T3a: lens_start plan, prompt, refusals and request ids (pure logic) (#825)

* Review rules T3a: lens_start's plan, prompt, refusals and request ids (pure logic)

New fork files next to the review-rules logic of #781. Nothing registers a tool yet.

- planLensStart: per pull request and batch plan. Required lenses come from planReview and
  requiredLenses, the round from judgeRounds (the gate's own rules), so lens_start cannot
  require fewer lenses than the gate. A lens whose newest report already read the head (or the
  same change) is not started again. A batch gives one child per lens that reads every pull
  request needing it and posts one report per pull request, each with that pull request's head.
- Refusals: rules off (unset, empty, off, unreadable), a bad call, an unknown, closed or merged
  pull request, a caller head GitHub does not name, no plan (unreadable change, no rule, a lens
  prompt not read), round past the cap, a person's override already on the head.
- confirmLensStart: just before starting, a child whose pull request moved or closed is refused.
- lensRequestId: same lens and heads = same id, in any order; fits delegate_task's 256 chars.
- The server builds the prompt: read only, the lens text, the state question word for word with
  a `state:` line, finding prefixes, report size, round and earlier reads.
- Tests replay every shared case, round and scan vector (counts checked) and answer the state
  question: same start twice, head moved, old/empty settings, round at the cap, partial batch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Review rules T3a: lens_start plans what the gate reads (fix round A+B)

- Restart every lens entry that does not name the head once anything must
  start, required or not: the gate needs every lens comment on one head.
  An entry lens_start cannot start (no header, unknown lens) is refused
  with what a person does. A newer override the gate counts is honoured.
- Read the gate's required-lenses input and the review block's mode;
  without a block the input names the lenses (built-in prompt), and an
  empty input outside enforce, a bad name or a bad mode is refused.
- Plan each pull request of a batch with its own base branch's rules.
- Earlier lens children: an ended one restarts as the next attempt
  (replaces + note), a running one is returned, never started twice.
- Repo and heads read lower-case; the approach lens runs on the approach
  runner by its role; lone-surrogate lens keys get a distinct id.
- Tests: both lens-A scenarios, a property test over every shared vector
  state (the gate's verdict, modelled from its code, passes after the plan
  is carried out, or a person must act), and a test per new refusal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Slot gate: enforce the capacity rule by default (dynamic slots D4) (#823)

* Slot gate: enforce the capacity rule by default (dynamic slots D4)

The capacity rule now decides agent starts (mode "enforce", the default when
agentSlots has no mode and is switched off):
- owed term: every agent still starting, held slot or waiter ahead owes its
  full cost, so two starts in one second both count;
- kinds from the task role: research, review and design are light, anything
  else or no role is a writer; a light agent that grows past the light cost
  counts as a writer, so a wrong role cannot hide one;
- floors (2 agents, 1 job) and derived ceilings (3 agents per core, at most 64);
- fallback to the fixed ceilings (10 agents, 4 jobs) with start costs raised
  25% per trip after an OOM kill (oom_kill in /proc/vmstat rises) or swap under
  10% free; it lifts after 10 minutes of calm, whole readings. A restart starts
  in the fallback and at "elevated"; unreadable readings are never calm.
Typed limits still apply while enabled; "mode": "fixed" turns the rule off.
The delegate_task route passes its role to the slot gate with the target.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Slot gate: fix round after lenses A and B (D4)

- floor always starts, also with failed, hung or out-of-range readings;
  after 2 minutes unread the fixed 10 counts alone
- a restart lifts on calm for this host: swap counts by trend, the first
  calm needs the margin only; a 30 s timer takes readings
- costs from the rule file (light 384, writer 768); light cost clamped
- only agent-slice OOM kills raise costs; untold kills raise at most 2;
  each calm spell lowers one raise
- basic tier (no scopes or no oom_kill) keeps the fixed 10; unread
  running agents count once as writers
- unreadable settings use the fixed limits; true counts in refusals
- tests for the held slot, the role line, no OOM counter

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Slot gate: kit evaluator follows the swap-trend rule; scheduled-run tests build the gate at START

The merge of main brought the heavy kit's Python evaluator of the capacity
rule (#786), written for the rule before this PR. This PR's rule counts swap
by its trend (pressure.swapFillingMb; calm.swapFreeAtLeastPercent gone), so
the kit read a key the shared rule no longer has (KeyError in
capacity_rule.test.py and every heavy facts call).

- lib/capacity_rule.py mirrors capacityPressure.ts and pressureOf: raw_level
  takes the last read's swap free (filling = it fell by more than
  swapFillingMb; nearly full counts only while filling; filling is never
  calm; no previous swap read = trend unknown), next_pressure keeps or starts
  the calm wait on an unknown trend but never ends it, and the kept state
  carries swapFreeMb for the next read (heavy facts' cache carries it).
  The shared capacity-vectors.json swap-trend cases and the facts carry test
  fail when any part is undone.
- capacity_rule.test.py: a kit copy of the rule from before the swap trend is
  refused by name; an empty or missing rule file raises (heavy facts then
  answers "not available", never free).
- agentSlotRoutes.test.ts: the gate's 30 s enforce sampler starts when the
  gate is built. Built at the test clock's 0, the tests' move to START ran
  every sample in the 56 years between (about 59 million): Test Server 5 hung
  until its 20 min cancel. boot now sets the clock to START first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* MCP profiles part 5: Codex threads apply their profile's outside servers (#826)

* MCP profiles part 5: Codex threads apply their profile's outside servers

Each Codex thread T3 loads on the shared app-server gets
mcp_servers.<name>.enabled = false in its own per-request config for
every server config/read lists for its folder that the profile leaves
out (launch-argument and project servers included; T3's own entries
stay). Each turn first reads the thread's live servers and refuses,
saying why and the fix, when one outside the profile is still on. A
missing or broken profile, a server list T3 cannot read, or a thread T3
cannot match is refused, never started with every server. Logic in
apps/server/src/fork/codexMcpProfile.ts; two seam lines in the Codex
adapter (announced in step 1). Remote delegation stays Claude-only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* MCP profiles part 5, fix round: check Codex-started turns, sub-agents and connectors

- Watch turn/started: a turn Codex starts on its own (a goal's next turn, a
  sub-agent's turn) gets the same check as turn/start; one that fails is
  stopped (goal paused, turn interrupted) and ends failed with the reason.
- Count Codex sub-agents as their parent's T3 thread (they copy the parent's
  loaded config, codex-rs child_config.rs), so their turns are checked too.
- Send features.apps=false when a narrowed profile leaves out codex_apps,
  which config/read never lists.
- A refused resume no longer becomes a fresh Codex session: the fallback
  start is refused once, so the history is kept.
- Tests for each, with Codex's real status words; docs updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* heavy holds: #913 follow-ups and neutral example names (#917)

- A hold cgroup that is there without a memory controller (no memory.stat)
  holds its whole budgetMb with a note, instead of nothing.
- The room a hold keeps is its budget less the RAM it uses: memory.max
  limits RAM only, so swap is left out (in use still counts swap).
- Holds in or the same as another hold's cgroup are refused (the same
  room held twice); a reservation file named like a hold gives a note.
- Tests that fail without the code: at most 8 holds (9 distinct labels),
  memory.max "max" gives no "cannot be read" note, and one mutation check
  per fix.
- Neutral example names in the reservation-folder docs and test.

Fixes #913

Co-authored-by: Claude Opus 5.5 <[email protected]>

* MCP profiles: T3 tool groups on T3's MCP server, for every provider (#827)

* MCP profiles: T3 tool groups on T3's MCP server, for every provider

MCP profile design PR 4. A profile's t3Tools now applies: one global
rule on T3's MCP server hides a T3 tool outside the calling thread's
groups from tools/list, refuses it on tools/call with a plain reason and
its fix, and keeps it out of tool_search. The groups are fixed as each
turn starts (Claude: as its query opens; other providers: the turn
check), so a running turn keeps its set and a change applies from the
next turn. A profile that cannot be worked out, or a thread T3 cannot
read, keeps only request_secret, send_to_user and tool_search.

Claude no longer refuses a profile whose t3Tools is a list, and a group
change gives its next turn a fresh process. Off Claude, a turn now
refuses only a profile that leaves out an outside server.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* MCP profiles: guard the T3 tool table against drift; a tool in no group is refused as a T3 bug

- personOnlySettings.test.ts: the T3 tool filter's table must hold exactly the toolkit folders'
  tools, each in its folder's group, and every group of MCP_T3_TOOL_GROUPS must have a tool there.
  Dropping a toolkit from the filter's hand list, or adding a group with no toolkit, fails CI.
- A tool in no group is still refused by any profile but all, but its refusal now says it is a T3
  bug to report, not a setting to change.
- docs/fork: profiles are not a sandbox (requests with no thread, such as the t3 thread CLI, are not
  filtered); the sets live per thread, not per credential.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* FORK_CHANGES: shorten the MCP profiles row so the table keeps main's widths

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: the machine's agent guard hooks as a kit (#834 G4) (#847)

* fork-kit/agent-guards: the machine's agent guard hooks as a kit (#834 G4)

Five Claude Code hooks that guard every agent on a shared machine, as one kit with one
installer, facts from the machine file and the same messages and exit codes as before:

- actions-disable-guard (PreToolUse Bash): no disabling of workflows, Actions or branch
  protection; fails closed (a missing or failing hook refuses, and says so)
- capacity-pipe-guard (PreToolUse Bash|Monitor): no pipe out of a capacity check
- memory-index-guard (Pre/PostToolUse): the auto-memory index stays inside its budget
- bg-guard (Stop): no stop while a background Bash command still runs
- agent-slots (UserPromptSubmit, Stop): slot and ready-queue context for orchestrators

The others fail open with a visible line. `agent-guards check` runs each wired command
with a case it must refuse and one it must pass; `--settings` writes a managed settings
drop-in. Shared bootstrap and kit_install contract tests cover the new kit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: lens round 1 fixes for G4a

- actions-disable-guard and capacity-pipe-guard match Bash|Monitor; the
  memory-index after-call check matches Monitor too; check reports a
  guard wired for Bash only as missing.
- The owner's approval is a root-owned file with the hash of a one-time
  code (agent-guards approve); the session variable is no longer read,
  since nested sessions inherited it.
- Refuse starting a nested session without this machine's hooks
  (claude --bare/--safe-mode, CLAUDE_CODE_SIMPLE, codex).
- The closed hook sets onFailure block; an empty guard file refuses.
- A ruleset set to evaluate is refused like disabled.
- Each hook reads only its own part of the machine file section; bad
  keys and refuseScripts rows are dropped one by one and named to the
  agent; self-check does the strict check.
- Uninstall refuses while a foreign settings file names a hook or an
  older session runs; rollback is --no-settings.
- check --settings as root reads only a root-owned file; check runs
  hooks under a temporary HOME; self-check checks links, an open
  approval and passwordless ways to root.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: GraphQL ruleset update with EVALUATE in a variable is refused (lens B r2 minor 1)

The off word of updateRepositoryRuleset was looked for in canon() text, which blanks text with no cue
word, so `-F e=EVALUATE` (or a JSON variables block) was '' before OFF_WORD saw it. It is now read
without the cue words, as the REST ruleset body already was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: an owner approval passes one command, in one folder, once (lens B r2 major 2)

`sudo agent-guards approve --command '<cmd>' [--cwd DIR]` now stores the hash of the
normalised command and the folder next to the code's hash (approval file version 2).
The guard passes only that command, ending in the marker, run in that folder, and
records the use in its state folder (O_EXCL link; the same tool_use_id passes again),
so the approval is used up. A code seen in a transcript, the app database or ps opens
no other command. A version 1 file counts as no approval.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: refuse hookless agent sessions by path, package and wrapper, and say what the guards are not (lens B r2 major 1)

A list of strings cannot be complete, so this does both things the review asked for:

(a) Wider detection where it is cheap and reliable. claude and codex now count by name, by their real
program path (.../claude/versions/<v>, the @anthropic-ai/claude-code and @openai/codex packages), as a
link to or a copy of the installed program, through npx, bunx, pnpm dlx, npm exec, bun x and
`node <their cli>`, behind `$(which claude)`, and inside python -c, node -e, perl -e, at, systemd-run
and the other wrappers already read for gh. CLAUDE_CODE_SIMPLE counts in the command, through env -S,
in a sourced file, in BASH_ENV/--rcfile and in the user's shell start files.

(b) The threat model, written plainly in the README ("What the guards are and are not") and the guard's
docstring: the guards stop mistakes and casual misuse; they are not a boundary against a hostile agent;
the boundary is the GitHub permissions of the agent's token (a fine-grained token without Actions and
Administration write is the recommended setup).

Codex arguments are now read option by option (an option's value is not taken for the subcommand),
because the new path and package forms need it; the separate codex nits follow in their own commit.

Tests: LensSecurityR2Test.test_r2_major1_* (each fails on 6d5047d4).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork-kit/agent-guards: codex arguments are read option by option; codex mcp passes (lens A r2 nit)

`codex -m o3 exec x` is now refused as `codex exec` (the option's value is no longer taken for the
subcommand), `codex mcp list` (MCP setup, no session) passes, and `npx -y @openai/codex exec x` is refused
(the package form came with the major-1 commit). `codex mcp-server` stays refused.

Test: LensSecurityR2Test.test_r2_nit_codex_arguments_n…
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