Skip to content

fix(sessions): report archive cleanup in sessions cleanup - #97103

Closed
samrusani wants to merge 23 commits into
openclaw:mainfrom
samrusani:codex/sessions-cleanup-archive-report
Closed

samrusani wants to merge 23 commits into
openclaw:mainfrom
samrusani:codex/sessions-cleanup-archive-report

Conversation

@samrusani

@samrusani samrusani commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #75658

What Problem This Solves

Fixes an issue where operators running openclaw sessions cleanup --dry-run could not preview expired .deleted.* and .reset.* transcript archives, and apply output did not report the physical archive files it removed.

Why This Change Was Made

Cleanup uses the configured archive-retention rules for preview and apply reporting. Physical archive retention is owned by the canonical config/session lifecycle module shared by SQLite cleanup and Gateway callers, without a config-to-Gateway runtime bridge or a new session-accessor debt exemption.

Logical ownership remains separate from physical directory identity. A selected agent cannot remove archives from a directory shared by another configured agent, including a symlink alias; --all-agents can clean that physical directory once.

Successful retention deletion clears reset-archive discovery state before notifying transcript subscribers. Dry-run stays non-mutating: archive-directory identity checks use a read-only matcher and never create missing-path alias probes.

User Impact

Users can see deleted/reset transcript archive cleanup in dry-run and apply summaries. Shared directories stay protected during agent-scoped cleanup, while all-agent cleanup deduplicates physical work and reports the result.

Current Head

  • Head: add96cdb4c807a6d3e5c6b60ffc352b5292733ca.
  • Rebased onto upstream main 165a2e9ede696adbc84313bbb731ee89c1ef53d2.
  • Author and committer: Sami Rusani <[email protected]>.

Evidence

  • Rebase resolution retained current-main compatibility-owner logic and the PR's configured-owner archive coordinator. The resulting change has no conflict markers and git diff --check passed.
  • Focused archive/config/lifecycle tests: 131 passed across 4 files.
  • Command rendering tests: 13 passed.
  • Gateway archive tests: 45 passed across 3 files.
  • Session-accessor boundary guard and changed-file formatting check passed.
  • pnpm dev rebuilt the CLI and bundled plugin assets before the isolated CLI proof.
  • Changed-file lint was queued behind a separate repository validation lock; exact-head hosted CI remains required before merge.

CLI Proof

Disposable isolated fixture with two logical agents sharing one archive directory, one expired .deleted archive, and one fresh .reset archive:

  • selected-agent dry-run: reports shared-directory-requires-all-agents and preserves the directory;
  • all-agent dry-run: scans 2 archives and reports 1 eligible deletion;
  • explicit offline apply: scans 2, removes the expired archive, and leaves the fresh archive present.

No external service, credentials, or user data was used.

AI Assistance

AI-assisted: yes. Codex was used to inspect contributor rules and review feedback, rebase the patch, resolve current-main integration conflicts, run focused validation, and produce the isolated CLI proof. No agent transcript is attached.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime commands Command implementations size: M labels Jun 26, 2026
@clawsweeper

clawsweeper Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Adds deleted/reset transcript archive counts to session cleanup previews and results while protecting directories shared with unselected agents.

Example: With seven-day archive retention, a directory contains one expired deleted archive and one fresh reset archive.

  • Before: Cleanup output does not separately report the expired archive.
  • After: Dry-run reports one eligible archive; apply reports its removal and preserves the fresh archive.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful, focused behavior with meaningful filesystem coverage and no verified introduced bug; the currently available real-behavior evidence is descriptive rather than inspectable.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Operators cannot see expired deleted/reset archive cleanup separately in previews and applied results.
Reason: Reporting existing configured retention improves operator understanding without adding configuration or changing the keep-by-default policy.

Merge readiness

⛔ Blocked before merge - 2 items remain

This PR retains useful archive-reporting work that current main does not provide; its reported merge conflict requires integration with the newer retention lifecycle.

Priority: P2
Reviewed head: add96cdb4c807a6d3e5c6b60ffc352b5292733ca

Before merge

  • Add real behavior proof - The current body describes an isolated real-CLI fixture and expected counts, but supplies no inspectable terminal output, redacted logs, or linked artifact demonstrating those results; attach that evidence and redact credentials, IPs, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve merge risk - Before merge, resolve the conflict by carrying archive reporting through current main's lifecycle owner while preserving coordinated filesystem deletion and published SQLite archive-record pruning.

Findings

None.

Tests

  • Low-value test src/config/sessions/cleanup-archive.test.ts: The single-owner preview/apply test primarily asserts mocked return values and argument forwarding; filesystem and service tests provide stronger behavior coverage.
  • Low-value test src/config/sessions/cleanup-archive.test.ts: The all-owner deduplication test primarily pins mocked call counts; the real service ownership and symlink tests already verify one physical cleanup.
  • Missing end-to-end proof: Attach inspectable real-CLI dry-run/apply output showing archive counts, selected-agent preservation, all-agent deduplication, and fresh-archive preservation.
Agent review details

How this fits together

The sessions cleanup CLI delegates to the Gateway or local cleanup service, which selects session stores and applies retention to SQLite history and filesystem artifacts.

flowchart TD
  A[Sessions cleanup CLI] --> B[Gateway or local cleanup service]
  B --> C[Logical store selection]
  C --> D[Shared directory coordinator]
  D --> E[Archive retention owner]
  E --> F[Transcript archive files]
  B --> G[SQLite session lifecycle]
  E --> H[Cleanup summaries]
Loading

Technical review

Best possible solution:

Integrate archive preview and removal counts into current main's canonical cleanup lifecycle, reusing its artifact-directory resolver and retaining shared-directory protection.

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

Current main's preview and summary omit dedicated archive-retention counts; source establishes that reporting gap without executing target code.

Is this the best way to solve the issue?

A shared retention owner is the right fix location, but the final integration should reuse current main's directory and SQLite lifecycle owners rather than establish a competing cleanup flow.

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Integrate with the current retention lifecycle (recommended)
    Resolve the reported conflict using current cleanup owners, preserve published archive-record pruning, and return reporting from the coordinated operation.

Provenance checked

  • Archive retention and maintenance ownership keeps the original intent (9eb6e6d: Provide a transaction-sized maintenance seam and explicit post-commit artifact cleanup for the SQLite transition.)
  • Shared archive enumeration keeps the original intent (8682d07: Avoid repeated directory enumeration for deleted and reset retention rules.)
  • Retention filesystem failures keeps the original intent (fad7edd: Propagate real filesystem failures and count only successful removals while tolerating missing-file races.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit fad7edd adds src/config/sessions/store-maintenance-operations.ts:180 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: fad7edd262af; files: src/config/sessions/store-maintenance-operations.ts)
  • Josh Lehman: Raw commit 9eb6e6d adds src/config/sessions/store-maintenance-operations.ts:150 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9eb6e6d32675; files: src/config/sessions/store-maintenance-operations.ts)
  • Alex Knight: Raw commit 8682d07 adds src/gateway/session-transcript-files.fs.ts:506 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 8682d0701b27; files: src/gateway/session-transcript-files.fs.ts)

PR surface

Source +382, Tests +594, Other -1. Total +975 across 21 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 13 550 168 +382
Tests 7 603 9 +594
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 21 1153 178 +975

Review metrics

Metric Value Why it matters
Production versus test LOC Production net +382; tests net +594; tooling baseline −1. Production is +550/−168 and tests +603/−9 before discounting relocated code; moves do not change the net growth. New preview accounting and logical-directory ownership coordination provide concrete capabilities absent from the base, although integration should reuse main's newer directory resolver.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Archive cleanup visibility is a bounded operator improvement, with no demonstrated urgent runtime regression.
  • merge-risk: 🚨 compatibility: The conflicting branch predates main's coordinated filesystem and SQLite archive-record retention; conflict resolution must preserve that persisted-history contract.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-23T11:53:46.820Z sha add96cd :: found issues before merge. :: [P1] Prune published archive records after file retention
  • reviewed 2026-08-23T12:12:49.535Z sha add96cd :: found issues before merge. :: [P1] Retain published archive record pruning
  • reviewed 2026-08-29T12:32:29.265Z sha add96cd :: needs changes before merge. :: [P1] Prune published SQLite archive records after deletion
  • reviewed August 29, 2026, 9:00 AM ET / 13:00 UTC sha unknown :: needs changes before merge. :: [P1] Retain published archive-row pruning after retention
  • reviewed September 5, 2026, 4:18 PM ET / 20:18 UTC sha unknown :: blocked before merge. :: none
  • reviewed 2026-09-25T09:56:48.426Z sha add96cd :: blocked before merge. :: [P1] Prune published archive rows after deleting their files
  • reviewed 2026-10-09T11:23:11.386Z sha add96cd :: blocked before merge. :: none
  • reviewed 2026-10-09T11:32:50.964Z sha add96cd :: blocked before merge. :: none

Reviewed October 16, 2026, 1:37 AM ET / 05:37 UTC (Revision 11).

@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. P2 Normal backlog priority with limited blast radius. labels Jun 26, 2026
@samrusani

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Pushed c079b74d630a48643bc68dc1f630bade32ef09b4 to address the dry-run double-count finding. Archive cleanup dry-run now receives the disk-budget exclusion set, with regression coverage for disk-budget-claimed archive files. I also updated the PR body with redacted CLI dry-run/apply proof and the rerun validation.

@clawsweeper

clawsweeper Bot commented Jun 27, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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. 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 27, 2026
@samrusani
samrusani marked this pull request as ready for review July 2, 2026 22:58

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c079b74d63

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/config/sessions/cleanup-service.ts Resolved
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. labels Jul 2, 2026
@samrusani

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (165a2e9ede696adbc84313bbb731ee89c1ef53d2). Focused session/config, command, and Gateway archive validation passed; the PR body now records the exact-head evidence and isolated CLI proof.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 13, 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:

@steipete

Copy link
Copy Markdown
Contributor

Thanks for the PR. We're closing older pull requests that have gone stale against current main.

This XL PR has had no commits since August 13 and still needs real behavior proof. Please open a fresh, smaller PR against current main if archive cleanup reporting is still missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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.

feat: sessions cleanup should remove physical .deleted and .reset files, not only index entries

2 participants