specification

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package specification implements the repository's executable acceptance contracts. It is used by native tests and the evidence command, never by product requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaseFields

func CaseFields(c Case) []string

CaseFields enumerates schema-validated declarative inputs plus expected fields. Every input configures Run's fixture or production adapter; expected values reach the assertions reader, which rejects any unhandled expectation.

func Root

func Root() (string, error)

func Run

func Run(t *testing.T, execute Adapter)

Run owns the full case set and every expectation assertion. Adapters execute production entrypoints; they cannot claim a field or case was consumed.

Types

type Adapter

type Adapter func(*testing.T, Input) Observation

type Binding

type Binding struct {
	File string `json:"file"`
	Name string `json:"name"`
}

type Case

type Case struct {
	ID            string                     `json:"id"`
	Action        string                     `json:"action"`
	Operation     string                     `json:"operation,omitempty"`
	Arguments     []string                   `json:"arguments,omitempty"`
	Format        string                     `json:"format,omitempty"`
	Fixture       string                     `json:"fixture,omitempty"`
	Count         int                        `json:"count,omitempty"`
	FailureStatus int                        `json:"failureStatus,omitempty"`
	FailurePage   int                        `json:"failurePage,omitempty"`
	Value         string                     `json:"value,omitempty"`
	Malformed     bool                       `json:"malformed,omitempty"`
	Want          map[string]json.RawMessage `json:"want"`
	// contains filtered or unexported fields
}

Each action has a closed schema. Raw want fields are read only by the family checker; its destructive reader detects fields that never reach an assertion.

func (*Case) UnmarshalJSON

func (c *Case) UnmarshalJSON(data []byte) error

type Coverage

type Coverage struct {
	Provenance   Provenance `json:"provenance"`
	RunID        string     `json:"runId"`
	Requirements int        `json:"requirements"`
	Cases        int        `json:"cases"`
	Passed       int        `json:"passed"`
	GatePassed   bool       `json:"gatePassed"`
	Receipts     []Receipt  `json:"receipts"`
}

func Collect

func Collect(repo *Repository, reader io.Reader, runID string) (Coverage, error)

Collect joins declarations with independent native Go execution events. A log receipt alone never proves a test ran or passed.

type Document

type Document struct {
	Schema  string `json:"$schema"`
	Version int    `json:"version"`
	Owner   string `json:"owner"`
	Source  struct {
		OpenAPI    string `json:"openapi"`
		Provenance string `json:"provenance"`
	} `json:"source"`
	Requirements []Requirement `json:"requirements"`
}

func ValidateDocument

func ValidateDocument(spec, schema []byte) (Document, error)

type Input

type Input struct {
	ServerURL string
	Arguments []string
	Format    string
	Value     string
	Action    string
}

type NativeEvent

type NativeEvent struct {
	Action  string
	Package string
	Test    string
	Output  string
}

type Observation

type Observation struct {
	Output           string
	Data             any
	Err              error
	Commands         []string
	Violations       int
	Calls            int
	Identity         string
	Completed        bool
	Action           string
	CompletionAction string
}

func Capture

func Capture(t *testing.T, format string, run func() error) Observation

func Execute

func Execute(t *testing.T, cmd *cobra.Command, in Input) Observation

Execute captures the actual production command's stdout. It does not inspect expectations; all assertions remain in Run's closed family consumers.

type Provenance

type Provenance struct {
	WorkingTreeClean bool   `json:"workingTreeClean"`
	Commit           string `json:"commit"`
	SpecSHA256       string `json:"specSha256"`
	SchemaSHA256     string `json:"schemaSha256"`
	SourceSHA256     string `json:"sourceSha256"`
	SourceCommit     string `json:"sourceCommit"`
}

type Receipt

type Receipt struct {
	Requirement string     `json:"requirement"`
	Case        string     `json:"case"`
	NativeName  string     `json:"nativeName"`
	RunID       string     `json:"runId"`
	Provenance  Provenance `json:"provenance"`
	Consumed    []string   `json:"consumed"`
}

type Repository

type Repository struct {
	Root       string
	Document   Document
	API        *openapi3.T
	Router     routers.Router
	Provenance Provenance
	Operations map[string]*openapi3.Operation
}

func Load

func Load(root string) (*Repository, error)

func (*Repository) Requirement

func (r *Repository) Requirement(name string) (Requirement, error)

type Requirement

type Requirement struct {
	ID           string  `json:"id"`
	Scope        string  `json:"scope"`
	Rationale    string  `json:"rationale"`
	Test         Binding `json:"test"`
	Expectations struct {
		Kind  string `json:"kind"`
		Cases []Case `json:"cases"`
	} `json:"expectations"`
}

Directories

Path Synopsis
cmd
evidence command

Jump to

Keyboard shortcuts

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