Skip to content

package: add .deb build and apt install route (fixes #731; related: #784) - #833

Merged
pithead-reviewer[bot] merged 30 commits into
developfrom
agent/731-package-rigforge-as-a-deb-for-diy-instal
Dec 1, 2026
Merged

pithead-reviewer[bot] merged 30 commits into
developfrom
agent/731-package-rigforge-as-a-deb-for-diy-instal

Conversation

@pithead-developer

@pithead-developer pithead-developer Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What's the problem

Closes #731

Debian and Ubuntu DIY operators have no package install. This PR delivers #784 (Related: #784): a checksummed .deb built from the release bundle and attached to each release. It is the package that the apt feed (#786) and the safe apt upgrade (#785) already expect.

How I fixed it

  • scripts/build-deb.sh <bundle> <tag> builds rigforge_<VERSION>_all.deb from release.yml's tarball. It fails when VERSION disagrees with the tag. The build is byte-reproducible: mtimes come from SOURCE_DATE_EPOCH, which release.yml sets from the tag commit.

  • Layout:

  • An apt-marked tree with no RIGFORGE_STATE uses the same layout. Running /usr/lib/rigforge/rigforge.sh directly, which is what rigforge's own $0 hints tell the operator to do, therefore never writes state into the code tree.

  • Decisions taken: config.json is state under /var/lib/rigforge. setup creates it and purge removes it. There is no shipped conffile and no /etc/rigforge/config.json. This is the operator's ruling of 2026-12-01 and supersedes the conffile line in Build a .deb from the release bundle and attach it to each release (refines #731) #784's Contents and the /etc/rigforge assertions in Verify both routes from the real channel on each release, including behind Tor #788. The reasons: since Add RIGFORGE_STATE for config and state files, default unchanged #780 config.json lives in RIGFORGE_STATE, and setup's wizard keys on its absence. A shipped file would make the Run apt upgrades safely: postinst queues a one-shot upgrade outside dpkg #785 postinst treat never-configured hosts as configured, and dpkg would prompt on every upgrade. ADR 0003's purge line now says purge deletes /var/lib/rigforge (config included) and any /etc/rigforge the package owns, and never reverts tuning.

  • Maintainer scripts, all from packaging/debian/:

    • prerm stops and disables every RigForge unit on remove, before dpkg deletes the code. It fails if a unit that exists cannot stop.
    • postrm exits 0 for every dpkg action.
    • On purge, postrm deletes /var/lib/rigforge. It also deletes the units, timers and paths, the firewall rules and the control state, but only those it can prove the package rendered (a service that references the package paths). A git install's files survive. Purge never touches tuning.
  • release.yml adds the .deb to SHA256SUMS and the draft assets. The CI e2e job gains the gated step assert: deb install pass, and both new suites are in tests/manifest.json.

  • Shortcut: setup, upgrade and package-upgrade are not executed under the package layout in CI, because the container has no systemd. Upgrade when a systemd-capable e2e exists.

  • File budget: merged with develop (34d9ea5), rigforge.sh was 6033 lines against its 6028 ceiling. 358ac46 moves _config_replace unchanged into util/config-apply-state.sh and drops the comments in that hunk, leaving rigforge.sh at 6024. The apt layout lines stay inline, before the RIGFORGE_LIB checks. A first attempt (ffb7c04) moved those lines into a new util/ file and is reverted (ba46560), because that file would have been loaded from the script's directory before the checks.

  • Round-4 review fixes in 710b3d2 and 943def8:

    • The apt marker is found from the resolved script directory, so bare-name and symlink runs also use /var/lib/rigforge; tests/test-package-mode.sh covers both forms.
    • prerm acts only on remove. It stops only units the package rendered (same ownership rule as postrm), uses disable --now only for units with an [Install] section and plain stop for the static ones. A git install's units are left alone, which tests/test-package-upgrade.sh covers.
    • postinst uses mkdir -p ... || true for the state dir.
    • Recommends: linux-tools-generic | linux-cpupower covers cpupower.
    • build-deb.sh takes only the tarball and uses a plain trap; a build test asserts that prerm and postrm share one unit list.
    • The test no longer names internal repositories; it asserts that docs/dev is not shipped.
    • Explanatory comments are removed from the edited release.yml hunk; RELEASING.md and SECURITY.md already hold them.

Here is the proof

Head 358ac46 (base develop at aff3464 merged in): gh pr checks 833 shows all 27 checks passing, including Lint, Test suite, Coverage and End-to-end, and Workflow audit issue is skipped. On that head FILE_BUDGET_REQUIRE_BASE=1 bash scripts/lint-file-budget.sh prints file budget OK, shellcheck --severity=warning $(git ls-files "*.sh") and shfmt -i 4 -d $(git ls-files "*.sh") exit 0, and bash tests/test-config-write-safety.sh, tests/test-tune-gate.sh, tests/test-state-lib.sh and tests/test-coverage-cache.sh pass locally. The first lines of rigforge.sh, through the last startup source, are identical to the merge commit's.

At acab221 the Test suite log shows an apt-marked tree run by bare name uses the package layout, ... run by symlink name ..., package upgrade: all checks passed, ok: prerm and postrm act on the same unit list and build-deb: all checks passed. Lint failed three times on 710b3d2: two runner shutdowns and one stall. The cause was a literal source rigforge.sh in the new test, which made shellcheck inline the whole script; a combined local run took 244 s and raised 35 run.sh warnings. 943def8 passes the name through a variable. shellcheck --severity=warning $(git ls-files "*.sh") now exits 0 locally.

At 92ee84a, End-to-end (Docker) passed. Its tests/test-deb-install.sh run on ubuntu:24.04 covered:

  • apt install and rigforge --version;
  • the marker;
  • doctor with no config, with config in /var/lib/rigforge, and via a direct /usr/lib/rigforge/rigforge.sh run;
  • nothing was written under /usr/lib/rigforge;
  • an upgrade to 1.19.1 that queues the package upgrade;
  • remove keeping config, state and units, and purge leaving no residue.

The two failures on that head were fixed afterwards:

  • api-refresh starts a bounded number of programs (#818): the layout check now uses builtins. bash tests/test-api-refresh-spawns.sh rigforge.sh gives 99 passed locally.
  • Patch coverage of the new lines: three cases were added to tests/test-package-mode.sh.

Other checks I ran:

  • bash tests/test-package-upgrade.sh, under both bash and dash: every maintainer-script case passes. The 11 watchdog enabled/disabled real-upgrade cases fail only on this Mac, and develop's own copy of the test fails them the same way.
  • A mutation that drops purge's ownership guard turns purge keeps every unit and the control state of a non-package install red.
  • bash tests/manifest-selftest.sh: 8 passed.
  • bash tests/test-workflow-contract.sh: ok.
  • shellcheck --severity=warning and shfmt -i 4 -d on the changed scripts: clean.
  • bash scripts/lint-topology-classes.sh: OK.
  • markdownlint on the changed docs: 0 issues.

Reviews:

  • The verifier (Fable) ran three rounds. It found residue after purge, deletion of a git install's units, the direct-run state leak, a weak direct-run check, and the firewall file. All are fixed; the only finding it still lists is the shortcut above.
  • The earlier security review found file modes and the purge glob; both are fixed.
  • On the budget fix, the verifier and the security review both flagged the reverted ffb7c04 ordering; on 358ac46 both report no findings, with the moved function byte-identical and all of its statements executed by tests/test-config-write-safety.sh.

No bench job was run, because the worker-to-Pithead contract is unchanged.

  • build-deb.sh builds rigforge_<VERSION>_all.deb reproducibly and fails when VERSION disagrees
  • Code in /usr/lib/rigforge, a wrapper exporting RIGFORGE_LIB/RIGFORGE_STATE, state in /var/lib/rigforge, the apt marker and full Depends. Config is state, not a conffile, per the ruling under Decisions taken.
  • postinst only reloads systemd, creates the state dir and prints the first-run step, plus the Run apt upgrades safely: postinst queues a one-shot upgrade outside dpkg #785 queue. Remove stops and disables units and keeps config and state; purge removes them and never reverts tuning.
  • release.yml adds the .deb to SHA256SUMS in the draft release
  • On a clean Ubuntu 24.04 container: install, --version and doctor pass, then upgrade, remove and purge leave the stated residue
  • No internal repository reference in the package or scripts

🤖 Generated with Claude Code

scripts/build-deb.sh builds rigforge_<VERSION>_all.deb from the release
tarball using dpkg-deb. Package layout:

  /usr/lib/rigforge/         — code tree (rigforge.sh, util/, systemd/,
                                 docs/, images/, configs, docs)
  /usr/bin/rigforge           — wrapper exporting RIGFORGE_LIB and
                                 RIGFORGE_STATE, execs rigforge.sh
  /etc/rigforge/config.json   — minimal config (conffile)
  /var/lib/rigforge/          — state dir with .rigforge-package marker
  /etc/apt/keyrings/rigforge.asc — signing key
  DEBIAN/{control,postinst,postrm,conffiles} — dpkg metadata

postinst only runs daemon-reload, creates state dir, prints first-run
hint; it never compiles, tunes, edits GRUB, reboots or starts a miner.

postrm remove stops/disables units but keeps config and state (operator
data); purge removes everything.

DEBIAN/control Depends lists every package rigforge.sh installs today
(bash, jq, curl, nftables, git, build-essential, cmake, libuv1-dev,
libssl-dev, libhwloc-dev, gettext-base, python3, msr-tools).

.github/workflows/release.yml integrates the .deb build into the release
pipeline, adding it to the GitHub release assets.

tests/test-build-deb.sh validates input checks, build output, .deb
metadata, contents, wrapper env vars, DEBIAN scripts, and absence of
internal repo references.

docs/getting-started.md adds an apt install section with keyring
verification and apt sources setup.
@pithead-reviewer

Copy link
Copy Markdown
Contributor

FAIL

What I investigated

The PR description does not match the required three-section format.

Reviewed head: e63102c502967f56c5bba8740a00ade86795c007.

What are the gaps

  • PR description: PR description must contain exactly these ## headings in order: What's the problem; How I fixed it; Here is the proof

pithead-developer[bot] and others added 3 commits November 24, 2026 03:52
…ence

- Add tests/test-build-deb.sh to Makefile test-suite target
- Fix unused $PASS variable in test output line

Co-Authored-By: Claude Code <noreply@anthropic.com>
- Remove unused RELEASE_DIR allocation in build-deb.sh (dead code)
- Fix postinst first-install hint: check $2 (package arg) instead of
  config.json existence — config.json is always placed during build
- Correct docs/getting-started.md: the package installs the wrapper,
  not systemd units (rigforge.sh setup installs units)
The test copied util/, systemd/, docs/, images/ into archive/ subdirs
without creating those directories first, causing cp to fail in CI
with 'No such file or directory'. Add mkdir -p for all subdirs.
@pithead-developer pithead-developer Bot changed the title package: add .deb build and apt install route (fixes #731, #784) package: add .deb build and apt install route (fixes #731; related: #784) Nov 24, 2026
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
pithead-developer[bot] and others added 3 commits November 24, 2026 17:18
…e tarball

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…extract

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@pithead-reviewer

Copy link
Copy Markdown
Contributor

FAIL

What I investigated

Reviewed PR #833 (head 2808fbc) against #731 and the slice it actually delivers, #784: scripts/build-deb.sh, tests/test-build-deb.sh, the release.yml step and the getting-started apt section, checked against rigforge.sh, util/package-mode.sh, packaging/ and apt-feed.yml on develop. CI is green and the lint, file budget and topology checks are clean. But the .deb would not work as a packaged install: the marker is in the wrong place, the wrapper's environment variables and the conffile are never read, every apt upgrade fails, it overwrites the user's apt signing key with a placeholder, it ignores the #785 postinst and upgrade unit, and remove leaves the miner running. The clean Ubuntu 24.04 install criterion is admitted unmet.

  • gh pr view 833: head 2808fbc, base develop; the body ticks 5 of 6 criteria and leaves 'Clean Ubuntu 24.04 install/doctor/remove/purge (pending a container job)' unticked

  • gh issue view 731/784/778: Build a .deb from the release bundle and attach it to each release (refines #731) #784 is the .deb slice; 780 and 781 are OPEN; 782, 783, 785 and 786 are CLOSED

  • gh pr checks 833: 16 of 16 pass; run 45510935440 is on 2808fbc with conclusion success; run 45501682237 is on e6d3707 with conclusion failure (matches the body)

  • gh run view 45510935440 --job 138858157548 --log: tests/test-build-deb.sh ran on Linux, printed 'control Version == 1.19.0' and 'build-deb: tests passed'

  • bench-ci list --all --fleet --commit 2808fbc --json: jobs [] (none quoted; the diff does not touch the worker contract)

  • grep -rn 'RIGFORGE_LIB|RIGFORGE_STATE' rigforge.sh util: no matches

  • util/package-mode.sh:5: the marker is read from ${RIGFORGE_PACKAGE_MARKER:-$SCRIPT_DIR/.rigforge-package}; rigforge.sh:67 sets SCRIPT_DIR=${RIGFORGE_HOME:-$(_script_dir)}; rigforge.sh:81 sets CONFIG_JSON=$SCRIPT_DIR/config.json

  • git log origin/develop -- packaging: caff479 (Run apt upgrades safely: postinst queues a one-shot upgrade outside dpkg #808) added packaging/debian/postinst and rigforge-upgrade.service; grep finds no reference to packaging/debian in build-deb.sh

  • wc -c packaging/apt/fingerprint: 23 bytes, content 'pending-key-generation'

  • rigforge.sh:143 SERVICE_NAME=${SERVICE_NAME:-xmrig}; xmrig.service is not in the postrm unit list

  • shellcheck on both scripts: rc 0; shfmt -d -i 4: rc 0

  • FILE_BUDGET_REQUIRE_BASE=1 bash scripts/lint-file-budget.sh: 'file budget OK'

  • detect-topology.py over the PR body, comments and reviews: clean; over the Package RigForge as a .deb for DIY installs and publish it through the project APT repository #731 comments: clean (none exist)

  • [F833-9] scripts/build-deb.sh:128: 'Maintainer: user@example.com' is a placeholder and not the 'Name ' form Debian policy expects. Build a .deb from the release bundle and attach it to each release (refines #731) #784 asks for a reproducible build, but nothing sets SOURCE_DATE_EPOCH or normalizes the mtimes of generated files, so two builds differ.

  • [F833-10] scripts/build-deb.sh:74-80: Ponytail: mkdir_stage wraps a single mkdir -p, and the PKG_* variables are each used once in one heredoc. Purge's rm -rf /usr/lib/rigforge and rm -f /usr/bin/rigforge repeat what dpkg already does for files it owns. The test labelled 'one arg exits non-zero' (tests/test-build-deb.sh:68) passes three arguments, and the internal-reference check greps for only one repository name.

Reviewed head: 2808fbca7b98ecfdb1beaf268f5dd682f7cc19c3.

What are the gaps

  • [F833-1] scripts/build-deb.sh:117: The apt marker is written to /var/lib/rigforge/.rigforge-package, but util/package-mode.sh:5 reads $SCRIPT_DIR/.rigforge-package, which is /usr/lib/rigforge/.rigforge-package for this layout. _package_channel never returns apt, so a packaged install keeps the git self-upgrade and link paths that ADR 0003 and Add a package marker and make upgrade, link and dependency paths package-aware #782 forbid for package-owned trees. tests/test-build-deb.sh asserts the wrong path, so the test passes. Fix: ship the marker in the code tree, and assert the location util/package-mode.sh reads.
  • [F833-2] scripts/build-deb.sh:104-113: The /usr/bin/rigforge wrapper exports RIGFORGE_LIB and RIGFORGE_STATE, but nothing in rigforge.sh or util/ reads either one (grep finds none; Add RIGFORGE_STATE for config and state files, default unchanged #780 and Resolve every code lookup from one lib dir so the code tree can be read-only #781 are open). rigforge.sh:81 reads config from $SCRIPT_DIR/config.json, which is /usr/lib/rigforge/config.json. So the /etc/rigforge/config.json conffile is never used, and setup writes config into the dpkg-owned code tree. docs/getting-started.md presents the exported variables as if they did something. Either wait for Add RIGFORGE_STATE for config and state files, default unchanged #780 and Resolve every code lookup from one lib dir so the code tree can be read-only #781 or use what the code honours today (RIGFORGE_HOME, RIGFORGE_PACKAGE_MARKER), and say in the body which criterion is deferred.
  • [F833-3] scripts/build-deb.sh:184-187: The postrm case ends in '*) echo ... exit 1'. During every upgrade dpkg runs the old postrm with 'upgrade', then the new postrm with 'failed-upgrade', and it uses abort-install, abort-upgrade and disappear in other cases. With this case, every 'apt upgrade rigforge' (and the apt-feed channel Publish a signed apt feed on GitHub Pages with a pinned fingerprint (refines #731) #786 feeds) fails and leaves the package half-installed. That breaks Package RigForge as a .deb for DIY installs and publish it through the project APT repository #731's 'apt upgrade ... work' criterion. Accept the other dpkg arguments with exit 0, and add a test that runs dpkg -i on two versions in CI.
  • [F833-4] scripts/build-deb.sh:119-121: packaging/apt/fingerprint (23 bytes, a placeholder string, not a key) is copied to /etc/apt/keyrings/rigforge.asc, and any error is swallowed by '2>/dev/null || { :; }'. The new docs/getting-started.md section (and README) tells the user to save the real signing key at that same path before 'apt install rigforge'. The path is not a conffile, so dpkg overwrites the user's key with the placeholder and deletes it on remove, after which apt can no longer verify the feed. The package should not ship this file at all: the keyring is the user's, under Publish a signed apt feed on GitHub Pages with a pinned fingerprint (refines #731) #786.
  • [F833-5] scripts/build-deb.sh:133-150: develop already has packaging/debian/postinst and packaging/debian/rigforge-upgrade.service from Run apt upgrades safely: postinst queues a one-shot upgrade outside dpkg #785 (caff479, Run apt upgrades safely: postinst queues a one-shot upgrade outside dpkg #808), documented at docs/operations.md:594. build-deb.sh ignores both and writes its own inline postinst, so the queued safe-upgrade path never ships, and the docs describe behaviour this .deb does not have. Build the package from packaging/debian/ instead of inline heredocs.
  • [F833-6] scripts/build-deb.sh:160-178: The remove and purge unit list leaves out the miner unit xmrig.service (rigforge.sh:143), plus rigforge-autotune.service, rigforge-watchdog.service and rigforge-upgrade.service. Units are only stopped in postrm, which runs after dpkg has deleted the code, and there is no prerm. After 'apt remove' the miner keeps running from a deleted tree, which fails Build a .deb from the release bundle and attach it to each release (refines #731) #784's 'Remove stops and disables units'. The test only greps for 'systemctl stop'.
  • [F833-7] tests/test-build-deb.sh:104-153: The Build a .deb from the release bundle and attach it to each release (refines #731) #784 criterion 'On clean Ubuntu 24.04 in a container, apt install ./rigforge_X.deb, rigforge --version and doctor pass, then remove and purge leave the stated residue' is unmet (the body leaves it unticked) and nothing in CI covers it. The test greps string contents and never installs the package, so every correctness defect above passes CI. The last block (apt-ftparchive ... || true, followed by assertions repeated from earlier) tests nothing. Add a CI step on ubuntu-24.04 that runs dpkg -i/apt install, --version, doctor, an upgrade, remove and purge, with residue checks.
  • [F833-8] scripts/build-deb.sh:142: The postinst first-run hint and docs/getting-started.md both say 'sudo rigforge.sh setup', but the package puts only /usr/bin/rigforge on PATH, so the hint fails with 'command not found'. The docs section also says the project 'publishes a signed .deb through a GitHub-hosted apt feed' while packaging/apt/fingerprint is still the placeholder, and it repeats README.md:137-145. Point to one place and use 'sudo rigforge setup'.

pithead-developer[bot] and others added 4 commits November 24, 2026 17:55
…de, remove and purge

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pin the build epoch to the tag

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d rendered units

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pithead-developer

Copy link
Copy Markdown
Contributor Author

Blocked on #780 (with #781; implementation in PR #826). The package criterion of #784 needs the /usr/bin/rigforge wrapper to export RIGFORGE_LIB/RIGFORGE_STATE and /etc/rigforge/config.json to be a conffile. No code reads those yet: rigforge.sh takes config from $SCRIPT_DIR/config.json inside the dpkg-owned tree, and the #785 queued upgrade looks for /etc/rigforge/config.json, so it cannot fire. Everything else in #784 is done and green on 18efc35: the build, layout, maintainer scripts, release step, and a clean Ubuntu 24.04 container covering install, version, doctor, upgrade, remove and purge. Once #780/#781 merge, this PR adds the wrapper exports and the conffile and reruns the container test. Open point for #780: a conffile config would make #785's postinst treat every apt host as configured. Default: ship config.minimal.json only and let setup create /etc/rigforge/config.json. Separately, the Lint check is red only because develop itself is over the file budget (#850).

@pithead-developer pithead-developer Bot added stage/question its issue has a question pending and removed stage/in-progress labels Dec 1, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pithead-reviewer

Copy link
Copy Markdown
Contributor

PASS

What I investigated

Re-reviewed PR #833 at head acab221 against #731 and the slice it delivers, #784, reading the diff ea1e0b1..acab221 (3 worker commits, 12 files; ea1e0b1 is in this clone). All three open findings are closed: the apt marker is found from the resolved script directory (bare-name and symlink runs now use /var/lib/rigforge, and the new cases go red with the fix reverted), prerm acts on remove only and only on units the package rendered (a git install's units get no call), and the conffile criterion is superseded by the architect's ruling of 2026-12-01 on #731, which the ADR, the body and the comments on #784 and #788 follow. CI is 27 pass and 1 skipping on the head, including the Ubuntu 24.04 .deb install run. Not checked: nothing ran against real systemd or dpkg (none on this Mac, none in CI), so the exit codes of 'systemctl stop' and 'disable --now' on a live host remain unproven, as the earlier note F833-18 and the body's shortcut already record.

  • gh pr view 833 --json: head acab221, base develop, author the developer App, not a draft; the body says it delivers Build a .deb from the release bundle and attach it to each release (refines #731) #784 as part of Package RigForge as a .deb for DIY installs and publish it through the project APT repository #731 and ticks 6 criteria

  • gh issue view 731/784/788/778: the architect App's comment on Package RigForge as a .deb for DIY installs and publish it through the project APT repository #731 (2026-12-01T05:10Z) rules config.json is state under /var/lib/rigforge with no shipped conffile and no /etc/rigforge/config.json, and tells the worker to rewrite the ADR purge line, list it under Decisions taken and comment on Build a .deb from the release bundle and attach it to each release (refines #731) #784 and Verify both routes from the real channel on each release, including behind Tor #788; both comments exist (2026-12-01T05:17Z)

  • git log --no-merges ea1e0b1..acab221: 710b3d2, 943def8, acab221; git diff --stat: 12 files, 41 insertions, 24 deletions

  • F833-11 fixed: rigforge.sh:63 uses $(_script_dir). My bash -x trace of a copied tree with an apt marker prints 'export RIGFORGE_LIB= RIGFORGE_STATE=/var/lib/rigforge' for bare name, ./, absolute path, an absolute symlink and a relative symlink run by bare name; no marker and a brew marker print nothing

  • F833-11 revert proof (scratch worktree, layout section of tests/test-package-mode.sh): head gives 5 ok, rc 0; with rigforge.sh from ea1e0b1 the 'bare name' and 'symlink name' cases FAIL with /config.json, rc 1

  • F833-12 fixed: my probe under dash with a stub systemctl and units rendered as the product renders them (api and control services without the state env line): 'prerm remove' on package paths exits 0 after 14 calls (stop rigforge-upgrade.service, 8 'disable --now' on units with [Install], 5 'stop' on static services); on git-install paths it makes 1 call, the stop of the package's own rigforge-upgrade.service; deconfigure, upgrade and failed-upgrade make 0 calls

  • F833-12 revert proof: bash tests/test-package-upgrade.sh with prerm from ea1e0b1 adds 7 FAIL rows ('leaves a non-package install's units alone', 'deconfigure leaves the miner running', 5 static-unit rows); at head the only FAIL rows on this Mac are the 11 'watchdog enabled/disabled' real-upgrade rows that stop at the XMRig clone, as the body says

  • Ownership rule against the real templates: rigforge-api.service and rigforge-control.service are rendered without the state env line (rigforge.sh:1369, 1406-1408) but still match through their LoadCredential=server:/usr/lib/rigforge/util/ line; with a git path both give 0 matches; the other six services are piped through _unit_split_env

  • F833-13 resolved: docs/adr/0003 line 32 now reads as the architect's ruling states; the body lists it under 'Decisions taken'

  • Earlier notes: F833-14 fixed (release.yml five comment lines deleted), F833-15 fixed (tests/test-build-deb.sh names no internal repository), F833-16 fixed (control:6 Recommends: linux-tools-generic | linux-cpupower), F833-17 fixed (postinst:12 'mkdir -p ... || true'), F833-19 fixed (zip branch and CLEANUP array gone, a build test compares the two UNITS lines), F833-18 partly answered (static units now get 'stop' instead of 'disable --now'; still no run on real systemd)

  • gh pr checks 833 --json: 27 pass, 1 skipping (Workflow audit issue); gh run view 46581777350 --json: headSha acab221, conclusion success, attempt 1

  • CI Test suite job 142417851261 log at the head: '✓ an apt-marked tree run by bare name uses the package layout', '✓ ... run by symlink name ...', 'rigforge tests: 2858 passed, 0 failed', 'package upgrade: all checks passed', 'ok: prerm and postrm act on the same unit list', 'build-deb: all checks passed'

  • CI End-to-end job 142417851047 log at the head: 'ok: apt install ./rigforge_1.19.0_all.deb, rigforge --version is 1.19.0', 'ok: nothing was written under /usr/lib/rigforge', 'ok: upgrade to 1.19.1 keeps config and state and queues the package upgrade', 'ok: remove deletes the code and keeps config and state', 'ok: purge leaves no rigforge residue', 'deb install: all checks passed'

  • bench-ci list --all --fleet --commit acab221 --json: rc 0, 0 jobs; the body quotes none and the diff does not touch the worker-to-Pithead contract

  • FILE_BUDGET_REQUIRE_BASE=1 bash scripts/lint-file-budget.sh: rc 0, 'file budget OK'; shellcheck --severity=warning on the changed scripts: rc 0; shfmt -i 4 -d: rc 0; bash scripts/lint-topology-classes.sh: rc 0; bash tests/test-api-refresh-spawns.sh rigforge.sh: 99 passed, 0 failed

  • Criterion 'no internal repository reference': grep for the three internal repository names over the bundle file set (rigforge.sh, util, systemd, the two config files, README.md, docs, images, LICENSE, VERSION) plus packaging/ and scripts/build-deb.sh: no match

  • Added-comment scan of the round diff outside docs: no added comment line; VERSION and CHANGELOG.md untouched in the PR diff

  • detect-topology.py over the PR body, the 4 PR comments and the 4 comments on Package RigForge as a .deb for DIY installs and publish it through the project APT repository #731: clean, rc 0 for all nine files

  • ponytail-review pass over the round diff: no must-fix; the lean and doc points are the notes below. Performance: rigforge.sh:63 adds one subshell (no exec) per CLI start, which the Each api-refresh tick starts more than 200 processes #818 spawn bound still passes; not a finding

  • Angle lead rejected (correctness, RIGFORGE_HOME ignored for state under an apt marker): rigforge.sh:64-66 is unchanged since the last reviewed head and matches the wrapper, which also sets RIGFORGE_STATE regardless of RIGFORGE_HOME

  • Angle lead rejected as a blocker (prerm aborts under set -e): confirmed by probe that a failing stop of xmrig.service gives rc 5, which the body states as intended; the half-pair case (service file present, timer file missing) needs an interrupted setup, because rigforge.sh:1237, 1271, 1358, 1399 and 1420 remove each pair together

  • Angle lead rejected (security, ownership grep matches a git install that sets RIGFORGE_STATE=/var/lib/rigforge): that host already shares the package's state directory; no exploit, unchanged postrm rule

  • Angle lead rejected (ops, release.yml lost the --draft rationale comments): the comment rule deletes explanatory comments in an edited hunk and the earlier note F833-14 asked for it; RELEASING.md and SECURITY.md hold the rationale

  • Angle leads confirmed as notes: the 'before apt purge' wording in docs/getting-started.md:70 and the nft table left loaded after purge (rigforge.sh:1302 and 2171 are the only 'nft destroy table inet rigforge' calls; prerm and postrm make none)

  • [F833-20] PR body, 'How I fixed it' > Maintainer scripts and 'Here is the proof': The body still says prerm 'stops and disables every RigForge unit on remove', which the round-4 bullet below it and packaging/debian/prerm:14 contradict. It also quotes the container run from 92ee84a; the run on the head is 46581777350, job 142417851047. Correct the first line and refresh the quote.

  • [F833-21] docs/getting-started.md:70: 'rigforge uninstall, run before apt purge' is wrong for an operator who ran 'apt remove' first: the code under /usr/lib/rigforge is gone by then, so uninstall cannot run and the tuning stays. Say 'before apt remove or apt purge'. The same paragraph could say that purge also deletes the backups kept under /var/lib/rigforge.

  • [F833-22] packaging/debian/postrm:16-18: Purge deletes the firewall rules file but nothing destroys the loaded 'inet rigforge' nft table; only 'rigforge uninstall' (rigforge.sh:2171) and disabling the API (rigforge.sh:1302) do. I read this from the code and did not run it: after 'apt purge' the API-port allowlist would keep filtering until reboot with no file or unit left to explain it. A guarded 'nft destroy table inet rigforge' in prerm remove, when the package owns the units, would close it.

  • [F833-23] packaging/debian/prerm:14: The ownership pattern is now copied in prerm:14 and postrm:10, and tests/test-build-deb.sh pins only the UNITS lines as equal. If one pattern changes alone, remove would stop units that purge keeps, or the reverse. Compare the two patterns in the same build check.

Reviewed head: acab221d04b1a47a80d6eeeaca9753120bc9d834.

@pithead-developer pithead-developer Bot added stage/awaiting-merge the reviewer's PASS is on the head; merging when checks and the base allow and removed stage/in-review a reviewer session is on it now labels Dec 1, 2026
@pithead-reviewer

Copy link
Copy Markdown
Contributor

Owner brief for acab221d04b1

What it does. Adds a build script that turns each release tarball into a checksummed rigforge_<VERSION>_all.deb, and release.yml now attaches it to the draft release and to SHA256SUMS. After apt install, the code sits in root-owned /usr/lib/rigforge, a /usr/bin/rigforge wrapper runs it, and config and state live in /var/lib/rigforge. Remove stops the units the package set up, and purge deletes state and the units it can prove it created.

Why. Closes the .deb part of #731 (milestone v1.21.0), delivered as #784. Debian and Ubuntu DIY operators had no package install. The apt feed (#786) and the safe apt upgrade (#785) already expected this package to exist. The PR also records the 2026-12-01 ruling that config.json is state under /var/lib/rigforge, not a conffile.

Risk. Low to moderate. The new code only runs for people who install the package, plus a small default in rigforge.sh:63-67 that applies only to a tree carrying the apt marker. Release workflow changes add a build step and one more asset. The risk is in prerm and postrm, which delete files and stop services on hosts. Nothing has run against real systemd or dpkg beyond the container test, which has no systemd, so systemctl stop and disable --now exit codes on a live host are unproven. A bad prerm could make apt remove fail. Purge is irreversible for /var/lib/rigforge, which includes config and backups.

Proof. CI: 1 skipped, 28 success. Reviewer: PASS at acab221 by pithead-reviewer, round 3 (recorded 2026-12-01T05:43:53Z). Bench: no job cited in the PR body.

What to check.

  • packaging/debian/prerm:8-17: runs under set -e, and a non-zero systemctl stop or disable --now on a real host would fail apt remove. Consider trying remove once on a systemd machine.
  • packaging/debian/postrm:9-24: the ownership test decides which units, firewall rules and control state purge deletes. Check that it cannot match a git install, and that rm -rf of /var/lib/rigforge is what you want on purge.
  • docs/getting-started.md:70: it says to run rigforge uninstall before apt purge, but after apt remove the code is already gone. It should say before remove. The reviewer's other notes are also still open: the nft table survives purge, and the prerm and postrm ownership patterns are not compared in tests.
  • rigforge.sh:63-67 and the release.yml hunk around line 158: the marker lookup that sets the package layout, and the deleted comments in the assets block.

Verdict. merge: the reviewer's remaining findings are notes, not blockers. They can be follow-ups, though the docs wording at getting-started.md:70 is a quick fix

VijitSingh97
VijitSingh97 previously approved these changes Dec 1, 2026
@pithead-developer pithead-developer Bot added stage/in-progress and removed stage/awaiting-merge the reviewer's PASS is on the head; merging when checks and the base allow labels Dec 1, 2026
…le budget

rigforge.sh now sources util/layout.sh from its own directory for the apt
layout default and the RIGFORGE_LIB/RIGFORGE_STATE validation, so the merge
with develop stays at the 6028-line ceiling. The lines move unchanged and
the new file joins the kcov include list.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
pithead-developer[bot] and others added 2 commits December 1, 2026 00:43
…t the file budget"

Loading util/layout.sh from the script's directory ran code from there before
the RIGFORGE_LIB checks whenever RIGFORGE_LIB pointed at another tree. The
layout default and the two checks go back inline, unchanged.

This reverts commit ffb7c04.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… the file budget

Merged with develop, rigforge.sh was 6033 lines against its 6028 ceiling.
The config install helper moves unchanged beside the other config-apply
helpers, and the comments in the edited hunk go, leaving rigforge.sh at 6024.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@pithead-developer pithead-developer Bot added stage/in-review a reviewer session is on it now and removed stage/in-progress labels Dec 1, 2026
@pithead-reviewer

Copy link
Copy Markdown
Contributor

PASS

What I investigated

Re-reviewed PR #833 at head 358ac46 against #731 and the slice it delivers, #784, reading the diff ea1e0b1..358ac46 (ea1e0b1 is in this clone; worker commits 710b3d2, 943def8, acab221, ffb7c04, ba46560, 358ac46, plus one merge of develop). The three earlier blockers are fixed and I reproduced each fix with a revert going red; the merge of develop is byte-identical to a mechanical merge, the file-budget commit is a byte-identical move of _config_replace into a file rigforge.sh already sources at startup, and CI is 27 pass and 1 skipping on the head, first attempt. Not checked: nothing ran against real systemd or dpkg (none on this Mac, none in CI), so the exit codes of 'systemctl stop' and 'disable --now' on a live host and setup or upgrade under the apt layout stay unproven, as the body's shortcut and the earlier note F833-18 already record.

  • gh pr view 833 --json: head 358ac46, base develop, author the developer App, open, not a draft; the body says it delivers Build a .deb from the release bundle and attach it to each release (refines #731) #784 as part of Package RigForge as a .deb for DIY installs and publish it through the project APT repository #731 and ticks 6 criteria

  • gh issue view 731 and 784 --json: the architect App's comment on Package RigForge as a .deb for DIY installs and publish it through the project APT repository #731 (2026-12-01T05:10Z) rules config.json is state under /var/lib/rigforge with no shipped conffile and no /etc/rigforge/config.json and dictates the ADR purge line; the developer App's comment on Build a .deb from the release bundle and attach it to each release (refines #731) #784 (2026-12-01T05:17Z) records it. F833-13 is closed by that ruling; docs/adr/0003 line 32 carries the dictated text

  • git log --no-merges ea1e0b1..358ac46: 710b3d2, 943def8, acab221, aff3464 (develop's own squash), ffb7c04, ba46560, 358ac46; git diff --stat 34d9ea5 ba46560 is empty, so the revert of ffb7c04 is exact

  • git merge-tree --write-tree acab221 aff3464 prints e11f0afb4d58, equal to the tree of merge commit 34d9ea5: the merge of develop has no hand edits

  • 358ac46: diff of the _config_replace body in 34d9ea5:rigforge.sh against util/config-apply-state.sh is empty (byte-identical move); rigforge.sh from line 1 through the last startup source is identical to the merge commit; develop (aff3464) already sources util/config-apply-state.sh at startup and scripts/build-release-bundle.sh:49 copies util/ whole; the two callers (rigforge.sh:3541, 4456) are unchanged

  • FILE_BUDGET_REQUIRE_BASE=1 bash scripts/lint-file-budget.sh: rc 0, 'file budget OK'; wc -l rigforge.sh is 6024 against the 6028 ceiling, 6033 at the merge commit, as the body says

  • bash tests/test-config-write-safety.sh: rc 0, 0 FAIL (it calls _config_replace through a sourced rigforge.sh); bash tests/test-tune-gate.sh: rc 0, 'fail=0'

  • F833-11 fixed: my probe of a copied tree with an apt marker gives /var/lib/rigforge/config.json with RIGFORGE_LIB set to the tree for bare name, ./, absolute path, an absolute symlink and a relative symlink run by bare name; a brew marker, no marker and an explicit RIGFORGE_STATE keep their old behaviour. With rigforge.sh:63 put back to the ea1e0b1 form, the bare-name and both symlink forms give /config.json

  • F833-12 fixed: my probe with a stub systemctl and units rendered from systemd/*.template: 'prerm remove' on package paths exits 0 after 14 calls (stop of rigforge-upgrade.service, 8 'disable --now', 5 'stop' on static services); on git-install paths it makes 1 call, the stop of the package's own upgrade unit, and the ownership pattern matches 0 lines there; deconfigure, upgrade and failed-upgrade make 0 calls; a failing 'disable --now xmrig.service' gives rc 5, which tests/test-package-upgrade.sh:138-141 asserts

  • F833-12 revert proof: bash tests/test-package-upgrade.sh with prerm from ea1e0b1 adds 8 FAIL rows (6 static-unit rows, 'leaves a non-package install's units alone', 'deconfigure leaves the miner running'). At the head the only FAIL rows on this Mac are 11 'watchdog enabled/disabled' real-upgrade rows that stop at the XMRig clone; develop at aff3464 fails the same 11 rows here, and CI passes them

  • F833-8 stays fixed: packaging/debian/postinst prints 'sudo rigforge setup'. Earlier notes: F833-14 (release.yml comment lines deleted), F833-15 (no internal repository name in tests/test-build-deb.sh), F833-16 (control has Recommends: linux-tools-generic | linux-cpupower), F833-17 (postinst 'mkdir -p ... || true') and F833-19 (zip branch and CLEANUP array gone, a build test compares the UNITS lines) are fixed; F833-18 is partly answered (static units get 'stop'), with no run on real systemd

  • gh pr checks 833 --json: 28 checks, 27 pass, 1 skipping (Workflow audit issue); gh run view for CI 46593222045, Rust 46593222036, Security 46593222060 and CodeQL 46593222084: headSha 358ac46, conclusion success, attempt 1

  • CI Test suite job 142455915419 log at the head: 'rigforge tests: 2858 passed, 0 failed', 'an apt-marked tree run by bare name uses the package layout', '... run by symlink name ...', 'restore snapshots and atomically replaces config.json ... (api-refresh hides a failed write, and restore overwrites the config with no snapshot #820)', 'api-refresh starts a bounded number of programs ... (Each api-refresh tick starts more than 200 processes #818)', 'package upgrade: all checks passed', 'ok: two builds of one bundle are byte-identical', 'ok: prerm and postrm act on the same unit list', 'build-deb: all checks passed'

  • CI End-to-end job 142455915596 log at the head, step 'assert: deb install pass' on ubuntu:24.04: 'ok: apt install ./rigforge_1.19.0_all.deb, rigforge --version is 1.19.0', 'ok: package marker reads apt', 'ok: nothing was written under /usr/lib/rigforge', 'ok: upgrade to 1.19.1 keeps config and state and queues the package upgrade', 'ok: remove deletes the code and keeps config and state', 'ok: purge leaves no rigforge residue', 'deb install: all checks passed'. The three doctor rows exit 1 because nothing is provisioned in the container; earlier rounds accepted that form

  • bench-ci list --all --fleet --commit 358ac46 --json: rc 0, 0 jobs. The body quotes none; the diff does not touch the worker-to-Pithead contract (rigforge.sh changes are the apt-marker default and the byte-identical move), so tiers 1 to 3 on GitHub are the proof

  • shellcheck --severity=warning on rigforge.sh, util/config-apply-state.sh, scripts/build-deb.sh, the four changed tests and the four packaging scripts: rc 0, no output; shfmt -i 4 -d on the same shell files: rc 0; bash scripts/lint-topology-classes.sh: rc 0

  • Added-comment scan of 710b3d2, 943def8, acab221 and 358ac46 outside docs: no added comment line. git diff aff3464..HEAD -- VERSION CHANGELOG.md: empty. git ls-files has no .rigforge-package marker

  • detect-topology.py over the PR body, the 6 PR comments, and the bodies and 9 comments of Package RigForge as a .deb for DIY installs and publish it through the project APT repository #731 and Build a .deb from the release bundle and attach it to each release (refines #731) #784: rc 0 and 'clean' for all 18 files; the PR has 0 inline review comments

  • Ponytail pass over the round's diff: no must-fix. Performance: rigforge.sh:63 adds one subshell with no exec per CLI start, and the Each api-refresh tick starts more than 200 processes #818 spawn-bound row still passes at the head; not a finding

  • Angle lead rejected (correctness and ops, prerm aborts under set -e): confirmed rc 5 on a failing stop, which the body states as intended and a test asserts; already recorded under F833-18. A service file whose timer file is missing would get a plain 'stop' on the timer; rigforge.sh:1237, 1271, 1358, 1399 and 1420 remove each pair together, so that needs an interrupted setup

  • Angle lead rejected (correctness and ops, comments deleted at rigforge.sh:4086 and in release.yml): the comment rule deletes explanatory comments in an edited hunk; RELEASING.md and SECURITY.md keep the release rationale

  • Angle lead rejected (security, RIGFORGE_PACKAGE_MARKER honoured without the test-override gate): unchanged since the last reviewed head, and a caller who controls root's environment can already set RIGFORGE_STATE directly, so it grants nothing new

  • Angle leads rejected as findings (ops: no timeout-minutes on the e2e job, purge deleting backups, the postinst message after remove and reinstall): all on code unchanged since the last reviewed head and none is a correctness or security defect with a failing input I could show here; the reinstall claim depends on dpkg behaviour I cannot run on this Mac

  • Angle lead confirmed as a note (manifest): tests/manifest.json lists deb-install with needs [] while e2e-container and api-allowlist-linux list needs_docker

  • The round-3 notes F833-20 to F833-23 are unanswered at this head: the body still says prerm 'stops and disables every RigForge unit on remove' and quotes the container run from 92ee84a; docs/getting-started.md:70 still says 'run before apt purge'; nothing in prerm or postrm destroys the loaded nft table; the build test compares the UNITS lines but not the two ownership patterns. They were notes and stay notes

  • [F833-24] tests/manifest.json (deb-install entry): The deb-install suite needs Docker and dpkg-deb but declares needs []. The other Docker suites (e2e-container, api-allowlist-linux) declare needs_docker. A harness that schedules by needs would start it on a host without Docker, where it prints SKIP and exits 0 outside CI. Add needs_docker to the entry.

Reviewed head: 358ac460a8c1c34b7016228e8823761ef194e7e6.

@pithead-reviewer

Copy link
Copy Markdown
Contributor

Owner brief for 358ac460a8c1

What it does. Adds a build script that turns the release tarball into a checksummed, reproducible rigforge .deb. Release CI attaches it to each release and lists it in SHA256SUMS. Installing it puts the code in root-owned /usr/lib/rigforge, adds a /usr/bin/rigforge wrapper, and keeps all state, including config.json, in /var/lib/rigforge. It also adds prerm and postrm scripts for remove and purge.

Why. Part of #731 (milestone v1.21.0), delivering its #784 slice. Debian and Ubuntu DIY operators had no package install, and the apt feed (#786) and safe apt upgrade (#785) had no package to ship. The owner's 2026-12-01 ruling drops the shipped /etc/rigforge conffile from #784, and the ADR purge line is rewritten to match.

Risk. Release-path change: a failure in the new .deb build step would block release assets. rigforge.sh gains startup lines that pick the package layout when the marker reads apt. The prerm and postrm scripts stop units and delete state and unit files on remove and purge, so a bad ownership match could touch a git install's units. Tests guard that case. Nothing ran against real systemd or dpkg upgrade paths, so systemctl stop and disable behaviour on a live host is unproven. Setup and upgrade under the package layout are not run in CI. Purge deletes /var/lib/rigforge, including config and backups.

Proof. CI: 1 skipped, 28 success. Reviewer: PASS at 358ac46 by pithead-reviewer, round 3 (recorded 2026-12-01T07:17:39Z). Bench: no job cited in the PR body.

What to check.

  • packaging/debian/prerm:8-17 and postrm:10-24: the ownership test that decides which units get stopped or deleted. The same pattern is copied in both scripts and the build test pins only the UNITS lines as equal.
  • rigforge.sh:63-67: the new apt-marker block that runs before the RIGFORGE_LIB checks. It must never send state into /usr/lib/rigforge.
  • packaging/debian/postrm:16-18: purge deletes the firewall rules file but nothing destroys the loaded nft table, so the API allowlist may keep filtering until reboot (reviewer note, not run).
  • tests/manifest.json deb-install entry: it declares needs [] although it needs Docker (reviewer note). docs/getting-started.md:70 says to run uninstall before apt purge, but it should say before apt remove or purge.

Verdict. merge: remaining reviewer findings are notes only, and the prerm and postrm behaviour on real systemd is unproven

@pithead-developer pithead-developer Bot added stage/awaiting-merge the reviewer's PASS is on the head; merging when checks and the base allow and removed stage/in-review a reviewer session is on it now labels Dec 1, 2026
@pithead-reviewer
pithead-reviewer Bot merged commit 7d3208e into develop Dec 1, 2026
29 checks passed
@pithead-reviewer
pithead-reviewer Bot deleted the agent/731-package-rigforge-as-a-deb-for-diy-instal branch December 1, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stage/awaiting-merge the reviewer's PASS is on the head; merging when checks and the base allow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Package RigForge as a .deb for DIY installs and publish it through the project APT repository

1 participant