← Back to Pull requests

feat(codex): load the core plugin's hooks in selected Codex seats through Codex's own install #1551

Closed
unknown closed this pull request without merging on Oct 20, 2026 07:31 UTC
View on GitHub
unknown unknown commented on Oct 19, 2026 21:11 UTC
Author

Refs #1341

What a user gets

A Codex seat whose plugin selection includes openrig-core can now run the plugin's refocus hooks (UserPromptSubmit and
PostCompact) and its activity relay. Until now Codex never loaded them: OpenRig copied the plugin into a folder Codex
doesn't read. Every other Codex session on the same home, whether an unselected seat or a person's own session, is a
successful no-op for these hooks, even with no node on its PATH.

How it works

1. Install through Codex itself, only for a selected seat. With runtime.codex.hooks_enabled on, the install runs only
when a Codex seat's resolved plugin selection includes openrig-core:
- at that seat's launch, when it starts a conversation: the same check that sets the seat's
OPENRIG_SEAT_PROJECT_DIR. A resume (a launch with a resume token, or building the in-place restart's resume command)
never installs;
- at boot: after the plugin is vendored (so it installs the version this daemon ships), when some Codex seat's saved
selection includes it.

Launching an unselected Codex seat never installs it. The install:
- writes a local marketplace manifest beside its vendored plugin (<plugins>/.agents/plugins/marketplace.json);
- runs codex plugin marketplace add <plugins>, then codex plugin add openrig-core@openrig, under its own
CODEX_HOME.

It writes nothing into Codex's plugin cache, and no hook trust or hook state.
2. The person's choice comes first. Before any install or reinstall, it reads the Codex config files it can see: the
system /etc/codex/config.toml, the user $CODEX_HOME/config.toml, and the legacy /etc/codex/managed_config.toml.
- An explicit [plugins."openrig-core@openrig"] enabled = false: stays disabled.
- A [plugins._default] enabled = false with no explicit value for the plugin: stays disabled. Codex applies that
default, and an install would replace it with an explicit true.
- An explicit enabled = true: allows it.
- A file that can't be read or parsed: installs nothing and reports why.
- Upgrades follow the same rule. A new plugin version is reinstalled only while the plugin isn't disabled.
3. A guard before any interpreter. Every entry in hooks/codex.json starts with
test -n "$OPENRIG_SEAT_PROJECT_DIR" && test -f "$OPENRIG_NODE" && test -x "$OPENRIG_NODE" || exit 0, then
exec "$OPENRIG_NODE" …. OpenRig sets both variables only for a Codex seat that selected the plugin (on fresh launch,
handover and successor), with OPENRIG_NODE the daemon's absolute Node. Codex runs hooks through the login shell, and
a missing command there would be a failed hook; the guard exits 0 first.
4. Activity is reported, possibly twice, never zero times. On Codex the plugin's relay always reports. Whether Codex
also runs the daemon's own managed relay for an event depends on hook state merged from every user layer (a selected
profile included) and session flags, and on the handler as written, none of which the plugin can see. So on a selected
Codex seat with both routes active, each activity event is reported twice. The daemon records both; nothing is lost.

Changed results

  • Codex seats that selected openrig-core get its refocus and activity hooks, once Codex's exact-hook review admits

  • them. Review is still required for each hook.
  • The daemon's Codex config.toml gains [marketplaces.openrig] and [plugins."openrig-core@openrig"] enabled = true.

  • Codex's own install writes them.
  • The plugin's skills become available to every Codex session on that home, including a person's own sessions.

  • The plugin manifests move to 0.1.16, so vendoring replaces an older installed copy.

  • Launch can take longer the first time. When the installed plugin isn't current, the install runs Codex's own CLI

  • inside the launch (or boot) path: up to two commands, each with a 120 s limit. It is skipped once the vendored version
    is installed.
  • The person's user config is written, through Codex. Codex's install writes the person's $CODEX_HOME/config.toml

  • (the marketplace entry and enabled = true for the plugin). OpenRig only writes its own marketplace manifest beside the
    vendored plugin.
  • The plugin's Codex relay entries now pass --from-plugin.
  • Changes after review

  • One lock for Codex config setup. A launch's config write and, for a selected seat, its install run as one step under

  • a single adapter-level lock; the boot install and resume take the same lock. Two concurrent launches no longer
    interleave writes to the same CODEX_HOME.
  • "Current" means registered, not just cached. The install is skipped only when the vendored version is in Codex's

  • store and the user config still has OpenRig's marketplace and an explicit enabled = true. A cache left behind
    after either entry was removed is installed again. A disable still wins.
  • Marketplace sources are compared by real path, so a symlinked plugins folder isn't mistaken for another source.

  • A failed codex start reports why (for example, not found) instead of "exit null".

  • Merged with main (including the refocus-notes change, which also took 0.1.15); this branch now ships 0.1.16.

  • plugins._default follows Codex's layer precedence. A higher layer's _default.enabled = true overrides a lower

  • layer's false (system, then user, then legacy managed), so OpenRig no longer refuses an install Codex would allow.
  • Only a hook group before the managed relay block moves it. A person's own group for the same event placed after

  • the block no longer makes the plugin relay report too, so that event is reported once. (Superseded by the next item.)
  • A resume never installs. The install is an explicit fresh-launch decision; a resume launch and building the

  • in-place restart's resume command never run codex plugin. The config lock and managed-config step still run.
  • On Codex the plugin's activity relay always reports. Codex decides from hook state merged across every user layer

  • (a selected profile included) and session flags, and from the handler as written, so a profile disable or a stanza
    edited after it was trusted could leave the managed handler skipped while the plugin stayed quiet. The relay now never
    suppresses: each activity event is reported twice on a selected Codex seat with both routes, never zero.
  • Promotion counts each relay route on its own, so an event reported twice doesn't count twice. The relay tags each

  • post plugin or managed; an untagged post (an older relay, the Pi and stub runners) is a route of its own, as
    before, and any other label is one more fixed route. The Codex hook rung is promoted when one route alone has 50
    consecutive agreements over at least an hour from its own first agreement. A disagreement from any route still resets
    every route's count and clock.

    Known limits

  • A Codex started from inside a selected seat's shell inherits the seat's variables and acts as that seat. This

  • change doesn't add launch isolation.
  • Config OpenRig can't see: profile, project, session-flag, MDM and cloud-managed config. A disable set only there

  • isn't seen before install. Codex itself still honours it when loading the plugin.
  • Duplicate activity: on a selected Codex seat with the daemon's managed relay active, each activity event

  • (SessionStart, UserPromptSubmit, Stop, PermissionRequest) is reported twice, by the managed relay and by the plugin. It
    is never lost, and it doesn't count twice toward promoting the hook rung.
  • Promotion is counted per route: it's slower when the two routes cover different stretches, never faster.

  • Tested Codex version: the behaviour was read from Codex's public source at rust-v0.163.0. Other versions may differ.
  • Tests

  • New: test/codex-core-plugin-route.test.ts (25).

  • - The guard, through real sh -lc and bash -lc with a PATH lacking node: personal, unselected and selected
    sessions, and an unusable interpreter.
    - The launch signal for selected, unselected and Claude seats.
    - The install gate: an unselected Codex seat's launch makes no Codex CLI call, a selected one installs, and the
    managed-config step alone never installs.
    - The relay copied alone, as a Claude seat's settings relay, still loads.
    - The install decision: explicit values, _default, layers above the user file, unreadable and unparsable files.
    - The install calls, with a fake codex: first install, a version change, disabled, current, and a foreign
    marketplace.
    - The relay predicate: trusted, disabled, untrusted, modified, a matcher, another script, a group before it,
    plugin-only, a non-managed event, no node, and the Claude path unchanged.
  • Promotion per route (test/activity-evidence-ladder.test.ts, 6 new):

  • - 25 events posted by both routes don't promote, and the next sampler-versus-hook disagreement is still decided by
    sampling;
    - one route's 50 agreements over the hour do promote, repeated identical events without a turn id included;
    - 30 on one route and 30 on the other don't add together;
    - 49 on one route, a disagreement from the other, then one agreement doesn't promote; 49 more inside the hour (50
    since the reset) still don't, and the next one after the hour does, so both the count and the clock were reset;
    - untagged posts still promote on their own; untagged, unrecognised and managed posts don't add together;
    - a permission request from the other route neither counts nor resets.
  • The route label: the relay tags plugin or managed (test/activity-relay-endpoint.test.ts), and the hooks route

  • passes it into the evidence, with any other label as unrecognised (test/seat-activity-retirement-hooks.test.ts).
  • Red first: the paired, split and mixed-route promotion tests and both label tests fail on the previous head and pass

  • here.
  • Before this change: every Codex plugin entry exited 127 in a session without node on PATH. Now each exits 0.

  • Updated: one existing test that asserted no Codex entry passes --from-plugin.

  • Also run: the related Codex, plugin, relay, refocus, launcher, handover and startup suites; lint; typecheck; build.

  • Hermetic only: temp HOME and CODEX_HOME, and no real codex.
  • Native: NOT RUN

    Not run:

  • an install against a real Codex 0.163;

  • hooks/list and exact-hook review;

  • refocus context in the model's input after a compaction;

  • the activity count with both routes present;

  • out-of-selection sessions on a real home.
  • 🤖 Generated with Claude Code

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: mvschwarz Review duration: 620m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    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.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1551"
    general weight: 0.35
    Reviewers
    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: 52% (MEDIUM) · Higher = larger blast radius
    52%
    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: 20.5% · Safe to merge
    20.5%