web lint hook: run the reviewed copy's source checks when a push also changes scripts/cmux-next; INPUTS typos fail the tests
Summary
Stacked on #34046 (land it first; until then this diff also shows its two commits). Three follow-ups to the pre-push web lint's per-check INPUTS:
-
A typo in
INPUTSturned coverage off with no error. A new test reads everypython3source check of the real webviewscheck. If a script assignsINPUTS,declared_inputs()must be able to read it, and every entry must match at least one tracked file (a glob must have a match). A wrong path now failstests/test_web_lint_prepush.py; I confirmed this by changingcheck-toast-targets.py's entry toSourcesx/**/*.swift. -
The c0230efd501 case.
- Why the hook refused: the trust boundary. The hook never runs code that a push changes. c0230efd501 changed
scripts/cmux-next/media/states/*.json, andscripts/cmux-next/is code the webviews check executes, so the hook did not lint that push at all, and the ringed Swift field passed. - The hook can still check that push. It holds a reviewed copy of
scripts/cmux-next(--trusted-scripts-dir, refreshed from feat-cmux-next). When every executed file that the push changes is in that folder, the hook now runs the declared source checks that the changed files feed, from that copy, on the pushed tree. TheirINPUTSalso come from the copy. - Each check runs under the hook's own interpreter with
-I, as though it sat at its own path in the pushed tree. (Each check finds the repository from__file__.) ''and the working directory leavesys.pathbefore any import, so a module that the push adds can never stand in for the standard library. A test pushesscripts/cmux-next/argparse.pyand confirms that it never loads.- A check whose own script the push changes is not run, and the hook names it. The copy would judge the push by the rule that the push replaces; CI's web lint checks the new rule.
- On the real c0230efd501, the hook now refuses the push at
AllThemesPlaygroundView.swift:18. Text-focus, toast-targets, dialog-keys and catalog-keys run in 2.5 s or less each. - The module docstring states the trust boundary and this case. It no longer claims that #34046 covered c0230efd501.
- Why the hook refused: the trust boundary. The hook never runs code that a push changes. c0230efd501 changed
-
A check that cannot fail is not in the pre-push set.
check-system-blue.pyonly warns (it always exits 0), so it no longer declaresINPUTS. This matchescheck-attachment-caps. A test keeps both withoutINPUTS.
No CI job, step or gate is added.
Testing
Red on 925f866d056 (#34046's head; the tests are in their own commit), green on the head:
(cd tests && python3 -m unittest -k scripts_cmux_next -k reviewed_copy -k check_script -k only_warns -k swift test_web_lint_prepush)
On the base, 6 tests fail: the push with a state file and a ringed field reaches origin (on a build host and with CMUX_LOCAL_HEAVY_CHECKS=0); the shadowing-module push and the changed-rule push are not handled; system-blue still declares INPUTS. On the head, all pass.
Observed / Not run
Observed:
python3 tests/test_web_lint_prepush.py: 67 tests OK.- The INPUTS test fails on a wrong path (
'Packages/macOS/CmuxNext/Sourcesx/**/*.swift' matches no tracked file) and passes on the real paths. make_planandrun_planon c0230efd501 (a worktree of that commit, this branch'sscripts/cmux-nextas the trusted copy): text-focus is red atAllThemesPlaygroundView.swift:18; toast-targets, dialog-keys and catalog-keys pass.python3 scripts/cmux-next/prepush-gate.py: no new violations.scripts/web-lint.sh: only the base red atAllThemesPlaygroundView.swift:18(#34025 fixes it).
Not run:
- A real push of c0230efd501's shape through an installed hook on a Mac. The tests use the real
git pushand the installed hook in a throwaway repository. - This Linux host's git guard refuses the existing
tree_of's-c core.hooksPath=/dev/null. That code is older than this PR and this PR does not change it.
Changelog
none
Proof
No capture: hook tooling only.
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
Improves the pre-push web lint so Swift-only changes and pushes that also modify scripts/cmux-next are still linted. The hook now runs the specific source-check pieces that read changed files (declared in each script's INPUTS) instead of skipping or refusing the push, and INPUTS typos now fail the test suite.
Key changes
- Source-check scripts declare what they read via
INPUTS; the hook runs only those pieces when a push touches them, skipping installs and the rest of the check. - Pushes that change executed script code under
scripts/cmux-nextuse the hook's reviewed copy to run the affected pieces on the pushed tree, as long as no check script itself changed; the runner blocks every way to load or start code from the pushed tree (imports, module spec loads, code-file opens,ctypes.dlopen, and subprocess oros.exec*of a tree program) and reads the reviewed script before the guards go in, and a piece the copy lacks is named instead of dropped silently. check-system-blue.pyandcheck-attachment-caps.pydeclare noINPUTSsince they only warn.- A new test verifies every declared
INPUTSpattern matches at least one tracked file, and finds the bindings viaast, so typed or unspaced declarations count and a typo can't silently disable coverage.