Repository navigation
refactor(routing): reuse prepared event session targets - #140454
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. |
|
Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 5:27 PM ET / 21:27 UTC. ClawSweeper reviewWhat this changesThe PR reuses parsed event-session targets and stops allowlist lookup at the first configured list, with tests protecting existing routing behavior. Merge readiness✅ Ready for maintainer review Keep open: this is a focused optimization that remains absent from inspected main and preserves the routing contract. No actionable correctness defect was found. Likely related people: Peter Steinberger and Vincent Koc are unverified routing candidates from available file history. Priority: P3 Review scores
Verification
How this fits togetherEvent-session routing maps background execution and scheduled events to the session that should receive them. It combines session identifiers, configured allowlists, and route bindings to select event destinations and heartbeat wake targets. flowchart TD
A[Background or scheduled event] --> B[Parse session target]
C[Allowlist and route configuration] --> D[Prepare routing policy]
B --> D
D --> E[Preserve direct session or select main]
E --> F[Event destination]
E --> G[Heartbeat wake target]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -8, Tests +90. Total +82 across 2 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep one canonical routing flow that reuses prepared targets while preserving allowlist precedence, empty-list semantics, agent ownership, and route bindings. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR optimizes existing behavior rather than repairing a reported functional failure; redundant parsing and eager allowlist evaluation are directly visible in main. Is this the best way to solve the issue? Yes: reusing the existing parsed target and short-circuiting array-or-undefined readers removes duplicate work without adding a cache, API, or competing routing path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 270762e51d65. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
* commit '294df333c58f2da104eccffc623ccb3c4d43d4d8': (1802 commits) fix: clear stale diagnostics after Gateway changes (#140426) fix: keep plugin catalogs intact after discovery timeouts (#140441) perf(tui): prepare session picker rows once per overlay (#140462) refactor(config): reuse environment substitution for write-back (#140460) refactor(discord): remove retired auto-presence templates (#140463) fix(ui): finish roster refreshes during session activity (#140459) fix(setup): match prepared credentials to the model provider (#140461) fix: keep MiniMax discovery on the selected credential (#140438) refactor(tests): remove unused parent context cache reset (#140456) fix: avoid repeated xAI OAuth refresh during discovery (#140434) perf(routing): reuse prepared event session targets (#140454) fix(media): keep deferred audio and extraction providers discoverable (#139231) refactor(codex): remove redundant app-server forwarding (#140451) fix(test): avoid false native polling timeouts (#140119) test(gateway): retain saved source in reload fixtures (#140453) fix(gateway): reduce repeated model work when listing sessions (#140414) fix(feishu): fall back to post mode over table limit (#136382) fix: use the bundle-compatible Proxyline runtime under Bun (#140411) refactor(trace): reuse the canonical usage counter type (#140444) refactor(node-host): share execution policy result fields (#140446) ...
What Problem This Solves
Event-triggered work repeatedly parses the same direct-session key while preparing routing policy. Allowlist selection also evaluates all six configuration locations even when the first one is already authoritative.
Why This Change Was Made
Carry the parsed direct target into the private allowlist resolver, short-circuit the existing allowlist readers with nullish coalescing, and remove an outer parse already implied by successful direct-target parsing. This deletes duplicate work without introducing a cache or a second routing path.
The six-location precedence, authoritative empty arrays, named and blank overrides, agent ownership, thread handling, route-binding preservation, cron mapping, and wildcard/multiple-owner behavior stay unchanged. Production −8 lines; tests +90. No config, API, protocol, schema, or authorization change.
User Impact
Less local work when preparing event routing. There is no intended routing or delivery change, and this does not claim faster complete Gateway turns or cron execution.
Evidence
122 focused tests passed. All 29 normal checks are covered by qualified recovery: the original gate passed 18 checks before a disk safety stop; recovery completed the remaining checks. A test-only unused callback name and its formatting were corrected after lint/format failures. The successful stages were not replayed. Fresh independent Codex review is clean. Every failure and process-closure receipt remains recorded; this is not described as one uninterrupted gate pass.
Fixed B0/C0/C1/B1 measurement on Node 26.8.1 at baseline
81050949f524ee1e486db5ef973366196dcdeb0a: 32 fixtures expand to 128 repeated/rotating policy/composed rows, 545,024 checked calls, 4,352 retained first outputs and 4,096 batch means. Independent audit decoded every V8 output (including undefined properties), reconstructed fixture expectations, and recomputed all 768 statistics. Warmup/timed outputs were checked in process; only first outputs were retained. Saved input JSON omits undefined fields; original input V8 bytes were not archived.Configured-precedence policy medians improved 23.25–43.54%; override composition improved 15.45–27.10%; binding-preserved composition improved 29.62–38.62%. The fuller first-precedence repeated/composed row was near-flat: −2.78% forward / +2.40% reverse. All 9/256 adverse medians, 12 means and 40 maximum batch means remain included. Largest median adverse: +8.09% (+105 ns) on an explicit-allowlist control; largest maximum-batch adverse: +119.14% (+1.66 µs) on a missing-channel control. These maxima are not individual latency percentiles.
Native whole-child wall improved 16.04%/11.13%, but reverse system CPU increased 11.76% and forward peak RSS increased slightly. No uniform memory or end-to-end claim. All phase/reducer processes closed, source was restored, and selected pins remained stable. This exercises the actual exported policy/key/wake composition; it does not dispatch a heartbeat, contact a channel, or use provider credentials. Real-Gateway campaign measurements remain separate.