|
| 1 | +// SPDX-License-Identifier: PMPL-1.0-or-later |
| 2 | +// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk> |
| 3 | += k9iser-mcp — K9 contract regeneration cartridge |
| 4 | +:toc: macro |
| 5 | +:orientation: shallow |
| 6 | + |
| 7 | +toc::[] |
| 8 | + |
| 9 | +== Purpose |
| 10 | + |
| 11 | +Wraps the `k9iser` generator as a BoJ cartridge so that a repository's |
| 12 | +`generated/k9iser/*.k9` contracts are regenerated *centrally, on trigger* |
| 13 | +instead of being run ad hoc and hand-committed (which is how they rot — |
| 14 | +see hyperpolymath/k9iser#8 and the idaptik#77 triage). |
| 15 | + |
| 16 | +This is the reference implementation for the `-iser` regeneration-cartridge |
| 17 | +pattern (standards epic): every `-iser` generator should ship an equivalent |
| 18 | +so `generated/*` stops being hand-maintained drift estate-wide. |
| 19 | + |
| 20 | +== Pipeline |
| 21 | + |
| 22 | +[source] |
| 23 | +---- |
| 24 | +Empty -> ManifestLoaded -> Generated -> Validated -> Applied |
| 25 | +---- |
| 26 | + |
| 27 | +Enforced safety invariants (formally in `abi/K9iserMcp/SafeK9iser.idr`, |
| 28 | +executably in `ffi/k9iser_ffi.zig`): |
| 29 | + |
| 30 | +. *No apply without validate* — contracts that fail the canonical |
| 31 | + `k9-validate` ruleset (K9! magic + pedigree) can never be committed back |
| 32 | + to a repository. |
| 33 | +. *No validate without generate* — stale/absent output is never validated. |
| 34 | +. *Generate requires a loaded manifest.* |
| 35 | + |
| 36 | +== Tools (`cartridge.json`) |
| 37 | + |
| 38 | +[cols="1,3"] |
| 39 | +|=== |
| 40 | +| `k9_load_manifest` | Load a repo's `k9iser.toml` |
| 41 | +| `k9_generate` | Generate K9 contracts from configs + manifest rules |
| 42 | +| `k9_validate` | Validate against the canonical K9! + pedigree ruleset |
| 43 | +| `k9_apply` | Commit + push regenerated contracts to the branch |
| 44 | +| `k9_clean` | Clean the session |
| 45 | +|=== |
| 46 | + |
| 47 | +== Layout |
| 48 | + |
| 49 | +* `cartridge.json` — manifest (tools, ADR-0006 ffi symbols) |
| 50 | +* `mod.js` — Deno MCP bridge → backend at `K9ISER_BACKEND_URL` |
| 51 | + (default `http://127.0.0.1:7743`) |
| 52 | +* `abi/` — Idris2 ABI: pipeline state machine + safety GADT |
| 53 | +* `ffi/` — Zig FFI: C-ABI exports + ADR-0006 `boj_cartridge_invoke` |
| 54 | + dispatch (16/16 tests pass) |
| 55 | +* `adapter/` — three-protocol (REST/gRPC-compat/GraphQL) adapter |
| 56 | +* `panels/` — Panll dashboard manifest |
| 57 | + |
| 58 | +== Status |
| 59 | + |
| 60 | +Grade D Alpha. Cartridge package + verified state machine are complete. |
| 61 | +`boj_cartridge_invoke` returns shaped stubs; the live path additionally |
| 62 | +needs the backend service (runs the `k9iser` binary against a checked-out |
| 63 | +working tree) *and* the BoJ REST runtime, which is pending the Elixir |
| 64 | +rewrite — until that deploys, the templated `k9iser-regen` trigger is |
| 65 | +fire-and-forget exactly like `boj-build.yml` is today. |
0 commit comments