testsAndMisc/docs/superpowers/contracts/setup-midnight-shutdown-split-2026-08-21.json
Krzysztof kuhy Rudnicki d72f03ea93 setup_midnight_shutdown: split into lib/ — the cap is now zero
1734 -> 109 lines across eight libs plus one payload file. This was the last
file over the 250-line cap; check_file_length.sh --all now reports "all
checked files are within 250 lines".

This file needed a different proof from the others. Its product is scripts
generated into /usr/local/bin via heredocs, so "did the functions move
verbatim" is not the question that matters — "does it still emit the same
bytes" is. Every heredoc body was hashed before the split: 11 of 12 are
byte-identical afterwards, and the twelfth (the 224-line config-unlock body)
now lives in lib/payloads/shutdown-config-unlock.sh.in at hash
1a5c67cfd0244101, exactly matching what it replaced. No new bodies appeared.

The "~39 top-level functions" this file is documented as having are not real.
log(), now_epoch(), cmd_add() and friends sit at column 0 because they are
inside the generated scripts. The brace-matching extractor keeps each heredoc
with its owning generator, so they moved as part of it. That is also why
verify_shell_split.sh reports a bare "-log": it cannot tell a heredoc-internal
definition from a top-level one. log() is not lost — it is line 17 of the
payload, which is where it always ran from.

$_MS_PAYLOAD_DIR is defined in the same file as its use, directly above it,
following the _NL_PAYLOAD_DIR lesson from earlier in this campaign.

--help is byte-identical, shellcheck is clean with no suppression added.
`setup` itself is not executed — it installs systemd units, makes the config
immutable and arms a shutdown timer.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F3PzGc75gBcdxP3PkHXGcV
2026-08-21 16:27:54 +02:00

18 lines
1.4 KiB
JSON

{
"title": "Split setup_midnight_shutdown.sh under the 250-line cap",
"objective": "Bring the last over-cap file (1734 lines) under 250 by moving its 20 real top-level functions into eight libs and its largest quoted heredoc into a verbatim payload, without altering any of the scripts it generates into /usr/local/bin.",
"acceptance_criteria": [
"check_file_length.sh --all reports zero files over the cap, with the payloads git-tracked.",
"Every heredoc body is byte-identical before and after, except the one deliberately moved to a payload file whose hash matches it exactly.",
"verify_shell_split.sh shows no unexplained body change; the -log entry is a known heredoc-internal false positive and must be justified, not ignored.",
"--help is byte-identical to the pre-split baseline.",
"shellcheck passes without -x, shfmt is a no-op, no suppression added."
],
"out_of_scope": [
"Running `setup`: it installs systemd units, chattr +i's the config and arms a shutdown timer.",
"Rewriting the deployed /usr/local/bin scripts — unnecessary, since the generated content is provably unchanged.",
"Phase 2 (wiring the cap into pre-commit), which starts only once the cap is at zero."
],
"verifier": "Per-file heredoc body hashing before vs after (the decisive check); verify_shell_split.sh with the -log entry explained; line-multiset check including the payload; diff of --help; shellcheck + shfmt + check_file_length --all."
}