How to Move a FACET Contract from Core to Hypervisor
A FACET Core contract should not become a Hypervisor contract by accident.
Core is deliberately small: resolve imports, check types, render canonical messages, and preserve a policy identity. Hypervisor adds reactive variables, runtime inputs, lenses, tests, Token Box layout, executable policy guards, and provenance. That is not a feature toggle. It is a change in what the contract is allowed to mean.
I would therefore migrate by adding one semantic boundary at a time and preserving a reviewable artifact after every step. The goal is not merely to make the document compile under the larger profile. The goal is to know exactly which new authority, variability, and runtime obligation entered the system.
Start with a frozen Core baseline
Before adding Hypervisor features, freeze the smallest evidence packet that describes current behavior:
baseline/
├── contract.facet
├── resolved-ast.json
├── canonical.json
├── document-hash.txt
└── negative-fixtures/
The baseline must include failures, not only a successful build. If an import escapes the allowed root, a variable has the wrong type, or a Core-forbidden construct appears, the contract should already fail with a stable diagnostic class.
This gives the migration a reference point. Without it, a later canonical diff cannot tell you whether Hypervisor added intentional semantics or merely exposed an unrelated source change.
The distinction follows the same principle as Canonical JSON as an AI intermediate representation: source text is an authoring form, while the compiled artifact is the review boundary.
Migration step 1: introduce runtime inputs without hidden defaults
Core allows literal @vars. Hypervisor can accept @input(...) and evaluate a reactive dependency graph. The first danger is not syntax. It is allowing deployment state to enter through an undocumented path.
For every new runtime input, record:
- its type;
- whether it is required;
- the authority that supplies it;
- whether it can affect messages, tools, policy, or layout;
- the failure expected when it is missing or invalid.
A runtime input should not inherit a convenient default merely to keep the pipeline green. Defaults are behavior. If a value controls a consequential boundary, absence should remain visible until the contract names the intended fallback.
After this step, compare the resolved AST and canonical output using a fixed input fixture. Then run a negative fixture with the input omitted. Both results belong in the migration review.
Migration step 2: add computation as a dependency graph
Reactive variables are useful because they turn request construction into an explicit program. They are also a new execution surface.
Add computed variables in small groups. For each group, inspect the dependency DAG and verify three properties:
- dependencies are explicit and acyclic;
- an override changes the intended value without silently reordering unrelated evaluation;
- identical declared inputs produce the same computed state.
Do not review only the final prompt. Two dependency graphs can render similar text while encoding different update behavior. FACET’s value is precisely that the construction path can be inspected before model inference.
This is where the broader AI engineering runtime distinction matters: the model proposes inside an execution system; it should not be responsible for reconstructing that system’s state rules from prose.
Migration step 3: classify every lens by trust level
A lens can look like a formatting helper while changing the reproducibility contract.
Pure deterministic transforms such as trimming or normalization are different from cache-backed transforms and different again from effectful execution. During migration, make that difference visible:
| Lens class | Migration question | Required evidence |
|---|---|---|
| Pure deterministic | Does it always produce the same result from the same arguments? | positive and negative fixtures |
| Pure cache-only | Is the cache identity complete and is a miss fail-closed? | pinned cache fixture and miss case |
| Exec/effectful | Which host capability authorizes it? | guard decision and execution artifact |
Do not move an effectful lens into the contract just because --exec makes the example work. Exec mode expands what the host may perform. That authority must be reviewed separately from the text transformation itself.
Migration step 4: introduce Token Box with overflow fixtures
Core does not perform Token Box layout. Hypervisor does. The moment Token Box becomes active, context ordering and overflow behavior become contract semantics.
Start with a budget large enough to preserve the Core canonical messages. Confirm that the first Hypervisor layout is semantically equivalent. Then reduce the budget deliberately and test each boundary:
- a flexible section can shrink according to its declared strategy;
- a protected section is not silently dropped;
- a critical overflow fails instead of inventing room;
- UTF-8 text is truncated only at valid boundaries;
- the layout artifact explains what was retained, compressed, truncated, or rejected.
This is not a token-cost optimization pass. It is a migration of request meaning. FACET YAML and Canonical JSON are useful here because the review must separate human-readable source from the exact machine artifact produced after layout.
Migration step 5: turn policy identity into runtime enforcement
Core can validate @policy and render policy_hash, but execution enforcement points are not applicable there. Hypervisor adds the runtime guard.
That transition is easy to misread. A stable policy hash does not prove that a tool call was authorized. It proves the identity of the effective policy representation. Hypervisor must additionally evaluate the operation against that policy and fail closed when the decision cannot be established.
For every allowed operation, add a paired denial case over fixed inputs:
allow: declared principal + declared capability + matching operation
deny: same operation, one required authorization fact removed
The pair matters more than the happy path. It proves that authority comes from the guard boundary rather than from a model instruction or an integration convention.
Migration step 6: require evidence from failed runs
The final profile change is operational. Hypervisor can emit execution artifacts and guard decisions. Use them for failures as well as successes.
A denied operation, exhausted gas budget, missing cache entry, invalid runtime input, or critical context overflow should leave enough evidence to answer:
- which compiled contract ran;
- which profile and mode applied;
- which input and policy identities were active;
- which phase failed;
- whether an external effect was attempted;
- whether retry is safe, forbidden, or requires reconciliation.
The artifact is not a verbose log. It is the minimum proof needed to understand the boundary that stopped execution. That keeps FACET responsible for deterministic request admissibility while leaving transport, durable workflow state, credentials, retries, and compensation with the host runtime, as described in Where FACET stops.
The migration gate I would use
I would approve the profile change only when the review contains this matrix:
| Boundary | Core baseline | Hypervisor addition | Negative proof |
|---|---|---|---|
| Inputs | literals | typed runtime inputs | missing/invalid input fails |
| Computation | none | inspected R-DAG | cycle or unknown dependency fails |
| Transforms | none | declared lens trust | cache miss/effect denial fails |
| Context | rendered messages | Token Box layout | protected/critical overflow behaves as declared |
| Authority | policy identity | runtime guard | matched denial fixture fails closed |
| Evidence | canonical artifact | execution artifact | failed run preserves the decision |
If a row cannot be explained, the migration is incomplete even when the compiler accepts the document.
Boundary conditions
This guide describes a migration method derived from the FACET v2.1.3 profile definitions and the reference compiler’s documented build, inspect, run, and test surfaces. It does not certify a particular deployment, provider adapter, or host runtime. The exact evidence paths depend on the pinned compiler revision and host profile.
Core and Hypervisor are not “basic” and “advanced” labels. They are different contracts with different claims. Core is useful when deterministic construction is enough. Hypervisor is justified when the system needs runtime inputs, computation, bounded context, executable authorization, and provenance.
The safe migration is therefore additive and inspectable: preserve the Core meaning, introduce one new semantic boundary, add the failure case, and only then continue.