diff --git a/agents/conductors/batch/AGENTS.md b/agents/conductors/batch/AGENTS.md index 2bed0cb..7611b83 100644 --- a/agents/conductors/batch/AGENTS.md +++ b/agents/conductors/batch/AGENTS.md @@ -560,7 +560,8 @@ The reap keeps what the worker left before deleting its marker: the `.done` lines go to `outcomes` (``; a `merged ` line, which no shift worker writes since 2026-11-19, is still recorded as an in-turn merge), and `.proof.md` moves to `/proofs/`. The first tick after `review-at:` runs `finish_shift` once: `_digest.build` writes the `## Digest` -(`PyAutoMind/batches/AGENTS.md` format — brief work, backlog picks each with +(`PyAutoMind/batches/AGENTS.md` format — first a numbered review table grouped +by the human's next action (#718), then brief work, backlog picks each with its `why:`, one proof packet per started task or a stub that says none was written, every counter) to `/digest.md`, appends it to the record through the one Mind writer, writes `digest.html` only under `packet: yes`, then diff --git a/agents/conductors/batch/_digest.py b/agents/conductors/batch/_digest.py index e548c71..b294757 100644 --- a/agents/conductors/batch/_digest.py +++ b/agents/conductors/batch/_digest.py @@ -741,6 +741,208 @@ def held_leases(slot: Path) -> dict[str, dict]: return out +# --- the review table ---------------------------------------------------------- + +REVIEW_HEADING = "### Review table" +#: The table's groups, by the human's next action, most urgent first. A task +#: sits in exactly one: the most urgent of its PRs' groups. +G_MERGE, G_ANSWER, G_FIX, G_BLOCKED, G_RUNNING, G_DONE, G_PROPOSED = range(7) +REVIEW_GROUPS = ("Merge: your /prm", "Answer: question on the issue", + "Fix: CI failed or crashed", "Blocked or not started", "Still running", + "Done", "Proposed (shadow)") +#: A `plain_outcome` word's group; the first prefix that matches wins. An +#: unknown word goes to Merge: it fails toward the human's attention. The +#: digest is written at `review-at:` and the late sweep never closes a PR +#: out ("what arrives late waits for /prm"), so a PR whose CI is still +#: running, or held on an unknown workspace sweep, is the human's /prm too. +#: Only a close-out at work and a worker still out are "still running". +_GROUP_OF = ( + ("Merged with NO merge slot", G_MERGE), + ("Merged", G_DONE), ("Already merged", G_DONE), ("Verdict posted", G_DONE), + ("Finished", G_BLOCKED), + ("CI failed", G_FIX), ("Abandoned", G_FIX), ("Crashed", G_FIX), ("Killed", G_FIX), + ("Needs you — question", G_ANSWER), ("Needs you — blocked", G_ANSWER), + ("Needs you — not merged", G_MERGE), ("Waiting — merges after", G_MERGE), + ("CI green", G_MERGE), ("No CI checks", G_MERGE), ("CI unknown", G_MERGE), + ("CI running", G_MERGE), ("Waiting — workspace sweep", G_MERGE), + ("Still running", G_RUNNING), + ("Obsolete", G_BLOCKED), ("Not started", G_BLOCKED), + ("Proposed", G_PROPOSED), +) +#: The CI word that ends an UPDATED or CURRENT state (`… CI on new head FAILED`). +_TRAILING_CI_RE = re.compile(r"\bCI (?:on new head )?([A-Z][A-Z-]*)\s*$") +#: The CI words that send a PR to Fix. +_CI_RED = ("FAILED", "RED") +#: The prefixes `task_state` puts on a task the human dropped by `/drop`. +_DROPPED = ("dropped, still running — ", "dropped by /drop — ") +#: A note longer than this is cut, with an ellipsis. +NOTE_MAX = 90 +_WORK_REF_RE = re.compile(r"^https://github\.com/[^/\s]+/([^/\s]+)/(?:pull|issues)/(\d+)") +_URL_PART_RE = re.compile(r"; (?=https?://)") + + +def work_ref(url: str) -> str: + """`repo#n` for a GitHub PR or issue URL; the URL itself otherwise.""" + m = _WORK_REF_RE.match(url or "") + return f"{m.group(1)}#{m.group(2)}" if m else (url or "?") + + +def _cell(text: str) -> str: + """Text safe in a Markdown table cell: one line, `<` and `>` as entities + (GitHub would read them as HTML), pipes escaped once.""" + text = " ".join(str(text or "").split()).replace("<", "<").replace(">", ">") + return re.sub(r"(? int: + return next((g for p, g in _GROUP_OF if word.startswith(p)), G_MERGE) + + +def _trailing_ci(what: str) -> str: + """The CI word an UPDATED or CURRENT state ends on, or "".""" + if not what.startswith((UPDATED, CURRENT)): + return "" + m = _TRAILING_CI_RE.search(what) + return m.group(1) if m else "UNKNOWN" + + +def _part_group(what: str) -> int: + """One part of a task's state as a review group. A branch updated from + main (or already up to date) is judged by its CI word: red is Fix, any + other is the human's /prm.""" + ci = _trailing_ci(what) + if ci: + return G_FIX if ci in _CI_RED else G_MERGE + return _group_of(plain_outcome(what)) + + +def _state_parts(state: str) -> list[tuple[str, str]]: + """A `task_state` as (url, what) per URL it names; ("", state) when it + names none.""" + parts = [] + for part in _URL_PART_RE.split(state): + if part.startswith("http") and " — " in part: + url, what = part.split(" — ", 1) + parts.append((url, what)) + else: + parts.append(("", part)) + return parts + + +def _part_note(url: str, what: str) -> str: + """The short reason one part of a task's state gives, or "".""" + if what.startswith("awaiting /prm — close-out refused: "): + why = what[len("awaiting /prm — close-out refused: "):] + return refusal_class(why).split(" — ", 1)[0] + if what.startswith("PARKED-ON-ISSUE"): + return f"question on {work_ref(url)}" if url else "question on the issue" + if what.startswith("waits behind"): + return "" # the Work cell says "after repo#m" + for head in ("not started — skipped: ", "not started — refused: ", + NOT_REDISPATCHED + ": ", "obsolete (premise check): "): + if what.startswith(head): + return what[len(head):].split(" — ", 1)[0] + if what.startswith(IN_TURN_NO_SLOT): + return "merged with NO merge slot" + if what.startswith(("parked", "blocked on a person")): + return "blocked on a person" + ci = _trailing_ci(what) + if ci: + return ("branch updated" if what.startswith(UPDATED) else "branch up to date") \ + + f", CI {ci}" + if what.startswith("RUNNING"): + return "CI still running" + if what.startswith("waiting: workspace sweep unknown"): + return "workspace sweep unknown" + if what.startswith("finished, no PR or issue named"): + return "finished, no PR or issue named" + return plain_outcome(what) + + +def merge_ordered(prs: list[str], waits: dict) -> list[str]: + """A task's PRs in merge order: as its `.done` named them, except that a + PR waiting behind another of them comes after it.""" + out: list[str] = [] + + def place(u, seen=()): + if u in out or u in seen: + return + for b in (waits.get(u) or {}).get("behind") or []: + if b in prs: + place(b, (*seen, u)) + out.append(u) + for u in prs: + place(u) + return out + + +def review_row(task: str, counters: dict, state: str, tier: str, + links: MindLinks | None = None) -> dict: + """One task as a review-table row: its group, the Task, Tier, Work and + Note cells, and how many open PRs it leaves for the human.""" + pick = counters.get("picks", {}).get(task) or {} + out = (counters.get("outcomes") or {}).get(task) or {} + dropped = next((p for p in _DROPPED if state.startswith(p)), "") + parts = _state_parts(state[len(dropped):]) + group = min((_part_group(what) for _, what in parts), default=G_MERGE) + # A dropped task is Blocked, unless a part of it still needs the human: + # a merge with no slot, or an open PR to merge or fix. + if dropped and group not in (G_MERGE, G_FIX): + group = G_BLOCKED + waits = counters.get("merge_waits") or {} + prs = merge_ordered(list(out.get("prs") or []), waits) + work = [] + for url in prs + list(out.get("issues") or []): + ref = f"[{_cell(work_ref(url))}]({url})" + behind = (waits.get(url) or {}).get("behind") or [] + work.append(ref + (" after " + ", ".join(map(work_ref, behind)) if behind else "")) + notes = (["dropped by /drop"] if dropped else []) + [ + n for url, what in parts for n in [_part_note(url, what)] if n] + note = "; ".join(dict.fromkeys(notes)) + if len(note) > NOTE_MAX: + note = note[:NOTE_MAX - 1].rstrip() + "…" + title = _cell(pick.get("title") or task) + mind_url = links.prompt_url(pick.get("prompt") or "") if links else "" + done = set(out.get("merged") or []) | set(out.get("verdicts") or []) \ + | settled_prs(counters) + return {"task": task, "group": group, + "cells": [f"[{title}]({mind_url})" if mind_url else title, + _cell(tier) if tier and tier != "?" else "—", + "
".join(work) or "—", _cell(note) or "—"], + "open_prs": sum(1 for u in prs if "/pull/" in u and u not in done)} + + +def _count_line(rows: list[dict]) -> str: + n = [sum(1 for r in rows if r["group"] == g) for g in range(len(REVIEW_GROUPS))] + prs = sum(r["open_prs"] for r in rows if r["group"] == G_MERGE) + words = (f"{n[G_MERGE]} to /prm" + (f" ({prs} PR{'s' if prs != 1 else ''})" if prs else ""), + f"{n[G_ANSWER]} to answer", f"{n[G_FIX]} to fix", + f"{n[G_BLOCKED]} blocked or not started", f"{n[G_RUNNING]} still running", + f"{n[G_DONE]} done", f"{n[G_PROPOSED]} proposed") + return " · ".join(w for g, w in enumerate(words) if n[g]) + + +def review_table_lines(rows: list[dict]) -> list[str]: + """The `### Review table`: a count line, then one table of every named + task and backlog pick, grouped by the human's next action (a bold row + per group, empty groups left out) and numbered 1…N straight through, so + a reply can say "prm 1–4, 6".""" + out = [REVIEW_HEADING] + if not rows: + return out + ["Nothing to review — no tasks this shift.", ""] + out += [_count_line(rows), "", "| # | Task | Tier | Work | Note |", "|---|---|---|---|---|"] + n = 0 + for g, name in enumerate(REVIEW_GROUPS): + group = [r for r in rows if r["group"] == g] + if not group: + continue + out.append(f"| | **{name}** | | | |") + for r in group: + n += 1 + out.append(f"| {n} | " + " | ".join(r["cells"]) + " |") + return out + [""] + + def _line(task: str, counters: dict, tier: str, health, links: MindLinks | None = None, why: str = "", lease: dict | None = None) -> str: state, tiered = task_state(task, counters, health, lease=lease) @@ -764,12 +966,23 @@ def _packet(task: str, slot: Path, counters: dict) -> str: "- revert: see the PR") +def _memo(health): + """`health`, read once per URL.""" + seen: dict = {} + + def once(url): + if url not in seen: + seen[url] = health(url) + return seen[url] + return once + + def build(brief: dict, slot: Path, counters: dict, *, tiers: dict | None = None, health=None, issue: str = "", mind=None) -> str: """The `## Digest` block for one shift, as Markdown. `mind` is the watcher's Mind checkout, read locally for the prompt links.""" tiers = tiers or {} - health = health or pr_health + health = _memo(health or pr_health) # the table and the entries read it once try: # the slot file is the merge evidence; fresh at build time counters = {**counters, "slot_holders": _merge_slots.holders(slot)} except (_merge_slots.MergeSlotError, OSError): @@ -787,10 +1000,18 @@ def build(brief: dict, slot: Path, counters: dict, *, tiers: dict | None = None, inbox = [x for x in [_questions.inbox_line(counters, Path(slot).name, mind)] + _questions.unfiled_lines(counters) if x] lines += inbox + [""] if inbox else [] - lines += ["### Brief work"] links = MindLinks(mind, issue) # A worker still out at review-at keeps its lease. held = {t: l for t, l in held_leases(slot).items() if l.get("state") != "parked"} + # The review table: every named task and backlog pick (a settled + # carry-over is in neither, so it is left out here too). + rows = [] + for t in named + backlog: + tier = tiers.get(t, picks.get(t, {}).get("tier", "?")) + state, _ = task_state(t, counters, health, lease=held.get(t)) + rows.append(review_row(t, counters, state, tier, links)) + lines += review_table_lines(rows) + lines += ["### Brief work"] lines += [_line(t, counters, tiers.get(t, picks.get(t, {}).get("tier", "?")), health, links, lease=held.get(t)) for t in named] or [NO_PICKS] lines += ["", "### Backlog picks"] diff --git a/skills/batch/reference.md b/skills/batch/reference.md index cf1ab61..6876a3b 100644 --- a/skills/batch/reference.md +++ b/skills/batch/reference.md @@ -34,7 +34,8 @@ reached; `batch.md` points here from each one. ## Under a brief, the digest is the review surface **Under a brief, the digest is the review surface** (2026-11-03). The watcher -appends a `## Digest` to the record — brief work, then backlog picks with a +appends a `## Digest` to the record — a review table grouped by what the human +does next (merge, answer, fix, blocked, running, done), then brief work, then backlog picks with a one-line reason each, one proof packet per task, then the shift counters — and posts it once as a comment on the shift's `issue:`. The record plus that comment is what the human reads; the HTML packet is written only when the brief says diff --git a/tests/test_orchestrator_digest.py b/tests/test_orchestrator_digest.py index dc8a808..4ec01f0 100644 --- a/tests/test_orchestrator_digest.py +++ b/tests/test_orchestrator_digest.py @@ -477,3 +477,201 @@ def test_683_the_digest_lists_each_librarys_merge_order_and_marks_the_next_prm(t c["merge_waits"] = {} assert "### Merge order" not in _digest.build( _brief.parse(brief.read_text())["brief"], slot, c, health=_health, issue=ISSUE) + + +# --- PyAutoBrain#718: the review table at the top of the digest ---------------------- + +G = "https://github.com/example-org/autogalaxy/pull/" + + +def _row(task, counters, health=_health, tier="judge"): + state, _ = _digest.task_state(task, counters, health) + return _digest.review_row(task, counters, state, tier) + + +@pytest.mark.parametrize("counters, health, group", [ + pytest.param({"outcomes": {"t": {"prs": [G + "1"], "merged": [], "issues": []}}, + "closeouts": {G + "1": {"state": "refused", "why": "tier judge — your /prm"}}}, + _health, _digest.G_MERGE, id="awaiting-prm"), + pytest.param({"outcomes": {"t": {"prs": [G + "1"], "merged": [], "issues": []}}}, + _health, _digest.G_MERGE, id="ci-green"), + pytest.param({"outcomes": {"t": {"prs": [G + "1"], "merged": [], "issues": []}}}, + lambda u: "NO-CHECKS", _digest.G_MERGE, id="no-checks"), + pytest.param({"outcomes": {"t": {"prs": [G + "1"], "merged": [G + "1"], "issues": []}}}, + _health, _digest.G_MERGE, id="merged-with-no-slot-needs-you"), + pytest.param({"outcomes": {"t": {"prs": [], "merged": [], "issues": [G[:-5] + "issues/3"]}}}, + _health, _digest.G_ANSWER, id="parked-on-issue"), + pytest.param({"parked": ["t"]}, _health, _digest.G_ANSWER, id="blocked-on-a-person"), + pytest.param({"outcomes": {"t": {"prs": [G + "1"], "merged": [], "issues": []}}}, + lambda u: "FAILED", _digest.G_FIX, id="ci-failed"), + pytest.param({"abandoned": ["t"]}, _health, _digest.G_FIX, id="abandoned"), + pytest.param({"pending_redispatch": ["t"]}, _health, _digest.G_FIX, id="not-redispatched"), + pytest.param({}, _health, _digest.G_BLOCKED, id="not-started"), + pytest.param({"dropped": {"t": {}}}, _health, _digest.G_BLOCKED, id="dropped"), + pytest.param({"outcomes": {"t": {"prs": [], "merged": [], "issues": [], "obsolete": "done"}}}, + _health, _digest.G_BLOCKED, id="obsolete"), + pytest.param({"outcomes": {"t": {"prs": [G + "1"], "merged": [], "issues": []}}}, + lambda u: "RUNNING", _digest.G_MERGE, id="ci-running-is-your-prm"), + pytest.param({"outcomes": {"t": {"prs": [G + "1"], "merged": [], "issues": []}}, + "closeouts": {G + "1": {"state": "running"}}}, + _health, _digest.G_RUNNING, id="closeout-running"), + pytest.param({"outcomes": {"t": {"prs": [G + "1"], "merged": [G + "1"], "issues": []}}, + "closeouts": {G + "1": {"state": "merged", "model": "m"}}}, + _health, _digest.G_DONE, id="merged-unattended"), + pytest.param({"outcomes": {"t": {"prs": [], "merged": [], "issues": [G[:-5] + "issues/3"], + "verdicts": [G[:-5] + "issues/3"]}}}, + _health, _digest.G_DONE, id="verdict-posted"), + pytest.param({"picks": {"t": {"proposed": True}}}, _health, _digest.G_PROPOSED, + id="proposed-shadow"), +]) +def test_718_each_state_sits_in_its_action_group(counters, health, group): + assert _row("t", counters, health)["group"] == group + + +def test_718_a_task_goes_to_its_most_urgent_group(): + """One PR merged, one awaiting /prm: the task is a Merge row, not Done.""" + c = {"outcomes": {"t": {"prs": [G + "1", G + "2"], "merged": [G + "1"], "issues": []}}, + "closeouts": {G + "1": {"state": "merged", "model": "m"}, + G + "2": {"state": "refused", "why": "decision-taken — the human's /prm"}}} + row = _row("t", c) + assert row["group"] == _digest.G_MERGE + assert row["open_prs"] == 1 # the merged one is not counted + assert row["cells"][3] == "Merged; decision-taken" # in PR order + + +def test_718_groups_in_order_numbered_straight_through_and_empty_ones_left_out(): + rows = [{"group": g, "cells": [name, "judge", "—", "—"], "open_prs": 1} + for g, name in [(_digest.G_DONE, "d"), (_digest.G_MERGE, "m1"), + (_digest.G_BLOCKED, "b"), (_digest.G_MERGE, "m2")]] + lines = _digest.review_table_lines(rows) + assert lines[0] == "### Review table" + assert lines[1] == "2 to /prm (2 PRs) · 1 blocked or not started · 1 done" + one = [{**rows[1], "open_prs": 1}] + assert _digest.review_table_lines(one)[1] == "1 to /prm (1 PR)" + body = [ln for ln in lines if ln.startswith("| ") and not ln.startswith("| # ")] + assert body == ["| | **Merge: your /prm** | | | |", "| 1 | m1 | judge | — | — |", + "| 2 | m2 | judge | — | — |", "| | **Blocked or not started** | | | |", + "| 3 | b | judge | — | — |", "| | **Done** | | | |", + "| 4 | d | judge | — | — |"] + assert not any("Answer" in ln or "Still running" in ln for ln in lines) + assert _digest.review_table_lines([])[1].startswith("Nothing to review") + + +def test_718_a_multi_pr_task_lists_its_prs_in_merge_order_with_after(): + g7, g8, g9 = G + "7", G + "8", G + "9" + lens = "https://github.com/example-org/autolens/pull/5" + c = {"outcomes": {"t": {"prs": [g9, lens, g8], "merged": [], "issues": []}}, + "closeouts": {g7: {"state": "refused", "why": "tier judge — your /prm"}}, + "merge_waits": {g8: {"behind": [g7]}, g9: {"behind": [g7, g8]}}} + row = _row("t", c) + assert row["group"] == _digest.G_MERGE + assert row["cells"][2] == (f"[autogalaxy#8]({g8}) after autogalaxy#7
" + f"[autogalaxy#9]({g9}) after autogalaxy#7, autogalaxy#8
" + f"[autolens#5]({lens})") + + +def test_718_pipes_and_newlines_never_break_the_table(): + c = {"picks": {"t": {"title": "a | b\nc"}}, + "backlog_gates": {"named": {"draft/x/t.md": "repo a|b held by\nsomeone"}}} + row = _row("t", c) + assert row["cells"][0] == r"a \| b c" + assert row["cells"][3] == r"repo a\|b held by someone" + line = _digest.review_table_lines([row])[-2] + assert line.count("|") - line.count(r"\|") == 6 # 5 cells, never more + + +def test_718_the_digest_opens_with_the_table_and_brief_work_is_unchanged(tmp_path): + """Built from a real shift: the table sits after the notices and before + `### Brief work`, covers each named task and backlog pick once, leaves a + settled carry-over out, and the record still validates.""" + mind, brief, home = _shift(tmp_path) + slot = orch.slot_dir(brief, home) + c = orch.read_counters(slot) + done = "https://github.com/o/r/pull/66" + c["picks"]["carried"] = {"title": "Carried", "tier": "glance"} + c["outcomes"]["carried"] = {"prs": [done], "merged": [], "issues": [], + "carried_from": "2026-11-03-am"} + c["closeouts"] = {**(c.get("closeouts") or {}), + done: {"state": "refused", "settled": "merged", "why": "already merged"}} + b = _brief.parse(brief.read_text())["brief"] + d = _digest.build(b, slot, c, health=_health, issue=ISSUE) + head, rest = d.split("### Brief work", 1) + table = head.split("### Review table", 1)[1] + assert head.index("## Digest") < head.index("### Review table") + # `named` merged in-turn with no slot: it needs you, but no PR is left open. + assert table.splitlines()[1] == "1 to /prm · 1 blocked or not started · 1 still running" + rows = [ln for ln in table.splitlines() if ln[:2] == "| " and ln[2:3].isdigit()] + assert [r.split(" | ")[1] for r in rows] == ["named", "never", "picked"] + assert "Carried" not in table # settled: left out + assert "| " not in rest.split("### Proof packets")[0] # no table rows below + # The entries below are exactly what they were (the earlier tests pin them). + assert ("- **Merged with NO merge slot — needs you** — [named](https://github.com/o/r/pull/1)" + in rest) + assert _digest.validate(d) == [] + rec = tmp_path / "record.md" + rec.write_text(brief.read_text() + "\n" + d) + res = _brief.check(rec, mind) + assert res["ok"], res["errors"] + + +_ONE = {"prs": [G + "1"], "merged": [], "issues": []} + + +def _co(state, **kw): + return {"outcomes": {"t": dict(_ONE)}, "closeouts": {G + "1": {"state": state, **kw}}} + + +@pytest.mark.parametrize("counters, health, group, note", [ + pytest.param(_co("updated", after=[G + "0"]), lambda u: "FAILED", _digest.G_FIX, + "branch updated, CI FAILED", id="updated-ci-failed"), + pytest.param(_co("updated", after=[G + "0"]), _health, _digest.G_MERGE, + "branch updated, CI HEALTHY", id="updated-ci-green"), + pytest.param(_co("updated", after=[G + "0"]), lambda u: "RUNNING", _digest.G_MERGE, + "branch updated, CI RUNNING", id="updated-ci-running"), + pytest.param(_co("current"), lambda u: "FAILED", _digest.G_FIX, + "branch up to date, CI FAILED", id="current-ci-failed"), + pytest.param(_co("current"), _health, _digest.G_MERGE, + "branch up to date, CI HEALTHY", id="current-ci-green"), + pytest.param(_co("current"), lambda u: "RUNNING", _digest.G_MERGE, + "branch up to date, CI RUNNING", id="current-ci-running"), + pytest.param({"outcomes": {"t": dict(_ONE)}}, lambda u: "RUNNING", _digest.G_MERGE, + "CI still running", id="ci-running"), + pytest.param({"outcomes": {"t": dict(_ONE)}, + "sweep_waits": {G + "1": {"why": "workspace sweep unknown since 08:00Z"}}}, + _health, _digest.G_MERGE, "workspace sweep unknown", id="sweep-wait"), + pytest.param({"outcomes": {"t": {"prs": [], "merged": [], "issues": []}}}, _health, + _digest.G_BLOCKED, "finished, no PR or issue named", id="finished-no-pr"), + pytest.param({"outcomes": {"t": {**_ONE, "merged": [G + "1"]}}}, _health, _digest.G_MERGE, + "merged with NO merge slot", id="in-turn-no-slot"), + pytest.param({"outcomes": {"t": {**_ONE, "merged": [G + "1"]}}, + "slot_holders": {_digest._merge_slots.pr_key(G + "1"): {"task": "t"}}}, + _health, _digest.G_DONE, "Merged", id="in-turn-merged-with-slot"), + pytest.param(_co("refused", settled="merged", + why="already merged since 2026-11-23-am3 (by someone)"), + _health, _digest.G_DONE, "Already merged — nothing to do", id="settled"), + pytest.param({"outcomes": {"t": {**_ONE, "merged": [G + "1"]}}, "dropped": {"t": {}}}, + _health, _digest.G_MERGE, "dropped by /drop; merged with NO merge slot", + id="dropped-but-merged-with-no-slot"), + pytest.param({"outcomes": {"t": {"prs": [], "merged": [], + "issues": [G[:-5] + "issues/3"]}}, "dropped": {"t": {}}}, + _health, _digest.G_BLOCKED, "dropped by /drop; question on autogalaxy#3", + id="dropped-parked-stays-blocked"), + pytest.param({"outcomes": {"t": dict(_ONE)}, "dropped": {"t": {}}}, + lambda u: "FAILED", _digest.G_FIX, "dropped by /drop; CI failed — needs you", + id="dropped-but-ci-failed"), +]) +def test_718_review_round_1_states(counters, health, group, note): + row = _row("t", counters, health) + assert (row["group"], row["cells"][3]) == (group, note) + + +def test_718_a_verdict_is_not_an_open_pr(): + c = {"outcomes": {"t": {"prs": [G + "1", G + "2"], "merged": [], "issues": [], + "verdicts": [G + "1"]}}} + row = _row("t", c) + assert row["group"] == _digest.G_MERGE and row["open_prs"] == 1 + assert _digest._count_line([row]) == "1 to /prm (1 PR)" + + +def test_718_cells_escape_html_and_never_double_escape_a_pipe(): + assert _digest._cell("a \\| b | c") == "<b>a</b> \\| b \\| c"