trace

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SchemaVersion           = 1
	MaxTraces               = 1_000
	MaxTraceFiles           = 1_000
	MaxTraceRowBytes        = 256 * 1_024
	MaxTraceStoreBytes      = 16 * 1_024 * 1_024
	MaxTracePaths           = 200
	MaxAdmissionCandidates  = 200_000
	MaxVerificationCommands = 50
	MaxCommandCharacters    = 512
	MaxTaskCharacters       = 2_000
)
View Source
const (
	StateAbsent = "absent"
	StateReady  = "ready"
)

Variables

This section is empty.

Functions

func AdmissibleCurrentPaths

func AdmissibleCurrentPaths(values, trackedPaths []string) ([]string, error)

AdmissibleCurrentPaths classifies a bounded complete changed-path set through the same per-path admission primitive NewRecord uses. Malformed input fails; valid paths outside the exact tracked source set are filtered.

func AdmissionFailureReason

func AdmissionFailureReason(err error) string

AdmissionFailureReason returns the bounded reason for an exact changed-path admission failure. It is empty for errors outside that classifier.

func CandidateRevisions

func CandidateRevisions(root string) ([]string, error)

CandidateRevisions returns the bounded, pinned revision filenames currently in the store.

func CandidateRevisionsForAppend

func CandidateRevisionsForAppend(root string) ([]string, error)

CandidateRevisionsForAppend permits only the single persistent operation-lock overage that an interrupted exact-cap append can leave after recovery.

func Encode

func Encode(record Record) ([]byte, error)

Encode returns the exact Python-compatible canonical JSONL bytes for record.

func IsDrift

func IsDrift(err error) bool

IsDrift reports a candidate-set, file-byte, pathname, or directory-binding change observed while a pinned trace read was in flight.

func RecoverInterruptedAppend

func RecoverInterruptedAppend(root string, checkStable func() error, validateBeforeMutation func() error) (resultErr error)

RecoverInterruptedAppend resolves retention residue for the explicit record path before strict candidate discovery. Read paths never call it. Validation runs only when recovery would mutate the trace store.

func StorePath

func StorePath(root, revision string) string

StorePath returns the Python-compatible path for a revision candidate.

func TransformLegacy

func TransformLegacy(data []byte, treeRevision, commitRevision string, trackedPaths []string) ([]byte, error)

TransformLegacy rewrites validated tree-named rows to a commit revision.

func VerificationFailureReason

func VerificationFailureReason(err error) string

VerificationFailureReason returns the bounded reason for an exact verification-command failure. It is empty for other errors.

Types

type Input

type Input struct {
	Revision     string
	TreeRevision string
	Task         string
	OpenedPaths  []string
	ChangedPaths []string
	Verification []string
	Outcome      string
}

Input contains the caller-controlled fields of a new trace record.

type MigrationAuthority

type MigrationAuthority struct {
	CommitRevision string
	TreeRevision   string
	ObjectFormat   string
	DirtyPaths     []string
	ProfileID      string
	Commits        map[string]Revision
	Trees          map[string][]string
	TrackedPaths   func(string) ([]string, error)
}

MigrationAuthority is the immutable repository evidence used to classify trace files.

type MigrationEntry

type MigrationEntry struct {
	TreeRevision   string `json:"tree_revision"`
	CommitRevision string `json:"commit_revision"`
	SourceSHA256   string `json:"source_sha256"`
	TargetSHA256   string `json:"target_sha256"`
	RowCount       int    `json:"row_count"`
	// contains filtered or unexported fields
}

MigrationEntry is one legacy tree file and its canonical commit replacement.

type MigrationPlan

type MigrationPlan struct {
	Authority  MigrationAuthority
	Digest     string
	Entries    []MigrationEntry
	Candidates []migrationCandidate
}

MigrationPlan is a fully validated, byte-bound trace migration plan.

func ApplyMigration

func ApplyMigration(root string, authority MigrationAuthority, digest string, checkStable func() error) (MigrationPlan, error)

ApplyMigration validates the digest before mutation, locks, replans, and publishes verified files.

func PlanMigration

func PlanMigration(root string, authority MigrationAuthority, checkStable func() error) (MigrationPlan, error)

PlanMigration validates the entire trace store without writing it.

func (MigrationPlan) Result

func (plan MigrationPlan) Result(apply bool) MigrationResult

Result converts a plan to the public command result.

type MigrationResult

type MigrationResult struct {
	Mutates             bool
	Mode                string
	PlanDigest          string
	CommitRevision      string
	TreeRevision        string
	CandidateTraceFiles int
	LegacyTraceFiles    int
	TraceRows           int
	Entries             []MigrationEntry
}

MigrationResult is the Python-compatible public command result.

type Record

type Record struct {
	SchemaVersion int
	Revision      string
	TraceID       string
	Task          string
	OpenedPaths   []string
	ChangedPaths  []string
	Verification  []string
	Outcome       string
}

Record is the schema-version 1 JSONL record shared with the Python runtime. Slices are always normalized to non-nil values by constructors and decoders.

func DecodeStore

func DecodeStore(data []byte, revision string, trackedPaths []string) ([]Record, error)

DecodeStore validates one revision file and preserves its row order.

func NewRecord

func NewRecord(input Input, trackedPaths []string) (Record, error)

NewRecord applies the Python writer's normalization and computes TraceID.

type Revision

type Revision struct {
	TreeRevision     string
	Legacy           bool
	TrackedPaths     []string
	AncestryDistance int
}

Revision binds one candidate filename to one immutable repository snapshot.

type Store

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

Store owns bounded, stable reads and appends beneath .context-corvint/traces. checkStable must revalidate the caller's clean commit/tree snapshot.

func NewStore

func NewStore(root string, revisions map[string]Revision, checkStable func() error) (*Store, error)

NewStore freezes revision authority and tracked paths for one repository snapshot.

func (*Store) Append

func (store *Store) Append(record Record) (written bool, resultErr error)

Append atomically publishes one canonical row. It returns false when the row already exists.

func (*Store) Read

func (store *Store) Read() ([]Record, string, error)

Read validates the complete candidate set and returns records sorted by TraceID.

Jump to

Keyboard shortcuts

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