Skip to content

fix(sessions): migrate long histories without exhausting heap - #131276

Merged
steipete merged 3 commits into
mainfrom
steipete/openclaw-migration-stress-testing-43a217
Aug 28, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/openclaw-migration-stress-testing-43a217

Conversation

@steipete

@steipete steipete commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #127468.

What Problem This Solves

Operators upgrading many long transcripts—or one very long transcript—could exhaust the JavaScript heap before Doctor committed their import. Chunked JSONL reading did not help: the import owner retained every parsed transcript in a 256-session batch, then kept complete payload strings for deduplication and projection rebuilding. Even after importing successfully, healthy header and label checks could materialize the entire history again.

Large imports also paid for full-file SQLite repacking during automatic cleanup. In the profiled 256,000-event case, maintenance/compaction consumed about 66 of 164 seconds while full repacking reclaimed only 1.2% of the database.

Why This Change Was Made

The canonical import path now stages payloads and exact-byte deduplication in a private, disposable SQLite database. Readers and deferred source-fingerprint validators finish before the existing atomic batch transaction. Projection rebuilding retains navigation metadata, streams selected payloads, and uses a linear ancestor walk. The old whole-payload arrays/set and duplicate projection-building path are removed.

Healthy header detection reads the first ordered stored row, including nonzero sequences. Label detection streams through the existing normalizer. Actual repairs retain their full exact snapshots, malformed-sibling checks, ownership/binding checks, and atomic mutation guards. Automatic import finalization consolidates the former close/migrate booleans and incrementally vacuums databases that already support auto-vacuum. NONE-mode conversion and explicit session/shared compaction still run full VACUUM; full integrity and foreign-key checks, busy-checkpoint refusal, quarantine handling, and permissions remain intact.

Both storage decisions were explicitly approved before implementation. No canonical schema/version, runtime fallback, configuration option, dependency, or archive/restore contract is added or changed. Temporary-volume space and retaining partially filled pages are the documented tradeoffs. The final large corpus uses about 1.18% more database space than full repacking.

Production LOC: +460/-314 (net +146). Tests/test support: +921/-111 (net +810). Docs: +12. Guard/ratchet tooling: net +3, including an exact shrink-only assertion-baseline update. Production growth owns private disk staging, exact disk-backed deduplication, streamed projections, and bounded no-op detection. Smaller batches would not bound one long transcript; reading files inside the write transaction would violate its contract; deleting integrity checks would weaken the approved repair.

Regression provenance is clear for the allocations: batch materialization came from the large-session batching change, commit 1a821db04926, on 2026-08-17 (code author, PR author, and merger: @steipete). Whole-history label snapshots came with plain inbound-context labels, commit d7627d6f4cc4, on 2026-07-27 (code/PR author and merger: @jesse-merhi); header snapshots came with missing-header repair, commit 8aa67634ca03, on 2026-07-28 (code/PR author and merger: @galiniliev). Those repair behaviors remain; their healthy-path payload retention does not.

User Impact

Long histories can migrate without retaining a whole batch's payloads in the JavaScript heap. Session IDs, ordered content, active branches, exact SQLite handoff bytes, timestamps, ownership, source-change rejection, and recovery archives remain protected. Staging never becomes a second runtime store and is never resumed after interruption.

A JSON record must still fit in memory. Huge histories that genuinely need header or label mutation still use the existing full-snapshot repair contract. Healthy label scans remain linear. This PR does not claim globally bounded memory for every Doctor operation or provider execution.

AI-assisted implementation and verification. No release or package publication is requested.

Evidence

Source identity and focused proof

Final head: e3887beb8da8099b316633a32c2937ccd706b91a. Candidate package SHA-256: f912864d7aa27c7f77acb83e74bb493be5ed45a21c5640305e5d64dea1e6956a (58,991,509 bytes). The package builder checked all 16 changed/new performance files before and after building; after commit, every tested file was matched against its Git blob at this head. Package inventory/import integrity checks passed.

Both original import regressions aborted before the fix with exit 134 under a 256 MiB JavaScript heap: 256 transcripts × 64 roughly 32 KiB tool-result events, and one 100,000-event roughly 4 KiB transcript. The same limits passed after the repair on Linux Node 24.19.0 in 24.5 s and 24.9 s, including exact hashes, active projections, archives, and repeat import. That run passed 125 focused tests with 2 existing platform skips; another 62 ownership, handoff, race/ledger/startup, reconciliation, search, and Doctor sibling tests passed locally.

The healthy-header/label regressions separately failed before inside SQLite .all() on a 320 MiB transcript, after seeding outside the constrained child. Both now pass under the unchanged 256 MiB/30-second child limits with exact raw JSON/sequence/timestamp digests. The final four-file Doctor run passed 133 tests, including real SQLite NONE/FULL/INCREMENTAL cleanup, explicit session/shared repacking, Unicode-escaped labels, malformed siblings, snapshot races, recency, ownership, and FTS behavior.

Local pnpm build, the full changed-file gate, Kysely guard, typechecks, lint, architecture checks, and whitespace checks passed. No ineffective dynamic-import warning was emitted. Fresh isolated Codex autoreview of the performance diff and then the complete branch reported no accepted/actionable findings at its default P0-only threshold; reviews did not execute tests. The full-branch review confidence was 0.93.

Actual installed-package Docker matrix

Latest stable was resolved and rechecked as [email protected], with registry integrity sha512-ycF3yPcbjN6bUPeaUx6Mh6vze1hQWoD3CT/wWcmD7a8xaHHHRUaAlaq+lFxMHf1ssEgODVAwjlzYqp2twkYZ7g==. Each case installed that actual package and ran openclaw update --tag file:<candidate.tgz> --yes --no-restart --json.

All six final cases pass full ordered event-content/identity checks, complete expected session entries, active-branch projections, exact original/archive byte hashes, SQLite integrity/foreign keys, repeated-Doctor idempotence, real Gateway readiness, sessions.list, and visible chat.history markers. Inactive branch markers stay absent. Combined: 649 sessions, 1,132,000 transcript events, 960 additional artifact events, and 2,927,466,266 source bytes, rerun on the final candidate.

Corpus Sessions Events Source bytes First Doctor before → after Entire final package update Repeat Doctor
Branches/compaction, tools, Unicode, archived/reset/deleted/orphan/checkpoint files 24 24,000 + 480 artifacts 58,605,969 11.648 → 12.135 s 43.39 s 5.98 s
Many long tool-rich histories across three agents 192 192,000 463,907,229 70.957 → 53.413 s 100.22 s 19.12 s
Large three-agent corpus 384 768,000 1,862,265,993 569.658 → 290.431 s 379.40 s 62.08 s
One deep transcript 1 100,000 243,257,891 52.213 → 34.039 s 79.73 s 10.51 s
Large tool-result bodies 24 24,000 240,823,431 20.637 → 18.970 s 50.81 s 6.83 s
Copied installation with the old root absent 24 24,000 + 480 artifacts 58,605,753 14.189 → 15.406 s 47.02 s 6.03 s

Before/after use Node 24.19.0/npm 11.17.0 and the same four-CPU/12 GiB container limits on separate Testboxes. These are observed runs, not a universal speedup claim; small cases include installation/startup noise. The largest complete update dropped from 668.41 to 379.40 seconds. Full update peak RSS includes npm installation and is not migration-only memory.

The actual installed full Doctor previously aborted at 256 MiB on the already-current 100,000-event history. It now completes in 11.43 s at that heap limit, peak RSS 464,088 KiB, with exact idempotence. Without the heap cap, that case's peak RSS fell from 1,478,276 to 517,720 KiB.

An additional historical-store case used the actual stable setup --baseline and memory status --json to create shared and per-agent schema-v1, auto-vacuum NONE databases. With 100,000 events/243,257,894 source bytes, the package update completed in 74.63 s (first Doctor 33.476 s). Existing migrations produced shared schema 13 and agent schema 17, with the agent database converted to incremental auto-vacuum. Full integrity/FKs, exact content/archives, 256 MiB full Doctor (11.60 s), idempotence, and real Gateway history passed. This PR does not change those schema versions.

Provider: blacksmith-testbox, final package/fault lease tbx_01m12x62e689qkwxh01y210a1n, environment run, now explicitly stopped. First-candidate comparison used the earlier Testbox environment. No operator state, host home, service bus, or provider/channel credentials were mounted into the app containers. This is Testbox-hosted Docker proof, not direct AWS Crabbox or authenticated provider proof.

Fault and recovery boundaries

  • Between batches: SIGKILL of the packaged targeted Doctor after the first visible commit left exactly 256 sessions/128,000 events, good integrity/FKs, and every original source byte. Retry completed all 512 sessions/256,000 events in 92.32 s, peak RSS 446,600 KiB; a further import was idempotent.
  • Concurrent source modification: changing an earlier source while later sources were staged produced a visible error, zero canonical sessions/events, and retained the source/index.
  • Real updater finalization: SIGKILL of an updater-owned Doctor subprocess returned a visible CLI error after all 512 sessions/256,000 events had been committed and archived. This kill was not between batches. Actual openclaw update repair --yes --json completed in 24.97 s with unchanged full data/archive hashes; another Doctor and real Gateway history passed.
  • Temporary volume full: an actual 64 MiB tmpfs exhausted SQLite staging. Doctor exited nonzero with a disk-full error, wrote zero canonical rows, removed the failed stage, and retained all source bytes. Retrying with space on the temporary volume imported 64 sessions/64,000 events and passed exact/idempotent verification. Node's compile cache was outside the fault volume so the test targeted staging, not an unrelated cache failure.

Genuine dev-channel update and remaining gates

Separately, the literal published-stable → moving-dev command was exercised against GitHub, selecting e68aa7b5ff9c0605d37bcd48cde008e2a49d5c4a. It installed dev and migrated all 192,000 events/463,905,309 source bytes, but the old stable updater then failed loading a replaced module during finalization. Fresh openclaw update repair --yes --json completed in 32.16 s with unchanged verified data and archives. The fresh-process install-switch fix already exists on main in 4ee399c714d6; this PR does not rewrite or claim to fix the already-published stable binary.

The second genuine stable → dev clone/build/update used a fresh Git directory and the supported internal target-ref hook pinned to this exact PR head. It also returned exit 1 after 863.02 s with the same released-updater finalization error. Before recovery, the installed Git revision was independently verified as e3887beb8da8099b316633a32c2937ccd706b91a, and all 192 sessions/192,000 events/463,807,965 source bytes plus archives passed the complete oracle. Actual openclaw update repair --yes --json then succeeded in 49.40 s, with unchanged data/archive hashes. The newly installed CLI's subsequent openclaw update --channel dev --yes --json succeeded in 403.83 s, retaining the same pinned head. Another full Doctor passed in 31.13 s, and real Gateway readiness, session listing, and history passed for all three agents. The model selection was verified in both actual catalogs; no provider call was made.

That sequence proves candidate installation, migration, recovery, and a successful subsequent update—not a clean first hop from the old released updater. Git clone/build/check time is separate from migration timing; no Git checkout or build was faked. Provider blacksmith-testbox, lease tbx_01m1317mzdz5z8rffggtbhf8d5, exact-dev environment run, now explicitly stopped.

Exact-head CI run 33134954706 completed with openclaw/ci-gate SUCCESS. The native watcher ended GREEN after excluding superseded/cancelled contexts. A separate source review against frozen main 075487ad7755b5902f25af03f0d2fecbc7708cac found no new interaction defect in the upstream history/checkpoint/provenance changes: added arguments are optional and the canonical writers/schema owners are unchanged. That assessment is source-based, not a separately executed combined-tree suite.

The corpus uses stable V3 transcripts. Provider execution, native external-harness transcripts, binary media, and host-power-loss recovery are not claimed. Overall logical digests include source mutation metadata and are compared within each state directory; per-state content/metadata/archive oracles remain exact. Early harness setup/probe errors were corrected without weakening those oracles. The earlier ClawSweeper live probe stopped after 30 seconds waiting for a test-name string and did not observe a terminal suite result; the complete focused executions above are the test evidence. Its requested deep/interruption recovery evidence is now included here.

Exact permanent regression commands:

OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/commands/doctor-session-sqlite.memory.test.ts src/config/sessions/session-accessor.sqlite-import.test.ts src/config/sessions/session-transcript-projection-rebuild.test.ts src/config/sessions/transcript-tree.test.ts src/config/sessions/session-accessor.sqlite-bounded-context.test.ts src/config/sessions/session-accessor.sqlite-owner.test.ts src/commands/doctor-session-sqlite.test.ts
OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/config/sessions/legacy-main-session-migration.test.ts src/config/sessions/legacy-main-session-migration.race.test.ts src/config/sessions/legacy-main-session-migration.ledger.test.ts src/config/sessions/legacy-main-session-migration.startup.test.ts src/config/sessions/session-transcript-reconcile.lifecycle.test.ts src/config/sessions/session-transcript-search.test.ts src/commands/doctor-session-transcripts.test.ts
OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/commands/doctor-session-transcript-headers.test.ts src/commands/doctor-session-transcript-labels.test.ts src/commands/doctor-session-sqlite.test.ts src/commands/doctor-state-sqlite-compact.test.ts --reporter=verbose

The local host was heavily contended during early import-memory runs; one timed out and two diagnostic repeats were stopped. Unchanged tests passed on isolated Linux without larger heaps/timeouts. Subsequent complete local Doctor tests, changed gates, and build passed. Synthetic corpus tooling and raw proof remain campaign artifacts, not product runtime or committed transcripts.

Stage transcript payloads and deduplication in private temporary SQLite storage before the existing atomic import. Rebuild projections from navigation metadata and stream payload reads rather than retaining entire histories. Preserve exact handoffs, source validation, and archive recovery.\n\nFixes #127468.
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations size: L maintainer Maintainer-authored PR labels Aug 27, 2026
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Aug 28, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 11:51 PM ET / August 28, 2026, 03:51 UTC.

ClawSweeper review

What this changes

Migrates large legacy JSONL session histories through a temporary SQLite staging store so Doctor can import them without retaining whole transcript batches in heap.

Warning

SQLite table change

This PR modifies persisted SQLite tables in src/config/sessions/session-accessor.sqlite-import-stage.ts. Prefer a design that avoids changing persisted SQLite tables. If the change is necessary, verify migration and upgrade compatibility against an existing database before merge.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

The PR remains necessary and its introduced disk-backed staging path is coherent; no introduced correctness defect was found. Merge review should still reconcile the overlapping session-store PR and refresh exact-head/main validation before landing.

Priority: P1
Reviewed head: e3887beb8da8099b316633a32c2937ccd706b91a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has focused owner-boundary coverage and no verified introduced defect, with remaining value in exact-main overlap validation.
Proof confidence 🌊 off-meta tidepool Not applicable: The PR author is a repository member, so the external-contributor proof gate does not apply; the supplied PR evidence nevertheless describes installed-package and Docker migration proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The PR author is a repository member, so the external-contributor proof gate does not apply; the supplied PR evidence nevertheless describes installed-package and Docker migration proof.
Evidence reviewed 5 items Introduced migration owner: The PR resolves one physical destination store, stages callback rows before the canonical write transaction, reruns deferred source validators, then imports staged rows synchronously.
Bounded staging implementation: The new private temporary SQLite store constrains SQLite cache usage, keeps temporary work on disk, and removes its directory in a finally block.
Regression coverage: Focused import tests cover staging cleanup, rollback, changed sources, deduplication, idempotence, exact handoff, and physical-store rejection; constrained-memory Doctor coverage exercises the intended resource boundary.
Findings None None.
Security None None.

How this fits together

Doctor moves legacy session transcripts into OpenClaw’s canonical per-agent SQLite store before Gateway resumes using that history. The change replaces in-memory import preparation and healthy-history scans with bounded, disk-backed or streamed processing.

flowchart LR
  A[Legacy JSONL transcripts] --> B[Doctor migration reader]
  B --> C[Temporary SQLite staging]
  C --> D[Source fingerprint check]
  D --> E[Canonical SQLite transaction]
  E --> F[Gateway session history]
Loading

Before merge

  • Resolve merge risk (P1) - The bug fix adds roughly 146 net production lines for temporary staging and streamed health checks; that growth is justified by the bounded-memory ownership boundary but merits final maintainer scrutiny.
  • Resolve merge risk (P1) - The change overlaps open fix(sessions): preserve shared history across startup and repairs #127241 in Doctor/session-store ownership; the final merge must preserve both bounded import behavior and that PR’s physical-store/logical-agent routing.
  • Resolve merge risk (P1) - Exact current-main and three-way merge behavior could not be independently refreshed from this checkout, so exact-head CI and a current-main rebase remain needed before landing.
  • Complete next step (P2) - No repair work is queued because no introduced defect was found; a maintainer should review the exact-head reconciliation with the open shared-session-store change.
Agent review details

Security

None.

PR surface

Source +455, Tests +501, Docs +12, Other +3. Total +971 across 26 files.

View PR surface stats
Area Files Added Removed Net
Source 16 769 314 +455
Tests 7 612 111 +501
Docs 1 12 0 +12
Config 0 0 0 0
Generated 0 0 0 0
Other 2 4 1 +3
Total 26 1397 426 +971

Review metrics

Metric Value Why it matters
Production versus test delta production +460/-314 (net +146); tests/support +921/-111 (net +810); docs +12 Production growth implements the private disk spool, streamed projection/health reads, and transaction-safe handoff; most added coverage exercises migration and constrained-heap boundaries.
Changed decision surfaces 29 files affected The patch spans Doctor import, transcript health repair, projection rebuilding, and their regression coverage, so combined session-store validation matters before merge.

Stored data model

Persistent data-model change detected: database schema: src/config/sessions/session-accessor.sqlite-import-stage.ts, migration/backfill/repair: config/assertion-safety-baseline.txt, migration/backfill/repair: scripts/check-kysely-guardrails.mts, migration/backfill/repair: src/commands/doctor-session-sqlite-compact.ts, migration/backfill/repair: src/commands/doctor-session-sqlite-readers.ts, migration/backfill/repair: src/commands/doctor-session-sqlite-transcript-readers.ts, and 25 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #127468
Summary: This PR is the candidate repair for the long-history import heap defect; the shared-session-store PR is a partially overlapping follow-up.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Reconcile session-store overlap before merge (recommended)
    Rebase onto current main, retain the physical-store routing guarantees from fix(sessions): preserve shared history across startup and repairs #127241, and rerun the combined migration and restart proof.
  2. Pause until combined validation is available
    Defer landing if the overlapping session-store behavior cannot be validated together on the exact merge head.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Rebase onto current main, preserve bounded import staging plus physical-store/logical-agent routing, and attach exact-head combined migration and restart validation.

Technical review

Best possible solution:

Land one canonical bounded import path after reconciling it with the shared-session-store work and proving the rebased head preserves migration, integrity, and restart behavior.

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

No independent current-head execution was run in this read-only checkout, but the former whole-history preparation and the new constrained-heap regression harness make the failing path source-reproducible with high confidence.

Is this the best way to solve the issue?

Yes, subject to the overlap validation: staging before the synchronous canonical transaction keeps filesystem work out of the write lock while avoiding JavaScript retention of full transcript batches.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against eda219c4c21b.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool 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:

  • P1: A high-volume legacy migration can exhaust Doctor or Gateway memory before it reaches the durable import transaction, blocking an upgrade path.
  • merge-risk: 🚨 compatibility: The PR changes the shipped legacy-to-SQLite migration path and archival preconditions for existing installations.
  • merge-risk: 🚨 session-state: It transfers and rebuilds persisted transcript rows, indexes, and projections used by active session history.
  • merge-risk: 🚨 availability: The intended behavior directly affects whether large migrations can finish rather than exhausting process memory.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The PR author is a repository member, so the external-contributor proof gate does not apply; the supplied PR evidence nevertheless describes installed-package and Docker migration proof.

Evidence

Acceptance criteria:

  • [P1] Rebase or test-merge against current main.
  • [P1] Run the combined bounded-memory import, physical-store/logical-agent selection, transcript integrity, and Gateway restart coverage.
  • [P1] Confirm exact-head CI for the reconciled merge.

What I checked:

Likely related people:

  • steipete: Authored the introduced staging and healthy-history changes and earlier batched session-import work. (role: recent area contributor; confidence: high; commits: 1c0c732f3531, e3887beb8da8, 1a821db04926; files: src/config/sessions/session-accessor.sqlite-import.ts, src/config/sessions/session-accessor.sqlite-import-stage.ts, src/commands/doctor-session-sqlite-readers.ts)
  • jesse-merhi: Merged label-repair work that the streamed transcript-health readers preserve. (role: feature owner; confidence: medium; commits: d7627d6f4cc4; files: src/commands/doctor-session-transcript-labels.ts)
  • galiniliev: Merged the session-header repair whose detection and repair boundary are covered by this PR. (role: feature owner; confidence: medium; commits: 8aa67634ca03; files: src/commands/doctor-session-transcript-headers.ts)

Rank-up moves

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

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-08-28T00:14:30.547Z sha dc9b252 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T00:35:01.602Z sha dc9b252 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 28, 2026
Stream unchanged header and label detection while retaining exact snapshots and atomic guards for positive repairs. Reuse one import-finalize operation for handle closure, schema maintenance, and automatic incremental vacuum.

Keep full integrity checks, NONE-mode conversion, and explicit full compaction. Verified constrained-heap regressions, real historical upgrades, complete long-history Docker cases, process interruption, source mutation, and temporary-volume exhaustion.
@steipete
steipete marked this pull request as ready for review August 28, 2026 02:07
@steipete

steipete commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Land-ready review for e3887beb8da8099b316633a32c2937ccd706b91a. The exact-head CI run completed successfully with openclaw/ci-gate green. Native review artifacts are completed and validated; isolated full-branch Codex autoreview found no accepted/actionable findings at its default P0-only threshold. The PR body contains the exact permanent regression commands, source/package identities, timings, and complete limitations.

The root cause was payload retention at the import/projection and healthy-Doctor owners, not JSONL read chunk size. The canonical path now uses private disposable disk staging and exact disk-backed deduplication, streams selected projection payloads and healthy checks, and preserves source revalidation before the atomic canonical transaction. Automatic cleanup avoids unnecessary full repacking while retaining integrity/FK checks, NONE conversion, and explicit full compaction. Both storage decisions were approved before implementation. The temporary tables are not a canonical schema change. Production net +146 is justified by that planning boundary; tests/support net +810. Smaller batches do not bound one long transcript, and source reads inside the canonical transaction would violate the ownership contract.

All final package/fault proof is complete: six Docker cases, 649 sessions, 1,132,000 transcript events plus 960 artifacts, and 2.93 GB of source data; actual stable schema-v1 stores; 256 MiB full Doctor; between-batch SIGKILL/recovery; source mutation; updater-finalization SIGKILL/repair; and real 64 MiB tmpfs exhaustion/retry. Exact content, metadata, identity, projections, source/archive bytes, integrity/FKs, idempotence and real Gateway history passed. Largest first Doctor: 569.658 → 290.431 seconds; entire package update: 668.41 → 379.40 seconds under equal quotas on separate Testboxes. Final package/fault environment, provider blacksmith-testbox, lease tbx_01m12x62e689qkwxh01y210a1n, stopped.

The genuine stable → exact-dev clone/build test also completed. The published stable updater installed this head and migrated all 192,000 events, but returned exit 1 during its known replaced-module finalization bug. Before recovery, the installed full head and every data/archive invariant were independently verified. Actual openclaw update repair --yes --json succeeded in 49.40 seconds; the new CLI's subsequent openclaw update --channel dev --yes --json succeeded in 403.83 seconds. Another Doctor and real Gateway histories for all three agents passed. This proves installation, migration, recovery, and subsequent update—not a clean first hop from the already-published binary. The fresh-process fix already exists on main in 4ee399c714d6. Exact-dev environment, provider blacksmith-testbox, lease tbx_01m1317mzdz5z8rffggtbhf8d5, stopped. No provider execution or release is claimed.

Latest ClawSweeper exact-head review found no introduced correctness/security defect. Its remaining shared-store overlap/rank-up item is resolved by landing order: the physical-store/logical-agent repair is still OPEN and unmerged at 077ebbd94dd7d1534d99fa467eea917d6de795ae; it is not current-main behavior to import into this change. Land this bounded-memory owner first. That second PR must then retain staging, streamed health readers, import-finalization behavior, canonical physical options, logical-agent selection and defaultAgentId forwarding, and rerun the combined coverage as its own body requires. Combined execution of those two unmerged patches is explicitly deferred to the second landing, not claimed here.

Current-main reconciliation was refreshed: git merge-tree --write-tree origin/main e3887beb8da8099b316633a32c2937ccd706b91a succeeds against main 629a47e3cc20a9f8b6d19c105f840b8a693ec4aa, yielding tree 12d8dc90bb5212415828bd07b1013c19dad2115b. The migration/import/projection/health/compaction owners are unchanged since the earlier inspected main; newly adjacent cursor/shared-state changes were checked. This is a real conflict-free test merge plus source analysis, not a separately executed combined-tree suite. No rebase solely for moving-main drift is needed under the native workflow.

Focused results remain 125 import/projection/ownership passes (two existing platform skips), 62 sibling passes, and 133 final Doctor passes; local build and changed gates passed. Individual records and positive header/label repairs retain documented memory limits; incremental cleanup retains partly filled pages. The earlier 30-second ClawSweeper probe did not observe suite completion, whereas complete Linux logs do. No workloads, heap caps, timeouts, integrity checks, or exact-content assertions were weakened.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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 Aug 28, 2026
@steipete
steipete merged commit cd7b282 into main Aug 28, 2026
314 of 315 checks passed
@steipete
steipete deleted the steipete/openclaw-migration-stress-testing-43a217 branch August 28, 2026 04:44
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 28, 2026
…aw#131276)

* fix(sessions): bound legacy transcript import memory

Stage transcript payloads and deduplication in private temporary SQLite storage before the existing atomic import. Rebuild projections from navigation metadata and stream payload reads rather than retaining entire histories. Preserve exact handoffs, source validation, and archive recovery.\n\nFixes openclaw#127468.

* build: register doctor transcript staging SQL boundary

* perf(doctor): bound healthy history checks and import cleanup

Stream unchanged header and label detection while retaining exact snapshots and atomic guards for positive repairs. Reuse one import-finalize operation for handle closure, schema maintenance, and automatic incremental vacuum.

Keep full integrity checks, NONE-mode conversion, and explicit full compaction. Verified constrained-heap regressions, real historical upgrades, complete long-history Docker cases, process interruption, source mutation, and temporary-volume exhaustion.
@VACInc

VACInc commented Sep 13, 2026

Copy link
Copy Markdown
Member

Follow-up #146597 has merged. It builds on this PR's incremental-vacuum import-finalization path by skipping redundant cleanup and the second integrity scan for already-compact databases with zero free pages and no WAL. It retains initial validation and leaves explicit compaction and pending-cleanup behavior unchanged. This is an additional optimization; it does not replace this PR's bounded-memory migration work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. 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.

Legacy SQLite transcript import retains up to 256 complete unbounded transcripts before its transaction

2 participants