Skip to content

feat: model LCM family and segment continuity#3

Open
100yenadmin wants to merge 1 commit intofeat/lcm-645-sqlite-frontierfrom
feat/lcm-642-identity
Open

feat: model LCM family and segment continuity#3
100yenadmin wants to merge 1 commit intofeat/lcm-645-sqlite-frontierfrom
feat/lcm-642-identity

Conversation

@100yenadmin
Copy link
Copy Markdown
Owner

Summary

Introduces the continuity model Lossless Claw needs to map onto OpenClaw's database-first runtime without treating every runtime sessionId change as a brand-new logical conversation.

This PR adds explicit:

  • familyKey
  • segmentKey
  • runtime sessionId

to LCM conversation identity.

That lets LCM represent:

  • one logical family across multiple runtime sessions
  • one logical segment within that family until a real lifecycle split happens
  • explicit new segments for /reset, idle, and daily lifecycle events

This is the implementation slice for #642, stacked on top of the SQLite frontier work in #646.

Why this is better

OpenClaw's newer runtime semantics separate:

  • stable logical ownership
  • lifecycle-driven session replacement
  • raw runtime sessionId churn

LCM's older model was effectively:

  • stable sessionKey when present
  • otherwise raw sessionId

That is too weak once the canonical source is a multi-entity SQLite runtime.

This PR gives LCM a continuity model that matches the architecture we actually want:

  • stable family continuity
  • explicit segment splits
  • runtime sessionId as an operational identity, not the whole story

Architecture

flowchart LR
    A["familyKey"] --> B["segmentKey"]
    B --> C["runtime sessionId"]
    A --> D["logical conversation family"]
    B --> E["current active segment"]
    C --> F["current runtime owner"]
Loading

Lifecycle mapping in this PR:

  • same sessionKey, new runtime sessionId: same family, same segment
  • /reset: same family, new segment
  • idle: same family, new segment
  • daily: same family, new segment

What changed

Schema and migration

  • adds family_key and segment_key to conversations
  • backfills older rows forward from legacy session identity
  • adds supporting indexes for active family lookup and unique segment identity

ConversationStore continuity rules

  • getOrCreateConversation(...) now reasons about family and segment continuity explicitly
  • active family reuse updates runtime sessionId in place
  • legacy sessionId rows can backfill into keyed family continuity without creating duplicates

Engine lifecycle behavior

  • lifecycle replacement now creates fresh segments inside an existing family instead of creating unrelated identity islands
  • runtime logs include family and segment information so later slices can reason about continuity explicitly

Non-goals

This PR does not:

  • solve bootstrap message_parts fidelity from #643
  • remap maintenance / rotate / GC behavior from #644
  • redesign the SQLite frontier from #645

Validation

cd /Volumes/LEXAR/repos/lossless-claw-642-identity
pnpm test \
  test/message-identity.test.ts \
  test/engine.test.ts \
  test/regression-2026-03-17.test.ts \
  test/lcm-tools.test.ts

Observed locally:

  • 4 files passed
  • 254 tests passed

Stack placement

This is the continuity-model slice for LCM vNext.

Related stack:

Issue

Refs Martian-Engineering/lossless-claw#642.

@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: 11d5cf56-e9ee-4c2c-bc1e-154011ead805

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-642-identity

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