Documentation
¶
Overview ¶
Package contract implements the `aiwf contract` verb and its subcommand graph (verify, bind, unbind, recipes, recipe show / install / remove). The parent verb is non-Runnable — `aiwf contract` with no subcommand prints help.
RunValidation, ApplyHintsLikeRun, BindingCount, and ResultToFinding are exported because the `check` verb (in cmd/aiwf/main.go until M-0118 moves it) calls them to run contract validation as part of `aiwf check`.
Index ¶
- func ApplyHintsLikeRun(findings []check.Finding)
- func BindingCount(c *aiwfyaml.Contracts) int
- func NewCmd() *cobra.Command
- func ResultToFinding(r contractverify.Result, strictValidators bool) check.Finding
- func Run(root, format string, pretty bool) int
- func RunValidation(ctx context.Context, tr *tree.Tree, rootDir string, ...) []check.Finding
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyHintsLikeRun ¶
ApplyHintsLikeRun fills the Hint field on every finding from the shared hint table. Mirrors the post-processing check.Run does for entity-level findings; we inline it here because we don't go through check.Run for contract verify.
func BindingCount ¶
BindingCount is a small helper for the JSON envelope's metadata.
func NewCmd ¶
NewCmd builds the `aiwf contract` parent command. Five direct children (verify, bind, unbind, recipes, recipe) plus the recipe sub-tree (show, install, remove). The parent itself is non-Runnable — `aiwf contract` with no subcommand prints help.
func ResultToFinding ¶
func ResultToFinding(r contractverify.Result, strictValidators bool) check.Finding
ResultToFinding converts a contractverify.Result into the Finding shape the render layer expects. Most codes are errors; the per-machine `validator-unavailable` code is a warning by default, upgraded to an error by strictValidators.
func Run ¶
Run is the exported entry point for `aiwf contract verify`. `contract verify` is read-only — it loads the tree, runs the contractcheck (config correspondence) and contractverify (subprocess validators) passes, and prints findings. The internal/policies/read_only.go entry pins this path so a future regression that adds gitops.Commit / verb.Apply / os.WriteFile to the verify body fails CI.
func RunValidation ¶
func RunValidation(ctx context.Context, tr *tree.Tree, rootDir string, contracts *aiwfyaml.Contracts) []check.Finding
RunValidation is the shared entry point for both the CLI `aiwf contract verify` and the pre-push integration in `aiwf check`. It runs contractcheck (config correspondence) plus contractverify (subprocess validators) and returns the combined findings slice (un-sorted, hints not applied — caller composes).
A nil contracts argument is treated as "no contracts configured": the function returns nil. Terminal-state contract entities (rejected, retired) are excluded from verification.
Types ¶
This section is empty.