analyst

package
v0.16.8 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: BSD-3-Clause, GPL-3.0 Imports: 27 Imported by: 0 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 analyst implements finite, explicitly included capture investigations.

Index

Constants

View Source
const MaxDecodedBytes int64 = 128 << 20
View Source
const MaxRecords = 100000
View Source
const ReviewedLogFile = "analyst-reviewed-log.json"
View Source
const WorkspaceFile = "analyst-workspace.json"
View Source
const WorkspaceLockFile = ".analyst-workspace.lock"

Variables

View Source
var ErrBusy = errors.New("analyst workspace is leased; stale locks require explicit operator removal")
View Source
var ErrStale = errors.New("analyst evidence binding is stale")

Functions

func ApproveLog

func ApproveLog(ctx context.Context, dir string, review LogReview) error

func AtomicJSON

func AtomicJSON(ctx context.Context, dir, name string, data []byte, validate func() error) error

func CatalogueFields

func CatalogueFields() map[string]map[string][]string

func Check

func Check(ctx context.Context, dir string, expected Binding) error

func CheckDiagnostic

func CheckDiagnostic(ctx context.Context, dir string, expected Binding) error

func DecodeStrict

func DecodeStrict(data []byte, value any) error

func Digest

func Digest(data []byte) string

func IsHash

func IsHash(s string) bool

func Match

func Match(q Query, msg proto.Message, typ string) []string

func RecordJSON

func RecordJSON(msg proto.Message) (json.RawMessage, error)

func Resolve

func Resolve(ctx context.Context, dir string, ref Reference) (json.RawMessage, error)

func Scan

func Scan(ctx context.Context, dir string, binding Binding, recordType string, visit func(Reference, proto.Message) error) (string, error)

func ValidateQuery

func ValidateQuery(q Query) error

func Walk

func Walk(ctx context.Context, dir string, binding Binding, recordType string, visit func(Reference, proto.Message) error) error

Walk hashes the stored audit file and each original protobuf frame. A callback result must not be published until Walk succeeds and file/generation checks finish.

Types

type Binding

type Binding struct {
	RunID          string `json:"runId"`
	SourceSHA256   string `json:"sourceSHA256"`
	ManifestSHA256 string `json:"manifestSHA256"`
}

func Bind

func Bind(ctx context.Context, dir string) (Binding, error)

func BindDiagnostic

func BindDiagnostic(ctx context.Context, dir string) (Binding, error)

type Catalogue

type Catalogue struct {
	SnapshotSHA256   string       `json:"snapshotSHA256,omitempty"`
	TotalOccurrences int          `json:"totalOccurrences"`
	NextOffset       *int         `json:"nextOffset,omitempty"`
	Version          int          `json:"version"`
	Query            Query        `json:"query"`
	Sources          []Source     `json:"sources"`
	Coverage         []Coverage   `json:"coverage"`
	Occurrences      []Occurrence `json:"occurrences"`
	Novelty          string       `json:"novelty"`
	Limitations      []string     `json:"limitations"`
}

func Paginate

func Paginate(result Catalogue, page *CataloguePage, expected string) (Catalogue, error)
func Search(ctx context.Context, sources []Source, q Query) (Catalogue, error)

Search performs a finite scan of the explicitly supplied sources. Source zero is the target; later sources are the declared novelty baseline, never an estate.

type CataloguePage

type CataloguePage struct {
	Offset int `json:"offset"`
	Limit  int `json:"limit"`
}

type CatalogueRequest

type CatalogueRequest struct {
	Page                   *CataloguePage    `json:"page,omitempty"`
	ExpectedSnapshotSHA256 string            `json:"expectedSnapshotSHA256,omitempty"`
	Sources                []SourceSelection `json:"sources"`
	Query                  Query             `json:"query"`
}

type Coverage

type Coverage struct {
	FileSHA256         string  `json:"fileSHA256,omitempty"`
	SourceID           string  `json:"sourceId"`
	Binding            Binding `json:"binding"`
	Type               string  `json:"type"`
	State              string  `json:"state"`
	Records            int     `json:"records"`
	QualifiedRecords   int     `json:"qualifiedRecords"`
	UnqualifiedRecords int     `json:"unqualifiedRecords"`
}

type Document

type Document struct {
	CatalogueSnapshotSHA256 string            `json:"catalogueSnapshotSHA256,omitempty"`
	IncludedSources         []SourceSelection `json:"includedSources"`
	ID                      string            `json:"id"`
	Revision                int               `json:"revision"`
	Kind                    string            `json:"kind"`
	Title                   string            `json:"title"`
	Body                    string            `json:"body"`
	Binding                 Binding           `json:"binding"`
	Query                   *Query            `json:"query,omitempty"`
	References              []Reference       `json:"references"`
	Review                  string            `json:"review"`
	Reviewer                string            `json:"reviewer,omitempty"`
	UpdatedAt               string            `json:"updatedAt"`
}

func SaveDocument

func SaveDocument(ctx context.Context, dir string, binding Binding, doc Document, expected int) (saved Document, resultErr error)

SaveDocument uses revision CAS and an atomic private-file replacement. Reviewed content cannot be edited without explicitly returning it to draft.

type InspectRequest

type InspectRequest struct {
	Source SourceSelection `json:"source"`
}

type LogReview

type LogReview struct {
	Version          int           `json:"version"`
	Binding          Binding       `json:"binding"`
	File             string        `json:"file"`
	FileSHA256       string        `json:"fileSHA256"`
	Start            int           `json:"start"`
	End              int           `json:"end"`
	Lines            []SafeLogLine `json:"lines"`
	ProjectionSHA256 string        `json:"projectionSHA256"`
	State            string        `json:"state"`
}

func PreviewLog

func PreviewLog(ctx context.Context, dir string, binding Binding, name string, start, end int) (LogReview, error)

func ReviewedLog

func ReviewedLog(ctx context.Context, dir string, binding Binding) (LogReview, error)

type LogReviewRequest

type LogReviewRequest struct {
	Source  SourceSelection `json:"source"`
	File    string          `json:"file"`
	Start   int             `json:"start"`
	End     int             `json:"end"`
	Approve *LogReview      `json:"approve,omitempty"`
}

type Occurrence

type Occurrence struct {
	SourceID  string    `json:"sourceId"`
	Reference Reference `json:"reference"`
	Fields    []string  `json:"fields"`
	Endpoints []string  `json:"endpoints"`
}

type OccurrencesRequest

type OccurrencesRequest struct {
	Source SourceSelection `json:"source"`
	Type   string          `json:"type"`
}

type Query

type Query struct {
	Kind  string   `json:"kind"`
	Value string   `json:"value"`
	Types []string `json:"types"`
}

type Reference

type Reference struct {
	Version      int     `json:"version"`
	Binding      Binding `json:"binding"`
	Type         string  `json:"type"`
	File         string  `json:"file"`
	FileSHA256   string  `json:"fileSHA256"`
	Ordinal      string  `json:"ordinal"`
	RecordSHA256 string  `json:"recordSHA256"`
	TimestampNs  string  `json:"timestampNs"`
}

type ResolveRequest

type ResolveRequest struct {
	Source    SourceSelection `json:"source"`
	Reference Reference       `json:"reference"`
}

type SafeLogLine

type SafeLogLine struct {
	Ordinal int      `json:"ordinal"`
	SHA256  string   `json:"sha256"`
	Classes []string `json:"classes"`
}

type Source

type Source struct {
	ID        string  `json:"id"`
	Binding   Binding `json:"binding"`
	Directory string  `json:"-"`
}

type SourceSelection

type SourceSelection struct {
	SessionID string  `json:"sessionId,omitempty"`
	InputFile string  `json:"inputFile,omitempty"`
	Binding   Binding `json:"binding"`
}

SourceSelection never permits an implicit active-capture fallback.

type Workspace

type Workspace struct {
	Version   int        `json:"version"`
	Binding   Binding    `json:"binding"`
	Documents []Document `json:"documents"`
}

func LoadWorkspace

func LoadWorkspace(ctx context.Context, dir string, binding Binding) (Workspace, error)

type WorkspaceRequest

type WorkspaceRequest struct {
	Source           SourceSelection `json:"source"`
	Document         *Document       `json:"document,omitempty"`
	ExpectedRevision int             `json:"expectedRevision"`
}

Jump to

Keyboard shortcuts

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