|
| 1 | +# NLBoot Integration Guide |
| 2 | + |
| 3 | +`sourceos-boot` adapts the [`SociOS-Linux/nlboot`](https://github.com/SociOS-Linux/nlboot) safe planning protocol into SourceOS BootReleaseSet contracts and Prophet Lattice evidence envelopes. |
| 4 | + |
| 5 | +## What nlboot provides |
| 6 | + |
| 7 | +The nlboot reference implementation defines: |
| 8 | + |
| 9 | +| Object | Description | |
| 10 | +|---|---| |
| 11 | +| `SignedBootManifest` | Signed artifact manifest with kernel/initrd/rootfs refs, boot mode, and crypto profile | |
| 12 | +| `EnrollmentToken` | One-time, time-bound, boot-mode-scoped authorization token | |
| 13 | +| `BootPlan` | Side-effect-free plan record with `execute=false` and required proof gates | |
| 14 | + |
| 15 | +nlboot enforces RSA-PSS/SHA-256 manifest verification and FIPS-140-3-compatible crypto profile markers before emitting any plan. |
| 16 | + |
| 17 | +## Integration stance |
| 18 | + |
| 19 | +`sourceos-boot` does not fork the nlboot protocol vocabulary. Instead: |
| 20 | + |
| 21 | +- nlboot remains the safe planner and reference protocol lane. |
| 22 | +- `sourceos-boot` adapts nlboot manifest/token/plan output into BootReleaseSet patches, BootAuthorization records, and evidence envelopes. |
| 23 | +- BootReleaseSet is the handoff object for Prophet Platform, SourceOS, and Lattice. |
| 24 | + |
| 25 | +See [`NLBOOT_COMPATIBILITY.md`](NLBOOT_COMPATIBILITY.md) for the field-level mapping. |
| 26 | + |
| 27 | +## Adapter flow |
| 28 | + |
| 29 | +The `SourceOSBootAdapter` models a five-stage, side-effect-free handshake: |
| 30 | + |
| 31 | +``` |
| 32 | +announce → authorize → fetch manifest → verify → emit evidence |
| 33 | +``` |
| 34 | + |
| 35 | +1. **Announce** — build a `SourceOSBootAnnounce` payload from a `DeviceClaim`. |
| 36 | +2. **Authorize** — convert an nlboot `EnrollmentToken` document into a `BootAuthorization`. |
| 37 | +3. **Fetch** — build a `SourceOSBootFetchRequest` using the `BootAuthorization`. |
| 38 | +4. **Verify** — apply the nlboot manifest to produce a `BootReleaseSet` patch. |
| 39 | +5. **Evidence** — emit a `BootEvidence` envelope covering device claim, manifest hash, channel, boot mode, and verification result. |
| 40 | + |
| 41 | +All operations are pure and side-effect-free. No disk writes, kexec calls, or network requests are performed. |
| 42 | + |
| 43 | +## Boot mode mapping |
| 44 | + |
| 45 | +| nlboot `boot_mode` | SourceOS channel | SourceOS action | |
| 46 | +|---|---|---| |
| 47 | +| `installer` | `installer` | `install` | |
| 48 | +| `recovery` | `recovery` | `repair` | |
| 49 | +| `ephemeral` | `live` | `kexec` | |
| 50 | +| `bootstrap` | `live` | `enroll` | |
| 51 | + |
| 52 | +## CLI usage |
| 53 | + |
| 54 | +```bash |
| 55 | +PYTHONPATH=src python -m sourceos_boot.cli adapt-nlboot \ |
| 56 | + --manifest examples/nlboot/manifest.json \ |
| 57 | + --token examples/nlboot/token.json \ |
| 58 | + --device-id device-demo-m2 \ |
| 59 | + --public-key-fingerprint sha256:0000000000000000000000000000000000000000000000000000000000000000 \ |
| 60 | + --platform apple-silicon \ |
| 61 | + --nonce nonce-demo-1 \ |
| 62 | + --correlation-id corr-demo-1 |
| 63 | +``` |
| 64 | + |
| 65 | +The command emits an `NlbootAdapterOutput` JSON object to stdout. See |
| 66 | +`examples/nlboot/adapted-output.example.json` for the expected structure. |
| 67 | + |
| 68 | +## Fixture files |
| 69 | + |
| 70 | +| File | Description | |
| 71 | +|---|---| |
| 72 | +| `examples/nlboot/manifest.json` | Minimal nlboot `SignedBootManifest` fixture | |
| 73 | +| `examples/nlboot/token.json` | Minimal nlboot `EnrollmentToken` fixture | |
| 74 | +| `examples/nlboot/adapted-output.example.json` | Expected `NlbootAdapterOutput` for the above fixtures | |
| 75 | + |
| 76 | +## Validation |
| 77 | + |
| 78 | +```bash |
| 79 | +make validate # validate BootReleaseSet example and exercise the nlboot adapter |
| 80 | +make test # run pytest suite |
| 81 | +``` |
| 82 | + |
| 83 | +The CI workflow (`ci.yml`) also validates `examples/boot-release-set.example.json` |
| 84 | +and runs the full pytest suite on every push and pull request. |
| 85 | + |
| 86 | +## Known gaps |
| 87 | + |
| 88 | +- Real nlboot manifest signature verification (RSA-PSS/SHA-256) is not yet wired |
| 89 | + into this adapter; the adapter accepts a pre-verified manifest document. |
| 90 | +- Artifact fetch, SHA-256 check, and content-addressed cache are implemented in |
| 91 | + the Rust `nlboot-client` lane; the Python adapter here covers planning only. |
| 92 | +- Host mutation (kexec, install, rollback) remains disabled pending explicit |
| 93 | + platform adapter review. See `WORLD_CLASS_TARGETS.md` for the implementation path. |
| 94 | + |
| 95 | +## References |
| 96 | + |
| 97 | +- [`NLBOOT_COMPATIBILITY.md`](NLBOOT_COMPATIBILITY.md) — detailed field mapping |
| 98 | +- [`INTEGRATION.md`](INTEGRATION.md) — upstream/downstream dependency contract |
| 99 | +- [`WORLD_CLASS_TARGETS.md`](WORLD_CLASS_TARGETS.md) — implementation roadmap |
| 100 | +- [`SociOS-Linux/nlboot`](https://github.com/SociOS-Linux/nlboot) — upstream safe planner |
| 101 | +- [`src/sourceos_boot/adapter.py`](../src/sourceos_boot/adapter.py) — adapter implementation |
0 commit comments