recall

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package recall defines input and paging contracts and an activity-side evidence handler. Workflows own allowance charging and dispatch.

Index

Constants

View Source
const (
	// Read consumes the read allowance.
	Read Kind = "read"
	// List consumes the discovery allowance.
	List Kind = "list"
	// Find consumes the discovery allowance.
	Find Kind = "find"
	// Result selects eligible result, message or summary text.
	Result Part = "result"
	// Arguments selects a tool call's original arguments.
	Arguments Part = "arguments"
	// Attachment selects one non-text user-message part.
	Attachment Part = "attachment"
)
View Source
const (
	// Description contains all model-facing discovery and paging guidance.
	Description = `` /* 1606-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func EncodeCursor

func EncodeCursor(cursor Cursor) (string, error)

EncodeCursor returns deterministic, unpadded base32. It signs no authority.

func NewCitationResolver

func NewCitationResolver(ctx context.Context, source index.Source, entries []index.MessageEntry, through index.MessageID) checkpoint.CitationResolver

NewCitationResolver binds current-run citations to authorized canonical entries. Like K13's default nil RunChain, it resolves no rN labels before K18. Source must already be authorized for the activity's root run scope.

func Spec

func Spec() tools.ToolSpec

Spec returns an owned tool spec without registering or advertising it.

func ValidateToolName

func ValidateToolName(identifier tools.Ident, providerName string) error

ValidateToolName rejects identifiers and provider names that expose the reserved lookup name in rendered receipts. Registration invokes this for application tools when compaction is enabled; the runtime-owned spec is exempt.

Types

type Access

type Access struct{ SessionID, RunID, TargetRunID, Scope string }

Access identifies a run reached through verified transcript evidence.

type AttachmentInfo

type AttachmentInfo struct {
	Message string `json:"message,omitzero"`
	Run     string `json:"run,omitzero"`
	Part    int    `json:"part"`
	Kind    string `json:"kind"`
	Format  string `json:"format"`
	Bytes   int    `json:"bytes"`
	Tokens  int    `json:"tokens"`
}

AttachmentInfo identifies an original message part without exposing its bytes.

type Code

type Code string

Code is a stable model-facing recall outcome.

const (
	// CodeBudgetExhausted reports an exhausted read or discovery allowance.
	CodeBudgetExhausted Code = "recall_budget_exhausted"
	// CodeNotFound reports an ID or selector absent from the reachable chain.
	CodeNotFound Code = "recall_not_found"
	// CodeUnauthorized reports session or authorizer denial.
	CodeUnauthorized Code = "recall_unauthorized"
	// CodeUnavailable reports content removed by retention.
	CodeUnavailable Code = "recall_unavailable"
	// CodeInvalidInput reports malformed arguments or cursor encoding.
	CodeInvalidInput Code = "recall_invalid_input"
	// CodeUnsupportedPart reports a non-text part pending multimodal recall.
	CodeUnsupportedPart Code = "recall_unsupported_part"
)

type Cursor

type Cursor struct {
	Kind     Kind        `json:"kind"`
	Handle   string      `json:"handle,omitempty"`
	Range    *Range      `json:"range,omitempty"`
	Scan     string      `json:"scan,omitempty"`
	Position int         `json:"position"`
	Anchor   *FindAnchor `json:"anchor,omitempty"`
}

Cursor is an untrusted continuation selector, never a capability. A handler must re-resolve its selector through the current checkpoint chain on every call and bind it to the requested operation before using Position.

func DecodeCursor

func DecodeCursor(token string) (Cursor, error)

DecodeCursor checks only encoding and shape. Even a successfully decoded selector and position must pass chain resolution and authorization later.

type Error

type Error struct {
	Code Code `json:"code"`
}

Error carries a structured code without exposing parser or store details.

func (*Error) Error

func (e *Error) Error() string

Error returns the stable code, without caller-authored input fragments.

type FindAnchor

type FindAnchor struct {
	Run   string          `json:"run"`
	Entry index.MessageID `json:"entry"`
	Chunk int             `json:"chunk"`
}

FindAnchor identifies an immutable entry and its text/call chunk in scan order. Position in the enclosing cursor is a byte offset within this chunk.

type FindInput

type FindInput struct {
	Text   string `json:"text"`
	Cursor string `json:"cursor,omitempty"`
}

FindInput searches for a literal, case-sensitive UTF-8 string.

type Handler

type Handler struct {
	Store     runstore.Store
	Sessions  session.Store
	Chain     RunChain
	Authorize func(context.Context, Access) error
}

Handler reads only model-eligible evidence reachable from the activity envelope.

func (Handler) Handle

func (h Handler) Handle(ctx context.Context, req Request, in Input) (Response, error)

Handle resolves a parsed input. Stable rejections are results; infrastructure faults are errors so durable engines retry rather than invent missing evidence.

type Input

type Input struct {
	Kind Kind       `json:"-"`
	Read *ReadInput `json:"read,omitempty"`
	List *ListInput `json:"list,omitempty"`
	Find *FindInput `json:"find,omitempty"`
}

Input contains exactly one operation. ParseInput preserves a recognized Kind on validation failure; callers charge discovery when Kind is empty.

func ParseInput

func ParseInput(data []byte) (Input, error)

ParseInput validates the exactly-one operation envelope without resolving IDs or cursors. A malformed recognized operation keeps its Kind for charging.

type Kind

type Kind string

Kind selects the allowance and operation even for malformed known inputs.

type Line

type Line struct {
	ID    string `json:"id"`
	Run   string `json:"run,omitzero"`
	Kind  string `json:"kind"`
	Text  string `json:"text,omitzero"`
	Bytes int    `json:"bytes,omitzero"`
	Error bool   `json:"error,omitzero"`
}

Line is a bounded model-visible receipt or message descriptor.

type ListInput

type ListInput struct {
	Handle  string          `json:"handle,omitempty"`
	From    index.MessageID `json:"from,omitempty"`
	Through index.MessageID `json:"through,omitempty"`
	Run     string          `json:"run,omitempty"`
	Cursor  string          `json:"cursor,omitempty"`
}

ListInput selects either a collapsed handle or an inclusive message range.

type Match

type Match struct {
	ID            string `json:"id"`
	Part          Part   `json:"part"`
	Run           string `json:"run,omitzero"`
	Offset        int    `json:"offset"`
	SnippetOffset int    `json:"snippet_offset"`
	Snippet       string `json:"snippet"`
}

Match locates literal eligible text and its bounded surrounding excerpt.

type Part

type Part string

Part selects the model-visible result or original tool arguments.

type Range

type Range struct {
	From    index.MessageID `json:"from"`
	Through index.MessageID `json:"through"`
	Run     string          `json:"run,omitempty"`
}

Range is the inclusive message range and optional run label of a listing.

type ReadInput

type ReadInput struct {
	ID     string `json:"id"`
	Run    string `json:"run,omitempty"`
	Part   Part   `json:"part"`
	Offset int    `json:"offset"`
	Index  int    `json:"index,omitzero"`
}

ReadInput addresses eligible content. Offset is a nonnegative byte offset.

type Request

type Request struct {
	Parts                model.ToolResultPartSupport
	PartTokens           int
	RunID, Scope         string
	View                 index.ViewRef
	Head                 runstore.Hash
	PageBytes, ScanBytes int
}

Request is the trusted activity envelope, never caller-supplied tool arguments.

type Response

type Response struct {
	Parts       []model.ToolResultContentPart `json:"-"`
	Attachments []AttachmentInfo              `json:"attachments,omitzero"`
	Attachment  *AttachmentInfo               `json:"attachment,omitzero"`
	Reason      string                        `json:"reason,omitzero"`
	LimitUnit   string                        `json:"limit_unit,omitzero"`
	Limit       int                           `json:"limit,omitzero"`
	Code        Code                          `json:"code,omitzero"`
	Text        string                        `json:"text,omitzero"`
	NextOffset  *int                          `json:"next_offset,omitzero"`
	Entries     []Line                        `json:"entries,omitzero"`
	Matches     []Match                       `json:"matches,omitzero"`
	ReadHint    string                        `json:"read_hint,omitzero"`
	Cursor      string                        `json:"cursor,omitzero"`
	Format      string                        `json:"format,omitzero"`
	Bytes       int                           `json:"bytes,omitzero"`
}

Response is the model-facing result. Cursor and NextOffset continue bounded pages.

type RunChain

type RunChain interface {
	Resolve(context.Context, string, string) (index.RunCheckpoint, error)
	Head(context.Context, string, string) (runstore.Hash, error)
}

RunChain resolves displayed labels and index heads. K13's default (nil) resolves no rN labels; K18 supplies the production continuation chain.

Jump to

Keyboard shortcuts

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