Skip to content

[pr-clusters] Merged PR clusters - 2026-12-03 - run 47071969616/1 #1024

Backlog

Description

@github-actions

Overview

Top three clusters

Rank Theme PRs % of corpus Summary
1 Runtime and workflow dependency fixes (n00831) 10 20.4% Microsoft npm feed, Copilot SDK/CLI/gh-aw migration and the resulting workflow, launcher and fixture fixes.
2 Claude dynamic-workflow compatibility improvements (n00927) 7 14.3% Docs/mapping gaps for porting Claude dynamic workflows to rig.
3 Integration test model routing fixes (n00890) 6 12.2% Model selection and API handling fixes for Pi/DeepSeek/Sonnet integration runs.

Cluster details

Outside the top three: 6 clusters containing 26 PRs: n00891 Engine integration testing and credentials (6), n00734 Rig sample additions and catalog refresh (5), n00917 Daily benchmark and sampler failures (5), n00934 Action Failure Repair workflow and fixes (4), n00744 rig.ts header updates (3), n00751 Dependency version bumps (3). There are no unclassified PRs: Louvain assigns every PR to a community and the program has no outlier option. At least three meaningful clusters exist, so none is missing.

Strategy comparison

  • History consulted: all 16 records in repo memory (37680026048-1 ... 46846850047-1); full source reviewed for the five most recent (46128492209, 46245325031, 46386695563, 46612481419, 46846850047) plus 45970215617 and 45771811713.
  • Nearest prior strategy: pairwise-verified-similarity-graph-components (45553032858-1), and co-association (46612481419-1) / odd-one-out triplets (46846850047-1).
  • Behavioral change: the model sees the whole corpus (rotated order per call) and itself nominates 1-3 most similar peers for each PR in batches of 7, with no lexical candidate pre-filter. TypeScript builds a rank-weighted (3/2/1) graph and runs a self-written multi-level Louvain modularity optimisation. There is no similarity threshold, linkage cut, or connected-components step; cluster count emerges from modularity. Models only name the communities.
  • Evidence: title plus 110-char URL-stripped body excerpt (140 chars for naming). 16 model calls (7 nomination, 9 naming).
  • Limitations: modularity always places every PR, so loosely related PRs (e.g. Improve schema and workflow guidance #949, Update native structured-output support and engine capability guidance #993) sit in the "Engine integration testing" cluster, and the largest cluster merges the Microsoft npm/SDK migration with several fix PRs. No measured comparison with other strategies was made, so no claim of being better.
  • Lessons: nominations over the full corpus produced coherent bot-family clusters (Claude compat, samples, header, dependency bumps); an outlier/minimum-modularity-contribution rule could add unclassified output.

Rig source

Digest (SHA-256): 6ebb9d72d5e0dc8c9fdb5ec766c1a8b5d8ac75b499747c42748554e60af5502c. Repo-memory record: pr-cluster-rigs/47071969616-1.json (persisted by the repo-memory job).

Complete generated Rig program (pr-clusters-nomination-louvain.ts)
import { agent, s, workflow } from "rig";
import { readFileSync } from "node:fs";

type Pr = { number: number; title: string; body?: string };

// Agent role: nominate the most similar peer PRs for each PR in a batch, seeing the whole corpus.
const nominate = agent({
  name: "nominate",
  model: "small",
  input: s.object({ corpus: s.string, batch: s.string }),
  output: s.object({
    items: s.array(s.object({ pr: s.int, peers: s.array(s.int) })),
  }),
  instructions:
    "CORPUS lists every merged PR as 'number | title | excerpt'. BATCH lists the PR numbers to process. For each BATCH PR, nominate 1 to 3 other CORPUS PRs that address the same specific engineering concern, most similar first. Never nominate the PR itself. Use only CORPUS numbers; return each BATCH number exactly once.",
});

// Agent role: name a community of PRs found in the nomination graph.
const describeCluster = agent({
  name: "describeCluster",
  model: "small",
  input: s.object({ members: s.string }),
  output: s.object({ label: s.string, summary: s.string }),
  instructions:
    "Each line is 'number | title | excerpt'. Return a short thematic label (max 6 words) and a one-sentence summary grounded only in these members.",
});

const clean = (t = "") => t.replace(/https?:\S+/g, "").replace(/[#>*|`]/g, " ").replace((s/redacted)+/g, " ").trim();

function louvain(adj: Map<number, number>[]): number[] {
  let g = adj;
  let map = adj.map((_, i) => i);
  for (let level = 0; level < 10; level++) {
    const n = g.length;
    const k = g.map((m) => [...m.values()].reduce((a, b) => a + b, 0));
    const m2 = k.reduce((a, b) => a + b, 0);
    if (m2 === 0) break;
    const comm = g.map((_, i) => i);
    const tot = k.slice();
    let any = false;
    for (let pass = 0, moved = true; moved && pass < 50; pass++) {
      moved = false;
      for (let i = 0; i < n; i++) {
        const links = new Map<number, number>();
        for (const [j, w] of g[i]) if (j !== i) links.set(comm[j], (links.get(comm[j]) ?? 0) + w);
        const ci = comm[i];
        tot[ci] -= k[i];
        let best = ci;
        let bg = (links.get(ci) ?? 0) - (tot[ci] * k[i]) / m2;
        for (const [c, w] of links) {
          const gain = w - (tot[c] * k[i]) / m2;
          if (gain > bg + 1e-12) { best = c; bg = gain; }
        }
        tot[best] += k[i];
        if (best !== ci) { comm[i] = best; moved = true; any = true; }
      }
    }
    if (!any) break;
    const ids = [...new Set(comm)].sort((a, b) => a - b);
    const idx = new Map(ids.map((c, i) => [c, i]));
    const next: Map<number, number>[] = ids.map(() => new Map());
    for (let i = 0; i < n; i++)
      for (const [j, w] of g[i]) {
        const a = idx.get(comm[i])!;
        const b = idx.get(comm[j])!;
        next[a].set(b, (next[a].get(b) ?? 0) + w);
      }
    map = map.map((x) => idx.get(comm[x])!);
    g = next;
  }
  return map;
}

// Workflow role: peer-nomination graph clustering: models nominate similar PRs, TypeScript runs Louvain modularity, models name communities.
export default workflow({
  meta: {
    name: "nomination-graph-louvain",
    description: "Whole-corpus peer nominations, weighted mutual graph, Louvain community detection, community naming",
    phases: ["Nominate", "Communities", "Describe", "Validate"],
  },
  body: async ({ call, phase }) => {
    const corpus = JSON.parse(readFileSync("/tmp/gh-aw/agent/merged-prs.json", "utf8"));
    const prs: Pr[] = [...corpus.prs].sort((a: Pr, b: Pr) => a.number - b.number);
    const byNum = new Map(prs.map((p) => [p.number, p]));
    if (prs.length < 3 || byNum.size !== prs.length) throw new Error("bad corpus");
    const nums = prs.map((p) => p.number);
    const idxOf = new Map(nums.map((n, i) => [n, i]));
    const line = (n: number, len: number) => `${n} | ${byNum.get(n)!.title} | ${clean(byNum.get(n)!.body).slice(0, len)}`;

    phase("Nominate");
    const batches: number[][] = [];
    for (let i = 0; i < nums.length; i += 7) batches.push(nums.slice(i, i + 7));
    if (batches.length > 12) throw new Error("too many batches");
    const adj: Map<number, number>[] = nums.map(() => new Map());
    const link = (a: number, b: number, w: number) => {
      adj[a].set(b, (adj[a].get(b) ?? 0) + w);
      adj[b].set(a, (adj[b].get(a) ?? 0) + w);
    };
    for (let g = 0; g < batches.length; g += 3) {
      const group = batches.slice(g, g + 3);
      const res = await Promise.all(
        group.map((b, i) => {
          const rot = ((g + i) * 7) % nums.length;
          const order = [...nums.slice(rot), ...nums.slice(0, rot)];
          return call(nominate, { corpus: order.map((n) => line(n, 110)).join("\n"), batch: b.join(", ") }, { label: `nominate${g + i}` });
        }),
      );
      res.forEach((r, i) => {
        if (!r) throw new Error(`missing nomination ${g + i}`);
        const want = new Set(group[i]);
        const seen = new Set<number>();
        for (const it of r.items) {
          if (!want.has(it.pr) || seen.has(it.pr)) throw new Error(`invalid or duplicate PR ${it.pr}`);
          seen.add(it.pr);
          const peers = [...new Set(it.peers)];
          if (peers.length < 1 || peers.length > 3 || peers.some((p) => p === it.pr || !byNum.has(p))) throw new Error(`invalid peers for PR ${it.pr}`);
          peers.forEach((p, rank) => link(idxOf.get(it.pr)!, idxOf.get(p)!, 3 - rank));
        }
        if (seen.size !== want.size) throw new Error(`batch ${g + i}: incomplete nominations`);
      });
    }

    phase("Communities");
    const comm = louvain(adj);
    const byComm = new Map<number, number[]>();
    nums.forEach((n, i) => byComm.set(comm[i], [...(byComm.get(comm[i]) ?? []), n]));
    const multi = [...byComm.values()].filter((m) => m.length >= 2).map((m) => [...m].sort((a, b) => a - b));
    const unclassified = [...byComm.values()]
      .filter((m) => m.length === 1)
      .map((m) => ({ pr: m[0], reason: "Louvain left it alone: its nominations and nominators did not form a community with any peer" }))
      .sort((a, b) => a.pr - b.pr);
    if (batches.length + multi.length > 38) throw new Error("call budget exceeded");

    phase("Describe");
    const described: ({ label: string; summary: string } | null)[] = [];
    for (let g = 0; g < multi.length; g += 3) {
      const out = await Promise.all(
        multi.slice(g, g + 3).map((m, i) => call(describeCluster, { members: m.map((n) => line(n, 140)).join("\n") }, { label: `describe${g + i}` })),
      );
      described.push(...out);
    }
    const clusters = multi
      .map((m, i) => {
        const d = described[i];
        if (!d || !d.label.trim() || !d.summary.trim()) throw new Error("missing cluster description");
        return { id: `n${String(m[0]).padStart(5, "0")}`, label: d.label.trim(), summary: d.summary.trim(), prs: m, size: m.length };
      })
      .sort((x, y) => y.size - x.size || x.id.localeCompare(y.id));

    phase("Validate");
    const seen = new Set<number>();
    for (const n of [...clusters.flatMap((c) => c.prs), ...unclassified.map((u) => u.pr)]) {
      if (!byNum.has(n) || seen.has(n)) throw new Error(`invalid or duplicate PR ${n}`);
      seen.add(n);
    }
    if (seen.size !== prs.length) throw new Error("incomplete coverage");
    if (new Set(clusters.map((c) => c.id)).size !== clusters.length) throw new Error("duplicate cluster id");

    return {
      repository: corpus.repository,
      window: corpus.window,
      strategy: "Peer-nomination graph: whole-corpus model nominations of up to 3 similar PRs per PR, rank-weighted undirected graph, TypeScript Louvain modularity communities, community naming",
      totalPrs: prs.length,
      modelCalls: batches.length + multi.length,
      clusters,
      topThree: clusters.slice(0, 3).map((c) => c.id),
      unclassified,
    };
  },
});

Validation and attempts

  • Attempt 1 (only attempt): eslint lint passed, --typecheck passed, run_rig execution succeeded with 16 model calls (limit 40), no errors, no repairs needed.
  • Independent node check against the corpus: 49 PRs each appear exactly once, all numbers known, unique cluster IDs, sizes equal unique PR counts, ranking by size desc then ID asc, top three n00831, n00927, n00890, window and repository match the corpus.
  • Workflow run: https://github.com/githubnext/rig/actions/runs/47071969616

Generated by Monthly PR Clusters · copilot · auto (Claude Sonnet 5.5) · ~148 AIC · ⌖ ~2 AIC · ⊞ 10.7K · history

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions