trajectory

package
v0.10.0 Latest Latest
Warning

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

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

Documentation

Overview

Package trajectory defines the normalized event schema every agent adapter maps its native stream onto. The drift engine and trigger measurement read only this schema, so adding an agent never touches scoring code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Digest

func Digest(s string) string

Digest returns a stable, non-reversible fingerprint of s, or "" for empty input so that callers can omit the field entirely. Digesting the empty string would produce a real-looking hash for a value that was never present.

Types

type Event

type Event struct {
	Seq        int       `json:"seq"`
	TS         time.Time `json:"ts"`
	Type       EventType `json:"type"`
	Name       string    `json:"name,omitempty"`
	ArgsDigest string    `json:"args_digest,omitempty"`
	Paths      []string  `json:"paths,omitempty"`
	// ExitCode is a pointer so that a real exit code of 0 is distinguishable
	// from "no exit code was reported". With a plain int and omitempty, every
	// successful command would serialize as if it had never run.
	ExitCode   *int   `json:"exit_code,omitempty"`
	TextDigest string `json:"text_digest,omitempty"`
}

Event is one normalized step in an agent's trajectory. Arguments and message text are digested rather than stored: trajectories are retained for scoring, and the raw text can contain workspace contents and credentials.

func Contractable

func Contractable(events []Event) []Event

Contractable filters a trajectory down to the events a contract may be scored against, preserving order.

func (Event) Contractable

func (e Event) Contractable() bool

Contractable reports whether the event may be evaluated against a contract.

type EventType

type EventType string

EventType is the normalized event vocabulary.

const (
	TypeMessage    EventType = "message"
	TypeToolCall   EventType = "tool_call"
	TypeToolResult EventType = "tool_result"
	TypeShell      EventType = "shell"
	TypeFileRead   EventType = "file_read"
	TypeFileWrite  EventType = "file_write"
	TypeSkillRead  EventType = "skill_read"
	TypeAskUser    EventType = "ask_user"

	// TypeOpaque is what a parser emits for a native event it does not
	// recognise. Opaque events are recorded but never scored: they are excluded
	// from contract denominators so that an unmapped event — a new tool, a
	// changed CLI format — cannot be counted as a contract violation.
	TypeOpaque EventType = "opaque"
)

Jump to

Keyboard shortcuts

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