mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 17:34:04 +01:00
verify_shell_split.sh sources the libs and never calls them, which is why
analyze_repo.sh shipped broken after passing every static check. This runs
the script for real with ~30 mutating binaries (sudo, pacman, systemctl,
adb, nft, mount, reboot...) shadowed by PATH stubs that record their calls
and exit 0, then prints a diffable trace: exit status, stubbed calls in
order, stdout, stderr.
Verified against both bugs the handoff documents: it catches the `set -e`
function-tail abort (exit 1, later calls absent from the trace) and the
self-referencing nameref (exit 0, correct stdout, `circular name
reference` in stderr). `systemctl is-active foo` stayed inactive across
all three runs, so nothing reached the live system.
This is what lets Decision 6 ("never execute an enforcement script") and
the user's "run-and-diff always" coexist. Handoff updated with both, plus
the win32_window.cpp resolution: it is tracked and listed in
CMakeLists.txt, so gitignore cannot work -- the exemption belongs in
~/utils/file_length/config.py.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
48 lines
3.2 KiB
JSON
48 lines
3.2 KiB
JSON
{
|
|
"intent": "Add an execution-trace harness so shell splits can be verified by running the script with mutating commands stubbed, closing the gap that let a green-but-broken split ship.",
|
|
"scope": [
|
|
"meta/scripts/trace_shell_split.sh (new)",
|
|
"Non-goal: does not replace verify_shell_split.sh; that still covers syntax, lint and source-line resolution"
|
|
],
|
|
"changes": [
|
|
"New harness that shadows 30 mutating binaries (sudo, pacman, systemctl, adb, nft, mount, mkinitcpio, reboot...) with PATH stubs that record their invocation and exit 0, runs the target script, and prints a diffable trace: exit status, stubbed calls in order with arguments, stdout, stderr.",
|
|
"Trace is the comparison artifact: capture at the pre-split commit and after the split, then diff."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "trace_shell_split.sh on a fixture reproducing the `set -e` function-tail bug",
|
|
"result": "pass (bug detected)",
|
|
"evidence": "exit status 1, empty stdout, and the later `sudo systemctl restart foo` absent from the trace -- the script died silently at the false conditional tail. This is the analyze_repo.sh failure that bash -n, shellcheck, a function-set diff and the stubbed probe all passed."
|
|
},
|
|
{
|
|
"command": "trace_shell_split.sh on the same fixture with `|| true` appended",
|
|
"result": "pass",
|
|
"evidence": "exit status 0, trace records 'sudo systemctl restart foo', stdout shows 'detected: py=true' and 'done'. The two traces differ, so the harness discriminates rather than always agreeing."
|
|
},
|
|
{
|
|
"command": "trace_shell_split.sh on a fixture reproducing the self-referencing nameref bug",
|
|
"result": "pass (bug detected)",
|
|
"evidence": "exit status 0 and correct stdout, but stderr carries four 'circular name reference' warnings that a trace diff surfaces. This bug is invisible to exit-status checking alone."
|
|
},
|
|
{
|
|
"command": "systemctl is-active foo",
|
|
"result": "pass",
|
|
"evidence": "inactive -- the stub absorbed the call; the live system was not touched by any of the three runs."
|
|
},
|
|
{
|
|
"command": "shellcheck + shfmt -d on meta/scripts/trace_shell_split.sh",
|
|
"result": "pass",
|
|
"evidence": "Both clean. SC2155 fixed by splitting declare from assign rather than suppressing. Banner count 2 before and 2 after shfmt -w (that formatter is known to delete banners). Re-ran both fixtures after formatting and behaviour was unchanged."
|
|
}
|
|
],
|
|
"risks": [
|
|
"Stubs always exit 0, so a script branching on a real failure exit status takes a path it would not take live; such cases need a hand-written stub and a note in that split's evidence.",
|
|
"A mutating command not in STUBBED_COMMANDS runs for real. The list must be extended deliberately before tracing a script that uses something new -- check with a grep for mutating verbs first.",
|
|
"Not a substitute for reading the diff: an identical trace proves the same calls happened, not that the split is well-factored."
|
|
],
|
|
"rollback": [
|
|
"Delete meta/scripts/trace_shell_split.sh; no other file imports it.",
|
|
"Shell splits fall back to verify_shell_split.sh plus the by-hand checks in docs/shell-split-verification.md."
|
|
]
|
|
}
|