diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f1549e..530f8c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,7 @@ jobs: - run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings - run: cargo test --workspace --all-targets --all-features --locked - run: cargo doc --workspace --no-deps --locked + - run: cargo package -p eggup-service --locked msrv: name: MSRV check @@ -28,6 +29,26 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@1.89.0 - run: cargo check --workspace --all-targets --locked + - run: cargo package -p eggup-service --locked + + service-systemd: + name: Linux systemd service qualification + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - run: cargo fmt --manifest-path crates/eggup-service/tests/published-api-0.1.2/Cargo.toml -- --check + - run: cargo check --manifest-path crates/eggup-service/tests/published-api-0.1.2/Cargo.toml --locked + # This registry-only 0.1.2 fixture is a deliberate negative control for + # the failed-unit behavior added to the unpublished workspace 0.1.3. + - run: sudo --preserve-env=PATH,HOME,RUSTUP_HOME,CARGO_HOME env EGGUP_SYSTEMD_INTEGRATION=1 "$HOME/.cargo/bin/cargo" test --manifest-path crates/eggup-service/tests/published-api-0.1.2/Cargo.toml --locked -- --nocapture + # This fixture writes disposable unit files under /run/systemd/system. + # Run the test process as root so systemd can load and control them. + - run: sudo --preserve-env=PATH,HOME,RUSTUP_HOME,CARGO_HOME env EGGUP_SYSTEMD_INTEGRATION=1 "$HOME/.cargo/bin/cargo" test -p eggup-service --test systemd_failed_service --locked -- --nocapture + # These tests resolve the published crate and core from crates.io only. + - run: cargo fmt --manifest-path crates/eggup-service/tests/published-api-0.1.3/Cargo.toml -- --check + - run: cargo check --manifest-path crates/eggup-service/tests/published-api-0.1.3/Cargo.toml --locked + - run: sudo --preserve-env=PATH,HOME,RUSTUP_HOME,CARGO_HOME env EGGUP_SYSTEMD_INTEGRATION=1 "$HOME/.cargo/bin/cargo" test --manifest-path crates/eggup-service/tests/published-api-0.1.3/Cargo.toml --locked -- --nocapture macos: name: macOS tests @@ -38,6 +59,7 @@ jobs: with: components: rustfmt, clippy - run: cargo test --workspace --all-targets --all-features --locked + - run: cargo package -p eggup-service --locked windows-check: name: Windows archive, acquisition, and service tests and check @@ -59,3 +81,4 @@ jobs: # --no-fail-fast: this lane is the only Windows test coverage, so a single # failing target must not hide the state of every other one. - run: cargo test --workspace --all-targets --locked --no-fail-fast + - run: cargo package -p eggup-service --locked diff --git a/.gitignore b/.gitignore index b2eb7f4..9bda1e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ /target/ +/crates/eggup-service/tests/published-api-0.1.2/target/ +/crates/eggup-service/tests/published-api-0.1.3/target/ # macOS Finder metadata. Ignored so the tree can stay clean for the # no---allow-dirty publication step in the release plans. diff --git a/.opencode/skills/docs-hygiene/SKILL.md b/.opencode/skills/docs-hygiene/SKILL.md index bf07655..9d9f800 100644 --- a/.opencode/skills/docs-hygiene/SKILL.md +++ b/.opencode/skills/docs-hygiene/SKILL.md @@ -56,13 +56,14 @@ to stay correct. Each has occurred at least once — check for them explicitly: -1. **CI lane understatement.** Windows runs six `cargo test` steps - (`ci.yml:48-53`), not just `cargo check`. MSRV is compile-only. Never call - `windows-check` "compile-only" — and count the steps, not the bullets: the - three named `eggup-service` tests are three steps, not one. -2. **Publication status.** "Unpublished" is wrong for `eggup-service` — it is on - crates.io at `0.1.0`/`0.1.1` while its `0.1.2` was never published. Check - crates.io rather than inferring from a `publish = false` key or a plan. +1. **CI lane understatement.** Windows runs nine `cargo test` steps + (`ci.yml:66-79`) plus packaged service verification. There is also a + privileged Linux `service-systemd` lane. Count commands, not bullets: three + named `eggup-service` diagnostic tests are three steps. The MSRV lane runs a + workspace check and packaged service verification; it does not run tests. +2. **Publication status.** `eggup-service 0.1.2` is published; the corrected + `0.1.3` service candidate is not yet published. Check crates.io rather than + inferring from a `publish = false` key or a plan. 3. **Enum tables lagging the source.** `architecture/core-transaction.md` once described a whole earlier generation of `eggup-core`'s enums. When a variant is added, renamed, or removed, update every table that lists variants. @@ -82,9 +83,10 @@ Each has occurred at least once — check for them explicitly: 8. **Broken markdown tables.** Copy-pasting a row between tables of different arity silently drops cells. Check column counts. 9. **Counting steps, not bullets.** A CI lane that runs three separately-named - tests is three steps, not one. `windows-check` is six `cargo test` steps - (`ci.yml:48-53`): one combined three-crate run, one eggpack run, three named - `eggup-service` tests, and `windows_scm::tests`. Count the `- run:` lines. + tests is three steps, not one. `windows-check` is nine `cargo test` steps + (`ci.yml:66-79`): one combined three-crate run, eggpack, three named service + tests, SCM, two Core integration fixtures, and the full workspace run. It + then verifies the packaged service crate. Count the `- run:` lines. 10. **A quoted phrase that was never written.** A governance section attributed a quoted comment to a skill file that did not contain it. When a doc quotes another doc, `grep` the quoted string — a paraphrase presented as a diff --git a/.opencode/skills/release-workflow/SKILL.md b/.opencode/skills/release-workflow/SKILL.md index a6a4e2c..e1e6057 100644 --- a/.opencode/skills/release-workflow/SKILL.md +++ b/.opencode/skills/release-workflow/SKILL.md @@ -46,9 +46,9 @@ explicitly in the plan and in the registry, or it will be discovered late. version (`0.1.2` → `0.1.3`). - Do not move `v0.1.1` / `v0.1.2` tags. Extend release notes instead. - Do not publish `eggup-transport-footprint` — it is `publish = false`. -- Do not publish `eggup-service` without a milestone authorizing it. It is on - crates.io at `0.1.0`/`0.1.1` while its `0.1.2` has never been published, so - "it is unpublished" is the wrong mental model. +- Do not publish `eggup-service` without explicit maintainer authorization for + Service M011. It is published through `0.1.2`; the M010 correction is the + unpublished `0.1.3` candidate. - Do not add release CI. Manual publication is a recorded decision. ## Qualification before publishing diff --git a/.opencode/skills/verify-workflow/SKILL.md b/.opencode/skills/verify-workflow/SKILL.md index 1f0f6f0..807d304 100644 --- a/.opencode/skills/verify-workflow/SKILL.md +++ b/.opencode/skills/verify-workflow/SKILL.md @@ -34,10 +34,11 @@ only** — nothing in the script or CI fails when a boundary is crossed. | Job | Runner | What it adds | |---|---|---| -| `stable` | ubuntu | fmt + clippy + full `cargo test` + `cargo doc`; the only lane running clippy, fmt, and doc | -| `msrv` | ubuntu, pinned `1.89.0` | `cargo check --workspace --all-targets --locked` — compile-only, no clippy, no tests | -| `macos` | macos-latest | full `cargo test`; the only macOS evidence | -| `windows-check` | windows-latest | **runs tests**, ending in a full `cargo test --workspace --all-targets` — see below | +| `stable` | ubuntu | fmt + clippy + full `cargo test` + `cargo doc` + packaged service verification; the only lane running clippy, fmt, and doc | +| `msrv` | ubuntu, pinned `1.89.0` | workspace `cargo check` and packaged service verification at the MSRV | +| `service-systemd` | ubuntu-latest | registry-only 0.1.2 negative control, current workspace systemd fixtures, and published registry-only 0.1.3 positive quiescence plus ownership controls | +| `macos` | macos-latest | full `cargo test` + packaged service verification; the only macOS evidence | +| `windows-check` | windows-latest | **runs nine test steps**, ending in a full `cargo test --workspace --all-targets`, then package verification — see below | `windows-check` is *not* compile-only, and it is no longer a curated subset. It runs the platform-sensitive steps, then the two Core fixture files, then the @@ -56,7 +57,8 @@ whole workspace: 6. `cargo test -p eggup-core --test stale_lock_recovery --locked` — exercises the claim/race fixtures natively; `rename` semantics differ per platform, so compile-only evidence is not sufficient for M011. -7. `cargo test --workspace --all-targets --locked` +7. `cargo test --workspace --all-targets --locked --no-fail-fast` +8. `cargo package -p eggup-service --locked` — verifies package-produced source on Windows Step 7 exists because the per-crate steps cannot catch a regression in an untargeted crate. It passes `--no-fail-fast` deliberately: this lane is the only @@ -85,6 +87,8 @@ narrowing the step, and keep `--no-fail-fast`. `eggup-transport-footprint` binaries are behind `required-features`, so **no MSRV lane and no Windows lane ever compiles them**. Only `stable` and `macos` build non-default features. +- The `msrv` package check applies the Rust 1.89 floor to `eggup-service` only; + other crates are covered by the workspace `cargo check`. - clippy and fmt run on Linux only — a `#[cfg(windows)]` or `#[cfg(target_os = "macos")]` clippy violation is caught by no lane. - `macos` is the only lane that runs `cargo test` with `--all-features`, and diff --git a/AGENTS.md b/AGENTS.md index dfae8bc..d47f293 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -42,7 +42,7 @@ gaps are in [`architecture/tooling-governance.md`](architecture/tooling-governan Focused runs: `cargo test -p eggup-core`, `cargo test -p eggup-core `, `cargo clippy -p --all-targets --locked -- -D warnings`. -CI (`.github/workflows/ci.yml`) adds what the script lacks: `stable` (fmt/clippy/test/doc on Linux), `msrv` (compile-only `cargo check` on 1.89.0), `macos` (full `cargo test`), and `windows-check` — which **runs tests**, not just a check: the acquisition/archive/curl, `eggup-eggpack`, and named `eggup-service` diagnostic-safety runs, then `cargo test -p eggup-core --test current_executable` and `--test stale_lock_recovery` (Core M010/M011 self-replacement and lock-race fixtures must execute natively, not merely compile), then a full `cargo test --workspace --all-targets`. Neither `msrv` nor `windows-check` passes `--all-features`, so the feature-gated footprint binaries are built only by `stable` and `macos`. CI never publishes; releases are manual. +CI (`.github/workflows/ci.yml`) adds what the script lacks: `stable` (fmt/clippy/test/doc plus packaged service verification on Linux), `msrv` (workspace `cargo check` and packaged service verification on 1.89.0), `service-systemd` (registry-only published 0.1.2 negative controls, current real-systemd fixtures, and published registry-only 0.1.3 positive quiescence and ownership controls), `macos` (full `cargo test` plus package verification), and `windows-check` — which runs nine `cargo test` steps, then `cargo package -p eggup-service --locked`. Windows tests cover acquisition/archive/curl, eggpack, three named service diagnostic tests, SCM, Core `current_executable` and `stale_lock_recovery`, then the full workspace. Core M010/M011 self-replacement and lock-race fixtures execute natively, not merely compile. Neither `msrv` nor `windows-check` passes `--all-features`, so the feature-gated footprint binaries are built only by `stable` and `macos`. CI never publishes; releases are manual. ## Where to look diff --git a/CHANGELOG.md b/CHANGELOG.md index bcde681..82ae697 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -208,6 +208,17 @@ claims are made by any of these crates. authenticity, and authorizes no filesystem destination; caller-bound destination APIs are unchanged. +- `eggup-service 0.1.3` (Service M011; published 2026-10-09): + contains the Service M010 source-compatible correction for stopping an + exact-owned failed systemd unit only after identity, manager state, process, + and cgroup quiescence evidence agree. Unknown state, changed identity, + restart races, and a remaining cgroup task fail closed. Runtime source is + `0bde3fefbda07019529ad7566c02e6e4ec141fd6`; the package source commit is + `feb6ae5aea4c9b61c4051957f3662ca49d845f9e` and the registry checksum is + `9f7f7ea854577158e66aa202709ab1c97a3aedcf00b06c1ab914d25b132124dc`. + M011's registry-only post-publication and hosted systemd evidence is recorded + in `plans/closure/service-lifecycle/011-status.md`. + ## Unreleased The workspace-wide bug-audit fixes below are recorded here as well as in the diff --git a/README.md b/README.md index c05c7ab..2a1023b 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,10 @@ user-facing guidance and never overrides them. ## Publication state `eggup-core`, `eggup-archive`, `eggup-acquisition`, `eggup-eggfetch`, -`eggup-eggpack`, `eggup-curl`, and `eggup-service` are all published at `0.1.2`. +`eggup-core`, `eggup-archive`, `eggup-acquisition`, `eggup-eggfetch`, and +`eggup-eggpack` are published at `0.1.3`; `eggup-curl` and `eggup-service` are +published at `0.1.2`. Service M010's `0.1.3` correction is still in M011 release +qualification and has not been published. `eggup-service` was published later from a different source commit than the shared `v0.1.2` tag, which denotes the `eggup-core`/`eggup-archive` publication; the tag was not moved. `eggup-transport-footprint` is `publish = false` by design. CI never diff --git a/architecture/overview.md b/architecture/overview.md index bdb6242..a146a5e 100644 --- a/architecture/overview.md +++ b/architecture/overview.md @@ -42,8 +42,11 @@ manager, and producer concerns. Derived from the `crates/*/Cargo.toml` manifests. Arrows point from dependent to dependency (compile-time direction). All 8 crates carry the workspace version -`0.1.2`; six of them are published at `0.1.2` on crates.io. `eggup-service` is -published but lags at `0.1.1`, and `eggup-transport-footprint` is `publish = false`. +`0.1.3`; all seven library crates are published at `0.1.2` or `0.1.3` on crates.io. +Service M011 published the M010 `eggup-service 0.1.3` correction from source +`feb6ae5aea4c9b61c4051957f3662ca49d845f9e`; its checksum and external +qualification are recorded in the M011 closure. The shared `v0.1.3` tag was +not moved. `eggup-transport-footprint` is `publish = false`. ```text eggup-transport-footprint (publish = false, 3 bins) @@ -243,9 +246,10 @@ Contract-level detail that belongs to no single crate: - [closure records](../plans/closure/README.md) — requirement → evidence matrices Publication state: `eggup-core`, `eggup-archive`, `eggup-acquisition`, -`eggup-eggfetch`, `eggup-eggpack`, and `eggup-curl` are published at `0.1.2`. -`eggup-service` **is** on crates.io but only at `0.1.0`/`0.1.1`, so its `0.1.2` -has never been published and no milestone authorizes it. +`eggup-eggfetch`, `eggup-eggpack`, and `eggup-service` are published at `0.1.3`; +`eggup-curl` is published through `0.1.2`. Service M011 published the M010 +correction from `feb6ae5`; checksum and registry-only qualification are in its +closure record. The shared `v0.1.3` tag was not moved. `eggup-transport-footprint` is `publish = false` by design and has no registry version. CI never publishes; releases are manual — see [tooling-governance.md](tooling-governance.md) §8. diff --git a/architecture/service-lifecycle.md b/architecture/service-lifecycle.md index 443db81..e2ec738 100644 --- a/architecture/service-lifecycle.md +++ b/architecture/service-lifecycle.md @@ -64,11 +64,14 @@ eggup-service -> windows-args (=0.2.0) **Windows-target dependency**, so the Linux/macOS build never links it. - `windows-args` is cross-platform and is used for the SCM command-line parser, so the ownership tests in `windows_scm.rs` run on every host. -- **The crate is published but lags the workspace.** It is on crates.io at - `0.1.0` and `0.1.1`; its `0.1.2` has not yet been published. Service M009 now - authorizes a future manual `0.1.2` publication, but until that milestone closes - the `Unreleased` section below is still not on the registry. `eggup-core`, `eggup-archive`, `eggup-acquisition`, `eggup-eggfetch`, - `eggup-eggpack`, and `eggup-curl` are the published `0.1.2` set. +- **The crate is current with the workspace.** It is on crates.io at + `0.1.0`, `0.1.1`, `0.1.2`, and `0.1.3`; the `0.1.2` service publication came + from `7fb84bc`, after the shared `v0.1.2` tag, which remains the core/archive + source tag. Service M011 published the `0.1.3` owned failed-systemd + quiescence correction from source `feb6ae5`; its exact checksum and registry + qualification are in the M011 closure. + `eggup-core`, `eggup-archive`, `eggup-acquisition`, `eggup-eggfetch`, + `eggup-eggpack`, and `eggup-curl` are also published at `0.1.2` or later. `eggup-transport-footprint` is `publish = false` ([registry.md](../plans/registry.md)). - Dependency order position: 5th deepest in @@ -799,6 +802,19 @@ narrow `parse_exec_start` (`lib.rs:1574`) plus `reconcile_config_identity`. asked for them via `SystemdInstall::{enable,reload}`. `start` / `stop` / `restart` are bounded by `OperationDeadline` and confirm the resulting state. +`stop` handles an exact-owned unit reported as `failed` without changing the +closed public `LifecycleState` enum. It re-reads the full systemd observation +immediately before stopping and after the stop. Completion requires matching +ownership, a stable failed/inactive state, no active job, zero `MainPID` and +`ControlPID`, and either no unit control group or an empty cgroup v2 process +list with `cgroup.events` reporting `populated 0`. It also checks that +`systemctl is-active` agrees with the final `ActiveState`. Unknown state, +changed identity/control group, inaccessible or malformed cgroup evidence, and +restart/transition races return incomplete or an error; they do not authorize +rollback against a possibly live process. It never calls `reset-failed`. +`plans/closure/service-lifecycle/010-status.md` records the real-systemd +qualification and its negative controls. + `reconcile_config_identity` (`lib.rs:1491-1524`) is the subtle part: the config path is only treated as part of identity if it appears **exactly once** in the spec's canonical args and once in the observed args. Zero occurrences in the diff --git a/architecture/tooling-governance.md b/architecture/tooling-governance.md index a5f05e6..958db25 100644 --- a/architecture/tooling-governance.md +++ b/architecture/tooling-governance.md @@ -9,7 +9,7 @@ and `plans/`. Factual as of the current tree. Every other deep dive in `architecture/` describes *what a subsystem does*. This one describes *how a change is admitted*: the workspace manifest and its dependency boundaries, the three lint layers, the single local verification -script, the four-job CI matrix, and the plan → implement → closure → registry +script, the five-job CI matrix, and the plan → implement → closure → registry process that produces the evidence a reviewer checks. The governing idea is separation of concerns applied to verification itself: @@ -42,7 +42,7 @@ lane is a claim. | `crates/eggup-curl` | yes | External-curl adapter | | `crates/eggup-archive` | yes | Bounded allowlisted local extraction | | `crates/eggup-eggpack` | yes | Optional Eggpack ReleaseManifest v1 adapter | -| `crates/eggup-service` | yes, but lagging (registry at `0.1.0`/`0.1.1`; `0.1.2` never published) | Manager-neutral service lifecycle | +| `crates/eggup-service` | yes; registry through `0.1.3` (M011) | Manager-neutral service lifecycle | | `crates/eggup-transport-footprint` | no (`publish = false`) | Footprint fixture binaries | `resolver = "2"` is load-bearing rather than cosmetic: the workspace mixes @@ -249,14 +249,15 @@ under time pressure, and it is the one that protects the layered design. ## 5. The CI matrix `.github/workflows/ci.yml` — triggers `push` and `pull_request` (`ci.yml:3-6`), -`permissions: contents: read` (`ci.yml:7-8`), four jobs. +`permissions: contents: read` (`ci.yml:7-8`), five jobs. | Job | Runner | Toolchain | Exact commands | What it uniquely proves | |---|---|---|---|---| -| `stable` | `ubuntu-latest` | stable + `rustfmt`, `clippy` | `cargo fmt --all -- --check`; `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`; `cargo test --workspace --all-targets --all-features --locked`; `cargo doc --workspace --no-deps --locked` | Linux is the reference platform. The only lane that runs clippy, fmt, and doc | -| `msrv` | `ubuntu-latest` | `1.89.0` (`ci.yml:29`) | `cargo check --workspace --all-targets --locked` | The code type-checks at the declared `rust-version` floor. Clippy and tests are not run here, so this is a compile check only | -| `macos` | `macos-latest` | stable | `cargo test --workspace --all-targets --all-features --locked` | The full test suite passes on a non-Linux Unix — the only evidence for macOS behavior | -| `windows-check` | `windows-latest` | stable | `cargo test -p eggup-acquisition -p eggup-archive -p eggup-curl --locked`; `cargo test -p eggup-eggpack --all-targets --all-features --locked`; three `cargo test -p eggup-service --lib --locked` steps; `cargo test -p eggup-service --lib windows_scm::tests --locked`; `cargo test -p eggup-core --test current_executable --locked`; `cargo test -p eggup-core --test stale_lock_recovery --locked`; then `cargo test --workspace --all-targets --locked --no-fail-fast` (`ci.yml:48-61`) | Windows compiles the whole workspace and *runs* it. The targeted steps run first so a platform-specific failure is named before the broad run buries it | +| `stable` | `ubuntu-latest` | stable + `rustfmt`, `clippy` | `cargo fmt --all -- --check`; `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`; `cargo test --workspace --all-targets --all-features --locked`; `cargo doc --workspace --no-deps --locked`; `cargo package -p eggup-service --locked` | Linux is the reference platform. The only lane that runs clippy, fmt, and doc; also verifies packaged service source | +| `msrv` | `ubuntu-latest` | `1.89.0` (`ci.yml:30`) | `cargo check --workspace --all-targets --locked`; `cargo package -p eggup-service --locked` | The workspace type-checks and the packaged service crate verifies at the declared `rust-version` floor. Clippy and tests are not run here | +| `service-systemd` | `ubuntu-latest` | stable | registry-only published 0.1.2 negative control; privileged current workspace systemd test; registry-only published 0.1.3 positive quiescence and Foreign/malformed controls | Real systemd evidence for the published limitation and correction, auto-restart stop, residual cgroup refusal, and foreign preservation | +| `macos` | `macos-latest` | stable | `cargo test --workspace --all-targets --all-features --locked`; `cargo package -p eggup-service --locked` | The full test suite and packaged service source pass on a non-Linux Unix — the only evidence for macOS behavior | +| `windows-check` | `windows-latest` | stable | nine `cargo test` steps (`ci.yml:66-79`), followed by `cargo package -p eggup-service --locked` (`ci.yml:80`) | Windows compiles and *runs* the workspace and separately verifies packaged service source. Targeted tests run first so a platform-specific failure is named before the broad run buries it | ### 5.1 Why `windows-check` leads with targeted steps @@ -269,6 +270,8 @@ The targeted steps stay, ahead of the full run, because they name the failure instead of reporting a pile of results. The closing run passes `--no-fail-fast`: this is the only Windows test coverage, so one failing target must not hide the state of every other one. +The final `cargo package -p eggup-service --locked` step also verifies the +package-produced source on Windows. The widening has already paid for itself. Turning on `cargo test --workspace` exposed @@ -318,7 +321,7 @@ platform lane that a whole-workspace run would not guarantee. |---|---| | No `cargo tree` anywhere in CI | The dependency-boundary review is local-only, and the local step is advisory (§4.1) | | No `cargo check` with `--all-features` on the MSRV lane | `msrv` uses `cargo check --workspace --all-targets --locked` (`ci.yml:30`) — no `--all-features`. Feature-gated code is not compiled at the 1.89 floor, so an MSRV break that only appears under a non-default feature passes | -| No `cargo check` with `--all-features` on the Windows lane | `ci.yml:54` is the same command. The feature-gated footprint binaries are not built on Windows either | +| No `cargo check` with `--all-features` on the Windows lane | `ci.yml:65-79` runs default-feature tests plus a packaged `eggup-service` check; it does not build the feature-gated footprint binaries on Windows | | Clippy and fmt run on Linux only | A `#[cfg(windows)]` or `#[cfg(target_os = "macos")]` clippy violation is not caught by any lane — the Windows and macOS jobs run `test`/`check`, never `clippy` | | `cargo doc` on Linux only | `deny(missing_docs)` is not re-verified per platform, which is acceptable since rustdoc is platform-independent | | No `cargo test` with `--all-features` on the Windows lane | The closing run is `cargo test --workspace --all-targets --locked`. Combined with the targeted steps, every crate's tests now execute on Windows — but only under default features, so the footprint binaries and any other feature-gated path remain unbuilt there | @@ -516,7 +519,7 @@ drifting skill is corrected by rewriting the skill, never by deferring to it. | Skill | Summarizes | Source of truth | |---|---|---| | `planning-workflow` | Plan → implement → closure → registry; the 16-section template; closure requirements; naming; the severity gate | `plans/003-planning-process.md`, `plans/implementation/README.md`, `plans/closure/README.md` | -| `verify-workflow` | Local gate order, focused runs, the four CI lanes, and the known coverage gaps | `scripts/check-local.sh`, `.github/workflows/ci.yml`, §4–§5 | +| `verify-workflow` | Local gate order, focused runs, the five CI lanes, and the known coverage gaps | `scripts/check-local.sh`, `.github/workflows/ci.yml`, §4–§5 | | `docs-hygiene` | Which doc owns which fact, the doc-change chain, and the drift classes this repo keeps hitting | this file, `plans/registry.md`, `crates/*/README.md` | | `release-workflow` | Manual publication as a milestone, dependency ordering, the exact-pin cascade, post-publish bookkeeping | §8, `plans/registry.md`, the four publication closures | @@ -536,8 +539,9 @@ instances, recorded at the end of this file. The maintenance rules: of `eggup-core`'s failure enums. - A doc that claims a **CI lane** is read from the workflow file, not from another doc. `verify-workflow` and `AGENTS.md` both once understated the - Windows lane as compile-only when it runs six `cargo test` steps - (`ci.yml:48-53`). + Windows lane as compile-only; it now runs nine `cargo test` steps and a + packaged service build, and the fifth `service-systemd` job runs privileged + real-manager qualification (`ci.yml:34-80`). - A doc that claims a **publication status** is checked against crates.io. `eggup-service` was described as "unpublished" in three places while being on crates.io at `0.1.0`/`0.1.1`. @@ -590,31 +594,28 @@ CI added." | Crate | Workspace version | On crates.io | Note | |---|---|---|---| -| `eggup-core` | 0.1.2 | 0.1.0, 0.1.1, **0.1.2** | Sole dep `sha2`; transaction mechanics | -| `eggup-archive` | 0.1.2 | **0.1.2** | Bounded extraction | -| `eggup-acquisition` | 0.1.2 | 0.1.0, 0.1.1, **0.1.2** | Zero-dependency seam; `0.1.3` is M010 | -| `eggup-eggfetch` | 0.1.2 | 0.1.0, 0.1.1, **0.1.2** | Native HTTP adapter | -| `eggup-curl` | 0.1.2 | **0.1.2** | External-curl adapter; first publication was 0.1.2 | -| `eggup-eggpack` | 0.1.2 | **0.1.2** | Only crate touching producer types; pins `=0.1.2` | -| `eggup-service` | 0.1.2 | 0.1.0, **0.1.1** | **Published but lagging** — see below | -| `eggup-transport-footprint` | 0.1.2 | none (`publish = false`) | Binary-only fixture crate, non-publishable by design | - -All 8 crates share the workspace version `0.1.2`; only the registry state -differs. Six crates are published at `0.1.2`. - -**`eggup-service` is not an unpublished crate.** It is on crates.io at `0.1.0` -and `0.1.1` (it was part of the lockstep `0.1.1` patch, listed in -`plans/registry.md`), but its current `0.1.2` has never been published and no -publication milestone authorizes it. Its manifest carries no `publish = false` -key — it is simply outside every publication authorization to date. Describing -it as "unpublished" is wrong in the sense that matters: a downstream consumer -can and does resolve `eggup-service 0.1.1` today, and that published code -predates the `Unreleased` fixes in its changelog. +| `eggup-core` | 0.1.3 | 0.1.0, 0.1.1, 0.1.2, **0.1.3** | Sole dep `sha2`; transaction mechanics | +| `eggup-archive` | 0.1.3 | 0.1.2, **0.1.3** | Bounded extraction | +| `eggup-acquisition` | 0.1.3 | 0.1.0, 0.1.1, 0.1.2, **0.1.3** | Zero-dependency seam | +| `eggup-eggfetch` | 0.1.3 | 0.1.0, 0.1.1, 0.1.2, **0.1.3** | Native HTTP adapter | +| `eggup-curl` | 0.1.3 | **0.1.2** | External-curl adapter | +| `eggup-eggpack` | 0.1.3 | 0.1.2, **0.1.3** | Only crate touching producer types; pins `=0.1.3` | +| `eggup-service` | 0.1.3 | 0.1.0, 0.1.1, 0.1.2, **0.1.3** | M011 published the owned failed-systemd quiescence correction | +| `eggup-transport-footprint` | 0.1.3 | none (`publish = false`) | Binary-only fixture crate, non-publishable by design | + +All 8 crates share workspace version `0.1.3`; seven are on crates.io at +`0.1.2` or `0.1.3`. Six have reached `0.1.3`. + +**`eggup-service` is current with the workspace.** M011 published `0.1.3` on +2026-10-09 with the M010 owned failed-systemd quiescence correction. The +package was built from `feb6ae5aea4c9b61c4051957f3662ca49d845f9e`, after the +shared `v0.1.3` tag; that tag remains unchanged and package provenance is carried +by `.cargo_vcs_info.json`. `CHANGELOG.md` discipline follows the same separation: every published crate keeps an `Unreleased` section (7 of 8 crates have a CHANGELOG; the fixture -crate is the exception) carrying an explicit no-publication / no-migration -disclaimer while `0.1.2` remains the published baseline. +crate is the exception), while the service `0.1.3` release is documented in its +published changelog and M011 record. ## 9. Reviewer's checklist @@ -724,8 +725,7 @@ Corrected in the doc-hygiene pass recorded in the workspace history: | Was | Resolution | |---|---| -| `verify-workflow` + `AGENTS.md` described `windows-check` as `cargo check` / "compile-only" | Both now describe the six `cargo test` steps (`ci.yml:48-53`) plus the closing workspace check (§5, §7) | -| `AGENTS.md` and `registry.md` called `eggup-service` "unpublished" | It is on crates.io at `0.1.0`/`0.1.1`; its `0.1.2` was never published. Corrected in `AGENTS.md`, [overview.md](overview.md), §8, and the registry | +| `verify-workflow` + `AGENTS.md` described `windows-check` as `cargo check` / "compile-only" | Both now describe its nine `cargo test` steps plus packaged service verification, and the real Linux systemd service lane (§5) | | `AGENTS.md` gave `eggup-eggpack` a partial dependency list, omitting `sha2` | `sha2` added; the list now matches `crates/eggup-eggpack/Cargo.toml` | | `AGENTS.md` stated "keep crate `README.md` + `CHANGELOG.md` current" as absolute | Now scoped to library crates, with `eggup-transport-footprint` named as the exception (§3.4) | | `core-transaction.md` listed a previous generation of `FailureCategory`, `FailurePhase`, `IntegrityRequirement`, `IntegrityStatus`, and `PermissionsIntent` | All five rows regenerated from source; the two `FailureCategory::Destination` references replaced with real variants | @@ -738,10 +738,7 @@ Corrected in the doc-hygiene pass recorded in the workspace history: | `registry.md` "Recently closed foundation" understated 3 workstreams and omitted 3 | Rewritten to match the closure directories | | `registry.md` "Planned / blocked work" declared 4 columns; 4 rows carried 5 | Cells merged; two rows that duplicated rows in the same table removed | | `planning-closure-hygiene-corrective/010` plan still read `Status: ready for handoff` | Set to closed, matching its closure record and C011/C012 | -| Root `CHANGELOG.md` called `eggup-service` "not published" while `README.md`, [overview.md](overview.md), and the crate's own changelog said published | Rewritten: published at `0.1.0`/`0.1.1`, `0.1.2` never published. This was the same drift the previous pass fixed everywhere except the root changelog | -| `tooling-governance.md` §2.1 listed `eggup-service` as "no (unpublished)" and §2.3 called it "the unpublished `eggup-service`", contradicting §8 of the same document | Both corrected to "published but lagging" | -| `service-lifecycle.md` and `core-transaction.md` still labelled `eggup-service` unpublished | Corrected; `service-lifecycle.md` now states the `0.1.0`/`0.1.1` registry state and that `Unreleased` is not on the registry | -| Windows lane counted as "four `cargo test` invocations" in §5, §7.3, the Resolved table, `verify-workflow`, and `docs-hygiene` | It is **six** steps at `ci.yml:48-53` — the three named `eggup-service` tests are three steps, not one bullet. All five locations corrected, and a drift class added for counting steps rather than bullets | +| Windows lane counted as "four `cargo test` invocations" in §5, §7.3, the Resolved table, `verify-workflow`, and `docs-hygiene` | It now has **nine** test steps at `ci.yml:66-79` — the three named `eggup-service` tests are three steps, not one bullet. All five locations and the count-step drift class were updated | | §4.1 attributed the quote "dependency-surface review, no gate" to `verify-workflow`, and "review-only, no gate" to `AGENTS.md` | Neither string exists in those files. Replaced with the actual sentences from each | | §4 described `scripts/check-local.sh` as "6 lines" | It is 9 lines (shebang + `set -euo pipefail` + 5 `cargo` commands + blank); the per-line table already used the correct `4`-`8` numbering | | [overview.md](overview.md) claimed "Every crate carries `#![forbid(unsafe_code)]` and `#![deny(missing_docs)]`" | Scoped to the 7 library crates; `eggup-transport-footprint` has no `lib.rs`, so `missing_docs` is not enforced there at all (§3.4) | diff --git a/crates/eggup-service/CHANGELOG.md b/crates/eggup-service/CHANGELOG.md index e924a0f..2005780 100644 --- a/crates/eggup-service/CHANGELOG.md +++ b/crates/eggup-service/CHANGELOG.md @@ -56,6 +56,19 @@ consumers of `0.1.1` need no migration and pick up the corrected behavior by upgrading within the `0.1.x` range. No public API was added, removed, or changed by this release. -## Unreleased +## 0.1.3 — 2026-10-09 + +- **Fixed: owned failed systemd units could never complete `stop`.** The + adapter now recognizes the specific `ActiveState=failed` case without + changing the public `LifecycleState` enum, revalidates the exact `ExecStart` + identity around the stop, and reports completion only after manager job, + process IDs, active-state output, and cgroup evidence agree that the unit is + quiescent. Unknown states and remaining cgroup tasks fail closed. No + `reset-failed`, privilege escalation, or new dependency is introduced. + The runtime implementation is Service M010 source commit + `0bde3fefbda07019529ad7566c02e6e4ec141fd6`; the package's exact source + revision is recorded by `.cargo_vcs_info.json` as + `feb6ae5aea4c9b61c4051957f3662ca49d845f9e`. The published crate checksum is + `9f7f7ea854577158e66aa202709ab1c97a3aedcf00b06c1ab914d25b132124dc`. -Nothing yet. \ No newline at end of file +## Unreleased diff --git a/crates/eggup-service/README.md b/crates/eggup-service/README.md index fc6bd60..af5be15 100644 --- a/crates/eggup-service/README.md +++ b/crates/eggup-service/README.md @@ -80,7 +80,9 @@ lifecycle-snapshot model plus reusable Unix manager mechanics - systemd: explicit `--system`/`--user` scope, narrow `ExecStart` parsing (ambiguous/specifier shapes yield `Unknown`), atomic definition writes, explicit `enable`/`daemon-reload` only, bounded `start`/`stop`/`restart` - with state confirmation, no `sudo`; + with state confirmation, no `sudo`; a recognized exact-owned `failed` + unit is stopped only after ownership revalidation and proof that its manager + job, main/control processes, and cgroup work are gone; - launchd: explicit `gui/` vs `system` targets (never guessed), structured `ProgramArguments` parsing (malformed yields `Unknown`), label-only never proves ownership, bounded `bootstrap`/`bootout`/ diff --git a/crates/eggup-service/src/lib.rs b/crates/eggup-service/src/lib.rs index 79172cd..63f2159 100644 --- a/crates/eggup-service/src/lib.rs +++ b/crates/eggup-service/src/lib.rs @@ -375,7 +375,11 @@ pub trait ServiceManager { timeout: Duration, ) -> Result; - /// Stops an `Owned` running service within `timeout`. + /// Stops an `Owned` service within `timeout`. + /// + /// An adapter may stop a recognized manager failure state only when exact + /// ownership is revalidated and it can prove there is no remaining work. + /// Other unknown states fail closed. fn stop( &mut self, spec: &ServiceSpec, @@ -1355,6 +1359,18 @@ impl SystemdManager { ] } + fn quiescence_show_argv(&self) -> Vec { + vec![ + "systemctl".to_string(), + self.install.scope.flag().to_string(), + "show".to_string(), + self.install.unit_name.clone(), + "-p".to_string(), + "LoadState,ActiveState,SubState,ExecStart,MainPID,ControlPID,ControlGroup,Job" + .to_string(), + ] + } + fn ownership_of( &self, spec: &ServiceSpec, @@ -1441,6 +1457,238 @@ impl SystemdManager { ); } } + + fn stop_failed_owned( + &mut self, + spec: &ServiceSpec, + deadline: OperationDeadline, + ) -> Result { + let before = self.quiescence_observation(spec, deadline)?; + require_owned(spec.id(), before.ownership)?; + if before.active_state != "failed" { + if before.active_state == "inactive" + && quiescence_proven(&before, Path::new("/sys/fs/cgroup")) + { + return Ok(stopped_result(true, "already quiescent")); + } + return Ok(stopped_result( + false, + "failed-unit state changed before stop; quiescence unconfirmed", + )); + } + + self.run_unit("stop", deadline)?; + loop { + let Some(remaining) = deadline.remaining() else { + return Ok(stopped_result( + false, + "failed-unit stop deadline expired; quiescence unconfirmed", + )); + }; + let after = match self.quiescence_observation(spec, deadline) { + Ok(observation) => observation, + Err(error) => { + return Ok(stopped_result( + false, + &format!("failed-unit post-stop observation failed: {error}"), + )); + } + }; + if after.ownership != Ownership::Owned || after.control_group != before.control_group { + return Ok(stopped_result( + false, + "failed-unit ownership or control group changed; quiescence unconfirmed", + )); + } + if !matches!(after.active_state.as_str(), "failed" | "inactive") { + return Ok(stopped_result( + false, + "failed unit became active or transitioning; quiescence unconfirmed", + )); + } + if quiescence_proven(&after, Path::new("/sys/fs/cgroup")) { + let confirmed = match self.quiescence_observation(spec, deadline) { + Ok(observation) => observation, + Err(_) => { + return Ok(stopped_result( + false, + "failed-unit proof revalidation failed; quiescence unconfirmed", + )); + } + }; + if confirmed != after || !quiescence_proven(&confirmed, Path::new("/sys/fs/cgroup")) + { + return Ok(stopped_result( + false, + "failed-unit proof changed during revalidation; quiescence unconfirmed", + )); + } + let active = self.is_active(deadline)?; + let expected = if after.active_state == "failed" { + ("failed", Some(3)) + } else { + ("inactive", Some(3)) + }; + if active.0 == expected.0 && active.1 == expected.1 { + return Ok(stopped_result(true, "owned failed unit is quiescent")); + } + return Ok(stopped_result( + false, + "systemd active-state observations disagree; quiescence unconfirmed", + )); + } + std::thread::sleep(remaining.min(Duration::from_millis(50))); + } + } + + fn quiescence_observation( + &self, + spec: &ServiceSpec, + deadline: OperationDeadline, + ) -> Result { + let out = self.executor.run( + &self.quiescence_show_argv(), + None, + deadline.command_timeout()?, + )?; + if out.status != Some(0) { + return Err(ServiceError::manager( + "systemd quiescence observation failed", + )); + } + parse_quiescence_observation(&out.stdout_text(), spec) + } + + fn is_active( + &self, + deadline: OperationDeadline, + ) -> Result<(String, Option), ServiceError> { + let argv = vec![ + "systemctl".to_string(), + self.install.scope.flag().to_string(), + "is-active".to_string(), + self.install.unit_name.clone(), + ]; + let out = self + .executor + .run(&argv, None, deadline.command_timeout()?) + .map_err(permission_hint)?; + Ok((out.stdout_text().trim().to_owned(), out.status)) + } +} + +#[derive(Debug, PartialEq, Eq)] +struct SystemdQuiescenceObservation { + ownership: Ownership, + active_state: String, + sub_state: String, + main_pid: u32, + control_pid: u32, + control_group: String, + job: String, +} + +fn stopped_result(completed: bool, detail: &str) -> TransitionResult { + TransitionResult { + operation: ServiceOperation::Stop, + completed, + detail: ServiceError::bounded(detail), + } +} + +fn parse_quiescence_observation( + text: &str, + spec: &ServiceSpec, +) -> Result { + let mut properties = std::collections::HashMap::new(); + for line in text.lines() { + let Some((key, value)) = line.split_once('=') else { + return Err(ServiceError::manager("malformed systemd observation")); + }; + if properties.insert(key, value).is_some() { + return Err(ServiceError::manager("duplicate systemd observation field")); + } + } + let property = |key| { + properties + .get(key) + .copied() + .ok_or_else(|| ServiceError::manager("incomplete systemd observation")) + }; + let (ownership, _, _) = systemd_ownership(text, spec)?; + let main_pid = property("MainPID")? + .parse() + .map_err(|_| ServiceError::manager("invalid systemd MainPID"))?; + let control_pid = property("ControlPID")? + .parse() + .map_err(|_| ServiceError::manager("invalid systemd ControlPID"))?; + Ok(SystemdQuiescenceObservation { + ownership, + active_state: property("ActiveState")?.to_string(), + sub_state: property("SubState")?.to_string(), + main_pid, + control_pid, + control_group: property("ControlGroup")?.to_string(), + job: property("Job")?.to_string(), + }) +} + +fn quiescence_proven(observation: &SystemdQuiescenceObservation, cgroup_root: &Path) -> bool { + if observation.ownership != Ownership::Owned + || !matches!(observation.active_state.as_str(), "failed" | "inactive") + || (observation.active_state == "failed" && observation.sub_state != "failed") + || (observation.active_state == "inactive" + && !matches!(observation.sub_state.as_str(), "dead" | "exited")) + || observation.main_pid != 0 + || observation.control_pid != 0 + || !matches!(observation.job.as_str(), "" | "n/a") + { + return false; + } + if observation.control_group.is_empty() { + // systemd has removed the unit's cgroup after all its tasks exited. + return true; + } + let Ok(root_metadata) = std::fs::symlink_metadata(cgroup_root) else { + return false; + }; + if !root_metadata.is_dir() || root_metadata.file_type().is_symlink() { + return false; + } + let Some(relative) = observation.control_group.strip_prefix('/') else { + return false; + }; + let mut path = cgroup_root.to_path_buf(); + for component in relative.split('/') { + if component.is_empty() || component == "." || component == ".." { + return false; + } + path.push(component); + let metadata = match std::fs::symlink_metadata(&path) { + Ok(metadata) => metadata, + Err(error) if error.kind() == std::io::ErrorKind::NotFound => return true, + Err(_) => return false, + }; + if !metadata.is_dir() || metadata.file_type().is_symlink() { + return false; + } + } + let Ok(processes) = std::fs::read_to_string(path.join("cgroup.procs")) else { + return false; + }; + let Ok(events) = std::fs::read_to_string(path.join("cgroup.events")) else { + return false; + }; + let mut populated = None; + for line in events.lines() { + if let Some(value) = line.strip_prefix("populated ") { + if populated.is_some() || !matches!(value, "0" | "1") { + return false; + } + populated = Some(value == "1"); + } + } + processes.trim().is_empty() && populated == Some(false) } #[derive(Debug, Clone, Copy)] @@ -1755,6 +2003,9 @@ impl ServiceManager for SystemdManager { let deadline = OperationDeadline::new(timeout)?; let (ownership, state) = self.ownership_until(spec, deadline)?; require_owned(spec.id(), ownership)?; + if state == LifecycleState::Unknown { + return self.stop_failed_owned(spec, deadline); + } if state == LifecycleState::Stopped { return Ok(TransitionResult { operation: ServiceOperation::Stop, @@ -3744,6 +3995,240 @@ mod unix_tests { } } + fn quiescence_show(active: &str, control_group: &str, main_pid: u32, job: &str) -> String { + format!( + "LoadState=loaded\nActiveState={active}\nSubState={}\nExecStart={{ path=/opt/app/bin ; argv[]=/opt/app/bin --serve ; ignore_errors=no }}\nMainPID={main_pid}\nControlPID=0\nControlGroup={control_group}\nJob={job}\n", + if active == "failed" { "failed" } else { "dead" } + ) + } + + #[test] + fn systemd_failed_stop_requires_proven_quiescence_and_revalidates_ownership() { + let fake = FakeExecutor::new(); + let failed_state = show_loaded_active("/opt/app/bin", "--serve", "failed"); + for _ in 0..1 { + fake.expect( + &[ + "systemctl", + "--user", + "show", + "my-daemon.service", + "-p", + "LoadState,ActiveState,ExecStart", + ], + out(0, &failed_state), + ); + } + let extended_argv = [ + "systemctl", + "--user", + "show", + "my-daemon.service", + "-p", + "LoadState,ActiveState,SubState,ExecStart,MainPID,ControlPID,ControlGroup,Job", + ]; + fake.expect( + &extended_argv, + out(0, &quiescence_show("failed", "", 0, "")), + ); + fake.expect( + &["systemctl", "--user", "stop", "my-daemon.service"], + out(0, ""), + ); + fake.expect( + &extended_argv, + out(0, &quiescence_show("failed", "", 0, "")), + ); + fake.expect( + &extended_argv, + out(0, &quiescence_show("failed", "", 0, "")), + ); + fake.expect( + &["systemctl", "--user", "is-active", "my-daemon.service"], + out(3, "failed\n"), + ); + let dir = temp_dir("sysd-failed-stop"); + let mut manager = systemd_manager(fake, dir.join("my-daemon.service")); + let want = spec("my-daemon.service", "/opt/app/bin", &["--serve"]); + let result = manager.stop(&want, Duration::from_secs(2)).unwrap(); + assert!(result.completed, "{result:?}"); + assert_eq!(result.detail, "owned failed unit is quiescent"); + assert!(manager.executor().is_exhausted()); + let _ = std::fs::remove_dir_all(&dir); + } + + #[test] + fn systemd_failed_stop_refuses_changed_identity_or_unknown_state() { + let old_owned = show_loaded_active("/opt/app/bin", "--serve", "failed"); + let extended_argv = [ + "systemctl", + "--user", + "show", + "my-daemon.service", + "-p", + "LoadState,ActiveState,SubState,ExecStart,MainPID,ControlPID,ControlGroup,Job", + ]; + + let fake = FakeExecutor::new(); + fake.expect( + &[ + "systemctl", + "--user", + "show", + "my-daemon.service", + "-p", + "LoadState,ActiveState,ExecStart", + ], + out(0, &old_owned), + ); + fake.expect( + &extended_argv, + out(0, &quiescence_show("failed", "", 0, "")), + ); + fake.expect( + &["systemctl", "--user", "stop", "my-daemon.service"], + out(0, ""), + ); + fake.expect( + &extended_argv, + out( + 0, + "LoadState=loaded\nActiveState=failed\nSubState=failed\nExecStart={ path=/opt/other/bin ; argv[]=/opt/other/bin --serve ; ignore_errors=no }\nMainPID=0\nControlPID=0\nControlGroup=\nJob=\n", + ), + ); + let dir = temp_dir("sysd-failed-drift"); + let mut manager = systemd_manager(fake, dir.join("my-daemon.service")); + let want = spec("my-daemon.service", "/opt/app/bin", &["--serve"]); + let result = manager.stop(&want, Duration::from_secs(2)).unwrap(); + assert!(!result.completed, "{result:?}"); + assert!(result.detail.contains("ownership")); + assert!(manager.executor().is_exhausted()); + let _ = std::fs::remove_dir_all(&dir); + + let fake = FakeExecutor::new(); + fake.expect( + &[ + "systemctl", + "--user", + "show", + "my-daemon.service", + "-p", + "LoadState,ActiveState,ExecStart", + ], + out(0, &old_owned), + ); + fake.expect( + &extended_argv, + out(0, &quiescence_show("maintenance", "", 0, "")), + ); + let dir = temp_dir("sysd-failed-unknown"); + let mut manager = systemd_manager(fake, dir.join("my-daemon.service")); + let result = manager.stop(&want, Duration::from_secs(2)).unwrap(); + assert!(!result.completed, "{result:?}"); + assert!(result.detail.contains("changed before stop")); + assert!(manager.executor().is_exhausted()); + let _ = std::fs::remove_dir_all(&dir); + } + + #[test] + fn systemd_failed_stop_fails_closed_on_restart_race_or_conflicting_active_state() { + let old_owned = show_loaded_active("/opt/app/bin", "--serve", "failed"); + let ownership_argv = [ + "systemctl", + "--user", + "show", + "my-daemon.service", + "-p", + "LoadState,ActiveState,ExecStart", + ]; + let extended_argv = [ + "systemctl", + "--user", + "show", + "my-daemon.service", + "-p", + "LoadState,ActiveState,SubState,ExecStart,MainPID,ControlPID,ControlGroup,Job", + ]; + let stop_argv = ["systemctl", "--user", "stop", "my-daemon.service"]; + let want = spec("my-daemon.service", "/opt/app/bin", &["--serve"]); + + let fake = FakeExecutor::new(); + fake.expect(&ownership_argv, out(0, &old_owned)); + fake.expect( + &extended_argv, + out(0, &quiescence_show("failed", "", 0, "")), + ); + fake.expect(&stop_argv, out(0, "")); + fake.expect( + &extended_argv, + out(0, &quiescence_show("activating", "", 0, "")), + ); + let dir = temp_dir("sysd-failed-restart-race"); + let mut manager = systemd_manager(fake, dir.join("my-daemon.service")); + let result = manager.stop(&want, Duration::from_secs(2)).unwrap(); + assert!(!result.completed, "{result:?}"); + assert!(result.detail.contains("became active or transitioning")); + assert!(manager.executor().is_exhausted()); + let _ = std::fs::remove_dir_all(&dir); + + let fake = FakeExecutor::new(); + fake.expect(&ownership_argv, out(0, &old_owned)); + fake.expect( + &extended_argv, + out(0, &quiescence_show("failed", "", 0, "")), + ); + fake.expect(&stop_argv, out(0, "")); + fake.expect( + &extended_argv, + out(0, &quiescence_show("failed", "", 0, "")), + ); + fake.expect( + &extended_argv, + out(0, &quiescence_show("failed", "", 0, "")), + ); + fake.expect( + &["systemctl", "--user", "is-active", "my-daemon.service"], + out(0, "active\n"), + ); + let dir = temp_dir("sysd-failed-inconsistent-state"); + let mut manager = systemd_manager(fake, dir.join("my-daemon.service")); + let result = manager.stop(&want, Duration::from_secs(2)).unwrap(); + assert!(!result.completed, "{result:?}"); + assert!(result.detail.contains("observations disagree")); + assert!(manager.executor().is_exhausted()); + let _ = std::fs::remove_dir_all(&dir); + } + + #[test] + fn systemd_cgroup_quiescence_checks_processes_events_and_path_safety() { + let root = temp_dir("sysd-cgroup-proof"); + let group = root.join("system.slice").join("owned.service"); + std::fs::create_dir_all(&group).unwrap(); + std::fs::write(group.join("cgroup.procs"), b"").unwrap(); + std::fs::write(group.join("cgroup.events"), b"populated 0\nfrozen 0\n").unwrap(); + let mut observation = SystemdQuiescenceObservation { + ownership: Ownership::Owned, + active_state: "failed".to_string(), + sub_state: "failed".to_string(), + main_pid: 0, + control_pid: 0, + control_group: "/system.slice/owned.service".to_string(), + job: String::new(), + }; + assert!(quiescence_proven(&observation, &root)); + observation.control_group = "/system.slice/removed.service".to_string(); + assert!(quiescence_proven(&observation, &root)); + observation.control_group = "/system.slice/owned.service".to_string(); + std::fs::write(group.join("cgroup.procs"), b"123\n").unwrap(); + assert!(!quiescence_proven(&observation, &root)); + std::fs::write(group.join("cgroup.procs"), b"").unwrap(); + std::fs::write(group.join("cgroup.events"), b"populated 1\nfrozen 0\n").unwrap(); + assert!(!quiescence_proven(&observation, &root)); + observation.control_group = "/system.slice/../foreign.service".to_string(); + assert!(!quiescence_proven(&observation, &root)); + let _ = std::fs::remove_dir_all(&root); + } + #[test] fn systemd_permission_denial_has_no_sudo() { let fake = FakeExecutor::new(); diff --git a/crates/eggup-service/tests/api_compatibility.rs b/crates/eggup-service/tests/api_compatibility.rs new file mode 100644 index 0000000..e2f15b4 --- /dev/null +++ b/crates/eggup-service/tests/api_compatibility.rs @@ -0,0 +1,16 @@ +use eggup_service::LifecycleState; + +fn classify(state: LifecycleState) -> &'static str { + match state { + LifecycleState::Stopped => "stopped", + LifecycleState::Running => "running", + LifecycleState::Transitioning => "transitioning", + LifecycleState::Unknown => "unknown", + _ => "future", + } +} + +#[test] +fn closed_lifecycle_state_match_remains_exhaustive() { + assert_eq!(classify(LifecycleState::Unknown), "unknown"); +} diff --git a/crates/eggup-service/tests/published-api-0.1.2/Cargo.lock b/crates/eggup-service/tests/published-api-0.1.2/Cargo.lock new file mode 100644 index 0000000..992cde5 --- /dev/null +++ b/crates/eggup-service/tests/published-api-0.1.2/Cargo.lock @@ -0,0 +1,322 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "eggup-core" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "161b244bc474fa24815ebd81db8cda46e0f752dd4b84983e454239f89fd789ad" +dependencies = [ + "self-replace", + "sha2", +] + +[[package]] +name = "eggup-service" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6288eb17dd9906380de8c75104d33dfa95c9039b39dc481f49b3700dd750e3f" +dependencies = [ + "eggup-core", + "windows-args", + "windows-service", +] + +[[package]] +name = "eggup-service-published-api-compatibility" +version = "0.0.0" +dependencies = [ + "eggup-service", +] + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi", +] + +[[package]] +name = "libc" +version = "0.2.190" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rustix" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "self-replace" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03ec815b5eab420ab893f63393878d89c90fdd94c0bcc44c07abb8ad95552fb7" +dependencies = [ + "fastrand", + "tempfile", + "windows-sys 0.52.0", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "widestring" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72069c3113ab32ab29e5584db3c6ec55d416895e60715417b5b883a357c3e471" + +[[package]] +name = "windows-args" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a461b757e38ae4fdf8cb97a017605010589ba4199486ced90a44ab3aade3d7e5" +dependencies = [ + "wtf8", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-service" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "857224b3b211c6f3616921f081ee54721ee3ad2ace2fac6a6337e032f7b4dcf2" +dependencies = [ + "bitflags", + "widestring", + "windows-sys 0.61.2", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wtf8" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6b9309a86639c488a8eb2b5331cb5127cc9feb0a94a0db4b5d1ab5b84977956" diff --git a/crates/eggup-service/tests/published-api-0.1.2/Cargo.toml b/crates/eggup-service/tests/published-api-0.1.2/Cargo.toml new file mode 100644 index 0000000..eb4ca3b --- /dev/null +++ b/crates/eggup-service/tests/published-api-0.1.2/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "eggup-service-published-api-compatibility" +version = "0.0.0" +edition = "2021" +publish = false + +[workspace] + +[dependencies] +eggup-service = "=0.1.2" diff --git a/crates/eggup-service/tests/published-api-0.1.2/src/main.rs b/crates/eggup-service/tests/published-api-0.1.2/src/main.rs new file mode 100644 index 0000000..412619a --- /dev/null +++ b/crates/eggup-service/tests/published-api-0.1.2/src/main.rs @@ -0,0 +1,17 @@ +#![forbid(unsafe_code)] + +use eggup_service::LifecycleState; + +fn classify(state: LifecycleState) -> &'static str { + match state { + LifecycleState::Stopped => "stopped", + LifecycleState::Running => "running", + LifecycleState::Transitioning => "transitioning", + LifecycleState::Unknown => "unknown", + _ => "future", + } +} + +fn main() { + let _ = classify(LifecycleState::Unknown); +} diff --git a/crates/eggup-service/tests/published-api-0.1.2/tests/systemd_failed_stop_negative_control.rs b/crates/eggup-service/tests/published-api-0.1.2/tests/systemd_failed_stop_negative_control.rs new file mode 100644 index 0000000..cc5301b --- /dev/null +++ b/crates/eggup-service/tests/published-api-0.1.2/tests/systemd_failed_stop_negative_control.rs @@ -0,0 +1,139 @@ +#![forbid(unsafe_code)] + +use eggup_service::{ + ServiceId, ServiceManager, ServiceSpec, SystemExecutor, SystemdInstall, SystemdManager, + SystemdScope, +}; +use std::path::{Path, PathBuf}; +use std::process::{Command, Output}; +use std::time::{Duration, Instant}; + +struct UnitFixture { + name: String, + path: PathBuf, +} + +impl UnitFixture { + fn new() -> Self { + let name = format!("eggup-m010-012-{}.service", std::process::id()); + let path = Path::new("/run/systemd/system").join(&name); + std::fs::write( + &path, + "[Unit]\nDescription=Eggup published 0.1.2 negative control\n[Service]\nType=exec\nExecStart=/usr/bin/false\nRestart=no\n", + ) + .expect("write disposable unit"); + assert_success(&systemctl(&["daemon-reload"]), "daemon-reload"); + Self { name, path } + } + + fn start(&self) -> Output { + systemctl(&["start", &self.name]) + } + + fn show(&self) -> String { + let output = systemctl(&[ + "show", + &self.name, + "-p", + "LoadState,ActiveState,ExecStart,MainPID,ControlPID,ControlGroup,Job", + ]); + assert_success(&output, "systemctl show"); + String::from_utf8(output.stdout).expect("show output is UTF-8") + } +} + +impl Drop for UnitFixture { + fn drop(&mut self) { + let _ = systemctl(&["stop", &self.name]); + let _ = std::fs::remove_file(&self.path); + let _ = systemctl(&["daemon-reload"]); + } +} + +fn systemctl(args: &[&str]) -> Output { + Command::new("/usr/bin/systemctl") + .arg("--system") + .args(args) + .output() + .expect("run systemctl") +} + +fn assert_success(output: &Output, operation: &str) { + assert!( + output.status.success(), + "{operation} failed: status={:?}, stderr={}", + output.status.code(), + String::from_utf8_lossy(&output.stderr) + ); +} + +#[test] +fn published_0_1_2_cannot_complete_stop_for_owned_failed_unit() { + if std::env::var_os("EGGUP_SYSTEMD_INTEGRATION").is_none() { + eprintln!("skipped: set EGGUP_SYSTEMD_INTEGRATION=1 in a disposable systemd VM"); + return; + } + assert_eq!( + std::fs::read_to_string("/proc/1/comm") + .expect("read init process") + .trim(), + "systemd", + "negative control requires systemd as PID 1" + ); + assert!(Path::new("/sys/fs/cgroup/cgroup.controllers").exists()); + + let fixture = UnitFixture::new(); + let start = fixture.start(); + eprintln!("published_0_1_2_start_status={:?}", start.status.code()); + let deadline = Instant::now() + Duration::from_secs(5); + let before = loop { + let show = fixture.show(); + if show.lines().any(|line| line == "ActiveState=failed") { + break show; + } + assert!(Instant::now() < deadline, "unit did not fail: {show}"); + std::thread::sleep(Duration::from_millis(10)); + }; + + let spec = ServiceSpec::new( + ServiceId::new(fixture.name.clone()).expect("service id"), + PathBuf::from("/usr/bin/false"), + Vec::new(), + None, + ) + .expect("service spec"); + let install = SystemdInstall::new( + fixture.name.clone(), + SystemdScope::System, + fixture.path.clone(), + b"[Unit]\nDescription=Eggup published 0.1.2 negative control\n[Service]\nType=exec\nExecStart=/usr/bin/false\nRestart=no\n".to_vec(), + false, + false, + Duration::from_secs(5), + ) + .expect("systemd install descriptor"); + let mut manager = SystemdManager::new(SystemExecutor::new(), install); + let before_stop = manager.inspect(&spec).expect("inspect failed unit"); + assert_eq!(before_stop.ownership, eggup_service::Ownership::Owned); + assert_eq!(before_stop.state, eggup_service::LifecycleState::Unknown); + let stop = manager.stop(&spec, Duration::from_secs(5)); + let after = fixture.show(); + eprintln!("published_0_1_2_before={before:?} stop={stop:?} after={after:?}"); + for expected in [ + "ActiveState=failed", + "MainPID=0", + "ControlPID=0", + "ControlGroup=", + "Job=", + ] { + assert!( + after.lines().any(|line| line == expected), + "negative control did not establish {expected:?}: {after}" + ); + } + assert!( + !matches!(&stop, Ok(result) if result.completed), + "published 0.1.2 unexpectedly completed an owned failed unit stop: {stop:?}" + ); + assert!(after.lines().any(|line| line == "ActiveState=failed")); +} diff --git a/crates/eggup-service/tests/published-api-0.1.2/tests/systemd_inspection_controls.rs b/crates/eggup-service/tests/published-api-0.1.2/tests/systemd_inspection_controls.rs new file mode 100644 index 0000000..a47712d --- /dev/null +++ b/crates/eggup-service/tests/published-api-0.1.2/tests/systemd_inspection_controls.rs @@ -0,0 +1,75 @@ +#![forbid(unsafe_code)] + +use eggup_service::{ + CommandExecutor, CommandOutput, LifecycleState, Ownership, ServiceError, ServiceId, + ServiceManager, ServiceSpec, SystemdInstall, SystemdManager, SystemdScope, +}; +use std::path::PathBuf; +use std::time::Duration; + +#[derive(Debug)] +struct FixedExecutor(&'static str); + +impl CommandExecutor for FixedExecutor { + fn run( + &self, + _argv: &[String], + _stdin_data: Option<&[u8]>, + _timeout: Duration, + ) -> Result { + Ok(CommandOutput { + status: Some(0), + stdout: self.0.as_bytes().to_vec(), + stderr: Vec::new(), + }) + } +} + +fn inspect_fixture(show: &'static str) -> eggup_service::LifecycleSnapshot { + let unit_name = "eggup-m010-control.service"; + let install = SystemdInstall::new( + unit_name.to_string(), + SystemdScope::System, + PathBuf::from(format!("/run/systemd/system/{unit_name}")), + b"[Service]\nExecStart=/usr/bin/false\n".to_vec(), + false, + false, + Duration::from_secs(2), + ) + .expect("install descriptor"); + let manager = SystemdManager::new(FixedExecutor(show), install); + let spec = ServiceSpec::new( + ServiceId::new(unit_name).expect("service id"), + PathBuf::from("/usr/bin/false"), + Vec::new(), + None, + ) + .expect("service spec"); + manager.inspect(&spec).expect("inspect fixture output") +} + +#[test] +fn registry_0_1_2_classifies_exact_failed_registration_as_owned_unknown_state() { + let snapshot = inspect_fixture( + "LoadState=loaded\nActiveState=failed\nExecStart={ path=/usr/bin/false ; argv[]=/usr/bin/false ; ignore_errors=no ; }\n", + ); + assert_eq!(snapshot.ownership, Ownership::Owned); + assert_eq!(snapshot.state, LifecycleState::Unknown); +} + +#[test] +fn registry_0_1_2_marks_changed_exec_start_foreign() { + let snapshot = inspect_fixture( + "LoadState=loaded\nActiveState=active\nExecStart={ path=/usr/bin/sleep ; argv[]=/usr/bin/sleep 120 ; ignore_errors=no ; }\n", + ); + assert_eq!(snapshot.ownership, Ownership::Foreign); + assert_eq!(snapshot.state, LifecycleState::Running); +} + +#[test] +fn registry_0_1_2_malformed_exec_start_is_unknown() { + let snapshot = + inspect_fixture("LoadState=loaded\nActiveState=failed\nExecStart=ambiguous output\n"); + assert_eq!(snapshot.ownership, Ownership::Unknown); + assert_eq!(snapshot.state, LifecycleState::Unknown); +} diff --git a/crates/eggup-service/tests/published-api-0.1.3/Cargo.lock b/crates/eggup-service/tests/published-api-0.1.3/Cargo.lock new file mode 100644 index 0000000..27a0e51 --- /dev/null +++ b/crates/eggup-service/tests/published-api-0.1.3/Cargo.lock @@ -0,0 +1,322 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "eggup-core" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "161b244bc474fa24815ebd81db8cda46e0f752dd4b84983e454239f89fd789ad" +dependencies = [ + "self-replace", + "sha2", +] + +[[package]] +name = "eggup-service" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7f7ea854577158e66aa202709ab1c97a3aedcf00b06c1ab914d25b132124dc" +dependencies = [ + "eggup-core", + "windows-args", + "windows-service", +] + +[[package]] +name = "eggup-service-published-api-0-1-3" +version = "0.0.0" +dependencies = [ + "eggup-service", +] + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi", +] + +[[package]] +name = "libc" +version = "0.2.190" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rustix" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "self-replace" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03ec815b5eab420ab893f63393878d89c90fdd94c0bcc44c07abb8ad95552fb7" +dependencies = [ + "fastrand", + "tempfile", + "windows-sys 0.52.0", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "widestring" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72069c3113ab32ab29e5584db3c6ec55d416895e60715417b5b883a357c3e471" + +[[package]] +name = "windows-args" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a461b757e38ae4fdf8cb97a017605010589ba4199486ced90a44ab3aade3d7e5" +dependencies = [ + "wtf8", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-service" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "857224b3b211c6f3616921f081ee54721ee3ad2ace2fac6a6337e032f7b4dcf2" +dependencies = [ + "bitflags", + "widestring", + "windows-sys 0.61.2", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wtf8" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6b9309a86639c488a8eb2b5331cb5127cc9feb0a94a0db4b5d1ab5b84977956" diff --git a/crates/eggup-service/tests/published-api-0.1.3/Cargo.toml b/crates/eggup-service/tests/published-api-0.1.3/Cargo.toml new file mode 100644 index 0000000..fc56f08 --- /dev/null +++ b/crates/eggup-service/tests/published-api-0.1.3/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "eggup-service-published-api-0-1-3" +version = "0.0.0" +edition = "2021" +publish = false + +[workspace] + +[dependencies] +eggup-service = "=0.1.3" diff --git a/crates/eggup-service/tests/published-api-0.1.3/src/main.rs b/crates/eggup-service/tests/published-api-0.1.3/src/main.rs new file mode 100644 index 0000000..412619a --- /dev/null +++ b/crates/eggup-service/tests/published-api-0.1.3/src/main.rs @@ -0,0 +1,17 @@ +#![forbid(unsafe_code)] + +use eggup_service::LifecycleState; + +fn classify(state: LifecycleState) -> &'static str { + match state { + LifecycleState::Stopped => "stopped", + LifecycleState::Running => "running", + LifecycleState::Transitioning => "transitioning", + LifecycleState::Unknown => "unknown", + _ => "future", + } +} + +fn main() { + let _ = classify(LifecycleState::Unknown); +} diff --git a/crates/eggup-service/tests/published-api-0.1.3/tests/systemd_failed_service.rs b/crates/eggup-service/tests/published-api-0.1.3/tests/systemd_failed_service.rs new file mode 100644 index 0000000..28adf0a --- /dev/null +++ b/crates/eggup-service/tests/published-api-0.1.3/tests/systemd_failed_service.rs @@ -0,0 +1,524 @@ +#![forbid(unsafe_code)] + +use eggup_service::{ + CommandExecutor, CommandOutput, LifecycleState, ServiceError, ServiceId, ServiceManager, + ServiceSpec, SystemdInstall, SystemdManager, SystemdScope, +}; +#[cfg(target_os = "linux")] +use std::os::unix::fs::PermissionsExt; +use std::path::{Path, PathBuf}; +use std::process::{Command, Output}; +use std::sync::Mutex; +use std::time::Duration; + +const SHOW_PROPERTIES: &str = + "LoadState,ActiveState,SubState,ExecStart,MainPID,ControlPID,ControlGroup,Job,Result,NRestarts"; + +struct UnitFixture { + name: String, + path: PathBuf, +} + +#[derive(Debug, Default)] +struct RecordingExecutor { + inner: eggup_service::SystemExecutor, + calls: Mutex, Option)>>, +} + +impl RecordingExecutor { + fn calls(&self) -> Vec<(Vec, Option)> { + self.calls.lock().expect("call log mutex").clone() + } +} + +impl CommandExecutor for RecordingExecutor { + fn run( + &self, + argv: &[String], + stdin_data: Option<&[u8]>, + timeout: Duration, + ) -> Result { + let output = self.inner.run(argv, stdin_data, timeout)?; + self.calls + .lock() + .expect("call log mutex") + .push((argv.to_vec(), output.status)); + Ok(output) + } +} + +impl UnitFixture { + fn new(label: &str, definition: &str) -> Self { + let name = format!("eggup-m010-{}-{label}.service", std::process::id()); + let path = Path::new("/run/systemd/system").join(&name); + std::fs::write(&path, definition).expect("write disposable unit"); + let output = systemctl(&["daemon-reload"]); + assert_success(&output, "daemon-reload"); + Self { name, path } + } + + fn show(&self) -> String { + let output = systemctl(&["show", &self.name, "-p", SHOW_PROPERTIES]); + assert_success(&output, "systemctl show"); + String::from_utf8(output.stdout).expect("systemd show output is UTF-8") + } + + fn is_active(&self) -> (String, Option) { + let output = systemctl(&["is-active", &self.name]); + ( + String::from_utf8_lossy(&output.stdout).trim().to_owned(), + output.status.code(), + ) + } + + fn start(&self) -> Output { + systemctl(&["start", &self.name]) + } + + fn wait_for_active_state(&self, wanted: &str) -> String { + let deadline = std::time::Instant::now() + Duration::from_secs(5); + loop { + let show = self.show(); + if show + .lines() + .any(|line| line == format!("ActiveState={wanted}")) + { + return show; + } + assert!( + std::time::Instant::now() < deadline, + "unit did not reach ActiveState={wanted}: {show}" + ); + std::thread::sleep(Duration::from_millis(20)); + } + } + + fn wait_for_sub_state(&self, wanted: &str) -> String { + let deadline = std::time::Instant::now() + Duration::from_secs(5); + loop { + let show = self.show(); + if show + .lines() + .any(|line| line == format!("SubState={wanted}")) + { + return show; + } + assert!( + std::time::Instant::now() < deadline, + "unit did not reach SubState={wanted}: show={show}" + ); + std::thread::sleep(Duration::from_millis(10)); + } + } + + fn wait_for_failed_result(&self) -> String { + let deadline = std::time::Instant::now() + Duration::from_secs(5); + loop { + let show = self.show(); + if show.lines().any(|line| line == "ActiveState=failed") { + return show; + } + assert!( + std::time::Instant::now() < deadline, + "unit did not reach failed state: show={show}" + ); + std::thread::sleep(Duration::from_millis(20)); + } + } +} + +impl Drop for UnitFixture { + fn drop(&mut self) { + let _ = systemctl(&["stop", &self.name]); + let _ = std::fs::remove_file(&self.path); + let _ = systemctl(&["daemon-reload"]); + } +} + +fn systemctl(args: &[&str]) -> Output { + Command::new("/usr/bin/systemctl") + .arg("--system") + .args(args) + .output() + .expect("run systemctl") +} + +fn journal(unit: &str) -> String { + let output = Command::new("/usr/bin/journalctl") + .args(["--no-pager", "--output=cat", "--lines=30", "--unit", unit]) + .output() + .expect("run journalctl"); + String::from_utf8_lossy(&output.stdout).into_owned() +} + +fn assert_success(output: &Output, operation: &str) { + assert!( + output.status.success(), + "{operation} failed: status={:?}, stderr={}", + output.status.code(), + String::from_utf8_lossy(&output.stderr) + ); +} + +fn spec(name: &str, executable: &str) -> ServiceSpec { + ServiceSpec::new( + ServiceId::new(name).expect("service id"), + PathBuf::from(executable), + Vec::new(), + None, + ) + .expect("service spec") +} + +fn manager(fixture: &UnitFixture, definition: &str) -> SystemdManager { + SystemdManager::new( + RecordingExecutor::default(), + SystemdInstall::new( + fixture.name.clone(), + SystemdScope::System, + fixture.path.clone(), + definition.as_bytes().to_vec(), + false, + false, + Duration::from_secs(5), + ) + .expect("systemd install descriptor"), + ) +} + +fn require_systemd_host() { + assert_eq!( + std::fs::read_to_string("/proc/1/comm") + .expect("read init process") + .trim(), + "systemd", + "M010 qualification requires a Linux VM with systemd as PID 1" + ); + assert!( + Path::new("/sys/fs/cgroup/cgroup.controllers").exists(), + "M010 cgroup quiescence qualification requires cgroup v2" + ); + eprintln!( + "kernel={}", + std::fs::read_to_string("/proc/sys/kernel/osrelease") + .expect("read Linux kernel release") + .trim() + ); + let output = systemctl(&["show-environment"]); + assert_success(&output, "systemctl show-environment"); +} + +fn assert_no_cgroup_tasks(show: &str) { + let properties: std::collections::HashMap<_, _> = show + .lines() + .filter_map(|line| line.split_once('=')) + .collect(); + assert_eq!(properties.get("MainPID"), Some(&"0"), "{show}"); + assert_eq!(properties.get("ControlPID"), Some(&"0"), "{show}"); + let group = properties + .get("ControlGroup") + .expect("ControlGroup property"); + if group.is_empty() { + eprintln!("cgroup_quiescence=ControlGroup absent"); + return; + } + assert!(group.starts_with('/'), "untrusted ControlGroup: {group:?}"); + assert!( + group + .split('/') + .skip(1) + .all(|component| !component.is_empty() && component != "." && component != ".."), + "unsafe ControlGroup: {group:?}" + ); + let path = Path::new("/sys/fs/cgroup").join(group.trim_start_matches('/')); + if !path.exists() { + return; + } + let processes = + std::fs::read_to_string(path.join("cgroup.procs")).expect("read cgroup process list"); + assert!( + processes.trim().is_empty(), + "live cgroup processes: {processes}" + ); + let events = std::fs::read_to_string(path.join("cgroup.events")).expect("read cgroup events"); + eprintln!("cgroup_quiescence=path={path:?} procs={processes:?} events={events:?}"); + assert!( + events.lines().any(|line| line == "populated 0"), + "cgroup still populated: {events}" + ); +} + +fn cgroup_snapshot(show: &str) -> String { + let group = show + .lines() + .find_map(|line| line.strip_prefix("ControlGroup=")) + .unwrap_or(""); + if group.is_empty() { + return "ControlGroup absent".to_string(); + } + if !group.starts_with('/') || group.split('/').any(|part| part == "..") { + return format!("unsafe ControlGroup {group:?}"); + } + let path = Path::new("/sys/fs/cgroup").join(group.trim_start_matches('/')); + format!( + "ControlGroup={group:?} cgroup.procs={:?} cgroup.events={:?}", + std::fs::read_to_string(path.join("cgroup.procs")), + std::fs::read_to_string(path.join("cgroup.events")) + ) +} + +#[cfg(target_os = "linux")] +fn failed_unit_with_residual_cgroup_process_is_not_complete() { + let directory = + std::env::temp_dir().join(format!("eggup-m010-residual-{}", std::process::id())); + std::fs::create_dir_all(&directory).expect("create helper directory"); + let script = directory.join("fail-after-spawning-child"); + let pid_file = directory.join("child.pid"); + std::fs::write( + &script, + format!( + "#!/bin/sh\n/usr/bin/sleep 120 &\necho $! > {}\nexit 23\n", + pid_file.display() + ), + ) + .expect("write helper executable"); + let mut permissions = std::fs::metadata(&script) + .expect("stat helper executable") + .permissions(); + permissions.set_mode(0o700); + std::fs::set_permissions(&script, permissions).expect("make helper executable"); + + let definition = format!( + "[Unit]\nDescription=Eggup M010 residual cgroup fixture\n[Service]\nType=exec\nExecStart={}\nKillMode=process\nRestart=no\n", + script.display() + ); + let fixture = UnitFixture::new("residual", &definition); + let start = fixture.start(); + eprintln!("residual_process_start_status={:?}", start.status.code()); + let before = fixture.wait_for_active_state("failed"); + let pid: u32 = std::fs::read_to_string(&pid_file) + .expect("read fixture child pid") + .trim() + .parse() + .expect("fixture child pid is numeric"); + struct ChildCleanup(u32); + impl Drop for ChildCleanup { + fn drop(&mut self) { + let _ = Command::new("/usr/bin/kill") + .arg(self.0.to_string()) + .output(); + } + } + let _child_cleanup = ChildCleanup(pid); + assert!(Path::new(&format!("/proc/{pid}")).exists()); + eprintln!("residual_process_before={before:?} pid={pid}"); + + let mut manager = manager(&fixture, &definition); + let want = spec(&fixture.name, script.to_str().expect("UTF-8 helper path")); + let stop = manager + .stop(&want, Duration::from_secs(5)) + .expect("owned failed unit stop should return a bounded result"); + let after = fixture.show(); + eprintln!( + "residual_process_stop={stop:?} after_show={after:?} cgroup={}", + cgroup_snapshot(&after) + ); + eprintln!( + "residual_process_stop_commands={:?}", + manager + .executor() + .calls() + .into_iter() + .filter(|(argv, _)| argv.get(2).map(String::as_str) == Some("stop")) + .collect::>() + ); + assert!( + !stop.completed, + "live process/cgroup cannot be called quiescent" + ); + assert!(Path::new(&format!("/proc/{pid}")).exists()); + drop(_child_cleanup); + drop(fixture); + let _ = std::fs::remove_dir_all(directory); +} + +#[test] +fn real_systemd_owned_failed_service_stop_is_observed_and_quiescent() { + if std::env::var_os("EGGUP_SYSTEMD_INTEGRATION").is_none() { + eprintln!("skipped: set EGGUP_SYSTEMD_INTEGRATION=1 in a disposable systemd VM"); + return; + } + require_systemd_host(); + + let failed_definition = "[Unit]\nDescription=Eggup M010 failed-unit fixture\n[Service]\nType=exec\nExecStart=/usr/bin/false\nRestart=no\n"; + let failed = UnitFixture::new("failed", failed_definition); + let start = failed.start(); + let before = failed.wait_for_active_state("failed"); + let (active_before, active_status_before) = failed.is_active(); + eprintln!( + "systemd={} start_status={:?} before_show={before:?} before_is_active=({active_before:?}, {active_status_before:?})", + String::from_utf8_lossy(&systemctl(&["--version"]).stdout) + .lines() + .next() + .unwrap_or("unknown"), + start.status.code() + ); + assert!(before.lines().any(|line| line == "LoadState=loaded")); + assert!(before.lines().any(|line| line == "ActiveState=failed")); + assert_eq!(active_before, "failed"); + + let mut failed_manager = manager(&failed, failed_definition); + let failed_spec = spec(&failed.name, "/usr/bin/false"); + let observed = failed_manager + .inspect(&failed_spec) + .expect("inspect failed unit"); + assert_eq!(observed.ownership, eggup_service::Ownership::Owned); + assert_eq!(observed.state, LifecycleState::Unknown); + let stop = failed_manager + .stop(&failed_spec, Duration::from_secs(5)) + .expect("owned failed-unit stop should return a bounded result"); + let after = failed.show(); + let (active_after, active_status_after) = failed.is_active(); + eprintln!( + "failed_stop={stop:?} after_show={after:?} after_is_active=({active_after:?}, {active_status_after:?})" + ); + eprintln!( + "failed_stop_commands={:?}", + failed_manager + .executor() + .calls() + .into_iter() + .filter(|(argv, _)| argv.get(2).map(String::as_str) == Some("stop")) + .collect::>() + ); + assert!( + stop.completed, + "owned failed unit was not proven quiescent: {stop:?}" + ); + assert!(matches!(active_after.as_str(), "failed" | "inactive")); + assert_eq!(active_status_after, Some(3)); + assert!(after + .lines() + .any(|line| line == format!("ActiveState={active_after}"))); + assert_no_cgroup_tasks(&after); + + let recovered_definition = "[Unit]\nDescription=Eggup M010 caller-repaired fixture\n[Service]\nType=exec\nExecStart=/usr/bin/sleep 120\nRestart=no\n"; + std::fs::write(&failed.path, recovered_definition).expect("write caller-repaired unit"); + assert_success( + &systemctl(&["daemon-reload"]), + "reload caller-repaired unit", + ); + let mut recovered_manager = manager(&failed, recovered_definition); + let recovered_spec = ServiceSpec::new( + ServiceId::new(failed.name.clone()).expect("repaired service id"), + PathBuf::from("/usr/bin/sleep"), + vec!["120".to_string()], + None, + ) + .expect("repaired service spec"); + let started = recovered_manager + .start(&recovered_spec, Duration::from_secs(5)) + .expect("start caller-repaired unit"); + assert!(started.completed, "{started:?}"); + let stopped = recovered_manager + .stop(&recovered_spec, Duration::from_secs(5)) + .expect("stop caller-repaired unit"); + assert!(stopped.completed, "{stopped:?}"); + + let restart_definition = "[Unit]\nDescription=Eggup M010 restart-limit fixture\nStartLimitIntervalSec=60s\nStartLimitBurst=2\n[Service]\nType=exec\nExecStart=/usr/bin/false\nRestart=no\n"; + let restart = UnitFixture::new("restart-limit", restart_definition); + let restart_start = restart.start(); + let restart_first = restart.wait_for_failed_result(); + let restart_second_start = restart.start(); + // `systemctl start` may return nonzero when Type=exec exits immediately; + // the changed ExecStart invocation below proves whether the second run + // actually launched, while the third request must remain rate-limited. + let restart_second = restart.wait_for_failed_result(); + let rejected_start = restart.start(); + let restart_limited = restart.show(); + let first_exec = restart_first + .lines() + .find(|line| line.starts_with("ExecStart=")) + .expect("first failed invocation"); + let second_exec = restart_second + .lines() + .find(|line| line.starts_with("ExecStart=")) + .expect("second failed invocation"); + let limited_exec = restart_limited + .lines() + .find(|line| line.starts_with("ExecStart=")) + .expect("rate-limited invocation record"); + assert_ne!(first_exec, second_exec, "second launch must execute again"); + assert_eq!( + second_exec, limited_exec, + "rejected launch must not execute" + ); + assert!( + !rejected_start.status.success(), + "third start must be rate limited" + ); + eprintln!( + "restart_limit_start_status={:?} second_status={:?} rejected_status={:?} first={restart_first:?} second={restart_second:?} limited={restart_limited:?} journal={:?}", + restart_start.status.code(), + restart_second_start.status.code(), + rejected_start.status.code(), + journal(&restart.name), + ); + assert!(restart_limited + .lines() + .any(|line| line == "ActiveState=failed")); + let mut restart_manager = manager(&restart, restart_definition); + let restart_spec = spec(&restart.name, "/usr/bin/false"); + let restart_stop = restart_manager + .stop(&restart_spec, Duration::from_secs(5)) + .expect("stop rate-limited failed unit"); + let restart_after = restart.show(); + eprintln!( + "restart_limit_stop={restart_stop:?} show={restart_after:?} cgroup={}", + cgroup_snapshot(&restart_after) + ); + assert!(restart_stop.completed, "{restart_stop:?}"); + assert_no_cgroup_tasks(&restart_after); + + let auto_restart_definition = "[Unit]\nDescription=Eggup M010 auto-restart race fixture\nStartLimitIntervalSec=60s\nStartLimitBurst=20\n[Service]\nType=exec\nExecStart=/usr/bin/false\nRestart=on-failure\nRestartSec=500ms\n"; + let auto_restart = UnitFixture::new("auto-restart", auto_restart_definition); + let auto_start = auto_restart.start(); + let racing_before = auto_restart.wait_for_sub_state("auto-restart"); + let mut auto_restart_manager = manager(&auto_restart, auto_restart_definition); + let auto_spec = spec(&auto_restart.name, "/usr/bin/false"); + let racing_stop = auto_restart_manager + .stop(&auto_spec, Duration::from_secs(5)) + .expect("stop during real systemd auto-restart should return a bounded result"); + let racing_after = auto_restart.show(); + let (racing_active, racing_active_status) = auto_restart.is_active(); + eprintln!( + "auto_restart_race_start_status={:?} before={racing_before:?} stop={racing_stop:?} after={racing_after:?} is_active=({racing_active:?}, {racing_active_status:?}) journal={:?}", + auto_start.status.code(), + journal(&auto_restart.name), + ); + assert!( + racing_stop.completed, + "auto-restart race did not quiesce: {racing_stop:?}" + ); + assert_eq!(racing_active, "inactive"); + assert_eq!(racing_active_status, Some(3)); + assert!(racing_after + .lines() + .any(|line| line == "ActiveState=inactive")); + assert_no_cgroup_tasks(&racing_after); + + #[cfg(target_os = "linux")] + failed_unit_with_residual_cgroup_process_is_not_complete(); + + let running_definition = "[Unit]\nDescription=Eggup M010 foreign-unit fixture\n[Service]\nType=exec\nExecStart=/usr/bin/sleep 120\nRestart=no\n"; + let foreign = UnitFixture::new("foreign", running_definition); + assert_success(&foreign.start(), "start foreign control unit"); + let mut foreign_manager = manager(&foreign, running_definition); + let wrong_spec = spec(&foreign.name, "/usr/bin/false"); + let denied = foreign_manager + .stop(&wrong_spec, Duration::from_secs(2)) + .expect_err("changed ExecStart must deny stop"); + assert!(denied.to_string().contains("ownership")); + assert_eq!(foreign.is_active().0, "active"); + eprintln!("foreign_control_denied={denied}"); +} diff --git a/crates/eggup-service/tests/published-api-0.1.3/tests/systemd_inspection_controls.rs b/crates/eggup-service/tests/published-api-0.1.3/tests/systemd_inspection_controls.rs new file mode 100644 index 0000000..de1f6f7 --- /dev/null +++ b/crates/eggup-service/tests/published-api-0.1.3/tests/systemd_inspection_controls.rs @@ -0,0 +1,75 @@ +#![forbid(unsafe_code)] + +use eggup_service::{ + CommandExecutor, CommandOutput, LifecycleState, Ownership, ServiceError, ServiceId, + ServiceManager, ServiceSpec, SystemdInstall, SystemdManager, SystemdScope, +}; +use std::path::PathBuf; +use std::time::Duration; + +#[derive(Debug)] +struct FixedExecutor(&'static str); + +impl CommandExecutor for FixedExecutor { + fn run( + &self, + _argv: &[String], + _stdin_data: Option<&[u8]>, + _timeout: Duration, + ) -> Result { + Ok(CommandOutput { + status: Some(0), + stdout: self.0.as_bytes().to_vec(), + stderr: Vec::new(), + }) + } +} + +fn inspect_fixture(show: &'static str) -> eggup_service::LifecycleSnapshot { + let unit_name = "eggup-m010-control.service"; + let install = SystemdInstall::new( + unit_name.to_string(), + SystemdScope::System, + PathBuf::from(format!("/run/systemd/system/{unit_name}")), + b"[Service]\nExecStart=/usr/bin/false\n".to_vec(), + false, + false, + Duration::from_secs(2), + ) + .expect("install descriptor"); + let manager = SystemdManager::new(FixedExecutor(show), install); + let spec = ServiceSpec::new( + ServiceId::new(unit_name).expect("service id"), + PathBuf::from("/usr/bin/false"), + Vec::new(), + None, + ) + .expect("service spec"); + manager.inspect(&spec).expect("inspect fixture output") +} + +#[test] +fn registry_0_1_3_classifies_exact_failed_registration_as_owned_unknown_state() { + let snapshot = inspect_fixture( + "LoadState=loaded\nActiveState=failed\nExecStart={ path=/usr/bin/false ; argv[]=/usr/bin/false ; ignore_errors=no ; }\n", + ); + assert_eq!(snapshot.ownership, Ownership::Owned); + assert_eq!(snapshot.state, LifecycleState::Unknown); +} + +#[test] +fn registry_0_1_3_marks_changed_exec_start_foreign() { + let snapshot = inspect_fixture( + "LoadState=loaded\nActiveState=active\nExecStart={ path=/usr/bin/sleep ; argv[]=/usr/bin/sleep 120 ; ignore_errors=no ; }\n", + ); + assert_eq!(snapshot.ownership, Ownership::Foreign); + assert_eq!(snapshot.state, LifecycleState::Running); +} + +#[test] +fn registry_0_1_3_malformed_exec_start_is_unknown() { + let snapshot = + inspect_fixture("LoadState=loaded\nActiveState=failed\nExecStart=ambiguous output\n"); + assert_eq!(snapshot.ownership, Ownership::Unknown); + assert_eq!(snapshot.state, LifecycleState::Unknown); +} diff --git a/crates/eggup-service/tests/systemd_failed_service.rs b/crates/eggup-service/tests/systemd_failed_service.rs new file mode 100644 index 0000000..28adf0a --- /dev/null +++ b/crates/eggup-service/tests/systemd_failed_service.rs @@ -0,0 +1,524 @@ +#![forbid(unsafe_code)] + +use eggup_service::{ + CommandExecutor, CommandOutput, LifecycleState, ServiceError, ServiceId, ServiceManager, + ServiceSpec, SystemdInstall, SystemdManager, SystemdScope, +}; +#[cfg(target_os = "linux")] +use std::os::unix::fs::PermissionsExt; +use std::path::{Path, PathBuf}; +use std::process::{Command, Output}; +use std::sync::Mutex; +use std::time::Duration; + +const SHOW_PROPERTIES: &str = + "LoadState,ActiveState,SubState,ExecStart,MainPID,ControlPID,ControlGroup,Job,Result,NRestarts"; + +struct UnitFixture { + name: String, + path: PathBuf, +} + +#[derive(Debug, Default)] +struct RecordingExecutor { + inner: eggup_service::SystemExecutor, + calls: Mutex, Option)>>, +} + +impl RecordingExecutor { + fn calls(&self) -> Vec<(Vec, Option)> { + self.calls.lock().expect("call log mutex").clone() + } +} + +impl CommandExecutor for RecordingExecutor { + fn run( + &self, + argv: &[String], + stdin_data: Option<&[u8]>, + timeout: Duration, + ) -> Result { + let output = self.inner.run(argv, stdin_data, timeout)?; + self.calls + .lock() + .expect("call log mutex") + .push((argv.to_vec(), output.status)); + Ok(output) + } +} + +impl UnitFixture { + fn new(label: &str, definition: &str) -> Self { + let name = format!("eggup-m010-{}-{label}.service", std::process::id()); + let path = Path::new("/run/systemd/system").join(&name); + std::fs::write(&path, definition).expect("write disposable unit"); + let output = systemctl(&["daemon-reload"]); + assert_success(&output, "daemon-reload"); + Self { name, path } + } + + fn show(&self) -> String { + let output = systemctl(&["show", &self.name, "-p", SHOW_PROPERTIES]); + assert_success(&output, "systemctl show"); + String::from_utf8(output.stdout).expect("systemd show output is UTF-8") + } + + fn is_active(&self) -> (String, Option) { + let output = systemctl(&["is-active", &self.name]); + ( + String::from_utf8_lossy(&output.stdout).trim().to_owned(), + output.status.code(), + ) + } + + fn start(&self) -> Output { + systemctl(&["start", &self.name]) + } + + fn wait_for_active_state(&self, wanted: &str) -> String { + let deadline = std::time::Instant::now() + Duration::from_secs(5); + loop { + let show = self.show(); + if show + .lines() + .any(|line| line == format!("ActiveState={wanted}")) + { + return show; + } + assert!( + std::time::Instant::now() < deadline, + "unit did not reach ActiveState={wanted}: {show}" + ); + std::thread::sleep(Duration::from_millis(20)); + } + } + + fn wait_for_sub_state(&self, wanted: &str) -> String { + let deadline = std::time::Instant::now() + Duration::from_secs(5); + loop { + let show = self.show(); + if show + .lines() + .any(|line| line == format!("SubState={wanted}")) + { + return show; + } + assert!( + std::time::Instant::now() < deadline, + "unit did not reach SubState={wanted}: show={show}" + ); + std::thread::sleep(Duration::from_millis(10)); + } + } + + fn wait_for_failed_result(&self) -> String { + let deadline = std::time::Instant::now() + Duration::from_secs(5); + loop { + let show = self.show(); + if show.lines().any(|line| line == "ActiveState=failed") { + return show; + } + assert!( + std::time::Instant::now() < deadline, + "unit did not reach failed state: show={show}" + ); + std::thread::sleep(Duration::from_millis(20)); + } + } +} + +impl Drop for UnitFixture { + fn drop(&mut self) { + let _ = systemctl(&["stop", &self.name]); + let _ = std::fs::remove_file(&self.path); + let _ = systemctl(&["daemon-reload"]); + } +} + +fn systemctl(args: &[&str]) -> Output { + Command::new("/usr/bin/systemctl") + .arg("--system") + .args(args) + .output() + .expect("run systemctl") +} + +fn journal(unit: &str) -> String { + let output = Command::new("/usr/bin/journalctl") + .args(["--no-pager", "--output=cat", "--lines=30", "--unit", unit]) + .output() + .expect("run journalctl"); + String::from_utf8_lossy(&output.stdout).into_owned() +} + +fn assert_success(output: &Output, operation: &str) { + assert!( + output.status.success(), + "{operation} failed: status={:?}, stderr={}", + output.status.code(), + String::from_utf8_lossy(&output.stderr) + ); +} + +fn spec(name: &str, executable: &str) -> ServiceSpec { + ServiceSpec::new( + ServiceId::new(name).expect("service id"), + PathBuf::from(executable), + Vec::new(), + None, + ) + .expect("service spec") +} + +fn manager(fixture: &UnitFixture, definition: &str) -> SystemdManager { + SystemdManager::new( + RecordingExecutor::default(), + SystemdInstall::new( + fixture.name.clone(), + SystemdScope::System, + fixture.path.clone(), + definition.as_bytes().to_vec(), + false, + false, + Duration::from_secs(5), + ) + .expect("systemd install descriptor"), + ) +} + +fn require_systemd_host() { + assert_eq!( + std::fs::read_to_string("/proc/1/comm") + .expect("read init process") + .trim(), + "systemd", + "M010 qualification requires a Linux VM with systemd as PID 1" + ); + assert!( + Path::new("/sys/fs/cgroup/cgroup.controllers").exists(), + "M010 cgroup quiescence qualification requires cgroup v2" + ); + eprintln!( + "kernel={}", + std::fs::read_to_string("/proc/sys/kernel/osrelease") + .expect("read Linux kernel release") + .trim() + ); + let output = systemctl(&["show-environment"]); + assert_success(&output, "systemctl show-environment"); +} + +fn assert_no_cgroup_tasks(show: &str) { + let properties: std::collections::HashMap<_, _> = show + .lines() + .filter_map(|line| line.split_once('=')) + .collect(); + assert_eq!(properties.get("MainPID"), Some(&"0"), "{show}"); + assert_eq!(properties.get("ControlPID"), Some(&"0"), "{show}"); + let group = properties + .get("ControlGroup") + .expect("ControlGroup property"); + if group.is_empty() { + eprintln!("cgroup_quiescence=ControlGroup absent"); + return; + } + assert!(group.starts_with('/'), "untrusted ControlGroup: {group:?}"); + assert!( + group + .split('/') + .skip(1) + .all(|component| !component.is_empty() && component != "." && component != ".."), + "unsafe ControlGroup: {group:?}" + ); + let path = Path::new("/sys/fs/cgroup").join(group.trim_start_matches('/')); + if !path.exists() { + return; + } + let processes = + std::fs::read_to_string(path.join("cgroup.procs")).expect("read cgroup process list"); + assert!( + processes.trim().is_empty(), + "live cgroup processes: {processes}" + ); + let events = std::fs::read_to_string(path.join("cgroup.events")).expect("read cgroup events"); + eprintln!("cgroup_quiescence=path={path:?} procs={processes:?} events={events:?}"); + assert!( + events.lines().any(|line| line == "populated 0"), + "cgroup still populated: {events}" + ); +} + +fn cgroup_snapshot(show: &str) -> String { + let group = show + .lines() + .find_map(|line| line.strip_prefix("ControlGroup=")) + .unwrap_or(""); + if group.is_empty() { + return "ControlGroup absent".to_string(); + } + if !group.starts_with('/') || group.split('/').any(|part| part == "..") { + return format!("unsafe ControlGroup {group:?}"); + } + let path = Path::new("/sys/fs/cgroup").join(group.trim_start_matches('/')); + format!( + "ControlGroup={group:?} cgroup.procs={:?} cgroup.events={:?}", + std::fs::read_to_string(path.join("cgroup.procs")), + std::fs::read_to_string(path.join("cgroup.events")) + ) +} + +#[cfg(target_os = "linux")] +fn failed_unit_with_residual_cgroup_process_is_not_complete() { + let directory = + std::env::temp_dir().join(format!("eggup-m010-residual-{}", std::process::id())); + std::fs::create_dir_all(&directory).expect("create helper directory"); + let script = directory.join("fail-after-spawning-child"); + let pid_file = directory.join("child.pid"); + std::fs::write( + &script, + format!( + "#!/bin/sh\n/usr/bin/sleep 120 &\necho $! > {}\nexit 23\n", + pid_file.display() + ), + ) + .expect("write helper executable"); + let mut permissions = std::fs::metadata(&script) + .expect("stat helper executable") + .permissions(); + permissions.set_mode(0o700); + std::fs::set_permissions(&script, permissions).expect("make helper executable"); + + let definition = format!( + "[Unit]\nDescription=Eggup M010 residual cgroup fixture\n[Service]\nType=exec\nExecStart={}\nKillMode=process\nRestart=no\n", + script.display() + ); + let fixture = UnitFixture::new("residual", &definition); + let start = fixture.start(); + eprintln!("residual_process_start_status={:?}", start.status.code()); + let before = fixture.wait_for_active_state("failed"); + let pid: u32 = std::fs::read_to_string(&pid_file) + .expect("read fixture child pid") + .trim() + .parse() + .expect("fixture child pid is numeric"); + struct ChildCleanup(u32); + impl Drop for ChildCleanup { + fn drop(&mut self) { + let _ = Command::new("/usr/bin/kill") + .arg(self.0.to_string()) + .output(); + } + } + let _child_cleanup = ChildCleanup(pid); + assert!(Path::new(&format!("/proc/{pid}")).exists()); + eprintln!("residual_process_before={before:?} pid={pid}"); + + let mut manager = manager(&fixture, &definition); + let want = spec(&fixture.name, script.to_str().expect("UTF-8 helper path")); + let stop = manager + .stop(&want, Duration::from_secs(5)) + .expect("owned failed unit stop should return a bounded result"); + let after = fixture.show(); + eprintln!( + "residual_process_stop={stop:?} after_show={after:?} cgroup={}", + cgroup_snapshot(&after) + ); + eprintln!( + "residual_process_stop_commands={:?}", + manager + .executor() + .calls() + .into_iter() + .filter(|(argv, _)| argv.get(2).map(String::as_str) == Some("stop")) + .collect::>() + ); + assert!( + !stop.completed, + "live process/cgroup cannot be called quiescent" + ); + assert!(Path::new(&format!("/proc/{pid}")).exists()); + drop(_child_cleanup); + drop(fixture); + let _ = std::fs::remove_dir_all(directory); +} + +#[test] +fn real_systemd_owned_failed_service_stop_is_observed_and_quiescent() { + if std::env::var_os("EGGUP_SYSTEMD_INTEGRATION").is_none() { + eprintln!("skipped: set EGGUP_SYSTEMD_INTEGRATION=1 in a disposable systemd VM"); + return; + } + require_systemd_host(); + + let failed_definition = "[Unit]\nDescription=Eggup M010 failed-unit fixture\n[Service]\nType=exec\nExecStart=/usr/bin/false\nRestart=no\n"; + let failed = UnitFixture::new("failed", failed_definition); + let start = failed.start(); + let before = failed.wait_for_active_state("failed"); + let (active_before, active_status_before) = failed.is_active(); + eprintln!( + "systemd={} start_status={:?} before_show={before:?} before_is_active=({active_before:?}, {active_status_before:?})", + String::from_utf8_lossy(&systemctl(&["--version"]).stdout) + .lines() + .next() + .unwrap_or("unknown"), + start.status.code() + ); + assert!(before.lines().any(|line| line == "LoadState=loaded")); + assert!(before.lines().any(|line| line == "ActiveState=failed")); + assert_eq!(active_before, "failed"); + + let mut failed_manager = manager(&failed, failed_definition); + let failed_spec = spec(&failed.name, "/usr/bin/false"); + let observed = failed_manager + .inspect(&failed_spec) + .expect("inspect failed unit"); + assert_eq!(observed.ownership, eggup_service::Ownership::Owned); + assert_eq!(observed.state, LifecycleState::Unknown); + let stop = failed_manager + .stop(&failed_spec, Duration::from_secs(5)) + .expect("owned failed-unit stop should return a bounded result"); + let after = failed.show(); + let (active_after, active_status_after) = failed.is_active(); + eprintln!( + "failed_stop={stop:?} after_show={after:?} after_is_active=({active_after:?}, {active_status_after:?})" + ); + eprintln!( + "failed_stop_commands={:?}", + failed_manager + .executor() + .calls() + .into_iter() + .filter(|(argv, _)| argv.get(2).map(String::as_str) == Some("stop")) + .collect::>() + ); + assert!( + stop.completed, + "owned failed unit was not proven quiescent: {stop:?}" + ); + assert!(matches!(active_after.as_str(), "failed" | "inactive")); + assert_eq!(active_status_after, Some(3)); + assert!(after + .lines() + .any(|line| line == format!("ActiveState={active_after}"))); + assert_no_cgroup_tasks(&after); + + let recovered_definition = "[Unit]\nDescription=Eggup M010 caller-repaired fixture\n[Service]\nType=exec\nExecStart=/usr/bin/sleep 120\nRestart=no\n"; + std::fs::write(&failed.path, recovered_definition).expect("write caller-repaired unit"); + assert_success( + &systemctl(&["daemon-reload"]), + "reload caller-repaired unit", + ); + let mut recovered_manager = manager(&failed, recovered_definition); + let recovered_spec = ServiceSpec::new( + ServiceId::new(failed.name.clone()).expect("repaired service id"), + PathBuf::from("/usr/bin/sleep"), + vec!["120".to_string()], + None, + ) + .expect("repaired service spec"); + let started = recovered_manager + .start(&recovered_spec, Duration::from_secs(5)) + .expect("start caller-repaired unit"); + assert!(started.completed, "{started:?}"); + let stopped = recovered_manager + .stop(&recovered_spec, Duration::from_secs(5)) + .expect("stop caller-repaired unit"); + assert!(stopped.completed, "{stopped:?}"); + + let restart_definition = "[Unit]\nDescription=Eggup M010 restart-limit fixture\nStartLimitIntervalSec=60s\nStartLimitBurst=2\n[Service]\nType=exec\nExecStart=/usr/bin/false\nRestart=no\n"; + let restart = UnitFixture::new("restart-limit", restart_definition); + let restart_start = restart.start(); + let restart_first = restart.wait_for_failed_result(); + let restart_second_start = restart.start(); + // `systemctl start` may return nonzero when Type=exec exits immediately; + // the changed ExecStart invocation below proves whether the second run + // actually launched, while the third request must remain rate-limited. + let restart_second = restart.wait_for_failed_result(); + let rejected_start = restart.start(); + let restart_limited = restart.show(); + let first_exec = restart_first + .lines() + .find(|line| line.starts_with("ExecStart=")) + .expect("first failed invocation"); + let second_exec = restart_second + .lines() + .find(|line| line.starts_with("ExecStart=")) + .expect("second failed invocation"); + let limited_exec = restart_limited + .lines() + .find(|line| line.starts_with("ExecStart=")) + .expect("rate-limited invocation record"); + assert_ne!(first_exec, second_exec, "second launch must execute again"); + assert_eq!( + second_exec, limited_exec, + "rejected launch must not execute" + ); + assert!( + !rejected_start.status.success(), + "third start must be rate limited" + ); + eprintln!( + "restart_limit_start_status={:?} second_status={:?} rejected_status={:?} first={restart_first:?} second={restart_second:?} limited={restart_limited:?} journal={:?}", + restart_start.status.code(), + restart_second_start.status.code(), + rejected_start.status.code(), + journal(&restart.name), + ); + assert!(restart_limited + .lines() + .any(|line| line == "ActiveState=failed")); + let mut restart_manager = manager(&restart, restart_definition); + let restart_spec = spec(&restart.name, "/usr/bin/false"); + let restart_stop = restart_manager + .stop(&restart_spec, Duration::from_secs(5)) + .expect("stop rate-limited failed unit"); + let restart_after = restart.show(); + eprintln!( + "restart_limit_stop={restart_stop:?} show={restart_after:?} cgroup={}", + cgroup_snapshot(&restart_after) + ); + assert!(restart_stop.completed, "{restart_stop:?}"); + assert_no_cgroup_tasks(&restart_after); + + let auto_restart_definition = "[Unit]\nDescription=Eggup M010 auto-restart race fixture\nStartLimitIntervalSec=60s\nStartLimitBurst=20\n[Service]\nType=exec\nExecStart=/usr/bin/false\nRestart=on-failure\nRestartSec=500ms\n"; + let auto_restart = UnitFixture::new("auto-restart", auto_restart_definition); + let auto_start = auto_restart.start(); + let racing_before = auto_restart.wait_for_sub_state("auto-restart"); + let mut auto_restart_manager = manager(&auto_restart, auto_restart_definition); + let auto_spec = spec(&auto_restart.name, "/usr/bin/false"); + let racing_stop = auto_restart_manager + .stop(&auto_spec, Duration::from_secs(5)) + .expect("stop during real systemd auto-restart should return a bounded result"); + let racing_after = auto_restart.show(); + let (racing_active, racing_active_status) = auto_restart.is_active(); + eprintln!( + "auto_restart_race_start_status={:?} before={racing_before:?} stop={racing_stop:?} after={racing_after:?} is_active=({racing_active:?}, {racing_active_status:?}) journal={:?}", + auto_start.status.code(), + journal(&auto_restart.name), + ); + assert!( + racing_stop.completed, + "auto-restart race did not quiesce: {racing_stop:?}" + ); + assert_eq!(racing_active, "inactive"); + assert_eq!(racing_active_status, Some(3)); + assert!(racing_after + .lines() + .any(|line| line == "ActiveState=inactive")); + assert_no_cgroup_tasks(&racing_after); + + #[cfg(target_os = "linux")] + failed_unit_with_residual_cgroup_process_is_not_complete(); + + let running_definition = "[Unit]\nDescription=Eggup M010 foreign-unit fixture\n[Service]\nType=exec\nExecStart=/usr/bin/sleep 120\nRestart=no\n"; + let foreign = UnitFixture::new("foreign", running_definition); + assert_success(&foreign.start(), "start foreign control unit"); + let mut foreign_manager = manager(&foreign, running_definition); + let wrong_spec = spec(&foreign.name, "/usr/bin/false"); + let denied = foreign_manager + .stop(&wrong_spec, Duration::from_secs(2)) + .expect_err("changed ExecStart must deny stop"); + assert!(denied.to_string().contains("ownership")); + assert_eq!(foreign.is_active().0, "active"); + eprintln!("foreign_control_denied={denied}"); +} diff --git a/docs/releases.md b/docs/releases.md index a215ed5..bcccad1 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -1,7 +1,7 @@ # Releases, pinning, and upgrading Eggup is published to crates.io. **crates.io is the source of truth** for what -exists. The table below was queried from the crates.io API on **2026-10-05** +exists. The table below was rechecked against crates.io with `cargo info` on **2026-10-09** and matches the workspace manifests; re-check it when a release milestone closes, since registry state is the one fact here that changes without a commit. See also @@ -9,17 +9,17 @@ commit. See also ## Published state -All crates share the source version `0.1.2`. Only the registry differs. +All workspace crates currently declare source version `0.1.3`. Only the registry differs. | Crate | On crates.io | Notes | |---|---|---| -| `eggup-core` | `0.1.0`, `0.1.1`, `0.1.2` | | -| `eggup-acquisition` | `0.1.0`, `0.1.1`, `0.1.2` | | -| `eggup-eggfetch` | `0.1.0`, `0.1.1`, `0.1.2` | | +| `eggup-core` | `0.1.0`, `0.1.1`, `0.1.2`, `0.1.3` | latest published `0.1.3` | +| `eggup-acquisition` | `0.1.0`, `0.1.1`, `0.1.2`, `0.1.3` | latest published `0.1.3` | +| `eggup-eggfetch` | `0.1.0`, `0.1.1`, `0.1.2`, `0.1.3` | latest published `0.1.3` | | `eggup-curl` | `0.1.2` | first publication was `0.1.2` | -| `eggup-archive` | `0.1.2` | first publication was `0.1.2` | -| `eggup-eggpack` | `0.1.2` | first publication was `0.1.2` | -| `eggup-service` | `0.1.0`, `0.1.1`, `0.1.2` | published last, from a different source commit than the `v0.1.2` tag | +| `eggup-archive` | `0.1.2`, `0.1.3` | latest published `0.1.3` | +| `eggup-eggpack` | `0.1.2`, `0.1.3` | latest published `0.1.3` | +| `eggup-service` | `0.1.0`, `0.1.1`, `0.1.2`, `0.1.3` | M011 published the M010 owned failed-systemd quiescence correction on 2026-10-09 | | `eggup-transport-footprint` | — | `publish = false`; not on the registry at all | One consequence worth planning around: diff --git a/plans/closure/service-lifecycle/010-status.md b/plans/closure/service-lifecycle/010-status.md new file mode 100644 index 0000000..1fac833 --- /dev/null +++ b/plans/closure/service-lifecycle/010-status.md @@ -0,0 +1,205 @@ +# Service Lifecycle M010 — Closure and Verification Record + +Status: closed + +Source plan: `plans/implementation/service-lifecycle/010-owned-failed-systemd-service-quiescence-corrective.md` + +Source roadmap: `plans/subsystems/service-lifecycle-roadmap.md#M010--owned-failed-systemd-service-quiescence-corrective` + +Reviewed repository baseline (plan): `70ec4e63c52988bc6c82bea30d14f72eefda920a` + +Implementation source: `0bde3fefbda07019529ad7566c02e6e4ec141fd6` + +Hosted qualification: GitHub Actions run [`37875012280`](https://github.com/eggstack/eggup/actions/runs/37875012280), exact head `0bde3fefbda07019529ad7566c02e6e4ec141fd6`, all five jobs green. + +## Executive finding + +M010 found a required Eggup runtime correction. On Linux systemd 255, an exact-owned +unit whose process had exited remained `ActiveState=failed` after a successful +`systemctl stop`; its `is-active` result remained `failed` (exit status 3), and +the unit had no control group. The previous stop loop accepted only +`inactive`, so it could not report completion. The published `eggup-service +0.1.2` therefore does not supply this behavior, and downstream M011 is +applicable. + +The correction keeps the public API unchanged. Only a recognized `failed` state +with exact proven ownership enters the failed-unit path. It rechecks unit +identity around mutation and proof, verifies stable manager state and no pending +job, requires zero MainPID/ControlPID, and validates cgroup v2 process/event +evidence whenever systemd supplies a control group. The final `is-active` +observation must agree with `failed` or `inactive`. Unknown or contradictory +observations and unconfirmed quiescence return incomplete/refusal; they never +authorize rollback. The adapter does not clear systemd failure history, restart +the service, kill processes directly, elevate privileges, or add dependencies. + +Real-systemd qualification also demonstrated the negative case: a failed unit +with a surviving child in its cgroup returned `completed=false` at the bounded +deadline, while the process remained alive. A changed-ExecStart unit was denied +without stopping the foreign running service. Caller repair and a known-good +start/stop succeeded. + +## Requirement-to-evidence matrix + +| Requirement | Evidence | Result | +|---|---|---| +| Exact Owned authority before mutation | Failed-specific path revalidates parsed `ExecStart`; real foreign/changed-ExecStart control remained active and returned ownership denial | passed | +| Failed diagnosis does not mean quiescent | Real failed fixture remained `ActiveState=failed`, `is-active=failed`/3, with MainPID=0, ControlPID=0, no Job, and no ControlGroup after successful `systemctl stop` | passed | +| Manager proof and independent task proof | Stable post-stop observation, manager-job check, zero process IDs, and validated cgroup-v2 `cgroup.procs`/`cgroup.events` when present; residual child fixture remained populated and incomplete | passed | +| Restart/start-limit case | Real fixture recorded two distinct failed ExecStart invocations, rejected a third start without changing invocation identity, and retained systemd's “Start request repeated too quickly” journal evidence; subsequent stop completed | passed | +| Stop during automatic restart | Real fixture observed `ActiveState=activating`, `SubState=auto-restart`; Eggup stop completed, and post-stop state was `inactive`/`dead`, status 3, with zero process IDs and no cgroup | passed | +| Ownership/state races and malformed data | Deterministic fake-executor tests cover identity flap, unknown state, active/restart race, inconsistent status, unsafe cgroup, remaining process, and bounded timeout; mutation refusals remain fail-closed | passed | +| Ordinary running stop and repair path | Real systemd disposable sleep unit started and stopped after caller repaired its unit definition | passed | +| Public API compatibility | No public signatures or enum variants changed; external fixture resolves registry `eggup-service =0.1.2` and compiles wildcard matching for the already-`#[non_exhaustive]` `LifecycleState` | passed | +| Platform/MSRV qualification | Exact-head Stable, Rust 1.89 MSRV, macOS, Windows, and Linux systemd jobs green in run `37875012280` | passed | +| Package integrity / dependency scope | `cargo package` verifies 10-file service package; dry-run upload succeeds; no dependency or workspace manifest changes | passed | +| Documentation and plan governance | Service README/changelog, root changelog, service architecture, source plan, roadmap, registry, and this closure updated | passed | + +## Production and real-systemd evidence + +The systemd observation now includes `SubState`, `MainPID`, `ControlPID`, +`ControlGroup`, and `Job` in addition to load/active state and executable +identity. The failed-specific path is private to the systemd adapter and +preserves `LifecycleState::Unknown` for the generic public observation. The +successful stop command is not treated as sufficient evidence: ownership and +the final state are reread, cgroup paths are validated before use, and +contradictory `is-active` results prevent completion. + +The hosted fixture ran on Ubuntu 24.04.5 LTS, kernel `6.17.0-1022-azure`, systemd +`255 (255.4-1ubuntu8.17)`, cgroup v2. The failed `/usr/bin/false` fixture was +observed both before and after stop as `LoadState=loaded`, `ActiveState=failed`, +`SubState=failed`, `Result=exit-code`, `MainPID=0`, `ControlPID=0`, `Job=` and +`ControlGroup=`. `systemctl stop` exited 0; `is-active` returned `failed` with +status 3; Eggup returned `completed=true` only after that state was independently +shown to have no cgroup. + +The residual-process control used `KillMode=process`: its failing wrapper left a +live `/usr/bin/sleep` child in +`/system.slice/eggup-m010-…-residual.service`; cgroup evidence was +`cgroup.procs=` and `cgroup.events=populated 1`. Despite +`systemctl stop` exiting 0 and the manager reporting failed with zero MainPID, +Eggup returned `completed=false` at the 5-second deadline. This directly +discriminates process quiescence from the systemd failure diagnosis. + +The restart fixture used a 60-second `StartLimitIntervalSec` and +`StartLimitBurst=2`. It observed different invocation PIDs for the first two +failed starts and the same `ExecStart` invocation after the rejected third +request; the journal recorded the start-limit message. This avoids depending on +the optional `NRestarts` show property or localized journal text as a test gate. + +A separate restart-race fixture used `Restart=on-failure` and observed +`ActiveState=activating`, `SubState=auto-restart` before invoking Eggup stop. +Stop completed and systemd then reported `ActiveState=inactive`, `SubState=dead`, +`MainPID=0`, `ControlPID=0`, `Job=`, and status 3 from `is-active`. + +The test uses disposable system unit files under `/run/systemd/system`, removes +them, and reloads systemd on teardown. It does not alter unrelated units. The +real native lane qualifies system scope; user scope is not exercised by the +hosted VM, while deterministic adapter tests cover the shared proof logic. + +## Exact verification commands and results + +On the implementation tree: + +```text +rtk ./scripts/check-local.sh + passed on `753bc7c` before the final native auto-restart fixture was added +rtk cargo fmt --all + passed +rtk cargo test -p eggup-service --all-targets --all-features --locked + 110 passed (3 suites), after adding the native auto-restart fixture at `0bde3fe` +rtk cargo package -p eggup-service --list --locked + passed; 10 package files +rtk cargo package -p eggup-service --locked + passed; 10 files, 395.7 KiB unpacked, 72.5 KiB compressed +rtk cargo publish -p eggup-service --dry-run --locked + passed; upload verified, aborted due to dry-run +rtk cargo check --manifest-path crates/eggup-service/tests/published-api-0.1.2/Cargo.toml --locked + passed; exact registry-only 0.1.2 compatibility fixture +rtk cargo info eggup-service@0.1.3 --registry crates-io + confirmed absent from crates.io at qualification time +rtk git diff --check + passed +``` + +Package qualification produced `target/package/eggup-service-0.1.3.crate`, +72.5 KiB compressed, SHA-256 +`9d5f0246bf0e61b2b53c38049294c9b611c3205a5931f514e11719177e5d240c` at source +`753bc7c`. This is an M011 preflight artifact, not a release artifact: M011 must +rebuild and record the checksum from its final clean release-preparation source +commit. Crates.io reported no `eggup-service 0.1.3` version. No publish command +without `--dry-run` was issued. + +Exact hosted run `37875012280` results: + +| Lane | Result | +|---|---| +| Stable Linux: fmt, clippy, full workspace all-target/all-feature tests, docs | success | +| Rust 1.89 MSRV: workspace/all-target `cargo check` | success | +| macOS: full workspace/all-target/all-feature tests | success | +| Windows: named acquisition/archive/curl/eggpack/service/Core tests and full workspace test suite | success | +| Linux systemd: published 0.1.2 registry fixture plus privileged systemd integration matrix | success | + +Earlier hosted attempts `37874216157` and `37874306959` exposed fixture +assumptions (localized journal wording, and a deliberately failing service's +start exit status). They were corrected in the test harness; final exact-head +run `37874476249` passed every lane before the additional real auto-restart case; +the final run `37875012280` includes that case and passed every lane. + +## Invariant, failure, and recovery review + +- Foreign, changed, missing, malformed, unknown, or inconsistent observations + cannot authorize a stop or successful quiescence. +- `ActiveState=failed`, zero MainPID, a successful stop command, and a status-3 + `is-active` result are each insufficient alone. Completion requires the + complete observation protocol and cgroup proof when a group exists. +- A stop deadline or live cgroup task returns an incomplete bounded result. The + caller retains rollback/recovery authority; Eggup does not start a service or + mutate artifacts in response. +- Restart and identity races fail closed; the real rate-limit fixture confirms + the failed state can preserve manager diagnostics without `reset-failed`. +- No lock, artifact transaction, database compatibility, or consumer recovery + policy was moved into the service adapter. + +## Compatibility and security review + +Public `LifecycleState`, `Ownership`, `ServiceManager`, and `TransitionResult` +surfaces are unchanged; `LifecycleState` was already `#[non_exhaustive]`. The +plan's initial “closed enum” wording was corrected before acceptance. The +registry-only consumer check used published `eggup-service 0.1.2` and its +registry dependency graph, with no workspace path or Git override. Rust 1.89 and +all supported hosted target lanes passed. No dependencies, unsafe code, +privilege escalation, arbitrary command construction, or service-manager +fallback were added. + +The cgroup path is accepted only when rooted, component-safe, and accessed below +the validated cgroup v2 root. Symlink/unsafe/unreadable paths and conflicting +manager evidence do not become empty-cgroup success. Diagnostics remain bounded +through the existing executor and error paths. + +## Documentation, unresolved findings, and roadmap disposition + +Updated `architecture/service-lifecycle.md`, +`crates/eggup-service/README.md`, `crates/eggup-service/CHANGELOG.md`, and the +root `CHANGELOG.md`. Corrected an existing stale architecture statement that +said service 0.1.2 was unpublished. Updated the source plan, roadmap, registry, +and closure record. No user-facing guide needed a new code example. + +No unresolved M010 finding at medium-or-higher severity. The hosted systemd +evidence is Linux system-scope only; this does not weaken the cross-platform +compile/test evidence and is stated rather than inferred for user scope. + +Roadmap disposition: M010 is closed with a required runtime source change. +Service M011 is now dependency-ready and applicable; it owns publication of +the qualified service behavior if and only if explicit maintainer publication +authorization is obtained. The existing published 0.1.2 does not meet M010's +failed-owned-unit completion contract. The separate wg-basic C001a consumer +handoff remains pending the immutable registry release evidence from M011. + +## Registry updates + +- Service Lifecycle M010: `closed`; this record is authoritative. +- Service Lifecycle M011: applicable and dependency-ready after M010 runtime + closure; release preparation can proceed, while registry publication remains + blocked on explicit maintainer authorization. +- No other implementation plan's hard dependency changed as a consequence of + M010. diff --git a/plans/closure/service-lifecycle/011-status.md b/plans/closure/service-lifecycle/011-status.md new file mode 100644 index 0000000..37cd227 --- /dev/null +++ b/plans/closure/service-lifecycle/011-status.md @@ -0,0 +1,220 @@ +# Service Lifecycle M011 — Closure and Verification Record + +Status: closed + +Source plan: `plans/implementation/service-lifecycle/011-verified-service-patch-publication.md` + +Source roadmap: `plans/subsystems/service-lifecycle-roadmap.md#M011--conditional-published-service-patch-for-wg-basic` + +Reviewed planning baseline: `0bde3fefbda07019529ad7566c02e6e4ec141fd6` (M010 strict closure) + +Pre-publication qualification head: `f65496fbd8950cb50d46620f57da336b2da232fb`; hosted run `37876276212` green. + +Publication source: `feb6ae5aea4c9b61c4051957f3662ca49d845f9e` (`crates/eggup-service`) + +Post-publication qualification head: `2fbb3c6f75ae536b53a7d30087c0b0edef7c74ec`; hosted run [`37883703334`](https://github.com/eggstack/eggup/actions/runs/37883703334) green on all five jobs. + +## Executive finding + +Service M011 published the M010 owned-failed-systemd quiescence correction as +`eggup-service 0.1.3` on 2026-10-09. Only `eggup-service` was uploaded. The +registry package is 74,405 bytes (72.7 KiB compressed; 396.0 KiB unpacked), +with SHA-256 +`9f7f7ea854577158e66aa202709ab1c97a3aedcf00b06c1ab914d25b132124dc`. Its +embedded `.cargo_vcs_info.json` identifies source commit +`feb6ae5aea4c9b61c4051957f3662ca49d845f9e` and path `crates/eggup-service`. +Cargo downloaded and verified the registry archive against this checksum. + +A new external fixture depends on exactly `eggup-service = "=0.1.3"`; its lock +file resolves both `eggup-service 0.1.3` and `eggup-core 0.1.3` from the +crates.io registry, with no path or Git edge. Hosted systemd 255 evidence +confirms the published adapter completes stop for the exact-owned failed unit +only after quiescence evidence agrees. The same run retains the 0.1.2 negative +control and the Foreign/malformed inspection controls. + +The existing shared `v0.1.3` tag was not moved. GitHub Release `0.1.3` was +extended with the package-specific source, checksum, downstream pin guidance, +and the exact registry `.crate` as a release asset. No other crate was +published or changed in the registry. + +## Publication record + +| Field | Value | +|---|---| +| Registry package | `eggup-service 0.1.3` | +| Published | 2026-10-09; explicit maintainer authorization received in this task | +| Registry checksum | `9f7f7ea854577158e66aa202709ab1c97a3aedcf00b06c1ab914d25b132124dc` | +| Local registry cache SHA-256 | identical | +| Package size | 74,405 bytes; 10 files; 396.0 KiB unpacked / 72.7 KiB compressed | +| Source revision | `feb6ae5aea4c9b61c4051957f3662ca49d845f9e` | +| `.cargo_vcs_info.json` path | `crates/eggup-service` | +| `cargo info` | Version 0.1.3; Rust 1.89; MIT; registry resolves | +| GitHub release | [0.1.3](https://github.com/eggstack/eggup/releases/tag/v0.1.3), extended with this package and `.crate` asset | +| GitHub asset verification | Downloaded `eggup-service-0.1.3.crate`; 74,405 bytes and SHA-256 identical to crates.io | +| Existing tag | `v0.1.3` object `414279c51fa274be9968030dacacb8b033090210`, peeled commit `bd4368369aaf0ae1de2ce213fc16689281bdd664`; unchanged | + +## Requirement-to-evidence matrix + +| Requirement | Evidence | Result | +|---|---|---| +| M010 correction is required and source-compatible | M010 closure `plans/closure/service-lifecycle/010-status.md`; no public enum/signature change or added dependency | passed | +| `0.1.3` unused before publish | `cargo info eggup-service@0.1.2 --registry crates-io` resolved; `cargo info eggup-service@0.1.3 --registry crates-io` returned no version before upload | passed | +| Published package source is identified exactly | `.cargo_vcs_info.json` inside the downloaded `.crate` names `feb6ae5aea4c9b61c4051957f3662ca49d845f9e` and `crates/eggup-service` | passed | +| Registry checksum matches the downloaded artifact | `shasum -a 256` of Cargo's registry cache file equals the checksum stored in the 0.1.3 external fixture lockfile and crates.io resolution | passed | +| Registry-only graph has no path/Git edge | `crates/eggup-service/tests/published-api-0.1.3/Cargo.toml` declares only `eggup-service = "=0.1.3"`; lock/tree show registry `eggup-service 0.1.3` and `eggup-core 0.1.3` | passed | +| API remains compatible | External fixture wildcard-matches `LifecycleState`; Owned failed inspection remains `Ownership::Owned` + `LifecycleState::Unknown`; no signature/variant migration | passed | +| Published 0.1.2 remains a discriminating negative control | Existing privileged `published-api-0.1.2` fixture still observed `Owned/Unknown` with `MainPID=0`, `ControlPID=0`, empty `ControlGroup`, no job, yet stop did not complete | passed | +| Published 0.1.3 completes exact-owned failed-unit stop safely | New privileged registry-only fixture observed `ActiveState=failed`, zero PIDs, no job and empty ControlGroup; stop returned `completed=true` only after independent post-stop proof | passed | +| Foreign and malformed controls fail closed | New registry-only 0.1.3 inspection controls passed for changed `ExecStart` → Foreign and malformed `ExecStart` → Unknown | passed | +| Other packages and tags remain untouched | One crates.io upload (`eggup-service 0.1.3`); `v0.1.3` remote ref and peeled target unchanged | passed | +| GitHub release is complete | Existing Release `0.1.3` notes extended; downloaded release asset is 74,405 bytes and SHA-256 matches the registry artifact; tag not recreated or moved | passed | +| Downstream version/checksum handoff is explicit | Release note and this record name wg-basic Distribution M004 C001a, exact pin `=0.1.3`, source SHA, checksum, and no API migration | passed | +| No newly unblocked Eggup implementation plan was omitted | Service M011 is the only direct successor to M010. The independent Acquisition M012 readiness is unchanged; wg-basic M004 remains active on rootful qualification and production trust-root needs, so M005 remains blocked | passed | + +## Registry-only fixture and hosted platform evidence + +Fixture: `crates/eggup-service/tests/published-api-0.1.3/`. The standalone +manifest has no workspace inheritance, `[patch]`, path dependency, or Git +dependency. Its lockfile records: + +```text +name = "eggup-core" version = "0.1.3" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "161b244bc474fa24815ebd81db8cda46e0f752dd4b84983e454239f89fd789ad" +name = "eggup-service" version = "0.1.3" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "9f7f7ea854577158e66aa202709ab1c97a3aedcf00b06c1ab914d25b132124dc" +``` + +Hosted run `37883703334` passed: + +| Lane | Evidence | Result | +|---|---|---| +| Stable/Linux | fmt, clippy, full workspace tests, docs, packaged service verification | passed | +| Rust 1.89 MSRV | workspace check and packaged service verification | passed | +| Linux systemd | 0.1.2 negative control, current workspace failed-stop suite, 0.1.3 registry-only API/check/systemd suite | passed | +| macOS | full workspace test suite and packaged service verification | passed | +| Windows | targeted native tests, full workspace tests, packaged service verification | passed | + +The post-publication systemd fixture ran on Ubuntu 24.04.5 LTS, kernel +`6.17.0-1022-azure`, systemd `255 (255.4-1ubuntu8.17)`. It proved the published +0.1.3 stop against `/usr/bin/false` while systemd continued to report +`ActiveState=failed`, `MainPID=0`, `ControlPID=0`, `Job=`, and `ControlGroup=`; +`is-active` returned `failed`/3 and Eggup returned +`TransitionResult { operation: Stop, completed: true }`. The copied full +systemd integration suite also covers residual cgroup tasks, auto-restart, +start-limit behavior, and foreign service preservation. The external +inspection-control suite passed all three tests. + +## Exact commands and results + +Local verification on the final implementation/test tree: + +```text +./scripts/check-local.sh PASS +cargo fmt --manifest-path crates/eggup-service/tests/published-api-0.1.3/Cargo.toml -- --check PASS +cargo check --manifest-path crates/eggup-service/tests/published-api-0.1.3/Cargo.toml --locked PASS +cargo test --manifest-path crates/eggup-service/tests/published-api-0.1.3/Cargo.toml --locked -- --nocapture 4 passed; real systemd integration is skipped without EGGUP_SYSTEMD_INTEGRATION +cargo tree --manifest-path crates/eggup-service/tests/published-api-0.1.3/Cargo.toml --locked registry-only graph +git diff --check PASS +``` + +Release qualification and publication: + +```text +cargo package -p eggup-service --list --locked PASS (10 files; pre-publication qualification) +cargo package -p eggup-service --locked PASS (pre-publication qualification) +cargo publish -p eggup-service --dry-run --locked PASS (pre-publication qualification) +cargo publish -p eggup-service --locked Published 0.1.3 from feb6ae5 +cargo info eggup-service@0.1.3 --registry crates-io PASS; registry resolves 0.1.3 +shasum -a 256 eggup-service-0.1.3.crate 9f7f7ea854577158e66aa202709ab1c97a3aedcf00b06c1ab914d25b132124dc +``` + +The Linux systemd integration was not run on the local macOS host; its native +result is provided by hosted Linux run `37883703334`. macOS and Windows +evidence is separately present in that same all-green run. + +## Hosted rerun history + +- Run `37883459560` failed in the existing systemd restart-limit fixture because + it assumed `systemctl start` must return success for a `Type=exec` + `/usr/bin/false` unit. The test now uses the changed `ExecStart` invocation + record to prove the second launch and tests that the third is rate-limited; + runtime code did not change for this harness correction. +- Run `37883703334` initially hit Linux `ETXTBSY` in the unrelated Core + `bounded_candidates_are_exact_and_environment_is_cleared` test. The failed + Stable job was rerun on the same source SHA and passed; all five jobs in the + completed run are green. + +## Invariants, compatibility, and security review + +- Failed systemd status is still not a public `LifecycleState` variant. +- Stop completion requires exact ownership revalidation, stable manager + observations, no active manager job, zero process IDs, consistent + `is-active`, and validated cgroup quiescence when a control group exists. +- Foreign, Unknown, malformed, racing, and residual-process cases fail closed. +- No `reset-failed`, direct process kill, privilege escalation, new dependency, + or automatic restart was introduced. +- The public API is unchanged; consumers can move a direct exact pin from + `eggup-service = "=0.1.2"` to `=0.1.3` and refresh the lockfile without a + source migration. +- Only `eggup-service` was published. SHA-256 remains integrity evidence only; + this release makes no authenticity/signature claim. + +## Documentation, known limitation, and roadmap disposition + +Updated the service and root changelogs, release documentation, service and +workspace architecture, CI guidance, M011 plan, roadmap, and registry. GitHub +Release `0.1.3` now records the service source/checksum, downstream pin, and +registry `.crate` asset. No historical service M009 closure or shared tag was +rewritten. + +One low-severity documentation limitation remains in immutable registry bytes: +the embedded `CHANGELOG.md` is the pre-upload source snapshot and labels 0.1.3 a +release candidate. The checked-in changelog and GitHub release note now state +the actual published status and document this snapshot. The source snapshot is +truthful as of its build time, the code/package checksum is verified, and no +runtime/API defect is involved. No medium-or-higher finding remains open. + +The downstream handoff is now available in the GitHub release record and here: +wg-basic Distribution M004 C001a should use `eggup-service = "=0.1.3"` with +lockfile refresh; its public API needs no migration. This publication makes the +version prerequisite available but does not close wg-basic M004, whose rootful +qualification and production trust-root requirements remain, nor unblock M005. +No additional Eggup implementation plan became dependency-ready from this +publication. Acquisition M012 remains independently ready and unchanged. + +## Registry updates + +- Service Lifecycle M010: closed with required runtime correction; unchanged. +- Service Lifecycle M011: closed after registry verification, exact-version + external/systemd proof, GitHub release extension, and downstream version + handoff. +- Service Lifecycle roadmap and `plans/registry.md`: updated to published + `eggup-service 0.1.3` and M011 closed. +- No other milestone status changed. wg-basic M004 remains active; M005 remains + blocked on M004. + +## Downstream status addendum — wg-basic adoption and technical closure (2026-10-09) + +The preceding handoff and status describe the state immediately after the +`eggup-service 0.1.3` publication. The downstream repository has since merged +the M004 corrective and qualification work to `main` at +`dbowm91/wg-basic@ff40f85` (merge of PR #1, +`plans/m004-update-correctives`). The current main contains the formal M004, +M005, and Phase 11 closure records; the earlier open-blocker disposition above +is historical and is superseded by this addendum. + +| Downstream result | Evidence | Status | +|---|---|---| +| M004 adopted the published Eggup fix | `Cargo.toml` pins `eggup-service = "=0.1.3"`; `Cargo.lock` resolves registry package 0.1.3. `plans/closure/distribution/004-c001a-status.md` records the exact checksum and typed failed-unit recovery path. | closed | +| M004 rootful updater qualification and corrective gates | `plans/closure/distribution/004-status.md` and `004-c001-status.md` / `004-c001a-status.md` / `004-c002-status.md`; dedicated systemd run [`37929914324`](https://github.com/dbowm91/wg-basic/actions/runs/37929914324), full CI [`37929917248`](https://github.com/dbowm91/wg-basic/actions/runs/37929917248), distribution native-target run [`37929920418`](https://github.com/dbowm91/wg-basic/actions/runs/37929920418). | technically closed | +| M005 and Phase 10 lifecycle qualification | `plans/closure/distribution/005-status.md`; implementation head `c7de919c0b9d8f3326c50c799779ee5dc3734dca`; full CI [`37936112512`](https://github.com/dbowm91/wg-basic/actions/runs/37936112512), native artifact/lifecycle run [`37936276064`](https://github.com/dbowm91/wg-basic/actions/runs/37936276064). | technically closed | +| Subsequent eligible Phase 11 implementation work | wg-basic registry and roadmap record M001–M004 closed; M004 closure [`plans/closure/ipv6-route-policy/004-status.md`](https://github.com/dbowm91/wg-basic/blob/ff40f85/plans/closure/ipv6-route-policy/004-status.md) records Phase 11 closure. wg-basic registry has no active implementation plan and keeps Phase 12 deferred. | no further eligible implementation plan | +| Production release | wg-basic registry lists production signing/public release as blocked pending maintainer-provisioned key, signed draft, and explicit publication authorization. Fixture signing establishes technical mechanics only. | externally blocked; not part of M004 technical closure | + +M004's formal closure correctly separates technical completion from the +production signing gate. M005 and Phase 11 are also closed, so no additional +wg-basic implementation plan became eligible after those closures. No new +Eggup implementation plan was unblocked; Acquisition M012 remains independently +ready, as before. No Eggup runtime or publication state changed. diff --git a/plans/implementation/service-lifecycle/010-owned-failed-systemd-service-quiescence-corrective.md b/plans/implementation/service-lifecycle/010-owned-failed-systemd-service-quiescence-corrective.md new file mode 100644 index 0000000..dbf8dd9 --- /dev/null +++ b/plans/implementation/service-lifecycle/010-owned-failed-systemd-service-quiescence-corrective.md @@ -0,0 +1,129 @@ +# Service Lifecycle M010 — Owned Failed-systemd Service Quiescence Corrective + +Status: closed; see `plans/closure/service-lifecycle/010-status.md`. +Repository baseline: `eggstack/eggup@70ec4e63c52988bc6c82bea30d14f72eefda920a` (2026-10-08). +Source roadmap: `plans/subsystems/service-lifecycle-roadmap.md`. +Primary class: invariant / corrective. +Consumer blocker: `dbowm91/wg-basic`, Distribution M004 C001 at `plans/m004-update-correctives`, closure disposition `plans/closure/distribution/004-c001-status.md`. + +## 1. Objective + +Supply a product-neutral, ownership-safe systemd service-quiescence operation that handles a known *failed* owned service during update rollback/recovery. A service reported as `failed` by systemd is not by itself a proof that no processes or cgroup tasks are running. The API must distinguish (a) recognized failure diagnosis, (b) authority over the exact owned registration, and (c) demonstrably completed quiescence. + +Enable a consumer to stop a failed candidate and restore a compatible application binary/database without adding a product-specific raw `systemctl` fallback. Preserve fail-closed behavior for foreign, malformed, unidentifiable, transitioning, and unverifiably quiesced registrations. + +## 2. Readiness, historical reference, and detection gap + +- Service M001–M009 are closed, with `eggup-service 0.1.2` published and the workspace at `0.1.3`. See `plans/implementation/service-lifecycle/005-prepared-transaction-lifecycle-integration.md`, `plans/closure/service-lifecycle/005-status.md`, `plans/implementation/service-lifecycle/006-daemon-update-disposition-and-reference-qualification.md`, `plans/closure/service-lifecycle/006-status.md`, and `plans/closure/service-lifecycle/009-status.md`. +- In `crates/eggup-service/src/lib.rs`, `systemd_ownership()` maps `ActiveState=active` to Running, `inactive` to Stopped, `activating|deactivating|reloading` to Transitioning, and all other values (including `failed`) to Unknown. +- `SystemdManager::stop()` checks ownership via the parsed `ExecStart` and systemd unit, issues an owned `systemctl stop`, then `poll_active(false)` accepts only `is-active=inactive` with status 3. A failed unit may remain reported as failed unless an explicit stop changes the manager state; exact behavior requires a real-systemd fixture. +- `wg-basic` refuses Unknown/Transitioning before its service-stop path and cannot prove safety or recover a candidate after such a failed start. Its C001 implementation therefore remains `corrective required`, not closed, despite earlier synthetic tests and unrelated Phase 9 rootful upgrade rehearsal. +- Earlier service M005/M006 closure tests exercised ordinary owned Running/Stopped, foreign preservation, and selected lifecycle failures, but did not discriminate an exact owned `failed` systemd unit from a genuinely unknown/unowned unit after candidate start failure. +- systemd documents `failed` as an error/diagnostic state; `reset-failed` clears failure metadata and restart limits. Resetting failure history is neither necessary nor sufficient to prove quiescence and must not be treated as an automatic repair action. + +Hard dependency: historical service M001–M009 closure only; this was ready independently of wg-basic implementation. M011 is now dependency-ready because M010 closed with a required runtime change; crates.io publication remains a separate explicit authorization boundary. + +## 3. Discriminating research fixture first (mandatory) + +Build a Linux systemd VM fixture with a real service definition and exact owned `ServiceSpec`, with cases: +1. normal running -> `stop` -> inactive; +2. immediate exit nonzero -> `ActiveState=failed`, `is-active=failed`, no remaining tasks; +3. `Restart=on-failure` repeated failure/start-limit hit; +4. failed `ExecStartPre` or failing startup with surviving `ExecStopPost`/cgroup tasks if reproducible; +5. stop racing failed -> activating/auto-restart; +6. control case: exact unit file but changed `ExecStart`, foreign unit, missing unit, malformed show output, and inaccessible manager; +7. user/system scope as supported by the adapter. + +Record before/after `systemctl show -p LoadState,ActiveState,SubState,ExecStart,MainPID,ControlPID,ControlGroup,Job,Result`, `is-active` output and exit code, `stop` exit code, and independently established process/cgroup quiescence. Include host systemd version. **Determine whether existing Eggup stop already converges failed -> inactive after a legal stop.** If so, the minimum correction may be to improve explicitly typed classification/diagnostics and tests, while the wg-basic call-site correction belongs downstream; do not invent a new public mechanism without a demonstrated need. + +## 4. Invariants + +- Only exact `Ownership::Owned` units may be stopped. Inspect ownership again immediately before manager mutation, and do not broaden ownership by unit name alone, PID alone, `LoadState` alone, or a caller's assertion. +- A reported `failed` or zero `MainPID` alone is **not** proof of no surviving unit processes. Successful quiescence requires actual stop/completion evidence and conservative post-stop active/substate and, where necessary, cgroup/process presence evidence. A partially failing stop never yields Completed. +- An unknown manager state, foreign or changed `ExecStart`, unknown/suspicious control-group identity, inconsistent observations, active manager job, restart race, permission failure, or timed-out call must produce a bounded, classified failure and retain recovery authority with the caller (no implicit restart). +- `systemctl reset-failed` is not a substitute for `stop`, and must not be invoked merely to normalize `is-active`. If test evidence requires it, stop for a new reviewed design because it clears manager diagnostics and rate-limit counters. +- Preserve absolute `OperationDeadline` budgets, process-output byte limits, bounded subprocess cleanup, exact service-registration matching, private data redaction and no automatic privilege escalation. +- Preserve the existing `LifecycleState` variants and meanings. The enum is already `#[non_exhaustive]`, so external consumers must include a wildcard arm; do not rely on the original plan's incorrect claim that it is closed. Keep failure diagnosis internal to the systemd adapter and do not add a public variant for this correction. +- No application-specific notion of database compatibility, service health HTTP, unit string, or VPN state enters Eggup. + +## 5. Scope and non-scope + +In scope: systemd adapter `inspect/stop` classification and quiescence proof, narrowly necessary typed API additions if documented, deterministic fake-executor fixtures with negative controls, real systemd integration qualification, service docs/roadmap/closure handoff. + +Out of scope: Core artifact transaction semantics, non-systemd daemon manager changes, any cross-platform API break, arbitrary systemctl string passthrough, blanket `Unknown -> Stopped` mapping, default `reset-failed`, raw kill/cgroup manipulation as a shortcut, changing service configuration/hardening of consumers, registry publication (M011), wg-basic consumer code (separate corrective). + +## 6. Ordered work packages + +### WP1 — Classify and reproduce + +Run the real fixture matrix in §3. Produce a state transition table for `Loaded+Owned` in `active/inactive/failed/activating/deactivating`, for `Foreign`, and for malformed show/is-active output. Identify whether the failure is in the Eggup adapter, its observation schema, the downstream preflight, or a combination. Avoid speculative API additions before this finding. + +### WP2 — Minimal safe implementation + +- Ensure known `failed` can lead to an owned stop attempt without granting stop authority to truly unknown states. Separate *failure classification* from *ownership proof* even if public `LifecycleState` stays Unknown. +- Prefer preserving `ServiceManager::stop` and its existing public signatures. If the generic enum cannot express the evidence, add a documented additive systemd-specific operation or auxiliary typed observation/proof method; document its exact preconditions and postconditions. Do not add an enum variant or silently treat all Unknown as Stopped. +- Consider final quiescence evidence from successful `systemctl stop`, post-stop `ActiveState=inactive`, lack of an in-flight job, and cgroup/process absence where a failed state can persist. Establish what is actually needed with real-systemd evidence; do not build an unchecked `PID=0` heuristic or hide a failed polling result. +- Re-inspect exact ownership after the mutation and at proof consumption, reject changed unit executable/config and symlink/foreign unit state, and retain an observable recovery-required error on ambiguity. +- Preserve former success semantics for already stopped units, for normal Running -> Stopped, and for dry/foreign/malformed refusals. + +### WP3 — Regressions, edge cases, and consumer fixture + +Add deterministic FakeExecutor/fake systemctl tests for `failed` with/without safe post-stop result, failed->inactive, failed->still-failed, failed->active restart, changed ExecStart, loaded unknown, missing fields, failed manager process, arbitrary nonzero is-active status, job stuck, timeout, foreign ownership, and untrusted diagnostics. Include a test where a process/cgroup remains after a nominal success, which MUST fail if the evidence protocol requires process proof. + +Run at least one real systemd executable fixture: owned candidate fails startup, expected stop/quiescence result, then restart of a known-good unit after a caller-controlled repair. Demonstrate that the new behavior is not a semantic relaxation of Foreign/Unknown mutation. + +Add a product-neutral consumer fixture or a short pinned external wg-basic smoke (read-only version/compile + controlled unit) to prove service M010 can be used for failed-candidate rollback; do not block Eggup on completing the whole wg-basic application update. + +### WP4 — Security/API review and native portability + +Diff public `LifecycleState`, `Ownership`, `ServiceManager` and `TransitionResult` against published service 0.1.2; compile a registry-only external consumer using the required wildcard enum match and reject removed or newly required API. Confirm no service change on macOS launchd, cron, Windows SCM or non-systemd Linux. Keep the dependency graph and Rust 1.89 intact, `unsafe_code = deny`, and no new shell-based command construction. + +## 7. Failure, restart, contention and cancellation + +A bounded stop which times out or loses ownership must return a refusal/uncertain-state result, never a success. A candidate with a restart loop may change state between observation and mutation; require final revalidation and fail closed if convergence is not proven. Do not kill unrelated processes or alter host-global service-manager state. If observed states are contradictory, report precise safe metadata without invoking an unreviewed new transition. This is a local manager operation, not a binary/DB rollback transaction. + +## 8. Compatibility and migrations + +If public additions are necessary, add them in a source-compatible fashion with explicit docs and caller migration examples. No modification to `eggup-core` or other crate APIs, no new protocol/schema/lock migrations. A consumer may need to change its own pre-stop guard to permit the newly qualified *specific* Failed case; downstream wg-basic C001a owns that adoption. Do not conflate `LifecycleState::Unknown` with `Ownership::Unknown` in docs or tests. + +## 9. Verification + +```text +cargo fmt --all -- --check +cargo clippy --workspace --all-targets --all-features --locked -- -D warnings +cargo test -p eggup-service --all-targets --all-features --locked +cargo test --workspace --all-targets --all-features --locked +cargo doc --workspace --no-deps --locked +cargo +1.89.0 check --workspace --all-targets --locked +cargo package -p eggup-service --locked +cargo publish -p eggup-service --dry-run --locked +git diff --check +``` + +Hosted evidence: Linux Stable, Rust 1.89, macOS, Windows; real disposable systemd fixture plus negative tests. Explicitly record package diff and portable compile. A simulated `systemctl` transcript alone is not sufficient to claim that `failed` is quiescent. + +## 10. Documentation + +Update `architecture/service-lifecycle.md`, `crates/eggup-service/README.md`, `crates/eggup-service/CHANGELOG.md` Unreleased section, `plans/subsystems/service-lifecycle-roadmap.md` and `plans/registry.md` after implementation. Cross-link `dbowm91/wg-basic` C001a handoff. Preserve historical service M005/M006/M009 closure records. + +## 11. Acceptance criteria + +1. Exact Owned failed candidates can be stopped/proven quiescent through Eggup without generic downstream systemctl fallback, **or** the documented discriminating fixture proves existing Eggup API is fully sufficient and identifies only the downstream guard as defective; record the narrower conclusion honestly. +2. A failed/foreign/malformed/ambiguous state cannot yield a false completion or mutate a foreign service. +3. Real systemd and deterministic negative-control fixtures pass, including failed->inactive or failed-state persistence as actually observed, and deadline/restart races. +4. An external consumer matching the published non-exhaustive `LifecycleState` with a wildcard still compiles; no platform regressions, new dependency, or privilege escalation. +5. All required current-head CI and Rust 1.89 gates pass, and an exact source/behavior/consumer handoff is recorded. + +If M010 closes as `existing API sufficient, no service runtime change`, **do not publish a gratuitous service patch**; mark M011 not needed and unblock the downstream corrective using proven 0.1.2. Otherwise M011 owns the registry release. + +## 12. Stop conditions + +Stop for design review if proving quiescence requires clearing systemd failure history/rate limit, changing published public enum variants, treating any Unknown as stopped, assuming absent PID proves an empty cgroup, accepting stale ownership after a restart race, breaking service M005/M006 semantics, adding a service-manager escape hatch, or silently skipping a native CI lane. + +## 13. Closure evidence + +Write `plans/closure/service-lifecycle/010-status.md` only after real implementation evidence. Record baseline/implementation SHAs, exact observed systemd state/transitions, failure detection evidence, old/new behavior with negative controls, service API diff and external consumer compile, real systemd runner/kernel, full hosted run links, package dry-run, unresolved severity, and explicit disposition on the M011 publication requirement. + +## 14. Handoff + +Eggup Service M011 is dependency-ready on M010's closed, **runtime-changed** disposition. The wg-basic C001a handoff can qualify against a published patched service version after M011; the already published 0.1.2 does not provide the required failed-owned-unit quiescence behavior. diff --git a/plans/implementation/service-lifecycle/011-verified-service-patch-publication.md b/plans/implementation/service-lifecycle/011-verified-service-patch-publication.md new file mode 100644 index 0000000..e9aae8e --- /dev/null +++ b/plans/implementation/service-lifecycle/011-verified-service-patch-publication.md @@ -0,0 +1,116 @@ +# Service Lifecycle M011 — Publish the Qualified Failed-unit Quiescence Correction + +Status: closed; `eggup-service 0.1.3` published 2026-10-09 and post-publication qualification passed. +Repository planning baseline: `eggstack/eggup@0bde3fefbda07019529ad7566c02e6e4ec141fd6` (M010 strict closure and final hosted qualification, 2026-10-09). +Source roadmap: `plans/subsystems/service-lifecycle-roadmap.md`. +Primary class: infrastructure / release qualification. +Hard dependency: Service M010 (`plans/implementation/service-lifecycle/010-owned-failed-systemd-service-quiescence-corrective.md`) CLOSED with the required runtime change, real-systemd proof, and no public API break. +Operational dependency: explicit maintainer publishing authorization (satisfied 2026-10-09). The M010 implementation head passed hosted run `37875012280`; the pre-publication M011 head passed the complete hosted matrix in run `37876276212`. + +Registry preflight on 2026-10-09 confirmed `eggup-service 0.1.2` and absence of `0.1.3`. Authorized publication completed for `eggup-service 0.1.3` only. Cargo downloaded and checksum-verified the published package: 10 files, 396.0 KiB unpacked, 72.7 KiB compressed, SHA-256 `9f7f7ea854577158e66aa202709ab1c97a3aedcf00b06c1ab914d25b132124dc`. Its `.cargo_vcs_info.json` names source commit `feb6ae5aea4c9b61c4051957f3662ca49d845f9e` and path `crates/eggup-service`. + +Pre-publication qualification is complete. Hosted run +`37876276212` is green on Stable, Rust 1.89 MSRV, macOS, Windows, and the +privileged Linux systemd lane at exact head `f65496fbd8950cb50d46620f57da336b2da232fb`. +The systemd lane confirmed registry-only `eggup-service =0.1.2` classifies the +exact failed registration as Owned/Unknown but returns +`Manager("transition deadline exhausted before manager command")` despite +zero PIDs, empty ControlGroup, and no Job; current workspace 0.1.3 passed its +positive real-systemd failed-stop fixture in the same run. Three external +inspection controls pass for Owned, Foreign, and malformed registrations. The +local workspace gate, registry-only fixture, `cargo package --list`, package +verification, and `cargo publish --dry-run` passed before publication. The +package checksum and size are recorded above. Publication was explicitly +authorized and completed. A fresh registry-only +`=0.1.3` fixture now covers positive quiescence and Foreign/malformed controls. +Downstream M004 remains active with independent rootful qualification and +production trust-root blockers; this service publication does not close M004 +or unblock M005. + +## 1. Objective + +Make the M010 corrected `eggup-service` state/quiescence contract consumable from crates.io by `wg-basic`, with exact reproducible packaged source, registry-only compatibility evidence and no accidental change to other Eggup crates. The current repository uses workspace package version `0.1.3`; the previously published `eggup-service 0.1.2` is immutable. Publish the next valid, unused service patch version after explicit registry inspection; `0.1.3` is the expected candidate, not permission to assume availability or overwrite anything. + +## 2. Detection and cross-repository blocker + +`wg-basic` pins `eggup-service = "=0.1.2"`, which lacks a safe completion path for its failed-candidate rollback. M010's real-systemd negative control proved the published stop reports incomplete even when the exact-owned failed unit has no remaining tasks; M010 therefore requires an Eggup runtime change. It is not acceptable to adopt unpublished Eggup Git/path code as production or to permit `wg-basic` release CI to drift to a dependency different from the frozen installed binary. + +The M010 applicability decision is complete: this release plan is required to deliver the qualified behavior to registry-only consumers. + +## 3. Invariants + +- This plan never silently changes M010's reviewed service API or behaviour. Any regression first returns to M010. +- `eggup-service` remains compatible with `eggup-core ^0.1.0` and Rust 1.89; run an external, registry-only fixture to prove exact resolution of the published core 0.1.3 graph. +- All other crates preserve their existing published identity/source/version. Workspace version `0.1.3` is not authority to republish already-published core/archive/acquisition/eggpack crates. +- Do not move old `v0.1.2` or `v0.1.3` tags. If service source ships from a later commit, record package-specific source provenance, SHA, checksum and registry identity precisely. +- No automatic publication. An explicit maintainer-authorized crates.io publish operation is a separate irreversible boundary. +- No breaking enum variant or public signature change masquerading as `0.1.3`. Preserve exhaustive-match consumer compatibility and the no-unsafe rule. + +## 4. Ordered work packages + +1. Retrieve Service M010 strict closure evidence and exact implementation commit, full native/negative test matrix, API diff and affected platform list. +2. Inspect crates.io for `eggup-service` current versions, publish ownership and exact `0.1.3` absence. If `0.1.3` is already occupied, stop/replan next version with compatibility evaluation; do not republish or silently bump workspace/other crates. +3. Make the source changelog clearly identify the behavior correction and M010 runtime source revision. The exact release-prep commit must also be captured by packaged `.cargo_vcs_info.json`. Ensure package manifest exposes the expected version and dependency graph without Git/path replacement in packaged output. +4. Run `cargo package -p eggup-service --list --locked`, `cargo package -p eggup-service --locked`, `cargo publish -p eggup-service --dry-run --locked`, and the external registry-only fixture. Before publication, fixture must still resolve 0.1.2 and the privileged systemd negative control must demonstrate the failed-case limitation. Build/verify the packaged crate on Linux, macOS, Windows, and Rust 1.89 CI lanes. +5. Require hosted Stable + Rust 1.89 MSRV + macOS + Windows CI green at the exact candidate SHA. Re-run service real-systemd matrix or obtain an equally recent immutable qualified run on the same source. +6. Obtain explicit maintainer authorization; publish **only eggup-service** to crates.io. Completed 2026-10-09. +7. Verify registry checksum/source metadata, direct external `eggup-service = "=0.1.3"` dependency and a positive proof of owned failed-unit quiescence. Verify other published crates and existing tags untouched. +8. Write exact version+checksum+API migration handoff to `dbowm91/wg-basic` M004 C001a. Reconcile current Eggup roadmap, registry, changelog and release notes without rewriting historical service M009 closure. + +## 5. Failure, restart, and contention + +Publishing is immutable. On ambiguous registry result after an attempted publish, query the registry and package checksum before retrying; never assume timeout means no artifact exists. No live host services, install receipts or artifact bytes are mutated by release qualification. If core ABI compatibility, platform behaviour or ownership proof changes during package reconstruction, block and return to M010. + +## 6. Public API and platform compatibility + +No public enum variant changes. No loss of `ServiceManager` or `SystemdManager` methods, no new mandatory features/third-party dependencies. Cross-platform source compatibility for Unix non-systemd/macOS/Windows must be verified with the exact packaged crate, not merely workspace tests. + +## 7. Tests and broad verification + +```text +git status --porcelain +git rev-parse HEAD +cargo fmt --all -- --check +cargo clippy --workspace --all-targets --all-features --locked -- -D warnings +cargo test -p eggup-service --all-targets --all-features --locked +cargo test --workspace --all-targets --all-features --locked +cargo doc --workspace --no-deps --locked +cargo +1.89.0 check --workspace --all-targets --locked +cargo package -p eggup-service --list --locked +cargo package -p eggup-service --locked +cargo publish -p eggup-service --dry-run --locked +cargo fmt --manifest-path crates/eggup-service/tests/published-api-0.1.2/Cargo.toml -- --check +cargo check --manifest-path crates/eggup-service/tests/published-api-0.1.2/Cargo.toml --locked +cargo test --manifest-path crates/eggup-service/tests/published-api-0.1.2/Cargo.toml --locked -- --nocapture +sudo env EGGUP_SYSTEMD_INTEGRATION=1 cargo test --manifest-path crates/eggup-service/tests/published-api-0.1.2/Cargo.toml --locked -- --nocapture +sudo env EGGUP_SYSTEMD_INTEGRATION=1 cargo test -p eggup-service --test systemd_failed_service --locked -- --nocapture +cargo tree --manifest-path crates/eggup-service/tests/published-api-0.1.2/Cargo.toml --locked +cargo fmt --manifest-path crates/eggup-service/tests/published-api-0.1.3/Cargo.toml -- --check +cargo check --manifest-path crates/eggup-service/tests/published-api-0.1.3/Cargo.toml --locked +cargo test --manifest-path crates/eggup-service/tests/published-api-0.1.3/Cargo.toml --locked -- --nocapture +sudo env EGGUP_SYSTEMD_INTEGRATION=1 cargo test --manifest-path crates/eggup-service/tests/published-api-0.1.3/Cargo.toml --locked -- --nocapture +git diff --check +``` + +The compatibility fixture at `crates/eggup-service/tests/published-api-0.1.2/` +resolves `eggup-service = "=0.1.2"` and `eggup-core` purely from the registry, +records registry sources in its lockfile, and matches the non-exhaustive public +enum with a wildcard. Its privileged Linux integration test proves the old +failed-unit stop limitation. The packaged candidate itself is built by +`cargo package` in Stable/Linux, MSRV 1.89, macOS, and Windows CI jobs. After +publication, add a fresh external fixture at the exact version and test +positive failed-unit quiescence plus Foreign/malformed controls. Log exact +checksum, package byte size, and source revision. The external fixture and +hosted systemd run are now required for closure. + +## 8. Acceptance criteria + +Exact reviewed service correction is published under an unused immutable version; checksum/provenance and registry-only test pass; no other crate/tag changes; supported platform/MSRV tests pass; downstream adoption version is explicit; release/security policy is unchanged. + +## 9. Stop conditions + +Version occupied, publish authority absent, registry-only fixture fails, source/package drift, significant native failure, public API break, workspace version train conflict, or an attempt to move `v0.1.3`. Classify publication as `blocked` when authorization is absent; do not mark the release plan closed before registry verification and downstream handoff. + +## 10. Closure evidence and handoff + +After publication only, write `plans/closure/service-lifecycle/011-status.md` with M010 closure SHA, package/commit/version/checksum, registry preflight, exact gates, downstream fixture, operator authorization result, supported-platform matrix, tag integrity, known limitations, and `wg-basic` adoption pointer. This is a release step, not consent to auto-publish wg-basic itself. diff --git a/plans/registry.md b/plans/registry.md index a8aa36a..a4a4bab 100644 --- a/plans/registry.md +++ b/plans/registry.md @@ -2,7 +2,7 @@ Status: active -Last implementation/closure baseline reviewed: `bd43683` (the 0.1.3 release train: M010 acquisition published from `bb8fe41`; Core M012/M013, Acquisition M011, Archive M004, and Eggpack M005 published from `bd43683`; hosted runs `37525705132` and `37527706900` green on Stable/MSRV/macOS/Windows; `v0.1.3` + GitHub Release `0.1.3` created) +Last implementation/closure baseline reviewed: `2fbb3c6f75ae536b53a7d30087c0b0edef7c74ec` (Service M011 post-publication fixture and test-harness correction; final hosted run `37883703334` green; package source `feb6ae5`, checksum `9f7f7ea854577158e66aa202709ab1c97a3aedcf00b06c1ab914d25b132124dc`). Downstream handoff refreshed 2026-10-09 against `dbowm91/wg-basic@ff40f85`. Superseded baseline: `44d7fdf6d31d67a2e2c8b0f62aa4f00ec365daeb` (Core M010/M011 final hosted-qualified line; run `37376971555` green on Stable/MSRV/macOS/Windows; subsequent `44d7fdf6` is docs-only governance correction) @@ -14,6 +14,13 @@ Latest registration reconciliation before this header refresh: `8f1d10db370c0fda Newest qualified Eggup runtime delta with fully green hosted qualification is the Core M010/M011 corrective line, final run `37376971555` green on Stable/MSRV/macOS/Windows. M010/M011 implementation began at `95f75678` and the Windows qualification wave fixed the missing cross-platform current-executable identity proof plus portability defects before final closure. Earlier M003a implementation `39ff6260` remains historical adapter evidence. Runtime commits have landed after `39ff626`: `git log 39ff626..HEAD -- crates/` returns `e548b64` (eggpack 0.1.2 registry promotion), `0b8cb98` (workspace bug-audit fixes across `eggup-acquisition`/`eggup-archive`/`eggup-core`), `b485228` (eggup-curl 0.1.2 changelog cut), and `4a95e4d` (docs reconciliation touching `crates/eggup-service/CHANGELOG.md` only). The two `0b8cb98` acquisition fixes were **published on 2026-10-06** as `eggup-acquisition 0.1.3`; `^0.1.0` consumers (curl, eggfetch) and, since `eggup-eggpack 0.1.3`, adapter consumers now receive them automatically. The historical note that they were unpublished is superseded; the 0.1.2-era caveat remains recorded for readers of that version. M003 Eggsact real-consumer adoption is closed at consumer `eggstack/eggsact@65c916ba3b0f02916203ec1aad09d7e5c023c278` on Eggup pin `e336b32` (hosted CI run `36902758482` + drift run `36902758396` green). The M009 release-prep head `e8e07eb538d0eef18ea4cb4ace3bb905c316da72` (run `36487099388` green) remains the provenance for the published `eggup-core`/`eggup-archive 0.1.2` pair, not the latest qualified runtime. Code qualification was established at `9a5500e` (M002a clippy + Windows-adapter head; run `36477024102` green, superseding failed run `36463041223`); Core M008a reran the exact clean-tree package/publish-dry-run evidence on the post-M002a tree with no material delta. Planning-hygiene C009 corrected the stale Consumer M006 claim: current `eggstack/eggress@03134f8` has both the updater surface and registered Delivery M003 plan. Eggup M009 published the compatible 0.1.2 pair on 2026-09-28; Egress M006 subsequently closed on 2026-09-29 after Egress Delivery M003 landed with hosted Linux/macOS/Windows updater evidence. The prior Eggpack cross-repo drift is now reconciled: Eggpack interoperability M003 records the downstream closure, and Eggpack Release Manifest M003 is closed: `eggpack-manifest 0.1.0` is published to crates.io from Eggpack `8d661e4` (checksum `2a08f24b…b629`, tag `eggpack-manifest-v0.1.0`, closure `eggstack/eggpack: plans/closure/release-manifest/003-status.md`). +The newest service runtime correction is M010 at `0bde3fe`, with run +`37875012280` green including Linux systemd. M011 published `eggup-service +0.1.3` from source `feb6ae5`; the 72.7 KiB package checksum is +`9f7f7ea854577158e66aa202709ab1c97a3aedcf00b06c1ab914d25b132124dc`. The +pre-publication head `f65496f` passed run `37876276212`; post-publication exact +version/systemd proof passed run `37883703334`, closing M011. + This file is the compact control surface for active Eggup planning. Detailed requirements live in the linked plans and roadmaps. ## Canonical documents @@ -47,7 +54,7 @@ Eggup owns consumer-side acquisition, verification, candidate validation, local |---|---|---| | Verified update core | M001-M013 closed; `eggup-core 0.1.3` published 2026-10-06; hosted runs `37376971555` and `37527706900` green on Stable/MSRV/macOS/Windows | `plans/closure/verified-update-core/` | | Acquisition transport | M001-M011 closed; M009 published `eggup-curl 0.1.2` (2026-10-04), M010 published `eggup-acquisition 0.1.3` (2026-10-06), M011 published `eggup-eggfetch 0.1.3` (2026-10-06); M012 registered, `ready for handoff` | `plans/closure/acquisition-transport/` | -| Service lifecycle | M001-M009 closed; `eggup-service 0.1.2` published 2026-10-05 | `plans/closure/service-lifecycle/` | +| Service lifecycle | M001–M011 closed; `eggup-service 0.1.3` published 2026-10-09 | `plans/closure/service-lifecycle/` | | Archive extraction | M001 lineage + M001d closed; M004 published `eggup-archive 0.1.3` 2026-10-06 | `plans/closure/archive-extraction/` | | Eggpack manifest interoperability | M001-M005 all closed; M004 published the 0.1.2 triple, M005 published `eggup-eggpack 0.1.3` 2026-10-06 with the member-identity cross-check | `plans/closure/eggpack-manifest-interoperability/` | | Distribution/bootstrap (archived/transferred) | M001-M004 | `plans/closure/distribution-bootstrap/` | @@ -65,7 +72,7 @@ Published 0.1.1 crates (lockstep patch superseding 0.1.0): Published `0.1.2` set on crates.io — **all seven published crates**, in four steps: `eggup-core`, `eggup-archive` (2026-09-28); `eggup-acquisition`, `eggup-eggfetch`, `eggup-eggpack` (2026-10-02); `eggup-curl` (2026-10-04); `eggup-service` (2026-10-05, from `7fb84bc`, registry id `3411496`, checksum `c6288eb1…50e3f`). `eggup-service` was published later from a different source commit than the shared `v0.1.2` tag; the tag still denotes the core/archive publication source and was not moved. `eggup-transport-footprint` is `publish = false` by design and has no registry version. -Published `0.1.3` set on crates.io — **five crates, two source commits**, all published 2026-10-06: +Initial `0.1.3` train — **five crates, two source commits**, published 2026-10-06: | Package | Published from | Registry checksum | |---|---|---| @@ -78,11 +85,12 @@ Published `0.1.3` set on crates.io — **five crates, two source commits**, all `eggup-acquisition` had to publish first because the other four depend on it — `eggpack` exact-pins it and the others resolve it as a caret requirement — so it was released from the earlier ancestor `bb8fe41` rather than the tag commit. -`eggup-curl` and `eggup-service` remain at `0.1.2`; both now receive the -acquisition and core fixes automatically through their caret requirements, proven -from the registry with no `[patch]`, path, or Git override. `v0.1.3` and GitHub -Release `0.1.3` were created after the registry proofs; `v0.1.1`/`v0.1.2` and -release `0.1.2` were not moved. `eggup-transport-footprint` remains +`eggup-curl` remains at `0.1.2` and receives the acquisition/core fixes through +its caret requirements. Service M011 separately published `eggup-service +0.1.3` on 2026-10-09 from `feb6ae5` (checksum +`9f7f7ea854577158e66aa202709ab1c97a3aedcf00b06c1ab914d25b132124dc`); it extends +GitHub Release `0.1.3` without moving the shared tag `v0.1.3`. `v0.1.1`/`v0.1.2` +and release `0.1.2` were not moved. `eggup-transport-footprint` remains `publish = false`. `eggup-dist` was unpublished and existed only as migration predecessor evidence. It was removed after Eggpack Contract M002 qualified the complete M003 behavior; see `plans/closure/distribution-bootstrap/004-status.md`. @@ -156,7 +164,7 @@ The 2026-10-05 Gregg/EggPool parity gaps are now **fully closed**. Core M010/M01 |---|---|---| | Verified update core | M001-M013 closed/hosted-green (`37527706900`) | — (`eggup-core 0.1.3` published; the 0.1.x compatibility gate is discharged) | | Acquisition transport | M001-M011 closed; acquisition/eggfetch 0.1.3 published, curl 0.1.2 published; M012 registered | M012 sub-second deadline test-determinism corrective — test-only, no dependency and no publication; closes post-0.1.3 open finding 1 | -| Service lifecycle | M001-M009 closed; `eggup-service 0.1.2` published 2026-10-05 | — (service substrate now resolvable from the registry) | +| Service lifecycle | M001–M011 closed | M010 closed with a required runtime correction; M011 0.1.3 published and registry-only post-publication systemd proof passed | | Archive extraction | M001 lineage + M004 closed; `eggup-archive 0.1.3` published 2026-10-06 | — | | Distribution/bootstrap | archived/transferred; M001-M004 closed | no further Eggup producer work | | Eggpack manifest interoperability | M001-M005 closed; `eggup-eggpack 0.1.3` carries the member-identity cross-check | — | @@ -171,6 +179,8 @@ The 2026-10-05 Gregg/EggPool parity gaps are now **fully closed**. Core M010/M01 | Verified update core | M012 0.1.x public-error compatibility corrective | closed | `plans/implementation/verified-update-core/012-0.1x-public-error-compatibility-corrective.md`; `plans/closure/verified-update-core/012-status.md` | `Error` keeps the seven published 0.1.2 variants; `RecoveryError` added for retained evidence; byte-identical exhaustive-match fixture fails against pre-M012 main | | Verified update core | M013 eggup-core 0.1.3 publication | closed 2026-10-06 | `plans/implementation/verified-update-core/013-eggup-core 0.1.3-publication.md`; `plans/closure/verified-update-core/013-status.md` | published from `bd43683` (run `37527706900` green); `v0.1.3` + release created; registry-only direct fixture and the `eggup-service 0.1.2 -> eggup-core 0.1.3` graph both green | | Service lifecycle | M009 eggup-service 0.1.2 publication | closed 2026-10-05 | `plans/implementation/service-lifecycle/009-eggup-service-0.1.2-publication.md`; `plans/closure/service-lifecycle/009-status.md` | published from `7fb84bc`; registry checksum matches locally built `.crate`; registry-only fixture 10/10; no `src/` change; `v0.1.2` unmoved | +| Service lifecycle | M010 owned failed-systemd quiescence corrective | closed | `plans/implementation/service-lifecycle/010-owned-failed-systemd-service-quiescence-corrective.md`; `plans/closure/service-lifecycle/010-status.md` | Runtime correction required; hosted run `37875012280` green on all lanes including real systemd auto-restart race; residual cgroup task correctly remains incomplete | +| Service lifecycle | M011 qualified service patch publication | closed 2026-10-09 | `plans/implementation/service-lifecycle/011-verified-service-patch-publication.md`; `plans/closure/service-lifecycle/011-status.md` | Published from `feb6ae5`, checksum `9f7f7ea8…32124dc`; final hosted run `37883703334` green; release extended and package asset attached | | Acquisition transport | M009 eggup-curl 0.1.2 publication | closed 2026-10-04 | `plans/implementation/acquisition-transport/009-eggup-curl-0.1.2-publication.md`; `plans/closure/acquisition-transport/009-status.md` | published from `b485228`, hosted run `37223895075` green on all lanes; registry-only fixture 6/6 with registry-source lockfile; no `src/` change; `v0.1.1`/`v0.1.2` unmoved, release `0.1.2` notes extended; M007 Windows live-loopback limitation retained | | Acquisition transport | M010 eggup-acquisition 0.1.3 publication | closed 2026-10-06 | `plans/implementation/acquisition-transport/010-eggup-acquisition-0.1.3-publication.md`; `plans/closure/acquisition-transport/010-status.md` | published from `bb8fe41` (run `37525705132` green); registry-only fixture 4/4 and fails 2/4 against the defective 0.1.2 | | Acquisition transport | M011 eggup-eggfetch 0.1.3 correctness publication | closed 2026-10-06 | `plans/implementation/acquisition-transport/011-eggup-eggfetch-0.1.3-correctness-publication.md`; `plans/closure/acquisition-transport/011-status.md` | published from `bd43683` (run `37527706900` green); registry-only fixture 4/4 and **aborts the process** against 0.1.2 | @@ -377,7 +387,7 @@ The earlier 2026-09-26 review opened acquisition M007 and service M007; those ar - Rust baseline: 1.89. - Core: M001-M009 are closed and the 0.1.2 core/archive pair remains published. Current consumer-parity research registers M010 (current-executable authority + Windows running-image rollback) and M011 (proof-authorized stale-lock recovery) as ready. A later Core package/publication milestone is intentionally unwritten until both close. - Acquisition: M001-M006 are closed; M007 is conditionally closed. M008 sub-second deadline truthfulness is closed via hosted run `36222536670`, which executed the Windows portable acquisition/curl tests after Archive M001b restored the Windows lane. **M009 closed 2026-10-04**: `eggup-curl 0.1.2` was published from release-prep commit `b485228` (checksum `79df200f…b465`, 17193 bytes) after hosted run `37223895075` passed Stable/MSRV/macOS/Windows. `cargo package` compiled the package against the registry-downloaded `eggup-acquisition 0.1.2`, and an external registry-only fixture passed 6/6 with one registry source per package and no git or path entry. No `src/` byte changed, no tag was moved, and the M007 Windows live-loopback limitation is retained rather than upgraded. M010 is now the next dependency-ready milestone: it republishes the seam as `eggup-acquisition 0.1.3` carrying the two `0b8cb98` fixes that published `0.1.2` lacks. -- Service: M001-M009 are closed. `eggup-service 0.1.2` was published 2026-10-05 and its former release-order gate on Acquisition M010 is satisfied. +- Service: M001-M011 are closed. `eggup-service 0.1.2` was published 2026-10-05 and its former release-order gate on Acquisition M010 is satisfied. M010's owned failed-systemd quiescence correction is published as `0.1.3` from `feb6ae5`; checksum and post-publication systemd proof are in the M011 closure. wg-basic adopted the exact `0.1.3` registry package and closed M004 technically, then closed M005/Phase 10; only production signing/publication remains externally blocked. See the downstream status addendum in the M011 closure. - Distribution: M001-M003 remain historical predecessor evidence; M004 removed the producer crate after Eggpack Contract M002 closure. The subsystem is archived/transferred to Eggpack. - Consumer adoption: Gregg M004 remains intentionally unwritten until Acquisition M010 and Core M012/M013 close. EggPool M007 remains intentionally unwritten until Core M012/M013 close; only its StandaloneRust transaction is in scope and package-manager/provenance paths stay downstream. Egress M006 is closed 2026-09-29 (Egress Delivery M003 landed on the registry 0.1.2 pair; M003-landed addendum in `plans/closure/consumer-adoption/006-status.md`). - Archive extraction: the runtime/extraction line is closed through M003; M004 is registered to publish the already-implemented 0.1.3 correctness fixes once workspace 0.1.3 exists. @@ -387,7 +397,7 @@ The earlier 2026-09-26 review opened acquisition M007 and service M007; those ar ## Next handoff -The next handoff is a bounded 0.1.3 release train. **Core M012** is the immediate source/API corrective: remove the two unpublished breaking additions from the old public `Error` surface while retaining typed stale-recovery evidence through a new recovery-specific API. **Acquisition M010** is independently ready and establishes workspace 0.1.3 while publishing the two acquisition fixes. **Core M013** then publishes the versioned M010/M011 substrate and must prove fresh `eggup-service 0.1.2 -> eggup-core 0.1.3` resolution. After that, Gregg M004 and EggPool M007 become authorable. Non-blocking release hygiene follows as Archive M004 and Acquisition M011, then Eggpack Interop M005 once its exact core/archive/acquisition 0.1.3 pins exist. Eggpack M005 is security-relevant because registry `eggup-eggpack 0.1.2` still carries the positional archive-member binding defect. +The bounded 0.1.3 release train, including Service M011 publication and closure, is complete. wg-basic Distribution M004 C001a adopted `eggup-service = "=0.1.3"` (source `feb6ae5`, checksum `9f7f7ea854577158e66aa202709ab1c97a3aedcf00b06c1ab914d25b132124dc`) and now has formal technical closures for M004, M005, and Phase 10; production signing/publication remains externally blocked. Its Phase 11 work is also closed, and wg-basic's registry reports no active implementation plan (Phase 12 is deferred). No new Eggup implementation plan became ready from this downstream closure. Acquisition M012 remains independently ready and unchanged. Do not author or implement an Eggup installer generator. Keep producer behavior in Eggpack and archive extraction outside the adapter. M004a is closed (qualification/package-simulation only; nothing published); M004 is implemented, qualified, and closed; do not re-open it or re-publish its `0.1.2` versions. The `eggpack-manifest` producer item was discharged by Eggpack Release Manifest M003 and consumed by M004's registry pin. Do not duplicate producer ownership in Eggup. M009 is likewise closed: do not re-publish `eggup-curl 0.1.2` or any other published `0.1.2` version, and do not move `v0.1.1`/`v0.1.2`. M010 publishes a new `0.1.3` version of the seam only; it does not re-open M009 or M004. diff --git a/plans/subsystems/service-lifecycle-roadmap.md b/plans/subsystems/service-lifecycle-roadmap.md index 1d8b41b..7cf564c 100644 --- a/plans/subsystems/service-lifecycle-roadmap.md +++ b/plans/subsystems/service-lifecycle-roadmap.md @@ -1,6 +1,6 @@ # Service Lifecycle Roadmap -Status: active; M001-M009 closed; `eggup-service 0.1.2` published 2026-10-05 +Status: active; M001–M011 closed; `eggup-service 0.1.3` published 2026-10-09; downstream wg-basic M004 and M005 technical work closed; production signing/publication remains externally blocked Long-term references: @@ -116,9 +116,14 @@ M006 daemon disposition + revalidation [closed; evidence reconciled via acquisit M008 deadline-test determinism [CLOSED via run 36332823865] | v - M009 eggup-service 0.1.2 publication [READY] - | - `--> Acquisition M010 workspace 0.1.3 bump may proceed + M009 eggup-service 0.1.2 publication [CLOSED] + | | + | `--> Acquisition M010 workspace 0.1.3 bump + v + M010 failed-systemd quiescence [CLOSED; runtime change] + | + v + M011 service 0.1.3 release [CLOSED; published 2026-10-09] ``` ## 7. Milestones @@ -200,6 +205,24 @@ Publish the already-qualified M001-M008 service substrate without runtime/source M009 must preserve the existing `v0.1.2` tag as the historical core/archive publication source; service 0.1.2 is a later package publication from its own recorded commit and is documented additively. +### M010 — Owned failed-systemd service quiescence corrective + +Plan: `plans/implementation/service-lifecycle/010-owned-failed-systemd-service-quiescence-corrective.md`. + +Status: **closed**; see `plans/closure/service-lifecycle/010-status.md`. + +A real wg-basic failed-candidate recovery identified that systemd `ActiveState=failed` is mapped to generic `LifecycleState::Unknown`; the wg-basic adapter refuses this state before calling Eggup stop and Eggup's stop completion accepts only `inactive`. First build a discriminating real-systemd fixture: a failed unit may or may not converge to inactive after stop, and failure is not proof of quiescence. Implement the minimum portable source-compatible ownership-safe quiescence operation actually needed; do not add a public closed-enum `Failed` variant or treat all Unknown as Stopped. Recheck exact service owner, inspect manager/process state and preserve restart/deadline/foreign refusal invariants. + +M010 found and fixed an upstream runtime defect. On systemd 255, a successful stop left an exact-owned failed service reported as `failed`, so the former inactive-only poll could not complete. The implementation now proves post-stop ownership, manager state, job/process evidence, cgroup quiescence when present, and consistent `is-active` output. A live child in the cgroup remains incomplete, and a changed-ExecStart control is denied. The hosted Linux systemd lane and Stable/MSRV/macOS/Windows matrix are green; see the M010 closure for exact evidence. + +### M011 — Conditional published service patch for wg-basic + +Plan: `plans/implementation/service-lifecycle/011-verified-service-patch-publication.md`. + +Status: **closed; published 2026-10-09**. M010 closed with a required runtime change, so this plan was required. Pre-publication head `f65496f` passed hosted run `37876276212`; post-publication exact-version fixture and full five-job run `37883703334` also passed. + +`eggup-service 0.1.3` was published from source `feb6ae5aea4c9b61c4051957f3662ca49d845f9e`, checksum `9f7f7ea854577158e66aa202709ab1c97a3aedcf00b06c1ab914d25b132124dc`. Registry-only exact-version and post-publication systemd proof passed in run `37883703334`. The existing shared `v0.1.3` tag and all other crate identities remain unchanged. The GitHub release carries the package and an exact wg-basic M004 C001a dependency/checksum handoff. wg-basic adopted the exact registry package and subsequently closed M004 technically, then closed M005 and Phase 10; current hosted evidence and the remaining production signing/publication gate are recorded in the dated addendum to the M011 closure. + ## 8. Cross-cutting requirements No destructive action on Foreign/Unknown. Permission errors return remediation rather than escalating. Service definition rendering must reject unsafe control characters/path ambiguity. @@ -214,7 +237,7 @@ System-level versus user-level service registration differs across consumers. Us ## 11. Completion definition -Manager mechanics remain shared by service-bearing consumers without losing application-specific policy. M006 additionally requires product-neutral reference parity for mature daemon-update dispositions without downstream migration. M007 closed the bounded-diagnostic panic gap. M008 closed the deadline-arithmetic determinism gap with a fresh green hosted matrix. M009 is now registered to publish the already-qualified 0.1.2 service package before the workspace advances to 0.1.3. +Manager mechanics remain shared by service-bearing consumers without losing application-specific policy. M006 additionally requires product-neutral reference parity for mature daemon-update dispositions without downstream migration. M007 closed the bounded-diagnostic panic gap. M008 closed the deadline-arithmetic determinism gap with a fresh green hosted matrix. M009 published the 0.1.2 package; M010 closed the owned failed-systemd quiescence defect with a source-compatible runtime correction. M011 published 0.1.3; its closure records registry-only post-publication evidence and the wg-basic version/checksum handoff. ## 12. Milestone status @@ -229,3 +252,5 @@ Manager mechanics remain shared by service-bearing consumers without losing appl | M007 | closed | `plans/implementation/service-lifecycle/007-utf8-safe-bounded-diagnostics-corrective.md` | `plans/closure/service-lifecycle/007-status.md` | — | | M008 | closed | `plans/implementation/service-lifecycle/008-operation-deadline-test-determinism-corrective.md` | `plans/closure/service-lifecycle/008-status.md` | — | | M009 | closed | `plans/implementation/service-lifecycle/009-eggup-service-0.1.2-publication.md` | `plans/closure/service-lifecycle/009-status.md` | — (published 2026-10-05 from `7fb84bc`; registry-only fixture 10/10; `v0.1.2` unmoved; no `src/` change). Unblocks the Acquisition M010 workspace bump | +| M010 | closed — runtime corrective | `plans/implementation/service-lifecycle/010-owned-failed-systemd-service-quiescence-corrective.md` | `plans/closure/service-lifecycle/010-status.md` | run `37875012280` green on Stable/MSRV/macOS/Windows and real Linux systemd including auto-restart race; runtime change required | +| M011 | closed; published 2026-10-09 | `plans/implementation/service-lifecycle/011-verified-service-patch-publication.md` | `plans/closure/service-lifecycle/011-status.md` | Source `feb6ae5`, checksum `9f7f7ea8…32124dc`; hosted run `37883703334` green; GitHub release extended without moving `v0.1.3` |