pack

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package pack turns ranked candidates into a budgeted injection envelope. Granularity ladder per card: body (≤400 tok) → summary → hook line. The budget is under-filled to ~90% so token-estimation error can never blow the hard cap (C3).

Index

Constants

View Source
const PointerHeader = `` /* 189-byte string literal not displayed */

PointerHeader is the one-time SessionStart preface that teaches the model what ▸ pointer lines are and how to pull them (plan §6). Without it a fresh session sees bare pointers with no in-band instruction and tends to ignore them. Its token cost is charged against the baseline budget by the caller.

Variables

This section is empty.

Functions

This section is empty.

Types

type BodyLoader

type BodyLoader func(rowids []int64) (map[int64]string, error)

BodyLoader hydrates bodies for the few cards packed at body granularity — the hot-path scan deliberately omits bodies.

type Injection

type Injection struct {
	Items  []Item
	Tokens int
}

Injection is the rendered result. Empty Items ⇒ inject nothing.

func Pack

func Pack(cands []retrieve.Candidate, injected map[string]int, budget int, load BodyLoader) (Injection, error)

Pack fills the budget greedily in rank order. injected holds the session's prior granularity levels (monotonic dedup: a card re-emits only at a strictly higher level).

func (Injection) Records

func (inj Injection) Records() []store.InjectionRecord

Records converts packed items into injection-log rows.

func (Injection) Render

func (inj Injection) Render() string

Render produces the final envelope string ("" when nothing packed).

func (Injection) RenderWith

func (inj Injection) RenderWith(header string) string

RenderWith prefaces the envelope with a non-card header line (e.g. PointerHeader). Header text is never recorded in the injection log — it is instruction, not knowledge, so 14.43's dedup does not apply.

type Item

type Item struct {
	CardID      string
	ShortID     string
	Granularity string
	Tokens      int
	Text        string
}

Item is one packed card at one granularity.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL