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 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 ValidatePath(path string) error
- func WriteCanonicalValue(output *strings.Builder, value Value)
- type Basis
- type Evidence
- type Hunk
- type Kind
- type Map
- type Object
- type Range
- type Span
- type Value
Constants ¶
const ( Spec01 = "cem/0.1" Spec02 = "cem/0.2" 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 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.
Functions ¶
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 ValidatePath ¶
ValidatePath enforces the frozen relative POSIX path grammar.
func WriteCanonicalValue ¶
WriteCanonicalValue appends the canonical encoding of value to output.
Types ¶
type Hunk ¶
type Hunk struct {
ID string
Path string
OldRange Range
NewRange Range
Disposition string
Reason string
Basis []Basis
}
Hunk is one mapped patch hunk.
type Map ¶
type Map struct {
Spec string
BaseRevision string
PatchSha256 string
ExcludedPath string // empty for 0.1; the frozen literal for 0.2
Evidence []Evidence
Hunks []Hunk
}
Map is a validated CEM 0.1 or 0.2 document.