gortex icon indicating copy to clipboard operation
gortex copied to clipboard

doctor: dead `Stop` hook raises the untrusted-hook blocker whose remedy its own activity table contradicts

Open rolldav opened this issue 2 months ago • 1 comments

Summary

gortex doctor raises the untrusted-hook blocker for a dead Stop hook and prescribes the /hooks trust remedy, while the activity table it prints two lines above shows the other four Codex hooks running tens of thousands of times. The blocker's own wording acknowledges the contradiction ("while other hooks did"), yet the remedy is the one documented for the case where none has run.

Following that remedy costs a user a real round trip and changes nothing, because trust is demonstrably not the problem.

Environment

  • gortex v0.64.0+aa0da6b
  • macOS 26.6.2, arm64
  • Codex CLI codex-cli 0.153.0, hooks declared in ~/.codex/config.toml (Gortex's own representation), counted in hooks.json (0), config.toml (5)

What doctor prints, verbatim, in one run

  codex — hook activity
    event                 runs  injected  daemon-up unattrib  last seen
    SessionStart           139       139    139/139        0  2026-09-06T23:05:00
    UserPromptSubmit       236        13    236/236        0  2026-09-06T22:54:04
    PreToolUse           10219       102 10219/10219        0  2026-09-06T23:03:29
    PostToolUse           3352        56  3352/3352        0  2026-09-06T23:02:53
    Stop                     0         0        n/a        0  never

  codex — adoption (what the model actually called)
    ✗ BLOCKER [codex] Stop is configured but never ran, while other hooks did (not once, ever).
              → run `/hooks` inside Codex, review the gortex entries, and trust them

The same run also reports ✓ OK [codex] Gortex tools are 100% of tool calls (87 Gortex vs 0 shell), so the integration is healthy in every other respect.

Why the remedy cannot apply

docs/agents.md § codex defines the signature precisely:

hooks configured but none has run is the untrusted-hook signature, reported as a blocker with the /hooks remedy.

Here four of five hooks have run, continuously and recently. Codex records trust per hook, so a single untrusted hook is possible in principle — but then the blocker should say so and point at that one entry, not reuse the "none has run" remedy. In practice the user has run /hooks and trusted the entries; Stop still shows runs 0 · never.

Expected

Distinguish the two cases:

  • no hook has ever run → untrusted-hook signature, /hooks remedy (current behaviour, correct);
  • some hooks run and one never does → a different diagnosis. Either the single hook is untrusted and the message should name it and show its trust state, or the event is never dispatched to it, which is not a trust problem at all and should not carry the /hooks remedy.

At minimum, the blocker should not print a remedy whose stated precondition its own adjacent table contradicts.

Secondary question

Is Stop expected to fire at all under Codex CLI 0.153.0? Codex's own /hooks panel lists both Stop ("Right before Codex ends its turn") and SessionEnd ("Right before a session ends"), and reports the Gortex Stop entry as installed and active. Yet its run count has been 0 · never across 139 sessions and 10 219 PreToolUse invocations. If Codex does not dispatch Stop to non-plugin hooks, doctor could report that as a host limitation instead of a blocker.

rolldav avatar Sep 06 '26 23:09 rolldav

Resolving my own secondary question, and narrowing this report.

Stop is dispatched normally. It fired on the first Codex session that actually terminated: a non-interactive codex exec run. Immediately after it, the activity table reads

    Stop                     1         1        1/1        0  2026-09-06T23:16:53

and the blocker cleared on its own — no /hooks involved, no configuration change between the two measurements.

So the underlying cause is a usage pattern, not a fault: this user's Codex sessions are long-lived TUI sessions that are closed or killed rather than ended cleanly, so Stop had never been reached across 140 SessionStart and 10 242 PreToolUse invocations. Nothing was broken.

That leaves one real defect, and it is narrower than my original title suggests: the blocker's remedy is wrong for this case. It prints the untrusted-hook remedy (run /hooks inside Codex …) for a situation its own adjacent table refutes, and following it costs a round trip that cannot help. A hook that has never run while others run constantly is far more likely to be an event that has not been reached yet than an untrusted entry.

Suggested behaviour for the some run, one never case:

  • do not reuse the /hooks remedy, whose documented precondition (none has run) is false here;
  • state the discriminator instead — e.g. "Stop fires only when a session ends; long-lived sessions that are closed or killed never reach it" — and consider demoting it from BLOCKER to a WARN or INFO, since no user action is required and the condition clears by itself on the next clean exit.

rolldav avatar Sep 06 '26 23:09 rolldav