advanced30 min studyLesson 915 in Engineering

Recheck document permissions when retrieval evidence is consumed

Bind retrieval, reranking, prompt construction, citations and cached answers to current document policy rather than ingest-time visibility or query-text similarity.

On this page

What you’ll understand

  • Distinguish ingestion provenance from current read permission.
  • Define a freshness and revocation contract for retrieved documents and derived caches.
  • Test stale grants, cross-tenant caches and permission changes at each consumption boundary.

A retrieval index can retain a document after its owner changes permissions. A cached answer can also contain information from documents that the current caller may no longer read. Ingestion authorization and vector similarity do not establish query-time access. Define when permission is checked, how fresh that decision must be, and what happens when policy changes during a request. Carry document identity and version through retrieval, reranking, model context and citations so access remains attributable to actual evidence.

Treat similarity candidates as untrusted until permission is established

Associate chunks and embeddings with canonical source-document identity, version and policy metadata. Scope candidate search to authorized data where supported, but verify that the filter is authoritative and fresh under the chosen system. If candidate IDs are fetched before final authorization, do not expose restricted content, sensitive metadata or scores to the model or user along that path. Rerankers, document fetches, citation previews and debugging traces can all become separate disclosure points.

The authorization service should evaluate the authenticated principal, tenant, read action and current document policy. An ACL copied into an index at ingestion can become stale; a periodic refresh has a delay that must be measured and accepted explicitly. State whether a request uses a policy snapshot or rechecks before context construction and response delivery. No sequence of independent checks automatically creates a transaction spanning the policy store, retriever, model and client; stronger revocation semantics require a coordinated design.

Dcontext(p,t)⊆{d:canRead(p,d,t)}D_{\rm context}(p,t)\subseteq\{d:{\rm canRead}(p,d,t)\}
D_context is the set of source documents whose content enters the model under a strict current-read design at declared check time t. This set predicate does not itself enforce freshness or atomic revocation across services. A snapshot/lease design must state its different effective time and allowed revocation window.↔ Scroll wide equations horizontally.

Cache reuse needs provenance and current access, not only a hit

A semantic answer cache can serve the same question to different principals, while a prefix cache can retain previously constructed evidence. Partition by appropriate tenant and representation versions, retain source-document provenance, and reauthorize the documents supporting a cached result under the declared freshness policy. Merely adding tenant ID to a key may be insufficient when users within that tenant have different permissions. Query-string equality also does not show that the caller can read the prior evidence.

If a derived answer lacks enough provenance to establish its permitted use, reject that reuse or rebuild it under the actual design rather than guessing that a short TTL is adequate. Invalidation, online checks, policy-version keys and leases have different availability and revocation tradeoffs. A TTL bounds age only under correct clocks and cache enforcement; it does not prove instantaneous policy freshness. HTTP cache rules also do not automatically apply to an application semantic cache unless implemented there.

reuse(p,c,t)=compatible(c)∧⋀d∈sources⁡(c)canRead(p,d,t){\rm reuse}(p,c,t)={\rm compatible}(c)\land\bigwedge_{d\in\operatorname{sources}(c)}{\rm canRead}(p,d,t)
This proposed strict reuse predicate assumes complete trusted source provenance for cached item c and authoritative current checks. Compatibility covers model/prompt/data versions separately. It is not a guarantee supplied by LRU, HTTP caching, a vector index or a tenant-key prefix.↔ Scroll wide equations horizontally.

Test revocation at the evidence release points

Use a document visible to one principal and denied to another, then warm all relevant caches. Revoke permission while keeping the document and query unchanged. Verify what reaches candidate previews, reranking, prompt construction, final answers and citations under the declared policy. Include a request already in progress and record whether previously released information can be recalled; generally it cannot. A strict contract must define the last revocation check and acknowledge the concurrency boundary it actually enforces.

The cache lab isolates locality while deliberately omitting access policy. Reset and set both C=4,s=4, predict twelve hits among sixteen initial requests, then Play or Step. Reset and set both C=3,s=4 predicts zero initial hits. Edits retain elapsed time and the trace caps at 4,096 requests. The LRU hit is only a residency event: there are no principals, documents, ACL versions, revocations or derived-answer provenance. Its contrast makes clear why a faster reuse path still needs an independent permission decision.

Find a stated TTL revocation window

A fictional cache records an allow decision at elapsed time 0 s and uses a 60-second TTL without online rechecks or invalidation. A permission is revoked at time 15 s. Assume correct cache clocks and a strict expiry at 60 s; this is a deliberately weaker policy than immediate revocation.

  1. The cached allow remains considered fresh by that TTL rule until time 60 s. The policy change at fifteen seconds does not alter the cached entry in this fixture.

  2. The potential stale-allow interval after revocation is 60−15=45 seconds, excluding the expiry endpoint. Requests during that interval can reuse the obsolete grant under the stated implementation.

  3. If the service requires current authorization instead, this implementation fails that contract. Introduce and test the selected authoritative recheck/invalidation or coordinated lease design, rather than relabeling the sixty-second TTL as immediate revocation.

The result

The fixture exposes a forty-five-second stale-grant window. A cache-hit rate or short TTL does not establish the stronger freshness property.

Explore the model

Interactive lab

Interactive lab · cache

Separate a locality hit from a permission decision

Reset → set both C=4,s=4 predicts twelve hits in the initial sixteen requests; Reset → set both C=3,s=4 predicts zero. Play/Step extends to a 4,096-request cap, and edits retain time. This LRU stream contains no ACL, tenant, document version, revocation or answer provenance.

Separate a locality hit from a permission decisionA fully associative LRU cache starts empty and requests address (i·s) mod 16. Hits move an address to the newest position; misses evict the oldest when full. Playback starts with 16 requests and adds two per second, capped at 4096 explicitly simulated requests. This toy stream is not a processor-cache benchmark. Current readings: Hits / requests: 0 / 16; Hit rate: 0%; Address-stream period: 16 addresses. All parameters are adjustable with the labeled controls below.Fully associative LRU cache after 16 deterministic requests: 0 hits and 16 misses.Most recent 16 requestsaddress = i × 3 mod 160M3M6M9M12M15M2M5M8M11M14M1M4M7M10M13MCurrent cache order · oldest → newest471013Latest address 13 · miss: inserted as newestToy address stream · period 16 · starts empty
Cached addressMiss / evictionMost recent request
Hits / requests
0 / 16
Hit rate
0%
Address-stream period
16 addresses
t = 0 s

A fully associative LRU cache starts empty and requests address (i·s) mod 16. Hits move an address to the newest position; misses evict the oldest when full. Playback starts with 16 requests and adds two per second, capped at 4096 explicitly simulated requests. This toy stream is not a processor-cache benchmark. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forA resident cached item can still be unauthorized for the current caller.

Check your understanding

A tenant-scoped answer cache was built from two documents. One caller in that tenant cannot read one source. What follows under the strict reuse policy?

Try it yourself

A request can read documents A and B at its context check. Permission to B is revoked after context construction but before the response. Does the earlier check prove permission is current at response time? What does a 20-second policy lease mean if revocation occurs five seconds after lease issuance?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Separate a point-in-time observation from a declared lease window, and do not claim earlier released content can be recalled.

Compare with the solution

The earlier check does not prove response-time permission. A strict response boundary needs its specified fresh check or coordinated mechanism, with the actual race/snapshot scope stated. Under a deliberately honored twenty-second lease, revocation five seconds after issuance leaves up to fifteen seconds of lease-valid use, assuming the lease cannot be extended or bypassed. That is an explicit bounded-delay policy, not instantaneous revocation, and it cannot retract content already sent.

Take it with you

  • Ingest-time visibility and similarity are insufficient for query-time access.
  • Carry trusted source provenance and the actual freshness policy through every cache and evidence consumer.
  • Test revocation and in-progress requests at the boundary the service really promises.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.