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_promptfield andCompactionRecord::prior_system_prompt), never as a plain user message.
Structs§
- Compaction
Record - Typed provenance persisted with every compaction summary (spec §9.3).
Enums§
- Compaction
Mode - Where compaction summarization runs (spec §9.4).
- Content
Class - Content classes source material may belong to. Shared vocabulary between summary provenance (spec §9.3) and the compaction disclosure policy (spec §9.4).
- Redaction
Policy - 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.