Skip to content

code.symbol_history and the review brief name the PRs behind a regression record - #2359

Merged
zlareb1 merged 13 commits into
mainfrom
feat/brief-regression-evidence
Dec 6, 2026
Merged

zlareb1 merged 13 commits into
mainfrom
feat/brief-regression-evidence

Conversation

@zlareb1

@zlareb1 zlareb1 commented Dec 6, 2026 •

Copy link
Copy Markdown
Member

Related: #2040

Changelog category (leave one):

  • Improvement

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

code.symbol_history returns regression_prs, the PRs behind its fix, revert and caused-issue counts with their titles, merge dates, the test files they changed and a code.test_gate query for those tests. The history rows of code.review_brief that make symbol_with_regressions carry them.

Why

The brief's history section kept only counts per touched definition (named_fix_prs, reverts, caused_issues). An analyst who sees symbol_with_regressions could not tell which earlier PR it rests on, what it fixed or which test guards it, so the gap could not be replayed. code.symbol_history already builds the PR rows those counts come from. This change names them.

Each entry has pr_number, title (the one-line cause), merged_at (date) and kinds (fix, revert, caused_issue). A caused_issue entry has caused_issues. A fix entry has fix_by: title when the title says fix, crash, regression and the like, or linked_issue when the PR counts as a fix only because it closes an issue. When the PR changed test files, test_gate holds the code.test_gate arguments {org, namespace, files}, so the call can be replayed as-is in the namespace the history was read from. files holds up to 4 of the PR ledger's test paths: runnable first, then test-named files, then fixtures. The list is read from the whole window. limit only bounds prs, and the brief asks for 5. At most 3 entries, in this order: a PR behind more of the counts first, then any entry before a linked_issue fix, then fix, revert, caused_issue, then the newest.

Measured on a large C++ repository (to re-run: for each history row that makes regressions in a stored brief, call code.symbol_history over HTTP with limit: 120, rebuild PrRows from its prs with the files of each PR from loom.code_pr_history, and call this branch's regression_prs on them): the 40 newest stored briefs whose history says regressions named no PR. The fix computes regression_prs with this branch's code over live code.symbol_history rows and the ledger's file lists, for 14 of those briefs (one regression row each). That gave 22 entries. Checked by hand against the issue and PR titles:

  • caused_issue and revert entries: 15 of 16 are genuine culprits (the issue describes a bug the PR introduced; one is a feature request tied to a stress-test PR).
  • fix entries with fix_by: title: 2 of 2 are real bug fixes of the function.
  • fix entries with fix_by: linked_issue: 0 of 6 are bug fixes. They are performance or refactoring PRs that close an issue.

The last result comes from is_fix_title, which counts any PR that closes an issue as a fix. This change leaves the counts and the verdict alone. Instead, fix_by discloses the weak case, and such a fix ranks after every revert and culprit PR, so the cap of 3 keeps the stronger evidence.

Assumptions about the repository

Every assumption, and why it holds for any repository Loom indexes:

  • Test files are the PR ledger's changed paths that is_test_path accepts: a test directory, or a test file name in the languages its pattern lists (Python, shell, SQL, Ruby, Go, Rust, C and C++, the JavaScript family, Java, Kotlin, C#, Swift, PHP). Anything else outside a test directory is not listed. A PR that changed none has no test_gate.
  • Order within the cap of 4: first the files code.test_gate has a run recipe for (its built-in ones and the deployment's code_test_gate_run_templates), then files whose own name marks them as tests (test_x.py, XTest.java, gtest_x.cpp), then fixtures that are tests only by their directory. So a gtest or JUnit layout with no recipe still keeps its test ahead of its fixtures. Within that order, one file of each run command (such as one integration suite's directory) comes before a second file of the same command, so one suite's files cannot crowd another out.
  • fix_by: title reuses the fix-word rule that already decides is_fix. It is not a new list. A repository whose titles never use those words still gets every fix, marked linked_issue.
  • caused_issue comes from the tracker's caused_by edges. Without a bound tracker the kind does not occur, as today.
  • No new language- or repository-specific code. The ledger and the tracker work the same for every language. The run recipes are code.test_gate's existing built-ins (pytest, Go, vitest, Rust, and a ClickHouse stateless-test recipe) plus the deployment's setting. A recipe only lifts the files it matches, so a repository it does not match keeps the test-named-then-fixture order.

Unit tests use a made-up layout (spec/tally.case and spec/<suite>/ with custom run templates, tests/test_items.py, tests/fixtures/*.json).

Second repository: Loom's own Python code base. The scan covered the history rows of its 80 newest briefs (104 functions). Five functions have live named fixes. Each got one entry, all fix_by: linked_issue, because its PR titles state the outcome rather than saying "fix". All 5 carry the PR's own tests in test_gate, for example tests/unit/test_llm_anthropic.py for AnthropicLLMClient.complete and tests/unit/test_gitrepo_ca_file.py for gitrepo.auth_env. On that code base the fix-title rule never fires, which fix_by makes visible.

Scope and risk

Read-only. The handler adds one field, built from rows it already computes. No new query: the ledger read already selected files. The brief copies at most 3 entries per row, and only onto rows that make regressions. That is at most 6 definitions × 3 entries, each with ≤4 paths and a 160-character title, with no list repeated. Section verdicts, decisions and history_verdict are unchanged. summarize now counts named fixes, reverts and caused issues through the same rule that names them, with the same conditions as before. Payload version is unchanged: the field is additive and records no cap or failed read. Tenant scope: the op's entries come from the same scoped ledger and tracker reads. A stored brief is read by every viewer of the code namespace, so the brief follows the restricted-tracker rule its qa section uses. The brief carries no regression_prs when a tracker namespace a record may rest on is restricted, or its classification cannot be read (fail closed; an unread classification also keeps the brief unstored, so the next read builds it again). That covers two namespaces: the one bound to the code namespace, read from the binding as the qa section reads it, and each one a record says it read, since the binding can move during a build. A fix entry can rest on the tracker alone (its diff match or a fixes link), so a partial filter would not be safe. The row's existing counts already crossed into stored briefs before this PR. Removing them would change what makes regressions, which stays as it is. test_gate.files are the ledger's paths for the PR, so a path that PR deleted, or a later PR renamed, may be gone; the docs say so. The behaviour is language-neutral (PR ledger and existing test-path rules).

Compatibility, rollout and rollback

  • Wire: code.symbol_history output adds regression_prs. code.review_brief history rows add regression_prs where they make regressions. SDK tables regenerated.
  • Operator steps: none. Briefs built from now on carry the field.
  • Rollback: stored briefs keep an extra key in their history rows. An older build ignores it.

Tests

  • tests/unit/test_code_symbol_history.py: ranking, kinds, fix_by, test-file order (built-in and deployment recipes, test-named files before fixtures on a gtest and a Java layout with no recipe) and the four-file cap, the newest-first tie-break, and that a fix that touched only the file is neither counted nor named, test_gate only with tests and carrying the read's org and namespace. Also, the handler serves the same evidence at limit=1 as at limit=3.
  • tests/unit/test_code_review_brief_sections.py: the row that makes regressions carries the op's entries and a clean row does not.
  • test_history_rows_name_no_pr_a_restricted_tracker_read (six cases): a restricted or unclassifiable tracker, bound or read by a record, leaves regression_prs out; an unread classification keeps the brief unstored with no cause; counts and verdict stand.
  • test_a_template_that_does_not_format_counts_as_no_recipe: a deployment template with a stray brace, a missing attribute or a bad index does not fail the op.
  • make format-check, make lint, mypy on the changed modules, the brief, symbol-history, docs-reference, public-copy, package-contract and SDK-generation unit tests.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. It also ran the measurement above and checked the sampled PRs and issues by hand.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • Generated files are regenerated in this PR, not by hand.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers.
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code


Note

Low Risk
Read-only, additive API field with access-control gating aligned to existing brief QA rules; no new persistence or auth paths.

Overview
Adds regression_prs to code.symbol_history: up to three PRs that explain the summary’s named fixes, reverts, and caused-issue counts, ranked by strength, with kinds, fix_by (title vs linked_issue), optional caused_issues, and a replayable test_gate payload when the PR changed test paths (ledger files, ordered via code.test_gate recipes). summarize now derives those counts with the same evidence rules as regression_prs.

code.review_brief history rows that drive symbol_with_regressions copy regression_prs when tracker namespaces are readable and not restricted (_tracker_gate); otherwise counts stay but PR names are omitted, and unread classification blocks storing the brief. test_gate gains is_test_named and tolerates bad run templates without failing the op. SDKs, API models, and docs are updated; unit tests cover ranking, test-file caps, tracker gating, and brief propagation.

Reviewed by Cursor Bugbot for commit f705d55. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 6, 2026 7:59am UTC
loom-telemetry Ready Ready Preview Dec 6, 2026 7:59am UTC

Request Review

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@zlareb1
zlareb1 force-pushed the feat/brief-regression-evidence branch from 4424c92 to b46bc89 Compare December 6, 2026 06:31

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d33bef6. Configure here.

zlareb1 and others added 11 commits December 6, 2026 07:31
…sion record

code.symbol_history returns regression_prs: up to three PRs behind its
named_fix_prs, reverts and caused_issues counts, strongest first, each with
its title, merge date, kinds, fix_by, the issues it caused, up to four test
files it changed and a code.test_gate query for them. A code.review_brief
history row that makes `regressions` carries them. The counts and verdicts
are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
regression_prs reads code_test_gate_run_templates as code.test_gate does,
so a repository whose runner only that setting knows lists its tests before
their fixtures. The brief copies the op's list as served. Tests cover the
four-file cap and an override recipe on a made-up layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
… counts

A test file no run recipe knows (a gtest, a JUnit class) now sorts before
fixtures that are tests only by their directory, so the four-file cap keeps
it. summarize counts named fixes, reverts and caused issues through the same
rule regression_prs names them by, and the brief copies whatever the op
returned. Test files are picked only for the PRs named.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…ents

A fix counted only for closing an issue now ranks after every revert and
culprit PR, so the three-entry cap keeps the stronger evidence. Each entry's
test files are now one `test_gate` object, the code.test_gate arguments
(org, namespace, files) for the namespace the history was read from, in
place of a file list and a query that repeated it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…heir entries

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
A stored brief is read by every viewer of the code namespace. When a history
record's tracker namespace is restricted, or its classification cannot be
read, the brief's copy of regression_prs drops the caused_issue kind and its
issue numbers, and an entry with no kind left, as the brief's qa section
leaves that tracker out. The field comment states the order as the code
sorts it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
A fix entry can rest on the tracker alone (its diff match or a fixes link),
so filtering kinds left tracker facts in a stored brief and broke the cap and
order. When the records' tracker namespace is restricted or unclassified the
brief keeps the counts and carries no regression_prs. The docs say a listed
test path may since be gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
A record whose tracker side raised names no namespace, so the brief now
reads the namespace bound to the code namespace, as its qa section does,
and only when a record names a PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
The binding can move between the op's read and the brief's check, so the
brief is closed when the bound tracker or any tracker a record says it read
is restricted or unclassified. A handler test shows the deployment's run
templates reach the ordering.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…template is no recipe

A brief that leaves out regression_prs because the tracker's classification
could not be read is served and not stored, so the next read builds it
again; no verdict rests on it. run_command_for treats a template that does
not format as no recipe, so it cannot fail code.symbol_history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
@zlareb1
zlareb1 force-pushed the feat/brief-regression-evidence branch from 78191bc to 8426c88 Compare December 6, 2026 07:37
zlareb1 and others added 2 commits December 6, 2026 07:48
Four config files of one integration suite no longer push another suite
the PR changed out of the four-file cap: within the order, one file of each
run command comes before a second of it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
A record whose symbol resolved to another file is discarded before the
tracker gate, so its tracker no longer keeps the brief unstored. The
regression_prs field description is one sentence, and the suite-ordering
test uses a made-up run template.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
@zlareb1
zlareb1 merged commit ebe91c7 into main Dec 6, 2026
92 of 95 checks passed
@zlareb1
zlareb1 deleted the feat/brief-regression-evidence branch December 6, 2026 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant