Skip to content

Report the first answer and a time stop from the upgrade pass - #110

Merged
jonyoder merged 3 commits into
mainfrom
upgrade-report
Nov 20, 2026
Merged

jonyoder merged 3 commits into
mainfrom
upgrade-report

Conversation

@jonyoder

@jonyoder jonyoder commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Resolution.Upgrade now reports on the UpgradeRoots pass: First is the first solve's answer (the pass-off answer) and StoppedByTime says whether a time bound or the end of ctx cut the pass short. Package Manager needs this to fall back to the first answer when its deadline interrupts a pass, without solving again (rstudio/package-manager#22820). It is nil with the pass off, and the answer the pass keeps does not change.


API (resolver/resolver.go): Resolution.Upgrade *UpgradeReport, with First *Resolution and StoppedByTime bool. When the pass keeps the first answer, the outer Resolution is a copy, so First shares no maps or slices with it.

By time: UpgradeTimeFactor/UpgradeMaxTime reached between re-solves, a re-solve cut by that bound, or the pass running into the end of ctx (cancel or deadline). The step bounds, the UpgradeRoots budget, and running out of roots are not.

Tests (resolver/upgrade_report_test.go, fake clock and a hand-expired ctx, no sleeps):

  • Red: before the change, all five pass-on tests fail with Upgrade is nil. Mutations caught: dropping the ctx signal, dropping the cut-re-solve signal, always reporting true, and returning First aliased with the outer answer each fail at least one test.
  • Review follow-up: ctx ends while scoring the last re-solve (index hides the ctx error), at a loop check, while listing roots, and in a usability lookup each have a test; the scoring one failed before the fix, and the other three fail with the loop-head check and u.failed removed. cloneResolution has a field-by-field test and a reflect guard for new map/slice/pointer fields.
  • Green: go test ./... (1281 pass, 0 fail), go test -race ./resolver/, go vet, gofmt -l, golangci-lint v2.11.2: 0 issues.

🤖 Generated with Claude Code

jonyoder and others added 3 commits November 20, 2026 16:30
Resolution.Upgrade carries the first solve's answer and whether time cut the
pass short, so a caller can fall back without solving again
(rstudio/package-manager#22820).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A ctx that ends just after the pass returned did not cut it short.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An index can report a ended ctx as unusable metadata, so check ctx after
scoring a re-solve. Test ctx ends at a loop check, in the root set and in a
usability lookup; test that cloneResolution copies every field. Make the
StoppedByTime doc and the CHANGELOG entry match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jonyoder

Copy link
Copy Markdown
Collaborator Author

Merging at 3f80c7de60de0d646aa7e33616b202d4002bc9a1 under Jon's standing approval for go-pyresolver. Jon agreed the design on rstudio/package-manager#22820; he has not reviewed this code himself.

Since this adds a public API, it had two independent reviews (separate Claude sessions that did not write it):

  • Round 1, at 70d2b47: approve with nits. Five low items: a deadline could go unflagged if an index hides the deadline error during the last attempt; deadline paths outside a running re-solve had no tests; the copy test checked only two fields; two doc comments overstated; the CHANGELOG entry was long. All fixed in 3f80c7d.
  • Round 2, at this commit: approve with nits. The reviewer confirmed each fix by breaking it in a scratch copy and watching a test fail.

RoboRev: job 5710 found one medium (a deadline that passed after the pass finished counted as a stop), fixed in 70d2b47. Jobs 5711 and 5717 passed with no findings. CI: build and lint green.

Left as is, all low:

  • After a re-solve, the check reads the caller's ctx, not the pass's own timed one. With an index that hides deadline errors, a time-bounded pass could in theory keep a different answer unflagged; the reviewer could not build such a case. It cannot happen with only a step bound, which is how PPM will run it.
  • One set of ctx checks is redundant with the loop-head check, and the check at "no root left to pick" has no test that needs it.

@jonyoder
jonyoder merged commit 582a6fb into main Nov 20, 2026
2 checks passed
@jonyoder
jonyoder deleted the upgrade-report branch November 20, 2026 22:07
@jonyoder jonyoder mentioned this pull request Nov 20, 2026
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