Skip to content

perf(trajectory): move global retention off the append writer - #165274

Merged
steipete merged 4 commits into
mainfrom
steipete/perf-micro-trajectory-append-sweep-20260919
Oct 5, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/perf-micro-trajectory-append-sweep-20260919

Conversation

@steipete

@steipete steipete commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Trajectory appends can block every other agent-database writer while performing global retention. A 24-hour production census recorded 12 append holds of 2.4–3.0 seconds, totaling 28.7 seconds, on an hourly cadence. The covering index landed in #165074 reduces scan cost, but the scan still holds the append writer.

User Impact

Global retention reads now run outside both the append transaction and its canonical writer reservation. Events are serialized before BEGIN; the existing bounded per-session suffix trim remains in the append. The 14-day age policy, 512 MiB global target, protected current session, whole-run eviction, byte accounting, and tie ordering remain intact. No new schema, configuration, dependency, or migration is introduced.

The tradeoff is more total maintenance work: in the final fixture, retention settlement took 31.44 seconds instead of 3.82 seconds. Concurrent changes reject a stale selection and defer remaining cleanup to a later append. Progress under continuous writes and full reclamation to the default 512 MiB budget remain unproven. Nested synchronous appends also defer cleanup until a later independent append, avoiding maintenance inside the caller's transaction and premature cadence publication after rollback.

Why This Change Was Made

One lifecycle-owned retention job reuses the existing read worker. SQL aggregates through the canonical covering index; a bounded accumulator keeps the oldest 100 candidate runs while preserving locale-sensitive and NULL/empty-ID ordering. Separate admitted transactions delete an oldest prefix capped at 100 runs and 10 MiB, allowing one oversized complete run. Native incarnation, local mutation revision, and foreign data version must still match before deletion. Committed results carry the revision to the next batch; only a complete sweep advances cadence.

The inline global scan and unbounded JavaScript run array/sort are removed. Private prepared rows receive their sequence numbers inside the writer without another object copy. One retention kernel serves synchronous and asynchronous callers. Cancellation, database borrowing, and cleanup remain attached to agent/shared-state lifecycles; failed cleanup stays visible to lifecycle joiners, and callbacks do not retain completed append batches.

LOC exception: +419 net (586 added, 167 removed; excluding tests, test support, and docs): +416 runtime lines and three wrapper-inventory entries, exceeding this lane's neutral-LOC target. The added code preserves the independent reader's cancellation/drainage and database borrow, admitted revision-fenced deletion, and exact eviction ordering. No alternate inline implementation or new persistence owner remains.

Evidence

The final comparison uses indexed main c8b847edc7e4e5089cec4b01ca056727f24e279a and the final implementation, including the allocation cleanup. Both use the real schema, writer broker, admission, and read-worker boundaries with the same synthetic fixture shape: 20,067,216 rows, 200,001 runs, 156-byte event envelopes, 3,130,485,696 payload bytes, and a 5,725,073,408-byte database.

Final 20M-row comparison Indexed main This change
Queued-append burst p99 4,342.77 ms 2,302.67 ms
First-use append 1,957.74 ms 162.55 ms
Maximum append IMMEDIATE hold 1,807.82 ms 80.04 ms
Ordinary append p99 143.52 ms 113.83 ms
Suffix traversal p50 / p99 64.60 / 93.89 ms 56.85 / 71.32 ms
Retention-outcome run: maximum append hold 2,109.47 ms 74.11 ms
Retention-outcome run: maximum separate delete hold — 15.17 ms
Retention settlement, excluding identity hashing 3.816 s 31.439 s

Exact retention outcome: both retain 19,866,470 rows, with ordered identity SHA-256 db5b7c0a15f21c9c15610bcf38faf97b5b422ce0e165549a55e198d818515d78. Starting after the timing phase, 20,066,516 rows + 22 appended rows − 200,068 deleted rows = 19,866,470. Both delete the same 2,000 historical runs/200,000 rows and 68 rolling-prefix rows. Candidate cleanup uses 20 delete transactions: 11.67 ms median, 15.17 ms maximum, 235.40 ms total. Its 21 deferred reads total 27.925 seconds. Identity hashing takes 17.228 / 16.974 seconds separately; complete outcome runs take 21.045 / 48.413 seconds.

The final pair ran on Blacksmith Testbox tbx_01m44s37p4q078rvbd5hdxbybh, profile openclaw-check, Linux, 4 guest-reported CPUs, Node 24.19.0, SQLite 3.53.3, and pnpm 12.5.1. Load samples ranged from approximately 0.01 to 1.68. Both revisions used nice -n 10 ionice -c3, isolated state/TMPDIR on disk, and enforced free-space reserves. The full paired driver exited 0 in 215.897 runner seconds; each completed synthetic database was removed after its evidence was recorded.

Limits: 31 queued victims make nearest-rank burst p99 equal to the maximum; ordinary p99 has 300 samples. First-use exercises the hourly retention kernel without waiting an hour. The roughly 67k-row active suffix is a tiny-event stress case, not production payload distribution. Scan timing raises the existing internal byte cap to retain the large corpus; the outcome applies age/byte pressure for 2,000 run evictions. An earlier shared-rig run corroborated shorter writer holds but had worse ordinary p99, so these observations do not establish a general throughput improvement.

Validation, costs, and source identity

The benchmarked runtime implementation at 50bb65373eae93e3b2e5e5db9bb050bbf694efcd against the pinned base has full-index patch SHA-256 12f668727e2f37847a42821ebb850dc37c434f55b7b6c5aa66277fba0f677574 (abbreviated-index patch 283f2ef88218ae5c7cc17386d9662b1dda941710a8d86a52dd5ee1dacf1571aa). It was verified before and after execution in an isolated Testbox checkout. The subsequent CI repair changes only the wrapper inventory; every runtime file remains byte-identical.

Command / scope Provider and lease Result / measured cost
node scripts/check-changed.mjs --staged blacksmith-testbox, tbx_01m44s37p4q078rvbd5hdxbybh Passed, 1,693.249 s command wall; all guards, core typechecking, 27 test typecheck graphs, export scans, lint, import-cycle and database checks
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json <11 changed TS files> --threads=1 Same final lease 0 warnings/errors, 10.474 s wall
node scripts/run-vitest.mjs src/trajectory/runtime-store.sqlite.test.ts --maxWorkers=1 Same final lease 34 passed, 25.030 s wall including cold transforms
node scripts/run-vitest.mjs src/trajectory/runtime-store-writer.test.ts --maxWorkers=1 Same final lease 11 passed, 18.713 s wall
All eight trajectory test files plus src/infra/sqlite-readonly-worker.operations.test.ts blacksmith-testbox, tbx_01m44nsza4ybe4vwc7d1k8djty 132 passed across nine files before the final allocation/type-only lint repairs; affected 45 tests rerun above
node scripts/run-vitest.mjs src/trajectory/runtime-retention.test.ts --maxWorkers=1 That preceding lease 1 passed, 2.348 s command wall
Other trajectory/read-worker siblings, six files through the repository runner That preceding lease 86 passed across three shards, 27.156 s wall
pnpm build blacksmith-testbox, tbx_01m44gvd9k34v67pcszaz9pz2v Passed on the original pre-rebase candidate in 491.725 s; separately reported a Control UI startup-size overage. Final tests compiled the current worker generation; this is not claimed as a full build of the rebased head.

CI repair: run 37255362137 passed every selected check except checks-node-compact-small-2 and its aggregate gate. The source-closure test found three newly reachable files absent from the maintainer wrapper inventory: src/trajectory/paths.ts, runtime-retention.sqlite.ts, and runtime-retention.worker.ts. The repair adds those exact entries; no assertion changed. On blacksmith-testbox / openclaw-check lease tbx_01m44z7cmar9nafr9cxhfv2k4a, the original pr-wrapper-source-closure.test.ts passed all 3 cases in 3.136 s wall, the selected eager-import-closure.test.ts “PR wrapper inventory” case passed in 3.804 s, and node scripts/check-changed.mjs --staged passed for the manifest delta in 94.526 s. The repair also passed independent P0–P2 review. Repaired-head CI passed: run 37259893749, head 7945005063dce5d57d64e623f2751cd1b147b77a: 59 successful jobs, 24 intentionally skipped jobs, 6m27s run elapsed, and 8,508 accumulated job wall seconds. The formerly failing compact-small-2 job passed in 110 job wall seconds (including setup).

Original baseline ae4ebd2c failed the serialization, competing-writer, and bounded-delete regressions for their intended reasons (25.23 s focused invocation). The extended cadence regression also failed on the candidate's pre-fix synchronous implementation: after outer rollback, the next independent append incorrectly retained the old run (26.18 s invocation). It passes in the final full SQLite suite.

Independent review found cleanup-failure propagation, append-payload capture, and nested-transaction cadence defects; each was repaired. The final source repairs are scoped-clean at P0–P2. The first complete rig gate passed its guards/typechecks/export scans but found three lint errors; those were fixed without suppressions before the final green Testbox gate. No assertions, baselines, budgets, or guard policies were weakened.

Queued/disappeared leases, checksum-sync failures, and mismatched sync-root Git metadata were infrastructure failures, not passing evidence. Validation used a pinned isolated checkout and full object IDs. Superseded/cancelled rig gates are not claimed as passing. The final pair moved to Testbox when safe cleanup could not restore the rig's required disk reserve. All owned leases and rig worktrees have been stopped or removed. Auto-merge completed as squash commit 09242dc32ae1182f72856721170524882051f0f8 after repaired-head CI passed. The documented sustained-write/default-budget convergence gap remains; the automated review requested a maintainer decision on that operational tradeoff.

No production database was queried or modified, and no Gateway was restarted.

Prepare serialized rows before writer admission, select bounded whole-run retention candidates outside the writer, and fence short delete batches with the native database revision. Preserve age and byte policies, active-session protection, and eviction ordering.
Use the canonical covering index for one grouped retention scan, preserve its plan regression, and defer synchronous maintenance while an enclosing transaction remains open. This keeps failed outer writes from suppressing the next retention pass.
Assign sequence numbers to private prepared rows inside the writer without allocating another object per event. Declare receiver-free authority callbacks and keep maintenance promise observation with its lifecycle owner.
@clawsweeper

clawsweeper Bot commented Oct 5, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XL labels Oct 5, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 5, 2026
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 4, 2026, 11:39 PM ET / October 5, 2026, 03:39 UTC (Revision 3).

ClawSweeper review

What this changes

Trajectory event capture moves global cleanup outside append transactions into independent reads and short, revision-checked deletion batches.

Merge readiness

⛔ Blocked before merge - 3 items remain

This remains a useful, measured improvement absent from current main. No discrete correctness defect was found, but retention progress under sustained writes remains unresolved from the previous review.

Priority: P2
Reviewed head: 7945005063dce5d57d64e623f2751cd1b147b77a
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Substantial production-boundary evidence and a focused implementation support normal good quality, with retention liveness still requiring resolution.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The captured paired Testbox run exercises the changed append, retention reader, and admitted deletion owners through real SQLite and worker boundaries, showing shorter holds and identical retained rows. Sustained-write/default-budget coverage remains a separate operational uncertainty. No stored-data model changes require migration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured paired Testbox run exercises the changed append, retention reader, and admitted deletion owners through real SQLite and worker boundaries, showing shorter holds and identical retained rows. Sustained-write/default-budget coverage remains a separate operational uncertainty. No stored-data model changes require migration.
Evidence reviewed 9 items Pinned introduction and review continuity: Reviewed the introduced merge-base-to-head changes. The only change since the previous reviewed head is three wrapper-inventory entries; the runtime and its prior retention-progress concern are unchanged. The supplied test merge is stale and was not used to infer removal of base-branch behavior.
Current main still performs inline retention: Current main invokes global retention from inside the append transaction. GitHub confirms #165074 merged the covering-index optimization, which reduces scan cost but does not implement independent cleanup.
Latest release retains the previous implementation: Read the runtime store directly from the v2026.9.8 GitHub contents endpoint after its local object was unavailable. That release also invokes the global sweep inside append processing.
Findings None None.
Security None None.

How this fits together

Trajectory records agent-run events in each agent’s SQLite database for diagnostic export. Its appends share the database writer with other agent state operations, so long cleanup transactions delay unrelated writes.

flowchart TD
 A[Agent runtime events] --> B[Prepare serialized rows]
 B --> C[Append and trim session window]
 C --> D[Independent retention read]
 D --> E[Check authority and database revision]
 E -->|Current| F[Delete bounded historical runs]
 E -->|Changed| G[Defer until another append]
 F --> D
Loading

Decision needed

Question Recommendation
Must retention demonstrate sustained-write progress and convergence to the default 512 MiB target before merge, or may cleanup depend on quiet periods? Establish retention progress: Require production-boundary evidence of progress during sustained writes and convergence to the default budget before accepting the tradeoff.

Why: The latency benefit is demonstrated, but accepting potentially indefinite cleanup deferral requires explicit owner intent.

Before merge

  • Resolve merge risk (P1) - Sustained database writes can repeatedly invalidate cleanup selections, leaving historical events above the age or byte target; convergence to the default 512 MiB budget remains unproven, while measured settlement work increased about eightfold.
  • Complete next step (P2) - Resolve the retention-progress tradeoff through sustained-write/default-budget evidence or explicit acceptance of quiet-period cleanup.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source +416, Tests +468, Docs +14, Other +3. Total +901 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 8 583 167 +416
Tests 3 485 17 +468
Docs 2 22 8 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 0 +3
Total 14 1093 192 +901

Review metrics

Metric Value Why it matters
Writer hold versus cleanup cost Maximum append hold 1,807.82 → 80.04 ms; settlement 3.816 → 31.439 s The paired fixture demonstrates the intended latency benefit and its maintenance-cost tradeoff.
Production versus test growth Runtime net +416 lines; wrapper inventory +3; tests net +468 The body justifies production growth through reader lifecycle ownership, revision-fenced deletion, and preserved eviction ordering.

Merge-risk options

Maintainer options:

  1. Verify cleanup under write pressure (recommended)
    Show retained-byte progress during sustained writes and settlement to the default budget, repairing scheduling if that scenario cannot converge.
  2. Own the quiet-period limitation
    Record explicit acceptance of potentially indefinite retention deferral on busy databases and document the operator-visible limitation.

Technical review

Best possible solution:

Preserve short append holds while ensuring retention makes progress under write pressure, with explicit documentation of any accepted quiet-period limitation.

Do we have a high-confidence way to reproduce the issue?

Yes: current main places the global scan inside append admission, and the captured production-boundary benchmark demonstrates long writer holds. This review did not execute code.

Is this the best way to solve the issue?

Unclear: independent reads and bounded deletion address writer latency cleanly, but sustained-write retention progress must be demonstrated or explicitly accepted as a limitation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 94f1e932eedc.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This addresses measured shared-writer latency without evidence of an urgent outage.
  • merge-risk: 🚨 availability: Repeated cleanup deferral can permit historical storage growth, and the recorded fixture requires substantially more maintenance work.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The captured paired Testbox run exercises the changed append, retention reader, and admitted deletion owners through real SQLite and worker boundaries, showing shorter holds and identical retained rows. Sustained-write/default-budget coverage remains a separate operational uncertainty. No stored-data model changes require migration.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured paired Testbox run exercises the changed append, retention reader, and admitted deletion owners through real SQLite and worker boundaries, showing shorter holds and identical retained rows. Sustained-write/default-budget coverage remains a separate operational uncertainty. No stored-data model changes require migration.

Evidence

What I checked:

  • Pinned introduction and review continuity: Reviewed the introduced merge-base-to-head changes. The only change since the previous reviewed head is three wrapper-inventory entries; the runtime and its prior retention-progress concern are unchanged. The supplied test merge is stale and was not used to infer removal of base-branch behavior. (scripts/pr-lib/wrapper-components.txt:1720, 7945005063dc)
  • Current main still performs inline retention: Current main invokes global retention from inside the append transaction. GitHub confirms perf(trajectory): sweep retention from a covering index instead of regrouping every event #165074 merged the covering-index optimization, which reduces scan cost but does not implement independent cleanup. (src/trajectory/runtime-store.sqlite.ts:177, 94f1e932eedc)
  • Latest release retains the previous implementation: Read the runtime store directly from the v2026.9.8 GitHub contents endpoint after its local object was unavailable. That release also invokes the global sweep inside append processing. (src/trajectory/runtime-store.sqlite.ts:137, fc23bc864e45)
  • Real production-boundary performance evidence: The complete captured body, source identity 5549e38b92747be542436e22e874aaaa7bcb7398e447b964589eb3c78cade56b, reports paired isolated Testbox execution through real SQLite schema, writer broker, admission, and read-worker boundaries on 20,067,216 rows. Maximum append hold fell from 1,807.82 ms to 80.04 ms, with identical retained row identities. Settlement increased from 3.816 s to 31.439 s. Comparison against the previous reviewed head verifies that benchmarked runtime files remain unchanged. (src/trajectory/runtime-retention.ts:130, 50bb65373eae)
  • Retention progress remains conditional: Deletion rejects any changed native incarnation, foreign data version, or local mutation revision. The scheduler ends that sweep on rejection and requires another append to retry. The added competing-append regression explicitly retains historical events after invalidation and removes them on a later retry; it does not establish continuous-write progress. (src/trajectory/runtime-retention.sqlite.ts:184, 7945005063dc)
  • Prior concern has no recorded acceptance: The prior completed review requested sustained-write progress and default-budget convergence evidence or explicit acceptance of quiet-period cleanup. The captured body still identifies those scenarios as unproven, and the live discussion contains no human acceptance resolving the tradeoff.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Demonstrate retention progress during sustained writes and convergence to the default 512 MiB target, or record explicit acceptance of quiet-period cleanup.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-05T02:23:22.159Z sha 50bb653 :: blocked before merge. :: none
  • reviewed 2026-10-05T02:29:38.564Z sha 50bb653 :: blocked before merge. :: none

@steipete
steipete marked this pull request as ready for review October 5, 2026 02:25
@steipete
steipete enabled auto-merge (squash) October 5, 2026 02:26
Keep the trusted wrapper source inventory closed over the new read-only retention operation and its runtime imports.
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 5, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 5, 2026
@steipete
steipete merged commit 09242dc into main Oct 5, 2026
147 checks passed
@steipete
steipete deleted the steipete/perf-micro-trajectory-append-sweep-20260919 branch October 5, 2026 03:40
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer decision (post-merge, lead of the Team perf campaign): accepted with a follow-up.

The latency half is proven on the paired Testbox run (max append writer hold 1,808 ms to 80 ms, deletions at most 15 ms, identical retained rows), and this landed as part of the Team round-48 deployment. The retention-progress question is real: under sustained writes the revalidation step can keep invalidating cleanup selections, so convergence to the default 512 MiB budget is unproven and settlement grew about eightfold on the synthetic run. Team's trajectory table is currently far under budget (0.63 GiB, every session under its per-session cap), so this is a contract risk rather than an active regression.

Resolution: a dedicated follow-up lane is measuring convergence under a sustained-write workload (continuous appends across hundreds of sessions while the sweep runs) and, if it does not converge within one sweep cycle, will make revalidation reject only candidates whose own facts changed and carry sweep progress forward with a cursor, keeping the bounded deletion holds and the current-session protection. That work references this decision in its PR body.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 5, 2026
…aw#165274)

* perf(trajectory): move retention reads off the append writer

Prepare serialized rows before writer admission, select bounded whole-run retention candidates outside the writer, and fence short delete batches with the native database revision. Preserve age and byte policies, active-session protection, and eviction ordering.

* fix(trajectory): preserve retention cadence across nested rollbacks

Use the canonical covering index for one grouped retention scan, preserve its plan regression, and defer synchronous maintenance while an enclosing transaction remains open. This keeps failed outer writes from suppressing the next retention pass.

* perf(trajectory): avoid copying prepared insert rows

Assign sequence numbers to private prepared rows inside the writer without allocating another object per event. Declare receiver-free authority callbacks and keep maintenance promise observation with its lifecycle owner.

* fix(trajectory): include retention worker in maintainer wrapper

Keep the trusted wrapper source inventory closed over the new read-only retention operation and its runtime imports.
steipete added a commit that referenced this pull request Oct 5, 2026
Move retention request and result types into a dependency-free leaf contract shared by the SQLite reader registry and worker. Keep the existing lazy worker loader and retention behavior unchanged.

The type-only registry import introduced by 09242dc (#165274) pulled the agent database and SQLite reader back into the registry graph.

Validated both import-cycle guards at zero, core and state/trajectory test types, focused SQLite/retention tests (36 passed), formatting, and lint.
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up on the accepted post-merge finding (retention convergence under sustained writes): #165678 lands the fix. The global aggregate now runs outside the writer transaction with sweep-scoped in-memory receipts and a foreign-commit refresh; on the 20M-row fixture retention converges in 9.7 s with zero invalidations (previously no sweep completed in 30 minutes), and the deletion transaction's SQL hold is 3.7 ms (the remaining ~123 ms peak is a WAL checkpoint commit, tracked separately as "WAL checkpoint scheduling during retention deletes").

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
Move retention request and result types into a dependency-free leaf contract shared by the SQLite reader registry and worker. Keep the existing lazy worker loader and retention behavior unchanged.

The type-only registry import introduced by b7ca379 (openclaw#165274) pulled the agent database and SQLite reader back into the registry graph.

Validated both import-cycle guards at zero, core and state/trajectory test types, focused SQLite/retention tests (36 passed), formatting, and lint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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