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
15 changes: 12 additions & 3 deletions agents/conductors/community/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ gates every outward message.

| Mode | Surface | Consumed by |
|------|---------|-------------|
| `scan` *(default)* | the **Discussions hub**'s open threads (unanswered = no accepted answer and the last word is not ours) + every `PyAutoMind/repos.yaml` repo → open issues **and PRs** authored by non-self humans (bots filtered), with **awaiting-response** detection (the conversation's last word is not ours) ranked by waiting time, plus open PRs with **review requested** from a self login (any author) | `/community` step 1; the board's community sensory leg |
| `scan` *(default)* | the **Discussions hub**'s open threads (awaiting-response = no accepted answer and the last word is not ours, except Announcements and Show and tell, which remain ours to watch) + every `PyAutoMind/repos.yaml` repo → open issues **and PRs** authored by non-self humans (bots filtered), with **awaiting-response** detection (the conversation's last word is not ours) ranked by waiting time, plus open PRs with **review requested** from a self login (any author) | `/community` step 1; the board's community sensory leg |
| `triage <ref>` | one discussion, issue or PR → context-sufficiency signals (code block, traceback, versions, expected-vs-actual, data pointer), missing-signal clarifying-question seeds, comment tail, route; a discussion ref routes to **answer in the thread** (a confirmed bug gets an issue with a link back); a PR ref adds the **change-shape block** (draft, files, +/-, requested reviewers, mergeable state, head→base) | `/community` steps 2–3 |

```
Expand Down Expand Up @@ -62,10 +62,19 @@ failed search degrades honestly (`degraded:` in the surface), never silently.
reader: a question, a help request or an idea is answered in its
Discussions thread; a report with a reproducer is an issue and routes to
`/start_dev_for_user`; a discussion that turns out to be a bug gets an
issue opened with a link back and the thread marked answered with the
issue link. No session can post to, answer or convert a Discussion (the
issue opened with a link back. Accepted implementation proposals follow
that same issue route; the human marks the verdict comment as the accepted
answer in Ideas & Proposals, whether acceptance with the issue link or a recorded
no. Accepted answers settle threads in answerable categories only.
No session can post to, answer or convert a Discussion (the
REST Discussions API is read-only, GraphQL is refused) — the human's click
is always the last step.
- **Broadcasts are ours to watch.** Announcements and Show and tell remain
visible and can be triaged explicitly, but an outside comment does not
put them in awaiting-response. Help & Questions, Ideas & Proposals, and
Bugs & Errors follow the last-word rule until an accepted answer settles
the thread. Bugs & Errors is for investigation; confirmed reproducible
defects are tracked on linked repository issues.
- **Conversation state lives on GitHub + Mind, never here.** Labels
(`needs-info`, `pending-release`) and the issue thread itself are the
conversation's memory; in-flight dev state is the `user-facing: true` entry
Expand Down
31 changes: 20 additions & 11 deletions agents/conductors/community/_community.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/community skill reasons over:

scan the hub's open discussions (unanswered = no accepted answer and
the last word is not ours) + every repos.yaml repo -> open issues
the last word is not ours, except broadcast categories) + every repos.yaml repo -> open issues
AND pull requests raised by non-self humans (awaiting-response
detection, waiting-time ranking) + open PRs with review requested
from a self login (the board's community sensory leg)
Expand Down Expand Up @@ -63,6 +63,7 @@
# PyAutoLabs/.github. Every library and workspace points here; the repos
# themselves keep Discussions off.
HUB = os.environ.get("COMMUNITY_HUB", "PyAutoLabs/.github")
BROADCAST_CATEGORIES = {"Announcements", "Show and tell"}
SCAN_DETAIL_CAP = 30 # issues that get a per-issue last-commenter lookup
# Pause between search-API calls — the scan makes up to six, and GitHub's
# secondary rate limit trips on rapid bursts (hermetic tests set it to 0).
Expand Down Expand Up @@ -200,7 +201,8 @@ def _discussion_entry(d, hub):
def hub_discussions(hub, degraded):
"""Open, unlocked, human-authored threads on the hub. An accepted answer
settles a thread (awaiting_response=False without a comment lookup);
otherwise the last word decides, exactly as for an issue."""
broadcast categories remain ours to watch; otherwise the last word
decides, exactly as for an issue."""
items = list_discussions(hub)
if items is None:
degraded.append(f"{hub} discussions listing failed (gh auth? Discussions off?)")
Expand Down Expand Up @@ -267,9 +269,11 @@ def build_scan():
# v2 limit, recorded in AGENTS.md).
discussions = hub_discussions(HUB, degraded)
for entry in discussions:
if entry["answered"]:
if entry["answered"] or entry["category"] in BROADCAST_CATEGORIES:
entry["awaiting_response"] = False
conversations = issues + prs + [d for d in discussions if not d["answered"]]
conversations = issues + prs + [
d for d in discussions if d["awaiting_response"] is None
]
for entry in sorted(
conversations, key=lambda e: e["updated_at"] or "", reverse=True
)[:SCAN_DETAIL_CAP]:
Expand Down Expand Up @@ -327,11 +331,10 @@ def print_scan(s):
for e in s["awaiting_response"]:
days = f"{e['waiting_days']:.0f}d" if e["waiting_days"] is not None else "?"
print(f" ! {ref_label(e)} [{days} waiting] @{e['author']}: {e['title'][:70]}")
for e in s["open_external_issues"] + s["open_external_prs"]:
for e in s["open_external_issues"] + s["open_external_prs"] + s["open_discussions"]:
if not e["awaiting_response"]:
state = "ours-to-watch" if e["awaiting_response"] is False else "unchecked"
kind = "PR " if e["type"] == "pr" else ""
print(f" - {kind}{e['repo']}#{e['number']} ({state}) @{e['author']}: {e['title'][:70]}")
print(f" - {ref_label(e)} ({state}) @{e['author']}: {e['title'][:70]}")
if s["awaiting_review"]:
print(f"Review requested: {c['awaiting_review']}")
for e in s["awaiting_review"]:
Expand Down Expand Up @@ -428,6 +431,7 @@ def build_discussion_triage(owner_repo, number):
tail = _tail(comments)
last = tail[-1]["author"] if tail else (d.get("user") or {}).get("login")
answered = d.get("answer_chosen_at") is not None
category = (d.get("category") or {}).get("name")
return {
"type": "discussion",
"pr": None,
Expand All @@ -438,19 +442,24 @@ def build_discussion_triage(owner_repo, number):
"author": (d.get("user") or {}).get("login"),
"author_is_external": not is_self(d.get("user")),
"state": d.get("state"),
"category": (d.get("category") or {}).get("name"),
"category": category,
"answered": answered,
"labels": [l.get("name") for l in d.get("labels", []) or []],
"body": body,
"signals_present": present,
"signals_missing": missing,
"comment_tail": tail,
"awaiting_response": (not answered) and last not in SELF_LOGINS,
"awaiting_response": (
not answered and category not in BROADCAST_CATEGORIES
and last is not None and last not in SELF_LOGINS
),
"route": (
f"answer in the thread {d.get('html_url')} — the session drafts the "
"reply, the human posts it and marks the answer; a confirmed bug -> "
"reply, the human posts it and, in an answerable category, marks "
"the settling answer; a confirmed bug or accepted proposal -> "
"open the issue on the target repo with a link back, route it via "
"/start_dev_for_user, and mark the thread answered with the issue link"
"/start_dev_for_user. In Ideas & Proposals, mark the verdict comment "
"(acceptance with the issue link, or a recorded no) as the answer"
),
"reminders": [
"the session judges sufficiency — these signals are heuristics, not a verdict",
Expand Down
6 changes: 3 additions & 3 deletions board/_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,12 +1135,12 @@ def render_md(data):
if e.get("waiting_days") is not None else "?")
L.append(f" - `/community triage {community_ref(e)}` "
f"[{days} waiting] @{e['author']}: {e['title'][:70]}")
for e in c["open_external_issues"] + c["open_external_prs"]:
for e in c["open_external_issues"] + c["open_external_prs"] + c.get("open_discussions", []):
if (e.get("type"), e["repo"], e["number"]) in awaiting_keys:
continue
note = ("ours to watch" if e.get("awaiting_response") is False
else "unchecked")
L.append(f" - `/community triage {e['repo']}#{e['number']}` "
L.append(f" - `/community triage {community_ref(e)}` "
f"[{note}] @{e['author']}: {e['title'][:70]}")
for e in c["awaiting_review"]:
L.append(f" - `/community triage {e['repo']}#{e['number']}` "
Expand Down Expand Up @@ -1499,7 +1499,7 @@ def community_row(e, note, tone):
days = f"{waited:.0f}d waiting" if waited is not None else "waiting"
H.append(community_row(
e, days, "r" if (waited or 0) >= COMMUNITY_STALE_DAYS else "y"))
for e in c["open_external_issues"] + c["open_external_prs"]:
for e in c["open_external_issues"] + c["open_external_prs"] + c.get("open_discussions", []):
if (e.get("type"), e["repo"], e["number"]) in awaiting_keys:
continue
note = ("ours to watch" if e.get("awaiting_response") is False
Expand Down
20 changes: 15 additions & 5 deletions skills/community/community.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ docs: `bin/pyauto-brain help community`.

Emits a **CommunityScan**: the Discussions hub's open threads (the
surface users post to — `PyAutoMind/policy/community_surface.md`;
unanswered = no accepted answer and the last word is not ours), plus open
awaiting-response = no accepted answer and the last word is not ours,
except Announcements and Show and tell, which stay ours to watch), plus open
issues **and PRs** authored by non-self humans across every `repos.yaml`
repo, with awaiting-response detection ranked by waiting time, plus open
PRs with review requested from you. The Brain board runs this same scan
Expand All @@ -40,10 +41,19 @@ docs: `bin/pyauto-brain help community`.

3. **Converse — drafts only.** Based on your judgment:
- **A discussion** → answer **in the thread**: draft the reply, the human
posts it and marks it as the answer. If the thread is a bug with a
reproducer, open the issue on the target repo (quote the thread, link
it), route that issue via `/start_dev_for_user`, and have the human mark
the thread answered with the issue link. Never convert a thread in
posts it. In an answerable category, the human marks the settling reply
as the accepted answer. If the thread is a bug with a reproducer or an
accepted implementation proposal, open the issue on the target repo
(quote the thread, link it) and route it via `/start_dev_for_user`.
In **Ideas & Proposals**, mark the verdict comment — acceptance with the issue
link, or a recorded no — as the accepted answer; this is what stops the
Ears chasing the thread. Feature wishes and concrete designs share
that category. **Help & Questions** covers code and scientific help;
**Bugs & Errors** covers errors and suspected defects to investigate.
Confirmed reproducible defects still get linked repository issues.
Non-answerable categories have no accept button;
Announcements and Show and tell remain ours to watch and can still be
triaged explicitly. Never convert a thread in
place, and never ask a user to re-file: the hub is *their* surface.
No session can post to, answer or convert a Discussion — the REST API
is read-only and GraphQL is refused — so the human's click is the last
Expand Down
26 changes: 26 additions & 0 deletions tests/test_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def _default_fixtures(**overrides):
"annotations.json": [],
"comm_issues.json": EMPTY_SEARCH,
"comm_prs.json": EMPTY_SEARCH,
"comm_discussions.json": [],
"comments.json": [],
}
fx.update(overrides)
Expand Down Expand Up @@ -258,6 +259,7 @@ def _fabricate(tmp_path, fixtures, heart_board=None):
q=org:*is:issue*) cat "{fixture_dir}/comm_issues.json"; exit 0 ;;
q=org:*is:pr*) cat "{fixture_dir}/comm_prs.json"; exit 0 ;;
q=repo:*) cat "{fixture_dir}/comm_prs.json"; exit 0 ;;
repos/*/discussions) cat "{fixture_dir}/comm_discussions.json"; exit 0 ;;
*/comments) cat "{fixture_dir}/comments.json"; exit 0 ;;
esac
done
Expand Down Expand Up @@ -551,6 +553,30 @@ def test_every_community_conversation_gets_its_own_chip(tmp_path):
assert "`/community triage ExampleOrg/RepoB#9`" in md


def test_broadcast_discussion_is_visible_as_ours_to_watch(tmp_path):
url = "https://github.com/ExampleOrg/RepoA/discussions/21"
thread = {
**_community_item("ExampleOrg/RepoA", 21, "visitor", "release feedback"),
"html_url": url,
"category": {"name": "Announcements"},
"state": "open",
"answer_chosen_at": None,
}
stub = _fabricate(tmp_path, _default_fixtures(**{
"comm_discussions.json": [thread],
}))
page_result = _run(["--html"], tmp_path, stub)
assert page_result.returncode == 0, page_result.stderr
page = page_result.stdout
assert f'data-cmd="/community triage {url}"' in page
assert "ours to watch" in page
md_result = _run([], tmp_path, stub)
assert md_result.returncode == 0, md_result.stderr
md = md_result.stdout
assert f"`/community triage {url}` [ours to watch]" in md
assert "0 awaiting our reply" in md


def test_boards_footer_lists_the_family_without_self(tmp_path):
stub = _fabricate(tmp_path, _default_fixtures())
page = _run(["--html"], tmp_path, stub).stdout
Expand Down
83 changes: 80 additions & 3 deletions tests/test_community_conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import subprocess
from pathlib import Path

import pytest

BRAIN_HOME = Path(__file__).resolve().parents[1]
BRAIN = BRAIN_HOME / "bin" / "pyauto-brain"

Expand Down Expand Up @@ -50,7 +52,7 @@


def _discussion(hub, number, login, title, comments=0, answered=False,
category="Q&A", state="open", locked=False):
category="Help & Questions", state="open", locked=False):
return {
"number": number,
"title": title,
Expand Down Expand Up @@ -316,6 +318,81 @@ def test_scan_hears_the_hub_and_only_unanswered_threads_await(tmp_path):
assert "Open discussions: 3 on the hub" in text


@pytest.mark.parametrize("category,answered,awaiting", [
("Announcements", False, False),
("Show and tell", False, False),
("Help & Questions", False, True),
("Help & Questions", True, False),
("Ideas & Proposals", False, True),
("Ideas & Proposals", True, False),
("Bugs & Errors", False, True),
("Bugs & Errors", True, False),
])
def test_discussion_category_and_answer_control_response(
tmp_path, category, answered, awaiting,
):
discussion = _discussion(
HUB, 21, "Jammy2211", "a community thread", comments=1,
category=category, answered=answered,
)
discussion["body"] = "Context remains available for manual triage."
stub = _fabricate(tmp_path, {
**EMPTY_SEARCHES,
"discussions.json": [discussion],
"discussion.json": discussion,
"discussion_comments.json": [
{"user": {"login": "visitor"}, "created_at": "2026-07-10T01:00:00Z",
"body": "an outside comment"},
],
})
scan = _run(["scan", "--json"], tmp_path, stub)
assert scan.returncode == 0, scan.stderr
surface = json.loads(scan.stdout)
assert surface["open_discussions"][0]["awaiting_response"] is awaiting
assert len(surface["awaiting_response"]) == int(awaiting)
assert surface["counts"]["open_discussions"] == 1

triage = _run(["triage", f"{HUB}/discussions/21", "--json"], tmp_path, stub)
assert triage.returncode == 0, triage.stderr
context = json.loads(triage.stdout)
assert context["awaiting_response"] is awaiting
assert context["category"] == category
assert context["body"] == discussion["body"]
assert context["comment_tail"][0]["author"] == "visitor"
assert context["signals_missing"]
assert "answer in the thread" in context["route"]
assert "accepted proposal" in context["route"]
assert "in an answerable category" in context["route"]

readable = _run(["scan"], tmp_path, stub)
assert readable.returncode == 0, readable.stderr
assert discussion["html_url"] in readable.stdout
if not awaiting:
assert f"{discussion['html_url']} (ours-to-watch)" in readable.stdout


def test_broadcasts_do_not_consume_the_scan_detail_budget(tmp_path):
broadcasts = [
_discussion(HUB, number, "Jammy2211", "release news", comments=1,
category="Announcements")
for number in range(30)
]
question = _discussion(HUB, 40, "asker", "still need help", comments=1)
question["updated_at"] = "2026-07-09T00:00:00Z"
stub = _fabricate(tmp_path, {
**EMPTY_SEARCHES,
"discussions.json": broadcasts + [question],
"discussion_comments.json": [{"user": {"login": "visitor"}, "body": "hi"}],
})
result = _run(["scan", "--json"], tmp_path, stub)
assert result.returncode == 0, result.stderr
surface = json.loads(result.stdout)
assert [e["number"] for e in surface["awaiting_response"]] == [40]
assert all(e["awaiting_response"] is False for e in surface["open_discussions"][:30])
calls = (tmp_path / "gh_calls.log").read_text()
assert calls.count("/comments") == 1


def test_triage_discussion_ref_routes_to_the_thread(tmp_path):
stub = _fabricate(tmp_path, {
**EMPTY_SEARCHES,
Expand All @@ -334,11 +411,11 @@ def test_triage_discussion_ref_routes_to_the_thread(tmp_path):
assert t["type"] == "discussion" and t["pr"] is None
assert t["repo"] == HUB and t["number"] == 11
assert t["author_is_external"] and t["awaiting_response"]
assert t["category"] == "Q&A" and t["answered"] is False
assert t["category"] == "Help & Questions" and t["answered"] is False
assert "answer in the thread" in t["route"]
assert "/start_dev_for_user" in t["route"]
# Nothing in the run hit the issues endpoints for a discussion ref.
calls = (tmp_path / "gh_calls.log").read_text()
assert "/issues/" not in calls
text = _run(["triage", f"{HUB}/discussions/11"], tmp_path, stub).stdout
assert "(discussion)" in text and "Category: Q&A" in text
assert "(discussion)" in text and "Category: Help & Questions" in text
Loading