Repository navigation
code.blame_range reads the trunk ledger and a sibling branch head only when the caller may read them - #241
Merged
Conversation
…y when the caller may read them The transport gates only the addressed namespace. The trunk ledger leg and the release-minor window resolution now pass the namespace Loom adds on its own through search_fanout.readable_subset: an unreadable trunk is left out of the ledger, and an unreadable sibling's head falls through to the mirror ref. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…acks Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… readable trunk Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
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.
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.blame_rangeon a release-branch namespace no longer returns the trunk namespace's PR titles, authors and merge shas to a caller who cannot read the trunk, and a release version in the window no longer resolves through a branch namespace the caller cannot read.Why
Failing case: a principal can view
code-x-26-4(a release branch) but notcode-x(its trunk).code.blame_range(namespace="code-x-26-4", ...)passes the transport's gate oncode-x-26-4._ledger_legthen adds the trunk entry and runspr_history_in_windowoncode-x, so the candidates carry the trunk ledger's PR numbers, titles, authors and merge shas._resolve_refdoes the same for a release minor (to_version="26.4"addressed at the trunk): it reads the branch namespace's recordedgit_headwithout a check.Pattern: a namespace Loom adds on its own (trunk or sibling) is read under the gate of the namespace the caller addressed.
code.verify_citationsalready handles this withsearch_fanout.readable_subset(citations._readable_namespaces).Fix: both reads go through
readable_subset. An unreadable trunk is left out of the ledger leg (the answer keeps the addressed namespace's rows and the blame leg). An unreadable sibling's head is skipped and the window end resolves through the mirror's branch or-newtag, as it does when no branch namespace is configured.Scope and risk
Touches
server/code/app/blame.py(the two gates andlegs.ledger.skipped), thelegscomment inserver/code/api/models_history.py(and its generated row indocs/reference/operations/code.md), thereadable_subsetdocstring inserver/code/app/search_fanout.py, a paragraph ofdocs/features/code-index/history-and-prs.md, and the tests intests/unit/test_code_blame_range.pyandtests/unit/test_code_repos_trunk.py. Nothing changes for a caller who can read the trunk, or with no auth context (row_in_scopeanswers true). One extra grant check per call for each added namespace; the grant map is cached. Left alone on purpose: the git mirror is shared by every namespace of one repository, so the mirror-ref fallback (refs/heads/26.4) still blames the branch's public git history; what is gated is Loom's indexed rows of the other namespace (its ledger and recorded head).Compatibility, rollout and rollback
legs.ledgergains an additiveskipped: [{namespace, reason: "not_readable"}]key naming the trunk it left out (the same shapecode.searchuses for an unreadable fan-out namespace).Tests
tests/unit/test_code_blame_range.py::test_trunk_and_sibling_namespaces_are_read_only_when_the_caller_may_read_themstubsrow_in_scopeto refuse one namespace. It failed before the fix (the ledger readcode-clickhousefor a caller who can read onlycode-clickhouse-26-3) and passes after; it also checks that an unreadable sibling's head is not read and the window end comes frommirror_ref. Ran the blame, trunk and package-contract unit tests,make format lint typecheck,test_public_copy.pyandtest_doc_links.py.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. Checked the gate against
citations._readable_namespacesand the test's failure before the fix.I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code