Skip to content

fix(media): keep the ttl sweep out of the managed outgoing tree - #119127

Merged
steipete merged 25 commits into
openclaw:mainfrom
he-yufeng:fix/media-sweep-managed-outgoing
Aug 5, 2026
Merged

steipete merged 25 commits into
openclaw:mainfrom
he-yufeng:fix/media-sweep-managed-outgoing

Conversation

@he-yufeng

@he-yufeng he-yufeng commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #119088.

What Problem This Solves

Fixes an issue where operators who configured attachments.ttlHours could lose generated attachments referenced by chat history. The generic mtime sweep entered media/outgoing, deleting the only original while its SQLite history record remained, and could remove legacy outgoing/records/*.json metadata that intentionally blocks destructive orphan cleanup until Doctor imports it.

Why This Change Was Made

The generic TTL sweep now stays out of the managed outgoing subtree. That subtree remains owned by its SQLite- and transcript-aware reaper, which runs independently at gateway startup and hourly even when the configurable TTL is disabled, fails, or is still in flight. Playback cache retention remains a separate fixed owner lifecycle.

The maintenance owner now keeps its interval private and exposes one asynchronous stop operation. Gateway shutdown and startup-race disposal stop future runs and normally drain any in-flight configured sweep, playback cleanup, and managed outgoing cleanup before closing shared state. The drain is bounded at five seconds: a stuck operation records an operator-visible warning and cannot block restart forever. Unresolved drains are tracked process-wide across gateway generations; shared SQLite remains open until every prior-generation drain settles, and the attached all-settled observers handle late outcomes. This lifecycle is independently required by the new always-on managed reaper; it is not a workaround for the separate loaded-shard Doctor timeout.

The transcript-aware reaper also preserves session-store availability as a first-class result. Confirmed missing databases/sessions may be treated as absent, while schema/table unavailability retains history records and originals instead of converting an operational failure into deletion. Serving remains fail-closed while storage is unavailable.

The config help describes the actual boundary: attachments.ttlHours controls the general mtime sweep, while generated chat attachments use managed outgoing retention.

User Impact

Generated attachments retained by chat history and pre-SQLite migration metadata are no longer deleted by attachments.ttlHours. Transient managed outgoing media still expires on its own startup/hourly lifecycle without requiring a chat.history read or the optional general TTL setting. Gateway shutdown and restart no longer let media maintenance continue against retired state.

Evidence

Exact rebased head: 2f7699dccfac436e1a81b7ed3600883d1069740a.

  • Exact-head focused regression run — 341 passed, 4 skipped across gateway maintenance/startup/close/managed-media, extracted session-availability, and agent-SQLite suites. The contributor's end-to-end dropped-session_nodes GC regression is included.
    • Managed cleanup runs without attachments.ttlHours, survives a failed or hung general sweep, and skips overlap.
    • Playback, configured TTL, and managed outgoing cleanup retain independent failure/overlap policy.
    • The maintenance factory performs no media work until the runtime publishes its stop owner and explicitly activates cleanup.
    • Stop-before-start permanently suppresses activation; close/startup-race disposal do not launch unowned cleanup.
    • Normal shutdown drains all three active owners before closing shared state; a permanently hung cleanup returns after five seconds, records the warning, schedules no later tick, and keeps the shared database available to late work.
    • The timeout fence survives in-process gateway restarts; a later generation cannot close shared state until every prior drain settles.
    • Real SQLite regressions cover dropped/missing/invalid session tables and rows, missing configured stores, corrupted sibling candidates, retired stores, and explicit/unscoped ownership.
    • Readable candidates still require an affirmative missing reference before deletion; unavailable results are not cached as absence, and HTTP serving remains fail-closed.
  • Final exact-head pnpm build and pnpm deadcode:full — passed.
  • Core and core-test tsgo, targeted oxlint/oxfmt, and git diff --check — passed. The broad local changed wrapper later stopped on an unrelated current-main max-lines baseline shrink; its earlier exact touched-surface run had passed all related gates.
  • Final integrated branch-level Codex P1 autoreview against the frozen origin/main baseline — clean, no P0/P1 findings; patch correct at 0.87 confidence.

Source-blind exact-head runtime behavior proof

The source-blind validator built and ran exact head 2f7699dccfac436e1a81b7ed3600883d1069740a against an isolated state directory and loopback gateway with attachments.ttlHours=1:

  • Removed 48-hour-old nested general media under inbound, downloads, uploads, browser, and temp, while preserving fresh controls in all five trees.
  • Preserved 400-day-old files under media/outgoing/originals, legacy-metadata.json, and .migration-barrier through the post-ready maintenance pass; repeated-restart preservation was also observed on the immediately preceding behavior-identical heads.
  • Reached the operator-visible ready state; GET /health returned {"ok":true,"status":"live"}. After a 15-second post-ready maintenance window, SIGTERM shutdown completed cleanly in 6 seconds.
  • Verdict: 3 passed, 0 failed, 3 blocked.
    • A real chat.history/SQLite attachment reference could not be provisioned through the isolated no-provider public workflow; the exact-head real filesystem/SQLite regression covers that boundary.
    • chmod 000 did not establish a permission fault for the validator process on this host, so the permission-fault clause was not claimed as a pass.
    • The public runtime surface has no safe fault injection for a permanently hung cleanup; the exact-head lifecycle regression proves the bounded five-second warning outcome.

Anti-cheat probes used distinct expired and fresh files, inspected disk state instead of trusting logs, restarted the same isolated state, and rejected the permission test when the intended fault did not take effect. The predecessor source-blind run remains supplementary evidence for the SQLite-reference and permission-fault scenarios, but is not presented as exact-head proof.

Loaded-shard Doctor timeout reclassification

The exact logged core-unit-fast-2 CI process was reproduced locally with the CI runner, recorded include list, --isolate=false, three workers, and matching environment. It reproduced the same synchronous Discord Doctor timeout while neither PR media test was part of that process.

The identical timeout also occurred on unrelated PR #119331 at head 13110081850da0e43b6c9e32f30d08a6c68698d6: https://github.com/openclaw/openclaw/actions/runs/30969952001/attempts/1. Latest main's matching shard passed at 22de30f998216c0c480b8858f9185d9829d90bae: https://github.com/openclaw/openclaw/actions/runs/30970858385/job/92194836323. Current main now includes the separate Doctor runtime-load repair from #119391, which this branch picked up during rebase.

The isolated Doctor file passes 10/10 on the rebased head. The loaded-shard regression is tracked separately and is not attributed to this media PR.

@openclaw-barnacle openclaw-barnacle Bot added size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 4, 2026
@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. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 4, 2026
@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 9:13 AM ET / 13:13 UTC.

ClawSweeper review

What this changes

The PR excludes SQLite-managed outgoing attachments from the general TTL sweep, gives their record-aware cleanup an independent gateway lifecycle, and retains media when session state cannot be read safely.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this PR open for maintainer review: the exact head repairs a still-current P0 data-loss path with no actionable source finding, but intentionally narrows the existing TTL retention contract for managed outgoing media.

Priority: P0
Reviewed head: 2f7699dccfac436e1a81b7ed3600883d1069740a
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Exact-head runtime evidence, focused real-SQLite coverage, and source review support a strong patch; the remaining gate is the intentional retention-contract decision.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body and maintainer exact-head update provide source-blind gateway output showing staged-media deletion, outgoing/barrier preservation, health readiness, and clean shutdown, supplemented by real-SQLite regressions.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body and maintainer exact-head update provide source-blind gateway output showing staged-media deletion, outgoing/barrier preservation, health readiness, and clean shutdown, supplemented by real-SQLite regressions.
Evidence reviewed 6 items Current-main defect remains: Current main recursively prunes every media child except playback, so it includes outgoing; gateway maintenance invokes that sweep immediately and hourly when TTL is configured.
Correct retention owner boundary: The PR excludes outgoing from the mtime-only traversal and independently invokes the managed reaper, which deletes history media only after a confirmed transcript miss.
Fail-closed availability handling: Exact session-row and store-target probes preserve unavailable database, schema, table, and invalid-row states; the reaper treats unavailable state as retention rather than deletion proof.
Findings None None.
Security None None.

How this fits together

Gateway maintenance periodically prunes staged media and managed outgoing attachments under the OpenClaw state directory. General TTL cleanup removes ordinary staged files, while managed outgoing cleanup consults SQLite session and transcript state before deciding whether an attachment can be deleted.

flowchart LR
  A[Attachment TTL setting] --> B[Gateway maintenance]
  B --> C[General staged-media sweep]
  B --> D[Managed outgoing reaper]
  D --> E[Session and transcript state]
  C --> F[Expired staged media removed]
  D --> G[Referenced attachments retained]
  H[Gateway shutdown] --> I[Cleanup drain fence]
  I --> E
Loading

Decision needed

Question Recommendation
Should attachments.ttlHours stop governing SQLite-managed outgoing attachments and leave their retention to the independent record-aware reaper? Accept the corrected boundary: Merge the PR so durable chat attachments are never deleted by an mtime-only TTL sweep.

Why: The source and proof support the data-loss repair, but this deliberately changes what an existing configured retention setting governs.

Before merge

  • Resolve merge risk (P1) - Existing installations that relied on attachments.ttlHours to age out all outgoing files will instead retain managed outgoing media under its record-aware lifecycle; this is the required data-loss fix, but it is an intentional compatibility change.
  • Complete next step (P2) - A maintainer must explicitly accept the corrected attachments.ttlHours compatibility boundary; no mechanical repair remains.
Agent review details

Security

None.

PR surface

Source +514, Tests +987. Total +1501 across 22 files.

View PR surface stats
Area Files Added Removed Net
Source 12 575 61 +514
Tests 10 1070 83 +987
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 22 1645 144 +1501

Review metrics

Metric Value Why it matters
Retention contract 0 config keys added or removed; 1 existing TTL help contract changed The setting remains opt-in, but its documented cleanup boundary changes from the full media tree to staged media.
Production vs test LOC production +575/-61 (net +514); tests +1,070/-83 (net +987) The production growth establishes a record-availability boundary and lifecycle fence; the accompanying tests cover data retention, shutdown, and real-SQLite failure paths.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/media/store.cleanup.test.ts, persistent cache schema: src/config/sessions/targets-read-availability.test.ts, persistent cache schema: src/config/sessions/targets-read-availability.ts, serialized state: src/config/schema.help.runtime.ts, serialized state: src/config/sessions/session-accessor.sqlite-entry-availability.ts, serialized state: src/config/sessions/targets-read-availability.test.ts, and 3 more. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Merge-risk options

Maintainer options:

  1. Accept record-aware retention (recommended)
    Merge after confirming that preventing durable attachment loss outweighs the prior full-tree TTL behavior for existing configurations.
  2. Pause for a different retention contract
    Do not merge if maintainers require attachments.ttlHours to continue deleting managed outgoing files until an explicit safe policy is designed.

Technical review

Best possible solution:

Adopt managed outgoing media as the sole record-aware retention owner and keep attachments.ttlHours limited to general staged media after a maintainer accepts that corrected upgrade contract.

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

Yes: current main directly walks media/outgoing under the configured recursive TTL sweep, and the PR body supplies exact-head filesystem, gateway, and real-SQLite evidence for the repaired boundary.

Is this the best way to solve the issue?

Yes: the generic sweep cannot determine SQLite-backed transcript ownership, so isolating the managed subtree and using its existing record-aware reaper is the narrowest maintainable fix.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 36ee98d815db.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body and maintainer exact-head update provide source-blind gateway output showing staged-media deletion, outgoing/barrier preservation, health readiness, and clean shutdown, supplemented by real-SQLite regressions.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body and maintainer exact-head update provide source-blind gateway output showing staged-media deletion, outgoing/barrier preservation, health readiness, and clean shutdown, supplemented by real-SQLite regressions.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove merge-risk: 🚨 availability: Current PR review merge-risk labels are merge-risk: 🚨 compatibility, merge-risk: 🚨 session-state.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P0: Current main can permanently delete chat-history attachment bytes when an operator enables the TTL sweep.
  • merge-risk: 🚨 compatibility: Existing attachments.ttlHours configurations stop applying mtime expiry to managed outgoing media.
  • merge-risk: 🚨 session-state: The deletion decision now depends on persisted session and transcript availability and ownership.
  • 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 and maintainer exact-head update provide source-blind gateway output showing staged-media deletion, outgoing/barrier preservation, health readiness, and clean shutdown, supplemented by real-SQLite regressions.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and maintainer exact-head update provide source-blind gateway output showing staged-media deletion, outgoing/barrier preservation, health readiness, and clean shutdown, supplemented by real-SQLite regressions.

Evidence

What I checked:

  • Current-main defect remains: Current main recursively prunes every media child except playback, so it includes outgoing; gateway maintenance invokes that sweep immediately and hourly when TTL is configured. (src/media/store.ts:240, 36ee98d815db)
  • Correct retention owner boundary: The PR excludes outgoing from the mtime-only traversal and independently invokes the managed reaper, which deletes history media only after a confirmed transcript miss. (src/gateway/managed-image-attachments.ts:666, 2f7699dccfac)
  • Fail-closed availability handling: Exact session-row and store-target probes preserve unavailable database, schema, table, and invalid-row states; the reaper treats unavailable state as retention rather than deletion proof. (src/config/sessions/session-accessor.sqlite-entry-availability.ts:20, 2f7699dccfac)
  • Regression coverage: New tests preserve a managed history original and legacy migration barrier during TTL cleanup, and use real SQLite with a dropped session_nodes table to verify that bytes and metadata survive unavailable session state. (src/gateway/managed-outgoing-gc-availability.test.ts:74, 2f7699dccfac)
  • Lifecycle ownership: Cleanup is activated only after its stop owner is published, is fenced synchronously during close, and retains shared state if a bounded drain times out. (src/gateway/server-startup-finish.ts:659, 2f7699dccfac)
  • History and release status: The current sweeping behavior dates to the current-main commit, while this PR head is newer and is not contained by a local release tag; the supplied latest release predates the branch. (src/media/store.ts:240, 60a8ec821cb8)

Likely related people:

  • steipete: Blame ties the current broad media sweep to 60a8ec8, and the PR's lifecycle and availability repair series is largely authored by this contributor. (role: current behavior introducer and recent area contributor; confidence: high; commits: 60a8ec821cb8, 8990f39ff334, 2f7699dccfac; files: src/media/store.ts, src/gateway/server-maintenance.ts, src/gateway/managed-image-attachments.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (28 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-05T08:04:49.019Z sha 72eeacd592fe34ce9d5cf082e7c250a605b1e5e6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-05T08:21:44.108Z sha 72559f346b183409d1f1fd007a3edc7870b77f73 :: needs real behavior proof before merge. :: [P1] Revalidate pending claims before deleting media
  • reviewed 2026-08-05T09:04:40.971Z sha cc09ff7 :: needs real behavior proof before merge. :: [P2] Stop media maintenance in the close prelude
  • reviewed 2026-08-05T09:36:15.197Z sha d439a1a :: needs real behavior proof before merge. :: [P1] Propagate unreadable per-agent candidates
  • reviewed 2026-08-05T10:07:45.334Z sha c716e87 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-05T10:30:01.758Z sha 03a3ec1bf2b3e04db5bdba83dad174aed8066576 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-05T12:03:01.615Z sha 2c66ffb :: needs maintainer review before merge. :: none
  • reviewed 2026-08-05T12:10:53.882Z sha 2c66ffb :: needs maintainer review before merge. :: none

@he-yufeng

Copy link
Copy Markdown
Contributor Author

Both findings landed in 18c170fe94:

  • P1: the managed reaper now runs right after every maintenance sweep (runMediaCleanup), so transient records and unindexed originals keep expiring even in sessions that never read chat history. New maintenance test asserts startup plus hourly cadence.
  • P2: the attachments.ttlHours help now scopes the contract to inbound media and points at the managed SQLite-aware retention instead of claiming the full tree.

Real behavior proof on this exact head (18c170fe94): a harness runs the real maintenance timers against a temp OPENCLAW_STATE_DIR holding a transient record aged past its 15-minute TTL, with the file aged past a 1h mediaCleanupTtlMs. After the startup tick, both the record and its file are reaped, which is the path the sweep used to take and now the reaper owns. Transcript in the PR body. Full run: maintenance 28 + attachments + cleanup files, 251 tests pass.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 4, 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: 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 rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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 Aug 4, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 4, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 4, 2026
@he-yufeng

Copy link
Copy Markdown
Contributor Author

The check-lint red was real: my maintenance-timer edit missed an oxfmt pass on the dynamic import, fixed in 0e4137ce80. The other three failures in that run do not touch this change: build-artifacts died on gateway connect/request timeouts in its own harness, and checks-node-compact-large-3 failed a doctor open-policy test in an untouched tree. Expect them to settle on the rerun.

@clawsweeper clawsweeper Bot added 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 Aug 5, 2026
@steipete

steipete commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer proof update for rebased exact head 2f7699dccfac436e1a81b7ed3600883d1069740a:

The managed outgoing reaper is lifecycle-owned independently of attachments.ttlHours. Shutdown stops and fences cleanup before shared-state teardown; timed-out drains remain process-wide across gateway generations, and shared SQLite stays open until they settle. Session-store discovery and exact reads preserve availability: missing fixed stores, retired stores with missing schema metadata, and missing session tables retain history records/originals instead of falling through to apparent absence. Serving remains fail-closed.

Exact-head proof:

  • Focused regression suites: 341 passed, 4 skipped on the exact head, covering close-prelude/startup fencing, independent lanes, extracted store-availability checks, invalid rows, and the contributor's real-SQLite GC regression.
  • Final exact-head build and full dead-export/dependency check: passed.
  • Isolated Doctor test: 10/10 repetitions passed.
  • Core/core-test typecheck, targeted lint/format, and diff checks passed; the earlier exact touched-surface changed gate also passed related architecture/database checks.
  • Final integrated branch-level Codex P1 autoreview against the frozen current-main baseline: clean, no P0/P1 findings; patch correct at 0.87 confidence.
  • Source-blind exact-head validator: 3 passed, 0 failed, 3 blocked; general TTL deletion, outgoing/legacy preservation after post-ready maintenance, gateway health, and clean SIGTERM shutdown passed. Repeated-restart preservation was observed on the immediately preceding behavior-identical heads; blocked fault injections are covered by exact-head regressions.

The exact recorded core-unit-fast-2 loaded shard reproduced the Discord Doctor timeout locally even though neither PR media test was present in that process. Unrelated PR #119331 failed the identical test at https://github.com/openclaw/openclaw/actions/runs/30969952001/attempts/1, while latest main's matching shard passed at https://github.com/openclaw/openclaw/actions/runs/30970858385/job/92194836323. The rebased branch now contains main's separate #119391 Doctor runtime-load fix; the broader loaded-shard regression is being handled separately.

The PR body contains the durable runtime, lifecycle, and CI evidence.

@clawsweeper

clawsweeper Bot commented Aug 5, 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: 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 rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 5, 2026
@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Exact-head source-blind runtime proof and the unrelated CI-timeout verification are now in the PR body and maintainer proof comment.

@clawsweeper re-review

@clawsweeper clawsweeper Bot added 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 Aug 5, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 5, 2026
@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Frozen landing head d439a1aaf3201833fee20922f9e52f4ba0431500 addresses the close-prelude finding: markClosePreludeStarted synchronously starts and caches the current media stop before any awaited shutdown step; the prelude joins it and the later close handler reuses the same promise. Exact-head gateway suites (269), session/SQLite suites (39 + 96), build/deadcode, source-blind runtime/shutdown proof, and final integrated branch-level P1 autoreview are clean. Per frozen-baseline policy, later unrelated main movement is intentionally not chased.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 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: 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 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 Aug 5, 2026
@he-yufeng

Copy link
Copy Markdown
Contributor Author

@steipete thanks for taking the implementation over and doing it properly at the accessor boundary. I read through the result: the availability reason now survives loadExactSessionEntryReadOnlyResult, the discovery layer short-circuits before any entry lookup, and the startup/restart/close fencing covers the "don't enable the cadence before the invariant holds" point.

One addition in 03a3ec1bf2, keeping to the case your review named: an end-to-end regression that seeds a real database, drops session_nodes, runs the global sweep, and asserts the record row and the original bytes both survive, plus a control that a genuinely dereferenced record still gets deleted when the store reads fine. I verified it fails against the pre-guard code and passes with yours.

steipete and others added 2 commits August 5, 2026 04:39
The exact case the review called out: a real seeded database loses its
session_nodes table, the global sweep runs, and the record plus its
original bytes must survive. A control case keeps the healthy path
honest: a dereferenced record still gets deleted when the store reads
fine. Fails against the pre-guard code, passes with it.
@steipete
steipete force-pushed the fix/media-sweep-managed-outgoing branch from 03a3ec1 to 2c66ffb Compare August 5, 2026 11:40
@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Converged exact head 2c66ffbacc56ff596c46dbff5ce6066c0c4106b9 resolves the three direct late blockers coherently: every configured/discovered candidate is availability-validated, exact-row validity precedes fallback acceptance, explicit-state reads stay within the requested state, and replacement cleanup activation defers in the background until prior-generation drains settle without blocking gateway readiness. Focused regressions total 381 passed/4 skipped, build/deadcode and source-blind runtime/shutdown proof pass, and the final branch-level P1 autoreview is clean. The frozen baseline is intentional; unrelated later main movement will not be chased.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 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: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Final exact head 2f7699dccfac436e1a81b7ed3600883d1069740a preserves the converged retention/lifecycle behavior while mechanically extracting availability probes from oversized owners to satisfy lint. Exact-head focused proof (341 passed/4 skipped), build/deadcode, source-blind runtime/shutdown evidence, and the final integrated branch-level P1 autoreview are clean. The ordinary session accessor remains unchanged from origin/main; managed retention alone uses the focused fail-closed probe. Frozen-baseline policy remains in effect.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 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: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Maintainer decision: accept the corrected retention boundary. attachments.ttlHours continues to govern general staged media, while SQLite/transcript-aware managed retention is the sole authority for media/outgoing. The old full-tree behavior is rejected because it deterministically deletes durable chat-history bytes and migration-barrier metadata without ownership evidence.

The remaining optional rebase/rank-up move is intentionally skipped under the frozen-baseline policy: exact head 2f7699dccfac436e1a81b7ed3600883d1069740a is mergeable, exact-head CI is green, source-blind proof is current, and the exact-head ClawSweeper review has no actionable finding. Later unrelated movement on main does not justify repeating the proof cycle.

@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

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

Labels

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. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XL 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.

[Bug]: attachments.ttlHours sweeps media/outgoing, deleting chat-history managed media and lifting the managed-image migration barrier

2 participants