Interface ContextStrategy

All Known Implementing Classes:
Hierarchical, PriorityTruncate, SlidingWindow

public sealed interface ContextStrategy permits PriorityTruncate, SlidingWindow, Hierarchical
How a ParsedDocument is rendered into the bounded context window of an LLM call. Sealed; the only permitted strategies are PriorityTruncate, SlidingWindow, and Hierarchical.

Adding a new strategy requires a major version bump and a new permits entry — the sealed contract makes every consumer's exhaustive switch fail to compile, which is the desired forcing function.

Since:
0.1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    Render the document into a single user-prompt string, applying this strategy's truncation / windowing rules.
  • Method Details

    • assemble

      Render the document into a single user-prompt string, applying this strategy's truncation / windowing rules.

      Implementations MUST NOT silently overrun the strategy's documented budget — per CONTRIBUTING.md "Engineering principles" §2 (no silent failures) and the production lessons codified in OverBudgetPolicy. Callers either get a result inside the budget, a clearly-flagged warning + an over-budget result, or an ExtractionException.

      Parameters:
      doc - the parsed document; must not be null.
      Returns:
      a single string suitable for use as the user prompt.
      Throws:
      ExtractionException - if the strategy cannot satisfy its budget contract (e.g. PriorityTruncate OverBudgetPolicy.STRICT with priority sections exceeding maxChars).
      NullPointerException - if doc is null.