Repository navigation
fix(review): hosted pull request reviews fail closed before Codex runs - #1308
Conversation
Review history hydration attempts one bounded fetch that names both the pinned base and the reviewed head. A depth-limited fetch sets the retained depth from every revision it names rather than extending history, so naming the base moves that window's origin to the base and drops the merge base out of it. On a live reproduction the commits reachable from the pinned base fall from 84,773 to 256 and the merge base, 189 commits behind that base, is lost with them. Hydration then reports no merge base and the host-owned input scan refuses incomplete_source before any agent runs, so the pull request gets no verdict and the durable queue re-leases an item that keeps failing. Deepen the reviewed head on its own first, since tree hydration fetched it at depth one and the merge base sits just behind it. If that does not establish one, fall back to the fetch this function already issued, unchanged, for the case where the base is itself shallow. The fallback is byte-identical to today's behaviour, so this can only add recoveries; the depth bound, filters, timeout and admission predicate are unchanged, and history that cannot be reached within the bound still reports no merge base and still refuses.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 3:41 PM ET / 19:41 UTC. ClawSweeper reviewWhat this changesThis PR changes hosted pull-request history hydration to deepen the reviewed head before falling back to the existing base-and-head fetch, and adds Git-fixture regression coverage. Merge readinessKeep open: current main still uses the original single base-and-head history fetch, while this PR adds a bounded two-stage recovery with focused coverage for both recovery and fail-closed cases. Priority: P1 Review scores
Verification
How this fits togetherHosted reviews prepare a restricted checkout of a pull request before scanning its introduced content and invoking Codex. History hydration must establish a verified merge base so the input scan can safely determine the reviewed change. flowchart TD
A[Hosted pull request] --> B[Restricted review checkout]
B --> C[History hydration]
C --> D{Verified merge base?}
D -->|Yes| E[Input secret scan]
E --> F[Codex review verdict]
D -->|No| G[Fail-closed refusal]
Before merge
Agent review detailsSecurityNone. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Land the narrow two-stage hydration change after the current checks finish, retaining the bounded fallback and its fail-closed regression coverage. Do we have a high-confidence way to reproduce the issue? Yes—the provided live Git checkout scenario exercises the merge-base predicate that gates the scan, and fetched current main still contains the pre-fix implementation. Is this the best way to solve the issue? Yes—the head-first fetch preserves existing base ancestry while the unchanged fallback handles genuinely shallow bases and retains the existing fail-closed bound. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 74b0f8552fde. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
@clawsweeper review The current head only adds the maintainer changelog entry to the tested implementation. The PR body now includes independent live Git and real scanner proof, a passing full Linux check, and the successful hosted native Codex smoke. Please review the current head and updated proof for landing. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Closes #1307
What Problem This Solves
Addresses hosted ClawSweeper reviews of
openclaw/openclawpull requests that stop beforeCodex runs and publish no verdict. The run fails with
AgentInputScanError: Agent input scan refused: incomplete_source, the durable queuere-leases the item, and every retry fails the same way, so the pull request keeps its
"ClawSweeper picked this up" acknowledgement and looks unreviewed to its author. The companion issue carries the public
run evidence and the timing across
the pull request that introduced host-owned secret scanning, which made a verified merge base a
precondition of the host-owned input scan.
Why This Change Was Made
This PR changes how review-history hydration deepens: which revisions its bounded fetch names,
and in what order. When the merge base is unavailable,
hydratePullRequestReviewHistorydeepens with onebounded fetch that names both the pinned base and the reviewed head. A depth-limited fetch
re-bounds the ancestry of every revision it names, so naming the base truncates history the
checkout already had. In case A of the proof below, the commits reachable from the pinned base
drop from 84,773 to 256 across that single call, taking the merge base with them; hydration
then returns
nulland the scan refuses before any agent runs.The head is the revision that actually needs deepening — tree hydration fetched it at depth 1.
Deepening from the head keeps the merge base inside the window the fetch retains; naming the
base as well moves that window's origin to the base and drops the merge base out of it.
So: deepen the head on its own first. If that does not establish a merge base, fall back to the
fetch this function already issued — both revisions, same depth, same flags, same timeout —
which is what the case of a genuinely shallow base still needs. The fallback issues the same arguments today's single fetch
issues — the head-only fetch has run first, so the repository state it starts from is not
identical, but the request is. In the four cases exercised below the change either recovers a
review that fails today (A/B) or leaves the outcome unchanged (C/D); that is the tested range,
not a claim about every input.
What changes, precisely: where the function issued one depth-limited fetch naming the pinned
base and the reviewed head, it now issues that fetch on the head alone and, only if no merge
base results, repeats the original fetch unchanged. So the fetch count is one or two rather
than always one, the ordering is new, and the head-only fetch touches the shared checkout's
shallow state before the fallback would. Not in scope: everything else. The admission
predicate itself is the unmodified
reviewMergeBase— what changes is that the ancestry itneeds is still present when it runs, so a review that was refused for a merge base this
function had truncated can now reach one. History that cannot be reached
within the bound still reports no merge base and still refuses — the
stays fail-closed when the bounded deepening cannot reachtest. It doesnot try to rescue every pull request whose merge
base lies beyond the bound. And the fallback still re-bounds the base exactly as the
current single fetch does, which matters because a review checkout is shared across a shard.
That is pre-existing behaviour on a path that only runs when the review would otherwise fail,
so on that path the request is what it is today; in the four tested cases nothing that recovers
today stops recovering, and reading the code that holds generally — but the tests are the four.
This change does not narrow that behaviour either.
I tried to narrow it and backed out twice, which is worth recording. Both attempts gated the
fallback on a proxy for "is the base shallow": first on the base's ancestry ending at a
shallow boundary, then on its reachable commit count being below the fetch depth. Each was
carried by the fixtures in
test/review-blob-hydration.test.tsfor the cases it was designedfor and failed the others — the boundary form cannot tell a shallow base that already reaches
deeper than the bound from one that does not, and the count form is inflated by side history
in a merge-heavy base, so each turns a case that recovers today into one that fails closed. A
predicate that inspects the ancestry path to the merge base rather than a proxy would work,
but it needs its own change and its own tests.
gitInfo()'s depth-limited base-branch refresh, the--depth=1tree fetches, TruffleHog provisioning,GIT_NO_LAZY_FETCH=1andprotocol.allow=neverare untouched. The separate observability gap —reviewMergeBasedistinguishes five failure reasons and
the gate in
scanAgentInputcollapses them into
incomplete_source— is left for its own change.User Impact
For pull requests whose merge base was lost to that truncation, the merge base now resolves, so
the scan's precondition can be met where it previously could not be. Whether the
review then completes and publishes is downstream of this change.
Measured cost is comparable, on one run per case. In the proof below all four cases — both pull requests, both
builds — are single runs that took 4.6–5.1s and ended at 188–190 MiB of
.gitdisk usage,with no case standing apart from the others. That is four runs on one host and one network
path, so it supports "no case is an outlier here", not a performance comparison. The change can issue one extra bounded
fetch, and only when the first left no merge base; on the subject pull request the head-only
fetch replaces the failing one rather than adding to it. Wall-clock and disk are what was
measured — not fetch count or bytes on the wire.
OpenClaw Bay Impact
No Bay change is needed. The production half of the diff is confined to
src/clawsweeper-review-blobs.ts; the other file is a test. Review publication, the queue,status, telemetry and dashboard data contracts are untouched, and no field or state Bay reads
is added or changed.
Documentation Impact
No documented contract changes.
docs/review-cache.mdanddocs/repair/README.mddescribereview inputs, caching and the restricted checkout; neither states which revisions the
deepening fetch names, and the depth bound, its timeout and the scan's admission rules are
unchanged. This corrects which revisions that existing fetch is asked to bound.
Evidence
Tests added: four focused tests in
test/review-blob-hydration.test.ts, over real git fixturesserved from a
file://origin; the merge-base status is never mocked. Run them withpnpm run build && node --test --test-name-pattern "review history hydration" test/review-blob-hydration.test.ts:behind the head but further behind the pinned base than the bound reaches. What it asserts is
that the merge base verifies and that more than the bound's worth of base ancestry
survives: the retained count still falls (in the live proof, 84,773 to 770), so read the name
as "keeps enough of it to reach the merge base", not "leaves it untouched".
arrives with no ancestry, so the second stage has to run. This is the case that makes
"deepen only the head" wrong on its own.
hydration reports
nulland the merge base staysunavailable. The bound doing its job.merge base.
Negative control on the fix itself: dropping the head-only fetch, so the fallback runs alone and
the function behaves as it does today, fails
keeps base ancestry the checkout already hadandleaves the other three passing. That is the only control run against this diff; earlier, larger
variants of the change carried further tests that went with them.
pnpm run checkexits non-zero on this contributor host. Its static gates —check:active-surface,check:dashboard-queue-boundary,check:dashboard-strict,check:docs,check:limits,format:checkand the typecheck — all pass; the non-zero exitcomes from 27 failing tests, all in
test/live-proof-review-environment.test.tsandtest/repair/target-validation.test.ts— terminal-proof, container and dependency-setup casesthat need tooling this host does not provide. Restoring both changed files to their
c179a46660versions andrunning those two suites produces the same 27, and the two failing-test lists compare equal, so
they are not attributable to this change. CI will re-run the suite on its own runners.
Real Behavior Proof
Claim. In the hosted checkout shape, hydration's single bounded fetch truncates the base
ancestry and returns no merge base for
openclaw/openclaw#133034— a sufficient cause for therefusal, since
scanAgentInputgates on exactly that predicate. The proof exercises thepredicate, not the hosted refusal path itself. With this change the same call keeps that ancestry and resolves the merge
base, and a control pull request that already worked is unaffected in result and in cost.
Exercised surface.
hydratePullRequestReviewHistoryandensurePullRequestReviewHeadthrough the built
dist/clawsweeper-review-blobs.js, against the livehttps://github.com/openclaw/openclaw.git.reviewMergeBase— the predicatescanAgentInputgates on — is unmodified here and is the instrument in every case.
Scenario / fixture. Four independent checkouts, each built to model the hosted target
shape:
git clone --filter=blob:none --branch main --single-branch(the hosted step adds--reference-if-able, which changes where objects come from, not the single-branch scopingthis turns on), then the review runtime's
git fetch origin refs/heads/main:refs/remotes/origin/main --depth=50. All four pin the basebranch to one SHA captured before any clone. A/B run the subject pull request on the base
commit's build and on this branch; C/D do the same for control
#132716.Command and environment. Two builds of this repository are needed: one from the base
commit and one from this branch. Build the base commit in a separate worktree so its
HEADreally is that commit,
pnpm install && pnpm run buildin each, then run the four casesagainst the live repository, loading one build per case. git 2.34.1, Node 24.18.0, branch head
bdd681fd7e431aabc3a8fbe92b561ae597746f24. The base commit for the baseline build isc179a466606f782ae73404357a0c94e6bead5807. The harness that runs the four cases isrun-proof.sh, invoked asBUILD=<branch checkout> BASELINE=<baseline dist> BASE_COMMIT=c179a46660 ./run-proof.sh; itperforms exactly the sequence described under Scenario and refuses to start unless the two builds differ in the expected direction and each
records its was built from.
Assertions. The script exits non-zero unless every case pinned the same base-branch SHA,
neither pull request's base or head moved while the cases ran (re-read and compared at the
end; both can also be pinned from outside via
EXPECT_*variables),case A reproduces the failure, cases B/C/D each verify a merge base, case A's base ancestry is
bounded at the fetch depth while case B's is not, and C and D agree once timing and size are
excluded. It also refuses to start unless the baseline dist lacks
deepenReviewHistoryand the branch build does, and unless each build records the commit itBUILD'sHEAD— a stale build was caught by that check while preparing this. Only a runending in
ALL ASSERTIONS PASSEDis a result.Observed result.
.gitdisk61a75f5494a7a2dacc7aa7a2dacc7aIn each of these four runs the depth-limited fetch re-bounded ancestry — which is what
--depthis documented to do, setting retained depth from each named revision — which is visible here as the reachable count changing across the singlefetch in
hydratePullRequestReviewHistory. Thedifference the fix makes is where the retained window starts: from the base (A, 256 commits,
merge base lost) or from the head (B, 770 commits, merge base kept). C and D end identically. The script asserts the results and the
control equivalence, not which internal fetch produced them; C/D matching on both builds is
consistent with the fallback running on both sides, and that is how the code reads, but the
transcript does not prove it on its own.
The transcript above is an excerpt of the run's output, kept to the lines that carry the
result; the run also prints each case's clone tip, the pinned SHA it asserts, post-refresh
ancestry, shallow state and
.gitsize, and ends with theALL ASSERTIONS PASSEDline quoted.The authoritative complete output is what the harness prints when run — the excerpt omits
lines, it does not alter them.
The
after head, before hydrationline is the control that isolates the cause: with thereviewed head installed and nothing deepened, base reachability is untouched at 84,773 and the
merge base is still unavailable. Only the hydration fetch that follows changes it.
Limitations. The proof reproduces the mechanism in a model of the hosted checkout, not a capture
from a runner, so it establishes a sufficient cause for the observed refusals rather than
proving it is the only one in production. It observes
reviewMergeBase, the predicate the scangates on; it does not run TruffleHog or Codex, because the host-owned scanner is provisioned
inside the hosted runner by
.github/actions/setup-review-toolsand is not reproducible on acontributor host — and the refusal being repaired happens before either runs.
mainmovescontinuously, so ancestry counts differ between runs; the A/B asymmetry from a pinned starting
state and the C/D equivalence are the invariant parts.
Maintainer verification — 2026-08-30
Current head:
f14ad532805d463ee09e9fcdaa3951fac31865f8. The maintainer addition is one changelog entry thanking @masatohoshino. Production code, tests, scripts, workflows, and dependencies are byte-identical to the tested implementation headbdd681fd7e431aabc3a8fbe92b561ae597746f24.pnpm run checkpassed on AWS Crabbox, leasecbx_646cfbf7ff39, runrun_d8090c339f9b, Linux amd64 with Node 24.18.1. This includes the full coverage gate. A fresh isolated Codex autoreview of the implementation returned no accepted/actionable findings at its default P0 threshold.An independent live Git/scanner replay also passed on that lease (run
run_690796422745, Git 2.53.0, the repository-pinned TruffleHog 3.97.1). Four independent blobless, single-branch clones fetched the public OpenClaw Git remote, pinned the base-branch tip to0594a100d9710a94cd8c80d72713a3565eefd2ff, applied the depth-50 refresh, then called the actual baseline or patched history-hydration implementation. The scanner and merge-base predicate were unchanged between cases.afd26c0259ddf10382d4165d7a2075c2dda445c1incomplete_source61a75f549406a8c7e359c0e1243ab0adb42cd89dverified; real scanner passedab326763775abbf573eaee488fa0cf87b1773c3ea7a2dacc7a43be0b8e88f74649b4b90cfc9e7cab; 309 reachable commits after hydrationThe controlled live harness ended with
ALL LIVE HISTORY AND SCANNER ASSERTIONS PASSED. It scans the affected PR's real introduced before/after bytes with a synthetic prompt; it does not run inference or publish a review. The 128-file control tests history only, because it exceeds the existing 80-file blob-hydration bound. An initial harness attempted that broader control scan, hit this existing limit, and was corrected to keep the control scoped to ancestry; the affected-PR scanner assertions were retained unchanged.Separately, the manually dispatched hosted CI run passed, including the normally skipped Hosted native review scan smoke. Its
hosted-review-scan-proofartifact records zero provider starts for four refusal scenarios and one successful real Codex structured response for a clean synthetic committed change, on Ubuntu 24 with the pinned scanner. This proves scanner/inference integration, not publication of a real target review.No Bay change is needed: this PR changes history hydration and adds a changelog entry, without modifying queue, publication, or dashboard contracts. Terminal retry classification remains a separate follow-up; the scan continues to refuse genuinely incomplete ancestry.