Skip to content

refactor: add session reset delete lifecycle seam#93659

Merged
jalehman merged 2 commits into
mainfrom
clawdbot-d02.1.9.1.31/31b-session-reset-delete-lifecycle-seam
Jun 17, 2026
Merged

refactor: add session reset delete lifecycle seam#93659
jalehman merged 2 commits into
mainfrom
clawdbot-d02.1.9.1.31/31b-session-reset-delete-lifecycle-seam

Conversation

@jalehman

@jalehman jalehman commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a narrow storage-neutral session accessor boundary for gateway session reset/delete lifecycle mutations so entry changes and transcript artifact transitions are represented as one backend-owned operation.

Why

The SQLite migration needs reset/delete to be expressed as logical storage operations instead of gateway code mutating the session entry and then separately archiving or creating transcript artifacts. This PR keeps the current file-backed behavior while giving the future SQLite adapter a single operation to implement transactionally.

Changes

  • Expose reset/delete lifecycle operations from session-accessor.ts
  • Keep file-backed lifecycle implementation in store.ts
  • Route public session barrel/runtime exports through accessor
  • Preserve gateway hook/runtime cleanup outside storage
  • Add focused reset/delete lifecycle tests

Testing

  • node scripts/run-vitest.mjs src/config/sessions/store.session-lifecycle-mutation.test.ts src/gateway/server.sessions.reset-hooks.test.ts src/gateway/server.sessions.reset-cleanup.test.ts src/gateway/server.sessions.delete-lifecycle.test.ts test/scripts/check-session-accessor-boundary.test.ts
  • node scripts/check-session-accessor-boundary.mjs
  • git diff --check upstream/main...HEAD
  • node scripts/run-tsgo.mjs --noEmit --pretty false
  • node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/config/sessions.ts src/config/sessions/session-accessor.ts src/config/sessions/store.runtime.ts src/config/sessions/store.session-lifecycle-mutation.test.ts src/config/sessions/store.ts src/gateway/server-methods/sessions.ts src/gateway/session-reset-service.ts
  • pnpm exec oxfmt --check --threads=1 src/config/sessions.ts src/config/sessions/session-accessor.ts src/config/sessions/store.runtime.ts src/config/sessions/store.session-lifecycle-mutation.test.ts src/config/sessions/store.ts src/gateway/server-methods/sessions.ts src/gateway/session-reset-service.ts scripts/check-session-accessor-boundary.mjs test/scripts/check-session-accessor-boundary.test.ts
  • /Users/phaedrus/Projects/prompts/skills/autoreview/scripts/autoreview --mode branch --base upstream/main --no-web-search --thinking codex=low
  • pnpm build

Real behavior proof

Behavior addressed: Gateway sessions.reset and sessions.delete now route persisted entry mutation plus transcript artifact transition through the storage-neutral session lifecycle accessor seam while preserving file-backed behavior.

Real environment tested: local live gateway from /Users/phaedrus/Projects/clawdbot at 57b810c7c60cecfdabd3773575e54f573c2a98d7 (pnpm openclaw --version reported OpenClaw 2026.6.8 (57b810c)) on port 18789.

Exact steps or command run after this patch:

pnpm build
pnpm openclaw gateway restart
pnpm openclaw --version
curl -fsS http://127.0.0.1:18789/readyz
pnpm openclaw gateway call health --json --timeout 30000
pnpm openclaw gateway call sessions.create --params '{"key":"agent:main:dashboard:path3-proof-reset","label":"Path 3 reset proof final"}' --json --timeout 30000
pnpm openclaw gateway call sessions.create --params '{"key":"agent:main:dashboard:path3-proof-delete","label":"Path 3 delete proof final"}' --json --timeout 30000
pnpm openclaw gateway call sessions.reset --params '{"key":"agent:main:dashboard:path3-proof-reset","reason":"reset"}' --json --timeout 30000
pnpm openclaw gateway call sessions.delete --params '{"key":"agent:main:dashboard:path3-proof-delete","deleteTranscript":true}' --json --timeout 30000
node <persisted-state inspection script>
pnpm openclaw gateway call sessions.delete --params '{"key":"agent:main:dashboard:path3-proof-reset","deleteTranscript":true}' --json --timeout 30000
curl -fsS http://127.0.0.1:18789/readyz
rm <exact proof transcript archives and temporary sessions.json backup>
node <proof-key cleanup inspection script>

Evidence after fix: sessions.reset changed agent:main:dashboard:path3-proof-reset from session id e7aa69e2-89cd-4c9a-b26c-6cf574903406 to d53d7988-268e-4477-9674-0c9d74017d89; sessions.json pointed that key at /Users/phaedrus/.openclaw/agents/main/sessions/d53d7988-268e-4477-9674-0c9d74017d89.jsonl; the old transcript was archived as e7aa69e2-89cd-4c9a-b26c-6cf574903406.jsonl.reset.2026-06-17T16-26-31.278Z; the new transcript header contained id d53d7988-268e-4477-9674-0c9d74017d89. sessions.delete removed agent:main:dashboard:path3-proof-delete and archived 96c88b65-00a2-4b9e-9390-1bda35f90eee.jsonl.deleted.2026-06-17T16-26-31.379Z. Cleanup then deleted the reset proof session through sessions.delete, removed only the proof transcript archives, and verified both proof keys were absent from sessions.json. Final /readyz returned {"ready":true,"failing":[]}.

Observed result after fix: The live gateway successfully performed reset and delete through the new lifecycle seam; persisted session metadata, reset transcript header creation, transcript archive naming, delete removal, and cleanup all matched the existing file-backed behavior.

What was not tested: future SQLite adapter implementation, doctor/import migration, runtime storage flip, SDK compatibility surfaces, runtime JSON fallback or dual-read behavior, and off-machine Crabbox/Testbox proof.

Current Review State

Ready for review. Latest head 57b810c7c6 is rebased onto current upstream/main; SQLite implementation remains a separate 3.2 adapter/foundation concern.

Related #88838.

@clawsweeper

clawsweeper Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper review: did not complete due to Codex infrastructure failure. Reviewed June 16, 2026, 11:01 AM ET / 15:01 UTC.

Summary
Review failed before ClawSweeper could summarize the requested change.

PR surface: Source +206, Tests +116. Total +322 across 5 files.

Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: src/config/sessions/store.session-lifecycle-mutation.test.ts, serialized state: src/config/sessions/store.ts, serialized state: src/gateway/server-methods/sessions.ts, serialized state: src/gateway/session-reset-service.ts, unknown-data-model-change: src/config/sessions/store.session-lifecycle-mutation.test.ts, unknown-data-model-change: src/config/sessions/store.ts, and 2 more. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Not assessed.
Failure reason: invalid structured output.

This is a ClawSweeper/Codex infrastructure failure, not a PR readiness or patch-quality verdict.
Keep any merge decision on the normal maintainer review path until ClawSweeper can complete a fresh review.

Risk before merge

  • [P1] No close action taken because the review did not complete.

Maintainer options:

  1. Decide the mitigation before merge
    Retry the Codex review after fixing the execution failure.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • Review did not complete, so no work-lane recommendation was made.
Review details

Best possible solution:

Retry the Codex review after fixing the execution failure.

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

Unclear. The review failed before ClawSweeper could establish a reproduction path.

Is this the best way to solve the issue?

Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction.

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model internal, reasoning high; reviewed against 75cdf22152de.

Evidence reviewed

PR surface:

Source +206, Tests +116. Total +322 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 4 420 214 +206
Tests 1 116 0 +116
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 536 214 +322

What I checked:

  • failure reason: invalid structured output.
  • codex failure detail: Codex review failed for this PR with exit 0 and wrote invalid JSON or schema-invalid output to /home/runner/work/clawsweeper/clawsweeper/artifacts/event/codex/93659.json: decision.rootCauseCluster.currentItemRelationship fixed_by_candidate requires a canonical PR.
  • codex stderr: No stderr captured.
  • codex stdout: nspect the merge result for reset/delete ordering, and rerun the focused reset/delete lifecycle tests plus tsgo before merge.","category":"fix_before_merge","recommended":true,"automergeInstruction":""},{"title":"Accept the storage-lock scope","body":"Maintainers can accept the longer lifecycle writer boundary if the rebased proof shows no reset/delete stalls or transcript archive regressions.","category":"accept_risk","recommended":false,"automergeInstruction":""},{"title":"Pause behind the canonical migration issue","body":"If the lock boundary or API shape is still unsettled, leave this draft paused under the open migration tracker instead of merging a speculative seam.","category":"pause_or_close","recommended":false,"automergeInstruction":""}],"reviewMetrics":[{"label":"Storage lifecycle operations","value":"2 added: reset and delete","reason":"These operations b.

Likely related people:

  • unknown: Codex failed before it could trace repository history. (role: review did not complete; confidence: low)
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.

@vincentkoc

Copy link
Copy Markdown
Member

Holding this one open rather than forcing it through the batch. It is still a draft, currently conflicts with main, and changes the session-storage lifecycle boundary broadly enough that it needs the owning maintainer's continuation and architecture proof before landing.

@jalehman
jalehman force-pushed the clawdbot-d02.1.9.1.31/31b-session-reset-delete-lifecycle-seam branch from 0f99605 to 0911eb4 Compare June 17, 2026 16:11
@jalehman
jalehman marked this pull request as ready for review June 17, 2026 16:17
@jalehman
jalehman force-pushed the clawdbot-d02.1.9.1.31/31b-session-reset-delete-lifecycle-seam branch from 0911eb4 to 57b810c Compare June 17, 2026 16:23
@jalehman
jalehman merged commit c41bc58 into main Jun 17, 2026
173 checks passed
@jalehman
jalehman deleted the clawdbot-d02.1.9.1.31/31b-session-reset-delete-lifecycle-seam branch June 17, 2026 17:43
crh-code pushed a commit to crh-code/openclaw that referenced this pull request Jun 18, 2026
* refactor: add session reset delete lifecycle seam

* refactor: expose session lifecycle seam through accessor
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 18, 2026
* refactor: add session reset delete lifecycle seam

* refactor: expose session lifecycle seam through accessor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants