Repository navigation
fix(agents): harden native hook relay ownership - #159255
Airyn-Axyl wants to merge 15 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
436b29a to
e7ffc8d
Compare
|
Codex review: needs real behavior proof before merge. Reviewed September 27, 2026, 9:00 AM ET / 13:00 UTC (Revision 18). ClawSweeper reviewWhat this changesThe branch keeps overlapping Codex native-hook registrations on one relay, routes hooks by claimed turn, checks PreToolUse readiness, and adds lifecycle and command-boundary tests. Merge readiness⛔ Blocked before merge - 7 items remain The overlapping-run failure remains on current main, and this PR has a useful repair path. Two blocking concerns remain: retired turn claims can lose their denial history, and the exported registration API changes same-ID behavior for existing callers. The new boundary test proves one recovery and denial case, but not the eviction case. Priority: P1 Review scores
Verification
How this fits togetherCodex starts turns and sends native tool hooks to OpenClaw through a generated command and loopback relay. The relay selects the run that owns each hook before OpenClaw returns a tool or approval decision. flowchart LR
A[Codex turn] --> B[Native hook command]
B --> C[Loopback relay]
C --> D{Live turn owner?}
D -->|Yes| E[Hook policy and approval]
D -->|No| F[Unavailable denial]
E --> G[Tool decision]
Before merge
Findings
Agent review detailsSecurityNeeds attention: The relay changes authority selection, and claim eviction can let a retired turn reach another run's hook policy. PR surfaceSource +663, Tests +1117. Total +1780 across 44 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep exact ownership for bundled Codex runs, preserve replacement behavior for the public registration API, and make retired-turn rejection survive bounded-history eviction before any hook effect. Do we have a high-confidence way to reproduce the issue? Yes for the review findings by source path: retire enough claims to evict an old turn, then leave one unclaimed sibling and deliver the old hook; separately, overlap two public same-ID registrations with a turn-bearing hook. These cases were not executed in this read-only review. Is this the best way to solve the issue? No, not yet. The private multi-owner path addresses the reported overlap, but the public API needs its replacement contract preserved and the retired-turn denial must remain authoritative after history eviction. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e374c800cd88. LabelsLabel changes: No label changes. Label justifications:
EvidenceSecurity concerns:
Acceptance 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 (17 earlier review cycles; latest 8 shown)
|
e7ffc8d to
dd64592
Compare
dd64592 to
468219e
Compare
7ff7ae1 to
bd370ca
Compare
5644887 to
00e353e
Compare
412b7fb to
6a4070a
Compare
|
Field data supporting this direction, from a production-like setup on 2026.9.7 with heavy native-child delegation. Symptoms before our local mitigation:
What we observed, which matches this PR's diagnosis:
Result: keeping overlapping registrations alive under one On the eviction concern raised in review: in our experience, a bounded history that fails closed when full did not |
Reject late native hook callbacks before they can use a successor run's tool policy. Bind the foreground relay to the accepted native thread and turn, revalidate authority after waits, and retire the binding through the existing lifetime cleanup. Keep warm/incognito hook commands and separately admitted children. Remove the inert foreground symbol and duplicate private owner projection; production net +25 lines. Main's real CLI/loopback reproduction and unchanged resumed-attempt regression are red. The repaired candidate passes 76 selected Node and 32 Bun cases, touched-file typed lint, formatting parity, and independent Codex autoreview at P0–P2. PR CI supplies broad proof. Allocate 182 net test lines for the CLI and resumed-attempt ownership regressions and necessary identity fixture updates; shared test baseline unchanged. Supersedes #159255, thanks @Airyn-Axyl. Co-authored-by: AxyL <[email protected]>
|
Thanks @Airyn-Axyl for calling out the relay ownership risk. We reproduced cross-run policy dispatch on main and landed the focused thread/turn binding and lifetime cleanup repair in #191788 (da5ff0f). Closing this broader proposal in favor of that merged replacement, with your contribution preserved as co-author. |
Reject late native hook callbacks before they can use a successor run's tool policy. Bind the foreground relay to the accepted native thread and turn, revalidate authority after waits, and retire the binding through the existing lifetime cleanup. Keep warm/incognito hook commands and separately admitted children. Remove the inert foreground symbol and duplicate private owner projection; production net +25 lines. Main's real CLI/loopback reproduction and unchanged resumed-attempt regression are red. The repaired candidate passes 76 selected Node and 32 Bun cases, touched-file typed lint, formatting parity, and independent Codex autoreview at P0–P2. PR CI supplies broad proof. Allocate 182 net test lines for the CLI and resumed-attempt ownership regressions and necessary identity fixture updates; shared test baseline unchanged. Supersedes openclaw#159255, thanks @Airyn-Axyl. Co-authored-by: AxyL <[email protected]>
What Problem This Solves
Codex resumes with a stable native-hook relay ID/generation, while OpenClaw stored only one registration per relay ID. An overlapping run replaced the first registration and teardown retired the listener/locator still referenced by active hook commands. Restart clears in-process registrations, and under event-loop pressure this surfaced as
native hook relay not foundor timeout. Startup checked publication but never executed an end-to-end PreToolUse request.Summary
/bin/echo okprobe, one bounded renew/drain/retry, and component-specific failuresEvidence
tsgo:coreandtsgo:extensionspassedpwd,git status --short --branch,/bin/echo ok; protected guard mutation was denied before executionAdjacent Work
Reconciles the registration-lifecycle overlap in #134346 without duplicating the bound-chat restart recovery in #158752.
Deployment Note
No installed Gateway or protected guard infrastructure was changed. Live install/restart and repeated fresh-session proof remain a separate operator-approved step after review.
Exact-head authority proof (6a4070a)