MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / check

Function check

tests/harness/kg_closure_e2e.py:11–117  ·  view source on GitHub ↗
(binary)

Source from the content-addressed store, hash-verified

9
10
11def check(binary):
12 with tempfile.TemporaryDirectory(prefix="atomic-kg-closure-") as directory:
13 base = Path(directory)
14 root, home = base / "repo", base / "home"
15 root.mkdir()
16 home.mkdir()
17 env = dict(os.environ, HOME=str(home), ATOMIC_NO_DAEMON="1")
18
19 def run(*args, status=0, stdin=None, as_json=False):
20 result = subprocess.run([binary, *args], cwd=root, env=env,
21 input=stdin, text=True, capture_output=True)
22 assert result.returncode == status, (
23 f"{args}: expected {status}, got {result.returncode}\n"
24 f"{result.stdout}\n{result.stderr}"
25 )
26 return json.loads(result.stdout) if as_json else result.stdout
27
28 run("init", "--view", "main")
29 identity = run("repo", "identity", "show", "--json", as_json=True)
30 assert re.fullmatch(r"[A-Z2-7]{51}[AQ]", identity["project"])
31 assert identity["minted"] == "created"
32 assert identity["urn"] == "urn:atomic:project:" + identity["project"]
33 empty = run("query", "validate", "--shape", "https://atomic.dev/ns/shapes/projection/1.0.0#GeneratedChange", "--format", "json", as_json=True)
34 assert empty["conforms"] and all(c["evaluated"] == 0 for c in empty["target_coverage"])
35 assert any("vacuous" in diagnostic for diagnostic in empty["diagnostics"])
36
37 run("vault", "init")
38 uid = "01ARZ3NDEKTSV4RRFFQ69G5FAV"
39 intent = root / ".vault" / "intents" / uid / "intent.md"
40 intent.parent.mkdir(parents=True, exist_ok=True)
41 intent.write_text(f"""---
42uid: {uid}
43id: TEST::alice::1
44title: Workflow harness
45kind: feature
46status: in_progress
47author: Alice
48---
49:::why
50Verify the real workflow projection end to end.
51:::
52:::acceptance-criterion{{#{uid}-ac-1 status=unmet}}
53The source is represented by a file resource.
54:::
55:::task{{#{uid}-1 status=unmet criteria={uid}-ac-1}}
56Inspect the source.
57::file-ref{{path=src/main.rs}}
58:::
59""")
60 (root / "src").mkdir(exist_ok=True)
61 (root / "src/main.rs").write_text("fn main() {}\n")
62 run("add", "src/main.rs")
63 run("record", "-m", "Workflow harness source")
64 run("vault", "sync")
65 run("query", "reindex", "--full")
66
67 plan = {"schema_version": 1, "steps": [
68 {"type": "kg_search", "query": "Workflow harness", "limit": 100, "bind": "all"},

Callers 1

kg_closure_e2e.pyFile · 0.70

Calls 3

runFunction · 0.70
runMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected