Skip to content

Merge Codex hooks.json and tolerate tool-installed skill dirs - #25

Merged
DROOdotFOO merged 2 commits into
mainfrom
codex-hooks-merge
Oct 13, 2026
Merged

DROOdotFOO merged 2 commits into
mainfrom
codex-hooks-merge

Conversation

@DROOdotFOO

@DROOdotFOO DROOdotFOO commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • ~/.codex/hooks.json becomes a modify_ merge (same recipe as ~/.claude/settings.json and Zed): PreToolUse/SessionStart stay managed, events other tools install (npx impeccable install writes PostToolUse and Stop) survive chezmoi apply
  • run_after_sync-skills.sh.tmpl no longer exits 1 when a real directory sits in ~/.agents/skills/ after the one-time legacy migration; tool-installed skills (impeccable) stay in place and are mirrored to ~/.claude/skills/. The script had been failing on this machine since 2026-10-04 for that reason, so new upstream skills were not being linked
  • Zed managed theme matches the object Zed's picker writes (mode: system, light One Light, dark Synthwave84 Soft), ending the MM drift on settings.json
  • Stale Claude links are judged against the merged root, so tool-installed skills no longer churn (remove + re-add) on every run; a real directory that shadows a source skill is reported with a WARNING on stderr (it still wins)
  • CLAUDE.md documents both

Checks

  • make lint pass
  • make codex-check pass (new cases: merge keeps managed PreToolUse authoritative and keeps a foreign PostToolUse; sync script keeps a real dir, links new upstream skills beside it, mirrors it to Claude without churn, warns when it shadows a source skill)
  • make test: only [Config] chezmoi verify fails, identically on main -- it runs against the live source (~/.local/share/chezmoi, still pre-PR) whose rendered hooks.json, Zed settings.json, and ~/CODE/CLAUDE.md differ from the live home. That is exactly the drift this PR removes; expected to pass after merge + apply
  • chezmoi --source ./home diff for ~/.codex/hooks.json, ~/.config/zed/settings.json, ~/.agents/skills, ~/.claude/skills: empty against the live home

Manual testing

  • chezmoi apply on the live source after merge; confirm ~/.codex/hooks.json keeps the impeccable events and Codex does not re-prompt for trust (source on main hashes hooks individually by event/matcher/command, so a reformat should not re-prompt)

@DROOdotFOO

Copy link
Copy Markdown
Owner Author

Adversarial Review: PR #25 (Codex hooks merge, tool-installed skill dirs, Zed theme)

Evidence: ran run_after_sync-skills.sh.tmpl repeatedly in scratch HOMEs; jq type-edge probes (string * object, null * object, array file); Codex hooks/src/engine/discovery.rs on main for hook trust; make lint, make codex-check; new test run against the pre-PR script.

CRITICAL

  • none

HIGH

  • [Saboteur + Security Auditor] (promoted MEDIUM -> HIGH) A real directory in ~/.agents/skills/ that shares a name with a source skill silently wins: the link loop skips it (! -e) and every host loads the shadow instead of the vetted upstream copy. The pre-PR script at least refused loudly (exit 1) in that state; the PR traded that signal for nothing. Fixed in 74aeff2: the link loop prints WARNING: <path> is a real directory and shadows <root>/<name> to stderr; real dir still wins (never deleted). Test added.

MEDIUM

  • [Saboteur] Claude mirror churn: the stale-link pass used skill_exists (source roots only), so a tool-installed skill not present in any root was removed from ~/.claude/skills/ and re-created on every run -- Removed stale Claude skill link: toolonly on runs 2..n, with a transient window where the link is absent. Reproduced in a scratch HOME. Fixed: staleness is judged against the merged root (merged_skill), skill_exists deleted. Test asserts no churn on the second run; the new test fails against the old script (tool-installed skill link churns on every run).
  • [New Hire] Comment claimed "the link loops below never replace or delete a non-symlink entry" while the Claude pass could remove/re-add the mirror link; and "Codex still asks you to review and trust any hook it did not see before" was asserted without evidence. Fixed: comment wording; trust claim now states the verified mechanism -- Codex hashes each hook as (event, matcher, command) (hook_hash in codex-rs/hooks/src/engine/discovery.rs), so merge reformatting does not re-prompt and a tool-added hook stays disabled until trusted.

LOW

  • [Saboteur] jq '. * $managed' errors on a non-object top level (array, number) and chezmoi apply fails loudly: array ([]) and object ... cannot be multiplied. null/string leaves merge fine ({theme:"x"} * {theme:{...}} -> object). Same behaviour as the two existing modify_ scripts; left.
  • [Saboteur] Managed events that get disabled (prepper = false) persist in the target. Documented trade-off shared with the other modify_ files; left.
  • [New Hire] modify_hooks.json.tmpl was committed 100755; the two precedent modify_ scripts are 100644. Fixed to match.
  • [New Hire] CLAUDE.md said Zed uses Synthwave84 Soft; with theme.mode = "system" that is dark mode only. Fixed wording.
  • [Security Auditor] The merge now preserves hook events written by any tool run as the user (e.g. an unpinned npx impeccable install); pre-PR, chezmoi apply reset hooks.json to a known-good file. Residual risk is bounded by Codex's per-hook trust gate (untrusted hooks do not run) -- verified in source, not exercised on 0.151. Left; documented in the script header.
  • [Security Auditor] Mirroring tool-installed real dirs into ~/.claude/skills/ widens what Claude Code loads, but Codex already read ~/.agents/skills/ directly, so no new trust boundary. Left.

Cross-Persona Overlaps

  • Silent shadowing of a source skill by a real directory: Saboteur (stale copy wins) + Security Auditor (unvetted copy replaces vetted) -> MEDIUM promoted to HIGH.

Verdict: CONCERNS -> addressed in 74aeff2

Checks

  • make lint ok; make codex-check "Codex target checks passed"
  • New assertions vs. pre-PR script: FAIL (tool-installed skill link churns on every run); vs. PR: pass
  • Sync script against the live HOME: exit 0, no warnings, impeccable real dir untouched, linear link intact
  • make test: [Config] chezmoi verify still fails identically on main (live source is pre-PR; this is the drift the PR removes)

Not verified

  • Codex 0.151 hook-trust hashing (read on main); the manual-testing checkbox stays.

@DROOdotFOO
DROOdotFOO merged commit 986b5b7 into main Oct 13, 2026
5 checks passed
@DROOdotFOO
DROOdotFOO deleted the codex-hooks-merge branch October 13, 2026 19:13
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