Catalog/P family/P27
Proposed specificationSource-located exemplarH3

Lineage and threshold compaction

Bound history while retaining useful state.

JOIN POINTcontext_projectionRECORD STATUSCandidate · v0.1.0
UML class view for Lineage and threshold compaction, showing participant roles, received calls, and analytical dependencies
FIG. P27 / UML CLASS VIEW
Object interaction diagram for Lineage and threshold compaction, showing role collaboration and a numbered message sequence
FIG. P27 / OBJECT INTERACTIONS
Context
History approaches a context or count threshold before a model call.
Trigger
A compaction policy activates.
Structure
Threshold, selection strategy, summarizer or truncator, and lineage metadata.
Effect
Model input is reduced while retained and removed evidence remains attributable.
Requires
Context usage, protected items, and eviction policy are available.
Ensures
The replacement fits the target and records what replaced which history.
Invariant
Required system, safety, or current-task evidence is not silently evicted.
Violation
Summary failure, threshold conflict, or empty projection falls back explicitly.

Negative control

A generic text truncate utility is not compaction without lineage.

Permitted variation

Message count, token budget, oldest-first, protected groups, remote or local.

Test obligation

Test threshold edge, protected item, failure, lineage, and post-compaction facts.

Evolution question

Did summarization become thresholded and lineage-aware?

PROMPT SKETCH
Compact context against a target budget while protecting declared items. Record which history was replaced by which summary, and keep the lineage queryable after compaction.
CODE DESIGN / PYTHON
def compact(history, policy, target_tokens):
    protected, evictable = history.split(policy.protected_ids)
    summary = summarize(evictable, max_tokens=target_tokens - protected.tokens)
    replacement = ContextSummary(
        text=summary,
        replaces=[item.id for item in evictable],
        protected=[item.id for item in protected],
    )
    return history.replace(evictable, replacement)

Illustrative design sketch. Compaction is a provenance operation, not just a shorter string. This example is a teaching aid, not implementation evidence or a conformance claim.

Join point
context_projection
Source locator
Barbaste et al., §9.5, p. 32 (“Threshold Compaction”); §9.5, p. 33 (Hermes, “Lineage Compaction”); merged label
Lexical cue
(?i)\b(?:compact(?:ion|ed|or)?|summari[sz](?:e|ation)|truncate[_-]?history|token[_-]?limited[_-]?history)\bFrozen expression, v0.1.0. A match is a retrieval cue, not a confirmed implementation.
Aliases
None
Canonical exemplar
anomalyco/opencodepackages/core/src/session/compaction.ts:298Support: packages/core/test/session-native-compaction.test.ts:213
Negative control
A generic text truncate utility is not compaction without lineage.

Scope-anchored review. pohe-agent analyze <repo> --pattern P27 anchors the cue to its enclosing declaration and checks a separate operational signature for all four pointcut dimensions. Missing roles and negative-control risks remain visible; a structural match is not E2/E3. Calibration report ↗

Source-located exemplar

A concrete source anchor is available for this proposed record. It is one exemplar, not evidence that all repositories—or every contract field—conform.

Review boundary: this candidate and its specification come from an AI-assisted study. Independent human validation remains open.

ANY-EVIDENCE FAMILY COVERAGE35/36

97.2% of repository families in the frozen panel have at least one current cue, historical cue, or canonical source layer. This is not confirmed prevalence.

Current lexical-cue repositories: 39 / 41
Canonical source anchoranomalyco/opencode 885df74024b6packages/core/src/session/compaction.ts:298

Threshold, background, and native compaction.

Exploratory retrieval cue Regex / v0.1.0
(?i)\b(?:compact(?:ion|ed|or)?|summari[sz](?:e|ation)|truncate[_-]?history|token[_-]?limited[_-]?history)\b

This expression is a discovery instrument only. A match is a retrieval cue—not a confirmed implementation, pointcut match, or contract proof.