Documentation
¶
Overview ¶
Package commitintent defines the durable, pure queue record that sits before an effectful fak commit drain.
The package deliberately does not run git, inspect the live index, take locks, or push. It validates and orders submit records so a later single-writer drain can consume one deterministic stream.
Index ¶
- Constants
- Variables
- func DefaultQueueDir(repoRoot string) string
- func MarshalQueue(q Queue) ([]byte, error)
- func MarshalRecord(rec SubmitRecord) ([]byte, error)
- func MarshalSelection(sel Selection) ([]byte, error)
- func NormalizeHexDigest(digest, field string) (string, error)
- func NormalizeID(id string) (string, error)
- func NormalizePath(raw string) (string, error)
- func NormalizePaths(paths []string) ([]string, error)
- func NormalizeSHA(sha string) (string, error)
- func PathDigest(paths []string) string
- func Submit(q Queue, now time.Time, intent Intent) (Queue, SubmitRecord, error)
- func ValidateIntent(in Intent) error
- func ValidateIntentForBase(in Intent, currentBaseSHA string) error
- func ValidateMetadata(meta StampMetadata) error
- func ValidateQueue(q Queue) error
- func ValidateRecord(rec SubmitRecord) error
- func ValidateStamp(stamp Stamp) error
- func ValidateState(state State) error
- func ValidateSubject(subject string) error
- func ValidateTier(t Tier) error
- type DrainPlan
- type FieldError
- type Intent
- type InvalidRecord
- type Provenance
- type QualityCase
- type Queue
- type Selection
- type Stamp
- type StampKind
- type StampMetadata
- type State
- type Store
- type SubmitRecord
- type Surface
- type SurfaceRule
- type Tier
Constants ¶
const ( QueueSchema = "fak.commit-intent.queue.v1" RecordSchema = "fak.commit-intent.submit.v1" )
const ( StoreDirName = "commit-intents" StoreQueueFile = "queue.json" StoreLockFile = "queue.lock" )
const SelectionSchema = "fak.commit-intent.quality-selection.v1"
SelectionSchema versions the quality-case selection emitted for a changed surface set.
Variables ¶
Functions ¶
func DefaultQueueDir ¶
func MarshalQueue ¶
func MarshalRecord ¶
func MarshalRecord(rec SubmitRecord) ([]byte, error)
func MarshalSelection ¶ added in v0.41.0
MarshalSelection renders a selection as a stable, newline-terminated JSON artifact. The artifact carries only surface labels, changed paths, and provenance identifiers — no request content — so it is safe to attach to a failure as a replay record.
func NormalizeHexDigest ¶
func NormalizeID ¶
func NormalizePath ¶
func NormalizePaths ¶
func NormalizeSHA ¶
func PathDigest ¶
func ValidateIntent ¶
func ValidateIntentForBase ¶
func ValidateMetadata ¶
func ValidateMetadata(meta StampMetadata) error
func ValidateQueue ¶
func ValidateRecord ¶
func ValidateRecord(rec SubmitRecord) error
func ValidateStamp ¶
func ValidateState ¶
func ValidateSubject ¶
func ValidateTier ¶ added in v0.41.0
ValidateTier reports whether t is one of the explicit PR, nightly, or release tiers a quality case may be assigned to.
Types ¶
type DrainPlan ¶
type DrainPlan struct {
Ready []SubmitRecord `json:"ready"`
Stale []SubmitRecord `json:"stale"`
Invalid []InvalidRecord `json:"invalid"`
}
type FieldError ¶
func (FieldError) Error ¶
func (e FieldError) Error() string
func (FieldError) Unwrap ¶
func (e FieldError) Unwrap() error
type Intent ¶
type Intent struct {
ID string `json:"id"`
BaseSHA string `json:"base_sha"`
Paths []string `json:"paths"`
PathDigest string `json:"path_digest"`
DiffDigest string `json:"diff_digest,omitempty"`
Subject string `json:"subject"`
Stamp Stamp `json:"stamp"`
Metadata StampMetadata `json:"metadata,omitempty"`
}
func NormalizeIntent ¶
type InvalidRecord ¶
type InvalidRecord struct {
Record SubmitRecord `json:"record"`
Error string `json:"error"`
}
type Provenance ¶ added in v0.41.0
type Provenance struct {
Model string `json:"model,omitempty"`
Tokenizer string `json:"tokenizer,omitempty"`
Engine string `json:"engine,omitempty"`
Oracle string `json:"oracle"`
Revision string `json:"revision"`
Baseline string `json:"baseline"`
Tolerance string `json:"tolerance,omitempty"`
}
Provenance records how a quality case is pinned so a failure is replayable and a pass is trustworthy: the model/tokenizer/engine under test, the seed or deterministic oracle, the code/module revision, and the tolerance/baseline it is scored against. Oracle, Revision, and Baseline are mandatory — without them a "pass" is not independently verifiable.
type QualityCase ¶ added in v0.41.0
type QualityCase struct {
Surface Surface `json:"surface"`
Tier Tier `json:"tier"`
Cost string `json:"cost"`
Rationale string `json:"rationale"`
MatchedPaths []string `json:"matched_paths,omitempty"`
Provenance Provenance `json:"provenance"`
}
QualityCase is a single case the selector picked for a changed surface, with the tier it runs in, its runtime/resource cost, the rationale for the choice, the changed paths that triggered it, and its provenance.
type Queue ¶
type Queue struct {
Schema string `json:"schema"`
NextSequence int64 `json:"next_sequence"`
Records []SubmitRecord `json:"records"`
}
func ParseQueue ¶
type Selection ¶ added in v0.41.0
type Selection struct {
Schema string `json:"schema"`
Revision string `json:"revision"`
Cases []QualityCase `json:"cases"`
UnknownPaths []string `json:"unknown_paths,omitempty"`
Expanded bool `json:"expanded"`
Inconclusive bool `json:"inconclusive"`
}
Selection is the deterministic plan of quality cases for one changed path set. Expanded is set when an unknown path forced full-surface coverage; Inconclusive is set when no path could be classified, so downstream must treat the sentinel-only plan as "unproven", never as a silent empty pass.
func SelectCases ¶ added in v0.41.0
func SelectCases(changed []string, rev string, rules []SurfaceRule) (Selection, error)
SelectCases maps changed onto the quality cases that must run for revision rev. It is pure and deterministic: identical inputs yield an identical Selection. Passing nil rules uses DefaultSurfaceRules.
A changed path that no rule maps is recorded in UnknownPaths and forces Expanded coverage — every surface is selected — because an unclassified change could regress anywhere. When no path can be classified at all the Selection is Inconclusive and carries only the sentinel case, so an empty selection can never be read as "nothing to check".
func SelectForIntent ¶ added in v0.41.0
func SelectForIntent(intent Intent, rules []SurfaceRule) (Selection, error)
SelectForIntent maps a commit intent's normalized changed paths onto the quality cases that must run before the intent drains, using the intent's base SHA as the code/module revision.
type Stamp ¶
type Stamp struct {
Kind StampKind `json:"kind"`
Leaf string `json:"leaf,omitempty"`
Text string `json:"text,omitempty"`
}
func StampFromSubject ¶
type StampMetadata ¶
type Store ¶
type SubmitRecord ¶
type SubmitRecord struct {
Schema string `json:"schema"`
Sequence int64 `json:"sequence"`
SubmittedAt time.Time `json:"submitted_at"`
State State `json:"state"`
Intent Intent `json:"intent"`
}
func Ordered ¶
func Ordered(records []SubmitRecord) []SubmitRecord
func ParseRecord ¶
func ParseRecord(data []byte) (SubmitRecord, error)
type Surface ¶ added in v0.41.0
type Surface string
Surface is a quality-bearing engine surface a changed path can touch. A diff is mapped onto surfaces so the matching quality cases run; a path no rule maps is treated as unknown and expands coverage rather than silently passing.
type SurfaceRule ¶ added in v0.41.0
type SurfaceRule struct {
Surface Surface
Match []string
Tier Tier
Cost string
Provenance Provenance
}
SurfaceRule maps changed paths onto one Surface. Match holds lowercase path substrings; a changed path whose lowercased form contains any of them selects the rule's surface. Provenance carries the case defaults; its Revision is filled per selection.
func DefaultSurfaceRules ¶ added in v0.41.0
func DefaultSurfaceRules() []SurfaceRule
DefaultSurfaceRules is the built-in diff→surface mapping. Matching is coarse and explainable — a path substring names the surface — so an operator can read why a case was picked. Unmapped paths are handled by expansion, not by silently guessing a surface.