Lease-guard test misses bare-name calls such as from ..gpu import lease
The finding
The test only flags calls where node.func is an ast.Attribute (for example gpu.lease(...) or self._gpu.alease(...)). A module that does from argus_scout.gpu import lease and then calls lease(...) or async with alease(...) produces an ast.Name func node. That call is never flagged. A channel or the echo synthesiser could take a GPU lease around speech using that import style and the test would still pass, which defeats the invariant it is meant to enforce. Separately, the exemption path.name != "gpu.py" matches any file named gpu.py in any subpackage, not only the narrative guard's module.
1| """GPU leases (argus-iris broker): the committed manifest, what a model call leases, where it goes, and what happens
2| when no lease is granted."""
3|
4| from __future__ import annotations
5|
6| import ast
7| import contextlib
8| from pathlib import Path
9|
10| import httpx
11| import pytest
12| from argus_cortex.gpu import GpuLease, GpuLeaseRefused, GpuLeaseTimeout, NullCoordinator, coordinator_from_env
13| from argus_cortex.gpu_wire import load_tenant_manifest
14| from pydantic import ValidationError
15| from test_llm import PROMPT, ollama_reply, openai_reply, stub
16| from test_narrative import narrator, seed
17|
18| from argus_scout import gpu
19| from argus_scout.budget import DailyBudget
20| from argus_scout.config import LLMConfig, LLMGpuConfigThe work pack
Recommendation. Also match isinstance(node.func, ast.Name) and node.func.id in ("lease", "alease"). Better, also flag ImportFrom nodes that import lease/alease. Compare the exemption against the exact relative path, e.g. path.relative_to(SRC) != Path("gpu.py").
Acceptance criteria
- Address: Lease-guard test misses bare-name calls such as
from ..gpu import lease - Keep the change scoped to the cited file/symbols unless impact requires otherwise
- Also match
isinstance(node.func, ast.Name) and node.func.id in ("lease", "alease"). Better, also flagImportFromnodes that importlease/alease. Compare the exemption against the exact relative path, e.g. `path.relative_to(SRC) != P - Re-check
tests/test_gpu.pyafter the fix
Status
- claimed
- resolved
The fix
32938f23c1 test: the GPU lease guard catches bare-name calls and lease imports, and exempts only gpu.py at the root.
@@ -134,18 +134,44 @@ async def test_lease_is_released_before_generate_returns(): assert log == ["acquire", "call", "release", "returned"] +LEASE_NAMES = ("lease", "alease")+++def lease_sites(source: str) -> list[int]:+ """Lines that take a GPU lease, or import a lease function under any name: ``x.lease(...)``, a bare+ ``lease(...)`` / ``alease(...)``, and ``from ... import lease`` (aliased or not)."""+ lines = []+ for node in ast.walk(ast.parse(source)):+ if isinstance(node, ast.Call):+ func = node.func+ name = func.attr if isinstance(func, ast.Attribute) else func.id if isinstance(func, ast.Name) else None+ if name in LEASE_NAMES:+ lines.append(node.lineno)+ elif isinstance(node, ast.ImportFrom) and any(a.name in LEASE_NAMES for a in node.names):+ lines.append(node.lineno)+ return lines+++def test_lease_sites_catch_every_call_and_import_form():+ for source in (+ "gpu.lease()",+ "self._gpu.alease()",+ "lease()",+ "async def f():\n async with alease():\n pass",+ "from argus_scout.gpu import lease as take",+ "from argus_cortex.gpu import alease",+ ):+ assert lease_sites(source), source+ assert lease_sites("release()\nfrom x import leased") == []++ def test_only_the_narrative_guard_takes_a_lease(): """Scout leases only around its own model call; nothing (channels, the echo synthesiser) leases around speech.""" offenders = [] for path in SRC.rglob("*.py"):- for node in ast.walk(ast.parse(path.read_text(encoding="utf-8"))):- leases = (- isinstance(node, ast.Call)- and isinstance(node.func, ast.Attribute)- and node.func.attr in ("lease", "alease")- )- if leases and path.name != "gpu.py":- offenders.append(f"{path.relative_to(SRC)}:{node.lineno}")+ if path.relative_to(SRC) == Path("gpu.py"): # the narrative guard's own module, and only that one+ continue+ offenders += [f"{path.relative_to(SRC)}:{line}" for line in lease_sites(path.read_text(encoding="utf-8"))] assert offenders == [] How it was judged
Waiver evidence waived: Test-only finding: the fix strengthens a test, so the same test runs on both trees and passes on dev's source. Verified locally by mutation: the strengthened test fails when the guarded behaviour is b
Judged 24 Nov 2026, 04:54 UTC against dev at d0c0f66.
This fix strengthens a test. The stronger test passes on dev's code as well, so there is no failure on dev for it to show. It resolved on a written waiver of at least twenty characters, recorded with the pack:
Test-only finding: the fix strengthens a test, so the same test runs on both trees and passes on dev's source. Verified locally by mutation: the strengthened test fails when the guarded behaviour is broken, where the old one passed.