Repository navigation
feat(platform): decide retrievability for an emailed attachment - #3220
Merged
Merged
Conversation
Step 1 of #3121, and the one that has to ship first. The corpus write already carries `conversation_id` (`core/knowledge/indexing.ts`), but the retrievability gate never read it: the SELECT fetched `thread_id` only, and `decideRetrievable` branched on a document or a thread. A conversation-scoped row would therefore fall through — and every scope column NULL reads as an ORG-WIDE hub row in the SQL pre-filter, which is exactly the posture #3011 was written to prevent. Nothing indexes these files yet, so no such row exists and the fallback is unreachable today. It becomes reachable the moment queue-on-bind lands, which is why the gate goes in before it rather than with it. ## The decision `decideRetrievable` gains a conversation branch, and it is ASSIGNMENT privacy, not org scope. Conversations are scoped more narrowly than anything else the platform retrieves: an unassigned inbox row is admin-triage only. So the caller supplies the conversations it may read and this file never derives them — a second copy of that rule is how a reader ends up publishing an inbox. `allowedConversationIds` resolves them through `conversationAssignmentAllows`, the one definition, and is bounded by the CANDIDATES rather than the caller: an admin may read every conversation, so enumerating theirs would ship thousands of ids into every dispatch. One read of the candidates' assignment stamps, then the shared predicate. Without a caller identity nothing is allowed, so an emailed attachment stays denied on any path that does not supply one. ## Tests | Mutation | Went red | | --- | --- | | admit any conversation-bound row | `denies one whose conversation the caller may not read`, `denies when the caller has no conversations at all`, `is not widened by team or project scope` | | ignore the conversation-scoped opt-out | `honours the conversation-scoped opt-out` | | let a folder filter reach an attachment | `never surfaces an attachment under a folder filter` | `is not widened by team or project scope` is the one worth having: a member of every team and project still sees only their own conversations. Corrects two docstrings that claimed the conversation branch denies, and the MIGRATION.md `PENDING` note, which now names what actually remains — `msg:` refs and queue-on-bind.
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.
Step 1 of #3121 — the piece the issue says must ship first.
What was missing
The corpus write already carries
conversation_id(
core/knowledge/indexing.tsstamps it, and its comment says why: "to keepthe row out of the hub clause"). The retrievability gate never read it. The
SELECT fetched
thread_idonly, anddecideRetrievablebranched on adocument or a thread.
So a conversation-scoped row fell through — and every scope column NULL reads
as an org-wide hub row in the SQL pre-filter. That is the posture #3011 was
written to prevent.
Nothing indexes these files yet, so no such row exists and the fallback is
unreachable today. It becomes reachable the moment queue-on-bind lands, which
is why the gate goes in before it rather than with it.
The decision is assignment privacy, not org scope
Conversations are scoped more narrowly than anything else the platform
retrieves: an unassigned inbox row is admin-triage only, not org-readable. So
the caller supplies the conversations it may read and
decideRetrievableneverderives them. A second copy of that rule is how a reader ends up subtly wider
than the rule it mirrors, and the failure mode is publishing an entire inbox
into a chat answer.
allowedConversationIdsdelegates toconversationAssignmentAllows— the onedefinition — and is bounded by the candidates, not the caller. An admin may
read every conversation, so enumerating theirs would ship thousands of ids into
every dispatch's scope. One read of the candidates' assignment stamps, then the
shared predicate per row. The team lookup that predicate defers costs nothing
here, because the document branches have already resolved the caller's teams.
No caller identity means nothing is allowed, so an emailed attachment stays
denied on any path that doesn't supply one.
Verification
denies one whose conversation the caller may not read,denies when the caller has no conversations at all,is not widened by team or project scopehonours the conversation-scoped opt-outnever surfaces an attachment under a folder filteris not widened by team or project scopeis the one worth having: a member ofevery team and every project still sees only their own conversations. The
document branches' scope says nothing about an inbox row.
Also
Two docstrings in
knowledge/service.tsstill claimed the conversation branchreturns deny; both corrected. The
MIGRATION.mdPENDINGnote now names whatactually remains —
msg:refs and queue-on-bind — rather than the branch thatjust landed. Verified additive: +211 characters, main's text intact.
Gate
typecheck0 errors,oxlint --type-awareclean,oxfmt --checkclean,knowledge suites 278 passed (18 files).
What's left on #3121
Step 2 (queue on bind, in the bind's own transaction) and step 3 (
msg:refs)are unblocked by this and belong in their own changes — step 2 is where #2995's
lesson about splitting that promise across a boundary applies.