verify

package
v0.3.5 Latest Latest
Warning

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

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

Documentation

Overview

Package verify implements `canary verify`: the evidence-backed answer to "are this project's claims true right now?". It reads declarations from the tree, claims from a gap-analysis file, and passing-test evidence from the evidence store, then delegates the verdict to pkg/evidence.Complete — the single completion function. Nothing here decides completeness on its own.

Index

Constants

View Source
const (
	FormatJSON = "json"
	FormatText = "text"
)

Format values accepted by --format.

View Source
const DefaultEvidencePath = ".canary/evidence.json"

DefaultEvidencePath is the evidence store's path relative to the project root.

Variables

View Source
var VerifyCmd = &cobra.Command{
	Use:   "verify [flags]",
	Short: "Verify claimed requirements against passing-test evidence",
	Long: `Verify that every requirement claimed in a gap-analysis file has passing
evidence recorded at the current commit.

Claims are lines like "✅ <REQ-ID>" in the claims file. For each claimed
requirement, every feature/aspect it declares in source must have a PASS
evidence record for this project at HEAD. Declarations alone (STATUS=TESTED,
TEST=...) never verify anything.

Exit codes: 0 verified, 1 not verified (or unknowable).

Flags:
  --root <dir>              Project root to scan (default ".")
  --claims <file>           Claims file (default "GAP_ANALYSIS.md")
  --evidence <file>         Evidence store (default ".canary/evidence.json")
  --format json|text        Output format (default "json")
  --project <id>            Override the configured project key
  --allow-empty             Treat a claims file with no claims as verified
  --allow-unknown-external  Do not block on unresolvable external dependencies
  --allow-dirty             Accept a working tree that does not match HEAD
  --allow-imported          Accept evidence imported from a stream (from-go-test/ingest)
                            rather than executed by canary evidence run

Examples:
  canary verify
  canary verify --format text --claims GAP_ANALYSIS.md`,

	PersistentPreRunE: func(cmd *cobra.Command, args []string) error { return nil },
	RunE: func(cmd *cobra.Command, args []string) error {
		opts := Options{}
		opts.Root, _ = cmd.Flags().GetString("root")
		opts.ClaimsPath, _ = cmd.Flags().GetString("claims")
		opts.EvidencePath, _ = cmd.Flags().GetString("evidence")
		opts.Format, _ = cmd.Flags().GetString("format")
		opts.ProjectID, _ = cmd.Flags().GetString("project")
		opts.AllowEmpty, _ = cmd.Flags().GetBool("allow-empty")
		opts.AllowUnknownExternal, _ = cmd.Flags().GetBool("allow-unknown-external")
		opts.AllowDirty, _ = cmd.Flags().GetBool("allow-dirty")
		opts.AllowImported, _ = cmd.Flags().GetBool("allow-imported")

		if opts.Format != FormatJSON && opts.Format != FormatText {
			return fmt.Errorf("unknown --format %q (want %q or %q)", opts.Format, FormatJSON, FormatText)
		}
		if code := Run(opts, cmd.OutOrStdout(), cmd.ErrOrStderr()); code != 0 {
			os.Exit(code)
		}
		return nil
	},
}

CANARY: REQ=CP-236; FEATURE="EvidenceVerify"; ASPECT=CLI; STATUS=TESTED; TEST=TestAuditF01CLI,TestAuditF01CLI_PartialDeclaredTestsUnproven,TestAuditF15CLI,TestAuditF22,TestVerifyRun_EvidenceMissing,TestVerifyRun_Verified,TestVerifyRun_WrongCommitIsNotVerified,TestVerifyRun_TextFormat,TestVerifyRun_ScanIssueIsIncomplete,TestVerifyRun_UndeclaredClaim,TestVerifyRun_MissingClaimsFileIsUnknown,TestVerifyRun_ExternalUnknownBlocks,TestVerifyRun_ProjectOverride,TestVerifyRun_DirtyTreeRefused,TestVerifyRun_AllowDirtyOptsOut,TestVerifyRun_RelativeClaimsResolvesUnderRoot,TestVerifyRun_ImportedEvidenceIneligibleByDefault,TestVerifyRun_DirtyEvidenceNeverEligible,TestVerifyRun_ArtifactMismatchIsUnknown,TestVerifyRun_MissingArtifactIsTolerated; UPDATED=2026-08-31 VerifyCmd is the `canary verify` command.

Functions

func Run

func Run(opts Options, stdout, stderr io.Writer) int

Run performs one verification and returns the process exit code: 0 when the verdict is OK, 1 otherwise. Exactly one line is ever written to stdout (the verdict); every diagnostic goes to stderr.

Types

type Options

type Options struct {
	Root         string
	ClaimsPath   string
	EvidencePath string
	Format       string
	// ProjectID overrides the configured project.key when non-empty.
	ProjectID            string
	AllowEmpty           bool
	AllowUnknownExternal bool
	// AllowDirty accepts a working tree that does not match HEAD. Without
	// it, Run refuses with DIRTY_TREE: evidence bound to HEAD cannot answer
	// for a tree HEAD no longer describes.
	AllowDirty bool
	// AllowImported accepts evidence records whose origin is "imported"
	// (from-go-test/ingest) rather than "executed" (canary evidence run).
	// Without it, imported records are dropped before verification: they
	// were not produced by canary's own dedicated verifier and are not, by
	// default, trusted to prove a claim.
	AllowImported bool
}

Options are the resolved inputs of one verification run.

Jump to

Keyboard shortcuts

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