From d3336f2f641a75a527f6c91439f6a4a6aab5c851 Mon Sep 17 00:00:00 2001 From: "Darwin D. Wu" Date: Fri, 23 Oct 2026 18:10:22 -0700 Subject: [PATCH 1/3] docs: point RFD references to chaba-dev/rfds The RFDs that lived in rfd/ moved to the shared chaba-dev/rfds repository (https://github.com/chaba-dev/rfds), published at https://chaba-rfds.pages.dev, and were renumbered there: RFD 1 -> RFD 18 RFD 2 -> RFD 19 RFD 3 -> RFD 20 RFD 4 -> RFD 21 RFD 5 -> RFD 22 Rewrite prose mentions in docs, comments, CI step names, and script messages to the new numbers in a single pass, and point links and paths into rfd/ at the site page for the new number. Identifiers, file names, test names, environment variables, and output directories that carry the old number (rfd3_phase*, scripts/rfd3-*, poc/rfd3-*, .poc/rfd4-phase0-gate) are unchanged. The QEMU patch header is unchanged because the flake applies that file to the pinned QEMU. --- .github/workflows/ci.yml | 4 +-- README.md | 26 +++++++++---------- crates/simferret/src/checker.rs | 2 +- crates/simferret/src/runtime.rs | 2 +- crates/simferret/src/vm.rs | 6 ++--- crates/simferret/src/workload/mod.rs | 2 +- crates/simferret/tests/rfd3_phase1.rs | 2 +- crates/simferret/tests/rfd3_phase2.rs | 2 +- crates/simferret/tests/rfd3_phase3.rs | 2 +- crates/simferret/tests/rfd3_phase4.rs | 2 +- docs/time-model.adoc | 16 ++++++------ flake.nix | 2 +- poc/rfd3-phase0/build-layout.py | 2 +- poc/rfd3-phase0/oci_prototype.py | 2 +- poc/rfd3-phase0/supervisor-test-workload.c | 2 +- poc/rfd3-phase0/supervisor.c | 2 +- poc/time-model/EVIDENCE.adoc | 4 +-- .../qemu-nosleep-replay-upstream.adoc | 8 +++--- poc/time-model/reference-host-values.txt | 6 ++--- scripts/rfd3-entry-gate.sh | 2 +- scripts/rfd3-phase0-spike-test.sh | 4 +-- scripts/rfd3-phase0-spike.sh | 10 +++---- scripts/rfd3-phase1-evidence.sh | 2 +- scripts/rfd3-phase2-runtime.sh | 8 +++--- scripts/rfd3-phase3-acceptance.sh | 4 +-- scripts/rfd3-phase4-acceptance.sh | 4 +-- scripts/rfd3-phase4-checks-test.sh | 4 +-- scripts/rfd3-phase4-checks.sh | 2 +- scripts/rfd3-phase4-runtime.sh | 10 +++---- scripts/time-model-gate-test.sh | 2 +- scripts/time-model-gate.sh | 4 +-- scripts/time-model-input-probe.sh | 4 +-- 32 files changed, 77 insertions(+), 77 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2622b6..3317c75 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: - run: nix develop --command ./scripts/time-model-gate-test.sh - run: nix develop --command ./scripts/rfd3-phase0-spike-test.sh - run: nix develop --command ./scripts/rfd3-phase1-evidence.sh - - name: RFD 3 phase 2 guest runtime + - name: RFD 20 phase 2 guest runtime # The runtime changes root, drops credentials, and creates device nodes, # and its guest-wide cleanup barrier needs a private PID namespace, so # the test binary is built unprivileged and then run as PID 1 under sudo. @@ -77,7 +77,7 @@ jobs: nix develop --command sudo --preserve-env=PATH,SIMFERRET_BUSYBOX \ env SIMFERRET_PHASE2_TEST_BINARY="$binary" \ ./scripts/rfd3-phase2-runtime.sh - - name: RFD 3 phase 4 guest-visible conformance + - name: RFD 20 phase 4 guest-visible conformance # The conformance check changes root, drops credentials, and creates # device nodes, and its guest-wide cleanup barrier needs a private PID # namespace, so the test binary is built unprivileged and then run as diff --git a/README.md b/README.md index 8858ef0..af4e85b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ SimFerret is an experimental deterministic simulation platform for finding and reproducing failures in unmodified software. The project is currently in design and proof-of-concept development. See the -[Requests for Discussion](rfd/README.adoc) for architecture decisions and +[Requests for Discussion](https://chaba-rfds.pages.dev) for architecture decisions and implementation plans. ## Architecture @@ -24,7 +24,7 @@ Rust owns scenario choices, VM lifecycle, artifacts, event normalization, and assertions. QEMU owns deterministic machine execution and its replay log. All guest-affecting host input crosses a recorded boundary; uncontrolled network, host filesystems, entropy, and wall clocks are outside the initial replay -contract. [RFD 1](rfd/0001/README.adoc) records the architecture and +contract. [RFD 18](https://chaba-rfds.pages.dev/rfd/0018/) records the architecture and defines the bounded echo/restart proof of concept. ## QEMU replay spike @@ -112,7 +112,7 @@ under `.poc/phase4-acceptance/`. CI runs the same command on Ubuntu. ## Network replay spike -The RFD 2 Phase 0 spike adds an explicit RTL8139 NIC with its option ROM +The RFD 19 Phase 0 spike adds an explicit RTL8139 NIC with its option ROM disabled, restricted QEMU user networking, and a mandatory replay filter. It fetches content across the NIC, proves a peer-specific administrative outage, restores connectivity, passively replays the run twice after removing fixture @@ -131,7 +131,7 @@ durations, identities, digests, serial output, and QEMU diagnostics under `.poc/qemu-network-replay-smoke/`. Set `SIMFERRET_NETWORK_REQUESTS` from 1 through 1000 for bounded traffic-scaling experiments. -## RFD 2 network scenario +## RFD 19 network scenario The proof-of-concept scenario, choice-plan, and guest protocols remain at version 1. The seeded choice plan records @@ -151,9 +151,9 @@ choice plan before launch, uses an empty adapter-owned TFTP directory for passive replay, and verifies normalized events, assertion bytes, and the semantic outcome digest on every replay. -## RFD 3 workload packaging spike +## RFD 20 workload packaging spike -The RFD 3 Phase 0 spike packages an external executable instead of the built-in +The RFD 20 Phase 0 spike packages an external executable instead of the built-in fixture. It compiles one static and one dynamically linked workload, builds local OCI image layouts that carry them, applies representative base and upper layers twice into one stable canonical filesystem digest, normalizes every @@ -184,9 +184,9 @@ The suite also runs the guest supervisor's cleanup path as PID 1 of a private PI namespace, which needs unprivileged user namespaces or passwordless `sudo`; the test reports which one it used and fails if neither is available. -## RFD 3 workload specification and canonical assembler +## RFD 20 workload specification and canonical assembler -The RFD 3 Phase 1 assembler replaces the Phase 0 prototype with a typed, +The RFD 20 Phase 1 assembler replaces the Phase 0 prototype with a typed, versioned workload specification and a bounded canonical normalizer. A workload is one of two tagged source forms: @@ -260,7 +260,7 @@ Phase 1 acceptance tests: .agents/dev cargo test --locked --workspace --all-targets --all-features ``` -## RFD 3 guest process runtime +## RFD 20 guest process runtime The PID-1 agent supervises one packaged workload at a time. The immutable template is assembled below `/workload`, outside the agent, its tools, and the @@ -308,9 +308,9 @@ sudo env "PATH=$PATH" SIMFERRET_BUSYBOX="$SIMFERRET_BUSYBOX" \ Selecting the workload in `simferret run`, recording its identity in the run manifest, driving the live protocol from the scenario checker, and the recorded -passive replay are implemented by the RFD 3 Phase 3 integration below. +passive replay are implemented by the RFD 20 Phase 3 integration below. -## RFD 3 workload scenario and passive replay +## RFD 20 workload scenario and passive replay `simferret run` accepts an optional `--workload SPECIFICATION`. When it is present the scenario is parsed as the versioned workload-driven acceptance @@ -344,9 +344,9 @@ after deleting the live source: ./scripts/rfd3-phase3-acceptance.sh ``` -## RFD 3 acceptance and evidence +## RFD 20 acceptance and evidence -The complete RFD 3 demonstration runs unprivileged on x86-64 Linux: +The complete RFD 20 demonstration runs unprivileged on x86-64 Linux: ```shell .agents/dev ./scripts/rfd3-phase4-acceptance.sh diff --git a/crates/simferret/src/checker.rs b/crates/simferret/src/checker.rs index 016a4f7..32a4c87 100644 --- a/crates/simferret/src/checker.rs +++ b/crates/simferret/src/checker.rs @@ -1,4 +1,4 @@ -//! RFD 3 Phase 3: the host-side workload scenario checker. +//! RFD 20 Phase 3: the host-side workload scenario checker. //! //! The guest runtime reports process and byte facts only. This module owns the //! application meaning of the recorded output frames: it reconstructs each diff --git a/crates/simferret/src/runtime.rs b/crates/simferret/src/runtime.rs index 8479621..3751cdd 100644 --- a/crates/simferret/src/runtime.rs +++ b/crates/simferret/src/runtime.rs @@ -1,4 +1,4 @@ -//! RFD 3 Phase 2: the guest process runtime. +//! RFD 20 Phase 2: the guest process runtime. //! //! The agent stays PID 1 outside an immutable workload template. For every //! invocation it materializes a fresh writable root from that template, applies diff --git a/crates/simferret/src/vm.rs b/crates/simferret/src/vm.rs index 8065a86..f3a8a81 100644 --- a/crates/simferret/src/vm.rs +++ b/crates/simferret/src/vm.rs @@ -24,7 +24,7 @@ const MEMORY_MIB: u32 = 128; /// The QEMU time model that record and replay both launch. `shift=auto` lets /// QEMU adjust the virtual CPU speed against host real time. /// -/// RFD 4 pins `shift=4,sleep=off`: a fixed scale, so the guest's virtual time +/// RFD 21 pins `shift=4,sleep=off`: a fixed scale, so the guest's virtual time /// advances with the instructions it executes and its idle timers advance /// deterministically rather than with host scheduling, and no idle sleep, so the /// guest's clock is not paced by the host either. @@ -37,7 +37,7 @@ const MEMORY_MIB: u32 = 128; /// so a recording can be driven. It is carried until upstream includes the fix, /// and dropping it is a versioned change: recordings made under a different /// emulator are not comparable, and every host in the supported matrix must be -/// re-validated. `rfd/0004/EVIDENCE.adoc` records the measurement, the pin, and +/// re-validated. RFD 21's evidence (https://chaba-rfds.pages.dev/rfd/0021/) records the measurement, the pin, and /// the spike that established the patch. /// /// Changing this value is a versioned change for the same reason: the model is @@ -1872,7 +1872,7 @@ mod tests { #[test] fn record_and_replay_launch_the_configured_time_model() { - // The literal is the model the product launches. It is pinned by RFD 4 + // The literal is the model the product launches. It is pinned by RFD 21 // and reaches QEMU through the pinned emulator, which carries the // replay-flush patch `sleep=off` needs; changing either the value or the // emulator is a versioned change that also updates this assertion and diff --git a/crates/simferret/src/workload/mod.rs b/crates/simferret/src/workload/mod.rs index 1fe80be..5b5f4c1 100644 --- a/crates/simferret/src/workload/mod.rs +++ b/crates/simferret/src/workload/mod.rs @@ -1,4 +1,4 @@ -//! RFD 3 Phase 1: typed workload specification and canonical assembler. +//! RFD 20 Phase 1: typed workload specification and canonical assembler. //! //! One standalone static binary or one local `linux/amd64` OCI image layout is //! normalized into one content-addressed guest workload: a canonical filesystem diff --git a/crates/simferret/tests/rfd3_phase1.rs b/crates/simferret/tests/rfd3_phase1.rs index c3e16c5..f279543 100644 --- a/crates/simferret/tests/rfd3_phase1.rs +++ b/crates/simferret/tests/rfd3_phase1.rs @@ -1,4 +1,4 @@ -//! RFD 3 Phase 1 acceptance: the typed workload specification and canonical +//! RFD 20 Phase 1 acceptance: the typed workload specification and canonical //! assembler. //! //! The suite builds standalone binary and local OCI image-layout sources, diff --git a/crates/simferret/tests/rfd3_phase2.rs b/crates/simferret/tests/rfd3_phase2.rs index 00d9a99..98adca8 100644 --- a/crates/simferret/tests/rfd3_phase2.rs +++ b/crates/simferret/tests/rfd3_phase2.rs @@ -2,7 +2,7 @@ // only there. The checked-in script runs it as PID 1 in a fresh PID namespace. #![cfg(target_os = "linux")] -//! RFD 3 Phase 2 acceptance: the guest process runtime. +//! RFD 20 Phase 2 acceptance: the guest process runtime. //! //! The runtime changes the child root, drops to nonzero credentials, and //! creates the overlay device nodes, so these tests require root. They skip diff --git a/crates/simferret/tests/rfd3_phase3.rs b/crates/simferret/tests/rfd3_phase3.rs index 7036520..8941af0 100644 --- a/crates/simferret/tests/rfd3_phase3.rs +++ b/crates/simferret/tests/rfd3_phase3.rs @@ -1,4 +1,4 @@ -//! RFD 3 Phase 3 acceptance: the workload-driven scenario and the host checker. +//! RFD 20 Phase 3 acceptance: the workload-driven scenario and the host checker. //! //! The complete record and passive-replay pipeline is exercised end to end in //! `run.rs`'s unit tests against a deterministic fake VM, and the checked-in diff --git a/crates/simferret/tests/rfd3_phase4.rs b/crates/simferret/tests/rfd3_phase4.rs index 0570463..a153ca0 100644 --- a/crates/simferret/tests/rfd3_phase4.rs +++ b/crates/simferret/tests/rfd3_phase4.rs @@ -4,7 +4,7 @@ // exactly as the guest owns its process table. #![cfg(target_os = "linux")] -//! RFD 3 Phase 4 acceptance: guest-visible conformance and input exclusion. +//! RFD 20 Phase 4 acceptance: guest-visible conformance and input exclusion. //! //! Phase 1 proves the canonical view on the host and Phase 3 proves the packaged //! workload records and replays in the real guest. This suite closes the diff --git a/docs/time-model.adoc b/docs/time-model.adoc index e65c328..b06a816 100644 --- a/docs/time-model.adoc +++ b/docs/time-model.adoc @@ -13,11 +13,11 @@ measurements. Current progress lives in the implementation checklist, not here. | Artifact | Path | What it records | RFD -| link:../rfd/0004/README.adoc[RFD 4: Deterministic guest time model] +| link:https://chaba-rfds.pages.dev/rfd/0021/[RFD 21: Deterministic guest time model] | The proposal, the determinism, compatibility, and controllability needs it separates, what it excludes, and its acceptance criteria | Implementation checklist -| link:../rfd/0004/IMPLEMENTATION.adoc[RFD 0004 implementation checklist] +| link:https://chaba-rfds.pages.dev/rfd/0021/[RFD 21 implementation checklist] | Phase 0 (pin and validate the model), Phase 1 (identity, rejection, and migration), Phase 2 (contract and documentation), and the exit criteria | Pre-RFD measurement @@ -25,7 +25,7 @@ measurements. Current progress lives in the implementation checklist, not here. | The exploratory probe results under `shift=auto`, `shift=auto,sleep=off`, `shift=7`, `shift=7,sleep=off`, and `shift=4,sleep=off`, with their caveats and the exploratory `shift=10` observation | Implementation evidence -| link:../rfd/0004/EVIDENCE.adoc[RFD 4 evidence] +| link:https://chaba-rfds.pages.dev/rfd/0021/[RFD 21 evidence] | The pinned-scale selection and its reason, the Phase 0 validation on the reference host, the record-mode limitation that the pinned emulator's carried patch resolves, and the re-validation trigger | Validation gate @@ -110,12 +110,12 @@ reports variation instead of failing on it: arrival timing of live host input has no deterministic position in guest virtual time; both are separate work.is carried by the pinned emulator and adopted by the product. The measurement, the models it was compared against, and the source-level cause are in - link:../rfd/0004/EVIDENCE.adoc[RFD 4 evidence], and + link:https://chaba-rfds.pages.dev/rfd/0021/[RFD 21 evidence], and `scripts/time-model-input-probe.sh` reproduces them. Continuous integration asserts that known result, so a QEMU change that fixes it fails the job instead of going unnoticed. * The limitation is one early return in QEMU, and the spike recorded in - link:../rfd/0004/EVIDENCE.adoc[RFD 4 evidence] shows that moving the flush + link:https://chaba-rfds.pages.dev/rfd/0021/[RFD 21 evidence] shows that moving the flush ahead of it makes the pinned model record and replay: the product's record and two replays then match, with the same normalized events, assertions, and semantic outcome digest as the model in use. Adopting that patch is a project @@ -123,6 +123,6 @@ reports variation instead of failing on it: == Related increments -* link:../rfd/0001/README.adoc[RFD 1: Deterministic execution proof of concept] established bounded record and replay. -* link:../rfd/0002/README.adoc[RFD 2: Deterministic network fault model] added the deterministic network boundary. -* link:../rfd/0003/README.adoc[RFD 3: Reproducible workload packaging] packages the workload that exercises the model. +* link:https://chaba-rfds.pages.dev/rfd/0018/[RFD 18: Deterministic execution proof of concept] established bounded record and replay. +* link:https://chaba-rfds.pages.dev/rfd/0019/[RFD 19: Deterministic network fault model] added the deterministic network boundary. +* link:https://chaba-rfds.pages.dev/rfd/0020/[RFD 20: Reproducible workload packaging] packages the workload that exercises the model. diff --git a/flake.nix b/flake.nix index d1ead2e..c58e9fd 100644 --- a/flake.nix +++ b/flake.nix @@ -32,7 +32,7 @@ # The pinned emulator, built from the repository's patch rather than from # a second expression: `sleep=off` needs the replay flush the patch # restores, and only the system target the project runs is built. - # `rfd/0004/README.adoc` records why it is carried and what dropping it + # RFD 21 (https://chaba-rfds.pages.dev/rfd/0021/) records why it is carried and what dropping it # means. qemuPinned = (pkgs.qemu.override { hostCpuTargets = [ "x86_64-softmmu" ]; diff --git a/poc/rfd3-phase0/build-layout.py b/poc/rfd3-phase0/build-layout.py index 82699dd..6af3a72 100755 --- a/poc/rfd3-phase0/build-layout.py +++ b/poc/rfd3-phase0/build-layout.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -"""Build the representative local OCI image layouts used by the RFD 3 Phase 0 +"""Build the representative local OCI image layouts used by the RFD 20 Phase 0 spike. This is throwaway spike code and is deliberately independent of the prototype diff --git a/poc/rfd3-phase0/oci_prototype.py b/poc/rfd3-phase0/oci_prototype.py index 1dd4dfe..424f174 100755 --- a/poc/rfd3-phase0/oci_prototype.py +++ b/poc/rfd3-phase0/oci_prototype.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -"""RFD 3 Phase 0 spike prototype for OCI normalization and canonical identity. +"""RFD 20 Phase 0 spike prototype for OCI normalization and canonical identity. This is throwaway spike code. The Phase 1 Rust assembler replaces it. The prototype exists to answer the Phase 0 questions about layer semantics, digest diff --git a/poc/rfd3-phase0/supervisor-test-workload.c b/poc/rfd3-phase0/supervisor-test-workload.c index 7816eb5..c8f5cf5 100644 --- a/poc/rfd3-phase0/supervisor-test-workload.c +++ b/poc/rfd3-phase0/supervisor-test-workload.c @@ -1,5 +1,5 @@ /* - * Test-only workload for the RFD 3 Phase 0 supervisor cleanup regression. + * Test-only workload for the RFD 20 Phase 0 supervisor cleanup regression. * * The supervisor regression test execs this program as the primary guest * workload. It reads its mode from /mode inside the workload root and leaves a diff --git a/poc/rfd3-phase0/supervisor.c b/poc/rfd3-phase0/supervisor.c index 6c890a4..869df01 100644 --- a/poc/rfd3-phase0/supervisor.c +++ b/poc/rfd3-phase0/supervisor.c @@ -1,5 +1,5 @@ /* - * RFD 3 Phase 0 spike guest supervisor. + * RFD 20 Phase 0 spike guest supervisor. * * Boots one external workload inside a private chroot, feeds it a fixed command * sequence, drains its output while it runs, then kills and reaps every diff --git a/poc/time-model/EVIDENCE.adoc b/poc/time-model/EVIDENCE.adoc index 1e3536f..fe46a87 100644 --- a/poc/time-model/EVIDENCE.adoc +++ b/poc/time-model/EVIDENCE.adoc @@ -129,7 +129,7 @@ The remaining measurements, with the value each configuration produced: |=== `shift=10` is a separate observation from an earlier exploratory run, not from -this probe: it used the RFD 3 workload fixture rather than `poc/time-model`, and +this probe: it used the RFD 20 workload fixture rather than `poc/time-model`, and default `sleep` behavior. No guest output appeared within a 180-second deadline and the replay log reached 117 MB. Those raw artifacts were not retained. It therefore establishes only that no guest output was observed before the @@ -205,7 +205,7 @@ and comparisons against runs 3 to 5 found 1,030 to 1,036 differing bytes. Equal size across five runs is therefore not evidence of equal content, and the raw replay log is not a suitable identity for comparing independent recordings. The payloads of the differing regions were not decoded, so their meaning is -undetermined. This is consistent with RFD 2's evidence, which already records +undetermined. This is consistent with RFD 19's evidence, which already records that replay-log size and wall-clock duration vary across recordings and hosts and that they are measurements rather than replay identity. diff --git a/poc/time-model/qemu-nosleep-replay-upstream.adoc b/poc/time-model/qemu-nosleep-replay-upstream.adoc index e0e86ba..2a9da9e 100644 --- a/poc/time-model/qemu-nosleep-replay-upstream.adoc +++ b/poc/time-model/qemu-nosleep-replay-upstream.adoc @@ -11,7 +11,7 @@ It is a draft for the project owner to send, and nothing here has been submitted: the `Signed-off-by` trailer is the submitter's to add, and the proposed regression test is a proposal rather than something this repository can run, because it lives in QEMU's own test suite. The measurements it cites -are recorded in link:../../rfd/0004/EVIDENCE.adoc[RFD 4 evidence], and the runs +are recorded in link:https://chaba-rfds.pages.dev/rfd/0021/[RFD 21 evidence], and the runs in the reproduction section were re-measured for this document against the pinned QEMU 11.1.0 with and without the patch. @@ -224,7 +224,7 @@ guest's `READY`, stops the guest through QEMU's monitor, writes one line while the guest cannot be polling, resumes it, and reports whether the line arrived. The acknowledged stop and resume are what make a non-delivery claim causal rather than timing-dependent; the measurement is recorded in -link:../../rfd/0004/EVIDENCE.adoc[RFD 4 evidence]. The checked-in commands are: +link:https://chaba-rfds.pages.dev/rfd/0021/[RFD 21 evidence]. The checked-in commands are: [source,shell] ---- @@ -331,7 +331,7 @@ is data loss in record mode and a hang in replay mode rather than a delay. reference value exactly, and the product's record-and-two-replays run has normalized events, assertions, and semantic outcome digest byte-identical to the same run under the model in use - (link:../../rfd/0004/EVIDENCE.adoc[RFD 4 evidence]). The patch does not + (link:https://chaba-rfds.pages.dev/rfd/0021/[RFD 21 evidence]). The patch does not perturb what a recording contains beyond adding the input it was dropping. == Counter-arguments to expect @@ -449,7 +449,7 @@ inherit its machinery: == References * link:qemu-nosleep-replay-flush.patch[`poc/time-model/qemu-nosleep-replay-flush.patch`] -* link:../../rfd/0004/EVIDENCE.adoc[RFD 4 evidence] +* link:https://chaba-rfds.pages.dev/rfd/0021/[RFD 21 evidence] * link:input-probe.c[`poc/time-model/input-probe.c`] and link:../../scripts/time-model-input-probe.sh[`scripts/time-model-input-probe.sh`] * Upstream sources cited: `accel/tcg/icount-common.c`, diff --git a/poc/time-model/reference-host-values.txt b/poc/time-model/reference-host-values.txt index ab47360..c5e2e62 100644 --- a/poc/time-model/reference-host-values.txt +++ b/poc/time-model/reference-host-values.txt @@ -1,11 +1,11 @@ -# SimFerret pinned time-model reference values (RFD 4 Phase 0). +# SimFerret pinned time-model reference values (RFD 21 Phase 0). # # The guest measurements, the artifact identities, and the model below were # produced by `scripts/time-model-probe.sh` under the pinned model on the # reference x86-64 Linux host (AMD Ryzen 5 3600, 12 threads, Linux 6.18.41), # with the pinned QEMU 11.1.0, the pinned guest kernel 6.18.49, and the # initramfs the probe builds from `poc/time-model/probe.c`. The run, its -# deadline, and its reason are recorded in `rfd/0004/EVIDENCE.adoc`. +# deadline, and its reason are recorded in RFD 21's evidence (https://chaba-rfds.pages.dev/rfd/0021/). # # `scripts/time-model-gate.sh` compares a host's validation run against these # values. They are exact rather than tolerances: the RFD requires the guest @@ -25,7 +25,7 @@ # practice a `flake.lock` update that moves either), to the model in # `crates/simferret/src/vm.rs`, or to the probe source makes these values stale. # Re-measure on the reference host, re-record them here and in -# `rfd/0004/EVIDENCE.adoc`, and let the gate re-validate every host in the +# RFD 21's evidence (https://chaba-rfds.pages.dev/rfd/0021/), and let the gate re-validate every host in the # supported matrix. Until then the gate fails, which is the intended outcome: a # host that cannot complete under the pinned model is an unsupported execution # rather than a reason to fall back to another model. diff --git a/scripts/rfd3-entry-gate.sh b/scripts/rfd3-entry-gate.sh index d0ed363..0d6a22b 100755 --- a/scripts/rfd3-entry-gate.sh +++ b/scripts/rfd3-entry-gate.sh @@ -6,7 +6,7 @@ output_root="${SIMFERRET_RFD3_ENTRY_OUTPUT:-$repo_root/.poc/rfd3-entry-gate}" cc="${CC:-cc}" if [[ "$(uname -s)" != "Linux" || "$(uname -m)" != "x86_64" ]]; then - echo "The RFD 3 entry gate supports x86-64 Linux only." >&2 + echo "The RFD 20 entry gate supports x86-64 Linux only." >&2 exit 1 fi for command in "$cc" python3; do diff --git a/scripts/rfd3-phase0-spike-test.sh b/scripts/rfd3-phase0-spike-test.sh index a90d503..d722df9 100755 --- a/scripts/rfd3-phase0-spike-test.sh +++ b/scripts/rfd3-phase0-spike-test.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -# Focused regression tests for the RFD 3 Phase 0 workload and OCI spike. +# Focused regression tests for the RFD 20 Phase 0 workload and OCI spike. # # The QEMU invocation is faked so the orchestration, source-removal, and # replay-comparison behavior is exercised quickly. The prototype's layer @@ -733,4 +733,4 @@ for supervisor_case in writer silent; do "$supervisor_root/$supervisor_case.stdout" done -printf 'RFD 3 Phase 0 spike regression tests passed.\n' +printf 'RFD 20 Phase 0 spike regression tests passed.\n' diff --git a/scripts/rfd3-phase0-spike.sh b/scripts/rfd3-phase0-spike.sh index d44c2ef..9378737 100755 --- a/scripts/rfd3-phase0-spike.sh +++ b/scripts/rfd3-phase0-spike.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -# RFD 3 Phase 0 workload and OCI spike. +# RFD 20 Phase 0 workload and OCI spike. # # Builds one external static executable and two local OCI image layouts, applies # representative base and upper layers twice into stable canonical trees, @@ -31,7 +31,7 @@ complete=false report_incomplete() { if [[ "$complete" != true && -n "$output_dir" ]]; then - echo "RFD 3 Phase 0 spike failed; diagnostics: $output_dir" >&2 + echo "RFD 20 Phase 0 spike failed; diagnostics: $output_dir" >&2 fi } @@ -63,14 +63,14 @@ json_field() { } if [[ "$(uname -s)" != "Linux" || "$(uname -m)" != "x86_64" ]]; then - echo "The RFD 3 Phase 0 spike supports x86-64 Linux only." >&2 + echo "The RFD 20 Phase 0 spike supports x86-64 Linux only." >&2 exit 1 fi validate_positive_duration SIMFERRET_QEMU_TIMEOUT "$qemu_timeout" validate_positive_duration SIMFERRET_QEMU_KILL_AFTER "$qemu_kill_after" require_file SIMFERRET_KERNEL "$kernel" -require_file "RFD 3 workload fixture" "$fixture_source" -require_file "RFD 3 supervisor" "$supervisor_source" +require_file "RFD 20 workload fixture" "$fixture_source" +require_file "RFD 20 supervisor" "$supervisor_source" for command in "$qemu" "$static_cc" "$dynamic_cc" "$python" "$readelf" cpio gzip mktemp sha256sum timeout; do if ! command -v "$command" >/dev/null 2>&1; then diff --git a/scripts/rfd3-phase1-evidence.sh b/scripts/rfd3-phase1-evidence.sh index d8d3d7d..8633af3 100755 --- a/scripts/rfd3-phase1-evidence.sh +++ b/scripts/rfd3-phase1-evidence.sh @@ -7,7 +7,7 @@ cc="${CC:-cc}" binary="$repo_root/target/x86_64-unknown-linux-musl/release/simferret" if [[ "$(uname -s)" != "Linux" || "$(uname -m)" != "x86_64" ]]; then - echo "The RFD 3 Phase 1 evidence run supports x86-64 Linux only." >&2 + echo "The RFD 20 Phase 1 evidence run supports x86-64 Linux only." >&2 exit 1 fi for command in "$cc" python3 cargo du find jq sha256sum stat cmp; do diff --git a/scripts/rfd3-phase2-runtime.sh b/scripts/rfd3-phase2-runtime.sh index defd6af..551daf5 100755 --- a/scripts/rfd3-phase2-runtime.sh +++ b/scripts/rfd3-phase2-runtime.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# RFD 3 phase 2 guest process runtime tests. +# RFD 20 phase 2 guest process runtime tests. # # The runtime changes the child root, drops to nonzero credentials, and creates # the overlay device nodes, so these tests require root. The guest-wide cleanup @@ -14,11 +14,11 @@ set -euo pipefail repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" if [[ "$(uname -s)" != "Linux" || "$(uname -m)" != "x86_64" ]]; then - echo "The RFD 3 Phase 2 runtime tests support x86-64 Linux only." >&2 + echo "The RFD 20 Phase 2 runtime tests support x86-64 Linux only." >&2 exit 1 fi if [[ "$(id -u)" -ne 0 ]]; then - echo "The RFD 3 Phase 2 runtime tests require root (chroot, setuid, mknod)." >&2 + echo "The RFD 20 Phase 2 runtime tests require root (chroot, setuid, mknod)." >&2 echo "Run: sudo env \"PATH=\$PATH\" SIMFERRET_BUSYBOX=\"\$SIMFERRET_BUSYBOX\" $0" >&2 exit 1 fi @@ -56,7 +56,7 @@ for line in sys.stdin: ' | tail -1)" fi if [[ -z "$binary" || ! -x "$binary" ]]; then - echo "Cannot locate the RFD 3 Phase 2 test binary." >&2 + echo "Cannot locate the RFD 20 Phase 2 test binary." >&2 exit 1 fi diff --git a/scripts/rfd3-phase3-acceptance.sh b/scripts/rfd3-phase3-acceptance.sh index c1756e9..769386b 100755 --- a/scripts/rfd3-phase3-acceptance.sh +++ b/scripts/rfd3-phase3-acceptance.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# RFD 3 Phase 3 acceptance: workload-driven scenario and passive replay. +# RFD 20 Phase 3 acceptance: workload-driven scenario and passive replay. # # Builds one external static fixture and one dynamically linked fixture, packages # the static fixture as both a standalone binary workload and a local OCI image @@ -28,7 +28,7 @@ store_name=".workload-store" interpreter_path="/lib64/ld-linux-x86-64.so.2" if [[ "$(uname -s)" != "Linux" || "$(uname -m)" != "x86_64" ]]; then - echo "RFD 3 phase 3 acceptance supports x86-64 Linux only." >&2 + echo "RFD 20 phase 3 acceptance supports x86-64 Linux only." >&2 exit 1 fi if [[ -z "$kernel" || ! -f "$kernel" ]]; then diff --git a/scripts/rfd3-phase4-acceptance.sh b/scripts/rfd3-phase4-acceptance.sh index ab0b474..e2b321c 100755 --- a/scripts/rfd3-phase4-acceptance.sh +++ b/scripts/rfd3-phase4-acceptance.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# RFD 3 Phase 4 acceptance: unprivileged acceptance and evidence. +# RFD 20 Phase 4 acceptance: unprivileged acceptance and evidence. # # Runs the checked-in Phase 3 record-and-two-replay demonstration for the # standalone binary and both local OCI source forms, then adds the Phase 4 @@ -35,7 +35,7 @@ ambient_canary="SIMFERRET_PHASE4_AMBIENT_CANARY" ambient_value="ambient-canary-value" if [[ "$(uname -s)" != "Linux" || "$(uname -m)" != "x86_64" ]]; then - echo "RFD 3 phase 4 acceptance supports x86-64 Linux only." >&2 + echo "RFD 20 phase 4 acceptance supports x86-64 Linux only." >&2 exit 1 fi if [[ -z "$kernel" || ! -f "$kernel" ]]; then diff --git a/scripts/rfd3-phase4-checks-test.sh b/scripts/rfd3-phase4-checks-test.sh index 9a3f1c1..6f271f7 100755 --- a/scripts/rfd3-phase4-checks-test.sh +++ b/scripts/rfd3-phase4-checks-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Regression harness for the RFD 3 Phase 4 evidence checks. +# Regression harness for the RFD 20 Phase 4 evidence checks. # # The acceptance script must fail closed: an unreadable tree, a failed # measurement producer, a leaked canary in either encoding, an unexpected file @@ -421,4 +421,4 @@ expect_fail "a negative value" \ expect_fail "a non-numeric value" \ "is not a nonnegative integer" require_nonnegative_integers "measurement" 1 unknown -printf 'RFD 3 phase 4 evidence check regression tests passed.\n' +printf 'RFD 20 phase 4 evidence check regression tests passed.\n' diff --git a/scripts/rfd3-phase4-checks.sh b/scripts/rfd3-phase4-checks.sh index e6a9a7a..5b3307e 100755 --- a/scripts/rfd3-phase4-checks.sh +++ b/scripts/rfd3-phase4-checks.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# RFD 3 Phase 4 evidence checks. +# RFD 20 Phase 4 evidence checks. # # The acceptance script and its regression harness share these checks, so the # harness proves the same code the acceptance run relies on. Every check treats diff --git a/scripts/rfd3-phase4-runtime.sh b/scripts/rfd3-phase4-runtime.sh index 5fe1ed6..ee3a01e 100755 --- a/scripts/rfd3-phase4-runtime.sh +++ b/scripts/rfd3-phase4-runtime.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# RFD 3 phase 4 guest-visible conformance tests. +# RFD 20 phase 4 guest-visible conformance tests. # # The conformance check assembles a real OCI layout, extracts its encoded guest # template, and runs a workload that changes root and drops to nonzero @@ -15,11 +15,11 @@ set -euo pipefail repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" if [[ "$(uname -s)" != "Linux" || "$(uname -m)" != "x86_64" ]]; then - echo "The RFD 3 Phase 4 conformance tests support x86-64 Linux only." >&2 + echo "The RFD 20 Phase 4 conformance tests support x86-64 Linux only." >&2 exit 1 fi if [[ "$(id -u)" -ne 0 ]]; then - echo "The RFD 3 Phase 4 conformance tests require root (chroot, setuid, mknod)." >&2 + echo "The RFD 20 Phase 4 conformance tests require root (chroot, setuid, mknod)." >&2 echo "Run: sudo env \"PATH=\$PATH\" SIMFERRET_BUSYBOX=\"\$SIMFERRET_BUSYBOX\" $0" >&2 exit 1 fi @@ -60,12 +60,12 @@ for line in sys.stdin: print(message["executable"]) ' | tail -1 )"; then - echo "cargo could not build the RFD 3 Phase 4 test binary." >&2 + echo "cargo could not build the RFD 20 Phase 4 test binary." >&2 exit 1 fi fi if [[ -z "$binary" || ! -x "$binary" ]]; then - echo "Cannot locate the RFD 3 Phase 4 test binary." >&2 + echo "Cannot locate the RFD 20 Phase 4 test binary." >&2 exit 1 fi diff --git a/scripts/time-model-gate-test.sh b/scripts/time-model-gate-test.sh index adb9d0d..66fbdc2 100755 --- a/scripts/time-model-gate-test.sh +++ b/scripts/time-model-gate-test.sh @@ -316,7 +316,7 @@ EOF chmod +x "$test_root/fake-static-cc" # The gate validates the model the checked-in reference values were measured -# under. That record must name the model RFD 4 pins, because the gate is the +# under. That record must name the model RFD 21 pins, because the gate is the # Phase 0 acceptance gate for that model rather than for whatever the probe # happens to run. pinned_time_model="$(sed -n 's/^icount_options=//p' "$reference_source")" diff --git a/scripts/time-model-gate.sh b/scripts/time-model-gate.sh index 0e01744..a943039 100755 --- a/scripts/time-model-gate.sh +++ b/scripts/time-model-gate.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -# SimFerret pinned time-model gate (RFD 4 Phase 0). +# SimFerret pinned time-model gate (RFD 21 Phase 0). # # The time-model probe reports variation rather than failing on it, because # variation is the finding it exists to detect. This gate is the opposite: it @@ -18,7 +18,7 @@ set -euo pipefail # initramfs, and one measurement per metric. The product launches this model: # `TIME_MODEL` in `crates/simferret/src/vm.rs` pins it, and the pinned emulator the # flake builds carries the replay-flush patch `sleep=off` needs, so a recording can -# be driven. `rfd/0004/EVIDENCE.adoc` records the measurement, the pin, and the +# be driven. RFD 21's evidence (https://chaba-rfds.pages.dev/rfd/0021/) records the measurement, the pin, and the # resolution. # # The deadline and the sample size are the RFD's acceptance rule, not the diff --git a/scripts/time-model-input-probe.sh b/scripts/time-model-input-probe.sh index fe9c9ad..c4320b0 100755 --- a/scripts/time-model-input-probe.sh +++ b/scripts/time-model-input-probe.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -# SimFerret host-input probe (RFD 4 Phase 0). +# SimFerret host-input probe (RFD 21 Phase 0). # # The time-model probe establishes that guest time is reproducible. This probe # establishes the complementary fact the product needs: whether the host can @@ -659,7 +659,7 @@ if [[ -n "$expectation" ]]; then echo "The experiment is inconclusive: $inconclusive_reason." >&2 elif [[ "$expectation" == "not-delivered" ]]; then echo "Input delivery under the pinned model may unblock the pin: re-measure and" >&2 - echo "re-record rfd/0004/EVIDENCE.adoc before changing the model the product launches." >&2 + echo "re-record RFD 21's evidence (https://chaba-rfds.pages.dev/rfd/0021/) before changing the model the product launches." >&2 fi echo "Artifacts: $output_dir" >&2 exit 1 From fa23076bb380dfb3ed504c51df8642b991d8acaf Mon Sep 17 00:00:00 2001 From: "Darwin D. Wu" Date: Fri, 23 Oct 2026 18:10:43 -0700 Subject: [PATCH 2/3] docs(rfd): move RFDs to chaba-dev/rfds RFDs 1 through 5, their implementation checklists, their evidence, and the rfd/ index moved to the shared chaba-dev/rfds repository (https://github.com/chaba-dev/rfds), published at https://chaba-rfds.pages.dev, as RFDs 18 through 22 (1 -> 18, 2 -> 19, 3 -> 20, 4 -> 21, 5 -> 22). Delete rfd/ and the tooling that only validated it: the check-rfd-status.sh checker and its regression test, the check-rfds Makefile target (the Makefile had no other target), and the CI steps that ran it. Point the AGENTS.md RFD guidance at the shared repository. --- .github/workflows/ci.yml | 2 - AGENTS.md | 3 +- Makefile | 6 - README.md | 1 - rfd/0001/EVIDENCE.adoc | 330 ----- rfd/0001/IMPLEMENTATION.adoc | 104 -- rfd/0001/README.adoc | 288 ----- rfd/0002/EVIDENCE.adoc | 383 ------ rfd/0002/IMPLEMENTATION.adoc | 116 -- rfd/0002/README.adoc | 346 ----- rfd/0003/EVIDENCE.adoc | 2076 ------------------------------ rfd/0003/IMPLEMENTATION.adoc | 424 ------ rfd/0003/README.adoc | 610 --------- rfd/0004/EVIDENCE.adoc | 605 --------- rfd/0004/IMPLEMENTATION.adoc | 125 -- rfd/0004/README.adoc | 453 ------- rfd/0005/IMPLEMENTATION.adoc | 41 - rfd/0005/README.adoc | 131 -- rfd/README.adoc | 91 -- scripts/check-rfd-status-test.sh | 606 --------- scripts/check-rfd-status.sh | 333 ----- 21 files changed, 1 insertion(+), 7073 deletions(-) delete mode 100644 Makefile delete mode 100644 rfd/0001/EVIDENCE.adoc delete mode 100644 rfd/0001/IMPLEMENTATION.adoc delete mode 100644 rfd/0001/README.adoc delete mode 100644 rfd/0002/EVIDENCE.adoc delete mode 100644 rfd/0002/IMPLEMENTATION.adoc delete mode 100644 rfd/0002/README.adoc delete mode 100644 rfd/0003/EVIDENCE.adoc delete mode 100644 rfd/0003/IMPLEMENTATION.adoc delete mode 100644 rfd/0003/README.adoc delete mode 100644 rfd/0004/EVIDENCE.adoc delete mode 100644 rfd/0004/IMPLEMENTATION.adoc delete mode 100644 rfd/0004/README.adoc delete mode 100644 rfd/0005/IMPLEMENTATION.adoc delete mode 100644 rfd/0005/README.adoc delete mode 100644 rfd/README.adoc delete mode 100755 scripts/check-rfd-status-test.sh delete mode 100755 scripts/check-rfd-status.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3317c75..011d2a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - - run: make check-rfds - uses: cachix/install-nix-action@13d8dd58da0234aa297dedd986986ccb8e7f3e24 # v31 with: install_url: https://releases.nixos.org/nix/nix-2.35.1/install @@ -41,7 +40,6 @@ jobs: os: [ubuntu-latest, macos-latest] steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - - run: make check-rfds - uses: cachix/install-nix-action@13d8dd58da0234aa297dedd986986ccb8e7f3e24 # v31 with: install_url: https://releases.nixos.org/nix/nix-2.35.1/install diff --git a/AGENTS.md b/AGENTS.md index 00a608e..32d67e6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -20,5 +20,4 @@ # RFDs -- Follow the lifecycle and source conventions in `rfd/README.adoc`. -- Keep design documents in `rfd/NNNN/README.adoc` and implementation progress in the adjacent `IMPLEMENTATION.adoc` file. +- RFDs live in the shared chaba-dev/rfds repository (https://github.com/chaba-dev/rfds) and are published at https://chaba-rfds.pages.dev; follow its lifecycle and source conventions there, not in this repository. diff --git a/Makefile b/Makefile deleted file mode 100644 index 1f1daaf..0000000 --- a/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -.PHONY: check-rfds - -## Validate RFD sources and the checker regression fixtures -check-rfds: - @./scripts/check-rfd-status.sh - @./scripts/check-rfd-status-test.sh diff --git a/README.md b/README.md index af4e85b..bebbef5 100644 --- a/README.md +++ b/README.md @@ -402,7 +402,6 @@ Jujutsu. To enter the environment directly, run Run repository commands through the development environment: ```shell -make check-rfds nix --extra-experimental-features 'nix-command flakes' flake check .agents/dev cargo fmt --all -- --check .agents/dev cargo clippy --locked --workspace --all-targets --all-features -- --deny warnings diff --git a/rfd/0001/EVIDENCE.adoc b/rfd/0001/EVIDENCE.adoc deleted file mode 100644 index b2d7667..0000000 --- a/rfd/0001/EVIDENCE.adoc +++ /dev/null @@ -1,330 +0,0 @@ -= RFD 1 Evidence - -== Phase 0 — QEMU replay spike - -The phase 0 spike is automated by -link:../../scripts/qemu-replay-smoke.sh[`scripts/qemu-replay-smoke.sh`]. The Nix -flake pins QEMU, a Linux kernel, a static C compiler, `cpio`, and `gzip`. The -script builds a diskless initramfs containing a single static `/init`, then -boots it under TCG with one vCPU and these replay-relevant settings: - -[source,text] ----- --machine pc-i440fx-9.2,accel=tcg --cpu qemu64 -smp 1 -m 128M --nodefaults -no-user-config -display none -monitor none -serial stdio --no-reboot -net none --rtc base=2000-01-01T00:00:00,clock=vm --kernel -initrd --append "console=ttyS0 quiet loglevel=0 panic=-1 nokaslr random.trust_cpu=off init=/init" --icount shift=auto,rr=,rrfile= ----- - -Run it with: - -[source,shell] ----- -.agents/dev ./scripts/qemu-replay-smoke.sh ----- - -The command records once, replays the same log twice, requires the guest marker -`SIMFERRET_PHASE0_OK version=1`, and compares all three serial streams byte for -byte. It writes executable versions, content digests, durations, serial output, -and QEMU diagnostics to a fresh `run.*` directory under -`.poc/qemu-replay-smoke/`; previous runs are preserved. - -An x86-64 Linux run on 2026-09-05 passed with QEMU 11.1.0, Linux 6.18.49, -and machine type `pc-i440fx-9.2`. Record time was 6.02 seconds; the two replay -times were 10.07 and 10.02 seconds. The replay log was 6,211,724 bytes. The -recording and both replay serial streams had the same SHA-256 digest: - -[source,text] ----- -3771b23d96c0b8635c375ecb9e3c39664890e3dc7f5eb06a3317041799f25b66 ----- - -The pinned kernel digest was -`d4c2d110cb9b82dad81517cc2f1f3a46d0e31c8937237cf3df59eeffb3d7070b`. -Two independent builds produced the same initramfs digest, -`9d8e70a63441ae9a752259bc6a34bddc502c3318b8868b923245b76748da2f33`. -The generated `evidence.txt` retains nanosecond durations and all artifact -digests for each invocation. - -The runner fixes the build umask at `022` and regression tests verify identical -initramfs hashes when callers use umasks `022` and `077`. The tests also verify -that pre-existing output is preserved, mismatched replay bytes and missing guest -markers fail, and a QEMU process that ignores `SIGTERM` is forcibly terminated. -Timeout overrides must be finite and strictly positive; zero-valued overrides -are rejected before QEMU starts. The forced-termination regression separately -verifies that the runner returns status 137 before its outer watchdog expires. -Linux CI executes both these focused checks and the real QEMU record/replay -smoke test, retaining its diagnostics when a failure occurs. - -No block, network, audio, graphics, monitor, host filesystem, or mutable image -device is present. This avoids the replay filters required by those device -classes. Serial output is supported by QEMU record/replay. The machine type is -explicit rather than using QEMU's moving `pc` alias. - -This evidence establishes only that the pinned QEMU/kernel/initramfs tuple can -replay the fixed boot and guest action. It does not establish the RFD's later -process-control, semantic-event, assertion, or replay-identity acceptance -criteria. - -== Phase 1 — Fixture and event protocol - -The `simferret guest-agent` entry point reads commands from standard input and -writes structured events to standard output. Each frame is a four-byte, -unsigned, big-endian body length followed by UTF-8 JSON. Bodies are limited to -1 MiB. Every command and event envelope contains `protocol_version` (currently -`1`) and a stable command or event identifier; unsupported versions, malformed -JSON, unknown fields, truncated frames, and oversized frames fail the agent. -Request identifiers and payloads have a combined 64 KiB logical limit so every -accepted request and corresponding built-in fixture response can be represented -by an event frame. - -Version 1 commands start and stop the echo-server process, make one workload -request, evaluate assertions, and shut down the agent. Events report server -lifecycle, every request attempt, matching responses or unavailability, the -complete assertion report, and agent shutdown. Requests and responses carry an -opaque request identifier and payload. The server's intentional corruption mode -changes only the returned payload so the safety checker observes the violation. -The agent retains the configured endpoint while the server is stopped, so an -outage command executes the real workload client and records its connection -failure. A private pipe reports server readiness only after the child process -successfully binds its socket. -Addresses are canonical numeric loopback socket addresses with nonzero ports; -invalid, hostname, wildcard, external, and ephemeral-port inputs are rejected -before a child starts. A controlled stop succeeds only when the agent terminates -a live child with `SIGKILL`, while cleanup tolerates an already-exited child. -The fixture also watches a private parent-owned standard-input pipe and exits if -the agent terminates before performing normal cleanup. - -Normalized events retain the protocol version, stable identifiers, and complete -event body. Exactly three diagnostic fields are excluded as non-semantic: -`guest_pid`, `host_received_at_unix_nanos`, and `temporary_path`. Adding another -exclusion requires changing the typed normalizer rather than silently dropping -unknown JSON fields. - -Run the phase checks with: - -[source,shell] ----- -.agents/dev cargo test --locked --workspace --all-targets --all-features -.agents/dev cargo clippy --locked --workspace --all-targets --all-features -- --deny warnings ----- - -On 2026-09-05, all twenty-two tests passed. Fifteen unit tests cover framing, protocol -version rejection, normalization, the TCP echo/corruption fixture, and all three -assertion forms. Seven process-level integration tests drive framed commands -through the real guest agent. The first starts the server, succeeds once, stops -the server, observes a stopped-phase attempt and bounded unavailable result, -restarts the server, and observes bounded matching success. The second corrupts -a response and verifies both a failed safety assertion and agent exit status -`1`. Additional regressions cover occupied and unusable server addresses, a real -stopped-phase client call, unexpected child death, request-size boundaries, and -bounded assertion-report serialization. Assertion details reference stable event -identifiers rather than copying arbitrary request data. Assertion bounds are -measured in stable event identifiers, not host time. Process tests concurrently -drain all pipes, enforce bounded waits, and verify that terminating an agent also -terminates its fixture child. - -== Phase 2 — Rust record path - -The x86-64 Linux record path is exercised with the repository's pinned static -Rust target, QEMU, and kernel: - -[source,shell] ----- -.agents/dev cargo build --release --target x86_64-unknown-linux-musl -.agents/dev ./target/x86_64-unknown-linux-musl/release/simferret run \ - --scenario scenarios/echo-process-restart.toml --seed 42 ----- - -The scenario parser rejects unknown fields and invalid bounds. Its explicitly -implemented SplitMix64 algorithm materializes the fault index, request IDs, and -payloads into `choices.json`, so later library changes cannot silently replace -the run's choices. Seed 42 selected request index 2 of 6 as the fault point. - -The controller launched QEMU 11.1.0 in TCG record mode with machine -`pc-i440fx-9.2`, CPU `qemu64`, one vCPU, 128 MiB of memory, no network, and a -replay-aware ISA serial port as the recorded command/event boundary. Serial -commands use line-delimited JSON. The host sends one byte at a time and waits -for a guest acknowledgement before sending the next, preventing QEMU's deferred -record events from overrunning the emulated UART. QEMU command-line construction, -process supervision, QMP capability negotiation, and bounded startup/event/exit -waits are owned by one VM adapter. A typed readiness event prevents host input -from reaching the serial port before the guest has configured it for raw I/O. -Scenario execution itself contains no sleeps or wall-clock decisions. The -manifest identifies both QEMU firmware inputs by absolute path and digest. The -verification run started from a directory containing a shadow -`linuxboot_dma.bin`; QEMU's private working directory and explicit firmware -paths prevented that file from affecting the recording. - -The real run produced 17 normalized events: two matching requests before the -fault, one stopped-phase attempt followed by unavailability, a server restart, -and three matching requests after the restart. Safety passed, controlled outage -passed with the unavailable result one event after its attempt, and bounded -liveness passed with matching success two events after restart. The command -returned zero and printed the run ID, artifact path, assertion summary, and -`simferret replay ` command. - -The completed run directory was published with one rename only after QEMU exited -normally and every artifact had been written. It contained the exact scenario, -choice plan, 12,366,448-byte QEMU replay log, normalized JSON-lines events, -assertion report, QEMU and serial diagnostics, and a manifest that digested all -seven non-manifest artifacts. The semantic outcome digest covering scenario, -choices, events, and assertions was: - -[source,text] ----- -49ae101c084a591442365568b1a5f0b33b9a2cb47a904e8b65a1f54ad3be7ed3 ----- - -The recorded initramfs digest was -`1e3b6589da8bd98b16befc8e207374431c4356668c36b2c5f40235a58b0d85da`; -the replay log digest was -`6247d1d0723b56096ecdc18762f691a0050a9abce702eeb2adde60bec854e448`. -The existing kernel digest remained -`d4c2d110cb9b82dad81517cc2f1f3a46d0e31c8937237cf3df59eeffb3d7070b`. -An adapter-backed regression test independently verifies complete artifact -publication and every manifest digest without requiring QEMU. Together with the -scenario and VM-boundary tests, the workspace now has sixty-one unit tests and -seven process-level integration tests. - -== Phase 3 — Rust replay path - -The Phase 3 command validates a completed run before launching QEMU: - -[source,shell] ----- -.agents/dev ./target/x86_64-unknown-linux-musl/release/simferret replay \ - runs/ ----- - -Validation requires the exact seven-artifact manifest set and checks every -digest. It parses bounded scenario, choice, event, and assertion artifacts, -rematerializes the choice plan from the recorded seed, rebuilds the -content-addressed initial state from the current executable, and compares the -current QEMU, kernel, firmware, machine, CPU, memory, vCPU, accelerator, and -device identity with the recording. QEMU consumes a verified private copy of -the replay log, so replay does not modify the recorded run. Every input is -opened nonblocking without following symlinks, verified as a bounded regular -file through its descriptor, and bounded again while reading, hashing, or -copying it. - -On 2026-09-06, a fresh recording under QEMU 11.1.0 completed in approximately -65 seconds and produced a 12,366,448-byte replay log. Two consecutive replays -completed in 74.63 and 74.78 seconds. The replay controller made zero command -writes: QEMU supplied all guest input from the recorded serial stream. Both -replays reached normal termination and incrementally verified 17 byte-identical -normalized events, the byte-identical assertion report, and this semantic -outcome digest: - -[source,text] ----- -49ae101c084a591442365568b1a5f0b33b9a2cb47a904e8b65a1f54ad3be7ed3 ----- - -The replay log, normalized event, and assertion digests remained unchanged -after both runs: - -[source,text] ----- -replay.bin 6247d1d0723b56096ecdc18762f691a0050a9abce702eeb2adde60bec854e448 -events.jsonl c8e706bf77ba5f4e9a81b1faaa667087267046620db7bd613aad144a0d270fc2 -assertions.json 416af5fbbed7c8522f713d3f73ddf08f350dbc64d9bb59b006f7e7f4c1de5b9d ----- - -The initial-state digest was -`1e3b6589da8bd98b16befc8e207374431c4356668c36b2c5f40235a58b0d85da`. -An initial 10-second event deadline was insufficient, and a 60-second deadline -was sensitive to host load despite active QEMU progress. Replay therefore uses -a three-minute per-event infrastructure deadline while command writes retain a -separate 10-second bound. Errors identify the command and expected response -position. - -Regression tests replay the adapter-backed recording twice, reject changes to -each of the seven artifacts before launch, reject VM identity mismatch, and -report the first valid-but-divergent event before reading later output. They -also reject FIFOs, devices, symlinks, oversized inputs, inconsistent recorded -semantics, forged guest assertions, and malformed Unicode run IDs, while -retaining both diagnostic streams for launch, execution, and final encoding -failures. Shared VM and protocol tests cover replay-aware serial topology, -per-byte acknowledgement framing, passive replay, bounded startup/event/exit -waits, early termination, malformed or missing frames, and surplus terminal -events. The workspace has sixty-one unit tests and seven process-level integration -tests. - -== Phase 4 — Acceptance demonstration - -The complete acceptance path is automated by -link:../../scripts/phase4-acceptance.sh[`scripts/phase4-acceptance.sh`] and runs -in the Linux QEMU CI job. From a clean x86-64 Linux checkout after the documented -Nix setup, the single command is: - -[source,shell] ----- -.agents/dev ./scripts/phase4-acceptance.sh ----- - -The script builds the static guest/controller executable and exercises every -acceptance criterion. It records the seed-42 scenario, checks the stopped-phase -attempt and matching unavailable event are one event apart, and requires the -controlled-outage assertion to pass. It passively replays that recording twice -and compares the two CLI summaries. It then verifies both an altered event -artifact and an altered VM memory identity are rejected. Finally, it records -link:../../scenarios/echo-process-restart-corrupt.toml[the intentional-corruption -scenario] with seed 43, requires CLI status `1`, and requires its safety -assertion to fail. - -An x86-64 Linux run on 2026-09-06 passed under QEMU 11.1.0 and Linux 6.18.49. -The normal recording took 63.89 seconds and its two replays took 70.10 and 70.47 -seconds. The intentional-corruption recording took 57.93 seconds. Seed 42 chose -fault request index 2 and first request ID -`request-0000-28efe333b266f103`; seed 43 chose index 1 and first request ID -`request-0000-9cde98852e60034b`. Their complete materialized choice plans were -different. - -The normal run's principal artifact sizes were: - -[cols="1,1", options="header"] -|=== -| Artifact | Bytes - -| `replay.bin` | 8,454,205 -| `events.jsonl` | 3,739 -| `assertions.json` | 437 -| `choices.json` | 789 -| `scenario.toml` | 187 -| `manifest.json` | 2,386 -|=== - -Its semantic outcome digest was -`49ae101c084a591442365568b1a5f0b33b9a2cb47a904e8b65a1f54ad3be7ed3`. -The normalized event and assertion digests matched the Phase 3 evidence. The -replay-log digest for this recording was -`51659d871af1a57058a1a22b3318f7822243c3f7da3f59ace55e764c912995fe`. - -All observed divergences were expected and actionable. Appending bytes to -`events.jsonl` failed before replay with its expected and actual SHA-256 -digests. Changing the manifest's VM memory from 128 MiB to 129 MiB failed with -the complete expected and actual VM identities. Intentional response corruption -failed safety at response event 3 because its request identity or payload did -not match, while controlled outage and bounded liveness still passed. Normal -record and replay produced no semantic divergence. - -The fidelity limits remain the RFD's initial constraints: x86-64 Linux, the -pinned QEMU/kernel/firmware tuple, TCG, one vCPU, fixed machine and CPU models, -and no network, block, passthrough, acceleration, mutable host mount, or external -service. Exact replay also requires the recorded SimFerret executable and -content-addressed guest image. Per-byte serial acknowledgement avoids replay -loss at the ISA UART but makes the approximately one-minute scenario unsuitable -as a fast unit test. Abrupt host failure can retain temporary run state, and -absolute dependency paths make artifacts tied to the recorded Nix environment. - -The recommended next increment is a deterministic network fault model using a -QEMU-supported recorded network boundary. It adds materially broader distributed -failure coverage while preserving the proven controller/VM ownership split and -without first taking on checkpoint-tree scheduling or general container -packaging. This RFD does not implement that increment; it should begin with a -separate design and replay spike. diff --git a/rfd/0001/IMPLEMENTATION.adoc b/rfd/0001/IMPLEMENTATION.adoc deleted file mode 100644 index 02d562a..0000000 --- a/rfd/0001/IMPLEMENTATION.adoc +++ /dev/null @@ -1,104 +0,0 @@ -= RFD 0001 implementation checklist - -Implements link:README.adoc[RFD 1: Deterministic execution proof of concept]. - -== Objective - -Prove exact record/replay of one bounded client/server execution with a -controlled server restart, using the documented Rust/QEMU boundaries, before -expanding SimFerret's application or fault surface. - -== Repository foundation - -Status: DONE. - -* [x] Create the Rust workspace and `simferret` binary target. - -== Delivery rules - -Each phase records its commands and decisive output. A phase is complete only when -its automated checks pass from a clean checkout in the documented environment. -New platform features discovered during the PoC are deferred unless they are -required by an acceptance criterion in the RFD. - -== Phase 0 — Manual QEMU replay spike - -Status: DONE. - -* [x] Select and pin a QEMU version and minimal x86-64 Linux image. -* [x] Boot the image under TCG with one vCPU and no uncontrolled network or - mutable host mounts. -* [x] Record and replay a fixed guest command using QEMU `icount` record/replay. -* [x] Verify replay twice and record any unsupported machine or device options. -* [x] Save exact commands, durations, versions, and output digests in an evidence - document beside this checklist. - -== Phase 1 — Fixture and event protocol - -Status: DONE. - -* [x] Implement the minimal echo server, workload client, checker, and guest - agent. -* [x] Define a versioned framed command and structured-event protocol for the - controlled host/guest channel. -* [x] Define explicit normalization rules for non-semantic event fields. -* [x] Test safety, controlled-outage, and bounded-liveness assertion evaluation - outside the VM. -* [x] Require at least one request attempt while the server is stopped and a - bounded failed or unavailable result. -* [x] Add an intentional response-corruption mode that proves property failures - propagate to a nonzero result. - -== Phase 2 — Rust record path - -Status: DONE. - -* [x] Parse the echo restart scenario and generate a stable choice plan from its - seed. -* [x] Keep QEMU command-line and QMP interaction behind one VM adapter rather - than invoking QEMU from fixture or scenario code. -* [x] Launch QEMU in record mode and drive the finite scenario without wall-clock - sleeps controlling semantic choices. -* [x] Terminate and restart the server at an explicit recorded choice point. -* [x] Persist the manifest, scenario, choice plan, replay log, normalized events, - assertion results, semantic outcome digest, and diagnostic logs atomically - under one run identifier. -* [x] Print a replay command and return an exit status derived from assertions - and infrastructure health. - -== Phase 3 — Rust replay path - -Status: DONE. - -* [x] Validate artifact digests and environment compatibility before replay. -* [x] Launch QEMU from the recorded initial state in replay mode. -* [x] Detect early termination, hangs, surplus events, missing events, and event - divergence with an actionable first-difference report. -* [x] Compare normalized event, assertion, and semantic outcome artifacts. -* [x] Prove two consecutive replays produce byte-identical semantic artifacts. - -== Phase 4 — Acceptance and evidence - -Status: DONE. - -* [x] Automate the record-and-replay demonstration in a supported environment. -* [x] Verify a different seed changes the materialized request or fault plan. -* [x] Verify at least one request encounters the stopped server and reports a - bounded failed or unavailable result. -* [x] Verify artifact or replay-identity tampering is rejected. -* [x] Verify intentional fixture corruption fails its safety assertion and CLI - exit status. -* [x] Record record/replay duration, artifact sizes, fidelity limitations, and - all observed divergence in `EVIDENCE.adoc`. -* [x] Recommend one next increment without implementing it. - -== Exit criteria - -* [x] Every acceptance criterion in the RFD has linked automated or captured - evidence. -* [x] The PoC can be demonstrated from a clean checkout without undocumented - interactive setup. -* [x] The implementation uses the documented ownership boundaries rather than - invoking QEMU throughout fixture or scenario code. -* [x] No custom VMM or broad QEMU fork exists without recorded evidence that an - upstream interface was insufficient. diff --git a/rfd/0001/README.adoc b/rfd/0001/README.adoc deleted file mode 100644 index 5cb7f81..0000000 --- a/rfd/0001/README.adoc +++ /dev/null @@ -1,288 +0,0 @@ -:authors: Darwin Wu -:state: committed -:discussion: https://github.com/chaba-dev/simferret/pull/3 -:labels: architecture, determinism, proof-of-concept, qemu, replay, rust, testing - -= RFD 1 Deterministic execution proof of concept - -== Goal - -Establish an architecture for running unmodified Linux software in a controlled -environment where a recorded execution can be reproduced exactly. The first -implementation should prove the determinism boundary with the least original -hypervisor work while preserving a path toward state-space exploration. - -Deliver a command-line proof of concept that records and exactly replays a small -Linux execution containing a client, a server, a workload, a checker, and one -controlled process failure. The result should determine whether this -architecture is a viable base for SimFerret before work begins on branching -exploration or general application support. - -== Context - -Deterministic simulation testing needs three distinct capabilities: - -* deterministic execution and replay; -* exploration of alternative inputs, schedules, and faults; -* properties that identify invalid system states. - -FoundationDB obtains determinism by routing production actors through simulated -time, network, storage, and process implementations. SimFerret instead aims to -run software that was not designed for simulation. Its determinism boundary -must therefore sit below the application and guest operating system. - -Antithesis demonstrates this model with a deterministic hypervisor, simulated -devices, snapshots, guided exploration, and property checking. Reproducing that -complete platform is not an appropriate first milestone. SimFerret first needs -to establish that it can control and replay one small whole-system execution. - -== Proposal - -SimFerret uses Rust for its control plane and QEMU TCG for its initial execution -engine. QEMU runs one x86-64 Linux guest with one virtual CPU. The Rust process -starts and controls QEMU through its command-line and QMP interfaces, records -the complete execution identity, and stores simulation events and results. - -The initial boundary is: - -[source,text] ----- -Rust CLI and controller - -> scenario and deterministic choice plan - -> QMP and controlled guest input - -> QEMU TCG record/replay - -> one-vCPU Linux guest - -> application, workload, and checker processes ----- - -QEMU's instruction-counted record/replay mode supplies the first CPU, virtual -time, interrupt, and supported-device replay implementation. SimFerret does not -fork QEMU until a concrete missing hook is demonstrated. Any necessary QEMU -changes remain narrow and are kept separate from the Rust control plane. - -The controller may use ordinary asynchronous Rust for process supervision and -artifact I/O. Decisions that affect a scenario use an explicit seeded PRNG and -stable ordering. They are materialized into a choice plan before or through a -controlled input boundary rather than depending on host task wake order or wall -clock time. - -== Replay identity - -A replay is identified by all inputs capable of changing guest execution: - -* SimFerret and QEMU executable digests or immutable Nix derivation identities, - plus their reported versions; -* guest kernel, root filesystem, and application artifact digests; -* QEMU machine, CPU, memory, firmware digest, and device configuration; -* initial disk or VM snapshot digest; -* QEMU record/replay log; -* SimFerret scenario, seed, choice plan, and configuration. - -A seed alone is not an exact replay contract. It generates SimFerret's choices, -while QEMU's replay log fixes the instruction positions and ordering of external -events. SimFerret must reject or clearly mark a replay when its recorded -identity does not match the available environment. - -== Ownership boundaries - -The Rust control plane owns scenario parsing, seeded choices, VM lifecycle, -fault requests, artifacts, event normalization, assertions, and later -exploration policy. QEMU owns guest CPU execution, virtual machine state, and -record/replay of supported nondeterministic machine events. A small guest agent -may translate controlled commands into process lifecycle operations and emit -structured events, but it must not become an application-specific simulator. - -All host communication that can affect the guest is part of the deterministic -input boundary. Uncontrolled external networks, host filesystems, entropy, and -wall clocks are excluded from a replayable simulation. - -== Proof-of-concept scenario - -The proof of concept uses a fixed minimal Linux guest with one virtual CPU. The -guest contains a small TCP echo server, a workload client, a checker, and a -SimFerret guest agent. These fixtures should be simple enough to audit and exist -only to exercise orchestration rather than demonstrate a useful distributed -system. - -For each generated operation, the client sends an opaque request identifier and -payload. The server returns both unchanged. The checker asserts that every -successful response matches its request and records progress as structured -events. - -The scenario performs this sequence: - -. boot the guest and establish the controlled agent channel; -. start the server, client, and checker; -. execute a seed-derived finite request plan; -. terminate the server at a recorded choice point; -. observe bounded failed or unavailable requests; -. restart the server; -. observe a subsequent successful matching response; -. finish the workload and emit assertion results. - -The failure validates process control and liveness checking without requiring a -custom network or storage model. Network partitions, disk corruption, and -durable state are intentionally later scenarios. - -== Command-line contract - -The intended interface is approximately: - -[source,shell] ----- -simferret image build -simferret run --scenario scenarios/echo-process-restart.toml --seed 42 -simferret replay runs/ ----- - -The exact command spelling may change during implementation, but record and -replay remain separate operations. A successful run prints its run identifier, -assertion summary, artifact location, and replay command. - -== Determinism contract - -The first execution records QEMU's nondeterministic event log and SimFerret's -choice plan. Replay starts from the same recorded initial state and consumes -those artifacts. It is successful only when it reaches normal termination and -produces the same normalized guest-event sequence, assertion results, and -semantic outcome digest. - -The QEMU replay log establishes reproduction of machine execution under the -recorded replay identity. Byte-identical normalized event, assertion, and -semantic outcome artifacts establish observable equivalence. The PoC does not -claim that the semantic outcome digest represents all guest memory or device -state. - -Timestamps, host process identifiers, temporary paths, and QEMU diagnostic -noise are not semantic events and are excluded from comparison. Exclusions must -be enumerated; the implementation may not silently discard a field merely -because it differs. - -The PoC claims exact replay from a recorded run. It does not claim that running -the same seed twice without the QEMU replay log produces instruction-identical -executions. - -== Assertions - -The scenario defines three initial property forms: - -* safety: every successful response contains the request identifier and payload - sent by the client; -* controlled outage: at least one request attempt occurs while the server is - stopped and produces a failed or unavailable result within a scenario-defined - virtual-time or event bound; -* bounded liveness: after the controlled restart, at least one matching request - succeeds within a scenario-defined virtual-time or event bound. - -Assertion evaluation uses structured events rather than scraping human logs. -The run fails when any property fails, a required event is absent, replay -diverges, QEMU exits unexpectedly, or the scenario exceeds its bound. - -== Artifacts - -Every run directory contains the run outputs and compatibility identities needed -to inspect and request replay of the run: - -[source,text] ----- -runs// - manifest.json - scenario.toml - choices.json - replay.bin - events.jsonl - assertions.json - logs/ ----- - -The manifest records the full replay identity and digests every other run -artifact; `manifest.json` does not contain its own digest. Replay also requires -matching content-addressed external QEMU, firmware, guest-image, application, -and initial-state artifacts; the PoC does not copy those large dependencies -into every run directory. The semantic outcome digest covers normalized events -and all explicitly serializable SimFerret state. - -== Acceptance criteria - -The proof of concept is complete when: - -* one documented command builds or obtains the fixed guest image; -* one command records the scenario without interactive steps; -* at least one request attempt occurs while the server is stopped and reports a - bounded failed or unavailable result; -* replay succeeds at least twice from the produced run directory; -* each replay produces byte-identical normalized event and assertion artifacts - and a matching semantic outcome digest; -* changing the scenario seed changes the request or fault choice plan; -* tampering with a replay identity or artifact is detected before or during - replay; -* an intentionally violated fixture property produces a failing assertion and - nonzero CLI exit status; -* the complete demonstration runs in a documented supported environment. - -== Initial constraints - -The first implementation supports one host architecture, one QEMU version, one -machine definition, one virtual CPU, and a minimal fixed Linux image. Device -passthrough, accelerators, and host-mounted mutable filesystems are forbidden. -These constraints reduce the number of execution paths that can escape QEMU's -record/replay model. - -== Excluded from the proof of concept - -The proof of concept does not include: - -* KVM, MSHV, or hardware-accelerated deterministic execution; -* Cloud Hypervisor or a custom VMM; -* arbitrary Docker Compose or Kubernetes deployments; -* multiple VMs or multiple virtual CPUs; -* custom deterministic network or block devices; -* uncontrolled external network or service dependencies; -* disk faults or network partitions; -* snapshot-tree branching and distributed exploration workers; -* coverage-guided or reinforcement-learning exploration; -* time-travel debugging user interfaces; -* performance, security, or compatibility claims for production use. - -It is not a performance benchmark. TCG speed is recorded to establish a -baseline but is not an acceptance criterion unless the scenario cannot complete -in a practical development loop. The excluded capabilities are possible later -RFDs after the proof of concept establishes a measured baseline and identifies -which QEMU facilities are sufficient. - -== Alternatives considered - -Cloud Hypervisor provides a smaller Rust VMM and useful snapshot and virtio -boundaries, but currently relies on KVM or MSHV and does not provide deterministic -CPU execution, instruction-counted virtual time, or whole-system record/replay. -Choosing it first would make those mechanisms prerequisite to any simulation. - -A new Rust VMM would provide maximum control but requires implementing or -integrating CPU execution, interrupt and timer semantics, deterministic devices, -snapshots, and replay before validating the product model. - -Application-level simulation is much smaller and faster, as FoundationDB shows, -but requires applications to adopt SimFerret-specific interfaces. That conflicts -with the goal of running unmodified software. - -== Follow-up decision - -Completion produces an evidence record covering replay fidelity, event-log and -snapshot sizes, record and replay duration, unsupported QEMU devices or inputs, -observed divergence, and operational friction. That evidence informs a new RFD -choosing the next increment. Likely candidates are a deterministic network -fault model, checkpoint branching, or packaging arbitrary container workloads; -none is selected by this RFD. - -== Implementation - -Delivery phases are tracked in -link:IMPLEMENTATION.adoc[RFD 1 implementation checklist], with measured results -in the adjacent link:EVIDENCE.adoc[evidence record]. - -== References - -* https://www.qemu.org/docs/master/system/replay.html[QEMU record/replay] -* https://www.qemu.org/docs/master/devel/replay.html[QEMU record/replay internals] -* https://antithesis.com/blog/deterministic_hypervisor/[Antithesis deterministic hypervisor overview] -* https://apple.github.io/foundationdb/testing.html[FoundationDB simulation and testing] diff --git a/rfd/0002/EVIDENCE.adoc b/rfd/0002/EVIDENCE.adoc deleted file mode 100644 index 0d45b18..0000000 --- a/rfd/0002/EVIDENCE.adoc +++ /dev/null @@ -1,383 +0,0 @@ -= RFD 2 Evidence - -== Purpose - -This record starts with the pre-implementation spikes that tested whether the -network boundary proposed by RFD 2 was feasible with the QEMU, kernel, machine, -and unprivileged CI constraints committed by RFD 1. The final sections record -the integrated implementation and acceptance evidence. - -== Sophie runner baseline - -The `sophie` x86-64 Linux runner fetched `origin/main` at commit `e27ffb2f` and -ran the repository's pinned QEMU 11.1.0, Linux 6.18.49, machine -`pc-i440fx-9.2`, and TCG as an unprivileged user. - -The RFD 1 QEMU smoke test passed in 24.97 seconds. Its internal record duration -was 5.75 seconds and its two replay durations were 8.89 and 9.43 seconds. The -5,863,403-byte replay log had SHA-256 digest -`b0c696f907f8706e8147506e9948dc7c9c19e648a798dc5a1a74d162a4186090`. -All serial outputs had SHA-256 digest -`3771b23d96c0b8635c375ecb9e3c39664890e3dc7f5eb06a3317041799f25b66`. - -The complete RFD 1 acceptance demonstration also passed in 236.35 seconds. The -normal record took 54.96 seconds, its replays took 63.40 and 62.95 seconds, and -the intentional-corruption record took 53.91 seconds. Artifact tampering, -identity tampering, and intentional fixture corruption produced their expected -failures. - -== RTL8139 ingress and passive replay on Sophie - -A disposable spike used this replay-relevant network shape: - -[source,text] ----- --device rtl8139,netdev=net0,mac=52:54:00:12:34:56 --netdev user,id=net0,restrict=on,hostfwd=udp:127.0.0.1:45555-:12345 --object filter-replay,id=net-replay,netdev=net0 --icount shift=auto,rr=,rrfile= ----- - -The guest received the 23-byte payload `simferret-network-spike` from -`10.0.2.2` and emitted `NET_SPIKE_OK`. Record mode completed in 6.54 seconds. -Two replays without the host forward or sender completed in 10.87 and 11.10 -seconds with byte-identical serial output. - -A stronger replay replaced the recording-time user backend with an isolated -socket netdev listening on a private unused address and no peer. It completed in -11.20 seconds with the same serial output. This directly establishes that -replay requires a netdev object for structural attachment but does not require -the recording backend, host forward, sender, or peer interaction. - -The 8,335,311-byte replay log had SHA-256 digest -`47df1845882b06f7020c40cf24f1a35429d804cb6eef13585c261be2d7962fa2`. -The record and all three replay serial streams had SHA-256 digest -`c96da14b312c0e61c09dbdefb550bb4a165ca914165f9201703afd467d23bc38`. -Against the focused no-network smoke run, this one-packet sample increased log -size by 1.42 times, record duration by 1.14 times, and replay duration by -approximately 1.2 times. It is not a throughput forecast. - -== Outage and recovery spike in an Amp orb - -A second disposable spike used QEMU 11.1.0, the same kernel and machine, an -explicit e1000 NIC, restricted user-mode networking, built-in TFTP fixture -content, and `filter-replay`. A static BusyBox guest configured the NIC and a -fixed route. - -The guest fetched matching content, installed a peer-specific `prohibit` route, -observed an immediate unavailable result, removed the route, and fetched the -matching content again. It emitted all three markers: - -[source,text] ----- -SIMFERRET_NET_PRE_OK version=1 -SIMFERRET_NET_OUTAGE_OK version=1 -SIMFERRET_NET_RECOVERY_OK version=1 ----- - -After record mode, the TFTP fixture directory was deleted. Two passive replays -still produced byte-identical serial output. Record mode took 13.27 seconds and -the replays took 34.12 and 34.02 seconds. The replay log was 20,951,688 bytes -with SHA-256 digest -`5de81a09527cebd7aabe6fb376f4aa4504dc33fa4e0c108e9e0028c61ded801a`. -All serial streams had SHA-256 digest -`59ae1229ae23afdab0e79bee1fa80ec3b83bedc8c893d9d21673f3a4bbb5a7a2`. - -This proves the initial peer-specific route fault with e1000. RFD 2 still must -repeat the integrated outage scenario with its selected RTL8139 identity. - -== Checked-in RTL8139 outage tuple in an Amp orb - -The checked-in `scripts/qemu-network-replay-smoke.sh` closes the gap between the -two disposable spikes. It uses the RFD's selected identity and one integrated -scenario: - -[source,text] ----- --machine pc-i440fx-9.2,accel=tcg --cpu qemu64 --netdev user,id=simnet,restrict=on,tftp= --device rtl8139,netdev=simnet,mac=52:54:00:12:34:56,bus=pci.0,addr=0x3,romfile= --object filter-replay,id=simnet-replay,netdev=simnet,queue=all --icount shift=auto,rr=,rrfile=/replay.bin ----- - -The reproducible initramfs contains the pinned static BusyBox and decompressed -`mii` and `8139cp` modules. The guest verifies that `8139cp` actually binds the -NIC before testing traffic. Each bounded request maps canonically to -`request-NNNNNN`; the corresponding TFTP file contains that request identifier -and `payload-NNNNNN` for guest-side comparison. - -The exact checked-in command passed in this Amp orb with one request. The record -took 10.063 seconds, its two passive replays took 32.681 and 34.212 seconds, and -the intentional-corruption record took 8.700 seconds. The three successful -serial streams were byte-identical with SHA-256 digest -`33ddf17fe726d78ffe495a37f1926284cba9038dcb218ad4874778453671dbf3`. -The 866,175-byte initramfs produced a 24,399,452-byte replay log. - -Before both passive replays, the script deletes every TFTP fixture file while -retaining the same restricted backend profile. Both replays still pass. The -guest also proves that a peer-specific `prohibit` route causes `sendto` to fail -with errno 13 (`EACCES`) before removing the route and refetching the fixture. -Finally, a separate record serves corrupted bytes for the first request. The -guest emits a typed `response_mismatch` property failure and does not emit the -success marker. This demonstrates that success is derived from network-returned -content rather than the guest command alone. - -The accompanying fake-QEMU regression suite passes and checks the exact network -arguments, mandatory filter, disabled option ROM, passive fixture removal, -intentional corruption, serial mismatch, missing marker, infrastructure-failure -event, invalid request bounds, comma-bearing QEMU option path, retained prior -output, and reproducible initramfs across caller umasks. - -=== Bounded traffic sample - -The complete one-request run and earlier scaling runs of the same checked-in -scenario produced: - -[cols="1,1,1,1,1",options="header"] -|=== -| Requests | Record seconds | Replay 1 seconds | Replay 2 seconds | Replay-log bytes - -| 1 -| 10.063 -| 32.681 -| 34.212 -| 24,399,452 - -| 10 -| 9.602 -| 19.215 -| 19.472 -| 9,863,840 - -| 100 -| 15.542 -| 27.801 -| 28.119 -| 10,201,304 -|=== - -The one-request row is the later complete run and is not directly comparable to -the earlier 10- and 100-request rows. Replay-log size also varied substantially -between repeated runs. These measurements establish bounded execution through -100 requests, but do not establish smooth scaling, deterministic replay-log -size, or production throughput. - -=== Independent checked-in tuple on Sophie - -The same guest sources, build script, pinned dependencies, and QEMU tuple passed -independent execution on the unprivileged `sophie` runner. The regression suite -completed in 4.13 seconds. The real smoke command completed in 38.68 seconds: -record took 6.598 seconds, the two passive replays took 11.029 and 10.965 -seconds, and the intentional-corruption record took 6.692 seconds. - -The 866,175-byte initramfs had SHA-256 digest -`57757eb8eb820d916eee3a980e321c74bec345654f70aa5c71835d6a25f57f33`. -The 7,754,388-byte replay log had SHA-256 digest -`28ae9af6f3a0b237ee21bfee6b543638b819f84f3afa6356c7bdd3d68932d8e7`. -Record and both replay serial streams were byte-identical and matched the Amp -orb's semantic serial digest, -`33ddf17fe726d78ffe495a37f1926284cba9038dcb218ad4874778453671dbf3`. -The corrupt run emitted the typed `response_mismatch` marker and no success -marker. All QEMU diagnostic logs were empty. - -The different hosts produced materially different durations and replay-log -sizes despite matching semantic output. Replay-log byte identity across separate -recordings is therefore not a supported invariant. The transfer archive was -applied over `origin/main`, so its RFD index check failed because the archive -contained only the later robustness commit and not RFD 2's earlier index entry. -The complete RFD 2 branch contains that entry and passes the same check. This was -a validation-transfer issue, not a QEMU or repository-branch failure. - -=== GitHub-hosted x86-64 Linux - -The checked-in regression and real network smoke commands passed in the -`QEMU record/replay` job on GitHub-hosted Ubuntu. The complete job passed in 6 -minutes 38 seconds without elevated privileges. The network record took 5.733 -seconds, its passive replays took 9.008 and 8.781 seconds, and the intentional -corruption record took 5.986 seconds. - -The initramfs size and digest matched `sophie`. The 3,502,215-byte replay log had -SHA-256 digest -`b5aa21826f7b9c71d85aade288611aa8c514f78b8757444d906d6d30367ce38b`. -Record and both replay serial streams again had the cross-host semantic digest -`33ddf17fe726d78ffe495a37f1926284cba9038dcb218ad4874778453671dbf3`. -The corrupt serial stream had the expected digest -`f1a0bd0af1b41a564493105a4bb213b6d1469c8dba33e36dcb74a49192dc20bb`. - -The Amp orb, independent `sophie` runner, and GitHub-hosted runner therefore all -validate the selected tuple. This completes the Phase 0 feasibility gate while -leaving controller integration, typed production identities, and full RFD 2 -acceptance to subsequent phases. - -== Negative results and constraints - -Omitting `filter-replay` allowed recording and ingress but caused replay to hang -until its 15-second watchdog expired. Referring the filter to a nonexistent -netdev, or omitting the netdev object, failed immediately because the filter -requires a backend identifier. - -Changing the MAC address during replay produced partial divergence and then a -15-second timeout. Reusing the recording-time host forward while its port was -occupied failed QEMU startup. In the orb spike, omitting the filter or changing -the MAC similarly hung until a 20-second watchdog expired. QEMU therefore cannot -provide the required actionable compatibility validation; SimFerret must reject -these differences before launch. - -Using a TCP `guestfwd` endpoint caused QEMU to connect to its peer during backend -initialization, including before replay could disable packet interaction. The -recording peer could not simply be absent. The disposable socket replay proved -that changing backend types can work, but a listening socket cannot guarantee -isolation from other local processes. The selected profile instead retains the -restricted built-in TFTP backend and removes its fixture content before replay. - -The pinned kernel builds RTL8139, e1000, and virtio-net drivers as modules. The -RTL8139 spike required `mii`, `8139cp`, and `8139too`. Its minimal loader could -not pass compressed `.ko.xz` files directly to `finit_module`; the initramfs -decompressed them first. - -Netfilter core is built in, while nftables, iptables, and netem functionality is -provided as modules. Their module dependency closures exist, but the current -guest does not contain them or a pinned `nft`, `iptables`, or `tc` executable. -A peer-specific route through pinned static BusyBox is proven and smaller for -the first outage. Rich packet faults remain unproven. - -All successful network spikes ran as uid 1000 with QEMU TCG and user-mode -networking. They required no root access, TAP, bridge, KVM, or uncontrolled -Internet traffic. - -== Phase 1 — Network identity and VM adapter - -The VM adapter now represents the selected NIC, fixed MAC and PCI attachment, -restricted backend, mandatory replay filter, addressing, route, immutable TFTP -fixture, and peer-specific prohibit-route fault as typed semantic identity. It -constructs the complete network argument sequence and rejects changed or unsafe -profiles before QEMU starts. Replay incompatibility reports identify the first -differing field and include its expected and actual values. - -Record fixture identity is derived from a bounded canonical encoding of sorted -filenames and bytes rather than accepted from the caller. The adapter traverses -the source without following directory or file symlinks, rejects special files, -and copies the verified bytes into a private runtime snapshot. QEMU receives -only that adapter-owned snapshot. Replay refuses live fixture input and creates -a fresh empty private directory with the same semantic endpoint type. Runtime -paths remain diagnostic and are excluded from the persisted identity. - -Unit regressions cover exact QEMU options, unsupported backends, missing replay -filters, field-level replay diagnostics, canonical fixture identity, source and -leaf symlink rejection, special files, bounded file counts and sizes, directory -substitution, source mutation, preservation of an existing recording after -preflight failure, absolute runtime paths, passive replay emptiness, and fixture -ownership through VM launch and drop. The pre-existing no-network profile and -manifest schema remain compatible with RFD 1. - -== Phase 3 — Record and passive replay integration - -On September 9, 2026, the x86-64 Linux Amp runner executed -`./scripts/phase4-acceptance.sh` through the pinned development environment. -The command recorded the six-request network scenario and replayed it twice -through QEMU 11.1.0 with an empty replay fixture. Record completed in 58.47 -seconds and the passive replays completed in 67.30 and 66.77 seconds. Both -replays produced the same 3,861-byte normalized event artifact, 598-byte -assertion artifact, and semantic outcome digest -`be5ec6342d82234bc8d28ad538cf1dca34d38e42106fd9e12aec3e918fc0c927`. -The 22,696,092-byte replay log had SHA-256 digest -`c79c26e825eecd9ae646fe1b3eeb2b99bb59c59c246433c60aed1006e732e069`. - -The same run rejected event-artifact tampering before launch and rejected a -self-consistent VM identity change before QEMU execution. Unit regressions also -reject a missing replay filter, a fault plan whose restoration does not follow -activation, every digested network artifact change, and the first normalized -network-event divergence. - -Dependency, preflight, launch, execution, publication, and replay-validation -failures now atomically retain a separate bounded bundle under the run root's -`failures/` directory. The JSON report identifies the failure stage, sanitized -validated local network configuration when available, record or passive replay -backend mode, fixture mode, observed fault transitions, and semantic -request-result counts. It reports packet counters as unavailable because the -selected QEMU user backend and replay filter expose no counter API rather than -inventing packet evidence. Error text and sanitized QEMU and guest log tails -are each limited to 64 KiB. Report-only dependency and runtime-creation bundles -do not inspect unvalidated recording logs. Real artifact- and VM-identity -preflight rejections each produced and retained a bundle during the acceptance -run. - -== Phase 4 — Acceptance - -The complete integration is automated by `scripts/phase4-acceptance.sh` and the -repository's `QEMU record/replay` GitHub Actions job. The September 9, 2026 main -run at commit `aa4c78a96444d27e564cb2946c02a9022cb0841e` passed all five jobs. -The unprivileged GitHub-hosted Ubuntu QEMU job completed in 8 minutes 42 seconds: - -* https://github.com/chaba-dev/simferret/actions/runs/34316273634[CI run 34316273634] -* https://github.com/chaba-dev/simferret/actions/runs/34316273634/job/102353043771[QEMU record/replay job] - -A final local rerun against that integrated implementation recorded in 58.08 -seconds, replayed in 66.62 and 66.35 seconds, and completed the intentional -corruption run in 59.09 seconds. Its 10,089,520-byte replay log had SHA-256 -digest `c64b6b74c827a2df43775e84f823b97f55d4f9def05fb1d1bf946be6333a17d1`. -Both replays matched the recorded semantic outcome digest -`be5ec6342d82234bc8d28ad538cf1dca34d38e42106fd9e12aec3e918fc0c927`. -Artifact and VM-identity rejection each retained the expected bounded failure -bundle. - -The six-request seed-42 choice plan activates the outage before request index 2 -and restores it before index 4. Its semantic traffic consists of six attempts, -four matching TFTP responses through the RTL8139 NIC, and two immediate -administrative rejections while the peer route is prohibited. The six canonical -fixture files materialized for recording contain 492 bytes in total and are -removed before atomic publication; this is application-level traffic evidence, -not a packet or link-byte count. QEMU exposes no packet-counter API for the -selected user backend and replay filter, so the bounded failure report marks -packet counters unavailable. - -The first unavailable result follows its request attempt by one semantic event, -meeting the configured outage bound of one. The first matching response after -restoration follows the restoration confirmation by two semantic events, -meeting the configured recovery bound of two. Seed 43 changes both request -content and the fault plan: activation moves to index 1 and restoration to index -5. Its intentionally corrupted first network response fails safety and returns -CLI status 1 while the outage, restoration, and recovery assertions still pass. - -Compatibility regressions alter one field in each typed network identity class: -NIC, backend, replay filter, addressing, route, fixture, and fault. Every change -is rejected before launch with the first differing field. Validation regressions -separately reject unrestricted user networking, TAP and other unsupported -backends, and a missing replay filter. Artifact tests cover every persisted -artifact, malformed choice plans, semantic inconsistencies, and normalized event -divergence. - -An equivalent self-hosted run requires x86-64 Linux, Nix, and the repository's -pinned QEMU, kernel, modules, BusyBox, and Rust environment. It runs as an -ordinary unprivileged user and requires neither KVM nor TAP, a bridge, firewall -changes, or external network access. The invocation is identical: - -[source,shell] ----- -.agents/dev ./scripts/phase4-acceptance.sh ----- - -=== Limitations and observed divergence - -The semantic artifacts and outcome digest are stable across passive replays, -but replay-log size and wall-clock duration vary across recordings and hosts. -They are measurements, not replay identity. The selected boundary supports one -RTL8139 NIC, one restricted user-mode backend, immutable TFTP fixtures, and one -outbound peer-specific prohibit route. It does not establish packet loss, -latency, reordering, multiple guests, or production throughput. No semantic -divergence was observed in accepted record/replay runs. Intentional content -corruption, identity changes, artifact changes, missing filters, and malformed -plans produced the expected explicit failures. - -== Recommendation - -QEMU's replay-filtered user network is reliable enough for the bounded model: -the same integrated scenario passed locally and on GitHub-hosted x86-64 Linux, -passive replays reproduced exact semantic artifacts, and preflight checks turned -QEMU's otherwise hanging identity failures into actionable errors. The next RFD -should add reproducible OCI workload packaging so users can apply the proven -process and network faults to their own software. Checkpoint branching should -follow once a real packaged workload supplies representative snapshot and -exploration costs. diff --git a/rfd/0002/IMPLEMENTATION.adoc b/rfd/0002/IMPLEMENTATION.adoc deleted file mode 100644 index cba929c..0000000 --- a/rfd/0002/IMPLEMENTATION.adoc +++ /dev/null @@ -1,116 +0,0 @@ -= RFD 0002 implementation checklist - -Implements link:README.adoc[RFD 2: Deterministic network fault model]. - -== Objective - -Prove a bounded network outage and recovery through an explicit QEMU network -device and replay filter while preserving RFD 1's exact passive replay contract. - -== Entry gate - -Status: DONE. - -* [x] Complete RFD 1 and review its replay fidelity, runtime, artifact size, - unsupported-input, and GitHub Actions evidence. -* [x] Confirm that QEMU documents record/replay for network backends through one - replay filter per backend. -* [x] Select an unprivileged single-guest spike before considering TAP, multiple - guests, a custom network stack, or broad QEMU changes. - -== Phase 0 — Network replay spike - -Status: DONE. - -* [x] Select and pin an emulated NIC, fixed MAC address, user-mode backend, and - replay-filter configuration supported by the pinned QEMU. -* [x] Build the smallest guest kernel and initramfs additions required for a - fixed address, route, network request, and narrow network rule. -* [x] Connect the guest through a restricted private network path to - content-controlled fixture input without external network access. -* [x] Record the selected RTL8139 success, administrative-outage, and recovery - tuple in an Amp orb and replay it twice without fixture content. -* [x] Run the same checked-in spike on the `sophie` runner. -* [x] Run the same checked-in spike on GitHub-hosted x86-64 Linux. -* [x] Verify that omitting or misplacing the replay filter fails the spike rather - than producing an artifact marked replayable. -* [x] Record exact QEMU options, packet direction, device support, duration, - replay-log growth, and all observed divergence. - -== Phase 1 — Network identity and VM adapter - -Status: DONE. - -* [x] Add the NIC, MAC, restricted backend, replay filter, addressing, route, - fixture, and fault settings to typed identities. -* [x] Construct and supervise all QEMU network options and private peer endpoints - inside the VM adapter boundary. -* [x] Restrict accepted configurations to the proven unprivileged backend and - reject unrestricted, TAP, bridge, passthrough, and unrecorded networking. -* [x] Validate all network identity fields before replay and report the first - incompatibility with expected and actual values. -* [x] Keep runtime-only socket paths and host process identifiers diagnostic - without removing endpoint type and safety behavior from the launch contract. - -== Phase 2 — Fault protocol and properties - -Status: DONE. - -* [x] Extend the scenario and stable choice plan with outage activation and - restoration points. -* [x] Add versioned guest commands and events for applying, confirming, and - removing one outbound peer-specific prohibit route. -* [x] Ensure fault transitions are event-driven and no host sleep or task wake - order controls scenario semantics. -* [x] Route fixture workload traffic through the emulated NIC rather than guest - loopback. -* [x] Evaluate typed pre-outage safety, bounded outage, restoration, and bounded - recovery properties from structured events. -* [x] Preserve intentional response corruption as a safety-property failure - across the network boundary. - -== Phase 3 — Record and passive replay integration - -Status: DONE. - -* [x] Record a finite successful, outage, and recovery sequence and persist its - complete network identity and semantic artifacts atomically. -* [x] Replay the recording twice through the restricted replay-filtered backend - without fixture content or peer interaction. -* [x] Compare normalized events, assertion artifacts, and semantic outcome - digests while QEMU injects recorded incoming packets. -* [x] Reject tampered network identities, missing replay filters, malformed - fault plans, and network artifact divergence. -* [x] Retain bounded QEMU, backend-mode, fault-transition, and packet-count - diagnostics in a failure bundle for launch, watchdog, execution, and replay - failures. - -== Phase 4 — Acceptance and evidence - -Status: DONE. - -* [x] Automate the record-and-two-replays demonstration on a GitHub-hosted - x86-64 Linux runner without elevated privileges. -* [x] Verify another seed changes the materialized request or outage plan. -* [x] Verify every network identity class is covered by compatibility or - tampering tests. -* [x] Verify forbidden external and privileged network configurations fail - before QEMU starts. -* [x] Verify intentional response corruption returns a nonzero CLI result. -* [x] Document the equivalent self-hosted-runner requirements and invocation. -* [x] Record runtime, replay-log growth, traffic volume, event-bounded fault - latency, device limitations, and all observed divergence in `EVIDENCE.adoc`. -* [x] Recommend the next RFD from the measured network and CI evidence. - -== Exit criteria - -* [x] Every acceptance criterion in the RFD has linked automated or captured - evidence. -* [x] Replay is passive with respect to the host network backend and fixture - input. -* [x] The acceptance traffic demonstrably traverses the configured QEMU NIC and - replay filter. -* [x] The implementation preserves RFD 1's VM adapter, artifact, identity, - normalization, and assertion ownership boundaries. -* [x] No privileged networking, external service, second guest, custom network - stack, custom VMM, or broad QEMU fork exists without new evidence and an RFD. diff --git a/rfd/0002/README.adoc b/rfd/0002/README.adoc deleted file mode 100644 index 3e9c3c5..0000000 --- a/rfd/0002/README.adoc +++ /dev/null @@ -1,346 +0,0 @@ -:authors: Darwin Wu -:state: committed -:discussion: https://github.com/chaba-dev/simferret/pull/8 -:labels: determinism, faults, network, qemu, replay, testing - -= RFD 2 Deterministic network fault model - -== Goal - -Add one explicitly configured virtual network to SimFerret and prove that a -seeded, recorded network outage can be reproduced exactly. The increment should -expand the RFD 1 process-restart scenario across a QEMU-supported network replay -boundary without adding a custom network stack, privileged host networking, -multiple virtual machines, or uncontrolled Internet access. - -The result establishes whether QEMU's replay filter and an unprivileged network -backend are a viable base for later partitions, packet faults, multiple nodes, -and state-space exploration. - -== Motivation - -RFD 1 proved exact record and replay of one diskless, one-vCPU guest controlled -through a replay-aware serial port. Its acceptance run completed without -semantic divergence, detected artifact and VM-identity tampering, and passed in -GitHub Actions. It also remained limited to guest loopback communication and a -process failure. - -The final RFD 1 evidence recommends a deterministic network fault model as the -next increment. A network replay spike is narrower than general container -packaging and gives the project evidence about the QEMU device boundary before -it commits to multi-node workloads or snapshot branching. - -RFD 1 recorded approximately 64 seconds for the normal scenario and 70 seconds -for each replay, with an 8.5 MB replay log. The per-byte acknowledged ISA serial -protocol contributes operational overhead. This RFD records the additional -cost of a NIC and network traffic but does not combine that measurement with an -unrelated control-channel redesign. - -== QEMU network replay boundary - -QEMU record/replay supports network input through one `filter-replay` object per -network backend. In record mode the filter writes packets entering QEMU from the -backend to the replay log. In replay mode it disables backend interaction and -injects those packets from the log. Outbound packets and guest device execution -remain deterministic consequences of the initial state and recorded inputs. - -The initial spike selected the emulated RTL8139 NIC used by QEMU's documented -record/replay example. Record mode uses an unprivileged, restricted user-mode -network backend and one replay filter: - -[source,text] ----- --netdev user,id=simnet,restrict=on, --device rtl8139,netdev=simnet,mac=52:54:00:12:34:56 --object filter-replay,id=simnet-replay,netdev=simnet ----- - -Replay still requires a netdev object with the recorded identifier. The initial -supported profile retains the same restricted user backend and replay filter but -removes all fixture files before replay: - -[source,text] ----- --netdev user,id=simnet,restrict=on,tftp= --device rtl8139,netdev=simnet,mac=52:54:00:12:34:56 --object filter-replay,id=simnet-replay,netdev=simnet ----- - -Using one backend type avoids claiming that a listening socket is isolated from -other local processes. The fixture identity is a semantic input, while its -runtime directory is reconstructed for each launch and is empty in replay mode. -The replay filter must prevent backend packet interaction; the empty directory -also ensures that an accidental live TFTP request cannot reproduce the recorded -response. - -The record backend is restricted from reaching arbitrary external networks. It -exposes only the minimum fixture service or forwarding path required by the -scenario. TAP, host bridges, raw sockets, and host firewall configuration are -excluded because they require privileges and would make the GitHub-hosted CI -environment materially different from local execution. - -The pinned kernel provides RTL8139 support as compressed modules rather than -built-in code. The reproducible initramfs includes `mii` and `8139cp`, -decompresses them at build time, and verifies that `8139cp` binds the NIC. The -source and decompressed module digests and load order are part of the initial -state identity. The NIC option ROM is disabled with `romfile=""` because this -direct-kernel workload does not perform network boot. - -== Scenario boundary - -The acceptance scenario retains one guest and the small auditable fixtures from -RFD 1. Traffic under test must traverse the emulated NIC; guest loopback traffic -does not satisfy this RFD. - -The initial outage topology is: - -[source,text] ----- -guest workload client - -> guest TCP/IP stack - -> emulated NIC - -> QEMU user network backend and replay filter - -> content-controlled fixture service ----- - -The guest uses a fixed MAC address and static network configuration so DHCP and -DNS do not add inputs unrelated to the test. The first fixture is immutable -content served by QEMU's restricted built-in TFTP service. The controller -materializes and digests that content in a private run directory. The backend -has no route to an external service. - -Each request identifier maps to one canonical relative TFTP filename. The file -contains the expected request identifier and payload in a bounded canonical -encoding. The guest reports values parsed from the received file rather than -manufacturing a successful response from its command. Intentional corruption -changes the served bytes while preserving the expected values. - -The guest agent continues to emit structured semantic events over the existing -serial channel. Network traffic is an application input, not a replacement -control plane. In replay mode the fixture content is absent and the restricted -backend has no input to serve; QEMU must supply all incoming packets from the -recorded replay log. This passive replay condition is an acceptance requirement -rather than an implementation detail. - -== Fault contract - -The first fault is a bounded outbound outage for the configured fixture peer. At -a seed-derived choice point, the controller sends a recorded fault command to -the guest agent. The agent installs a `prohibit` route for that peer address, -confirms the transition as a structured event, and later removes the route at -another explicit choice point. A disposable spike proved immediate failure and -recovery with this mechanism through an e1000 NIC; the implementation repeats -the result with the selected RTL8139 identity. - -The route targets only the fixture peer and may not alter unrelated guest -traffic. A pinned static BusyBox `ip` implementation applies the route without -requiring nftables, iptables, qdisc, or their module dependency closures. The -tool digest, arguments, route representation, and resulting event are part of -the initial-state and scenario identities. - -The fault model is event-driven. Host sleeps, host packet timing, and task wake -order do not determine when the outage begins or ends. Infrastructure deadlines -may terminate a hung run, but they are not semantic fault choices. - -The recorded scenario performs this sequence: - -. boot the guest and configure the explicit network interface; -. establish the content-controlled fixture service; -. send at least one successful request through the emulated NIC; -. activate the directional outage at the recorded choice point; -. attempt at least one request and observe a bounded unavailable result; -. remove the outage; -. observe a subsequent matching response within an event bound; -. evaluate structured safety, outage, and recovery properties; and -. shut down normally. - -The route produces an immediate administrative rejection: the local network -operation must report `EACCES`. Installing or removing the wrong route, a -missing fixture file, a malformed response, or an infrastructure timeout cannot -satisfy the outage property. - -Silent packet loss, port-specific filtering, probabilistic loss, latency, -duplication, corruption, reordering, bandwidth limits, and asymmetric partitions -are later extensions. The pinned kernel exposes nftables, iptables, and netem as -modules, but no corresponding userspace tool is currently pinned in the guest. -Kernel configuration alone is not evidence that those later faults are usable. - -== Choice plan and replay identity - -The scenario seed materializes the request plan, outage activation point, and -restoration point into the choice plan before those choices affect the guest. -A seed alone remains insufficient for exact replay. - -The RFD 1 replay identity is extended with at least: - -* NIC model, fixed MAC address, and all device properties; -* restricted backend type and complete semantic configuration; -* replay-filter type, placement, and properties; -* guest network address, route, peer, transport, and direction; -* guest-kernel fault mechanism and rule representation; and -* identities of the fixture content and its fixed serving behavior. - -Runtime-only socket paths and host-assigned process identifiers are diagnostic, -not semantic, but their endpoint type and safety behavior remain part of the -launch contract. Replay rejects missing, extra, or changed semantic network -identity fields and changed order-sensitive device or filter sequences before -starting QEMU. Serialization order of typed object fields is not semantic. - -Incoming packets are already represented in QEMU's replay log and are not -duplicated into SimFerret's semantic event stream. Semantic events identify the -request, response, fault transition, and property result. Optional packet -diagnostics must be bounded and must not become a second source of replay truth. - -== Assertions - -The scenario retains RFD 1's response-integrity safety property and adds typed -network fault events. It passes only when: - -* a pre-outage request traverses the configured network and returns the matching - request identifier and payload; -* the outage is confirmed active before an under-fault request is attempted; -* at least one under-fault request reports the typed administrative rejection - within its event bound; -* restoration is confirmed before the recovery request is attempted; and -* a matching post-restoration response arrives within its event bound. - -The checker uses structured guest and controller events rather than parsing -human logs or inferring a partition solely from elapsed host time. -The outage bound is measured from request-attempt event to typed result event; -the recovery bound is measured from restoration-confirmed event to matching -response event. A missing event or host watchdog expiration is an infrastructure -failure, not a semantic unavailable result. - -== Artifacts and compatibility - -Run directories retain the RFD 1 manifest, scenario, choices, replay log, -normalized events, assertions, and diagnostics. The manifest includes the -extended network identity and digests every additional semantic artifact. - -Network diagnostics should make first failures actionable. They include a -sanitized QEMU network configuration with runtime paths replaced by typed -placeholders, backend mode, fault transitions, bounded packet counters when -available, and QEMU errors. Secrets, ambient environment, temporary socket paths, -and unrestricted packet payload captures are not added to normal run artifacts. - -QEMU does not reliably diagnose replay identity errors itself. In the completed -spikes, omitting the replay filter or changing the MAC address caused a hang -until the watchdog expired. SimFerret must validate the complete network -identity and mandatory filter before launch rather than relying on QEMU to fail -fast. - -== GitHub Actions and workers - -The acceptance scenario runs as an ordinary process on a GitHub-hosted x86-64 -Linux runner. It uses QEMU TCG and unprivileged user-mode networking, so it does -not require nested virtualization, `/dev/kvm`, TAP devices, or persistent host -network configuration. - -The same CLI invocation is supported on an x86-64 Linux self-hosted runner. The -GitHub runner remains outside the deterministic guest: placing the Actions agent -inside the guest would introduce GitHub's network and timing behavior into the -simulation boundary. - -CI uploads a retained, bounded failure bundle distinct from atomically published -replayable runs. Launch and watchdog failures retain enough sanitized network, -QEMU, and guest diagnostics to identify the failed boundary. A later thin GitHub -Action may wrap the stable CLI, but Action-specific code is not part of this -increment. - -== Acceptance criteria - -This increment is complete when: - -* a documented spike records one successful request through an explicit QEMU - NIC and replay-filtered backend, then passively replays it twice; -* replay succeeds twice with the fixture content and peer interaction absent, - using the same restricted backend profile and mandatory replay filter; -* the scenario activates and restores a narrowly scoped directional outage at - materialized choice points without host sleeps controlling semantics; -* at least one request succeeds before the outage, one bounded request reports - unavailable during it, and one matching request succeeds after restoration; -* two consecutive replays produce byte-identical normalized event and assertion - artifacts and matching semantic outcome digests; -* changing the seed changes the materialized request or fault choice plan; -* changing any NIC, backend, filter, address, route, peer, or fault-rule identity - is rejected before replay, and an unsafe backend is rejected; -* omitting the replay filter cannot accidentally produce a run marked - replayable; -* attempts to configure unrestricted external networking, TAP, a host bridge, - or an unrecorded backend are rejected; -* intentional response corruption still produces a failing safety assertion - and nonzero CLI result across the network boundary; -* the complete acceptance demonstration passes on a GitHub-hosted x86-64 Linux - runner without additional privileges; and -* evidence records device compatibility, record and replay duration, - replay-log growth, traffic volume, fault latency in semantic events, and all - observed divergence. - -== Excluded from this increment - -This proposal does not include: - -* uncontrolled Internet or LAN access; -* TAP, bridge, passthrough, vhost, or privileged host networking; -* multiple guests, multiple virtual CPUs, or arbitrary network topology; -* probabilistic loss, delay, duplication, corruption, or packet reordering; -* general application, OCI, Docker Compose, or Kubernetes packaging; -* persistent block devices, disk faults, or durable application state; -* checkpoint-tree branching or exploration workers; -* replacing the recorded serial control channel; -* a custom TCP/IP stack, VMM, or broad QEMU fork; or -* hosted product, user interface, billing, or organization features. - -== Follow-up decision - -Completion produces evidence about NIC replay fidelity, passive replay, -network-log growth, fault control, CI portability, and runtime cost. That -evidence informs the next RFD. - -If the boundary is reliable, reproducible OCI workload packaging is the -recommended next product-facing increment so users can apply the network model -to their own software. Checkpoint branching should follow once a real workload -and network traffic provide representative snapshot and exploration costs. -Broader packet faults or a second guest move earlier only if the evidence shows -that the initial outage is too narrow to validate the model. - -== Alternatives considered - -Reproducible OCI workload packaging would improve user onboarding immediately, -but it would preserve only the process-restart fault proven by RFD 1. The final -RFD 1 evidence explicitly recommends validating QEMU's network boundary first. - -Checkpoint branching would begin the exploration engine, but its throughput and -snapshot costs are not representative while the guest has no external device -traffic and only a small built-in fixture. - -TAP networking offers familiar host integration but requires privileges and -host configuration that are unavailable or undesirable on GitHub-hosted -runners. QEMU's user-mode backend is narrower and supported by its documented -replay filter. - -A custom deterministic switch or TCP/IP stack would offer precise packet -scheduling, but it is not required to answer whether QEMU can record and replay -a controlled network boundary. Such a component requires separate evidence and -an RFD after a concrete limitation is observed. - -Guest nftables or qdisc would support narrower and richer packet faults. The -pinned kernel has the relevant modules, but the current guest contains neither -their dependency closures nor pinned control tools. A peer-specific route is the -smallest mechanism already proven to answer this RFD's outage question. - -Two guests would model a realistic partition, but coordinating two independent -QEMU record/replay timelines introduces a new synchronization problem. The -single-guest scenario isolates the network replay question first. - -== Implementation - -Delivery phases are tracked in -link:IMPLEMENTATION.adoc[RFD 2 implementation checklist], with preliminary -results in the adjacent link:EVIDENCE.adoc[evidence record]. - -== References - -* https://www.qemu.org/docs/master/system/replay.html[QEMU record/replay] -* https://www.qemu.org/docs/master/system/devices/net.html[QEMU network emulation] -* link:../0001/README.adoc[RFD 1: Deterministic execution proof of concept] diff --git a/rfd/0003/EVIDENCE.adoc b/rfd/0003/EVIDENCE.adoc deleted file mode 100644 index b17b34c..0000000 --- a/rfd/0003/EVIDENCE.adoc +++ /dev/null @@ -1,2076 +0,0 @@ -= RFD 3 Evidence - -== Entry gate - -The entry gate selects `poc/rfd3-workload/main.c` as the acceptance workload. -It is a bounded C program with no SimFerret library dependency. Its line protocol -can echo asymmetric input, create and detect invocation state under `/tmp`, -double-fork a session-leader descendant that ignores `SIGTERM` and retains -standard output, and fetch one bounded TFTP response from the existing -`10.0.2.2` RFD 2 peer. It recognizes `EACCES` from the peer-specific prohibited -route separately from malformed or unavailable responses. The `fetch` command -accepts the scenario's independently generated expected payload rather than -deriving it from the request identifier. These behaviors cover the process, -fresh-root, live-output, and network assertions required by the RFD without -putting application interpretation in the guest agent. - -This selection does not claim that RFD 3 process supervision exists. Booting and -supervising the external executable remains the first Phase 0 task. - -=== Representative artifact capture - -The checked-in capture command is: - -[source,shell] ----- -.agents/dev ./scripts/rfd3-entry-gate.sh ----- - -It compiles the fixture as a static little-endian x86-64 Linux ELF and emits two -uncommitted inputs below one unique `.poc/rfd3-entry-gate/capture.*` directory: -the executable itself and a local OCI image layout containing that executable in -one uncompressed layer. Unique directories make concurrent captures independent -instead of replacing a shared `current` path. The OCI config selects -`/bin/simferret-workload-fixture`, an exact environment, `/` as working -directory, and `65534:65534`. The layout contains `oci-layout`, `index.json`, and -selected config, manifest, and layer blobs. The script uses canonical JSON, -USTAR metadata with zero timestamps, and a fixed entry order; it neither pulls -an image nor invokes a container daemon. - -The capture ran with `x86_64-unknown-linux-musl-gcc (GCC) 15.3.0` and Python -3.14.7 from the pinned development environment. Repeating the command into a -second output directory and recursively comparing the results produced no -difference. The executable reported a 64-bit little-endian AMD x86-64 ELF with -no interpreter program header. A host-side protocol smoke produced: - -[source,text] ----- -ready version=1 -echo value=asymmetric_42 -state value=fresh root=fresh -state value=stale root=stale -stopped status=0 ----- - -The focused regression command is: - -[source,shell] ----- -.agents/dev ./scripts/rfd3-entry-gate-test.sh ----- - -It serves the actual RFD 2 response shape with an independently supplied -32-hex-character payload, confirms the fixture accepts an exact response and -rejects a corrupted payload, proves a second descendant-spawn command exits with -status 2 without creating another process, and runs two captures concurrently -into distinct byte-identical directories. The test compiles only its network -peer address and ephemeral UDP port as test constants; the captured fixture -retains the fixed `10.0.2.2:69` peer. - -The captured measurements and identities are: - -[cols="2,1,3",options="header"] -|=== -| Object | Bytes | SHA-256 - -| Fixture source -| 8,888 -| `34161feb2f7c3f8c28deef21dcf51a92e6f02df23cfe9e6bb3a62f730faf5a83` - -| Standalone executable -| 70,912 -| `582a51e4c5ed835752fa84809a8b5a2f5ecdf49736be7d93d72a6c23d069243f` - -| OCI config -| 276 -| `c7a8a586a744a35527d1e37cb3ebc9233d488b567ef5d58c115b59dd40bd7650` - -| OCI manifest -| 399 -| `399efbdb79b760c5babc749882b385b36d6a8db1c5f68ecb411f76030aeb4e6d` - -| OCI layer and DiffID -| 81,920 -| `e80ac2d42a82e47fb34715c714da972d1aa4bf5e08bea87ffb3921d7ad230550` -|=== - -The complete five-file OCI layout is 82,932 bytes. These observations establish -representative lower bounds only. They deliberately precede and do not choose -descriptor-count, path, file, compressed-byte, expanded-byte, or cache limits; -Phase 0 captures broader representative images before those limits are fixed. - -== Phase 0 workload and OCI spike - -The Phase 0 spike answers the packaging questions before any typed -specification or assembler exists. It is throwaway prototype code under -`poc/rfd3-phase0/` driven by `scripts/rfd3-phase0-spike.sh`; the Phase 1 Rust -assembler replaces the prototype. The prototype deliberately reuses -standard-library primitives (`json`, `tarfile`, `gzip`, `hashlib`) rather than -hand-rolling container parsing, and it never extracts a layer with the host -`tar` program. - -The checked-in command is: - -[source,shell] ----- -.agents/dev ./scripts/rfd3-phase0-spike.sh ----- - -It compiles one external static executable and one dynamically linked -executable from `poc/rfd3-workload/main.c`, builds four local OCI image -layouts, applies representative layers twice, normalizes every source into a -content-addressed store, removes the entire generated source tree, and only -then records and passively replays each workload through one guest supervisor. -The guest supervisor is a spike, not the Phase 2 agent: it launches the packaged -program in a private `chroot`, feeds it a fixed command file, drains its output -while it runs, and then kills and reaps every remaining guest process. It -exposes no command protocol, makes no application-protocol assertions, and does -not yet apply a normalized launch configuration. - -Every workload printed the same bounded exchange, and both replays of each -source were byte-identical to its record: - -[source,text] ----- -ready version=1 -echo value=asymmetric_42 -state value=fresh -descendant state=escaped -stopped status=0 -supervisor source= -supervisor workload_status=0 -supervisor cleanup_reaped=1 -supervisor output_bytes=101 -SIMFERRET_PHASE0_SUPERVISOR_OK version=1 ----- - -`cleanup_reaped=1` is the escaped double-forked session leader the fixture -creates: it survives the primary process, retains the workload output -descriptor, and is killed and reaped only through the supervisor's -whole-guest barrier. The output stream reached end of file only after that -barrier, so no workload descriptor survived it. - -=== Representative sources - -The static fixture is built by the pinned musl static compiler and the dynamic -fixture by the pinned glibc compiler with an explicit canonical interpreter -path. Both are little-endian x86-64 Linux ELF executables. - -[cols="2,1,1,3",options="header"] -|=== -| Source object | Bytes | Interpreter | SHA-256 - -| Static executable -| 70,912 -| none -| `582a51e4c5ed835752fa84809a8b5a2f5ecdf49736be7d93d72a6c23d069243f` - -| Dynamic executable -| 21,648 -| `/lib64/ld-linux-x86-64.so.2` -| `37cb51e280ffddd038442c878db111b407261f414ecbbdda3fcc6d025e18f1db` - -| In-image loader -| 263,056 -| --- -| `0e470f96e41ddd98ac964b3b729df0becfa7562c8ba78ab3cab1822fa5498d23` - -| In-image `libc.so.6` -| 2,404,904 -| --- -| `8334bf4b6c5ab4939cab40f9c9594d0756d10dc6df3e5603593d223f7c538b02` -|=== - -The dynamic layout places the executable, the interpreter, and the shared -library in the image only. The guest has no other filesystem, so the focused -dynamic workload executed from its in-image loader and library closure. - -[cols="2,1,2",options="header"] -|=== -| Layout | Bytes | Selected manifest digest - -| Static, one uncompressed layer -| 82,862 -| `sha256:399efbdb79b760c5babc749882b385b36d6a8db1c5f68ecb411f76030aeb4e6d` - -| Dynamic, gzip base layer plus uncompressed upper layer -| 1,171,472 -| `sha256:846176de46401217327ea8e25c3268f5ce46a3835b8308ddb91fe2a83cb18ad8` - -| Layer-semantics, two uncompressed layers -| 113,807 -| `sha256:0125b5e9911fcf46bb1af087942366823e37431e82bf63fbae9fca5ca9c932bc` - -| Root-opacity, two uncompressed layers -| --- -| `sha256:144d0c9fb7bd1486b2b922c04634d8173f80ac173c59c0969ceeecd54ccf6215` -|=== - -The static layout reproduces the entry gate's config and manifest digests -exactly (`c7a8a586...` and `399efbdb...`), which confirms the canonical JSON and -layer encoding are reproducible across independent generators. The entry gate's -index annotation changes only `index.json` and therefore neither digest. - -=== Layer semantics and canonical identity - -The layer-semantics layout applies a base layer and an upper layer that -exercise directory metadata updates, content and metadata replacement, a -whiteout that removes a lower entry with no same-layer addition, a whiteout -whose same-layer addition must survive, an opaque directory, a lower file -replaced by an opaque directory, new nested directories, a relative symbolic -link that escapes upward but stays inside the root, and a whiteout for a path -that does not exist. The `opt` opaque marker and the root-opacity marker both -appear *after* the additions they coexist with, so an implementation that -applied markers in archive order would delete same-layer additions and change -the result. The `etc/swap` marker deliberately precedes its addition, because -it also covers a lower file replaced by an opaque directory. - -Applying it twice, in separate processes with different `PYTHONHASHSEED` -values, produced one canonical digest over 19 entries and byte-identical -materialized trees: - -[source,text] ----- -semantics_canonical_digest=38782e7c828a0eec4ac79dc20ab30bf6ab3c0b10c3048b15265db4b0d74e27f0 -semantics_entries=19 -semantics_expanded_bytes=70808 -semantics_duration_ns=141189175 -semantics_reapply_equal=true ----- - -The observed final tree confirms each rule: `etc/` moved from mode `0755` to -`0750`; `etc/config` was replaced by upper content with new metadata; -`etc/remove-me` is the upper addition at mode `0600`, so the whiteout removed -only the lower-layer entry; `etc/pure-delete` is absent, so a whiteout with no -same-layer addition removes its lower entry; `etc/swap` is a directory -containing `new`, so a lower file can be replaced by an opaque directory; -`opt/keep`, `opt/drop`, and `opt/nested` are gone while `opt/new` survives the -opaque marker that appears after it; `srv/opaque/lower` is untouched by an -unrelated opaque marker; and both symbolic links kept their exact targets. - -The canonical digest also covers numeric ownership, which the host staging tree -cannot reproduce because the spike runs unprivileged. The fixture sets `etc/` to -canonical `2000:2000`; the materialized tree shows the host owner instead. That -distinction is why the regression test asserts mode and modification time and -not ownership, and it is why guest-visible nonzero ownership remains a Phase 2 -assembler and Phase 4 verification concern. Symlink modes are normalized to -`0777` in the canonical model, because a Linux symbolic link has no settable -mode, so the identity never claims a mode the guest cannot have. - -=== Root-level opacity - -A separate two-layer layout covers the root directory, because a root-level -opaque marker in the main fixture would erase the executable. The base layer -holds `bin/simferret-workload-fixture`, `keep/lower`, `drop`, and `dir/child`; -the upper layer re-adds `bin`, `keep/upper`, and finally a root -`.wh..wh..opq`. The resulting tree is exactly the upper layer's own additions: - -[source,text] ----- -opacity_tree=./bin ./bin/simferret-workload-fixture ./keep ./keep/upper ----- - -That proves root opacity removes lower-layer descendants rather than nothing, -and that it leaves same-layer additions alone even though the marker is last. - -=== Content-addressed closure and live-source removal - -Each source produces one raw closure and one derived entry. Raw evidence is the -opened executable plus the canonical specification for a binary, and -`oci-layout`, `index.json`, the selected manifest, the config, and each stored -layer for OCI. The prototype re-derives the canonical tree from the raw objects -on every replay and refuses to proceed when a raw object is missing, corrupt, or -inconsistent with its recorded size and digest. - -Replay also verifies more than the tree. The binary specification is re-parsed -from its verified raw object rather than read back from the closure record, so -editing the record cannot change the launch the store reproduces; the -re-derived launch, layer evidence, policy versions, and limits are each compared -against the closure; and the closure record is pinned by a digested lock, so -editing it is detected even when the edit is internally consistent. The lock -belongs in the run manifest in the Phase 1 assembler; the store-sidecar lock is -the prototype equivalent. It is a corruption detector, not an authentication -mechanism: replacing the raw objects, the closure, the sidecar, and the derived -lock consistently would produce another self-consistent recording, which is the -same limitation RFD 3 records for content digests generally. - -[cols="1,1,1,1,1",options="header"] -|=== -| Source | Raw bytes | Expanded bytes | Canonical digest | Assembly - -| Binary -| 71,084 -| 70,912 -| `9190efc1...2ee9e4af` -| 69.6 ms - -| Static OCI -| 82,862 -| 70,912 -| `9190efc1...2ee9e4af` -| 71.7 ms - -| Dynamic OCI -| 1,171,472 -| 2,689,608 -| `773718c1...cd4b10ca6` -| 97.1 ms -|=== - -The standalone static executable and the static OCI layout converged on the -same canonical filesystem digest, so both sources enter the same runtime -boundary even though their raw closures differ. Reassembling the binary source -into a second store produced a byte-identical `closure.json`. - -Every source is assembled before any QEMU invocation, and then the complete -generated source tree is deleted and its absence asserted. The regression test -independently fails any QEMU run that starts while a `sources` directory still -exists, so moving deletion later cannot pass unnoticed. What this demonstrates -is workload-input closure: the assembler, supervisor, kernel, and QEMU are -pinned environment dependencies and are still read from the repository or the -pinned store. - -=== Record and passive replay - -Each source was recorded once and passively replayed twice with the live -sources absent. The baseline is a workload-free image containing only the -supervisor, so the growth column is the workload plus the launch-harness -`/etc` files, measured against a supervisor-only image rather than against an -empty initramfs. - -[cols="2,1,1,1,1,1",options="header"] -|=== -| Source | Initramfs bytes | Growth over baseline | Workload tree bytes | Record | Replay 1 | Replay 2 - -| Binary -| 53,079 -| 32,078 -| 70,912 -| 6.20 s -| 10.71 s -| 10.80 s - -| Static OCI -| 53,080 -| 32,079 -| 70,912 -| 6.28 s -| 10.96 s -| 10.86 s - -| Dynamic OCI -| 1,172,482 -| 1,151,481 -| 2,689,608 -| 6.01 s -| 9.27 s -| 9.35 s -|=== - -The workload-free baseline is 21,001 bytes. Replay logs were 8,523,815, -8,134,856, and 5,835,881 bytes. Record serial streams had SHA-256 digests -`cc564e42...5ccc0bddafa`, `da3b4c38...cc73b0141b6`, and `328bb993...6af86a4aaf4c31`; both -replays of each source matched their record byte for byte, so the supervisor's -concurrent draining preserved the guest-visible output exactly. The initramfs is smaller than the -workload tree for the static sources because the archive is gzip-compressed. -Repeated independent runs reproduced every canonical digest and serial digest -exactly; only durations and replay-log sizes moved with host scheduling, so no -divergence, retry, or nondeterminism was observed in semantic output. - -==== Replay divergence under the host-coupled model - -That claim has an observed exception, and it matters to the model question rather -than to this increment's construction. A continuous-integration run of the Phase 4 -acceptance (which runs this demonstration) failed in the binary source's first -replay with - -[source,text] ----- -qemu-system-x86_64: Missing character write event in the replay log - (insn total 2362086659/74 left, event 5431704 is EVENT_INSTRUCTION) ----- - -and a failure bundle recording `error_kind: early-termination`, `error: truncated -serial event frame`, `stage: execution`, and `backend_mode: replay`. - -What it means. The replaying guest performed a character write at an instruction -position where the replay log's next event is an instruction event. QEMU's -`replay_char_write_event_load()` accepts only `EVENT_CHAR_WRITE` there, so the -replaying guest's instruction stream had diverged from the recording's before -that point. The run was recorded under the model the product launches today, -`shift=auto`, where the guest's virtual clock is coupled to host real time, so -the number of instructions the guest executes between its serial writes depends -on how the host schedules it. - -What it rules out. A truncated or incomplete recording is ruled out by the -message rather than by a digest: the log still held a well-formed event at that -position, where a truncated log fails while reading one. The recording's own log -digest could not be compared against its manifest for this run, because the -uploaded bundle carries the replay's logs and `failure.json` only; a replay of a -recording whose log was truncated would fail differently, and no such failure has -been observed. A QEMU defect is not ruled out, but the same binary replays the -same demonstration correctly under the pinned model below, and the message is the -machinery reporting a divergence rather than misreading an intact log. - -Rate and reproduction. One failure in the continuous-integration history of this -step (run 35713214491; the neighbouring revisions of the same branch passed it), -and no failure in the local phase 3 acceptance run under deliberate load (eight -CPU consumers and three parallel QEMU guests) that was recorded for comparison. -The failure is rare rather than impossible, so a green run is not evidence that -the recording is reproducible. - -The pinned model. The same demonstration, recorded and replayed under -`shift=4,sleep=off` with the spike QEMU of RFD 4 -(`poc/time-model/qemu-nosleep-replay-flush.patch`), completed with both replays -matching under the same load shape, and the Phase 4 acceptance under that model -passes. Under `shift=4,sleep=off` the guest's virtual time is a function of its -instruction count, so the positions this failure depends on cannot move with host -scheduling. That is evidence for the pin, not proof that `shift=auto` is the only -model that can diverge: the failure is too rare to bound a rate from one sample. - -Guards, proposed rather than built. Validate the recorded log's integrity against -the manifest before replaying, so an incomplete recording is reported as an -incomplete recording rather than as a guest divergence; and classify QEMU's -replay-divergence message as a typed error, because the frame-level -`truncated serial event frame` this currently surfaces as points at the symptom -rather than at the divergence. Neither guard would make a host-coupled recording -reproducible, which is the model question RFD 4 records. - -=== Unsupported OCI constructs - -Eighteen representative constructs were refused before any output was -materialized, and each left no partial directory: - -[cols="1,3",options="header"] -|=== -| Construct | Observed rejection - -| Absolute layer path -| `absolute layer path '/etc/passwd'` - -| Escaping layer path -| `escaping layer path '../escape'` - -| Hard link -| `hard link at 'bin/second'` - -| Setuid mode -| `setuid or setgid mode at 'bin/simferret-workload-fixture'` - -| Device node -| `unsupported file type at 'dev/null'` - -| Duplicate path in one layer -| `duplicate layer path 'bin/simferret-workload-fixture'` - -| Traversal through a symbolic link -| `path 'redirect/file' traverses symlink 'redirect'` - -| Oversized file -| `file 'data/oversized' exceeds 16777216 bytes` - -| Unsupported layer media type -| `unsupported layer media type 'application/vnd.oci.image.layer.v1.tar+zstd'` - -| Wrong platform -| `selected descriptor is not linux/amd64` - -| Stored-layer to DiffID mismatch -| `layer 0 DiffID does not match uncompressed bytes` - -| Unsupported rootfs type -| `config rootfs type is not layers` - -| Corrupt stored blob -| `layer 0 descriptor digest does not match stored bytes` - -| Missing stored blob -| `cannot open file 'blobs/sha256/e80ac2d4...d7ad230550'` - -| Nonempty whiteout marker -| `whiteout marker at '.wh.victim' is not an empty regular file` - -| Marker path through a symbolic link -| `marker 'redirect/victim' traverses symlink 'redirect'` - -| Chained symbolic link that escapes the root -| `escaping symbolic link target at 'b'` - -| Whiteout marker that is not a basename -| `whiteout marker '.wh.a' is not a basename` -|=== - -The rejections above are the Phase 0 prototype's observed output, kept verbatim -as spike evidence. The shipped assembler refuses the same constructs with -value-free diagnostics: every layer rejection names the layer and member position -plus a fixed category (`absolute layer paths are unsupported`, `layer paths must -not contain '..' components`, `a layer contains duplicate normalized paths`, -`a layer marker traverses a symbolic link`, `layer 0 member 3 has an unsupported -mode`, `layer 0 member 3 is a hard link, which is unsupported`, and so on), never -the path, media type, link target, or raw header field that caused it. The tar -parser's own errors, which quote the pathname and the invalid numeric field, are -reduced to fixed context for the same reason. - -The prototype also rejects FIFOs, sockets, sparse files, empty or malformed -digests, empty manifests, numeric metadata outside its serializable range, an -opaque marker whose parent is still a non-directory after the layer is applied, -and invalid launch fields such as non-numeric or root credentials, duplicate -environment names, non-absolute working directories, volumes, and stop signals. -Its limits are prototype-local policy: 64 MiB stored layer, 256 MiB expanded -layer, 16 MiB file, 4,096 entries, 16 layers, 1,024-byte path, 4,096-byte -symbolic link target, 40 symbolic link expansions, 64 raw closure objects, and -a 4 MiB bound on cache metadata files. Phase 1 replaces them with the limits the -RFD fixes. The cache bound matters because replay reads `closure.json`, -`tree.json`, and the derived lock through the same bounded beneath-root reader -as raw objects, and a materialized tree containing a special file is rejected -rather than read. - -Two deviations from the RFD's stated profile are deliberate and recorded for -Phase 1. Python's `tarfile` consumes GNU `longname` and `longlink` records -transparently, so a layer using them is accepted even though the prototype -rejects PAX headers; detecting the physical extension records would mean -re-implementing tar parsing, which the RFD forbids. And descriptor `urls` and -embedded `data` are not yet rejected, because the prototype only ever opens -local `blobs/sha256/` paths; that is a Phase 1 rejection requirement, not a -safety gap, since nothing is fetched. - -The derived entry is also shaped differently from the RFD: it contains -`tree.json`, the materialized tree, and a lock naming the closure, while the -RFD describes a derived entry that names its complete raw closure. The -relationship is recorded, but in the closure record rather than in the derived -entry, so Phase 1 should decide which direction the RFD intends. - -=== Rust primitive selection - -The Phase 1 assembler should select existing primitives before writing custom -format handling. The spike evaluated the pinned workspace dependencies and the -candidate crates: - -[cols="1,1,3",options="header"] -|=== -| Concern | Selection | Rationale - -| JSON -| `serde` 1.0 and `serde_json` 1.0 -| Already pinned in the workspace; serde's default of ignoring unknown fields - matches the OCI forward-compatibility requirement without relaxing explicit - rejection of unsupported selected values. - -| Digests -| `sha2` 0.10 -| Already pinned; supplies descriptor, DiffID, and canonical-identity SHA-256 - without a C dependency. - -| Gzip -| `flate2` 1.1 with `rust_backend` -| Already pinned with the pure-Rust backend, so layer decompression is - reproducible and does not link a system zlib. Decompression still needs an - explicit expanded-byte bound because the reader can expand past a limit. - -| Tar -| `tar` 0.4 -| Streams USTAR/PAX entries without extracting them and exposes entry type, - mode, ownership, link target, and size so the assembler can reject hard - links, devices, sparse files, and setuid modes itself. The prototype's GNU - longname experience is the reason to inspect physical extension records - deliberately rather than rely on a library's convenience behavior. - -| Safe filesystem access -| `rustix` 1.1 -| Exposes `openat`-style calls with `O_NOFOLLOW`, `O_NONBLOCK`, and directory - file descriptors so every source read and staging write stays beneath one - opened root. `O_NONBLOCK` is required: a blocking open on a FIFO waits for a - writer instead of rejecting the special file. `cap-std` 4.0 is the - alternative but is a larger abstraction than this increment needs. - -| OCI types -| Minimal `serde` structs, with `oci-spec` 0.10 as a reference -| The bounded profile needs strict rejection of unsupported selected values and - deliberate ignoring of unrelated fields, which minimal structs express - directly. `oci-spec` remains the reference for media-type and field naming. -|=== - -None of these crates is added to the workspace in Phase 0. The prototype is -Python so that a wrong policy costs a spike edit instead of an assembler -rewrite; Phase 1 adopts the selection above and its pinned versions. - -=== Phase 0 regression tests - -The focused command is: - -[source,shell] ----- -.agents/dev ./scripts/rfd3-phase0-spike-test.sh ----- - -It fakes the QEMU invocation and checks that one successful run records exactly -three QEMU invocations per source, removes the whole generated source tree, and -writes the expected evidence keys. The fake refuses to start while a `sources` -directory exists, so a regression that moved deletion after QEMU would fail -rather than pass. It fails divergent, incomplete, and infrastructure-failure -guest output, and it requires invalid duration bounds to fail before QEMU -starts. - -It then exercises the prototype directly: the layer-semantics digest and tree -are stable and include a pure-deletion whiteout, an opaque directory after its -same-layer addition, and a file replaced by an opaque directory; root-level -opacity produces exactly the upper layer's additions; the binary and static OCI -sources converge; repeated layout generation is byte-stable; a missing, corrupt, -or tampered raw object, a tampered derived entry, an edited closure record, a -closure whose launch no longer matches its specification, a closure missing its -specification object, an oversized closure record, and a special file inside a -cached tree all fail materialization; a symbolic-link source is rejected; a -whiteout whose parent the same layer replaces with a symbolic link is accepted -while a marker inside a lower-layer symbolic link is refused; and every -unsupported construct is refused without partial output. - -== Phase 1 typed specification and canonical assembler - -Phase 1 replaces the Python prototype with `crates/simferret/src/workload/`: a -strict TOML specification, a bounded beneath-root reader, an OCI image-layout -normalizer, a canonical tree and identity, and a raw closure plus derived cache -store. It selects the Rust primitives the Phase 0 spike recommended: `serde` and -`serde_json` for JSON, `sha2` for digests, `flate2` with `rust_backend` for -gzip, `tar` 0.4 for layer records, and `rustix` 1.1 for `openat`-style access -with `O_NOFOLLOW`, `O_NONBLOCK`, and directory descriptors. The prototype is no -longer on any execution path. - -=== Resolved Phase 0 deviations - -* GNU `longname` and `longlink` records, PAX `x` and `g` records, hard links, - devices, FIFOs, sockets, sparse files, setuid and setgid modes, and unknown - tar type bytes are each rejected by inspecting the physical record type with - raw iteration. The prototype accepted GNU long names because Python's - `tarfile` resolved them transparently. -* Selected descriptors that declare `urls` or embedded `data` are rejected - before the referenced content is opened. Unselected descriptors are still - ignored whatever they contain, so forward compatibility is preserved. -* The derived entry names its complete raw closure. `derived//lock.json` - records the closure digest, the canonical digest, and the tree and template - digests, and verification refuses a derived entry that does not name the - closure being replayed. The Phase 0 record-direction question is resolved in - favor of the RFD's "each derived entry names its complete raw closure". - -=== Bounded profile - -The Phase 0 prototype's limits are adopted as fixed constants: 1 MiB -specification, layout, manifest, and config; 4 MiB index; 64 MiB stored layer; -256 MiB expanded layer and canonical expanded bytes; 16 MiB file; 4,096 entries -per layer; 16 layers; 1,024-byte path; 4,096-byte link target; 40 link -expansions; 64 raw closure objects; 32,768 canonical entries; 4 MiB cache -metadata; 256 arguments and environment entries; 4 KiB per argument and -environment entry; and 64 KiB total environment. Every bound is recorded in the -raw closure, so changing one changes the workload identity and a recording made -under other limits fails verification rather than being reinterpreted. - -Two further profile decisions are recorded here. Modification times are limited -to the unsigned 32-bit whole-second range because the guest template is a `newc` -CPIO archive, and a timestamp the template cannot encode is rejected rather than -truncated. A standalone binary installs at the one fixed canonical path -`/bin/simferret-workload`; binary specifications therefore carry no install path -and no auxiliary file tree. - -The Phase 1 store holds exactly one workload closure and refuses to replace it -with a different one, so the derived entry can name its closure unambiguously. -Reusing a shared store across different workloads is deferred to the Phase 3 run -integration, which will name closures by digest. - -=== Checked-in evidence command - -[source,shell] ----- -.agents/dev ./scripts/rfd3-phase1-evidence.sh ----- - -It compiles `poc/rfd3-workload/main.c` with the pinned static compiler, builds a -converging local OCI image layout, assembles the same fixture as a binary source -and as an OCI source, verifies both stores, and requires one canonical identity, -one template identity, owner-only store permissions, and a reproduced closure. -Every digest it compares is first checked to be a 64-character hexadecimal -SHA-256 value, and a missing summary field is a failure rather than an empty -comparison: every reported field is read into a variable where a failing -substitution aborts the script, instead of inside the report block where `echo` -would mask it, and the script injects a reader that emits a usable field and then -fails to prove that partial output is rejected. The two independently derived -`derived//template.cpio` artifacts are compared byte-for-byte with -`cmp`, both stores must verify to the canonical digest their assembly reported, -and a re-assembly must reproduce both the closure identity and the complete -summary. Every directory and file in both stores is scanned and must be mode -`0700` or `0600` respectively, so a regression in any single artifact fails the -run rather than only the two paths sampled before. -A representative run produced: - -[cols="2,3",options="header"] -|=== -| Measurement | Value - -| Fixture source SHA-256 -| `34161feb...30faf5a83` - -| Static executable -| 70,912 bytes, `582a51e4...d069243f` - -| OCI layout -| 82,854 bytes, selected manifest `sha256:3fa49528...c0798493` - -| Binary canonical / tree / template -| `bfb6c8c9...87f8c91` / `0f30f1ef...0c7ccfe66` / `cc1946f3...4eac1db6` - -| OCI canonical / tree / template -| identical to the binary source - -| Binary closure -| `2ad827ac...3f6e93e62` (2 raw objects) - -| OCI closure -| `671b85dc...c312751ca` (5 raw objects) - -| Canonical entries / expanded bytes -| 3 / 70,912 for both sources - -| Assembly duration (both sources) -| 23.6 ms warm; durations move with host scheduling - -| Store bytes (binary / OCI) -| 144,410 / 156,837 - -| Re-assembly -| byte-identical summary and closure -|=== - -The static executable digest and the fixture source digest are unchanged from -the entry gate, so Phase 1 consumes the same representative artifact. The two -source closures differ, as the RFD requires, while the canonical and template -identities converge before the runtime boundary. - -=== Phase 1 regression tests - -[source,shell] ----- -.agents/dev cargo test --locked --workspace --all-targets --all-features ----- - -`tests/rfd3_phase1.rs` builds standalone binary and local OCI image-layout -sources and covers, before any output is published: static-ELF, architecture, -endianness, malformed, relocated (static PIE), symlinked, escaping, and oversized -binary inputs; absolute -and escaping layer paths, hard links, devices, setuid modes, per-layer duplicate -paths, PAX and GNU extension records, symlink traversal, unsupported layer media -types, wrong or ambiguous or platform-less or remote selection, DiffID mismatch, -unsupported rootfs type, corrupt and missing selected blobs, nonempty whiteout -markers, markers that traverse a lower symlink, chained symlink escapes, -non-basename markers, volumes, stop signals, `ArgsEscaped`, root and named -credentials, duplicate environment names, relative and missing executables, -non-executable modes, relative and missing working directories, config platform -extensions, non-array launch vectors, and empty layer lists. It verifies that -binary and OCI sources converge, that layer semantics are order independent and -legally replace lower entries, that root opacity keeps only same-layer -additions, that the template reproduces canonical metadata, and that every -launch identity class changes the closure. It tampers each raw and derived -identity class independently, proves a self-consistent manifest and stored-layer -change still fails against the unchanged relationships, proves a self-consistent -configuration change still fails against the derived lock, proves a derived -entry alone is insufficient when raw content is missing, proves a special file -in the store is refused, proves a second closure cannot replace a verified store -entry, proves a closure whose derived lock names a different closure is refused, -and runs four concurrent assemblies that publish one verified entry. It also -proves the reserved owner identifier is refused in a binary specification, in -the OCI configuration, in a layer entry's owner and group, and in a retained -canonical specification during replay; that a self-consistent recording which -moves the binary install path is refused by the profile invariant; that a -pre-existing store root, internal directory, populated raw object directory, -raw object, or derived entry with group or other access is not adopted; that a -directory or symbolic link declaring a nonzero size, and a layer whose -end-of-archive marker is missing or followed by a hidden member, are refused -before publication; and that the unconfigured forms of the unsupported launch -extensions are accepted while their wrong JSON types are not. - -Unit tests cover canonical identity order independence and field coverage, the -encoded template, bounded symlink resolution, layer-path normalization, and the -whiteout, opaque, replacement, duplicate, and marker-traversal rules directly. - -=== Review hardening - -A pre-merge review of the Phase 1 implementation found and fixed nine issues. -Each fix carries a regression test: - -* The guest template now emits the root entry first and requires the canonical - root to be a directory. Initramfs extraction does not create missing parents, - so a path such as `!early`, which sorts before the `.` root sentinel, would - otherwise have been dropped during extraction. Covered by - `template_emits_the_root_before_paths_that_sort_before_it`, - `template_emits_the_root_first_with_canonical_metadata`, - `a_non_directory_root_is_rejected`, and `a_non_directory_root_has_no_template`. -* `Root::sha256_file` validates the file type and size on the same descriptor it - hashes, so a FIFO or device in the derived entry is refused instead of read. - Covered by `a_fifo_in_the_store_is_rejected`. -* Source locators are traversed component-wise through the specification - directory descriptor, so a symlinked layout component is refused, and the - specification open is non-blocking and type-checked. Covered by - `a_symlinked_layout_locator_is_rejected` and - `a_fifo_specification_does_not_block`. -* Store directories are created mode `0700` and store files mode `0600`, as the - RFD requires for private artifacts, independently of the ambient umask. - Covered by `store_artifacts_are_owner_only`; the evidence script asserts the - same under `umask 022`. -* Canonical entry and expanded-byte bounds are enforced after every applied - layer and on replay, not only at publication, so a hostile multi-layer image - cannot accumulate an unbounded intermediate tree. Covered by - `an_over_entry_limit_tree_is_rejected_during_construction`, - `an_expanded_layer_beyond_the_limit_is_rejected`, and - `canonical_tree_bounds_are_enforced`. -* The ELF validator uses checked range arithmetic, requires an executable - `e_type`, bounds the program table and each loadable segment, requires at least - one loadable segment, and requires the native program-header size and a program - table within the guest loader's 64 KiB limit. Covered by the extended - `unsupported_binary_inputs_are_rejected` cases, including - `wrong-program-header-size` and `oversized-program-table`. -* The combined OCI `Entrypoint` and `Cmd` vector is validated against the shared - argument bounds, and `Env: null` is treated as empty. Covered by - `oci_launch_arguments_are_bounded` and `a_null_environment_is_treated_as_empty`. -* The raw closure is published last, after the derived entry it names, and an - existing different closure is rejected before anything is written, so a - failure cannot commit a closure without its derived entry. Covered by - `a_failed_derived_publication_leaves_no_closure`; `write_file_atomic` also - removes its staging file when the final rename fails. -* An opaque marker's own target directory is included in the lower-layer symlink - traversal check. Covered by - `an_opaque_marker_may_not_traverse_a_lower_symlink`. - -The regression suite also gained a decoded `newc` assertion of template names, -order, modes, owners, timestamps, contents, and link targets; a self-consistent -raw subgraph change that must still fail against the unchanged manifest -relationship and derived lock; a self-contained-store check that mutating or -removing the live source cannot affect replay; and a working-directory launch -identity class. - -A second pre-merge review found four further issues. Each fix carries a -regression test: - -* Publication order now verifies the derived entry it just wrote *before* - committing the raw closure, so a conflicting concurrent builder can no longer - leave a store whose closure names a derived entry that does not match it. An - existing different closure is still rejected before anything is written. - Covered by `a_conflicting_builder_cannot_commit_an_unusable_store` and - `a_valid_closure_with_the_wrong_lock_is_rejected`. -* The owner identifier `u32::MAX` is reserved and refused in every input class - that can carry ownership: a binary specification, the OCI launch credentials, - and each layer entry. Without the check, the sentinel could collide with an - in-band "unknown owner" encoding. Covered by - `the_reserved_owner_identifier_is_rejected`. -* `Entrypoint` and `Cmd` are now parsed as strict string lists: only absence or - `null` means "absent", and any other non-array value such as `false`, `0`, or - `{}` is refused instead of being treated as empty. Covered by the extended - `unsupported_oci_constructs_are_rejected_before_publication` cases - `entrypoint-wrong-type` and `cmd-wrong-type`. -* The ELF loadable-segment check uses the full checked range comparison, so a - segment whose offset is at end of file or whose offset plus file size - overflows is refused. Covered by the extended - `unsupported_binary_inputs_are_rejected` cases `loadable-segment-past-file` - and `loadable-segment-offset-overflow`. - -The entry and expanded-byte bounds are enforced by the same -`validate_canonical_tree` call during construction and during replay, so the -byte-bound analogue of the entry-bound test is that shared replay path rather -than a separate case; the over-limit construction tests assert against -`MAX_VIEW_ENTRIES` directly and the shared unit test covers the expanded-byte -half of the same function. -`a_fifo_in_the_store_is_rejected` asserts the "is not a regular file" diagnostic -so the refusal is attributed to the type check rather than to a read error. - -A third pre-merge review found five further issues. Each fix carries a -regression test: - -* `Volumes`, `StopSignal`, and `ArgsEscaped` are validated per field instead of - through a shared "truthy" test, so a wrong JSON type such as `false`, `0`, or - `{}` is malformed rather than silently unconfigured. Each field keeps its own - unconfigured form: an empty object, an empty string, and `false`. Covered by - the `volumes-wrong-type`, `stop-signal-wrong-type`, and - `args-escaped-wrong-type` cases in - `unsupported_oci_constructs_are_rejected_before_publication` and by - `empty_launch_extension_fields_are_treated_as_unconfigured`. -* Reused store paths must already satisfy the private-store contract. The store - root, every directory reopened beneath it, every reused raw object, the reused - closure, and every reused derived entry are checked for owner and mode, so - assembly can no longer succeed while leaving a world-writable store behind. - Covered by `a_reused_store_path_must_already_be_owner_only`. Verification is - read-only and re-derives every artifact from the closure, so it does not - re-impose modes on a store it did not write. -* Replay enforces the fixed binary install path. The canonical specification - retained in a closure is re-validated by the same - `binary_tree_and_launch` path that assembly uses, so a self-consistent - recording that moves the install path is refused by the profile invariant - rather than accepted. Covered by - `a_retained_specification_with_a_moved_install_path_is_rejected_on_replay`. -* The evidence script is fail-closed: every reported field is hoisted out of the - report block so a missing field aborts, every compared identity is validated - as a digest and every count as a number, both verification outputs are compared - with their assembly, and every directory and file in both stores is checked - rather than two sampled paths. -* The replay-time reserved-owner guard has its own regression. The numeric owner - in a retained canonical specification never passes through the specification - parser, so it is now exercised directly, and the layer case covers both the - owner and group fields. Covered by - `a_retained_specification_with_a_reserved_owner_is_rejected_on_replay`. - -A fourth review round closed three remaining gaps: - -* A populated `raw/sha256` directory is validated before objects are written or - reused. A reused object is read without reopening its parent, so the earlier - per-artifact check did not cover a weakened object directory in an - already-populated store. Covered by an added case in - `a_reused_store_path_must_already_be_owner_only`. -* A metadata-only USTAR member that declares a data record is rejected. The raw - iterator advances by the declared size, so a directory or symbolic link with a - nonzero size would have silently dropped physical bytes while the parsed tree - stayed valid. Covered by - `a_metadata_only_member_with_a_data_record_is_rejected`. -* The evidence script's store inventory is written to a private file and `find`'s - own status is checked, so a failed or partial enumeration can no longer pass - silently, and the remaining source, executable, layout, and store-size - measurements are hoisted out of the report block. - -The moved-install-path regression was also corrected: the retained install path -is relative (`bin/simferret-workload`), so the test now moves it to `opt/app`. -The earlier fixture used an absolute path, which the pre-existing layer-path -normalizer already rejects, so it did not reach the profile invariant. With the -guard removed the recording is still rejected, but later, by the launch-identity -comparison; the test's diagnostic assertion is what pins the profile invariant. - -A fifth review round closed two more gaps: - -* The evidence script's field reader propagates a failing reader status - explicitly, because `errexit` is disabled inside a command substitution, so a - reader that emits a usable field and then fails would otherwise be accepted. - The script now injects exactly that fault on every run and requires it to - abort. -* Layer archives must end with the two zero blocks POSIX requires after the last - member. The pinned raw iterator stops at the first zero block or at end of - input, so a truncated archive, or a member hidden behind a single zero block, - would have been parsed as a shorter valid archive. Covered by - `a_layer_without_a_valid_end_of_archive_marker_is_rejected`. - -Two profile notes are recorded rather than fixed. A nonzero directory size is a -permitted USTAR directory-allocation hint, but this profile refuses it because -the pinned iterator cannot distinguish it from a payload; supporting it later -requires correct header-only framing. And publication is atomic with respect to -process failure, not to power loss: staging files are synced, but the store -directories are not, so durable crash recovery remains follow-up work. - -A sixth review round closed one more malformed-input acceptance. The ELF -validator now requires the native 56-byte program-header size and a program table -no larger than the guest loader's 64 KiB limit, instead of only rejecting a -header smaller than the native size. Covered by the -`wrong-program-header-size` and `oversized-program-table` cases in -`unsupported_binary_inputs_are_rejected`; both inputs were confirmed to be -accepted before the fix. - -A seventh review round extended the same validator with the guest's mapping -contract: - -* A file-backed loadable segment's file offset and virtual address must share a - page offset, because the guest maps it from `address - (address % page)`; a - mismatch fails only after the process image has already been replaced. -* A loadable segment's virtual address range, and the entry point, must stay - below the guest's 47-bit user address-space limit, matching the loader's own - address checks. - -The test ELF fixture now places its payload at a page-congruent address and -declares an entry point, so each negative case violates one invariant instead of -passing for an incidental reason. Covered by the `misaligned-loadable-segment`, -`loadable-segment-outside-address-space`, and `entry-outside-address-space` cases -in `unsupported_binary_inputs_are_rejected`, and by -`a_program_table_at_the_loader_limit_is_accepted`, which pins the 65,520-byte -boundary so the table limit cannot drift to `>=`. The compiled acceptance fixture -was rechecked against the new rules: its eight program headers, 448-byte table, -entry point, and four page-congruent loadable segments all satisfy them. - -An eighth review round corrected the address-space comparison and closed two -further loader-refused inputs: - -* A loadable segment's exclusive end may equal the guest's user address-space - limit; only a larger end is refused. The limit is the four-level value because - the pinned guest CPU model does not expose five-level paging, and the entry - bound is an assembly-time necessary condition rather than a guarantee for a - relocated image, whose final entry also depends on the runtime load bias. -* A fixed-address executable may not map below the guest's minimum mapping - address, which the pinned kernel keeps at its default and the unprivileged - workload cannot lower. Relocated images may legitimately map at zero, so the - rule applies to fixed-address executables only. -* A relocated image must have a nonzero aggregate mapping span, computed from its - first loadable segment's page start to its last segment's end, as the loader - computes it. - -Covered by the `fixed-segment-below-minimum-mapping` and -`relocated-image-without-mapping-span` cases in -`unsupported_binary_inputs_are_rejected` and by -`elf_address_space_boundaries_are_enforced_exactly`, which accepts a segment end -exactly at the limit, a fixed mapping exactly at the minimum mapping address, and -a relocated image with a mapping span, and refuses one page past the limit. - -A ninth review round replaced the header-order mapping-span rule with the -loader's actual requirement, after checking the pinned kernel's loader source: - -* A relocated image must begin with a file-backed loadable segment, because that - is the mapping the loader uses to choose its load base. A first segment with no - file content is instead mapped anonymously at the base the loader has not - chosen yet, which the unprivileged guest refuses. A file-backed first segment - also makes the aggregate mapping span nonzero, which the loader requires before - it relocates anything, so the separate span test is subsumed and was removed. - The earlier header-order endpoint comparison could additionally reject a layout - the loader accepts, because the loader measures the span from the lowest page - start to the highest segment end. -* A relocated image may not request a power-of-two alignment at least as large as - the user address space, because the loader then rounds its chosen base to zero - and retries at a fixed address the guest refuses. Non-power-of-two alignments - are ignored rather than rejected. -* A fixed-address segment with no memory content requests no mapping, so it is - exempt from the minimum mapping address. - -The first two rules above applied only to relocated images and were removed when -the profile was narrowed to fixed-address executables in the next round; only the -no-op-load exemption remains. - -A tenth review round then closed the increment by narrowing the profile instead -of extending that model. Simulating `ET_DYN` relocation was proving unbounded: -each round produced another source-provable way for the loader to refuse an image -that assembly had accepted, most recently a relocated image whose single -reservation covered the whole user address space. The standalone binary profile -now accepts only a fixed-address (`ET_EXEC`) image, because a relocated image's -load base, entry address, and mapping alignment are chosen by the guest loader at -exec time, so assembly cannot establish that it would load. A static PIE is -refused with the diagnostic "binary workload must be a fixed-address executable -ELF file, not a relocatable, core, or static-PIE image", and the same bytes are -still accepted from an OCI source, where loading is left to the guest. Covered by -`a_relocated_binary_is_refused_with_a_profile_diagnostic` and -`the_same_relocated_executable_is_accepted_from_an_oci_source`; the `ET_EXEC` -boundary, no-op-load, and address-space cases remain as they were. - -Each of these tests was confirmed to fail when its fix is reverted, so none of -them asserts a merely incidental error. - -== Phase 2 guest process runtime - -Phase 2 replaces the throwaway Phase 0 supervisor with `crates/simferret/src/runtime.rs` -and extends the versioned control protocol with the process commands. The PID-1 -agent stays outside an immutable workload template at `/workload`; for every -invocation it materializes a fresh writable root under `/run/simferret`, applies -the versioned overlay, and supervises exactly one child in a private filesystem -root. - -The guest image assembler now appends the canonical workload template below that -reserved root. `Tree::template_entries` emits the same `newc` records as -`Tree::template` without the trailing marker, so the workload template and the -agent's own entries concatenate into one initramfs archive. A unit test decodes -the resulting archive and requires `workload` and `workload/bin/app` to be -present, `init`, `bin/busybox`, and `modules/mii.ko` to stay outside it, and -exactly one trailer. The run flow still passes no template, because selecting the -workload and recording its identity in the run manifest belongs to Phase 3. - -=== Runtime profile - -The runtime enforces the RFD's launch and lifecycle rules: - -* The template is validated before any invocation. A package entry at `/tmp` or - `/dev` must be a directory and is replaced by the overlay; a non-directory - entry anywhere below those paths is rejected as an overlay collision. Special - files, entries beyond the canonical view bound, and paths beyond the canonical - path bound are rejected before any root is created. The runtime reuses the - assembler's constants and counts the template root the same way, so the two - phases agree on the template bounds and the runtime never rejects a template - for exceeding a bound the assembler allowed. - - Overlay compatibility is a separate rule and is enforced only at the runtime - boundary: the assembler does not yet reject a package entry that collides with - the overlay, nor a launch path that overlay replacement invalidates. A template - whose package entry collides is refused when the runtime is constructed, so the - agent reports an infrastructure error rather than a `launch-failed` event; a - launch path that overlay replacement invalidates is refused per invocation as a - typed `launch-failed` event. Moving both checks into assembly is listed for - Phase 3. -* Each invocation copies the template bytes and canonical metadata into a new - root, skipping the `/tmp` and `/dev` subtrees so the overlay replaces them - instead of merging with them, then synthesizes `/tmp` as a root-owned - mode-`01777` directory, `/dev` as a root-owned mode-`0755` directory, and - `/dev/null` and `/dev/zero` as mode-`0666` character devices `1:3` and `1:5`. - The canonical root metadata is applied after the overlay, so creating it cannot - change the recorded directory timestamps. The root is removed at the cleanup - barrier, so no invocation can observe a previous one. -* The child receives only fresh standard pipes; every other inherited descriptor - is closed, covering the whole descriptor table in two `close_range` calls so a - descriptor above any scan cap cannot leak. A table scan is not an equivalent - fallback, because lowering `RLIMIT_NOFILE` does not close descriptors that are - already open; setup therefore fails with a typed `launch-failed` event rather - than continuing with a descriptor that might reach the workload. The - close-on-exec flag is cleared explicitly on the standard descriptors, because - `dup2` leaves it alone when both descriptors are equal. The child then restores - the default `SIGPIPE` disposition that Rust installs for itself, changes root, - changes to the normalized working directory, clears supplementary groups, sets - `no_new_privs`, applies the nonzero GID and UID, and executes the exact - argument vector without a shell. Setup failures are reported through a - close-on-exec pipe as typed `launch-failed` events, so a successful `execve` is - unambiguous. -* Launch validation is one shared rule set, applied both when the assembler - normalizes a binary or OCI source and again when the runtime accepts an - invocation: the executable and the working directory must be absolute in-root - paths, the first argument must name an absolute in-root path without being - required to equal the executed path, and the argument and environment vectors - are bounded. Diagnostics name the field and never echo a caller-supplied - argument or environment value. -* The versioned process commands are `start`, `stdin-write`, `stdin-eof`, and - `terminate`. `stdin-write` carries an invocation identifier, a strictly - contiguous byte offset, and bounded hexadecimal exact bytes; `terminate` is an - unconditional `SIGKILL` independent of any OCI stop signal. -* Live stdout and stderr frames carry the invocation, the stream, a per-stream - byte offset, one monotonic cross-stream sequence number, and exact bytes. The - exit record independently reports per-stream totals, SHA-256 digests, and the - number of frames emitted. A per-frame or per-invocation limit overflow, a - non-contiguous offset, and a control or pipe transport failure are fatal: the - invocation is killed and the agent reports an infrastructure error rather than - a workload property. One batch offers each stream at most half of the remaining - budget, so a continuously readable stream cannot starve the other, while a - single ready stream still drains the whole budget across the batch. A process - exit record whose code or signal is outside the Linux range cannot be accepted - by a typed frame reader. The runtime's own producer uses the wait-status macros, - so it only ever encodes values inside the range. -* On primary exit or termination the runtime signals every member of the active - invocation, reaps until only the agent remains, and drains both pipes to end of - file before emitting `cleanup-complete`. The reap and the signal are scoped to - the invocation: in guest scope they cover the whole process table, and in - process-group scope only the invocation's own process group, so a host test - cannot disturb or consume an unrelated child. Each advance reaps before it - services input, so an already-exited primary moves straight into the barrier - instead of a write to a pipe whose readers are gone being reported as an - infrastructure failure. `terminate` discards queued input and closes the - child's standard input before it signals, for the same reason, and input is - refused once termination is requested. - - Root removal is explicit and fallible on every path that created a root, - including a failed start: a removal failure is reported alongside the launch - failure, and a root that could not be removed is remembered so the next start - retries its removal and is refused while the path survives. The single-workload - slot also stays occupied when the barrier cannot remove its root, so a later - invocation can never start on top of a root that is still on disk. A new - `start` is refused until that barrier completes. The agent - reports process and byte facts only; application protocol interpretation - remains in the host scenario checker. - -=== Checked-in evidence command - -[source,shell] ----- -sudo env "PATH=$PATH" SIMFERRET_BUSYBOX="$SIMFERRET_BUSYBOX" \ - ./scripts/rfd3-phase2-runtime.sh ----- - -The script builds the phase 2 test binary, then runs it as PID 1 in a fresh PID -namespace. The namespace matters twice: the runtime changes root, drops -credentials, and creates device nodes, which needs root; and the guest-wide -cleanup barrier signals every process in the process table, which must not reach -the host. A representative run produced: - -[source,text] ----- -running 29 tests -test a_completed_invocation_reports_a_root_that_cannot_be_removed ... ok -test a_continuously_ready_stream_does_not_starve_the_other ... ok -test a_descendant_retaining_the_output_pipe_is_killed_by_the_cleanup_barrier ... ok -test a_failed_materialization_leaves_no_partial_root ... ok -test a_failed_start_reports_a_root_that_cannot_be_removed_and_refuses_the_next_start ... ok -test a_full_stdin_pipe_does_not_block_the_control_loop ... ok -test a_member_that_closes_its_output_descriptors_is_still_reaped ... ok -test a_missing_executable_is_a_typed_launch_failure ... ok -test a_non_contiguous_offset_kills_the_invocation_and_is_fatal ... ok -test a_package_directory_below_the_overlay_does_not_block_the_launch ... ok -test a_second_start_is_refused_while_an_invocation_is_active ... ok -test a_standard_pipe_that_lands_on_descriptor_zero_survives_exec ... ok -test an_escaped_descendant_cannot_outlive_the_cleanup_barrier ... ok -test an_inherited_descriptor_above_the_scan_cap_does_not_leak ... ok -test an_invocation_does_not_steal_an_unrelated_child ... ok -test an_invocation_identifier_cannot_be_reused ... ok -test an_oci_normalized_launch_identity_runs ... ok -test an_overlay_collision_is_rejected_before_any_invocation ... ok -test an_unexecutable_file_reports_a_typed_launch_failure ... ok -test each_invocation_materializes_a_fresh_root ... ok -test output_frames_are_contiguous_per_stream_and_sequenced ... ok -test output_offsets_advance_across_multiple_frames_per_stream ... ok -test shutdown_reports_the_real_primary_exit_status ... ok -test standard_input_round_trips_through_contiguous_offsets ... ok -test terminate_kills_and_reaps_the_invocation ... ok -test terminating_an_invocation_with_queued_input_is_not_an_infrastructure_error ... ok -test the_agent_drives_the_runtime_over_the_serial_control_channel ... ok -test the_runtime_overlay_is_visible_inside_the_workload_root ... ok -test the_workload_starts_with_the_default_sigpipe_disposition ... ok - -test result: ok. 29 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.18s ----- - -The fixture is the pinned static busybox copied into the template and executed as -the workload. It is ordinary Linux software with no SimFerret library dependency, -so the runtime supervises what a packaged workload would be. When the effective -user is not root the tests skip with an explicit diagnostic instead of failing; -the same code runs as PID 1 in the guest. - -=== Phase 2 regression tests - -`crates/simferret/src/runtime.rs` unit tests cover the template walk and overlay -profile: a valid template with content outside the overlay, a non-directory -`/tmp` and a non-directory `/dev/null`, a legal nested empty directory tree, the -entry and path bounds, a FIFO, and every rejected launch value including an -escaping or relative executable, root credentials, an empty or mismatched -argument vector, a malformed environment entry, and a relative working directory. - -`crates/simferret/tests/rfd3_phase2.rs` covers the runtime end to end: - -* live stdout and stderr frames with exact bytes, per-stream offsets, one - cross-stream sequence, and independently recomputed totals and digests; -* a stdin round trip through contiguous offsets and `stdin-eof`, with the - accepted-offset record matching the input exactly; -* a non-contiguous offset that kills the invocation and reports a fatal error; -* `terminate` producing a `SIGKILL` exit record and a completed barrier; -* a second `start` refused while an invocation is active, and accepted only after - `cleanup-complete`; -* a first invocation's `/tmp` mutation absent from a second invocation; -* the overlay visible inside the workload root as character devices and a - sticky, world-writable `/tmp`; -* a package-provided empty directory tree below `/tmp` and a directory at - `/dev/null` not blocking the launch, with the overlay replacing the subtree - instead of merging with it, and the canonical root and `/dev` timestamps - preserved across overlay creation; -* a copied template file bounded by the canonical file bound rather than by the - invocation's output budget, and the template entry bound and root-inclusive - entry count matching the assembler's; -* a descendant that retains the output pipe being killed before the barrier can - complete; -* an escaped `setsid` descendant killed by the guest-wide barrier, which requires - the PID namespace the script provides. The descendant publishes its own - identifier after `setsid`, and the test confirms from the process table that it - really leads its own process group and session before terminating the primary, - so the test cannot pass because `setsid` silently failed; -* a missing or unexecutable executable reported as a typed `launch-failed` event - with no active invocation and no surviving partial root; -* an overlay collision rejected before the runtime root is created; -* an OCI-normalized launch identity whose first argument differs from the - executed path running, and launch diagnostics that never echo a caller value; -* a writable inherited descriptor above the old descriptor-scan cap not reaching - the workload, and a standard input pipe that lands on descriptor `0` because - the agent closed its own surviving `execve`; -* the workload starting with the default `SIGPIPE` disposition rather than the - one Rust installs for itself; -* an invocation leaving an unrelated exited child of the agent alone, so the - agent can still observe that child's status; -* the agent driving the runtime over the real serial control channel. The test - reads the event channel while the agent runs and waits for the agent to report - each state instead of sleeping, so it asserts an exact per-byte command - acknowledgement count, live output attributed to the command being handled - while the workload ran, an exact output stream, `cleanup-complete`, and - `agent-stopped`. - -* termination with input still queued behind a full pipe reporting the requested - termination and a completed barrier rather than a broken-pipe infrastructure - failure; -* a continuously readable stdout not starving stderr, so a stream that is always - ready cannot delay the other until the invocation fails; -* per-stream offsets advancing across more than one frame, with the exit record's - frame count matching the frames actually emitted; -* a root that cannot be removed being reported instead of swallowed, on both a - failed start and a completed invocation, with the next start refused while the - root is still on disk and accepted again once removal succeeds, and a malformed - process exit record being refused while the frame is read; -* a batch that starts with a whole batch of standard output already waiting still - servicing standard error, with the batch staying inside its frame bound; -* a guest process state record with a non-UTF-8 command name still yielding its - flags, so a workload cannot break the barrier by naming itself with arbitrary - bytes. - -Output framing is asserted as a contract rather than a fixed split: per-stream -offsets start at zero and stay contiguous, sequence numbers are contiguous across -the whole series of frames, and the concatenated bytes per stream are exact. - -=== Deliberate limits - -The host tests exercise the process-group scope for the ordinary descendant and -the guest-wide scope only inside a PID namespace, because the guest-wide sweep -must not signal unrelated host processes. In process-group scope the reap is -scoped to the invocation's own process group, so a host test cannot lose an -unrelated child it still needs to observe. Application protocol parsing, workload -assertions, and the run manifest's workload identity remain Phase 3 work, and so -does a recorded QEMU acceptance of this runtime: the checked-in phase 2 evidence -is the host PID-namespace script above. The runtime reports no throughput or -security claim beyond the accepted profile. - -== Phase 3 scenario and passive replay integration - -Phase 3 wires the assembled workload into the run pipeline. `simferret run` gains -an optional `--workload SPECIFICATION`; when it is present the scenario is parsed -as the versioned workload-driven acceptance scenario and the packaged workload, -not the agent, originates every recorded request. The normalized workload -identity is recorded in the run manifest and in a private `workload.lock` -artifact, and replay re-derives it from the raw closure before QEMU starts. - -The host checker (`crates/simferret/src/checker.rs`) owns all application -meaning. It folds the recorded events into a process and stream trace, checks -each invocation's reconstructed stdout and stderr against the exit record's -independently reported totals and digests, matches the ordered response lines to -the recorded input commands, and evaluates five properties: `process_safety`, -`response_integrity`, `controlled_outage`, `restoration`, and -`bounded_recovery`. The guest agent still reports process and byte facts only. - -The acceptance fixture is the checked-in `poc/rfd3-workload/main.c`. It answers -`echo`, reports whether its root already carried a previous invocation's marker, -spawns an escaped `setsid` descendant that retains the output descriptor, fetches -a named fixture file over TFTP from `10.0.2.2`, and exits on end of input. The -same source is compiled once and packaged three ways: - -* a standalone fixed-address static binary workload; -* a local `linux/amd64` OCI image layout carrying the same executable at the - binary profile's canonical install path, so both forms converge on one - canonical tree; and -* a focused dynamically linked OCI layout whose executable, interpreter - (`/lib64/ld-linux-x86-64.so.2`), and `libc.so.6` closure exist only in the - image. - -The seeded workload choice plan adds a process-fault request index alongside the -outage and restoration indices, and requires at least four requests so the fault -is always strictly inside the sequence and distinct from both transitions. - -=== Checked-in evidence command - -[source,shell] ----- -./scripts/rfd3-phase3-acceptance.sh ----- - -For each source form the script records the acceptance scenario, records the -same scenario with a corrupted fixture response, removes the entire live source -directory, passively replays the recording twice, and checks that a -self-consistently changed workload lock, a changed derived cache entry, a missing -raw closure, and a removed closure-referenced raw object are each refused before -QEMU starts. It also requires two fresh-root witnesses per form, and requires the -run directory, the guest image cache, and the workload store to be owner-only. A -representative unprivileged run produced: - -[source,text] ----- -qemu_version=QEMU emulator version 11.1.0 -kernel=/nix/store/s40h0m3746r0l287laa9sxa9345bkykf-linux-6.18.49/bzImage -static_fixture_sha256=582a51e4c5ed835752fa84809a8b5a2f5ecdf49736be7d93d72a6c23d069243f -dynamic_fixture_sha256=37cb51e280ffddd038442c878db111b407261f414ecbbdda3fcc6d025e18f1db -dynamic_interpreter=/lib64/ld-linux-x86-64.so.2 -static_manifest_digest=sha256:3fa49528561cec23ff1f30d929a6362f2240add059f6a197b53073c0c0798493 -dynamic_manifest_digest=sha256:846176de46401217327ea8e25c3268f5ce46a3835b8308ddb91fe2a83cb18ad8 -binary_canonical=bfb6c8c9fe7ee7f612dca4b0dc76695c826ec2970bca968b3a401c21087f8c91 -binary_closure=2ad827acc0e604d1f806ba18a4e0930fddfaf7cb67916b4694d74873f6e93e62 -binary_record_duration_ns=9120231509 -binary_replay_1_duration_ns=15285330573 -binary_replay_2_duration_ns=15489995932 -binary_store_bytes=144410 -binary_initramfs_bytes=2187979 -binary_semantic_outcome=40431f4144c9aca39048191fff665b896b796cd68f3646d76ef6fdceb1be08bb -binary_events=36 -binary_replay_log_bytes=6612322 -oci-static_canonical=bfb6c8c9fe7ee7f612dca4b0dc76695c826ec2970bca968b3a401c21087f8c91 -oci-static_closure=671b85dca94869d0f8e7b8a820bcd3892ea7334883ab5d95b3d4c1fc312751ca -oci-static_record_duration_ns=20045197096 -oci-static_replay_1_duration_ns=27262514510 -oci-static_replay_2_duration_ns=27370961242 -oci-static_store_bytes=156837 -oci-static_initramfs_bytes=2187979 -oci-static_semantic_outcome=40431f4144c9aca39048191fff665b896b796cd68f3646d76ef6fdceb1be08bb -oci-static_events=36 -oci-static_replay_log_bytes=8711357 -oci-dynamic_canonical=445d1445fe4532202a9860803cd6aaeb45e223125a9970a44a6b70cf7e9daf89 -oci-dynamic_closure=65fce5916519c4c9ec6cef0f0abcbe130823d4cbffd7598c11f2d1eee717868d -oci-dynamic_record_duration_ns=16260407970 -oci-dynamic_replay_1_duration_ns=23074207592 -oci-dynamic_replay_2_duration_ns=23194709343 -oci-dynamic_store_bytes=3865319 -oci-dynamic_initramfs_bytes=3308963 -oci-dynamic_semantic_outcome=226712a5057bc1b95e9273b463c44e1ca58b05ff5c383bd63cf908034e4b6f04 -oci-dynamic_events=36 -oci-dynamic_replay_log_bytes=7682064 -intentional_divergence=process_safety and response_integrity failed with CLI status 1 -workload_lock_tamper_error=simferret: the workload lock identity differs from the manifest -derived_template_tamper_error=simferret: derived guest template does not match the raw closure -missing_raw_closure_error=simferret: raw closure raw/closure.json is missing -missing_raw_object_error=simferret: raw object sha256:582a51e4c5ed835752fa84809a8b5a2f5ecdf49736be7d93d72a6c23d069243f is missing -private_artifacts=run directory, guest image cache, and workload store are owner-only -fresh_root_witnesses=state value=fresh root=fresh observed once per invocation ----- - -The standalone binary and static OCI sources converge on one canonical digest -(`bfb6c8c9...`) and one semantic outcome digest (`40431f41...`), and both replay -twice with byte-identical normalized events and assertions. The dynamically -linked OCI source has its own canonical tree (`445d1445...`), executes from the -in-image interpreter and library closure, and replays twice with its own stable -semantic outcome digest. Every replay begins after the form's whole source -directory has been removed, so no live source, registry, daemon, host mount, or -fixture interaction participates. Intentional response corruption makes -`process_safety` and `response_integrity` fail and returns CLI status 1 for both -source forms. Each form also reports the strengthened fresh-root witness twice, -proves its run directory, guest image cache, and store are owner-only, and names -the missing raw evidence in both tamper cases. - -=== Two integration fixes - -Two pre-existing behaviours only became observable once a workload was live, and -both were fixed in this phase: - -* `Runtime::terminate` closed the child's standard input before signalling. A - workload that treats end of input as a clean exit left the process before the - fixed `SIGKILL` landed, so the exit record reported `exited` instead of the - requested termination. The signal is now delivered first and the queued input - is dropped in the same critical section, so the command is unconditional as - documented and no later poll can write to a pipe whose readers are gone. -* The host command writer wrote one byte and waited for one acknowledgement per - byte. That round trip costs roughly 30ms once a workload is live under the - pinned TCG/icount profile, so a 250-byte workload command could not complete - inside the command deadline. The writer now writes bounded 16-byte chunks (the - guest UART FIFO depth) and waits for the same number of acknowledgements, so - the guest still acknowledges every byte it consumes while the round trip is - paid once per chunk. Record duration dropped from a timeout to about 14s and - replay to about 22s. A larger chunk overran the guest serial FIFO and - corrupted the control stream, which is why the chunk is pinned to the FIFO - depth. - -=== Assembly-time overlay compatibility and artifact classification - -The runtime overlay rules moved into assembly: `validate_overlay_compatibility` -refuses a canonical tree with a non-directory entry at or below `/tmp` or -`/dev`, and refuses a launch executable or working directory the overlay -replacement would invalidate. Assembly and replay both apply it, so a template -the runtime would refuse is never published and replay re-derives the same -decision from the raw closure instead of failing at the runtime boundary. - -The run directory and the host-written run artifacts are owner-only (`0700` and -`0600`): they carry the recorded launch environment, the exact workload stream -bytes, and the private replay closure. The shareable failure bundle is a separate -directory and carries bounded protocol metadata, counts, digests, and typed -errors only; a regression test asserts that neither the recorded environment -value nor a recorded workload output line appears anywhere in it. The sanitizer -replaces every private path it knows — the staging directory, the runtime -directory, and the whole runs directory, which holds the workload store, the -guest image cache, and the run artifacts — with a fixed `` label, -so a diagnostic that names one of them cannot carry the operator's own path into -the shareable report. Every representation is covered, because the path can be -relative, QEMU comma-escaped, or Rust debug-escaped, and the replacement only -applies at a path boundary so an unrelated longer name that shares a prefix -survives. The store and cache rejections do not render the path at all: they name -the object with a fixed label, and the record path derives the store and cache -from the canonicalized runs directory. - -=== Adversarial review hardening - -The first adversarial review of the Phase 3 stack found fifteen issues, and every -one of them was addressed in the same phase rather than deferred: - -* *Value-free diagnostics.* Every divergence, envelope, and parser diagnostic now - names the event kind and its non-secret coordinates (invocation, stream, - offsets, byte lengths, digests) instead of formatting whole events, commands, - or environment entries. A divergence or a malformed `NAME=VALUE` entry can no - longer put the recorded launch environment or exact stream bytes into - `failure.json` or the CLI error text. `Event::kind`/`Event::describe` and - `Command::kind`/`Command::describe` are the single source of those - descriptions, and a protocol unit test pins the tag names against the wire form - and asserts that no marker value survives. Parser failures are reduced by - `crates/simferret/src/diagnostics.rs`: a private artifact reports only a - category and a location, and a user-authored specification or scenario reports - only a location as well, because both serde and TOML format the offending value - with escaping a redactor cannot reliably undo. The generic frame readers, the - retained canonical specification, and the surplus-event diagnostic all use the - same reduction, and canaries place the secret in the offending value itself, - including one that embeds the delimiter the parser quotes it with. Semantic - launch validation is value-free too: the user, working directory, executable - argument, digest, and manifest-descriptor diagnostics name the field and the - expected shape rather than the value, the working-directory and executable - paths map the layer-path helper's value-bearing error onto a field-specific - one, and the recorded OCI manifest digest is validated before it can be named. - Record-path canaries assert that neither the CLI text nor the shareable failure - bundle carries a marker placed in those fields, including a traversal path. - Guest-reported free-form strings are not descriptions either: a diverging - `network-configured`, `outage-activated`, `network-restored`, or request event - can carry any bytes in its gateway, peer, rule, or request-identifier field, so - `Event::describe` names the tag, the request phase, the typed error, and the - numeric coordinates only, and the fault-transition diagnostics in - `failure.json` take their peer and rule from the validated network profile the - run configured instead of from the event. The protocol canary places a marker - in each of those fields, and an end-to-end record canary asserts that a rejected - activation's strings appear in neither the CLI text nor the bundle. The store's - raw-closure reader follows the same rule: an unknown object role and an object - that exceeds its policy limit are named by their position, so a tampered - `closure.json` cannot carry a marker into the CLI text or the failure bundle of - a replay that rejects it. Three more semantic rejections follow the same rule: - the overlay collision names the fixed `/tmp` or `/dev` subtree instead of the - colliding entry path, the replay scenario-name comparison names the - disagreement instead of either name, and a repeated raw-closure role names the - object's position. The layer reader is value-free as well: a rejected member - names the layer and member position plus a fixed category, never the path, the - symbolic-link target, the media type, or a raw header field, and the tar - parser's own errors are reduced to fixed context. The replay identity - comparisons and the version check name the differing field only, because a - recorded identity can carry an arbitrary string or a private host path. The - binary and OCI assembly boundaries reduce a source-locator failure to the field - it belongs to and the error's category, because the root's own diagnostics - quote the locator and it is a user-authored specification value. -* *Owner-only image cache.* The `.images` cache is created `0700` with `0600` - entries, and a reused entry is validated before it is opened: its type, - ownership, and mode are checked first and repaired where possible, then it is - hashed through the same `O_NOFOLLOW | O_NONBLOCK` reader the replay inputs use, - so a writer-less FIFO or a device node is rejected instead of blocking the run. -* *Validated asynchronous events.* The driver folds events it does not - synchronously await, so the checker validates them instead: a start, exit, - termination, cleanup, launch failure, or input acknowledgement for an unknown - invocation, an input acknowledgement after the invocation was terminated, a - duplicate start, exit, termination, cleanup, network configuration, activation, - or restoration, a termination after its exit, a cleanup before its exit or - without reaping a process, a configuration that is not the fixed private - profile, and an activation without its prohibition rule are all - stream-structure violations. A launch failure is an alternative outcome to a - start record rather than an event of a running invocation, so it is retained for - an invocation that never started; it may still not repeat, and it may not arrive - after the invocation exited. `process_safety` also requires exactly one - termination record, for the first invocation, which is what the acceptance - profile performs. -* *Complete stream evaluation.* Per-invocation offset, sequence, and input-stream - violations are now evaluated alongside the trace-level ones; sequences must - start at one and stay contiguous; each accepted input must advance the accepted - offset by exactly its byte count and name a distinct later command; an - end-of-input must be unique and last; every response line but the startup line - must have its own accepted command; every invocation must end on a complete - stdout line; and no invocation may write a single stderr byte. The - end-of-input acknowledgement is required rather than merely permitted: the - acceptance contract ends the surviving invocation's input, so its accounting - must show exactly one end of input for the restarted invocation and none for - the terminated one, and a recording that omits it cannot pass. The accounting - also correlates responses with commands: the trace retains each data - acknowledgement's event identifier and the event that carried each response - line's first byte, so a response recorded before the command it answers is a - violation even though the ordered lines and the aggregate counts are unchanged. - The same evidence anchors the fault witnesses: `controlled_outage` and - `bounded_recovery` require the witness's acknowledgement to follow the - activation or restoration, so a response whose bytes were already present before - the transition cannot count once its newline arrives. The witness arithmetic is - lazy, so a witness that precedes its transition fails the property instead of - underflowing, and the accepted input offset is compared through a checked sum, - so a positive byte count can no longer repeat a saturated offset and pass. -* *Process evidence.* The first cleanup barrier must reap at least two processes - (the terminated primary and the escaped descendant) and the escaped-descendant - line must precede the termination request, with termination, exit, and cleanup - ordered by event identifier. -* *Restart recovery bound.* `bounded_recovery` now requires the restarted - invocation to answer its first command within the scenario's liveness bound, so - the first invocation's responses can no longer satisfy the property. -* *Strict response matching.* The driver requires each invocation's *next* - complete line to equal the expected line, and an already-observed failure takes - precedence over a matching line: it stops as soon as the invocation writes to - stderr or its current stdout line exceeds the response bound, because the - pinned fixture writes to stderr only when it is failing and a line over the - bound can never be valid. The same health test gates every process command and - the end-of-input step, so a failure observed by the pre-command drain stops the - drive as well, and the wait for an exit consults the same test before its first - blocking receive, so a failing tail folded by the acknowledgement it awaited - ends the wait instead of becoming a receive error. The over-bound condition is - sticky for the invocation: a line that completes with a newline still fails the - health test, so a known-invalid response cannot become a timeout merely because - its terminator arrived. The exit wait also ends on any complete stdout line the - driver did not consume and on a pending byte: every expected response is - complete and consumed by then, so a further line or even one byte can only be a - response the checker must reject. A wrong - response, a reported application error, or an over-long unfinished line - therefore fails the property through the checker instead of blocking until the - VM deadline. -* *Schedule-free passive replay.* A replayed guest reproduces the recorded - execution, including the input it received, so the host sends nothing. Passive - replay therefore consumes the recorded event stream in order, requires every - event to match byte for byte, requires the stream to end with the agent-stopped - acknowledgement, and lets the checker recompute the report from those events. - It no longer re-decides the command schedule from its own queue timing, so a - recording whose failing response became visible one command later than it would - in a faster replay still replays to the same failing report. -* *Outage bookkeeping.* The driver tracks the administrative outage and restores - the network before an early shutdown, because the agent refuses to stop while - an outage is active. A network acknowledgement also folds the lifecycle events - of a stopped invocation, because the runtime serializes an exit and its cleanup - barrier as separate frames that can arrive after the host has already read the - exit record. The fake guest enforces both the refusal and a separately - delivered barrier, so forgetting either is a test failure rather than a - production-only infrastructure error. -* *Process-command safety.* The driver waits for an invocation's startup line - before its first command, folds every already-queued event before each process - command, and treats a terminal event observed while awaiting a response as an - orderly end. Passive replay can deliver events ahead of the commands that own - them, so a drain parks those events and preserves the exact read order. -* *Envelope and acknowledgement correlation.* Every event's command identifier is - bounded by the last issued command, synchronous acknowledgements must name the - awaited command, every network acknowledgement must carry the values the host - configured rather than only its variant, `input-accepted` contents are - validated against the sent bytes, the shutdown drain accepts only workload - events and requires the agent-stopped acknowledgement to name its command, and - only passive replay may park an event whose command has not been issued yet. -* *Preparation-time bounds.* `payload_bytes` is constrained to the fixture's - hex-encoded token limit (63 bytes) and the serialized start command, start - event, and widest input frames are preflighted in both record and replay, so an - undeliverable launch identity or input fails before QEMU starts. Every - published artifact is hashed through the same bounded reader the replay path - uses, so the recorded event stream, assertion report, workload lock, run - manifest, replay log, and diagnostic logs are each required to fit their - reader's limit before anything is published. -* *Acceptance harness.* The missing-raw case asserts the intended diagnostic - instead of any nonzero exit, and a removed closure-referenced raw object is - covered too. The fresh-root witness check concatenates each invocation's stdout - frames before it splits them into lines, exactly as the host checker - reconstructs the streams, so a line split across frames still counts. Only the - acceptance report, process status, and shareable failure bundles are uploaded - from the Phase 3 diagnostics artifact. -* *Stronger fresh-root witness.* The fixture mutates its own executable's mode in - the immutable workload root, outside the writable overlay, and each invocation - must report `state value=fresh root=fresh`. A reused workload root is therefore - observable even if the overlay alone were recreated. - -=== Phase 3 regression tests - -`crates/simferret/src/checker.rs` unit tests cover a complete structured run and -each individual failure: a reused root reported as `stale` (including a stale -root witness while the `/tmp` marker is fresh), a mismatched response line, a -cleanup barrier that reaped fewer than two processes, a sequence that does not -start at one, a sequence gap, a non-contiguous output offset, a non-contiguous -input offset, a replayed input command identifier, a missing input -acknowledgement, a missing end of input for the restarted invocation, a response -recorded before the input acknowledgement it answers, a witness acknowledged -before the activation or restoration it is measured against, an -unterminated stdout line, a stderr byte, a missing restoration, an outage response that arrives only after -restoration, a restart that answers outside the liveness bound, exit totals that -disagree with the recorded frames, and a typed launch failure that cannot satisfy -a workload property. - -`crates/simferret/src/run.rs` drives the whole pipeline against a deterministic -fake VM that models the pinned fixture's line protocol, so the driver, checker, -manifest, and replay preflight are exercised without QEMU. The tests cover: - -* a workload recording that passes every property, records the workload identity - in the manifest and the lock, publishes the raw and derived closure, and - passively replays twice from the store after the live source is deleted; -* a self-consistently changed lock whose artifact digest is updated in the - manifest, an independently changed launch identity, a missing raw closure with - the derived entry still present, a changed raw object, a changed derived - template, and a changed scenario artifact, each refused before launch; -* an intentionally corrupted fixture response that fails `process_safety` and - `response_integrity`, publishes a complete run, and reproduces the same failing - report on replay with CLI status 1; -* owner-only run directories and artifacts, and a failure bundle that contains - neither the recorded environment value nor a workload output line; -* an application failure inside the outage window, which must restore the network - before the shutdown handshake because the guest refuses to stop while an outage - is active; -* a wrong response line, which must fail the property with the guest stopped - instead of blocking the driver; -* a workload that exits before its first command, whose queued exit must be - observed rather than raced by a process command; -* a duplicated input acknowledgement, which must fail `process_safety` as a - stream-structure violation; -* the preparation-time preflight of an undeliverable launch identity and an - oversized planned input; -* the owner-only guest image cache, including repair of a world-readable entry - and refusal of a non-regular one; and -* a replayed launch-identity divergence, whose error text and shareable failure - bundle must carry no environment value and no workload stream byte; -* a malformed private artifact and a malformed workload specification, whose - diagnostics must not quote the launch environment; -* a late cleanup barrier, a wrong network acknowledgement, a late agent-stopped - acknowledgement, and an event for an unissued command, each of which must be - folded or rejected exactly as the protocol requires; -* a failing application that writes to stderr and stays alive, which must fail - the property instead of exhausting the VM deadline; -* a launch identity at the start-command boundary, which the response-frame - preflight must still reject; -* a writer-less FIFO in the guest image cache, which must be rejected without - blocking; -* an oversized published artifact, which must be refused before publication; -* a malformed canonical specification whose launch field carries the marker, and - a malformed protocol frame whose launch field carries the marker, neither of - which may quote it; and -* an over-bound unfinished stdout line, which must stop the wait instead of - reaching the VM deadline, including when it follows a matching response in a - separate frame; -* a termination for an invocation that already exited, and a duplicated - termination, both of which must fail process safety; and -* a correctly typed but invalid user or working directory, and an OCI entrypoint - whose first argument is not absolute, not in the workload, or escapes it - through a traversal component, none of which may quote the value in the CLI - text or the failure bundle, plus a manifest descriptor selected by a marker - digest; -* an input acknowledgement after an invocation was terminated, and a termination - that arrives after the invocation completed cleanup; -* an over-bound tail that becomes visible only after the end-of-input - acknowledgement, which must still stop the run; and -* a recording whose failing response became visible one command later than a - faster replay would observe it, which must still replay to the same report; -* a failing tail folded by the end-of-input acknowledgement, on stderr and as an - over-bound unfinished stdout line, which must stop the run and publish a - failing report instead of becoming a receive error; -* a workload that exits cleanly after its last response and before its input can - be ended, whose recording must fail `response_integrity`; and -* a rejected outage activation whose peer and rule carry a marker, which must - leave the error text and the whole failure bundle free of it while the report - still names the validated profile's peer and rule; -* a workload that answers the state command during the preceding echo command, - which the driver accepts because the line is already buffered and only the - checker can reject; and -* a tampered raw closure whose role and digest carry a marker, neither of which - may appear in the CLI text or the failure bundle; and -* a failed start for each invocation, which must publish a failing report with a - typed launch failure instead of waiting for a startup line that never arrives; -* a complete short stdout line the driver never asked for, folded by the - end-of-input acknowledgement, which must end the exit wait; and -* a tampered manifest scenario name, which must not appear in the CLI text or the - failure bundle; -* a pending stdout byte folded by the end-of-input acknowledgement, before and - after it, which must end the exit wait; and -* a replay whose recorded version or VM identity differs, whose diagnostic must - name the field without either value; -* a missing binary path and a missing OCI layout, whose locator must not appear - in the CLI text or the failure bundle; and -* a recording whose output sequence is the maximum value, whose next frame must - report the structural violation instead of overflowing the comparison; -* an outage witness and a recovery witness that both precede their transition, - which must fail the property instead of underflowing; -* a trace whose input acknowledgements repeat a saturated offset, which must fail - process safety; and -* a record against a marked runs directory whose store is not owner-only, whose - retained report must name a fixed label; and -* a sanitizer case covering the plain, QEMU-escaped, and debug-escaped - representations of a private path and a longer unrelated name that shares its - prefix. - -`crates/simferret/tests/rfd3_phase3.rs` pins the public contract: the strict -versioned workload scenario, the seeded choice plan and its bounds, the request -phase to expected-response mapping, and that an incomplete or structurally -invalid run cannot satisfy any property. - -`crates/simferret/src/workload/mod.rs` unit tests cover overlay collisions at and -below `/tmp` and `/dev` and the launch paths the overlay invalidates. - -=== Deliberate limits - -The host checker understands the checked-in acceptance fixture's line protocol -only; general protocol adapters and automatic property inference remain excluded, -as the RFD requires. The dynamically linked fixture packages the glibc -interpreter and `libc.so.6` from the pinned development environment, which is -what makes its closure reproducible in this repository; standalone dynamic -binaries remain unsupported. The workload store is shared by the runs in one runs -directory and refuses a second, different raw closure, so each source form uses -its own runs directory. The chunked command write is a host-side transport -change: the wire format, the guest's per-byte acknowledgement, and the versioned -protocol are unchanged. - -The workload driver folds every already-queued event before it issues a process -command, and it treats a terminal event observed while awaiting a response as an -orderly end, so an invocation that has already exited is reported as an -application failure rather than raced. The residual window is the interval -between that drain and the guest reading the command: if the invocation is -released inside it, the guest answers with the exit record and the protocol -classifies the acknowledgement mismatch as an infrastructure error. Closing that -window completely would require a typed rejection event for a command that races -a process exit, which is a protocol change and is left to a later increment. - -== Phase 4 acceptance and evidence - -Phase 4 turns the Phase 1 to Phase 3 behaviour into checked-in acceptance -evidence and closes the last open RFD acceptance criterion: canonical metadata -and layer semantics must be observed correctly inside the workload root, not only -in the host staging tree. - -=== Acceptance automation - -`.github/workflows/ci.yml` runs, on GitHub-hosted x86-64 Ubuntu without a -container daemon: - -* `scripts/rfd3-phase4-acceptance.sh`, which runs the Phase 3 - record-and-two-replay demonstration for the standalone binary, the converging - static OCI layout, and the dynamically linked OCI layout, then adds the Phase 4 - measurements and checks; -* `scripts/rfd3-phase4-checks-test.sh`, which regression-tests the shared - evidence checks against leaked, malformed, and unreadable artifacts; and -* `scripts/rfd3-phase4-runtime.sh`, which runs the guest-visible conformance - suite as PID 1 in a private PID namespace. The test binary is built - unprivileged, and only that namespace run uses the runner's passwordless - `sudo`. - -Both commands are unprivileged in the sense the RFD requires: no registry, -container daemon, host mount, TAP device, or KVM is used, and the only elevated -operation is the chroot, setuid, and mknod the guest runtime itself performs. -`scripts/rfd3-phase4-acceptance.sh` records the conformance result when it is -already root and otherwise names the checked-in runtime command, so a self-hosted -runner can run one command or the other. - -=== Guest-visible OCI conformance - -`crates/simferret/tests/rfd3_phase4.rs` builds one local `linux/amd64` OCI layout -with a base and an upper layer. Each layer mechanism owns its own subtree, -because opacity hides every lower child of its directory: the upper layer -legally replaces `replace/keep`, whiteouts `hide/removed` while `hide/kept` -survives, marks `opaque` opaque so its lower children disappear while the -same-layer `opaque/added` survives, and adds a symbolic link; the base layer -carries a non-default directory mode, owner, and timestamp. -`each_layer_mechanism_is_independently_load_bearing` assembles a baseline and -three variants that each omit exactly one mechanism, and requires the -lower-layer entry that mechanism should have affected to reappear with its own -bytes, mode, owner, and timestamp, so no mechanism can be masked by another. - -`template_encoding_preserves_oci_conformance_metadata` decodes the encoded CPIO -template and pins every header, so a whiteout or opaque marker can never appear -in the guest image. `canonical_metadata_survives_cpio_encoding_and_is_visible_in_the_guest` -then extracts that template exactly as the guest initramfs does, materializes it -through the real runtime, and runs the pinned static BusyBox workload as the -normalized nonzero user. The workload reports what it sees inside its root: - -[source,text] ----- -root 755 0 0 0 -bin 755 0 0 0 -busybox 755 0 0 0 -replace 751 2000 2000 1700000003 -keep 640 1001 1001 1700000008 upper -kept 644 1200 1200 1700000005 safe -added 644 1300 1300 1700000006 added -link replace/keep -linkmode 777 1700000004 -removed=absent -lower=absent -nested=absent ----- - -Every value matches the canonical view, so modes, owners, modification times, -symbolic links, legal replacement, whiteout, and opacity survive CPIO encoding -and are observed inside the workload root. The guest-visible check needs root to -change root and drop credentials, and a private PID namespace for the -guest-wide cleanup barrier, so it returns early without root; the unprivileged -`the_conformance_workload_can_read_every_path_it_reports` test decides the same -permissions the runtime grants the workload, and fails on a fixture the guest -run could not read. The guest-visible check is the checked-in -`scripts/rfd3-phase4-runtime.sh` command and the CI job runs it. - -=== Ambient input and artifact classification - -`ambient_host_environment_never_enters_the_assembled_workload` asserts the launch -environment is exactly the specification's and then assembles the same -specification in a child process that carries a distinctive canary variable, -requiring neither the canary's name nor its value to reach any retained byte. -`an_unrelated_host_file_never_enters_the_assembled_workload` places an unrelated -file beside the binary source and inside an OCI layout directory, assembles each -form twice, and requires both assemblies to agree on the closure, canonical -tree, and template identities, on every retained raw-object digest, and on the -absence of the unrelated path and content. -`a_host_source_path_never_enters_the_retained_closure` walks the whole store, -including the derived cache entry's lock, tree, and encoded template, and -requires the host source path to stay out of every retained byte. - -The unprivileged acceptance run repeats the ambient check with a distinctive -canary value and requires the ambient canary value and the host output path to -stay out of the raw closure and derived lock, while the recorded launch -environment is exactly `["MODE=acceptance"]`. It also requires the run -directory, the guest image cache, the workload store, and every host-written run -artifact to be owner-only, and it records its own canary workload so the -classification check has a launch value and per-run stream tokens that cannot -occur in a shareable artifact by coincidence. Every failure bundle the Phase 3 -demonstration and the canary recording published — including the ones a -tampered copy of a run directory published, and the canary recording's own -bundle, which must be among them — must carry exactly the published report and -diagnostics fields and optional sanitized log tails, and must contain none of -those canaries in plain text or in the hex encoding the event stream uses. The -check rejects an unreadable, linked, or special entry instead of skipping it, so -it never certifies a tree it did not read. The checks themselves are -fail-closed and regression-tested by `scripts/rfd3-phase4-checks-test.sh`, which -rejects a leaked canary in either encoding, an unexpected file or nested field, -a missing or untyped report, an unreadable bundle directory, a recording -without stdout, and a failed measurement producer. The run-level -`private_run_artifacts_are_owner_only_and_failures_exclude_workload_data` unit -test remains the focused regression. - -=== Coverage map - -Every RFD identity class and adversarial case is covered before QEMU starts. The -guest-visible metadata case is listed last because it runs the real runtime -instead of a host-only check. The checked-in tests are: - -[cols="1,2",options="header"] -|=== -| Required case | Test - -| Specification identity | `a_retained_specification_with_a_reserved_owner_is_rejected_on_replay`, - `a_retained_specification_with_a_moved_install_path_is_rejected_on_replay` -| Standalone executable | `tampered_raw_or_derived_content_is_rejected` (`raw-executable`), - `replay_rejects_every_independently_changed_workload_identity` (raw object) -| Manifest, config, stored layer, DiffID | `a_changed_manifest_and_layer_under_the_old_digest_is_rejected`, - `a_self_consistent_config_change_is_rejected_by_relationship_checks`, - `corrupt_or_missing_selected_blobs_are_rejected`, - `unsupported_oci_constructs_are_rejected_before_publication` -| Normalized filesystem | `tampered_raw_or_derived_content_is_rejected` (`derived-tree`, - `derived-template`), the Phase 3 acceptance `tampered-template` case -| Launch arguments, environment, working directory, credentials | - `every_launch_identity_class_changes_the_closure` -| Descriptor selection, platform, ambiguity, remote content | - `descriptor_selection_rejects_ambiguous_platform_less_and_remote_content`, - `unrelated_index_entries_and_blobs_are_ignored` -| Layer archive, per-layer duplicate, whiteout order, opacity, links | - `duplicate_paths_in_one_layer_are_rejected`, - `layer_semantics_are_order_independent_and_legally_replace_lower_entries`, - `each_layer_mechanism_is_independently_load_bearing`, - `root_level_opacity_keeps_only_upper_layer_additions`, - `an_opaque_marker_may_not_traverse_a_lower_symlink`, - `additions_may_not_traverse_a_lower_non_directory`, - `symlink_targets_are_validated_when_read` -| Paths, file types, hard links, expansion, oversize | - `unsupported_oci_constructs_are_rejected_before_publication`, - `oversized_inputs_are_rejected_by_their_bounds`, - `an_expanded_layer_beyond_the_limit_is_rejected` -| Immutable read, source mutation, special files | - `a_self_contained_store_survives_source_mutation`, - `a_symlinked_layout_locator_is_rejected`, `a_fifo_specification_does_not_block`, - `a_special_file_in_the_store_is_rejected` -| Raw and derived cache | `missing_raw_content_fails_even_with_a_valid_derived_entry`, - `a_store_reuses_identical_content_and_rejects_a_different_closure`, - `a_reused_store_path_must_already_be_owner_only`, - `a_failed_derived_publication_leaves_no_closure` -| Binary profile rejections | `unsupported_binary_inputs_are_rejected`, - `a_relocated_binary_is_refused_with_a_profile_diagnostic`, - `the_same_relocated_executable_is_accepted_from_an_oci_source`, - `elf_address_space_boundaries_are_enforced_exactly` -| Runtime rejections | the Phase 2 suite: privileged credentials, forbidden - descriptors, stale roots, malformed input offsets, output overflow, and an - escaped descendant retaining a pipe -| Replay rejections | `replay_rejects_every_independently_changed_workload_identity`, - `a_workload_replay_divergence_never_leaks_the_launch_environment` -| Guest-visible metadata and input exclusion | - `canonical_metadata_survives_cpio_encoding_and_is_visible_in_the_guest`, - `template_encoding_preserves_oci_conformance_metadata`, - `the_conformance_workload_can_read_every_path_it_reports`, - `each_layer_mechanism_is_independently_load_bearing`, - `ambient_host_environment_never_enters_the_assembled_workload`, - `an_unrelated_host_file_never_enters_the_assembled_workload`, - `a_host_source_path_never_enters_the_retained_closure` -|=== - -=== Measurements - -The checked-in acceptance command is: - -[source,shell] ----- -.agents/dev ./scripts/rfd3-phase4-acceptance.sh ----- - -A representative unprivileged run produced: - -[source,text] ----- -qemu_version=QEMU emulator version 11.1.0 -kernel=/nix/store/s40h0m3746r0l287laa9sxa9345bkykf-linux-6.18.49/bzImage -phase3_duration_ns=252719240552 -assembly_duration_ns=20518347 -assembly_canonical=bfb6c8c9fe7ee7f612dca4b0dc76695c826ec2970bca968b3a401c21087f8c91 -assembly_closure=2ad827acc0e604d1f806ba18a4e0930fddfaf7cb67916b4694d74873f6e93e62 -assembly_entries=3 -assembly_expanded_bytes=70912 -assembly_raw_objects=2 -assembly_store_bytes=144410 -assembly_template_bytes=71424 -ambient_identity_unchanged=bfb6c8c9fe7ee7f612dca4b0dc76695c826ec2970bca968b3a401c21087f8c91 -shareable_bundles=13 -shareable_canaries=23 -shareable_excludes_environment_and_streams=yes -classification_canary_recorded=yes -private_artifacts=run directory, guest image cache, workload store, and run artifacts are owner-only -guest_visible_conformance=not run here; run scripts/rfd3-phase4-runtime.sh as root -binary_canonical=bfb6c8c9fe7ee7f612dca4b0dc76695c826ec2970bca968b3a401c21087f8c91 -binary_workload_stdout_bytes=551 -binary_workload_stderr_bytes=0 -binary_traffic_attempted=6 -binary_traffic_succeeded=4 -binary_traffic_unavailable=2 -oci-static_canonical=bfb6c8c9fe7ee7f612dca4b0dc76695c826ec2970bca968b3a401c21087f8c91 -oci-static_workload_stdout_bytes=551 -oci-static_workload_stderr_bytes=0 -oci-static_traffic_attempted=6 -oci-static_traffic_succeeded=4 -oci-static_traffic_unavailable=2 -oci-dynamic_canonical=445d1445fe4532202a9860803cd6aaeb45e223125a9970a44a6b70cf7e9daf89 -oci-dynamic_workload_stdout_bytes=551 -oci-dynamic_workload_stderr_bytes=0 -oci-dynamic_traffic_attempted=6 -oci-dynamic_traffic_succeeded=4 -oci-dynamic_traffic_unavailable=2 ----- - -Assembly of the 70912-byte static fixture takes milliseconds and produces a -144410-byte store and a 71424-byte template; the whole Phase 3 demonstration -records three source forms, records three intentionally corrupt runs, replays -each successful recording twice, and runs every tamper case in about 253s, and -the classification check adds one canary recording and one rejected replay. Each -form's workload emits 551 bytes on stdout and no stderr, and originates six -TFTP attempts: four succeed, and the two inside the bounded outage return the -typed administrative rejection. The Phase 3 evidence above records the per-form -record and replay durations, initramfs sizes, replay-log growth, semantic -outcome digests, and store sizes; the phase 4 run adds assembly cost, output -volume, workload traffic volume, and the classification check, which inspected -13 published failure bundles against 23 launch-environment and per-run stream -canaries. Every observed divergence remains the single intentional corruption, -which fails `process_safety` and `response_integrity` with CLI status 1 for both -source forms. - -=== Supported profiles, self-hosted requirements, and invocations - -The supported inputs are the RFD's bounded set: a standalone fixed-address, -little-endian x86-64 Linux ELF, or one direct `linux/amd64` manifest selected by -digest from a local OCI image layout with plain or gzip layers and OCI whiteout -and opaque-directory semantics. Relocated (static PIE) binaries, standalone -dynamic binaries, device nodes, sockets, FIFOs, setuid and setgid modes, hard -links, sparse files, ACLs, unsupported extended attributes, descriptor URLs, and -embedded descriptor data are rejected before QEMU starts. No registry, container -daemon, host mount, or network access participates. `README.md` carries the same -profile statement and the exact invocations. - -The unprivileged acceptance command needs x86-64 Linux, the pinned Nix -environment (QEMU, kernel, the static and dynamic C compilers, `readelf`, -`python3`, `jq`), and no elevated privilege. The guest-visible conformance -command additionally needs root for the guest runtime's chroot, setuid, and -mknod, plus a PID namespace for the guest-wide cleanup barrier. GitHub-hosted -Ubuntu provides passwordless `sudo`; a self-hosted runner needs the same or an -equivalent unprivileged path. - -=== Next RFD decision - -The RFD's follow-up decision is to choose between checkpoint branching, -OCI-profile expansion, and serial control optimization. The Phase 3 and Phase 4 -evidence point to checkpoint branching: - -* Assembly and replay are reliable across three source forms and two replays per - form, with byte-identical normalized events and matching semantic outcome - digests, so the packaging boundary is stable enough to build on. -* The packaged workload is small (144 KB store, 2.2 MB initramfs for the static - forms) and records in about 10 to 20 seconds, so checkpoint size and restore - cost can be measured on a representative filesystem and process rather than the - built-in fixture. -* No OCI compatibility failure was observed in the accepted profile; the - bounded layer semantics were sufficient for the static and dynamic fixtures, - so profile expansion has no concrete mismatch to justify it. -* Record and replay cost is dominated by the QEMU run itself, not the serial - control protocol; the chunked writer already removed the one observed - transport bottleneck, so control optimization has no measured target. - -The next increment should therefore measure checkpoint-tree size, restore cost, -and branching throughput on this packaged workload. OCI-profile expansion and -serial control optimization move earlier only if checkpoint evidence shows they -block it. - -=== Deliberate limits - -The guest-visible conformance workload is the pinned static BusyBox and reports -metadata through its own `stat`, `readlink`, and existence tests; it is a -repository fixture, not a general OCI conformance suite. The check extracts the -encoded template exactly as the guest initramfs does and runs the real runtime, -but it is a host-run guest test rather than a full QEMU boot, so it does not -re-verify the kernel's own initramfs extraction beyond the Phase 3 acceptance -boots. The identity and adversarial coverage map names the checked-in tests -rather than generating one test per case, so a future change that removes a test -must also update this evidence. diff --git a/rfd/0003/IMPLEMENTATION.adoc b/rfd/0003/IMPLEMENTATION.adoc deleted file mode 100644 index 3c85c1d..0000000 --- a/rfd/0003/IMPLEMENTATION.adoc +++ /dev/null @@ -1,424 +0,0 @@ -= RFD 0003 implementation checklist - -Implements link:README.adoc[RFD 3: Reproducible workload packaging]. - -== Objective - -Accept one standalone binary or local OCI image layout, normalize it into one -content-addressed guest workload, and preserve exact passive replay. - -== Entry gate - -Status: DONE. - -* [x] Complete RFD 2 and review its replay fidelity, runtime, failure bundles, - network constraints, and next-increment recommendation. -* [x] Select one auditable static workload fixture that can exercise process - supervision and traffic through the existing network boundary. -* [x] Capture representative standalone and minimal OCI artifacts before fixing - parser, expansion, and cache limits. - -== Phase 0 — Workload and OCI spikes - -Status: DONE. - -* [x] Boot and supervise an external static x86-64 Linux executable that is not - the SimFerret agent. -* [x] Build a minimal local OCI image layout containing the same executable and - launch it without a registry or container daemon. -* [x] Build a second minimal OCI layout whose executable is dynamically linked - and whose interpreter and shared-library closure exist only in the image. -* [x] Select existing Rust parsing, archive, compression, and safe-filesystem - primitives before writing custom format handling. -* [x] Apply representative base and upper layers twice and verify a stable - normalized filesystem digest, including metadata, replacement, whiteout, and - opaque-directory cases. -* [x] Prove that record mode can remove all live workload sources before QEMU - starts and that replay needs only the retained raw and derived - content-addressed closure. -* [x] Record source sizes, expanded sizes, assembly duration, initramfs growth, - unsupported OCI constructs, and all observed nondeterminism. - -== Phase 1 — Typed specification and canonical assembler - -Status: DONE. - -* [x] Add a strict versioned workload specification with tagged binary and OCI - source variants, explicit non-root credentials, and a shared launch identity. -* [x] Validate static ELF architecture and derive binary content identity from - opened bytes rather than caller claims. -* [x] Read binary and OCI source objects as bounded regular files beneath an - opened source root, reject links and special files, and use immutable copied - bytes for verification and assembly. -* [x] Select only the requested direct `linux/amd64` descriptor, require absent - variant and OS extensions, ignore unrelated entries, and validate its manifest, - config, ordered stored layers, and uncompressed DiffIDs independently. -* [x] Normalize OCI launch fields exactly, including Entrypoint/Cmd composition, - environment, working directory, non-root numeric credentials, and rejected - volume, stop-signal, group, and privileged semantics. -* [x] Implement bounded, beneath-root layer application with per-layer duplicate - detection, legal lower-layer replacement, order-independent whiteout and - opaque-directory semantics, and rejection of every hard link and unsupported - file type. -* [x] Produce a canonical filesystem identity covering every guest-visible path, - type, byte, link target, mode, owner, group, and timestamp decision. -* [x] Retain the canonical specification and complete binary or OCI selection - evidence, manifest, config, stored layers, and DiffID relationships as a raw - content-addressed replay closure. -* [x] Build and verify derived canonical-tree and guest-template cache entries - that name the complete raw closure through atomic private staging. -* [x] Reject concurrent publication conflicts, corrupted cache entries, source - mutation, missing raw evidence, path traversal, unsafe links, expansion - limits, and partial output. - -== Phase 2 — Guest process runtime - -Status: DONE. - -* [x] Assemble binary and OCI workloads below the same reserved initramfs root - while keeping the PID-1 agent and tools outside it. -* [x] Materialize a fresh writable root from an immutable template for every - invocation, synthesize deterministic `/tmp`, `/dev/null`, and `/dev/zero` - metadata, and reject overlay collisions. -* [x] In the child only, connect standard pipes, close inherited descriptors, - chroot and change directory, clear groups, set `no_new_privs`, drop to the - normalized nonzero GID and UID, and exec without a shell. -* [x] Add generic versioned start, stdin-write, stdin-EOF, and fixed-SIGKILL - termination commands with stable invocation identifiers and contiguous input - offsets. -* [x] Emit bounded live stdout and stderr frames with invocation, stream offset, - cross-stream sequence, exact bytes, and independently checked final totals and - digests; make overflow or transport failure explicit and fatal. -* [x] Treat every non-agent guest process as invocation membership, kill and - reap through a process-table-and-pipe-EOF cleanup barrier, and refuse restart - before cleanup completes. -* [x] Prove an escaped descendant that retains an output descriptor is killed and - reaped by the guest-wide barrier, and that a first invocation's root mutations - are absent from a second invocation. Whether those facts are enough to satisfy a - later recovery assertion is evaluated with the Phase 3 scenario checker. -* [x] Keep application protocol interpretation and assertions in the host - scenario checker; limit the guest agent to generic process and byte facts. - -== Phase 3 — Scenario and passive replay integration - -Status: DONE. - -* [x] Run the same acceptance fixture from standalone binary and OCI sources - through the shared guest runtime. -* [x] Run the focused dynamically linked OCI fixture from its in-image loader and - library closure and passively replay it. -* [x] Materialize a process termination and restart in the seeded choice plan and - evaluate ordered process safety, cleanup, fresh-root, and recovery properties. -* [x] Drive the live workload exclusively through recorded input commands and - derive response-integrity assertions from ordered output frames in the host - checker before process exit. -* [x] Make workload-originated application traffic traverse the RFD 2 NIC and - observe the bounded peer-specific outage and restoration. -* [x] Record each source form and passively replay it twice without live source, - registry, daemon, host mount, or fixture interaction. -* [x] Compare normalized events, assertions, workload-output identities, and - semantic outcome digests on every replay. -* [x] Reject independently changed workload, launch, cache, scenario, and - network identities before QEMU starts. -* [x] Require raw source evidence on replay even when a valid derived cache entry - exists, and recheck selection and stored-layer-to-DiffID relationships before - reusing that entry. -* [x] Preserve intentional output corruption as a failing safety assertion and - nonzero CLI result for both source forms. -* [x] Enforce runtime overlay compatibility during assembly and replay, so a - package entry that collides with the overlay, or a launch path that overlay - replacement invalidates, is refused before a template is published instead of - at the runtime boundary. -* [x] Separate owner-only replay closure and optional bounded output bytes from - default shareable failure metadata, which contains no environment values or - stream bytes. The Phase 1 store already publishes owner-only objects, but the - run-level classification belongs with the run manifest, which this phase owns. -* [x] Harden the phase against the first adversarial review of the stack, with a - regression test for each finding: -** [x] Make every divergence, envelope, and parser diagnostic value-free, so a - shareable failure report names the event kind and its coordinates without the - recorded launch environment or exact stream bytes. -** [x] Publish the guest image cache owner-only (0700 directory, 0600 entries), - repair a reused entry's mode, and refuse a non-regular entry. -** [x] Evaluate per-invocation stream violations, require sequences to start at - one and stay contiguous, require accepted inputs to advance by their byte - count as distinct later commands, and require complete stdout lines and no - stderr bytes at exit. -** [x] Require the first cleanup barrier to reap the escaped descendant as well - as the primary, and order termination, exit, cleanup, and the escaped line. -** [x] Bound the restarted invocation's first answer with the scenario's - liveness bound so the first invocation cannot satisfy recovery. -** [x] Match each invocation's next complete response line strictly, so a wrong - response fails the property instead of blocking until the VM deadline. -** [x] Track the administrative outage in the driver and restore the network - before an early shutdown, and make the fake guest enforce the agent's refusal. -** [x] Wait for the startup line before the first command, drain queued events - before every process command, and treat a terminal event observed while - awaiting a response as an orderly end. -** [x] Bound every command identifier by the last issued command, require - synchronous acknowledgements to name the awaited command, validate - input-accepted contents, and restrict the shutdown drain to workload events. -** [x] Constrain `payload_bytes` to the fixture's hex-encoded token limit and - preflight the serialized start and input frames in record and replay. -** [x] Enforce the replay artifact budget on the recorded event stream before - publication. -** [x] Assert the intended missing-raw diagnostics and cover a removed - closure-referenced raw object in the acceptance script. -** [x] Strengthen the fresh-root witness so the fixture also mutates its own - executable's mode in the immutable workload root and each invocation reports - `state value=fresh root=fresh`. -** [x] Upload only the acceptance report, process status, and shareable failure - bundles from the Phase 3 diagnostics artifact. -* [x] Harden the phase against the second adversarial review, which rechecked the - first round and found four fixes incomplete and three new defects: -** [x] Reduce every parser failure that can reach a diagnostic to a value-free - form, including TOML type errors and surplus guest frames, and cover both a - malformed specification and a malformed private artifact with canaries. -** [x] Fold the lifecycle events of a stopped invocation while awaiting a network - acknowledgement, because the runtime serializes an exit and its cleanup - barrier as separate frames. -** [x] Correlate network acknowledgements with the values the host configured, - require the agent-stopped acknowledgement to name its command, park - future-command events only in passive replay, and require the checker to - account for every accepted input command and the end-of-input state. -** [x] Preflight the launch-bearing response frame as well as the command, and - enforce the replay budget on the workload lock and run manifest. -** [x] Validate a reused cache entry before opening it, so a non-regular entry is - rejected instead of blocking the hash. -** [x] End the wait for a response line as soon as the invocation writes to - stderr, so a failing application that stays alive fails its property instead - of exhausting the VM deadline. -** [x] Reconstruct each invocation's stdout before counting fresh-root witnesses - in the acceptance harness, so a line split across frames still counts. -* [x] Harden the phase against the third adversarial review, which found the - confidentiality fix bypassable and three further defects: -** [x] Reduce every parser failure to a location only, including the generic - frame readers, the retained canonical specification, and the TOML - specification and scenario parsers, and add canaries whose secret is the - offending value itself, including one that embeds the parser's delimiter. -** [x] Validate the asynchronous lifecycle and network events the driver folds - without an expectation: unknown invocations, duplicate starts, exits, - cleanups, configurations, activations, and restorations, a cleanup before its - exit or without a reap, a configuration outside the fixed profile, and an - activation without its prohibition rule. -** [x] Bound every published artifact with the same reader the replay path uses, - so an oversized replay log or diagnostic log cannot be published and then - rejected on replay. -** [x] Stop the wait for a response line once its current stdout line exceeds the - response bound, so an over-long unfinished line fails its property instead of - exhausting the VM deadline. -** [x] Require the acceptance harness to observe one fresh-root witness in each - of the two invocations, counting only newline-completed lines. -* [x] Harden the phase against the fourth adversarial review: -** [x] Make semantic launch validation value-free as well, so the user, working - directory, executable argument, and digest diagnostics name the field and the - expected shape, and add record-path canaries that assert both the CLI text and - the shareable failure bundle. -** [x] Reject a second termination record and a termination for an invocation - that has already exited, and require exactly one termination record for the - acceptance profile. -** [x] Give an already-observed response failure precedence over a matching line, - and gate every process command and the end-of-input step on the same health - test, so an over-long unfinished tail stops the drive instead of reaching the - VM deadline. -* [x] Harden the phase against the fifth adversarial review: -** [x] Map the layer-path helper's value-bearing error onto field-specific - diagnostics for the working directory and the executable argument, validate - the recorded OCI manifest digest before it can be named, and extend the - canaries with a traversal path and a missing manifest descriptor. -** [x] Reject an input acknowledgement for an invocation that has already been - terminated, and reject a termination that arrives after the invocation - completed cleanup. -** [x] Make the wait for an exit interruptible by an output frame that fails the - response health test, so a tail observed after the end-of-input - acknowledgement cannot run to the VM deadline. -** [x] Stop re-deciding the command schedule during passive replay: a replay now - consumes and compares the recorded event stream in order and lets the checker - recompute the report, so a recording that observed a failing response one - command later than a faster replay still replays to the same report. -* [x] Harden the phase against the sixth adversarial review, which confirmed the - first, second, and fourth fifth-round fixes and found the third incomplete plus - three new defects: -** [x] Consult the invocation's health before the wait for an exit performs its - first blocking receive, so a failing tail folded by the acknowledgement it - awaited ends the wait instead of becoming a receive error. -** [x] Require the recorded end of input instead of merely permitting it: the - terminated invocation must acknowledge none and the restarted invocation - exactly one, so a recording whose workload stopped on its own after its last - response cannot pass every property. -** [x] Keep guest-reported free-form strings out of shareable output: event - descriptions name the tag, the request phase, the typed error, and the - numeric coordinates only, and the fault-transition diagnostics take their - peer and rule from the validated network profile rather than from the event - the driver observed before validating it. -** [x] Add regression tests for each fix: a stderr and an over-bound tail folded - by the end-of-input acknowledgement, a deletion-based checker case and a - fake-guest run for the missing end of input, an extended protocol canary for - the four guest-reported string fields, and an end-to-end record canary that - scans both the CLI text and the failure bundle for a rejected activation's - marker. -* [x] Harden the phase against the seventh adversarial review, which confirmed all - three sixth-round fixes and found three further defects: -** [x] Correlate responses with the commands they answer: the trace retains each - data acknowledgement's event identifier and the event that carried each - response line's first byte, and response integrity requires every response to - begin after its acknowledgement, so a response emitted before the command it - answers cannot pass on ordered lines and matching aggregate counts alone. -** [x] Make the over-bound response condition sticky: completing an oversized - line with a newline no longer clears the driver's health test, so a - known-invalid response cannot become a receive timeout instead of a failing - report. -** [x] Name raw-closure objects by position instead of by value, so a tampered - `closure.json` cannot carry an unknown role or an unvalidated digest into the - CLI text or the failure bundle of the replay that rejects it. -** [x] Add regression tests for each fix: a checker case that moves a response - before its acknowledgement, a fake-guest run that answers the state command - during the preceding echo command, a completed oversized line and a split - oversized line in the end-of-input regression, and a replay canary that - tampers a raw-closure role and digest independently. -* [x] Harden the phase against the eighth adversarial review, which confirmed all - three seventh-round fixes and found four further defects: -** [x] Retain a launch failure for an invocation that never started: an - unsuccessful start reports only the typed failure, so requiring a start record - discarded it and left the driver waiting for a startup line that could never - arrive. A failure may still not repeat or arrive after an exit. -** [x] End the exit wait on any complete stdout line the driver did not consume, - because every expected line has already been consumed by then, so a short - unexpected tail cannot become a receive timeout. -** [x] Make three more semantic diagnostics value-free: the overlay collision - names the fixed `/tmp` or `/dev` subtree, the replay scenario-name comparison - names the disagreement, and a repeated raw-closure role names the object's - position. -** [x] Require a fault witness's acknowledgement to follow the activation or - restoration it is measured against, so a response whose bytes were already - present before the transition cannot satisfy `controlled_outage` or - `bounded_recovery` once its newline arrives. -** [x] Add regression tests for each fix: a fake-guest failed start for each - invocation, a complete short extra stdout line in the end-of-input - regression, overlay and scenario-name canaries, a duplicate-role variant in - the raw-closure canary, and checker cases that move each witness's - acknowledgement before its transition. -* [x] Harden the phase against the ninth adversarial review, which confirmed all - four eighth-round fixes, found two further defects, and ruled the layer - diagnostics in scope: -** [x] End the exit wait on a pending stdout byte as well: every expected - response is complete and consumed by the time the driver waits for an exit, - so a single byte cannot become a valid response, and a workload that emitted - one and then stayed silent must not block until the VM deadline. -** [x] Name a differing replay identity field without its values, and stop - quoting the recorded version in the version diagnostic, because a recorded - identity can carry an arbitrary string or a private host path. -** [x] Make the layer reader value-free: every layer rejection names the layer - and member position plus a fixed category instead of the member path, the - symbolic-link target, the media type, or a raw numeric header field; the - forwarded tar parser errors are reduced to fixed context; and the path, - symbolic-link, overlay, marker, and traversal helpers name the rule they - enforce. -** [x] Add regression tests for each fix: pending-byte variants in the - end-of-input regression, identity and version value-freedom assertions in the - VM tests, and a layer canary that presents rejected raw headers and - tree-level collisions and asserts that a marker in the artifact appears in no - diagnostic. -* [x] Harden the phase against the tenth adversarial review, which confirmed all - three ninth-round items and found two further defects: -** [x] Reduce a source-locator failure at the binary and OCI assembly boundaries - to the field it belongs to and the error's category, because the root's own - diagnostics quote the locator and it is a user-authored specification value - that reaches the shareable bundle. -** [x] Compare the next output sequence with a checked addition: the trace - retains a rejected sequence, so a recording whose sequence was the maximum - value panicked in an overflow-checked build instead of reporting the - structural violation. -** [x] Add regression tests for each fix: a record-path canary for a missing - binary path and a missing OCI layout, and a checker case that folds a maximal - sequence followed by another frame. -* [x] Harden the phase against the eleventh adversarial review, which confirmed - both tenth-round fixes and found three further defects: -** [x] Make the witness arithmetic lazy: the outage, recovery, and restart - witnesses built their reported distance with `then_some`, so the subtraction - ran even when the predicate was false and a witness that preceded its - transition underflowed instead of failing the property. -** [x] Compare the accepted input offset through a checked sum: the saturating - sum accepted an acknowledgement of the maximum byte count at the maximum - offset, after which every later acknowledgement could repeat the same offset - without advancing and still pass every property. -** [x] Replace the whole runs directory in a retained report: the sanitizer - covered only the staging and runtime directories, so a diagnostic that named - the workload store, the guest image cache, or a run artifact kept the - operator's own runs path in `failure.json`, and the replacement label now - names a private path rather than a runtime directory. -** [x] Add regression tests for each fix: two witness cases that precede their - transition, a non-advancing input offset, and a record against a marked runs - directory whose store is not owner-only. -* [x] Harden the phase against the twelfth adversarial review, which confirmed the - two eleventh-round checker fixes and found the operational-path fix incomplete: -** [x] Name the store and guest image cache with fixed labels instead of their - host paths, because those rejections reach the shareable report. -** [x] Derive the workload store and image cache from the canonicalized runs - directory, so a relative `--runs-dir` cannot disagree with the path the report - sanitizer replaces. -** [x] Replace every representation of a private path in a retained report — - plain, QEMU comma-escaped, and Rust debug-escaped — and only at a path - boundary, so an unrelated longer name that shares a prefix survives. -** [x] Add regression tests for each fix: the fixed-label store rejection and a - sanitizer case covering all three representations plus the shared prefix. - -== Phase 4 — Acceptance and evidence - -Status: DONE. - -* [x] Automate both record-and-two-replay demonstrations on GitHub-hosted x86-64 - Linux without elevated privileges or a container daemon. `ci.yml` runs - `scripts/rfd3-phase4-acceptance.sh`, which runs the Phase 3 demonstration for - both source forms and the dynamically linked OCI fixture. -* [x] Cover every workload identity class with compatibility or tampering tests. - `EVIDENCE.adoc` maps each RFD identity class to its checked-in test. -* [x] Cover adversarial descriptor, layer-archive, whiteout, path, link, file - type, per-layer duplicate, expansion, immutable-read, and raw/derived cache - cases before VM launch. `EVIDENCE.adoc` carries the coverage map. -* [x] Verify canonical modes, owners, modification times, links, replacements, - whiteouts, and opacity survive CPIO encoding and are visible in the guest. - `crates/simferret/tests/rfd3_phase4.rs` encodes a real OCI conformance layout, - decodes the template, and runs the real runtime as PID 1 in a private PID - namespace through `scripts/rfd3-phase4-runtime.sh`. -* [x] Verify no ambient host environment, mutable source, or unrelated host file - enters the assembled workload. The Phase 4 suite and the acceptance run check - each case independently. -* [x] Verify shareable successful-run metadata and failure bundles exclude raw - config, lock values, environment values, and workload bytes, while private - artifacts are owner-only and explicitly classified. The acceptance run checks - the modes and the bundle contents; the run-level unit test remains the focused - regression. -* [x] Document supported OCI and binary profiles, self-hosted requirements, and - exact invocations in `README.md` and `EVIDENCE.adoc`. -* [x] Record assembly cost, initramfs and replay-log growth, record and replay - duration, workload traffic and output volume, and all observed divergence in - `EVIDENCE.adoc`. -* [x] Decide whether checkpoint branching, OCI-profile expansion, or serial - control optimization is the next evidence-driven RFD. `EVIDENCE.adoc` - recommends checkpoint branching. - -== Exit criteria - -* [x] Every acceptance criterion in the RFD has linked automated or captured - evidence. `EVIDENCE.adoc` carries the acceptance and coverage maps. -* [x] Binary and OCI inputs converge before the guest runtime boundary. The - Phase 1 convergence test and the Phase 3 acceptance agree on one canonical - digest for the standalone binary and the static OCI source. -* [x] Replay reconstructs workload identity independently and uses no live or - ambient workload input after QEMU starts; derived cache alone is insufficient. - The Phase 3 acceptance removes every live source and rechecks the raw closure - before QEMU starts. -* [x] The packaged workload demonstrably owns the process and network behavior - used by acceptance assertions. The workload, not the agent, originates every - recorded request and TFTP attempt. -* [x] The agent exposes only an unprivileged child chroot and generic protocol; - the dedicated VM remains the host security boundary. The Phase 2 runtime - contract is unchanged. -* [x] The implementation preserves RFD 1 and RFD 2's VM adapter, replay, - artifact, and normalization ownership boundaries and documents the intentional - host-only refinement for workload-specific assertions. `EVIDENCE.adoc` - records the boundary. -* [x] No registry runtime, container daemon, host mount, second workload, - persistent disk, richer fault model, or exploration engine exists without new - evidence and an RFD. diff --git a/rfd/0003/README.adoc b/rfd/0003/README.adoc deleted file mode 100644 index 4e25e7f..0000000 --- a/rfd/0003/README.adoc +++ /dev/null @@ -1,610 +0,0 @@ -:authors: Darwin Wu -:state: committed -:discussion: https://github.com/chaba-dev/simferret/pull/13 -:labels: applications, binaries, determinism, oci, packaging, replay - -= RFD 3 Reproducible workload packaging - -== Goal - -Run one user-supplied Linux workload inside SimFerret without making users build -a guest image or link against a SimFerret API. Accept either a standalone static -executable or a local OCI image layout, normalize both into one content-addressed -guest workload model, and preserve RFD 1 and RFD 2's exact replay contract. - -The increment should prove that packaging is an input to deterministic execution, -not a second runtime boundary. All workload bytes and launch semantics are fixed -before QEMU starts. Replay must reject changed workload content or configuration -before guest execution and must not contact a registry, read a live host -filesystem, or depend on a container daemon. - -== Motivation - -RFD 1 established exact whole-system record and replay. RFD 2 added an explicit -replay-filtered network and a deterministic outage. Both acceptance scenarios -still run repository-built fixture behavior from SimFerret's own initramfs. This -proves the execution and network boundaries but not that a user can bring an -application. - -OCI is useful here as a content-addressed distribution format. Existing build -pipelines already produce image manifests, configs, and layers with digests, and -those identities fit SimFerret's replay validation. SimFerret does not need OCI -namespaces, registry behavior, a daemon, or orchestration to consume those -artifacts. - -OCI alone would impose unnecessary work on users with a single static service or -test binary. A standalone executable is also the smallest way to prove that the -guest agent can supervise code other than itself. Supporting both inputs through -one normalized model avoids making either source format part of the execution -engine. - -The RFD 2 evidence recommends packaging before checkpoint exploration. A real -workload gives later snapshot, branching, and search measurements a more -representative filesystem and process than the built-in fixture. - -== Proposal - -Add a versioned workload specification selected by `simferret run`. Its source -is one of two tagged forms: - -* `binary`: one statically linked, fixed-address, little-endian x86-64 Linux ELF - executable; -* `oci`: one manifest selected by digest from a local OCI image-layout directory. - -Both sources produce a canonical workload containing: - -* an ordered filesystem tree rooted below a reserved guest path; -* an executable path and exact argument vector; -* an exact environment without host inheritance; -* an absolute working directory inside the workload root; -* numeric user and group identifiers; and -* source and normalized-content identities. - -The canonical workload is assembled into the existing deterministic initramfs. -The SimFerret agent remains PID 1 outside the workload root and supervises one -workload process. The process receives no host bind mounts or ambient host -environment. OCI and binary inputs share the same guest launch and supervision -path after normalization. - -The intended boundary is: - -[source,text] ----- -local binary or OCI image layout - -> bounded parser and independent digest validation - -> canonical workload filesystem and launch identity - -> deterministic initramfs assembler - -> SimFerret guest agent as PID 1 - -> one workload process in a private filesystem root - -> existing deterministic process and network boundaries ----- - -== Workload specification - -The exact CLI and field names may change during implementation. The initial -shape is approximately: - -[source,toml] ----- -version = 1 -kind = "binary" -path = "bin/example-server" -args = ["--listen", "0.0.0.0:8080"] -env = ["MODE=acceptance"] -working_directory = "/" -user = "1000:1000" ----- - -or: - -[source,toml] ----- -version = 1 -kind = "oci" -layout = "images/example" -manifest_digest = "sha256:" ----- - -Source paths are resolved relative to the workload specification and are -operational locators, not semantic identity. SimFerret computes identities from -opened bytes and never accepts a caller-provided content digest as proof of -those bytes. The OCI manifest digest selects content but is still independently -verified. - -Binary specifications provide launch values explicitly. They require a static -ELF so no undeclared host or guest library closure can affect execution. The -initial binary profile accepts only a fixed-address (`ET_EXEC`) image: a -relocated image's load base, entry address, and mapping alignment are chosen by -the guest loader at exec time, so assembly cannot establish that it would load. -A static PIE is refused with that diagnostic and is instead linked with -`-no-pie` or packaged as an OCI source, where the same bytes are accepted. The -executable is installed at one fixed canonical path with normalized ownership, -executable mode, and zero timestamp. The initial binary profile has no auxiliary -file tree; users that need libraries or application data use OCI. - -OCI specifications use the selected image config for `Entrypoint`, `Cmd`, `Env`, -`WorkingDir`, and `User`. The initial profile does not allow per-run overrides. -Shell expansion, host environment interpolation, named user lookup, and -supplementary groups are excluded. - -Launch normalization uses these rules: - -[cols="1,3",options="header"] -|=== -| OCI field | Initial SimFerret rule - -| `Entrypoint`, `Cmd` -| Treat null as absent. Use nonempty `Entrypoint` followed by `Cmd`, or nonempty - `Cmd` alone. Require the resulting first argument to be an absolute in-root - executable path; reject an empty result and do not search `PATH`. - -| `Env` -| Treat null or absence as empty. Require bounded `NAME=VALUE` UTF-8 entries, - reject NUL and duplicate names, preserve order, and inherit nothing from the - host or agent. - -| `WorkingDir` -| Treat null, absence, or an empty string as `/`. Otherwise require an absolute - path that resolves to a directory inside the final workload root without - traversing a symbolic link. - -| `User` -| Treat null, absence, or an empty string as the SimFerret default - `65534:65534`. Otherwise require an explicit nonzero decimal `uid:gid` pair. - Reject names, UID-only values, root credentials, and supplementary groups. - -| `Volumes`, `StopSignal`, `ArgsEscaped` -| Reject nonempty volumes, a configured stop signal, and `ArgsEscaped = true`. - The process-fault signal is fixed by the scenario contract. - -| `ExposedPorts`, `Labels`, `History` -| Treat as non-execution metadata. Their raw config bytes remain source identity, - but they do not change the normalized launch. -|=== - -Binary specifications use the same normalized launch rules and require an -explicit nonzero `uid:gid`. Every selected default and rejection policy is -versioned and included in workload identity. - -== OCI input profile - -The first OCI implementation accepts a local image-layout directory containing -`oci-layout`, `index.json`, and local blobs. It first finds exactly one direct -image-manifest descriptor with the requested digest. That selected descriptor -must declare `linux/amd64`; `variant`, `os.version`, and `os.features` must be -absent, and the selected config must agree. Duplicate selected descriptors, -platform-less selected descriptors, nested selection, or a selected descriptor -with remote or missing content is rejected. Unselected descriptors and blobs do -not enter the execution closure and are ignored even when they use unsupported -media types or refer to unavailable content. - -Before parsing or decompressing referenced content, SimFerret checks each -descriptor's media type, size, and SHA-256 digest against the opened bytes. It -then checks that the config uses `rootfs.type = "layers"`, that layer and DiffID -counts agree, and that each uncompressed layer stream matches its ordered DiffID. -Layers are applied from base to top into an empty private staging root. - -The supported layer profile includes bounded plain or gzip-compressed tar, -directories, regular files, safe relative symbolic links, and OCI whiteout and -opaque-directory semantics. Paths are normalized once. Absolute paths, NUL, -escape through `..`, traversal through an existing symbolic link, and duplicate -normalized archive paths within one layer are rejected. A later layer may -legally replace an earlier path: directory-over-directory updates attributes, -while other type or content replacements remove and recreate the path. -Whiteouts and opaque markers affect only the lower-layer view regardless of tar -member order; same-layer additions survive, and markers never enter the final -root. - -Device nodes, sockets, FIFOs, setuid and setgid modes, all hard links, sparse -files, ACLs, unsupported extended attributes, unknown layer -encodings, descriptor URLs, and embedded descriptor data are rejected in the -initial profile. Accepted whole-second OCI modification times are preserved and -included in canonical identity; unsupported extended timestamp encodings are -rejected. The implementation must not delegate extraction to an unrestricted -`tar` process. Limits cover descriptor count, nesting, compressed and expanded -bytes, file count, path length, and individual file size. A limit failure occurs -before QEMU starts and produces bounded diagnostics. - -All source access uses bounded regular-file reads beneath an already opened real -layout directory. `oci-layout`, `index.json`, digest directories, and selected -blob files may not be symlinks, FIFOs, devices, or other special files. Digest -components map to one validated canonical blob path. SimFerret copies bytes into -private immutable staging, then verifies, parses, decompresses, and extracts -those same bytes; it never verifies one path and later reopens mutable source -content. The binary source and existing cache follow the same -verification-to-use rule. - -Unknown OCI JSON fields and unrelated layout files are ignored where the OCI -specification requires forward compatibility. Unsupported selected media types -or execution semantics are rejected explicitly rather than interpreted -approximately. - -== Canonical filesystem and identity - -The normalized filesystem identity is a domain-separated digest over sorted -entries. Each entry encodes its canonical absolute workload path, type, mode, -numeric owner, numeric group, timestamp policy, and either file bytes or symbolic -link target. Directory entries are explicit. Serialization uses bounded lengths -and unambiguous type tags; it does not depend on host directory enumeration, -inode numbers, tar header order where OCI semantics do not make order -significant, locale, or host umask. - -The workload replay identity includes at least: - -* workload-specification version and source kind; -* the canonical workload specification and exact source-selection evidence; -* source executable digest, or selected OCI manifest, config, stored-layer, and - uncompressed DiffID identities in order; -* canonical normalized-filesystem digest and assembler format version; -* executable path, ordered arguments, ordered environment, working directory, - numeric credentials, and all defaulting decisions; -* supported OCI media types, extraction-policy version, and runtime-overlay - version; and -* the resulting initial-state digest already owned by the VM identity. - -The source identity preserves useful provenance while the canonical identity -defines guest-visible content. Two source forms are not required to have the -same identity even when they contain the same executable. They are required to -enter the same runtime path and obey the same process contract. - -Host source paths, staging paths, cache paths, process identifiers, and archive -inode metadata are diagnostic only. Any source metadata visible to the guest is -canonicalized or included in identity. - -== Content cache and replay - -Large workload content is not copied into every run directory. The content store -contains both raw evidence and derived content. For a binary, raw evidence is the -opened executable and canonical workload specification. For OCI, it is -`oci-layout`, `index.json`, the selected index descriptor, and the exact selected -manifest, config, and stored layer blobs. Every object is addressed by digest; -the selected descriptor order and relationships form one raw replay closure. -Operational source locators are not part of it. - -Derived entries contain the canonical filesystem tree and encoded immutable -guest template. Each derived entry names its complete raw closure, normalized -launch digest, policy versions, and canonical filesystem digest. Assembly writes -raw and derived entries through private staging, verifies complete bytes and -relationships, and publishes atomically. Concurrent builders must either -produce the same bytes or fail without replacing a verified entry. - -The run manifest records only workload, launch, and resulting guest-image -identities. A canonical workload lock is a digested private run artifact and -names the entire raw and derived closure. Replay verifies every required raw -object against its digest, reparses the specification and selected OCI graph, -rechecks stored-layer-to-DiffID relationships, and then either rebuilds the -canonical tree or verifies a derived entry against those independently computed -identities. A derived tree alone is insufficient. Missing raw or derived content -produces an actionable preflight error rather than falling back to a live source. - -Once QEMU starts, replay behaves exactly as in RFD 2. It provides no live -workload files, registry interaction, or host mounts. QEMU replays recorded guest -inputs and network packets, while SimFerret compares normalized events, -assertions, and the semantic outcome digest. - -== Guest runtime - -The initramfs keeps PID 1, the agent, and its tools outside an immutable workload -template. For every start, including restart within one boot, the agent creates a -new writable RAM root from that template. It reproduces canonical bytes and -metadata, then applies a versioned runtime overlay: `/tmp` is an empty root-owned -mode-`01777` directory; `/dev` is root-owned mode `0755`; and `/dev/null` and -`/dev/zero` are mode-`0666` character devices with fixed owners and device -numbers. Package entries at `/tmp` and `/dev` must be directories and have their -metadata replaced by the overlay; entries below those paths collide and are -rejected except for an empty directory tree. No `/proc`, `/sys`, entropy device, -or other guest interface is exposed. Overlay paths, metadata, collision rules, -copy algorithm, and timestamp handling are workload identity. - -The agent itself never changes root. It forks a workload child, connects only -fresh standard-input/output/error pipes, closes every other inherited descriptor, -changes the child root and then its in-root working directory, clears -supplementary groups, sets `no_new_privs`, applies the nonzero GID and UID, and -executes the exact argument vector without a shell. A setup failure exits the -child without executing workload code and emits a typed launch failure. The -immutable template and previous invocation roots are never reachable from the -child. - -The versioned process protocol accepts only these semantic commands: - -* `start(invocation, workload_identity)`; -* `stdin-write(invocation, offset, bytes)` with bounded frames and strictly - contiguous offsets; -* `stdin-eof(invocation)`; and -* `terminate(invocation)`, whose initial-profile meaning is unconditional - `SIGKILL`, independent of OCI `StopSignal`. - -The agent emits start, input-accepted, requested-termination, exit, launch-failure, -and cleanup-complete events. While the process is live it also emits bounded -output frames containing invocation identifier, `stdout` or `stderr`, per-stream -byte offset, one monotonic cross-stream sequence number, and exact bytes. Final -exit records contain independent per-stream totals and digests. Fixed per-frame, -queued-output, and per-invocation limits are identified by the scenario. The -agent drains both streams while the child runs; a limit, offset, pipe, or control -transport failure kills the invocation and is an infrastructure failure. Output -is never silently truncated and host read chunking is not exposed as a semantic -event. - -The initial single-workload profile defines every guest process other than PID 1 -as a member of the active invocation. On termination or primary-process exit, -the agent repeatedly enumerates the guest process table, sends `SIGKILL` to every -remaining member, and reaps until only PID 1 remains and all workload output -pipes reach EOF. It emits `cleanup-complete` only after that barrier and refuses -another start before it. This deliberately includes double-forked, reparented, -or process-group-escaped descendants. - -The agent reports process and byte facts but does not parse fixture protocols or -evaluate application properties. The host scenario checker incrementally parses -recorded output frames, correlates them with commands and network events, and -owns workload assertions. This is an explicit refinement of the earlier -guest/host assertion mirror: the guest still enforces and reports generic -protocol invariants, while application meaning exists only in the versioned host -checker. Passive replay compares the resulting frames and assertions exactly. - -This boundary supplies deterministic execution, not container isolation. Source -parsing and extraction treat inputs as hostile, and the VM protects the host, -but an accepted workload is trusted not to exhaust the entire guest. `chroot` -limits the non-root child namespace; it is not the host security boundary or a -multi-tenant sandbox. Linux namespaces, cgroups, seccomp, OCI capabilities and -hooks, terminals, and general resource controls remain separate concerns. - -== Acceptance scenario - -The acceptance fixture is built once as a static x86-64 Linux executable and -packaged in both supported forms: directly as a binary workload and inside a -minimal OCI image layout. It is ordinary Linux software and does not link to a -SimFerret library. Fixture-specific output interpretation remains in the -scenario checker rather than the guest agent. - -For each source form, the checked-in acceptance scenario: - -. assembles and boots the workload through the canonical runtime path; -. observes a typed workload-start event; -. sends bounded, recorded `stdin-write` commands and parses live, ordered output - frames whose response is derived from that input; -. terminates the workload at a materialized process-fault choice point and - confirms exit and cleanup completion, including an escaped descendant that - retains an output descriptor; -. restarts the same workload identity into a fresh root, proves a mutation from - the first invocation is absent, observes a matching response, and exercises - recorded `stdin-eof`; -. performs a request through the RFD 2 RTL8139 and restricted replay-filtered - backend before, during, and after the existing peer-specific outage; -. evaluates structured process, response-integrity, outage, and recovery - properties; and -. shuts down normally. - -The workload, rather than built-in agent request code, must originate the -acceptance application traffic. Any fixture protocol exists only to make this -fact auditable. General adapters for arbitrary service protocols are not claimed -by this RFD. - -A focused OCI conformance fixture independently covers preserved modes, numeric -owners, whole-second modification times, safe symbolic links, legal -cross-layer replacement, whiteouts, and opaque directories. It verifies the -guest-visible metadata after initramfs encoding rather than only the host staging -tree. A second minimal OCI fixture contains a dynamically linked executable, -interpreter, and shared library and must execute and passively replay; standalone -dynamic binaries remain unsupported. - -Record mode is followed by two passive replays for each source form. Replays -must produce byte-identical normalized event and assertion artifacts and matching -semantic outcome digests. The acceptance harness records assembly size and -duration, initramfs growth, QEMU record and replay duration, replay-log growth, -workload output volume, and all observed divergence. - -== Assertions - -The scenario passes only when: - -* the started executable and launch identity match the materialized workload; -* bounded live workload frames preserve per-stream bytes and cross-stream order, - and the host checker derives the expected application response; -* the intended invocation reaches the cleanup barrier and no escaped descendant - or retained output descriptor survives; -* the restarted invocation uses the same workload identity, begins from the same - immutable root, and responds within its event bound; -* application traffic demonstrably crosses the configured NIC and observes the - typed administrative rejection while the outage is active; -* matching application traffic recovers after route restoration; and -* all required process and network events occur in command-correlated order. - -An exec error, unsupported dynamic binary, malformed OCI object, extraction -limit, missing output, output truncation, infrastructure deadline, or agent-made -response cannot satisfy a workload property. - -== Tampering and negative tests - -Preflight tests change each workload identity class independently. At minimum -they cover the specification, standalone executable, manifest, config, stored -layer, DiffID, normalized filesystem, launch arguments, environment, working -directory, and credentials. Changing any object while keeping the recorded lock -fixed must fail. Self-consistently changing one subgraph, such as a manifest and -stored layer, must still fail against the unchanged config, DiffIDs, lock, or -derived identity. Missing raw closure content fails even when a derived -filesystem is present. - -Adversarial OCI fixtures cover absolute and escaping paths, path traversal -through symbolic links, duplicate normalized names, unsafe hard links, whiteout -ordering, opaque directories, decompression expansion, oversized content, -unsupported file types, missing blobs, digest and size mismatch, wrong platform, -ambiguous selection, and unsupported media types. Every failure must occur before -QEMU launch and leave no partially published cache entry. - -Binary tests reject dynamically linked, relocated (static PIE), -wrong-architecture, malformed, mutable, oversized, and non-regular inputs. -Runtime tests reject privileged credentials, -forbidden inherited descriptors and interfaces, stale writable roots, malformed -input offsets, output overflow, and an escaped descendant retaining a pipe. -Replay tests reject missing or altered raw and derived content and prove that -unrelated host files and environment variables do not enter the workload. - -Content digests provide corruption detection and replay identity, not publisher -authentication. A change to one object, relationship, lock, or derived artifact -against the rest of a recorded closure must fail. An attacker able to replace -the complete closure and all expected identities can instead create a different -self-consistent recording; detecting that requires signatures, transparency, or -an external trusted digest, all excluded from this increment. - -== CLI and diagnostics - -The intended command is approximately: - -[source,shell] ----- -simferret run \ - --workload workloads/example-binary.toml \ - --scenario scenarios/workload-network-outage.toml \ - --seed 42 ----- - -Success output retains the RFD 2 run identifier, assertion summary, artifact -directory, and replay command. The manifest and bounded failure bundle add the -workload source kind, canonical identity, launch identity, assembly/cache mode, -and first incompatible field without printing field values that may be secret. - -Replay closure, workload lock, raw OCI config, and exact workload streams are -private local artifacts: they may contain user-supplied environment values or -application data, use owner-only permissions, and are never uploaded by default. -The default shareable failure bundle contains bounded protocol metadata, counts, -digests, typed errors, and sanitized source labels, but excludes raw source -objects, lock contents, environment values, and output bytes. An explicit local -opt-in may collect bounded private stream bytes for debugging; SimFerret does not -claim it can infer or redact secrets from arbitrary workload output. - -== GitHub Actions and supported hosts - -The complete binary and OCI acceptance demonstration runs on a GitHub-hosted -x86-64 Linux runner without root, KVM, TAP, a container daemon, or network -access beyond dependency acquisition already owned by the pinned development -environment. Test workload artifacts are built or materialized reproducibly in -the repository environment rather than pulled from a registry during the test. - -Assembly may run on another host architecture when it is byte-reproducible, but -execution remains x86-64 Linux QEMU TCG. Cross-host assembly identity is evidence -to collect, not an initial acceptance claim. - -== Acceptance criteria - -This increment is complete when: - -* one versioned workload schema represents binary and OCI sources as a tagged - union and both normalize into one runtime model; -* a standalone static x86-64 Linux binary records and passively replays twice; -* a local `linux/amd64` OCI image layout records and passively replays twice; -* a focused dynamically linked OCI workload and its complete in-image dependency - closure execute and passively replay; -* both source forms use the same guest process supervision and event protocol; -* workload-originated traffic passes through the RFD 2 NIC and replay filter and - observes bounded outage and recovery; -* a materialized process fault terminates and restarts the packaged workload - through a whole-guest cleanup barrier and a fresh writable root, without a - stale process or mutation satisfying recovery; -* live input commands and ordered output frames let the host checker evaluate - application properties before exit without fixture logic in the agent; -* normalized event and assertion artifacts are byte-identical across each pair - of replays and semantic outcome digests match; -* all workload and launch identity changes are rejected before replay; -* adversarial descriptor, layer-archive, link, whiteout, limit, and cache tests - fail before QEMU starts without escaping staging or publishing partial content; -* OCI metadata and layer semantics survive guest-image encoding and are observed - correctly inside the workload root; -* replay requires and independently verifies the complete raw source closure as - well as any reused derived cache entry; -* no registry, daemon, host bind mount, ambient environment, or live workload - source is consulted after QEMU starts; -* intentional workload-output corruption fails safety with a nonzero CLI result; -* default shareable diagnostics contain no raw environment values or workload - stream bytes, while private artifacts are explicitly identified; -* the complete demonstration passes in unprivileged GitHub-hosted x86-64 Linux; - and -* evidence records supported formats, assembly and execution cost, artifact - growth, operational limits, and every observed divergence. - -== Excluded from this increment - -This proposal does not include: - -* registry clients, mutable tags, signature policy, transparency logs, or image - provenance verification beyond content digests; -* Docker archive compatibility, Docker or containerd daemons, BuildKit, or - building Dockerfiles; -* dynamically linked or relocated (static PIE) standalone binaries, or automatic - host library discovery; -* arbitrary host directory trees, bind mounts, persistent volumes, block - devices, or mutable root filesystems retained across runs; -* multiple workloads, sidecars, Docker Compose, Kubernetes, service discovery, - or general topology configuration; -* full OCI Runtime Specification behavior, namespaces, cgroups, capabilities, - seccomp, hooks, terminal handling, or resource controls; -* named user and group resolution, shell command interpretation, or host - environment inheritance; -* non-Linux, non-amd64, privileged, setuid, or device-dependent workloads; -* general protocol adapters or automatic property inference for arbitrary - applications; -* richer network faults, a second guest, persistent storage faults, checkpoint - branching, or exploration workers; or -* performance or security claims beyond the bounded accepted profile. - -== Alternatives considered - -OCI-only support maximizes compatibility with container build pipelines but -forces users with a single static artifact to construct layers and image -metadata. The binary source adds little runtime complexity once both normalize -to the same model and provides the smallest end-to-end acceptance case. - -Binary-only support avoids layer extraction but cannot represent dynamically -linked applications and their filesystem dependencies without inventing another -bundle format. OCI already provides a content-addressed answer for that case. - -A custom SimFerret archive could encode exactly the supported semantics, but it -would create a new build ecosystem before OCI demonstrates a concrete mismatch. -The canonical internal model remains available if such a format is justified -later. - -Mounting a host directory into the guest would be operationally simple but adds -live filesystem input outside QEMU replay and makes host metadata semantic by -accident. Copying and canonicalizing content before launch is required. - -Running Docker, containerd, or a complete OCI runtime inside the guest adds a -daemon, mutable state, namespaces, and additional nondeterministic behavior that -does not help answer the packaging question. SimFerret needs deterministic -process launch, not a nested container platform. - -Using Nix closures directly would provide strong identities for Nix users but -would not accept the dominant OCI artifact format and would couple the workload -contract to SimFerret's development environment. - -Attaching a writable disk image would support larger images and persistent state -but introduces block-device replay, filesystem initialization, and storage-fault -questions. The initial bounded workload remains in the deterministic initramfs; -disk-backed workloads require a later RFD. - -== Follow-up decision - -Completion provides the first representative user workload for measuring -checkpoint size, restore cost, and branching throughput. If assembly and replay -remain reliable, checkpoint-tree branching and deterministic exploration should -be the next RFD. - -If OCI compatibility failures dominate because the bounded layer profile is too -narrow, expand only the observed filesystem semantics before exploration. If -acceptance runtime rather than workload size dominates, optimize the recorded -serial control protocol as a separate focused change. Richer packet faults or -multiple guests move earlier only when packaged workload evidence requires them. - -== Implementation - -Delivery phases are tracked in -link:IMPLEMENTATION.adoc[RFD 3 implementation checklist]. Captured measurements -and validation results are retained in link:EVIDENCE.adoc[RFD 3 evidence]. - -== References - -* https://github.com/opencontainers/image-spec/blob/main/image-layout.md[OCI image layout] -* https://github.com/opencontainers/image-spec/blob/main/descriptor.md[OCI descriptors] -* https://github.com/opencontainers/image-spec/blob/main/manifest.md[OCI image manifest] -* https://github.com/opencontainers/image-spec/blob/main/config.md[OCI image configuration] -* https://github.com/opencontainers/image-spec/blob/main/layer.md[OCI image layers] -* link:../0001/README.adoc[RFD 1: Deterministic execution proof of concept] -* link:../0002/README.adoc[RFD 2: Deterministic network fault model] diff --git a/rfd/0004/EVIDENCE.adoc b/rfd/0004/EVIDENCE.adoc deleted file mode 100644 index a409f8a..0000000 --- a/rfd/0004/EVIDENCE.adoc +++ /dev/null @@ -1,605 +0,0 @@ -= RFD 4 Evidence - -== Phase 0 pinned time model - -=== Scale selection - -The selection rule is the one the RFD records: a fixed value that boots and -completes every validation run within the configured deadline on every host in -the supported matrix, justified against its neighbors and recorded with the -reason. - -The validation deadline is the probe's per-run QEMU deadline, 180 s -(`SIMFERRET_QEMU_TIMEOUT`), and every configuration below was measured with the -probe's default of five requested runs. A run that times out, exits nonzero, or -reports a malformed measurement is recorded and excluded from the comparison; a -configuration is rejected when no run completes, when the control checksum -varies, or when the spin count and state disagree. - -The checked-in command is: - -[source,shell] ----- -SIMFERRET_ICOUNT_OPTIONS= \ -SIMFERRET_TIME_MODEL_OUTPUT= \ -.agents/dev ./scripts/time-model-probe.sh ----- - -Every run used `sleep=off`, the pinned QEMU 11.1.0, the guest kernel 6.18.49, -`-machine pc-i440fx-9.2,accel=tcg`, `-cpu qemu64`, one vCPU, `-rtc -base=2000-01-01T00:00:00,clock=vm`, and one initramfs -(`sha256 24d0dfffc169a4275657c61281097882447fd565ecff87eb619cc587a57e1b4c`), on -the reference x86-64 Linux host (AMD Ryzen 5 3600, 12 threads, Linux 6.18.41). - -[cols="1,1,1,1,1,1,1",options="header"] -|=== -| `-icount` options | 20 ms sleep | 100 × 1 ms sleeps | 2,000,000-iteration computation | Spin chunks | Replay log | Run wall time - -| `shift=2,sleep=off` -| 20.076 ms -| 111.577 ms -| 42.746 ms -| 128 -| 85,633 B -| 6.32–6.67 s - -| `shift=3,sleep=off` -| 20.103 ms -| 115.003 ms -| 86.960 ms -| 64 -| 163,273 B -| 6.30–6.39 s - -| `shift=4,sleep=off` -| 21.951 ms -| 117.778 ms -| 182.042 ms -| 64 -| 330,255 B -| 6.70–6.76 s - -| `shift=5,sleep=off` -| 20.284 ms -| 124.969 ms -| 387.858 ms -| 64 -| 713,979 B -| 7.71–7.76 s - -| `shift=7,sleep=off` -| 20.948 ms -| 207.060 ms -| 2,262.144 ms -| 64 -| 3,303,901 B -| 14.07–14.27 s -|=== - -Every value is exact across its five runs: all twenty-five runs completed, no -time measurement varied, and the control checksum was identical in all of them. -The spin count is the one measurement that differs between models, 128 chunks at -`shift=2` against 64 at `shift=3` and coarser, which is the polling quantization -the probe documents rather than a reproducibility difference; the spin state -agreed with the count in every run. The `shift=4` and `shift=7` rows reproduce -link:../../poc/time-model/EVIDENCE.adoc[the pre-RFD measurement] exactly -(21.951 ms, 117.78 ms, 330,255 B; 20.948 ms, 207.06 ms, 3,303,901 B), so the -model is stable across sessions rather than only within one experiment. - -The chosen value is `shift=4,sleep=off`: - -* Correctness does not discriminate. `shift=2`, `shift=3`, `shift=4`, `shift=5`, - and `shift=7` all reproduce exactly, so the validated window is flat in - reproducibility and the choice is a semantic one about the artificial - performance model. -* The fine direction has no measured failure mode and is cheaper on every - measured axis: the replay log falls from 3,303,901 B at `shift=7` to 85,633 B - at `shift=2`, the run wall time from 14.07 s to 6.32 s, and the fixed - computation from 2,262.144 ms to 42.746 ms. A rule of "the finest value - validated so far" would therefore keep moving as finer values are measured, - which is a poor basis for a versioned constant. -* `shift=4` is the value the pre-RFD measurement analyzed and the published RFD - cites: it completes no slower than `auto` (6.70–6.76 s here against 6.77–6.80 s - under `auto`) and writes a replay log an order of magnitude smaller than - `shift=7`. Its immediate neighbors on both sides (`shift=3` and `shift=5`) are - validated here, so the choice is not at the edge of the measured window and its - justification is complete against both directions. -* The coarse direction is the one with a measured failure mode. The exploratory - `shift=10` run produced no guest output within the deadline and a 117 MB - replay log, and the fixed computation grows faster than the exchange rate - between `shift=5` and `shift=7` (387.858 ms to 2,262.144 ms, 5.8x for two - steps), so the choice should sit inside the window rather than at its coarse - edge. -* Observed overshoot is recorded rather than optimized, as the RFD requires, and - it is not monotonic in the scale. The 20 ms sleep overshoots by 0.076 ms at - `shift=2`, 0.103 ms at `shift=3`, 1.951 ms at `shift=4`, 0.284 ms at `shift=5`, - and 0.948 ms at `shift=7`; the 100 × 1 ms loop totals 111.577 ms, 115.003 ms, - 117.778 ms, 124.969 ms, and 207.060 ms respectively. - -`shift=3` and `shift=2` are equally reproducible and cheaper, and either is -available if the artifact size or the virtual-time inflation of CPU-bound work -later matters more than stability of the constant; changing the value afterwards -is a versioned change, because the model is part of VM identity and runs recorded -under different models are not comparable. - -This section measures the reference host only, which is half of the rule. The -supported matrix adds GitHub-hosted `ubuntu-latest` x86-64 Linux, where the -Phase 0 continuous-integration gate requires every requested run to complete and -the verdict to be `reproducible`, and where a host that cannot complete under the -pinned model must fail as an unsupported execution rather than fall back to -another model. Pinning a different scale later is a versioned change, because -the model is part of VM identity and runs recorded under different models are not -comparable. - -Raw per-run serial output, replay logs, and durations remain in the untracked -`.poc/rfd4-phase0/` directory. - -=== Validation on the reference host - -The validation deadline is the probe's per-run QEMU deadline, 180 s -(`SIMFERRET_QEMU_TIMEOUT`), and the sample is the RFD's minimum of five complete -runs. `scripts/time-model-gate.sh` fixes both rather than inheriting them from -the caller: a different deadline, a smaller sample, or a sample larger than the -probe's own bound is a configuration error before any run starts, and the gate -fails a host unless every requested run completed, the verdict is an explicit -`reproducible`, and the guest measurements equal the checked-in reference values -exactly. Failures are classified rather than merged into one status: a bad -record, an unsupported platform, or a probe that rejects its arguments is a -configuration error; a host that did not complete the runs is an unsupported -execution and no fallback model is attempted; and a completed experiment that -disagrees with the reference record, or that is invalid on its own control -checks, is a validation failure. The probe's own outcomes are mapped rather than -merged, and an exit the probe does not document is not read as a statement about -the host. Each invocation creates its own directory under the output root before -anything is validated, with its result file, the probe's output, and the probe's -run directory, so a configuration error is recorded where it happened and a -failed rerun cannot leave an earlier success standing. - -The checked-in command is: - -[source,shell] ----- -.agents/dev ./scripts/time-model-gate.sh ----- - -On the reference host (AMD Ryzen 5 3600, 12 threads, Linux 6.18.41, QEMU 11.1.0, -guest kernel 6.18.49) it reports: -The table is the validation as first run, under the stock emulator, whose -executable digest is `a26dcb...`; the pinned emulator that carries the patch is -validated again in the resolution section, with its own digest, and the guest -measurements are the same under both: - -[cols="1,2",options="header"] -|=== -| Field | Value - -| `icount_options` | `shift=4,sleep=off` -| `requested_runs` / `complete_runs` / `incomplete_runs` | 5 / 5 / 0 -| `verdict` | `reproducible` -| `varying_time_metrics` | 0 -| `qemu_version` | `QEMU emulator version 11.1.0` -| `qemu_sha256` | `a26dcb363d6817495c7fdfe824f0c60e9c0e6369d90fdbfda9648d40f8dbdbd7` -| `initramfs_sha256` | `24d0dfffc169a4275657c61281097882447fd565ecff87eb619cc587a57e1b4c` -| `kernel_sha256` | `d4c2d110cb9b82dad81517cc2f1f3a46d0e31c8937237cf3df59eeffb3d7070b` -| replay log per run | 330,255 B, identical in all five runs -| run wall time | 6.6–6.8 s per run, inside the 180 s deadline -| guest measurements | equal to the reference host's recorded values -|=== - -The QEMU identity is the SHA-256 of the executable rather than its version -string, so a rebuilt or patched QEMU with an unchanged version string cannot pass -as the reference build. That matters here because the model's blocker is a QEMU -behaviour, and the feasibility spike below builds a patched QEMU that reports the -same version. - -The values a host must reproduce are checked in as -`poc/time-model/reference-host-values.txt`, which also names the model they were -measured under. The gate reads both from that one record, so it cannot compare a -host against values measured under a different model: - -[cols="1,2",options="header"] -|=== -| Measurement | Reference-host value - -| 20 ms sleep | `probe sleep requested_ns=20000000 observed_ns=21950896` -| spin | `probe spin chunks=64 window_ns=20000000 state=13811787166479837696` -| fixed computation | `probe race work=2000000 elapsed_ns=182041872 within_deadline=no` -| 100 × 1 ms sleeps | `probe sleep_loop iterations=100 observed_ns=117777696` -| control checksum | `probe checksum value=14786994027932720960` -|=== - -These are the same values the scale-selection table above reports for -`shift=4,sleep=off` (21.951 ms, 64 chunks, 182.042 ms, 117.778 ms), measured -again in a later session, so the model reproduces across sessions and not only -within one experiment. Each gate invocation writes its own directory under the -untracked `.poc/rfd4-phase0-gate/` tree, holding its result file, the probe's -output, and the probe's run directory with the per-run serial output, replay -logs, and durations. - -=== Cross-host equality - -Requiring zero variation within a host is not the RFD's rule; the rule is that -the guest measurements are equal across the supported hosts for identical -artifacts and the same model. The gate therefore compares each host against the -reference host's checked-in values instead of only against itself, and it checks -the artifacts that make the comparison meaningful: the SHA-256 of the QEMU -executable, of the guest kernel, and of the initramfs the probe builds. A host -whose guest measurements differ fails the gate rather than passing with a -warning. - -The reference host is the half measured here. The `ubuntu-latest` half is -measured by the `qemu-replay` job in `.github/workflows/ci.yml`, which runs -`scripts/time-model-gate-test.sh` and then the gate itself. Its first green run -(GitHub-hosted `ubuntu-latest`, QEMU 11.1.0, the same kernel and initramfs -digests) reproduced every value exactly: 5 of 5 requested runs completed, the -verdict was `reproducible`, the four time measurements and the control checksum -were identical to the reference host's, and every replay log was 330,255 bytes. -The two hosts therefore agree on the measurements rather than each being only -internally stable, which is the rule this section exists to enforce. The run is -retained at -https://github.com/chaba-dev/simferret/actions/runs/35672759147/job/106572696097. - -=== Record mode cannot use the pinned model - -The gate validates the model for a guest that never waits for host input, which -is what the probe does. The product's guests do wait: a recording is driven by -control commands written to the guest's serial port. Measuring that case -separates the model's reproducibility from its usability, and it fails. - -`scripts/time-model-input-probe.sh` boots `poc/time-model/input-probe.c`, waits -for the guest's `READY`, writes one line, and reports whether the guest received -it. The guest polls with a 100 ms timeout rather than blocking, so it also -measures delivery while virtual time keeps advancing, and it has no poll limit: -it polls until the line arrives or the probe stops the emulator. - -The order of operations is the measurement, and QEMU's monitor is what makes it -causal rather than timing-dependent. The guest polls until the probe stops the -emulator, so a bounded guest window cannot close before the write. The probe then -stops the guest with an acknowledged monitor command (it waits for QEMU's reply, -so a request QEMU has not acted on is not mistaken for a stopped guest), drains -the output the guest produced before it stopped, writes the line, and resumes the -guest with a second acknowledged command. A stopped guest cannot poll and cannot -produce output, so the polling it does after the resume is polling after the -write, and no report read after the resume can be one the guest produced earlier; -without that ordering the result would rest on how the host happened to be -scheduled, which is exactly what a reproducibility measurement must not do. -After the wait the probe stops the emulator and reads its output to its end -before closing the pipe, so a delivery report emitted while the emulator is being -stopped is classified rather than lost. Only an output that ended in one piece -supports a non-delivery claim: an end that never arrives, a report cut off -mid-line, or the emulator's own deadline expiring all leave the experiment -inconclusive, because in those cases the probe cannot say that nothing else was -coming. - -`input=not-delivered` therefore means: the guest reported `READY`, produced a -poll report after the resumed write, the write succeeded, the guest had not -stopped polling for longer than the stall bound, the emulator was still running -when the wait expired and was stopped by the probe, and its output then ended in -one piece, with no delivery report seen before or during shutdown. The stall -bound is a liveness heuristic rather than a proof — a host stalled while -consuming output cannot tell old progress from new — but the ordering does not -rest on it, because the acknowledged stop and resume do. Receiving the line is -reported whatever else the experiment did, and a guest that never reported -`READY`, a host that could not write the line, a guest that produced no poll -report after the write, an emulator that exited on its own, an output that did -not end or ended mid-report, or a deadline that expired is inconclusive, which -satisfies no assertion. All four measurements used the pinned QEMU, the pinned -kernel, and the same probe build: - -[cols="2,1,1",options="header"] -|=== -| `-icount` options | Replay | Host input delivered - -| `shift=4,sleep=off` (pinned) -| `rr=record` -| *no*, the guest polled for the 84 s after boot, reporting 26,740 polls, and never received the line - -| `shift=4,sleep=off` (pinned) -| none -| yes - -| `shift=4` -| `rr=record` -| yes - -| `shift=auto` (what the product launches today) -| `rr=record` -| yes -|=== - -The command that reproduced each row at the time is below; the table is -historical, so reproducing it needs the stock emulator rather than the patched -build the dev shell now supplies: - -[source,shell] ----- -.agents/dev ./scripts/time-model-input-probe.sh # pinned model, records -.agents/dev ./scripts/time-model-input-probe.sh --live # pinned model, no record -.agents/dev ./scripts/time-model-input-probe.sh shift=4 # sleep=on control -.agents/dev ./scripts/time-model-input-probe.sh shift=auto # the product's current model ----- - -Continuous integration asserts the pinned emulator's behaviour rather than -leaving it to be re-checked by hand: the `qemu-replay` job runs -`scripts/time-model-input-probe.sh --expect delivered`, so dropping or breaking -the carried patch fails the job rather than silently returning the model to the -state the blocker section above describes. The same job runs the guest's own -regression tests (`scripts/time-model-input-probe-test.sh`), which drive the real -polling loop through stubs: a line that arrives after more than the polls the -guest used to stop after is still reported as received, and the guest never -reports giving up, so restoring either fails there rather than passing. - -The cause is in QEMU rather than in the host. With record/replay enabled, live -character input is not delivered when it is read: QEMU queues it as a -`REPLAY_ASYNC_EVENT_CHAR_READ` and delivers it only when the replay event queue is -flushed, which happens in `replay_async_events()` from -`icount_account_warp_timer()`. That function returns immediately when -`icount_sleep` is false, which is what `sleep=off` sets. Under the pinned model -the guest therefore never receives the bytes, whether it blocks on a read, polls -with a timer, or busy-polls, and whether the host writes them before or after -boot. - -The limitation is not specific to record mode. In QEMU 11.1.0 -`replay_async_events()` has exactly one caller, that function, and it is the -single site that saves queued events in record mode and injects recorded ones in -replay mode through `replay_read_events()`; `sleep=off` therefore skips -asynchronous input in both directions. A guest that needs no host input still -records and replays, which is why the time-model probe is unaffected, but a -recording under this model cannot be made and an existing recording's -asynchronous input would not be injected either. The spike below shows a patch -restoring that single processing site for both modes. - -The same limitation reaches the product and the earlier increments' spikes: - -* `scripts/phase4-acceptance.sh` records with the product and fails with - `simferret: timed out writing command to guest` after the first command, with - `traffic.requests_attempted: 0` in the failure diagnostics. -* `scripts/qemu-network-replay-smoke.sh` fails because the guest's TFTP fetch - times out: the SLIRP response is also a replay asynchronous event, so it is - queued rather than delivered. -* `scripts/qemu-replay-smoke.sh`, which needs no host input, passes under the - same model, so the failures are specific to asynchronous input rather than to - record and replay as a mechanism. - -What this blocks: Phase 0's requirement that the product's record and replay -launch paths pass the pinned model, and its requirement that a run recorded under -the pinned model replays twice with matching events, assertions, and outcome -digest. A recording cannot be made under the pinned model, so the second -requirement cannot be satisfied by any implementation that does not first change -how input reaches the guest. Until that is decided, the product's launch paths -keep launching the model they can complete under, which -`crates/simferret/src/vm.rs` names `TIME_MODEL` and documents there. - -==== Resolution: the pinned emulator carries the fix - -The owner approved carrying the patch, so the block above is history rather than -the current state. `flake.nix` applies `poc/time-model/qemu-nosleep-replay-flush.patch` -to the pinned emulator, so the dev shell's `qemu-system-x86_64` is the patched -build and the patch is a build input rather than a spike; the spike expression -that first built it is gone, and the repository does not keep two ways to build -the same emulator. The product's `TIME_MODEL` is `shift=4,sleep=off`, and the -reference record is re-measured against the patched binary, so `qemu_sha256` is -the patched digest and VM identity records the emulator that carries the fix. The -patch is carried until upstream includes it; dropping it is a versioned change, -because recordings made under a different emulator are not comparable. -`README.adoc` records the same decision from the RFD's side. - -The pin is verified the way the checklist asks. The launch paths are asserted by -`record_and_replay_launch_the_configured_time_model`, which fails unless both -record and replay launch the pinned options; the pinned model was re-measured -against the patched emulator and reproduced every reference value, so the patch -does not move the guest's measurements; the host-input assertion in continuous -integration now expects delivery, which keeps the patch load-bearing; and -`scripts/phase4-acceptance.sh` records a run under the pinned model and replays -it twice with matching normalized events, assertions, and semantic outcome -digest. One observation moves with the patch and is not a guest measurement: the -replay log grows, from the 330,255 bytes the stock emulator recorded to -3,386,955 bytes in every run of the pinned build, which is replay bookkeeping the restored flush adds rather than a guest measurement. Run wall -time is 6.89-7.17 s per run against 6.6-6.8 s before, inside the same deadline. - -The pin has a cost, because the patched emulator is not in `cache.nixos.org`. -The unrestricted spike build took 16 minutes end to end on the reference host -(configure 3m16s, build 11m28s, fixup 1m02s); the pinned build restricts QEMU to -the x86-64 system target and drops its documentation, which brought it under -about eight minutes here, and the dev shell split keeps it to the single job that -runs QEMU: the format, lint, and test jobs use `devShells.light`, which has no -emulator, so they do not build the patched emulator. - -The decision this left to the RFD was not a scale choice, and the owner has -since taken it: the project carries the patch. The alternatives considered were: keep a -fixed scale and drop `sleep=off`, which reintroduces the residual host-coupled -variation the scale-selection section measured; fix QEMU's no-sleep replay path -so queued asynchronous events are flushed at a deterministic point; or deliver -input to the guest by a mechanism that does not depend on the replay event queue, -which is the deterministic-ingress work this RFD already separates from the -model. - -==== What this measurement does not establish - -The measurement is the strongest ordering the emulator exposes, and it is worth -being explicit about what it rests on, because the blocker claim is only as good -as the ordering it is measured under. - -* The acknowledged stop and resume are asserted in the harness, not fixtured for - the delayed case. `scripts/time-model-gate-test.sh` drives the probe against a - QMP-speaking double and asserts that the monitor log contains `stop` and `cont` - around the write, and the probe's own code waits for QEMU's reply before it - drains and writes, so a request QEMU has not acted on cannot be mistaken for a - stopped guest. A fixture for the case where the pause takes effect only after - the request was written was dropped: its timing could not reliably distinguish - the acknowledgement from the delay, so the delayed-pause behaviour is reasoned - about rather than measured. -* That nothing remains buffered in the guest or the output path when the write is - submitted is a source-level argument rather than a monitor-level one. QEMU's - stdio chardev writes guest output through `io_channel_send` with no user-space - buffer, so a drained pipe is the boundary between what the guest produced before - the write and what it produces after the resume; QEMU exposes no "output - flushed" acknowledgement at the monitor, so this part cannot be asserted through - the channel that orders the write. The stall bound in the probe is a liveness - heuristic for the same reason: a host stalled while consuming output cannot tell - old progress from new. -* The causal claim does not depend on the probe's instrumentation alone. The - spike below changes one early return in QEMU's `icount_account_warp_timer()` and - delivery appears under the same model with the same probe, which is independent - confirmation that the flush ordering is the cause of the non-delivery rather - than an artifact of how the probe accounts for it. - -=== Feasibility spike: a patched QEMU that flushes the queue - -The blocker above is one early return. `poc/time-model/qemu-nosleep-replay-flush.patch` -moves the flush before it; the spike expression that first built the pinned QEMU -with it is gone, and `flake.nix` is what applies it now. The patch is wired into `flake.nix`, which applies it to the pinned emulator; -the spike expression that first built it is gone, and the measurements below -answer whether a minimal fix is possible. - -[source,diff] ----- - void icount_account_warp_timer(void) - { -- if (!icount_sleep) { -- return; -- } -- - /* - * Nothing to do if the VM is stopped: QEMU_CLOCK_VIRTUAL timers - * do not fire, so computing the deadline does not make sense. - */ - if (!runstate_is_running()) { - return; - } - -+ /* -+ * Flush queued replay events before the sleep check. External input is -+ * queued as a replay asynchronous event and delivered by this flush, so -+ * returning first would leave a guest that waits for host input without -+ * it in both record and replay mode. -+ */ - replay_async_events(); - -+ if (!icount_sleep) { -+ return; -+ } -+ - /* warp clock deterministically in record/replay mode */ - if (!replay_checkpoint(CHECKPOINT_CLOCK_WARP_ACCOUNT)) { - return; - } ----- - -The build is the flake's pinned emulator, which applies this patch: - -[source,shell] ----- -nix develop --command qemu-system-x86_64 --version ----- - -That spike produced `/nix/store/6a4jza3ydplb1k9l4kbk9gcsqy2iaka8-qemu-11.1.0`, -whose `qemu-system-x86_64` reports the same `QEMU emulator version 11.1.0` and -hashes to `f9c26bcdcd50ecbbccd923840bbcfaede6fddc675764cd99c93e12e97779faa8`; -that build is historical now, and the current one is the flake's pinned emulator, -whose executable hashes to -`2c6adfd8fc39a972ebb6051f7105f10f11cc2715efd1ff0b4e3385809a0fae0d`. Every -measurement below used the spike binary through `QEMU_SYSTEM_X86_64`, and the -reference column is the pinned stock QEMU. - -Because the repository's own revision does not launch the pinned model, the -pinned-model rows were produced as follows. The input probe and the gate ran -against this revision's scripts with the patched binary. The product acceptance -ran the blocked pin, checked out with `jj edit rfd-4-phase0-pin-blocked`, so the -product itself launched `shift=4,sleep=off`; that revision is not part of this -change. The two record and replay spikes hard-code `shift=auto`, so for the -spike they were temporarily set to the pinned model -(`sed -i 's/-icount "shift=auto,rr=/-icount "shift=4,sleep=off,rr/' scripts/qemu-replay-smoke.sh scripts/qemu-network-replay-smoke.sh`) -and restored afterwards with `jj restore`. The gate row used a spike-local -reference record: the checked-in record with `qemu_sha256` replaced by the -patched binary's digest, passed through `SIMFERRET_TIME_MODEL_REFERENCE`. - -[cols="2,1,1",options="header"] -|=== -| Check | Stock QEMU | Patched QEMU - -| Host input under the pinned model with `rr=record` (`time-model-input-probe.sh`) -| not delivered; the guest polled for the whole wait (26,740 polls over 84 s) -| delivered immediately after `READY` - -| Host input under the pinned model without record/replay (`--live`) -| delivered -| delivered - -| Product record and two replays under the pinned model (`phase4-acceptance.sh`) -| fails with `simferret: timed out writing command to guest` -| passes, with the two replays matching - -| Network record and replay under the pinned model (`qemu-network-replay-smoke.sh`) -| fails when the guest's TFTP fetch times out -| passes - -| Record and replay with no host input (`qemu-replay-smoke.sh`) -| passes -| passes - -| Gate under the pinned model (`time-model-gate.sh`) -| passes against the checked-in reference record -| fails against that record on the QEMU digest, and passes against a record carrying the patched digest, with every guest measurement identical to the reference host's -|=== - -The gate row is the behaviour the QEMU digest exists for: the patched binary -reports the same version string, and only the digest distinguishes it. - -The acceptance run is the two-replay confirmation this increment cannot make -under the pinned model otherwise. Its normalized artifacts are byte-identical to -the artifacts recorded under the product's current model in the same session: -`events.jsonl` SHA-256 `e95693c7adee291b3f40ce6457189a6832402021826428c510c2f7f0bb55bd4d`, -`assertions.json` SHA-256 -`d95cf483f182e37ff31687b80599dd37d2a877336eb966cb42c754faed4ea83f`, and -`semantic_outcome_sha256` `be5ec6342d82234bc8d28ad538cf1dca34d38e42106fd9e12aec3e918fc0c927`. -Only the replay log differs, 3,539,432 bytes under the pinned model against -6,384,125 bytes under the current model, which is a measurement rather than -identity, as RFD 2 already scopes it. - -Replay semantics. The flush is not moved past a checkpoint; the no-sleep path -simply stops skipping it. In record mode `replay_async_events()` writes the -queued events at the current instruction count and then runs them, and -`replay_checkpoint(CHECKPOINT_CLOCK_WARP_ACCOUNT)` still follows in every path -that reaches it, in the same order as before. With `sleep=on` nothing changes: -the running-state check, the flush, and the checkpoint happen in the same -sequence, and a stopped VM still returns before the flush in both modes. With -`sleep=off` the checkpoint and the clock warp are still skipped, exactly as they -were, so the change adds the flush without touching checkpoint ordering. The -events therefore keep their instruction-position semantics, which is what the -two-replay comparison above measures. - -What an upstream submission would argue: `-icount sleep=off` is documented as -giving deterministic execution times from the guest's point of view, and -record/replay is documented as recording and replaying serial, network, and -input-device input. Those two documented behaviours do not compose today, -because the only flush site for asynchronous events sits behind the sleep check. -Moving the flush ahead of that check keeps checkpoint ordering, changes nothing -for `sleep=on`, and makes `sleep=off` usable for guests that receive input. The -counter-argument to expect is that a change here should come with a record/replay -test covering input under `sleep=off`; the measurements above are the basis for -one. - -Recommendation: the fix looks minimal, effective, and upstreamable, and it does -not perturb the model's measurements. The project carries it now: `flake.nix` applies the patch to the pinned emulator and the product launches the pinned model, and the patch is dropped when upstream includes the fix. Re-validate when any of -these changes: - -* the pinned QEMU or guest kernel, in practice a `flake.lock` update that moves - `pkgs.qemu` or `pkgs.linuxPackages.kernel`; -* the model recorded in `poc/time-model/reference-host-values.txt`; -* `poc/time-model/probe.c`, which changes the guest and therefore the initramfs - digest the gate checks; or -* `poc/time-model/input-probe.c`, which changes the input probe's own guest, so - the input result below must be re-measured; the gate does not check that - initramfs. - -Re-validation means running `scripts/time-model-gate.sh` on every host in the -supported matrix and `scripts/time-model-input-probe.sh` for the models in the -table above, then re-recording the results here and the values in the reference -record.the same job asserts the pinned emulator's delivery, so a change that breaks or drops the carried patch fails the job instead of waiting to be noticed. - -The pin adopted that resolution: the pinned emulator carries the patch, the -product launches the pinned model, and the record and two-replay acceptance runs -under it. A change to the patch, the model, or the pinned emulator is the -re-validation trigger above, and the probe's assertion is what makes a silent -difference visible. diff --git a/rfd/0004/IMPLEMENTATION.adoc b/rfd/0004/IMPLEMENTATION.adoc deleted file mode 100644 index 0d816f4..0000000 --- a/rfd/0004/IMPLEMENTATION.adoc +++ /dev/null @@ -1,125 +0,0 @@ -= RFD 0004 implementation checklist - -Implements link:README.adoc[RFD 4: Deterministic guest time model]. - -== Objective - -Remove host-dependent clock scaling and idle pacing from guest execution, make -the pinned model part of versioned VM identity, and state precisely what the -earlier increments did and did not establish about fresh executions. - -== Entry gate - -Status: DONE. - -* [x] Measure guest time reproducibility under the current configuration and - separate the time model's contribution from the result of fixed work. -* [x] Establish that fixed work produces the same result while its measured - virtual duration varies, and that the guest instruction stream is not - identical across runs. -* [x] Identify a configuration that is reproducible at no measured wall-clock - cost. -* [x] Record what the earlier increments did and did not claim about replay and - fresh execution. - -== Phase 0 — Pin and validate the time model - -Status: DONE. - -The scale is selected and the model is validated on every host in the supported -matrix. The model is pinned and the product launches it. With `sleep=off` alone, -QEMU queues live serial input as a replay asynchronous event and never flushes -the queue, so a guest that waits for the control commands a recording is driven -with never receives them; the owner approved carrying -`poc/time-model/qemu-nosleep-replay-flush.patch`, `flake.nix` applies it to the -pinned emulator, and the two items below that depended on it are complete. The -measurement, the reproduction, the source-level cause, and the resolution are in -`EVIDENCE.adoc`. - -* [x] Select the pinned scale by the documented rule and record why that value - was chosen over its neighbors. -* [x] Set the validation deadline used to accept or reject a scale, and - validate against the supported-host matrix named in the RFD. - The deadline is the probe's per-run 180 s and is recorded with the selection; - the reference host and GitHub-hosted `ubuntu-latest` both complete inside it. -* [x] Require zero varying time measurements across at least five complete runs - on every host in the supported matrix. - `scripts/time-model-gate.sh` enforces five complete runs and an explicit - `reproducible` verdict, and both hosts pass it. -* [x] Require guest measurements to be equal across supported hosts for - identical artifacts and the same model, not merely stable within each host. - The gate compares each host against the checked-in reference values and the - artifact identities, and the two hosts agree on every measurement exactly. -* [x] Pass the pinned model from the product's record and replay launch paths - rather than configuring it separately, and assert that both launched argument - vectors use the pinned constant. - Both launch paths read the single `TIME_MODEL` constant in - `crates/simferret/src/vm.rs`, which is now `shift=4,sleep=off` and records why - the pinned emulator carries the patch; the launched argument vector is asserted - by `record_and_replay_launch_the_configured_time_model`. The second half of the - item — a typed time-model field in VM identity, with the launched options - compared against it — is Phase 1's, where `VmIdentity` gains the field; today - the assertion binds the launch paths to the constant, and the executable digest - in identity is what rejects a recording made by another emulator. -* [x] Confirm that a run recorded under the pinned model replays twice with - matching normalized events, assertions, and semantic outcome digest. - `scripts/phase4-acceptance.sh` performs the record and two-replay comparison - under the pinned model with the pinned emulator, and it passes: the two replays - match on normalized events, assertions, and the semantic outcome digest. -* [x] Fail a host that cannot complete under the pinned model as an unsupported - execution rather than falling back to another model. -* [x] Run the time-model probe as a continuous-integration gate on x86-64 - Linux, requiring every requested run to complete and the verdict to be - `reproducible` rather than merely invoking the diagnostic. - The gate is implemented and wired into the `qemu-replay` job, and it passes on - the reference host and on GitHub-hosted `ubuntu-latest`. -* [x] Define and document the re-validation trigger for changes to the pinned - QEMU or guest kernel. - -== Phase 1 — Identity, rejection, and migration - -Status: TODO. - -* [ ] Add the pinned time model to typed VM identity rather than leaving it in - the adapter's diagnostic fields. -* [ ] Reject a run whose manifest time model differs from the configured model - before QEMU starts, naming the first incompatible field. -* [ ] Require a run recorded before the pinned model existed to name its - environment or an explicit legacy profile, and never acquire the new model - through a default. -* [ ] Keep host-only observations such as wall-clock duration out of identity. -* [ ] Cover the new identity field with a compatibility or tampering test. - -== Phase 2 — Contract and documentation - -Status: TODO. - -* [ ] Document the pinned model, its idle-advancement semantics, and its wakeup - behavior in the project README and the run manifest. -* [ ] Document that the chosen scale defines an artificial performance model, so - timeout-sensitive results are conclusions about that model rather than - predictions of production timing. -* [ ] Document the unresolved input-arrival gap: live host input has no - deterministic position in guest virtual time, and deterministic ingress is - separate work. -* [ ] Record that replay's contract is conditional on artifacts, scenario, - executable, initial state, the specific log, and matching events and outcome - digest, and that RFD 2 already scopes its determinism claim to passive - replays. -* [ ] State explicitly that time, entropy, and ordering fault injection remain - unimplemented and are not implied by this increment. -* [ ] Record the measurements and validation results in `EVIDENCE.adoc`. - -== Exit criteria - -* [ ] The probe's four guest time measurements are identical across at least - five complete independent runs on every host in the supported matrix, and - equal across those hosts for identical artifacts and the same model. -* [ ] The pinned model is what the record and replay launch paths use, and it is - part of versioned VM identity with mismatches rejected before launch. -* [ ] Older recordings cannot silently acquire the new model. -* [ ] The model's guarantees and its unresolved gaps are documented. -* [ ] This increment introduces no new time, entropy, ordering, or compatibility - surface. -* [ ] The earlier increments' replay and determinism claims are unchanged and - correctly scoped. diff --git a/rfd/0004/README.adoc b/rfd/0004/README.adoc deleted file mode 100644 index 769f270..0000000 --- a/rfd/0004/README.adoc +++ /dev/null @@ -1,453 +0,0 @@ -:authors: Darwin Wu -:state: published -:discussion: https://github.com/chaba-dev/simferret/pull/16 -:labels: determinism, qemu, replay, time, virtual-clock - -= RFD 4 Deterministic guest time model - -== Goal - -Remove host-dependent clock scaling and idle pacing from guest execution, so -that the passage of time inside the guest is a reproducible function of the -fixed VM configuration and the work the guest performs. - -The increment is deliberately narrow. It pins the QEMU time model, adds that -model to versioned VM identity, and states precisely what the earlier increments -did and did not establish about fresh executions. It does not add time or -entropy interfaces to the guest, it does not add fault injection, and it does -not by itself make a fresh execution fully deterministic, because the arrival -timing of live host input remains outside this model. - -== Motivation - -RFD 1 established bounded record and replay. RFD 2 added a deterministic network -boundary. RFD 3 packages a user-supplied workload. Their guests share one vCPU, -`nokaslr`, and `-rtc clock=vm`; RFD 1 and RFD 2 additionally mount `devtmpfs`, -`proc`, and `sysfs` inside the guest, while RFD 3's proposed workload root -deliberately exposes none of them. All of them record and replay through -`-icount`. - -That construction controls the guest's input boundary and makes a recording -reproducible. It does not control the mapping from executed instructions to -virtual time. QEMU documents the mechanism directly: with `-icount shift=N` "the -virtual cpu will execute one instruction every 2^N ns of virtual time", while -`shift=auto` means "the virtual cpu speed will be automatically adjusted to keep -virtual time within a few seconds of real time". The same reference notes that -with `clock=vm`, which icount mode recommends, "the speed of the virtual clock -is variable and can in general differ from the host clock". QEMU's own record -and replay examples use `shift=auto`, so the current configuration follows -upstream convention. - -A probe that boots a fixed guest, takes four time measurements plus a control, -and repeats (`poc/time-model/probe.c`, driven by `scripts/time-model-probe.sh`) -produced these results. Five runs per configuration, except `shift=4,sleep=off` -which used three. - -[cols="2,1,1,1,1",options="header"] -|=== -| `-icount` options | Reproducible | Fixed work (2,000,000 iterations) | Replay log | Run wall time - -| `shift=auto` (current) -| no, 4/4 metrics vary -| 42.65–126.05 ms (3.0x) -| 4,653,579–10,094,763 B, all distinct -| 6.77–6.80 s - -| `shift=auto,sleep=off` (unsupported combination) -| no, 4/4 metrics vary -| 10.21–88.19 ms (8.6x) -| 199,665–234,497 B, all distinct -| 5.66–6.16 s - -| `shift=7` -| no, 3/4 metrics vary -| 2253.86–2262.97 ms (0.4%) -| 4,677,667–5,249,009 B, all distinct -| 13.81–14.45 s - -| `shift=7,sleep=off` -| yes, 0/4 metrics vary -| 2262.14 ms exact -| 3,303,901 B exact -| 13.36–13.95 s - -| `shift=4,sleep=off` -| yes, 0/4 metrics vary -| 182.04 ms exact -| 330,255 B exact -| 6.51–6.64 s -|=== - -Three further observations from the same runs: - -* Under the current default, 100 consecutive one-millisecond sleeps took - 119.37–147.92 ms instead of about 100 ms, a 24% spread. -* With `shift=auto,sleep=off` the fixed computation measured against a fixed - 20 ms deadline answered `within_deadline=yes` on one run and `no` on the - others. A timeout, retry, backoff, TTL, deadline, or rate limit can therefore - take a different branch between two runs of the same binary with the same - inputs, which would present as flakiness in the workload rather than as a - platform defect. -* The control checksum, derived only from the fixed computation, matched in - every configuration and every run. This establishes that the *fixed - computation produced the same result* while its measured virtual duration - varied. It does not establish that the guest executed an identical - instruction stream: the spin-loop chunk counts differ between runs, which - shows that it did not. - -=== What this does and does not say about RFD 1, RFD 2, and RFD 3 - -This increment does not invalidate their results, and it does not repair a -promise they made. - -RFD 2's evidence already records that semantic artifacts and the outcome digest -are stable across *passive replays* while replay-log size and wall-clock -duration vary across recordings and hosts, and that those are measurements -rather than replay identity. That scoping is correct and this increment leaves -it intact. - -The pinned emulator carries a patch. `sleep=off` needs the replay flush that -QEMU performs only from `icount_account_warp_timer()`, which returns before it -when `sleep=off`, so a recording cannot be driven under the pinned model on an -unpatched build. `poc/time-model/qemu-nosleep-replay-flush.patch` moves the flush -ahead of the sleep check, `flake.nix` applies it to the pinned emulator, and the -patch is carried until upstream includes it; dropping it is a versioned change, -because recordings made under a different emulator are not comparable. The -evidence document records the measurement, the patch, and the spike that -established it. - -Replay is also not unconditional. A successful replay requires valid recorded -artifacts and digests, a matching scenario and materialized choice plan, a -matching SimFerret executable and rebuilt initial state, the specific verified -replay log, normal QEMU termination, and matching normalized events, -assertions, and semantic outcome digest. Matching VM identity is a necessary -condition among these, not a sufficient one. Replay reproduces the timing the -guest observed because the log records it. That is not unconditional either: the -phase 3 acceptance observed a replay fail under the model the product launches -today, where the guest's clock is coupled to host real time, when the replaying -guest's instruction stream diverged from the recording's before a character -write. `rfd/0003/EVIDENCE.adoc` records that failure, what it rules out (an -incomplete recording, by the message rather than by a digest), that the mechanism -is narrowed rather than proven and a QEMU defect is not ruled out, and that the -observed rate is too thin to bound. The log records the timeline the guest -observed; it does not make a timeline that depends on host scheduling -reproducible. - -What is narrower than it may have appeared is *fresh execution*: a new -recording of the same workload with the same inputs. That is the property this -increment strengthens, and it was never claimed. - -== Determinism needs - -The platform's determinism rests on separable needs. Only the first is in scope -here, and naming the others prevents this increment from being read as a general -promise. - -[cols="1,2,2",options="header"] -|=== -| Need | Meaning | Status - -| Determinism -| Two runs of the same workload with the same inputs behave the same. -| Partially controlled. The input boundary and the replay contract are - established; clock scaling and idle pacing are this increment. The arrival - timing of live host input remains uncontrolled. - -| Compatibility -| The workload can run at all. -| Narrow by choice. Adding interfaces is surface-area work, not determinism - work, and each added interface must establish its own determinism boundary - rather than inheriting one. - -| Controllability -| Time, entropy, or ordering can be *deliberately perturbed* to test a - hypothesis. -| Not implemented and not implied by this increment. It requires an explicit - fault surface and is a separate proposal. -|=== - -Inputs whose value comes from the *host* — the host clock, host entropy, -unfiltered network, host filesystem — cannot be made deterministic from inside -the guest and stay excluded. That does not mean every interface implemented -inside the guest is automatically deterministic: a guest interface can still -expose state influenced by input delivery, device events, or entropy. In -particular, excluding entropy device nodes does not exclude the `getrandom` -system call, which needs no filesystem path. - -== Proposal - -Pin the QEMU time model for both record and replay: - -* `-icount shift=N` with a fixed `N` instead of `auto`; and -* `sleep=off`, so the guest is not paced against host real time. - -Both options were required among the tested configurations, and QEMU documents -a constraint on their use: -`sleep=off` "cannot be used together with either `shift=auto` or `align=on`". -Pinning the scale is therefore not merely preferable, it is what makes the -option QEMU describes as deterministic usable in a documented supported -configuration. Pinning the scale while -leaving host-paced idle advancement enabled left a residual spread of 0.4% in -fixed work and 3.6% in the single 20 ms sleep. - -The reproducible configuration need not cost wall-clock time: in this -measurement `shift=4,sleep=off` completed no slower than `shift=auto` while -producing a replay log ten times smaller than `shift=7,sleep=off`. - -The pinned model becomes part of versioned VM identity, and the product's record -and replay launch paths must pass that model rather than configuring it -separately. A run whose manifest records a different time model is rejected -before QEMU starts, using the existing first-incompatible-field reporting rather -than a new mechanism. - -=== Choosing the scale - -The scale is a semantic choice, not only a bootability choice. At `shift=4` the -model advances 16 nanoseconds per counted instruction and at `shift=7` it -advances 128, an eight-fold difference in the conversion factor, and the same -fixed computation measured 182 ms and 2262 ms of virtual time under the two -models. The chosen value defines an artificial performance model, and -timeout-sensitive results are conclusions about that model rather than -predictions of production timing. - -The selection rule is therefore: a fixed value that boots and completes every -validation run within the configured deadline on every host in the supported -matrix, justified against its neighbors and recorded with the reason. The -measured failure mode at the coarse end is not graceful — `shift=10` produced no -guest output within a 180-second deadline while writing a 117 MB replay log, in -a run that used the RFD 3 fixture rather than this probe and default `sleep` -behavior, so the cause is undetermined and the observation is limited to the -absence of guest output before the deadline. - -The value must be validated at boot on every supported host and re-validated -whenever the pinned QEMU or guest kernel changes. It is never derived per host, -because a host-derived value reintroduces exactly the host dependence this -increment removes. Where the pinned model cannot complete on a host, the run -must fail as an unsupported execution rather than silently falling back to -another model. - -The supported matrix for this increment is the reference x86-64 Linux -development host and GitHub-hosted `ubuntu-latest` x86-64 Linux. Additional -hosts may be validated later without changing the model. - -== What the pinned model actually is - -With a fixed shift and `sleep=off`, virtual time is not solely a function of -executed instructions. While the guest executes, time advances per counted -instruction; while the guest is idle, it jumps to the next timer deadline and -does not advance at all if no timer is enabled. The model is therefore -instruction-derived progress plus deterministic timer-driven advancement, which -QEMU describes as giving "deterministic execution times from the guest point of -view". - -That has consequences worth documenting rather than assuming: - -* a long virtual wait need not consume equivalent host wall time, which is a - service advantage and also means wall-clock duration is not a property of the - model; -* a busy-wait and an idle sleep have very different execution costs; -* periodic kernel and device timers still consume processing during a long wait; -* the relative ordering of guest timers and live host input can change, which is - the unresolved gap below; and -* stable timer behavior under this model is not necessarily representative of - physical hardware timing. - -Observed sleep overshoot is part of the model and is documented rather than -minimized. In this probe a 20 ms sleep overshot by 0.082–0.102 ms under `auto`, -0.948 ms at `shift=7,sleep=off`, and 1.951 ms at `shift=4,sleep=off`. Pinning therefore -trades a smaller but variable overshoot, measured here on one workload, for a -repeatable one. That is the right trade for reproducibility, and the repeatable -value is a property of this model and workload rather than a latency that can be -assumed for every workload. - -== Unresolved: input arrival timing - -This increment removes host-dependent clock scaling and idle pacing. It does not -make the arrival of live host input deterministic. - -Record-mode commands cross the guest serial port as framed messages paced by a -guest acknowledgement for every byte. That pacing constrains ordering and -prevents deferred replay events from overrunning the UART, but it does not give -an input byte a deterministic guest instruction position or virtual timestamp: -the guest continues executing between bytes, and how far it gets depends on host -scheduling. A workload that starts a timer after one command and races that -timer against the next command can therefore still take different branches in -two fresh recordings with identical command contents and choice plans. -`sleep=off` can accentuate this, because idle virtual time can advance quickly -while the host prepares the next byte. - -Recording the arrival positions makes a particular execution replayable; it does -not make the positions identical in a fresh recording. Closing this gap needs -deterministic input delivery — explicit barriers, a preloaded guest-side choice -plan, or scheduled injection — and is separate work. This RFD neither implements -it nor claims it. - -== Identity and versioning - -The `-icount` options change the replay log, so the time model is already -implicitly part of what a run reproduces; this increment makes it explicit and -validated. Three consequences follow. - -Runs recorded under different time models are not comparable and must not be -silently mixed, including in a seed sweep or an exploration tree. Changing the -pinned scale is a versioned change, and previous runs stay valid only under the -model they recorded. - -An existing manifest must not silently acquire the new model through a default. -A run recorded before the pinned model existed either requires the environment -it recorded, consistent with the existing executable and initial-state checks, -or is supported through an explicitly named legacy profile. Retaining an old -replay log does not by itself guarantee that a new executable can consume it. - -Wall-clock observations — how long a run took on the host — remain diagnostic -and stay out of identity, because they are a property of the host rather than of -the run. - -== What this does not guarantee - -* Workloads that require interfaces the workload root does not provide remain - unsupported. That is the compatibility need, not this one. -* Virtual time is instruction-derived progress plus idle advancement, not a - function of wall-clock time, and the model's resolution is not physical - hardware resolution. -* A fresh execution can still differ because live host input arrives at a - different point in virtual time. -* A workload can still be nondeterministic for reasons outside the time model, - including entropy derived from the deterministic boot and any interface added - later without its own determinism treatment. -* Nothing here makes time, entropy, or ordering perturbable on purpose. - -== Acceptance criteria - -This increment is complete when: - -* the probe reports zero varying time measurements across at least five complete - runs on each host in the supported matrix; -* the probe's guest measurements are equal across the supported hosts for - identical artifacts and the same model, not merely stable within each host; -* every validation run completes within the configured deadline on each - supported host, and the chosen scale is justified against its neighbors and - recorded with the reason; -* the product's record and replay launch paths pass the pinned model, and the - options actually launched match the recorded identity; -* a run recorded under the pinned model replays twice with matching normalized - events, assertions, and semantic outcome digest; -* a run whose manifest records a different time model is rejected before QEMU - starts, naming the first incompatible field; -* the probe runs as a continuous-integration gate on x86-64 Linux; -* the pinned model, its idle-advancement semantics, its wakeup behavior, its - meaning as an artificial performance model, and the unresolved input-arrival - gap are documented in the project README and the run manifest; and -* re-validating the scale when the pinned QEMU or guest kernel changes is a - documented requirement. - -== Excluded from this increment - -This proposal does not include: - -* deterministic input arrival, command barriers, or a guest-side choice plan; -* time, entropy, ordering, or scheduling fault injection, or any interface that - lets a scenario choose when a timer fires; -* dynamic linking, `/proc`, `/sys`, sockets, threads, or any other compatibility - surface for real services; -* deterministic entropy beyond what a deterministic boot already provides; -* multiple vCPUs, SMP timing models, or device-timer interaction under load; -* absolute or wall-clock time semantics, or any promise that virtual time tracks - real time; -* checkpointing, branching, or exploration; or -* performance claims beyond the wall-clock cost of the pinned scale. - -== Alternatives considered - -Keeping `shift=auto` needs no validation and was not the slowest configuration -measured, but it leaves the mapping host- and run-dependent: fixed work varied by -3.0x and short sleeps by 24% across runs. A deadline decision that flips between -runs was observed in the unsupported `sleep=off` combination rather than under -this default, and under the default every run answered the same way; the risk is -that a deadline falling inside the measured duration range would not. Rejected. - -Adding `sleep=off` alone is not a supported configuration, because QEMU -documents it as incompatible with `shift=auto`. It was measured anyway, because -the pinned QEMU accepts it in a fresh process, but the measurement does not -establish which behavior that option changed. The relative spread in fixed work -was 8.6x rather than 3.0x and the deadline decision varied between runs, although -the absolute duration range was slightly smaller. Rejected as unsupported, and -not reproducible in this sample even where it is accepted. - -Pinning the shift while leaving host-time synchronization enabled reduced the -spread to 0.4% in fixed work but left 3.6% in the single 20 ms sleep and about -2.3% across the 100 one-millisecond sleeps, and any residual means a workload -whose deadline sits near the boundary can still flip. Rejected as insufficient -rather than wrong. - -Dropping `icount` entirely would remove the mechanism, but QEMU's record and -replay require it, so this forfeits replay. Rejected. - -Enabling `align=on` aligns the virtual clock with the real clock, which is the -opposite of the goal because it increases host coupling. Rejected. - -Declaring time-dependent behavior out of scope for supported workloads would -avoid the problem by shrinking the workload class. Timeouts and retries are -precisely the behavior worth testing, so this trades the increment for a smaller -product. Rejected. - -Replacing the base model with a logical clock or an event scheduler is the most -complete long-term answer, and it would not presuppose a fixed `icount` scale. It -is a substantially larger design that would have to reproduce the whole-machine -behavior the current model already provides, so it is deferred rather than -rejected, and this increment's pinned model is a prerequisite for measuring -whether it is needed. - -Virtualizing time behind a syscall or paravirtual boundary with a -scenario-controllable clock is the right shape for the controllability need. It -presupposes a pinned base model to perturb, so scheduling it first would mean -designing a fault surface on top of a nondeterministic scale. Deferred. - -== Follow-up decision - -This increment removes a host-dependent variable rather than adding a -capability. The recommended order below is the lowest-risk sequencing for this -project, not a dependency inherent in every possible design. - -Pinning the clock first is worthwhile because variable clock scaling is an -uncontrolled experimental variable in any timing-sensitive comparison. -Exploration and seed sweeps benefit directly, although existing record and replay -can already support sweeps whose individual failures retain their logs, and -checkpoint mechanics can be investigated independently. - -Two capabilities remain candidates. Widening the compatibility surface decides -whether real services can be tested at all, and it is the larger product -question; each added interface must establish its own determinism boundary. -Time and ordering fault injection decides whether timing hypotheses can be -tested deliberately rather than merely reproduced, and it should be built on the -model this increment pins. Deterministic input arrival is a third, potentially -larger increment that this RFD identifies but does not resolve. - -RFD 3 is a reasonable product-evidence gate for deciding which of these matters -most, because a representative workload is what makes any of them measurable. It -is not a technical prerequisite for investigating them; this increment's own -probe is evidence that useful measurement can precede a representative service. - -== Implementation - -Delivery phases are tracked in link:IMPLEMENTATION.adoc[RFD 4 implementation checklist]. -The pre-RFD measurement, its aggregate results, its caveats, and the commands -that reproduce it are retained beside the probe in -link:../../poc/time-model/EVIDENCE.adoc[the time-model evidence]; the raw -per-run serial and replay artifacts stay in the untracked `.poc/` output -directory. Validation results produced while implementing this proposal will be -retained in link:EVIDENCE.adoc[RFD 4 evidence]. - -The probe and the evidence document are introduced by the companion change that -adds `scripts/time-model-probe.sh` and `poc/time-model/EVIDENCE.adoc`; they are -not part of this document's own change. This RFD's evidence therefore depends on -that change, and the two must land together rather than this document first. - -== References - -* https://www.qemu.org/docs/master/system/replay.html[QEMU record/replay] -* https://www.qemu.org/docs/master/system/invocation.html[QEMU invocation and `-icount`] -* link:../../poc/time-model/EVIDENCE.adoc[Guest time-model measurements] -* link:../0001/README.adoc[RFD 1: Deterministic execution proof of concept] -* link:../0002/README.adoc[RFD 2: Deterministic network fault model] -* link:../0003/README.adoc[RFD 3: Reproducible workload packaging] diff --git a/rfd/0005/IMPLEMENTATION.adoc b/rfd/0005/IMPLEMENTATION.adoc deleted file mode 100644 index 5c1c289..0000000 --- a/rfd/0005/IMPLEMENTATION.adoc +++ /dev/null @@ -1,41 +0,0 @@ -= RFD 0005 implementation checklist - -Implements link:README.adoc[RFD 5: CI execution and historical results MVP]. - -== Foundation - -* [ ] Finish RFD 4 identity, rejection, migration policy, and documentation. -* [ ] Inspect Ryusen's current recovery tests and define the durable-result oracle. -* [ ] Measure Ryusen guest compatibility and record required runtime extensions. -* [ ] Review the process coordination and retained-state design before implementation. - -== Execution MVP - -* [ ] Execute the real Ryusen server and worker under the supported guest profile. -* [ ] Inject server-process failure and restart with retained SQLite state. -* [ ] Assert completion without re-executing a durably accepted step. -* [ ] Detect a deliberate regression with the same property checker. -* [ ] Replay the failing recording twice with matching events and assertions. -* [ ] Run the acceptance case in GitHub Actions and record time and artifact budgets. - -== CI distribution and reports - -* [ ] Specify the versioned CI-neutral report and stable test/runtime identities. -* [ ] Separate property verdicts, infrastructure errors, and upload failures. -* [ ] Define replay-environment availability and incompatible-version rejection. -* [ ] Package a pinned runtime without per-job QEMU source builds. -* [ ] Deliver a thin Action in a separate repository with an end-to-end consumer example. - -== Historical results - -* [ ] Settle repository visibility, authentication, authorization, and fork-PR trust. -* [ ] Define safe summary fields, upload idempotency, retention, and deletion. -* [ ] Implement optional upload without changing local test verdicts. -* [ ] Show historical results by repository, revision, and stable test identity. -* [ ] Verify execution and replay remain useful when the service is unavailable. - -== Lighthouse review gate - -* [ ] Recheck Lighthouse progress near completion of the Ryusen CI integration. -* [ ] Confirm implemented acknowledgement and duplicate semantics before selecting tests. -* [ ] Define controlled dependency boundaries and a separately scoped ingestion-failure increment. diff --git a/rfd/0005/README.adoc b/rfd/0005/README.adoc deleted file mode 100644 index 7840393..0000000 --- a/rfd/0005/README.adoc +++ /dev/null @@ -1,131 +0,0 @@ -:authors: Darwin Wu -:state: discussion -:discussion: https://github.com/chaba-dev/simferret/pull/49 -:labels: ci, product, replay - -= RFD 5 CI execution and historical results MVP - -== Decision and scope - -SimFerret will run in the user's CI, initially GitHub Actions, rather than -requiring a hosted execution fleet. The main SimFerret release is open source. -A separate Action repository will make pinned installation and execution easy -to reference. Other CI systems should use the same CLI and report contract; -execution must not depend on GitHub-specific APIs. - -A separate results service will receive optional uploads and provide historical -results by repository, revision, and test. Local execution, reports, and replay -must remain useful without that service. Upload failure must not rewrite the -test verdict; upload status is reported separately. - -These product choices were agreed in the -https://ampcode.com/threads/T-01a0ca68-a003-73a0-a12d-21735b1462ef[planning thread]. -This RFD is under review before publication as project direction; -the acceptance sequence below is a proposed way to deliver the agreed scope, -not evidence of implemented capabilities. - -== Existing foundation and gaps - -RFDs 1 through 3 establish bounded record/replay, a controlled network outage, -workload packaging, and a supervised workload runtime. They do not establish -general application test configuration or a CI results service. RFD 4 pins the -guest time model, with identity/versioning and contract work still outstanding -at this decision point. - -Replaying one retained recording is distinct from making fresh executions with -the same seed identical. Live input arrival remains an unresolved source of -fresh-execution variation. This MVP must not advertise seed-only reproduction; -a stronger fresh-execution promise needs its own deterministic-ingress design. - -== First acceptance application: Ryusen - -Ryusen is the first execution-MVP gate. Use its local SQLite backend and real -server and connected Rust SDK worker, not FoundationDB. The proposed test is: - -. Start the server and worker and submit a bounded workflow. -. Observe a durably accepted step result at an explicitly defined boundary. -. Kill and restart the server while retaining its SQLite data. -. Require completion without re-executing the already accepted step. -. Replay the recording twice with matching normalized events and assertions. -. Demonstrate that a deliberately introduced regression fails the property. - -An authorized effect whose result is unresolved is a different case: Ryusen's -contract may require `Unknown`, not automatic retry or exactly-once execution. -Derive the oracle from Ryusen's current protocol and recovery tests before -implementing either case. - -The current SimFerret runtime supervises one workload at a time and creates a -fresh writable root on restart. Compatibility discovery must therefore resolve -server/worker/client coordination, storage retained across process restart, -threads, sockets, entropy, and guest filesystem needs. Do not silently change -the existing fresh-root contract. A process crash with retained files does not -establish VM power-loss or disk-durability behavior. - -== Follow-on application: Lighthouse - -Lighthouse is the second candidate, for ingestion failures. It does not gate the -first release. Recheck its implementation and settled contracts when the Ryusen -CI slice is close to integration; do not freeze its current proposal into -SimFerret requirements. This is a milestone review, not a scheduled monitor. - -The current direction in the -https://ampcode.com/threads/T-01a0cd03-0646-7549-8a5e-8c3395c92092[Lighthouse thread] -is OTel Collector ingestion into ClickHouse, object-storage overflow during -downstream failure, and separate catch-up Collectors. Candidate scenarios are -primary outage, recovery with backlog, catch-up crash around acknowledgement, -and simultaneous primary/overflow failure. Durable acceptance and duplicate -semantics must be settled before writing assertions. Do not assume the older -custom batch-receipt proposal is the OTLP client contract. - -Dependencies must be within controlled execution boundaries or explicitly -scoped test doubles. A model test does not qualify a real cloud provider, and -live cloud dependencies must not inherit the deterministic replay guarantee. - -== Delivery sequence and acceptance - -. Complete RFD 4's identity, compatibility rejection, and documentation work. -. Establish Ryusen's supported guest profile and exact recovery oracle, then - specify the smallest runtime extension needed to execute it. -. Run the recovery scenario in GitHub Actions, detect a deliberate regression, - retain replay artifacts, and reproduce the failing recording twice. -. Define a versioned CI-neutral report with stable test identity, revision and - runtime identity, assertion outcomes, infrastructure errors, and replay - references. Measure execution time and artifact sizes to set CI budgets. -. Distribute a pinned runtime and a thin Action from a separate repository; - avoid requiring a QEMU source build in every consumer job. -. Add optional upload and historical results using that report contract. -. Reassess Lighthouse before committing to its integration design. - -The execution milestone is independently useful, but the full product MVP also -requires result ingestion and history. Passing local tests alone does not mean -the Action, releases, or service have been published or deployed. - -== Open decisions and non-goals - -Before service implementation, decide public/private repository support, -authentication and authorization, fork-PR upload trust, report idempotency, -retention/deletion, and the initial history interface. No service stack or -hosting provider is selected here. - -Replay bundles may contain private workload bytes and inputs. The proposed -default is summary-only upload with full bundles retained as customer CI -artifacts; specify the safe summary schema and explicit full-bundle consent -before uploading. Define how users obtain matching execution environments for -retained recordings and how unsupported identities are rejected. - -Hosted execution, public multi-tenant workload isolation, billing, arbitrary -Compose/Kubernetes topologies, checkpoint exploration, and production timing -claims are outside this MVP. Broader runtime and fault surfaces need separate -design and evidence, not implicit inclusion through an application choice. - -== Coordination - -Planning and integration ownership remain in the coordinating thread. -Implementation is delegated to DeepSeek subthreads on runner `sophie`, with -isolated workspaces or explicit disjoint ownership and exact source revisions. -Existing work must be preserved. Publishing repositories, releases, changes, or -deployments requires the owner's applicable authorization. - -== Implementation - -Progress is tracked in link:IMPLEMENTATION.adoc[RFD 5 implementation checklist]. diff --git a/rfd/README.adoc b/rfd/README.adoc deleted file mode 100644 index 761b418..0000000 --- a/rfd/README.adoc +++ /dev/null @@ -1,91 +0,0 @@ -= SimFerret Requests for Discussion - -Requests for Discussion (RFDs) capture ideas early enough to shape them through -written discussion and preserve the reasoning behind decisions. An RFD is not -authoritative merely because it exists; its `state` says how it should be read. - -[cols="1,3", options="header"] -|=== -| RFD | Topic - -| link:0001/README.adoc[1: Deterministic execution proof of concept] -| Rust/QEMU execution architecture and a bounded record/replay demonstration with a controlled process failure - -| link:0002/README.adoc[2: Deterministic network fault model] -| Record and replay a bounded network outage through an explicit QEMU network boundary - -| link:0003/README.adoc[3: Reproducible workload packaging] -| Normalize standalone binaries and local OCI images into one deterministic guest workload - -| link:0004/README.adoc[4: Deterministic guest time model] -| Remove host-dependent clock scaling and idle pacing from guest execution - -| link:0005/README.adoc[5: CI execution and historical results MVP] -| GitHub Actions first, optional historical results, Ryusen acceptance, and a later Lighthouse review -|=== - -== Source format - -Each RFD lives at `rfd/NNNN/README.adoc`, where `NNNN` is a four-digit number. -The document starts with canonical AsciiDoc attributes and an unpadded title: - -[source,asciidoc] ----- -:authors: Name -:state: prediscussion -:discussion: -:labels: software, process - -= RFD 7 Example title ----- - -`authors` contains semicolon-separated owners. `discussion` contains the RFD's -pull-request URL once discussion starts. `labels` is a comma-separated set of -searchable topics. The document is the single source of truth for this metadata; -the index intentionally does not duplicate it. - -Implementation progress lives separately in `rfd/NNNN/IMPLEMENTATION.adoc`; it -is the only implementation checklist format. Its first line is -`= RFD NNNN implementation checklist`, and it contains the standalone sentence -`Implements link:README.adoc[...].`. The RFD links with -`link:IMPLEMENTATION.adoc[...]`. The RFD and checklist thus link to each other, -keeping the design and decision record stable while implementation tasks are -checked off. Each phase records its status in a `Status: DONE.` or -`Status: TODO.` line, which documents the phase and does not set the RFD's -state. The index at `rfd/README.adoc` links to every RFD with -`link:NNNN/README.adoc[...]`. - -Checklist tasks are AsciiDoc checklist items: `*` bullets (`**` for nested -tasks) followed by `[ ]`, `[x]`, or the alternate checked `[*]`, plus the -project's partial `[-]` marker, which AsciiDoc renders as text. Only `[x]` and -`[*]` count as complete; an uppercase `[X]`, which AsciiDoc does not recognize -as a checkbox, is rejected. Examples that resemble tasks belong in listing -(`----`), literal (`....`), or comment (`////`) blocks, in `//` line comments, -or in inline code spans so they are excluded from status totals. - -== States - -* `prediscussion`: actively being written and not ready for broad review. -* `ideation`: a narrowly scoped topic or scratchpad without active revision. -* `discussion`: under active review in the linked pull request. -* `published`: discussion has converged and the RFD expresses project direction. -* `committed`: the proposal is fully implemented and describes current behavior. -* `abandoned`: deliberately not proceeding or otherwise retained only for history. - -The usual path is `prediscussion` or `ideation` to `discussion`, then -`published`, and eventually `committed`. `abandoned` is an off-ramp at any stage. -Implementation checklist progress does not determine the RFD's state. - -== Lifecycle - -Reserve the next unused four-digit number and create `rfd/NNNN/README.adoc` and -its `IMPLEMENTATION.adoc` checklist on a branch. Cross-link the two documents. -Use `prediscussion` while writing or `ideation` for a topic placeholder. When -the document is ready for review, open a pull request, set the state to -`discussion`, and add that pull request as the discussion URL. - -Before merging a proposal that represents project direction, move it to -`published`. Once the described work is entirely implemented, update it to -`committed`. Material changes to a published or committed RFD go through a new -pull request and retain the original discussion link unless the RFD explicitly -documents a replacement. diff --git a/scripts/check-rfd-status-test.sh b/scripts/check-rfd-status-test.sh deleted file mode 100755 index 3f9e7ec..0000000 --- a/scripts/check-rfd-status-test.sh +++ /dev/null @@ -1,606 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -checker="${repo_root}/scripts/check-rfd-status.sh" -test_root="$(mktemp -d "${TMPDIR:-/tmp}/simferret-rfd-check.XXXXXX")" -rfd_root="${test_root}/rfd" -output="${test_root}/output" -trap 'rm -rf "${test_root}"' EXIT - -reset_fixtures() { - rm -rf "${rfd_root}"; mkdir -p "${rfd_root}" - printf '= Test RFDs\n' >"${rfd_root}/README.adoc" -} - -run_success() { - local expected="${1:-}" - if ! NO_COLOR=1 RFD_DIR="${rfd_root}" bash "${checker}" >"${output}" 2>&1; then - cat "${output}" >&2; printf 'expected RFD checker to pass\n' >&2; exit 1 - fi - if [[ -n "${expected}" ]] && ! grep -Fq "${expected}" "${output}"; then - cat "${output}" >&2; printf 'RFD checker output did not include: %s\n' "${expected}" >&2; exit 1 - fi -} - -run_failure() { - local expected="$1" - if NO_COLOR=1 RFD_DIR="${rfd_root}" bash "${checker}" >"${output}" 2>&1; then - cat "${output}" >&2; printf 'expected RFD checker to fail with: %s\n' "${expected}" >&2; exit 1 - fi - if ! grep -Fq "${expected}" "${output}"; then - cat "${output}" >&2; printf 'RFD checker failure did not include: %s\n' "${expected}" >&2; exit 1 - fi -} - -assert_labels_align() { - local header_column row_column rows=0 - header_column="$(awk 'NR == 1 { print index($0, "Labels") }' "${output}")" - if [[ "${header_column}" -eq 0 ]]; then - cat "${output}" >&2 - printf 'Labels header column was not found\n' >&2 - exit 1 - fi - while IFS= read -r row_column; do - rows=$((rows + 1)) - if [[ "${row_column}" -ne "${header_column}" ]]; then - cat "${output}" >&2 - printf 'Labels column is not vertically aligned\n' >&2 - exit 1 - fi - done < <(awk '/^[0-9][0-9][0-9][0-9] / { print index($0, "software, process") }' "${output}") - if [[ "${rows}" -eq 0 ]]; then - cat "${output}" >&2 - printf 'Labels column was not found in any RFD row\n' >&2 - exit 1 - fi -} - -run_missing_directory_failure() { - if NO_COLOR=1 RFD_DIR="${test_root}/missing" bash "${checker}" >"${output}" 2>&1; then - cat "${output}" >&2; printf 'expected missing RFD directory to fail\n' >&2; exit 1 - fi - grep -Fq "RFD directory not found" "${output}" || { - cat "${output}" >&2; printf 'missing directory diagnostic was not emitted\n' >&2; exit 1 - } -} - -write_valid_rfd() { - local state="$1" discussion="$2" - mkdir -p "${rfd_root}/0001" - printf '\nlink:0001/README.adoc[1: Valid RFD]\n' >>"${rfd_root}/README.adoc" - cat >"${rfd_root}/0001/README.adoc" < -:state: ${state} -:discussion: ${discussion} -:labels: software, process - -= RFD 1 Valid RFD - -== Implementation - -See link:IMPLEMENTATION.adoc[implementation checklist]. -EOF - cat >"${rfd_root}/0001/IMPLEMENTATION.adoc" <<'EOF' -= RFD 0001 implementation checklist - -Implements link:README.adoc[RFD 1: Valid RFD]. - -* [ ] Complete the work. -EOF -} - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak 's/Valid RFD/A title long enough to exceed the minimum column width/' "${rfd_root}/README.adoc" "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/README.adoc.bak" "${rfd_root}/0001/README.adoc.bak" -run_success "A title long enough to exceed the minimum column width" -assert_labels_align - -reset_fixtures; write_valid_rfd prediscussion "" -mkdir -p "${rfd_root}/0002" -printf '\nlink:0002/README.adoc[2: Second RFD]\n' >>"${rfd_root}/README.adoc" -cat >"${rfd_root}/0002/README.adoc" <<'EOF' -:authors: Example Author -:state: prediscussion -:discussion: -:labels: software, process - -= RFD 2 Second RFD - -== Implementation - -See link:IMPLEMENTATION.adoc[implementation checklist]. -EOF -{ - printf '= RFD 0002 implementation checklist\n\nImplements link:README.adoc[RFD 2: Second RFD].\n' - for ((task = 1; task <= 100; task++)); do - printf -- '* [x] Finished task %s.\n' "${task}" - done -} >"${rfd_root}/0002/IMPLEMENTATION.adoc" -run_success "0001 prediscussion 0/1 Valid RFD" -run_success "0002 prediscussion 100/100 Second RFD" -assert_labels_align - -reset_fixtures; write_valid_rfd discussion https://example.com/pull/1 -cat >>"${rfd_root}/0001/IMPLEMENTATION.adoc" <<'EOF' -* [x] Finished task. -** [x] Finished nested task. -* [-] Partially finished task. -** [-] Partially finished nested task. -* [*] Alternate checked task. - ----- -* [x] Example, not a task. ----- - -.... -** [x] Example, not a task. -.... - -//// -* [-] Example, not a task. -//// - -// * [x] Commented, not a task. - -+ [x] A list continuation is not a task marker. -EOF -cat >>"${rfd_root}/0001/README.adoc" <<'EOF' - -[source,asciidoc] ----- -:state: committed -* [ ] Example, not an implementation task. -.... -:labels: still-inside-the-listing -.... -link:NOT-A-CHECKLIST[Example link] ----- -EOF -run_success "0001 discussion 3/6" - -reset_fixtures; write_valid_rfd prediscussion "" -cat >>"${rfd_root}/0001/IMPLEMENTATION.adoc" <<'EOF' -* [x] Finished task. -** [x] Another finished task. - ----- -* [x] Example, not a task. -.... -** [x] Still inside the listing block. -//// -* [x] A comment delimiter inside a listing block stays literal. ----- -* [x] Visible task. -EOF -run_success "0001 prediscussion 3/4" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '\n* [x]\n* [ ]\n' >>"${rfd_root}/0001/IMPLEMENTATION.adoc" -run_success "0001 prediscussion 1/3" - -reset_fixtures; write_valid_rfd prediscussion "" -cat >>"${rfd_root}/0001/IMPLEMENTATION.adoc" <<'EOF' -//// -* [x] Hidden in a comment block. -//// -* [x] Visible after a comment block. -// * [ ] Hidden on a line comment. -* [x] Visible after a line comment. -EOF -run_success "0001 prediscussion 2/3" - -reset_fixtures; write_valid_rfd prediscussion "" -cat >>"${rfd_root}/0001/IMPLEMENTATION.adoc" <<'EOF' -.... -* [x] Hidden in a literal block. -.... -* [x] Visible after a literal block. -EOF -run_success "0001 prediscussion 1/2" - -reset_fixtures; write_valid_rfd prediscussion "" -cat >>"${rfd_root}/0001/IMPLEMENTATION.adoc" <<'EOF' -----not-a-delimiter -* [x] Visible after an invalid delimiter. -EOF -run_success "0001 prediscussion 1/2" - -reset_fixtures; write_valid_rfd prediscussion "" -cat >>"${rfd_root}/0001/IMPLEMENTATION.adoc" <<'EOF' -- [x] A hyphen is also an AsciiDoc list marker. -EOF -run_success "0001 prediscussion 1/2" - -reset_fixtures; write_valid_rfd prediscussion "" -cat >>"${rfd_root}/0001/README.adoc" <<'EOF' - -//// -:state: committed -* [-] Example, not an implementation task. -link:NOT-A-CHECKLIST[Example link] -//// -EOF -run_success "0001 prediscussion 0/1" - -run_missing_directory_failure - -reset_fixtures; rm "${rfd_root}/README.adoc" -run_failure "RFD index not found" - -reset_fixtures -run_failure "no RFDs found" - -reset_fixtures; write_valid_rfd prediscussion "" -rm "${rfd_root}/0001/IMPLEMENTATION.adoc" -run_failure "missing implementation checklist" - -reset_fixtures; write_valid_rfd prediscussion "" -rm "${rfd_root}/0001/README.adoc" -run_failure "missing canonical RFD source" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '= Test RFDs\n' >"${rfd_root}/README.adoc" -run_failure "RFD index must link to each RFD" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '= Test RFDs\n\n// link:0001/README.adoc[comment only]\n' >"${rfd_root}/README.adoc" -run_failure "RFD index must link to each RFD" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '= Test RFDs\n\n////\nlink:0001/README.adoc[comment only]\n////\n' >"${rfd_root}/README.adoc" -run_failure "RFD index must link to each RFD" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '= Test RFDs\n\nlink:0001/README.adoc[truncated\n' >"${rfd_root}/README.adoc" -run_failure "RFD index must link to each RFD" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '= Test RFDs\n\nnolink:0001/README.adoc[not a link]\n' >"${rfd_root}/README.adoc" -run_failure "RFD index must link to each RFD" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '= Test RFDs\n\nlink:0001/README.adoc[escaped close\\]\n' >"${rfd_root}/README.adoc" -run_failure "RFD index must link to each RFD" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '= Test RFDs\n\n``link:0001/README.adoc[code only]``\n' >"${rfd_root}/README.adoc" -run_failure "RFD index must link to each RFD" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '= Test RFDs\n\n`link:0001/README.adoc[code]`; link:0001/README.adoc[visible]\n' >"${rfd_root}/README.adoc" -run_success - -reset_fixtures; write_valid_rfd prediscussion "" -printf '\n* [ ] This belongs in the implementation document.\n' >>"${rfd_root}/0001/README.adoc" -run_failure "implementation checkboxes belong in a separate implementation document" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '\n ** [ ] This also belongs in the implementation document.\n' >>"${rfd_root}/0001/README.adoc" -run_failure "implementation checkboxes belong in a separate implementation document" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '\n* [*] This checked item also belongs in the implementation document.\n' >>"${rfd_root}/0001/README.adoc" -run_failure "implementation checkboxes belong in a separate implementation document" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '\n* [-] This partial item also belongs in the implementation document.\n' >>"${rfd_root}/0001/README.adoc" -run_failure "implementation checkboxes belong in a separate implementation document" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '\n* [ ]\n' >>"${rfd_root}/0001/README.adoc" -run_failure "implementation checkboxes belong in a separate implementation document" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '\n// * [ ] Commented-out checkbox.\n' >>"${rfd_root}/0001/README.adoc" -run_success - -reset_fixtures; write_valid_rfd prediscussion "" -printf '\n+ [ ] Not an AsciiDoc checkbox.\n' >>"${rfd_root}/0001/README.adoc" -run_success - -reset_fixtures; write_valid_rfd prediscussion "" -cat >>"${rfd_root}/0001/README.adoc" <<'EOF' - ----- -* [ ] Example checkbox inside a listing block. ----- -EOF -run_success - -reset_fixtures; write_valid_rfd prediscussion "" -printf '# RFD 0001 implementation checklist\n\nImplements [RFD 1](README.adoc).\n' >"${rfd_root}/0001/IMPLEMENTATION.md" -run_failure "retired implementation checklist format: 0001/IMPLEMENTATION.md" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '#+TITLE: RFD 0001 implementation checklist\n\nImplements [[file:README.adoc][RFD 1: Valid RFD]].\n' >"${rfd_root}/0001/IMPLEMENTATION.org" -run_failure "retired implementation checklist format: 0001/IMPLEMENTATION.org" - -reset_fixtures; write_valid_rfd prediscussion "" -rm "${rfd_root}/0001/IMPLEMENTATION.adoc" -printf '#+TITLE: RFD 0001 implementation checklist\n\nImplements [[file:README.adoc][RFD 1: Valid RFD]].\n' >"${rfd_root}/0001/IMPLEMENTATION.org" -run_failure "missing implementation checklist" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '1s/.*/== invalid heading/' "${rfd_root}/0001/IMPLEMENTATION.adoc" -rm "${rfd_root}/0001/IMPLEMENTATION.adoc.bak" -run_failure "invalid implementation checklist heading" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/Implements/d' "${rfd_root}/0001/IMPLEMENTATION.adoc" -rm "${rfd_root}/0001/IMPLEMENTATION.adoc.bak" -run_failure "implementation checklist must link to its RFD" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/Implements/d' "${rfd_root}/0001/IMPLEMENTATION.adoc" -rm "${rfd_root}/0001/IMPLEMENTATION.adoc.bak" -cat >>"${rfd_root}/0001/IMPLEMENTATION.adoc" <<'EOF' - ----- -Implements link:README.adoc[RFD link shown as a listing]. ----- -EOF -run_failure "implementation checklist must link to its RFD" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/Implements/d' "${rfd_root}/0001/IMPLEMENTATION.adoc" -rm "${rfd_root}/0001/IMPLEMENTATION.adoc.bak" -cat >>"${rfd_root}/0001/IMPLEMENTATION.adoc" <<'EOF' - -.... -Implements link:README.adoc[RFD link shown as a literal]. -.... -EOF -run_failure "implementation checklist must link to its RFD" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/Implements/d' "${rfd_root}/0001/IMPLEMENTATION.adoc" -rm "${rfd_root}/0001/IMPLEMENTATION.adoc.bak" -cat >>"${rfd_root}/0001/IMPLEMENTATION.adoc" <<'EOF' - -//// -Implements link:README.adoc[RFD link shown as a comment]. -//// -EOF -run_failure "implementation checklist must link to its RFD" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/Implements/d' "${rfd_root}/0001/IMPLEMENTATION.adoc" -rm "${rfd_root}/0001/IMPLEMENTATION.adoc.bak" -printf '\n// Implements link:README.adoc[RFD link shown as a line comment].\n' >>"${rfd_root}/0001/IMPLEMENTATION.adoc" -run_failure "implementation checklist must link to its RFD" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/Implements/d' "${rfd_root}/0001/IMPLEMENTATION.adoc" -rm "${rfd_root}/0001/IMPLEMENTATION.adoc.bak" -printf '\n`Implements link:README.adoc[RFD link shown as inline code].`\n' >>"${rfd_root}/0001/IMPLEMENTATION.adoc" -run_failure "implementation checklist must link to its RFD" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/Implements/d' "${rfd_root}/0001/IMPLEMENTATION.adoc" -rm "${rfd_root}/0001/IMPLEMENTATION.adoc.bak" -printf '\nImplements [[file:README.adoc][Org-style link]].\n' >>"${rfd_root}/0001/IMPLEMENTATION.adoc" -run_failure "implementation checklist must link to its RFD" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/Implements/d' "${rfd_root}/0001/IMPLEMENTATION.adoc" -rm "${rfd_root}/0001/IMPLEMENTATION.adoc.bak" -printf '\nImplements [Markdown-style link](README.adoc).\n' >>"${rfd_root}/0001/IMPLEMENTATION.adoc" -run_failure "implementation checklist must link to its RFD" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/Implements/d' "${rfd_root}/0001/IMPLEMENTATION.adoc" -rm "${rfd_root}/0001/IMPLEMENTATION.adoc.bak" -cat >>"${rfd_root}/0001/IMPLEMENTATION.adoc" <<'EOF' - -//// -Implements link:README.adoc[comment only]. -//// -Implements link:README.adoc[RFD 1: Valid RFD]. -EOF -run_success - -reset_fixtures; write_valid_rfd prediscussion "" -printf '\n* [y] Invalid AsciiDoc task state.\n' >>"${rfd_root}/0001/IMPLEMENTATION.adoc" -run_failure "invalid AsciiDoc task state" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '\n* [X] An uppercase state is not an AsciiDoc checkbox.\n' >>"${rfd_root}/0001/IMPLEMENTATION.adoc" -run_failure "invalid AsciiDoc task state" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/link:IMPLEMENTATION.adoc/d' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -run_failure "RFD must link to its implementation checklist" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/link:IMPLEMENTATION.adoc/d' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -cat >>"${rfd_root}/0001/README.adoc" <<'EOF' - ----- -link:IMPLEMENTATION.adoc[Example link] ----- -EOF -run_failure "RFD must link to its implementation checklist" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/link:IMPLEMENTATION.adoc/d' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -printf '\n// link:IMPLEMENTATION.adoc[comment only]\n' >>"${rfd_root}/0001/README.adoc" -run_failure "RFD must link to its implementation checklist" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/link:IMPLEMENTATION.adoc/d' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -printf '\nlink:IMPLEMENTATION.adoc[truncated\n' >>"${rfd_root}/0001/README.adoc" -run_failure "RFD must link to its implementation checklist" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/link:IMPLEMENTATION.adoc/d' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -printf '\nnolink:IMPLEMENTATION.adoc[not a link]\n' >>"${rfd_root}/0001/README.adoc" -run_failure "RFD must link to its implementation checklist" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/link:IMPLEMENTATION.adoc/d' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -printf '\nA literal backtick is \\`; link:IMPLEMENTATION.adoc[visible].\n' >>"${rfd_root}/0001/README.adoc" -run_success - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/link:IMPLEMENTATION.adoc/d' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -printf '\n``link:IMPLEMENTATION.adoc[code only]``\n' >>"${rfd_root}/0001/README.adoc" -run_failure "RFD must link to its implementation checklist" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/link:IMPLEMENTATION.adoc/d' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -printf '\n`link:IMPLEMENTATION.adoc[code]`; link:IMPLEMENTATION.adoc[visible]\n' >>"${rfd_root}/0001/README.adoc" -run_success - -reset_fixtures; write_valid_rfd draft "" -run_failure "invalid state: draft" - -reset_fixtures; write_valid_rfd discussion "" -run_failure "state discussion requires a discussion URL" - -reset_fixtures; write_valid_rfd discussion "https://" -run_failure "discussion must be empty or an HTTP(S) URL" - -reset_fixtures; write_valid_rfd discussion "https://?query" -run_failure "discussion must be empty or an HTTP(S) URL" - -reset_fixtures; write_valid_rfd discussion "https://#fragment" -run_failure "discussion must be empty or an HTTP(S) URL" - -reset_fixtures; write_valid_rfd discussion "https://:" -run_failure "discussion must be empty or an HTTP(S) URL" - -reset_fixtures; write_valid_rfd discussion "https://[" -run_failure "discussion must be empty or an HTTP(S) URL" - -reset_fixtures; write_valid_rfd discussion "https://host:bad" -run_failure "discussion must be empty or an HTTP(S) URL" - -reset_fixtures; write_valid_rfd discussion "https://example.com/pull/1 trailing-space" -run_failure "discussion must be empty or an HTTP(S) URL" - -reset_fixtures; write_valid_rfd discussion "https://[.]" -run_failure "discussion must be empty or an HTTP(S) URL" - -reset_fixtures; write_valid_rfd discussion "https://[:::]" -run_failure "discussion must be empty or an HTTP(S) URL" - -reset_fixtures; write_valid_rfd discussion "HTTPS://github.com/chaba-dev/simferret/pull/1" -run_success - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '1s/.*/:authors: Example Author ; Missing Address/' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -run_failure "each author must include a name and address in angle brackets" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '4s/.*/:labels: ,/' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -run_failure "labels must be comma-separated names" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '1s/.*/:state: prediscussion/; 2s/.*/:authors: Example Author /' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -run_failure "first line must be the authors attribute" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '2s/.*/:authors: Another Author /' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -run_failure "second line must be the state attribute" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '3s/.*/not a discussion attribute/' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -run_failure "third line must be the discussion attribute" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '4s/.*/not a labels attribute/' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -run_failure "fourth line must be the labels attribute" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '5s/.*/not blank/' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -run_failure "canonical attributes must be followed by a blank line" - -reset_fixtures; write_valid_rfd prediscussion "" -{ - head -n 5 "${rfd_root}/0001/README.adoc" - printf 'Title moved down\n\n= RFD 1 Valid RFD\n' - tail -n +7 "${rfd_root}/0001/README.adoc" -} >"${rfd_root}/0001/README.adoc.tmp" -mv "${rfd_root}/0001/README.adoc.tmp" "${rfd_root}/0001/README.adoc" -run_failure "sixth line must be the tab-free RFD title" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak $'6s/Valid RFD/Valid\tRFD/' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -run_failure "sixth line must be the tab-free RFD title" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '6s/Valid RFD/ /' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -run_failure "sixth line must be the tab-free RFD title" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak 's/See link:/Use `simferret`; see link:/' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -run_success - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '1a\ -:authors: Another Author -' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -run_failure "exactly one non-empty authors attribute" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '\n:state: abandoned\n' >>"${rfd_root}/0001/README.adoc" -run_failure "exactly one non-empty state attribute" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '\n:discussion: https://example.com/other\n' >>"${rfd_root}/0001/README.adoc" -run_failure "exactly one discussion attribute" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '\n:labels: duplicate\n' >>"${rfd_root}/0001/README.adoc" -run_failure "exactly one non-empty labels attribute" - -reset_fixtures; write_valid_rfd prediscussion "" -printf '\n= RFD 1 Duplicate title\n' >>"${rfd_root}/0001/README.adoc" -run_failure "exactly one RFD title" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/^:labels:/d' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -run_failure "exactly one non-empty labels attribute" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/^:discussion:/d' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -run_failure "exactly one discussion attribute" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak '/^= RFD 1 /d' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -run_failure "exactly one RFD title" - -reset_fixtures; write_valid_rfd prediscussion "" -sed -i.bak 's/= RFD 1 /= RFD 2 /' "${rfd_root}/0001/README.adoc" -rm "${rfd_root}/0001/README.adoc.bak" -run_failure "does not match directory number 1" - -reset_fixtures; mkdir -p "${rfd_root}/1" -printf '= RFD 1 Invalid directory\n' >"${rfd_root}/1/README.adoc" -run_failure "invalid RFD entry" - -printf 'RFD checker tests passed.\n' diff --git a/scripts/check-rfd-status.sh b/scripts/check-rfd-status.sh deleted file mode 100755 index 4f03296..0000000 --- a/scripts/check-rfd-status.sh +++ /dev/null @@ -1,333 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -rfd_root="${RFD_DIR:-${repo_root}/rfd}" - -if [[ -z "${NO_COLOR:-}" && (-t 1 || -n "${FORCE_COLOR:-}") ]]; then - color_reset=$'\033[0m'; color_bold=$'\033[1m'; color_red=$'\033[31m' - color_green=$'\033[32m'; color_yellow=$'\033[33m'; color_blue=$'\033[34m'; color_dim=$'\033[2m' -else - color_reset=""; color_bold=""; color_red=""; color_green="" - color_yellow=""; color_blue=""; color_dim="" -fi - -if [[ ! -d "${rfd_root}" ]]; then - printf "%sRFD directory not found:%s %s\n" "${color_red}" "${color_reset}" "${rfd_root}" >&2 - exit 1 -fi -if [[ ! -f "${rfd_root}/README.adoc" ]]; then - printf "%sRFD index not found:%s %s/README.adoc\n" "${color_red}" "${color_reset}" "${rfd_root}" >&2 - exit 1 -fi - -colorize_state() { - local state="$1" padded="$2" - case "${state}" in - prediscussion | ideation) printf "%s%s%s" "${color_blue}" "${padded}" "${color_reset}" ;; - discussion) printf "%s%s%s" "${color_yellow}" "${padded}" "${color_reset}" ;; - published | committed) printf "%s%s%s" "${color_green}" "${padded}" "${color_reset}" ;; - abandoned) printf "%s%s%s" "${color_dim}" "${padded}" "${color_reset}" ;; - *) printf "%s%s%s" "${color_red}" "${padded}" "${color_reset}" ;; - esac -} - -adoc_contains() { - local source="$1" needle="$2" - awk -v needle="${needle}" ' - $0 == "----" || $0 == "...." || $0 == "////" { - if (!blocked) { blocked = 1; delimiter = $0 } - else if ($0 == delimiter) { blocked = 0; delimiter = "" } - next - } - !blocked && $0 !~ /^[[:space:]]*\/\// { - in_single = 0; in_double = 0 - for (i = 1; i <= length($0); i++) { - backslashes = 0 - for (j = i - 1; j > 0 && substr($0, j, 1) == "\\"; j--) backslashes++ - if (backslashes % 2 == 0 && substr($0, i, 2) == "``") { in_double = !in_double; i++; continue } - if (backslashes % 2 == 0 && substr($0, i, 1) == "`" && !in_double) { in_single = !in_single; continue } - if (!in_single && !in_double && substr($0, i, length(needle)) == needle && - (i == 1 || substr($0, i - 1, 1) !~ /[[:alnum:]_\\]/)) { - for (j = i + length(needle); j <= length($0); j++) { - if (substr($0, j, 1) == "]" && substr($0, j - 1, 1) != "\\") { found = 1; break } - } - } - } - } - END { exit !found } - ' "${source}" -} - -adoc_has_checkbox() { - awk ' - $0 == "----" || $0 == "...." || $0 == "////" { - if (!blocked) { blocked = 1; delimiter = $0 } - else if ($0 == delimiter) { blocked = 0; delimiter = "" } - next - } - !blocked && $0 !~ /^[[:space:]]*\/\// && $0 ~ /^[[:space:]]*[-*]+[[:space:]]+\[[ *xX-]\]([[:space:]]|$)/ { found = 1 } - END { exit !found } - ' "$1" -} - -implementation_has_backlink() { - local source="$1" - awk ' - $0 == "----" || $0 == "...." || $0 == "////" { - if (!blocked) { blocked = 1; delimiter = $0 } - else if ($0 == delimiter) { blocked = 0; delimiter = "" } - next - } - !blocked && $0 !~ /^[[:space:]]*\/\// && $0 ~ /^Implements link:README\.adoc\[[^]]+\]\.$/ { found = 1 } - END { exit !found } - ' "${source}" -} - -read_rfd() { - local source="$1" source_name="$2" expected_number="$3" - awk -v source_name="${source_name}" -v expected_number="${expected_number}" ' - function problem(message) { - printf " %s: %s\n", source_name, message > "/dev/stderr" - errors++ - } - function clean(value) { - sub(/^:[^:]+:[[:space:]]*/, "", value) - if (index(value, "\t") > 0) { - problem("attribute values must not contain tabs") - gsub(/\t/, " ", value) - } - return value - } - function trim(value) { - sub(/^[[:space:]]+/, "", value); sub(/[[:space:]]+$/, "", value) - return value - } - function valid_url(value, rest, authority, host, port, colon, scheme_end, scheme) { - if (value ~ /[[:space:]]/) return 0 - scheme_end = index(value, "://") - scheme = tolower(substr(value, 1, scheme_end - 1)) - if (!scheme_end || (scheme != "http" && scheme != "https")) return 0 - rest = substr(value, scheme_end + 3) - authority = rest; sub(/[\/?#].*$/, "", authority) - colon = index(authority, ":") - host = authority - if (colon) { - host = substr(authority, 1, colon - 1); port = substr(authority, colon + 1) - if (port !~ /^[0-9][0-9]*$/ || index(substr(authority, colon + 1), ":")) return 0 - } - return host ~ /^[[:alnum:]]([[:alnum:].-]*[[:alnum:]])?$/ - } - BEGIN { - authors = ""; state = ""; discussion = ""; labels = "" - title = ""; title_number = ""; errors = 0 - } - NR == 1 && $0 !~ /^:authors:[[:space:]]+/ { problem("first line must be the authors attribute") } - NR == 2 && $0 !~ /^:state:[[:space:]]+/ { problem("second line must be the state attribute") } - NR == 3 && $0 !~ /^:discussion:([[:space:]]+.*)?$/ { problem("third line must be the discussion attribute") } - NR == 4 && $0 !~ /^:labels:[[:space:]]+/ { problem("fourth line must be the labels attribute") } - NR == 5 && $0 != "" { problem("canonical attributes must be followed by a blank line") } - NR == 6 && ($0 !~ /^= RFD [0-9]+ [^[:space:]].*/ || index($0, "\t")) { problem("sixth line must be the tab-free RFD title") } - NR > 6 && ($0 == "----" || $0 == "...." || $0 == "////") { - if (!blocked) { blocked = 1; delimiter = $0 } - else if ($0 == delimiter) { blocked = 0; delimiter = "" } - next - } - blocked { next } - $0 ~ /^:authors:[[:space:]]*/ { - authors_count++; if (authors_count == 1) authors = clean($0); next - } - $0 ~ /^:state:[[:space:]]*/ { - state_count++; if (state_count == 1) state = clean($0); next - } - $0 ~ /^:discussion:[[:space:]]*/ { - discussion_count++; if (discussion_count == 1) discussion = clean($0); next - } - $0 ~ /^:labels:[[:space:]]*/ { - labels_count++; if (labels_count == 1) labels = clean($0); next - } - $0 ~ /^= RFD [0-9]+ [^[:space:]].*/ { - title_count++ - if (title_count == 1) { - value = $0; sub(/^= RFD /, "", value) - title_number = value; sub(/ .*/, "", title_number) - title = value; sub(/^[0-9]+ /, "", title) - } - } - END { - if (authors_count != 1 || authors == "") { - problem("document must contain exactly one non-empty authors attribute") - } else { - author_count = split(authors, author, ";") - for (i = 1; i <= author_count; i++) { - value = trim(author[i]) - if (value !~ /^[^<>[:space:]][^<>]*[[:space:]]+<[^<>[:space:]]+>$/) { - problem("each author must include a name and address in angle brackets") - } - } - } - if (state_count != 1 || state == "") { - problem("document must contain exactly one non-empty state attribute") - } else if (state !~ /^(prediscussion|ideation|discussion|published|committed|abandoned)$/) { - problem("invalid state: " state) - } - if (discussion_count != 1) { - problem("document must contain exactly one discussion attribute") - } else if (discussion != "" && !valid_url(discussion)) { - problem("discussion must be empty or an HTTP(S) URL") - } else if (state ~ /^(discussion|published|committed)$/ && discussion == "") { - problem("state " state " requires a discussion URL") - } - if (labels_count != 1 || labels == "") { - problem("document must contain exactly one non-empty labels attribute") - } else { - label_count = split(labels, label, ",") - for (i = 1; i <= label_count; i++) { - value = trim(label[i]) - if (value !~ /^[[:alnum:]][[:alnum:]_-]*$/) { - problem("labels must be comma-separated names") - } - } - } - if (title_count != 1 || title == "") { - problem("document must contain exactly one RFD title") - } else if (title_number != expected_number) { - problem("title number " title_number " does not match directory number " expected_number) - } - printf "%s\t%s\t%s\t%s\t%s\t%d\n", state, title, authors, labels, discussion, errors - } - ' "${source}" -} - -failures=0 -found=0 -title_width=35 -task_width=5 -row_numbers=() -row_states=() -row_tasks=() -row_titles=() -row_labels=() -shopt -s nullglob -entries=("${rfd_root}"/*) -shopt -u nullglob - -for entry in "${entries[@]}"; do - entry_name="$(basename "${entry}")" - [[ "${entry_name}" == "README.adoc" ]] && continue - if [[ ! -d "${entry}" || ! "${entry_name}" =~ ^[0-9]{4}$ ]]; then - printf "%sinvalid RFD entry%s: %s\n" "${color_red}" "${color_reset}" "${entry_name}" >&2 - failures=$((failures + 1)); continue - fi - - found=1 - source="${entry}/README.adoc" - if [[ ! -f "${source}" ]]; then - printf "%smissing canonical RFD source%s: %s/README.adoc\n" "${color_red}" "${color_reset}" "${entry_name}" >&2 - failures=$((failures + 1)); continue - fi - if ! adoc_contains "${rfd_root}/README.adoc" "link:${entry_name}/README.adoc["; then - printf "%sRFD index must link to each RFD%s: %s/README.adoc\n" "${color_red}" "${color_reset}" "${entry_name}" >&2 - failures=$((failures + 1)) - fi - - number="$(printf '%s\n' "${entry_name}" | sed 's/^0*//')" - [[ -n "${number}" ]] || number="0" - task_summary="-" - implementation="${entry}/IMPLEMENTATION.adoc" - if [[ ! -f "${implementation}" ]]; then - printf "%smissing implementation checklist%s: %s/IMPLEMENTATION.adoc\n" "${color_red}" "${color_reset}" "${entry_name}" >&2 - failures=$((failures + 1)) - fi - for retired in org md; do - if [[ -f "${entry}/IMPLEMENTATION.${retired}" ]]; then - printf "%sretired implementation checklist format%s: %s/IMPLEMENTATION.%s (use IMPLEMENTATION.adoc)\n" "${color_red}" "${color_reset}" "${entry_name}" "${retired}" >&2 - failures=$((failures + 1)) - fi - done - if [[ -f "${implementation}" ]]; then - implementation_name="IMPLEMENTATION.adoc" - read -r implementation_total implementation_completed implementation_invalid < <( - awk ' - $0 == "----" || $0 == "...." || $0 == "////" { - if (!blocked) { blocked = 1; delimiter = $0 } - else if ($0 == delimiter) { blocked = 0; delimiter = "" } - next - } - !blocked && $0 ~ /^[[:space:]]*\/\// { next } - { - if (blocked) next - task = $0 - if (task !~ /^[[:space:]]*[-*]+[[:space:]]+\[[^]]\]([[:space:]]|$)/) next - if (task !~ /^[[:space:]]*[-*]+[[:space:]]+\[[ x*-]\]([[:space:]]|$)/) { - printf " invalid AsciiDoc task state: %s\n", task > "/dev/stderr"; invalid++; next - } - total++ - if (task ~ /^[[:space:]]*[-*]+[[:space:]]+\[[x*]\]([[:space:]]|$)/) completed++ - } - END { printf "%d %d %d\n", total, completed, invalid } - ' "${implementation}" - ) - failures=$((failures + implementation_invalid)) - task_summary="${implementation_completed}/${implementation_total}" - if [[ "$(head -n 1 "${implementation}")" != "= RFD ${entry_name} implementation checklist" ]]; then - printf "%sinvalid implementation checklist heading%s: %s/%s\n" "${color_red}" "${color_reset}" "${entry_name}" "${implementation_name}" >&2 - failures=$((failures + 1)) - fi - if ! implementation_has_backlink "${implementation}"; then - printf "%simplementation checklist must link to its RFD%s: %s/%s\n" "${color_red}" "${color_reset}" "${entry_name}" "${implementation_name}" >&2 - failures=$((failures + 1)) - fi - if ! adoc_contains "${source}" "link:IMPLEMENTATION.adoc["; then - printf "%sRFD must link to its implementation checklist%s: %s/README.adoc\n" "${color_red}" "${color_reset}" "${entry_name}" >&2 - failures=$((failures + 1)) - fi - fi - - if adoc_has_checkbox "${source}"; then - printf "%simplementation checkboxes belong in a separate implementation document%s: %s/README.adoc\n" "${color_red}" "${color_reset}" "${entry_name}" >&2 - failures=$((failures + 1)) - fi - - parsed="$(read_rfd "${source}" "${entry_name}/README.adoc" "${number}")" - state="${parsed%%$'\t'*}" - remainder="${parsed#*$'\t'}"; title="${remainder%%$'\t'*}" - remainder="${remainder#*$'\t'}"; remainder="${remainder#*$'\t'}" - labels="${remainder%%$'\t'*}"; remainder="${remainder#*$'\t'}" - parser_errors="${remainder##*$'\t'}" - failures=$((failures + parser_errors)) - display_title="${title:-\(missing title\)}" - row_numbers+=("${entry_name}") - row_states+=("${state}") - row_tasks+=("${task_summary}") - row_titles+=("${display_title}") - row_labels+=("${labels:-\(missing labels\)}") - if [[ "${#display_title}" -gt "${title_width}" ]]; then - title_width="${#display_title}" - fi - if [[ "${#task_summary}" -gt "${task_width}" ]]; then - task_width="${#task_summary}" - fi -done - -if [[ "${found}" -eq 0 ]]; then - printf "%sno RFDs found%s in %s\n" "${color_red}" "${color_reset}" "${rfd_root}" >&2 - exit 1 -fi - -printf "%s%-4s %-13s %*s %-*s %s%s\n" "${color_bold}" "RFD" "State" "${task_width}" "Tasks" "${title_width}" "Title" "Labels" "${color_reset}" -printf "%s%-4s %-13s %*s %-*s %s%s\n" "${color_dim}" "----" "-------------" "${task_width}" "$(printf '%*s' "${task_width}" '' | tr ' ' '-')" "${title_width}" "$(printf '%*s' "${title_width}" '' | tr ' ' '-')" "--------------------" "${color_reset}" -for ((i = 0; i < ${#row_numbers[@]}; i++)); do - state_field="$(printf '%-13s' "${row_states[i]:-\(missing\)}")" - state_text="$(colorize_state "${row_states[i]}" "${state_field}")" - printf "%-4s %s %*s %-*s %s\n" "${row_numbers[i]}" "${state_text}" "${task_width}" "${row_tasks[i]}" "${title_width}" "${row_titles[i]}" "${row_labels[i]}" -done - -if [[ "${failures}" -gt 0 ]]; then - echo - printf "%sRFD status check failed%s with %s issue(s).\n" "${color_red}" "${color_reset}" "${failures}" >&2 - exit 1 -fi -echo -printf "%sRFD status check passed.%s\n" "${color_green}" "${color_reset}" From abc76cd6c3522c5d8576b2e18280e29cf50d3e03 Mon Sep 17 00:00:00 2001 From: "Darwin D. Wu" Date: Fri, 23 Oct 2026 18:36:20 -0700 Subject: [PATCH 3/3] docs: link RFD evidence at its last public revision The chaba-rfds site renders only each RFD's README, and the chaba-dev/rfds repository is private, so links to RFD 21's evidence and implementation checklist that pointed at the site page reached nothing a public reader can open. Point them at the files in this repository at its last public revision before the move (83ebd1fa, under rfd/0004/). Links to the RFDs themselves stay on the site. Lead the AGENTS.md RFD guidance with the public site and note that the source repository is private to the organization. --- AGENTS.md | 2 +- crates/simferret/src/vm.rs | 2 +- docs/time-model.adoc | 8 ++++---- poc/time-model/qemu-nosleep-replay-upstream.adoc | 8 ++++---- poc/time-model/reference-host-values.txt | 4 ++-- scripts/time-model-gate.sh | 2 +- scripts/time-model-input-probe.sh | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 32d67e6..71f087c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -20,4 +20,4 @@ # RFDs -- RFDs live in the shared chaba-dev/rfds repository (https://github.com/chaba-dev/rfds) and are published at https://chaba-rfds.pages.dev; follow its lifecycle and source conventions there, not in this repository. +- RFDs are published at https://chaba-rfds.pages.dev. Their source lives in the shared chaba-dev/rfds repository (https://github.com/chaba-dev/rfds), which is private to the organization; follow its lifecycle and source conventions there, not in this repository. diff --git a/crates/simferret/src/vm.rs b/crates/simferret/src/vm.rs index f3a8a81..aa98da5 100644 --- a/crates/simferret/src/vm.rs +++ b/crates/simferret/src/vm.rs @@ -37,7 +37,7 @@ const MEMORY_MIB: u32 = 128; /// so a recording can be driven. It is carried until upstream includes the fix, /// and dropping it is a versioned change: recordings made under a different /// emulator are not comparable, and every host in the supported matrix must be -/// re-validated. RFD 21's evidence (https://chaba-rfds.pages.dev/rfd/0021/) records the measurement, the pin, and +/// re-validated. RFD 21's evidence (https://github.com/chaba-dev/simferret/blob/83ebd1fadc50cf391a8e8002939a69870335ec7e/rfd/0004/EVIDENCE.adoc) records the measurement, the pin, and /// the spike that established the patch. /// /// Changing this value is a versioned change for the same reason: the model is diff --git a/docs/time-model.adoc b/docs/time-model.adoc index b06a816..dd8b181 100644 --- a/docs/time-model.adoc +++ b/docs/time-model.adoc @@ -17,7 +17,7 @@ measurements. Current progress lives in the implementation checklist, not here. | The proposal, the determinism, compatibility, and controllability needs it separates, what it excludes, and its acceptance criteria | Implementation checklist -| link:https://chaba-rfds.pages.dev/rfd/0021/[RFD 21 implementation checklist] +| link:https://github.com/chaba-dev/simferret/blob/83ebd1fadc50cf391a8e8002939a69870335ec7e/rfd/0004/IMPLEMENTATION.adoc[RFD 21 implementation checklist] | Phase 0 (pin and validate the model), Phase 1 (identity, rejection, and migration), Phase 2 (contract and documentation), and the exit criteria | Pre-RFD measurement @@ -25,7 +25,7 @@ measurements. Current progress lives in the implementation checklist, not here. | The exploratory probe results under `shift=auto`, `shift=auto,sleep=off`, `shift=7`, `shift=7,sleep=off`, and `shift=4,sleep=off`, with their caveats and the exploratory `shift=10` observation | Implementation evidence -| link:https://chaba-rfds.pages.dev/rfd/0021/[RFD 21 evidence] +| link:https://github.com/chaba-dev/simferret/blob/83ebd1fadc50cf391a8e8002939a69870335ec7e/rfd/0004/EVIDENCE.adoc[RFD 21 evidence] | The pinned-scale selection and its reason, the Phase 0 validation on the reference host, the record-mode limitation that the pinned emulator's carried patch resolves, and the re-validation trigger | Validation gate @@ -110,12 +110,12 @@ reports variation instead of failing on it: arrival timing of live host input has no deterministic position in guest virtual time; both are separate work.is carried by the pinned emulator and adopted by the product. The measurement, the models it was compared against, and the source-level cause are in - link:https://chaba-rfds.pages.dev/rfd/0021/[RFD 21 evidence], and + link:https://github.com/chaba-dev/simferret/blob/83ebd1fadc50cf391a8e8002939a69870335ec7e/rfd/0004/EVIDENCE.adoc[RFD 21 evidence], and `scripts/time-model-input-probe.sh` reproduces them. Continuous integration asserts that known result, so a QEMU change that fixes it fails the job instead of going unnoticed. * The limitation is one early return in QEMU, and the spike recorded in - link:https://chaba-rfds.pages.dev/rfd/0021/[RFD 21 evidence] shows that moving the flush + link:https://github.com/chaba-dev/simferret/blob/83ebd1fadc50cf391a8e8002939a69870335ec7e/rfd/0004/EVIDENCE.adoc[RFD 21 evidence] shows that moving the flush ahead of it makes the pinned model record and replay: the product's record and two replays then match, with the same normalized events, assertions, and semantic outcome digest as the model in use. Adopting that patch is a project diff --git a/poc/time-model/qemu-nosleep-replay-upstream.adoc b/poc/time-model/qemu-nosleep-replay-upstream.adoc index 2a9da9e..bc56118 100644 --- a/poc/time-model/qemu-nosleep-replay-upstream.adoc +++ b/poc/time-model/qemu-nosleep-replay-upstream.adoc @@ -11,7 +11,7 @@ It is a draft for the project owner to send, and nothing here has been submitted: the `Signed-off-by` trailer is the submitter's to add, and the proposed regression test is a proposal rather than something this repository can run, because it lives in QEMU's own test suite. The measurements it cites -are recorded in link:https://chaba-rfds.pages.dev/rfd/0021/[RFD 21 evidence], and the runs +are recorded in link:https://github.com/chaba-dev/simferret/blob/83ebd1fadc50cf391a8e8002939a69870335ec7e/rfd/0004/EVIDENCE.adoc[RFD 21 evidence], and the runs in the reproduction section were re-measured for this document against the pinned QEMU 11.1.0 with and without the patch. @@ -224,7 +224,7 @@ guest's `READY`, stops the guest through QEMU's monitor, writes one line while the guest cannot be polling, resumes it, and reports whether the line arrived. The acknowledged stop and resume are what make a non-delivery claim causal rather than timing-dependent; the measurement is recorded in -link:https://chaba-rfds.pages.dev/rfd/0021/[RFD 21 evidence]. The checked-in commands are: +link:https://github.com/chaba-dev/simferret/blob/83ebd1fadc50cf391a8e8002939a69870335ec7e/rfd/0004/EVIDENCE.adoc[RFD 21 evidence]. The checked-in commands are: [source,shell] ---- @@ -331,7 +331,7 @@ is data loss in record mode and a hang in replay mode rather than a delay. reference value exactly, and the product's record-and-two-replays run has normalized events, assertions, and semantic outcome digest byte-identical to the same run under the model in use - (link:https://chaba-rfds.pages.dev/rfd/0021/[RFD 21 evidence]). The patch does not + (link:https://github.com/chaba-dev/simferret/blob/83ebd1fadc50cf391a8e8002939a69870335ec7e/rfd/0004/EVIDENCE.adoc[RFD 21 evidence]). The patch does not perturb what a recording contains beyond adding the input it was dropping. == Counter-arguments to expect @@ -449,7 +449,7 @@ inherit its machinery: == References * link:qemu-nosleep-replay-flush.patch[`poc/time-model/qemu-nosleep-replay-flush.patch`] -* link:https://chaba-rfds.pages.dev/rfd/0021/[RFD 21 evidence] +* link:https://github.com/chaba-dev/simferret/blob/83ebd1fadc50cf391a8e8002939a69870335ec7e/rfd/0004/EVIDENCE.adoc[RFD 21 evidence] * link:input-probe.c[`poc/time-model/input-probe.c`] and link:../../scripts/time-model-input-probe.sh[`scripts/time-model-input-probe.sh`] * Upstream sources cited: `accel/tcg/icount-common.c`, diff --git a/poc/time-model/reference-host-values.txt b/poc/time-model/reference-host-values.txt index c5e2e62..4a9265c 100644 --- a/poc/time-model/reference-host-values.txt +++ b/poc/time-model/reference-host-values.txt @@ -5,7 +5,7 @@ # reference x86-64 Linux host (AMD Ryzen 5 3600, 12 threads, Linux 6.18.41), # with the pinned QEMU 11.1.0, the pinned guest kernel 6.18.49, and the # initramfs the probe builds from `poc/time-model/probe.c`. The run, its -# deadline, and its reason are recorded in RFD 21's evidence (https://chaba-rfds.pages.dev/rfd/0021/). +# deadline, and its reason are recorded in RFD 21's evidence (https://github.com/chaba-dev/simferret/blob/83ebd1fadc50cf391a8e8002939a69870335ec7e/rfd/0004/EVIDENCE.adoc). # # `scripts/time-model-gate.sh` compares a host's validation run against these # values. They are exact rather than tolerances: the RFD requires the guest @@ -25,7 +25,7 @@ # practice a `flake.lock` update that moves either), to the model in # `crates/simferret/src/vm.rs`, or to the probe source makes these values stale. # Re-measure on the reference host, re-record them here and in -# RFD 21's evidence (https://chaba-rfds.pages.dev/rfd/0021/), and let the gate re-validate every host in the +# RFD 21's evidence (https://github.com/chaba-dev/simferret/blob/83ebd1fadc50cf391a8e8002939a69870335ec7e/rfd/0004/EVIDENCE.adoc), and let the gate re-validate every host in the # supported matrix. Until then the gate fails, which is the intended outcome: a # host that cannot complete under the pinned model is an unsupported execution # rather than a reason to fall back to another model. diff --git a/scripts/time-model-gate.sh b/scripts/time-model-gate.sh index a943039..95dd4f4 100755 --- a/scripts/time-model-gate.sh +++ b/scripts/time-model-gate.sh @@ -18,7 +18,7 @@ set -euo pipefail # initramfs, and one measurement per metric. The product launches this model: # `TIME_MODEL` in `crates/simferret/src/vm.rs` pins it, and the pinned emulator the # flake builds carries the replay-flush patch `sleep=off` needs, so a recording can -# be driven. RFD 21's evidence (https://chaba-rfds.pages.dev/rfd/0021/) records the measurement, the pin, and the +# be driven. RFD 21's evidence (https://github.com/chaba-dev/simferret/blob/83ebd1fadc50cf391a8e8002939a69870335ec7e/rfd/0004/EVIDENCE.adoc) records the measurement, the pin, and the # resolution. # # The deadline and the sample size are the RFD's acceptance rule, not the diff --git a/scripts/time-model-input-probe.sh b/scripts/time-model-input-probe.sh index c4320b0..2992579 100755 --- a/scripts/time-model-input-probe.sh +++ b/scripts/time-model-input-probe.sh @@ -659,7 +659,7 @@ if [[ -n "$expectation" ]]; then echo "The experiment is inconclusive: $inconclusive_reason." >&2 elif [[ "$expectation" == "not-delivered" ]]; then echo "Input delivery under the pinned model may unblock the pin: re-measure and" >&2 - echo "re-record RFD 21's evidence (https://chaba-rfds.pages.dev/rfd/0021/) before changing the model the product launches." >&2 + echo "re-record RFD 21's evidence (https://github.com/chaba-dev/simferret/blob/83ebd1fadc50cf391a8e8002939a69870335ec7e/rfd/0004/EVIDENCE.adoc) before changing the model the product launches." >&2 fi echo "Artifacts: $output_dir" >&2 exit 1