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.Lineage and threshold compaction
Bound history while retaining useful state.
context_projectionRECORD STATUSCandidate · v0.1.0UML class view
The proposed contract drawn as participant roles, received calls, and numbered dependencies.
Object interactions
The same roles and calls as a class collaboration and a numbered message sequence.
Pointcut
Where the mechanism applies. All four dimensions belong to the proposed match, not just its vocabulary.
- 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.
Protected contract
The obligation that clients, operators, and auditors should be able to rely on.
- 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.
Variation & lifecycle
The hot spot is admitted only where the protected semantics survive.
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 + code design
An illustrative prompt and a small design sketch for the proposed contract. Names and APIs are invented; this is not a repository excerpt.
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.
Detection & matching
The frozen rule that retrieves this record, the canonical source exemplar, and the control that should stay unmatched.
- 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/opencode
packages/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 ↗
Repository files
Up to five public files retrieved by the frozen cue and pinned to the audited commit. A match is a place to inspect, not a confirmed implementation.
packages/core/src/session/compaction.ts:298CANONICAL SOURCE02aaif-goose/goosecrates/goose/examples/agent.rs:65RETRIEVAL CUE03affaan-m/ECCskills/agent-self-evaluation/scripts/evaluate.py:267RETRIEVAL CUE04agno-agi/agnolibs/agno/agno/db/base.py:2284RETRIEVAL CUE05Aider-AI/aideraider/args.py:189RETRIEVAL CUEEvidence & provenance
Each layer answers a different question. Do not substitute retrieval for review.
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.
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 / 41885df74024b6packages/core/src/session/compaction.ts:298packages/core/test/session-native-compaction.test.ts:213Threshold, 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)\bThis expression is a discovery instrument only. A match is a retrieval cue—not a confirmed implementation, pointcut match, or contract proof.