Expand description
Typed page classification and minimum-fidelity invariants for context compaction.
Every context segment entering the assembler is tagged with a PageType and
wrapped in a TypedPage. The PageInvariant trait declares the fidelity
contract enforced at every compaction boundary.
Classification is deterministic and side-effect free — no I/O, no LLM calls.
§Architecture
This module lives in zeph-context to keep classification logic co-located with
the assembler. No dependency on zeph-memory is introduced here.
§Feature flag
All typed-page functionality is gated behind the
[memory.compaction.typed_pages] enabled = true config key. When disabled the
assembler falls back to the legacy untyped path without behaviour change.
Structs§
- Batch
Assertions - Batch-level compaction assertions for typed-page enforcement.
- Batch
Violation - A failed batch-level compaction assertion.
- Compacted
Page - The output of a compaction attempt, passed to
PageInvariant::verify. - Compacted
Page Record - One JSONL audit record emitted per compacted page (FR-007).
- Compaction
Audit Sink - Async bounded-mpsc audit sink for compaction records.
- Conversation
Turn Invariant - Invariant for
PageType::ConversationTurnpages. - Fidelity
Contract - The set of fields that must be present in a compacted page.
- Fidelity
Violation - Describes why an invariant check failed after compaction.
- Invariant
Registry - Registry mapping each
PageTypeto itsPageInvariantimplementation. - Memory
Excerpt Invariant - Invariant for
PageType::MemoryExcerptpages. - PageId
- Stable content-addressed identifier for a
TypedPage. - System
Context Invariant - Invariant for
PageType::SystemContextpages. - Tool
Output Invariant - Invariant for
PageType::ToolOutputpages. - Typed
Page - A classified context segment ready for invariant-aware compaction.
- Typed
Pages State - Shared runtime state for typed-page compaction, created once at agent startup.
Enums§
- Page
Origin - Provenance of a
TypedPage, serialised into audit records. - Page
Type - Classification of a context segment for compaction purposes.
- Schema
Hint - Body format hint for
PageType::ToolOutputpages.
Constants§
- SYSTEM_
POINTER_ PREFIX - Pointer prefix that the compactor writes for
SystemContextpages.
Traits§
- Page
Invariant - Minimum-fidelity contract for a single
PageType.
Functions§
- classify
- Classify a context segment by examining well-known prefix markers.
- classify_
with_ role - Classify a context segment, with an explicit
is_system_rolehint. - detect_
schema_ hint - Detect
SchemaHintfor aPageType::ToolOutputbody.