Documentation
¶
Overview ¶
Package summarize provides pure eligible-evidence rendering, deterministic summary chunk planning and ordered validation. It does not load or store content.
Index ¶
- Constants
- func AnnotateReceipts(lines []index.ReceiptLine, plan Plan) ([]index.ReceiptLine, error)
- func RenderChunk(prompt, previous string, chunk Chunk) *model.Request
- type ByteRange
- type Chunk
- type ChunkOptions
- type Evidence
- type Input
- type PartAnnotation
- type Piece
- type Plan
- type Rejection
- type Unit
- type Validation
- type ValidationInput
Constants ¶
const MaxSummaryChunks = 8
MaxSummaryChunks bounds sequential summariser calls per compaction.
Variables ¶
This section is empty.
Functions ¶
func AnnotateReceipts ¶
func AnnotateReceipts(lines []index.ReceiptLine, plan Plan) ([]index.ReceiptLine, error)
AnnotateReceipts copies K12's lines and attaches exact inclusive byte ranges and non-text annotations. It never mutates previous immutable receipts.
func RenderChunk ¶
RenderChunk frames every evidence line as quoted data. The rendered running summary is bounded at the table rate to OutputTokens, including quote prefixes. Prompt must be the same rendered prompt supplied to PlanChunks.
Types ¶
type ByteRange ¶
type ByteRange struct {
MessageID index.MessageID
Part int
ToolUseID string
Start, End int
// IsResult binds ranges to original result bytes rather than call arguments.
IsResult bool
}
ByteRange is a half-open byte interval in a Unit's full eligible Text. ToolUseID binds result ranges to the call's receipt; Part identifies other text.
type ChunkOptions ¶
type ChunkOptions struct {
// MaxSummaryChunks and MaxSummarisedResultTokens override the default rules.
MaxSummaryChunks int
MaxSummarisedResultTokens int
Limits model.ContextLimits
MaxSummaryTokens int
Prompt string
// PromptFor measures a resolved custom template using the same quoted data as the actual call.
PromptFor func(previous string, chunk Chunk) (string, error)
}
ChunkOptions uses recorded summariser limits and the agent's summary cap.
type Evidence ¶
type Evidence struct {
Previous string
Units []Unit
Annotations []PartAnnotation
}
Evidence keeps full eligible input, independent of planner caps or view omissions.
func RenderInput ¶
RenderInput projects full eligible canonical evidence without view omissions. Contents must come from the authorized access layer: Record, Output and injected call fields are never selected. Hidden declarations are scanned beyond the cut.
type Input ¶
type Input struct {
Entries []index.MessageEntry
Contents map[runstore.Hash][]byte
From, To index.MessageID
CurrentPos, SummaryPos int
Previous string
AcceptsImages, AcceptsDocuments bool
RecallNames []string
}
Input supplies authorized canonical contents and entries. Entries include bookkeeping declarations after the cut; only [From, To) is summarized.
type PartAnnotation ¶
type PartAnnotation struct {
MessageID index.MessageID
Part int
ToolUseID, Kind, Format string
Bytes int
}
PartAnnotation identifies a non-text part excluded from summary requests.
func (PartAnnotation) String ¶
func (p PartAnnotation) String() string
String is the receipt annotation required for an unsupported part.
type Plan ¶
type Plan struct {
Budget, OutputTokens int
Chunks []Chunk
Unsummarised []ByteRange
Annotations []PartAnnotation
}
Plan carries call inputs and annotations for integration into K12 receipts.
func PlanChunks ¶
func PlanChunks(evidence Evidence, options ChunkOptions) (Plan, error)
PlanChunks uses only recorded limits, the uncalibrated 1/3 table rate, and integer arithmetic. Every request reserves a full running summary plus 10% of the input budget. Result caps apply to raw eligible bytes, not quoted framing. Out <= (window-Out)/4 uses floor(window/5); when window mod 5 is 4 this is conservatively one token below floor(Bs/4), which has no exact integer solution.
type Rejection ¶
type Rejection struct{ Kind string }
Rejection names the first contract failure; infrastructure errors stay errors.
type Unit ¶
type Unit struct {
MessageID index.MessageID
Part int
ToolUseID, Label, Text string
Attachment model.Part
IsResult bool
}
Unit is one labelled eligible part. Result Text is exact stored JSON, so byte ranges address the original result without a decoding/re-encoding step.
type Validation ¶
type Validation struct {
CitedUsers []checkpoint.UserLine
LooseRefs int
}
Validation returns canonical record-authored cited lines in citation order.
func Validate ¶
func Validate(in ValidationInput) (Validation, error)
Validate checks first-failure order before a checkpoint can be stored. Size estimation and citation-resolution infrastructure errors are returned intact. Earlier-run citations delegate to the recorded continuation resolver.
type ValidationInput ¶
type ValidationInput struct {
Text, StopReason string
Unfinished, DefaultPrompt bool
SummaryBytes, ReplacedTokens int
RenderedCheckpoint func(string) (int, error)
CurrentPos int
To index.MessageID
Resolver checkpoint.CitationResolver
RecallNames []string
}
ValidationInput supplies the current exact summary-section byte allowance, the old checkpoint plus evicted VIEW estimate, and the new rendered checkpoint estimate (including reselected pins). Estimates use the same K12 units.