CI / checks (push) Skipped
CI / checks (pull_request) Failing after 5m7s
- Config: `projects: {name: entry}` with repo, base_branch, workspace,
build_host, push credential, labels (defaults added to every issue),
secrets by ${VAR} reference with visibility (commands | harness), and
egress (recorded, not enforced). Every problem in every entry is
reported at once; an inline secret, a bad visibility, a repeated repo or
a non-slug name is an error.
- The old loop runs exactly one project (only_project) and refuses more.
- The new loop is per project: each its own clone, workspace (with its
commands-visible secrets, redacted on return), push credential and
milestones; intake polls every project's repository; items are scoped
to their project for every run, publish and PR watch. Issues are named
project#14 when there is more than one project, and a bare #14 that
matches two is asked about. Switching projects parks the one worked on
last (all others after a boot).
- A restatement that ends in a question is sent back to the driver, not
posted: the e2e driver kept asking "Is this the right interpretation?",
which a plain yes can't answer.
Tests: config entries and errors, two-project assembly, two-project loop
tests (intake, own workspaces and repos, #14 in both, do-next, label
defaults, parking across projects), the property walk over two projects
with a new own_repository_only property (an item using the first
project's repo fails 15 of 16 seeds), and the restatement check.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPQ14L3LikyefCMFBqEbKE
94 lines
3.5 KiB
Python
94 lines
3.5 KiB
Python
"""A work item's place in the loop (L1), kept in its row in the state store.
|
|
|
|
The row's ``position`` is the item's state; what the loop needs besides
|
|
(the thread its conversation lives in, the revision of what is put up for
|
|
agreement, what it is waiting for) is in ``data["loop"]``.
|
|
"""
|
|
|
|
from dataclasses import asdict, dataclass
|
|
from typing import Any
|
|
|
|
from nisse_dev.state import StateStore, WorkItem
|
|
|
|
READY = "ready"
|
|
RUNNING = "running" # a driver run is under way; on boot it means interrupted
|
|
WAITING = "waiting"
|
|
BLOCKED = "blocked" # waits for its recorded dependencies to close (L1)
|
|
CLOSED = "closed"
|
|
|
|
# What a waiting item waits for.
|
|
GO_AHEAD = "go-ahead" # a go on the restatement up (L3, D1)
|
|
ANSWER = "answer" # an answer to a question
|
|
MERGE = "merge" # the PR's review and merge (D4, D5)
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Loop:
|
|
thread: str = "" # the root of the item's Matrix thread (L5)
|
|
issue: int = 0 # its record issue (D1)
|
|
wait: str = "" # GO_AHEAD / ANSWER / MERGE, when waiting
|
|
rev: int = 0 # the latest proposal put up (L3)
|
|
started: bool = False # scope agreed: a go-ahead was given (D1)
|
|
note: str = "" # what a waiting item said it is waiting on
|
|
prepared: bool = False # its fresh workspace was made (D3)
|
|
milestone: int = 0 # the current milestone (D4)
|
|
branch: str = "" # the current milestone's branch, while one is open
|
|
pr: int = 0 # the current milestone's PR, once published
|
|
pr_url: str = ""
|
|
comments: int = 0 # the last PR conversation comment taken (L8)
|
|
notes: tuple[str, ...] = () # review notes taken (#69)
|
|
fixes: int = 0 # review fixes pushed, for follow-up branch names
|
|
blocked_by: tuple[str, ...] = () # open dependencies, "owner/repo#N" (L1)
|
|
first: int = 0 # the operator's "do #N next": higher runs sooner
|
|
labels: tuple[str, ...] = () # the issue's labels at intake: they steer (D1)
|
|
grace_until: float = 0.0 # a `bug` restatement proceeds then, unanswered
|
|
talked: bool = False # the operator has spoken in the item's thread
|
|
# Where the operator last spoke (D5: answer where asked): "" for the
|
|
# Matrix thread, or the PR it came from, with the inline location and a
|
|
# little of what they said, for quoting.
|
|
asked_on_pr: int = 0
|
|
asked_where: str = ""
|
|
asked_text: str = ""
|
|
|
|
def to_data(self) -> dict[str, Any]:
|
|
return asdict(self)
|
|
|
|
|
|
def loop_of(item: WorkItem) -> Loop:
|
|
data = dict(item.data.get("loop", {}))
|
|
data["notes"] = tuple(data.get("notes", ()))
|
|
data["blocked_by"] = tuple(data.get("blocked_by", ()))
|
|
data["labels"] = tuple(data.get("labels", ()))
|
|
return Loop(**data)
|
|
|
|
|
|
def save(
|
|
store: StateStore, item_id: str, state: str, loop: Loop, *, cause: str
|
|
) -> None:
|
|
item = store.work_item(item_id)
|
|
assert item is not None
|
|
store.update_work_item(
|
|
item_id,
|
|
position=state,
|
|
data={**item.data, "loop": loop.to_data()},
|
|
cause=cause,
|
|
)
|
|
|
|
|
|
def item_for_thread(store: StateStore, thread: str) -> WorkItem | None:
|
|
for item in store.work_items("open"):
|
|
if loop_of(item).thread == thread:
|
|
return item
|
|
return None
|
|
|
|
|
|
def item_for_issue(
|
|
store: StateStore, issue: int, project: str | None = None
|
|
) -> WorkItem | None:
|
|
"""Any item, open or closed, recorded by this issue (in ``project``,
|
|
when given): intake never takes an issue twice (D1)."""
|
|
for item in store.work_items():
|
|
if loop_of(item).issue == issue and project in (None, item.scope):
|
|
return item
|
|
return None
|