Skip to content

refactor(sessions): remove file-era transcript runtime - #113233

Merged
steipete merged 174 commits into
mainfrom
steipete/transcript-file-era-teardown
Jul 28, 2026
Merged

steipete merged 174 commits into
mainfrom
steipete/transcript-file-era-teardown

Conversation

@steipete

@steipete steipete commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

OpenClaw still carried a second, partially reachable JSONL transcript runtime beside the canonical SQLite session store. Six ephemeral helper agents were the final JSONL producers, while file repair, rotation, snapshot caches, successor transcripts, and marker-based identity plumbing kept the obsolete branch alive and made session ownership difficult to reason about.

This is a maintainer-requested refactor. AI-assisted implementation and review were used; the code and proof were manually adjudicated against the SQLite ownership contract.

Why This Change Was Made

runtime transcript state is SQLite-only; files are artifacts

The six one-shot helper agents now use SessionManager.inMemory, JSONL persistence/repair/rotation/snapshot code is deleted, and the embedded runner and public session facade share one SessionManager tree implementation. Runtime, gateway, worker, cron, BTW, TTS, trajectory, and plugin call sites now carry structured { agentId, sessionId, sessionKey, storePath } identity instead of rediscovering it from a transcript filename.

Deletion inventory

Removed surface Deleted LOC
Session file repair implementation and tests 2,233
Duplicate TranscriptFileState implementation 1,039
Compaction successor/manual file-boundary implementation and tests 1,576
File manager/init/cache implementation and tests 1,449
Retired session-lock controller and support modules 2,363
Rotation/file/compaction helpers and session-file key 161
Gateway transcript-key implementation and tests 324
File-era config cache utilities 172
SQLite marker path test 101
Gateway compaction checkpoint helper 22
Deleted-only files total 9,440

GitHub PR stats at head 38a4f131d6a: +11,194/-23,603 across 430 files (net -12,409). The non-test production diff remains strongly LOC-negative by thousands.

Identity conversion

Consumer group New identity path
Embedded attempts and compaction sessionTarget plus canonical session key
Gateway, worker environments, chat, checkpoints structured transcript target
Auto-reply, cron, BTW, TTS, hooks explicit agent/session/key/store identity
Trajectory runtime and export structured target; files remain export artifacts
Plugin runtime and memory host structured runtime target where current contracts permit
Session metadata production SessionEntry.sessionFile removed

Compatibility boundaries retained deliberately:

  • legacy-sqlite-marker.ts remains only for shipped Plugin SDK consumers, doctor/import, QA/test fixtures, and named artifact paths. It is not a runtime storage fallback.
  • Test-only SessionManager.create/openFile adapters remain in test/setup-openclaw-runtime.ts so legacy fixtures keep write-through semantics without reintroducing production file persistence.
  • Deprecated sessionFile result/hook values that cannot be removed in bounded Plugin SDK scope carry the canonical session key, not a filesystem path.
  • Persisted SessionManager.newSession() rejects in-place identity mutation; high-level AgentSession ctx.newSession() replaces the session instead.
  • truncateAfterCompaction no longer mints or rotates a successor JSONL transcript. Typed context-engine successor session IDs remain supported within the active key/store binding.

User Impact

There is no intended visible UI change. Operators get one canonical runtime transcript store, less repair/rotation ambiguity, and lower maintenance risk during compaction, reset, worker, and plugin flows. One-shot helper agents no longer create temporary transcript files.

Legacy transcript files remain importable through doctor, and trajectory export/archive files remain supported product artifacts.

Evidence

  • Attribution experiment: clean main 2bffce62daa passed subagent-completion-direct-fallback twice (runs 30183683527 and 30183731563), proving the original branch hang was introduced by this refactor rather than pre-existing or environmental.

  • Root cause and fix: SQLite cleanup admission waited on promptSettled when the SDK omitted reacquire, relative to the controller extraction in refactor(agents): split embedded session lock lifecycle #113779. The owning lock boundary now distinguishes terminal abort from yield handoff and admits cleanup without waiting for an event that will never fire.

  • Exact QA branch proof: runs 30184279357 and 30184337537 passed after the fix. A fresh final-head-adjacent Testbox rerun 30317351401 also passed after a prior checksum-sync attempt failed before task creation because tracked IDENTITY.md was absent on the remote box.

    scenario: subagent-completion-direct-fallback
    result: passed=1 failed=0 skipped=0 total=1
    
  • Final focused proof after the conflict-only rebase: 289 gateway, agent, session-manager, compaction, truncation, and context-engine tests passed. The CI repair then passed 10 targeted legacy-read tests; it preserves strict append validation by seeding malformed historical rows through SessionManager.fromEntries.

  • Blacksmith Testbox changed gate: run 30315702051, exit 0 in 27m20s; formatting, typecheck, lint, SDK surface, storage, import-cycle, and boundary lanes passed.

  • Blacksmith Testbox build: pnpm build passed in 2m20s with no [INEFFECTIVE_DYNAMIC_IMPORT] warning.

  • Exact-head CI: run 30322406346 for 38a4f131d6a passed with 0 pending and 0 failures.

  • Review-loop hardening: lease ownership is fenced by incarnation; append paths are failure-atomic; successor rebinding is CAS-safe; structured transcript targets are checked at ownership boundaries; and late prompt/yield cleanup is fenced from newer holders.

  • Autoreview: the final committed branch review covered five bounded passes. Findings were either fixed or rejected after caller/callee inspection: doctor/import deliberately owns legacy transcript-version migration; the reset-memory hook runs before the reset boundary; and the explicit reset-archive usage-reader claim has no production caller. The final CI-fix patch received a clean uncommitted review.

  • git diff --check clean.

ClawSweeper rank-up moves

  • SQLite runtime proof: applied with the redacted exact-QA result above. The scenario exercises a parent yield, child completion, SQLite-backed transcript finalization, and direct fallback delivery.
  • Doctor import plus trajectory/debug export demonstration: skipped as a second live demonstration under the convergence mandate. Those named product boundaries were not touched by the final test-only/format commits; their focused doctor/command and trajectory suites were already green, and the implementations remain explicitly retained rather than routed through runtime JSONL fallback.
  • Final exact-head checks: addressed by green run 30322406346. Earlier runs exposed runs.ts formatting drift, stale malformed-transcript setup, file-path runner fixtures, and loaded-runner timing flakes; each was fixed at its owning test/format boundary before the final green head.

Named follow-ups

  • Add heartbeat/fencing for unverifiable reused-PID lease recovery.
  • Add a byte-bounded or paginated SQLite API for trajectory tail reads.
  • If OpenClaw adopts overlapping mixed-version Gateway rollout as a supported deployment mode, define a rollout fence or transition bridge between the retired marker file lock and the SQLite lease protocol; the supported single-Gateway restart path does not run both protocols concurrently.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: telegram Channel integration: telegram app: web-ui App: web-ui gateway Gateway runtime commands Command implementations agents Agent runtime and tooling extensions: codex size: XL maintainer Maintainer-authored PR labels Jul 24, 2026
@steipete steipete self-assigned this Jul 24, 2026
@steipete
steipete marked this pull request as ready for review July 24, 2026 05:41
@steipete
steipete force-pushed the steipete/transcript-file-era-teardown branch from 4b816ac to 126f6a0 Compare July 24, 2026 06:46
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Jul 24, 2026
@steipete
steipete force-pushed the steipete/transcript-file-era-teardown branch from 126f6a0 to f5d10af Compare July 24, 2026 07:42
@steipete
steipete force-pushed the steipete/transcript-file-era-teardown branch 3 times, most recently from 810c6f2 to 10a66c5 Compare July 25, 2026 13:47
@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label Jul 25, 2026
@steipete
steipete force-pushed the steipete/transcript-file-era-teardown branch 2 times, most recently from 2b7971b to 3304c7d Compare July 25, 2026 14:50
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. 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. labels Jul 25, 2026
@clawsweeper

clawsweeper Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 27, 2026, 10:27 PM ET / July 28, 2026, 02:27 UTC.

ClawSweeper review

What this changes

This PR removes active JSONL transcript runtime behavior, moves persisted sessions to SQLite identity targets, and gives temporary helper runs in-memory transcript managers while preserving doctor import and export artifacts.

Merge readiness

⚠️ Needs maintainer review before merge - 3 items remain

Keep this PR open for explicit maintainer review. Its SQLite-only direction matches the repository’s runtime-storage policy and the supplied real-session/Testbox evidence is substantive, but this is a 430-file refactor of persisted session identity, plugin SDK compatibility, compaction, exports, and channel-adjacent paths; the protected maintainer label means it should not be auto-closed or auto-landed.

Priority: P2
Reviewed head: 38a4f131d6aac05091483cd6a15751779ef4a1d0
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The real behavior evidence is strong, but the very broad persisted-session compatibility surface still needs deliberate maintainer approval and an updated current-main review.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body includes redacted after-fix terminal-style QA evidence for SQLite-backed parent/child session finalization and direct fallback delivery, alongside exact-head CI and Testbox results; no private values should be added if proof is refreshed.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body includes redacted after-fix terminal-style QA evidence for SQLite-backed parent/child session finalization and direct fallback delivery, alongside exact-head CI and Testbox results; no private values should be added if proof is refreshed.
Evidence reviewed 5 items Repository storage policy: The checked repository policy requires runtime state to use canonical SQLite storage, with legacy file stores handled by doctor/migration code rather than steady-state runtime. This PR’s stated direction follows that boundary, while retaining legacy marker handling for import and SDK compatibility.
Central runtime conversion: The proposed CLI runner accepts a caller-owned in-memory manager or derives a structured persisted session target, then patches the authoritative session entry before opening the manager; this is the core replacement for path-based runtime opening.
Compatibility surface: The proposed plugin command types add an explicit sessionTarget while retaining the deprecated transcript locator, demonstrating that external plugin-facing session identity remains a compatibility-sensitive boundary rather than a pure internal deletion.
Findings None None.
Security None None.

How this fits together

Agent and channel runs create or resume sessions, whose active transcript state is then used by compaction, plugin hooks, status/diagnostics, memory indexing, and trajectory export. The PR replaces file-path-based runtime identity in that shared pipeline with structured SQLite session targets, while retaining legacy files only as import or export artifacts.

flowchart LR
  A[Agent and channel runs] --> B[Session identity target]
  B --> C[SQLite active transcript store]
  C --> D[Compaction and session lifecycle]
  C --> E[Plugins, memory, and diagnostics]
  C --> F[Trajectory and JSONL artifacts]
  G[Legacy JSONL files] --> H[Doctor import and export only]
Loading

Decision needed

Question Recommendation
After a current-main rebase, should OpenClaw accept the SQLite-only active-transcript contract and its retained Plugin SDK compatibility fields as the permanent session-storage boundary? Approve the SQLite-only boundary: Confirm the retained doctor/import and Plugin SDK compatibility paths are sufficient, then land after a refreshed current-main review.

Why: The patch intentionally changes a shared persisted-state contract and preserves selected legacy values for external consumers; whether those compatibility values and rollout semantics are the desired long-term public boundary requires maintainer intent beyond automated checks.

Before merge

  • Resolve merge risk (P1) - Merging changes persisted session identity across runtime, compaction, plugin, memory, trajectory, and status paths; maintainers should explicitly confirm upgrade behavior for existing SQLite rows and retained Plugin SDK fields after rebasing to current main.
  • Resolve merge risk (P1) - The PR is cleanly mergeable but behind main; review should refresh against the actual three-way merge result before landing because this refactor touches shared session-state ownership surfaces.
Agent review details

Security

None.

Review metrics

None.

Stored data model

Persistent data-model change detected: durable storage schema: src/worker/worker.fault-injection.test.ts, migration/backfill/repair: config/max-lines-baseline.txt, migration/backfill/repair: docs/reference/transcript-hygiene.md, serialized state: docs/concepts/agent-loop.md, serialized state: extensions/anthropic/session-catalog-history.test.ts, serialized state: extensions/anthropic/session-catalog-history.ts, and 26 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Rebase and verify persisted-session upgrades (recommended)
    Refresh the branch against current main and verify existing SQLite sessions, doctor imports, and deprecated Plugin SDK locator consumers before merge.
  2. Accept the documented rollout boundary
    Maintainers may accept the single-Gateway restart assumption and the retained compatibility adapters as the supported upgrade contract.
  3. Pause for rollout design
    Pause this broad refactor if overlapping mixed-version Gateway deployments must be supported before file-era runtime removal.

Technical review

Best possible solution:

Rebase onto current main, then complete a maintainer-owned upgrade and plugin-SDK compatibility review that verifies existing sessions remain readable, doctor remains the sole legacy-file migration path, and retained deprecated locator values cannot be mistaken for active filesystem paths.

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

Not applicable: this is a refactor PR, not a bug report with a standalone failure to reproduce. The supplied after-fix QA scenario is relevant behavioral proof for the changed session lifecycle.

Is this the best way to solve the issue?

Unclear: removing file-era runtime state is aligned with the repository’s SQLite-only ownership policy, but the final public compatibility and upgrade boundary needs a maintainer decision after a current-main refresh.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes redacted after-fix terminal-style QA evidence for SQLite-backed parent/child session finalization and direct fallback delivery, alongside exact-head CI and Testbox results; no private values should be added if proof is refreshed.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes redacted after-fix terminal-style QA evidence for SQLite-backed parent/child session finalization and direct fallback delivery, alongside exact-head CI and Testbox results; no private values should be added if proof is refreshed.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a broad but non-emergency session-runtime refactor with user-visible upgrade sensitivity rather than a confirmed active outage.
  • merge-risk: 🚨 compatibility: The branch changes persisted session metadata and Plugin SDK session identity while retaining deprecated locator values for existing consumers.
  • merge-risk: 🚨 session-state: Active transcript ownership moves from JSONL paths to SQLite targets across compaction, runtime, status, memory, and trajectory readers.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes redacted after-fix terminal-style QA evidence for SQLite-backed parent/child session finalization and direct fallback delivery, alongside exact-head CI and Testbox results; no private values should be added if proof is refreshed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes redacted after-fix terminal-style QA evidence for SQLite-backed parent/child session finalization and direct fallback delivery, alongside exact-head CI and Testbox results; no private values should be added if proof is refreshed.

Evidence

What I checked:

  • Repository storage policy: The checked repository policy requires runtime state to use canonical SQLite storage, with legacy file stores handled by doctor/migration code rather than steady-state runtime. This PR’s stated direction follows that boundary, while retaining legacy marker handling for import and SDK compatibility. (AGENTS.md:121, 6de4b47203a3)
  • Central runtime conversion: The proposed CLI runner accepts a caller-owned in-memory manager or derives a structured persisted session target, then patches the authoritative session entry before opening the manager; this is the core replacement for path-based runtime opening. (src/agents/cli-runner.ts:892, 38a4f131d6aa)
  • Compatibility surface: The proposed plugin command types add an explicit sessionTarget while retaining the deprecated transcript locator, demonstrating that external plugin-facing session identity remains a compatibility-sensitive boundary rather than a pure internal deletion. (src/plugins/plugin-command.types.ts:18, 38a4f131d6aa)
  • Real behavior evidence: The PR body provides a redacted after-fix QA scenario result for parent yield, child completion, SQLite-backed transcript finalization, and direct fallback delivery, and reports an exact-head CI run for commit 38a4f13 with no pending or failed checks. (38a4f131d6aa)
  • Related merged lock refactor: The PR explicitly builds on the session-lock lifecycle extraction merged as refactor(agents): split embedded session lock lifecycle #113779; that earlier merged work is adjacent infrastructure, not a replacement for this transcript-runtime removal. (src/agents/embedded-agent-runner:1, eb4eaea39b75)

Likely related people:

  • steipete: The current branch’s session-runtime conversion is authored by this contributor, and the related merged session-lock lifecycle refactor was also authored by the same person, providing continuity across the directly adjacent ownership boundary. (role: recent area contributor; confidence: medium; commits: 38a4f131d6aa, eb4eaea39b75; files: src/agents/cli-runner.ts, src/agents/sessions/session-manager-entries.ts, src/plugins/plugin-command.types.ts)

Rank-up moves

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

  • Rebase onto current main and refresh the session, Plugin SDK, doctor-import, and export compatibility review against the merge result.
  • Record the maintainer decision on the intended long-term compatibility contract for deprecated transcript locator fields and mixed-version rollout assumptions.

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 (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-27T17:51:20.760Z sha 7a5d06b :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-27T23:22:07.900Z sha 4be65c1 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-28T00:38:11.643Z sha 29d3598d30d65bcab79a9c8c41b7da4f1f317da2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-28T00:50:02.765Z sha 8507ebba32b50b2f47f2d20083787c8a61cc2529 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-28T01:24:30.274Z sha 583b85cd2130f90a813c3d54055450fd64151547 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-28T01:40:04.289Z sha a81f52c :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-28T02:05:41.065Z sha b92b2c5 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-28T02:16:29.955Z sha 38a4f13 :: needs real behavior proof before merge. :: none

@steipete
steipete force-pushed the steipete/transcript-file-era-teardown branch from 636394b to 1f86d72 Compare July 27, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui channel: telegram Channel integration: telegram cli CLI command changes commands Command implementations docs Improvements or additions to documentation extensions: anthropic extensions: codex extensions: memory-core Extension: memory-core extensions: qa-lab gateway Gateway runtime maintainer Maintainer-authored PR 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. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

1 participant