Skip to content
docsv0.2.0

LearnableArchitectureError

A structured, teachable diagnosis (spec §12): a machine `code`, a human `message`, the `why` (the concept the failure violated), the `context` that produced it, human-readable `fixes`, and `links` into the Academy. It is built by {@see ErrorCatalog} (the single source of that content) and attached to the report so every block teaches instead of merely failing. Its {@see toArray()} emits the agent shape of spec §20: the `links` become the bilingual `learn` map, and typed `recommendedActions` are derived from the code and context — the same diagnosis an agent can act on without inventing anything. Anti-pattern 4 ("error muerto") forbids a code without why + fix + learn link; the catalog test proves every code carries all three.

LearnableArchitectureError::__construct()

public function __construct(string $code, string $message, string $why, array $context = [], array $fixes = [], array $links = []):

Parameters

Parameters of __construct()
NameTypeDescription
$codestring
$messagestring
$whystring
$contextarray<string, mixed>
$fixeslist<string>
$linksarray<string, mixed>

LearnableArchitectureError::fromArray()

public static function fromArray(array $data): self

Rehydrate an error from its serialized agent shape; `learn` maps back to `links` and the typed `recommendedActions` are dropped (they are re-derived deterministically on the next toArray()).

Parameters

Parameters of fromArray()
NameTypeDescription
$dataarray<string, mixed>

LearnableArchitectureError::toArray()

public function toArray(): array

Serialize to the agent shape of spec §20: code, message, why, context, human fixes, typed recommendedActions derived from code + context, and the bilingual `learn` links.