|
| 1 | +<!-- |
| 2 | +SPDX-License-Identifier: CC-BY-SA-4.0 |
| 3 | +SPDX-FileCopyrightText: 2025-2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk> |
| 4 | +--> |
| 5 | + |
| 6 | +# Overview |
| 7 | + |
| 8 | +**GitHub Action to validate K9 configuration files in your repository.** |
| 9 | + |
| 10 | +K9 is a Nickel-based configuration contract format used by the |
| 11 | +contractile system for deployment validation and policy enforcement. |
| 12 | +Files use the `.k9` or `.k9.ncl` extension and follow a security-tiered |
| 13 | +"leash" model: kennel (data-only), yard (validated), and hunt (full |
| 14 | +execution). |
| 15 | + |
| 16 | +# Checks Performed |
| 17 | + |
| 18 | +1. **K9! magic number** — First non-empty line must be exactly `K9!` |
| 19 | + |
| 20 | +2. **SPDX header** — Verifies `SPDX-License-Identifier` in the first 10 |
| 21 | + lines |
| 22 | + |
| 23 | +3. **Pedigree block** — Requires a `pedigree` `=` `{` `…` `}` section |
| 24 | + with: |
| 25 | + |
| 26 | + - `name` field (in `pedigree.metadata` or directly) |
| 27 | + |
| 28 | + - `version` or `schema_version` field |
| 29 | + |
| 30 | +4. **Security level** — `leash` or `security_level` must be one of: |
| 31 | + `kennel`, `yard`, `hunt` |
| 32 | + |
| 33 | +5. **Hunt-level signature** — Files at `hunt` security level must |
| 34 | + include a `signature` or `signature_required` field |
| 35 | + |
| 36 | +# Usage |
| 37 | + |
| 38 | +Add to your workflow: |
| 39 | + |
| 40 | +```yaml |
| 41 | +name: Validate K9 |
| 42 | +on: [push, pull_request] |
| 43 | + |
| 44 | +permissions: |
| 45 | + contents: read |
| 46 | + |
| 47 | +jobs: |
| 48 | + validate: |
| 49 | + runs-on: ubuntu-latest |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v4 |
| 52 | + - uses: hyperpolymath/k9-validate-action@v1 |
| 53 | + with: |
| 54 | + path: '.' # Directory to scan (default: repo root) |
| 55 | + strict: 'false' # Promote warnings to errors (default: false) |
| 56 | + # paths-ignore: defaults to vendored / fixture patterns; override |
| 57 | + # via newline-separated string. Use '' to disable. |
| 58 | +``` |
| 59 | + |
| 60 | +## Inputs |
| 61 | + |
| 62 | +| Input | Default | Description | |
| 63 | +|----|----|----| |
| 64 | +| `path` | `.` | Directory path to scan for K9 files | |
| 65 | +| `strict` | `false` | When `true`, warnings become errors and the action fails on any issue | |
| 66 | +| `paths-ignore` | *vendored & fixture defaults* | Newline-separated path fragments to skip. Substring match against each file path. Default set: `vendor/`, `vendored/`, `verified-container-spec/`, `.audittraining/`, `integration/fixtures/`, `test/fixtures/`, `tests/fixtures/`. Pass an empty string (`paths-ignore:` `’’`) to disable and scan everything. See <https://github.com/hyperpolymath/hypatia/pull/243> for the architectural rationale (content-pattern validators must distinguish targets from fixtures / vendored / training-corpus files that legitimately contain the very pattern being checked). | |
| 67 | + |
| 68 | +### Why default-on path exemptions? |
| 69 | + |
| 70 | +K9 files inside vendored projects (e.g. `verified-container-spec/`) |
| 71 | +carry their own pedigree declarations in their upstream context — |
| 72 | +flagging every such file as "Pedigree block missing ’name’ field" is |
| 73 | +provenance noise. The defaults match the canonical RSR vendored-content |
| 74 | +paths; override for project-specific carve-outs. |
| 75 | + |
| 76 | +## Outputs |
| 77 | + |
| 78 | +| Output | Description | |
| 79 | +|-----------------|------------------------------| |
| 80 | +| `files-scanned` | Number of K9 files processed | |
| 81 | +| `errors` | Count of validation errors | |
| 82 | +| `warnings` | Count of validation warnings | |
| 83 | + |
| 84 | +# Security Levels |
| 85 | + |
| 86 | +| Level | Trust | Requirements | |
| 87 | +|----|----|----| |
| 88 | +| `kennel` | Data-only | No signature required. Pure configuration values. | |
| 89 | +| `yard` | Validated | Nickel contracts enforced. Type-checked before use. | |
| 90 | +| `hunt` | Full access | **Signature required.** Can execute commands and access system resources. | |
| 91 | + |
| 92 | +# Author |
| 93 | + |
| 94 | +Jonathan D.A. Jewell \<[j.d.a.jewell@open.ac](j.d.a.jewell@open.ac).uk\> |
| 95 | + |
| 96 | +# License |
| 97 | + |
| 98 | +SPDX-License-Identifier: CC-BY-SA-4.0 |
| 99 | + |
| 100 | +See [LICENSE](LICENSE) for details. |
0 commit comments