From 2be17828a9182a3ff62414075c2a9ee0ef1d1719 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Sun, 20 Sep 2026 22:33:22 -0400 Subject: [PATCH] fix(ledger): live_rows_for called access with nothing in scope (#4208) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lint caught an F821 that would have been a NameError the first time `stamps_to_review` was called: `access` is imported locally inside each of the seven functions in this module that need it — services/access reaches back here, so a module-level import closes a cycle — and the new function used it without one. I wrote the function by pattern-matching its neighbours and did not check what those neighbours do to make themselves work. Same shape as the tuple unpack two commits ago (#4207): the mistake is not in the logic I was thinking about, it is in the surrounding contract I did not read. Unit and integration were both green on the failing run (7095); only lint was red. Worth recording because the lane that caught it is the cheapest one and I had read its command as covering tests — `ruff check src/ scripts/` does not look at tests/ at all, so a clean test suite says nothing about it. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01821k5B3Ysecp9fNYs92Kuy --- src/scribe/services/shape_ledger.py | 4 ++++ tests/test_stamps_to_review.py | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/scribe/services/shape_ledger.py b/src/scribe/services/shape_ledger.py index cab9635..4c130e0 100644 --- a/src/scribe/services/shape_ledger.py +++ b/src/scribe/services/shape_ledger.py @@ -444,6 +444,10 @@ async def live_rows_for(user_id: int, project_id: int) -> list[CodeShape]: outside (an MCP tool, a route) rather than from a job that already established who is asking. Empty for a project the caller cannot read, never a partial answer.""" + # Deferred, like every other access import in this module: services/access + # reaches back here, and a module-level import closes the cycle. + from scribe.services import access + if not await access.can_read_project(user_id, project_id): return [] return await live_rows(project_id) diff --git a/tests/test_stamps_to_review.py b/tests/test_stamps_to_review.py index 115dafc..eb7acb7 100644 --- a/tests/test_stamps_to_review.py +++ b/tests/test_stamps_to_review.py @@ -22,8 +22,6 @@ hook's own history is made of. """ - - import pytest from scribe.services.shape_ledger import (