Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,17 @@ jobs:
# alone resolves features differently and compiles everything again).
- name: Incident regressions
run: cargo test --workspace -- 'incidents::'
# Stops, asks, blocks and loops replayed through the real decision
# functions and graded on the decision, with the stop judge's recorded
# answers k = 3 times each (pass^k; passes/replay/README.md). It gates
# any prompt, model or effort change to a judgment step.
- name: Replay suite
run: cargo test --workspace -- 'replay::'
# Includes the reviewer evals (worker passes::review_eval): recorded
# review histories replayed through the real decision code, no model.
# The incident suite already ran above, on the same build.
# The incident and replay suites already ran above, on the same build.
- name: Workspace tests
run: cargo test --workspace -- --skip 'incidents::'
run: cargo test --workspace -- --skip 'incidents::' --skip 'replay::'

rust:
name: Rust (workspace)
Expand Down
43 changes: 40 additions & 3 deletions lambda/stuck-run-cleanup/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,47 @@ def _send_waiting(run, why):
return False


def deadline_passed(run, now):
"""A question the stop judge let the run ask carries a default and a
deadline (worker passes::stop_judge::keep_ask_deadline). Once it passes
with no answer, reversible work goes ahead with the default."""
if not str(run.get("ask_default", "")).strip():
return False
due = _parse_time(run.get("ask_deadline"))
return due is not None and now >= due


def take_default(runs_table, run, now):
"""Claims the deadline once (the worker restarts the ticket with the
default as its answer). Returns True when this sweep claimed it."""
key = {"team_id": run["team_id"], "run_id": run["run_id"]}
try:
runs_table.update_item(
Key=key,
UpdateExpression="SET ask_default_taken_at = :now",
ExpressionAttributeNames={"#s": "status"},
ExpressionAttributeValues={":now": now.isoformat(), ":ni": NEEDS_INPUT},
ConditionExpression="#s = :ni AND attribute_not_exists(ask_default_taken_at)",
)
except _db().meta.client.exceptions.ConditionalCheckFailedException:
return False
except Exception as e:
logger.error(f"Could not claim the deadline of {run['run_id']}: {e}")
return False
return _send_waiting(run, "deadline")


def settle_waiting(runs_table, run, now):
"""A needs_input run: name its wait when it names none, or remind once.
Returns "named", "reminded" or ""."""
"""A needs_input run: take a passed question deadline's default, name
its wait when it names none, or remind once. Returns "defaulted",
"named", "reminded" or ""."""
run_id = run["run_id"]
key = {"team_id": run["team_id"], "run_id": run_id}
now_iso = now.isoformat()
if deadline_passed(run, now) and not run.get("ask_default_taken_at"):
if take_default(runs_table, run, now):
logger.info(f"Run {run_id}: question deadline passed, going ahead with the default")
return "defaulted"
try:
if not asks_something(run):
wait = named_wait(run, now_iso)
Expand Down Expand Up @@ -539,7 +574,7 @@ def handler(event, context):
# before, so awaiting_ci runs sat forever.
stuck_runs = []
over_count = 0
waiting = {"named": 0, "reminded": 0}
waiting = {"named": 0, "reminded": 0, "defaulted": 0}
scan_kwargs = {
"FilterExpression": "#s = :running OR #s = :awaiting OR #s = :ni",
"ExpressionAttributeNames": {"#s": "status"},
Expand Down Expand Up @@ -599,6 +634,7 @@ def handler(event, context):
"over_ceiling": over_count,
"waiting_named": waiting["named"],
"waiting_reminded": waiting["reminded"],
"waiting_defaulted": waiting["defaulted"],
}

logger.info(f"Found {len(stuck_runs)} stuck runs")
Expand Down Expand Up @@ -690,4 +726,5 @@ def handler(event, context):
"over_ceiling": over_count,
"waiting_named": waiting["named"],
"waiting_reminded": waiting["reminded"],
"waiting_defaulted": waiting["defaulted"],
}
23 changes: 23 additions & 0 deletions lambda/tests/test_stuck_run_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,29 @@ def test_a_stalled_run_with_its_pull_request_is_found_and_handed_to_review(self)
# Never failed or completed: still waiting, now for something named.
self.assertNotIn(":new", updates[0]["ExpressionAttributeValues"])

def test_a_passed_question_deadline_goes_ahead_with_the_default_once(self):
run = {
"team_id": "T",
"run_id": "R",
"status": "needs_input",
"updated_at": self.NOW.isoformat(),
"questions": '{"questions":[{"id":"q1","question":"Monthly or yearly?"}]}',
"ask_default": "Monthly",
"ask_deadline": (self.NOW - sweep.timedelta(hours=1)).isoformat(),
}
self.assertTrue(sweep.deadline_passed(run, self.NOW))
out, updates, sent = self._sweep([run])
self.assertEqual(out["waiting_defaulted"], 1)
self.assertIn("attribute_not_exists(ask_default_taken_at)", updates[0]["ConditionExpression"])
self.assertEqual(sent, [{"type": "run_waiting", "team_id": "T", "run_id": "R", "why": "deadline"}])
# Before the deadline, or already taken, or with no default: nothing.
early = dict(run, ask_deadline=(self.NOW + sweep.timedelta(hours=1)).isoformat())
self.assertFalse(sweep.deadline_passed(early, self.NOW))
self.assertFalse(sweep.deadline_passed(dict(run, ask_default=""), self.NOW))
out, _, sent = self._sweep([dict(run, ask_default_taken_at=self.NOW.isoformat())])
self.assertEqual(out["waiting_defaulted"], 0)
self.assertNotIn("deadline", [m["why"] for m in sent])

def test_without_a_pull_request_it_waits_for_a_retry(self):
wait = sweep.named_wait({"error_message": "stopped"}, "now")
self.assertIn("Retry", wait["action"])
Expand Down
2 changes: 1 addition & 1 deletion selfhost/versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"about": "The dashboard commit each platform release ships: a full 40-character commit SHA of CoderHelm/coderhelm, never a branch or tag (scripts/check-dashboard-ref.mjs fails CI and the release otherwise). The release workflow builds exactly this commit (dashboard/) into dashboard.tar.gz. Move it with scripts/bump-dashboard.sh in a reviewed PR, in the same PR as any API change the dashboard needs.",
"dashboardRef": "88285390aff81267992458e5e450a9a011c88fd6"
"dashboardRef": "8434a36b91d88b770f7757bee913f683e08b93f2"
}
Loading
Loading