test(adopt): bind the compatibility tables to code, and check apply's safety

Runbook 11.1 and 11.2 are decision tables, and nothing tied them to branches:
the two existing antivirus-legacy tests asserted only that kdb/kdb.yaml was
preserved, which stayed true while the surrounding behaviour was wrong. These
cases are parametrized over the table rows so prose and code cannot drift apart
again without a failure.

Writing them found two defects that no existing test could see. splice_managed_block
validated the file it patched but never the block being inserted, so a
hand-edited plan carrying unbalanced markers would have been written in and only
failed on a later run. And the adoption output schemas were validated nowhere,
which had let the richer content roots from the previous commit silently stop
conforming to AdoptionAssessment.

- table-driven coverage of the knowledge and agent-entrypoint rows
- path escape, forbidden path, dirty gate, rollback and preserve-tampering cases
- schema conformance for assessment, plan, report and the generated contract
- widen proposedContentRoots for writePolicy/generatedFrom, and constrain
  authority to the enum it always should have used
- add a synthetic_repo fixture instead of a fourth copy of git init

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Alexander Baranov
2026-08-24 18:48:54 +03:00
co-authored by Claude Opus 5
parent 005419a0ba
commit e5a42fa446
4 changed files with 325 additions and 1 deletions
+24
View File
@@ -34,6 +34,30 @@ def make_repo(tmp_path):
return _make
@pytest.fixture
def synthetic_repo(tmp_path):
"""Build a repository from an explicit path -> content mapping.
The checked-in fixtures cover two concrete legacy layouts; the adoption
compatibility tables need many small permutations of knowledge files and
agent entrypoints, which are clearer written inline than as dozens of
near-identical fixture trees.
"""
def _make(files: dict[str, str], *, name: str = "repo", git: bool = True) -> Path:
dest = tmp_path / name
dest.mkdir(parents=True, exist_ok=True)
for relative, content in files.items():
target = dest / relative
target.parent.mkdir(parents=True, exist_ok=True)
target.write_text(content, encoding="utf-8")
if git:
_git_init(dest)
return dest
return _make
@pytest.fixture
def negative_repo(tmp_path):
"""Materialize a negative/<name>/contract.yaml fixture as ops/contract.yaml under a fresh repo."""