feat(codex): load the core plugin's hooks in selected Codex seats through Codex's own install #1551
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
mvschwarz
Refs #1341
What a user gets
A Codex seat whose plugin selection includes
openrig-corecan now run the plugin's refocus hooks (UserPromptSubmit andPostCompact) 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
nodeon its PATH.How it works
1. Install through Codex itself, only for a selected seat. With
runtime.codex.hooks_enabledon, the install runs onlywhen 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>, thencodex plugin add openrig-core@openrig, under its ownCODEX_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 = falsewith no explicit value for the plugin: stays disabled. Codex applies thatdefault, 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.jsonstarts withtest -n "$OPENRIG_SEAT_PROJECT_DIR" && test -f "$OPENRIG_NODE" && test -x "$OPENRIG_NODE" || exit 0, thenexec "$OPENRIG_NODE" …. OpenRig sets both variables only for a Codex seat that selected the plugin (on fresh launch,handover and successor), with
OPENRIG_NODEthe daemon's absolute Node. Codex runs hooks through the login shell, anda 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
openrig-coreget its refocus and activity hooks, once Codex's exact-hook review admitsthem. Review is still required for each hook.
config.tomlgains[marketplaces.openrig]and[plugins."openrig-core@openrig"] enabled = true.Codex's own install writes them.
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.
$CODEX_HOME/config.toml(the marketplace entry and
enabled = truefor the plugin). OpenRig only writes its own marketplace manifest beside thevendored plugin.
--from-plugin.Changes after review
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.store and the user config still has OpenRig's marketplace and an explicit
enabled = true. A cache left behindafter either entry was removed is installed again. A disable still wins.
codexstart reports why (for example, not found) instead of "exit null".plugins._defaultfollows Codex's layer precedence. A higher layer's_default.enabled = trueoverrides a lowerlayer's
false(system, then user, then legacy managed), so OpenRig no longer refuses an install Codex would allow.the block no longer makes the plugin relay report too, so that event is reported once. (Superseded by the next item.)
in-place restart's resume command never run
codex plugin. The config lock and managed-config step still run.(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.
post
pluginormanaged; an untagged post (an older relay, the Pi and stub runners) is a route of its own, asbefore, 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
change doesn't add launch isolation.
isn't seen before install. Codex itself still honours it when loading the plugin.
(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.
rust-v0.163.0. Other versions may differ.Tests
test/codex-core-plugin-route.test.ts(25).- The guard, through real
sh -lcandbash -lcwith a PATH lackingnode: personal, unselected and selectedsessions, 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 foreignmarketplace.
- 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.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.
pluginormanaged(test/activity-relay-endpoint.test.ts), and the hooks routepasses it into the evidence, with any other label as
unrecognised(test/seat-activity-retirement-hooks.test.ts).here.
nodeon PATH. Now each exits 0.--from-plugin.HOMEandCODEX_HOME, and no realcodex.Native: NOT RUN
Not run:
hooks/listand exact-hook review;🤖 Generated with Claude Code