Context engineering
The context sheaf, live
Most agents concatenate retrieved text and hope it is consistent. G6 treats context as a sheaf: evidence is restricted along exact maps into a strict belief layer F, and disagreement between independent sources on a shared key is a measured, localised obstruction — not a yes/no opinion. The scorecards below are produced live by the real context_engine block.
Architecture — evidence to tokens
flowchart LR E["E — evidence cosheaf
(append-only observations)"] -->|colimit / belief select| F["F — strict sheaf
(typed claims, exact restriction maps)"] F -->|presentation| P["P — rendered context
(lossy, defect measured)"] P -->|budgeted| T["Tokens → agent"] F -.consistency.-> S["consistency scorecard
radius · obstructions · gluable · edge residuals · λ₊"]
Obstructed packet
gluable = FalseTwo independently-sourced governance claims disagree on deploy_target (planner = production, approval = staging). The sheaf refuses to glue them and says exactly where.
- consistency radius
- 1.0
- obstruction count
- 1
- gluable
- False
- coverage ratio
- 1.0
edge residuals (where they disagree)
- planner~approval1.0
Gluable packet
gluable = TrueThe same two sources now agree on deploy_target = staging. The packet glues into a single global section — radius zero, no obstructions.
- consistency radius
- 0.0
- obstruction count
- 0
- gluable
- True
- coverage ratio
- 1.0
edge residuals
- none — all shared projections agree
Uncorroborated packet
coverage = 0.0Two claims from different sources that never share a key (db_engine from planner, cache_ttl from retriever). Nothing contradicts — so it is gluable — but nothing was cross-checked either. Coverage tells these apart from a confirmed packet, so "gluable" is never mistaken for "verified true".
- gluable
- True
- coverage ratio
- 0.0
- corroborated keys
- 0
- uncorroborated keys
- 2
Consistency energy
E(x) = ‖δ⁰x‖² = ⟨x, Lx⟩ with the sheaf Laplacian L = (δ⁰)ᵀδ⁰ (Hansen–Ghrist). E = 0 iff every shared projection agrees — a global section.
Stability, honestly
dist(x, H⁰) ≤ ‖δ⁰x‖ / √λ₊. When the spectral gap λ₊ ≈ 0 no certificate is issued (the bound returns None) — a low residual is never over-read.
Cohomology honesty
δ⁰x is itself a coboundary, so its class is zero. We report a combinatorial nerve H⁰ and an obstruction count — never a fake non-zero H¹.
These scorecards are computed on the strict sheaf F (exact restriction-derived, independently-sourced claims) — not on summarised text. The consistency layer is gated by G6_CONTEXT_SHEAF and is byte-identical to the prior engine when off.