Skip to content

atlas(search): span-filter full-content payloads per sibling chunk (#12624) - #12630

Merged
dezren39 merged 1 commit into
mainfrom
felix/12624-span-filter
Nov 22, 2026
Merged

dezren39 merged 1 commit into
mainfrom
felix/12624-span-filter

Conversation

@dezren39

@dezren39 dezren39 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Closes the implementation scope of #12624 (the #12404 residual): full-content payloads (--with-message, hydration) are now filtered at span granularity. Not merging without review — the filter code is the review surface, as with #12404.

Mechanism

span_filter_payload in crates/atlas-core/src/search.rs runs at render time for every full-content payload under the non-public contexts (public-surface still withholds these payloads outright, per #12404). Every chunk of the payload's message is classified from its detail row and tested with the same grant ∩ context intersection the disclosure pass applies to candidates (DisclosureContext::permits_with_grant over chunk_classification). A chunk that fails has its text treated as a withheld span: every occurrence of that text in the message text is omitted from the served text. A chunk with no detail row fails closed, matching neighbor_map's rule. Withholding is tallied per search (SpanRecord) and recorded in the envelope notes in the #12404 idiom (disclosure: context … withheld N message span(s) …).

Two deliberate edges:

  • Unfilterable ⇒ withheld whole. A failing chunk whose text occurs nowhere in the message text (a store inconsistency) means the payload cannot be proven safe, so it is withheld entirely — message reads as null, hydrated is omitted — per design §4's rule for outputs that cannot be safely filtered, and counted in the notes as such.
  • Unattributed text rides on the served chunk's gate. Text belonging to no chunk is not a sibling chunk's text. A 300-message sample of multi-chunk messages in the publish corpus measured ~64% of message text as belonging to no chunk (the chunker is selective), so fail-closing unattributed text would gut payloads for the uniform-classification common case; it stays under the served chunk's atlas(classification): enforce disclosure-context filters at output boundaries #12404 gate. Documented in the span_filter_payload doc comment.

Withheld-span shape

Omission. No redaction-marker idiom exists anywhere in atlas or fleet-search; the codebase's withholding idiom is omission plus a count on the record (withheld candidates, withheld neighbors, withheld payloads in #12404). Spans follow it: the span's text is removed, the surroundings stand, and the envelope notes carry the count.

Seam

New SearchBackend::message_chunks enumerates a message's chunks: windowless MESSAGE_CHUNKS_SQL overrides in the local and Turso backends, a wide-window neighbors default (MESSAGE_CHUNKS_WINDOW, chunk_idx units; publish-corpus span measured 0..=1730) for wrappers and test stubs, explicit forwarding in Box<T>. The shard fan-out inherits correct routing through its own neighbors. No new dependencies.

Measurement (acceptance item 1, also recorded on #12624)

Publish corpus (atlas-publish-v2-2026-10-31.db, the Turso publish source; laptop, read-only SQL, 2026-11-22): 107,639 chunks over 71,551 messages with chunks (6,044 multi-chunk, max 1,731 chunks in one message). Every chunk carries a non-empty sensitivity (personal 99,926 / local-only 6,941 / secret-bearing 772; no shareable, no excluded_personal_life). Mixed-classification messages: 0 — per-chunk sensitivity is uniform within every message, and no message straddles any context ceiling. So there is no live leak today; this lands the guard before per-embed classification (#12408) can diverge inside a message. A companion probe (300 sampled multi-chunk messages) verified chunk texts occur verbatim in the message text, findable in chunk order, in 300/300 — the property span location relies on.

Leak evidence (venue: sandbox)

Fail-before at base f026268cb (the #12626 merge), new tests in crates/atlas-core/tests/disclosure.rs over a stub whose message mixes shareable / personal / secret-bearing / excluded chunks: 5 failed, all by leaking — the full payload, including the secret-bearing span (the vault code is 493812) and the excluded span, crossed under fleet-internal, hosted-per-user, and local-owner; the unfilterable payload was served whole. The 13 pre-existing #12404 tests passed.

Pass-after: disclosure suite 18/18 (incl. the served chunk's own text and admitted sibling spans still crossing — no over-withholding — and the excluded span withheld even for the owner while the secret-bearing span crosses); full cargo test -p atlas-core -p atlas-proto -p atlas-search green (exit 0); cargo check --workspace --all-targets clean; cargo fmt --check clean; no new clippy warnings (one collapsible-if in this diff was collapsed via a let-chain).

One stub change in the pre-existing tests: LeakBackend's m1 message text is now composed of its chunks' texts (the real corpus shape the span filter locates spans in); the #12404 test's assertions are unchanged in the public half and strengthened in the fleet half (payload present, secret span now asserted omitted, personal span asserted present).

What remains on #12624

Nothing in the issue's acceptance list: measurement recorded, leak test + chosen rule (span-level filtering) implemented and documented in search.rs, excluded spans barred under every context, suites green. Out of scope here, as it was for #12404: the shard path's tier content-store hydration (#6664) builds payloads outside search.rs; if it should span-filter too, that is a follow-up on the shard hydration path, not this boundary.


Get evidence
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…12624)

--with-message and hydration payloads carry the whole message
text, which spans every chunk of the message; #12404 gated them
on the served chunk's classification, so a higher-classified
sibling chunk's text could ride along under fleet-internal,
hosted-per-user, and local-owner contexts.

span_filter_payload (search.rs) now classifies every chunk of
the payload's message from its detail row and applies the same
grant-intersect-context test the disclosure pass applies to
candidates: a failing chunk's text is omitted at every
occurrence in the served text (excluded_personal_life spans
therefore never cross, in any context), withholding is counted
in the envelope notes, and a failing chunk whose text cannot be
located in the message text withholds the payload whole (design
section 4: an output that cannot be safely filtered is
withheld). Text belonging to no chunk rides on the served
chunk's gate, as #12404 established.

New SearchBackend::message_chunks enumerates a message's
chunks (windowless SQL in the local and Turso backends; a
wide-window neighbors default for wrappers and stubs).

Corpus measurement recorded on #12624: zero mixed-
classification messages in the publish corpus today, so this
is a guard for per-embed classification (#12408) divergence,
not a live-leak fix. Leak tests fail before / pass after;
atlas-core, atlas-proto, atlas-search suites green.
@dezren39
dezren39 requested a review from a team as a code owner November 22, 2026 16:44
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T16:47:31.881165Z a04a3d3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 48 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5c312277-2564-47ad-a52a-2f036e842c4a
Commits

Reviewing files that changed from the base of the PR and between d5bfa05 and a04a3d3.

Files selected for processing: 6

  • pkgs/atlas-search/crates/atlas-core/src/backend.rs
  • pkgs/atlas-search/crates/atlas-core/src/filters.rs
  • pkgs/atlas-search/crates/atlas-core/src/local.rs
  • pkgs/atlas-search/crates/atlas-core/src/search.rs
  • pkgs/atlas-search/crates/atlas-core/src/turso.rs
  • pkgs/atlas-search/crates/atlas-core/tests/disclosure.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dezren39
dezren39 merged commit 5df982d into main Nov 22, 2026
2 checks passed
@dezren39
dezren39 deleted the felix/12624-span-filter branch November 22, 2026 16:45

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a04a3d321a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

let start = from + off;
ranges.push((start, start + c.text.len()));
found = true;
from = start + 1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Advance the span scan along UTF-8 character boundaries

When a withheld sibling's text starts with a multibyte character (for example, ésecret), advancing to start + 1 places from inside that character. The next evaluation of full_text[from..] panics instead of returning a filtered payload, so valid Unicode messages can crash searches using either --with-message or hydration. Advance to the next character boundary while preserving overlapping-match detection, and add Unicode property coverage for this boundary-safety invariant; the added ASCII-only examples do not exercise it.

AGENTS.md reference: AGENTS.md:L37-L39

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

audit:complete PR fully implemented spawning issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant