trace

package
v1.0.0-rc.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ProducerCLI     = "cli"
	ProducerDogfood = "dogfood"
	ProducerPiTool  = "pi-tool"
	ProducerUnknown = "UNKNOWN"
)

The closed producer set. ProducerUnknown is a read-side label for schema-1 and schema-2 rows; it is never stored.

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"
)
View Source
const (
	SchemaVersionV2  = 2
	MaxArgvArguments = 32
	MaxArgvBytes     = 4096
)
View Source
const SchemaVersionV3 = 3

SchemaVersionV3 adds the closed producer member to either verification shape (LTPM-V0-015). Producer is part of the row identity, so the same observation recorded by two producers yields two distinct trace IDs.

Variables

Producers lists the closed stored set followed by the read-side label, in report order.

Functions

func AdmissibleAggregateCurrentPaths

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

AdmissibleAggregateCurrentPaths is the separate nonlearning aggregate policy. ALO-V0-002/003: ordinary trace admission remains capped at MaxTracePaths.

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 CanonicalArgv

func CanonicalArgv(argv []string) ([]byte, error)

CanonicalArgv returns the compact ASCII-escaped JSON array used in v2 identity and displays. It never joins arguments into an executable command.

func CountProducers

func CountProducers(producers []string) map[string]int

CountProducers returns one count per reportable producer, zeros included (LTPM-V0-016).

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 IsRecordArtifactPath

func IsRecordArtifactPath(path string, objectIDLength int) bool

IsRecordArtifactPath recognizes only the recorder's exact artifact names. It establishes no ownership, safety, or content validity by itself.

func IsTypedJSON

func IsTypedJSON(data []byte) bool

IsTypedJSON reports only the exact schema-2 or schema-3 discriminator; full admission needs DecodeTyped.

func ParseVerificationArgv

func ParseVerificationArgv(data []byte) ([]string, error)

ParseVerificationArgv decodes the public JSON transport without shell parsing. json/v2 rejects invalid UTF-8, unpaired surrogates and trailing JSON values.

func RecordProducers

func RecordProducers(records []Record) []string

RecordProducers returns each record's read-side producer, in order.

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 ReportableProducer

func ReportableProducer(value string) bool

ReportableProducer reports whether value names a producer a report may count or exclude: the stored set plus the read-side UNKNOWN label.

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 ValidProducer

func ValidProducer(value string) bool

ValidProducer reports whether value may be stored in a schema-3 row.

func ValidateRecordStatusPaths

func ValidateRecordStatusPaths(root string, paths []string, objectIDLength int, ownedStage string) error

ValidateRecordStatusPaths proves the read-only path prerequisites for ignoring untracked recorder artifacts in source-status admission. Canonical content is still validated by the store. ownedStage is empty except for Append's exact, descriptor-pinned temporary at its final prepublication stability check.

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
	VerificationArgv [][]string
	Outcome          string
	Producer         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)
	// CommitObject reports whether an unreachable name is still a commit
	// object, which makes its trace file stranded rather than unknown.
	CommitObject func(string) (bool, 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
	StrandedRevisions   []string
}

MigrationResult is the Python-compatible public command result.

type Record

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

Record holds either the immutable schema-v1 command list or schema-v2 typed entries; schema-v3 holds one of the two shapes plus its producer. 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 DecodeTyped

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

DecodeTyped validates a schema-2 or schema-3 row's structure, bounds, screening, canonical values and identity. Repository witnesses remain the caller's responsibility.

func NewRecord

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

NewRecord applies the Python writer's normalization and computes TraceID. Every new record is schema 3 and names its producer.

func WithoutProducers

func WithoutProducers(records []Record, excluded []string) []Record

WithoutProducers returns the records whose producer is not excluded, in order. It copies; the supplied records and the store are never changed.

func (Record) ProducerName

func (record Record) ProducerName() string

ProducerName returns the stored producer, or ProducerUnknown for rows written before schema 3.

func (Record) VerificationArgv

func (record Record) VerificationArgv() [][]string

VerificationArgv returns an owned copy for a second producer validation pass.

func (Record) VerificationCommands

func (record Record) VerificationCommands() []string

VerificationCommands retains command entries when revalidating a typed input.

func (Record) VerificationDisplay

func (record Record) VerificationDisplay() []string

VerificationDisplay keeps argv explicitly labelled as JSON data.

func (Record) VerificationValue

func (record Record) VerificationValue() any

VerificationValue exposes the version's exact JSON shape for receipt and batch projections; callers use it only on validated records.

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) (bool, error)

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

func (*Store) AppendWithStagingCheck

func (store *Store) AppendWithStagingCheck(record Record, check func(string) error) (bool, error)

AppendWithStagingCheck supplies the exact owned temporary to the caller only after its descriptor, bytes and surrounding snapshot have been validated. Earlier checks (including recovery) use the ordinary stability callback.

func (*Store) Read

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

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

type VerificationEntry

type VerificationEntry struct {
	Kind    string
	Command string
	Argv    []string
}

VerificationEntry is a closed schema-v2 union. Exactly the field selected by Kind is populated; Argv retains literal argument boundaries, never shell text.

Jump to

Keyboard shortcuts

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