Skip to content

Commit c71d341

Browse files
committed
test(security): preserve local-only truncation boundary
Signed-off-by: Narendran Raghavan <[email protected]>
1 parent 3c24a01 commit c71d341

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎tests/nodes/test_build_context.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,27 @@ def test_truncated_text_file_stays_in_llm_cache_with_audit_gap_marker(
14381438
assert artifact["disposition"] == "partial"
14391439

14401440

1441+
def test_source_local_only_truncated_text_stays_out_of_provider_cache(
1442+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
1443+
) -> None:
1444+
"""The truncated-file LLM view must not widen a local-only trust boundary."""
1445+
import skillspector.nodes.build_context as build_context_module
1446+
1447+
monkeypatch.setattr(build_context_module, "MAX_ANALYZABLE_FILE_BYTES", 64)
1448+
marker = "PRIVATE_TRUNCATED_CHILD_MARKER"
1449+
(tmp_path / "SKILL.md").write_text("# private child\n", encoding="utf-8")
1450+
(tmp_path / "server.py").write_text(marker + "\n" + "x" * 256, encoding="utf-8")
1451+
1452+
result = build_context({"skill_path": str(tmp_path), "source_local_only": True})
1453+
1454+
assert marker in result["local_file_cache"]["server.py"]
1455+
assert result["llm_file_cache"] == {}
1456+
assert result["llm_components"] == []
1457+
artifact = next(item for item in result["artifact_inventory"] if item["path"] == "server.py")
1458+
assert artifact["disposition"] == ArtifactDisposition.PARTIAL
1459+
assert artifact["reason"] == LedgerReason.SIZE_LIMIT.value
1460+
1461+
14411462
def test_build_context_shares_artifact_budget_across_child_bundles(tmp_path: Path) -> None:
14421463
"""A second child sees the artifact allowance already consumed by its sibling."""
14431464
from skillspector.cli import _TransitiveBudget, _TransitiveTraversalState

0 commit comments

Comments
 (0)