Skip to content
docsv0.2.0

ErrorCatalog

The single source of learnable-error content (spec §13/§19). For each error code it holds the cause (`why`), a message template, human `fixes`, and the LIVE, bilingual Academy `links` — and builds a {@see LearnableArchitectureError} from a code plus the entry context. The catalog enforces spec §25 anti-pattern 4 ("error muerto"): every code carries why + fix + Academy link, proven by walking the whole catalog in the test suite. Links are the URLs verified live in production — never invented; codes without a dedicated lesson point honestly at the Academy root plus its llms resource. It covers the 11 initial codes of spec §13, the two codes that split the engine's ambiguous usages (`MILPA_SURFACE_NOT_ENABLED`, `MILPA_SUGGESTED_CAPABILITY_MISSING`), `MILPA_RISK_EXPIRY_UNEVALUATED` (an accepted risk whose expiry could not be checked because the caller supplied no clock), and `MILPA_LEGACY_NOT_ALLOWED` (a legacy-shaped resolution the host profile's allowlist does not permit — the enforcement of `allowedLegacyContracts`).

ErrorCatalog::codes()

public static function codes(): array

Every code the catalog knows, in a stable order.

ErrorCatalog::has()

public static function has(string $code): bool

Whether a code has a catalog entry (used to decide which report entries earn a learnable error).

Parameters

Parameters of has()
NameTypeDescription
$codestring

ErrorCatalog::for()

public static function for(string $code, array $context = []): Milpa\Resolver\Report\LearnableArchitectureError

Build the learnable error for a code, templating its message and fixes with the entry context.

Parameters

Parameters of for()
NameTypeDescription
$codestring
$contextarray<string, mixed>

Throws

\InvalidArgumentException When the code has no catalog entry.