Skip to content

Commit 4cf6abb

Browse files
committed
ci: match independent daemon topology in planning controls
Signed-off-by: aihop <4408344+hhyykk@users.noreply.github.com>
1 parent 33742e1 commit 4cf6abb

4 files changed

Lines changed: 71 additions & 50 deletions

File tree

‎.github/pr7616-evaluation/analyze_performance.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
assert all(
3030
set(pair) == {"base", "head"}
3131
and pair["base"]["stdout_sha256"] == pair["head"]["stdout_sha256"]
32+
and pair["base"]["runtime_namespace"] != pair["head"]["runtime_namespace"]
33+
and pair["base"]["runtime_pid"] != pair["head"]["runtime_pid"]
3234
for pair in group.values()
3335
)
3436

‎.github/pr7616-evaluation/configure.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
root = pathlib.Path(__file__).resolve().parent
77
config = {
8-
"series": "repaired-planning-powered",
8+
"series": "repaired-planning-independent-controls",
9+
"control_design": "two independent baseline daemons for AA; two independent source-arm daemons for AB; both reset and warmed equally",
910
"warmups_per_arm_per_phase": 10,
1011
"baseline": "8505069601a5a722c11eccf5302f72ffb9276fed",
1112
"pr_target_main": "9dcdc0bacd455a8cf6f6146f052ffc4df0f5d04a",

‎.github/pr7616-evaluation/evaluate.py‎

Lines changed: 56 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@
3030
assert observed == CONFIG[key], f"source revision drift for {arm}"
3131

3232

33-
def environment(arm):
33+
def environment(arm, namespace=None):
3434
src = SOURCES[arm]
35+
runtime_tmp = TMP / (namespace or arm)
36+
runtime_tmp.mkdir(exist_ok=True)
3537
return {
3638
**os.environ,
3739
"PATH": str(CONFIG["node_bin"])
@@ -47,9 +49,9 @@ def environment(arm):
4749
+ ":"
4850
+ str(src),
4951
"PYTHONHASHSEED": "0",
50-
"TMPDIR": str(TMP),
51-
"TEMP": str(TMP),
52-
"TMP": str(TMP),
52+
"TMPDIR": str(runtime_tmp),
53+
"TEMP": str(runtime_tmp),
54+
"TMP": str(runtime_tmp),
5355
"NODE_OPTIONS": "--experimental-sqlite --import "
5456
+ (ROOT / "clock-hooks/clock.mjs").as_uri(),
5557
"LOOPX_USAGE_PING": "0",
@@ -105,28 +107,33 @@ def command(manifest, arm):
105107
]
106108

107109

108-
def run(manifest, arm, mode):
110+
def stop_runtime(arm, namespace=None):
111+
stopped = subprocess.run(
112+
[
113+
str(SOURCES[arm] / ".venv/bin/python"),
114+
"-c",
115+
"import json;from loopx.control_plane.effect_runtime import restart_effect_runtime; print(json.dumps(restart_effect_runtime(timeout=5,wait_for_exit=True)))",
116+
],
117+
capture_output=True,
118+
text=True,
119+
env=environment(arm, namespace),
120+
timeout=20,
121+
)
122+
assert stopped.returncode == 0, stopped.stderr
123+
assert json.loads(stopped.stdout)["status"] in ("stopped", "not_running"), (
124+
stopped.stdout
125+
)
126+
127+
128+
def run(manifest, arm, mode, namespace=None):
109129
if mode == "cold-daemon":
110-
stop = subprocess.run(
111-
[
112-
str(SOURCES[arm] / ".venv/bin/python"),
113-
"-c",
114-
"import json;from loopx.control_plane.effect_runtime import restart_effect_runtime; print(json.dumps(restart_effect_runtime(timeout=5,wait_for_exit=True)))",
115-
],
116-
capture_output=True,
117-
text=True,
118-
env=environment(arm),
119-
timeout=20,
120-
)
121-
assert stop.returncode == 0, stop.stderr
122-
assert json.loads(stop.stdout)["status"] in ("stopped", "not_running"), (
123-
stop.stdout
124-
)
130+
stop_runtime(arm, namespace)
131+
env = environment(arm, namespace)
125132
started = time.perf_counter_ns()
126133
p = subprocess.run(
127134
command(manifest, arm),
128135
cwd=manifest["project"],
129-
env=environment(arm),
136+
env=env,
130137
capture_output=True,
131138
timeout=120,
132139
)
@@ -139,8 +146,18 @@ def run(manifest, arm, mode):
139146
== "todo_tail_owned"
140147
)
141148
assert payload["agent_todo_summary"]["done_count"] == manifest["history"]
149+
runtime_infos = [
150+
json.loads(path.read_text())
151+
for path in (TMP / (namespace or arm)).glob("*/runtime-*.json")
152+
]
153+
runtime_pids = {
154+
info["pid"] for info in runtime_infos if isinstance(info.get("pid"), int)
155+
}
156+
assert len(runtime_pids) == 1, runtime_pids
142157
return {
143158
"arm": arm,
159+
"runtime_namespace": namespace or arm,
160+
"runtime_pid": runtime_pids.pop(),
144161
"ms": elapsed,
145162
"stdout_sha256": hashlib.sha256(p.stdout).hexdigest(),
146163
}, p.stdout
@@ -187,43 +204,36 @@ def benchmark():
187204
case = path.parent.name
188205
for mode in CONFIG["modes"]:
189206
for arm in ["base", "head"]:
190-
run(manifest, arm, "warm")
207+
stop_runtime(arm)
191208
for phase, n in [("aa", CONFIG["aa_pairs"]), ("ab", CONFIG["ab_pairs"])]:
192-
# Reset process history between controls and treatment, then warm both equally.
193-
for arm in ["base", "head"]:
194-
stopped = subprocess.run(
195-
[
196-
str(SOURCES[arm] / ".venv/bin/python"),
197-
"-c",
198-
"import json;from loopx.control_plane.effect_runtime import restart_effect_runtime; print(json.dumps(restart_effect_runtime(timeout=5,wait_for_exit=True)))",
199-
],
200-
capture_output=True,
201-
text=True,
202-
env=environment(arm),
203-
timeout=20,
204-
)
205-
assert stopped.returncode == 0, stopped.stderr
206-
assert json.loads(stopped.stdout)["status"] in (
207-
"stopped",
208-
"not_running",
209-
), stopped.stdout
209+
targets = {
210+
label: ("base" if phase == "aa" else label, f"{phase}-{label}")
211+
for label in ["base", "head"]
212+
}
213+
for arm, namespace in targets.values():
214+
stop_runtime(arm, namespace)
210215
for warmup in range(CONFIG.get("warmups_per_arm_per_phase", 3)):
211-
for arm in ["base", "head"]:
212-
run(manifest, arm, "warm")
216+
for arm, namespace in targets.values():
217+
run(manifest, arm, "warm", namespace)
213218
collected = {"base": [], "head": []}
214219
for pair in range(n):
215220
order = ["base", "head"] if pair % 2 == 0 else ["head", "base"]
216221
outputs = []
222+
runtime_pids = set()
217223
for label in order:
218-
arm = "base" if phase == "aa" else label
219-
row, out = run(manifest, arm, mode)
224+
arm, namespace = targets[label]
225+
row, out = run(manifest, arm, mode, namespace)
226+
runtime_pids.add(row["runtime_pid"])
220227
outputs.append(out)
221228
row.update(
222229
case=case, mode=mode, phase=phase, pair=pair, label=label
223230
)
224231
with ledger.open("a") as file:
225232
file.write(json.dumps(row) + "\n")
226233
collected[label].append(row["ms"])
234+
assert len(runtime_pids) == 2, (
235+
"controls and treatment require separate daemons"
236+
)
227237
assert outputs[0] == outputs[1], (
228238
f"raw output changed at {case}/{mode}/{phase}/{pair}"
229239
)
@@ -236,6 +246,8 @@ def benchmark():
236246
for arm, xs in collected.items()
237247
}
238248
print("PERFORMANCE", case, mode, phase, json.dumps(stats), flush=True)
249+
for arm, namespace in targets.values():
250+
stop_runtime(arm, namespace)
239251

240252

241253
if __name__ == "__main__":

‎.github/pr7616-evaluation/public_summary.py‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
k: c[k]
1010
for k in [
1111
"series",
12+
"control_design",
1213
"baseline",
1314
"candidate_head",
1415
"pr_target_main",
@@ -35,11 +36,16 @@
3536
).stdout.strip()
3637
versions = {}
3738
for arm, key in [("base", "baseline_source"), ("head", "candidate_source")]:
38-
versions[arm] = json.loads(subprocess.check_output(
39-
[str(pathlib.Path(c[key]) / ".venv/bin/python"), "-c",
40-
"import importlib.metadata as m,json;print(json.dumps(sorted((d.metadata['Name'],d.version) for d in m.distributions())))"],
41-
text=True,
42-
))
39+
versions[arm] = json.loads(
40+
subprocess.check_output(
41+
[
42+
str(pathlib.Path(c[key]) / ".venv/bin/python"),
43+
"-c",
44+
"import importlib.metadata as m,json;print(json.dumps(sorted((d.metadata['Name'],d.version) for d in m.distributions())))",
45+
],
46+
text=True,
47+
)
48+
)
4349
assert versions["base"] == versions["head"], "dependency-version mismatch"
4450
summary["dependency_versions"] = versions["base"]
4551
(root / "public-config.json").write_text(json.dumps(summary, indent=2))

0 commit comments

Comments
 (0)