Add a Minimal FACET Gate to GitHub Actions
I do not want prompt changes to reach an AI runtime as unreviewed text diffs. I want them to cross the same kind of boundary as code: compile, test, expose the resulting structure, and fail before deployment when the contract is invalid.
FACET already has the commands required for that boundary. The missing piece is usually not another platform. It is a small CI job placed in the repository that owns the contract.
This guide adds that job to GitHub Actions without replacing the provider SDK, application runtime, or response validation. It is deliberately narrow: validate the deterministic request-construction layer first, then leave probabilistic output evaluation to a separate suite.
The smallest useful repository shape
Start with one contract and its tests in version control:
.
├── contracts/
│ ├── main.facet
│ └── fixtures/
│ └── smoke.input.json
└── .github/
└── workflows/
└── facet-contracts.yml
The .facet file is the reviewed source. Runtime input remains separate because data and contract evolve for different reasons. Provider credentials are not needed for the CI gate described here: build, test --pure, and inspect operate before a model call.
That separation matters. A green FACET gate means the contract parsed, resolved, passed semantic checks, and satisfied its deterministic tests. It does not mean that a model will produce a correct answer. I treat those as different claims and keep them in different jobs.
A minimal GitHub Actions workflow
The current reference compiler ships the facet-fct binary. The workflow below installs it from the repository at a fixed revision, compiles the contract, runs embedded @test blocks in pure mode, and exports inspection views when the job fails.
name: FACET contracts
on:
pull_request:
paths:
- "contracts/**"
- ".github/workflows/facet-contracts.yml"
push:
branches: [main]
paths:
- "contracts/**"
permissions:
contents: read
jobs:
facet:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install pinned FACET compiler
run: |
cargo install \
--git https://github.com/rokoss21/facet-compiler \
--rev 9b61d0659e18cc2b9df3fb8e08d069a81a7cb6c3 \
--bin facet-fct
facet-fct --version
- name: Compile contract
run: facet-fct build --input contracts/main.facet
- name: Run deterministic contract tests
run: |
facet-fct test \
--input contracts/main.facet \
--output summary \
--pure
- name: Export inspection artifacts
if: failure()
run: |
mkdir -p facet-artifacts
facet-fct inspect \
--input contracts/main.facet \
--ast facet-artifacts/ast.json \
--dag facet-artifacts/dag.json \
--layout facet-artifacts/layout.json \
--policy facet-artifacts/policy.json
- name: Upload failure artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: facet-inspection
path: facet-artifacts/
if-no-files-found: ignore
Pinning the compiler revision makes the gate reproducible. Upgrading FACET then becomes an explicit pull request rather than an invisible change in CI behavior. The compiler repository currently identifies the language target as FACET v2.1.3; the revision is part of the effective contract toolchain.
For a hardened production workflow, I would also pin third-party actions to full commit SHAs according to the repository's supply-chain policy. The example keeps familiar release tags readable, but the FACET compiler itself is fixed because its semantics directly determine the result.
Put assertions inside the contract
Compilation catches structural and semantic errors. It does not prove that the intended policy branches are covered. That is the job of @test blocks.
A useful first suite should include at least:
- one valid minimal input;
- one denied or invalid path;
- one boundary value for a budget, type, or policy condition;
- one fixture that would fail if a required field disappeared.
The goal is not to snapshot model prose. The goal is to lock the deterministic decisions that happen before generation: input typing, imports, merge behavior, layout, tool exposure, and policy evaluation.
This is the practical difference between a prompt file and a contract. Text review asks whether the change looks reasonable. A contract test asks whether a named invariant still holds.
Keep runtime generation outside this gate
The compiler can produce canonical JSON for execution:
facet-fct run \
--input contracts/main.facet \
--runtime-input contracts/fixtures/smoke.input.json \
--format json \
--exec
That output is the boundary object passed to a provider adapter. In a real application I also record the compiler identity, document hash, policy hash, and downstream request identifier. Together they answer a more useful question than “which prompt did we send?”: which exact contract and policy produced this request?
But I would not put live provider calls into the minimal pull-request gate. Network access, credentials, rate limits, model drift, and evaluation noise create another failure domain. Deterministic FACET checks should remain fast and explainable. Model evaluations can run after merge, on a schedule, or only for high-risk contract changes.
This layered approach follows the same principle as testing an agent loop without calling a model: freeze the probabilistic dependency when the property under test belongs to the control path.
What should block a merge
I use a simple rule: block when the repository can prove that the contract is internally invalid or violates an explicit invariant.
The gate should fail on:
- parse, resolution, type, placement, or policy errors;
- failed
@testassertions; - missing required fixtures;
- compiler installation or version mismatch;
- inability to generate the expected inspection views when debugging is required.
The gate should not claim to block “bad AI answers.” FACET does not make model output deterministic. It makes request construction and policy boundaries inspectable and repeatable. The broader distinction is explained in FACET vs YAML vs JSON and the canonical category pillar on FACET as a deterministic contract layer.
The next safe increment
Once the minimal gate is stable, add one improvement at a time:
- cache Cargo downloads to reduce installation time;
- run the workflow for every changed
.facetfile rather than one fixed path; - upload inspection artifacts on every protected-branch build, not only failures;
- generate a manifest containing compiler revision and contract hashes;
- add a separate model-evaluation job with its own budget and failure policy.
I would not begin with all five. A CI control is valuable only when developers understand what its green state proves. The minimal gate proves a narrow but important fact: the AI request contract is buildable, its deterministic tests pass, and its internal representation can be inspected before the application is allowed to use it.
That is enough to turn prompt review from a text ritual into an engineering boundary.