← Back to Pull requests

fix(codex): keep Codex's own trust tables in OpenRig's hook block, and don't re-add hook groups Codex moved #2035

Closed
unknown closed this pull request without merging on Oct 25, 2026 19:23 UTC
View on GitHub
unknown unknown commented on Oct 25, 2026 16:29 UTC
Author

Stacked on #2034 until #2034 merges; review only the commits after it.

What a person gets

After this, a person's own Codex hook trust survives OpenRig's next seat launch, so Codex stops asking them to trust the same hooks again every launch. OpenRig never adds a second set of its activity hooks either.

Before:

  • Codex 0.164.0 rewrites all of [hooks.state] when it saves trust. That's its "Trust all", a ConfigEdit::SetPath on hooks.state. toml_edit then prints the rewritten table after the last hook group, which is inside OpenRig's # BEGIN/# END OPENRIG MANAGED ACTIVITY HOOKS block, ahead of the END comment. The END comment was the prefix of OpenRig's first trust table, and it moves with that table.

  • OpenRig's next launch replaced everything between the markers. That deleted the person's newly trusted entries, so the prompt came back on every launch. Turning OpenRig's hooks off deleted them the same way.

  • When a save left the markers apart from OpenRig's groups, OpenRig appended a second block, and the relay ran twice per event.
  • Reported by @borfast in #17. #2028 fixed the other half of that report, the trust key's group position.

    If Codex already shows OpenRig's hook twice, from a config the old code doubled, remove the extra [[hooks.<event>]] groups that run OpenRig's relay, once. This change stops new copies; it doesn't remove old ones.

    What changed

  • OpenRig's groups are read as TOML. The config is split at its real table headers, never at text inside a string or an array, and each header's key is decoded in any spelling, such as [[hooks."Stop"]]. A group is OpenRig's when it's for one of OpenRig's four events and runs nothing but OpenRig's relay. A person's own group for the same event, inside the markers or not, is theirs.

  • Inside the block: the activity-hook block rewrite and the strip that turns hooks off now keep every section between the markers that isn't one of OpenRig's groups, whole, with the comments just above it. Codex's [hooks.state] tables stay.

  • Groups without markers: when the markers are gone but groups already run OpenRig's shipped relay, those groups are OpenRig's where they sit.

  • - Only the command line of each one's own handler is pointed at the current relay, so an upgrade still works.
    - No second set is appended.
    - Their trust is keyed by their own positions.
  • A check before writing: the inline writers confirm that only OpenRig's groups and the [features].hooks flag changed and that the file still parses. Otherwise the config is left as it is, with a line in the daemon log. A config that doesn't parse is left as it is too.

  • Unchanged: a person's own hooks, their order, and every other table.
  • Tests

    codex-hook-trust.test.ts, "#17":

  • The fixture is Codex's actual save. It takes OpenRig's launch of a config with a person's own hooks, then applies the 0.164.0 write: [hooks.state] and every entry, sorted, with literal-quoted keys and values, printed after the last hook group, with the END comment travelling with OpenRig's first trust table. A first case checks the person's trust really is inside the markers.

  • The next launch keeps:

  • - the person's trust;
    - their groups and order;
    - exactly one set of OpenRig's groups, with correct trust.
    - It's also idempotent.
  • Turning hooks off keeps the person's trust.

  • With the markers gone, with the current relay or an earlier install's relay, no second set is added, and the commands point at the current relay.
  • Read as TOML (codex-hook-trust.test.ts, "OpenRig's groups are found by what they are, not by their text"):

  • a relay command example inside a person's multi-line instructions stays exact;

  • a person's group for another event that runs the relay isn't repointed;

  • OpenRig's group written with a quoted event key is removed when hooks are turned off, and replaced rather than kept beside the new one;

  • a kept section whose multi-line string holds a [[hooks.Stop]] example stays whole, and the file stays readable;

  • a person's own PermissionRequest group inside the markers is kept on a launch and when hooks are turned off;

  • a config that doesn't parse is left byte-identical.
  • With #2034's source, the four behaviour cases above them fail. With this PR's first revision, the seven new cases fail.

    🤖 Generated with Claude Code

    Diff: 552 lines (+414 / -138) across 6 files Reviewer: openrig-review Review duration: 174m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 552 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.378
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2035"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 48.1% (MEDIUM) · Higher = larger blast radius
    48.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19% · Safe to merge
    19%