Answer stability round 1: 0 🔴, 3 🟡 (0 misread); give an awaits-a-slot chunk no since, print the time in UTC and keep the status lines tested once

This commit is contained in:
2026-11-19 02:17:48 +01:00
parent 3e2e0ae5bf
commit ed58379da0
5 changed files with 22 additions and 36 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ class Listed:
dead: bool
# What its name says its parked chunk awaits, as the words after PARKED; empty for a chunk that isn't parked.
awaits: str = ""
# Whether its name ended in WAITS: its chunk's worker asks the human a question.
# Whether its name ended in WAITS: its loop asks the human something.
asks: bool = False
@property
+1 -1
View File
@@ -52,7 +52,7 @@ A chunk whose worker ends its run while its pull request waits on its checks, an
is parked: it frees its place for the next chunk, and its window's name says what it awaits. Its worker goes
on once the checks pass, the approval comes or a reviewer comments, and a place is free; until one is, the
name says `awaits a slot`. A parked chunk survives a reboot: run do-epic <EPIC-KEY> again to go on polling.
--status starts no chunk: it prints each open issue with whether its chunk runs, asks you a question, or why it waits: a parked chunk's gate and since when, a stopped window, a blocker or a human's task.
--status doesn't start any chunk. It prints a line per open issue: that its chunk runs or asks you a question, or why it waits, such as the gate a parked chunk awaits and since when.
{findings.HELP}
The Jira site and its credentials are set in ~/.claude-projects/do-epic/config.toml."""
# Under the home folder, where a chunk's cycles are archived, a folder per epic. It is not loop-claude's archive, since that archive's readers, such as judge-replay and the routing figures, read loop-claude's prompts.
+10 -7
View File
@@ -1,24 +1,24 @@
"""What `do-epic <EPIC-KEY> --status` prints: each open issue of the epic, with whether its chunk runs, asks the human, is parked on a gate, has stopped or has yet to start (docs/decisions.md → `do-epic: drives one Jira epic …`)."""
"""What `do-epic <EPIC-KEY> --status` prints: a line per open issue of the epic (docs/decisions.md → `do-epic: drives one Jira epic …`)."""
import datetime
import pathlib
from agent_cycle import tmux
from do_epic.backend.protocol import EpicIssue
from do_epic.parked import file_of, Parked, parked_chunks
from do_epic.parked import file_of, Parked, parked_chunks, SLOT
from do_epic.scheduler import chunks, STATE
from failure import Failure
def since(folder: pathlib.Path, chunk: Parked) -> str:
"""`, since <time>`, the time the chunk parked on what its file says it awaits, to the minute in the machine's time zone: the file is written once per gate, so its time is when the gate began. Empty where the file cannot be read."""
"""`, since <time>`: when the chunk's pull request began to await the gate its file records, to the minute in UTC, since the machine may be one the human reaches over ssh. The file is written once per gate. Empty where the file cannot be read."""
try:
return f", since {datetime.datetime.fromtimestamp(file_of(folder, chunk.issue).stat().st_mtime).strftime('%Y-%m-%d %H:%M')}"
return f", since {datetime.datetime.fromtimestamp(file_of(folder, chunk.issue).stat().st_mtime, datetime.timezone.utc).strftime('%Y-%m-%d %H:%M')} UTC"
except OSError:
return ""
def lines(key: str, home: pathlib.Path, issues: list[EpicIssue], run: tmux.Tmux) -> list[str] | Failure:
"""A line per open issue of the epic called key, in the tracker's rank order: that its chunk runs or asks the human, or why it waits. It doesn't start anything and checks no limit, so the line of a chunk that has yet to start doesn't say which limit holds it back."""
"""A line per open issue of the epic called key, in the tracker's rank order: that its chunk runs or asks the human, or why it waits. It doesn't start anything or check any limit, so the line of a chunk that has yet to start doesn't say which limit holds it back."""
found, waits = chunks(issues)
folder = home / STATE / key
parked = parked_chunks(folder)
@@ -31,8 +31,11 @@ def lines(key: str, home: pathlib.Path, issues: list[EpicIssue], run: tmux.Tmux)
reasons = {wait.issue: wait.reason for wait in waits}
for chunk in found:
if chunk.issue in parked:
when = since(folder, parked[chunk.issue])
reasons[chunk.issue] = parked[chunk.issue].waits(live[chunk.issue].awaits) + when if chunk.issue in live else f"{parked[chunk.issue].waits('')}{when}, and its window stopped; {again}"
shown = live[chunk.issue].awaits if chunk.issue in live else ""
# Past its gate, a chunk that awaits a slot has no time the file knows: the file's is when its gate began.
when = "" if shown == SLOT else since(folder, parked[chunk.issue])
stopped = "" if chunk.issue in live else f", and its window stopped; {again}"
reasons[chunk.issue] = parked[chunk.issue].waits(shown) + when + stopped
elif chunk.issue not in live:
reasons[chunk.issue] = f"its window stopped; {again}" if chunk.issue in {window.name for window in windows} else f"it has not started; `do-epic {key}` starts it once the epic and its repo have room"
return [line(issue.key, reasons, live, session) for issue in issues if issue.key in reasons or issue.key in live]
+2 -21
View File
@@ -1,9 +1,7 @@
import contextlib
import dataclasses
import datetime
import io
import json
import os
import pathlib
import shutil
import subprocess
@@ -43,11 +41,6 @@ class Description:
return self.text
# When the parked chunks of the status test were parked, and how the status prints it, in the machine's time zone.
PARKED_SINCE = 1_700_000_000
PARKED_ON = datetime.datetime.fromtimestamp(PARKED_SINCE).strftime("%Y-%m-%d %H:%M")
class DoEpicTest(unittest.TestCase):
def setUp(self) -> None:
made = tempfile.TemporaryDirectory()
@@ -615,25 +608,13 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
class TheStatus(DoEpicTest):
def test_prints_what_each_open_issue_does_and_starts_nothing(self) -> None:
self.issues = [issue("ABC-20", "repo:api"), issue("ABC-21", "repo:api"), issue("ABC-22", "repo:api"), issue("ABC-23", "repo:api", blockers=("ABC-20",)), issue("ABC-24", "repo:api"), issue("ABC-25", "repo:api", done=True), issue("ABC-26", "repo:api"), issue("ABC-27")]
folder = self.home / ".local/state/do-epic/ABC-12"
parked.park(folder, parked.Parked("ABC-20", "/code/api-ABC-20", "7", "s", "an approval"))
parked.park(folder, parked.Parked("ABC-26", "/code/api-ABC-26", "9", "s", "its checks"))
parked.park(folder, parked.Parked("ABC-28", "/code/api-ABC-28", "11", "s", "an approval"))
self.issues.insert(7, issue("ABC-28", "repo:api"))
for issue_key, when in (("ABC-20", PARKED_SINCE), ("ABC-26", PARKED_SINCE), ("ABC-28", PARKED_SINCE)):
os.utime(parked.file_of(folder, issue_key), (when, when))
fake = FakeEffects(windows="ABC-20 awaits an approval\t0\t@1\nABC-21 ?\t0\t@2\nABC-22\t1\t@3\nABC-28 awaits a slot\t0\t@4\n")
self.issues = [issue("ABC-21", "repo:api"), issue("ABC-24", "repo:api"), issue("ABC-27")]
fake = FakeEffects(windows="ABC-21 ?\t0\t@2\n")
code, out, err = self.run_main(["ABC-12", "--status"], fake)
self.assertEqual((code, err), (0, ""))
self.assertEqual(out.replace("<1790000000> ", "").splitlines(), [
f"ABC-20 waits: it is parked: its pull request #7 awaits an approval, since {PARKED_ON}",
"ABC-21 asks you: answer its question in the tmux window epic-ABC-12:ABC-21",
"ABC-22 waits: its window stopped; run `do-epic ABC-12` to start it again",
"ABC-23 waits: ABC-20 blocks it",
"ABC-24 waits: it has not started; `do-epic ABC-12` starts it once the epic and its repo have room",
f"ABC-26 waits: it is parked: its pull request #9 awaits its checks, since {PARKED_ON}, and its window stopped; run `do-epic ABC-12` to start it again",
f"ABC-28 waits: it is parked: its worker has work again on pull request #11 and awaits a slot, since {PARKED_ON}",
"ABC-27 waits: no label names its repo",
])
self.assertEqual({args[0] for args in fake.tmux_calls}, {"-V", "list-windows"})
+8 -6
View File
@@ -1,4 +1,3 @@
import datetime
import os
import pathlib
import tempfile
@@ -10,8 +9,8 @@ from do_epic.test_scheduler import issue, Tmux
from failure import Failure
SINCE = 1_700_000_000
# How the status prints SINCE, in the machine's time zone.
SINCE_ON = datetime.datetime.fromtimestamp(SINCE).strftime("%Y-%m-%d %H:%M")
# SINCE as the status prints it.
SINCE_ON = "2023-11-14 22:13 UTC"
EPIC = "epic-ABC-12"
@@ -20,10 +19,9 @@ class TheStatusLines(unittest.TestCase):
self.home = pathlib.Path(tempfile.mkdtemp())
self.folder = self.home / STATE / "ABC-12"
def park(self, key: str, on: str, since: int | None = SINCE) -> None:
def park(self, key: str, on: str) -> None:
parked.park(self.folder, parked.Parked(key, f"/code/api-{key}", "7", "s", on))
if since is not None:
os.utime(parked.file_of(self.folder, key), (since, since))
os.utime(parked.file_of(self.folder, key), (SINCE, SINCE))
def lines(self, issues: list, *windows: tuple[str, str, bool, str]) -> list[str] | Failure:
return status.lines("ABC-12", self.home, issues, Tmux(*windows))
@@ -36,6 +34,10 @@ class TheStatusLines(unittest.TestCase):
self.park("ABC-20", "an approval")
self.assertEqual(self.lines([issue("ABC-20", "repo:api")], (EPIC, "ABC-20 awaits its checks", False, "")), [f"ABC-20 waits: it is parked: its pull request #7 awaits its checks, since {SINCE_ON}"])
def test_a_parked_chunk_that_awaits_a_slot_gives_no_time_since_its_gate_began(self) -> None:
self.park("ABC-20", "an approval")
self.assertEqual(self.lines([issue("ABC-20", "repo:api")], (EPIC, "ABC-20 awaits a slot", False, "")), ["ABC-20 waits: it is parked: its worker has work again on pull request #7 and awaits a slot"])
def test_a_parked_chunk_without_a_window_says_since_when_and_how_to_start_it_again(self) -> None:
self.park("ABC-20", "an approval")
self.assertEqual(self.lines([issue("ABC-20", "repo:api")]), [f"ABC-20 waits: it is parked: its pull request #7 awaits an approval, since {SINCE_ON}, and its window stopped; run `do-epic ABC-12` to start it again"])