Answer stability round 1: 0 🔴, 5 🟡 (0 misread); park the window first, resend a failed DM, reword docstrings and trim two tests
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
"""A human's task that holds up other issues of an epic (docs/decisions.md → `do-epic: drives one Jira epic …`, "Human tasks").
|
||||
|
||||
do-epic leaves the issue as the team filed it. While it is open and blocks an open issue, its window DMs the human once, shows itself as parked so that it takes no running slot, and reads the epic every `poll` seconds. Once the issue is closed, or blocks nothing any more, the window ends, and the chunks it held up may start. A window that starts again, as after a reboot, DMs again."""
|
||||
A window that starts again, as after a reboot, DMs again, and so does one whose DM failed, on its next read."""
|
||||
import pathlib
|
||||
|
||||
from project_config.settings import by_name, ProjectConfig
|
||||
from loop_effects.effects import Effects, say
|
||||
from do_epic.backend.protocol import EpicIssue, EpicStore
|
||||
from failure import Failure
|
||||
from do_epic.repo_pick import recorded, Repo
|
||||
from do_epic import scheduler
|
||||
from agent_cycle.direct_message import tell
|
||||
from agent_cycle import tmux
|
||||
@@ -13,18 +17,29 @@ AWAITS = "a human's task"
|
||||
|
||||
|
||||
def holds_up(key: str, issues: list[EpicIssue]) -> list[str]:
|
||||
"""The keys of the open issues that the human's task called key holds up; none where it is no such task, or is closed."""
|
||||
"""The keys of the open issues that the human's task called key holds up; none where it is no such task, is closed, or an issue blocks it."""
|
||||
if not any(chunk.human and chunk.issue == key for chunk in scheduler.chunks(issues)[0]):
|
||||
return []
|
||||
return scheduler.held_up(issues)[key]
|
||||
|
||||
|
||||
def message(task: EpicIssue, epic: str, held: list[str]) -> str:
|
||||
return f"do-epic {epic} awaits you: {task.key}, \"{task.summary}\", blocks {' and '.join(held)}. It goes on once you close {task.key} in Jira."
|
||||
return f"do-epic {epic} awaits you: {task.key}, \"{task.summary}\", blocks {' and '.join(held)}. do-epic goes on once you close {task.key} in Jira."
|
||||
|
||||
|
||||
def awaited(task: EpicIssue, epic: str, store: EpicStore, window: tmux.Window, poll: int, effects: Effects) -> None:
|
||||
"""Waits in window for the human to close the human's task `task` of the epic called epic, and returns once it holds up no issue. A read of the epic that fails is said once and tried again."""
|
||||
def checkout_of(held: list[EpicIssue], home: pathlib.Path) -> str | None:
|
||||
"""The checkout of the first issue of held whose repo a project config names: where the DM finds its notifier, since the window runs in no checkout. None where there is none, and the DM goes by the current directory."""
|
||||
for issue in held:
|
||||
pick = recorded(issue)
|
||||
found = by_name(pick.name, home) if isinstance(pick, Repo) else None
|
||||
if isinstance(found, ProjectConfig):
|
||||
return str(found.top)
|
||||
return None
|
||||
|
||||
|
||||
def awaited(task: EpicIssue, epic: str, store: EpicStore, window: tmux.Window, poll: int, home: pathlib.Path, effects: Effects) -> None:
|
||||
"""Waits in window for the human to close the human's task `task` of the epic called epic, and returns once it no longer holds up any issue. A read of the epic that fails is said once and tried again."""
|
||||
tmux.park(window, AWAITS, effects.tmux)
|
||||
told, said = False, None
|
||||
while True:
|
||||
issues = store.read()
|
||||
@@ -35,7 +50,8 @@ def awaited(task: EpicIssue, epic: str, store: EpicStore, window: tmux.Window, p
|
||||
elif not (held := holds_up(task.key, issues)):
|
||||
return
|
||||
elif not told:
|
||||
tell(message(task, epic, held), effects)
|
||||
tmux.park(window, AWAITS, effects.tmux)
|
||||
told = True
|
||||
text = message(task, epic, held)
|
||||
say(text, effects, stdout=True)
|
||||
by_key = {issue.key: issue for issue in issues}
|
||||
told = tell(text, effects, checkout_of([by_key[key] for key in held], home))
|
||||
effects.sleep(poll)
|
||||
|
||||
Reference in New Issue
Block a user