From 5544f83679123ca127de70a5882afec2b58a555b Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sat, 14 Nov 2026 09:54:01 +0000 Subject: [PATCH] fix(kvb-check-score): import sibling modules under python -I MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit score.py and backfill.py ran with python -I drop their own directory from sys.path, so the sibling imports failed (Security 2.0 hit it 2026-11-14 02:40). Both now put their resolved script directory first; tests run both scripts isolated. 🎯 Fix: 95 % 💥 Break: 2 % 💸 Tokens: 100 % ⏱️ Velocity: 100 % 🛡️ Security: 100 % 🏆 Score: 93 🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 % Co-Authored-By: Claude Opus 5.5 --- skills/kvb-check-score/scripts/backfill.py | 2 ++ skills/kvb-check-score/scripts/score.py | 2 ++ tests/test_score.py | 9 +++++++++ tests/test_score_backfill.py | 5 +++++ 4 files changed, 18 insertions(+) diff --git a/skills/kvb-check-score/scripts/backfill.py b/skills/kvb-check-score/scripts/backfill.py index 4bdacd8..5248118 100755 --- a/skills/kvb-check-score/scripts/backfill.py +++ b/skills/kvb-check-score/scripts/backfill.py @@ -28,6 +28,8 @@ from collections import deque from pathlib import Path from typing import NamedTuple +sys.path.insert(0, str(Path(__file__).resolve().parent)) + from journal import ( LABELS, append, diff --git a/skills/kvb-check-score/scripts/score.py b/skills/kvb-check-score/scripts/score.py index af40373..bdade04 100755 --- a/skills/kvb-check-score/scripts/score.py +++ b/skills/kvb-check-score/scripts/score.py @@ -54,6 +54,8 @@ import sys import time from pathlib import Path +sys.path.insert(0, str(Path(__file__).resolve().parent)) + from journal import ( LABELS, append, diff --git a/tests/test_score.py b/tests/test_score.py index 268c7c5..f9ff973 100644 --- a/tests/test_score.py +++ b/tests/test_score.py @@ -35,6 +35,15 @@ class TestScore(unittest.TestCase): self.assertEqual(result.stderr, "") return result.stdout.splitlines(), result.returncode + def test_runs_under_python_isolated_mode_from_another_directory(self): + with tempfile.TemporaryDirectory() as elsewhere: + result = subprocess.run( + [sys.executable, "-I", str(SCORE), *flags(BASE), "--message-block"], + cwd=elsewhere, env=ENV, capture_output=True, text=True, check=False, + ) + self.assertEqual((result.returncode, result.stderr), (0, "")) + self.assertIn("🎯 Fix: 95 %", result.stdout) + def test_formula_and_line_format(self): self.assertEqual( self._score(fix="95", **{"break": "4"}), diff --git a/tests/test_score_backfill.py b/tests/test_score_backfill.py index 1bcca93..3c723a0 100644 --- a/tests/test_score_backfill.py +++ b/tests/test_score_backfill.py @@ -49,6 +49,11 @@ class TestBackfill(unittest.TestCase): def rows(self, council: Path) -> list[dict]: return [json.loads(line) for line in (council / JOURNAL_NAME).read_text(encoding="utf-8").splitlines()] + def test_runs_under_python_isolated_mode_from_another_directory(self): + done = subprocess.run([sys.executable, "-I", str(BACKFILL), "--help"], cwd=self.scratch, capture_output=True, text=True, check=False, timeout=HANG) + self.assertEqual((done.returncode, done.stderr), (0, "")) + self.assertIn("--repo", done.stdout) + def test_three_commits_with_blocks_give_three_rows_then_none(self): council = self.council("one") first = backfill(council, "--repo", str(self.fixture.a))