Skip to content

feat: add retrieval filtering examples#19

Merged
rlippmann merged 3 commits into
mainfrom
retrieval-filtering
Jun 29, 2026
Merged

feat: add retrieval filtering examples#19
rlippmann merged 3 commits into
mainfrom
retrieval-filtering

Conversation

@rlippmann

Copy link
Copy Markdown
Owner

Summary

Adds generic Python and TypeScript retrieval-filtering examples.

The examples demonstrate that Context Compiler authoritative state determines which documents are eligible for retrieval. The host owns retrieval, while Context Compiler owns the policy state that constrains retrieval access.

Why

Retrieval filtering is a distinct enforcement point.

These examples show that protected documents are filtered before retrieval results are returned. Access decisions are enforced by host-side filtering based on authoritative Context Compiler state, not by prompt instructions or model compliance.

The examples use an HR policy lookup domain with audience-restricted documents to demonstrate observable retrieval behavior changes as authoritative state changes.

Example metadata

  • Enforcement point: retrieval filtering
  • Domain: HR policy lookup
  • Technology/runtime: generic Python, generic TypeScript
  • Example type: minimal example
  • Does this use directive drafter? should normally be no: no
  • Does this derive state from model output? must be no for primary examples: no

Checklist

  • Repository scaffolding / governance change
  • One primary enforcement point
  • Explicit authoritative state
  • No model-derived state mutation
  • Adversarial stub or equivalent test
  • Observable runtime behavior change
  • Domain vocabulary is natural
  • Framework is secondary to the enforcement point
  • Docs updated
  • Tests/smoke checks added where practical

Notes

Both implementations demonstrate:

  • employee-only access retrieves employee documents
  • manager access expands the eligible document set
  • executive-only documents remain filtered when not authorized
  • adversarial requests do not bypass retrieval filtering
  • retrieval results change only when authoritative state changes
  • contradictory directives produce clarification behavior rather than silent overwrite

The examples intentionally perform filtering before documents are returned. This demonstrates retrieval filtering as a host-side enforcement point rather than a post-generation redaction strategy.

TypeScript validation scripts were updated so the new example participates in repository validation.

@rlippmann
rlippmann merged commit 672af80 into main Jun 29, 2026
5 checks passed
@rlippmann
rlippmann deleted the retrieval-filtering branch June 29, 2026 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant