Repository navigation
Expand file tree
/
Copy pathforward
More file actions
executable file
·70 lines (63 loc) · 3.09 KB
/
Copy pathforward
File metadata and controls
executable file
·70 lines (63 loc) · 3.09 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
#!/usr/bin/env python3
"""Run SpecBridge on selected CLEVER tasks and print generated Lean specs."""
import argparse
import json
import os
from pathlib import Path
import re
import subprocess
import sys
import tempfile
from uuid import uuid4
ROOT = Path(__file__).resolve().parent
def main() -> int:
parser = argparse.ArgumentParser(description="Generate Lean specifications with SpecBridge")
parser.add_argument("tasks", nargs="*", default=["clever_0", "clever_1"],
help="2–20 CLEVER task IDs (default: clever_0 clever_1)")
parser.add_argument("--model", default=os.environ.get("SPECBRIDGE_MODEL", "gpt-6-luna"))
parser.add_argument("--output", type=Path, help="new run directory")
args = parser.parse_args()
if not 2 <= len(args.tasks) <= 20 or len(set(args.tasks)) != len(args.tasks):
parser.error("provide 2–20 distinct CLEVER task IDs")
if any(re.fullmatch(r"clever_(?:0|[1-9][0-9]*)", task) is None for task in args.tasks):
parser.error("task IDs must have the form clever_N")
output = (args.output or ROOT / "runs" / uuid4().hex).resolve()
if output.exists():
parser.error(f"output directory already exists: {output}")
config = {
"schema": "specbridge-rs/v1", "repository": str(ROOT),
"output": str(output), "model": args.model,
"task_ids": args.tasks, "scope": "subset", "profile": "improved",
"stage": "forward", "prompt_profile": "predefined",
"predefined": True, "forward_only": True,
"task_concurrency": min(len(args.tasks), 8),
"llm_concurrency": 32, "llm_admission_concurrency": 32,
"lean_concurrency": min(len(args.tasks) + 1, 16),
"wall_seconds": 28800,
}
with tempfile.TemporaryDirectory(prefix="specbridge-config-") as temporary:
config_path = Path(temporary) / "forward.json"
config_path.write_text(json.dumps(config), encoding="utf-8")
command = ["cargo", "run", "--manifest-path", "specbridge-rs/Cargo.toml",
"--locked", "--release", "--", "run", "--config", str(config_path)]
completed = subprocess.run(command, cwd=ROOT, check=False)
if completed.returncode:
print(f"SpecBridge failed; inspect {output}", file=sys.stderr)
return completed.returncode
state = json.loads((output / "native-status.json").read_text(encoding="utf-8"))
if state.get("status") != "controllers_finished" or state.get("workflow_completed") is not True:
print(f"SpecBridge did not complete; inspect {output}", file=sys.stderr)
return 1
result = json.loads((output / "native-results.json").read_text(encoding="utf-8"))
endpoints = result["bridge"]["endpoints"]
missing = [entry["task_id"] for entry in endpoints if not entry.get("spec")]
for entry in endpoints:
if entry.get("spec"):
print(f"-- {entry['task_id']}\n{entry['spec']}\n")
print(f"Run artifacts: {output}", file=sys.stderr)
if missing:
print(f"No specification for: {', '.join(missing)}", file=sys.stderr)
return 1
return 0
if __name__ == "__main__":
sys.exit(main())