diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 247350d..345e844 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,24 @@ jobs: run: python3 scripts/check_execution_ownership.py - name: execution ownership guard negative-exit proof run: python3 scripts/check_execution_ownership.py --prove-negative-exit + # The design record used to cite *line numbers*. A line number is a + # property of the text, not of the symbol: every unrelated edit above the + # target invalidated it, and 85% of the resolvable citations no longer + # resolved at the line they named. The gate makes the record cite + # symbols instead, so a citation survives an edit that moves the code. + # It is stdlib-only Python and reads the tree, so it runs the same on + # every host and needs nothing built first. + - name: documentation citation guard + run: python3 scripts/check_doc_citations.py + - name: documentation citation guard negative-exit proof + run: python3 scripts/check_doc_citations.py --prove-negative-exit + # `docs/quickstart.md` is the user-facing instruction and + # `scripts/quickstart.sh` is the executed version of it. They are two + # renderings of one procedure, so they are checked against each other: + # the document's commands must be the script's commands, and the doctor + # output the document shows must be the output the node emits. + - name: quickstart document and script sync + run: python3 scripts/check_quickstart_sync.py - run: cargo fmt --all -- --check # `--locked` is load-bearing. A workspace version bump that does not # update `Cargo.lock` builds fine locally and passes both of these, then @@ -24,9 +42,38 @@ jobs: # release attempt: the `v0.1.3` producer run failed closed on it. CI must # catch a stale lock before a release does. - run: cargo clippy --locked --workspace --all-targets --all-features -- -D warnings + # The runner's capability probe drives the *built* sandbox helper and + # fails loudly when it is absent, so the helper has to exist before the + # test step runs. Building it explicitly is what makes the precondition + # deterministic rather than incidental. + - name: build the sandbox helper the capability probe drives + run: cargo build --locked -p eggwork-sandbox-helper + # The default test step does **not** enable the `qualification` feature: + # the qualification suite names an installed release as its subject + # through the environment, so it belongs in the `installed-qualification` + # job below, which stages that installation. Its tests are `#[ignore]`d + # as well, so adding `--all-features` here would not run them either. - run: cargo test --locked --workspace --all-targets - run: cargo check --workspace + - name: release identity coherence + # The release gate has two halves. The tag-dependent half — "does the + # tag about to be created name the workspace version?" — cannot live + # in CI: CI never knows the future tag, and the generated release + # workflow is producer authority. `scripts/check_release_tag.py` owns + # that comparison and is run by whoever cuts the tag, before the tag + # exists. + # + # The tag-independent half is the workspace manifest's version against + # the versions `Cargo.lock` pins for this repository's own packages. + # That is what this step asserts, on every push and every pull + # request, and it is exactly the condition that broke the `v0.1.3` + # release attempt. + run: python3 scripts/check_release_tag.py --coherence - name: release candidate validator tests + # These are the tag guard's own tests: they exercise the code path + # that decides whether a release may be tagged, against fixtures, so + # the guard's correctness is an executed result rather than a trusted + # assumption. run: python3 -m unittest discover --start-directory tests/release --top-level-directory tests/release windows-runner: # The Windows process-tree backend cannot be observed from Linux: Job Object @@ -35,10 +82,16 @@ jobs: # M004, so a green Linux run must never be read as Windows coverage. # # Scope is deliberately narrow. `eggwork-runner` runs its full suite on - # Windows; the server's own tests are `/bin/sh`-shaped and stay Linux-only - # until a separate milestone reshapes them. The installed production path - # (installed release bytes, not a build tree) is qualified by the - # `operational-qualification` workflow, not here. + # Windows; the server's own unit tests are `/bin/sh`-shaped and stay + # Linux-only until a separate milestone reshapes them. One server + # integration target is portable and is run below, so it is the native + # evidence that a node which cannot capture declared outputs refuses them + # instead of dropping them. The service host adds two more targets that + # *are* Windows-shaped — the host's lifecycle and its service identity — + # and they are run here. The installed production path (installed + # release bytes, not a build tree) is qualified by the + # `operational-qualification` workflow, not here, and the real service + # control manager lifecycle is the `windows-service-host` job below. runs-on: windows-latest steps: - uses: actions/checkout@v4 @@ -52,16 +105,340 @@ jobs: # Windows-only regression actually matters, and it is the surface a # release binary is built from. - run: cargo clippy --locked --workspace --lib --bins --all-features -- -D warnings - # Test targets only for the crate this milestone owns. `eggwork-server` - # and `eggwork-client` unit tests are Linux-shaped (they spawn `/bin/sh` - # and set `0700` modes through `std::os::unix`), so they do not compile - # for Windows and are not claimed as coverage. Making them portable is - # its own milestone; until then this job's scope is stated, not widened - # to hide the gap. + # Test targets only for the crates this job can honestly claim. + # `eggwork-server` and `eggwork-client` *unit* tests are Linux-shaped + # (they spawn `/bin/sh` and set `0700` modes through `std::os::unix`), + # so they do not compile for Windows and are not claimed as coverage. + # Making them portable is its own milestone; until then this job's scope + # is stated, not widened to hide the gap. - name: eggwork-runner test targets run: cargo clippy --locked -p eggwork-runner --all-targets --all-features -- -D warnings - name: Windows process-tree lifecycle suite + # The runner's capability probe drives the built sandbox helper and + # fails loudly when it is absent, so this job would need the helper + # built too. It does not: the helper-dependent half of that probe is + # `#[cfg(target_os = "linux")]`, so it does not exist in this job at + # all, and only the platform-neutral negative case — a missing helper + # must not advertise a capability — runs here. The Linux `rust` job + # builds the helper explicitly and runs the full probe. run: cargo test --locked -p eggwork-runner --all-targets -- --nocapture + # One portable server integration target, and only that target. The + # declared-artifact capture disposition is a contract about the + # *decision* rather than about the host, so it is checked from a target + # that compiles for Windows: this is the native evidence that a node + # which cannot capture declared outputs refuses them and ends the + # execution in a state that is not a success. The rest of the server's + # test surface is still Linux-only and is not claimed here. + - name: declared-artifact capture disposition suite + run: cargo test --locked -p eggwork-server --test artifact_capture_disposition + # The service-host lifecycle and the service identity contract. + # + # These two targets are the Windows service host's own surface. They are + # run explicitly here because the server's *unit* tests are + # `/bin/sh`-shaped and do not compile for Windows, so the server's test + # surface as a whole cannot be claimed here. These two can, and they + # are what the service host is made of. + - name: service-host lifecycle suite + run: cargo test --locked -p eggwork-server --bin eggworkd -- --nocapture + - name: service-host identity contract + run: cargo test --locked -p eggwork-server --test windows_service_contract -- --nocapture + # Only the two Windows targets are linted. `--tests` would build the + # server's Linux-shaped unit-test target as well, and that target does + # not compile for Windows. + - name: service-host test targets + run: cargo clippy --locked -p eggwork-server --test windows_service_contract --test windows_service_lifecycle -- -D warnings + windows-service-host: + # The Windows service host is proved by mutating a real service control + # manager registration on the hosted runner: install, start, answer an + # authenticated request while the manager says Running, stop with an + # active execution, start again, restart, uninstall, and prove that a + # same-name registration that is not Eggwork's is never touched. + # + # The daemon is built from source here. The *installed release* service + # lifecycle belongs to Operations M004, which owns release lineage and + # the exact installed bytes; this job owns the source-built proof. + # + # Every mutation goes through the product's own operator CLI and Eggup's + # typed adapter. The one exception is the foreign-ownership negative, + # which has to create a registration that is not Eggwork's, and that is + # test orchestration rather than a second production manager. + runs-on: windows-latest + timeout-minutes: 45 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.89.0 + - uses: Swatinem/rust-cache@v2 + with: + key: windows-msvc + - name: build the daemon under test + run: cargo build --locked -p eggwork-server --bin eggworkd + - name: stage the installation root + # The directories are created 0755 rather than with the shell's umask, + # because the installed helper's trust check walks every ancestor of + # its own path and refuses a group- or world-writable one. + shell: bash + run: | + set -euo pipefail + root="${{ runner.temp }}/service-host" + mkdir -p "$root/bin" + install -m 0755 target/debug/eggworkd.exe "$root/bin/eggworkd.exe" + chmod 0755 "$root" "$root/bin" + - name: reserve the loopback port + # The service-hosted node has to bind an address the test can reach, + # and the manager's state alone would not prove the node is serving. + # The port is reserved and released, and the node binds it for the + # duration of the lifecycle. + shell: pwsh + run: | + $listener = [System.Net.Sockets.TcpListener]::new([System.Net.IPAddress]::Loopback, 0) + $listener.Start() + $port = $listener.LocalEndpoint.Port + $listener.Stop() + "EGGWORK_QUALIFY_BIND=127.0.0.1:$port" >> $env:GITHUB_ENV + - name: materialise the bounded fixture + # The repository's own rcgen-based fixture, not a runner-provided one: + # a certificate the installed binary rejects would look like a product + # defect rather than a fixture problem. + shell: bash + run: | + set -euo pipefail + EGGWORK_QUALIFY_ROOT="${{ runner.temp }}/service-host" \ + cargo test --locked -p eggwork-server --features qualification \ + --test installed_qualification -- --ignored --exact qualification_fixture + - name: qualify the hosted service lifecycle + shell: bash + env: + EGGWORK_QUALIFY_ROOT: ${{ runner.temp }}/service-host + EGGWORK_SERVICE_DAEMON: ${{ runner.temp }}/service-host/bin/eggworkd.exe + run: | + set -euo pipefail + cargo test --locked -p eggwork-server --test windows_service_lifecycle \ + -- --ignored --nocapture + - name: the registration is gone + # The lifecycle removes its own registration, and a failed assertion + # must not leave one behind. This step is the belt to the test's + # braces: it fails the job if a registration survives the run. + # + # The step ends with an explicit `exit 0`, because `sc.exe query` + # exits non-zero when the service does not exist — which is the + # outcome this step wants. Without the explicit exit, the step + # inherits that non-zero code and turns a passed check into a failed + # job. This is the same trap M004 recorded for the Windows + # disposition step. + shell: pwsh + run: | + $existing = sc.exe query eggwork-node 2>&1 | Out-String + if ($LASTEXITCODE -eq 0) { + Write-Error "a service registration survived the lifecycle job: $existing" + exit 1 + } + Write-Output "no service registration survived the lifecycle job" + exit 0 + macos-runner: + # The release matrix builds macos-x64 and macos-arm64, and nothing in this + # workflow exercised a macOS target, so a macOS-only regression could reach + # a release candidate unobserved. This job is the native evidence that the + # shipped surface compiles and its platform-neutral tests pass on macOS. + # + # Scope is deliberately narrow and mirrors the Windows job. The runner's + # test targets are portable and run here; the server's own unit tests are + # `/bin/sh`-shaped and are not claimed here, except for the one portable + # integration target the Windows job already runs. + runs-on: macos-14 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.89.0 + with: + components: clippy + - uses: Swatinem/rust-cache@v2 + with: + key: macos-arm64 + # The production surface a release binary is built from, linted on the + # macOS target. + - run: cargo clippy --locked --workspace --lib --bins --all-features -- -D warnings + # The runner's test targets: the `OutputChunk` shape and the platform + # tree backend are both exercised here. + - name: eggwork-runner test targets + run: cargo clippy --locked -p eggwork-runner --all-targets --all-features -- -D warnings + - name: eggwork-runner test suite + run: cargo test --locked -p eggwork-runner --all-targets -- --nocapture + # The same portable server integration target the Windows job runs. + - name: declared-artifact capture disposition suite + run: cargo test --locked -p eggwork-server --test artifact_capture_disposition + macos-x64-runner: + # The release matrix builds macos-x64 and macos-arm64. `macos-runner` + # covers the arm64 target; this job covers the x64 one, so both macOS + # targets the matrix builds are exercised rather than only the one the + # hosted image happens to be. + # + # The scope mirrors `macos-runner` exactly. A target that is only + # compiled is not exercised, and an exercised target is not a qualified + # one: this job is the native evidence that the shipped surface compiles + # and its platform-neutral tests pass on macos-x64. + # + # `macos-15-intel` is the x64 image. The one before it, `macos-13`, is + # retired, and a job pinned to a retired image queues forever instead of + # failing, which is the worst possible failure for a gate. + runs-on: macos-15-intel + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.89.0 + with: + components: clippy + - uses: Swatinem/rust-cache@v2 + with: + key: macos-x64 + - run: cargo clippy --locked --workspace --lib --bins --all-features -- -D warnings + - name: eggwork-runner test targets + run: cargo clippy --locked -p eggwork-runner --all-targets --all-features -- -D warnings + - name: eggwork-runner test suite + run: cargo test --locked -p eggwork-runner --all-targets -- --nocapture + - name: declared-artifact capture disposition suite + run: cargo test --locked -p eggwork-server --test artifact_capture_disposition + quickstart: + # The quickstart is a *procedure*, and `docs/quickstart.md` is the + # user-facing instruction while `scripts/quickstart.sh` is its executed + # form. This job runs the script end to end on Linux against a locally + # built node with generated TLS material, so the document's claims are + # checked against a node that actually ran rather than against prose. + # + # The script needs `cargo`, `openssl`, `python3` and `stat`; all four are + # present on `ubuntu-latest`. It generates its own TLS material, installs + # the helper where the helper's trust check accepts it, and stops the node + # on every failure path, so a failed step never leaves a process holding + # the state directory's lock. + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.89.0 + - uses: Swatinem/rust-cache@v2 + - name: run the quickstart end to end + shell: bash + run: | + set -euo pipefail + bash scripts/quickstart.sh + installed-qualification: + # The `qualification`-feature suite qualifies an *installed* release: it + # names its subject through the environment (`EGGWORK_QUALIFY_DAEMON`, + # `EGGWORK_QUALIFY_CONFIG`, `EGGWORK_QUALIFY_TLS_DIR`) and its three + # tests are `#[ignore]`d. + # + # That is why the default `cargo test` step does not enable the feature. + # Adding `--all-features` there would compile the file, but the + # `#[ignore]` attributes would still keep all three tests out of the run, + # and an ordinary test run has no installed release to drive in the first + # place. The suite is therefore executed here, in the job that stages the + # installation it drives, so a green CI run is evidence that the code + # ran rather than only that it type-checked. + # + # The `operational-qualification` workflow runs the same suite against a + # *published* release's exact bytes. This job runs it against the bytes + # this repository builds, on every push and every pull request. + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.89.0 + - uses: Swatinem/rust-cache@v2 + - name: build the installed product surface + run: cargo build --locked -p eggwork-server -p eggwork-sandbox-helper --bins + - name: stage the installation root + # The directories are created 0755 rather than with the shell's umask, + # because the installed helper's trust check walks every ancestor of + # its own path and refuses a group- or world-writable one. + shell: bash + run: | + set -euo pipefail + root="${{ runner.temp }}/qualification" + mkdir -p "$root/bin" + install -m 0755 target/debug/eggworkd "$root/bin/eggworkd" + install -m 0755 target/debug/eggwork-sandbox-helper "$root/bin/eggwork-sandbox-helper" + chmod 0755 "$root" "$root/bin" + - name: check the installation root's trust chain + # The product's own rule, checked before the node is started: the + # helper's path and every ancestor of it must be free of group- and + # world-writable bits. The qualification harness's `ensure_trusted_root` + # fails closed on the same condition; here it is checked explicitly so + # a runner whose temporary directory is group-writable reports that + # reason instead of the node refusing its own helper. + shell: bash + env: + INSTALL_ROOT: ${{ runner.temp }}/qualification + run: | + set -euo pipefail + current="$INSTALL_ROOT" + while true; do + mode=$(stat -c '%a' "$current") + world="${mode: -1}" + group="${mode: -2:1}" + if [ $(( world & 2 )) -ne 0 ] || [ $(( group & 2 )) -ne 0 ]; then + echo "$current is group/world writable (mode $mode); the installed helper's trust check walks every ancestor and would reject it" >&2 + exit 1 + fi + parent=$(dirname "$current") + if [ "$parent" = "$current" ]; then + break + fi + current="$parent" + done + - name: materialise the bounded qualification fixture + # The TLS fixture and node configuration come from the repository's own + # `rcgen`-based harness, not from whichever OpenSSL the runner ships. + shell: bash + env: + EGGWORK_QUALIFY_ROOT: ${{ runner.temp }}/qualification + run: | + set -euo pipefail + cargo test --locked -p eggwork-server --features qualification \ + --test installed_qualification -- --ignored --exact qualification_fixture + - name: qualify installed execution through the production client + # Both qualification tests run against the fixture the previous step + # materialised; the fixture itself is skipped here so it is not + # re-materialised underneath the node that is already running. + # + # `--test-threads=1` is load-bearing. The two tests share one + # installation root, one state directory, and one execution-state + # lock, so a concurrent second daemon cannot start: the first test + # would fail with "the installed daemon exited before reporting + # ready". They are one installation, qualified one at a time. + shell: bash + env: + EGGWORK_QUALIFY_DAEMON: ${{ runner.temp }}/qualification/bin/eggworkd + EGGWORK_QUALIFY_CONFIG: ${{ runner.temp }}/qualification/state/node.json + EGGWORK_QUALIFY_TLS_DIR: ${{ runner.temp }}/qualification/state/tls + EGGWORK_QUALIFY_PLATFORM: linux + run: | + set -euo pipefail + cargo test --locked -p eggwork-server --features qualification \ + --test installed_qualification -- --ignored --skip qualification_fixture \ + --test-threads=1 --nocapture + - name: quickstart doctor output against the node's report + # The quickstart document shows a `doctor` report. The set of check + # names it shows must equal the set the node emits, in the same order: + # the document once showed seven checks while the node emitted eight, + # and nothing caught it. This step runs the installed daemon's own + # `doctor` against the fixture this job materialised and compares the + # two, so the shown output is a fact rather than a picture. + # + # `doctor` exits non-zero when any check is not ok, which is a verdict + # about the *node*, not about the document. The qualification step + # above already requires a healthy node, so this step's assertion is + # the comparison alone: the report is captured whatever the verdict, + # and an unreadable or empty report fails the comparison with a clear + # message. + shell: bash + env: + EGGWORK_QUALIFY_ROOT: ${{ runner.temp }}/qualification + run: | + set -euo pipefail + status=0 + "$EGGWORK_QUALIFY_ROOT/bin/eggworkd" doctor \ + --config "$EGGWORK_QUALIFY_ROOT/state/node.json" \ + > "$EGGWORK_QUALIFY_ROOT/doctor.json" || status=$? + printf 'doctor exited %s; the comparison below is the assertion\n' "$status" + python3 scripts/check_quickstart_sync.py \ + --doctor-report "$EGGWORK_QUALIFY_ROOT/doctor.json" release-drift: # Eggpack is producer authority for the release matrix: the generated # release workflow must be exactly what the pinned tool renders from the diff --git a/.github/workflows/operational-qualification.yml b/.github/workflows/operational-qualification.yml index 15d5553..4004abb 100644 --- a/.github/workflows/operational-qualification.yml +++ b/.github/workflows/operational-qualification.yml @@ -284,6 +284,28 @@ jobs: --test installed_qualification -- --ignored \ --exact installed_release_admits_execution_and_refuses_unsupported_isolation \ --nocapture + - name: Qualify the truthful declared-artifact disposition + # Windows cannot capture declared outputs, and the qualified claim is + # the *refusal*: the node must not advertise `artifact.declared.v1`, and + # an execution that declares outputs must end in a failed state with a + # `failed` capture disposition and a diagnostic event — never a + # successful execution whose declared outputs were silently dropped. + # Without this step the hosted qualification would never invoke the + # suite, because the workflow selects suites by `--exact` name. + shell: bash + env: + RELEASE_QUALIFICATION_TOKEN: ${{ secrets.RELEASE_QUALIFICATION_TOKEN }} + EGGWORK_QUALIFY_DAEMON: ${{ runner.temp }}/qualification/bin/eggworkd.exe + EGGWORK_QUALIFY_CONFIG: ${{ runner.temp }}/qualification/state/node.json + EGGWORK_QUALIFY_TLS_DIR: ${{ runner.temp }}/qualification/state/tls + EGGWORK_QUALIFY_RECEIPT: ${{ runner.temp }}/receipts/execution-windows.json + EGGWORK_QUALIFY_PLATFORM: windows + run: | + set -euo pipefail + cargo test --locked -p eggwork-server --features qualification \ + --test installed_qualification -- --ignored \ + --exact installed_release_reports_a_truthful_declared_artifact_disposition \ + --nocapture - name: Record the service management disposition shell: pwsh run: | @@ -291,10 +313,21 @@ jobs: $exe = "$root\bin\eggworkd.exe" $config = "$root\state\node.json" $receipt = "$env:RUNNER_TEMP\receipts\windows-service.txt" - # Service management is still `unsupported`: the daemon is not a - # service host. What is qualified here is the *refusal*, which must - # happen before any mutation. A release that registers a service has - # lost that guarantee, so this is a hard failure, not a note. + # The disposition is a property of the *candidate's bytes*, and the + # candidate is what this job qualifies. + # + # A candidate that predates the service host refuses the mutating + # verbs before any mutation, and that refusal is what is qualified + # here. A candidate that carries the host registers a service, + # starts it, proves it reaches Running, stops it, and removes it. + # + # The daemon's own usage names its process modes, so the capability + # is read from the candidate under test rather than assumed from + # the branch this workflow lives on. + $usage = (& $exe 2>&1 | Out-String) + $isHost = $usage -match 'service-host' + "capability: service-host=$isHost" | Out-File -FilePath $receipt -Encoding utf8 + $output = & $exe service install ` --config $config ` --executable $exe ` @@ -302,6 +335,57 @@ jobs: --windows-start-type manual 2>&1 | Out-String $exit = $LASTEXITCODE "service install exit=$exit output=$output" | Out-File -FilePath $receipt -Encoding utf8 + + if ($isHost) { + if ($exit -ne 0) { + throw "the candidate hosts a Windows service but the install failed: $output" + } + $start = & $exe service start ` + --config $config ` + --executable $exe ` + --service-config $config ` + --windows-start-type manual 2>&1 | Out-String + $startExit = $LASTEXITCODE + "service start exit=$startExit output=$start" | Out-File -FilePath $receipt -Encoding utf8 -Append + if ($startExit -ne 0) { + throw "the candidate hosts a Windows service but the service did not start: $start" + } + $status = & $exe service status ` + --config $config ` + --executable $exe ` + --service-config $config ` + --windows-start-type manual 2>&1 | Out-String + "service status output=$status" | Out-File -FilePath $receipt -Encoding utf8 -Append + if ($status -notmatch '"ownership":"Owned"') { + throw "the candidate registered the service but does not own it: $status" + } + if ($status -notmatch '"state":"Running"') { + throw "the candidate started the service but it is not Running: $status" + } + $stop = & $exe service stop ` + --config $config ` + --executable $exe ` + --service-config $config ` + --windows-start-type manual 2>&1 | Out-String + $stopExit = $LASTEXITCODE + "service stop exit=$stopExit output=$stop" | Out-File -FilePath $receipt -Encoding utf8 -Append + if ($stopExit -ne 0) { + throw "the candidate hosts a Windows service but the service did not stop: $stop" + } + $uninstall = & $exe service uninstall ` + --config $config ` + --executable $exe ` + --service-config $config ` + --windows-start-type manual 2>&1 | Out-String + $uninstallExit = $LASTEXITCODE + "service uninstall exit=$uninstallExit output=$uninstall" | Out-File -FilePath $receipt -Encoding utf8 -Append + if ($uninstallExit -ne 0) { + throw "the candidate hosts a Windows service but the service was not removed: $uninstall" + } + "DISPOSITION: supported (the candidate registered, started, and stopped the service)" | Out-File -FilePath $receipt -Encoding utf8 -Append + exit 0 + } + $unsupported = $output -match 'unsupported' if (-not $unsupported) { "DISPOSITION: CHANGED, the service verb mutated state; update the support matrix" | Out-File -FilePath $receipt -Encoding utf8 -Append diff --git a/.gitignore b/.gitignore index ce6d234..857bff6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /target/ +/target-*/ __pycache__/ *.sqlite *.sqlite-shm diff --git a/.skills/pre-submit-gate/SKILL.md b/.skills/pre-submit-gate/SKILL.md index d23bd47..51cafae 100644 --- a/.skills/pre-submit-gate/SKILL.md +++ b/.skills/pre-submit-gate/SKILL.md @@ -5,9 +5,9 @@ description: Run the mandatory pre-submit verification gate for eggwork before a # Pre-submit gate -Run the full gate before every commit. Six of the seven commands are cheap; the -one that costs real time is the workspace test suite, so start it first and read -results while it runs. +Run the full gate before every commit. All but two of the commands are cheap; +the ones that cost real time are the workspace test suite and the two +documentation gates, so start them first and read results while they run. ```bash cargo test --locked --workspace --all-targets # slow — start first @@ -17,6 +17,9 @@ cargo fmt --all -- --check cargo clippy --locked --workspace --all-targets --all-features -- -D warnings cargo check --workspace python3 -m unittest discover --start-directory tests/release --top-level-directory tests/release +python3 scripts/check_doc_citations.py +python3 scripts/check_doc_citations.py --prove-negative-exit +python3 scripts/check_quickstart_sync.py git diff --check ``` @@ -48,7 +51,10 @@ tag. See the `cut-a-release` skill. | `--prove-negative-exit` | Proves the scanner *detects* a synthetic forbidden spawn | **Not** a second full guard pass: it returns before `scan_sources()`/`check_dependencies()` | | `cargo fmt --check` | Formatting drift (no `rustfmt.toml`, so default rustfmt) | — | | `cargo clippy … -D warnings` | Lints; `unsafe_code = "deny"` and `clippy::all = "warn"` are workspace-level | — | -| `unittest discover` | The 52 Python harness tests backing `qualify_release.py`, `release_candidate_probe.py`, `verify_windows_reproducibility.py` | The Rust side | +| `unittest discover` | The Python harness tests backing `qualify_release.py`, `release_candidate_probe.py`, `verify_windows_reproducibility.py`, and the two documentation gates | The Rust side | +| `check_doc_citations.py` | A citation under `architecture/` or `docs/` that names a line number, a path that does not exist, a symbol that is not in the named file, or an ambiguous in-file symbol | Whether the cited symbol is the one the sentence *means* — that part is the design record's own re-verification | +| `check_doc_citations.py --prove-negative-exit` | Proves the citation gate *rejects* a deliberately wrong citation and accepts a correct one | A second full pass over the tree | +| `check_quickstart_sync.py` | `docs/quickstart.md` drifting from `scripts/quickstart.sh`, and the document's shown `doctor` output drifting from the node's real report | Whether the quickstart's steps are the *right* steps | | `git diff --check` | Whitespace errors and conflict markers | — | ## Two limits worth knowing before you trust a green gate diff --git a/AGENTS.md b/AGENTS.md index 9c56bd6..7be3f60 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,6 +11,7 @@ Rust-native, fixed-target remote execution fabric: a caller selects one node, su - Check: `cargo check --workspace` - Ownership guard: `python3 scripts/check_execution_ownership.py` (also `--prove-negative-exit`) - Harness tests: `python3 -m unittest discover --start-directory tests/release --top-level-directory tests/release` +- Documentation gates: `python3 scripts/check_doc_citations.py` (also `--prove-negative-exit`) and `python3 scripts/check_quickstart_sync.py` — a citation under `architecture/` or `docs/` must name a **symbol**, never a line number, and `docs/quickstart.md` must agree with `scripts/quickstart.sh` - Run the node: `cargo run -p eggwork-server --bin eggworkd -- run --config ` `--locked` is load-bearing on `clippy` and `test`: a version bump that skips `Cargo.lock` passes both and then fails every release build. @@ -59,12 +60,16 @@ reasoning and boundary evidence goes in `architecture/`. | [docs/deployment.md](docs/deployment.md) | Install/update a node as service software via Eggup | | [docs/releases.md](docs/releases.md) | Consume a published release; release identity, Windows reproducibility | -Quickstart commands in `docs/` are **executed and verified**, not illustrative. -The config loader's strictness (owner-only state directories `0700`, private key -`0600`, nothing group/world writable, and a sandbox helper outside world-writable -ancestors) is undocumented anywhere else and produces a single unhelpful -`configuration is invalid or unreadable` — if that message ever appears, check -permissions first. +Quickstart commands in `docs/` are **executed and verified**, not illustrative: +`scripts/quickstart.sh` runs the whole flow end to end and +`scripts/check_quickstart_sync.py` keeps the document and that script in +agreement. The config loader's strictness (owner-only state directories `0700`, +private key `0600`, nothing group/world writable, and a sandbox helper outside +world-writable ancestors) is undocumented anywhere else — since the M008a +corrective it is reported as a stable rule identifier, the offending file or +path, and the corrective action, and a secret-bearing item is named by its +role, never by its path. If a configuration fault still surfaces without a rule +id, check permissions first. ## Architecture index @@ -95,12 +100,15 @@ and deliberate. Deep dives: 1. **Process ownership is singular.** Only `eggwork-runner` and `eggwork-sandbox-helper` may create child processes; `eggwork-core`, `eggwork-client`, `eggwork-server` must not. Also banned outright: `command-group`, `duct`, `process-wrap`, `portable-pty`, `subprocess`. The allowlist lives in `scripts/check_execution_ownership.py`; adding an owner requires an architecture review. The guard scans only `crates/*/src/**/*.rs` — `tests/`, `examples/`, `build.rs`, and new top-level dirs are unscanned. The dependency denylist is the exception: every crate is checked against it, and the one recorded exemption is `eggwork-runner` → `process-wrap` (Windows Job Object ownership, `cfg(windows)` only), in `APPROVED_PROCESS_DEP_EXCEPTIONS`. 2. **No direct service-manager invocation for the *node service*.** Eggwork never manages its own service by shelling out — the node service lifecycle goes through Eggup adapters. **Exception, and it is not a violation:** `eggwork-runner` invokes `systemd-run --scope` and `systemctl show`/`stop` for *per-execution transient cgroup units*, which is resource enforcement owned by the process-lifecycle crate, not service lifecycle. A new `systemctl`-shaped call must pick a side and match the code to it. (No dedicated Python guard; the only automated check, `no_direct_service_manager_invocation_exists`, scans three `eggwork-server` files. `eggwork-runner` is not covered — discipline is on you.) 3. **Crate dependencies stay one-way.** core/helper → nothing; client → core; server → core + runner (`eggwork-client` is dev-only for the server). -4. **Isolation claims are earned.** Advertise filesystem isolation only when `verify_trusted_helper` accepts the installed helper; the same function backs capability advertisement, `doctor`, and admission. +4. **Isolation claims are earned.** Advertise filesystem isolation only when `verify_trusted_helper` accepts the installed helper; the same function backs capability advertisement, `doctor`, and admission. The node's environment policy has one owner — `crates/eggwork-runner/policy/environment-policy.toml` — generated into each crate and pinned by a parity test, so the runner and the sandbox helper cannot enforce different rules. 5. **Fail closed** on untrusted helper, version skew, missing prior-generation digest, unsupported service backend. Degrade only when the caller never demanded a guarantee, and always record `NotApplied`. 6. **No release identity in `release/eggpack/`** — no tag, source SHA, artifact digest, or size. 7. **`.github/workflows/release.yml` is generated** by `eggpack ci generate`. Never hand-edit; `eggpack ci check` fails on drift. 8. **Never set `RUSTFLAGS`/`CARGO_*RUSTFLAGS`** — the env would silently replace the target-scoped Windows link policy in `.cargo/config.toml` (`/BREPRO`, `/DEBUG:NONE`) that makes MSVC release binaries reproducible. 9. **Windows service management fails closed.** `deployment::windows_scm_manager` is retained but refuses before any mutation; daemon has no SCM dispatcher. +10. **Protocol contract facts have one owner.** The control-plane API schema version and the `exec.argv.v1` capability name are declared once, publicly, in `eggwork-core`; the runner owns the capability names it produces (`LANDLOCK_WORKSPACE_RW_CAPABILITY`, `CGROUPS_V2_{MEMORY,CPU,PIDS}_CAPABILITY`, `WORKSPACE_RW_PROFILE`); the terminal/non-terminal classification of `ExecutionState` is owned by `eggwork-core`'s `ExecutionState::is_terminal` / `is_non_terminal`. A second copy of any of these in an endpoint crate is a defect, not a convenience. See [ADR-0008](plans/adrs/ADR-0008-core-protocol-contract-ownership.md). +11. **A capability is advertised only where the node can honour it, and a failed claim fails the execution, not the report.** `artifact.declared.v1` is advertised only when the platform's capture-capability fact (`artifact::capture_capability`) says the capture can complete; an execution whose declared outputs were not captured ends in a truthful non-success state with a first-class disposition (`ExecutionResult::artifact_capture`), never `Succeeded` with the outputs silently dropped. The mapping from a capture attempt to the terminal facts is one decision (`eggwork_server::decide_artifact_capture`). +12. **The release harness holds no remembered copy of a fact that has an owner.** The workspace version is read once, by `scripts/release_candidate_probe.py`; the install identities and the published target set come from `release/eggpack/distribution.toml`; the service identity comes from the candidate daemon. A second *reader* of one owner is fine — `crates/eggwork-server/tests/release_contract.rs` is exactly that — but a second *rememberer* is a second owner. The same rule governs the design record: a citation names a symbol, never a line number, and `scripts/check_doc_citations.py` is the gate. ## Code style @@ -131,5 +139,5 @@ and deliberate. Deep dives: - Report suspected vulnerabilities privately to the maintainers (see `SECURITY.md`); no public issue with exploit detail. - Never commit secrets, node private keys, or published state (config, SQLite journal, workspaces, blobs, artifacts) — the latter belong to the installation root and never ship in a release artifact. -- Node trust requires a verified mTLS client CA and explicit per-principal grants; `config print` redacts private-key paths and certificate fingerprints. +- Node trust requires a verified mTLS client CA and explicit per-principal grants; a grant may narrow an operation to named resources, and the store's ownership fences remain authoritative; `config print` redacts private-key paths and certificate fingerprints. - SHA-256 sidecars are integrity evidence, not authenticity. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fd2a348..7149801 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,9 +16,18 @@ cargo clippy --locked --workspace --all-targets --all-features -- -D warnings cargo test --locked --workspace --all-targets cargo check --workspace python3 -m unittest discover --start-directory tests/release --top-level-directory tests/release +python3 scripts/check_doc_citations.py +python3 scripts/check_doc_citations.py --prove-negative-exit +python3 scripts/check_quickstart_sync.py git diff --check ``` +The two documentation gates are load-bearing for any change under `architecture/` +or `docs/`: a citation must name a **symbol**, never a line number, and the +quickstart document must agree with `scripts/quickstart.sh`, which is the +executed form of it. Both gates fail the build on a finding — see +[`.skills/pre-submit-gate/`](.skills/pre-submit-gate/). + `--locked` on the clippy and test steps is load-bearing. A workspace version bump that does not update `Cargo.lock` builds fine locally and passes both without it, then fails every release build at `cargo build --locked`. That cost a full diff --git a/Cargo.lock b/Cargo.lock index 0903d89..8011280 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -660,6 +660,7 @@ dependencies = [ "toml", "url", "uuid", + "windows-service", ] [[package]] diff --git a/README.md b/README.md index 1fe1a36..042275a 100644 --- a/README.md +++ b/README.md @@ -128,10 +128,21 @@ filesystem or resource isolation: a `Required` isolation or resource request is refused before the target starts, and a best-effort request is reported as `NotApplied` rather than enforced. -**Windows service management is unsupported and fails closed** — `eggworkd` has -no service-control dispatcher, so a registered service can never reach -`Running`. Every mutating `service` verb is refused before any mutation; Windows -binary installation and daemon runtime are unaffected. +**Windows refuses declared artifacts; it does not capture them.** A Windows +node cannot open a file beneath the workspace root without traversing a +symlink, so it refuses a declared output instead of capturing it. The node does +not advertise the `artifact.declared.v1` capability, and an execution that +declares outputs ends in a failed state with a `failed` capture disposition and +a diagnostic event — never a successful execution whose declared outputs were +silently dropped. + +**Windows hosts a real service.** `eggworkd service-host --config ` is the +Windows service entry: it joins the service control manager, reports +`START_PENDING` while the node comes up, claims `RUNNING` only once the node is +ready, and converges the active executions on `STOP` before it reports `STOPPED`. +Eggup still owns registration and install/start/stop/uninstall — Eggwork hosts +the process, it does not manage the service. The lifecycle proof is a +source-built hosted run; no published release carries it yet. ## Design and contribution diff --git a/architecture/ci-guardrails.md b/architecture/ci-guardrails.md index 4471e8c..d2fc030 100644 --- a/architecture/ci-guardrails.md +++ b/architecture/ci-guardrails.md @@ -19,11 +19,11 @@ Every invariant in [overview.md](overview.md) is stated as a rule that *is enfor | **1. Process ownership is singular.** Only `eggwork-runner` creates OS children; `eggwork-sandbox-helper` may create the target to apply sandbox mechanics. Server, client, and core must not. | `scripts/check_execution_ownership.py` — `scan_sources()` over `crates/*/src/**/*.rs` against the `APPROVED_PROCESS_OWNERS` allowlist, run as the `rust` job step "execution ownership guard" | Nonzero exit; CI red. Prints `process creation outside approved owners ()` per offending file. | | **1b. The ownership guard itself still fails when it should.** | `--prove-negative-exit` step, plus the in-process `self_test()` that runs on *every* invocation | A scanner regression (a dropped spawn pattern) makes the proof step exit 1 with `scanner regression — synthetic forbidden spawn was not detected`. | | **1c. Crate dependency direction.** `eggwork-server` owns no process machinery and must route through `eggwork-runner`. | `check_execution_ownership.py::check_dependencies()` over `cargo metadata --no-deps --format-version 1` | Nonzero exit naming the offending crate, e.g. `eggwork-core must not depend on eggwork-client`, `eggwork-server enables Tokio process creation; use eggwork-runner`, or `eggwork-server must depend on the canonical eggwork-runner`. | -| **2. No direct service-manager invocation** (`systemctl`, `launchctl`, SCM, `crontab`). | Not machine-checked by a dedicated guard. The one hand-written enforcement is `operational-qualification.yml`'s `windows-installed-execution` job, which fails hard if the Windows service verb *does* mutate. Normatively owned by `execution-ownership.md`. | See [Test coverage and gaps](#test-coverage-and-gaps) — this is the weakest-enforced invariant in the set. | +| **2. No direct service-manager invocation** (`systemctl`, `launchctl`, SCM, `crontab`). | Not machine-checked by a dedicated guard. The hand-written enforcement is the `windows-service-host` CI job, which drives every Windows service mutation through the product's own operator CLI and Eggup's typed SCM adapter against a real registration, so the shape of the mutation is visible in a hosted run; plus `operational-qualification.yml`'s `windows-installed-execution` job, whose recorded *service-refusal* disposition is a separate, still-open item (see below). Normatively owned by `execution-ownership.md`. | See [Test coverage and gaps](#test-coverage-and-gaps) — this is the weakest-enforced invariant in the set. | | **Windows owns the whole process tree, and that is checked where it happens.** | The `windows-runner` CI job on `windows-latest` running `cargo test --locked -p eggwork-runner --all-targets`, which compiles the `#![cfg(windows)]` tree-lifecycle suite; plus `cargo clippy --locked --workspace --all-targets -- -D warnings` on the same host | Nonzero exit on any Windows-path regression, and the Linux job's silence no longer reads as Windows coverage. | | **3. Fixed target.** The client names its target explicitly. | Structural: `eggwork-client` is denied a dependency on the node crates by `check_dependencies()`; no workflow resolves a "latest" release. | Nonzero exit from the ownership guard if `eggwork-client` ever gains a `eggwork-runner`/`eggwork-server` edge. | | **4. Isolation claims are earned, never assumed.** | Exercised, not enforced statically: `installed_release_admits_execution_and_refuses_unsupported_isolation` in `crates/eggwork-server/tests/installed_qualification.rs`, driven from the qualification workflow on three hosted targets. | That ignored integration test fails; the hosted job goes red and its receipts are not uploaded. | -| **5. Fail closed on uncertainty** for guarantees the caller demanded. | Same installed-execution test asserts required isolation is *refused* before the target runs; the Windows job records the service disposition and `throw`s if the refusal ever disappears (`the fail-closed guarantee is gone`). | Hard job failure. The Windows step deliberately ends `exit 0` only *after* recording the refusal, so the daemon's non-zero refusal exit is not inherited as the step's result. | +| **5. Fail closed on uncertainty** for guarantees the caller demanded. | Same installed-execution test asserts required isolation is *refused* before the target runs. The Windows job's separate service-refusal assertion (`the fail-closed guarantee is gone`) is a *platform-support* disposition rather than an uncertainty check, so it does not enforce this invariant — see the open item below. | Hard job failure. The Windows step deliberately ends `exit 0` only *after* recording the refusal, so the daemon's non-zero refusal exit is not inherited as the step's result. | | **6. Identity-free release configuration.** No tag, SHA, digest, or size under `release/eggpack/`. | `release_contract.rs::static_release_configuration_embeds_no_future_release_identity`, run inside `cargo test --locked --workspace --all-targets`; plus the `CONTRIBUTING.md` prohibition. | Test failure inside the `rust` job. | | **7. Generated release workflow; no second hand-maintained matrix.** | `release-drift` job running `eggpack ci check` with the pinned revision from `release/eggpack/github-policy.json`; reinforced by `release_contract.rs::the_generated_workflow_is_derived_only_from_static_configuration`, `the_embedded_workflow_shape_matches_the_checked_in_configuration`, and `no_second_hand_maintained_release_matrix_exists`. | `eggpack ci check` exits nonzero on any byte drift; `release-drift` red. | | **8. No published state.** Config, database, workspace, blob, and artifact state never ship in a release artifact. | `release_contract.rs::no_release_asset_carries_node_state`; `.gitignore` excludes `/target/`, `__pycache__/`, `*.sqlite`, `*.sqlite-shm`, `*.sqlite-wal`, `.env` from the tree. | Test failure; the `*_RUSTFLAGS`/rustflags policy is separately asserted by `the_windows_msvc_build_policy_is_deterministic_and_target_scoped`. | @@ -46,7 +46,7 @@ The scanner is deliberately narrow: for path in sorted((ROOT / "crates").glob("*/src/**/*.rs")): ``` -Only `.rs` files under `crates//src/`, at any nesting depth, are scanned. `crate_for_source()` maps a path to a crate by taking the second path component (`rel.parts[1]`) and returning `None` for anything else, so the crate identity is positional, not read from a manifest. Consequence: integration tests (`crates/*/tests/*.rs`), `examples/`, `benches/`, and `build.rs` are **not** scanned. That is the intended production boundary — a test that spawns a process is not a product that owns one — but it is a boundary a reviewer should confirm rather than assume. +Only `.rs` files under `crates//src/`, at any nesting depth, are scanned. `crate_for_source()` maps a path to a crate by taking the second path component (`rel.parts[1]`) and returning `None` for anything else, so the crate identity is positional, not read from a manifest. Consequence: integration tests (`crates/*/tests/*.rs`), `examples/`, `benches/`, and a Cargo build script are **not** scanned. That is the intended production boundary — a test that spawns a process is not a product that owns one — but it is a boundary a reviewer should confirm rather than assume. ### The dependency denylist and its one recorded exception @@ -161,10 +161,20 @@ The allowlist is keyed by crate name, so a backend that lives inside `eggwork-ru run: python3 scripts/check_execution_ownership.py - name: execution ownership guard negative-exit proof run: python3 scripts/check_execution_ownership.py --prove-negative-exit + - name: documentation citation guard + run: python3 scripts/check_doc_citations.py + - name: documentation citation guard negative-exit proof + run: python3 scripts/check_doc_citations.py --prove-negative-exit + - name: quickstart document and script sync + run: python3 scripts/check_quickstart_sync.py - run: cargo fmt --all -- --check - run: cargo clippy --locked --workspace --all-targets --all-features -- -D warnings + - name: build the sandbox helper the capability probe drives + run: cargo build --locked -p eggwork-sandbox-helper - run: cargo test --locked --workspace --all-targets - run: cargo check --workspace + - name: release identity coherence + run: python3 scripts/check_release_tag.py --coherence - name: release candidate validator tests run: python3 -m unittest discover --start-directory tests/release --top-level-directory tests/release ``` @@ -176,11 +186,16 @@ Step by step, and what each would miss without it: 3. **`Swatinem/rust-cache@v2`** — build-time only; no guardrail value. 4. **ownership guard** — the singular-owner assertion. Without it, a `Command::new` in `eggwork-server` is a normal-looking refactor that silently forks process ownership away from `eggwork-runner`, taking with it every lifecycle guarantee in [runner-execution.md](runner-execution.md): cleared environment, bounded stdin, concurrent drain, timeout, cancellation, process-group kill, and leader-exit-with-descendants signaling. 5. **negative-exit proof** — as above. Without it, the guard is a check that has only ever returned 0 in practice. -6. **`cargo fmt --all -- --check`** — mechanical formatting. Without it, diffs carry noise and review attention moves from substance to whitespace. -7. **`cargo clippy --locked --workspace --all-targets --all-features -- -D warnings`** — `--all-features` matters because the qualification and test features are where the interesting code lives; `-D warnings` is what makes the promotion from "warn" to "fail" real, matching `[workspace.lints.clippy] all = "warn"`. Without it, warnings accumulate and the workspace lint table becomes decorative. -8. **`cargo test --locked --workspace --all-targets`** — the whole Rust suite, including `crates/eggwork-server/tests/release_contract.rs` (36 `#[test]` functions), because `--all-targets` pulls in integration tests. This is where most of the release-configuration invariants in the map above are actually enforced. -9. **`cargo check --workspace`** — a cheap whole-workspace type check *without* `--locked` and without `--all-targets`. It is the fastest possible signal on a broken tree and the first thing a contributor sees go red. -10. **Python release validator tests** — the harness test suite, below. +6. **documentation citation guard** — `python3 scripts/check_doc_citations.py`. The design record used to cite **line numbers**. A line number is a property of the text, not of the symbol: every unrelated edit above the target invalidated it, and when the record was measured, 85% of the resolvable citations no longer resolved at the line they named — one of them (`verify_trusted_helper`) named the wrong *file* entirely. The gate makes the record cite **symbols** instead (`path::symbol`), so a citation survives an edit that moves the code, and it rejects the legacy `file.rs:NNN` form outright. It is stdlib-only and reads the tree, so it needs nothing built first and runs the same on every host. +7. **documentation citation guard negative-exit proof** — `--prove-negative-exit` builds a synthetic tree with a deliberately wrong citation and asserts that the *production* check rejects it while a correct one passes. Without it, the citation guard is a check that has only ever returned 0 in practice — the same failure the ownership guard's own proof exists to prevent. +8. **quickstart document and script sync** — `python3 scripts/check_quickstart_sync.py`. `docs/quickstart.md` is the user-facing instruction and `scripts/quickstart.sh` is the executed version of it; they are two renderings of one procedure, so the check compares them command by command, by *shape* rather than by literal text, so the document's `$ROOT` and the script's `$ROOT` are the same command. It also compares the set of `doctor` check names the document shows against the set the node emits — the document once showed seven checks while the node emitted eight, and nothing caught it. +9. **`cargo fmt --all -- --check`** — mechanical formatting. Without it, diffs carry noise and review attention moves from substance to whitespace. +10. **`cargo clippy --locked --workspace --all-targets --all-features -- -D warnings`** — `--all-features` matters because the qualification and test features are where the interesting code lives; `-D warnings` is what makes the promotion from "warn" to "fail" real, matching `[workspace.lints.clippy] all = "warn"`. Without it, warnings accumulate and the workspace lint table becomes decorative. +11. **`cargo build --locked -p eggwork-sandbox-helper`** — the runner's capability probe drives the *built* helper and **fails loudly** when it is absent, so the helper has to exist before the test step. Before Operations M008b that probe returned early and passed with zero assertions when it could not find the helper, which made the skip the normal path in CI as well as locally: the test proved nothing and reported success. Building the helper explicitly is what makes the precondition deterministic rather than incidental. The probe is not a separate job because the runner's test targets already run in this job. +12. **`cargo test --locked --workspace --all-targets`** — the whole Rust suite, including `crates/eggwork-server/tests/release_contract.rs` (36 `#[test]` functions), because `--all-targets` pulls in integration tests. This is where most of the release-configuration invariants in the map above are actually enforced. +13. **`cargo check --workspace`** — a cheap whole-workspace type check *without* `--locked` and without `--all-targets`. It is the fastest possible signal on a broken tree and the first thing a contributor sees go red. +14. **`release identity coherence`** — `python3 scripts/check_release_tag.py --coherence`. The release gate has two halves and only one of them needs a tag. The **tag-dependent** half — "does the tag about to be created name the workspace version?" — cannot live in CI: CI never knows the future tag, and the generated release workflow is producer authority. That comparison lives in `scripts/check_release_tag.py` and is run by whoever cuts the tag, before the tag exists. The **tag-independent** half — the workspace manifest's version against the versions `Cargo.lock` pins for this repository's own packages — needs no tag, so it runs here, on every push and every pull request. It is exactly the condition that broke the `v0.1.3` release attempt. The workflow says so in the step's own comment, so a reader does not have to infer where the gate is. +15. **Python release validator tests** — the harness test suite, below. It now includes the tag guard's own tests, so the code path that decides whether a release may be tagged is **executed against fixtures** by an automated job rather than trusted. ### Why `--locked` is load-bearing @@ -212,12 +227,39 @@ A second job in the same workflow, on `windows-latest`, added by Foundation M004 run: cargo clippy --locked -p eggwork-runner --all-targets --all-features -- -D warnings - name: Windows process-tree lifecycle suite run: cargo test --locked -p eggwork-runner --all-targets -- --nocapture + - name: declared-artifact capture disposition suite + run: cargo test --locked -p eggwork-server --test artifact_capture_disposition + - name: service-host lifecycle suite + run: cargo test --locked -p eggwork-server --bin eggworkd -- --nocapture + - name: service-host identity contract + run: cargo test --locked -p eggwork-server --test windows_service_contract -- --nocapture + # Only the two Windows targets are linted. `--tests` would build the + # server's Linux-shaped unit-test target as well, and that target does + # not compile for Windows. + - name: service-host test targets + run: cargo clippy --locked -p eggwork-server --test windows_service_contract --test windows_service_lifecycle -- -D warnings ``` +**The capability probe's loud failure is not expected here, and the reason is +recorded.** The `rust` job builds the sandbox helper explicitly because +`crates/eggwork-runner/tests/capability_probe.rs` drives the *built* helper and +now **fails loudly** when it cannot find it — the previous implementation +returned early and passed with zero assertions, so the skip was the normal path +in CI as well as locally. This job runs the same test target +(`cargo test --locked -p eggwork-runner --all-targets`), so the precondition has +to be accounted for. It is: the helper-dependent half of the probe is +`#[cfg(target_os = "linux")]`, so it **does not exist** in a Windows build at +all, and only the platform-neutral negative case — a missing helper must not +advertise a Landlock capability — runs here. The Linux `rust` job builds the +helper and runs the full probe. The workflow says the same thing in the step's +comment, so the reason is visible where a reader looks for it. + **Why it exists.** The Windows process-tree backend cannot be observed from Linux. Job Object ownership, descendant convergence after leader exit, and pipe inheritance across a process tree only mean something on a real Windows kernel, and a green Linux run must never be readable as Windows coverage. Foundation M004's `runner` tests are `#![cfg(windows)]`, so without this job the entire suite would silently not exist in CI. **What it deliberately does not run.** `cargo test --workspace` is not used, and test-target clippy is scoped to `eggwork-runner`. The server's and client's unit tests are Linux-shaped: they spawn `/bin/sh` and set `0700`/`0600` modes through `std::os::unix::fs`, so several test helpers do not even *compile* for Windows (`place_trusted_helper` in `crates/eggwork-server/src/lib.rs`, the `PermissionsExt` uses in `artifact.rs`, `blob.rs`, `operations.rs`, and `deployment.rs`). Making them portable is its own milestone. +Three server targets **are** Windows-shaped and **are** run: the declared-artifact capture disposition, `cargo test --locked -p eggwork-server --test artifact_capture_disposition`, which is a contract about the *decision* rather than about the host, so it compiles for Windows without a Linux-shaped harness and is the native evidence that a node which cannot capture declared outputs refuses them and ends the execution in a state that is not a success; the service-host lifecycle suite, `cargo test --locked -p eggwork-server --bin eggworkd`, whose tests live in the binary target because the server's *unit* tests are Linux-shaped and do not compile for Windows; and the service-host identity contract, `cargo test --locked -p eggwork-server --test windows_service_contract`, which asserts the `service-host` argv, the exact executable and config, and the ownership comparison that makes a foreign registration `Foreign` rather than `Owned`. The rest of the server's test surface is still Linux-only and is not claimed here. + That gap is stated rather than papered over, and the split is deliberate: - `cargo clippy --locked --workspace --lib --bins --all-features -- -D warnings` @@ -228,13 +270,260 @@ That gap is stated rather than papered over, and the split is deliberate: This job is still earning its keep: it found three real Windows-only lints that Linux can never see — an un-gated `landlock_runner.rs` header, a Linux-only -`deadline` binding plus a needless `return` in the Windows SCM refusal path, and +`deadline` binding plus a needless `return` in the Windows SCM path, and an ungated `PathBuf` import in the capability probe. The installed production path stays qualified by `operational-qualification.yml` from a staged release's own bytes; a build-tree job could not prove release identity. **Cross-check against the local guard.** Before pushing, `cargo check --locked -p eggwork-runner --all-targets --target x86_64-pc-windows-msvc` compiles the Windows-only code paths on a Linux host. It catches types, imports, and lints; it does not catch kernel behaviour, which is the entire point of the hosted job. (A full `--workspace --target x86_64-pc-windows-msvc` check does not work on Linux: `cc-rs` needs MSVC's `lib.exe` for a transitive C dependency.) +## The `windows-service-host` CI job + +Another job on `windows-latest`, added with the service host. It is the only place in CI +where a real service control manager is driven through a **full** lifecycle — install, +start, stop, restart, uninstall — and it is a different kind of evidence from the +`windows-runner` job: that one proves the host's *logic* compiles and behaves on a +Windows kernel; this one proves that a Windows *service* actually works. The +`windows-installed-execution` qualification job also touches the manager, but only to +register a service and record a disposition; it never starts one successfully. + +```yaml + windows-service-host: + runs-on: windows-latest + timeout-minutes: 45 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.89.0 + - uses: Swatinem/rust-cache@v2 + with: + key: windows-msvc + - name: build the daemon under test + run: cargo build --locked -p eggwork-server --bin eggworkd + - name: stage the installation root + shell: bash + run: … + - name: reserve the loopback port + shell: pwsh + run: … + - name: materialise the bounded fixture + shell: bash + run: … + - name: qualify the hosted service lifecycle + shell: bash + run: cargo test --locked -p eggwork-server --test windows_service_lifecycle -- --ignored --nocapture + - name: the registration is gone + shell: pwsh + run: … +``` + +**What it proves.** The daemon is built from source, the repository's own `rcgen`-based +qualification fixture is materialised, and the `#[ignore]`d +`crates/eggwork-server/tests/windows_service_lifecycle.rs` suite drives a real registration +through the product's own operator CLI: install, start, an authenticated request while the +manager says Running, stop with an active execution, start again, restart, uninstall, a +foreign same-name registration that Eggwork never touches, and a node whose configuration +cannot be loaded never reporting Running. The final step fails the job if a registration +survived the run, so a failed assertion cannot leave a service behind on the runner. + +Every mutation goes through the operator CLI and Eggup's typed adapter. The one exception +is the foreign-ownership negative, which has to create a registration that is not +Eggwork's — that is test orchestration, not a second production manager. + +**Why the fixture is the repository's own.** The same reason the qualification job +materialises its own: a certificate the binary rejects would look like a product defect +rather than a fixture problem, and a runner-provided certificate is exactly the kind of +thing that disagrees about version, extensions, and key encodings. + +**The boundary of the claim.** This job proves the *source-built* service lifecycle. The +*installed release* service lifecycle — release lineage and the exact installed bytes — is +a separate subject, and the repository has no immutable release containing both the M004 +and the M007 work, so there is no exact-release Windows service receipt to cite. The +`operational-qualification.yml` job that would eventually carry that receipt still records +the older service-*refusal* disposition, which is a separate, still-open item. + +## The `quickstart` CI job + +The quickstart is a *procedure*, and `docs/quickstart.md` is its user-facing +instruction while `scripts/quickstart.sh` is its executed form. The job runs +the script end to end: + +```yaml + quickstart: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.89.0 + - uses: Swatinem/rust-cache@v2 + - name: run the quickstart end to end + shell: bash + run: | + set -euo pipefail + bash scripts/quickstart.sh +``` + +The script needs `cargo`, `openssl`, `python3` and `stat`; all four are present +on `ubuntu-latest`. It generates its own TLS material with `openssl`, installs +the helper where the helper's own trust check accepts it, writes a node +configuration, sets the permissions the configuration loader's rules demand, +validates, runs the node, proves a confined execution, and finally compares +the document against itself. It stops the node on every failure path, so a +failed step never leaves a process holding the state directory's lock, and it +names the failing step in its output, so a red job is diagnosable from the log +alone. + +This is what makes the quickstart's commands **executed and verified** rather +than illustrative: the same commands the document shows are the commands CI +runs. The document and the script are kept honest against each other by +`scripts/check_quickstart_sync.py`, which the script itself invokes as its +last step. + +## The `installed-qualification` CI job + +A third job in the same workflow, on `ubuntu-latest`, added by Operations M008b: + +```yaml + installed-qualification: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.89.0 + - uses: Swatinem/rust-cache@v2 + - name: build the installed product surface + run: cargo build --locked -p eggwork-server -p eggwork-sandbox-helper --bins + - name: stage the installation root + run: | + set -euo pipefail + root="${{ runner.temp }}/qualification" + mkdir -p "$root/bin" + install -m 0755 target/debug/eggworkd "$root/bin/eggworkd" + install -m 0755 target/debug/eggwork-sandbox-helper "$root/bin/eggwork-sandbox-helper" + chmod 0755 "$root" "$root/bin" + - name: check the installation root's trust chain + env: + INSTALL_ROOT: ${{ runner.temp }}/qualification + run: | + set -euo pipefail + current="$INSTALL_ROOT" + while true; do + mode=$(stat -c '%a' "$current") + world="${mode: -1}" + group="${mode: -2:1}" + if [ $(( world & 2 )) -ne 0 ] || [ $(( group & 2 )) -ne 0 ]; then + echo "$current is group/world writable (mode $mode); ..." >&2 + exit 1 + fi + parent=$(dirname "$current") + if [ "$parent" = "$current" ]; then break; fi + current="$parent" + done + - name: materialise the bounded qualification fixture + env: + EGGWORK_QUALIFY_ROOT: ${{ runner.temp }}/qualification + run: | + cargo test --locked -p eggwork-server --features qualification \ + --test installed_qualification -- --ignored --exact qualification_fixture + - name: qualify installed execution through the production client + env: + EGGWORK_QUALIFY_DAEMON: ${{ runner.temp }}/qualification/bin/eggworkd + EGGWORK_QUALIFY_CONFIG: ${{ runner.temp }}/qualification/state/node.json + EGGWORK_QUALIFY_TLS_DIR: ${{ runner.temp }}/qualification/state/tls + EGGWORK_QUALIFY_PLATFORM: linux + run: | + cargo test --locked -p eggwork-server --features qualification \ + --test installed_qualification -- --ignored --skip qualification_fixture \ + --test-threads=1 --nocapture +``` + +Three conditions in that job are load-bearing, and each was found by running it, +not by reading it: + +- **The installation root's ancestor chain must be free of group- and + world-writable bits.** The installed helper's trust check + (`eggwork_runner::verify_trusted_helper`) walks *every* ancestor of its own + path and refuses a writable one, because such a directory lets another user + replace the binary that enforces the sandbox. A staging directory created + under a umask of `002` is therefore `0775` and the node refuses its own + helper with `sandbox-resource-backend: configured sandbox helper is missing + or fails installation ownership checks`. The job creates its directories + `0755` and checks the chain explicitly, so the failure names the cause. +- **The two qualification tests must run serially.** They share one + installation root, one state directory, and one execution-state lock, so a + concurrent second daemon cannot start and the first test fails with + `the installed daemon exited before reporting ready`. `--test-threads=1` is + what makes one installation qualify one test at a time. +- **The fixture's client grant must name every operation the suite + exercises.** The declared-artifact test creates a workspace and then lists + the published artifact, so the grant needs `workspace-create` and + `artifact-read`; without them the node refuses with a bare `403 forbidden` + and the qualification reports a fixture problem as a product one. The + repository's fixture now names them. + +**Why this is a separate job and not a flag on the default test step.** The +qualification suite is `crates/eggwork-server/tests/installed_qualification.rs`, +which is `#![cfg(feature = "qualification")]` and whose three tests are +`#[ignore]`d. Adding `--all-features` to the default `cargo test` step would +therefore **not** run them: the `#[ignore]` attributes keep all three tests out +of every ordinary run regardless of the feature set. And an ordinary run has no +installed release to drive in the first place — the suite names its subject +through the environment (`EGGWORK_QUALIFY_DAEMON`, `EGGWORK_QUALIFY_CONFIG`, +`EGGWORK_QUALIFY_TLS_DIR`), and it starts the installed daemon as a child +process. So the gap is closed by **executing** the ignored tests in a job that +has the environment they need: this one stages an installation root, lets the +repository's own `rcgen`-based fixture materialise the TLS material and the +node configuration into it, and then drives the installed daemon through the +production client path. + +**What it proves, and what it does not.** It proves that the bytes this +repository builds admit an execution, report it truthfully, and refuse an +unsupported isolation request — on the build tree's own bytes. It does not +prove release identity: the hosted `operational-qualification` workflow runs +the same suite against a *published* release's exact bytes, and only that can +say anything about what a consumer would download. The installation root here +is under the runner's temporary directory for the same reason the hosted +workflow puts it there: nothing on the installed helper's path may be group- or +world-writable, and the helper's trust check refuses a tree that is. + +**Where the suite runs, in one sentence.** The default `cargo test` step does +not enable `qualification` because the suite is opt-in, ignored, and needs an +installed release; it is executed by this job on every push and pull request, +and by `operational-qualification.yml` against a published release. + +### The quickstart's doctor output, checked in CI + +This job also carries the one step that makes the quickstart document's shown +`doctor` output an *executed* fact rather than a picture: + +```yaml + - name: quickstart doctor output against the node's report + env: + EGGWORK_QUALIFY_ROOT: ${{ runner.temp }}/qualification + run: | + set -euo pipefail + "$EGGWORK_QUALIFY_ROOT/bin/eggworkd" doctor \ + --config "$EGGWORK_QUALIFY_ROOT/state/node.json" \ + > "$EGGWORK_QUALIFY_ROOT/doctor.json" + python3 scripts/check_quickstart_sync.py \ + --doctor-report "$EGGWORK_QUALIFY_ROOT/doctor.json" +``` + +The job already stages an installation root and materialises a node +configuration into it, so the installed daemon's own `doctor` report is +available with no extra setup. The check compares the **set and order** of the +`doctor` check names the document shows against the set the node emits. The +document once showed seven checks while the node emitted eight (`host-telemetry` +was missing), and nothing caught it: the document is the user-facing contract, +so a check the node performs but the document does not mention is a doc +defect, and a check the document shows but the node does not perform is a +false promise to the reader. + +The step runs *after* the qualification execution, because the fixture step is +what materialises `state/node.json` and the TLS material the configuration +names. `scripts/quickstart.sh` performs the same comparison in the same way +when it runs the flow end to end, so the two paths cannot disagree about what +the document says. + ## The `release-drift` job ```yaml @@ -368,7 +657,7 @@ The fixture comes from the repository's own `rcgen`-based harness, not from whic **`native-service-lifecycle`** — macOS only (`aarch64-apple-darwin` and `x86_64-apple-darwin`, both flagged `unsupported_service: true`): `install`, fixture, `qualify_release.py service`, then `qualify_release.py update --prior-release-tag …` to exercise drain, update, and rollback against real generations. -**`windows-installed-execution`** — a hand-written, non-matrix job, and the most interesting one in the file. The header records two structural gaps found by hosted qualification: the installed `eggworkd` implements no service-control dispatcher, so SCM registers the service and then fails to start it with Windows error 1053; and the runner handed every child a Unix-only baseline environment (`PATH=/usr/bin:/bin`, no `SystemRoot`), so a Windows child started and exited with no capturable exit code. Both were fixed on `main` and neither is in the qualified candidate's bytes. So Windows is **dispositioned, not claimed**: the job records the real disposition and "fails if the observation ever diverges from it, so the limitation cannot silently rot." The pwsh step runs `service install`, writes a receipt, and then: +**`windows-installed-execution`** — a hand-written, non-matrix job, and the most interesting one in the file. The header records two structural gaps found by hosted qualification: the `eggworkd` in the qualified candidate implements no service-control dispatcher, so SCM registers the service and then fails to start it with Windows error 1053; and the runner handed every child a Unix-only baseline environment (`PATH=/usr/bin:/bin`, no `SystemRoot`), so a Windows child started and exited with no capturable exit code. The environment gap was fixed on `main`; the dispatcher gap was fixed later, by the service host; and neither fix is in the qualified candidate's bytes. So Windows is **dispositioned, not claimed**: the job records the real disposition and "fails if the observation ever diverges from it, so the limitation cannot silently rot." The pwsh step runs `service install`, writes a receipt, and then: ```powershell if (-not $unsupported) { @@ -382,6 +671,19 @@ exit 0 The trailing `exit 0` is deliberate and commented: the refusal *is* the recorded disposition, so the step must not inherit the daemon's nonzero exit as its own result. A release that registers a service has lost the guarantee, and that is a hard failure, not a note. +**That disposition is release-scoped, and re-pointing it is an open item — not a service +lifecycle.** The step asserts that `service install` *refuses*: the output has to match +`unsupported` and the exit code has to be non-zero. It runs against the **staged release's +own bytes**, so today it still passes — the released candidate predates the service host +and still refuses. The moment a release carrying the service host is staged, that +assertion inverts: the install succeeds, the output does not match `unsupported`, and the +job throws "Windows service install did not refuse; the fail-closed guarantee is gone". +Re-pointing the job at the new disposition is a separate, still-open item, and until that +is done this job says nothing about whether a Windows service works. It is not a service +lifecycle and must not be read as one: the lifecycle evidence is the hosted +`windows-service-host` CI job, and the *installed release* service lifecycle is a +separate subject that no candidate covers yet. + Every job uploads **bounded receipts** — `${{ runner.temp }}/receipts/*.json` (plus `windows-service.txt`) under a run-id-and-attempt-suffixed artifact name, `if-no-files-found: error`, 7-day retention. The harness internals — token handling, retry policy, size bounds, stage sequencing — are covered in [release-qualification.md](release-qualification.md). ## Lints and toolchain policy @@ -417,7 +719,11 @@ Both `ci.yml` and the generated release workflow install the same `1.89.0` chann ## Other guard scripts -**`scripts/check_release_tag.py` (pre-tag guard).** Takes one argument, the exact tag about to be created, e.g. `python3 scripts/check_release_tag.py v0.1.5`. It requires three things to agree: the tag (minus a leading `v`) equals the first `version = "…"` in `Cargo.toml`; every `eggwork-*` package in `Cargo.lock` is pinned at that same version; and the run is otherwise clean. Its docstring names both incidents it exists for — v0.1.3 (bump without lock regeneration, so every `--locked` release build failed closed) and v0.1.4 (bump missed entirely, so staged binaries reported `0.1.3` and hosted qualification refused them with `installed-daemon-version: daemon reports '0.1.3', expected 0.1.4`). Crucially, it is **not** a CI check, and the docstring explains why: "The tag-to-version link cannot live in CI: the generated release workflow is producer authority (the `release-drift` job rejects hand edits to it), and CI never knows the future tag. So the check lives here, run by whoever cuts the tag, before the tag exists." It defends the tag→version→lock identity, and its failure message ends with the remediation: `bump Cargo.toml, regenerate the lock, rerun the gates, then tag.` +**`scripts/check_release_tag.py` (pre-tag guard).** Takes one argument, the exact tag about to be created, e.g. `python3 scripts/check_release_tag.py v0.1.5`, or `--coherence` to run only the tag-independent half. It requires three things to agree: the tag (minus a leading `v`) equals `[workspace.package].version` in `Cargo.toml`; every package `Cargo.lock` records as built from this repository is pinned at that same version; and every workspace member is pinned in the lock at all. Its docstring names both incidents it exists for — v0.1.3 (bump without lock regeneration, so every `--locked` release build failed closed) and v0.1.4 (bump missed entirely, so staged binaries reported `0.1.3` and hosted qualification refused them with `installed-daemon-version: daemon reports '0.1.3', expected 0.1.4`). + +Two changes in Operations M008b are load-bearing rather than cosmetic. First, the guard no longer reads the manifest with a regular expression that took the *first* `version = "…"` line in the file — that was the right answer only by accident of the manifest's current layout — and it no longer parses `Cargo.lock` with regular expressions either. Both are read with real TOML readers now, because **a guard that decides whether a release may be tagged must not depend on the layout of the files it reads**. The workspace version comes from the shared reader in `release_candidate_probe.py`, which every release script uses. Second, the guard is no longer *only* a manual step: its **tag-independent** half now runs in CI on every push and every pull request (`release identity coherence` in the `rust` job), and its logic is exercised against fixtures by `tests/release/test_release_tag_guard.py`, so the code path that decides whether a release may be tagged is executed by an automated job rather than trusted. + +The **tag-dependent** half is still a human pre-tag step, and the docstring says why: "The tag-to-version link cannot live in CI: the generated release workflow is producer authority (the `release-drift` job rejects hand edits to it), and CI never knows the future tag. So the check lives here, run by whoever cuts the tag, before the tag exists." It defends the tag→version→lock identity, and its failure message ends with the remediation: `bump Cargo.toml, regenerate the lock, rerun the gates, then tag.` The upstream prerequisite that would move this half into the generated release workflow is recorded in [release-qualification.md](release-qualification.md#where-the-tag-gate-runs-today--and-where-it-does-not). **`scripts/release_candidate_probe.py` (shared bounded probe library).** Not a validator itself — the shared substrate the two Eggpack-facing validators import. Eggpack invokes each validator as `python3