claimcheck

package
v0.1.0-dev.20260908215119 Latest Latest
Warning

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

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

Documentation

Overview

Package claimcheck verifies that a provider method does what its `+devlore:claim=` directive says.

A claim is an assertion by the author, not a fact derived from the signature ([op.MethodClaims]). This package is what holds the author to it: it loads the module with full type information and reports every place a claiming method reaches a capability the claim forbids.

The check needs types, not syntax. `os.Getenv` and `os.FileMode` are the same shape to a parser — both a selector on `os` — and `os.FileMode(mode)` is a *call expression* despite being a type conversion. Only a type-checked program can say that the first is a function, the second a type, and the third a conversion. That is why this loads through packages rather than walking an AST.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Violation

type Violation struct {
	Method   string // the claiming method, as `provider.Method`
	Claim    string // the claim the reach contradicts
	Reach    string // the capability reached, as `package.Function`
	Position string // where, as `file.go:line`
	Via      string // the in-module hop that led there, empty when the claiming method reaches it directly
}

Violation is one claim contradicted by the code that carries it.

func Check

func Check(patterns ...string) ([]Violation, error)

Check loads `patterns` with type information and reports every claim its own code contradicts.

Loading is the expensive part — it runs the compiler front end — so callers pass every pattern at once rather than calling per package.

Parameters:

  • `patterns`: go package patterns, e.g. "./pkg/op/provider/...".

Returns:

  • `[]Violation`: the violations found, ordered by method then reach; empty when every claim holds.
  • `error`: non-nil when loading fails or a package carries type errors.

func CheckGOOS

func CheckGOOS(goos string, patterns ...string) ([]Violation, error)

CheckGOOS is Check against a chosen target platform.

A claim can hold on one platform and fail on another: build tags select different bodies, so the call graph a method reaches is not the same everywhere. CI covers the spread across its matrix — each leg checks its own host, and the legs span darwin, linux, and windows between them. Passing an explicit goos is for sweeping the others from one machine; see platformsUnderTest in the test.

Parameters:

  • `goos`: the target platform, e.g. "linux"; empty loads for the host.
  • `patterns`: go package patterns.

Returns:

  • `[]Violation`: the violations found for that platform.
  • `error`: non-nil when loading fails or a package carries type errors.

func (Violation) String

func (v Violation) String() string

String renders the violation as the build error an author reads.

The shape names the reach and never renders a verdict: an author who reads "calls os.Getenv at provider.go:110" knows what to change, where "not deterministic" sends them hunting. It mirrors the codegen-side message that quotes an offending signature back.

Returns:

  • `string`: the one-line failure.

Jump to

Keyboard shortcuts

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