|
| 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 | +Rust parser and renderer for K9 self-validating configuration files — |
| 7 | +declares software components with provenance tracking, security |
| 8 | +classification, build recipes, and runtime contracts. |
| 9 | + |
| 10 | +# Overview |
| 11 | + |
| 12 | +K9 is a configuration format for software component declarations. Each |
| 13 | +component carries: |
| 14 | + |
| 15 | +- **Pedigree** — provenance: origin URL, author, license, supply-chain |
| 16 | + hashes |
| 17 | + |
| 18 | +- **SecurityLevel** — Kennel / Yard / Hunt (same three-tier model as K9 |
| 19 | + Nickel components) |
| 20 | + |
| 21 | +- **Recipe** — build or assembly instructions (tool + command) |
| 22 | + |
| 23 | +- **Contracts** — runtime invariants with check commands and severity |
| 24 | + levels |
| 25 | + |
| 26 | +`k9-rs` supports two surface formats: |
| 27 | + |
| 28 | +- `.k9` — YAML-like plain-text format parsed natively |
| 29 | + |
| 30 | + \* `.k9.ncl` — Nickel format; detected and returned as \`K9Error |
| 31 | + NickelFormat\` (requires the Nickel evaluator — use `pandoc-k9` for |
| 32 | + Nickel K9 files) |
| 33 | + |
| 34 | + == Quick Start |
| 35 | + |
| 36 | +```rust |
| 37 | +use k9_svc::parser::parse; |
| 38 | +use k9_svc::renderer::render; |
| 39 | + |
| 40 | +let input = r#"component: my-svc |
| 41 | + version: 0.1.0 |
| 42 | + pedigree: |
| 43 | + origin: https://github.com/example/svc |
| 44 | + author: Alice |
| 45 | + security: kennel |
| 46 | +"#; |
| 47 | + |
| 48 | +let components = parse(input)?; |
| 49 | +let output = render(&components)?; |
| 50 | +``` |
| 51 | + |
| 52 | +# Security Levels |
| 53 | + |
| 54 | +| Level | Meaning | |
| 55 | +|----|----| |
| 56 | +| `kennel` | Data-only. No execution. Strict sandbox. Safe to parse anywhere. | |
| 57 | +| `yard` | Nickel evaluation + limited I/O. Capability-based sandbox. | |
| 58 | +| `hunt` | Full shell execution via recipes. Cryptographic signature required. | |
| 59 | + |
| 60 | +# Modules |
| 61 | + |
| 62 | +| Module | Purpose | |
| 63 | +|------------|----------------------------------------------------------------| |
| 64 | +| `types` | `Component`, `Pedigree`, `SecurityLevel`, `Recipe`, `Contract` | |
| 65 | +| `parser` | `parse(str)` `→` `Vec<Component>` — detects Nickel format | |
| 66 | +| `renderer` | `render(&[Component])` `→` `String` | |
| 67 | +| `error` | `K9Error`: `ParseError`, `NickelFormat`, `Io`, `RenderError` | |
| 68 | + |
| 69 | +# Related |
| 70 | + |
| 71 | +- [k9-haskell](https://github.com/hyperpolymath/k9-haskell) — Haskell |
| 72 | + implementation |
| 73 | + |
| 74 | +- [pandoc-k9](https://github.com/hyperpolymath/pandoc-k9) — Pandoc |
| 75 | + reader/writer for `.k9.ncl` files |
| 76 | + |
| 77 | +# License |
| 78 | + |
| 79 | +MPL-2.0 (MPL-2.0 preferred; MPL-2.0 required for crates.io). See |
| 80 | +[LICENSE](LICENSE). |
0 commit comments