Documentation
¶
Overview ¶
Package specpkg is what the commands that work on a spec package on disk share: spec, specr and speca each need to find a package from a reference, show where it is, list its tasks and describe how it validates, and none of them should carry a copy.
It sits between the library and the shell. It knows afspec's types and the public output types of package envelope, and the shell's usage error, and nothing of how a command parses its flags or writes its output.
Index ¶
- func Display(dir, root string) string
- func IntentDrift(spec *afspec.Spec) bool
- func Legacy(spec *afspec.Spec) bool
- func List(root string) ([]string, error)
- func Locate(tool, ref, root, specsDir string) (string, error)
- func ReportOf(v afspec.ValidationResult) envelope.ValidationReport
- func Rules(entries []afspec.ValidationEntry) []string
- func SameDir(a, b string) bool
- func TaskInfo(plan *afspec.TasksV2Json, t afspec.Task) envelope.TaskInfo
- func TaskInfos(spec *afspec.Spec) []envelope.TaskInfo
- func TraceOf(s *afspec.Spec) envelope.TraceReport
- func Verdict(specsDir string, spec *afspec.Spec, siblings ...*afspec.Spec) (afspec.ValidationResult, error)
- func Writable(spec *afspec.Spec) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Display ¶
Display is how a command shows the path of a package: dir relative to root when it is inside it, so a suggested next call stays short and runnable from the repository, and absolute otherwise.
func IntentDrift ¶
IntentDrift reports whether the intent of an active package has been changed since it was activated: its status is active, it has an intent_hash, and the hash of its PRD's ## Intent section either cannot be computed (the section is gone) or is another. It is the rule by which the library refuses to save an active package, so a caller learns here why. A nil package has not drifted.
func Legacy ¶
Legacy reports whether the package is in a format version other than the one this library reads. Such a package loads, but the v2 types read none of its tests or tasks: a v1 plan is task_groups, not tasks.
func List ¶
List returns the names of the NN_name directories under root, in the order of their numbers: the prefix compared as a number, so that 99_y comes before 100_x, and a tie broken by the whole name. It lists directories whether or not they hold a package that loads.
func Locate ¶
Locate turns the one positional argument of a command into the absolute directory of a spec package. tool is the command that was called, specr or speca, and every refusal begins with it.
The argument is a reference, not a document. It is tried as a path first — the package directory, or a file inside it — relative to the working directory and then to root. Then it is matched against the directory names under the spec root, as the whole name (16_indexed_code_search), the number (16, or 016) or the name after it (indexed_code_search). A reference that matches two packages is refused naming both, and one that matches none is refused naming what is there, and the archived package it matches, which is reached by its path only. Every refusal is a usage error: nothing was read.
func ReportOf ¶
func ReportOf(v afspec.ValidationResult) envelope.ValidationReport
ReportOf flattens afspec's verdict for JSON: the counts, and every error and warning with the rule that produced it.
func Rules ¶
func Rules(entries []afspec.ValidationEntry) []string
Rules names the rules a set of validation entries break: the Check of each, or its Category when it has none, each once, in the order it first appears.
func SameDir ¶
SameDir reports whether two paths are one directory, however they are spelled. A path that does not exist is none.
func TaskInfo ¶
TaskInfo describes one task of plan, with ready from the plan's own rule (afspec's IsReady), so that every command means the same by it.
func TaskInfos ¶
TaskInfos lists the plan's tasks without their bodies, in plan order. A package without a plan gives an empty list, not nil.
func TraceOf ¶
func TraceOf(s *afspec.Spec) envelope.TraceReport
TraceOf derives the coverage summary.
It is computed rather than read, because format v2 makes coverage and traceability derived: there is no coverage object in the artifacts to report, and the numbers here are the only place they exist. The matrix carries one link per criterion AND one per execution path, distinguished by Kind, which is why this walks it once rather than asking for coverage twice.
func Verdict ¶
func Verdict(specsDir string, spec *afspec.Spec, siblings ...*afspec.Spec) (afspec.ValidationResult, error)
Verdict is the format's full verdict on spec: its own validation (the schemas and the cross-file rules C1 to C11), then the cross-spec rules (format v2 §10.4) that concern it, which only a run over the whole spec root can apply. spec and speca give this one verdict, whichever of them asks.
siblings are packages that exist in memory only and belong to the spec root all the same: the packages of a run that writes nothing, which may include spec itself. Each is in the run of the cross-spec rules beside the packages on disk, and replaces the one at its directory if there is one. A run that writes nothing has not created the spec root either, so when siblings are given, a specsDir that does not exist holds no other package.
When specsDir cannot be read the rules across specs are not applied. The verdict is then spec's own, and err says why.
func Writable ¶
Writable reports whether a package can take a write: it is a draft, or it is active and its intent has not drifted. A sealed, superseded or archived package cannot, and neither can an active one whose intent drifted. speca's task form accepts only a writable package, and its report and specr's next suggest a claim only for one, so the two ask this one question. (The status form moves a package through the lifecycle, which includes the ones that cannot take a task change.) A nil package cannot.
Types ¶
This section is empty.