Skip to content

refactor: add session entry lifecycle seam#89519

Closed
jalehman wants to merge 24 commits into
mainfrom
clawdbot-b9d/31b-entry-lifecycle-mutation-seam
Closed

refactor: add session entry lifecycle seam#89519
jalehman wants to merge 24 commits into
mainfrom
clawdbot-b9d/31b-entry-lifecycle-mutation-seam

Conversation

@jalehman

@jalehman jalehman commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

What

Adds storage-neutral session entry lifecycle operations over the current file-backed store and routes representative lifecycle mutation callers through those operations instead of mutable whole-store callbacks.

Why

Path 3 needs delete, replace, scoped patch/delete, deleted-artifact archiving, and TUI/Gateway patch projection to be explicit domain operations before the SQLite storage flip. Arbitrary updateSessionStore(store => ...) callbacks do not map cleanly to SQLite row operations and would keep the old JSON-store shape as the hidden runtime contract.

Refs #88838.

Changes

  • Add lifecycle seam
  • Route cleanup callers
  • Route command writes
  • Route plugin cleanup
  • Add patch projection
  • Cover lifecycle regressions
File Change
src/config/sessions/session-entry-lifecycle.ts Adds lifecycle operation helpers
src/config/sessions/session-entry-lifecycle.test.ts Covers lifecycle semantics
src/cron/session-reaper.ts Uses lifecycle deletes/archive handling
src/commands/tasks.ts Uses lifecycle pruning
src/plugins/host-hook-cleanup.ts Uses scoped lifecycle cleanup
src/plugins/host-hook-state.ts Uses lifecycle patching
src/agents/command/attempt-execution.shared.ts Persists cleared fields through seam
src/auto-reply/reply/commands-session-store.ts Routes command store writes
src/gateway/sessions-patch.ts Adds storage-neutral patch projection
src/tui/embedded-backend.ts Uses patch projection seam

Testing

  • node scripts/run-vitest.mjs src/config/sessions/session-entry-lifecycle.test.ts src/cron/session-reaper.test.ts src/commands/tasks.test.ts src/plugins/contracts/host-hooks.contract.test.ts src/agents/command/attempt-execution.shared.test.ts
  • node scripts/run-vitest.mjs src/gateway/sessions-patch.test.ts src/tui/embedded-backend.test.ts
  • node scripts/run-oxlint.mjs <touched files>
  • pnpm tsgo:core
  • git diff --check
  • Autoreview completed with no accepted/actionable findings after review-driven fixes

This is file-backed and behavior-neutral. It does not add SQLite schema/store modules, production storage flip, runtime dual-read/fallback, doctor migration code, or a generic mutable whole-store runtime seam. Public SDK whole-store compatibility remains tracked separately in clawdbot-d02.1.9.1.18.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime commands Command implementations agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Jun 2, 2026
@clawsweeper

clawsweeper Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 14, 2026, 12:48 AM ET / 04:48 UTC.

Summary
The PR adds a file-backed session entry lifecycle mutation seam, routes gateway/TUI/agent/command/plugin/cron session mutations through it, and adds a session accessor boundary CI ratchet.

PR surface: Source +1071, Tests +928, Config +6, Generated 0, Other +146. Total +2151 across 30 files.

Reproducibility: not applicable. This is an internal refactor/migration slice rather than a bug report with a current-main reproduction path; the relevant evidence is source inspection, focused tests, and real behavior proof before merge.

Review metrics: 2 noteworthy metrics.

  • Lifecycle seam exports: 3 mutation helpers added. The new single-entry patch, bulk patch, and bulk delete helpers become part of the permanent storage seam future backends must implement.
  • Automation surface: 1 workflow row, 1 package script, 1 guard script added. The PR adds a new CI ratchet that maintainers should validate alongside the runtime session-state behavior.

Stored data model
Persistent data-model change detected: serialized state: src/agents/command/attempt-execution.shared.ts, serialized state: src/config/sessions.ts, serialized state: src/config/sessions/combined-store-gateway.ts, serialized state: src/config/sessions/session-accessor.test.ts, serialized state: src/config/sessions/session-accessor.ts, serialized state: src/config/sessions/session-entry-lifecycle.test.ts, and 23 more. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted real behavior proof that exercises lifecycle patch/delete behavior through an actual OpenClaw session workflow.
  • Mark the bulk lifecycle helpers as maintenance-only in their exported comments.
  • Refresh the conflicting stacked branch before requesting final review.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body lists tests, lint, typecheck, and autoreview, but no redacted real OpenClaw workflow proof for lifecycle patch/delete behavior; terminal output, logs, screenshots, recordings, or linked artifacts should redact private details before posting. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Merging this branch changes durable session mutation paths across gateway, TUI, agent command persistence, slash-command writes, cron pruning, task cleanup, and plugin cleanup; a wrong projection can overwrite, drop, or mis-associate persisted session/plugin state.
  • [P1] The PR is a stacked draft and GitHub currently reports it as conflicting, so final merge-result review and CI/proof are not meaningful until the stack is refreshed.
  • [P1] The PR body lists focused tests, lint, typecheck, and autoreview, but no real post-patch OpenClaw session workflow proof exercising lifecycle patch/delete behavior.
  • [P1] The author’s before-land note says patchSessionEntries/deleteSessionEntries are full-scan maintenance operations, but the exported comments still present them as general lifecycle APIs.

Maintainer options:

  1. Refresh, document, and prove before merge (recommended)
    Rebase the stack, mark the bulk lifecycle helpers as maintenance-only, and add redacted real workflow proof that lifecycle patch/delete behavior preserves session state.
  2. Accept as a maintainer-owned migration slice
    Maintainers can intentionally accept the session-storage architecture risk only with explicit release-gate ownership and broad post-refresh validation.
  3. Pause if the base stack changes
    If the canonical tracker or base accessor PR changes direction, pause or close this branch instead of landing a permanent seam that no longer matches the migration plan.

Next step before merge

  • [P1] The protected maintainer-labeled, stacked session-state architecture PR needs human stack/proof review rather than an automated repair lane.

Security
Cleared: The CI/script changes add a repo-local TypeScript boundary guard without new action permissions, external downloads, dependency sources, lifecycle hooks, or secret exposure.

Review findings

  • [P3] Mark bulk lifecycle helpers as maintenance-only — src/config/sessions/session-entry-lifecycle.ts:105
Review details

Best possible solution:

Keep this in the session/transcript SQLite migration stack, settle the base accessor PR, document the bulk helpers as maintenance-only, refresh conflicts, and add real gateway/TUI or CLI session proof before merge.

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

Not applicable. This is an internal refactor/migration slice rather than a bug report with a current-main reproduction path; the relevant evidence is source inspection, focused tests, and real behavior proof before merge.

Is this the best way to solve the issue?

Unclear as merge-ready. The branch-by-abstraction direction matches #88838, but this draft still needs the maintenance-only helper doc fix, conflict refresh, and real behavior proof before it can be judged the best landable slice.

Full review comments:

  • [P3] Mark bulk lifecycle helpers as maintenance-only — src/config/sessions/session-entry-lifecycle.ts:105
    The before-land comment says patchSessionEntries and deleteSessionEntries are full-scan predicate operations meant for maintenance callers, but the exported comments still present them as general lifecycle APIs. Because this seam is intended to survive the SQLite flip, please document the maintenance-only constraint so hot paths do not adopt broad scans that future storage must preserve.
    Confidence: 0.86

Overall correctness: patch is correct
Overall confidence: 0.78

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 231b5a14d5d7.

Label changes

Label justifications:

  • P2: This is a normal-priority internal migration slice with limited immediate user-facing effect before merge but meaningful session-state review cost.
  • merge-risk: 🚨 compatibility: The PR changes internal session lifecycle/accessor contracts that future SQLite storage and existing gateway/TUI/plugin callers must remain compatible with.
  • merge-risk: 🚨 session-state: The diff routes persisted session entry patch/delete paths through new helpers, so mistakes can lose or mis-associate durable session/plugin state.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body lists tests, lint, typecheck, and autoreview, but no redacted real OpenClaw workflow proof for lifecycle patch/delete behavior; terminal output, logs, screenshots, recordings, or linked artifacts should redact private details before posting. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +1071, Tests +928, Config +6, Generated 0, Other +146. Total +2151 across 30 files.

View PR surface stats
Area Files Added Removed Net
Source 18 1418 347 +1071
Tests 8 970 42 +928
Docs 0 0 0 0
Config 2 6 0 +6
Generated 1 2 2 0
Other 1 146 0 +146
Total 30 2542 391 +2151

What I checked:

  • Live PR state: Live GitHub metadata reports this PR as draft, mergeable=CONFLICTING, mergeStateStatus=DIRTY, with protected maintainer and session-state/compatibility merge-risk labels. (703abed79c6b)
  • Current main lacks lifecycle seam: A current-main search found no patchSessionLifecycleEntry, patchSessionEntries, deleteSessionEntries, session-entry-lifecycle, patchGatewaySessionEntry, or applySessionsPatchProjection symbols, so the central change is not already implemented on main. (231b5a14d5d7)
  • Lifecycle seam surface: The PR adds single-entry patch, bulk patch, and bulk delete lifecycle helpers; the bulk helper comments still present the full-scan operations as general lifecycle APIs. (src/config/sessions/session-entry-lifecycle.ts:105, 703abed79c6b)
  • Delete metadata follow-up mostly addressed: The delete result's removedSessionFiles map is populated by sessionId with the sessionFile as value, and the focused test expects a sessionId-keyed map. (src/config/sessions/session-entry-lifecycle.test.ts:185, 703abed79c6b)
  • Gateway/TUI patch projection: patchGatewaySessionEntry now projects sessions.patch changes inside updateSessionStore and writes the projected entry back to the primary key, making session metadata write semantics central to the PR. (src/gateway/sessions-patch.ts:681, 703abed79c6b)
  • Related canonical work: The canonical tracker remains open and lists this PR as the 3.1b entry lifecycle mutation slice; the base accessor PR is also open and mergeable, not merged.

Likely related people:

  • vincentkoc: Recent current-main history includes broad session/gateway/task touches across the same files, and blame on the current session store/gateway patch surfaces points to Vincent Koc in this shallow checkout. (role: recent area contributor; confidence: high; commits: 2d4a9eb40538, 8c802aa68351, f630e8d44037; files: src/config/sessions/store.ts, src/gateway/sessions-patch.ts, src/commands/tasks.ts)
  • steipete: Peter Steinberger has repeated recent commits in the session store, gateway patch, plugin state, and maintenance surfaces and authored the earlier SQLite session metadata PR that the tracker discusses as the reverted path. (role: primary adjacent area contributor; confidence: high; commits: cb3fbe7e50a2, b3ecabbbb722, 538d36eaaaa6; files: src/config/sessions/store.ts, src/gateway/sessions-patch.ts, src/plugins/host-hook-state.ts)
  • shakkernerd: History around session-store loader/maintenance and cron cleanup includes Shakker's refactors adjacent to this PR's delete/reaper lifecycle path. (role: session maintenance contributor; confidence: medium; commits: 192f880a0ba4, c2e93c76bd43, 73073a91bb15; files: src/config/sessions/store.ts, src/cron/session-reaper.ts)
  • jalehman: Josh Lehman owns the open tracker and stacked accessor/lifecycle PRs, and prior current-main history includes session-store cache fixes beyond this PR alone. (role: migration-stack owner and prior session-store contributor; confidence: medium; commits: 175c77017115, 1212328c8da1, 703abed79c6b; files: src/config/sessions/store.ts, src/config/sessions/session-entry-lifecycle.ts, src/gateway/sessions-patch.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@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. labels Jun 2, 2026
@jalehman
jalehman force-pushed the clawdbot-9c3/session-accessor-seam branch from f18f99c to b39023f Compare June 4, 2026 20:31
@jalehman
jalehman force-pushed the clawdbot-b9d/31b-entry-lifecycle-mutation-seam branch from e5d1bab to ddb5749 Compare June 4, 2026 21:31
@jalehman
jalehman changed the base branch from clawdbot-9c3/session-accessor-seam to clawdbot-9c3-ce2/session-accessor-gateway-entry June 4, 2026 21:31
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Jun 4, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 4, 2026
@jalehman
jalehman force-pushed the clawdbot-9c3-ce2/session-accessor-gateway-entry branch from a13e0eb to 890d5e3 Compare June 4, 2026 22:37
@jalehman
jalehman force-pushed the clawdbot-9c3-ce2/session-accessor-gateway-entry branch from 890d5e3 to b496b4b Compare June 10, 2026 22:16
@jalehman
jalehman force-pushed the clawdbot-b9d/31b-entry-lifecycle-mutation-seam branch from ddb5749 to 703abed Compare June 11, 2026 05:03
@openclaw-barnacle openclaw-barnacle Bot removed the docs Improvements or additions to documentation label Jun 11, 2026
@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed 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 Jun 11, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

Follow-ups before land (from the post-revert currency review):

  • SessionEntriesDeleteResult.removedSessionFiles is a file-path-keyed map — file-backend shape leaking into a permanent seam result. Re-key by sessionId before or alongside the 3.2 foundation so the SQLite implementation isn't forced to synthesize paths.
  • patchSessionEntries/deleteSessionEntries are full-scan predicate operations; all current callers are maintenance (reaper, task pruning, plugin cleanup). Mark them maintenance-only in their doc comments so they don't drift into hot-path use.

@jalehman
jalehman force-pushed the clawdbot-9c3-ce2/session-accessor-gateway-entry branch from 1e31abd to 094f9b5 Compare June 13, 2026 23:20
@clawsweeper clawsweeper Bot added 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. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 14, 2026
@jalehman
jalehman force-pushed the clawdbot-9c3-ce2/session-accessor-gateway-entry branch 3 times, most recently from 9a55d1b to 58aa59e Compare June 14, 2026 13:13
Base automatically changed from clawdbot-9c3-ce2/session-accessor-gateway-entry to main June 14, 2026 13:18
@jalehman
jalehman deleted the branch main June 14, 2026 13:18
@jalehman jalehman closed this Jun 14, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts labels Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation 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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant