Skip to content

fix(platform): clear stale mail stamps in the nightly stamp pass - #3668

Merged
yannickmonney merged 1 commit into
mainfrom
fix/clear-stale-mail-attachment-stamps
Sep 28, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
fix/clear-stale-mail-attachment-stamps

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

An attachment filed into a document can retain its conversation stamp without a re-index, hiding it from document retrieval. The scope reconcile also counted stamp removal as a failed scope sync. The nightly attachment pass now owns stamps in both directions, and reports cleared stamps separately from scope drift.

The second pass walks stamped corpus rows by ref, excluding email bodies, and checks backing attachments through the same tenant-scoped query as the first pass. It uses the existing corpus-only release: dead rows are removed; rows kept by another source lose their stale stamp. Failed releases retain the stamp. The clear compares the stamp originally read, leaves a different concurrent stamp alone, and preserves updated_at. The scope pass now changes scope columns only.

The release regression now models a dead blob, so accidentally wiring full release would delete bytes and fail the test. The developer migration note and manual automation register describe the new ownership.

Validation:

  • Independent related server suite: 1,251/1,251 tests across 98 files.
  • Independent real PostgreSQL and fresh MinIO: 64/64 checks across seven selected lanes (files, provider credentials, knowledge, scope reconciliation, corpus purge consistency, inbound bodies and emailed attachments). Includes document filing/unfiling, idempotent clearing, orphan removal, access controls and preserved attachment bytes. This also passes the file-deletion check that failed with the earlier moto fixture.
  • Independent mutation: replacing corpus-only release with full release fails the dead-attachment regression on an unexpected object deletion. Original source restored and worktree verified clean.
  • Platform type checking, scoped type-aware/type-check lint, manual guard and SAST (162 rules, six files, zero findings) pass. Current-head CI remains required before merge.
  • The original implementation run also killed 13 mutations and observed the two new integration assertions fail against the preceding source.

This is a filtered integration run, not full backend coverage. The existing case where a dead conversation attachment shares its ref with a separate non-mail file row still retains its stamp; this PR does not alter that multi-holder behavior. No schema migration or production mailbox/model run is involved.

The stamp pass only stamped. A row that stopped being an emailed
attachment kept its conversation stamp, and the corpus pre-filter keeps
every stamped row out of every document door. The scope pass cleared
such a stamp from an active document's ref, but it counted the clear as
scope drift, which the reconcile logs as a failed per-edit sync.

The stamp pass now owns the stamp in both directions. A second walk
reads the corpus rows that carry a stamp, email bodies aside, and checks
them against the attachment rows with the same statement the first walk
reads. Every ref no attachment backs goes to the corpus-only release. A
ref nothing keeps in the corpus is released; one something keeps loses
its stamp, guarded on the stamp the walk read. A dead ref's stamp is
never cleared, so it cannot become a clonable hub row.

The scope pass is scope-only again, so its drift line stays true, and
runCorpusReconcile reports cleared stamps on a line of their own.

The reconcile test's liveness fake now answers a dead blob, so wiring
the full release, which deletes bytes, fails it.
@yannickmonney
yannickmonney merged commit 480ee6a into main Sep 28, 2026
50 checks passed
@yannickmonney
yannickmonney deleted the fix/clear-stale-mail-attachment-stamps branch September 28, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant