Skip to content

Commit 77627b6

Browse files
authored
Merge pull request #6410 from loopx-project/codex/review-b-architecture-health-20261014-0540
2 parents 3ab0fba + 7581c5b commit 77627b6

3 files changed

Lines changed: 60 additions & 6 deletions

File tree

‎loopx/capabilities/benchmark_toolkit/integrity.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
from typing import Any, TypeGuard, cast
1414
from urllib.parse import urlsplit
1515

16+
from ...control_plane.content_digest import BARE_SHA256_PATTERN as _SHA256_PATTERN
17+
1618
from .environment_access import (
1719
_heredoc_delimiters,
1820
authorized_task_environment_probe_count,
@@ -94,7 +96,6 @@
9496
_EVALUATION_PROTOCOL_OUTPUT_KINDS = frozenset(
9597
{"score", "validation", "metrics", "summary", "diagnostics"}
9698
)
97-
_SHA256_PATTERN = re.compile(r"^[0-9a-f]{64}$")
9899

99100
_DEFAULT_DENIED_ARGUMENT_MARKERS: dict[str, tuple[str, ...]] = {
100101
"restricted_answer_source_request": (

‎tests/architecture/test_content_digest_single_owner.py‎

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
"loopx.capabilities.benchmark_toolkit.behavior_finding",
159159
"loopx.capabilities.benchmark_toolkit.continuation",
160160
"loopx.capabilities.benchmark_toolkit.factorial_contrast",
161+
"loopx.capabilities.benchmark_toolkit.integrity",
161162
"loopx.capabilities.benchmark_toolkit.runtime_continuity",
162163
"loopx.capabilities.benchmark_toolkit.study_projection",
163164
"loopx.capabilities.content_ops.item_lifecycle",
@@ -208,9 +209,15 @@
208209
"loopx.presentation.static_site",
209210
)
210211

211-
# A consumer that hands `re` a pattern this file cannot fold. Pinned empty: folding reads
212-
# every construction in every consumer today, so adding an entry has to be argued.
213-
UNREADABLE_CONSUMER_CONSTRUCTIONS: dict[str, str] = {}
212+
# A consumer that hands `re` a pattern this file cannot fold. Folding reads
213+
# every construction except the declared marker reader, which is fenced below.
214+
UNREADABLE_CONSUMER_CONSTRUCTIONS: dict[str, str] = {
215+
"loopx.capabilities.benchmark_toolkit.integrity": (
216+
"_marker_present matches an escaped caller-supplied filename/token inside "
217+
"command text with explicit basename boundaries; it does not validate a "
218+
"whole-value digest. Its sole dynamic regex is fenced to that reader."
219+
),
220+
}
214221

215222
# Reading `.pattern` off the owner and recompiling it states the decision a second time
216223
# while showing the scan no shape at all. Pinned empty; widening it is a review event.
@@ -1581,3 +1588,49 @@ def test_chat_bundle_source_digest_uses_the_owner_bare_shape() -> None:
15811588
from loopx.presentation import chat_bundle
15821589

15831590
assert chat_bundle.BARE_SHA256_PATTERN is BARE_SHA256_PATTERN
1591+
1592+
1593+
@pytest.mark.parametrize("digest", (*BARE_ACCEPTS, *BARE_REJECTS))
1594+
def test_benchmark_task_authorization_keeps_the_bare_digest_contract(
1595+
digest: str,
1596+
) -> None:
1597+
from loopx.capabilities.benchmark_toolkit.integrity import (
1598+
BENCHMARK_TASK_ENVIRONMENT_ACCESS_SCHEMA_VERSION,
1599+
_validated_task_environment_access,
1600+
)
1601+
1602+
access = {
1603+
"schema_version": BENCHMARK_TASK_ENVIRONMENT_ACCESS_SCHEMA_VERSION,
1604+
"authorization_id": "digest-contract-fixture",
1605+
"authorization_sha256": digest,
1606+
"authority": "benchmark_task",
1607+
"purpose": "task_submission",
1608+
"namespace": "TASKCAP_",
1609+
"variable_names": ["TASKCAP_TOKEN"],
1610+
}
1611+
if digest in BARE_ACCEPTS:
1612+
normalized = _validated_task_environment_access(access)
1613+
assert normalized is not None
1614+
assert normalized["authorization_sha256"] == digest
1615+
else:
1616+
with pytest.raises(
1617+
ValueError,
1618+
match="benchmark_task_environment_access_authorization_sha256_invalid",
1619+
):
1620+
_validated_task_environment_access(access)
1621+
1622+
1623+
def test_benchmark_dynamic_regex_exemption_stays_in_the_marker_reader() -> None:
1624+
analysis = _module_of("loopx.capabilities.benchmark_toolkit.integrity")
1625+
unreadable = [item for item in analysis["constructions"] if not item["readable"]]
1626+
source = (PACKAGE_ROOT / "capabilities/benchmark_toolkit/integrity.py").read_text(
1627+
encoding="utf-8"
1628+
)
1629+
marker_reader = next(
1630+
node
1631+
for node in ast.parse(source).body
1632+
if isinstance(node, ast.FunctionDef) and node.name == "_marker_present"
1633+
)
1634+
assert len(unreadable) == 1, "the marker exception must not hide another matcher"
1635+
assert marker_reader.lineno <= unreadable[0]["line"] <= marker_reader.end_lineno
1636+
assert unreadable[0]["construction"] == "search", "not a whole-value reader"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"schema": "loopx_top_level_module_budget_v0",
3-
"baseline_commit": "9eaacfbf2ff93d5386cee82ddf0847d9c739e78a",
4-
"max_top_level_modules": 147,
3+
"baseline_commit": "14112f36cfa56400851494e4236c84dd74538069",
4+
"max_top_level_modules": 146,
55
"allowlist": ["__init__.py", "entrypoint.py", "cli.py"]
66
}

0 commit comments

Comments
 (0)