Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 31, 2026, 6:10 PM ET / 22:10 UTC. ClawSweeper reviewWhat this changesThe PR tracks concurrent native-hook relay registrations, shares one loopback bridge between them, and binds Codex hook traffic to the provider turn that owns it. Merge readiness⛔ Blocked until stronger real behavior proof is added - 5 items remain Keep open: the per-registration routing direction addresses the reported overlap, but legacy/current module coexistence still tears down a live relay and the exported SDK handle gains a required field that breaks structural consumers. Priority: P1 Review scores
Verification
How this fits togetherCodex starts create native-hook relay registrations, while hook subprocesses send payloads through a shared loopback bridge. The relay selects the owning run’s policy context and returns the resulting allow/block response to the native client. flowchart LR
A[Codex turn start] --> B[Relay registration]
B --> C[Shared loopback bridge]
D[Native hook payload] --> E[Turn and generation routing]
E --> F[Run policy context]
F --> G[Gateway hook result]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +477, Tests +1079. Total +1556 across 10 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Adopt or retain a legacy shared-map registration for the full overlapping lifecycle, preserve the prior SDK handle shape, and prove exact-head overlapping turns and rejection paths at the final hook boundary. Do we have a high-confidence way to reproduce the issue? Yes, from source: register a legacy shared-map relay, register a slot-tracked sibling on its relay ID, then unregister the sibling; the old live relay is no longer represented and its bridge is torn down. Is this the best way to solve the issue? No: the central ownership direction is sound, but it must preserve the claimed mixed-module lifecycle and the existing public structural SDK contract. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 56b71ac114d5. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
853cbeb to
d9f490b
Compare
Codex native runs share one stable per-session relayId, and the single registration slot let an overlapping sibling run (new turn, nested run, or bound-thread resume reusing the persisted generation) evict the active registration at register time. Every later PreToolUse hook of the still-live run then failed closed with the stale-registration error mid-turn, and a retained relay guarding direct-child hooks could be torn down by the next turn's registration on the same session. Track every live registration per relayId in registration order and route invocations to the newest registration matching the presented generation, falling back to the current registration only for the bootstrap generation-mismatch grace. Unregister now removes only the caller's own registration; relayId-wide state (loopback bridge, SQLite locator record, invocation history, approval and permission state) is torn down only when the last registration goes. The bridge is reused across overlapping registrations, its record expiry covers the longest-lived registration, and renew works for non-current siblings so long turns no longer lose their relay at the original TTL. Retained-relay and foreground liveness checks key off slot membership instead of map currency, so a sibling registering or unregistering cannot invalidate an in-flight invocation binding. Registrations are capped per relayId, and at the cap the new registration is rejected instead of evicting a live sibling. Exact-generation authorization is preserved: a generation that was unregistered or expired still fails closed with the stale registration error. Shared-state objects written by older module copies are upgraded in place, and their relays-only registrations stay routable, expirable, and sweepable. Slot bookkeeping, lifetime teardown, and invocation-binding resolution move to native-hook-relay-registrations.ts to keep the relay facade under the max-lines cap.
d9f490b to
65b6654
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
This pull request has been automatically marked as stale due to inactivity. |
|
Closing due to inactivity. |
What Problem This Solves
Fixes an issue where Codex sessions with overlapping runs could lose native hook routing mid-turn and fail closed with
native hook relay bridge stale registrationornot founderrors. A new turn, nested run, or bound-thread resume reused the session's stable relay identifier and replaced a still-live registration.Why This Change Was Made
Tracks live registrations per relay identifier and routes each invocation to the newest registration matching its generation. The loopback bridge and SQLite locator remain shared until the final registration exits; renewals cover non-current siblings; retained relays remain valid across sibling churn; and the bounded registration cap rejects a newcomer instead of evicting active work.
The implementation preserves exact-generation fail-closed behavior and upgrades shared state created by older module copies in place.
User Impact
Overlapping Codex runs in the same session can continue using PreToolUse and related native hooks without one run invalidating another. Stale or unknown generations remain rejected.
Evidence
src/agents/harness/native-hook-relay.test.ts,src/gateway/server-methods/native-hook-relay.test.ts,extensions/codex/src/app-server/native-hook-relay.test.ts), including new regression coverage for: an invocation binding to the registration that claimed the payload turn; unclaimed hooks rejected while multiple live registrations contest one generation; a steered/duplicateturn/startclaim refused instead of transferring hook ownership; an open-foreground unclaimed direct child parking in admission-wait and resolving onclaimDirectChild; and closed-foreground unknown children still rejected.CHANGELOG.mdedit is removed per review.codex-rssource:turn/startis start-or-steer (app-server/src/request_processors/turn_processor.rs— a steered start returns the live sibling's turn id in the sameTurnStartResponseshape), and every hook payload carries a mandatoryturn_idset from the active turn (core/src/hook_runtime.rs,hooks/src/schema.rs). The turn-claim registry therefore keys on a selector that is always present, and a steeredturn/startcan no longer silently transfer hook ownership: a turn id already claimed by a live sibling is refused, and a double-claimed turn id fails closed (block/deny) rather than routing to the newest registration.NATIVE_HOOK_SMOKE_OK; two simultaneous overlapping native sessions in one Codex thread completedOVERLAP_A_OK/OVERLAP_B_OKwith zeronative hook relay not found/ stale-registration errors over the observation window, where the pre-fix build reproducibly failed mid-turn.src/cli/native-hook-relay-cli.ts), and the cap rejects the newcomer instead of evicting live work.