testsAndMisc/docs/superpowers/evidence/rpi-nc-install-suite-2026-08-22.json
Krzysztof kuhy Rudnicki 0e843c2a5f Cover rpi_nc_install.sh and fix two latent bugs in the nc_php suite
rpi_nc_install.sh is one 200-line function that apt-installs 24
packages, seeds MariaDB, rm -rf's /var/www/nextcloud, rewrites Apache
and PHP config and installs a www-data crontab. 29 assertions, run for
real inside the jail. The destructive step is the point: a bug in
`rm -rf /var/www/nextcloud` is invisible to any check that does not
actually run it.

Two latent bugs in the ALREADY-COMMITTED nc_php suite, both found by
finally reading its assertion results instead of only its coverage
percentage. It was failing 2 of 29 in isolation:

- the cron entry arrives on crontab's STDIN, not in argv, so asserting
  on the call log could never have passed for the right reason. The
  stub now records stdin.
- configure_mariadb's stdout is eaten by `db_password=$(...)`, so the
  phase-order marker now goes to stderr and the capture reads both.

Suites now: 28 + 30 + 29 = 87 assertions, 0 failures.

KNOWN AND UNEXPLAINED: kcov mis-measures rpi_nc_install.sh at 10/88 =
11.36%, recording lines 13-54 and nothing after -- yet the code past
line 54 provably runs, since /root/.nextcloud_db_password and
/etc/apache2/sites-available/nextcloud.conf both exist afterwards. The
three obvious culprits were each tested against a minimal reproduction
and DISPROVEN: kcov traces fine past a heredoc, into a $( ) command
substitution, and past a heredoc-fed stub reading stdin via $(cat).
The file stays on the allowlist and the suite is kept for its
assertions, not its percentage. Do not 'fix' the number by weakening a
test.

dot_resolver_install.sh 39/39 = 100.00%; nc_php.sh 84/85 = 98.82%.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbD4nco3EgL1UFoZKmKsLE
2026-08-22 11:49:47 +02:00

56 lines
4.5 KiB
JSON

{
"intent": "Cover rpi_nc_install.sh, the next-hardest library on the allowlist, and fix two latent assertion bugs discovered in the already-committed nc_php suite.",
"scope": [
"linux_configuration/scripts/single_use/features/lib/tests/test_rpi_nc_install.sh (new)",
"linux_configuration/scripts/single_use/features/lib/tests/test_nc_php.sh (two assertion bugs fixed)",
"Non-goal: removing either file from the allowlist -- neither meets the 100% bar"
],
"changes": [
"Added test_rpi_nc_install.sh: 29 assertions over the 200-line install phase, including the destructive `rm -rf /var/www/nextcloud` step and the idempotence of the OPcache block.",
"Fixed a latent bug in test_nc_php.sh: the cron entry arrives on crontab's STDIN, not in argv, so the stub now records stdin instead of discarding it. The old assertion could not have failed for the right reason.",
"Fixed a second latent bug in test_nc_php.sh: configure_mariadb's stdout is consumed by `db_password=$(configure_mariadb)`, so the phase-order marker is now written to stderr and the capture reads both streams."
],
"verification": [
{
"command": "run_all.sh inside the jail, reading assertion results rather than only coverage",
"result": "pass - all three suites green",
"evidence": "test_dot_resolver_install.sh 28 passed 0 failed; test_nc_php.sh 30 passed 0 failed; test_rpi_nc_install.sh 29 passed 0 failed; RUNALL EXIT=0."
},
{
"command": "the same suites before the nc_php fixes",
"result": "pass - the two bugs were real and are now gone",
"evidence": "test_nc_php.sh previously reported 27 passed, 2 failed IN ISOLATION -- so this was a genuine defect in the committed suite, not cross-suite interference. It was missed because the earlier session checked coverage percentages without reading the assertion results."
},
{
"command": "shell_coverage_jail.sh --measure for each of the three libs",
"result": "pass for two, MIS-MEASURED for the third",
"evidence": "dot_resolver_install.sh 39/39 = 100.00%; nc_php.sh 84/85 = 98.82%; rpi_nc_install.sh 10/88 = 11.36%."
},
{
"command": "check whether rpi_nc_install.sh's 'uncovered' lines actually execute",
"result": "pass - they do; the low number is a measurement failure, not missing coverage",
"evidence": "After a run inside the jail, /root/.nextcloud_db_password (line 61) and /etc/apache2/sites-available/nextcloud.conf (line 82) both exist, and all 29 assertions pass. kcov records lines 13-54 and nothing after."
},
{
"command": "three minimal reproductions isolating the suspected kcov triggers",
"result": "pass - all three hypotheses DISPROVEN",
"evidence": "kcov traces correctly past a plain heredoc (lines after it hit), into a function called inside `$(...)` (all 4 body lines hit), and past a heredoc-fed stub that reads stdin via `$(cat)` (lines after it hit). The cause of the rpi_nc_install mis-measurement remains unknown."
},
{
"command": "shellcheck on the new and modified files",
"result": "pass - clean, no suppressions",
"evidence": "Both test files clean."
}
],
"risks": [
"rpi_nc_install.sh is measured at 11.36% by a tool that provably under-reports it, so the number in the ledger is not trustworthy for this file. It STAYS on the allowlist. The suite is kept for its 29 assertions rather than its percentage, and the anomaly is documented in the file header so a later session does not 'fix' the number by weakening a test.",
"The kcov mis-measurement is an unexplained hole in the campaign's primary instrument. If it affects other subjects, their percentages are also suspect. Nothing so far suggests it does -- the other two libs in the same directory measure sensibly -- but it has not been bounded.",
"The unzip stub must MATERIALISE /var/www/nextcloud, because the phase `rm -rf`s that directory and then unzips over it. A record-only stub leaves the later `cd` with nothing to enter, the function returns 1, and `set -e` aborts the suite from inside a command substitution with NO stderr at all.",
"This session's earlier commit of test_nc_php.sh shipped two failing assertions. Coverage percentage was checked; assertion results were not. Both are needed."
],
"rollback": [
"git revert this commit; nothing is wired into a hook, so no commit path breaks.",
"After rollback, confirm dot_resolver_install.sh still measures 39/39 and that test_nc_php.sh returns to its previous 27-passed/2-failed state."
]
}