Repository navigation
Doctor's re-init fix keeps --no-hooks; deploy compose runs without tracekit on root's PATH (#464) - #845
Merged
Conversation
…acekit on root's PATH (#464) A plugin user who ran system init with --no-hooks (plugin/README.md) and followed doctor's re-init fix got init's hooks beside the plugin's, and a host that declined hooks got them back. In system mode the fix now adds --no-hooks when client.json records it or the Claude Code plugin is on for the agent's user. docs/deploy-compose.md ran `sudo tracekit deploy compose`, which finds no tracekit on root's PATH unless pip installed it system-wide; it now runs the checkout with your Python by its path, as deploy/compose/e2e.sh does, and the docs test no longer exempts deploy. Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>
) With init --managed and the Claude Code plugin on, every re-init fix became `init ... --no-hooks --managed`, and running it removed the root-owned managed hooks, leaving only the plugin's, which the agent's user can turn off. The plugin check reads the agent's own settings, so the agent could make doctor recommend that. The fix no longer adds --no-hooks when init's hooks are the managed ones. The re-init fix also named no --agent, so on another coding agent's host (init --agent codex, with or without --no-hooks) it set the host up again for Claude Code. collect() now adds init's agent to every re-init fix; the harness hook check no longer adds its own. docs/deploy-compose.md: the witness-class command follows a block that ends in `cd /srv/tracekit`; it now says to run it in the checkout. Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>
LoopGlitch26
enabled auto-merge (squash)
November 14, 2026 06:58
LoopGlitch26
added a commit
that referenced
this pull request
Nov 15, 2026
#845) (#858) On a host set up with init --managed, only the hook checks' fixes (D-HOOKS-MANAGED, D-HOOKS-PRESENT, D-HOOKS-VENV) named --managed. The other re-init fixes, D-PROCESS-BOUNDARY, D-CODE-TRUST, D-UNIT-HARDENING, D-TAILER-CONFIG among them, ended without it, so a person who followed one ran init without --managed: init wrote its hooks into the agent's own ~/.claude/settings.json, which the agent can edit, and took them out of the root-owned managed file. With the Tracekit plugin on, each call was then decided twice. Without --managed-only, init also turned off the allowManagedHooksOnly an init with it had turned on. collect() now adds --managed to every re-init fix when init's hooks are in Claude Code's managed settings, and --managed-only when init recorded it there (its _tracekit_allowManagedHooksOnly marker; an admin's own allowManagedHooksOnly has no marker, and init leaves it). The hook checks' fix no longer adds its own, so it names --managed once. --no-hooks and --agent stay as #845 left them. Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>
LoopGlitch26
added a commit
that referenced
this pull request
Nov 15, 2026
* doctor: a re-init fix on a --managed host keeps --managed (follow-up to #845) On a host set up with init --managed, only the hook checks' fixes (D-HOOKS-MANAGED, D-HOOKS-PRESENT, D-HOOKS-VENV) named --managed. The other re-init fixes, D-PROCESS-BOUNDARY, D-CODE-TRUST, D-UNIT-HARDENING, D-TAILER-CONFIG among them, ended without it, so a person who followed one ran init without --managed: init wrote its hooks into the agent's own ~/.claude/settings.json, which the agent can edit, and took them out of the root-owned managed file. With the Tracekit plugin on, each call was then decided twice. Without --managed-only, init also turned off the allowManagedHooksOnly an init with it had turned on. collect() now adds --managed to every re-init fix when init's hooks are in Claude Code's managed settings, and --managed-only when init recorded it there (its _tracekit_allowManagedHooksOnly marker; an admin's own allowManagedHooksOnly has no marker, and init leaves it). The hook checks' fix no longer adds its own, so it names --managed once. --no-hooks and --agent stay as #845 left them. Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com> * doctor: re-init advice keeps init's own flags (follow-up to #858) A fix that re-ran system init gave back init's agent, --no-hooks and --managed only. Following one on a host set up with --policy, --harness, --approver, --egress and the like rewrote signer.yaml with init's defaults (its own policy, no harness binding), and doctor didn't say. - init --v2 records the rest of its flags in client.json (hooks.init_flags, and the directory of a --project init); v1 init records its own at the top level. Doctor reads them from that root-owned file only and gives them back shell-quoted. A host whose client.json predates the record gets a fix that says doctor can't tell init's flags, instead of a re-init that drops them. - v1: V1_REINIT never named --managed; doctor now gives v1 init's flags too, and --managed where the managed settings hold v1 hooks on an older host. - D-HOOKS-PRESENT no longer fails "every call is decided twice" on an init --managed host with allowManagedHooksOnly on when only the agent's own settings enable the plugin (Claude Code doesn't run it then). On a managed host its fix no longer names tracekit uninstall, which never takes managed hooks out. - D-SYSTEM-CONFIG keeps --managed when the managed settings hold init's v2 hooks. - --managed-only is given again only while init's marker is there and allowManagedHooksOnly is still on, init's own rule. Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com> * doctor: re-init fixes run from the clone; init takes --project DIR (review of #860) - init --project [DIR]: a re-init fix for a --project host named the directory and had the person run `sudo python3 -m tracekit init` there, in the agent's own repo, where -m imports a planted tracekit/ before the release's, as root. init now takes the directory (no DIR keeps the working directory), init records it, and the fix runs from the root-owned clone like every other re-init. - --harness is recorded as given (absolute, symlinks kept), not as its resolved real path, which a package upgrade removes or leaves pointing at the old binary. The signer still binds the resolved program. - --managed-only is recorded (v1 and v2). When allowManagedHooksOnly is off now (an admin, or MDM replacing the managed file), the fix keeps it and says to drop it only if it was turned off on purpose; a fix's own --managed-only isn't given twice. - --i-understand-agent-is-privileged, --no-witness and --public-witness aren't recorded or replayed. - migrate --system keeps v1's init_flags. - install no longer imports doctor's private helpers: install.reinit_flags and install.setting are shared. doctor --config with no client.json says there is none. Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com> * doctor: keep --harness as given only where root alone can repoint it (re-review of #860) - harness_spec kept the given path, links and all, but trusted_file checks only the real path's chain: a link in a directory the agent's user can write could be repointed before a re-init, which then bound any root-owned program. The given path is now kept only when every directory its lookup reads, its links' targets included, is root-owned and not group- or world-writable; else init records the real path. - The no-record note names --project DIR: a bare --project run from the release's clone puts the hooks in the clone. - uninstall takes --project [DIR] as init does, and dev init's plugin check reads DIR's .claude (and doesn't take a named project's .claude for a user config root, as it didn't the working directory's). Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com> * cli: --project [DIR] resolves against os.getcwd() as init runs, on every OS CI's py3.9 Windows job failed five init --dev --v2 --project tests: the hooks went into the checkout, not the test's working directory. --project with no DIR went through os.path.abspath(".") at run time, and on Windows abspath asks the OS for the working directory (nt._getfullpathname) instead of calling os.getcwd(), which those tests patch to set it and which the code read before --project took a DIR. DIR is now joined to os.getcwd() and normalized, as POSIX abspath does. A test stands in an abspath that ignores a patched os.getcwd, as Windows' does, and checks a parser built before a chdir. The two CliProject tests compare against os.path.abspath of the input (C:\srv\my repo on Windows). Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com> * tests: HarnessSpec skips on Windows, as this file's other system-mode tests do CI's py3.13 windows-latest job failed it: resolve_harness couldn't take the temp script's "#!/bin/sh" interpreter, as Python 3.13's ntpath.isabs no longer counts a drive-less rooted path. Harness binding is system mode's, which _require_system refuses on Windows before any harness code runs. Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com> --------- Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The two items still open on #464 (its 11-13 status comment).
1. Doctor's re-init fix keeps
--no-hooksplugin/README.mdtells Claude Code plugin users to run system init with--no-hooks, but doctor's re-init fix (REINIT) has no--no-hooks. System init doesn't detect the plugin, so a plugin user who followed the fix got init's hooks beside the plugin's (doctor then warns,D-HOOKS-PRESENT), and a host that declined hooks (an SDK agent) got Claude Code hooks back.In system mode,
doctor.collectnow adds--no-hooksto every fix that names the re-init when client.json recordsno_hooks(init was told--no-hooks), or when the Claude Code plugin is on for the agent's user and the agent is Claude Code. Another agent's re-init (--agent codex) is left alone, since the Claude Code plugin doesn't give it hooks.2.
deploy composewithouttracekiton root's PATHdocs/deploy-compose.md(L9, L80) ransudo tracekit deploy compose. Root'sPATHhas notracekitunless pip installed it into the system Python, so from a checkout or a venv it fails with "command not found". The page now runssudo "$(command -v python3)" -m tracekit deploy compose …from the checkout, asdeploy/compose/e2e.shdoes, and says why root and why that form.tests/test_docs.pyno longer exemptssudo tracekit deploy.Checks
tests/test_doctor_v2.py::NoHooksChosen::test_the_reinit_fix_keeps_no_hooks_where_init_was_told_it_or_the_plugin_hooksandtests/test_docs.py::DocCommands::test_no_command_needs_tracekit_on_roots_pathboth fail on main'sdoctor.pyanddeploy-compose.mdand pass here.python -m tracekit deploy compose --dir <tmp>from the checkout (without sudo) writes the stack and prints the note about running as root.collectwith system mode's client.json mocked.make test-ts lint build testpass (5219 passed, 395 skipped). Linux CI is the merge gate.Fixes #464.