ed387a4f54
---ci--- project: acdl phase: 1 milestone: v1.25 status: verify phase_role: execution requirements: covered: [REQ-291, REQ-292, REQ-293, REQ-294, REQ-308, REQ-309] partial: [] ---/ci---
4.0 KiB
4.0 KiB
VERIFY — P1 engine-core (v1.25)
4-layer verify gate: structural, behavioral, security, quality. Phase: P1. Requirements: REQ-291..294, 308, 309. Result: PASS.
Structural
core/policy_engine.pyexists, implementsPolicyEngineProtocol (PEP 544,@runtime_checkable),PolicyEngineRegistrywithregister()+get_engine(),NullEnginefallback.adapters/kyverno-json/kyverno_json_engine.pyexists, exportsKyvernoJsonEnginewithname,is_configured(),evaluate().adapters/kyverno-json/__init__.pyloads the engine by file path (the dir name has a hyphen — not a valid Python package name).adapters/kyverno-json/policies/_smoke.jsonexists (trivial policy for round-trip validation).scripts/install-kyverno-json.shexists (go install kj@latest)..ciagent/config.jsonhas thepolicyobject (engine: kyverno-json,policy_root)..gitea/workflows/ci.yml+.github/workflows/ci.ymlhave the Go + kj install step (best-effort, tests skip when kj absent).tests/test_policy_engine.py(10 tests) +tests/test_kyverno_json_engine.py(16 tests) exist.
Behavioral
pytest tests/test_policy_engine.py tests/test_kyverno_json_engine.py: 24 passed, 2 skipped (kj not installed — expected;pytest.skip("kj not installed")).NullEnginesatisfies thePolicyEngineProtocol (G-Q8a —isinstance(NullEngine(), PolicyEngine)is True). Proves the swap boundary is real without implementing OPA.KyvernoJsonEngine.is_configured()returnsFalsewhenwhich kjis absent →evaluate()returns a singleKJ_ENGINE_NOT_CONFIGUREDSKIPPED PCR (distinctruleIdfrom NullEngine'sNULL_ENGINE_INACTIVE— G-Q4).- PCR records validate against
schemas/policy_check_result.schema.json(viajsonschema.validatein tests). - Defensive parsing: malformed kyverno-json output →
errorPCR (KJ_ENGINE_ERROR), never an exception. - Severity annotation reading (G-Q10a): policies with
nova.cloudinit.dev/severity: highproduce PCRs withseverity: high; policies without the annotation default toinfo. - Registry:
get_engine()returns the configured engine; unknown engine name raisesKeyError;policykey absent →NullEngine. - No regression:
pytest tests/test_confidence_signal.py tests/test_adapter.py tests/test_checkov_adapter.py tests/test_kyverno_adapter.py tests/test_contract_resolver.py— 132 passed (unchanged).
Security
- No new secrets, no new network calls in the engine core (the engine
shells to a local binary; the binary makes no network calls for
scan). is_configured()guard ensures the platform runs without the binary (no hard dependency that could be exploited as a DoS vector).- The engine writes the payload to a temp file (
tempfile.NamedTemporaryFile) and unlinks it in afinallyblock (no leftover payload on disk). - No
shell=Truein thesubprocess.runcall (command is a list — no shell injection surface).
Quality
python3 -m py_compilepasses on all new Python files.- The
PolicyEngineProtocol is minimal (3 members) — the swap boundary is the moat (NORTH_STAR Strategic Objective #2). - The
NullEngineproves a second implementation exists (structural conformance) — the OPA swap is a known quantity (RESEARCH §4.2). - Tests use
pytest.skipwhenwhich kjis absent, so the CI matrix passes with or without the binary (the suite is green in both cases).
Must-have checklist
PolicyEngineProtocol +PolicyEngineRegistry+NullEngine(REQ-291)config.json.policyobject (REQ-292)KyvernoJsonEngineadapter (REQ-293)__init__.py+_smoke.json+install-kyverno-json.sh+ CI install (REQ-294)test_policy_engine.py— protocol conformance, registry, NullEngine fallback (REQ-308)test_kyverno_json_engine.py— PCR schema validity, defensive parsing, skip-without-kj (REQ-309)
Verdict: PASS — all P1 must-haves met, no regressions, 24 new tests pass (2 skip-without-kj), 132 existing tests unchanged.