mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 17:34:04 +01:00
A shell library under a lib/ directory must now sit beside a tests/run_all.sh. This is a presence gate, not a coverage percentage: Phase 1 measured these libs' decision logic at ~90% under test but their effecting code at 0%, because it sudo-writes, pkills and installs. A numeric bar would only be reachable by shimming every external for every installer, or by the suppressions this repo forbids. Seeded at 125 exempt libraries out of 208 tracked; the other 83 already have a suite. The allowlist shrinks only — a modified library loses its exemption and must bring tests. Verified standalone: blocks a new untested lib (exit 1), and does NOT block covered libs, exempt libs, or unrelated entry scripts. That last case is the point of a ratchet over the repo-wide gate. The .pre-commit-config.yaml entry is deliberately NOT included — the edit was denied as a sensitive file, so the gate is runnable but not yet enforced.
58 lines
4.3 KiB
JSON
58 lines
4.3 KiB
JSON
{
|
|
"intent": "Phase 3: make a shell library unable to enter the repo without a test suite beside it, without blocking commits to the 125 libraries that predate the rule.",
|
|
"scope": [
|
|
"meta/scripts/check_shell_coverage.sh — new ratchet gate",
|
|
"meta/shell-coverage-allowlist.txt — seeded exemption list, shrink-only",
|
|
"NON-GOAL: a coverage percentage. Phase 1 measured the effecting code in these libs at 0% (sudo/pkill/curl/npm paths), so a numeric bar is only reachable via mass shimming or the suppressions this repo forbids. This gate checks for the PRESENCE of a suite.",
|
|
"NON-GOAL: entry scripts. Scope is .sh under a lib/ dir, excluding lib/tests/ and lib/payloads/.",
|
|
"NOT LANDED: the .pre-commit-config.yaml hook entry. The edit was denied as a sensitive file; the gate is standalone-runnable but not yet enforced."
|
|
],
|
|
"changes": [
|
|
"check_shell_coverage.sh gates named files (hook mode), reports repo-wide state (--all), and reseeds the exemption list (--seed).",
|
|
"A library counts as covered when its directory has a tests/run_all.sh. 4 such suites exist: digital_wellbeing, hosts, periodic_background, single_use/utils.",
|
|
"Allowlist seeded at 125 uncovered libraries out of 208 tracked lib files; the remaining 83 already sit beside a suite.",
|
|
"Discovery uses `git ls-files`, which excludes the .venv/.ci-mirror-venv/node_modules pollution that inflated a raw `find` to 565 files."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "bash meta/scripts/check_shell_coverage.sh --seed && bash meta/scripts/check_shell_coverage.sh --all",
|
|
"result": "pass",
|
|
"evidence": "seeded allowlist with 125 uncovered librar(ies); --all reports '125 uncovered, 125 exempt' and 0 BLOCK lines — the ratchet starts green."
|
|
},
|
|
{
|
|
"command": "bash meta/scripts/check_shell_coverage.sh <a new lib with no suite>",
|
|
"result": "pass",
|
|
"evidence": "exit=1. Blocked _ratchet_probe.sh under single_use/features/lib and named the required path single_use/features/lib/tests/run_all.sh. Probe file removed afterwards; tree confirmed clean. This is the case proving the gate has teeth."
|
|
},
|
|
{
|
|
"command": "bash meta/scripts/check_shell_coverage.sh meta/scripts/check_file_length.sh",
|
|
"result": "pass",
|
|
"evidence": "exit=0 on an unrelated non-lib entry script. This is the negative case that distinguishes a ratchet from the repo-wide gate that was rejected: unrelated commits are not blocked."
|
|
},
|
|
{
|
|
"command": "bash meta/scripts/check_shell_coverage.sh linux_configuration/scripts/single_use/utils/lib/cco_state.sh; and phone_focus_mode/lib/adb.sh",
|
|
"result": "pass",
|
|
"evidence": "exit=0 for a covered library (suite present) and exit=0 for an allowlisted one (exempt until modified)."
|
|
},
|
|
{
|
|
"command": "shellcheck meta/scripts/check_shell_coverage.sh; shfmt -d meta/scripts/check_shell_coverage.sh",
|
|
"result": "pass",
|
|
"evidence": "shellcheck clean, shfmt reports no diff. No suppressions added."
|
|
},
|
|
{
|
|
"command": "grep -nE '\\[[a-z0-9]+ - ' meta/scripts/check_shell_coverage.sh meta/shell-coverage-allowlist.txt",
|
|
"result": "pass",
|
|
"evidence": "Empty. The shfmt hyphenated-associative-key corruption canary from Phase 1 is clean."
|
|
}
|
|
],
|
|
"risks": [
|
|
"The gate proves a suite EXISTS beside a library, not that the suite exercises that particular file. A directory with a run_all.sh can gain an untested library silently. Presence is the strongest property enforceable without the forbidden suppressions; tightening it to per-file assertions is future work.",
|
|
"--seed rewrites the allowlist from the current tree, so running it after adding an untested library would exempt that library. The header says it may only ever be used to remove entries; nothing mechanically enforces the shrink-only rule yet.",
|
|
"Adding a tests/run_all.sh to a large exempt directory (features/lib has 45 entries) makes all of them enforced at once, which may surface a large batch of work in one commit."
|
|
],
|
|
"rollback": [
|
|
"Delete meta/scripts/check_shell_coverage.sh and meta/shell-coverage-allowlist.txt. Nothing else references them while the hook entry remains unlanded.",
|
|
"After rollback confirm `bash meta/scripts/check_file_length.sh --all` still exits 0 and that pre-commit runs unchanged — this change adds no dependency any other hook consumes."
|
|
]
|
|
}
|