Skip to content

fix(minimal): finalize-install replaces a stale or failing installed minzoned, and min ls names - #3481

Draft
minimal-foundry[bot] wants to merge 7 commits into
mainfrom
agent/3474-finalize-install-replaces-a-stale-or-failing-ins
Draft

minimal-foundry[bot] wants to merge 7 commits into
mainfrom
agent/3474-finalize-install-replaces-a-stale-or-failing-ins

Conversation

@minimal-foundry

Copy link
Copy Markdown
Contributor

Defect

Fixes #3474

  • Epic: none; not charged to an epic
  • Size: M; estimated 220 code, 200 tests
  • May touch:
    • crates/minimal/src/resolver.rs
    • crates/minimal/src/cmd/finalize_install.rs
    • crates/minimal/src/cmd/list.rs
    • crates/minimal/src/cmd/boxes/vm_host.rs
    • scripts/install.sh
    • scripts/install_test.sh
Task marker
### D3472 — finalize-install replaces a stale or failing installed minzoned, and min ls names Minimal's failing DNS service
  kind: task
  size: M
  est: 220 code, 200 tests
  executor: agent
  defect: bug
  layers:
    - resolver:
      - crates/minimal/src/resolver.rs: answerer_step_over compares the installed copy's SHA-256 with the shipped minzoned and reads the launchd job state; a different or failing copy is a new step that reinstalls; a line for a loaded job that is not running
      test: cargo test -p minimal answerer_step_over_reinstalls_a_copy_that_differs_from_the_shipped_minzoned
      test: cargo test -p minimal answerer_step_over_reinstalls_a_job_that_keeps_exiting
      test: cargo test -p minimal vm_host_answerer_line_names_a_failing_dns_service
    - cli:
      - crates/minimal/src/cmd/finalize_install.rs: names_item_on_this_host offers the answerer reinstall step when the port is held with no channel and the installed service is stale or not running, and does not report waiting
      - crates/minimal/src/cmd/list.rs: the DNS SERVICE line says Minimal's DNS service is not running and names min finalize-install when the dev.gominimal.zone job holds the port
      - crates/minimal/src/cmd/boxes/vm_host.rs: uses the same failing-service wording as min ls for the DNS service line
      test: cargo test -p minimal finalize_install_show_offers_reinstall_for_a_failing_answerer
    - installer:
      - scripts/install.sh: offer_finalize_install offers the step when an upgrade ships a minzoned that differs from the installed copy
      - scripts/install_test.sh: adds a case where the probe reports a stale answerer copy and the installer offers finalize-install
      test: bash scripts/install_test.sh
  proof: After an upgrade that ships a new minzoned, min finalize-install --show prints a script that replaces the installed copy, and min ls names the failing DNS service and the command that fixes it.

Proof

After an upgrade that ships a new minzoned, the installed DNS service reads as stale (its SHA-256 differs from the shipped minzoned) or failing (its dev.gominimal.zone or minzoned.service job is loaded but not running). min finalize-install --show then lists the names item as missing, not waiting, and --show --script prints a script that copies the pinned shipped minzoned over the installed copy. When that job holds 127.0.0.1:7656 and is not running, min ls and the session start print: "box names are not answered: Minimal's DNS service holds 127.0.0.1:7656 (UDP) but is not running. Run min finalize-install to reinstall it." The installer offers min finalize-install when the shipped minzoned differs from the installed copy.

Notes from the agent: New AnswererStep states: CopyDiffers and NotRunning. AnswererFacts gains installed_sha256, shipped_sha256 and job. The job state comes from launchctl print system/dev.gominimal.zone on macOS, or from systemctl show minzoned.service on Linux. The read has a 1 s bound and returns Unknown when it times out. An inactive, socket-activated systemd service claims nothing. finalize-install also offers the reinstall when no daemon reports a port at all and the installed service is stale or failing. It uses the service's fixed port 7656 for this. Without that, the installer probe, which runs with no daemon, never gets a script for a stale copy. The list.rs and vm_host.rs line goes through resolver::dns_service_line_on_this_host. That function runs the blocking job read only for a port held with no channel at 7656, so create.rs (outside the layers) needs no change. The new printed text is not fixed in the task: the failing-service DNS SERVICE line, the two finalize-install facts and the two installer lines. Review them. 'Run min finalize-install to reinstall it' is true only when the copy source verifies. When it does not, finalize-install says why it leaves the DNS service out. Not verified on macOS: this box is Li…[truncated]

Tests

line exit tail
cargo test -p minimal answerer_step_over_reinstalls_a_copy_that_differs_from_the_shipped_minzoned 0 running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 41 filtered out; finished in 0.00s running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 15 filtered out; finished in 0.00s running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 meas
cargo test -p minimal answerer_step_over_reinstalls_a_job_that_keeps_exiting 0 running 1 test test resolver::tests::answerer_step_over_reinstalls_a_job_that_keeps_exiting ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 983 filtered out; finished in 0.00s running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 41 filtered out; finishe
cargo test -p minimal vm_host_answerer_line_names_a_failing_dns_service 0 running 1 test test resolver::tests::vm_host_answerer_line_names_a_failing_dns_service ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 983 filtered out; finished in 0.00s running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 41 filtered out; finished in
cargo test -p minimal finalize_install_show_offers_reinstall_for_a_failing_answerer 0 running 1 test test cmd::finalize_install::tests::finalize_install_show_offers_reinstall_for_a_failing_answerer ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 983 filtered out; finished in 0.00s running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 41 f
bash scripts/install_test.sh 0 bare answerer ok - darwin upgrade to the bundle exits 0 ok - darwin: the upgrade installs the bundle ok - darwin: the upgrade removes the answerer's old path ok - darwin: the installer says what it removed ok - darwin: the removed path is no longer recorded ok - darwin install back to th

Verify

min task run agent-verify exited 100, so this PR is a draft.

 {
                "parent_span_id": "44208a59af0f2cdf",
                "rpc": "minimald-v1-GetSessionRecord",
                "span_id": "e2fdcc1446035521",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "e2fdcc1446035521",
                "queued_behind": "0",
                "span_id": "6acf027b095497dc",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "rpc",
            fields: {
                "parent_span_id": "44208a59af0f2cdf",
                "rpc": "minimald-v1-DestroySession",
                "span_id": "a12435fe392a8dca",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "a12435fe392a8dca",
                "queued_behind": "0",
                "span_id": "0c9d455860175ab9",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "DeleteSession",
                "parent_span_id": "a12435fe392a8dca",
                "queued_behind": "0",
                "span_id": "5af6aefe462a2bee",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "session.message",
            fields: {
                "kind": "Destroy",
                "parent_span_id": "5af6aefe462a2bee",
                "span_id": "285172fd8042c844",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "HandOverName",
                "parent_span_id": "5af6aefe462a2bee",
                "queued_behind": "0",
                "span_id": "6439efaa07320fad",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
    ]
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

  Cancelling due to test failure: 
────────────
     Summary [  83.622s] 1151 tests run: 1150 passed, 1 failed, 2 skipped
        FAIL [  13.135s] (1151/1151) minimal::otel_cli exec_run_attach_and_task_run_share_the_commands_trace
error: test run failed

Base

The base branch moved while the coder worked; it was merged in before the tests ran.

answerer_step_over compares the installed minzoned's SHA-256 with the
shipped one and reads the service job state. A different copy or a
loaded job that is not running is a step that reinstalls the service.
The DNS service line names a failing service and min finalize-install.
When the port is held with no channel and the installed DNS service is
stale or not running, the names item offers the reinstall step and does
not report waiting. min ls and the session start name the failing
service and min finalize-install.
When an upgrade ships a minzoned that differs from the installed
root-owned copy, the installer offers the step the probe prints, or
names min finalize-install when the probe has no script to offer.
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f434c3ae-9ccd-461e-bb77-24f85ce3a201

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@norrietaylor

Copy link
Copy Markdown
Member

/revise

Review of head 19ede39. Fix these. Keep every change inside the plan's six files.

  1. Only name min finalize-install where it offers the reinstall.
    • scripts/install.sh (offer_finalize_install, the new _fi_stale branch): when the probe prints no script, the installer now says "To replace it, run min finalize-install" from its own hash check alone. Right after an upgrade no daemon runs, so the probe takes the "waiting on a daemon" path, and min finalize-install then has nothing to run.
    • Print the replace line only when a run of min finalize-install will actually carry the replace step. Otherwise keep the old "after your first min" line. Test both cases in install_test.sh, the darwin branch of answerer_copy_differs included.
  2. Run the stale and failing check on every path that reports the names item.
    • crates/minimal/src/cmd/finalize_install.rs (the no-daemon and 5 s daemon-read timeout branch, about lines 653-662) still returns "waiting" without it.
    • If a stale or failing copy is found there, offer the reinstall step.
  3. Keep min ls and the session-start line consistent with finalize-install.
    • The failing-service line (resolver.rs about 5051-5091) says "Run min finalize-install to reinstall it" whenever the job is not running.
    • finalize-install offers no script for CustodyFailed, or when the shipped copy is unavailable (SourceUnavailable).
    • Name the command only for the states where finalize-install --show prints a script. For the others, state the situation and stop, per AGENTS.md "Say only what the code can prove".
  4. Bound and clean up the service-state read.
    • launchctl print / systemctl (about resolver.rs 1265-1291) runs a blocking subprocess of up to 1 s from the min ls formatter, once per VM row. On timeout the child is not killed.
    • Kill the child on timeout. Read the state once per command, not once per row.
    • Keep the pure formatter tests (the PortHeldNoChannel cases about resolver.rs 6012) free of a real launchctl/systemctl call.
  5. Tests. In finalize_install_show_offers_reinstall_for_a_failing_answerer (finalize_install.rs about 2934-2946), the assertion that the script replaces the installed copy runs only when answerer_install returns Some. Make it unconditional with a fixture, and assert the replace command itself, not only the port.
  6. Wording. Split "holds 127.0.0.1:7656 (UDP) but is not running" into two sentences, one fact each. Update the tests that pin it.

min ls and the session start read the DNS service state once per
command, with a bounded read that kills a slow service manager. The
failing-service line names min finalize-install only when --show
prints the reinstall, and splits its facts into two sentences.
finalize-install offers the reinstall on the daemon-timeout path too.
The replace line prints only when the probe's script copies this
release's minzoned. A probe that waits on a daemon keeps the
come-back note. install_test.sh covers both, on Linux and macOS.
@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 1 of 10 on a /revise note, pushed as 4f0583ce2e08.

line exit tail
cargo test -p minimal answerer_step_over_reinstalls_a_copy_that_differs_from_the_shipped_minzoned 0 running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 41 filtered out; finished in 0.00s running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 15 filtered out; finished in 0.00s running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 meas
cargo test -p minimal answerer_step_over_reinstalls_a_job_that_keeps_exiting 0 running 1 test test resolver::tests::answerer_step_over_reinstalls_a_job_that_keeps_exiting ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1001 filtered out; finished in 0.00s running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 41 filtered out; finish
cargo test -p minimal vm_host_answerer_line_names_a_failing_dns_service 0 running 1 test test resolver::tests::vm_host_answerer_line_names_a_failing_dns_service ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1001 filtered out; finished in 0.00s running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 41 filtered out; finished in
cargo test -p minimal finalize_install_show_offers_reinstall_for_a_failing_answerer 0 running 1 test test cmd::finalize_install::tests::finalize_install_show_offers_reinstall_for_a_failing_answerer ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1001 filtered out; finished in 0.00s running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 41
bash scripts/install_test.sh 0 bare answerer ok - darwin upgrade to the bundle exits 0 ok - darwin: the upgrade installs the bundle ok - darwin: the upgrade removes the answerer's old path ok - darwin: the installer says what it removed ok - darwin: the removed path is no longer recorded ok - darwin install back to th

Verify min task run agent-verify exited 100.

 {
                "parent_span_id": "b3aebed3fad1caef",
                "rpc": "minimald-v1-GetSessionRecord",
                "span_id": "e1ac5199f403a714",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "e1ac5199f403a714",
                "queued_behind": "0",
                "span_id": "08200c0d359a8841",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "rpc",
            fields: {
                "parent_span_id": "b3aebed3fad1caef",
                "rpc": "minimald-v1-DestroySession",
                "span_id": "37ba2d304f685018",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "37ba2d304f685018",
                "queued_behind": "0",
                "span_id": "48c4d4972bb707c5",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "DeleteSession",
                "parent_span_id": "37ba2d304f685018",
                "queued_behind": "0",
                "span_id": "3679ce18e3341e49",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "session.message",
            fields: {
                "kind": "Destroy",
                "parent_span_id": "3679ce18e3341e49",
                "span_id": "70324bd57506c55f",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "HandOverName",
                "parent_span_id": "3679ce18e3341e49",
                "queued_behind": "0",
                "span_id": "765c63fef817169f",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
    ]
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

  Cancelling due to test failure: 
────────────
     Summary [  78.030s] 1169 tests run: 1168 passed, 1 failed, 2 skipped
        FAIL [  12.889s] (1169/1169) minimal::otel_cli exec_run_attach_and_task_run_share_the_commands_trace
error: test run failed

Converted to a draft: something above needs a person before review.

After an upgrade that ships a new minzoned, min finalize-install --show prints a script that copies the shipped minzoned over the installed copy. This is true when a daemon answers, when none runs, and when the daemon read times out. min ls and the session start name Minimal's failing DNS service. They name min finalize-install only when that command offers the reinstall. The installer names the replace only when the probe's script carries the copy.

Notes from the agent: Revise round 1, the six items of the /revise note. (1) install.sh prints the replace line only when the probe's script quotes this release's minzoned (or Minimal.app on macOS) as its copy source. A probe with no script keeps the 'after your first min' line. install_test.sh covers both on Linux and darwin, plus a script that carries no copy. The fake min can now print $HOME/finalize.script. (2) The daemon-read timeout path and the no-port path both go through reinstall_or_waiting. (3) New AnswererStep::reinstall_offered: SourceVerified over a stale or failing service, with answerer_install Some. finalize-install, min ls and the session start all use it. The line names min finalize-install only when it is true. Otherwise it states the situation and stops. (4) answerer_job_blocking spawns the child, polls it to a 1 s deadline, and kills and reaps it on timeout. min ls reads the state once per command into a new HostInstall.dns_service field. The formatters read that field, so tests.rs formatter calls with HostInstall::default() make no service-manager call. The session start (vm_host_answerer_start_line, called from create.rs, which is outside the layers) reads the state once, on its own thread and runtime, and only for the service port held with no channel. read_answerer_step_with_job lets that read reuse the job state. (5) The finalize-install test now expects the reinstall unconditionally and asserts the install -m copy line, the pinned-hash check and the mv. Like the existing resolver …[truncated]

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

D3472 — finalize-install replaces a stale or failing installed minzoned, and min ls names Minimal's failing DNS service

1 participant