changewitness

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: 8 Imported by: 0

Documentation

Overview

Package changewitness is the experimental pure evaluator for the `ocm-change-witnessed-v0` relation (docs/specs/change-witness-relation-v0.md).

It decides, for one OCM obligation, whether a referenced hunk changes lines inside the unique Go definition its requirement span names. It reads no path, index, network, or worktree: every input is bytes the caller took from verified Git objects. No Frontier profile consumes it yet; `frontier/0` neither emits nor recognises the relation (CWR-V0-001).

Index

Constants

View Source
const (
	Relation       = "ocm-change-witnessed-v0"
	AuthorityClass = "VERIFIER_DERIVED"
)

Relation is the CWR-V0-001 relation string; AuthorityClass is CWR-V0-003's.

View Source
const (
	Witnessed = "witnessed"
	Withheld  = "withheld"
	Abstained = "abstained"
)

Outcomes (CWR-V0-015).

View Source
const (
	ReasonNotLinked         = "OBLIGATION_NOT_LINKED"
	SelfAuthoredObligation  = "SELF_AUTHORED_OBLIGATION"
	ReasonSourceUnparsed    = "RESOLVER_SOURCE_UNPARSED"
	ReasonNoNamedIdentifier = "NO_NAMED_IDENTIFIER"
	ReasonNoIntersection    = "NO_MATERIAL_INTERSECTION"
	ReasonIneligibleHunk    = "INELIGIBLE_WITNESS_HUNK"
	IdentifierUnresolved    = "IDENTIFIER_UNRESOLVED"
	IdentifierAmbiguous     = "IDENTIFIER_AMBIGUOUS"
	LanguageUnsupported     = "RESOLVER_LANGUAGE_UNSUPPORTED"
)

Reasons and diagnostic codes (CWR-V0-015). Only SelfAuthoredObligation is a Frontier reason; an abstained obligation keeps its frontier/0 reason.

Variables

This section is empty.

Functions

This section is empty.

Types

type Diagnostic

type Diagnostic struct {
	Code  string
	Count int
}

Diagnostic is a value-free count (CWR-V0-011).

type Hunk

type Hunk struct {
	ID, Path, Disposition string
	WhitespaceOnly        bool
	Changed               []LineRange
}

Hunk is one canonical CEM hunk. Changed holds its target-side changed line ranges; WhitespaceOnly marks a hunk the verifier reverified as whitespace-only or line-ending-only (CF-V0-008).

type Input

type Input struct {
	Disposition string   // OCM obligation disposition
	IntentPath  string   // OCM intent path
	TargetSpan  []byte   // requirement span bytes at the target revision
	BasePresent bool     // intent path and obligation ID both exist at the expected base
	BaseSpan    []byte   // requirement span bytes at the expected base
	Sources     []Source // every blob of the target tree; only `.go` paths are read
	Hunks       []Hunk   // hunks the obligation structurally references
}

Input is one obligation's verified relation inputs.

type LineRange

type LineRange struct{ Start, Count int }

LineRange is a 1-based start and a line count; a zero count is empty.

type Result

type Result struct {
	Outcome, Reason string
	HunkIDs         []string
	Witnesses       []Witness
	Diagnostics     []Diagnostic
}

Result is one evaluation. Witnesses is set only when Outcome is Witnessed; HunkIDs only when Withheld (CWR-V0-009 keeps the referenced hunk IDs).

func Evaluate

func Evaluate(in Input) Result

Evaluate applies CWR-V0-004's conditions in order and reports the first that fails, or every qualifying witness.

type Source

type Source struct {
	Path, BlobOID string
	Bytes         []byte
}

Source is one target-revision blob read from Git objects.

type Witness

type Witness struct {
	Identifier, Path, BlobOID string
	StartLine, EndLine        int
	HunkID                    string
}

Witness is one qualifying identifier/definition/hunk triple.

Jump to

Keyboard shortcuts

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