Skip to content

fix(sessions): publish complete rewrites without reset amplification - #138984

Merged
VACInc merged 8 commits into
mainfrom
openclaw/openclaw-openclaw-vacinc-issue-138965
Sep 7, 2026
Merged

VACInc merged 8 commits into
mainfrom
openclaw/openclaw-openclaw-vacinc-issue-138965

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

High Level TLDR

Transcript maintenance could lose the current task when interrupted, or repeatedly duplicate active history even when it succeeded. Publish the complete replacement branch atomically, preserve its explicit ancestry across resets, and make bounded/model-context readers retain that selected branch through later messages and session branching. An unchanged replacement now does no rewrite work.

Closes #138965. Closes #139201. Related to #119720; this does not close the Gateway starvation umbrella.

Current scope decision — September 6, 2026, 20:43 UTC

At the owner's direction, drop the custom old-stable-release rollback test and its associated blanket landing hold as requirements for this PR. This supersedes earlier hold wording in this body. The instruction is to finish CI and ClawSweeper review, not to merge or enable auto-merge.

  • The demonstrated v2026.9.2 shared-schema 15 → candidate shared-schema 16 boundary is inherited from the base, not introduced by this transcript repair. We will not create a bespoke old release, lower schema markers, or broaden this PR into repository-wide downgrade/checkpoint recovery to satisfy it.
  • Keep the atomic writer and selected-reader/branch repair together. The recorded older-reader context omission remains a real limitation: code-only rollback to those unpatched readers is not a supported recovery path for candidate-written history. Recovery must use a compatible build; restoring a verified matching pre-upgrade backup is a separate recovery operation and does not preserve subsequent work.
  • Keep the existing reset/no-reset, four-reader, later-append, interruption, admission and historical compatibility evidence. No new successful stable-release downgrade, end-to-end updater rollback, or universal same-schema compatibility is claimed.
  • A concrete regression in a rollback path the updater actually permits remains in scope. Schema-number equality alone does not prove transcript interpretation. Any such finding needs the reachable path and affected versions; dropping the broad drill does not waive a demonstrated runtime defect or weaken checks.
  • Broader whole-state recovery belongs with the existing updater work: verified package restoration and checkpoint/interrupted-update integration. The latter was still draft at inspection; this PR does not claim or depend on completed checkpoint recovery.

The optional review rank-up request for an additional custom rollback build is declined under this scope decision. Known limitations remain explicit rather than being hidden or relabeled as passing tests. Please assess current code/evidence and this recorded decision, rather than the superseded blanket hold.

September 7 post-interruption conflict refresh

Current head: c57369780ff3cffbd7fed54cd9bfd6c435175ac2, rebased onto 7600a4f571b10aaba679dba0f61100ea8c75fc5e. The preceding 2ff8e87fc967b5fc3b494b1a2ffdea4f9d0e9369 completed CI and review, but the resumed final-state check found a real new merge conflict after main changed identity publication in #138451. This refresh resolves that conflict; it is not a rebase merely to chase main movement.

The sole overlapping PR file was session-accessor.sqlite-transcript-write.ts. Branch replacement now returns both main's prepared identity-publication callback and the PR's transaction-produced transcript version. Retained assertActive checks run before mutation and before commit; manager adoption still precedes the publication callback in finally. Main's manual-compaction publication change is retained too. No new schema, storage format, configuration, or rollback policy is introduced. The earlier detached-reader repair and regression file remain byte-identical.

All eight commits retain their original authors and author dates (compared in order), exact VACInc co-author trailers, and ordered Worked on by blocks. No new fix commit or replacement PR was created.

Refresh validation

113 focused tests passed on this rebased candidate: branching/observer ordering and failed-write preservation, rewritten reset/no-reset readers, detached memory-flush snapshots, retained admission, and SQLite transaction ordering. The earlier 261-test run remains evidence for its original head below; it is not relabeled as a new 261-test run.

node scripts/run-vitest.mjs src/agents/embedded-agent-runner/transcript-rewrite.test.ts src/agents/sessions/session-manager-bounded.test.ts src/agents/sessions/session-manager-branching.test.ts src/agents/sessions/session-manager-model-context-snapshot.test.ts src/auto-reply/reply/memory-flush-session.test.ts src/agents/embedded-agent-runner/run/attempt-transcript-lifecycle-prepare.test.ts src/infra/sqlite-transaction.test.ts --reporter=dot

Writer type-aware lint, formatting for all changed TypeScript files, whitespace, and native schema guards passed. Fresh independent full-branch P1 autoreview against 7600a4f571b10aaba679dba0f61100ea8c75fc5e, with the new publication-owner contract supplied, was scoped-clean: no P0/P1 finding. Local typecheck/full-build dependency restrictions are unchanged; hosted exact-head build and typecheck gates have now passed. Full PR versus this base: production +672/-159 (net +513), tests +701/-11 (net +690), other -1.

Terminal refresh verification: CI run 34147175344 passed on exact head c57369780ff3cffbd7fed54cd9bfd6c435175ac2. The September 7, 17:39 UTC observation recorded 137 successful checks, 42 skipped, 1 neutral, zero failed or pending checks. Hosted build and production/test typecheck gates passed.

The fresh ClawSweeper review, reviewed September 7 at 17:27 UTC (worker 34147349101), covers this exact head and reports no actionable findings, proof 5/6, quality 4/6. Its remaining risk banner records the already accepted incompatible older-reader recovery limitation, not an outstanding code repair or a reinstated custom rollback hold. No manual duplicate review was requested.

The owner decision above remains authoritative: no custom old-stable drill or blanket rollback hold is reinstated. Keep the writer and repaired readers together; incompatible older-reader rollback stays unsupported. No merge or auto-merge authorized.

Earlier September 7 rebase and integration verification

Earlier verified head: 2ff8e87fc967b5fc3b494b1a2ffdea4f9d0e9369. Rebased the seven existing commits onto d234f9d4d09273615508d34bb1b098e803630165, preserving their original authors and exact contribution trailers, then added one credited integration-fix commit. All eight published commits retain the required VACInc co-author and ordered Worked on by block. The same PR branch is retained. A later main snapshot ba2a9af314262b2d2598db5dbbe82bc04ea911f2 merged cleanly in a non-publishing merge-tree check; no repeated rebase was done solely to chase unrelated main movement.

Rebase conflicts and newly exposed reader regression

Two import conflicts in session-manager.ts and session-manager-branching.ts were resolved by retaining both main's current-header validation / inherited branch-header version and this PR's transcript version receipts. Main still performs incremental suffix replay, so the atomic repair is not superseded.

Main also added SessionManager.openDetachedBounded for memory flushing. After the PR's side-entry rewrites, it fed the selected payload into the generic constructor without the omitted leaf controls. The extended existing regression failed in both reset/no-reset rows: without reset, the detached view retained only prefix and omitted the replacement/suffix; with reset, it exposed prefix instead of current task.

The fix routes detached bounded snapshots through the same selected-path constructor used by synchronous/asynchronous model-context readers, renamed fromSelectedEntries. It retains the owned-payload optimization and leaves public fromEntries cloning semantics unchanged. No new storage query, schema, migration, configuration, or compatibility fallback is added. The two existing cases now also verify detached append isolation, later durable appends, and session branching; no duplicate test cases were added.

Fresh proof

Node v26.7.0. 261 focused tests passed: 69 across rewrite, bounded/context-snapshot/branching and actual memory-flush preparation; 192 across shared rewrite callers, initial admission lifecycle, pending-input custody and SQLite transaction ordering. The two new failing assertions were reproduced before the owner repair.

node scripts/run-vitest.mjs src/agents/embedded-agent-runner/transcript-rewrite.test.ts src/agents/sessions/session-manager-bounded.test.ts src/agents/sessions/session-manager-branching.test.ts src/agents/sessions/session-manager-model-context-snapshot.test.ts src/auto-reply/reply/memory-flush-session.test.ts --reporter=dot
node scripts/run-vitest.mjs src/agents/embedded-agent-runner/tool-result-truncation.test.ts src/agents/embedded-agent-runner/thinking-replay-repair.test.ts src/agents/embedded-agent-runner/server-endpoint-compaction.test.ts src/agents/embedded-agent-runner/context-engine-maintenance.test.ts src/agents/embedded-agent-runner/run/attempt-transcript-lifecycle-prepare.test.ts src/config/sessions/session-accessor.pending-inputs.test.ts src/infra/sqlite-transaction.test.ts --reporter=dot

Changed-file type-aware lint/format, whitespace, conflict-marker, size, assertion-safety, native-state-schema and database-first guards passed. Fresh independent $autoreview --mode local --max-priority P1 was scoped-clean, reviewing the new repair with full owner/caller context supplied. Local typecheck/full-build gates were not rerun in the shared-dependency checkout; hosted exact-head CI supplies those gates, without bypassing checkout-local dependency boundaries.

New repair: production +5/-5 (net 0), tests +14/-0. Full PR against the rebase base: production +667/-153 (net +514); tests +701/-11 (net +690); other -1. The production increase remains the existing atomic publication/retained authority/selected-reader repair, not a new framework.

Terminal exact-head verification: CI run 34141522987 passed on 2ff8e87fc967b5fc3b494b1a2ffdea4f9d0e9369, including hosted build, production/test typechecks, Linux test shards, and both Windows test shards. The final observed rollup had 1 neutral, 42 skipped, 137 success, with zero failed or pending checks.

The fresh ClawSweeper review, completed September 7 at 16:12 UTC (worker 34141736325), reviewed this exact head and reports no actionable findings, proof 5/6, quality 4/6. It confirms the detached-reader integration repair and accepts the recorded rollback scope decision. Its remaining pre-merge notes are the documented unsupported older-reader recovery path and the absence of merge authorization—not an outstanding code repair or reinstated custom rollback drill. No manual duplicate review request was posted.

Historical evidence below retains its original SHA and is not relabeled as this head's test result.

The September 6, 20:43 UTC owner decision above remains authoritative: no custom old-stable drill or blanket rollback hold is reopened. Keep writer and repaired readers together; known incompatible code-only downgrades remain unsupported. No merge or auto-merge requested.

Historical stable-release rollback preflight — not a PR gate

On September 6, 2026, the requested real-release drill was stopped at its schema compatibility gate. v2026.9.2 plus only transcript reader/branch fixes is not a supported rollback target for this candidate's complete state directory. This is separate from the earlier transcript-only compatibility proof below.

Pinned revisions:

  • Stable tag v2026.9.2: annotated tag 87d32a44ab9744903d36a33b399c26cfc2b078d6, peeled commit 3928bad9badfcb6c7d140530435e806fb8092190; shared schema 15, agent schema 19.
  • Candidate: 1eff1c8e8c50685cc9f2769ef8738f762b393bf2; shared schema 16, agent schema 19.
  • Execution: Node v26.7.0, actual release source in a separate clean checkout with its own frozen-lockfile install (pnpm 12.1.0). Each phase ran in a fresh process using that checkout's real openOpenClawStateDatabase implementation. The candidate used its existing installed development dependencies. No copied storage methods, mocked version labels, packaged Gateway deployment, or operator databases were used.
Phase on one isolated synthetic shared database Observed result
Stable bootstrap Opened; user_version=15, metadata schema 15
Candidate opens stable output Canonical migration ran; opened with user_version=16, metadata schema 16
Unpatched stable opens candidate output Refused with SqliteSchemaVersionError: uses newer schema version 16; this build supports 15
Candidate reopens after refused downgrade Opened normally at schema 16

The stable refusal left the closed SQLite file byte-for-byte unchanged: SHA-256 before/after 8769c6535f60f54a5b646d4f8f4b1a296583a0511b26d180ae227d2764b4ca06. The version change is real shared-state migration already on the candidate base (Skill Workshop directory ownership), not a change introduced by this transcript PR. src/state/openclaw-state-db-schema-version.ts rejects the newer version before exposure; the release's startup preflight enforces the same schema boundary.

Scope and decision: no positive stable downgrade / keep-chatting / re-upgrade outcome is claimed. Reset/no-reset transcript fixtures, four-reader comparisons, and a reader-only stable backport were not executed because the prerequisite complete-state downgrade is incompatible. A reader-only backport cannot change shared-state schema support. No schema number was lowered, guard bypassed, database modified for downgrade, dependency patched, release published, or production source changed. Reopening the candidate is the demonstrated safe recovery from this refusal. Restoring a pre-upgrade backup would not establish preservation of post-upgrade conversation history.

This drill is retained as historical evidence of the inherited schema boundary. The owner has withdrawn a custom stable-release downgrade drill and its associated blanket hold as prerequisites for this PR; see the current scope decision above. No compatible rollback build is being manufactured or claimed.

Reproduce the actual-release schema gate

Create clean source checkouts pinned to the two full commits above. Install the stable checkout with pnpm install --frozen-lockfile; give each checkout its own compatible dependencies. Save this temporary probe outside both source trees, choose an absolute path to a new empty synthetic state directory, and run the four commands below. This is storage-owner execution, not a packaged full-Gateway or model-provider round trip.

import path from "node:path";
import { pathToFileURL } from "node:url";
const [stateDir, mode] = process.argv.slice(2);
if (!stateDir || !path.isAbsolute(stateDir)) throw new Error("absolute isolated state directory required");
process.env.OPENCLAW_STATE_DIR = stateDir;
const root = process.cwd();
const state = await import(pathToFileURL(path.join(root, "src/state/openclaw-state-db.ts")).href);
try {
  const opened = state.openOpenClawStateDatabase({ env: { ...process.env, OPENCLAW_STATE_DIR: stateDir } });
  console.log(JSON.stringify({ mode, root, outcome: "opened", schema: opened.db.prepare("PRAGMA user_version").get(), metadata: opened.db.prepare("SELECT role,schema_version,app_version FROM schema_meta WHERE meta_key = ?").get("primary") }));
} catch (error) {
  console.log(JSON.stringify({ mode, root, outcome: "refused", name: error instanceof Error ? error.name : "unknown", message: error instanceof Error ? error.message : String(error) }));
  if (mode !== "downgrade") process.exitCode = 1;
} finally { state.closeOpenClawStateDatabaseForTest(); }
# STABLE_ROOT and CANDIDATE_ROOT are the pinned source checkouts.
# PROBE and STATE_DIR are absolute paths; STATE_DIR must be new, empty, and synthetic.
(cd "$STABLE_ROOT" && node --import ./scripts/tsx.mjs "$PROBE" "$STATE_DIR" seed)
(cd "$CANDIDATE_ROOT" && node --import ./scripts/tsx.mjs "$PROBE" "$STATE_DIR" upgrade)
sha256sum "$STATE_DIR/state/openclaw.sqlite"
(cd "$STABLE_ROOT" && node --import ./scripts/tsx.mjs "$PROBE" "$STATE_DIR" downgrade)
sha256sum "$STATE_DIR/state/openclaw.sqlite"
(cd "$CANDIDATE_ROOT" && node --import ./scripts/tsx.mjs "$PROBE" "$STATE_DIR" reopen-after-refusal)

Expected observations are the table above. The probe prints a typed refusal rather than presenting a successful round trip; inspect its JSON outcomes, not only shell exit codes. Both tracked source trees remained clean.

September 6, 2026 rebase verification

Rebased the existing branch onto 856c5f518723d1c974024cf3e2811d50fbe655fb; reviewed rebase head: 6a882af1269b7fcf2b845d1cf8a004c0a4518b7e. Current attribution-normalized head: 1eff1c8e8c50685cc9f2769ef8738f762b393bf2. All seven commits now contain the exact VACInc co-author trailer and ordered multiline contribution block. Original authors, author dates, publication trailers, and every commit tree are preserved. The final tree is identical to the reviewed rebase head (2e83b13a657498e54652748bdf8d01a821163d3b). The prior merge resolutions were reconciled while retaining main's completed-turn anchors, transaction-local input custody, and compaction accounting. The atomic publisher and selected-reader/branch implementation remain byte-identical to the previously reviewed head.

Local proof: 236 distinct focused tests passed (rewrite 30; pending inputs 38; attempt lifecycle 21; bounded/context-snapshot readers 15; SQLite transaction 23; shared rewrite callers 109). The rewrite suite was rerun after the first main refresh; the final refresh changed only docs/docs.json. Changed-file format and type-aware lint, whitespace/conflict, size/assertion, native-schema, and database-first storage guards passed.

Commands used the repository node scripts/run-vitest.mjs runner for the named suites and direct repository guard/lint wrappers. Local production typecheck stopped before checking code because run-tsgo.mjs rejects an external dependency symlink; a fresh pnpm install is blocked by this host's minimum-release-age policy for pnpm 12.3.4. Core-test typecheck and a fresh local full build were not run. Hosted exact-head CI passed those lanes, including build-artifacts, check-prod-types, check-test-types and both core test-type shards; no local typecheck pass is claimed.

Terminal verification on final head 1eff1c8e8c50685cc9f2769ef8738f762b393bf2: CI run 34052609433 passed. Final observed rollup: 137 success, 42 skipped, 1 neutral, zero failures or pending checks. Hosted build, production types, test types, and relevant test shards passed.

The fresh ClawSweeper review also covers this exact final head, reviewed September 6 at 18:50 UTC (run 34052721734): no actionable findings, proof 5/6, quality/readiness 4/6. The automatic push event requested this review; no manual repeat review was posted. Its three remaining before-merge items all concern the explicit owner landing/rollback decision, not a current patch defect.

The preceding rebase head 6a882af1269b7fcf2b845d1cf8a004c0a4518b7e also passed CI run 34051686376 and received the no-actionable-findings review at 18:33 UTC. The attribution rewrite preserved every commit tree, original author and author date; the earlier compatibility matrices retain their original candidate revisions.

Historical hold superseded by the current scope decision above. No merge or auto-merge is requested. The selected-reader/branch fixes must remain present wherever candidate-written histories are consumed; unpatched older-reader compatibility is not claimed.

Previous-head verification and rollback decision

Head a9b90278f1dd1e3e1687f17409d9fb633fabe93d: CI gate passed, with no failed or pending checks when verified. The ClawSweeper review of this head confirms the previous reader finding is addressed and reports no actionable findings (quality/readiness 4/6, proof 5/6). The complete compatibility table resolved its prior excerpt-coverage concern; the historical request for a custom rollback build is superseded by the current scope decision above.

Complete final-format compatibility outcomes

Real production SessionManager/SQLite, two populated synthetic stores, with and without a reset. Candidate = the head above; older = 5eff5797bd53d3073ac241d36dbef4920c3f176f.

  • A = prefix, replacement, suffix, next turn.
  • B = current task, next turn.
  • A+ / B+ = that same context followed by rollback turn.
Exact step Full reader Bounded reader Sync model reader Async model reader
Older seeds store → candidate rewrites and appends, no reset A A A A
Older seeds store → candidate rewrites and appends, reset B B B B
Unpatched older opens candidate output, no reset A prefix, next turn prefix, next turn prefix, next turn
Unpatched older opens candidate output, reset B prefix, next turn empty-content entry, then next turn empty-content entry, then next turn
Older + reader backport opens candidate output, no reset / reset A / B A / B A / B A / B
Backported older appends through bounded manager, no reset / reset A+ / B+ A+ / B+ A+ / B+ A+ / B+
Candidate reopens after that older-code append, no reset / reset A+ / B+ A+ / B+ A+ / B+ A+ / B+
Backported older reopens the final stores again A+ / B+ A+ / B+ A+ / B+ A+ / B+

Read-only phases preserved every stored history record. The older-code append preserved every pre-existing history record and added the requested turn. The earlier head received only the three-file reader/branch backport reproduced below; its rewrite publisher stayed unchanged. Source records were not migrated, deduplicated, deleted or rewritten.

Decision boundary: this proves old→new and new→backported-old→new interoperability for the named revisions. It explicitly disproves safe rollback to the unpatched older readers. Retain/backport the reader repair when rolling back the writer. Older stable-release executables were not run; no blanket downgrade-compatibility claim is made. This is a required rollout/rollback condition, not an unresolved current-head code finding.

The requested scope remains code repair and proof. No merge or auto-merge is requested. Historical blanket rollback-test hold wording is superseded by the current scope decision above.

Root Cause

Two failures share the transcript rewrite owner:

  • Interrupted publication: the original implementation switched the live branch and persisted replayed entries individually. A stop during replay could leave an incomplete historical branch active. The existing PR replaces that with one transaction and adopts memory only at commit.
  • Successful amplification, reproduced on the previous PR head 5eff5797bd53d3073ac241d36dbef4920c3f176f: ordinary suffix appends cross an existing reset. The canonical navigation owners normalize those parents onto the old active leaf, retaining the old suffix and appending its replacement. A five-entry active branch became nine after one successful rewrite; the no-reset control passed. This is [Bug]: Reset normalization turns a successful transcript rewrite into active-suffix duplication #139201, not another interrupted write.

SessionManager.prepareTranscriptRewrite now publishes copied entries using the existing appendMode: "side" contract followed by one explicit leaf selection, all in the same transaction. This preserves the intended parent links without weakening reset protection for ordinary appends. Selected bounded/model-context readers must take their leaf from the already-selected projection/path: leaf controls are omitted from those payloads, so rescanning side entries alone previously selected obsolete context.

The follow-up to the review at 7353a58aa69 fixes the rest of selected-path reconstruction. In a,b,c, rewriting b and then appending d yielded a,d in selected readers because the omitted leaf control left a stale logical parent. After a reset, this could replace the current task with an old prefix. Both cases failed in the extended existing regression. One session-manager hydration helper now installs the already-resolved ancestry and active append cursor, resolving omitted parents through the bounded reader's existing links. Reset fences and raw stored entries stay intact.

The same test then exposed context loss when forking this history into a new session: copied entries retained inactive-side flags although their navigation controls were omitted. The branch-copy owner now removes those flags from the copied, selected path. The source session's rows remain unchanged.

The generic rewrite helper compares normalized replacement bytes before preparing the rewrite. An identical replacement returns unchanged without cloning or appending another suffix.

Owner boundaries and retained behavior

Surface Evidence and behavior
Entry points Tool-result truncation, thinking-replay repair, server-endpoint compaction, and context-engine maintenance call the shared rewrite helper. Their focused suites pass.
Publication owner session-manager.ts prepares only the loaded view; session-accessor.sqlite-branch-rewrite.ts validates source/version/authority and commits through existing message/event appenders.
Navigation contract transcript-tree.ts and session-entry-navigation.ts already define side entries and explicit leaf controls. No new event type or schema is introduced.
Input custody and lifecycle Existing pending-input relocation, commit ordering, retained admission, replacement/revocation, stale-snapshot and nested-transaction rejection remain in place. Reuses merged #139002.
Readers Full reopen, bounded loading, synchronous and asynchronous model context agree; the latest task after reset remains model-visible. Projection reconciliation, ordinary appends through a bounded manager, and copying into a new session are covered.
Current main The inspected main e09a265b111 still lacks this complete atomic rewrite repair. Existing reset protection is intentional; removing it would revive the historical failure tracked by #132586/#132606.

Removed from the earlier candidate: partial staging, per-entry leaf restoration, separate input-key transfer, and full-archive hydration/comparison during preparation. This update also removes unchanged-message replay. No configuration, dependency, schema, migration, protocol, or release changes.

Coverage of the reported system gaps

Reviewed the current #119720 and #138984 bodies, their description revisions, VACInc's updates, and linked reports. Similar visible hangs have different owners:

Case Decision
Interrupted rewrite changes the current task (#138965) Keep the atomic publication repair here. Failure before the final leaf commit preserves old rows and memory; retry succeeds.
Successful reset-crossing amplification (#139201) Fix here at the same publication owner, including selected-context readers and no-op handling.
Shared synchronous SQLite waits and repeated full-history work (#119720) Still open. This transaction remains synchronous. First reduce demonstrated repeated work (including transcript-mirror per-key anchor queries); separately evaluate shared asynchronous admission/writer ownership per physical database. A rewrite-only worker does not solve other writers' lock waits.
Projection rebuild/reconciliation (#115908) Do not revive the obsolete premise that all rebuild work is synchronous: #129182 and #138888 already moved work/admission off-thread. Sustained-write convergence needs separate proof.
Global-state writer contention and CLI read paths opening writers (#117262, #119583) Separate store/entry-point repairs; a per-agent transcript fix cannot claim them solved.
WebSocket failure after settled work and requester wake cancellation (#138959/#138985, #137643/#138966) Keep their existing smaller PRs separate. Recover final answers without replaying settled tools; preserve normal requester execution ownership. No blanket retry or timeout increase here.
Already-amplified or incorrectly selected production histories This prevents new amplification; it does not identify, deduplicate, delete, or repair old user data. Recovery must preserve the authoritative current task and input custody.
Manual compaction followed by persistent draining (#139178) Separate lifecycle investigation; timing alone does not prove compaction set the drain state.

Planner-statistics fixes #133925/#134062 are already merged; #119739/#119884 are historical context, not reasons to redo that work. Historical path-resolution, skills-snapshot bloat, heartbeat-labeling and permanent-delivery retry reports (#120074, #126663, #126841, #126844) are distinct. Memory reindex/plugin-state work (#137525), configurable SQLite knobs (#138326), and broader stream-resume policy (#126845) are not implemented by this PR. The #126848 settled-turn recovery closure is not proof that every transport-recovery case is fixed. Concurrent full-replacement races (#124393/#124899) remain distinct from this version-fenced append publication.

Verification

Real behavior proof

Real production SessionManager and SQLite, isolated synthetic stores, Node v25.9.0:

node scripts/run-vitest.mjs src/agents/embedded-agent-runner/transcript-rewrite.test.ts --reporter=dot

Result: 30 passed. The earlier amplification update added three cases. This reader follow-up adds zero new cases: it extends the two existing reset/no-reset rows through an ordinary append, all four reader views, and session branching, with source-row preservation.

  • The reset regression failed before the fix: expected five active entries, received nine. Three changing rewrites now preserve branch length/order, historical row bytes, reset boundary count and latest task; reopen and all selected-context readers agree.
  • SQLite insertion failure, including the final leaf, leaves rows and memory unchanged; removing the fault and retrying retains the latest task.
  • Identical replacement creates zero new rows. A later append extends the correct branch.
  • 251 focused tests passed: 123 across rewrite, bounded/model-context/snapshot, session branching/navigation and user idempotency; 128 across the four shared callers and initial transcript lifecycle preparation. Both newly exposed failures were reproduced before their respective fixes.
  • Production and core-test typechecks, changed-file type-aware lint/format, whitespace, schema, database-first storage, conflict-marker, assertion-safety and size guards passed.
  • The full changed-check launcher was blocked by ERR_PNPM_NO_MATURE_MATCHING_VERSION: pnpm 12.3.4 is younger than this host's minimum-release-age policy. Direct checks above ran without changing that policy.

Earlier amplification benchmark at 7353a58aa69: 32 synthetic 2 KiB messages, a reset and current-task message; six successive rewrites of the second active entry. One warmup, three measured samples, same host/dependencies. Each sample reconciles projections and verifies the current task after reopening.

Measurement Previous PR head Candidate
Active entries after six rewrites 2,113 in every sample 34 in every sample
Stored events 2,114 239
Total synchronous rewrite time (ms) 1,240 / 1,408 / 1,317 126 / 114 / 114
Longest individual synchronous rewrite (ms) 619 / 862 / 661 25 / 22 / 22

This demonstrates removal of repeated active-history amplification, not a bound on Gateway latency under contention. Append-only historical rows still accumulate linearly with real changed suffixes.

Reproduce the benchmark

In each isolated checkout, temporarily save this as src/agents/embedded-agent-runner/transcript-rewrite.performance.test.ts, then run node scripts/run-vitest.mjs src/agents/embedded-agent-runner/transcript-rewrite.performance.test.ts --reporter=dot. Remove the temporary file afterward. Baseline: 5eff5797bd53d3073ac241d36dbef4920c3f176f; candidate: 7353a58aa69cf7cb1a642cf8cd4461067d9a2e76.

import path from "node:path";
import { afterEach, expect, it } from "vitest";
import { useAutoCleanupTempDirTracker } from "../../../test/helpers/temp-dir.js";
import { replaceSessionEntry, loadTranscriptEvents } from "../../config/sessions/session-accessor.js";
import { waitForSessionTranscriptProjection } from "../../config/sessions/session-transcript-reconcile.js";
import { SessionManager } from "../sessions/session-manager.js";
import { rewriteTranscriptEntriesInSessionManager } from "./transcript-rewrite.js";
const dirs = useAutoCleanupTempDirTracker(afterEach);
it("measures repeated reset-crossing rewrite work", async () => {
 const samples = [];
 for (let sample = 0; sample < 4; sample++) {
  const dir = dirs.make("openclaw-rewrite-perf-");
  const target = { agentId: "main", sessionId: "performance", sessionKey: "agent:main:performance", storePath: path.join(dir, "sessions.json") };
  await replaceSessionEntry(target, {sessionId: target.sessionId, updatedAt: 1});
  const manager = SessionManager.open(target, dir);
  for(let i=0; i<32; i++) manager.appendMessage({role:"user",content:`${i}:` + "x".repeat(2048),timestamp:i+1});
  manager.appendResetBoundary("new");
  manager.appendMessage({role:"user",content:"current task",timestamp:33});
  let totalMs = 0, maxHoldMs = 0;
  for(let iteration=0; iteration<6; iteration++) {
   const entry = manager.getBranch()[1];
   if(entry?.type !== "message") throw new Error("missing benchmark target");
   const started = performance.now();
   rewriteTranscriptEntriesInSessionManager({sessionManager:manager,replacements:[{entryId:entry.id,message:{...entry.message,content:`replacement-${iteration}`}}]});
   const elapsed = performance.now()-started;
   totalMs += elapsed; maxHoldMs=Math.max(maxHoldMs,elapsed);
  }
  const events = await loadTranscriptEvents(target);
  samples.push({totalMs:Math.round(totalMs), maxSynchronousRewriteMs:Math.round(maxHoldMs), activeEvents:manager.getBranch().length, storedEvents:events.length});
  await waitForSessionTranscriptProjection(target);
  expect(SessionManager.open(target).buildSessionContext().messages.at(-1)).toMatchObject({content:"current task"});
 }
 console.log("REWRITE_BENCHMARK", JSON.stringify({node:process.version,warmupSamples:1,samples:samples.slice(1)}));
}, 120000);

Final reader proof and compatibility

Reader-fix head: a9b90278f1dd1e3e1687f17409d9fb633fabe93d.

Same-environment before/after reader benchmark (Node v25.9.0, one warmup plus three measured samples): six rewrites of the same 32-message/reset/current-task fixture, then an ordinary next message, projection reconciliation, and full/bounded/sync/async context reads.

Measurement Previous head 7353a58aa69 Reader fix
All four readers agree after next message false / false / false true / true / true
Active entries / stored events 35 / 240 35 / 240
Four context reads including async (ms) 15 / 13 / 14 15 / 16 / 19
Six synchronous rewrites (ms) 131 / 110 / 109 121 / 114 / 135
Longest synchronous rewrite (ms) 28 / 21 / 22 21 / 19 / 25
Harness wall time / max RSS 9.47 s / 2,608,696 KiB 9.52 s / 2,650,684 KiB

These are observed samples, not a zero-cost or Gateway-latency guarantee. The reader repair adds no storage queries or historical payload acquisition.

Populated-store compatibility was rerun with the final side-entry format and an ordinary next message, with and without resets:

  1. Seed two stores using the earlier PR head 5eff5797bd53d3073ac241d36dbef4920c3f176f.
  2. Open with the candidate, rewrite, append the next message and reconcile. Full, bounded, synchronous and asynchronous model-context readers agree.
  3. Open the same stores with unpatched 5eff5797bd53d3073ac241d36dbef4920c3f176f. The full reader is correct, but selected readers omit rewritten messages or select the old prefix. Reads leave stored rows unchanged.
  4. Apply only the three-file reader/branch backport below to that earlier head. All readers agree; append a further turn through its bounded manager. All readers include that turn, and every earlier stored history record remains equivalent.
  5. Reopen with the candidate. All four readers agree on the complete conversation, including the turn appended by the older code.
no reset: candidate / backported older / candidate = prefix, replacement, suffix, next turn, rollback turn
reset:    candidate / backported older / candidate = current task, next turn, rollback turn
unpatched older selected readers: mismatch in both scenarios
original history rows preserved: true

Rollback requirement: retain/backport the selected-reader fixes when rolling back the writer. A bare older binary is not safe for this history representation; the unchanged SQLite schema does not remove its reader bug. The tested backport provides a concrete path without migrating or rewriting user data. No older stable-release executable was tested; the inspected v2026.9.1 readers lack these fixes too. Support for any additional rollback release needs that version's backport and validation. No data deletion, schema bump, or automatic repair migration is introduced.

Tested reader-only backport onto 5eff579

The rewrite publisher on the older head stays unchanged. Apply with git apply in an isolated checkout at that head; this is a source backport, not a live-store edit.

--- a/src/agents/sessions/session-manager-core.ts
+++ b/src/agents/sessions/session-manager-core.ts
@@ -144,7 +144,7 @@
       for (const [id, parentId] of bounded.opaqueParents) {
         this.opaqueParentsById.set(id, parentId);
       }
-      this.appendParentId = bounded.activeLeafEntryId;
+      this.adoptSelectedTranscriptPath(bounded.activeLeafEntryId, bounded.parents);
       for (const [boundaryId, range] of bounded.firstKeptRanges) {
         // An empty retained slice starts at the boundary itself, never at an
         // earlier ancestor. Opaque entries do not become model-context cut points.
@@ -159,6 +159,21 @@
         this.boundedFirstKeptById.set(boundaryId, firstKeptEntryId);
       }
     }
+  }
+
+  protected adoptSelectedTranscriptPath(
+    appendParentId: string | null,
+    parents: Iterable<readonly [string, string | null]>,
+  ): void {
+    // Selected payloads omit navigation controls. Use their resolved ancestry,
+    // not the side-append parent guesses made while indexing those payloads.
+    this.logicalParentsById.clear();
+    for (const [id, parentId] of parents) {
+      this.logicalParentsById.set(id, this.resolveCanonicalParentId(parentId));
+    }
+    this.appendParentId = appendParentId;
+    this.leafId = this.resolveOpaqueLeafTargetId(appendParentId);
+    this.appendMode = undefined;
   }
 
   /** The loaded view only: bounded managers must never hydrate inactive history for a rewrite. */
--- a/src/agents/sessions/session-manager.ts
+++ b/src/agents/sessions/session-manager.ts
@@ -266,7 +266,12 @@
         "Persisted legacy session transcripts require doctor/import migration before runtime use",
       );
     }
-    return new SessionManager(cwd ?? header?.cwd ?? process.cwd(), undefined, entries);
+    const manager = new SessionManager(cwd ?? header?.cwd ?? process.cwd(), undefined, entries);
+    manager.adoptSelectedTranscriptPath(
+      manager.appendParentId,
+      [...manager.byId].map(([id, entry]) => [id, entry.parentId]),
+    );
+    return manager;
   }
 
   /** Synchronously consumes full-fidelity context; its iterator closes with the read snapshot. */
--- a/src/agents/sessions/session-manager-branching.ts
+++ b/src/agents/sessions/session-manager-branching.ts
@@ -73,10 +73,10 @@
         if (node.entry.type === "label") {
           continue;
         }
-        const branchEntry: SessionEntry =
-          node.entry.parentId === tailId
-            ? node.entry
-            : ({ ...node.entry, parentId: tailId } as SessionEntry);
+        // This is the selected path in a new session, not an inactive side branch.
+        // Its navigation controls are omitted, so copied entries must advance the leaf.
+        const branchEntry: SessionEntry = { ...node.entry, parentId: tailId };
+        delete branchEntry.appendMode;
         entries.push(branchEntry);
         tailId = branchEntry.id;
         continue;

The P1 reader finding from the ClawSweeper review at 7353a58aa69 is addressed by the failing/passing sequence above, including its requested reset/no-reset reader matrix and refreshed populated-store compatibility proof. Personal source/readiness review completed; no independent agent was spawned under the current no-delegation instruction. The exact-head CI gate passed, and the refreshed ClawSweeper review reports no actionable findings. Its historical excerpt-coverage concern is addressed by the complete compatibility table above; the earlier blanket rollback-test hold is superseded by the current scope decision. No merge or auto-merge is requested.

What was not tested

No production Gateway restart, deployment, authenticated provider/Telegram round trip, contended multi-session Gateway soak, or recovery of already-damaged live histories. Real SQLite fault/reopen/retry was exercised here; the previous head's separate-process SIGKILL evidence was not rerun on this update. No fresh local full package build was run. Hosted CI, including its build and test jobs, passed on the reader-fix head linked above.

Size

This reader follow-up: production +24/-10 (net +14) across three files; tests +35/-2 (net +33), with no new test cases; assertion-safety baseline -1 after removing an unnecessary cast. The added owner method installs selected ancestry and clears inactive append mode; branch copying replaces its old conditional copy with a canonical selected-path copy. Full PR versus merge base ac4c669dc5aea980e30bc8ded6a2a3580379cd3c: production +663/-149 (net +514) across 13 files; tests +687/-11 (net +676) across three files. Growth implements the missing atomic owner boundary, retained authority/version receipts, bounded ancestry and correct selected-leaf handling; no alternative storage framework or generic retry layer was added.

Worked on by:

@clawsweeper

clawsweeper Bot commented Sep 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 agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 5, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review September 5, 2026 09:28
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 7, 2026, 1:47 PM ET / 17:47 UTC.

ClawSweeper review

What this changes

Publishes conversation-history rewrites atomically and preserves the selected conversation across resets, bounded reads, later messages, and session branching.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains a distinct, necessary repair: current main and the latest release still publish rewrites incrementally. No actionable introduced defect was found. The recorded scope decision resolves the previous blanket rollback hold; the protected PR remains under owner-controlled landing.

Priority: P1
Reviewed head: c57369780ff3cffbd7fed54cd9bfd6c435175ac2

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent owner-level repair with strong production-boundary evidence, no actionable findings, and an explicitly accepted compatibility limitation.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Recorded production SessionManager/SQLite interruption, reopen, and retry results demonstrate preserved history; active versus closed/replaced admission cases demonstrate rejection before writes, and reader benchmarks demonstrate agreement after later messages. Current-head focused validation supplements those revision-identified runtime observations.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Recorded production SessionManager/SQLite interruption, reopen, and retry results demonstrate preserved history; active versus closed/replaced admission cases demonstrate rejection before writes, and reader benchmarks demonstrate agreement after later messages. Current-head focused validation supplements those revision-identified runtime observations.
Evidence reviewed 9 items Pinned scope and clean checkout: Inspected the complete local merge-base-to-head production diff and changed regression cases. The introduced paths match the host evidence; typing-related base-only changes were excluded. Whitespace validation passed and the checkout remained clean.
Repair still absent from current main: Current main branches the live manager and re-appends the suffix directly, without the prepared atomic publication introduced here.
Latest release retains incremental publication: The supplied latest release, v2026.9.2, also branches the live manager and persists copied suffix entries individually; it does not contain this repair.
Findings None None.
Security None None.

How this fits together

Transcript maintenance replaces stored messages during compaction and recovery. SessionManager and SQLite preserve the conversation history that subsequent agent turns and memory preparation read.

flowchart TD
 A[Compaction or recovery] --> B[Prepare replacement conversation]
 B --> C[Validate live writer and snapshot]
 C --> D[Atomic SQLite commit]
 C --> E[Reject stale or revoked work]
 D --> F[Publish committed conversation]
 F --> G[Agent context and memory readers]
Loading

Before merge

  • Resolve merge risk (P1) - Candidate-written selected history can be omitted by the tested older unpatched bounded/model-context readers. The recorded scope decision accepts that code-only rollback limitation; recovery requires compatible readers, and restoring a matching pre-upgrade backup discards subsequent work.
  • Complete next step (P2) - Obtain explicit owner authorization before landing; the recorded instruction remains review-only with no merge or auto-merge.
Agent review details

Security

None.

PR surface

Source +513, Tests +690, Other -1. Total +1202 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 13 672 159 +513
Tests 3 701 11 +690
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 17 1373 171 +1202

Review metrics

Metric Value Why it matters
Production and regression coverage Production +672/-159 (net +513); tests +701/-11 (net +690) The stated growth supports atomic publication, retained admission, snapshot fencing, and selected-reader consistency.

Merge-risk options

Maintainer options:

  1. Retain the accepted recovery boundary (recommended)
    Keep writer and reader changes together and preserve the documented requirement to recover with a compatible build.

Technical review

Best possible solution:

Keep the atomic writer and selected-reader repairs together, with compatible-build recovery and the accepted rollback limitation documented.

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

Yes: current main still mutates the live branch and persists its suffix incrementally, exposing interruption between entries; supplied before/after evidence also demonstrates reset amplification. This read-only review did not execute tests.

Is this the best way to solve the issue?

Yes: preparing a detached replacement and committing it through the existing SQLite and custody owners repairs the publication boundary, while matching reader changes preserve its interpretation.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The repair addresses interrupted maintenance losing the active task and successful rewrites duplicating active history.
  • merge-risk: 🚨 compatibility: Older unpatched readers can omit candidate-written selected history, making compatible-build recovery necessary.
  • 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): Recorded production SessionManager/SQLite interruption, reopen, and retry results demonstrate preserved history; active versus closed/replaced admission cases demonstrate rejection before writes, and reader benchmarks demonstrate agreement after later messages. Current-head focused validation supplements those revision-identified runtime observations.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded production SessionManager/SQLite interruption, reopen, and retry results demonstrate preserved history; active versus closed/replaced admission cases demonstrate rejection before writes, and reader benchmarks demonstrate agreement after later messages. Current-head focused validation supplements those revision-identified runtime observations.

Evidence

What I checked:

Likely related people:

  • VACInc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason (Json): 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 (16 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-06T18:33:05.131Z sha 6a882af1269b7fcf2b845d1cf8a004c0a4518b7e :: blocked before merge. :: none
  • reviewed 2026-09-06T18:50:22.890Z sha 1eff1c8 :: blocked before merge. :: none
  • reviewed 2026-09-06T19:06:07.421Z sha 1eff1c8 :: blocked before merge. :: none
  • reviewed 2026-09-06T20:14:18.942Z sha 1eff1c8 :: blocked before merge. :: none
  • reviewed 2026-09-06T20:49:44.091Z sha 1eff1c8 :: blocked before merge. :: none
  • reviewed 2026-09-07T16:12:29.517Z sha 2ff8e87 :: blocked before merge. :: none
  • reviewed 2026-09-07T16:33:49.978Z sha 2ff8e87 :: blocked before merge. :: none
  • reviewed 2026-09-07T17:27:53.386Z sha c573697 :: blocked before merge. :: none

@roboclaw-bot
roboclaw-bot force-pushed the openclaw/openclaw-openclaw-vacinc-issue-138965 branch from 3a129fe to 33cda55 Compare September 5, 2026 10:15
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

The five findings on 33cda55f95b3 are addressed at the existing manager/transcript owners: captured admission validation; canonical pending-input relocation on commit; prepared-view adoption before observers; transaction-produced snapshot versions; and bounded suffix preparation/ancestry. Reset-containing replay now commits in one standalone SQLite transaction; no per-entry staging or full archive hydration remains.

Authority-chain evidence, from production admission + SessionManager + SQLite fixtures (attempt-transcript-lifecycle-prepare.test.ts, 19/19 passed):

PASS uses the original manager admission for transcript rewrites (active)
PASS uses the original manager admission for transcript rewrites (closed)
PASS uses the original manager admission for transcript rewrites (replaced)
PASS does not let a retained manager append after its initial admission closes
PASS does not let a retained manager trim after its initial admission closes
PASS does not let a retained manager branch after its initial admission closes
PASS retains its initial admission even before the first append

Closed/replaced cases assert rejection before transcript rows or the live branch change; active admission publishes. Before/after regressions also cover receipt-backed retries, second rewrites, commit-observer reentrancy, dirty bounded projections, side ancestry, and stale snapshots. All 301 focused/sibling tests passed.

A separate child running real production SessionManager/SQLite was SIGKILLed during a reset-containing suffix replay: reopening retained all six original rows and the latest conversation, then a successful retry preserved those rows. The bounded proof rewrites 32 loaded events against 2,048 archived events (17,131,376 stored bytes) and retains only 64 loaded entries. These are real local process/storage proofs, not an authenticated-provider or UI recording.

The updated PR body records scope/LOC justification and proof limits. Independent local P0–P2 review is clean. Please review this new revision; do not merge or enable auto-merge.

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

Please review current head d67970df0633605fb5c04ff0f7bac4e88f9ce534. The earlier request was marked superseded during the upstream conflict refresh.

Reconciled #139002 without a parallel custody path: use its transaction-local relocation staging and remove the obsolete rewrite callback collector. The current diff stays in 12 production session/transcript files plus three tests (production net +472, tests net +536).

After reconciliation: 321 focused/sibling tests, core and core-test typechecks, lint/format, fresh independent P0–P2 review, real-process SIGKILL/reopen/retry and bounded-history proofs all passed. The active/closed/replaced admission evidence in my prior comment still passes. Full local checks/build refresh is blocked by the newly inherited pnpm 12.3.4 minimum-release-age policy; no safeguard was weakened. Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/33968647101

Please review only. The operator explicitly requested no merge and no auto-merge.

Follow-up noted outside this repair: a body-only PR edit can cancel the synchronize Labeler run and replace it with a skipped run (33968645229 → 33968662188), leaving a cancelled rollup check. No workflow change is included here.

@clawsweeper

clawsweeper Bot commented Sep 5, 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 proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 5, 2026
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/openclaw-openclaw-vacinc-issue-138965 branch from 1eff1c8 to 2ff8e87 Compare September 7, 2026 16:04
roboclaw-bot and others added 8 commits September 7, 2026 17:14
Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>
OpenClaw-Publication: d85e8c08-bb42-4d76-8731-9b7f9d42c0c0
Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>
OpenClaw-Publication: 160a4dea-5bbf-465d-8b49-974e1db38451
Keep interrupted rewrites from activating partial history. Publish input custody
and the manager view before commit observers, retain original writer authority,
and fence stale cached data with transaction-produced transcript versions.

Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>
Reuse selected-path adoption for the new detached bounded reader used by
memory flushing. Reconstructing selected side entries without their omitted
leaf controls otherwise drops the rewritten suffix or revives a pre-reset
prefix. Preserve the existing owned-payload optimization and detached writes.

Extend the existing reset/no-reset rewrite cases through detached reads and
appends, later persisted turns, and session branching. Both cases fail before
the owner repair; 261 focused tests and a scoped P1 autoreview pass afterward.

Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/openclaw-openclaw-vacinc-issue-138965 branch from 2ff8e87 to c573697 Compare September 7, 2026 17:20
@VACInc
VACInc merged commit b0ae5b6 into main Sep 7, 2026
186 checks passed
@VACInc
VACInc deleted the openclaw/openclaw-openclaw-vacinc-issue-138965 branch September 7, 2026 19:44
@VACInc

VACInc commented Sep 8, 2026

Copy link
Copy Markdown
Member

Follow-up attribution and repair: #141718 is now merged (merge commit). It fixes two session-handoff bugs: preflight accounting after lane release, and yield cleanup handing off before its deferred projection rebuild settles.

Neither was introduced by #138984. All four new regression cases also fail with the same errors on ca10e17c129eda1548de070010bc82d731d3dcc4, the immediate parent of this PR's merge commit, using an isolated checkout with unchanged production source. The tests pass with #141718 applied. This is additional handoff coverage alongside the atomic rewrite and selected-history work here.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
…penclaw#138984)

* fix(sessions): publish transcript rewrites atomically

Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>

* fix: interrupted transcript rewrites preserve active history

Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>
OpenClaw-Publication: d85e8c08-bb42-4d76-8731-9b7f9d42c0c0

* fix(sessions): fence transcript rewrite snapshots

Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>

* Publish openclaw/openclaw-openclaw-vacinc-issue-138965

Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>
OpenClaw-Publication: 160a4dea-5bbf-465d-8b49-974e1db38451

* fix(sessions): bind atomic rewrites to committed owner snapshots

Keep interrupted rewrites from activating partial history. Publish input custody
and the manager view before commit observers, retain original writer authority,
and fence stale cached data with transaction-produced transcript versions.

Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>

* fix(sessions): prevent reset-crossing rewrite amplification

Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>

* fix(sessions): preserve selected ancestry through later turns

Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>

* fix(sessions): preserve rewritten context in detached snapshots

Reuse selected-path adoption for the new detached bounded reader used by
memory flushing. Reconstructing selected side entries without their omitted
leaf controls otherwise drops the rewritten suffix or revives a pre-reset
prefix. Preserve the existing owned-payload optimization and detached writes.

Extend the existing reset/no-reset rewrite cases through detached reads and
appends, later persisted turns, and session branching. Both cases fail before
the owner repair; 261 focused tests and a scoped P1 autoreview pass afterward.

Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>

---------

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: VACInc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

2 participants