Repository navigation
perf(channels): claim idle ingress during durable admission - #175459
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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 32031990f6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const enqueueAndClaim = admissionQueue.enqueueAndClaim?.bind(admissionQueue); | ||
| const idleDrain = | ||
| prepared.length === 1 && enqueueAndClaim ? options.getIdleDrain() : undefined; | ||
| const ownerId = idleDrain?.idleOwnerId(); | ||
| if (idleDrain && ownerId && enqueueAndClaim) { |
There was a problem hiding this comment.
Keep enqueue decorators on the fused admission path
When a caller decorates a host queue by spreading it and overriding enqueue—as existing Twitch, Feishu, Nostr, Discord, and other bundled tests do—the spread now also retains the core enqueueAndClaim. For an idle singleton, this capability check invokes that retained native method instead of the override, so the decorator's append failure, gate, or instrumentation is silently skipped and the event can be acknowledged and dispatched. The changed IRC test works around this by deleting enqueueAndClaim, but existing and third-party queue decorators have not been migrated; make fused admission explicitly opt-in or ensure the decorated admission operation is honored.
AGENTS.md reference: AGENTS.md:L52-L53
Useful? React with 👍 / 👎.
|
Codex review: needs changes before merge. What this changesThis PR combines durable append and claim for idle singleton ingress and lets Telegram reuse fresh admission identity and lane facts. Example: Telegram update 17 arrives while its ingress monitor and queue are idle.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 2 items remain Keep open as a useful maintainer-directed optimization, with repairs required for bypassed enqueue decorators and the restart-drain regression test. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherChannel plugins submit inspected events to the shared ingress monitor, which persists them through the state worker and hands claims to the drain for delivery, retry, and completion. flowchart LR
A[Channel event] --> B[Ingress monitor]
B --> C[State worker transaction]
C --> D[Durable ingress queue]
C --> E[Existing drain]
B --> F[Transport acknowledgment]
F --> E
E --> G[Channel delivery]
Technical reviewBest possible solution: Keep fused admission with the existing worker and drain owners while preserving decorated queue admission and meaningful restart-recovery coverage. Do we have a high-confidence way to reproduce the issue? Source tracing establishes the decorator bypass, and exact-head CI shows the matching Microsoft Teams failure; no target code was executed during this review. Is this the best way to solve the issue? Combining append and claim inside the existing writer transaction is a coherent optimization, but capability detection must preserve supplied admission behavior. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9f39528c0cc7. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +259, Tests +418, Docs +22. Total +699 across 16 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 17, 2026, 7:33 AM ET / 11:33 UTC. |
|
The supplied-queue decorator issue remains an unresolved P2. Idle singleton admission calls an inherited optional The inspected bundled production callers do not use that override pattern; third-party decorators were not audited. Until the contract is repaired, wrappers must also wrap optional admission methods or omit them. Follow-up: make fused admission an explicit opt-in, or preserve the supplied wrapper’s interception semantics, with a regression proving the decorated operation is observed exactly once. |
…#175459) Append and claim eligible idle singleton messages through the existing ingress worker and drain. Preserve retry ordering, deduplication, claimant ownership, durable acknowledgment, and restart recovery. Reuse Telegram admission facts instead of inspecting the same fresh event again. Focused owner and transport tests, live Telegram singleton proof, types, lint, source contracts, and database ratchets validate the change. Inherited CI findings, SDK comparison limits, and the queue-decorator follow-up are documented in the PR.
Problem and design
A durable inbound message required separate enqueue, claim, and completion requests. This change lets the existing queue worker append and claim a fresh singleton in one transaction when its dispatcher is idle and no pending or claimed row precedes it. The existing drain owns the claim before transport acknowledgment and dispatches after acknowledgment settles. Failed acknowledgment stays visible; the durable message remains recoverable. Unknown append outcomes use recovery without retrying the append.
Telegram reuses admitted identity/lane facts, removing a second inspection. Accepted edge: a forum hint learned during append does not reclassify that singleton; later admission and recovery use their own facts. IRC still inspects retained lines to prepare delivery and reject malformed data. Retry ordering, peer ownership, effect authorization, lease-loss cancellation, settlement, and persisted-event validation remain. No schema change, new manager, fencing, or synchronous fallback.
Measured scope
All six alternating arms are complete. Base
4aa0f5a85299c69232ef04ee1060c3b7c6207adb; production candidate2fcf35c065548d347af6b084f6e8e5bea574d082; M1,C1,M2,C2,M3,C3. Final head530efbc2d4f2226c3dd67746a52e4a2d2c20a654changes only the Telegram test fixture; production, APIs, docs, and dependencies are byte-identical. Build, native, and SDK proof are reused on that basis. No latency or PostgreSQL performance claim.Fixed cost covers enqueue/claim/completion; whole flow includes discovery/settlement. All six completed owner/channel arms have no native SQL errors. Enqueue plus claim falls from 6 SQL/2 requests to one
enqueueAndClaimat 4/1; completion stays 3/1. Each singleton also avoids onelistand onestaleClaimsrequest, saving another 2 SQL/2 requests in the measured whole flow.Same-lane and distinct-lane ten-event batches stay at fixed 63/21 and whole 93/46 and 75/28 respectively. Album/forward fixed work stays 18/6; polling-batch stays 15/5. Whole Telegram fixture medians (SQL/requests) vary: album 1111/605→1043/537, forward 1126/624→976/474, polling-batch 368/86→351/70. These include setup, 10 ms polling, verification, and teardown; they are not per-message savings. Full ranges are preserved in the report and extraction.
Both causal and raw warm nonregression checks pass; this does not establish a whole-workload cost pass. Whole Gateway medians increase 42 SQL (+1.18%) and 15 requests (+1.66%). Combined boot/connect/first-turn work increases 882 [878–900] SQL / 211 [207–215] requests → 927 [927–954] / 226 [226–229]. Raw first-turn request median rises 100→110; causal first-turn requests rise 53→54. These increases remain a post-merge investigation item.
The shared workload has no inbound channel events. Its ingress work is identical in every arm: boot 1 SQL/0 requests/1 allowed boot MAIN, connect 2/1/0, restart-connect 2/1/0; total 5/2/1, with zero ingress work in warm turns. Extra measured work appears in unchanged catalog/cache/session-maintenance paths: entry-cache snapshots 20 SQL/12 requests→23/13, catalog request stacks increase, and the session-cost cache stack adds 2 median requests. Background medians rise 2182→2228 SQL and 530→544 requests; these independently computed medians are not additive to the whole delta. The trigger for the extra work is not established; unchanged ingress attribution is not proof that the PR caused none of it. All six attribution audits reconcile phases and wire requests, with no missing dispatches or native SQL errors.
The target of two fixed requests applies only to eligible idle singletons, not every message or whole-flow work. O(1) total-burst requests remain unmet: claim/completion still scale per message. Prior #175183 batches ten-event admission from 30 SQL/10 requests to 3/1 and combines the health-read pair from 2/2 to 2/1; those are Stage 1 results.
Proof and limits
Ingress T1: 0→0; repository T1: 182→182; deprecated compatibility: 10→10; dialect mechanical/design/engine: 0/0/0 unchanged. Final CI at synthetic merge
10fb1948into65920347had 60 successful and 24 skipped jobs. All static CI passed, including types, lint, contracts, bundles, Madge (zero cycles), and ratchets. Two behavioral jobs failed with exact pinned-main assertion matches: Telegram young-session conflict (main7de7f398) and two agent session-event assertions (main4b791ee3). The aggregate remained red. Security Review succeeded; its CI-gate status mirrored the aggregate. The exception rests on focused main reproductions, not the automated classifier's “unknown” result.Knip retains 16 exact observed-main findings below; matched source/scanner blobs do not establish identical historical dependency graphs. The complete 155-root native SDK declaration comparison was manually reviewed as additive/type-compatible. The stock per-export semantic renderer did not complete.
Exact observed-main findings
src/logging/diagnostic-memory.tsresetDiagnosticMemoryForTestfe84346907e6src/logging/diagnostic-phase.tsresetDiagnosticPhasesForTestfe84346907e6src/logging/diagnostic-run-activity.tsresetDiagnosticRunActivityForTestfe84346907e6src/logging/diagnostic-runtime.tsresetDiagnosticActivityForTestfe84346907e6src/logging/diagnostic-session-recovery-coordinator.tsresetDiagnosticSessionRecoveryCoordinatorForTestfe84346907e6src/logging/diagnostic-session-state.tsresetDiagnosticSessionStateForTestfe84346907e6src/logging/diagnostic-stability.tsresetDiagnosticStabilityRecorderForTestfe84346907e6packages/gateway-protocol/src/compiled/sender-identity.d.tsisSessionParticipantIdentityfe84346907e6src/agents/command/cli-compaction.test-support.tssystemCompactionHostb46ec6167975src/agents/embedded-agent-runner/tool-result-truncation.tstoolResultWarningDedupe (toolResultTruncation)b46ec6167975src/gateway/github-publication.test-support.tsBASE_HEADb46ec6167975src/gateway/server-worker-environment-startup.runtime.test-support.tsworkerStartupReceiptb46ec6167975src/infra/backup-create-family.test-support.tsexpectVerifiedBackupb46ec6167975src/infra/backup-create-family.test-support.tswriteFilesb46ec6167975src/system-agent/system-agent.test-helpers.tsrequireTestRecordb46ec6167975test/gateway-restart.test-support.tsreadRestartRowb46ec6167975Focused owner/adapter tests cover recovery, acknowledgment failure, dedupe, ordering, and claim handoff; all 18 final Telegram drain tests pass. Delayed native Telegram send/reply confirmed one fused admission followed by completion; cold arrival used ordinary enqueue/claim. Native proof cleanup passed. These prove behavior, not SQL counts; crash recovery was simulated. No update-driver cell applies: schema, migrations, update, Doctor, loading, and service lifecycle are unchanged.
Two Codex review rounds were used; no third round. ClawSweeper found no P0/P1/security issue, but P2 remains: inherited
enqueueAndClaimcan bypass a decorator overriding onlyenqueue. The fixture repair does not fix that contract. Third-party decorators were not audited. Wrap optional admission methods or omit them; follow-up is explicit opt-in or preserved interception semantics.Merged as
3f76f0b62d1f0ad0eebe1f74d283eb4f3ac7805cthrough the authorized head-pinned REST fallback after earlier lane native refusals; no new Stage 2 native landing attempt is claimed. Size: 19 files, +862/−158 (production +395/−136; tests/config +441/−18; docs +25/−3; baseline +1/−1).