kit

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package kit holds the small, dependency-free types that both the engine and the per-kind rule packages need. It exists so kind packages (internal/kinds/<kind>) can report problems and query other manifests without importing internal/engine, which would create an import cycle (engine imports the kinds registry to run their rules).

Index

Constants

This section is empty.

Variables

View Source
var LocalRefLists = map[string][]string{
	"resources":       {"resources"},
	"objectives":      {"objectives"},
	"deliverables":    {"deliverables"},
	"successCriteria": {"successCriteria"},
	"risks":           {"risks"},
	"problems":        {"summary", "problems"},
	"phases":          {"timeline", "phases"},
}

LocalRefLists maps the name a local reference uses to where that list actually sits in a spec. Every entry is a direct child of spec except the timeline's phases, which are nested; naming the path here keeps the one exception in a table instead of in every reader.

Functions

func LocalList

func LocalList(spec map[string]any, name string) ([]any, bool)

LocalList returns the items of one of a spec's own lists by the name a local reference uses for it, and whether that name is one Cartograph knows.

Types

type Lookup

type Lookup interface {
	// Documents returns the current parsed manifest document (the full
	// envelope: apiVersion, kind, metadata, spec) for every existing
	// manifest of the given kind, keyed by metadata.id.
	Documents(kind string) (map[string]map[string]any, error)
	// HasSnapshots returns true if the manifest of the given kind and id has
	// any immutable versions (version.Number >= 1). Returns false if not found.
	HasSnapshots(kind, id string) (bool, error)
}

Lookup lets a kind's rules see other stored manifests, for cross-manifest checks.

type Problem

type Problem struct {
	Path    string `json:"path"`
	Message string `json:"message"`
}

Problem is one validation failure. Path is a JSON pointer into the manifest's spec (rooted at "/spec", to match paths from schema and reference validation).

func GapCitationProblems

func GapCitationProblems(problems []any, path string, lookup Lookup) []Problem

GapCitationProblems checks the one thing a citation's schema cannot: that every segment it names is a segment the gap it cites actually has.

A gap enumerates the slices its shortfall was observed in. Work that reaches some of them addresses part of the gap, which is what naming segments records. Naming a segment the gap does not have is not a narrower claim, it is a different one — the evidence never covered that slice, so nothing there is being addressed on this gap's authority (TAXONOMY.md D9).

Shared by Project and Programme, which carry the same problems list, so the rule reads the same on both. An absent or empty segments list means the whole gap and is always allowed.

func KeyResultUnitProblem

func KeyResultUnitProblem(kr map[string]any, path string) *Problem

KeyResultUnitProblem checks the one KeyResult rule its JSON Schema cannot express: unit is required when kind is count, money or duration, and forbidden when kind is percent or ratio. kr is one key result object (already known to be a map); path is its location in the manifest, for example "/spec/keyResults/0". Shared by every kind that embeds KeyResult (Goal, Project), so the rule reads the same everywhere.

func LocalRefProblem

func LocalRefProblem(spec map[string]any, v any, path string) *Problem

LocalRefProblem checks one reference field: that it is a reference at all, and that a local one names a list Cartograph knows and an id that list actually holds. A cross-manifest reference is checked elsewhere, by the generic reference walker, and an external one names something the vault does not hold, so neither is resolved here. Returns nil when the field is absent, since whether a reference is required is each field's own rule.

func ObjectiveDigitProblem

func ObjectiveDigitProblem(objective, path string) *Problem

ObjectiveDigitProblem flags an objective statement that contains a digit, a sign it states a target rather than a qualitative aim (the number belongs in a key result instead). path is the objective field's own location, for example "/spec/objective". Shared by Goal and Project, which both carry an objective statement.

func RiskProblems

func RiskProblems(spec map[string]any, hasPhases bool) []Problem

RiskProblems checks the risk list a Project and a Programme both carry: that a dependency's far end resolves, that only a dependency carries an edge, that escalation states its reason, and that a phase named as the landing point is one the holder actually has.

hasPhases says whether this kind schedules at all. A project does, so needBy names one of its own phases; a programme does not, and a phase it cannot have is refused rather than silently ignored — how a programme is staged is the delivery tool's, which is why it holds no timeline.

type RuleContext

type RuleContext struct {
	// ID is the id of the manifest being validated. During an update this
	// is the existing manifest's id; rules that scan other manifests of the
	// same kind should exclude this id to avoid comparing a document
	// against itself.
	ID     string
	Lookup Lookup
}

RuleContext carries what a kind's Rules function needs beyond the document being validated.

type RulesFunc

type RulesFunc func(doc map[string]any, ctx RuleContext) []Problem

RulesFunc validates one kind's document (the full envelope, parsed as map[string]any) beyond what its JSON Schema and generic reference checks already cover.

Jump to

Keyboard shortcuts

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