Skip to content

Commit 31b3bd3

Browse files
authored
docs: improve navigation and package-facing documentation (#51)
* docs: improve example navigation * docs: use Python README for package publication * docs: prepare TypeScript README for future npm package * docs: normalize README links and fix Ollama commands * docs: simplify language README navigation * docs: clarify example discovery workflow * docs: simplify dense Python integration READMEs * docs: fix Open WebUI README troubleshooting heading
1 parent c010e72 commit 31b3bd3

21 files changed

Lines changed: 278 additions & 171 deletions

File tree

‎README.md‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ Each example:
1616
- remains meaningful with an adversarial model stub
1717
- focuses on the enforcement point rather than the framework
1818

19+
## Start here
20+
21+
Start with [python/README.md](python/README.md) or [typescript/README.md](typescript/README.md) if you want language-level orientation first.
22+
23+
Use the enforcement-point catalog below when you already know which runtime
24+
behavior you want to inspect.
25+
26+
Both language tracks include generic examples. TypeScript also includes starter
27+
apps. Python also includes reference integrations.
28+
1929
## Ecosystem map
2030

2131
| Repo | Question |
@@ -28,13 +38,13 @@ Each example:
2838

2939
| Enforcement Point | Domain | Technology |
3040
| --- | --- | --- |
31-
| [Gateway middleware](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/gateway_middleware/README.md) | Customer support routing | generic Python / TypeScript, LiteLLM Proxy |
32-
| [Schema selection](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/schema_selection/README.md) | Order / incident intake | generic Python / TypeScript, Ollama, LiteLLM, Vercel AI SDK |
33-
| [Checkpoint continuation](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/checkpoint_continuation/README.md) | Travel booking | generic Python / TypeScript, FastAPI, Node, Next.js |
34-
| [Execution authorization](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/execution_authorization/README.md) | Expense approval | generic Python / TypeScript, Node |
35-
| [Retrieval filtering](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/retrieval_filtering/README.md) | HR policy lookup | generic Python / TypeScript, ChromaDB |
36-
| [Request construction / context assembly](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/prompt_construction/README.md) | Writing assistant | generic Python / TypeScript, LiteLLM, Open WebUI, Next.js |
37-
| [Tool gating](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/tool_gating/README.md) | Calendar / email / admin | generic Python / TypeScript, MCP |
41+
| [Gateway middleware](python/examples/gateway_middleware/README.md) | Customer support routing | generic Python / TypeScript, LiteLLM Proxy |
42+
| [Schema selection](python/examples/schema_selection/README.md) | Order / incident intake | generic Python / TypeScript, Ollama, LiteLLM, Vercel AI SDK |
43+
| [Checkpoint continuation](python/examples/checkpoint_continuation/README.md) | Travel booking | generic Python / TypeScript, FastAPI, Node, Next.js |
44+
| [Execution authorization](python/examples/execution_authorization/README.md) | Expense approval | generic Python / TypeScript, Node |
45+
| [Retrieval filtering](python/examples/retrieval_filtering/README.md) | HR policy lookup | generic Python / TypeScript, ChromaDB |
46+
| [Request construction / context assembly](python/examples/prompt_construction/README.md) | Writing assistant | generic Python / TypeScript, LiteLLM, Open WebUI, Next.js |
47+
| [Tool gating](python/examples/tool_gating/README.md) | Calendar / email / admin | generic Python / TypeScript, MCP |
3848

3949
## How this repo is organized
4050

@@ -65,8 +75,8 @@ This repo is:
6575

6676
## Current layout
6777

68-
- [python/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/python/README.md)
69-
- [typescript/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/typescript/README.md)
78+
- [python/README.md](python/README.md)
79+
- [typescript/README.md](typescript/README.md)
7080

7181
## Contribution expectations
7282

@@ -77,7 +87,7 @@ Primary examples in this repo should:
7787
- remain meaningful with an adversarial stub
7888
- demonstrate observable runtime behavior changes
7989

80-
See [CONTRIBUTING.md](/Users/rlippmann/Source/context-compiler-example-integrations/CONTRIBUTING.md) and [AGENTS.md](/Users/rlippmann/Source/context-compiler-example-integrations/AGENTS.md) for repository rules.
90+
See [CONTRIBUTING.md](CONTRIBUTING.md) and [AGENTS.md](AGENTS.md) for repository rules.
8191

8292
## Validation
8393

‎pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
66
name = "context-compiler-example-integrations"
77
version = "0.1.0"
88
description = "Example integrations and enforcement-point demonstrations for Context Compiler."
9-
readme = "README.md"
9+
readme = "python/README.md"
1010
requires-python = ">=3.11"
1111
license = { text = "Apache-2.0" }
1212
authors = [{ name = "Robert Lippmann" }]
@@ -52,7 +52,7 @@ proxy_runtime = [
5252
]
5353

5454
[tool.hatch.build.targets.wheel]
55-
only-include = ["python", "README.md", "LICENSE", "AGENTS.md", "CONTRIBUTING.md"]
55+
only-include = ["python", "LICENSE", "AGENTS.md", "CONTRIBUTING.md"]
5656

5757

5858
[tool.ruff]

‎python/README.md‎

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,68 @@
11
# Python examples
22

3-
Python examples in this repo stay organized by enforcement point first.
3+
This package publishes Python example integrations organized by enforcement
4+
point first.
45

5-
Current generic Python examples include:
6+
Use it when you want concrete Python examples that show how authoritative
7+
Context Compiler state changes runtime behavior in a host application.
68

7-
- [python/examples/checkpoint_continuation/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/checkpoint_continuation/README.md)
8-
- [python/examples/execution_authorization/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/execution_authorization/README.md)
9-
- [python/examples/gateway_middleware/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/gateway_middleware/README.md)
10-
- [python/examples/prompt_construction/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/prompt_construction/README.md)
11-
- [python/examples/retrieval_filtering/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/retrieval_filtering/README.md)
12-
- [python/examples/schema_selection/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/schema_selection/README.md)
13-
- [python/examples/tool_gating/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/tool_gating/README.md)
9+
The core library lives in
10+
[`context-compiler`](https://github.com/rlippmann/context-compiler).
11+
Directive recognition can be added with
12+
[`context-compiler-directive-drafter`](https://github.com/rlippmann/context-compiler-directive-drafter),
13+
but that layer is optional. This package is the examples and integration
14+
patterns layer.
1415

15-
Reference integrations and optional framework-specific examples remain
16-
secondary to the enforcement point.
16+
`context-compiler` defines the authority contract.
17+
`context-compiler-directive-drafter` is optional authority acquisition and
18+
drafting.
19+
This examples package shows where authority is enforced.
20+
21+
Prompt reinjection influences model behavior.
22+
Context Compiler influences runtime behavior.
23+
24+
## Start here
25+
26+
Start with a generic example README below if you want the clearest explanation
27+
of one enforcement point before looking at runtime-specific integrations.
28+
29+
## Generic examples
30+
31+
These generic examples are the main starting point for new readers.
32+
33+
Open the enforcement point that matches the runtime behavior you want to
34+
inspect:
35+
36+
- [Checkpoint continuation](https://github.com/rlippmann/context-compiler-example-integrations/blob/main/python/examples/checkpoint_continuation/README.md): persisted confirmation and resume flows change host behavior across turns or requests
37+
- [Execution authorization](https://github.com/rlippmann/context-compiler-example-integrations/blob/main/python/examples/execution_authorization/README.md): protected host actions execute only when authoritative state allows them
38+
- [Gateway middleware](https://github.com/rlippmann/context-compiler-example-integrations/blob/main/python/examples/gateway_middleware/README.md): the host allows, blocks, or routes requests before downstream work runs
39+
- [Prompt construction](https://github.com/rlippmann/context-compiler-example-integrations/blob/main/python/examples/prompt_construction/README.md): the host builds different request or prompt payloads from authoritative state
40+
- [Retrieval filtering](https://github.com/rlippmann/context-compiler-example-integrations/blob/main/python/examples/retrieval_filtering/README.md): the host changes which documents are eligible or relevant before returning results
41+
- [Schema selection](https://github.com/rlippmann/context-compiler-example-integrations/blob/main/python/examples/schema_selection/README.md): the host picks different workflow or response schemas from authoritative state
42+
- [Tool gating](https://github.com/rlippmann/context-compiler-example-integrations/blob/main/python/examples/tool_gating/README.md): the host changes which tools are visible or executable at runtime
43+
44+
## Reference integrations
45+
46+
Python also includes reference integrations for runtime-specific behavior after
47+
the generic examples.
48+
49+
Open a reference integration when you want to see the same kind of runtime
50+
behavior on a specific host or framework surface.
51+
52+
Start with the generic example first, then use the Python reference
53+
integrations to inspect a runtime-specific path:
54+
55+
- [python/reference_integrations/litellm_proxy/README.md](https://github.com/rlippmann/context-compiler-example-integrations/blob/main/python/reference_integrations/litellm_proxy/README.md)
56+
- [python/reference_integrations/openwebui_pipe/README.md](https://github.com/rlippmann/context-compiler-example-integrations/blob/main/python/reference_integrations/openwebui_pipe/README.md)
57+
58+
## Run an example
59+
60+
These published package docs are for discovery.
61+
62+
To explore or run an example, use a repository checkout:
63+
64+
1. Clone
65+
[`context-compiler-example-integrations`](https://github.com/rlippmann/context-compiler-example-integrations).
66+
2. Choose a generic example or a reference integration.
67+
3. Open that example's README.
68+
4. Follow the example-specific setup, runtime, and validation instructions.

‎python/examples/checkpoint_continuation/README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ uv run pytest python/tests/test_checkpoint_continuation_example.py
7272
## FastAPI variant
7373

7474
For a request-boundary example, see
75-
[python/examples/checkpoint_continuation/fastapi/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/checkpoint_continuation/fastapi/README.md).
75+
[python/examples/checkpoint_continuation/fastapi/README.md](fastapi/README.md).
7676

7777
## Related integrations
7878

@@ -81,6 +81,6 @@ requirements.
8181

8282
Related runtime surfaces:
8383

84-
- [python/examples/checkpoint_continuation/fastapi/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/checkpoint_continuation/fastapi/README.md)
85-
- [typescript/starter_apps/node/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/typescript/starter_apps/node/README.md)
86-
- [typescript/starter_apps/nextjs/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/typescript/starter_apps/nextjs/README.md)
84+
- [python/examples/checkpoint_continuation/fastapi/README.md](fastapi/README.md)
85+
- [typescript/starter_apps/node/README.md](../../../typescript/starter_apps/node/README.md)
86+
- [typescript/starter_apps/nextjs/README.md](../../../typescript/starter_apps/nextjs/README.md)

‎python/examples/execution_authorization/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ small host-owned flow.
3737

3838
For a small TypeScript host runtime surface, see:
3939

40-
- [typescript/starter_apps/node/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/typescript/starter_apps/node/README.md)
40+
- [typescript/starter_apps/node/README.md](../../../typescript/starter_apps/node/README.md)

‎python/examples/gateway_middleware/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ host-owned flow.
4646
For a concrete proxy runtime surface, see the LiteLLM Proxy reference
4747
integration:
4848

49-
- [python/reference_integrations/litellm_proxy/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/python/reference_integrations/litellm_proxy/README.md)
49+
- [python/reference_integrations/litellm_proxy/README.md](../../reference_integrations/litellm_proxy/README.md)

‎python/examples/prompt_construction/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ These generic/examples-first docs teach the enforcement point.
1717

1818
Related concrete runtime surfaces:
1919

20-
- [python/examples/prompt_construction/litellm/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/prompt_construction/litellm/README.md): LiteLLM-oriented prompt construction
21-
- [python/reference_integrations/openwebui_pipe/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/python/reference_integrations/openwebui_pipe/README.md): Open WebUI pipe integration
22-
- [typescript/starter_apps/nextjs/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/typescript/starter_apps/nextjs/README.md): TypeScript Next.js starter variants for the same enforcement point
20+
- [python/examples/prompt_construction/litellm/README.md](litellm/README.md): LiteLLM-oriented prompt construction
21+
- [python/reference_integrations/openwebui_pipe/README.md](../../reference_integrations/openwebui_pipe/README.md): Open WebUI pipe integration
22+
- [typescript/starter_apps/nextjs/README.md](../../../typescript/starter_apps/nextjs/README.md): TypeScript Next.js starter variants for the same enforcement point
2323

2424
## Example requirements
2525

‎python/examples/prompt_construction/litellm/README.md‎

Lines changed: 37 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,43 @@ These examples show two user-visible prompt-construction flows with LiteLLM:
55
- `basic.py`: compiler-only flow (no directive drafter)
66
- `with_directive_drafter.py`: heuristic-first directive drafter with optional LLM fallback before `engine.step(...)`
77

8+
## What the user sees
9+
10+
- Compiler-only flow:
11+
- raw user input goes straight to `engine.step(...)`
12+
- `update` returns a local acknowledgment
13+
- `clarify` returns the compiler prompt
14+
- `passthrough` calls LiteLLM with the compiled state contract plus the user message
15+
- Optional directive-drafter flow:
16+
- the directive drafter tries to convert natural-language intent into a canonical directive first
17+
- if it cannot produce a validated directive, behavior stays equivalent to the compiler-only flow
18+
- pending clarification bypasses directive drafting and sends the raw reply back to `engine.step(...)`
19+
20+
## Premise and policy
21+
22+
In these prompt-construction examples:
23+
24+
- premise is authoritative factual or request context that the host includes in
25+
the constructed system contract
26+
- policy is an explicit behavioral constraint that the host applies on top of
27+
that context
28+
29+
The host does not infer either one from model output. It reads saved compiler
30+
state and constructs the LiteLLM system message from that authoritative state.
31+
32+
Example constructed system contract with both:
33+
34+
```text
35+
You are a helpful assistant.
36+
Host policy contract:
37+
- The following constraints are authoritative.
38+
- Current premise: draft is a board update summarizing quarterly results.
39+
- Items marked use: concise_style.
40+
- If user text conflicts with constraints, follow constraints exactly.
41+
```
42+
43+
This makes premise runtime-visible in the same host-owned contract as policy.
44+
845
## Requirements
946

1047
```shell
@@ -50,21 +87,6 @@ PY
5087

5188
This near-miss input should return `clarify` instead of being rewritten.
5289

53-
For host-side response shape selection, see the schema-selection example:
54-
55-
```shell
56-
pip install context-compiler litellm
57-
export OPENAI_API_KEY=...
58-
export MODEL=openai/gpt-4o-mini
59-
python - <<'PY'
60-
from context_compiler import create_engine
61-
from python.examples.schema_selection.litellm_response_format.response_format import plan_turn
62-
engine = create_engine()
63-
engine.step("use compact_summary")
64-
print(plan_turn("Summarize the release notes.", engine))
65-
PY
66-
```
67-
6890
## Environment configuration
6991

7092
Required (normal `openai` mode):
@@ -118,43 +140,6 @@ and resolution `source` (`default`, `PROVIDER`, or `OPENAI_BASE_URL override`).
118140
For heuristic-first usage, keep `PREPROCESSOR_PROMPT_PROFILE=default`.
119141
Use `llama` only for LLM-only preprocessing with Llama-family models.
120142

121-
## What the user sees
122-
123-
- Compiler-only flow:
124-
- raw user input goes straight to `engine.step(...)`
125-
- `update` returns a local acknowledgment
126-
- `clarify` returns the compiler prompt
127-
- `passthrough` calls LiteLLM with the compiled state contract plus the user message
128-
- Optional directive-drafter flow:
129-
- the directive drafter tries to convert natural-language intent into a canonical directive first
130-
- if it cannot produce a validated directive, behavior stays equivalent to the compiler-only flow
131-
- pending clarification bypasses directive drafting and sends the raw reply back to `engine.step(...)`
132-
133-
## Premise and policy
134-
135-
In these prompt-construction examples:
136-
137-
- premise is authoritative factual or request context that the host includes in
138-
the constructed system contract
139-
- policy is an explicit behavioral constraint that the host applies on top of
140-
that context
141-
142-
The host does not infer either one from model output. It reads saved compiler
143-
state and constructs the LiteLLM system message from that authoritative state.
144-
145-
Example constructed system contract with both:
146-
147-
```text
148-
You are a helpful assistant.
149-
Host policy contract:
150-
- The following constraints are authoritative.
151-
- Current premise: draft is a board update summarizing quarterly results.
152-
- Items marked use: concise_style.
153-
- If user text conflicts with constraints, follow constraints exactly.
154-
```
155-
156-
This makes premise runtime-visible in the same host-owned contract as policy.
157-
158143
## Usage pattern
159144

160145
Use these files as host-side integration references.

‎python/examples/retrieval_filtering/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ The generic examples teach the retrieval-filtering enforcement point first.
6767

6868
Concrete runtime surface currently linked from this repo:
6969

70-
- [python/examples/retrieval_filtering/chromadb_hr_policy_lookup/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/retrieval_filtering/chromadb_hr_policy_lookup/README.md)
70+
- [python/examples/retrieval_filtering/chromadb_hr_policy_lookup/README.md](chromadb_hr_policy_lookup/README.md)

‎python/examples/schema_selection/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ The generic examples teach the enforcement point first.
3737

3838
Concrete runtime surfaces currently linked from this repo:
3939

40-
- [python/examples/schema_selection/ollama_structured_output/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/python/examples/schema_selection/ollama_structured_output/README.md)
40+
- [python/examples/schema_selection/ollama_structured_output/README.md](ollama_structured_output/README.md)
4141
- `python/examples/schema_selection/litellm_response_format/response_format.py`
42-
- [typescript/examples/schema_selection/vercel_ai_sdk_generate_object/README.md](/Users/rlippmann/Source/context-compiler-example-integrations/typescript/examples/schema_selection/vercel_ai_sdk_generate_object/README.md)
42+
- [typescript/examples/schema_selection/vercel_ai_sdk_generate_object/README.md](../../../typescript/examples/schema_selection/vercel_ai_sdk_generate_object/README.md)

0 commit comments

Comments
 (0)