Skip to content

refactor: add task session registry maintenance seam#93734

Merged
jalehman merged 1 commit into
openclaw:mainfrom
jalehman:clawdbot-d02.1.9.1.39/31b-task-session-registry-maintenance-seam
Jun 18, 2026
Merged

refactor: add task session registry maintenance seam#93734
jalehman merged 1 commit into
openclaw:mainfrom
jalehman:clawdbot-d02.1.9.1.39/31b-task-session-registry-maintenance-seam

Conversation

@jalehman

@jalehman jalehman commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a named session-registry maintenance helper for task-owned cron-run session pruning.
  • Keeps openclaw tasks maintenance responsible for task and flow registry maintenance while delegating each session store prune to the new per-store boundary.
  • Preserves dry-run/apply summaries, running cron job preservation, missing-store behavior, retention semantics, and skipMaintenance on apply.
  • Intentionally leaves SQLite runtime flip, migrations, doctor repair, plugin SDK surfaces, and broader session maintenance ownership out of scope.
  • Review focus: whether runSessionRegistryMaintenanceForStore is the right transaction-sized boundary for the SQLite follow-up.

Linked context

Which issue does this close?

Part of #88838

Which issues, PRs, or discussions are related?

Related Pebbles clawdbot-d02.1.9.1.39

Was this requested by a maintainer or owner?

Maintainer-delegated OpenClaw Path 3 task.

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: openclaw tasks maintenance --apply no longer owns direct mutable session-store pruning; the prune runs through a named per-store session-registry maintenance helper.
  • Real environment tested: Local Codex OpenClaw worktree on macOS, rebased onto upstream/main fdb042b9ce09cdd8a2eff786f779e0f3004d955a with head 1153f94ef45d0a51daac074b91488f98cef5c875.
  • Exact steps or command run after this patch: seeded disposable OPENCLAW_STATE_DIR/OPENCLAW_CONFIG_PATH with four session rows and two cron jobs through saveCronStore; ran pnpm --silent openclaw tasks maintenance --apply --json; inspected agents/main/sessions/sessions.json afterward. Also ran focused Vitest, boundary guard, oxfmt, oxlint, both tsgo wrappers, git diff --check, and .agents/skills/autoreview/scripts/autoreview --mode branch --base upstream/main.
  • Evidence after fix: Real command output reported runningCronJobs: 1, pruned: 1, store beforeCount: 4, afterCount: 3, and preservedRunning: 1. Focused Vitest passed 3 shards; boundary guard passed; oxfmt check passed; oxlint passed; both tsgo wrappers exited 0; autoreview reported no accepted/actionable findings.
  • Observed result after fix: The stale completed cron-run row was removed; the stale running cron-run row, recent cron-run row, and ordinary old non-cron session row were preserved.
  • What was not tested: Live Gateway against a real user state directory.
  • Proof limitations or environment constraints: The real command proof used disposable local state under /tmp; SQLite runtime flip, migrations, and doctor repair remain follow-up work under Track core session/transcript SQLite migration via accessor seam #88838.
  • Before evidence (optional but encouraged): src/commands/tasks.ts previously imported loadSessionStore, pruneStaleEntries, and updateSessionStore directly for this maintenance path.

Tests and validation

  • node scripts/run-vitest.mjs src/config/sessions/session-registry-maintenance.test.ts src/commands/tasks.test.ts test/scripts/check-session-accessor-boundary.test.ts
  • node scripts/check-session-accessor-boundary.mjs
  • pnpm exec oxfmt --check src/config/sessions/session-registry-maintenance.ts src/config/sessions/session-registry-maintenance.test.ts src/config/sessions.ts src/commands/tasks.ts scripts/check-session-accessor-boundary.mjs test/scripts/check-session-accessor-boundary.test.ts
  • node scripts/run-oxlint.mjs src/config/sessions/session-registry-maintenance.ts src/config/sessions/session-registry-maintenance.test.ts src/config/sessions.ts src/commands/tasks.ts scripts/check-session-accessor-boundary.mjs test/scripts/check-session-accessor-boundary.test.ts
  • node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo
  • node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core-test.tsbuildinfo
  • git diff --check upstream/main..HEAD
  • Disposable real command proof: pnpm --silent openclaw tasks maintenance --apply --json with isolated OPENCLAW_STATE_DIR and OPENCLAW_CONFIG_PATH.
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base upstream/main

Regression coverage added in src/config/sessions/session-registry-maintenance.test.ts; boundary ratchet updated in scripts/check-session-accessor-boundary.mjs and test/scripts/check-session-accessor-boundary.test.ts.

Risk checklist

Did user-visible behavior change? (Yes/No)

No.

Did config, environment, or migration behavior change? (Yes/No)

No.

Did security, auth, secrets, network, or tool execution behavior change? (Yes/No)

No.

What is the highest-risk area?

Preserving the exact task-maintenance pruning semantics while moving the store write behind a helper.

How is that risk mitigated?

Existing command tests still cover task maintenance JSON behavior, and new helper tests cover dry-run/apply, running cron preservation, missing stores, and skip-maintenance preservation of non-cron rows.

Current review state

What is the next action?

Draft PR ready for maintainer review and CI.

What is still waiting on author, maintainer, CI, or external proof?

CI and maintainer decision after the rebased branch push. Local focused proof, real disposable command proof, and autoreview are complete.

Which bot or reviewer comments were addressed?

ClawSweeper posted an infrastructure/schema failure rather than actionable code feedback. Local autoreview completed cleanly after rebase.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts commands Command implementations labels Jun 16, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Jun 16, 2026
@clawsweeper

clawsweeper Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 18, 2026, 5:29 PM ET / 21:29 UTC.

Summary
The PR extracts task-maintenance cron-run session store pruning into a new session-registry maintenance helper, exports it through the sessions barrel, and updates the session-accessor boundary guard plus focused tests.

PR surface: Source +38, Tests +128, Other +3. Total +169 across 6 files.

Reproducibility: not applicable. as a bug reproduction: this is a behavior-neutral refactor seam. The changed behavior is still exercisable with disposable state through openclaw tasks maintenance --apply --json, and the PR body reports that after-patch run.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: src/config/sessions.ts, serialized state: src/config/sessions/session-registry-maintenance.test.ts, serialized state: src/config/sessions/session-registry-maintenance.ts, unknown-data-model-change: src/config/sessions/session-registry-maintenance.test.ts, unknown-data-model-change: src/config/sessions/session-registry-maintenance.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #88838
Summary: This PR is one implementation slice for the open Path 3 session/transcript SQLite accessor-seam tracker, not a standalone closure candidate.

Members:

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

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

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

Risk before merge

  • [P1] The PR is intended behavior-neutral, but it moves persisted session-row pruning behind a new helper; maintainers should explicitly accept that openclaw tasks maintenance --apply still deletes only stale completed cron-run rows and preserves running/non-cron rows.

Maintainer options:

  1. Accept the bounded session-state seam (recommended)
    Merge after maintainer review and required checks accept that this internal Path 3 slice preserves the existing cron-run pruning semantics through the new helper boundary.
  2. Ask for broader runtime proof
    If maintainers want more assurance, request a live Gateway or real user-state maintenance run before merge.
  3. Pause if Path 3 changes
    Keep this PR paused or close it only if the canonical SQLite accessor plan no longer wants a per-store maintenance boundary.

Next step before merge

  • [P2] The remaining action is maintainer review and session-state risk acceptance, not a narrow automated repair.

Security
Cleared: The diff adds no dependency, workflow, secret, network, package, or new external execution surface; no concrete security or supply-chain concern was found.

Review details

Best possible solution:

Merge the narrow per-store seam only after maintainer review accepts the bounded session-state risk on the final head, leaving the SQLite flip, migrations, and broader session ownership under the canonical tracker.

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

Not applicable as a bug reproduction: this is a behavior-neutral refactor seam. The changed behavior is still exercisable with disposable state through openclaw tasks maintenance --apply --json, and the PR body reports that after-patch run.

Is this the best way to solve the issue?

Yes. For this Path 3 slice, extracting the store-sized prune under src/config/sessions is narrower than flipping SQLite here and cleaner than leaving storage mutation in the command layer.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 39e9336d4031.

Label changes

Label justifications:

  • P2: This is a normal-priority internal refactor slice with limited surface area but real persisted session-row pruning impact.
  • merge-risk: 🚨 session-state: The PR changes the boundary that prunes persisted session registry rows during task maintenance.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides after-fix copied command output and persisted-state inspection from a disposable openclaw tasks maintenance --apply --json run, which is sufficient for this non-visual CLI refactor seam.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix copied command output and persisted-state inspection from a disposable openclaw tasks maintenance --apply --json run, which is sufficient for this non-visual CLI refactor seam.
Evidence reviewed

PR surface:

Source +38, Tests +128, Other +3. Total +169 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 129 91 +38
Tests 2 129 1 +128
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 1 +3
Total 6 262 93 +169

What I checked:

  • Repository policy read: Root policy and the relevant scoped scripts/ and test/ guides were read; the review applied the stored session-state, protected-label, boundary-guard, and wrapper/test guidance. (AGENTS.md:1, 39e9336d4031)
  • Current main behavior: Current main keeps openclaw tasks maintenance cron-run session pruning inline, including missing-store summaries, dry-run clone behavior, apply via updateSessionStore, running-cron preservation, and skipMaintenance. (src/commands/tasks.ts:179, 39e9336d4031)
  • Documented command contract: The CLI docs state that applied task maintenance prunes cron:<jobId>:run:<uuid> rows older than 7 days while preserving currently running cron jobs and non-cron rows. Public docs: docs/cli/tasks.md. (docs/cli/tasks.md:94, 39e9336d4031)
  • PR helper behavior: The new helper preserves the existing per-store behavior: missing stores return zero counts, preview prunes a clone, and apply uses updateSessionStore with skipMaintenance. (src/config/sessions/session-registry-maintenance.ts:79, 1153f94ef45d)
  • Caller delegation: The task command now delegates each resolved agent session store to runSessionRegistryMaintenanceForStore while preserving the command summary fields. (src/commands/tasks.ts:145, 1153f94ef45d)
  • Regression coverage: The added helper tests cover missing stores, dry-run immutability, apply pruning, running-cron preservation, and preservation of old ordinary non-cron session rows. (src/config/sessions/session-registry-maintenance.test.ts:33, 1153f94ef45d)

Likely related people:

  • jalehman: Recent merged Path 3 session-accessor and boundary-guard commits show sustained work on the session/transcript seam that this PR continues. (role: recent area contributor; confidence: high; commits: ef47dd610c87, e1744184b8c0, 127e174c9e4d; files: scripts/check-session-accessor-boundary.mjs, src/config/sessions/store.ts, src/config/sessions/session-accessor.ts)
  • brokemac79: GitHub path history shows the original task-maintenance cron session registry pruning and preserve-count fix in src/commands/tasks.ts were authored by this account. (role: introduced behavior; confidence: medium; commits: 021f753f72d6, 4ab6878473f8; files: src/commands/tasks.ts)
  • steipete: GitHub history shows adjacent task docs and the earlier reverted session metadata SQLite attempt that informs the current staged seam plan. (role: adjacent owner; confidence: medium; commits: 8d65e78a071e, 538d36eaaaa6, fbac4a2ec77c; files: src/commands/tasks.ts, docs/cli/tasks.md, src/config/sessions/store.ts)
  • vincentkoc: Recent history includes the session metadata SQLite revert and task-maintenance migration scoping fix in the same state-migration area. (role: recent adjacent contributor; confidence: medium; commits: 7f1d82ab2518, 3ed8d5f2c39b; files: src/commands/tasks.ts, src/config/sessions/store.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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jun 18, 2026
@jalehman
jalehman force-pushed the clawdbot-d02.1.9.1.39/31b-task-session-registry-maintenance-seam branch from 60157b3 to 98e7ba1 Compare June 18, 2026 21:12
@jalehman
jalehman force-pushed the clawdbot-d02.1.9.1.39/31b-task-session-registry-maintenance-seam branch from 98e7ba1 to 1153f94 Compare June 18, 2026 21:16
@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: 🦪 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 18, 2026
@jalehman
jalehman marked this pull request as ready for review June 18, 2026 21:19
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jun 18, 2026
@jalehman
jalehman merged commit 7845182 into openclaw:main Jun 18, 2026
245 of 250 checks passed
@jalehman
jalehman deleted the clawdbot-d02.1.9.1.39/31b-task-session-registry-maintenance-seam branch June 18, 2026 21:36
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR 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: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts size: M 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