Skip to content

hooks sync: optionally record Codex hook trust for the hooks it writes #828

Closed

Description

@salmonumbrella

The situation

skillshare hooks sync writes Codex hooks into each Codex home's hooks.json, including account targets like codex-2. Codex won't run a user-level hook until it's been trusted, and it keeps that trust in the same home's config.toml:

[hooks.state."/home/me/.codex/hooks.json:stop:0:0"]
trusted_hash = "sha256:..."
  • The key is the hook's position: <hooks.json path>:<event>:<group index>:<handler index> (hook_key in codex-rs/hooks/src/lib.rs).
  • The hash is Codex's own digest of the normalized event, matcher and handler (hook_hash in codex-rs/hooks/src/engine/discovery.rs, built on version_for_toml in codex-rs/config/src/fingerprint.rs). A hook whose hash doesn't match is modified, one with no hash is untrusted, and neither is loaded.
  • The only thing that writes it is the TUI's /hooks review screen, which asks the app-server for each hook's currentHash (hooks/list) and then writes hooks.state.<key>.trusted_hash through config/batchWrite (write_hook_trusts in codex-rs/tui/src/hooks_rpc.rs).

So every hook Skillshare installs or moves starts untrusted. codex exec has no review screen, so it just skips them. I hit this with a Stop hook synced into two Codex homes: it never fired under codex exec until I either passed --dangerously-bypass-hook-trust or opened /hooks in each home and trusted it by hand.

Codex 0.167.0, Skillshare 0.30.1. Source refs are at openai/codex 36e074a.

What works today, and why it is not enough

  • Open /hooks in the TUI for every Codex home after every sync that adds or moves a hook. That's one interactive step per home per change, and a headless box never gets it.
  • --dangerously-bypass-hook-trust on every run turns trust off for every hook, not just the ones I approved in Skillshare.
  • I wrote a small script that does what the TUI does: hooks/list, then config/batchWrite for the matching hooks. It works, but it has to be rerun after every sync, matches hooks by command text instead of by what Skillshare owns, and leaves stale trust behind when a hook moves or goes away.

The docs say sync never changes native trust, and I think that's the right default. The gap is that there's no way to opt in after I've already reviewed the hook in Skillshare.

Ask

An opt-in flag on skillshare hooks sync (global mode) that, after writing, records Codex trust for the hooks Skillshare owns in each Codex home it wrote:

  • Get the hash from Codex itself, through the same app-server calls the TUI uses, so it always matches what Codex computes. No hand-rolled hash.
  • Write only trusted_hash, like the TUI. Leave enabled and everything else in config.toml alone, and say when Codex has a Skillshare hook disabled.
  • When a hook moves or is removed, clear the trust Skillshare wrote for its old position, and only if it still holds the hash Skillshare wrote.
  • If codex isn't on PATH, the hooks files are still written and the command says trust wasn't recorded.

Out of scope: project-level Codex hooks, other Agents' trust, and any change to the default.

I have a draft PR ready.

Activity

  1. runkids commented on Nov 10, 2026

    @runkids
    Owner

    Thanks for writing this up so carefully, and for the PR. The source references made the Codex side easy to follow.

    Nothing is decided yet, but here is where my thinking is.

    The gap is real. A hook that syncs fine and then never fires under codex exec is a bad surprise, and opt-in with the default unchanged feels like the right shape.

    What I am unsure about is doing the write and the trust in one step. Codex's review exists so a person sees the command before it runs. Entries can reach config.yaml without being typed by the user, for example through hooks import --from codex taking over registrations already in hooks.json, or an agent editing the config. With --trust in an alias, those get trusted unseen.

    So I am leaning toward showing which hooks would be newly trusted, with their commands, and asking before writing, plus an explicit way to skip the prompt for headless use.

    Two questions. Would a confirmation step with a skip flag still fit your headless setup? And do you need trust on every sync, or mostly after adding or moving a hook?

  2. added
    feature
    on Nov 11, 2026
  3. salmonumbrella commented on Nov 12, 2026

    @salmonumbrella
    ContributorAuthor

    A confirmation step fits the headless setup as long as there is an explicit way to skip it after reviewing the commands. Showing the newly trusted hooks and their commands would make that review useful.

    Trust is needed after adding a hook, changing its command, or moving it to a different position or Codex home. Unchanged syncs do not need a new approval. Unattended jobs should still be able to run the opt-in step idempotently: matching trust is reported as unchanged, and stale trust written by Skillshare is cleared when needed.

    The current #829 implementation still has the explicit --trust flag without an interactive confirmation. Your proposed confirmation and headless-skip interface remains a design discussion; I have not treated it as approved. The current follow-up fixes the reported ownership and symlink regressions.

  4. runkids commented on Nov 15, 2026

    @runkids
    Owner

    Thanks for answering both questions. Here is the decision.

    hooks sync --trust stays opt-in, and the default stays unchanged. Before it writes anything, it lists the hooks it would newly trust, including ones whose command changed, with their commands, and asks once. Hooks whose trust already matches are reported as unchanged and need no answer; if nothing needs new trust, it does not ask.

    --yes (-y) skips the question, as it does for install and audit. Without a terminal and without --yes, it trusts nothing: it lists the hooks and exits with an error that names --yes. Unlike audit, a missing terminal is not consent here, because the point of Codex's review is that a person sees the command before it runs.

    Clearing stale trust that skillshare wrote earlier needs no confirmation, since it only removes trust.

    I'm adding the approved label for this shape. The implementation can continue in #829.

  5. added
    approved
    on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    approvedfeature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions