Repository navigation
feat(storage): backfill unfetched attachment acquisition from durable raw evidence - #3590
Conversation
|
Warning Review limit reached
Next review available in: 20 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
… raw evidence Problem: 7,376 of 9,289 attachments (79%, polylogue-pfdf/polylogue-7r6u) sit at acquisition_status='unfetched'. PR #2469 and 60d93b6 fixed real attachment-byte acquisition going forward (ParsedAttachment.inline_bytes propagation), but the historical backlog was never backfilled: an attachment ingested before a parser fix landed still has no blob_hash, even though its owning session's raw payload is durable in source.db and today's parser may already extract it. Separately, 'unfetched' was the only acquisition_status a genuinely gone attachment (e.g. ChatGPT Code Interpreter sandbox output, which chatgpt.py's own comments document as never carrying bytes) could ever reach -- indistinguishable from "not yet tried". What changed: new polylogue/storage/attachment_reacquisition.py, following the same read-only-classifier + operator-gated-actuator architecture as attachment_relink.py (ref-linkage backfill) and blob_integrity.py's raw actuators: - plan_attachment_reacquisition() classifies every unfetched attachment into reacquirable (re-parsing its still-durable raw_sessions payload with today's parser, via the real ingest_record entry point, reproduces its content-identity hash with inline bytes), unrecoverable (a static source_url='sandbox:...' signature -- no reparse needed, matches chatgpt.py's own documented semantics), or undetermined (left unfetched, honestly not-yet -- most commonly Drive/OAuth attachments needing a live authenticated fetch this module never performs, see polylogue-ck5v). - apply_attachment_reacquisition() acts on the safe verdicts only: dry-run by default; --apply requires an immutable JSONL manifest of every row acted on plus a verified backup manifest for the index tier (the same gate durable-tier migrations use). Reacquired bytes are published through the same content-addressed blob store and ArchiveBlobPublisher every other acquisition path uses; the schema's existing but previously-unused acquisition_status='unavailable' value is what marks unrecoverable attachments distinctly from 'unfetched', with no schema change needed. - Two devtools commands wire this into the control plane: `devtools workspace attachment-reacquisition` (report) and `...-apply` (actuator), mirroring the raw-live-source-reconciliation report/apply pair. Never touched: acquisition for Drive-hosted/OAuth attachments needing a live network fetch (polylogue-ck5v is the separate, larger follow-on for that); this module performs zero network I/O. Verification: `devtools test tests/unit/storage/test_attachment_reacquisition.py` (7 passed) exercises real ingest_record parsing against a real source.db/ blob store and real index.db mutation -- proves a historically-unfetched attachment with recoverable extracted_content bytes is reacquired, a sandbox-output attachment is marked unavailable without any reparse, a genuinely unmatched ("ghost") attachment stays undetermined/unfetched, and --apply refuses without a manifest path or a verified backup manifest. `devtools verify --quick` clean (added a degrade-loudly log call and a hash-boundary-census registry entry for the new hashlib.sha256 call site). Ran the new read-only report against the live production archive (/realm/db/polylogue, read-only) as a real-world sanity check. Ref polylogue-pfdf, polylogue-7r6u Co-Authored-By: Claude <[email protected]>
Ref polylogue-pfdf, polylogue-7r6u Co-Authored-By: Claude <[email protected]>
a08c719 to
b73deb3
Compare
Summary
Adds a read-only classifier plus an operator-gated actuator that backfills historically-unfetched
attachmentsrows where the source payload still contains the bytes, and marks the genuinely unrecoverable ones distinctly instead of leaving them ambiguously'unfetched'forever.Problem
7,376 of 9,289 attachments (79%, polylogue-pfdf / polylogue-7r6u) sit at
acquisition_status='unfetched'. PR #2469 and commit 60d93b6 ("acquire Claude extracted payloads") fixed real attachment-byte acquisition going forward, but the historical backlog was never backfilled: an attachment ingested before a parser fix landed still has noblob_hash, even though its owning session's raw payload is durable insource.dband today's parser may already extract it (ParsedAttachment.inline_bytes). Separately,'unfetched'was the onlyacquisition_statusa genuinely gone attachment could ever reach (e.g. ChatGPT Code Interpreter sandbox output —chatgpt.py's own comments document these as never carrying bytes at all) — indistinguishable from "not yet tried".Solution
polylogue/storage/attachment_reacquisition.pyfollows the same read-only-classifier + operator-gated-actuator architecture already established byattachment_relink.py(ref-linkage backfill) andblob_integrity.py's raw-side actuators:plan_attachment_reacquisition()classifies every unfetched attachment into:raw_sessionspayload with today's parser (via the realingest_recordentry point) reproduces its content-identity hash (write.py:_attachment_id, independent of session/message) with inline bytes.source_url='sandbox:...'signature — no reparse needed, matcheschatgpt.py's own documented "nothing local to fetch" semantics for Code Interpreter output.unfetched— most commonly Drive/OAuth attachments that would need a live authenticated fetch (the separate, larger polylogue-ck5v follow-on); this module performs zero network I/O and never guesses.apply_attachment_reacquisition()acts on the safe verdicts only. Dry-run by default;--applyrequires an immutable JSONL manifest of every row acted on plus a verified backup manifest for theindextier (the same gate durable-tier migrations use,validate_migration_backup_manifest). Reacquired bytes are published through the same content-addressed blob store/ArchiveBlobPublisherevery other acquisition path uses. The schema's existing but previously-unusedacquisition_status='unavailable'value is what marks unrecoverable attachments distinctly — no schema change needed.devtools workspace attachment-reacquisition(report) and...-apply(actuator), mirroring theraw-live-source-reconciliationreport/apply pair.Never attempted: acquisition for Drive-hosted/OAuth attachments needing a live network fetch — that is polylogue-ck5v's scope, not this bead's.
Verification
devtools test tests/unit/storage/test_attachment_reacquisition.py— 7 passed. Exercises realingest_recordparsing against a realsource.db/blob store and realindex.dbmutation: proves a historically-unfetched attachment with recoverableextracted_contentbytes is reacquired, a sandbox-output attachment is markedunavailablewith zero reparse, a genuinely unmatched ("ghost") attachment stays undetermined/unfetched, and--applyrefuses without a manifest path or a verified backup manifest.devtools verify --quickclean (added adegrade-loudlylog call and ahash-boundary-censusregistry entry for the newhashlib.sha256call site)./realm/db/polylogue, read-only, no mutation) as a real-world sanity check; full-corpus timing is dominated by real per-row parse cost on large session payloads (some multi-MB/GB Claude Code JSONL files), so a bounded--raw-row-limitis the intended operator dial for a first-pass classification before deciding on--applyscope.Ref polylogue-pfdf, polylogue-7r6u