Skip to content

🚀 The fast, Pythonic way to build MCP servers and clients.

Add reproducible public triage leads to backlog dashboard (#6293)

nate nowack4b02172ca240
diff --git a/.github/workflows/backlog-status.yml b/.github/workflows/backlog-status.yml
index 1da4f7407..c8b8733ed 100644
--- a/.github/workflows/backlog-status.yml
+++ b/.github/workflows/backlog-status.yml
@@ -8,6 +8,10 @@ on:
- ".github/workflows/backlog-status.yml"
- "scripts/backlog_status.py"
- "tests/test_backlog_status.py"
+ - "scripts/public_triage.py"
+ - "tests/test_public_triage.py"
+ - "tests/test_status_refresh.cjs"
+ - "status-site/app.js"
permissions: {}
concurrency:
group: backlog-status-${{ github.event.pull_request.number || 'publisher' }}
@@ -36,6 +40,29 @@ jobs:
name: backlog
path: ${{ runner.temp }}/backlog.json
retention-days: 3
+ triage:
+ runs-on: ubuntu-latest
+ timeout-minutes: 15
+ permissions:
+ contents: read
+ issues: read
+ pull-requests: read
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
+ - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
+ with:
+ node-version: "24"
+ - name: Check dashboard refresh ordering
+ run: node --test tests/test_status_refresh.cjs
+ - name: Collect optional public triage analytics
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: python scripts/public_triage.py --output "$RUNNER_TEMP/triage.json"
+ - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
+ with:
+ name: triage
+ path: ${{ runner.temp }}/triage.json
+ retention-days: 3
publish:
needs: build
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
@@ -46,6 +73,7 @@ jobs:
concurrency:
group: maintenance-status-publish
cancel-in-progress: false
+ queue: max
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
@@ -67,3 +95,35 @@ jobs:
-c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
commit -q -m "backlog: $(jq -r .as_of backlog.json)"
git push -q origin status
+ publish-triage:
+ needs: triage
+ if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ permissions:
+ contents: write
+ concurrency:
+ group: maintenance-status-publish
+ cancel-in-progress: false
+ queue: max
+ steps:
+ - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
+ with:
+ name: triage
+ path: snapshot
+ - name: Preserve the public triage snapshot
+ env:
+ GH_TOKEN: ${{ github.token }}
+ REPOSITORY: ${{ github.repository }}
+ run: |
+ git init -q site
+ cd site
+ git remote add origin "https://x-access-token:${GH_TOKEN}@github.com/${REPOSITORY}.git"
+ git fetch -q --depth 1 origin status
+ git checkout -q -b status FETCH_HEAD
+ cp ../snapshot/triage.json .
+ git add triage.json
+ git -c user.name="github-actions[bot]" \
+ -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
+ commit -q -m "triage: $(jq -r .collection_started_at triage.json)"
+ git push -q origin status
diff --git a/.github/workflows/maintenance-status.yml b/.github/workflows/maintenance-status.yml
index bf59fd220..7e4c7c490 100644
--- a/.github/workflows/maintenance-status.yml
+++ b/.github/workflows/maintenance-status.yml
@@ -75,6 +75,7 @@ jobs:
concurrency:
group: maintenance-status-publish
cancel-in-progress: false
+ queue: max
steps:
- name: Fetch the snapshot
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
diff --git a/scripts/backlog_status.py b/scripts/backlog_status.py
index 7b65b66e9..7719bf6fb 100644
--- a/scripts/backlog_status.py
+++ b/scripts/backlog_status.py
@@ -25,7 +25,7 @@ def fetch_items() -> list[dict]:
"--paginate",
f"repos/{REPO}/issues?state=all&per_page=100&sort=created&direction=asc",
"--jq",
- ".[] | {number, title, state, state_reason, created_at, closed_at, draft, pull_request: (if .pull_request then {merged_at: .pull_request.merged_at} else null end)}",
+ ".[] | {number, title, state, state_reason, created_at, closed_at, draft, body, author_association, labels, user: {login: .user.login, type: .user.type}, pull_request: (if .pull_request then {merged_at: .pull_request.merged_at} else null end)}",
],
capture_output=True,
text=True,
@@ -76,7 +76,7 @@ def outcome(item: dict) -> str | None:
def sample(items: list[dict], at: datetime, source: str) -> dict:
- row = {"at": at.isoformat(), "source": source}
+ row: dict = {"at": at.isoformat(), "source": source}
for category in ("issues", "prs"):
eligible = [
item
@@ -105,7 +105,7 @@ def build(items: list[dict], previous: dict, now: datetime) -> dict:
key=lambda row: parse_time(row["at"]),
)
today = now.astimezone(CENTRAL).date()
- daily = {}
+ daily: dict = {}
for offset in range(365, -1, -1):
day = (today - timedelta(days=offset)).isoformat()
daily[day] = {
@@ -158,6 +158,7 @@ def main() -> None:
parser.add_argument("--previous", type=Path)
parser.add_argument("--import-history", type=Path)
parser.add_argument("--output", type=Path, required=True)
+ parser.add_argument("--triage-output", type=Path)
args = parser.parse_args()
previous = json.loads(args.previous.read_text()) if args.previous else {}
if args.previous and previous.get("schema") != SCHEMA:
@@ -183,6 +184,14 @@ def main() -> None:
require_complete(items, newest)
doc = build(items, previous, now)
args.output.write_text(json.dumps(doc, separators=(",", ":")) + "\n")
+ if args.triage_output:
+ from public_triage import build as triage
+
+ report = triage(items, now)
+ report["source_sha"] = subprocess.run(
+ ["git", "rev-parse", "HEAD"], capture_output=True, text=True, check=True
+ ).stdout.strip()
+ args.triage_output.write_text(json.dumps(report, separators=(",", ":")) + "\n")
if __name__ == "__main__":
diff --git a/scripts/public_triage.py b/scripts/public_triage.py
new file mode 100644
index 000000000..6890558b1
--- /dev/null
+++ b/scripts/public_triage.py
@@ -0,0 +1,312 @@
+"""Public review leads from GitHub inventory and fully paginated discussion.
+
+No private judgments, model calls, or write credentials. A lead is not a verdict.
+"""
+
+import argparse
+import hashlib
+import json
+import re
+import subprocess
+import time
+from collections import Counter
+from datetime import datetime, timezone
+from pathlib import Path
+from urllib.parse import quote
+
+REPO = "PrefectHQ/fastmcp"
+MAINTAINERS = {"OWNER", "MEMBER", "COLLABORATOR"}
+HOLD = re.compile(r"\b(?:dnm|draft|do[ -]?not[ -]?merge|don['’]?t[ -]?merge)\b", re.I)
+
+
+class GitHubReadError(RuntimeError):
+ """Only allowlisted diagnostics may reach public output, never raw stderr."""
+
+ def __init__(self, kind: str, attempts: int, status: int | None = None):
+ super().__init__(kind)
+ self.diagnostic = {"kind": kind, "attempts": attempts, "http_status": status}
+
+
+def github(path: str, *, paginate: bool = False) -> dict | list:
+ command = ["gh", "api", f"repos/{REPO}/{path}"]
+ if paginate:
+ command.extend(["--paginate", "--slurp"])
+ for attempt in (1, 2):
+ status = None
+ try:
+ result = subprocess.run(
+ command, capture_output=True, text=True, check=True, timeout=15
+ )
+ value = json.loads(result.stdout)
+ if paginate:
+ if not isinstance(value, list) or any(
+ not isinstance(p, list) for p in value
+ ):
+ raise GitHubReadError("invalid_response", attempt)
+ return [item for page in value for item in page]
+ if not isinstance(value, dict):
+ raise GitHubReadError("invalid_response", attempt)
+ return value
+ except subprocess.TimeoutExpired:
+ kind = "timeout"
+ except json.JSONDecodeError:
+ kind = "invalid_json"
+ except subprocess.CalledProcessError as exc:
+ # Extract only a numeric status and fixed categories. API messages can
+ # contain arbitrary user content or credentials; do not retain them.
+ stderr = exc.stderr if isinstance(exc.stderr, str) else ""
+ match = re.search(r"\(HTTP ([1-5][0-9]{2})\)", stderr)
+ status = int(match[1]) if match else None
+ kind = "http_error" if status else "command_failed"
+ if not status and "looking for beginning of value" in stderr:
+ kind = "invalid_json"
+ except OSError:
+ raise GitHubReadError("client_unavailable", attempt) from None
+ if attempt == 2 or not (
+ kind in {"timeout", "invalid_json"}
+ or status == 429
+ or (status and status >= 500)
+ ):
+ raise GitHubReadError(kind, attempt, status) from None
+ time.sleep(1)
+ raise AssertionError("Unreachable retry loop")
+
+
+def diagnostic(error: Exception, stage: str) -> dict:
+ value = (
+ error.diagnostic
+ if isinstance(error, GitHubReadError)
+ else {"kind": "invalid_response", "attempts": 1, "http_status": None}
+ )
+ return {"stage": stage, **value}
+
+
+def review_binding(review: dict, number: int) -> dict | None:
+ marker = re.match(
+ r"^<!-- fastmcp-triage-review:v1 pr:([0-9]+) head:([a-f0-9]{40}) base:([a-f0-9]{40}) -->",
+ review.get("body") or "",
+ )
+ if (
+ not marker
+ or int(marker[1]) != number
+ or review.get("state") != "COMMENTED"
+ or review.get("commit_id") != marker[2]
+ ):
+ return None
+ return {
+ "review_id": review.get("id"),
+ "head_sha": marker[2],
+ "baseline_sha": marker[3],
+ "body_sha256": hashlib.sha256(review["body"].encode()).hexdigest(),
+ }
+
+
+def parse_time(value: str) -> datetime:
+ return datetime.fromisoformat(value.replace("Z", "+00:00"))
+
+
+def held(item: dict) -> bool:
+ labels = [label["name"] for label in item.get("labels", [])]
+ return bool(HOLD.search(" ".join([item["title"], item.get("body") or "", *labels])))
+
+
+def inspect_pr(number: int, now: datetime) -> dict:
+ pr = github(f"pulls/{number}")
+ assert isinstance(pr, dict)
+ result = {
+ "head_sha": pr["head"]["sha"],
+ "base_sha": pr["base"]["sha"],
+ "target": pr["base"]["ref"],
+ "github_updated_at": pr["updated_at"],
+ "pr_collected_at": datetime.now(timezone.utc).isoformat(),
+ "eligible_at_read": pr["state"] == "open" and not pr["draft"] and not held(pr),
+ "activity": {"status": "unavailable"},
+ "collection_diagnostics": [],
+ }
+ # Do not nominate work that was closed, drafted or held after inventory read.
+ if not result["eligible_at_read"]:
+ return result
+ result["baseline_sha"] = None
+ try:
+ branch = github(f"branches/{quote(pr['base']['ref'], safe='')}")
+ assert isinstance(branch, dict)
+ baseline = branch["commit"]["sha"]
+ if not re.fullmatch(r"[a-f0-9]{40}", baseline):
+ raise ValueError("Invalid target SHA")
+ result["baseline_sha"] = baseline
+ result["baseline_collected_at"] = datetime.now(timezone.utc).isoformat()
+ except (GitHubReadError, ValueError, KeyError, AssertionError) as exc:
+ result["collection_diagnostics"].append(diagnostic(exc, "target_baseline"))
+ try:
+ result["activity"] = read_activity(number, pr, result["baseline_sha"])
+ except (
+ GitHubReadError,
+ subprocess.SubprocessError,
+ ValueError,
+ KeyError,
+ TypeError,
+ AttributeError,
+ ) as exc:
+ result["collection_diagnostics"].append(diagnostic(exc, "discussion"))
+ result["collection_gap"] = "Discussion collection failed; inspect GitHub"
+ return result
+
+
+def read_activity(number: int, pr: dict, baseline: str | None) -> dict:
+ comments = github(f"issues/{number}/comments?per_page=100", paginate=True)
+ reviews = github(f"pulls/{number}/reviews?per_page=100", paginate=True)
+ if (
+ not isinstance(comments, list)
+ or not isinstance(reviews, list)
+ or any(not isinstance(value, dict) for value in [*comments, *reviews])
+ ):
+ raise ValueError("Invalid discussion shape")
+ author = pr["user"]["login"]
+ human = [
+ a["created_at"] if "created_at" in a else a["submitted_at"]
+ for a in [*comments, *reviews]
+ if a.get("author_association") in MAINTAINERS
+ and (a.get("user") or {}).get("type") == "User"
+ and a["user"]["login"] != author
+ and (a.get("created_at") or a.get("submitted_at"))
+ ]
+ bot_reviews = [
+ a
+ for a in reviews
+ if (a.get("user") or {}).get("login") == "fastmcp-triage-reviewer[bot]"
+ and a["user"].get("type") == "Bot"
+ ]
+ bindings = [
+ binding for review in bot_reviews if (binding := review_binding(review, number))
+ ]
+ return {
+ "status": "collected",
+ "pagination": "all_returned_pages",
+ "comments": len(comments),
+ "reviews": len(reviews),
+ "first_maintainer_account_response_at": min(human, default=None),
+ "last_maintainer_account_activity_at": max(human, default=None),
+ "triage_app_review_seen": bool(bot_reviews),
+ "triage_app_review_on_snapshot_revision": (
+ any(
+ b["head_sha"] == pr["head"]["sha"] and b["baseline_sha"] == baseline
+ for b in bindings
+ )
+ if baseline is not None
+ else None
+ ),
+ "triage_app_review_bindings": bindings,
+ "collected_at": datetime.now(timezone.utc).isoformat(),
+ }
+
+
+def build(items: list[dict], now: datetime, limit: int = 5) -> dict:
+ age_counts = {kind: Counter() for kind in ("issues", "prs")}
+ candidates = []
+ for item in items:
+ created = parse_time(item["created_at"])
+ closed = item.get("closed_at")
+ if created > now or (closed and parse_time(closed) <= now):
+ continue
+ kind = "prs" if item.get("pull_request") is not None else "issues"
+ age = max(0, (now - parse_time(item["created_at"])).days)
+ bucket = (
+ "lt_7d"
+ if age < 7
+ else "7_30d"
+ if age < 30
+ else "30_90d"
+ if age < 90
+ else "gte_90d"
+ )
+ age_counts[kind][bucket] += 1
+ if (
+ kind == "prs"
+ and item["state"] == "open"
+ and not item.get("draft")
+ and not held(item)
+ and item.get("author_association") not in MAINTAINERS
+ and (item.get("user") or {}).get("type") == "User"
+ ):
+ candidates.append(item)
+ candidates.sort(key=lambda item: (item["created_at"], item["number"]))
+ leads: list[dict] = []
+ for item in candidates[:limit]:
+ lead = {
+ "number": item["number"],
+ "title": item["title"],
+ "url": f"https://github.com/{REPO}/pull/{item['number']}",
+ "author": item["user"]["login"],
+ "age_days": max(0, (now - parse_time(item["created_at"])).days),
+ "activity": {"status": "unavailable"},
+ }
+ try:
+ lead.update(inspect_pr(item["number"], now))
+ except (
+ GitHubReadError,
+ subprocess.SubprocessError,
+ ValueError,
+ KeyError,
+ AssertionError,
+ ) as exc:
+ lead["collection_diagnostics"] = [diagnostic(exc, "pr_metadata")]
+ # Unknown stays unknown; never turn failed collection into no response.
+ lead["collection_gap"] = (
+ "PR or discussion collection failed; inspect GitHub"
+ )
+ if lead.get("eligible_at_read") is False:
+ continue
+ leads.append(lead)
+ return {
+ "schema": "fastmcp-public-triage/1",
+ "repo": REPO,
+ "collection_started_at": now.isoformat(),
+ "collection_finished_at": datetime.now(timezone.utc).isoformat(),
+ "inventory_items": len(items),
+ "open_age_buckets": {
+ kind: {key: counts[key] for key in ("lt_7d", "7_30d", "30_90d", "gte_90d")}
+ for kind, counts in age_counts.items()
+ },
+ "selection": {
+ "method": "oldest open, non-draft, non-held PRs by non-maintainer user accounts",
+ "eligible_in_inventory": len(candidates),
+ "inspection_limit": limit,
+ "returned": len(leads),
+ },
+ "lead_collection_status": "partial"
+ if any(
+ lead["activity"]["status"] != "collected"
+ or lead.get("collection_diagnostics")
+ for lead in leads
+ )
+ else "collected",
+ "review_leads": leads,
+ "limitations": [
+ "GitHub reads are sequential, not an atomic snapshot. Recheck current head, holds and discussion before acting.",
+ "Discussion includes issue comments and submitted reviews, not inline review threads or all timeline activity.",
+ "Maintainer account activity can be agent-assisted; it is not acknowledgement, approval or disposition.",
+ "A triage-app review, including on the snapshot head and target baseline, does not establish executable or independent verification.",
+ "Missing activity is unknown. Absence from this bounded queue does not mean handled. No closure or merge is authorized.",
+ ],
+ }
+
+
+def main() -> None:
+ from backlog_status import fetch_items, newest_number, require_complete
+
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("--output", type=Path, required=True)
+ args = parser.parse_args()
+ started = datetime.now(timezone.utc).replace(microsecond=0)
+ newest = newest_number()
+ items = fetch_items()
+ require_complete(items, newest)
+ report = build(items, started)
+ report["source_sha"] = subprocess.run(
+ ["git", "rev-parse", "HEAD"], capture_output=True, text=True, check=True
+ ).stdout.strip()
+ args.output.write_text(json.dumps(report, separators=(",", ":")) + "\n")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/status-site/README.md b/status-site/README.md
index 31d52d981..59cc2b059 100644
--- a/status-site/README.md
+++ b/status-site/README.md
@@ -61,3 +61,70 @@ remain ranking hints; their presence does not prove that the reporter still owes
a response. Check the discussion and later edits before acting on them.
On GitHub Pages, the browser reads JSON directly from the public `status` branch: bot commits do not trigger a Pages rebuild. Other hosts and local previews use adjacent `status.json`. Publishing the UI itself still requires a Pages deployment.
+
+## Public triage leads
+
+The existing half-hourly workflow publishes `triage.json` (`fastmcp-public-triage/1`)
+from a separate read-only job. Its independent public inventory read supplies age
+buckets and the five oldest
+open, non-draft, non-held contributor PR leads (by non-maintainer user accounts).
+Non-draft does not imply ready: contributors may still owe revisions. Both JSON and the
+page are public, reproducible from this repository, and independent of personal
+infrastructure, models, private reviewer ledgers, and Prefect Cloud credentials.
+
+```sh
+python scripts/public_triage.py --output triage.json
+```
+
+Run in a checkout with `gh` authenticated for read access. The report records the
+source commit, collection start/end, inventory size, selection bounds, exact PR
+head/base and activity collection status. Conversation comments and submitted
+reviews use all API pages; inline threads and other timeline events are excluded.
+Failed reads stay unavailable, never “unanswered.” Maintainer account activity
+can be agent-assisted and is not acknowledgement or approval. Triage-app review
+presence is separated from an authenticated EGM marker matching the PR number,
+snapshot head, submitted-review commit and separately collected target-branch tip.
+`base_sha` is the PR metadata's reported base; `baseline_sha` is the target tip
+read from the branch endpoint. A missing target tip makes revision matching
+unknown, not false. Valid public marker bindings retain the review ID and body
+hash, not the body. None of these observations proves tests or independent
+verification. Reads are not atomic: recheck heads, holds, discussion,
+CI, compatibility and supported behavior before any action. Missing from this
+bounded oldest-first queue does not mean handled. No closure/merge is authorized.
+
+Age buckets describe inventory at collection, including draft PRs; they are not
+historical reconstructions. Empty successful collection is explicitly zero, while
+GitHub inventory failure fails the job. The page flags collections over two hours
+old and handles unavailable triage data independently of the existing chart.
+Private evidence, author assessments and human authorizations must stay out of
+this public JSON. This is review prioritization, not a measure of causal model
+benefit or shipped fixes. A smaller backlog remains subject to correctness,
+performance, contributor credit and downstream compatibility checks.
+
+Refresh waits for both datasets; superseded successes and errors cannot replace
+a newer refresh. Check this behavior with `node --test tests/test_status_refresh.cjs`.
+
+## Collection failures and publication independence
+
+PR-detail reads retry once for timeouts, invalid JSON, HTTP 429 and HTTP 5xx.
+Authentication/permission/not-found errors are not blindly retried. Public
+`collection_diagnostics` contain only a stage, fixed error category, numeric HTTP
+status when available and attempt count. Raw stdout, stderr, response bodies and
+credentials are never diagnostics. A successful PR observation survives a failed
+discussion or target-tip read. `lead_collection_status` is partial when any
+returned lead has a gap; it does not claim coverage of all PRs or all activity.
+
+The first PR build retained five unavailable detail reads without their causes;
+that artifact cannot establish why they failed. This diagnostics contract makes
+future gaps inspectable without inventing an outage diagnosis or a no-response
+verdict. A successful retry is not evidence that historical failures had the
+same cause.
+
+Backlog collection and publication do not depend on the optional triage job.
+Both publishers and the maintenance publisher serialize writes to the existing
+status branch with `queue: max`, so one waiting publisher cannot displace another. The independent
+reads can observe different queue states; compare their collection timestamps
+rather than treating different totals as an inconsistency. A failed triage
+build leaves its previous snapshot to age visibly while the backlog can still
+advance. The public marker lookup reads GitHub only; it neither queries private
+Cloud artifacts nor acknowledges, authorizes or executes workflow decisions.
diff --git a/status-site/app.js b/status-site/app.js
index a892d3bcb..08f0b27b3 100644
--- a/status-site/app.js
+++ b/status-site/app.js
@@ -3,6 +3,10 @@ const DATA_URL =
window.location.origin === "https://prefecthq.github.io"
? "https://raw.githubusercontent.com/PrefectHQ/fastmcp/status/backlog.json"
: new URL("backlog.json", window.location.href).href;
+const TRIAGE_URL =
+ window.location.origin === "https://prefecthq.github.io"
+ ? "https://raw.githubusercontent.com/PrefectHQ/fastmcp/status/triage.json"
+ : new URL("triage.json", window.location.href).href;
const TZ = "America/Chicago";
const DAY = 86400000;
const labels = {
@@ -225,8 +229,15 @@ function backlog() {
cursor.setAttribute("x1", x(row));
cursor.setAttribute("x2", x(row));
cursor.setAttribute("visibility", "visible");
- $("backlog-readout").textContent =
- `${dateLabel(row.at, { year: "numeric", hour: "numeric", minute: "2-digit" })} Central: ${number(row.issues.open)} issues · ${number(row.prs.open)} PRs${row.prs.draft != null ? ` (${row.prs.draft} draft)` : ""} · ${row.source === "live" ? "recorded" : "reconstructed"}`;
+ $("backlog-readout").textContent = `${dateLabel(row.at, {
+ year: "numeric",
+ hour: "numeric",
+ minute: "2-digit",
+ })} Central: ${number(row.issues.open)} issues · ${number(
+ row.prs.open,
+ )} PRs${row.prs.draft != null ? ` (${row.prs.draft} draft)` : ""} · ${
+ row.source === "live" ? "recorded" : "reconstructed"
+ }`;
};
interactions(
graph,
@@ -290,7 +301,9 @@ function recent() {
box.append(
node(
"small",
- `${row.completed} completed · ${row.not_planned} not planned${row.other_closed ? ` · ${row.other_closed} unspecified` : ""}`,
+ `${row.completed} completed · ${row.not_planned} not planned${
+ row.other_closed ? ` · ${row.other_closed} unspecified` : ""
+ }`,
),
);
$("recent").append(box);
@@ -313,14 +326,18 @@ function activity() {
chip,
node(
"span",
- `${labels[key]} ${number(rows.reduce((sum, row) => sum + row[key], 0))}`,
+ `${labels[key]} ${number(
+ rows.reduce((sum, row) => sum + row[key], 0),
+ )}`,
),
);
$("activity-legend").append(item);
}
const { graph, left, right, top, bottom, width } = chartFrame(
"activity-chart",
- `Daily ${category === "issues" ? "issue" : "pull request"} openings and closure outcomes. Use arrow keys then Enter to inspect a day.`,
+ `Daily ${
+ category === "issues" ? "issue" : "pull request"
+ } openings and closure outcomes. Use arrow keys then Enter to inspect a day.`,
270,
);
const max = Math.max(
@@ -388,8 +405,9 @@ function activity() {
const row = rows[index];
cursor.setAttribute("x", left + index * step);
cursor.setAttribute("visibility", "visible");
- $("activity-readout").textContent =
- `${dayLabel(row.day)}: ${keys.map((key) => `${row[key]} ${labels[key].toLowerCase()}`).join(" · ")}`;
+ $("activity-readout").textContent = `${dayLabel(row.day)}: ${keys
+ .map((key) => `${row[key]} ${labels[key].toLowerCase()}`)
+ .join(" · ")}`;
};
interactions(
graph,
@@ -403,8 +421,9 @@ function activity() {
}
function detail(day, open) {
selectedDay = day;
- $("detail-title").textContent =
- `${dayLabel(day)} · ${category === "issues" ? "issues" : "pull requests"}`;
+ $("detail-title").textContent = `${dayLabel(day)} · ${
+ category === "issues" ? "issues" : "pull requests"
+ }`;
if (open) $("activity-detail").open = true;
const rows = data.events.filter(
(item) => item.day === day && item.kind === category,
@@ -425,7 +444,9 @@ function detail(day, open) {
for (const item of rows) {
const row = node("div", null, "work-row"),
link = node("a", `#${item.number}`);
- link.href = `https://github.com/PrefectHQ/fastmcp/${item.kind === "prs" ? "pull" : "issues"}/${item.number}`;
+ link.href = `https://github.com/PrefectHQ/fastmcp/${
+ item.kind === "prs" ? "pull" : "issues"
+ }/${item.number}`;
row.append(
link,
node("span", item.title),
@@ -446,18 +467,136 @@ function render() {
recent();
activity();
const stale = Date.now() - Date.parse(data.as_of) > 2 * 60 * 60 * 1000;
- $("freshness").textContent =
- `Updated ${dateLabel(data.as_of, { year: "numeric", hour: "numeric", minute: "2-digit" })} Central${stale ? " · update overdue" : ""}`;
+ $("freshness").textContent = `Updated ${dateLabel(data.as_of, {
+ year: "numeric",
+ hour: "numeric",
+ minute: "2-digit",
+ })} Central${stale ? " · update overdue" : ""}`;
$("notice").hidden = !stale;
$("notice").textContent =
"The latest snapshot is over two hours old. Counts may have changed; follow GitHub for the current queue.";
}
-async function refresh() {
- $("refresh").disabled = true;
+let refreshGeneration = 0;
+async function refreshTriage(generation) {
+ $("triage-data").href = TRIAGE_URL;
+ try {
+ const response = await fetch(TRIAGE_URL, { cache: "no-store" });
+ if (!response.ok) throw new Error("Triage unavailable");
+ const report = await response.json();
+ if (generation !== refreshGeneration) return;
+ if (
+ report.schema !== "fastmcp-public-triage/1" ||
+ !Array.isArray(report.review_leads) ||
+ !Number.isFinite(Date.parse(report.collection_started_at))
+ )
+ throw new Error("Invalid triage data");
+ const stale =
+ Date.now() - Date.parse(report.collection_started_at) >
+ 2 * 60 * 60 * 1000;
+ $("triage-freshness").textContent =
+ `Collection began ${dateLabel(report.collection_started_at, {
+ year: "numeric",
+ hour: "numeric",
+ minute: "2-digit",
+ })} Central${
+ stale ? " · update overdue; refresh GitHub before acting" : ""
+ }. ` +
+ `${report.selection.returned} lead${
+ report.selection.returned === 1 ? "" : "s"
+ } shown from ${
+ report.selection.eligible_in_inventory
+ } eligible PRs. Detail collection: ${
+ report.lead_collection_status || "unknown"
+ }. Reads are not atomic.`;
+ const ages = node("table"),
+ header = node("tr");
+ for (const label of [
+ "Open inventory",
+ "Under 7 days",
+ "7–29 days",
+ "30–89 days",
+ "90+ days",
+ ])
+ header.append(node("th", label));
+ ages.append(header);
+ for (const [kind, label] of [
+ ["issues", "Issues"],
+ ["prs", "PRs (including drafts)"],
+ ]) {
+ const row = node("tr");
+ row.append(node("th", label));
+ for (const key of ["lt_7d", "7_30d", "30_90d", "gte_90d"])
+ row.append(node("td", number(report.open_age_buckets[kind][key])));
+ ages.append(row);
+ }
+ $("triage-ages").replaceChildren(ages);
+ $("triage-leads").replaceChildren();
+ for (const lead of report.review_leads) {
+ const row = node("article", null, "work-row");
+ const link = node("a", `#${lead.number}`);
+ link.href = `https://github.com/PrefectHQ/fastmcp/pull/${lead.number}`;
+ const description = node("div");
+ description.append(node("p", lead.title));
+ let status =
+ "Discussion unavailable; inspect GitHub. No response conclusion.";
+ if (lead.activity.status === "collected") {
+ const last = lead.activity.last_maintainer_account_activity_at;
+ status = last
+ ? `Last maintainer account activity: ${dateLabel(last)}.`
+ : "No maintainer account response in collected conversation comments or reviews.";
+ if (lead.activity.triage_app_review_seen)
+ status += lead.activity.triage_app_review_on_snapshot_revision
+ ? " Triage-app marker matches snapshot head and target baseline; verification still needs checking."
+ : lead.activity.triage_app_review_on_snapshot_revision === null
+ ? " Triage-app review seen; target baseline unavailable."
+ : " Historical or unbound triage-app review; no matching revision marker.";
+ }
+ description.append(node("small", status));
+ for (const gap of lead.collection_diagnostics || [])
+ description.append(
+ node(
+ "small",
+ ` ${gap.stage}: ${gap.kind}${
+ gap.http_status ? ` (HTTP ${gap.http_status})` : ""
+ }; ${gap.attempts} attempt(s).`,
+ ),
+ );
+ if (lead.head_sha)
+ description.append(
+ node(
+ "small",
+ ` Snapshot head ${lead.head_sha.slice(0, 8)} · ${lead.target}${
+ lead.baseline_sha
+ ? ` at ${lead.baseline_sha.slice(0, 8)}`
+ : " (baseline unavailable)"
+ }.`,
+ ),
+ );
+ row.append(
+ link,
+ description,
+ node("span", `${lead.age_days} days`, "state"),
+ );
+ $("triage-leads").append(row);
+ }
+ if (!report.review_leads.length)
+ $("triage-leads").append(
+ node("p", "No leads in this bounded selection. Other work may remain."),
+ );
+ } catch {
+ if (generation !== refreshGeneration) return;
+ $("triage-freshness").textContent =
+ "Triage collection unavailable. Use GitHub for the current queue.";
+ $("triage-ages").replaceChildren();
+ $("triage-leads").replaceChildren();
+ }
+}
+async function refreshBacklog(generation) {
try {
const response = await fetch(DATA_URL, { cache: "no-store" });
if (!response.ok) throw new Error("Data unavailable");
const next = await response.json();
+ if (generation !== refreshGeneration) return;
if (
next.schema !== "fastmcp-backlog/1" ||
!next.samples?.length ||
@@ -469,12 +608,20 @@ async function refresh() {
data = next;
render();
} catch {
+ if (generation !== refreshGeneration) return;
$("notice").hidden = false;
$("notice").textContent = data
? "Refresh failed. Showing the last loaded data; check its timestamp above."
: "Backlog data is unavailable. Refresh to try again, or open the GitHub source below.";
+ }
+}
+async function refresh() {
+ const generation = ++refreshGeneration;
+ $("refresh").disabled = true;
+ try {
+ await Promise.all([refreshTriage(generation), refreshBacklog(generation)]);
} finally {
- $("refresh").disabled = false;
+ if (generation === refreshGeneration) $("refresh").disabled = false;
}
}
document.querySelectorAll("[data-days]").forEach((button) =>
diff --git a/status-site/index.html b/status-site/index.html
index 695f1c672..c7543930b 100644
--- a/status-site/index.html
+++ b/status-site/index.html
@@ -82,6 +82,27 @@
<div id="detail-items"></div>
</details>
</section>
+ <section aria-labelledby="triage-heading">
+ <h2 id="triage-heading">Where review can help</h2>
+ <p class="caption">
+ Oldest non-draft contributor PR leads, not approval or closure
+ recommendations. Contributors may still be revising them. Read the
+ current discussion, supported contract and verification evidence
+ before acting.
+ </p>
+ <p id="triage-freshness" class="caption" role="status">
+ Reading public triage data…
+ </p>
+ <div id="triage-ages"></div>
+ <div id="triage-leads"></div>
+ <p class="caption">
+ Activity covers paginated conversation comments and submitted reviews.
+ Inline threads and other timeline events are not included. Maintainer
+ account activity may be agent-assisted; bot review does not establish
+ independent verification.
+ </p>
+ <a id="triage-data" href="triage.json">Download triage JSON</a>
+ </section>
<section id="method" class="method" aria-labelledby="method-heading">
<h2 id="method-heading">About the data</h2>
<p>
diff --git a/status-site/style.css b/status-site/style.css
index d195bd196..49de7649b 100644
--- a/status-site/style.css
+++ b/status-site/style.css
@@ -385,3 +385,22 @@ footer button {
text-decoration-color: var(--line);
text-underline-offset: 3px;
}
+
+#triage-ages {
+ overflow-x: auto;
+ margin: 1rem 0;
+}
+#triage-ages table {
+ width: 100%;
+ border-collapse: collapse;
+ font-variant-numeric: tabular-nums;
+}
+#triage-ages th,
+#triage-ages td {
+ padding: 0.5rem 0.7rem;
+ text-align: right;
+ white-space: nowrap;
+}
+#triage-ages th:first-child {
+ text-align: left;
+}
diff --git a/tests/test_backlog_status.py b/tests/test_backlog_status.py
index 1fcc678ad..b4f6c9aa4 100644
--- a/tests/test_backlog_status.py
+++ b/tests/test_backlog_status.py
@@ -1,6 +1,8 @@
"""Counts, outcomes, and imported evidence for the public backlog charts."""
import importlib.util
+import json
+import sys
from datetime import datetime, timezone
from pathlib import Path
@@ -136,3 +138,15 @@ def test_truncated_collection_fails_without_publishing(backlog, tmp_path, monkey
def test_items_created_during_collection_are_accepted(backlog):
backlog.require_complete([item(1), item(2), item(3)], 2)
+
+
+def test_backlog_cli_does_not_require_optional_triage(backlog, tmp_path, monkeypatch):
+ output = tmp_path / "backlog.json"
+ monkeypatch.setitem(sys.modules, "public_triage", None)
+ monkeypatch.setattr("sys.argv", ["backlog_status.py", "--output", str(output)])
+ monkeypatch.setattr(backlog, "newest_number", lambda: 1)
+ monkeypatch.setattr(backlog, "fetch_items", lambda: [item(1)])
+ backlog.main()
+ report = json.loads(output.read_text())
+ assert report["schema"] == "fastmcp-backlog/1"
+ assert report["samples"][-1]["issues"]["open"] == 1
diff --git a/tests/test_public_triage.py b/tests/test_public_triage.py
new file mode 100644
index 000000000..b6b95ef53
--- /dev/null
+++ b/tests/test_public_triage.py
@@ -0,0 +1,487 @@
+"""Public analytics preserve uncertainty and do not manufacture review verdicts."""
+
+import importlib.util
+import json
+import subprocess
+import sys
+from datetime import datetime, timezone
+from pathlib import Path
+from types import SimpleNamespace
+
+import pytest
+
+NOW = datetime(2026, 11, 3, 18, tzinfo=timezone.utc)
+
+
+def triage():
+ spec = importlib.util.spec_from_file_location(
+ "public_triage", Path(__file__).parents[1] / "scripts/public_triage.py"
+ )
+ assert spec and spec.loader
+ module = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(module)
+ return module
+
+
+def item(number=1, **overrides):
+ return {
+ "number": number,
+ "title": "Fix supported behavior",
+ "created_at": "2026-10-01T00:00:00Z",
+ "state": "open",
+ "pull_request": {},
+ "draft": False,
+ "author_association": "NONE",
+ "user": {"login": "contributor", "type": "User"},
+ **overrides,
+ }
+
+
+def pr(**overrides):
+ return {
+ **item(),
+ "head": {"sha": "a" * 40},
+ "base": {"sha": "b" * 40, "ref": "main"},
+ "updated_at": "2026-11-03T00:00:00Z",
+ **overrides,
+ }
+
+
+def activity(login, when, *, bot=False, association="MEMBER", **fields):
+ return {
+ "user": {"login": login, "type": "Bot" if bot else "User"},
+ "author_association": association,
+ "created_at": when,
+ **fields,
+ }
+
+
+def test_discussion_after_first_page_and_historical_review(triage, monkeypatch):
+ # Paginated REST pages include a maintainer after 100 earlier comments.
+ comments = [activity("contributor", "2026-10-02T00:00:00Z")] * 100
+ last = activity("maintainer", "2026-11-02T00:00:00Z")
+ review = activity(
+ "fastmcp-triage-reviewer[bot]",
+ "2026-10-03T00:00:00Z",
+ bot=True,
+ commit_id="c" * 40,
+ )
+ calls = []
+
+ def run(command, **kwargs):
+ calls.append(command)
+ value = [[*comments], [last]] if "comments" in command[2] else [[review]]
+ if "--paginate" not in command:
+ value = {"commit": {"sha": "b" * 40}} if "branches/" in command[2] else pr()
+ return SimpleNamespace(stdout=json.dumps(value))
+
+ monkeypatch.setattr(triage.subprocess, "run", run)
+ report = triage.build([item()], NOW)
+ lead = report["review_leads"][0]
+ assert lead["activity"]["comments"] == 101
+ assert lead["activity"]["last_maintainer_account_activity_at"] == last["created_at"]
+ assert lead["activity"]["triage_app_review_seen"] is True
+ assert lead["activity"]["triage_app_review_on_snapshot_revision"] is False
+ assert lead["head_sha"] == "a" * 40
+ assert all(
+ "--slurp" in command
+ for command in calls
+ if "comments" in command[2] or "reviews" in command[2]
+ )
+
+
+def test_failed_activity_is_unknown_not_unanswered(triage, monkeypatch):
+ def failed(*args, **kwargs):
+ raise subprocess.TimeoutExpired("gh", 20)
+
+ monkeypatch.setattr(triage, "github", failed)
+ report = triage.build([item()], NOW)
+ lead = report["review_leads"][0]
+ assert lead["activity"] == {"status": "unavailable"}
+ assert "first_maintainer_account_response_at" not in lead["activity"]
+ assert "collection_gap" in lead
+ assert report["open_age_buckets"]["prs"]["30_90d"] == 1
+
+
+def test_bot_and_author_are_not_maintainer_response(triage, monkeypatch):
+ comments = [
+ activity("contributor", "2026-10-02T00:00:00Z"),
+ activity("bot", "2026-10-03T00:00:00Z", bot=True),
+ ]
+ monkeypatch.setattr(
+ triage,
+ "github",
+ lambda path, **kw: pr() if not kw else comments if "comments" in path else [],
+ )
+ lead = triage.build([item()], NOW)["review_leads"][0]
+ assert lead["activity"]["status"] == "collected"
+ assert lead["activity"]["first_maintainer_account_response_at"] is None
+
+
+ "change",
+ [
+ {"draft": True},
+ {"title": "[DNM] Fix"},
+ {"body": "DO NOT MERGE"},
+ {"labels": [{"name": "dont-merge"}]},
+ {"author_association": "MEMBER"},
+ {"user": {"login": "bot", "type": "Bot"}},
+ ],
+)
+def test_holds_drafts_bots_and_maintainers_are_not_leads(triage, monkeypatch, change):
+ monkeypatch.setattr(
+ triage, "github", lambda *a, **kw: pytest.fail("must not inspect excluded PR")
+ )
+ report = triage.build([item(**change)], NOW)
+ assert not report["review_leads"]
+ assert sum(report["open_age_buckets"]["prs"].values()) == 1
+
+
+def test_hold_after_inventory_prevents_nomination(triage, monkeypatch):
+ monkeypatch.setattr(triage, "github", lambda *a, **kw: pr(title="[DRAFT] held"))
+ report = triage.build([item()], NOW)
+ assert report["selection"]["eligible_in_inventory"] == 1
+ assert not report["review_leads"]
+
+
+def test_age_boundaries_and_empty_success_are_explicit(triage):
+ dates = ["2026-11-03", "2026-10-27", "2026-10-04", "2026-08-05"]
+ items = [
+ item(i, pull_request=None, created_at=d + "T18:00:00Z")
+ for i, d in enumerate(dates)
+ ]
+ report = triage.build(items, NOW)
+ assert report["open_age_buckets"]["issues"] == {
+ "lt_7d": 1,
+ "7_30d": 1,
+ "30_90d": 1,
+ "gte_90d": 1,
+ }
+ empty = triage.build([], NOW)
+ assert empty["inventory_items"] == 0
+ assert empty["collection_started_at"] == NOW.isoformat()
+ assert empty["collection_finished_at"]
+ assert empty["selection"]["returned"] == 0
+
+
+def test_bounded_queue_keeps_counts_and_does_not_export_bodies(triage, monkeypatch):
+ calls = []
+
+ def inspect(number, now):
+ calls.append(number)
+ return {"activity": {"status": "unavailable"}}
+
+ monkeypatch.setattr(triage, "inspect_pr", inspect)
+ report = triage.build(
+ [item(2, body="unpublished-sentinel input"), item(1)], NOW, limit=1
+ )
+ assert calls == [1]
+ assert report["selection"]["eligible_in_inventory"] == 2
+ assert sum(report["open_age_buckets"]["prs"].values()) == 2
+ assert "unpublished-sentinel" not in json.dumps(report)
+
+
+def test_counts_use_collection_start_like_backlog_chart(triage):
+ report = triage.build(
+ [
+ item(
+ 1, pull_request=None, state="closed", closed_at="2026-11-03T18:01:00Z"
+ ),
+ item(
+ 2, pull_request=None, state="closed", closed_at="2026-11-03T17:59:00Z"
+ ),
+ item(3, pull_request=None, created_at="2026-11-03T18:01:00Z"),
+ ],
+ NOW,
+ )
+ assert sum(report["open_age_buckets"]["issues"].values()) == 1
+
+
+def test_discussion_failure_preserves_successful_head_observation(triage, monkeypatch):
+ def fetch(path, **kwargs):
+ if kwargs:
+ raise subprocess.TimeoutExpired("gh", 20)
+ return pr()
+
+ monkeypatch.setattr(triage, "github", fetch)
+ lead = triage.build([item()], NOW)["review_leads"][0]
+ assert lead["head_sha"] == "a" * 40
+ assert lead["pr_collected_at"]
+ assert lead["activity"] == {"status": "unavailable"}
+ assert "collection_gap" in lead
+
+
+ "failure,expected_kind,status,expected_calls",
+ [
+ (
+ subprocess.TimeoutExpired("gh", 15, stderr="secret-sentinel"),
+ "timeout",
+ None,
+ 2,
+ ),
+ (
+ subprocess.CalledProcessError(1, "gh", stderr="secret-sentinel (HTTP 503)"),
+ "http_error",
+ 503,
+ 2,
+ ),
+ (
+ subprocess.CalledProcessError(1, "gh", stderr="secret-sentinel (HTTP 403)"),
+ "http_error",
+ 403,
+ 1,
+ ),
+ (
+ subprocess.CalledProcessError(
+ 1,
+ "gh",
+ stderr="invalid character 'S' looking for beginning of value: secret-sentinel",
+ ),
+ "invalid_json",
+ None,
+ 2,
+ ),
+ ],
+)
+def test_sanitized_diagnostics_and_bounded_retry(
+ triage, monkeypatch, failure, expected_kind, status, expected_calls
+):
+ calls = []
+
+ def run(*args, **kwargs):
+ calls.append(args)
+ raise failure
+
+ monkeypatch.setattr(triage.subprocess, "run", run)
+ monkeypatch.setattr(triage.time, "sleep", lambda seconds: None)
+ report = triage.build([item()], NOW)
+ gap = report["review_leads"][0]["collection_diagnostics"][0]
+ assert gap == {
+ "stage": "pr_metadata",
+ "kind": expected_kind,
+ "attempts": expected_calls,
+ "http_status": status,
+ }
+ assert len(calls) == expected_calls
+ assert "secret-sentinel" not in json.dumps(report)
+ assert report["review_leads"][0]["activity"]["status"] == "unavailable"
+
+
+def test_transient_non_json_response_recovers_without_retaining_body(
+ triage, monkeypatch
+):
+ results = iter(
+ [
+ SimpleNamespace(stdout="Server Error secret-sentinel"),
+ SimpleNamespace(stdout=json.dumps(pr())),
+ ]
+ )
+ calls = []
+
+ def run(command, **kwargs):
+ calls.append(command)
+ return next(results)
+
+ monkeypatch.setattr(triage.subprocess, "run", run)
+ monkeypatch.setattr(triage.time, "sleep", lambda seconds: None)
+ assert triage.github("pulls/1")["head"]["sha"] == "a" * 40
+ assert len(calls) == 2
+
+
+def marked_review(*, head="a" * 40, baseline="b" * 40, number=1, **overrides):
+ return (
+ activity(
+ "fastmcp-triage-reviewer[bot]",
+ "2026-10-03T00:00:00Z",
+ bot=True,
+ id=7,
+ state="COMMENTED",
+ commit_id=head,
+ body=f"<!-- fastmcp-triage-review:v1 pr:{number} head:{head} base:{baseline} -->\nPublic finding",
+ )
+ | overrides
+ )
+
+
+ "review,expected",
+ [
+ (marked_review(), True),
+ (marked_review(baseline="c" * 40), False),
+ (marked_review(head="c" * 40), False),
+ (marked_review(number=2), False),
+ (marked_review(commit_id="c" * 40), False),
+ (marked_review(body="unbound review"), False),
+ (marked_review(state="DISMISSED"), False),
+ ],
+)
+def test_review_provenance_requires_pr_head_and_current_target_baseline(
+ triage, monkeypatch, review, expected
+):
+ def fetch(path, **kwargs):
+ if path.startswith("branches/"):
+ return {"commit": {"sha": "b" * 40}}
+ if path.endswith("/reviews?per_page=100"):
+ return [review]
+ return [] if kwargs else pr(base={"sha": "d" * 40, "ref": "main"})
+
+ monkeypatch.setattr(triage, "github", fetch)
+ lead = triage.build([item()], NOW)["review_leads"][0]
+ assert (
+ lead["base_sha"] == "d" * 40
+ ) # PR metadata isn't the authoritative target tip.
+ assert lead["baseline_sha"] == "b" * 40
+ assert lead["activity"]["triage_app_review_on_snapshot_revision"] is expected
+ assert lead["activity"]["triage_app_review_seen"] is True
+
+
+def test_missing_baseline_stays_unknown_while_discussion_is_retained(
+ triage, monkeypatch
+):
+ def fetch(path, **kwargs):
+ if path.startswith("branches/"):
+ raise triage.GitHubReadError("http_error", 1, 403)
+ if "/reviews?" in path:
+ return [marked_review()]
+ return [] if kwargs else pr()
+
+ monkeypatch.setattr(triage, "github", fetch)
+ lead = triage.build([item()], NOW)["review_leads"][0]
+ assert lead["head_sha"] == "a" * 40
+ assert lead["baseline_sha"] is None
+ assert lead["activity"]["status"] == "collected"
+ assert lead["activity"]["triage_app_review_on_snapshot_revision"] is None
+ assert lead["collection_diagnostics"] == [
+ {
+ "stage": "target_baseline",
+ "kind": "http_error",
+ "attempts": 1,
+ "http_status": 403,
+ }
+ ]
+
+
+def test_untrusted_account_cannot_supply_revision_marker(triage, monkeypatch):
+ review = marked_review(
+ user={"login": "fastmcp-triage-reviewer[bot]", "type": "User"}
+ )
+ monkeypatch.setattr(
+ triage,
+ "github",
+ lambda path, **kw: (
+ {"commit": {"sha": "b" * 40}}
+ if path.startswith("branches/")
+ else [review]
+ if "/reviews?" in path
+ else []
+ if kw
+ else pr()
+ ),
+ )
+ activity_result = triage.build([item()], NOW)["review_leads"][0]["activity"]
+ assert activity_result["triage_app_review_seen"] is False
+ assert activity_result["triage_app_review_bindings"] == []
+
+
+def test_optional_triage_failure_cannot_block_backlog_publication():
+ import yaml
+
+ workflow = yaml.safe_load(
+ (Path(__file__).parents[1] / ".github/workflows/backlog-status.yml").read_text()
+ )
+ jobs = workflow["jobs"]
+ assert jobs["publish"]["needs"] == "build"
+ assert jobs["publish-triage"]["needs"] == "triage"
+ assert "needs" not in jobs["build"] and "needs" not in jobs["triage"]
+ maintenance = yaml.safe_load(
+ (
+ Path(__file__).parents[1] / ".github/workflows/maintenance-status.yml"
+ ).read_text()
+ )
+ for publisher in (
+ jobs["publish"],
+ jobs["publish-triage"],
+ maintenance["jobs"]["publish"],
+ ):
+ assert publisher["concurrency"] == {
+ "group": "maintenance-status-publish",
+ "cancel-in-progress": False,
+ "queue": "max",
+ }
+ commands = "\n".join(step.get("run", "") for step in jobs["build"]["steps"])
+ assert "--triage-output" not in commands and "public_triage.py" not in commands
+ assert (
+ "pull_request" in jobs["publish"]["if"]
+ and "pull_request" in jobs["publish-triage"]["if"]
+ )
+
+
+def test_malformed_discussion_retains_metadata_and_stage(triage, monkeypatch):
+ def fetch(path, **kwargs):
+ if path.startswith("branches/"):
+ return {"commit": {"sha": "b" * 40}}
+ return ["secret-sentinel"] if kwargs else pr()
+
+ monkeypatch.setattr(triage, "github", fetch)
+ report = triage.build([item()], NOW)
+ lead = report["review_leads"][0]
+ assert lead["head_sha"] == "a" * 40
+ assert lead["activity"]["status"] == "unavailable"
+ assert lead["collection_diagnostics"] == [
+ {
+ "stage": "discussion",
+ "kind": "invalid_response",
+ "attempts": 1,
+ "http_status": None,
+ }
+ ]
+ assert report["lead_collection_status"] == "partial"
+ assert "secret-sentinel" not in json.dumps(report)
+
+
+def test_standalone_cli_generates_provenance_without_cloud_access(tmp_path):
+ # Intercept only the external gh boundary in the child interpreter. A fake
+ # shebang executable on PATH cannot run on Windows.
+ wrapper = tmp_path / "run_collector.py"
+ wrapper.write_text(
+ "import json, runpy, subprocess, sys\nfrom pathlib import Path\n"
+ "original_run = subprocess.run\n"
+ "def fake_run(command, *args, **kwargs):\n"
+ " if command[0] != 'gh':\n"
+ " return original_run(command, *args, **kwargs)\n"
+ " endpoint = command[2]\n"
+ " if 'per_page=1&' in endpoint: value = 1\n"
+ f" elif '/issues?' in endpoint: value = {item()!r}\n"
+ f" elif '/branches/' in endpoint: value = {{'commit': {{'sha': {'b' * 40!r}}}}}\n"
+ " elif '--slurp' in command: value = [[]]\n"
+ f" else: value = {pr()!r}\n"
+ " return subprocess.CompletedProcess(command, 0, json.dumps(value), '')\n"
+ "subprocess.run = fake_run\n"
+ "sys.argv = sys.argv[1:]\n"
+ "sys.path.insert(0, str(Path(sys.argv[0]).parent))\n"
+ "runpy.run_path(sys.argv[0], run_name='__main__')\n"
+ )
+ output = tmp_path / "triage.json"
+ root = Path(__file__).parents[1]
+ subprocess.run(
+ [
+ sys.executable,
+ str(wrapper),
+ str(root / "scripts/public_triage.py"),
+ "--output",
+ str(output),
+ ],
+ cwd=root,
+ check=True,
+ capture_output=True,
+ text=True,
+ )
+ report = json.loads(output.read_text())
+ assert len(report["source_sha"]) == 40
+ assert report["inventory_items"] == 1
+ assert report["lead_collection_status"] == "collected"
+ assert report["review_leads"][0]["baseline_sha"] == "b" * 40
+ assert report["review_leads"][0]["activity"]["status"] == "collected"
diff --git a/tests/test_status_refresh.cjs b/tests/test_status_refresh.cjs
new file mode 100644
index 000000000..512cf3051
--- /dev/null
+++ b/tests/test_status_refresh.cjs
@@ -0,0 +1,185 @@
+const assert = require("node:assert/strict");
+const fs = require("node:fs");
+const path = require("node:path");
+const test = require("node:test");
+const vm = require("node:vm");
+
+function harness() {
+ const elements = new Map();
+ const element = () => ({
+ children: [],
+ dataset: {},
+ append(...children) {
+ this.children.push(...children);
+ },
+ replaceChildren(...children) {
+ this.children = children;
+ },
+ addEventListener() {},
+ });
+ const pending = [];
+ const context = vm.createContext({
+ URL,
+ Date,
+ console,
+ window: {
+ location: { origin: "http://localhost", href: "http://localhost/" },
+ },
+ document: {
+ getElementById(id) {
+ if (!elements.has(id)) elements.set(id, element());
+ return elements.get(id);
+ },
+ createElement: element,
+ querySelectorAll: () => [],
+ documentElement: { dataset: {} },
+ },
+ localStorage: { getItem: () => "dark" },
+ ResizeObserver: class {
+ observe() {}
+ },
+ setInterval() {},
+ fetch(url) {
+ return new Promise((resolve, reject) =>
+ pending.push({ url, resolve, reject }),
+ );
+ },
+ });
+ vm.runInContext(
+ fs.readFileSync(path.join(__dirname, "../status-site/app.js"), "utf8"),
+ context,
+ );
+ // Chart rendering has separate coverage; exercise real request/triage code.
+ vm.runInContext(
+ 'render = () => { document.getElementById("freshness").textContent = data.as_of; }',
+ context,
+ );
+ return {
+ pending,
+ elements,
+ refresh: () => vm.runInContext("refresh()", context),
+ respond(index, body) {
+ pending[index].resolve({ ok: true, json: async () => body });
+ },
+ requests(kind) {
+ return pending
+ .map((request, index) => ({ ...request, index }))
+ .filter((r) => r.url.includes(kind));
+ },
+ };
+}
+
+const flush = () => new Promise((resolve) => setImmediate(resolve));
+const backlog = (at) => ({
+ schema: "fastmcp-backlog/1",
+ as_of: at,
+ samples: [{}],
+ daily: [{}],
+ events: [],
+});
+const triage = (at) => ({
+ schema: "fastmcp-public-triage/1",
+ collection_started_at: at,
+ review_leads: [],
+ selection: { returned: 0, eligible_in_inventory: 0 },
+ open_age_buckets: {
+ issues: { lt_7d: 0, "7_30d": 0, "30_90d": 0, gte_90d: 0 },
+ prs: { lt_7d: 0, "7_30d": 0, "30_90d": 0, gte_90d: 0 },
+ },
+});
+
+// app.js automatically starts its initial refresh.
+test("refresh stays disabled until both collections settle", async () => {
+ const h = harness();
+ h.respond(h.requests("backlog")[0].index, backlog("2026-11-03T10:00:00Z"));
+ await flush();
+ assert.equal(h.elements.get("refresh").disabled, true);
+ h.respond(h.requests("triage")[0].index, triage("2026-11-03T10:00:00Z"));
+ await flush();
+ assert.equal(h.elements.get("refresh").disabled, false);
+});
+
+test("older successful responses cannot replace a newer refresh", async () => {
+ const h = harness();
+ const newer = h.refresh();
+ const oldAt = "2026-11-03T10:00:00Z",
+ newAt = "2026-11-03T12:00:00Z";
+ h.respond(h.requests("triage")[1].index, triage(newAt));
+ h.respond(h.requests("backlog")[1].index, backlog(newAt));
+ await newer;
+ await flush();
+ const latestTriage = h.elements.get("triage-freshness").textContent;
+ assert.match(latestTriage, /Collection began/);
+ h.respond(h.requests("triage")[0].index, triage(oldAt));
+ h.respond(h.requests("backlog")[0].index, backlog(oldAt));
+ await flush();
+ assert.equal(h.elements.get("triage-freshness").textContent, latestTriage);
+ assert.equal(h.elements.get("freshness").textContent, newAt);
+});
+
+test("older failed requests cannot clear newer results", async () => {
+ const h = harness();
+ const newer = h.refresh();
+ h.respond(h.requests("triage")[1].index, triage("2026-11-03T12:00:00Z"));
+ h.respond(h.requests("backlog")[1].index, backlog("2026-11-03T12:00:00Z"));
+ await newer;
+ await flush();
+ const latestTriage = h.elements.get("triage-freshness").textContent;
+ assert.match(latestTriage, /Collection began/);
+ h.requests("triage")[0].reject(new Error("old failure"));
+ h.requests("backlog")[0].reject(new Error("old failure"));
+ await flush();
+ assert.equal(h.elements.get("triage-freshness").textContent, latestTriage);
+ assert.notEqual(h.elements.get("notice")?.hidden, false);
+});
+
+function textContent(element) {
+ return [
+ element.textContent || "",
+ ...(element.children || []).map(textContent),
+ ].join(" ");
+}
+for (const [matching, expected] of [
+ [true, "marker matches snapshot head and target baseline"],
+ [false, "Historical or unbound triage-app review"],
+ [null, "target baseline unavailable"],
+]) {
+ test(`review display respects revision match ${matching}`, async () => {
+ const h = harness();
+ const report = triage("2026-11-03T12:00:00Z");
+ report.review_leads = [
+ {
+ number: 1,
+ title: "Fixture",
+ age_days: 10,
+ head_sha: "a".repeat(40),
+ baseline_sha: matching === null ? null : "b".repeat(40),
+ target: "main",
+ activity: {
+ status: "collected",
+ triage_app_review_seen: true,
+ triage_app_review_on_snapshot_revision: matching,
+ },
+ collection_diagnostics:
+ matching === null
+ ? [
+ {
+ stage: "target_baseline",
+ kind: "http_error",
+ http_status: 403,
+ attempts: 1,
+ },
+ ]
+ : [],
+ },
+ ];
+ h.respond(h.requests("triage")[0].index, report);
+ h.respond(h.requests("backlog")[0].index, backlog("2026-11-03T12:00:00Z"));
+ await flush();
+ const text = textContent(h.elements.get("triage-leads"));
+ assert.ok(text.includes(expected), text);
+ if (matching !== true) assert.ok(!text.includes("marker matches"));
+ if (matching === null)
+ assert.ok(text.includes("target_baseline: http_error (HTTP 403)"));
+ });
+}