Documentation
¶
Overview ¶
Package specs reads a project's specification as the project-spec agent (/spec) writes it, .agents/specs/NNN-<name>.md with README.md as the index, and checks it without a model (spec_057_spec_driven SDD-01..05): the title, the status, what each spec depends on, the requirements' IDs, "Done when" and the open questions.
Index ¶
- Constants
- Variables
- func BaselinePath(file string) string
- func DiffPath(file string, at time.Time) string
- func Done(s Spec, l Ledger) bool
- func DoneWhen(text string) string
- func Drift(change, was, now string, judged bool) string
- func EvidenceKind(p string) string
- func Fingerprint(text string) string
- func Hash(text string) string
- func LedgerPath(file string) string
- func SetStatus(text, status string) string
- func Sort(all []Spec)
- func StateOf(ev []Evidence) string
- func Touched(l Ledger, changed map[string]bool) []string
- func UnifiedDiff(name, a, b string) string
- func Unlisted(indexText string, all []Spec) []string
- type Approval
- type Change
- type Evidence
- type Finder
- type Finding
- type Item
- type Ledger
- type Order
- type Spec
- type Symbol
- type Trace
Constants ¶
const ( Traced = "traced" Untraced = "untraced" Implemented = "implemented" Partial = "partial" Missing = "missing" Contradicted = "contradicted" )
The states a requirement's trace can be in: the check without a model says traced (its ID is in the work) or untraced; the model's judgement says implemented, partial, missing or contradicted.
const Dir = ".agents/specs"
Dir is where a workspace's specs live.
const Index = "README.md"
Index is the specs' index file.
const LedgerDir = ".agents/.ledger"
LedgerDir holds what the specification's work is traced to (spec_057_spec_driven SDD-10): specs/<name>.json, a spec's approval and each requirement's trace; baselines/<file>, the text approved; diffs/, a diff for each change to an approved spec.
const MaxEvidence = 8
MaxEvidence is the most evidence kept for one requirement.
Variables ¶
var Statuses = []string{"draft", "approved", "in progress", "implemented", "changed", "retired"}
Statuses are a spec's states, in the order a spec goes through them.
Functions ¶
func BaselinePath ¶
BaselinePath is where the approved text of file is kept.
func Done ¶
Done reports that s is done: approved, unchanged since, and every requirement found in the work (traced, or judged implemented).
func Drift ¶
Drift is why an approved requirement no longer holds, if it doesn't: "changed" (since approval), "lost" (no longer found in the work: it was before), or "judged" (the model said missing or contradicted).
func EvidenceKind ¶
EvidenceKind says what a file is to a requirement: a test, a document, or code (anything else: scripts, configuration, notebooks).
func Fingerprint ¶
Fingerprint is a requirement's text, normalized (case, spacing and emphasis don't count), hashed: what tells that it changed.
func LedgerPath ¶
Paths in the ledger, for a spec file (002-orders.md).
func SetStatus ¶
SetStatus is text with its Status: line saying status (added after the title when there's none).
func Sort ¶
func Sort(all []Spec)
Sort puts specs in their order: the index first, then by number, then the unnumbered by name.
func StateOf ¶
StateOf is what the evidence says without a model: traced when code, a test or a commit names the requirement, untraced otherwise (documents that only mention it don't implement it).
func Touched ¶
Touched are the approved requirements whose evidence is in one of the changed files (relative, slash-separated): what a turn's changes may have broken (SDD-31).
func UnifiedDiff ¶
UnifiedDiff is a diff of a and b, every changed line with three lines around it, under name's headers.
Types ¶
type Approval ¶
type Approval struct {
At time.Time `json:"at"`
By string `json:"by,omitempty"`
Hash string `json:"hash"`
}
Approval is when a spec was approved, by whom, and its text's hash.
type Evidence ¶
type Evidence struct {
Path string `json:"path"`
Line int `json:"line,omitempty"`
Kind string `json:"kind"`
Text string `json:"text,omitempty"`
}
Evidence is where a requirement was found: a file's line (code, test or doc) or a commit (Path is its hash).
type Finder ¶
type Finder struct {
// Found is the evidence by ID, in the order it was found.
Found map[string][]Evidence
// contains filtered or unexported fields
}
Finder finds requirements' IDs in the work (SDD-12's pass without a model): a file's lines and commit messages that name one.
type Finding ¶
type Finding struct {
// Line is where (1-based; 0 for the whole spec).
Line int
// ID is the requirement it's about, if one.
ID string
// Severity is "error" (the spec can't be traced or ordered as written),
// "warning" (it can, but it's weaker for it) or "info".
Severity string
// Code names the check (no-title, duplicate-id, vague, …).
Code string
Message string
}
Finding is something a check found in a spec.
type Ledger ¶
type Ledger struct {
Spec string `json:"spec"`
Approved *Approval `json:"approved,omitempty"`
Items map[string]*Trace `json:"items"`
}
Ledger is one spec's entry: its approval and its requirements' traces.
func ReadLedger ¶
ReadLedger reads a ledger entry; empty data is an empty one for file.
func (*Ledger) Approve ¶
Approve records s (text) as approved at at by by: each requirement's text and fingerprint. A requirement whose fingerprint is unchanged keeps its verification; a changed one starts over; one gone is dropped.
type Order ¶
Order is where each numbered spec stands (SDD-32): Next is the first in order that isn't done and whose dependencies are; Blocked are, by number, the dependencies not done that each other spec waits for.
type Spec ¶
type Spec struct {
// File is its name in Dir (001-overview.md).
File string
// Number is its place in the order (0 for the index or an unnumbered file).
Number int
// Title is its heading's text, without the number ("Overview").
Title string
// TitleLine is the heading's line (1-based; 0 when there's none).
TitleLine int
// Status is its Status: line, lowercase ("" when there's none).
Status string
StatusLine int
// DependsOn are the numbers its Depends on: line names.
DependsOn []int
DependsOnLine int
// Kind is 001-overview's Kind: line (software, research, …).
Kind []string
// Items are its numbered requirements (or objectives, content).
Items []Item
// DoneWhen reports whether it says how to tell it's finished.
DoneWhen bool
// OpenQuestions are the lines under its Open questions heading.
OpenQuestions []string
}
Spec is one spec file, as read.
type Symbol ¶
type Symbol struct {
Name string
Path string
// Line and Column are the name's (1-based; the column in characters).
Line int
Column int
}
Symbol is a declaration a requirement's evidence sits in: the function, method, type or class whose uses an impact scan follows (SDD-20).
type Trace ¶
type Trace struct {
Text string `json:"text"`
Fingerprint string `json:"fingerprint"`
VerifiedAt *time.Time `json:"verified_at,omitempty"`
VerifiedFingerprint string `json:"verified_fingerprint,omitempty"`
State string `json:"state,omitempty"`
Judged bool `json:"judged,omitempty"`
Reason string `json:"reason,omitempty"`
Evidence []Evidence `json:"evidence,omitempty"`
}
Trace is one requirement: its text and fingerprint as approved, and its last verification (the fingerprint it was verified at, its state, why, and the evidence).