Skip to content

feat(platform): give an emailed attachment its mail's context - #3014

Merged
Israeltheminer merged 2 commits into
mainfrom
feat/attachment-mail-context
Aug 21, 2026
Merged

Israeltheminer merged 2 commits into
mainfrom
feat/attachment-mail-context

Conversation

@Israeltheminer

Copy link
Copy Markdown
Contributor

An emailed attachment can now be found by the mail it arrived on, not only by its filename and contents.

Why

A CV named for its author says nothing about the role it was sent for. Its chunk header was the filename alone, and the covering email's subject — which usually names the role — reached no index at all. So "what CVs came in for the sales position" could only match a document whose own text happened to say "sales".

Found while verifying #3011 and #3012 on a live deployment.

What changed

  • The chunk header carries filename, the conversation's subject, and the correspondent. It is prepended to every chunk, so it feeds both the keyword leg and the embedding.
  • indexDocument gains an optional title, distinct from filename. The filename is still what the corpus row stores and the UI shows; the title is only what the header announces. A Document Hub file passes none and its header is unchanged.
  • Absent context is omitted, not invented. A mail with neither subject nor correspondent keeps a bare filename header.
  • (no subject) is a stored subject rather than a render-time fallback, so it is excluded — indexing it would put the placeholder into the corpus as prose. It was a duplicated literal in three ingest files and is now NO_SUBJECT in ingest/constants.ts.

Risk

The correspondent comes from the conversation's linked contact, and a contact id is a reference rather than a permission. The read checks the contact's own organization, so a foreign contact's name cannot reach this org's header. A mutation removing that check is covered.

A dangling conversation costs only the context, never the binding: scope depends on the conversation id, and the subject and correspondent are enrichment.

Tests

New coverage: the header text for subject-plus-correspondent, subject-only, and neither; that a Document Hub file gets no title override; that the title reaches the written chunk rather than merely being passed; that the placeholder subject is excluded; and that a cross-org contact supplies no name.

Nine mutations, all red. Two were survivors first: nothing asserted the title reached the header (the ingest tests mocked indexDocument), and nothing asserted the cross-org contact check.

Scope

Does not index message bodies — that needs a new corpus ref class and a gate branch, since every ref currently resolves through fileMetadata and a message has no such row. It also needs an erasure cascade. Both follow separately.

This would not have helped the attachment that prompted it, which arrived with no subject and no body. It fixes the normal case.

Gate: typecheck, oxlint --type-aware, oxfmt, SAST 0 findings, platform 75,241 tests.

Israeltheminer and others added 2 commits August 19, 2026 19:17
A CV named for its author says nothing about the role it was sent for. Its
chunk header was the filename alone, so it could only be found by the author's
name or by words inside the document — and a covering email's subject, which
usually names the role, reached no index at all.

The header now carries the mail: filename, the conversation's subject, and the
correspondent. It is prepended to every chunk, so it feeds both the keyword leg
and the embedding, widening retrieval on both.

`indexDocument` gains an optional `title` distinct from `filename`. The
filename is still what the corpus row stores and the UI shows; the title is
only what the header announces. A Document Hub file passes none, so its header
is unchanged.

Absent context is omitted rather than invented. A mail with neither subject nor
correspondent keeps a bare filename header, which is the case that started
this: an attachment arrived with no subject and no body, and no header text
could have connected it to anything.

`(no subject)` is a STORED subject, not a render-time fallback, so indexing it
would put the placeholder into the corpus as prose. It was duplicated as a
literal in three ingest files; it is now `NO_SUBJECT` in `ingest/constants.ts`
and those three read it from there.
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