e22661ab54
REQ-320: policies/pilot-readiness/no-placeholder-account.json asserts account_id != "000000000000" over the env JSON (critical severity — a placeholder account drives a block band). Passes on dev (581513795199), fails on placeholder. REQ-315: policies/settlement-finality/all-matches- committed.json asserts all_committed == true over the settlement status JSON (critical severity). Authored + tested in v1.26; enforcement gates qa/prod/dr promotions, not dev (G-Q6 — dev all_committed is vacuously true). Both policy tests run against real kj (not skipped). ---ci--- project: acdl phase: 3 milestone: v1.26 status: execute wave: W4 ---
Nova Adapters
Overview
Adapters translate the engine-agnostic Target Stack IR to engine-specific formats. The Terraform adapter is the primary adapter (IR → HCL). Policy adapters translate security tool output into normalized PolicyCheckResult records that the confidence signal consumes in an engine-agnostic way.
Existing Adapters
| Adapter | Path | Input | Output | Purpose |
|---|---|---|---|---|
| Terraform adapter | adapters/terraform/adapter.py |
Stack instance JSON | Terraform HCL (main.tf, terraform.tf, providers.tf) |
Compiles IR to Terraform |
| Checkov adapter | adapters/terraform/policy/checkov_adapter.py |
Checkov JSON | PolicyCheckResult records |
Translates Checkov results |
| Wiz adapter | adapters/wiz/wiz_adapter.py |
Wiz API issues JSON | PolicyCheckResult records |
Translates Wiz security findings |
| Kyverno adapter | adapters/kyverno/kyverno_adapter.py |
Kyverno PolicyReport JSON | PolicyCheckResult records |
K8s-native policy translation |
| kyverno-json engine | adapters/kyverno-json/kyverno_json_engine.py |
Any JSON/YAML payload | PolicyCheckResult records |
v1.25 primary policy engine (swappable via PolicyEngine protocol) |
Policy Engine Protocol (v1.25)
The core/policy_engine.py module defines the swap boundary between
Nova and its policy engines. A PolicyEngine Python Protocol (PEP 544)
with three members (name, is_configured(), evaluate()) is the
contract; a PolicyEngineRegistry selects the active engine from
config.json's policy.engine key. The confidence signal and pipeline
never import an engine directly — they go through the registry.
Implementations:
KyvernoJsonEngine(adapters/kyverno-json/) — shells to thekjCLI; the v1.25 default.NullEngine(core/policy_engine.py) — fallback when thepolicykey is absent (emitsSKIPPED).- Future:
OpaEngine— implements the same protocol, shells toopa eval. The OPA-equivalent surface is documented in.ciagent/RESEARCH.md§4.2.
How to add a new engine:
- Create
adapters/<name>/<name>_engine.pyimplementing thePolicyEngineprotocol (name,is_configured(),evaluate()). evaluate()returnslist[dict]where each dict conforms toschemas/policy_check_result.schema.json.- Register the engine in
core/policy_engine.py's_autoload_*function (or callregister(name, factory)at startup). - Set
config.json.policy.engineto the engine'sname. - Add the engine to the
engineenum inschemas/policy_check_result.schema.jsonif it needs a distinct enum value (v1.25 reuses"kyverno"— see D-116).
How to Write an Adapter
Terraform Adapter Extension
- Add a stack type → Terraform type mapping to
TYPE_MAP. - Add non-identity input mappings to
INPUT_MAP. - Add non-identity output mappings to
OUTPUT_MAP. - Add a specialized
_emit_resourcebranch if the resource needs nested blocks (e.g. inline policies, rule sets).
Policy Adapter Pattern
- Define
SEVERITY_MAPandRESULT_MAPdicts that translate the engine's native severity/result vocabulary to thePolicyCheckResultenums. - Implement
_to_pcr(raw_record, contract_id)→PolicyCheckResultdict. - Implement
adapt(input_path, contract_id)→ list ofPolicyCheckResultdicts. - Implement
is_configured()→ bool (env var check) so the platform can skip the adapter when credentials are absent.
How to Wire an Adapter
- Terraform adapter — invoked by
scripts/run_platform.shStep 3 (terraform-plan). - Checkov adapter — invoked by
scripts/run_platform.shStep 5 (checkov). - Wiz / Kyverno adapters — optional Steps 5b/5c, run only when the relevant env vars are set.
- All policy adapters output records that are validated against
schemas/policy_check_result.schema.json.
Dependencies
jsonschema,pyyaml— used by all adapters for loading and validating inputs.boto3— used by the Wiz adapter for AWS API access.checkov— used by the Checkov adapter to run policy scans.- No external deps for the Terraform adapter (pure Python).
How to Test Adapters
tests/test_adapter.py— Terraform adapter (TYPE_MAP, resource emission, refs, outputs).tests/test_checkov_adapter.py— Checkov adapter.tests/test_wiz_adapter.py— Wiz adapter.tests/test_kyverno_adapter.py— Kyverno adapter.- All adapter tests load fixtures from
tests/fixtures/and usemotofor AWS mocking.
Where to Write Tests
tests/test_<adapter_name>.pypaired withtests/fixtures/<adapter>_fixture.json.
Adding a New Adapter
- Create
adapters/<name>/<name>_adapter.py. - Implement
adapt()and (for policy adapters)is_configured(). - Add the adapter's engine name to the
engineenum inschemas/policy_check_result.schema.jsonif it is a policy adapter. - Write a test (
tests/test_<name>_adapter.py) plus a fixture (tests/fixtures/<name>_fixture.json). - Add it to
scripts/run_platform.shif it is invoked at runtime. - Update this README.