feat(P4): regression-gate policies + docs (REQ-304..307)
regression/ policies (3): cap-013-adapter-dedup, cap-023-metrics-collector, cap-024-deck-structure — declarative mirrors of core/regression_verify.py over capability-inventory JSON. The imperative regression_verify.py is kept (drives CI gate); the policies are the declarative mirror (IDEATE I1 quality improvement). tests: test_regression_policies.py + clean/drifted fixtures. Skip-without-kj. docs: adapters/README.md (new kyverno-json row + PolicyEngine Protocol section with how-to-add-OpaEngine), adapters/kyverno-json/README.md (engine, install, policy directory layout, 4 categories, severity convention), schemas/README.md (D-116 engine enum reuse note), modules/STANDARDS.md §10 Policy Authoring Standard, docs/METRICS.md (swappable engine narrative). ---ci--- project: acdl phase: 4 milestone: v1.25 status: execute phase_role: execution requirements: covered: [REQ-304, REQ-305, REQ-306, REQ-307] partial: [] ---/ci---
This commit is contained in:
+61
-1
@@ -611,4 +611,64 @@ must be checked before the module is registered and published.
|
||||
`stack.schema.json`).
|
||||
- [ ] For an L2, a test is added that the composition resolves to the
|
||||
expected set of L1 instances and that the adapter emits a root module
|
||||
calling the L1 modules.
|
||||
calling the L1 modules.
|
||||
|
||||
---
|
||||
|
||||
## 10. Policy Authoring Standard (v1.25)
|
||||
|
||||
Module owners may ship per-module kyverno-json policies in
|
||||
`modules/<name>/policies/` (future convention; v1.25 policies live
|
||||
under `adapters/kyverno-json/policies/`). A policy file is a
|
||||
`ValidatingPolicy` resource (YAML or JSON).
|
||||
|
||||
### 10.1 Required fields
|
||||
|
||||
- `apiVersion: json.kyverno.io/v1alpha1`
|
||||
- `kind: ValidatingPolicy`
|
||||
- `metadata.name` — matches the filename (e.g. `require-tags.json` →
|
||||
`name: require-tags`). This becomes the `ruleId` prefix `KJ_<name>`.
|
||||
- `metadata.annotations["nova.cloudinit.dev/severity"]` — one of
|
||||
`critical`, `high`, `medium`, `low`, `info`. Drives the confidence
|
||||
signal's penalty mapping.
|
||||
- `spec.rules[].validate.assert` — an `all` or `any` list of assertion
|
||||
trees with JMESPath expressions. **No `forEach`, pattern operators,
|
||||
anchors, or wildcards** — use the `~` projection modifier to iterate.
|
||||
|
||||
### 10.2 Severity guidance
|
||||
|
||||
| Severity | When to use | Confidence penalty |
|
||||
| --- | --- | --- |
|
||||
| `critical` | a violation makes the deploy unsafe (e.g. public ingress on a prod DB) | hard override (score = 0, block) |
|
||||
| `high` | a violation is a security or compliance gap (e.g. plaintext secrets) | -0.20 |
|
||||
| `medium` | a violation is a best-practice miss (e.g. missing tags) | -0.05 |
|
||||
| `low` | a violation is a style or convention issue | -0.01 |
|
||||
| `info` | a non-blocking observation (default) | 0.0 |
|
||||
|
||||
### 10.3 Assertion-tree patterns
|
||||
|
||||
- **Iterate an array:** use the `~` modifier on the array key:
|
||||
```yaml
|
||||
check:
|
||||
~.resources:
|
||||
(@ < `5`): true
|
||||
```
|
||||
- **Match a resource type:** use the `match.any` block:
|
||||
```yaml
|
||||
match:
|
||||
any:
|
||||
- type: aws:s3:bucket
|
||||
```
|
||||
- **Binding for descendant access:** use `->name`:
|
||||
```yaml
|
||||
(bar + bat)->sum:
|
||||
($sum): 10
|
||||
```
|
||||
|
||||
### 10.4 Testing
|
||||
|
||||
- Ship a fixture pair (`passing.json` + `failing.json`) under
|
||||
`tests/fixtures/<policy_target>/`.
|
||||
- Add a test file `tests/test_<policy_target>_policies.py` using the
|
||||
`KyvernoJsonEngine` (skip-without-kj pattern).
|
||||
- The regression gate (`pytest tests/`) must remain green.
|
||||
Reference in New Issue
Block a user