fix(updater): refuse update under a package-manager receipt - #29
Merged
Merged
Conversation
Seal run 36178214528 moved past the relative-path fix (the managed DEB/RPM build step passed on both musl lanes for the first time) and hit the next first-time runner, the actual-package native lifecycle gate: `terraphim-agent update` under a dpkg receipt printed the managed-by message but exited 0. The Gitea #247 contract -- already implemented by terraphim-cli and by the C fixture in test_client_nfpm_native.sh -- requires an explicit `update` under a receipt to exit non-zero, print "<bin> update was refused: <status>" to stderr, and leave the installed binary byte-identical, while `check-update` keeps reporting the managed status on stdout with a zero exit. - terraphim_agent: PackageManaged arm in the Command::Update handler (eprintln the refusal line, exit 1) - terraphim_grep: same arm in handle_update_command - update_refusal_tests.rs in both crates: stage the real compiled binary into a temp prefix with a real dpkg/rpm receipt (the updater's own path-derived detection) and assert exit code, exact stderr line, and unchanged bytes; check-update asserts the stdout line and zero exit. No network, no mocks. All six refusal tests pass against the real binaries; learn_no_service_tests and no_thesaurus_cli still pass; rustfmt clean. Refs #337
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Seal run 36178214528 proved the previous fixes work (the managed DEB/RPM build
step passed on both musl lanes for the first time) and surfaced the next
first-time runner: the actual-package native lifecycle gate. Both lanes failed
identically:
terraphim-agent updateunder a package-manager receipt printed themanaged-by message but exited 0. The lifecycle gates require an explicit
updateunder a receipt to refuse.terraphim-clialready implements thiscontract (Gitea #247:
Err(anyhow!("{bin} update was refused: {other}"))), andthe C fixture in
test_client_nfpm_native.shreplicates it — the agent andgrep binaries were the gap.
Changes
crates/terraphim_agent/src/main.rs:PackageManagedarm in theCommand::Updatehandler — eprintlnterraphim-agent update was refused: <status>and exit 1; all other statuses keep the current stdout/exit-0 path.crates/terraphim_grep/src/main.rs: same arm inhandle_update_command.update_refusal_tests.rsin both crates: stage the real compiled binaryinto a temp prefix with a real dpkg/rpm receipt at
<prefix>/share/terraphim/package-manager.d/<bin>(the updater's ownpath-derived detection — no mocks, no network, no system paths) and assert:
updateexits non-zero under dpkg and under rpmterraphim-agent update was refused: [OK] Managed by dpkg; run \sudo apt update && sudo apt upgrade` to update`check-updatestill prints the managed line on stdout and exits 0Verification
cargo test -p terraphim_agent -p terraphim_grep --test update_refusal_tests:6/6 pass (3 per crate).
cargo test -p terraphim_agent --test learn_no_service_tests(4/4) andcargo test -p terraphim_grep --test no_thesaurus_cli(1/1) still pass.cargo fmt --checkclean.grep -Fxqpatterns (dpkg and rpm variants, host and docker paths).Refs #337