Repository navigation
feat(platform): let a message ref pass the retrieval gate - #3062
Merged
Merged
Conversation
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.
An email message can now pass the retrieval gate. Nothing writes such a ref yet, so no search result changes.
This is the mechanism half of #3015, the way #3011 preceded #3012.
Why
Every corpus ref today resolves through
fileMetadata.by_storageId, and the gate skips a ref whose row is missing. A message is not a blob and has no such row, so a message hit is denied before reaching any access branch.That is why this ships first. Index bodies without it and the rows are admitted by SQL, then silently dropped.
What changed
msg:<messageId>is a corpus ref for a message, in a newlib/knowledge/message-ref.ts.The gate gains one branch, decided before the blob lookup. A message is retrievable only when the caller can currently read the conversation it arrived on —
conversationAssignmentAllows, the same predicate emailed attachments use, so reassigning a conversation moves its messages with it. Scope exclusions and the folder filter are honoured exactly as the attachment branch honours them.The branch keys on the
msg:prefix rather than on a successful parse. A malformed ref is denied there instead of falling through to the blob path, whereparseBlobRefwould coerce it into a Convex storage id rather than reject it. A test pins that.One branch covers both readers:
knowledge/search.tsfilters hits through this gate, andknowledge/fetch.tsreturns null unless the ref comes back retrievable.Risk
msg:is deliberately not part ofBlobRef.parseBlobReftreats any non-s3:string as a storage id, and six modules call it orconvexStorageId, includingblob_delete.tsanderase_document_blobs.ts. That is safe only because every one of them reads its ref from a Convex row —documents.fileId,documents.historyFiles,fileMetadata.storageId— and a message has none of those.eraseDocumentBlobswas checked specifically: it walksdoc.fileIdanddoc.historyFiles, never a corpus ref.If a message ever gains a
documentsorfileMetadatarow, that reasoning expires andmsg:must joinParsedBlobRefso the compiler forces all six to handle it. The module says so.Tests
Thirteen cases in a new suite: the individual assignee, a member of the assigned team, another team's mail, unassigned mail, an admin, a cross-org message, a cross-org conversation, a missing message, a missing conversation, a ref that is not a message id, a bare prefix, a scope excluding conversations, a folder-scoped search, and an absent caller.
The suite's ctx has no
fileMetadataat all and throws if queried, so every passing case also proves the decision happened before the blob lookup.Eight deliberate breakages were introduced one at a time to confirm each is caught: always-allow, both org checks, the scope exclusion, the folder filter, the absent caller, the id check, and the malformed prefix. All eight were caught. The malformed-prefix case found a real flaw during development — the branch originally keyed on a successful parse, so a bare
msg:fell through to the blob path.Scope
Nothing writes a
msg:ref. Bodies are not indexed, and no erasure cascade exists for them; both belong to #3015's second half, which must ship the cascade in the same change so message text is not left behind after an erasure request.No SQL or DDL change. The corpus pre-filter already admits any row carrying a conversation, deliberately, because enumerating a caller's readable conversations is unbounded under assignment privacy.
Gate: typecheck,
oxlint --type-aware, oxfmt, knip, SAST 0 findings, platform suite 75,716 passing.