Skip to main content

Module compaction

Module compaction 

Source
Expand description

Task 30 — typed compaction summary provenance (spec §9.3).

A compaction summary is a typed context artifact: it carries provenance (where it came from, who produced it, under which prompt stack and disclosure classes) and enters model context through ONE canonical, sanitized rendering. It is neither ordinary user text nor immutable system policy:

  • wrapper/escaping injection inside a summary body is neutralized before the summary is rendered into context, so hostile summary text can never close its <context-summary> data boundary or forge system-prompt blocks;
  • the old system prompt survives as TYPED metadata (the session’s system_prompt field and CompactionRecord::prior_system_prompt), never as a plain user message.

Structs§

CompactionRecord
Typed provenance persisted with every compaction summary (spec §9.3).

Enums§

CompactionMode
Where compaction summarization runs (spec §9.4).
ContentClass
Content classes source material may belong to. Shared vocabulary between summary provenance (spec §9.3) and the compaction disclosure policy (spec §9.4).
RedactionPolicy
Redaction posture applied while serializing the source range for summarization.

Constants§

COMPACTION_SUMMARY_SCHEMA_VERSION
Version of the persisted summary artifact schema.

Functions§

compaction_context_messages
The ONE canonical rendering of a compaction summary into model context: a sanitized <context-summary> user message plus the assistant acknowledgement. Every frontend and both transition policies (linked successor and in-place) share this shape — that is what makes their logical histories equivalent.
message_range_digest
SHA-256 digest over the canonical serialization of a message range. Order-sensitive: the digest binds both content and sequence.
prompt_stack_digest
SHA-256 digest over the ordered prompt-stack parts used for summarization (system prompt, instruction template, custom focus).
sanitize_summary_text
Neutralize wrapper/escaping injection inside summary text (spec §9.3: escaping cannot elevate content). Any opening or closing form of a protected tag has its < replaced with the HTML entity, which keeps the text legible while breaking the markup.