Skip to content

[codex] Improve Codex plugin hook trust doctor - #258

Merged
ScriptedAlchemy merged 8 commits into
masterfrom
codex/codex-hook-trust-doctor
Jul 4, 2026
Merged

[codex] Improve Codex plugin hook trust doctor#258
ScriptedAlchemy merged 8 commits into
masterfrom
codex/codex-hook-trust-doctor

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Summary

  • make Codex doctor inspect plugin hook trust entries in ~/.codex/config.toml instead of always printing the generic /hooks reminder
  • keep Codex healthcheck on the plugin bundle path and stop validating project-local .codex/hooks.json/legacy config as supported installs
  • make update-plugin migrate legacy Codex config-managed installs by installing the plugin bundle

Context

Official Codex docs say plugin-bundled hooks are skipped until reviewed/trusted, /hooks manages hook trust, and project-local hooks only load when a project .codex/ layer is trusted:

Validation

  • cargo test codex_hook_trust_state --lib
  • cargo test codex_update_plugin_migrates_legacy_config_only_install_to_plugin --test agent_suite
  • cargo test test_healthcheck_codex --test agent_suite
  • cargo test test_codex_local_install_bundles_hooks_in_plugin --test agent_suite
  • cargo run --quiet -- doctor --agent codex

@changeset-bot

changeset-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e80eea5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ScriptedAlchemy
ScriptedAlchemy force-pushed the codex/codex-hook-trust-doctor branch 2 times, most recently from 6632510 to a94fe26 Compare July 3, 2026 22:53
ScriptedAlchemy and others added 5 commits July 3, 2026 23:51
Inspect Codex `config.toml` [hooks.state] and report which managed
hooks still lack a sha256 trust entry, instead of a generic `/hooks`
reminder. Drops the obsolete config-managed doctor paths.

Co-Authored-By: Claude <noreply@anthropic.com>
update_plugin now migrates a legacy config-only Codex install to the
plugin bundle and sweeps the old config, rather than reporting
ConfigOnly. Project-local Codex installs no longer ship hooks/hooks.json.

Co-Authored-By: Claude <noreply@anthropic.com>
Repo-local Codex installs intentionally stop shipping hooks/hooks.json
(Codex only trusts personal-plugin hooks), but two tests still asserted
the old layout. assert_codex_rendered_bundle_valid now takes an
expect_hooks flag (asserting absence for repo-local bundles), and the
codex local-install path list drops hooks/hooks.json.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ScriptedAlchemy
ScriptedAlchemy force-pushed the codex/codex-hook-trust-doctor branch from 32e8892 to 32b02ef Compare July 3, 2026 23:53
Make hook assertions scope-explicit and address review findings:
assert_codex_bundle_contains_bin silently skipped hook validation when
hooks/hooks.json was absent, letting global refresh tests pass even if
hooks stopped rendering; and the global-vs-repo-local scope policy was
scattered as ad-hoc conditionals across bundle writing, manifest/MCP
mutation, and the doctor.

- Add CodexBundlePolicy (include_hooks, mcp_args, mcp_env,
  hook_trust_config_path, include_memory_digest) consumed by the bundle
  writer, renderers, and doctor; collapse doctor_check_plugin's
  duplicated manifest/version/MCP checks into doctor_check_plugin_dir,
  which now warns if a repo-local bundle unexpectedly ships hooks.
- Tests take an explicit CodexScope: global bundles must ship
  hooks/hooks.json, repo-local bundles must not; repo-local rendered
  bundles keep the placeholder and source-coverage checks.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ScriptedAlchemy
ScriptedAlchemy force-pushed the codex/codex-hook-trust-doctor branch from 34c2b70 to 866cb61 Compare July 4, 2026 00:21
ScriptedAlchemy and others added 2 commits July 4, 2026 00:39
Review findings on the migration/doctor flow:

- update_plugin could sweep a working legacy config-managed global
  install while only a repo-local bundle refreshed, leaving no personal
  plugin as replacement; the bootstrap now installs whenever a legacy
  migration runs, and the sweep prints the required
  `codex plugin add tracedecay@personal` next step
- local-only installs (repo bundle, no personal plugin) got an all-green
  doctor with zero lifecycle hooks anywhere; healthcheck now warns that
  repo-local bundles ship no hooks
- the trusted-state info line now says trust is pinned to hook content,
  so a post-update hooks.json rewrite prompts a /hooks re-trust instead
  of reading as all-clear
- config.toml delete-if-empty now takes the same backup as the rewrite
  path; uninstall_hooks only rewrites and reports when it removed entries
- hook state keys derive from the managed hook's subcommand instead of a
  hand-rolled CamelCase converter that would break on acronym events

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- codex_config_path centralizes the four hand-built ~/.codex/config.toml
  joins
- codex_plugin_hook_trust_state treats a missing [hooks.state] table as
  empty so one pipeline produces the missing list
- stamp_manifest_version_with lets Codex strip the repo-local hooks key
  on the already-parsed manifest instead of a second JSON round-trip
- update_plugin folds the duplicated personal-bootstrap branches into
  one needs-personal condition

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ScriptedAlchemy
ScriptedAlchemy marked this pull request as ready for review July 4, 2026 00:50
@ScriptedAlchemy
ScriptedAlchemy merged commit 707cef0 into master Jul 4, 2026
16 checks passed
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@ScriptedAlchemy
ScriptedAlchemy deleted the codex/codex-hook-trust-doctor branch July 4, 2026 00:52
ScriptedAlchemy added a commit that referenced this pull request Jul 4, 2026
Return raw JSON envelopes from the fact_store and fact_feedback memory
write handlers instead of markdown-rendered output. After the markdown
default output change, these write-path handlers rendered their status
JSON as markdown, which interfered with the memory digest export
lifecycle. A new `tool_json` helper emits the truncated JSON envelope
(with project handle) directly; `handle_memory_status` continues to use
the rendered path.

Recovered from a stranded worktree whose stale rebase base had reverted
unrelated master work (PR #258/#260 agent-surface changes); only the
genuine memory.rs fix is carried forward here, rebuilt cleanly on
current origin/master.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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