Repository navigation
fix(platform): deny a corpus ref bound to neither document nor thread - #3192
Merged
Merged
Conversation
The retrieval gate admitted a file row with no document and no thread to any member of the organization. That shape is not obscure: the indexer stamps corpus scope only from a bound document, so such a row carries no project and no team, and the SQL half of the two-gate design reads exactly that as an org-wide hub row. The SQL half fails open by design and names this function as the decider, so both gates passed the ref. 0.4 denied it (documentId === undefined → continue). The previous posture was deliberate and documented, on the grounds that video-link transcripts index without a document and a blanket quarantine would dark that lane. The premise does not hold: a transcript row carries thread_id, so it admits through the thread branch. A welcome-page paste starts thread-less only because no thread exists yet, and the first send stamps it via bindStorageIdsToThread, which updates exactly the rows with no document and no thread. Before that send no turn can be scoped to it. So the assertion that locked in the old behaviour is replaced rather than deleted, and a new case proves the video-link lane still admits once its thread is stamped. Refs #3142.
Israeltheminer
force-pushed
the
fix/deny-unbound-corpus-ref-v2
branch
from
September 4, 2026 08:53
5243478 to
602d986
Compare
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.
A corpus row bound to neither a document nor a thread was retrievable by any
member of the organization.
decideRetrievable's unbound-file loop ended inreturn true, so a row that passed no scope check at all was admitted.Rebase of #3177 onto current main; no content change.
The premise it was defended on is wrong
The module docstring called this "the 0.4 same-org posture DELIBERATELY",
citing video-link transcripts as the lane that needs it. That lane does not
need it:
bindStorageIdsToThreadinbackend/domains/chat/shim.tsstampsthread_idat send time (WHERE document_id IS NULL AND thread_id IS NULL),so those rows arrive at the gate thread-bound and are served by the branch
directly above — the one that checks
access.threadIds.So nothing reaches the unbound arm by design. What reaches it is a row whose
binding never landed, and the corpus reads an unscoped row as org-wide. That
makes
return truea fail-open default, not a same-org one. Changed tocontinue, and the docstring now says that.Tests
The suite had a test asserting the old behaviour. It is replaced, not
deleted — two assertions now pin the denial, one with an access scope and one
without, because the two arms return through different paths.
Mutation-tested: restoring
return truefails both.continue→return truedenies a live row bound to neither a document nor a thread,denies it with no access scope eitherGate
retrievable.test.ts12 passed,typecheck0 errors,oxlint --type-awareclean,
oxfmt --checkclean.