Skip to content

feat(sessions): split deleted archive retention - #140793

Closed
jjjhenriksen wants to merge 6 commits into
openclaw:mainfrom
jjjhenriksen:fix/deleted-archive-retention
Closed

jjjhenriksen wants to merge 6 commits into
openclaw:mainfrom
jjjhenriksen:fix/deleted-archive-retention

Conversation

@jjjhenriksen

@jjjhenriksen jjjhenriksen commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Author-requested withdrawal — November 4, 2026

Jacqueline Henriksen (@jjjhenriksen) explicitly requested closure of this proposal after reassessing its current value. A separate deleted-archive retention policy is not currently justified by a concrete requirement, and carrying the additional public configuration and cleanup behavior forward is not worth the integration and maintenance cost.

This is a withdrawal for insufficient current need—not a claim that the feature is already implemented, that age alone invalidates it, or that the reported cleanup-safety concerns have been resolved. The discussion and implementation remain useful context if a concrete independent-retention requirement arises later.

The original proposal and evidence below are preserved for provenance.

What Problem This Solves

session.maintenance.resetArchiveRetention previously applied the same age cutoff to both reset and deleted transcript archives. This adds session.maintenance.deletedArchiveRetention as an independent duration-or-false control.

When omitted, deletedArchiveRetention inherits resetArchiveRetention for backward compatibility. An explicit duration or false overrides it independently. Both settings age archive artifacts; they do not age retained SQLite reset history or transcript rows.

Implementation

  • Resolves independent deleted/reset rules from configuration.
  • Applies those rules through legacy file-backed maintenance, cron reaping, and ordinary SQLite maintenance.
  • Ordinary SQLite maintenance runs archive cleanup even when no session rows are removed.
  • Removes a derived archive file before deleting its published SQLite recovery row; failed file cleanup leaves the recovery row intact.
  • Preserves inherited deleted retention for older resolved-maintenance callers while retaining explicit disablement.
  • Fences archive-row pruning against maintenance-owner invalidation before and inside each SQLite writer callback.
  • Updates schema help, examples, and session-management documentation.

Evidence

  • Exact pushed head: 5460eaf7b0ab2221938f1b7a4dbfc052e69d9588.
  • git diff --check passed.
  • Focused runtime command:
    pnpm exec vitest run src/config/sessions/session-accessor.sqlite-retention.integration.test.ts src/config/sessions/session-accessor.sqlite-maintenance-writer.test.ts src/config/sessions/store.pruning.archive-retention.test.ts src/config/sessions/cleanup-service.fix-missing.test.ts --reporter=verbose
    Result: 4 test files passed, 22 tests passed.
  • The unmocked integration proof loads a real config file and exercises both paths:
    • a fresh configured store is initialized (configuredFreshStore: true);
    • an existing configured store is maintained with independent cutoffs (configuredExistingStore: true);
    • the expired deleted archive file and its SQLite recovery row are absent after cleanup (deletedArchiveFile: false, deletedArchiveRow: false — false here means absent);
    • the reset archive remains (resetArchiveFile: true).
  • The focused tests additionally prove inherited retention for older resolved callers, explicit false disablement, ordinary SQLite archive cleanup with no session removals, maintenance-owner invalidation without reopening the store, file-before-row deletion ordering, and lifecycle-deletion failure recovery.
  • This proof is on the exact pushed head above; no claim is made that it resolves the separate current-base merge conflict or pending maintainer acceptance.

Known Gate

This change affects persistent retention and upgrade behavior. Maintainer acceptance of the independent retention contract, ordinary-maintenance deletion timing, and the accessor cleanup boundary remains required before merge.

Worked on by

@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-07T04:45:55.452095Z 9003d3f PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S labels Sep 7, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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 Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR adds an independent deleted-transcript archive retention setting and applies it across session cleanup paths.

Example: An operator wants deleted archives retained for 3 days and reset archives for 14 days.

  • Before: resetArchiveRetention applies one cutoff to both archive categories.
  • After: deletedArchiveRetention: "3d" and resetArchiveRetention: "14d" select separate cutoffs.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful retention-policy work remains, but the known deletion defect, unresolved direction, and test-only proof prevent merge readiness.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Operators cannot choose different retention periods for deleted-session and reset transcript archives.
Reason: The policy split has a concrete use case, but adds a retention knob without recorded owner acceptance.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep open: this assigned PR proposes independent retention controls that current main does not provide, and maintainer engagement prevents stale cleanup.

Priority: P2
Reviewed head: 8f4f52bc7714d802cce7e9c53e50598fa6810932
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should deleted archives gain an independent retention setting, with omission inheriting resetArchiveRetention?
  • Recommendation: Accept a narrow split in the existing owner: Sponsor independent deleted/reset cutoffs while retaining current main's maintenance ownership and existing omitted-setting behavior.
  • Why: This adds public configuration and changes persistent-retention behavior; the author explicitly records acceptance as pending, and no owner approval was found.

Before merge

  • Add real behavior proof - Authority-chain proof required: the supplied evidence is test execution, including an unmocked in-process SQLite/filesystem integration, rather than a shipped-entry-point trace. Provide redacted terminal output or logs showing cleanup with independent cutoffs and rejection before filesystem removal after owner invalidation; redact private paths, endpoints, IP addresses, credentials, and personal data. The purported existing-store upgrade creates that store with proposed code and does not demonstrate latest-stable upgrade compatibility, inherited/explicit-false cleanup, or failed-removal recovery. 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.
  • Recheck maintenance ownership before removing archive files (P2) - This previously reported finding remains unfixed. With an expired archive, close or replace the owning database while cleanupArchivedSessionTranscripts awaits readdir or stat: isCurrent becomes false, but the helper still calls fs.promises.rm. The later SQLite currentness checks cannot undo that filesystem deletion. Carry the owner check through to the final removal boundary, preferably using current main's guarded archive owner.
  • Resolve merge risk - Before merge, the contributor must resolve the reported conflict while preserving current main's worker-backed, reference-aware archive owner instead of retaining a competing entry-write expiry path.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P2] Recheck maintenance ownership before removing archive files — src/config/sessions/session-accessor.sqlite-maintenance.ts:580-583

Tests

  • Missing end-to-end proof: Missing shipped cleanup evidence from copied pre-change state covering independent cutoffs, inheritance, explicit false, failed-removal recovery, and owner invalidation before unlink; a base-failing regression run was not shown.
Agent review details

How this fits together

Session maintenance resolves configuration into archive-expiry rules, then removes eligible archive files and their SQLite recovery records.

flowchart TD
  A[Session configuration] --> B[Retention rule resolver]
  B --> C[Session maintenance]
  B --> D[Cron reaper]
  C --> E[Archive cleanup]
  D --> E
  E --> F[Archive files]
  E --> G[SQLite recovery rows]
Loading

Technical review

Best possible solution:

If approved, implement the independent cutoff in current main's existing archive owner while preserving inherited settings and fencing every deletion.

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

Source establishes the stale-owner deletion interleaving: database closure during an awaited scan invalidates the caller, but filesystem removal still proceeds; no target code was executed.

Is this the best way to solve the issue?

Separate cutoffs are coherent, but the smallest current implementation extends the existing archive-maintenance owner rather than adding expiry to ordinary entry maintenance.

Full review comments:

  • [P2] Recheck maintenance ownership before removing archive files — src/config/sessions/session-accessor.sqlite-maintenance.ts:580-583
    This previously reported finding remains unfixed. With an expired archive, close or replace the owning database while cleanupArchivedSessionTranscripts awaits readdir or stat: isCurrent becomes false, but the helper still calls fs.promises.rm. The later SQLite currentness checks cannot undo that filesystem deletion. Carry the owner check through to the final removal boundary, preferably using current main's guarded archive owner.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Reconcile with the existing archive owner (recommended)
    The contributor resolves the conflict and carries only the approved policy split into current main's guarded worker path.
  2. Pause implementation pending direction
    The maintainer pauses the branch until the retention contract is accepted or declined.

Provenance checked

  • Existing retention configuration keeps the original intent (Session/Cron maintenance hardening and cleanup UX #24753: The earlier maintenance work introduced first-class archive retention controls with additive, default-safe compatibility; this PR preserves the existing cutoff when the new field is omitted.)
  • Canonical archive recovery keeps the original intent (0a8e360: The SQLite transition made database rows canonical while retaining inspectable archive artifacts; this PR continues file-before-recovery-row cleanup.)
  • Ordinary maintenance expiry changes intended behavior with a stated reason (645c0ac: Maintenance was separated from ordinary entry-write latency; the PR explicitly adds archive expiry even without row removals to address the former cron-only gap, which current main now solves through another existing owner.)
  • Advisory filesystem failure handling keeps the original intent (fad7edd: Filesystem failures must remain visible without invalidating already-committed primary persistence; the added cleanup retains warning-based reporting and preserves recovery rows when file removal fails.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +121, Tests +291, Docs +4, Generated 0, Other +1. Total +417 across 24 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 10 138 17 +121
Tests 8 292 1 +291
Docs 3 16 12 +4
Config 0 0 0 0
Generated 2 3 3 0
Other 1 1 0 +1
Total 24 450 33 +417

Review metrics

Metric Value Why it matters
New configuration surface 1 optional setting deletedArchiveRetention adds an independently configurable duration-or-false contract, with omission inheriting the existing setting.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded retention improvement without an established urgent user-facing regression.
  • merge-risk: 🚨 compatibility: The new public setting and inherited behavior require an accepted contract and upgrade compatibility evidence.
  • merge-risk: 🚨 session-state: Archive deletion affects recovery history, and the newly introduced filesystem path can continue after maintenance ownership becomes invalid.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • 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 (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-08T01:00:57.179Z sha 0099a58c8aee79f247717b5a04094e3ecbd6424b :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-08T03:04:56.409Z sha 2697fc711cb1f964fddb4c302ca80648448828dd :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-08T03:26:06.802Z sha 26beee6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-08T17:32:46.507Z sha 5460eaf :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-10T17:52:10.853Z sha 5460eaf :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-21T18:30:06.680Z sha 8f4f52b :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-25T22:59:08.283Z sha 8f4f52b :: needs real behavior proof before merge. :: [P2] Recheck maintenance ownership before removing archive files
  • reviewed 2026-10-03T00:44:58.993Z sha 8f4f52b :: needs real behavior proof before merge. :: [P2] Recheck maintenance ownership before removing archive files

Reviewed November 1, 2026, 6:13 PM ET / 23:13 UTC (Revision 13).

@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: 9003d3fd12

ℹ️ 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/cron/session-reaper.ts Resolved
@jjjhenriksen

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

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

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 7, 2026
@roboclaw-bot roboclaw-bot added the clawtributor-review Clawtributor pull request awaiting prioritized maintainer review label Sep 7, 2026
@jjjhenriksen
jjjhenriksen force-pushed the fix/deleted-archive-retention branch from ff37eda to 0099a58 Compare September 8, 2026 00:54
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Sep 8, 2026
@jjjhenriksen
jjjhenriksen force-pushed the fix/deleted-archive-retention branch from 2697fc7 to 26beee6 Compare September 8, 2026 03:19
@openclaw-barnacle openclaw-barnacle Bot added the triage: blank-template Candidate: PR template appears mostly untouched. label Sep 8, 2026
@openclaw-barnacle openclaw-barnacle Bot added triage: dirty-candidate Candidate: broad unrelated surfaces; may need splitting or cleanup. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Sep 8, 2026
@jjjhenriksen

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 8, 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:

@jjjhenriksen

Copy link
Copy Markdown
Contributor Author

Maintainer-readiness follow-up: the implementation findings are addressed, but the remaining gate is upgrade safety for the retention contract. The missing proof is a pre-change store upgraded in place, plus explicit-false behavior and recovery after a failed file removal; the cleanup-boundary/config-compatibility decision also needs maintainer acceptance. I’ll target those exact cases on the next update, then request a fresh ClawSweeper review on the resulting head.

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 10, 2026
@jjjhenriksen

Copy link
Copy Markdown
Contributor Author

Exact-head integration proof pushed at 8f4f52bc771.

The SQLite/file integration now gives deleted and reset archives the same one-day age, applies independent cutoffs (deletedArchiveRetention: 1ms, resetArchiveRetention: 7d), and proves:

  • a pre-existing configured store is upgraded in place
  • the deleted derived file and canonical recovery row are removed
  • the equal-age reset archive remains

The targeted retention set also proves explicit disablement remains disabled and a canonical row is retained while its derived file still exists (the failed/not-yet-completed removal case).

Validation: 3 files, 13 tests passed.

This supplies behavior evidence only; it does not substitute for the requested maintainer decision on the retention contract/deletion timing.

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 4, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawtributor-review Clawtributor pull request awaiting prioritized maintainer review docs Improvements or additions to documentation gateway Gateway runtime 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: M stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: blank-template Candidate: PR template appears mostly untouched. triage: dirty-candidate Candidate: broad unrelated surfaces; may need splitting or cleanup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants