feat(viewers): outlines for Markdown and gists, refined pull request page

Markdown: the "On this page" outline covers h1-h3, draws redaction slots
like the body, treats a lone opening h1 as the title, highlights the
section past the reading line, and shows its menu from 768 to 1199px too.

Gists: one card per file and an outline of the files (name, language,
lines) with Markdown headings nested under each file; sticky right rail
on wide screens, an "In this gist" menu on narrow ones.

Pull requests: header with state, anonymized author, branches and
commit count; Conversation, Commits and Files changed tabs; a file list
with +/- counts, per-file collapse, inline review threads, and redaction
slots in the title, body and diff. The server now stores the author,
branch names, commits (no SHAs) and review comments, grouped into
threads; older pull requests render without them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Thomas DurieuxandClaude Opus 5.5 committed 2026-11-29 08:13:31 +00:00
1 parent 0640d741f1
commit 176bc857a1
22 files changed
+1515 -295

No files matched your search

+236 -1
View File
@@ -310,6 +310,7 @@ app.get("/api/conferences/:id", (req, res) => {
const explorerFiles = {
"": [
{ name: "src", path: "" },
{ name: "docs", path: "" },
{ name: "README.md", path: "", size: 640, sha: "a1" },
{ name: "LICENSE", path: "", size: 1070, sha: "a2" },
{ name: "requirements.txt", path: "", size: 40, sha: "a3" },
@@ -319,13 +320,80 @@ const explorerFiles = {
{ name: "train.py", path: "src", size: 900, sha: "b1" },
],
"src/utils": [{ name: "data.py", path: "src/utils", size: 300, sha: "c1" }],
docs: [
{ name: "REPRODUCING.md", path: "docs", size: 3400, sha: "d1" },
{ name: "NOTES.md", path: "docs", size: 120, sha: "d2" },
],
};
// A long guide (h1-h3, a redacted heading) for the Markdown outline, and a short
// note with two headings, which shows no outline.
const reproducingGuide = [
"# Reproducing the results",
"",
"This guide walks through every experiment in the paper by XXXX-1, from a clean machine to the numbers in Table 2. Each step lists the command, how long it takes on one GPU, and what the output should look like.",
"",
"## Requirements",
"",
"A Linux machine with Python 3.11, 32 GB of RAM and one GPU with at least 16 GB of memory. The scripts also run on CPU, about twenty times slower.",
"",
"### Python packages",
"",
"```bash\npip install -r requirements.txt\n```",
"",
"### Datasets",
"",
"The three datasets are mirrored on Zenodo. `scripts/fetch.sh` downloads them into `data/` and checks their hashes; nothing else needs a network connection.",
"",
"## Training",
"",
"Training reads `configs/base.yaml`. The defaults reproduce the main model; the ablations override one key each.",
"",
"```bash\npython src/train.py --config configs/base.yaml --seed 1\n```",
"",
"A full run takes about six hours. Checkpoints are written to `out/checkpoints/` every epoch, so an interrupted run resumes where it stopped.",
"",
"### Seeds",
"",
"The paper reports the mean of five seeds (1 to 5). Pass `--seed` to choose one; `scripts/sweep.sh` runs all five in sequence.",
"",
"## Evaluation",
"",
"`src/evaluate.py` loads a checkpoint and writes one JSON line per benchmark task to `out/results.jsonl`. The aggregate table is built from that file.",
"",
"| Benchmark | Tasks | Time |",
"| --- | --- | --- |",
"| Defects4J | 395 | 40 min |",
"| QuixBugs | 40 | 5 min |",
"| Bears | 251 | 30 min |",
"",
"### Expected numbers",
"",
"Within one point of Table 2 on every benchmark. Larger gaps usually mean a different PyTorch version; see the troubleshooting section.",
"",
"## Results from XXXX-2 cluster",
"",
"The original runs used the XXXX-2 cluster. Their logs are in `logs/` so the numbers can be checked without retraining.",
"",
"## Troubleshooting",
"",
"**Out of memory.** Lower `batch_size` in the config; accuracy is unchanged down to 8.",
"",
"**Different numbers.** Check `pip freeze` against `requirements.lock`. Contact XXXX-1 through the conference system if the gap persists.",
"",
"## License",
"",
"Code under MIT, data under CC BY 4.0.",
"",
].join("\n");
const explorerContent = {
"README.md": "# DeepLearnUtils\n\nDeveloped by XXXX-1 at XXXX-2.\n\nUtilities for reproducing the paper's experiments. Every script in `src/` reads its configuration from `configs/` and writes results to `out/`, so a full run of the evaluation only needs the two commands below. The long sentence here checks the reading width of rendered Markdown.\n\n## Quick start\n\n```bash\n# maintained by XXXX-1\npip install -r requirements.txt\npython src/train.py --config configs/base.yaml\n```\n\n```mermaid\ngraph LR; XXXX-2 --> Paper\n```\n\n| Model | Accuracy |\n| --- | --- |\n| Baseline | 71.2 |\n| Ours | 78.9 |\n\nContact: XXXX-3\n",
LICENSE: "MIT License\n\nCopyright (c) 2026 XXXX-1\n",
"requirements.txt": "torch>=2.3\nnumpy\npyyaml\n",
"src/train.py": '# Copyright 2026 XXXX-1, XXXX-2\nimport argparse\nimport yaml\n\nfrom utils.data import load_dataset\n\n\ndef main():\n parser = argparse.ArgumentParser(description="Train the model")\n parser.add_argument("--config", required=True)\n args = parser.parse_args()\n with open(args.config) as f:\n config = yaml.safe_load(f)\n dataset = load_dataset(config["data"])\n print(f"Loaded {len(dataset)} examples")\n\n\nif __name__ == "__main__":\n main()\n',
"src/utils/data.py": "def load_dataset(path):\n with open(path) as f:\n return [line.strip() for line in f]\n",
"docs/REPRODUCING.md": reproducingGuide,
"docs/NOTES.md": "# Notes\n\nScratch notes.\n\n## Open questions\n\nNone yet.\n",
};
const EXPLORER_ID = "anonymous_github-C72C";
app.get("/api/repo/missing-repo/{*rest}", (req, res) =>
@@ -347,7 +415,7 @@ app.get(`/api/repo/${EXPLORER_ID}/options`, (req, res) =>
})
);
app.get(`/api/repo/${EXPLORER_ID}/files/counts`, (req, res) =>
res.json({ "": 6, src: 2, "src/utils": 1 })
res.json({ "": 9, src: 2, "src/utils": 1, docs: 2 })
);
app.get(`/api/repo/${EXPLORER_ID}/files`, (req, res) =>
res.json(explorerFiles[req.query.path || ""] || [])
@@ -1297,6 +1365,173 @@ app.get("/api/admin/billing/grants", (req, res) => {
res.json({ page: pageNo, limit, total: rows.length, results, stateCounts, statuses: [...new Set(billingGrants.map((g) => g.status))].sort() });
});
// Reviewer pages for an anonymized pull request and gist: several files, a long
// diff, issue and review comments, and redacted terms in the title, body and diff.
const PR_ID = "robust-repair-pr-1F3A";
const longEvalBody = Array.from({ length: 46 }, (_, i) => `+ rows.append(score_task(model, tasks[${i}], seed=seed)) # task ${i + 1}`).join("\n");
const prDiff = [
"diff --git a/src/evaluate.py b/src/evaluate.py",
"index 3f2a1c0..8b9d4e2 100644",
"--- a/src/evaluate.py",
"+++ b/src/evaluate.py",
"@@ -1,18 +1,24 @@",
" # Evaluation harness for the XXXX-1 repair model.",
" import argparse",
" import json",
"+import statistics",
" ",
" from utils.data import load_dataset",
"+from utils.seeds import SEEDS",
" ",
" ",
"-def evaluate(model, tasks):",
"- return [score_task(model, t) for t in tasks]",
"+def evaluate(model, tasks, seeds=SEEDS):",
"+ \"\"\"Score every task once per seed and keep the per-seed rows.\"\"\"",
"+ rows = []",
"+ for seed in seeds:",
"+ rows.extend(score_task(model, t, seed=seed) for t in tasks)",
"+ return rows",
" ",
" ",
" def main():",
" parser = argparse.ArgumentParser(description=\"Evaluate a checkpoint\")",
" parser.add_argument(\"--checkpoint\", required=True)",
"+ parser.add_argument(\"--seeds\", type=int, nargs=\"+\", default=SEEDS)",
" args = parser.parse_args()",
"- rows = evaluate(load_model(args.checkpoint), load_dataset(\"data/test.jsonl\"))",
"+ rows = evaluate(load_model(args.checkpoint), load_dataset(\"data/test.jsonl\"), args.seeds)",
"+ print(\"mean accuracy\", statistics.mean(r[\"accuracy\"] for r in rows))",
" with open(\"out/results.jsonl\", \"w\") as f:",
" for row in rows:",
" f.write(json.dumps(row) + \"\\n\")",
"@@ -40,6 +46,58 @@ def score_task(model, task):",
" return {\"task\": task[\"id\"], \"accuracy\": acc}",
" ",
" ",
"+def score_all(model, tasks, seed):",
"+ rows = []",
longEvalBody,
"+ return rows",
"+",
"+",
" if __name__ == \"__main__\":",
" main()",
"diff --git a/src/utils/seeds.py b/src/utils/seeds.py",
"new file mode 100644",
"index 0000000..1d2c3b4",
"--- /dev/null",
"+++ b/src/utils/seeds.py",
"@@ -0,0 +1,6 @@",
"+\"\"\"Seeds used for every number in the paper (see XXXX-2 lab notes).\"\"\"",
"+",
"+SEEDS = [1, 2, 3, 4, 5]",
"+",
"+# Seed 6 diverged on the XXXX-2 cluster; keep it out of the mean.",
"+EXCLUDED = [6]",
"diff --git a/configs/base.yaml b/configs/base.yaml",
"index 6a7b8c9..0d1e2f3 100644",
"--- a/configs/base.yaml",
"+++ b/configs/base.yaml",
"@@ -1,5 +1,6 @@",
"-# Base configuration (XXXX-1)",
"+# Base configuration",
" data: data/train.jsonl",
" model: transformer-small",
"-seed: 1",
"+seeds: [1, 2, 3, 4, 5]",
"+batch_size: 16",
" output: /home/XXXX-3/out",
"diff --git a/scripts/sweep.sh b/scripts/sweep.sh",
"new file mode 100755",
"index 0000000..aa11bb2",
"--- /dev/null",
"+++ b/scripts/sweep.sh",
"@@ -0,0 +1,7 @@",
"+#!/usr/bin/env bash",
"+# Run the five seeds of Table 2 in sequence.",
"+set -euo pipefail",
"+for seed in 1 2 3 4 5; do",
"+ python src/train.py --config configs/base.yaml --seed \"$seed\"",
"+done",
"+python src/evaluate.py --checkpoint out/checkpoints/last.pt",
"diff --git a/README.md b/README.md",
"index 1234567..89abcde 100644",
"--- a/README.md",
"+++ b/README.md",
"@@ -8,9 +8,12 @@ Utilities for reproducing the paper's experiments.",
" ## Quick start",
" ",
" ```bash",
"-# maintained by XXXX-1",
" pip install -r requirements.txt",
" python src/train.py --config configs/base.yaml",
"+# all five seeds, then the evaluation",
"+bash scripts/sweep.sh",
" ```",
" ",
"+Results are the mean of five seeds; see `src/utils/seeds.py`.",
"+",
" Contact: XXXX-3",
"diff --git a/scripts/old_eval.sh b/scripts/old_eval.sh",
"deleted file mode 100644",
"index 5566778..0000000",
"--- a/scripts/old_eval.sh",
"+++ /dev/null",
"@@ -1,3 +0,0 @@",
"-#!/usr/bin/env bash",
"-# Single-seed evaluation used before the camera-ready.",
"-python src/evaluate.py --checkpoint out/checkpoints/last.pt",
].join("\n") + "\n";
const prContent = {
anonymizeDate: ago(1), merged: false, state: "open", draft: false,
title: "Average Table 2 over five seeds in the XXXX-1 evaluation harness",
body: "This replaces the single-seed evaluation with the five-seed protocol described in Section 5 of the paper.\n\n## Changes\n\n- `evaluate()` scores every task once per seed and keeps the per-seed rows.\n- New `src/utils/seeds.py` lists the seeds; seed 6 is excluded (it diverged on the XXXX-2 cluster).\n- `scripts/sweep.sh` trains and evaluates all five seeds.\n\n## How to test\n\n```bash\nbash scripts/sweep.sh\n```\n\nThe mean accuracy should be within one point of Table 2. cc @XXXX-3",
author: "XXXX-3", baseRef: "main", headRef: "XXXX-3/five-seeds",
diff: prDiff,
creationDate: ago(9), updatedDate: ago(2),
commits: [
{ message: "Score every task once per seed", author: "XXXX-3", date: ago(9) },
{ message: "Add the seed list and exclude seed 6\n\nSeed 6 diverged on the XXXX-2 cluster.", author: "XXXX-3", date: ago(8) },
{ message: "Add scripts/sweep.sh for the five-seed protocol", author: "XXXX-3", date: ago(6) },
{ message: "Drop the single-seed evaluation script", author: "XXXX-3", date: ago(5) },
{ message: "Document the sweep in the README", author: "XXXX-4", date: ago(3) },
],
comments: [
{ author: "XXXX-4", body: "Thanks! I ran the sweep on a second machine and got 78.7 mean accuracy, which matches Table 2 within 0.2.", creationDate: ago(7), updatedDate: ago(7) },
{ author: "XXXX-3", body: "Great, I also added `scripts/sweep.sh` so reviewers can run the same protocol. The README points to it now.", creationDate: ago(4), updatedDate: ago(4) },
],
reviewComments: [
{ path: "src/evaluate.py", line: 15, comments: [
{ author: "XXXX-4", body: "Should the default come from the config instead of `SEEDS`? Otherwise `configs/base.yaml` and this list can drift.", creationDate: ago(6), updatedDate: ago(6) },
{ author: "XXXX-3", body: "Good point. The config now has `seeds:` and the CLI flag overrides it; `SEEDS` is only the fallback.", creationDate: ago(5), updatedDate: ago(5) },
] },
{ path: "src/utils/seeds.py", line: 5, comments: [
{ author: "XXXX-4", body: "Can we say why seed 6 diverged? A reviewer will ask.", creationDate: ago(6), updatedDate: ago(6) },
] },
],
};
app.get(`/api/pr/${PR_ID}/options`, (req, res) => res.json({ url: null, lastUpdateDate: ago(1), isAdmin: false, isOwner: false }));
app.get(`/api/pr/${PR_ID}/content`, (req, res) => res.json(prContent));
const GIST_ID = "robust-repair-gist-8D2E";
const gistContent = {
anonymizeDate: ago(2), isPublic: false,
description: "Five-seed evaluation notes for the XXXX-1 replication",
ownerLogin: "XXXX-3", creationDate: ago(20), updatedDate: ago(3),
files: [
{ filename: "PROTOCOL.md", language: "Markdown", type: "text/markdown", size: 1480, content: "# Evaluation protocol\n\nHow the numbers in Table 2 were produced, written for the artifact reviewers.\n\n## Setup\n\nOne GPU with 16 GB of memory. Install the pinned packages from `requirements.lock`.\n\n### Data\n\nThe three benchmarks are mirrored on Zenodo; `fetch.sh` downloads and checks them.\n\n## Running the sweep\n\nRun `sweep.sh` below. It trains five seeds in sequence and then evaluates the last checkpoint of each.\n\n### Seeds\n\nSeeds 1 to 5. Seed 6 diverged on the XXXX-2 cluster and is excluded.\n\n## Results from XXXX-2\n\nMean accuracy 78.9 over the five seeds, standard deviation 0.3.\n\n## Contact\n\nQuestions go through the conference system, not to XXXX-1 directly.\n" },
{ filename: "sweep.sh", language: "Shell", type: "application/x-sh", size: 240, content: "#!/usr/bin/env bash\n# Run the five seeds of Table 2 in sequence.\nset -euo pipefail\nfor seed in 1 2 3 4 5; do\n python src/train.py --config configs/base.yaml --seed \"$seed\"\ndone\npython src/evaluate.py --checkpoint out/checkpoints/last.pt\n" },
{ filename: "aggregate.py", language: "Python", type: "application/x-python", size: 980, content: "\"\"\"Aggregate per-seed rows into Table 2 (XXXX-1, 2026).\"\"\"\nimport json\nimport statistics\nimport sys\n\n\ndef load(path):\n with open(path) as f:\n return [json.loads(line) for line in f if line.strip()]\n\n\ndef table(rows):\n by_bench = {}\n for row in rows:\n by_bench.setdefault(row[\"benchmark\"], []).append(row[\"accuracy\"])\n return {name: (statistics.mean(v), statistics.pstdev(v)) for name, v in sorted(by_bench.items())}\n\n\nif __name__ == \"__main__\":\n for name, (mean, sd) in table(load(sys.argv[1])).items():\n print(f\"{name:12} {mean:5.1f} ± {sd:.1f}\")\n" },
{ filename: "results.json", language: "JSON", type: "application/json", size: 310, content: "{\n \"Defects4J\": { \"mean\": 78.9, \"sd\": 0.3 },\n \"QuixBugs\": { \"mean\": 82.5, \"sd\": 1.1 },\n \"Bears\": { \"mean\": 61.2, \"sd\": 0.8 }\n}\n" },
],
comments: [
{ author: "XXXX-4", body: "Ran `sweep.sh` on a second machine: Defects4J 78.7, within the reported deviation.", creationDate: ago(4), updatedDate: ago(4) },
],
};
app.get(`/api/gist/${GIST_ID}/options`, (req, res) => res.json({ url: null, lastUpdateDate: ago(2), isAdmin: false, isOwner: false }));
app.get(`/api/gist/${GIST_ID}/content`, (req, res) => res.json(gistContent));
app.all("/api/{*rest}", (req, res) => res.status(404).json({ error: "not mocked: " + req.path }));
app.use((req, res, next) => {