|
158 | 158 | "loopx.capabilities.benchmark_toolkit.behavior_finding", |
159 | 159 | "loopx.capabilities.benchmark_toolkit.continuation", |
160 | 160 | "loopx.capabilities.benchmark_toolkit.factorial_contrast", |
| 161 | + "loopx.capabilities.benchmark_toolkit.integrity", |
161 | 162 | "loopx.capabilities.benchmark_toolkit.runtime_continuity", |
162 | 163 | "loopx.capabilities.benchmark_toolkit.study_projection", |
163 | 164 | "loopx.capabilities.content_ops.item_lifecycle", |
|
208 | 209 | "loopx.presentation.static_site", |
209 | 210 | ) |
210 | 211 |
|
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 | +} |
214 | 221 |
|
215 | 222 | # Reading `.pattern` off the owner and recompiling it states the decision a second time |
216 | 223 | # 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: |
1581 | 1588 | from loopx.presentation import chat_bundle |
1582 | 1589 |
|
1583 | 1590 | 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" |
0 commit comments