← Back to Pull requests

fix(codex): key inline hook trust by its actual group position #2028

Closed
unknown closed this pull request without merging on Oct 25, 2026 15:32 UTC
View on GitHub
unknown unknown commented on Oct 25, 2026 13:55 UTC
Author

What a user gets

Refs #17, without claiming to close its original Codex 0.155.1/macOS report.

OpenRig's inline activity hooks get their own exact trust records even when a person's config already contains groups for the same event. Previously, provisioning always wrote ...:<event>:0:0, although it appended its managed group after those existing groups. Its hook could remain untrusted, and a person's existing group-zero trust hash could be overwritten with OpenRig's different hash.

Count each event's groups before the managed block, then reuse the existing key/hash writer at that position. Groups after the block don't change its position. Personal hook definitions, their hashes and explicit disable choices stay unchanged. This neither grants blanket hook trust nor adds trust to the person's hooks. The existing JSON-hook provisioning route and hash algorithm are unchanged.

How you verified it

  • Workspace npm run build and npm run lint: pass.

  • Three related suites (codex-hook-trust, codex-owned-hook-trust, codex-activity-hooks): 72 tests pass.

  • Four new per-event regressions fail with the prior hard-coded-zero semantics and pass with the fix. They check nonzero positions, preservation of the person's hash/disable choice, and idempotence. A fifth control keeps a group appended after the managed block from changing OpenRig's position.

  • Actual Codex CLI 0.163.0 on Windows x64, invoking this checkout's real CodexRuntimeAdapter.ensureCodexActivityHooks, with separate temporary configurations and a loopback-only synthetic HTTP endpoint. Before the fix, a preceding personal SessionStart group prevented OpenRig's SessionStart from firing, while its separate UserPromptSubmit still fired. After the fix, both events fired. The clean-config control still works; the untrusted control and the untrusted personal hook never execute. The endpoint deliberately returns HTTP 400 before any model work, so exit 1 is expected. No real account, model request, paid usage or active OpenRig daemon was involved.

  • The two fixture files now construct config paths with the host path helper, matching the production join. Their previous POSIX-only map keys made native Windows checks miss the mocked config; no assertions were removed or relaxed.
  • Not run: the complete workspace matrix or installed-package scenario. No current macOS/0.155.1 or interactive trust-dialog claim, and no claim that every remaining case in #17 is fixed.

    Anything you were unsure about

    This prevents future writes at the wrong key. It cannot reconstruct a person's hash already replaced by an older version, and does not guess or rewrite that historical choice. Native evidence covers SessionStart and UserPromptSubmit; all four provisioned event positions are covered by deterministic tests.

    AI-assisted implementation and tests. No version bump, changelog edit, runtime deployment or new service.

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Bug Fixes
    Trust records now use the correct position when custom hook groups appear before the managed activity hooks. Hook groups added after the managed block do not affect that position.
    * Provisioning preserves existing trust entries and produces identical configuration when run again.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 431 lines (+323 / -108) across 5 files Reviewer: openrig-review Review duration: 96m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 431 lines diff across 5 files
    0.45
    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.363
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2028"
    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: 45.2% (MEDIUM) · Higher = larger blast radius
    45.2%
    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: 17.8% · Safe to merge
    17.8%