From a27d861d3b63dd9835b4cfb019bdb07ea3a861f7 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 24 Aug 2026 01:12:49 +0200 Subject: [PATCH] Scenario lifecycle: raise, exec, snapshot, restore, destroy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A declaration goes in and a disposable mesh comes out. Verified on a workstation, not asserted: two machines raised and addressed in 14.6s, snapshot 0.28s, restore-to-usable 11.6s, both families pinging with no loss, and the workstation with no route into any of it. The declaration layer implements the model in full — three positions a machine can be in, keyed on forwardability; gateways carrying the address the world sees them as; both address families; multi-homing; MTU; inter-segment policy. It is validated hard because the failures it prevents are silent: a private range on a public segment produces no error, the mesh simply never forms. Public segments are refused unless they use RFC 5737 or RFC 3849 space, and a range wider than the reserved block is refused too. 33 tests, all offline. The runtime implements less than the model, and refuses the difference. A scenario declaring gateways, published ports, policy, inbound deny or place is rejected at raise with every gap named. Raising it would produce a mesh that silently lacks what it declared, which is the fault this lab exists to catch — 04-ISSUES/003, where a firewall key is declared in five manifests and read by no code. Three bugs found by review and by running it, all of one family: The readiness check truthiness-tested incusOk's return. `exec … true` succeeds with EMPTY output, so every machine reported unreachable while incus exec on it worked perfectly. succeeds() now exists so the mistake is not available, and network delete had the same bug — it counted zero segments removed while removing them. list() split instance from machine on the last dash, so a machine called home-server absorbed half the instance id and destroy found nothing. Resources are now found by the metadata they carry, never by name. restore reported success in 0.79s while the machine's agent was still starting, so the next command failed. Both raise and restore now wait for usable and say how long that took — reporting the earlier number is transport reported as effect, which is the fault the lab is being built to find. Two incus behaviours worth recording. Its CLI reads a YAML definition from stdin when stdin is not a terminal, so a spawned command hangs until the timeout kills it and arrives with empty stderr — a failure with no explanation, on a command that works when typed. And it assigns a MAC at runtime without recording it in device config, so MACs are derived and set explicitly, which the guest needs anyway: it names interfaces by bus position, and matching by name configures the wrong one on a multi-homed machine. No build step; Node strips the types. The lifecycle has no unit tests because a fake hypervisor would assert that the fake behaves as expected, which is the shape of test this project exists to stop shipping. --- .gitignore | 1 + README.md | 142 +++++++++++++--- package-lock.json | 68 ++++++++ package.json | 20 +++ scenarios/bootstrap-single.yml | 22 +++ scenarios/the-ordinary-shape.yml | 81 ++++++++++ scenarios/two-on-a-segment.yml | 23 +++ src/cli.ts | 188 ++++++++++++++++++++++ src/declaration/net.ts | 88 ++++++++++ src/declaration/parse.ts | 116 ++++++++++++++ src/declaration/types.ts | 114 +++++++++++++ src/declaration/validate.ts | 267 +++++++++++++++++++++++++++++++ src/incus/client.ts | 216 +++++++++++++++++++++++++ src/lifecycle/address.ts | 100 ++++++++++++ src/lifecycle/names.ts | 66 ++++++++ src/lifecycle/operate.ts | 153 ++++++++++++++++++ src/lifecycle/raise.ts | 202 +++++++++++++++++++++++ src/lifecycle/ready.ts | 56 +++++++ src/lifecycle/supported.ts | 76 +++++++++ test/names.test.ts | 34 ++++ test/net.test.ts | 49 ++++++ test/supported.test.ts | 63 ++++++++ test/validate.test.ts | 187 ++++++++++++++++++++++ tsconfig.json | 21 +++ 24 files changed, 2331 insertions(+), 22 deletions(-) create mode 100644 .gitignore create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 scenarios/bootstrap-single.yml create mode 100644 scenarios/the-ordinary-shape.yml create mode 100644 scenarios/two-on-a-segment.yml create mode 100755 src/cli.ts create mode 100644 src/declaration/net.ts create mode 100644 src/declaration/parse.ts create mode 100644 src/declaration/types.ts create mode 100644 src/declaration/validate.ts create mode 100644 src/incus/client.ts create mode 100644 src/lifecycle/address.ts create mode 100644 src/lifecycle/names.ts create mode 100644 src/lifecycle/operate.ts create mode 100644 src/lifecycle/raise.ts create mode 100644 src/lifecycle/ready.ts create mode 100644 src/lifecycle/supported.ts create mode 100644 test/names.test.ts create mode 100644 test/net.test.ts create mode 100644 test/supported.test.ts create mode 100644 test/validate.test.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/README.md b/README.md index af4783d..bae2cca 100644 --- a/README.md +++ b/README.md @@ -26,38 +26,136 @@ The bootstrap scenario is a **strict subset** — same virtualisation, same netw lifecycle, stopping before a control plane exists. The full scenario is reached by putting more inside the machines, not by building a second thing. -**Bootstrap is what gets built here first.** Nothing in this repository requires a forge, a -coordinator or a pipeline to be useful. - -## Shape +## Using it ``` -scenarios/ declarations of a mesh to raise -lifecycle/ create · snapshot · reset · destroy -network/ segments and addressing -place/ getting a binary onto a machine +mesh-lab check can this machine run scenarios at all +mesh-lab validate scenarios/x.yml parse and check, raising nothing +mesh-lab raise scenarios/x.yml materialise it, wait until the machines are USABLE +mesh-lab list instances currently standing +mesh-lab exec -- +mesh-lab snapshot