provenance

package
v1.124.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package provenance answers, at the moment an asset is written, which calls produced it.

It reads the audit log rather than keeping a buffer of its own. The audit log is already the platform's record of every call: it survives a restart, it is shared by every replica, and it holds what a buffer never did — the call's identifier, its stated purpose, how long it took, and whether it succeeded. A per-process map could answer none of that, and answered nothing at all for a session whose calls were served by another replica (issue #1320).

A capture is scoped to the caller: the default window is the caller's own session, and an explicitly cited source is resolved only among the caller's own calls. Nothing here can put another person's query into an asset.

Index

Constants

View Source
const (
	// MaxCalls bounds how many calls one capture records. A capture is a
	// snapshot stored on the asset row, not a copy of the session.
	MaxCalls = 100
)

Variables

This section is empty.

Functions

func KindFor

func KindFor(toolkitKind string) string

KindFor returns the provenance call kind for a toolkit kind, or "" when calls to that toolkit are not asset sources.

func SourceToolkitKinds

func SourceToolkitKinds() []string

SourceToolkitKinds returns the toolkit kinds whose calls can be an asset's source. The call-reference middleware stamps exactly these calls with their own id, so what an agent can cite and what the platform captures by default are one rule rather than two lists that drift.

Types

type Capturer

type Capturer struct {
	// contains filtered or unexported fields
}

Capturer builds an asset write's provenance capture from the audit log.

func New

func New(events EventReader, flush Flusher) *Capturer

New builds a Capturer over the audit log. A nil reader yields a Capturer that records only what the caller states about itself, which is what a deployment with audit disabled gets. The flusher is optional: a synchronous audit writer has nothing to wait for.

func (*Capturer) Capture

Capture resolves the calls behind one asset write.

It never fails the write: an unreadable audit log yields a capture holding only what the caller stated about itself, because an asset that records less provenance is better than an asset that could not be saved.

type EventReader

type EventReader interface {
	Query(ctx context.Context, filter audit.QueryFilter) ([]audit.Event, error)
}

EventReader reads recorded calls back out of the audit log.

type Flusher

type Flusher interface {
	Flush(ctx context.Context) error
}

Flusher waits for already-enqueued audit events to reach the store. The platform's audit writer is asynchronous, so without this the call that most obviously produced the asset — the one that just finished — is the one most likely to be missing when the capture reads.

Jump to

Keyboard shortcuts

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