physics-mv
FORGE: request-bound machine realization, providers and verification for AienOS. Host, simulated and GB10 hardware paths have separate evidence.
Brought by drakestapleton
physics-mv / TRANSITION_PLAN_M2.md
| 1 | # Sovereign Tooling Transition Plan: Milestone 2 (PHYSICS) |
| 2 | Tracking: aien-spark/aien-architecture#12, aien-spark/physics#8 |
| 3 | |
| 4 | ## Context & Sovereignty Rule |
| 5 | Per the Sovereign Machine doctrine, qualification and build tooling must be local, in-house, and offline, with zero Python in the trusted path. |
| 6 | Milestone 2 previously relied on Python for canonical binary generation, variant matrix builds, static audits, QEMU dynamic harnesses, and gate orchestration (`build.py`, `run_milestone2_gates.py`, `seam1_static_audit.py`, `seam2_dynamic_harness.py`, `verify_golden.py`, `verify_unit.py`, `verify_trap.py`, `verify_no_auth.py`, `generate_canary.py`, `generate_snippet.py`, `generate_audit_ledger.py`). |
| 7 | |
| 8 | ## Implementation Summary |
| 9 | A complete, pure C (C11) and POSIX shell replacement suite has been designed and implemented in `aien-spark/physics`: |
| 10 | 1. `tools/m2tool.c`: Pure C host qualification tool compiled via host `gcc -O2` and linked directly with audited `sha256_clean.c`. |
| 11 | - Subcommands: `sha256`, `hexfield`, `bytes`, `pin-inc`, `gen-canary`, `gen-snippet`, `audit-verify`, `verify-golden`, `verify-unit`, `verify-trap`, `verify-no-auth`, `get-symbol`. |
| 12 | 2. `tools/qemu_inspect.sh`: Sovereign POSIX shell QEMU inspection harness using QMP socket `pmemsave` to inspect bare-metal execution state directly from physical memory. |
| 13 | 3. `m2_build.sh` (symlinked as `build.sh`): Master build pipeline that: |
| 14 | - Builds canonical `physics.bin` from source. |
| 15 | - Extracts symbol addresses, produces `physics_pin.inc`, and builds canonical `atlas_m2.bin`. |
| 16 | - Assembles and links qualification test variants: `unit`, `trap_brk`, `trap_align`, and the 22 hostile atlas defsym variants. |
| 17 | 4. `run_m2_gates.sh` (symlinked as `run_milestone2_gates.sh`): Master POSIX shell gate runner orchestrating Seam 1 static audits and Seam 2 dynamic harnesses. |
| 18 | |
| 19 | ## Artifact Integrity & Receipt Preservation |
| 20 | - The canonical binary artifacts are verified byte-identical to the qualified binaries: |
| 21 | - `physics.bin`: 6,144 bytes, SHA-256 `4b22a08c02c6d482d8c39db51d8b6daafdfb5fbe4c47ea41444743e498c8a141` |
| 22 | - `atlas_m2.bin`: 1,764 bytes, SHA-256 `1d6d75a6f29631627f7f0df88e99990526a6e2e59178652d880d32f504ca638d` |
| 23 | - The existing qualification receipt `qualification_receipt.json` remains **untouched** as historical evidence for the Python-based qualification. |
| 24 | - The new C/shell tooling was verified to produce 100% gate pass rate across all 15 gates: |
| 25 | 1. `PHYSICS_ARTIFACT_IDENTITY_PASS` |
| 26 | 2. `PHYSICS_CANARY_INTEGRITY_PASS` |
| 27 | 3. `PHYSICS_DISJOINT_MEMORY_PASS` |
| 28 | 4. `PHYSICS_HANDOFF_ABI_PASS` |
| 29 | 5. `PHYSICS_AUDIT_PASS` |
| 30 | 6. `PHYSICS_STEP_VERIFICATION_PASS` |
| 31 | 7. `PHYSICS_BRANCH_FREE_PASS` |
| 32 | 8. `PHYSICS_GOLDEN_BOOT_PASS` |
| 33 | 9. `PHYSICS_UNIT_TEST_PASS` (13/13 unit tests pass) |
| 34 | 10. `PHYSICS_TRAP_ALIGNMENT_PASS` |
| 35 | 11. `PHYSICS_TRAP_BREAKPOINT_PASS` |
| 36 | 12. `PHYSICS_AUTH_FAIL_ENTRY_PASS` |
| 37 | 13. `PHYSICS_AUTH_FAIL_STACK_PASS` |
| 38 | 14. `PHYSICS_AUTH_FAIL_DESCRIPTOR_PASS` |
| 39 | 15. `PHYSICS_AUTH_FAIL_MUTATION_PASS` (20/20 hostile corrupt ingress cases refused) |
| 40 | |
| 41 | All 15 gates complete execution in ~16.2 seconds with zero Python dependencies. |
| 42 | |
| 43 | ## Transition Phasing |
| 44 | 1. **Phase 1 (Dual-Track Availability - Present)**: |
| 45 | - Pure C and shell tooling (`tools/m2tool.c`, `tools/qemu_inspect.sh`, `m2_build.sh`, `run_m2_gates.sh`) are active. |
| 46 | - Developers and automated CI can build and verify all gates using `./run_m2_gates.sh` without Python. |
| 47 | - Legacy Python scripts were kept as historical reference until Phase 3 (below). |
| 48 | 2. **Phase 2 (Formal Requalification Decision)**: |
| 49 | - When recorded in `aien-architecture#12`, `run_m2_gates.sh --write-receipt` generates a refreshed receipt reflecting the pure C/shell verification toolchain. |
| 50 | 3. **Phase 3 (Python Retirement & Archival)**: |
| 51 | - Legacy Python files are moved to `history/legacy-python/` or deleted, completing total retirement of Python from the sovereign path. |
| 52 | |
| 53 | ## Phase 3 Status: COMPLETE (2026-09-30) |
| 54 | The five legacy Python files (`generate_physics_audit.py`, `m2_build.py`, `run_milestone2_gates.py`, |
| 55 | `seam1_physics_audit.py`, `seam2_physics_harness.py`) are deleted. They remain in git history at |
| 56 | `d52759d` and earlier; `qualification_receipt.json` (historical evidence, untouched) pins their SHA-256. |
| 57 | Phase 2 (receipt refresh under aien-architecture#12) remains open: the committed receipt still describes the |
| 58 | retired Python run. |
| 59 | |
| 60 | Equivalence check before deletion (scratch copies of `d52759d`, QEMU on the Spark): |
| 61 | - `python3 run_milestone2_gates.py` and `./run_m2_gates.sh` print the same 15 gate names, all PASS, no FAIL. |
| 62 | - Both rebuild `physics.bin` (`4b22a08c...f4aed3bd`) and `atlas_m2.bin` (`1d6d75a6...7b09012`) byte-identical |
| 63 | to the committed files. |
| 64 | - The Python audit generator regenerated `physics.audit`, `physics.manifest`, `physics.memory-map`, |
| 65 | `physics.control-flow` and `physics.sha256` byte-identical to the committed files; `physics.decode` differed |
| 66 | only in objdump's file-path header line. |
| 67 | |
| 68 | ### Regeneration recipe for the committed M2 audit artifacts (no Python) |
| 69 | Run `./m2_build.sh` first (produces `build/canonical/physics.elf` and `physics.bin`). |
| 70 | - `physics.sha256`: `(cd build/canonical && sha256sum physics.bin)`; byte-identical to the committed file. |
| 71 | - `physics.decode`: `aarch64-linux-gnu-objdump -d build/canonical/physics.elf`, run from the repository root; |
| 72 | identical to the committed file (line 2 names that repository-relative ELF path). |
| 73 | - `physics.audit`, `physics.manifest`, `physics.memory-map`, `physics.control-flow`: frozen M2 evidence, last |
| 74 | generated by `generate_physics_audit.py` (`git show d52759d:generate_physics_audit.py`). They are not |
| 75 | regenerated; `tools/m2tool audit-verify` re-checks `physics.audit`, `physics.manifest` and `physics.decode` |
| 76 | against `physics.bin` on every `./run_m2_gates.sh` run. If `physics.s` ever changes, these files need a |
| 77 | C/shell generator first (none exists yet). |
| 78 | - `physics_pin.inc`: `tools/m2tool pin-inc build/canonical/physics.bin physics_pin.inc` reproduces it except |
| 79 | the header comment (the committed copy still says it came from `m2_build.py`; left as committed). |