$ fssg build --deterministic --validate |

FACET Error Codes as an AI Execution Control Plane

FACET

Most agent runtimes treat failure as text. A tool throws an exception, a validator emits a paragraph, and another model is asked to “fix it.” That is not recovery logic. It is a second improvisation layered on top of the first.

A compiler can do better because it knows where the contract stopped being valid. FACET reserves stable diagnostics such as F451 for type mismatch, F454 for deterministic policy denial, F455 for an undecidable guard, F803 for a pure-mode cache miss, and F902 for exhausted gas. The important part is not the numbering. It is that each code names a machine-actionable failure class.

My thesis is simple: a diagnostic catalog is not developer decoration. In an AI execution system, it can become a control plane for recovery.

The same red light can require opposite actions

Consider four failures that may all appear to an operator as “the agent could not continue”:

Diagnostic Meaning Correct runtime response
F451 a value violates the expected type repair the producing step or input mapping
F454 policy deterministically denied the operation do not retry; return a refusal with policy evidence
F455 the guard could not reach a decision fail closed; repair missing decision inputs or escalate
F902 the execution budget was exhausted stop the run; reconsider the plan or budget explicitly

A generic retry policy is wrong for at least three rows. Retrying a policy denial wastes tokens. Treating an undecidable guard as an ordinary denial hides a policy defect. Increasing a budget cannot repair a type mismatch.

This is why error semantics must survive every layer: parser, validator, dependency graph, policy guard, context allocator, tool executor, CLI, and orchestration runtime. If an adapter collapses them into ExecutionError, it destroys information the scheduler needs.

A recovery matrix, not a retry loop

I would model recovery as a table owned by the runtime:

{
  "F451": {"action": "repair", "owner": "producer", "max_attempts": 1},
  "F454": {"action": "refuse", "owner": "policy", "max_attempts": 0},
  "F455": {"action": "escalate", "owner": "guard-inputs", "max_attempts": 0},
  "F803": {"action": "materialize-cache", "owner": "runtime", "max_attempts": 1},
  "F902": {"action": "replan", "owner": "orchestrator", "max_attempts": 0}
}

This is illustrative runtime policy, not FACET syntax. The mechanism matters more than the representation. A diagnostic selects a bounded transition; it does not become free-form advice to a model.

A useful transition record should carry at least:

  • the stable diagnostic code;
  • the phase and operation that emitted it;
  • the canonical input or artifact hash;
  • whether any side effect began;
  • the guard decision and applicable policy version;
  • the selected recovery action;
  • the parent attempt and next attempt IDs.

That record makes recovery auditable. It also prevents a repair agent from silently changing the original objective. The repair scope can be constrained to the failed boundary: fix the malformed value for F451, populate a permitted cache for F803, or request a human decision for F455. Everything else remains frozen.

Phase is part of the meaning

Codes are useful only when their provenance is preserved. A missing variable during validation is different from a missing field discovered while materializing runtime data. FACET separates these paths (F401 and F405) because the repair owner is different.

The same principle applies to safety boundaries. F454 means the policy engine had enough information and returned deny. F455 means it could not establish permission. Both stop execution, but they produce different evidence and different maintenance work.

This distinction closes a dangerous loophole: “evaluation failed, so continue with the default.” In a fail-closed system, inability to authorize is not authorization. The runtime must preserve the undecidable state instead of translating it into an allow, a retry, or a vague exception.

FACET's compiler documentation also specifies diagnostic precedence: parse defects first, then placement and schema, types, dependency graph, and finally runtime mode or policy. Deterministic precedence matters because one invalid artifact may contain several defects. Stable ordering gives tests, CI, and repair agents a reproducible first boundary to address.

Diagnostics can constrain repair agents

Once failure classes are structured, a repair agent no longer needs broad repository authority.

For F451, it may receive the expected type, observed canonical value, producer node, and permission to patch only the producer mapping. For F601, an import sandbox failure, it should not be allowed to widen the sandbox; it may propose a path inside the existing allowlist. For F901, critical context overflow, it must not silently drop a critical section. It can reduce optional material or return a budget conflict.

This is where diagnostics and capabilities meet. The error code selects not only a workflow, but also the smallest repair capability that workflow requires. Recovery becomes a contracted operation:

failure -> classified boundary -> bounded capability -> candidate repair
        -> recompile -> verify original boundary -> continue or stop

The model may propose the repair. The runtime decides whether that repair is allowed and whether the contract is valid again.

What this mechanism does not prove

Stable error codes do not make models deterministic. They do not guarantee that an automated repair is correct, and they do not replace transaction semantics for external effects. A catalog can also become misleading if implementations emit the wrong code or adapters discard provenance.

The practical requirements are therefore strict: codes need conformance tests; precedence must be deterministic; extensions should use separate namespaces; side-effect status must be explicit; and unknown codes must default to stop or escalation—not optimistic retry.

FACET's current compiler repository provides the primary evidence for this architecture: a reserved F000–F999 catalog, phase-specific diagnostics, policy deny versus undecidable separation, pure/exec mode failures, budget failures, and regression matrices for supported paths. This article explains the architectural consequence of those primitives. It does not claim measured superiority over other recovery systems or production adoption.

Errors should compile into decisions

The usual agent loop is try -> fail -> ask the model again. An engineering runtime needs a stronger loop:

compile -> execute -> classify -> authorize recovery -> verify -> resume

That one change moves failure handling out of prompt folklore and into system semantics.

I do not want an agent to be creative about why a contract failed. I want the compiler to identify the boundary, the runtime to select an allowed transition, and the trace to prove what happened. Creativity belongs inside the task. Recovery belongs in the control plane.

For the surrounding architecture, see FACET policy as executable authorization, canonical JSON as an AI intermediate representation, and why provider adapters must not repair semantics.

Sources

FACET AI CLI Terminal
facet@ai:~$