Documentation
¶
Overview ¶
Package wire reads and validates CEM 0.1/0.2 wire documents.
The reader is a strict JSON parser implementing interop/cem-0.1/ALGORITHMS.md "JSON and version dispatch": it rejects malformed UTF-8, duplicate object keys at any depth, non-integer or non-finite numbers, integers outside 0..9007199254740991, unpaired surrogates after JSON decoding, and inputs nested deeper than the documented operational depth bound.
Index ¶
- Constants
- Variables
- func Canonical(spec string) bool
- func CanonicalString(text string) string
- func CanonicalValue(value Value) []byte
- func EvidenceIdentity(blobOid, path string, span Span, spanSha256 string) string
- func HunkIdentity(contentSha256 string, oldPath, newPath *string, oldRange, newRange Range) string
- func IsGitOid(text string) bool
- func IsSha256(text string) bool
- func MechanicalReason(spec, reason string) bool
- func ValidatePath(path string) error
- func ValidateTestRun(text string) error
- func WriteCanonicalValue(output *strings.Builder, value Value)
- type Basis
- type CoverageWitness
- type DiscriminationBounds
- type DiscriminationWitness
- type Evidence
- type Hunk
- type Kind
- type Map
- type Object
- type Range
- type Span
- type SurvivingMutant
- type Value
Constants ¶
const ( Spec01 = "cem/0.1" Spec02 = "cem/0.2" Spec03 = "cem/0.3" ExcludedCEMPath = ".corvint/change.cem.json" MaxMapBytes = 4 << 20 MaxEvidence = 4096 MaxHunks = 2048 MaxBases = 32 MaxPathBytes = 512 EvidencePrefix = "evidence:sha256:" HunkPrefix = "hunk:sha256:" )
Frozen wire constants.
const ( CoverageCovered = "covered" CoverageUncovered = "uncovered" MaxTestRunBytes = 256 )
Frozen coverage witness vocabulary.
const ( DiscriminationDiscriminates = "discriminates" DiscriminationSurvived = "survived" DiscriminationNotRun = "not-run" MaxDiscriminationTextBytes = 512 )
Frozen discrimination witness vocabulary.
const MaxWireInteger = 9007199254740991
MaxWireInteger is the largest integer a CEM wire document may carry.
Variables ¶
var Relations = map[string]bool{ "call-site": true, "decision": true, "dependency": true, "implementation": true, "incident": true, "specification": true, "test-claim": true, }
Relations enumerates the frozen basis relations.
var StructuralReasons = map[string]bool{ "rename": true, "move": true, "import-reorder": true, "formatter-only": true, }
StructuralReasons enumerates the cem/0.3 mechanical reasons proved by Go structural comparison (CEM-SM-001); 0.1 and 0.2 documents reject them.
Functions ¶
func Canonical ¶ added in v0.7.0
Canonical reports whether spec is a canonical committed-change profile: cem/0.2, or cem/0.3 which adds the structural reason vocabulary and the optional hunk coverage witness.
func CanonicalString ¶
CanonicalString encodes one JSON string with the frozen escape profile.
func CanonicalValue ¶
CanonicalValue encodes one strict JSON value in the frozen canonical form: UTF-8, lexicographically sorted object keys, minimal separators, shortest signed decimal integers, no terminal LF. It is the single implementation of the `canonical-json-value` primitive every content address in the workspace hashes over, so a second approximation would silently fork identity.
func EvidenceIdentity ¶
EvidenceIdentity derives the frozen evidence ID for one evidence record.
func HunkIdentity ¶
HunkIdentity derives the frozen hunk ID. oldPath and newPath are nil for the created-from and deleted-to sides respectively.
func MechanicalReason ¶ added in v0.7.0
MechanicalReason reports whether reason is registered for spec.
func ValidatePath ¶
ValidatePath enforces the frozen relative POSIX path grammar.
func ValidateTestRun ¶ added in v0.7.0
ValidateTestRun checks the verbatim test run identity a coverage witness records: non-empty, at most MaxTestRunBytes, and free of control characters.
func WriteCanonicalValue ¶
WriteCanonicalValue appends the canonical encoding of value to output.
Types ¶
type CoverageWitness ¶ added in v0.7.0
type CoverageWitness struct {
ProfileSha256 string
TestRun string
Mode string
State string
Covered []Range
}
CoverageWitness is one hunk's optional cem/0.3 patch-coverage witness: the added lines one identified test run executed according to one local coverprofile (TCQ-V0-051). Covered ranges are one-based new-side line ranges inside the hunk's newRange, ascending and non-adjacent; an empty list is State CoverageUncovered, never an omitted witness.
type DiscriminationBounds ¶ added in v0.7.0
DiscriminationBounds are the caps one discriminate run declared.
type DiscriminationWitness ¶ added in v0.7.0
type DiscriminationWitness struct {
TreeRevision string
SelectionSha256 string
Mutants int64
Killed int64
Survived int64
Survivors []SurvivingMutant
Bounds DiscriminationBounds
State string
Detail string
}
DiscriminationWitness is one hunk's optional cem/0.3 mutation witness: whether the tests its test claims cite kill bounded mutants of the hunk's new-side lines on one tree revision (TCQ-V0-056). Survivors describe every mutant that lived; a hunk the run never judged carries State DiscriminationNotRun with zero counts and its Detail, never an omitted witness.
type Hunk ¶
type Hunk struct {
ID string
Path string
OldRange Range
NewRange Range
Disposition string
Reason string
Basis []Basis
Coverage *CoverageWitness
Discriminates *DiscriminationWitness
}
Hunk is one mapped patch hunk. Coverage and Discriminates are nil unless a cem/0.3 witness is recorded.
type Map ¶
type Map struct {
Spec string
BaseRevision string
PatchSha256 string
ExcludedPath string // empty for 0.1; the frozen literal for 0.2 and 0.3
Evidence []Evidence
Hunks []Hunk
}
Map is a validated CEM 0.1, 0.2, or 0.3 document.
type SurvivingMutant ¶ added in v0.7.0
SurvivingMutant is one mutant the selected tests let live.