generatedverify

package
v0.0.0-...-043add5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package generatedverify verifies checked-in generated artifacts from project-derived expectations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssemblyEntrypointPath

func AssemblyEntrypointPath(assemblyID string, asm *metadata.AssemblyMeta) string

AssemblyEntrypointPath returns the metadata-derived generated entrypoint path for an assembly. asm must be non-nil with a non-empty Build.Entrypoint (guaranteed by deriveAssembly post-parse). Passing nil or a zero Entrypoint is a programmer error; the function returns an empty string so callers fail loudly on the resulting invalid path rather than silently routing to cmd/{id}/.

Types

type Artifact

type Artifact struct {
	AssemblyID string
	Kind       string
	Path       string
	Content    []byte
}

Artifact is one generated file that must be checked in exactly as derived from project inputs.

func ExpectedArtifacts

func ExpectedArtifacts(ctx context.Context, root, module string, project *metadata.ProjectMeta) ([]Artifact, error)

ExpectedArtifacts derives the complete generated-artifact manifest and in-memory content from project inputs.

type Drift

type Drift struct {
	AssemblyID string
	Kind       string
	Path       string
	Message    string
}

Drift describes one mismatch between project-derived expectations and the checked-in repository state.

type Result

type Result struct {
	Artifacts []Artifact
	Drifts    []Drift
}

Result is the complete generated-artifact verification result.

func Verify

func Verify(ctx context.Context, root, module string, project *metadata.ProjectMeta) (*Result, error)

Verify derives every generated artifact path and content from project inputs, then compares the result with the checked-in repository state.

Two checks run against different data sources, deliberately:

  • Content byte-equality is compared against the working tree so developers can iterate locally without committing every step.
  • Tracking and reverse-enumeration are compared against HEAD so a file that was only `git add`-ed during CI cannot satisfy the gate, and committed files that fell out of the expected set are detected wherever they live in the tree.

Reverse enumeration is header-driven: every committed file at HEAD whose first line is a gocell generator sentinel (governance.GoGeneratedPrefix or governance.YAMLGeneratedPrefix) is a candidate. Anything outside the expected manifest is drift, regardless of directory. This makes assembly.yaml the single source of truth for what may live under any generator-owned path.

func (Result) Passed

func (r Result) Passed() bool

Passed reports whether all expected generated artifacts are present and byte-for-byte current, every expected file is committed in HEAD, and no other committed file in the work tree carries a gocell generator header. Tracking and reverse-enumeration checks are skipped when the project is not a git working tree (test fixtures), in which case only the content check runs.

Jump to

Keyboard shortcuts

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