Skip to content

fix(sessions): converge projections during active writes - #142018

Merged
RomneyDa merged 1 commit into
mainfrom
fix/session-projection-convergence
Sep 19, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/session-projection-convergence

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Summary

  • let transcript projection rebuilds claim a bounded, same-generation append-only tail instead of restarting whenever a live session advances
  • reuse one append classifier for live indexing, suffix projection, and rebuild catch-up so branch changes, resets, side appends, legacy/canonical transitions, and parent mismatches still fail closed

This ports the convergence design from #116259 onto the current projection/reconcile architecture and addresses the sustained-write livelock described in #115908.

Safety bounds

  • at most 512 post-snapshot rows
  • at most 256 KiB of serialized tail events
  • transcript generation must be unchanged
  • the full tail must be contiguous and append cleanly to the prepared cursor
  • prepared sources with unresolved leaf controls cannot use catch-up
  • partial base publication, rewrites, resets, branches, and oversized tails remain dirty for a fresh rebuild

Compatibility and recovery

  • no schema or stored-row format change; existing databases remain compatible
  • exact-snapshot publication remains unchanged
  • only bounded, same-generation append tails gain a successful publication path
  • reverting this commit restores exact-snapshot-only publication; raw transcript events are never rewritten by this change

Validation

  • pnpm check:changed passed on the rebased tree
  • 90 focused tests passed across projection catch-up/rebuild, replacement projection, memory reconcile, active events, search/cold archives, and exact suffix mutation
  • the exact compact-memory CI regression passes for both null and unresolved initial leaf controls
  • live recovery pass reconciled two previously stuck large projections (17,467 and 12,827 source events) to clean, exact-tip watermarks
  • the final unrelated-main rebase passed the exact-head regression tests and full changed-file gate

Review decision requested

Storage owner: please explicitly accept or reject the bounded same-generation catch-up publication contract above, including the compatibility, recovery, and rollback limits. This is the remaining material-store checkpoint identified by ClawSweeper.

Worked on by

@clawsweeper

clawsweeper Bot commented Sep 8, 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 size: L maintainer Maintainer-authored PR labels Sep 8, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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 Sep 8, 2026
@clawsweeper

clawsweeper Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 18, 2026, 1:04 AM ET / 05:04 UTC (Revision 13).

ClawSweeper review

What this changes

Allows session history and search indexes to finish rebuilding during bounded concurrent transcript writes, using shared append classification and generation checks.

Merge readiness

✅ Ready for maintainer review

This remains a useful fix: current main and v2026.9.4 still reject rebuilds when concurrent appends advance the snapshot. The prior content-block finding is resolved, and no blocking defect was found. The earlier separate storage-design approval blocker is not warranted by this contract-preserving repair.

Priority: P1
Reviewed head: ed94965154da48411a6b73a5b189a3f022a1abc0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, useful repair with conservative publication guards and no remaining blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal repair is exempt from the contributor proof gate. The body reports exact-tip recovery of two large projections; source and regression tests were inspected without executing the runtime.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored internal repair is exempt from the contributor proof gate. The body reports exact-tip recovery of two large projections; source and regression tests were inspected without executing the runtime.
Evidence reviewed 10 items Verified introduced scope: Reviewed the pinned merge-base-to-head changes, rather than endpoint drift. The changes preserve schema and stored-row formats; the stale test merge was not used to infer removal of main-branch behavior.
Remaining current-main defect: Current main requires both the prepared transcript timestamp and final sequence to remain unchanged at claim and finalization. An append racing preparation therefore rejects otherwise reusable work.
Latest-release comparison: The supplied v2026.9.4 release commit also contains exact-snapshot-only claim and publication checks. No released implementation of this bounded catch-up path was established.
Findings None None.
Security None None.

How this fits together

Session transcript projections turn canonical stored events into active conversation history and searchable text. A background worker prepares the projection, and the existing database writer publishes it for readers.

flowchart TD
  A[Transcript writes] --> B[Canonical stored events]
  B --> C[Worker prepares snapshot]
  C --> D[Claim and publish base chunks]
  B --> E[Validate bounded append tail]
  D --> F[Finalize current projection]
  E --> F
  F --> G[History and search readers]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +229, Tests +313, Other -1. Total +541 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 7 425 196 +229
Tests 2 313 0 +313
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 10 738 197 +541

Review metrics

Metric Value Why it matters
Production versus test growth Production +229 net lines; tests +313 net lines Production growth implements bounded catch-up and shared classification, with focused publication and rejection coverage.
Catch-up limits 512 rows and 256 KiB maximum Both claim and finalization bound the additional transcript tail accepted during concurrent writes.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #115908
Summary: This PR addresses the bounded snapshot-convergence portion of the canonical report, not all historical event-loop stalls.

Members:

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

Technical review

Best possible solution:

Keep history and search current during ordinary concurrent writes without weakening exact-current reads or rewriting canonical transcripts.

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

Yes, at source level: append after worker preparation and before claim or finalization; current main rejects the advanced snapshot and leaves reconciliation pending. No runtime reproduction was executed during this read-only review.

Is this the best way to solve the issue?

Yes for bounded transcript convergence: the patch reuses append classification and rechecks authoritative state before publication. It preserves the storage contract and does not claim to solve every broader Gateway starvation report.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7acf043d85c2.

Labels

Label justifications:

  • P1: The remaining convergence failure can keep active-session history unavailable while transcript writes continue.
  • 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: This maintainer-authored internal repair is exempt from the contributor proof gate. The body reports exact-tip recovery of two large projections; source and regression tests were inspected without executing the runtime.

Evidence

What I checked:

  • Verified introduced scope: Reviewed the pinned merge-base-to-head changes, rather than endpoint drift. The changes preserve schema and stored-row formats; the stale test merge was not used to infer removal of main-branch behavior. (ed94965154da)
  • Remaining current-main defect: Current main requires both the prepared transcript timestamp and final sequence to remain unchanged at claim and finalization. An append racing preparation therefore rejects otherwise reusable work. (src/config/sessions/session-transcript-projection-rebuild.ts, 7acf043d85c2)
  • Latest-release comparison: The supplied v2026.9.4 release commit also contains exact-snapshot-only claim and publication checks. No released implementation of this bounded catch-up path was established. (src/config/sessions/session-transcript-projection-rebuild.ts, 3a9d69db306c)
  • Publication safeguards: Finalization checks the current claim, complete active-row count, classification completeness, transcript generation, tail bounds, contiguous sequence, and append eligibility before inserting the tail and publishing readiness in the existing synchronous write transaction. Resets and ambiguous navigation reject catch-up. (src/config/sessions/session-transcript-projection-rebuild.ts:630, ed94965154da)
  • Reader and rewrite contracts preserved: Readers still require a clean, fully classified projection at the latest sequence within one read snapshot. Existing replacement and exact-rewrite owners rotate transcript generations, allowing the new finalization check to reject obsolete prepared data. (src/config/sessions/session-accessor.sqlite-projection-read.ts, ed94965154da)
  • Prior finding resolved and regression coverage inspected: The shared text extractor now compares content-block types without coercion. Added coverage preserves neighboring valid text and exercises catch-up success, oversized tails, unresolved leaf controls, reset/branch rejection, and generation changes. Tests were inspected, not executed. (src/config/sessions/session-transcript-projection-rebuild.test.ts:140, ed94965154da)

Likely related people:

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

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 (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-12T09:16:36.204Z sha 9e907c2 :: blocked before merge. :: none
  • reviewed 2026-09-14T00:17:49.427Z sha 377f7c6 :: blocked before merge. :: none
  • reviewed 2026-09-17T02:27:13.583Z sha d7a2695 :: blocked before merge. :: none
  • reviewed 2026-09-17T05:33:30.728Z sha d539dd4e2cf4330b9eb36fdca1cf78baf9dd481d :: blocked before merge. :: [P2] Preserve non-coercing checks for content-block types
  • reviewed 2026-09-17T05:54:15.824Z sha c41c168 :: blocked before merge. :: [P2] Preserve non-coercing checks for content-block types
  • reviewed 2026-09-17T06:43:43.578Z sha 7dd4bc0b695dd8d1615f5e00b03de01b4c41fedc :: blocked before merge. :: [P2] Preserve non-coercing checks for content-block types
  • reviewed 2026-09-17T07:18:27.354Z sha faeebd8 :: blocked before merge. :: [P2] Preserve non-coercing checks for content-block types
  • reviewed 2026-09-17T07:50:02.701Z sha ed94965 :: blocked before merge. :: none

@RomneyDa
RomneyDa force-pushed the fix/session-projection-convergence branch 2 times, most recently from f5dfbab to 4745f5e Compare September 12, 2026 08:08
@RomneyDa

Copy link
Copy Markdown
Member Author

Rebased and reconciled with current main at exact head 4745f5eeeeac2f86a2a5fafa5e72f71dc6c91fbd.

@steipete @shakkernerd @vincentkoc: requesting storage-owner review and an explicit accept/reject decision on the bounded same-generation catch-up publication contract. The PR body now records the no-schema compatibility story, conservative rejection paths, recovery limits, rollback behavior, 86-test integration proof, and live large-session recovery evidence.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 12, 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:

@RomneyDa
RomneyDa force-pushed the fix/session-projection-convergence branch from 4745f5e to 30064f5 Compare September 12, 2026 08:41
@RomneyDa

Copy link
Copy Markdown
Member Author

Pushed exact head 30064f53804803e51f245887f5ba436eba95c96c after fixing the compact-memory CI regression. The shared append classifier now preserves current-main first-row control initialization, while bounded catch-up rejects prepared sources with unresolved leaf controls before claim/publication. Added projection-level coverage; the exact failing memory-accounting case and the full changed-file gate pass locally. @clawsweeper re-review

@RomneyDa
RomneyDa force-pushed the fix/session-projection-convergence branch from 30064f5 to 9e907c2 Compare September 12, 2026 09:09
@RomneyDa

Copy link
Copy Markdown
Member Author

Rebased the unchanged patch onto current main at exact head 9e907c2e762592e08ce3e2aafc4fdc2d677a6e90. Patch ID is unchanged from the previously reviewed/green head; both leaf-control regressions and the full changed-file gate pass on this base. @clawsweeper re-review

@RomneyDa
RomneyDa force-pushed the fix/session-projection-convergence branch from 9e907c2 to 377f7c6 Compare September 14, 2026 00:08
@RomneyDa
RomneyDa force-pushed the fix/session-projection-convergence branch 3 times, most recently from 19c07c7 to d539dd4 Compare September 17, 2026 05:22
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 Sep 17, 2026
@RomneyDa
RomneyDa force-pushed the fix/session-projection-convergence branch from d539dd4 to dbcefaf Compare September 17, 2026 05:45
@RomneyDa
RomneyDa force-pushed the fix/session-projection-convergence branch from dbcefaf to c41c168 Compare September 17, 2026 05:46
@RomneyDa
RomneyDa force-pushed the fix/session-projection-convergence branch 2 times, most recently from 7dd4bc0 to faeebd8 Compare September 17, 2026 07:10
@RomneyDa
RomneyDa force-pushed the fix/session-projection-convergence branch from faeebd8 to ed94965 Compare September 17, 2026 07:42
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Sep 17, 2026
@RomneyDa
RomneyDa merged commit 3c9a40a into main Sep 19, 2026
222 checks passed
@RomneyDa
RomneyDa deleted the fix/session-projection-convergence branch September 19, 2026 22:51
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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