tcq

package
v0.8.1 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: 12 Imported by: 0

Documentation

Overview

Package tcq implements Test Claim Qualification V0 (`tcq/0`) as specified in docs/specs/test-claim-qualification-v0.md.

TCQ is a deterministic, source-body-free matcher over one verified OCM, only its selected claim anchors, their exact target-tree test units, and optionally one command plus one JUnit observation. It emits one result per selected `(obligationId, claimId)` edge.

Every emitted edge carries `authorityClass: CALLER_REPORTED` (TCQ-V0-006). The single positive relation `test-report-matched-v0` is a caller report, never execution attestation: per TCQ-V0-046 no consumer may alias it to harness-observed or mechanically proved execution, and no input can select another authority class.

Per TCQ-V0-045 this package is library and wire conformance only. It adds no CLI, no filesystem path API, no artifact persistence, and no runner: every raw artifact arrives as caller-supplied immutable bytes, and target source is read exclusively through the inherited CEM/OCM repository boundary (TCQ-V0-044).

Index

Constants

View Source
const (
	Profile          = "tcq/0"
	CommandSpec      = "test-command/0.1-experimental"
	ObservationSpec  = "test-observation/0.1-experimental"
	ReportFormat     = "junit-xml/corvint-v0"
	AuthorityClass   = "CALLER_REPORTED"
	MatchedRelation  = "test-report-matched-v0"
	OCMSpec          = "ocm/0.1-experimental"
	CEMCanonicalSpec = "cem/0.2"
	ClaimExtractor   = "corvint-test-claim/1"
)

Frozen profile and vocabulary constants (TCQ-V0-023, TCQ-V0-031, TCQ-V0-036).

View Source
const (
	CleanTargetAttested    = "CALLER_ATTESTED_CLEAN"
	CleanTargetNotAttested = "NOT_ATTESTED"
)

Clean-target attestations (TCQ-V0-024). Both are unauthenticated caller statements; only CALLER_ATTESTED_CLEAN can participate in the V0 relation, and neither is verifier evidence.

View Source
const (
	CodeInvalidInput               = "invalid-tcq-input"
	CodeUnsupportedCEMProfile      = "unsupported-cem-profile"
	CodeUnsupportedOCMProfile      = "unsupported-ocm-profile"
	CodeUnsupportedClaimExtractor  = "unsupported-claim-extractor"
	CodeInvalidCommand             = "invalid-command"
	CodeNoncanonicalCommand        = "noncanonical-command"
	CodeCommandTargetMismatch      = "command-target-mismatch"
	CodeCommandCwdUnavailable      = "command-cwd-unavailable"
	CodeInvalidObservation         = "invalid-observation"
	CodeNoncanonicalObservation    = "noncanonical-observation"
	CodeObservationTargetMismatch  = "observation-target-mismatch"
	CodeObservationCommandMismatch = "observation-command-mismatch"
	CodeReportDigestMismatch       = "report-digest-mismatch"
	CodeInvalidJUnit               = "invalid-junit"
	CodeReportCommandInconsistent  = "report-command-inconsistent"
	CodeInvalidTCQ                 = "invalid-tcq"
	CodeNoncanonicalTCQ            = "noncanonical-tcq"
	CodeResourceExhausted          = "tcq-resource-exhausted"

	// Inherited codes TCQ re-raises at its own stages (TCQ-V0-042 step 4/5).
	CodeExpectedBaseRequired = "expected-base-required"
	CodeTargetRequired       = "target-required"
	CodeBaseRevisionMismatch = "base-revision-mismatch"
	CodeTargetMismatch       = "target-mismatch"
	CodeObjectUnavailable    = "repository-object-unavailable"
	CodeNoncanonicalMap      = "noncanonical-map"
)

The exact operational vocabulary TCQ adds on top of the inherited CEM/OCM, repository, and Git codes (TCQ-V0-042).

View Source
const (
	AssociationAssociated = "ASSOCIATED"
	AssociationAbstained  = "ABSTAINED"

	HygieneEligible   = "ELIGIBLE"
	HygieneIneligible = "INELIGIBLE"
	HygieneAbstained  = "ABSTAINED"

	ReportNotMatched = "NOT_MATCHED"
	ReportPassed     = "PASSED"
	ReportFailed     = "FAILED"
	ReportError      = "ERROR"
	ReportSkipped    = "SKIPPED"
	ReportAmbiguous  = "AMBIGUOUS"
)

Axis values (TCQ-V0-006). No axis rewrites another and none is a confidence, coverage, proof, or generic success score.

View Source
const ReasonTestFlaky = reasonTestFlaky

ReasonTestFlaky is the TCQ-V0-049 flake diagnostic. It is exported because every Corvint test provider emits the shared rule's reason, never its own.

Variables

This section is empty.

Functions

func Flaky added in v0.7.0

func Flaky(statuses []string) bool

Flaky is the shared TCQ-V0-049 rule: one test's terminal statuses, observed at one target revision under one environment variant across two or more observations, diverge when more than one distinct status appears. Every Corvint test provider derives its flake qualification from this function; the caller supplies the grouping and TCQ supplies the judgement.

func MakeTestCommand

func MakeTestCommand(argv []string, cwd, runnerIdentity, runnerVersion, targetRevision, cleanTarget string) ([]byte, error)

MakeTestCommand builds one canonical `test-command/0.1-experimental` artifact. It is a declaration, never an instruction: TCQ neither executes the command nor claims that retaining it makes execution reproducible (TCQ-V0-025).

func MakeTestObservation

func MakeTestObservation(repository Repository, commandRaw, reportRaw []byte, targetRevision string, exitCode int64) ([]byte, error)

MakeTestObservation projects one caller-supplied JUnit report under one command into a canonical observation. Per TCQ-V0-029 an exit code of zero alongside any failed or errored testcase is `report-command-inconsistent`. The observation declares no environment variant (TCQ-V0-048).

func MakeTestObservationInEnvironment added in v0.7.0

func MakeTestObservationInEnvironment(repository Repository, commandRaw, reportRaw []byte, targetRevision string, exitCode int64, environment map[string]string) ([]byte, error)

MakeTestObservationInEnvironment is MakeTestObservation with a declared TCQ-V0-048 environment variant. A nil environment declares none; a non-nil map, even an empty one, is the declared variant and enters the observation ID.

Types

type ClaimResult

type ClaimResult struct {
	ObligationID       string
	ClaimID            string
	AnchorProfile      string
	AssociationKind    string
	AssociationState   string
	HygieneState       string
	ReportState        string
	TestUnitID         string
	ExecutionKeySha256 string
	RowIDs             []string
	Reasons            []string
	Relation           string
	// AuthorityClass is CALLER_REPORTED for every edge, including abstentions
	// (TCQ-V0-006). It is carried rather than assumed so no future producer can
	// silently upgrade it.
	AuthorityClass string
}

ClaimResult is one selected claim edge, in the shape of the reference vector at docs/specs/test-claim-qualification-v0.md:391. Empty string stands for the document's `null` in the nullable fields.

type Error

type Error struct {
	Code string
}

Error is one bounded operational failure. Per TCQ-V0-042 an operational error emits no partial artifact and no unverified path, OID, digest, selector, count, command argument, XML value, or derived identity — so the code alone is the payload and Message never carries input-derived text.

func (*Error) Error

func (err *Error) Error() string

type Repository

type Repository interface {
	// Blob returns the bytes of one target-tree blob by OID.
	Blob(oid string) ([]byte, error)
	// TreeEntry resolves one normalized repository-relative path at revision.
	// A missing object is (TreeEntry{}, nil), never an error; an error is a
	// failed lookup, which TCQ returns as-is (TCQ-V0-028).
	TreeEntry(revision, path string) (TreeEntry, error)
}

Repository is that inherited boundary. Both methods read the verified target tree only; sibling repositories, alternates, implicit fetch, and additional-repository discovery are forbidden and must be refused by the implementation, not by TCQ.

type Request

type Request struct {
	CEM          []byte
	OCM          []byte
	ExpectedBase string
	Target       string

	// The dynamic tuple is all-or-none (TCQ-V0-033). Any other combination is
	// `invalid-tcq-input`.
	Command     []byte
	Observation []byte
	Report      []byte

	// Expected optionally verifies a cached result byte-for-byte (TCQ-V0-043).
	Expected []byte

	// PriorObservations are earlier observations of the same target for the
	// TCQ-V0-050 flake rule. They require the dynamic tuple, bind the resolved
	// target, and can only remove a relation, never add one.
	PriorObservations [][]byte
}

Request is one TCQ invocation. Every artifact is caller-supplied immutable bytes (TCQ-V0-044); TCQ opens no raw-artifact filesystem path.

type Resolved

type Resolved struct {
	BaseRevision   string
	TargetRevision string
}

Resolved carries the two OIDs the shared CEM/OCM verifier resolved from the independent invocation inputs. TCQ-V0-036 binds these, never values learned from an artifact.

type Result

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

Result and ClaimResult are the producer side of the frozen seam declared in internal/frontier/upstream.go. A shim converts Result.ID/Result.Claims into frontier.TCQResult/TCQClaimResult field for field; this package deliberately does not import frontier, which consumes it. Frontier's TCQRequest carries no CEM bytes, so a shim must supply the canonical `cem/0.2` artifact the OCM binds — TCQ-V0-001 requires it and TCQ-V0-002 refuses `cem/0.1`.

Result is one `tcq/0` document. It is a recomputable local cache, never an authority token or execution record (TCQ-V0-043): Raw is the canonical bytes the identity commits to, and every consumer must recompute rather than trust.

func Evaluate

func Evaluate(repository Repository, verifier UpstreamVerifier, request Request) (Result, error)

Evaluate computes one canonical TCQ result. Operational validation stops at the first failing stage of TCQ-V0-042 and emits no partial artifact.

func (Result) Claims

func (result Result) Claims() []ClaimResult

Claims returns one result per selected edge, in TCQ-V0-003 order.

func (Result) ID

func (result Result) ID() string

ID is the `tcq:sha256:` identity of TCQ-V0-040.

func (Result) ObservationEnvironment added in v0.7.0

func (result Result) ObservationEnvironment() (map[string]string, bool)

ObservationEnvironment returns the verified observation's declared TCQ-V0-048 variant. The second value is false when the invocation was static or the observation declared no environment: the environment is then unknown, and no caller may substitute an empty variant for it.

func (Result) Raw

func (result Result) Raw() []byte

Raw returns the canonical document bytes, terminal LF included.

type TreeEntry

type TreeEntry struct {
	Mode  string
	Type  string
	Found bool
}

TreeEntry is one resolved target-tree object. TCQ never opens a worktree path: TCQ-V0-001 confines every source read to the inherited bounded, sanitized, no-fetch Git boundary.

type UpstreamVerifier

type UpstreamVerifier interface {
	VerifyOCM(cemRaw, ocmRaw []byte, expectedBase, target string) (Resolved, error)
}

UpstreamVerifier is the current OCM verifier, which in turn invokes the shared CEM 0.2 canonical verifier. TCQ-V0-001 requires the same bounded raw byte copies and both revision inputs to pass through it, and TCQ-V0-042 forbids reordering any validation internal to it — hence a seam rather than a reimplementation.

Jump to

Keyboard shortcuts

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