Skip to content

refactor: remove redundant collection precondition probes - #182890

Merged
steipete merged 1 commit into
mainfrom
dbasync/dpprobe
Oct 24, 2026
Merged

steipete merged 1 commit into
mainfrom
dbasync/dpprobe

Conversation

@steipete

@steipete steipete commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

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 stores undefined. 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 undefined as a stored value are intentionally retained.

Evidence

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.

Warm metric Baseline median [min–max], p95 Candidate median [min–max], p95 Ten-window total
SQL statements 50 [50–54], 54 50.5 [50–56], 56 511 → 515
Worker requests 12 [12–14], 14 12 [12–15], 15 125 → 126
Main-thread SQL 0 [0–0], 0 0 [0–0], 0 0 → 0

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: commitSessionEntryPatch 40→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 additional PRAGMA 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.

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.
@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T21:08:36.565529Z 0341c16 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: matrix Channel integration: matrix channel: telegram Channel integration: telegram channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web agents Agent runtime and tooling extensions: active-memory extensions: browser size: S labels Oct 24, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: The tracker checks and then removes 101 from the failed-update set before accepting its retry.
  • After: The tracker uses the deletion result to accept the same retry with one collection operation.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The source and green CI support a correct simplification, but the PR's registered measurement-based acceptance is unfinished.
Proof confidence 🦐 gold shrimp (3/6) Ordinary contributor proof gating is inapplicable to this maintainer-authored PR; exact-head CI supports the refactor, while the body still marks its Gateway count comparison pending.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
Reason: The maintainer-authored direction removes redundant work without adding machinery or changing the checked product contracts.

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
Reviewed head: 0341c16f0c94ef88f3bd24cf8123d2ec323915c1

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The registered baseline/candidate Gateway workload has no supplied result demonstrating its declared count acceptance criteria.
Agent review details

How this fits together

Channel, 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]
Loading

Technical review

Best 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

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

  • Pinned patch and current main: The introduced diff contains the collection substitutions described in the body; comparison of the touched paths against fetched main shows that main retains the pre-PR implementations. (0341c16f0c94)
  • Cached misses remain distinct: Discord stores strings or null, iMessage stores strings, null, or its ambiguity sentinel, and Telegram stores promises rather than their possibly missing resolved values; single reads preserve those cache contracts. (extensions/telegram/src/bot-message-dispatch-session.ts:22, 0341c16f0c94)
  • Retry and recency contracts: Telegram still exempts failed IDs before watermark rejection; Matrix still deletes before reinsertion, preserving watermark and prepared-trigger eviction order covered by existing owner tests. (extensions/matrix/src/matrix/monitor/room-history.test.ts:117, 0341c16f0c94)
  • Authority checks preserved: Completion consumption retains promotion, abort, and lifecycle checks; voice-call changes only the expiry callback's membership-and-removal pair, leaving token admission and expiry validation intact. (src/agents/embedded-agent-runner/runs.ts:403, 0341c16f0c94)
  • Exact-head CI: The reviewed head has successful aggregate CI, production types, prompt snapshots, dependency review, and security-sensitive review; ancillary auto-response cancellations do not establish a patch failure. (0341c16f0c94)
  • Supplied validation: The full live body and discussion contain static-check results and a registered Gateway count acceptance rule whose measurement remains pending; they contain no completed changed-path runtime comparison. (0341c16f0c94)

Likely related people:

  • Peter Steinberger: Raw commit e681569 adds src/agents/runtime-plan/tools.ts:52 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e681569536ea; files: src/agents/runtime-plan/tools.ts)
  • Vincent Koc: Raw commit 5aaf440 adds src/agents/embedded-agent-runner/runs.ts:1012 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5aaf44006b30; files: src/agents/embedded-agent-runner/runs.ts)
  • chain710: Raw commit 943163a adds extensions/matrix/src/matrix/monitor/room-history.ts:156 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 943163a419df; files: extensions/matrix/src/matrix/monitor/room-history.ts)

PR surface

Source -13. Total -13 across 16 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 16 40 53 -13
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 40 53 -13

Labels

Label changes:

  • add P3: This is behavior-preserving internal cleanup with no demonstrated user-facing defect or urgency.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is behavior-preserving internal cleanup with no demonstrated user-facing defect or urgency.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Complete the registered Gateway count comparison and verify its acceptance criteria.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 24, 2026, 5:22 PM ET / 21:22 UTC.

@steipete

Copy link
Copy Markdown
Contributor Author

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.

@steipete
steipete merged commit 2ddad7a into main Oct 24, 2026
185 of 194 checks passed
@steipete
steipete deleted the dbasync/dpprobe branch October 24, 2026 21:44
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: matrix Channel integration: matrix channel: telegram Channel integration: telegram channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web extensions: active-memory extensions: browser P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant