Repository navigation
refactor: remove redundant collection precondition probes - #182890
Conversation
Use native delete results and single cache reads at 20 synchronous owner-local sites. Preserve negative caching, insertion-order recency, retry exemptions, duplicate handling and effect-time authority checks. No public behavior or SQL changes.
|
🦞👀 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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR replaces redundant collection membership checks with native deletion results or single cached-value reads. Example: Telegram update 101 fails and is retried after update 102 completes.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-directed simplification preserves the checked collection contracts, with no actionable code or security findings. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherChannel, browser, agent, and terminal owners use local collections to cache lookups, retain recency, suppress duplicates, and consume one-shot state. flowchart LR
A[Channel and browser requests] --> C[Existing runtime owners]
B[Agent and terminal operations] --> C
C --> D[Owner local Maps and Sets]
D --> E[Lookup or deletion result]
E --> F[Existing guards and outcomes]
Technical reviewBest possible solution: Retain the native-collection simplification under the existing owners and complete its registered acceptance comparison before landing. Do we have a high-confidence way to reproduce the issue? No user-facing bug is claimed; source inspection confirms the redundant operations, and no target code was executed during this read-only review. Is this the best way to solve the issue? The substitutions are the smallest complete simplification: they reuse native collection results while retaining cache sentinels, ordering, retries, and existing guards. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against dc3a0a6a3d7a. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -13. Total -13 across 16 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 24, 2026, 5:22 PM ET / 21:22 UTC. |
|
Measurement correction: the baseline has completed, and the candidate build has started. The frozen v3.1.4 observer reads the retired diagnostic trace storage; current main uses AsyncContext after #181780. Its causal report therefore has no coverage for any of the ten warm turns. Native statement/request counts and raw execution-phase windows remain valid. The original preregistration is retained below. For this collection-only refactor, I will report the ten raw warm execution windows, their totals/median/p95/range, and native operation and statement-shape counts. These are not causal per-turn counts; missing causal coverage is unavailable, never zero. The frozen harness remains unchanged. No SQL-saving, CPU, latency, or wall-clock claim will be made. This correction was published after seeing baseline diagnostics and before seeing any candidate result. |
…82890) Remove 20 redundant Map/Set membership probes across cache, registry, cleanup, and prompt owners. Use delete results or a single cached read while preserving recency, negative caches, retry handling, one-shot consumption, and effect-time checks. Production changes are net 13 lines smaller. Validation: 453 focused tests and exact-head CI passed; Madge found no cycles; Knip signatures match the baseline. Frozen synthetic Gateway comparison recorded 511 to 515 warm-window SQL statements, 125 to 126 requests, and zero runtime main-thread SQL in both arms. Differences occur in unchanged session-patch and checkpoint owners; causal attribution is unavailable in the frozen observer. No SQL or timing saving is claimed.
What Problem This Solves
Several cache, registry, and cleanup paths probe Map/Set membership immediately before an operation that already returns the needed result.
User Impact
No user-visible behavior change. Removes 20 redundant membership probes across 16 owner files, with 13 fewer production lines and no new state, caches, public interfaces, SQL, or schema changes.
Why This Change Was Made
Use
delete()'s result for one-shot consumption and toggles, delete directly before recency-preserving insertions, and read cached values once where the owner never storesundefined. Preserve null negative caches, cached promises resolving to missing entries, Matrix recency, Telegram failed-update retry, duplicate tool names, ambiguous process directories, and prompt navigation restoration. Authority, token consumption, abort/lifecycle checks and destructive-effect guards remain in place.The accepted edge is unchanged: these are synchronous operations on owner-local native collections, with no intervening asynchronous work or external writer. Negative-cache sites that use
undefinedas a stored value are intentionally retained.Evidence
git diff --check: pass.1e3ff306abaf.Frozen synthetic Gateway comparison
One counts-only baseline/candidate pair on the exact committed heads; ten warm execution windows per arm. Cold/startup and whole-workload counts are separate. p95 uses nearest rank. Frozen v3.1.4 hashes: 36/36 unchanged.
Whole workload: 2,889 → 2,891 SQL; 761 → 760 requests; 95 → 95 main-thread SQL. No runtime main-thread SQL in either arm.
Warm operation deltas:
commitSessionEntryPatch40→43 SQL and 10→11 requests; unrequested maintenance SQL 4→5. The extra patch transaction occurs in the first warm window; its normalized shapes add one BEGIN, one session-node UPSERT, and one COMMIT. One additionalPRAGMA wal_checkpoint(PASSIVE)accounts for the fourth statement. The other 14 operation vectors and 24 statement-shape totals are identical. The 4→5 checkpoint count (+25%) was investigated explicitly: the periodic checkpoint owner and the session-patch owners are byte-identical across both heads. This is raw-window variation in unchanged owners; no causal allocation or SQL reduction is claimed.The frozen observer has no causal coverage for these ten turns after the diagnostic scope migrated to AsyncContext (#181780). Native counts remain valid. The preregistration correction was published after the baseline, before any candidate result; the original rule is retained below. No CPU, elapsed-time, cold-start, or latency claim.
Acceptance rule (original preregistration, retained verbatim)
Flow/workload: the frozen synthetic Gateway workload, one baseline/candidate pair with a fresh fixture in each arm and ten warm causal turns. Compare warm SQL statements, database worker requests, and main-thread SQL per turn; keep startup/settling counts separate. Report median, p95 and range for each arm, plus per-operation attribution. These collection-only changes predict zero SQL/request change and one fewer collection probe on each affected hit or consume operation. Acceptance requires the 20 source-proven probe removals, net-negative production LOC, preserved owner behavior, and no SQL/request increase attributable to the changed owners. A 20% worsening in any measured cell stops acceptance pending diagnosis. This is counts-only proof; no latency, CPU-time, or cold-start performance claim is made. Measurement and comparison are pending.
Observer limitation discovered after baseline
Measurement correction: the baseline has completed, and the candidate build has started. The frozen v3.1.4 observer reads the retired diagnostic trace storage; current main uses AsyncContext after #181780. Its causal report therefore has no coverage for any of the ten warm turns. Native statement/request counts and raw execution-phase windows remain valid.
The original preregistration is retained below. For this collection-only refactor, I will report the ten raw warm execution windows, their totals/median/p95/range, and native operation and statement-shape counts. These are not causal per-turn counts; missing causal coverage is unavailable, never zero. The frozen harness remains unchanged. No SQL-saving, CPU, latency, or wall-clock claim will be made. This correction was published after seeing baseline diagnostics and before seeing any candidate result.