Repository navigation
fix(minimal): a min bug bundle records the minzoned version, hashes, service state and log on macOS - #3484
Conversation
The bundle gains host/answerer.json (minzoned --version and the SHA-256 of the installed and shipped copies), the launchctl print or systemctl status transcript, and the service journal off macOS. The launchd unit now sends the service's output to <state>/logs/minzoned.log, which the logs collector takes.
…bundle-records-the-minzoned-version-ha
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
Spec lint
Advisory. None of this blocks the merge; the review decides. Advisory, and never a merge gate. Linter: |
|
/revise Review of head 2d1f568. Fix these. Keep every change inside the plan's six files.
|
…bundle-records-the-minzoned-version-ha
The launchd unit now sends the service's output to /private/var/log/minimal/minzoned.log, a fixed root-owned path the step creates, walks for custody, caps hourly, and removes on --undo. A unit that names no log re-surfaces the step. min bug collects the log as host/answerer.log, with a skip that says why when it is absent. The Linux journal read keeps journalctl's notes and ends at the bundle's creation time, and Linux bundles no longer list minzoned.log.
The log is a fixed root-owned file on macOS, capped hourly, re-offered to old installs, and removed by --undo (R2.13). The Linux journal window ends at the bundle's creation time.
…bundle-records-the-minzoned-version-ha
|
Round 1 of 10 on a /revise note, pushed as
Verify Converted to a draft: something above needs a person before review. On a macOS host where dev.gominimal.zone exits 1, the min bug bundle holds host/answerer.json with the minzoned version and the SHA-256 of the installed and shipped copies, host/answerer-service.txt with the launchctl print output, and host/answerer.log with the tail of /private/var/log/minimal/minzoned.log. When that log is absent, the manifest skip says why, and names min finalize-install for an install that predates the log. The fixture test shows each of these parts with fixture copies, transcripts and a log. Notes from the agent: Revise round 1, item by item. (1) The log moved to the fixed root-owned /private/var/log/minimal/minzoned.log, not /Library/Logs/minimal. The custody walk refuses any directory with group write. I believe /Library/Logs is root:admin with group write on stock macOS, but I could not check that on this Linux box. /private/var/log is root:wheel 0755. I used /private/var/log and not /var/log, because /var is a symlink. The step creates the directory (root:wheel 0755) and the file (operator, 0644) before it loads the unit. The custody walk covers the directory when the unit names the log. --undo removes the directory. min bug collects the file as host/answerer.log, with a skip that says why. (2) The path is a constant. answerer_log_path and its XDG lookup are removed. (3) AnswererFacts has a new unit_log field, read from the plist's StandardErrorPath. On macOS, a unit that names no log or a different log fails the step's check ('its unit keeps no log at ...'), so --show offers the step again. The bundle skip for that case says the installed service predates its log and names min finalize-install. (4) launchd has no size limit. The service holds the log open while it runs, so a newsyslog rename would not bound it. The step installs a second job instead: /Library/LaunchDaemons/dev.gominimal.zone.logcap.plist. It runs hourly as the operator, and when the log is over 1 MiB it cuts it in place to its last 256 KiB. launchd opens the l…[truncated] |
min finalize-install now writes the log size cap plist and /private/var/log/minimal on macOS. The installer's uninstall advice must remove them too, and install_test.sh checks that it names every path the step writes.
…bundle-records-the-minzoned-version-ha
|
Round 2 of 10 on a failed check suite, pushed as
Verify Outside the task's
Converted to a draft: something above needs a person before review. On a macOS host where dev.gominimal.zone exits 1, the min bug bundle shows the minzoned version, both SHA-256 hashes, the launchctl print output and the minzoned log lines. This round also makes the installer's uninstall advice remove the minzoned log, its directory and its size cap unit. Notes from the agent: The CI tests job failed in common::shell_harnesses. scripts/install_test.sh checks that the installer's uninstall advice names every path constant in crates/minimal/src/resolver.rs. The earlier round added /Library/LaunchDaemons/dev.gominimal.zone.logcap.plist, /private/var/log/minimal and /private/var/log/minimal/minzoned.log, and the advice did not name them. I touched scripts/install.sh, which is outside the task's layers. The fix adds those paths to the macOS removal list, removes the log directory with rm -rf, and boots out dev.gominimal.zone.logcap. This matches what min finalize-install --undo removes. ci-linux-native-success is the lane aggregator and fails only because the tests job failed. On this box, scripts/metrics_test.sh missing_nextest_fails_mutants_mode still fails with exit 127. It removes every PATH directory that holds cargo-nextest, and here that directory also holds other tools it needs. The branch does not change the metrics scripts. Doctests did not run here because rustdoc is not installed on this box. The branch adds no doc code blocks. I did not run cargo test -p minimal --lib unscoped to completion: in-process parallel runs time out on this box, and nextest passes all 1175 tests. |
|
/revise Review of head b260049. The seven points of the last directive are addressed. The
|
|
Reviewed: 1 finding, none blocking at Address the comments on the diff. Clobber: none seen. |
The answerer step now reads the dev.gominimal.zone.logcap plist on macOS. A missing cap plist, one root does not own, or one that runs other arguments re-surfaces the step. A cap that launchd does not load is removed, so the next read re-surfaces the step too. The min bug skip for a missing minzoned.log names min finalize-install only when its directory is gone. Otherwise it says the service creates the file when it next starts.
|
Round 3 of 10 on a /revise note, pushed as
Verify Outside the task's
Converted to a draft: something above needs a person before review. On a macOS host where dev.gominimal.zone exits 1, the min bug bundle shows the minzoned version, both SHA-256 hashes, the launchctl print output and the minzoned log lines. If the log is missing, the skip names min finalize-install only when the step has work to do. The step also reads the log cap plist, so min finalize-install --show reports a missing or changed cap. Notes from the agent: Item 1: the answerer step on macOS now reads /Library/LaunchDaemons/dev.gominimal.zone.logcap.plist (owner and mode, and its ProgramArguments, with the XML escapes undone). A missing plist, one root does not own, or one whose arguments are not /bin/sh -c is a failed check, so the step reads as not current. The check runs only when the main unit exists, the same as the log-path check. The step does not read whether the cap job is loaded. Instead, a failed bootstrap of the cap now removes the cap plist, so the next read fails the check. The warning for that case now ends with 'Run min finalize-install to try again.' Item 2: when the unit names the right log path and the file is missing, the skip now says 'absent: does not exist. The DNS service creates it when it next starts'. When the log's directory is also gone, launchd cannot create the file and the custody walk fails, so the skip names min finalize-install. Only Linux ran the build. The macOS-only code in answerer_step_over and read_answerer_step was not compiled here, and the macOS lane owes that check. The pure checks (answerer_log_cap_check, plist_string_array) are cfg(any(test, macos)) and ran in the Linux tests. I also ran cargo test -p minimal --lib answerer (16 passed) because the step fixtures changed. scripts/install.sh was not touched this round. |
|
The runtime will not revise this pull request again on its own: the diff is +1274/-19 (1293 lines), past 3x the plan's estimate of 380 lines (est: 260 code, 120 tests, as #3478 reads now), at round 3 (the last trigger was a /revise note). A person decides now. Remove |
norrietaylor
left a comment
There was a problem hiding this comment.
Approved at c574c36. The log now lives under a root-owned directory the step creates and --undo removes, existing installs are offered the new unit, the cap unit is in the step's checks, and the bundle tests use fixtures. The scripts/install.sh change is accepted: the uninstaller must name the new paths. One low edge case is filed in #3497.
bryan-minimal
left a comment
There was a problem hiding this comment.
Read the whole diff at c574c36, including the last commit, which adds a check on the log's size-cap unit (its owner and the arguments it runs) to the answerer step. The bundle half is good and I'd take it as it is. The other half changes the privileged macOS install, and that part needs a run on a Mac and a clearer title before it merges.
The collector (diag/answerer.rs): fine. Each part that cannot be read becomes a skip that says why, a non-zero exit of launchctl print or systemctl status is kept as the finding, every command is bounded, and the sources are injectable so the test does not depend on the host. Two small notes: the journal read is capped at 1000 lines newest-first inside a 24 hour window, which is right for a restart loop; and minzoned --version is run on the copy found on PATH, which is the caller's own program, so no concern.
The install change is larger than the title says. "A min bug bundle records…" also:
- adds a root-owned directory
/private/var/log/minimaland a log file owned by the operator; - adds a second LaunchDaemon,
dev.gominimal.zone.logcap, that runs a/bin/sh -cscript hourly as the operator; - makes the answerer step re-surface for every existing macOS install, because an installed unit that names no log now fails a check, and since the last commit so does a missing or altered size-cap unit. After this merges, every Mac user is offered
min finalize-install(a sudo prompt) again, for a diagnostics feature.
Point 3 is a product call and should be in the title or at least the first line of the body. If it is intended, fine; if not, the check could be advisory (the bundle's skip already says "run min finalize-install") and leave the step quiet.
None of the macOS path has run. The PR says so itself ("this box is Linux"). The pure parts are unit-tested, but the things that can go wrong are launchd's: whether a system job with UserName opens StandardOutPath as root or as the user, whether the job starts when the log file's owner and the directory's owner differ, and whether launchctl bootstrap of the cap job works from the step's script. I would not merge a change to the privileged step on reading alone. One min finalize-install, one --undo, and one upgrade from an install made by main, on a real Mac, would settle it.
Smaller points
- The log is mode 0644 in a world-readable directory, and it is the DNS service's output. On a Mac with more than one user, another user can read it. If the service logs box names, that is one user's box names shown to the others. Is 0640, or 0600, enough for the collector (it runs as the operator)?
- The cap script copies the tail to a temp file and then writes it back. Lines the service writes between the two commands are lost. Acceptable for a cap, but worth one sentence in the comment, since the reason for the log is a service that fails at start.
__OPERATOR__goes into the new plist withoutxml_escape, while the script beside it is escaped. The existing unit does the same, so this is consistency only.- The draft PRs for the macOS package install (#2975, #2976, #2977) do the same privileged setup from a package. Whichever lands second has to carry the log directory and the cap job too; noting it so it is not lost.
So: approve the collector, and for the install half I'd like the Mac run and a decision on point 3.
🤖 Generated with Claude Code
|
/revise Merge Keep both changes:
|
|
That Round 4 of 10 was not counted; #3478 carries the same sentence. |
…ed-version-ha Resolves the conflict in crates/minimal/src/resolver.rs with #3481 (finalize-install replaces a stale or failing minzoned). Both changes are kept: AnswererFacts carries the log-cap facts and the SHA-256/job facts, read_answerer_step_with_job reads both, and answerer_step_over runs the log and log-cap custody checks before the copy-differs and not-running states.
Defect
Fixes #3478
crates/minimal/src/diag/answerer.rscrates/minimal/src/diag/mod.rscrates/minimal/src/diag/collect.rscrates/minimal/src/resolver.rscrates/minimal/tests/bug.rsdocs/specs/10-spec-diagnostics/10-spec-diagnostics.mdTask marker
Proof
A min bug bundle now holds host/answerer.json with minzoned --version and the SHA-256 of the installed copy and of the copy beside min or on PATH. It also holds host/answerer-service.txt with the launchctl print system/dev.gominimal.zone transcript on macOS, or the systemctl status transcript on Linux, and on Linux host/answerer-journal.txt with the last 24 hours of the minzoned units' journal. The launchd plist now sets StandardOutPath and StandardErrorPath to /logs/minzoned.log, and the bundle's logs/ collector takes minzoned.log*. A host where dev.gominimal.zone exits 1 therefore shows its version, both hashes, the launchctl print output and the minzoned log lines. This was verified on Linux only. The macOS path compiles under cfg but was not run on a Mac.
Notes from the agent: The macOS branch (launchctl print, plist log path on a real launchd) was not exercised: this box is Linux. The log path takes effect only after the answerer step re-installs the plist (min finalize-install), so a host with the old plist has no minzoned.log until then. The journal window is a fixed 24 hours (-n 1000 cap), because min bug has no explicit bundle window. A third log prefix (minzoned.log, Host locality) changes one collect.rs unit test from a count of 2 to LOG_PREFIXES.len(). The resolver now exposes ANSWERER_LAUNCHD_LABEL, ANSWERER_SYSTEMD_UNIT, answerer_source and sha256_of as pub(crate), and adds ANSWERER_LOG_FILE, answerer_log_path and xml_escape. just lint-prose did not run: vale is not installed on this box. Also ran: cargo test -p minimal --test bug (16 passed) and cargo test -p minimal --lib -- diag:: resolver:: (160 passed).
Tests
cargo test -p minimal --test bug the_answerer_service_is_describedcargo test -p minimal answerer_plist_sets_a_log_pathcargo test -p minimal --test bug the_answerer_service_is_describedVerify
min task run agent-verifyexited 100, so this PR is a draft.Base
The base branch moved while the coder worked; it was merged in before the tests ran.