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:
co-authored by
Claude Opus 5
parent
005419a0ba
commit
e5a42fa446
@@ -54,6 +54,18 @@ def splice_managed_block(text: str, block: str) -> str:
|
||||
agent reads it first. Malformed or duplicated markers raise rather than
|
||||
guess at the author's intent.
|
||||
"""
|
||||
# The block arrives from a plan file, which can be hand-edited: inserting one
|
||||
# with unbalanced markers would corrupt the boundary this function relies on
|
||||
# and only fail on some later run.
|
||||
if block.count(MANAGED_BLOCK_START) != 1 or block.count(MANAGED_BLOCK_END) != 1:
|
||||
raise AdoptionError(
|
||||
"ADOPT_MANAGED_BLOCK_MALFORMED", "Replacement block must carry exactly one marker pair"
|
||||
)
|
||||
if block.index(MANAGED_BLOCK_END) < block.index(MANAGED_BLOCK_START):
|
||||
raise AdoptionError(
|
||||
"ADOPT_MANAGED_BLOCK_MALFORMED", "Replacement block ends before it starts"
|
||||
)
|
||||
|
||||
start_count = text.count(MANAGED_BLOCK_START)
|
||||
end_count = text.count(MANAGED_BLOCK_END)
|
||||
if start_count > 1 or end_count > 1:
|
||||
|
||||
@@ -60,7 +60,9 @@
|
||||
"id": { "type": "string" },
|
||||
"path": { "type": "string" },
|
||||
"role": { "type": "string" },
|
||||
"authority": { "type": "string" }
|
||||
"authority": { "enum": ["source", "generated", "observed", "mirror", "evidence"] },
|
||||
"writePolicy": { "enum": ["managed", "read-only", "generated"] },
|
||||
"generatedFrom": { "type": "array", "items": { "type": "string" } }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user