contract

package
v0.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyHintsLikeRun

func ApplyHintsLikeRun(findings []check.Finding)

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

func BindingCount(c *aiwfyaml.Contracts) int

BindingCount is a small helper for the JSON envelope's metadata.

func NewCmd

func NewCmd() *cobra.Command

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

func Run(root, format string, pretty bool) int

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL