Let a sweep run more than four at a time, and name the run a failure was in

Concurrent runs sat at 4 whatever FLOW_MAX_CASCADES said: that setting bounds
cascades, and the run drivers read a hardcoded MAX_PARALLEL nobody could reach.
FLOW_MAX_RUNS is the knob they read now, --max-runs/--max-cascades/--max-workers
are the same three as flags on serve, and the engine says which numbers it
started with — which is the only way to tell that a settings file was read.

Events keep the run they happened in. The payload always carried it and the
persist path dropped it, so reading one run's failures meant filtering the
engine-wide list; a batch run's id reaches those events now too, since a run
has no journaled item to name itself by.

Also: a provisioner's 0 means "no deadline" rather than "cancel on the next
reconcile", and a command that reaches no engine says how to start one.
This commit is contained in:
2026-08-27 14:17:51 +02:00
parent 2c081fe3ed
commit 081d499edc
23 changed files with 288 additions and 18 deletions
@@ -312,3 +312,30 @@ def test_events_narrow_to_one_minute(
# The upper bound is exclusive, so the failure a minute later is not in it.
assert [event["detail"] for event in events] == ["minute-in"]
def test_events_narrow_to_one_run(
client: TestClient, superuser_token_headers: dict[str, str], db: Session
) -> None:
"""Reading one run's failures without filtering the engine-wide list."""
ts = datetime.now(UTC) - timedelta(hours=6)
db.add(
EngineEvent(ts=ts, type="node_error", flow=FLOW, detail="mine", run="run-mine")
)
db.add(
EngineEvent(
ts=ts, type="node_error", flow=FLOW, detail="theirs", run="run-theirs"
)
)
# What a live cascade unrelated to any run leaves, and what every row
# written before the column existed looks like.
db.add(EngineEvent(ts=ts, type="node_error", flow=FLOW, detail="neither"))
db.commit()
events = client.get(
f"{PREFIX}/events",
headers=superuser_token_headers,
params={"flow": FLOW, "run": "run-mine"},
).json()
assert [event["detail"] for event in events] == ["mine"]
+44
View File
@@ -598,3 +598,47 @@ def test_a_step_the_x_metric_never_reached_is_left_out(
).json()
assert [point[0] for point in answer["lines"][0]["points"]] == [10.0, 20.0, 30.0]
def test_a_run_records_the_code_it_started_with_not_the_code_it_was_queued_with():
"""A sweep queues every run at once and the tree moves while it waits.
`_restamp` is what runs at claim time, so the digest the record keeps is
the one the run actually executed.
"""
service = RunService(controller=_Unusable(), queue=_Unusable())
with Session(db_engine) as session:
session.add(
Run(
id="stamp-1",
flow="study",
status="queued",
code_digest="at-submit",
created_at=datetime.now(UTC),
)
)
session.commit()
run = session.get(Run, "stamp-1")
assert service._restamp(run, "at-claim") == "at-claim"
with Session(db_engine) as session:
assert session.get(Run, "stamp-1").code_digest == "at-claim"
def test_a_tree_that_did_not_move_is_not_written_again():
service = RunService(controller=_Unusable(), queue=_Unusable())
with Session(db_engine) as session:
session.add(
Run(
id="stamp-2",
flow="study",
status="queued",
code_digest="same",
created_at=datetime.now(UTC),
)
)
session.commit()
run = session.get(Run, "stamp-2")
assert service._restamp(run, "same") == "same"