From 4585cda3ff2aa9e250f87c808b92a65da4c2e460 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 26 Aug 2026 15:13:40 -0400 Subject: [PATCH] =?UTF-8?q?fix(rules):=20import=20or=5F=20in=20rulebooks?= =?UTF-8?q?=20=E2=80=94=20the=20tier=20gate=20used=20it=20unimported=20(#3?= =?UTF-8?q?031)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NameError at runtime: the tier/area clause and co_surfaced_partners both build an or_(), which rulebooks.py never imported. py_compile passes on this (it is a name error, not a syntax error) and so did the whole unit suite. Where it surfaced is the useful part. The unit tests mock the session, so the project-areas query returns empty, `reachable` stays None, and the or_ branch is never taken — they exercised the path that avoids the bug. Only the integration lane, with a real project and real rows, went down the branch that needed the name. Six integration tests caught it, including the inception one that merely calls get_applicable_rules in passing. A reminder about which lane proves what: mocking the thing that selects the branch means the branch is untested by construction. Co-Authored-By: Claude Opus 5 (1M context) --- src/scribe/services/rulebooks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scribe/services/rulebooks.py b/src/scribe/services/rulebooks.py index c24020a..aece902 100644 --- a/src/scribe/services/rulebooks.py +++ b/src/scribe/services/rulebooks.py @@ -10,7 +10,7 @@ from __future__ import annotations import logging from typing import Optional -from sqlalchemy import delete as sql_delete, insert, select +from sqlalchemy import delete as sql_delete, insert, or_, select from scribe.models import async_session from scribe.models.system import System