Skip to content

fix: use canonical SQLite maintenance scope#2

Open
100yenadmin wants to merge 1 commit intofeat/lcm-643-message-partsfrom
feat/lcm-644-maintenance-remap
Open

fix: use canonical SQLite maintenance scope#2
100yenadmin wants to merge 1 commit intofeat/lcm-643-message-partsfrom
feat/lcm-644-maintenance-remap

Conversation

@100yenadmin
Copy link
Copy Markdown
Owner

Summary

Moves the maintenance-critical part of LCM off transcript-file ownership by treating OpenClaw's canonical SQLite transcript scope as the source of truth when it is available.

This PR closes the two real downstream survivors we were still seeing after the earlier slices:

  • transcript GC candidate matching still depended on reopening the transcript file even when SQLite was canonical
  • session_end(reason=\"compaction\") still split continuity into a fresh segment instead of preserving one logical conversation

This is the implementation slice for #644, stacked on top of #643.

Why this is better

Once OpenClaw's database-first runtime is canonical, LCM should behave like a companion projection system, not like the raw transcript owner.

That means:

  • maintenance should target canonical transcript scope, not file possession
  • checkpoint refresh should follow the canonical frontier, not only file stats
  • compaction successor runtime sessions should preserve one logical segment unless OpenClaw actually signals a real lifecycle split

This PR makes those boundaries real.

Architecture

flowchart LR
    A["OpenClaw canonical SQLite transcript scope"] --> B["LCM maintenance / GC mapping"]
    B --> C["summary-store GC candidates"]
    B --> D["rewrite request to host runtime"]
    A --> E["frontier refresh"]
    F["session_end reason=compaction"] --> G["same family, same segment"]
Loading

What changed

Canonical transcript GC mapping

  • adds SQLite-aware tool-result entry-id mapping for transcript GC candidate replacement
  • stops requiring transcript-file ownership when the host exposes canonical SQLite transcript replay
  • refreshes bootstrap checkpoint state from the SQLite frontier after maintenance when SQLite is the canonical source

Continuity correction for compaction successors

  • treats session_end(reason=\"compaction\") as successor continuity instead of archive-and-replace
  • preserves the same conversation family and segment while updating the runtime sessionId

Regression coverage

  • proves maintenance can target canonical SQLite transcript scope without reading a transcript file
  • proves successor runtime sessions can resume SQLite bootstrap inside the same logical segment

Non-goals

This PR does not:

  • redesign the upstream OpenClaw typed projection seam from #79905
  • move LCM summaries or recall state into OpenClaw core
  • remove legacy JSONL-only manual rotation paths for older hosts that still intentionally use them

Validation

cd /Volumes/LEXAR/repos/lossless-claw-644-maintenance-remap
./node_modules/.bin/vitest run --dir test \
  test/engine.test.ts \
  test/assembler-blocks.test.ts \
  test/bootstrap-flood-regression.test.ts \
  test/prune.test.ts \
  test/regression-2026-03-17.test.ts

cd /Volumes/LEXAR/repos/lossless-claw-644-maintenance-remap
pnpm run build

Observed locally:

  • 5 files passed
  • 319 tests passed
  • build passed

Stack placement

This is the last downstream migration slice in the current LCM vNext stack.

Related stack:

Issue

Refs Martian-Engineering/lossless-claw#644.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 10, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 29a53820-ea31-4bf7-8862-389e2b205879

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/lcm-644-maintenance-remap

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant