feat: local prune of synced sessions - #333
Open
upsetbit wants to merge 6 commits into
Open
Conversation
Migration 0011 adds pushed_at/pushed_hash/remote_uri to sync_state and pruned_at to sessions. Session gains PrunedAt; the session upsert clears pruned_at so a re-import is an explicit un-prune. New store APIs cover push-state recording, prune candidate selection, the guarded prune flip, and the advisory count. The reconcile manifest carries prune/push state and the denoise sweep skips pruned rows. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012b7bHAgVdeT5x7mhNu5suQ
Every successful or idempotent push now records the server-confirmed hash and raw_uri in sync_state. Reconcile excludes pruned rows from the catch-up work set (even under --overwrite, since there is no raw file to read) and backfills pushed state for sessions the server manifest already holds, covering pushes made before these columns existed. pushSession short-circuits pruned sessions with a skipped outcome. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012b7bHAgVdeT5x7mhNu5suQ
prune deletes the local raw copies of sessions inactive beyond --older-than (default 30d) whose push the server re-confirms via the manifest at prune time. The row flips to pruned before the file is removed so a failed delete can revert; empty YYYY/MM shard dirs are swept afterwards. Supports --dry-run, --limit, and NDJSON output via the global --json flag. Requires a logged-in server; offline prune is an error before anything is deleted. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012b7bHAgVdeT5x7mhNu5suQ
After the denoise pass, sync counts sessions pushed more than a week ago and inactive beyond 30 days, then advertises the total and the reclaimable bytes. Plain and TTY summaries print an advisory-only Prune line when the count is positive; the --json summary always carries prunable_sessions and prunable_bytes for a stable shape. The query is local, so the advisory also works offline. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012b7bHAgVdeT5x7mhNu5suQ
show --raw and the non-TTY pipe default reroute pruned sessions to the existing GetRaw streaming path instead of opening the deleted local file; a missing login yields an actionable error before any RPC. The rendered metadata line annotates a pruned raw path, and the timeline --json payload carries pruned_at. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012b7bHAgVdeT5x7mhNu5suQ
INTENT drops the blanket veto on retention: pruning exists but stays explicit and server-verified, and the pull-down exclusion now names the one read-back (streaming a pruned raw via GetRaw). Concepts gains the pruned lifecycle state; store.md documents migration 0011, the push state columns, and the new store APIs; cli.md, usage.md, README, and the rendering contract cover the prune command, the sync Prune advisory line, and show's remote raw streaming for pruned sessions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012b7bHAgVdeT5x7mhNu5suQ
upsetbit
force-pushed
the
feat/local-prune
branch
from
August 31, 2026 19:23
7a195a1 to
91054e3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
prosa prune: sessions already pushed to the server and inactive beyond a window (default 30d) get their local raw copy deleted, while the store keeps pointing at the remote location. Pruned sessions stay fully listed, searchable, and viewable offline — turns, FTS, usage, tools, and analytics all live instore.dband are untouched. Only raw reads change:prosa show --raw(and the non-TTY pipe default) stream a pruned session's raw from the server via the existingGetRawRPC.Nothing is ever pruned automatically.
prosa syncnow prints an advisory-only summary line (count + reclaimable disk) when prunable sessions exist; the--jsonsummary carriesprunable_sessions/prunable_bytes.How
0011_push_prune:sync_stategainspushed_at/pushed_hash/remote_uri(transport state — until now the CLI had no local record that a session reached the server);sessionsgainspruned_at.pruned_atbefore the file is removed (a failed delete reverts), so sync can never chase a missing raw.--overwriteand after futureProjectionVersionbumps); the denoise sweep skips them;pushSessionshort-circuits them. A re-import of a changed source file rewrites the raw and un-prunes the row atomically.PushResponse.raw_uriandGetRawalready existed; the CLI just starts using them.Scope note
This amends
INTENT.md§Out of scope: retention stays never automatic, but explicit, server-verified pruning now exists; the push-only posture is unchanged for sync (a pruned raw streams on read but never re-enters the local store).AGENTS.md,docs/concepts.md,docs/architecture/{store,cli}.md,docs/usage.md, and the rendering contract are updated to match.Upgrade note
Migration 0011 means read-only commands (
prosa,show,search,analytics) return the usualErrStoreNeedsMigrationguidance after upgrading until the first write command (prosa sync) runs — same behavior as every prior migration.Verification
just cigreen (fmt, vet, lint, race tests, gen-check, tidy-check).prosa-server: sync pushes, prune deletes and records the reals3://URIs, list/search/show stay local,show --rawstreams byte-identical raw from the server, and a follow-up sync converges with pruned rows excluded.🤖 Generated with Claude Code