Repository navigation
A brief stored at an older payload version is rebuilt on read, once per row and version - #2358
Merged
Merged
Conversation
…read A stored brief whose payload version is below PAYLOAD_VERSION answered `unsettled` with `brief:v<n>` on every read, and rule changes that alter a brief's answer did not bump the version. A read of a merged PR's brief of an older version now builds it again from its merge commit through the miss path and stores it in its place. The stored brief is served, with `code.review_brief: stale_brief_served` in `degraded`, when the read may not store, the host has no mirror, or the build fails or is left unstored; a failed build marks the row with the version it tried, so it runs at most once per stored row and version. A brief of a newer version is served as it is. PAYLOAD_VERSION is 3, and its comment says when to bump it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…a deleted row The marker row takes the version of the row it replaces plus one, below any build's, so a rebuild another replica stores in either order wins. A row deleted while the build ran is not written again. The new tests use a made-up repository, and cover a ledger-backed rebuild. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…ts row's key Raising the payload version left open-PR briefs unsettled until a push; they now rebuild through the open build under the same bound. The failed-build marker is written from the re-read row with its merge_sha key and built_at, so it never lands under a new key or outranks a later build of another merge commit. An open PR's brief found by a merged read is served, not built as a merged one. rolling-upgrades.md gains rule 100 for the payload version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…its cause names every note A merged rebuild the mirror places at another merge commit is stored under that key and leaves the stale row; it now counts as not stored, so the row is marked and a read of the old commit does not build on every call. The cause joins all of the build's notes. _rebuild takes pr_number and the sha and calls the build with it; the docstrings name the rebuild beside the miss. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…ich rules N-1 answers by The ledger read in the miss path raises outside its try; a rebuild now catches any exception from its build and serves the stored brief with the cause. The PR number comes from the stored row alone. The docs list a build stored under another merge commit, and the rolling-upgrade rule says N-1 answers a newer brief by its own rules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com> # Conflicts: # docs/architecture/rolling-upgrades.md
…er write that fails is tested Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…ted through the open build The store comment (and its reference page) names the rebuild of an older brief. A test runs the real open build and checks the row is stored under the PR's head. The _rebuild docstring points to the docs page; rule 101 notes an N-1 without a verdict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…rs a newer build's marker The build's notes are listed in degraded (and stored in rebuild_notes) instead of folded into one cut-off cause; stale_brief_served says rebuild failed. A re-read that finds a marker of this or a newer version keeps it. _build_at builds for the miss path and the rebuild alike, so _rebuild takes the row's key and PR number explicitly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…the op text names the rebuild 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>
…t says a rebuild happens on a read 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>
…ing it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…rror has its own cause Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 4 total unresolved issues (including 3 from previous reviews).
❌ 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 529a568. Configure here.
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>
… drop it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…he clock bound Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…ommit is a miss Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
… is pinned Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…ests 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>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…line says tracker Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…ommit_facts docstring Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…version marker Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…repeat 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Related: #2040
Related: #2218
Changelog category (leave one):
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.review_briefrebuilds a brief stored at an older payload version (a merged PR's from its merge commit, an open PR's at the same head) and stores the new one, so old briefs no longer stayunsettledwithbrief:v<n>. When it cannot rebuild, it serves the stored brief and namescode.review_brief: stale_brief_servedwith the cause indegraded.Why
A stored brief is served as it was built. A brief stored at a lower payload version answered
unsettledwithbrief:v<n>on every read, with no way for it to settle. Rule changes that alter a brief's answer (#2268, #2269, #2310, #2315) did not bump the version, so a stored brief also kept a verdict the current rules would not give.The version is now the version of the rules a brief is built and answered by. The comment beside
PAYLOAD_VERSIONsays to bump it in any change that alters what a build stores or whatbrief_verdictanswers over a stored brief. This PR bumps it to 3 for every rule change merged before it: the ones above, and #2359, which addsregression_prsto history rows. A read of a merged PR's brief stored at a lower version builds it again from its merge commit, using the same path as a miss, and stores it in place of the old row (same key, so the new insert replaces it).Bounded cost: a read rebuilds at most once per stored row per version.
store: falseor a measurement consumer. Otherwise it would build again on every read. It serves the stored brief.stale_brief_served (rebuild failed)indegradedand the build's notes after it as they were (the stale note goes first, so the note cap cannot hide it); an exception from the build (such as a ledger read that times out) is caught the same way. It writes the old payload back withrebuilt_for: <version>andrebuild_notes, so later reads of that version serve it without building. A build of a newer version tries once more. That marker row keeps the replaced row's key (merge_shacolumn, which is the head for an open brief) andbuilt_at, and takes its version plus one: a rebuild stored by any replica is stamped with its store time, so it wins in either order. Before writing, the read takes the row again. If another replica stored a rebuilt brief in the meantime, it serves that one; if a build of this or a newer version marked the row meanwhile, it keeps that marker. If the row was deleted while the build ran, it writes nothing. A merged row is rebuilt by its PR number and its own merge commit: the ledger is read by both, and the mirror by the commit. A commit whose subject names another PR is a miss, so the row is marked the same way. A rebuild'sversionis its host's clock, so on a host whose clock runs behind the stale row's writer by more than the time since that write, the rebuild loses to the row and reads build again until the clock passes it (rule 103 says so).unsettledwithbrief:v<n>, orgaps) until a higher version tries again. Retrying after a delay was rejected because it would trade that bound for a time-based one. The one exception is a marker that cannot be written (the store refuses inserts): the row stays unmarked, and the next read builds again.Rolling upgrades (rule 103): build N-1 serves N's newer payload as it is (its version is not lower), answering its verdict by its own rules, and never rewrites a stored row. The current release stores v1 briefs and has no brief verdict: it serves N's rows as stored sections and never rewrites a row on read, and the v1 rows its ingest writes are rebuilt once by N. A later bump that adds a cause N-1 does not know must ship N-1's reading of it first. N rebuilds only rows of a lower version, so at most once per row an N-1 build writes (a new merge it ingests). A row marked by N carries the old version, which N-1 serves unchanged.
Rejected: rebuilding on every read of an old row (no bound), and rebuilding without storing for reads that cannot store (no bound either).
Assumptions about the repository
None beyond what the miss path already reads. The change keys on the stored payload's version, the namespace's configured mirror (
present_dir, and whether it holds the merge commit) and the merge facts the ledger or the mirror give for the PR. It reads no path layout, test convention, language or PR-title rule. The tests run on a made-up Python repository (greeter/,checks/, branchtrunk), and the measurement below covers a C++ and a Python repository.Scope and risk
server/code/app/review_brief.py, the version constant and its comment, the point read's column list, the history docs page and a new rule 103 indocs/architecture/rolling-upgrades.md. An open PR's brief of an older version is rebuilt at the same head through the open build; one the merged read finds by number is served withstale_brief_served, never built as a merged brief.Compatibility, rollout and rollback
storefield's description (anddocs/reference/operations/code.md) says it also decides whether a stored brief of an older version is rebuilt. When a read names a merge commit, a brief the ledger does not hold is now looked up in the mirror by that commit (it was looked up by PR number when the read named both), and a commit whose subject names another PR than the one asked for is a miss. A brief built from a commit the read or the stored row names (every mirror rebuild included) disclosesmerge_commit: named_commitin its provenance (it wasmirror_first_parent, although no first-parent placement was made). A served stale brief addscode.review_brief: stale_brief_served (<cause>)todegraded. An open PR's brief built without its items row (a failed read) now answersstored: false; it was never stored, but the answer saidstored: true.Tests
tests/unit/test_code_review_brief_mirror.py, on a made-up repository:source: built);store: false, a measurement consumer, a host without the mirror and a mirror without the merge commit and one git cannot read (mirror unreadable) serve the stale brief with no build and no write;stored: falseand stores nothing;missingand stores nothing;built_at; read as merged, it is served without a build.test_code_review_brief_sections.pynow carry the current version, and the version-1/2 rationale cases read withstore: false. The pinned payload digest intest_code_review_brief_no_groups.pychanges only byv(withPAYLOAD_VERSION = 2the old digest still matches).make format-check,ruff check, the function-length and secrets gates, the docs/reference/settings codegen checks and mypy on the changed modules are clean. Focused review-brief tests pass;tests/analyzer/shapes.txtis regenerated for the point read's addedversioncolumn.store=Falseand trace writes stubbed out. Stored answers: 17unsettled, 7gaps. Rebuilt answers: 10gaps, 9no_source_change, 5unsettled.brief:v<n>now settle asno_source_changeor reportgaps.covered_no_gapsornothing_to_check.gapsbecameunsettledwithsymbols:unmapped_changes. The current rules read lines the v1 build did not.gaps, 5unsettledand 1no_source_change. Theno_source_changeone hadbrief:v2as its only cause. Thegapsverdicts were unchanged, and the 5 unsettled ones lostbrief:v2and kept their causes.missing. That is the failure path: the stored brief is served, and the row is marked so later reads do not build again.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. The rolling-upgrade cases, the rebuild bound and the measurement were checked against the code and the stored rows.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make test-unitand applicable integration results are reported by CI; a full local run is not required before pushing.docs/reference/operations/code.md(python scripts/codegen/docs_reference.py) andtests/analyzer/shapes.txt(python -m tests.analyzer.corpus --write).docs/describe the system as it now is, and this description names any operator steps and wire changes.git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code
Note
Medium Risk
Changes verdict and caching behavior for stored review briefs (including on-demand rebuilds and concurrent markers), but scope is bounded to one rebuild per row per version and is heavily covered by new unit tests.
Overview
code.review_briefno longer leaves old cached briefs stuck onunsettledwithbrief:v<n>after rule changes.PAYLOAD_VERSIONmoves to 3 (documented as the version of build/verdict rules), and a read of a stored brief with a lowervtriggers a one-time rebuild at the same key (merged PR at merge commit, open PR at head), replacing the row on success.When rebuild cannot run or persist (
store: false, no/unready mirror, build failure, wrong PR on commit), the handler serves the stored payload and addscode.review_brief: stale_brief_servedtodegraded. Failed attempts can write a marker row (rebuilt_for,rebuild_notes, bumpedversion) so the same build version does not retry every read; newer versions can try again. During rollouts, briefs at a newer payload version are served as-is (documented as rolling-upgrade rule 103).Related behavior tweaks: mirror miss path prefers a named
merge_shaover PR-number first-parent lookup, provenance can exposenamed_commit, open builds without a readable items row answerstored: false, and the point read selectsversionfrom ClickHouse.Reviewed by Cursor Bugbot for commit 65626a5. Bugbot is set up for automated code reviews on this repo. Configure here.