Documentation
¶
Overview ¶
Package agentcontext preserves source-asserted agent records separately from kernel observations and analysis. Missing source information remains unknown.
Index ¶
- Constants
- Variables
- func Number(n int64) *int64
- func ToolNodeID(e Entry) string
- type Candidate
- type ContentRef
- type Counts
- type Coverage
- type DiscoverOptions
- type Entry
- type EntryLinks
- type GraphLink
- type Inventory
- type Issue
- type Overview
- type Page
- type PageOptions
- type ParseBudget
- type ParseOptions
- type Parsed
- type PriorRange
- type Record
- type SaveResult
- type SelectOptions
- type SelectedSource
- type Selection
- type Service
- func (s Service) CompareSnapshots(ctx context.Context, runID, leftID, rightRunID, rightID string) (SnapshotComparison, error)
- func (s Service) Entries(ctx context.Context, opts PageOptions) (Page, error)
- func (s Service) ImportFile(ctx context.Context, runID string, opts ParseOptions) (SaveResult, error)
- func (s Service) Links(ctx context.Context, runID, entryID string) (EntryLinks, error)
- func (s Service) Overview(ctx context.Context, runID string) (Overview, error)
- func (s Service) ReadHandler() http.Handler
- func (s Service) Save(ctx context.Context, runID string, src Source, records []Record, ...) (SaveResult, error)
- type SnapshotChange
- type SnapshotComparison
- type SnapshotValue
- type Source
- type SourceCursor
- type Status
Constants ¶
const ( MaxDiscoveryFiles = 4096 MaxDiscoveryVisits = 20000 MaxDiscoveryBytes = 256 << 20 )
const ( CurrentExecution = "current_execution" PriorContext = "prior_context" )
const ( ParserVersion = "context-parser/v9" MaxInputBytes = 128 << 20 MaxLineBytes = 40 << 20 MaxRecords = 25000 )
const SchemaVersion = "agentprovenance.agent_context/v1"
Variables ¶
var ErrInvalidArgument = errors.New("invalid context argument")
Functions ¶
func ToolNodeID ¶
ToolNodeID namespaces a native call identity by run and actor. Transcript and hook channels can describe the same invocation, while separate runs cannot overwrite each other's graph nodes when a harness reuses a call ID.
Types ¶
type Candidate ¶
type Candidate struct {
Path string `json:"path"`
SessionID string `json:"session_id"`
ParentSessionID string `json:"parent_session_id,omitempty"`
AgentID string `json:"agent_id,omitempty"`
Workdir string `json:"workdir,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
ModifiedAt time.Time `json:"modified_at"`
Size int64 `json:"size"`
Cursor SourceCursor `json:"cursor"`
Issue string `json:"issue,omitempty"`
}
type ContentRef ¶
type Counts ¶
type Counts struct {
Discovered *int64 `json:"discovered"`
Matched *int64 `json:"matched"`
Read *int64 `json:"read"`
Parsed *int64 `json:"parsed"`
Stored *int64 `json:"stored"`
Duplicates *int64 `json:"duplicates"`
Truncated *int64 `json:"truncated"`
Failed *int64 `json:"failed"`
Unrecognized *int64 `json:"unrecognized"`
Deferred *int64 `json:"deferred"`
}
Counts are observations over one processing range, not estimates of all activity. Nil means unknown; a successful empty scan can explicitly report 0.
type Coverage ¶
type Coverage struct {
SchemaVersion string `json:"schema_version"`
ID string `json:"id"`
RunID string `json:"run_id"`
Source Source `json:"source"`
Status Status `json:"status"`
ObservedAt string `json:"observed_at"`
LastSuccessAt string `json:"last_success_at,omitempty"`
StartedAt string `json:"started_at,omitempty"`
EndedAt string `json:"ended_at,omitempty"`
FirstLine int64 `json:"first_line,omitempty"`
LastLine int64 `json:"last_line,omitempty"`
Counts Counts `json:"counts"`
Issues []Issue `json:"issues"`
MissingFields []string `json:"missing_fields"`
ObjectHash string `json:"object_hash,omitempty"`
PriorContext *PriorRange `json:"prior_context,omitempty"`
}
type DiscoverOptions ¶
type DiscoverOptions struct {
Harness string
Root string
// CatalogRoot optionally locates Codex state catalogs outside the scan root.
// No ambient home directory is consulted for explicitly acquired sources.
CatalogRoot string
Workdir string
SessionID string
// Snapshot captures a pre-execution cursor for candidates in this workdir.
Snapshot bool
}
type Entry ¶
type Entry struct {
SchemaVersion string `json:"schema_version"`
ID string `json:"id"`
RunID string `json:"run_id"`
Source Source `json:"source"`
SourceKey string `json:"source_key"`
Sequence int64 `json:"sequence"`
// SourceOrdinal is the normalized record's position within its physical
// source line. Zero means older evidence did not record that position.
SourceOrdinal int64 `json:"source_ordinal,omitempty"`
Kind string `json:"kind"`
Role string `json:"role,omitempty"`
AgentID string `json:"agent_id,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
ToolName string `json:"tool_name,omitempty"`
Status string `json:"status,omitempty"`
RecordedAt string `json:"recorded_at,omitempty"`
Content ContentRef `json:"content"`
RawContent ContentRef `json:"raw_content"`
MissingFields []string `json:"missing_fields,omitempty"`
EvidenceRefs []string `json:"evidence_refs,omitempty"`
ObjectHash string `json:"object_hash,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
ExecutionScope string `json:"execution_scope,omitempty"`
}
type EntryLinks ¶
type Inventory ¶
type Inventory struct {
Harness string `json:"harness"`
Root string `json:"root"`
CatalogRoot string `json:"catalog_root,omitempty"`
Candidates []Candidate `json:"candidates"`
Complete bool `json:"complete"`
Issues []Issue `json:"issues"`
}
Inventory contains identities and resume boundaries, never conversation text. An incomplete inventory cannot establish a unique automatic binding.
type Overview ¶
type Overview struct {
SchemaVersion string `json:"schema_version"`
RunID string `json:"run_id"`
Coverage []Coverage `json:"coverage"`
Messages *int64 `json:"messages"`
ToolCalls *int64 `json:"tool_calls"`
ToolResults *int64 `json:"tool_results"`
Snapshots *int64 `json:"snapshots"`
HasMoreSources bool `json:"has_more_sources"`
RuntimeCoverage observability.RuntimeCoverage `json:"runtime_coverage"`
}
type PageOptions ¶
type ParseBudget ¶
ParseBudget bounds a sequence of source imports, including decompressed input and records that are later rejected or deduplicated. It is not concurrency-safe. A nil budget keeps the normal per-source limits; zero means exhausted.
type ParseOptions ¶
type ParseOptions struct {
Harness string
Path string
SessionID string
ParentSessionID string
AgentID string
Binding string
BindingEvidence []string
// AfterLine is a physical source cursor captured before a resumed execution.
// Earlier records are retained as prior context, never current execution.
AfterLine int64
Cursor *SourceCursor
Budget *ParseBudget
}
type PriorRange ¶
type PriorRange struct {
FirstLine int64 `json:"first_line"`
LastLine int64 `json:"last_line"`
StartedAt string `json:"started_at,omitempty"`
EndedAt string `json:"ended_at,omitempty"`
Counts Counts `json:"counts"`
MissingFields []string `json:"missing_fields"`
}
PriorRange describes the retained prefix separately from the current range. These records supply historical context, not evidence of execution in this run.
type Record ¶
type Record struct {
Key string
Sequence int64
SourceOrdinal int64
Kind string
Role string
AgentID string
ToolCallID string
ToolName string
Status string
RecordedAt string
Body *string
RawBody *string
MediaType string
MissingReason string
MissingFields []string
ExecutionScope string
// Parsed values are position-specific, including unknown values. Nil lets
// explicit Record callers use the source defaults.
Workdir *string
ApplicationVersion *string
}
Record is a parser's transient output. Body never appears in the entry index or diagnostics: it is redacted and stored as bounded content-addressed chunks.
type SaveResult ¶
type SelectOptions ¶
type SelectedSource ¶
type SelectedSource struct {
Candidate
AfterLine int64 `json:"after_line"`
Binding string `json:"binding"`
BindingEvidence []string `json:"binding_evidence"`
ResumeCursor *SourceCursor `json:"resume_cursor,omitempty"`
}
func (SelectedSource) ParseOptions ¶
func (s SelectedSource) ParseOptions(harness string) ParseOptions
type Selection ¶
type Selection struct {
Sources []SelectedSource `json:"sources"`
Status Status `json:"status"`
Issues []Issue `json:"issues"`
}
func SelectSources ¶
func SelectSources(ctx context.Context, before, after Inventory, opts SelectOptions) Selection
SelectSources never chooses by mtime. Without a native identity, only one new root session with matching cwd and a source timestamp in the run window can match. A resumed session requires an explicit identity and a verified prefix.
type Service ¶
func (Service) CompareSnapshots ¶
func (Service) ImportFile ¶
func (s Service) ImportFile(ctx context.Context, runID string, opts ParseOptions) (SaveResult, error)
func (Service) Links ¶
Links exposes existing graph relationships, never a new matching inference. A result without a projected call deliberately has no execution destination.
func (Service) ReadHandler ¶
ReadHandler is shared by the local dashboard and daemon. It only resolves registered objects within the requested run; it never accepts disk paths.
func (Service) Save ¶
func (s Service) Save(ctx context.Context, runID string, src Source, records []Record, report Coverage) (SaveResult, error)
Save atomically appends immutable record revisions and a processing report. Re-reading unchanged records is a no-op; a late result or changed snapshot is a new revision. Neither a retry nor a parse failure deletes earlier evidence.
type SnapshotChange ¶
type SnapshotChange struct {
Path string `json:"path"`
Before SnapshotValue `json:"before"`
After SnapshotValue `json:"after"`
}
type SnapshotComparison ¶
type SnapshotComparison struct {
SchemaVersion string `json:"schema_version"`
Scope string `json:"scope"`
Status string `json:"status"`
Left Entry `json:"left"`
Right Entry `json:"right"`
Changes []SnapshotChange `json:"changes"`
HasMore bool `json:"has_more"`
Reason string `json:"reason,omitempty"`
}
SnapshotComparison compares recorded values, not effective permissions. An absent field means "not recorded here", never allowed, denied, or revoked.
type SnapshotValue ¶
type Source ¶
type Source struct {
ID string `json:"id"`
Harness string `json:"harness"`
Channel string `json:"channel,omitempty"`
SessionID string `json:"session_id"`
ParentSessionID string `json:"parent_session_id,omitempty"`
AgentID string `json:"agent_id,omitempty"`
Path string `json:"path,omitempty"`
ParserVersion string `json:"parser_version"`
ApplicationVersion string `json:"application_version,omitempty"`
FormatVersion string `json:"format_version,omitempty"`
Binding string `json:"binding"`
BindingEvidence []string `json:"binding_evidence,omitempty"`
Workdir string `json:"workdir,omitempty"`
}
type SourceCursor ¶
type SourceCursor struct {
Lines int64 `json:"lines"`
Bytes int64 `json:"bytes"`
SHA256 string `json:"sha256"`
Valid bool `json:"valid"`
}
A cursor hashes complete decompressed physical lines. A growing final line stays outside the prefix and is retried, including in concatenated zstd files.