"""Check a parallel-execution plan for the two properties that make it
actually parallel-safe: disjoint file ownership across workstreams, and
binary (not vague) acceptance criteria per workstream.
Usage: check_plan.py <plan.md>
VAGUE_WORDS = re.compile(r"\b(should work|looks good|feels right|properly|correctly|as expected)\b", re.IGNORECASE)
print("Usage: check_plan.py <plan.md>", file=sys.stderr)
text = open(sys.argv[1], encoding="utf-8").read()
workstreams = re.split(r"^##\s+Workstream", text, flags=re.MULTILINE)[1:]
print("❌ no '## Workstream ...' sections found")
for i, ws in enumerate(workstreams, start=1):
files = set(re.findall(r"`([\w./-]+\.\w+)`", ws))
file_owners.setdefault(f, []).append(i)
ac_match = re.search(r"Acceptance [Cc]riteria(.*?)(?:\n##|\Z)", ws, re.DOTALL)
ac_text = ac_match.group(1) if ac_match else ""
if VAGUE_WORDS.search(ac_text):
print(f"❌ workstream {i}: acceptance criteria contains a vague phrase — make it binary (pass/fail, not a feeling)")
print(f"✅ workstream {i}: acceptance criteria present and looks binary")
print(f"❌ workstream {i}: no 'Acceptance Criteria' section found")
conflicts = {f: owners for f, owners in file_owners.items() if len(set(owners)) > 1}
print(f"❌ file(s) owned by more than one workstream — not parallel-safe: {conflicts}")
print("✅ file ownership is disjoint across workstreams")
if __name__ == "__main__":