Repository navigation
fix(gateway): derive attachment visibility from current history - #138377
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 4, 2026, 2:46 PM ET / 18:46 UTC. ClawSweeper reviewWhat this changesThe PR removes the managed-attachment cache and derives download visibility from the current canonical session history, with SQLite/archive regression coverage. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 4 items remain Keep this PR open: it fixes the stale-visibility bug still present on current main, but it leaves the prior P2 availability concern unresolved by materializing all visible history for every media or artifact request. Priority: P1 Review scores
Verification
How this fits togetherGateway media routes consult session history to decide whether a managed outgoing attachment may still be downloaded. HTTP media requests and artifact-download RPCs both depend on that membership decision before returning bytes or a ticketed URL. flowchart LR
A[HTTP or artifact request] --> B[Managed attachment record]
B --> C[Session history reader]
C --> D[Attachment membership decision]
D --> E[Download URL or not found]
C --> F[Reset archive fallback]
F --> D
Decision needed
Why: The cache removal repairs an access bug, but the remaining request-path cost is explicit in source and the prior P2 finding; choosing immediate correctness versus the bounded lookup is a merge-risk tradeoff. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource -158, Tests +159. Total +1 across 6 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Use a generation-consistent, exact current-history attachment-membership lookup that falls back to reset archives only when active display history is empty, rather than retaining either archive-stat cache authority or a per-request full scan. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible: prime reset-archive membership, replace it with nonempty active SQLite history that omits the attachment, then request the same media; current main's stat-keyed cache can still return it. Is this the best way to solve the issue? No—the cache removal correctly repairs stale authorization, but a generation-consistent exact current-history membership read is the more maintainable solution than scanning every visible message on every request. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 26f87a37009b. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
The remaining scan cost is real: removing cross-request archive-stat reuse means repeated requests against reset-archive history reread that history. This PR makes no latency-improvement claim. The full active-SQLite read already exists in the predecessor; the removed filesystem-stat cache cannot establish current SQLite visibility and can retain access after the active history changes. The replacement keeps the canonical reader and cleanup-pass reuse. See the unchanged full-read boundary and cache removal and current membership owner. The suggested by-ID reader is not a drop-in replacement: it permits archive fallback after any missing ID, whereas attachment membership must respect nonempty active history. A separate count also needs a consistent generation. The current corruption cases preserve rejection and files when selected or unrelated visible history is malformed; narrowing the lookup needs an explicit canonical validation contract, rather than silently changing that behavior. This does not mean every unrelated JSON row must be parsed forever. We are retaining this bounded access-correctness repair and deferring both exact-lookup rank-up moves to the next measured follow-up: canonical exact attachment membership with consistent projection generation, archive fallback only for empty active display history, and explicit corruption/cleanup safety. That follow-up is owned and prioritized. The retained proof for this repair includes 187 focused cases, 96 overlap cases, six final regressions, and the real isolated Linux HTTP/WebSocket A/B: all four previously accessible URLs return 404 after live dereference, with authorization, claims, restoration and cleanup controls. The mechanical main integration leaves all six feature files byte-identical; fresh three-pass P2 review is clean. Exact-head CI is still pending, and no current-main live execution or performance gain is claimed. |
|
The latest review repeats the same availability trade-off. I am accepting the current request cost for this access-correctness repair and taking the bounded, generation-consistent membership optimization as the next measured follow-up. The prior source-bound disposition remains applicable: #138377 (comment). One cost clarification: the canonical archive reader already caches its validated index by file identity. Warm archive requests repeat message projection and attachment-reference collection; they do not necessarily rescan or parse the archive. Active SQLite history still materializes its visible range. The follow-up must preserve current visibility, empty-history-only archive fallback, consistent snapshots, and corruption/cleanup safety. No performance improvement is claimed for this PR. Exact-head CI is now green on |
|
Merged via squash.
|
What Problem This Solves
A managed attachment could remain downloadable after live SQLite history stopped referencing it when an unchanged reset archive had populated the attachment cache. Archive path, size and mtime were incorrectly treated as authority for current visibility.
Why This Change Was Made
Remove the process cache and its obsolete artifact discovery/stat path, including the unused resolver and barrel export. Each request now selects canonical full history. Cleanup keeps its existing per-pass reuse, ownership, claims and deletion behavior. Selected and unrelated malformed visible rows retain the existing full-history failure and record-retention behavior.
Production decreases by 158 lines; tests increase by 159. No schema, configuration, indexing, concurrency or retention-policy change.
User Impact
Existing ticket and bearer downloads respect current session history, including archive-to-live replacement and inactive branches. Full-history materialization remains a separate optimization; this correctness repair does not claim a general latency improvement.
Evidence
Execution used public base92daad5 with fs-safe0.7.0. Read-only qualification at a66263c found unchanged patch preimages and no relevant owner/dependency conflict; it is not a runtime test of the newer main or fs-safe0.7.1. No production workload or whole-server smoothness claim.