Repository navigation
perf(storage): bound retained database and worker data - #864
Merged
Merged
Conversation
Compact duplicate event text without losing provider metadata, bound sync replay and update caches, and clean expired thread history and unreferenced storage with durable worker cleanup. Fixes: #27
nixuuu
enabled auto-merge (squash)
November 16, 2026 08:36
nixuuu
added a commit
that referenced
this pull request
Nov 17, 2026
## Change A disconnected thread could repeatedly fail to resume with `Unknown/watch_failed` while **Load from scratch** restored it. A snapshot from another reader can leave several pending revisions of the same large item in the replay range. Saving those revisions in a single upsert violated PostgreSQL's one-update-per-row rule and rolled back every resume attempt. Keep the latest revision per entity when saving current content pointers, including inline replacements and removals, and prevent older revisions from overwriting newer pointers. Replay still delivers every sequence record. After two transient retries, repeated untyped gateway failures now try a fresh window, then a smaller window, before stopping with recovery actions. Visible messages remain available during recovery; ordinary transport drops retain automatic retries. The regression reproduces the original failure over WorkerLink and gRPC, then verifies replay catches up without replacing the snapshot. A separate gRPC-to-SSE regression verifies automatic recovery with a fresh window. Updated the transcript and UI API documentation. ## Verification - `check:tmp`: 27 passing tests across thread sequence content replay, replication retention, watch failures, and watch liveness; no temporary files left behind. - Domain and integration package typechecks passed. - Edited-file lint and formatting passed; `git diff --check` passed. - Full repository checks and builds remain with CI. - Copy audit: not applicable; no user-facing text changed. Fixes: #864 Fixes: #871
nixuuu
added a commit
that referenced
this pull request
Nov 20, 2026
## Changes - Expire old, unpublished events in the contiguous replication prefix while honoring active leases and the 10,000-record replay window. Expired clients can recover from source history. - Deduplicate exact transcript payloads, including tool JSON and diffs. Preserve full-content replay and reuse the existing content reference when a large preview needs further trimming. - Sweep the worker's preview cache hourly and at startup. Keep files referenced by pending journal events or in-flight writes. - Cap Electron's HTTP disk cache at 64 MiB. Fix a packaged Desktop regression where an origin captured by the bundled adapter caused valid forms to return HTTP 403 in Local or Remote mode. Foreign origins still receive HTTP 403. - Recover Codex turns from native archived and Zstandard-compressed rollouts. Automatic compression remains deferred while import and CLI rollback support are incomplete. The PostgreSQL 17 fixture with 600 items used 21.74 MiB across the three measured relations, down from 26.08 MiB (16.6%). An isolated Electron run retained 60 MiB after receiving 152 MiB of cacheable data. Both measurements are from test fixtures. ## Verification - Ran 460 non-live integration and focused test files on isolated databases. The first run had 2,880 passes, 12 skips and 13 failures. All 13 failing cases passed on focused reruns after fixture isolation and link-readiness fixes or when rerun without the parallel load. - Reran 34 tests for first and subsequent prompts, file and image delivery to Codex, Claude and Grok stand-ins, linked attachment reads, and client continuity. - In a real browser against the test stack, created a thread with a prompt, TXT and PNG, verified the worker received both files, and reopened the conversation. Also verified a follow-up with an attachment and opened the text and image previews. - Built the Linux x64 Desktop bundle. All five packaged-runtime tests and the Electron shell smoke passed. - Targeted typechecks, lint and formatting passed. GitHub CI will run the repository-wide gates for this revision. The mobile Connect transport and history tests ran in the integration suite. The changed form-origin handling and HTTP disk cache are Electron-specific. Native iOS and Android UI and live provider calls were outside this local run. No user-facing copy changed. Refs: #864 Refs: #1051
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.
Change
Streaming events currently create unnecessary notice invalidations and retain duplicate text, sync revisions, and unused files indefinitely. This change reduces write amplification and adds bounded, resumable cleanup for both existing and newly written data.
storage inspectand explicitstorage reclaim --offline --table .... Ordinary maintenance frees PostgreSQL space for reuse; physical disk reclamation is never automatic.Migrations 0153–0157 are additive. Historical journal rows receive a fresh one-hour protection period. Existing inline image history remains until thread purge, and legacy retention-exempt blobs remain protected. Cleanup starts automatically with the gateway and proceeds in bounded transactions.
Fixes: #27
Verification
Selective local verification passed during implementation:
Copy audit (§8): PASS. Delete confirmation previously mentioned immediate deletion and brief Undo; it now states the 31-day history cleanup and preserves the workspace-file warning. Settings explain the fixed recovery window. Browser inspection passed in light/dark themes at desktop and phone widths with short, typical, and 200-character names. Native mobile was not run.
Rebased onto current
dev; only two documentation status paragraphs required conflict resolution, preserving both descriptions. Full repository checks/builds and generated-code verification are left to required CI. No production data or files were modified, and offline reclamation was not run.CI follow-up: resolved lint spacing and size limits by extracting command replay policy and Welcome construction. Scoped lint/format and gateway/worker typechecks pass; WorkerLink and worker cleanup regression tests pass (22 tests, 67 assertions; clean
check:tmp).Retention test synchronization: wait for the initial turn to be durably completed before using its history; initial
idlecan precede worker admission. Deleted-retention suite passes (five tests, 23 assertions; cleancheck:tmp). On the preceding revision all CI checks except that test shard and its aggregate gate passed.