Documentation
¶
Overview ¶
Package validate checks the artifacts a /plan session produces against a machine-readable contract.
Before it, the only check on a whole plan was a single os.Stat on PROMPT.md (internal/tui/plan.go). Everything else the PDD SOP asks for — an outline, slices that name their files and verify command, gates that actually run, Done Criteria that are not template placeholders — was prose the model could decline. Across 53 spec directories, 3 had a complete artifact set and outline.md was missing from 70%.
A rule here returns Findings rather than a bool, because a Finding is fed back to the agent that produced the artifact: Message says what is wrong and Fix says what to do about it.
Index ¶
Constants ¶
const ManifestName = ".sop-manifest.json"
ManifestName duplicates sop.ManifestName for the same reason.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Args ¶
Args holds a rule invocation's arguments. The three shapes cover every rule the SOP schema needs: `max_lines(2000)`, `has_headings(["A","B"])`, and `slice_budget(max_files: 10, max_changed_lines: 400)`.
func ParseRule ¶
ParseRule splits a rule spec such as `slice_budget(max_files: 10)` into its name and arguments.
type ArtifactContract ¶
type ArtifactContract struct {
Artifact string `json:"artifact"`
Required bool `json:"required"`
Rules []string `json:"rules"`
}
ArtifactContract binds an artifact to the rules it must satisfy.
type Contract ¶
type Contract struct {
Name string `json:"name"`
Artifacts []ArtifactContract `json:"artifacts"`
}
Contract is the full set of checks for one gate in the pipeline.
func PlanContract ¶
func PlanContract() Contract
PlanContract is what a finished /plan session must satisfy. It is the prose PDD SOP's own rules, made checkable: every phase produces its artifact, the plan's slices are sized and self-describing, and PROMPT.md carries gates and Done Criteria that are real rather than template text.
func RunPreflightContract ¶
func RunPreflightContract() Contract
RunPreflightContract is what /run requires before it will start. It is deliberately narrower than PlanContract: a spec written by hand, or planned under an older SOP, should still run if the two artifacts a run actually consumes are sound.
func (Contract) Describe ¶
Describe renders the contract as instruction text for the agent that must satisfy it.
This is the half that makes validation a loop rather than a gate: the planner is told the exact rules its artifacts are checked against, in the same session where the findings come back. A contract the producer cannot see is just a way to fail late.
type Finding ¶
type Finding struct {
Artifact string `json:"artifact"`
Rule string `json:"rule"`
Severity Severity `json:"severity"`
Line int `json:"line,omitempty"`
Message string `json:"message"`
Fix string `json:"fix,omitempty"`
}
Finding is one rule violation.
type Findings ¶
type Findings []Finding
Findings is a rule result set.
func Check ¶
Check runs a contract over a loaded spec. repoRoot is the checkout the spec lives in; rules that resolve paths or probe commands need it, and pass when it is empty.