Skip to main content

Module typed_page

Module typed_page 

Source
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§

BatchAssertions
Batch-level compaction assertions for typed-page enforcement.
BatchViolation
A failed batch-level compaction assertion.
CompactedPage
The output of a compaction attempt, passed to PageInvariant::verify.
CompactedPageRecord
One JSONL audit record emitted per compacted page (FR-007).
CompactionAuditSink
Async bounded-mpsc audit sink for compaction records.
ConversationTurnInvariant
Invariant for PageType::ConversationTurn pages.
FidelityContract
The set of fields that must be present in a compacted page.
FidelityViolation
Describes why an invariant check failed after compaction.
InvariantRegistry
Registry mapping each PageType to its PageInvariant implementation.
MemoryExcerptInvariant
Invariant for PageType::MemoryExcerpt pages.
PageId
Stable content-addressed identifier for a TypedPage.
SystemContextInvariant
Invariant for PageType::SystemContext pages.
ToolOutputInvariant
Invariant for PageType::ToolOutput pages.
TypedPage
A classified context segment ready for invariant-aware compaction.
TypedPagesState
Shared runtime state for typed-page compaction, created once at agent startup.

Enums§

PageOrigin
Provenance of a TypedPage, serialised into audit records.
PageType
Classification of a context segment for compaction purposes.
SchemaHint
Body format hint for PageType::ToolOutput pages.

Constants§

SYSTEM_POINTER_PREFIX
Pointer prefix that the compactor writes for SystemContext pages.

Traits§

PageInvariant
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_role hint.
detect_schema_hint
Detect SchemaHint for a PageType::ToolOutput body.