Repository navigation
fix(githttp): refuse a ref at an object that no registered pack holds - #896
Conversation
The node's cache repository can hold an object that no registered pack holds (a cache that was copied or edited out of band, or a registry that was rolled back). git reads such an object, so three entry points stored a ref at it: POST branches/create and POST tags resolved the base or the target in the cache, and a push update with an empty pack passed git's connectivity check. Every other node hydrates from the registered packs alone, so each such ref wedged the repository. The two REST routes now answer 404 for a commit that no registered pack holds, and the update hook refuses the update, both by object state against a view of the cache that links only the packs that the registry lists. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh --> Change-Id: Ia072c3e1bd28cbd9b2a4441250dae1d810a2d150
…arget check Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh --> Change-Id: I89f3a475d656e81fd175b9b8f2c4c980c2409bfd
Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh --> Change-Id: I868869117ec8447c2206cf6ffea5cfc051631500
|
@codex review |
|
@codex security review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (2)
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3c8007fd81
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
🛡️ Codex Security Review
Here are some automated security review suggestions for this pull request.
Reviewed commit: 3c8007fd81
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
…e push The check moves from the update hook to pre-receive. Under --atomic an earlier update hook's compare-and-swap commits before a later command is refused, and each ref of a push paid a listing of the packs and a git child. Pre-receive asks once for the whole push, and only about new values that the main store already holds, so a push that adds objects pays one batch of git. The registered packs and the quarantine of the push answer, so a push that carries the object registers it and heals the node. The heal of a missing pack lists again, within a bound. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh --> Change-Id: I335225cf09bce68bf25f24062ced01472b9ce3b1
…registry check The registry check moved from the update hook into pre-receive. The sync commit line and the fingerprints of the touched functions move with it. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh --> Change-Id: I3a6d84d330f4b4a55eca2421cbe7db795cc0e147
… is not in the cache yet A push registers its pack in pre-receive, before git moves the pack out of its quarantine into the cache. A second push that built the registered-pack view in that window found a registered pack that the cache lacked, healed once and failed when the next listing named another such pack. Under eight concurrent pushers that refused valid updates (11 of 4200 operations, none on main). The view now keeps the packs that the cache lacks out, after a bounded number of heal rounds, and CheckAnswer fails the request only when an object reads as missing from such a view. An object that the view holds is held by a registered pack, so a found answer stands. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh --> Change-Id: I221deb6bf9fa5035f8aa12ac0b7112d69b2ec356
…istered-pack view The pre-receive registry check now calls CheckAnswer. The sync commit line and the fingerprint of denyUnregisteredTargets move with it. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh --> Change-Id: I6332ca43f9d3d5f4041494a017e4e414120f64fe
A view that cannot fetch a pack no longer fails to build. It leaves the pack out, and CheckAnswer fails a "missing" answer. The test pins both halves. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh --> Change-Id: Ie757e4a6674a1d295a0bb838eadb91be84f328bf
git runs hooks in the repository, and a stored commit is held by a registered pack. Four in-process tests ran pre-receive from a work tree with a commit that no pack held, which the registry check now refuses. They run from the git dir and register the pack of the work repository first. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh --> Change-Id: I1bb87a831c0ea795b3c7891ea4f987fb2cfdfcc2
Main added the git-refused probe next to the new registry check in hook.go, and moved the lane-schedule sync commit line and fingerprints. This keeps both functions, takes main's record files and re-records them in the next commit. Change-Id: I22be103b4553bbf608f8891d403e7b05b41086e7 Signed-off-by: Thomas Kosiewski <tk@coder.com>
… its cache holds The wire page lists what a push refuses. It now names the registry check, what it covers and what it does not, and records the re-recorded lane-schedule fingerprints after merging main. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh --> Change-Id: I8264d9c38115a3a6dd1b35c2f66ba2c641cd6644
|
@codex review |
|
@codex security review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b7ceae2591
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
… view was built Another node can register a pack that holds the object right after the view listed the registry, and a complete-looking view then reads the object as missing and refuses a push or a write that is healthy. AskRegisteredPacks now lists the registry again when an answer reads missing and builds a new view when a pack was added, at most three more times. Both callers, the pre-receive check and gitread.RegisteredKinds, use it. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh --> Change-Id: I0eb444bdcc565671a8c27a15dd293fd80c257411
…listing The pre-receive registry check now asks through AskRegisteredPacks. The sync commit line and the fingerprint of denyUnregisteredTargets move with it. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh --> Change-Id: I01688599a82d940b852354ac2b710693d4cc74d9
Only the lane-schedule sync commit line conflicted. Main moved it, so this takes main's line and the next commit re-records it. Change-Id: I86e90d903c958024381dd32e71bc30a170d11e6c Signed-off-by: Thomas Kosiewski <tk@coder.com>
Main moved the sync commit line in the same place. Only the line moves. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh --> Change-Id: I0c4f01ffbb872d23bdaa64eb1c160c5549d7216f
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
🛡️ Codex Security Review
Here are some automated security review suggestions for this pull request.
Reviewed commit: 262564715a
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
…about to write The registry check ran as soon as a branch base or tag target resolved, so a request that the ref policy denies, a tag that exists and a branch that stays where it is each built a view of the cache: one registry read, two symlinks for each registered pack and a git child. A writer could repeat such a request to spend that work without changing any state. The check now runs after the policy and after the no-op and exists answers, just before the compare-and-swap. A base that fails it still falls back to preferred_base. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh --> Change-Id: I6e6f9285e9b4bf0682f1ca04dcf1f08d23507fdb
…he order of the check The log for a view that lacks a pack said that the pack was missing from the blob store, but only the node cache lacks it. CheckAnswer now wraps ErrViewIncomplete. A new test pins that the pre-receive check runs before any upload or registration: a refused push that carries a new commit stores no pack. The http-api page now says that a create that leaves a branch at its tip, with force or a guard, reads no registry either. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ <!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh --> Change-Id: I6fcf7486de2b1e6aa44803748be3773f925b760e
Main gained #896 (githttp). The only conflict is the sync commit of the lane-schedule model; the next commit re-records it on the merged tree. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_ Change-Id: I366cda54751e41e91f387d4647f02b1a4dd3e3e1 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Why
The node's cache repository can hold an object that no registered pack holds: a cache that was copied or edited out of band, or a registry that was rolled back. git reads such an object without complaint. Every other node, and this node after it loses its cache, hydrates from the registered packs alone and cannot write a ref at that object (
update-ref ... trying to write ref ... with nonexistent object), so a ref at it wedges the repository: reads, clones and later writes answer500.A write-path audit of main found no product path that puts such an object into the cache (every writer registers its pack before the ref move), but three entry points trust the cache and not the registry, so one drifted cache is enough to store the wedging ref. I reproduced each on a live node and in tests by planting a loose commit in the cache directory:
POST /repos/branches/createresolvesbase_refandpreferred_basein the cache, and moves the ref without publishing a pack.POST /repos/tagsdoes the same forref.What changed
githttp.RegisteredPackViewis a temporary object directory that links exactly the pack files that the registry lists (ListPacks) from the cache. A git child withGIT_OBJECT_DIRECTORYset to it, and no alternates, reads an object only when a registered pack holds it.gitread.RegisteredKindsasks the view for the type of each id.missinganswer from such a view is an error (CheckAnswer, wrappingErrViewIncomplete) and the request fails, because the object may be in the pack that the view lacks. A first version of this PR failed on any absent pack, and a verifier's stress run with 8 concurrent pushers refused 11 of 4,200 valid updates with it, so the check is now tolerant.missinganswer also stands only when no pack was registered since the view was built.AskRegisteredPackslists the registry again on amissinganswer, builds a new view when a pack was added and asks again, at most three more times, so a pack that another node registers right after the listing never causes a refusal. The pre-receive check andgitread.RegisteredKindsboth ask through it. Afoundanswer never lists again.POST /repos/branches/create(base_ref,base_branch,preferred_base) andPOST /repos/tagswrite a ref only at a commit that a registered pack holds. A commit that only the cache holds answers404like one that does not exist, and a base that names no usable commit still falls back topreferred_base. The registry is read just before the compare-and-swap, after the ref policy and after the answers that write nothing (a tag that exists answers409, a create withforceorexpected_target_shaat the branch's tip answers200). So a request that the policy denies answers403even when its commit is only in the cache (it was404in the first version of this PR), and a denied request, a tag replay and a no-op branch create cost no registry read and no view.docs/reference/http-api.mdsays so.denyUnregisteredTargets), before the atomic gate, any hold or any upload, and the whole push is refused:pre-receive: <ref> is at <sha>, which no pack of this repository's registry holds: only this node's cache has the object. Push the object again with its pack. The check runs there and not in the update hook because under--atomican earlier update hook's compare-and-swap commits before a later command is refused, so a per-ref check would leave half of an atomic push stored. The check reads the new values that the main store already holds (onecat-file --batch-checkthat does not see this push's quarantine) and asks the registered packs, plus this push's quarantine (EnvForPush), only about those. A push that carries its objects has none of them in the main store, so a normal push pays that one git child and no registry read. A delete has no new value and is not checked. A push whose pack carries the commit heals the repository: the pack is registered before the ref moves.TestRefWritesRefuseACommitThatOnlyTheCacheHolds(5 request shapes, pg and sqlite) andTestPreReceiveRefusesATargetThatNoRegisteredPackHolds(5 subtests, including the push whose pack carries the commit) andTestPreReceiveRefusesTheWholePushForATargetThatNoRegisteredPackHolds(atomic and not) fail onmain.TestRegisteredKindsReadsTheRegisteredPacksOnly, theEnvForPushtest and the heal-retry test cover the view.preReceiveandupdateHookare covered functions (a newdenyUnregisteredTargetsandmainStoreKindsjoin the record). The model does not describe the check. The S3-WAL push census budget for a steady push stays at 21, because the check lists the registered packs only when the main store holds a new value.Limits
Verification
mainand pass here. At the head I ran theinternal/apirace lane without PostgreSQL (347 s),gofmt, golangci-lint 2.15.0 (0 issues),go vet, the doc-link gate and both fingerprint gates. At 3604afc I ran the fullinternal/githttprace lane (local backend, 851 s),internal/gitread,internal/gitlimit(lease audit) and the darwin test builds of githttp and api. After that commit the changes are ininternal/api(the write routes), the docs, a merge of main (fix(api): refuse sync credentials that the run refuses, and cut quoted sync values #900, api only) and, at the end, one error sentinel, one test and a comment in githttp. A verifier ran the stress, the mutants and the request matrix at 9a39152. CI runs every lane at the head. The PostgreSQL and S3-WAL lanes run in CI (this host has no docker).main. I ran the same script four times (2,400 operations) against 132e199, the head before main was merged in, and nothing was refused. I could not reproduce the refusal against the pre-receive version with the strict view either (four runs, 2,400 operations, none refused), so the tolerant view rests on its unit tests and on the reasoning above, not on a reproduced fix.TestRefWritesReadTheRegistryOnlyBeforeAWritecounts the pack listings of a denied request, a tag replay and a no-op branch create (none) and of a write (some), and fails on the previous head.TestBranchCreateFallsBackToPreferredBaseWhenTheBaseIsOnlyInTheCachepins the fallback.TestAskRegisteredPacksWhenAPackWasRegisteredSinceTheViewcovers the re-listing (a pack registered after the view, an unchanged listing, a found answer, the bound, an incomplete view). Dropping the change test or the bound fails it.Generated with
xum• Model:anthropic:claude-sonnet-5-5• Thinking:xhigh