Skip to content

atlas(classification): enforce disclosure-context filters at output boundaries (#12404) - #12626

Merged
dezren39 merged 1 commit into
mainfrom
felix/12404-disclosure-context-filter
Nov 22, 2026
Merged

dezren39 merged 1 commit into
mainfrom
felix/12404-disclosure-context-filter

Conversation

@dezren39

@dezren39 dezren39 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Implements the next slice of #12404: disclosure-context enforcement at Atlas's output boundaries, per the #9096 design (§4). Not merged — left for review; the filter point is in crates/atlas-core/src/search.rs (run_search_impl, the "Disclosure-context enforcement" block) and crates/atlas-core/src/disclosure.rs.

Mechanism

A new DisclosureContext (atlas-core disclosure.rs) carries the design §4 table — fleet-internal → local-only, hosted-per-user → personal, public-surface → shareable, local-owner → secret-bearing. In run_search_impl, after fusion and before any rendering, every ranked candidate's detail row is classified (chunk_classification: missing/unknown label → secret-bearing, fail-closed; excluded_personal_life label → excluded) and admitted only if context.permits_with_grant(class, caller_ceiling) — the intersection of grant ∩ context ceiling ∩ not-excluded. Every rendered shape draws only from that admitted set, and the query trace's served set is collected from the rendered envelope, so traced/cached/paged payloads inherit the filter. Context never widens a grant and a grant never widens a context (proptest-pinned).

Boundary inventory

Boundary Status How
Search results (flat) Enforced Top-k taken from the admitted set; a withheld candidate doesn't shrink the page
Grouped sessions Enforced Withheld candidates contribute neither chunks nor hit_count (counts are metadata)
Raw branch rows (--raw-rows=branches) Enforced Pool rows filtered by the same admitted set
Snippets / result text Enforced Result text comes only from admitted chunks' detail rows
Metadata (session objects, notes) Enforced Session metadata renders only for admitted chunks; withholding is recorded as a count-only envelope note (no titles/ids of withheld items)
Neighbor expansion (--expand, get-chunk neighbors) Enforced Neighbor rows carry no classification, so each neighbor's own detail row decides; no detail row → withheld. At base this path leaked unchecked (see evidence)
--with-message payloads Enforced Gated on the served chunk's classification; withheld outright on public-surface (full-message text can't be filtered at chunk granularity — design §4: "if an output cannot be safely filtered, withhold it")
Hydration payloads Enforced Same rule as --with-message
Get-chunk (by-id) Enforced run_get_chunk_with_context; a withheld chunk returns the same "not found" fatal as a missing one, so the lookup can't confirm classified content exists. run_get_chunk keeps its Python-parity contract under local-owner — the only behavior change is excluded content, now never served
Service job results + dedupe/result cache Enforced Results are computed under the resolved context, and the server CacheKey now includes the context — a payload filtered for one destination can never be served or coalesced into another (test: dedupe_never_crosses_disclosure_contexts)
Service chunk endpoint Enforced Existing ceiling/unknown→404 check preserved; exclusion stated explicitly
Query trace record Deferred → #9099 Design §10 assigns query trace fields to #9099. Withheld candidates already appear in the record as considered-but-not-served; the record gains no context field here
Hosted Worker (TS) surface Deferred → #12622 (task 21057) Worker pins CEILING = "personal" (= the hosted-per-user ceiling) and keys its cache by ceiling, but states no context and doesn't key by it. Belongs to #9092's hosted-surface work; the wire field it needs (SearchRequest.context) lands here
Legacy Python atlas_search.py Deferred → #12623 (task 21058) No context concept; serves excluded content at a sufficient ceiling. Parity or retirement, its own slice
Span-level filtering of message/hydration payloads Deferred → #12624 (task 21059) Residual found in this slice: under non-public contexts a payload is gated on the served chunk, but message text spans sibling chunks that may classify higher. Public-surface is fully covered (withheld outright)

Front-end context defaults (stated, per surface)

  • Library SearchOptions::default context: public-surface (fail-closed; a caller that states nothing gets the strictest outbound treatment).
  • CLI search --context: default fleet-internal (the CLI serves fleet surfaces); CLI get-chunk --context: default local-owner (the owner's explicit-id tool). Unknown values are a usage error (exit 2), never a silent default.
  • Service: a stated request context resolves fail-closed (unknown → public-surface); an unstated one defaults to fleet-internal (its callers are authenticated fleet surfaces; sinks beyond the service state their own context).
  • SearchRequest.context is additive/optional on the wire (#[serde(default, skip_serializing_if)]).

Leak-test evidence

Fail-before (base 516c13c29, scratch worktree, stub backend, maximal caller ceiling) — all three leaks reproduced:

BASE search results at secret-bearing ceiling: ["shareable deployment notes", "SECRET: production API key hunter2", "personal-life diary entry"]
BASE expand context for the shareable hit: {"before":[],"after":[{"chunk_id":2,"text":"SECRET: production API key hunter2"}]}
BASE get-chunk 3 text: "personal-life diary entry"

Pass-after (this branch, sandbox) — crates/atlas-core/tests/disclosure.rs, 13 tests, one per boundary class: public-surface filtering of a fully-cleared caller (whole-envelope scan for leaked strings), fleet-internal withholding secret-bearing, hosted narrowing a wider grant, local-owner unable to widen a narrower grant, exclusion in every context, fail-closed labels, unstated-context default, grouped counts, raw branch rows, expand neighbors, get-chunk gating, public full-content withholding. Plus disclosure.rs unit tests + proptests (intersection = min, never exceeds either side) and the server cache-separation test.

Suites (sandbox, cargo test -p atlas-core -p atlas-proto -p atlas-search): 357 passed, 0 failed. Harness updates where a harness models the local operator surface: it now states local-owner explicitly (flags/parity/live-smoke/cli_parity hybrid_secret_ceiling, the server dedupe canary test). No new dependencies.

What remains on #12404

Refs #12404 (slice; issue stays open for the deferred boundaries).


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

…oundaries (#12404)

Implements the #9096 design section 4 disclosure contexts in
Atlas search: the destination surface's context ceiling
(fleet-internal=local-only, hosted-per-user=personal,
public-surface=shareable, local-owner=secret-bearing)
intersects the caller's grant ceiling at the final output
boundary in atlas-core's run_search_impl, so neither can widen
the other and excluded_personal_life content is ineligible in
every context.

One filter point covers every rendered shape: flat results,
grouped sessions (chunks and hit_count), raw branch rows,
neighbor expansion (filtered per neighbor classification),
--with-message and hydration payloads (withheld outright on
public-surface), and get-chunk (context-gated; a withheld
chunk reads as not found). Missing/unknown sensitivity labels
fail closed to secret-bearing; an absent context fails closed
to public-surface (library default), with front-ends stating
their surface's context: CLI search defaults fleet-internal,
CLI get-chunk defaults local-owner, the service resolves a
stated context fail-closed and defaults fleet-internal for
its authenticated callers, and the service dedupe/result
CacheKey now includes the resolved context so cached payloads
cannot cross contexts. SearchRequest gains an additive
optional context field.

Leak evidence: at base, a stub-backend demonstration served
secret-bearing and excluded content at a maximal caller
ceiling, leaked a secret-bearing neighbor through --expand,
and served an excluded chunk by id. The new
crates/atlas-core/tests/disclosure.rs (13 tests) plus
disclosure.rs unit/proptests and a server cache-separation
test pin the intersection per boundary class; all atlas-core,
atlas-proto, and atlas-search suites green (357 tests).

Deferred boundaries, filed and enqueued from this slice:
Worker (TS) stated context + cache keying -> #12622 (task
21057); legacy Python atlas_search.py parity -> #12623 (task
21058); span-level filtering of full-content payloads ->
#12624 (task 21059). The query-trace context field belongs to
#9099 per design section 10 and is not built here.
@dezren39
dezren39 requested a review from a team as a code owner November 22, 2026 16:25
@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:27:21.337951Z 004a390 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

Explain Change →

Caution

Review failed

The pull request is closed.

  • 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

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

Labels

audit:partial PR partially implemented; gap filed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant