diff --git a/docs/superpowers/evidence/i3blocks-daily-limits-click-2026-10-09.json b/docs/superpowers/evidence/i3blocks-daily-limits-click-2026-10-09.json deleted file mode 100644 index 960848d4..00000000 --- a/docs/superpowers/evidence/i3blocks-daily-limits-click-2026-10-09.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "intent": "Left-clicking the ⏻ or 🎮 i3blocks block opens the daily-limits popup; before this, every click was a silent no-op.", - "scope": [ - "linux_configuration/i3blocks/gaming_budget.sh, shutdown_countdown.sh", - "linux_configuration/tests/test_i3blocks_gaming_budget.sh, test_i3blocks_shutdown_hint.sh" - ], - "changes": [ - "Root cause: the i3blocks process PATH has no ~/.local/bin, where daily-limits' install.sh puts the binary, so `command -v daily-limits` failed and the click was dropped", - "Both blocks call DAILY_LIMITS_BIN (default $HOME/.local/bin/daily-limits) by path, detached with setsid -f", - "A missing launcher raises a critical notify-send instead of doing nothing", - "Regression tests: click with PATH=/usr/bin:/bin runs `--gui`; missing launcher notifies" - ], - "verification": [ - { - "command": "env -i PATH=/usr/local/bin:/usr/bin:/bin BLOCK_BUTTON=1 DAILY_LIMITS_BIN= bash i3blocks/{gaming_budget,shutdown_countdown}.sh (i3blocks' real PATH from /proc//environ)", - "result": "pass", - "evidence": "stub log: 'clicked --gui' twice; block output unchanged (🎮 2h35 left · 2h25/5h00 ..., ⏻ 22:00 ... →max 23:00)" - }, - { - "command": "capped.sh bash tests/test_i3blocks_gaming_budget.sh; test_i3blocks_shutdown_hint.sh; test_i3blocks_efficiency.sh", - "result": "pass", - "evidence": "All gaming_budget checks passed. / All shutdown hint tests passed. / All i3blocks efficiency regression tests passed." - } - ], - "risks": [ - "If daily-limits is installed elsewhere, DAILY_LIMITS_BIN must be set in the i3blocks environment" - ], - "rollback": [ - "git revert this commit; clicks go back to doing nothing under i3blocks' PATH" - ] -} diff --git a/docs/superpowers/evidence/pytest-hook-installs-test-deps-2026-11-16.json b/docs/superpowers/evidence/pytest-hook-installs-test-deps-2026-11-16.json new file mode 100644 index 00000000..08133735 --- /dev/null +++ b/docs/superpowers/evidence/pytest-hook-installs-test-deps-2026-11-16.json @@ -0,0 +1,37 @@ +{ + "intent": "pre-commit's pytest hook stops failing with a collection ImportError when meta/requirements-test.txt gains a pin the hook's interpreter lacks (fastmcp from a4738c6f), and main's CI pre-commit job goes green again.", + "scope": [ + "meta/scripts/pytest_changed_packages.py: install absent test pins before running pytest", + "meta/requirements.txt: gatelock 0.13.0 -> 0.14.0, types-python-dateutil 2.9.0.20261104 -> 2.9.0.20261116", + "Non-goal: upgrading present packages at other versions; only absent ones are installed" + ], + "changes": [ + "pytest_changed_packages.py lists requirements-test.txt pins whose distribution is not installed (pip comment rule keeps #subdirectory URL fragments) and pip-installs them into the running interpreter (--user --break-system-packages outside a venv) before pytest; a failed install fails the hook", + "Bumped the two pins the dependency-freshness gate reports behind latest stable (the cause of main's red Pre-commit checks run 43829221139)" + ], + "verification": [ + { + "command": "python meta/scripts/pytest_changed_packages.py x.py (system python, before fix)", + "result": "fail", + "evidence": "ModuleNotFoundError: No module named 'fastmcp'; 3 errors during collection, rc=2" + }, + { + "command": "python meta/scripts/pytest_changed_packages.py x.py (system python, after fix)", + "result": "pass", + "evidence": "Installing missing test requirements: fastmcp==4.2.0 pytest-sugar==1.1.1; 1824 passed, coverage 100.00%, rc=0" + }, + { + "command": "scripts/check_dependency_freshness.sh --refresh meta/requirements.txt meta/requirements-test.txt", + "result": "pass", + "evidence": "before: 2 findings (gatelock, types-python-dateutil), rc=1; after: rc=0" + } + ], + "risks": [ + "The hook now needs network the first time a new test pin appears; offline it fails closed with a clear message instead of an ImportError", + "Installs into the user site of the system interpreter, matching how the existing test deps got there" + ], + "rollback": [ + "git revert this commit", + "Re-run pre-commit run --all-files and confirm the fastmcp ImportError returns only where fastmcp is absent" + ] +} diff --git a/meta/requirements.txt b/meta/requirements.txt index cf473217..e5de71ef 100644 --- a/meta/requirements.txt +++ b/meta/requirements.txt @@ -36,7 +36,7 @@ flake8-pyi==26.5.0 flake8-pytest-style==2.2.0 flake8-return==1.2.0 flake8-simplify==0.31.1 -gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.13.0#subdirectory=gatelock +gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.14.0#subdirectory=gatelock genanki==0.13.1 geopandas==1.2.0 howlongtobeatpy==1.0.24 @@ -86,7 +86,7 @@ secretstorage==3.5.0 selenium==4.52.0 sql_drills @ git+https://github.com/kuhyx/utils@sql-drills-v0.2.2#subdirectory=sql_drills typer==0.29.1 -types-python-dateutil==2.9.0.20261104 +types-python-dateutil==2.9.0.20261116 types-PyYAML==6.0.12.20261113 types-requests==2.33.0.20261030 types-setuptools==84.2.0.20261104 diff --git a/meta/scripts/pytest_changed_packages.py b/meta/scripts/pytest_changed_packages.py index bee54445..5a7889eb 100755 --- a/meta/scripts/pytest_changed_packages.py +++ b/meta/scripts/pytest_changed_packages.py @@ -17,8 +17,10 @@ they are not coverage-measured (coverage stays scoped to ``python_pkg``). from __future__ import annotations +from importlib import metadata import os from pathlib import Path +import re import shutil import subprocess import sys @@ -35,6 +37,50 @@ _TOTAL_MEM = "2G" # not coverage-measured. Skipped silently if the directory does not exist. _EXTRA_TEST_DIRS = ("linux_configuration/tests",) +# The suite's own dependency list. A pin added here (fastmcp, 2026-11) used to +# reach every checkout whose interpreter never installed it as a collection +# ImportError; the preflight below installs it instead. +_TEST_REQUIREMENTS = Path("meta/requirements-test.txt") +# pip's comment rule: "#" at line start or after whitespace. A bare "#" is a +# URL fragment (``#subdirectory=sql_drills``) and must survive. +_COMMENT = re.compile(r"(^|\s)#.*$") +_DIST_NAME = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._-]*") + + +def _missing_requirements() -> list[str]: + """Return the ``name==version`` pins whose distribution is not installed.""" + if not _TEST_REQUIREMENTS.is_file(): + return [] + missing = [] + for raw in _TEST_REQUIREMENTS.read_text(encoding="utf-8").splitlines(): + pin = _COMMENT.sub("", raw).strip() + name = _DIST_NAME.match(pin) + if name is None: # blank, or a "-r"/"-c" option line + continue + try: + metadata.distribution(name.group(0)) + except metadata.PackageNotFoundError: + missing.append(pin) + return missing + + +def _install_missing_requirements() -> int: + """Install absent test pins into this interpreter; 0 when nothing is missing. + + Only ABSENT packages are installed: a present one at another version is + left alone, so the hook never churns a working environment. Outside a venv + the system interpreter is externally managed, so it goes to the user site. + """ + missing = _missing_requirements() + if not missing: + return 0 + sys.stdout.write(f"Installing missing test requirements: {' '.join(missing)}\n") + sys.stdout.flush() + cmd = [sys.executable, "-m", "pip", "install", "--quiet"] + if sys.prefix == sys.base_prefix: + cmd += ["--user", "--break-system-packages"] + return subprocess.run([*cmd, *missing], check=False).returncode + def main() -> int: """Entry point.""" @@ -49,6 +95,11 @@ def main() -> int: if not packages: return 0 + installed = _install_missing_requirements() + if installed != 0: + sys.stderr.write("Installing the missing test requirements failed.\n") + return installed + test_dirs = [f"python_pkg/{pkg}/tests" for pkg in packages] test_dirs += [d for d in _EXTRA_TEST_DIRS if Path(d).is_dir()]