provenance

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package provenance labels untrusted content and removes prompt-injection spans before that content is handed to the main agent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Redact

func Redact(text string, spans []Span) string

Types

type Classifier

type Classifier interface {
	Classify(ctx context.Context, text string) ([]Span, error)
}

Classifier is deliberately isolated from tools and conversation state.

func ClassifierForConfig

func ClassifierForConfig(cfg types.Config) (Classifier, error)

ClassifierForConfig constructs the independently configured classifier transport. When no classifier block is present it inherits the main provider for backward compatibility; protection itself remains opt-in.

type Envelope

type Envelope struct {
	ID                  string `json:"id"`
	Origin              Origin `json:"origin"`
	Trust               Trust  `json:"trust"`
	Digest              string `json:"digest"`
	Raw                 string `json:"-"`
	Visible             string `json:"visible"`
	Findings            []Span `json:"findings,omitempty"`
	ClassificationError string `json:"classification_error,omitempty"`
}

Envelope keeps the immutable source identity separate from the model-visible text. Digest always describes Raw, including when Visible has been redacted.

func NewExternal

func NewExternal(ctx context.Context, id, kind, locator, raw string, classifier Classifier) Envelope

func (Envelope) ModelText

func (e Envelope) ModelText() string

func (Envelope) Suspicious

func (e Envelope) Suspicious() bool

type LLMClassifier

type LLMClassifier struct {
	LLM   cogito.LLM
	Model string
}

LLMClassifier runs a dedicated, context-free model pass. It receives no conversation history and advertises no tools. The model returns exact quotes; nib derives byte offsets itself instead of trusting model arithmetic.

func (LLMClassifier) Classify

func (c LLMClassifier) Classify(ctx context.Context, text string) ([]Span, error)

type Origin

type Origin struct {
	Kind    string `json:"kind"`
	Locator string `json:"locator,omitempty"`
}

type Span

type Span struct {
	Start int    `json:"start"`
	End   int    `json:"end"`
	Label string `json:"label"`
}

type Trust

type Trust string
const (
	TrustUser     Trust = "user"
	TrustLocal    Trust = "local"
	TrustExternal Trust = "external"
)

Jump to

Keyboard shortcuts

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