check-results.py
3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import json
import sys
def load(path):
try:
with open(path) as f:
return json.load(f)
except Exception as e:
return {"is_error": True, "result": f"could not parse {path}: {e}"}
def check_test1(d):
structured = d.get("structured_output") or {}
checks = {
"ran_without_error": not d.get("is_error", True),
"has_structured_output": isinstance(structured, dict) and "sum" in structured,
"sum_correct (2^2+3^2+4^2=29)": structured.get("sum") == 29,
"squares_correct ([4,9,16])": structured.get("squares") == [4, 9, 16],
"no_permission_denials": len(d.get("permission_denials", [])) == 0,
}
return checks
def main():
t1 = load(sys.argv[1])
t2 = load(sys.argv[2])
print("--- Test 1: normal `claude -p`, structured output ---")
c1 = check_test1(t1)
for k, v in c1.items():
print(f" [{'PASS' if v else 'FAIL'}] {k}")
a1_holds = all(c1.values())
if not a1_holds:
print(f" raw result field: {t1.get('result')}")
print()
print("--- Test 2: `claude --bare -p` ---")
bare_ran = not t2.get("is_error", True)
bare_structured = (t2.get("structured_output") or {}).get("sum") == 29
if bare_ran and bare_structured:
print(" [PASS] bare mode also discovers and runs .claude/workflows/")
print(" -> Executor can use --bare for scripted invocation")
else:
print(" [NOTE] bare mode did NOT successfully run the workflow")
print(f" raw result field: {t2.get('result')}")
print(" -> this is not necessarily fatal to A-1; it just means the")
print(" Executor's c_work_graph_execute must invoke `claude -p`")
print(" WITHOUT --bare (slower cold start, but full context/discovery)")
print()
print("=== A-1 VERDICT ===")
if a1_holds:
print("A-1 CONFIRMED: dynamic workflows can be invoked headlessly via `claude -p`,")
print("run unattended (no interactive prompt, no stdin needed), and return")
print("machine-parseable structured output. Proceed with architecture.md")
print("§10.1 Option A (reuse Claude Code native dynamic workflows).")
print()
print("Refinement to fold into 03-C-控制与接口.md: invocation is prompt-mediated")
print('(`claude -p "Run /<workflow-name> with args {...}"`), not a raw function')
print("call. c_work_graph_execute's implementation should:")
print(" 1. write/update the workflow .js file under the target repo's")
print(" .claude/workflows/ (versioned in the target repo's own git history)")
print(" 2. spawn `claude -p 'Run /<name> with args {...}' --output-format json")
print(" --json-schema <contract-schema>` as a subprocess")
print(" 3. parse structured_output from the JSON result")
print(" 4. map total_cost_usd / usage from the result into budget_guardrail_config")
else:
print("A-1 NOT CONFIRMED as tested. Check the FAIL lines above. Common causes:")
print(" - dynamic workflows not enabled on this account/plan")
print(" (interactive session -> /config -> enable 'Dynamic workflows')")
print(" - claude CLI version < 2.1.154 (`claude --version`)")
print(" - not logged in (`claude /login`)")
print(" - workflow script syntax issue -- check the `result` field above")
print(" for the actual error message")
print("If unresolved after debugging, treat A-1 as rejected and fall back to")
print("architecture.md §10.1 Option B (fully custom Graph Engine), which")
print("cascades into rewriting 03-C §3.4-3.6 and 05 §5.4/5.5.")
if __name__ == "__main__":
main()