Documentation
¶
Overview ¶
Package contracts loads and checks the product contracts registry (contracts/registry.yaml): the list of customer-observable invariants, the code that implements each one, and the tests that must fail if it breaks.
It answers two questions, both mechanically:
- Validate: is the registry itself sound? Every enforced contract names tests that exist and are not skipped, and code paths that exist.
- Impact: comparing a base revision's registry to the head tree, was a contract weakened? The BASE registry is the reference, so editing the registry in the same change as the implementation cannot hide it.
The package makes no decision about whether a contract change is right. It only makes the change impossible to land unnoticed: an unrecorded weakening fails, and a recorded one is listed in the gate summary with its reason. No human approval is part of the gate. See docs/engineering/PRODUCT-CONTRACTS.md.
Index ¶
Constants ¶
const ( StatusEnforced = "enforced" StatusOpen = "open" )
Status values. A contract is either enforced by tests or open: recorded because it matters, but contradictory or undecided, so nothing may claim it as an approved rule yet.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Contract ¶
type Contract struct {
ID string `yaml:"id"`
Area string `yaml:"area"`
Invariant string `yaml:"invariant"`
Status string `yaml:"status"`
OwnerApproved bool `yaml:"owner_approved"`
Authority string `yaml:"authority"`
Code []string `yaml:"code"`
Configs []string `yaml:"configs"`
Transitions Transitions `yaml:"transitions"`
Tests []TestRef `yaml:"tests"`
Validation string `yaml:"validation"`
Compatibility string `yaml:"compatibility"`
Question string `yaml:"question"`
}
Contract is one registry entry.
type Impact ¶
type Impact struct {
// Touched lists contracts whose code paths include a changed file. It is
// information for the reviewer, not a failure.
Touched []string
// Weakened lists contract changes that happened without an explicit
// record. Always a failure.
Weakened []string
// Recorded lists intentional changes, reported in the summary but never a
// failure: contracts changed or removed with a new amended/retired record,
// and edits to protected paths (the gate's own files).
Recorded []string
}
Impact is the result of comparing a base registry with the head tree.
type Record ¶
Record is an explicit, reviewable statement that a contract was changed or removed on purpose.
type Registry ¶
type Registry struct {
Version int `yaml:"version"`
Protected []string `yaml:"protected"`
Contracts []Contract `yaml:"contracts"`
Amended []Record `yaml:"amended"`
Retired []Record `yaml:"retired"`
}
Registry is the whole file.
type Transitions ¶
type Transitions struct {
Permitted []string `yaml:"permitted"`
Forbidden []string `yaml:"forbidden"`
}
Transitions lists the state changes a contract allows and forbids.