Repository navigation
refactor(check): resolve update status in internal/check - #452
Conversation
The CLI, GET /api/check and the check stream each carry their own copy of the resolution sequence, and only its leaf helpers were tested. Pin what each caller reports for every outcome, against local bare remotes, so the copies can be merged without changing output. Refs #444
The CLI, GET /api/check and the check stream each wrote out the same sequence: group skills by URL and branch, ask the remote hash, skip the tree fetch when every skill matches, otherwise compare tree hashes and assign a status. A fix such as branch handling had to be made three times, and the sequence could only be tested against real repositories. internal/check now owns it as Plan and Resolution.Run, with the remote hash source injected and a per-remote progress callback. The CLI progress bar and the SSE counter are adapters on that callback; the JSON handler passes none. The callers disagreed in two places, and both behaviours are kept: the dashboard reports a skill removed upstream as update_available where the CLI says stale, and gives no source or version for a skill without a remote. The server adapter narrows the result accordingly. Refs #444
Resolution.Run started a goroutine for every remote, even without Parallel. The dashboard handlers run sequentially and rely on net/http recovering a panic, which it only does on the request's goroutine, so a panic while resolving a remote would have ended the server process instead of failing one request, as it did before the resolution moved into internal/check. The sequential and the parallel path are now separate loops, so the invariant is visible instead of being spread over three Parallel checks. Refs #444
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ 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. |
TestGitRemoteHash_DefaultBranchUsesAuth puts an extensionless shell script named git first on PATH. On Windows exec.LookPath only resolves names with a PATHEXT extension, so the script is ignored and the real git.exe probes github.com, which answers "repository not found" for the made-up repository. The auth env is built without any platform branch, so the product path is unaffected; only the test double cannot work there. Skip it for the same reason the fake-git tests in internal/install/source_fallback_test.go already do. Refs #444
|
Cause (test, not product). The test puts an extensionless Fix (9cc4996). Skip the test on Windows with the same stated reason as the existing fake-git tests in
|
Type
proposals/only — see CONTRIBUTING.md)Linked Issue
Closes #444
What moved where
The update-status resolution (group by clone URL + branch → remote hash → all-match fast path → tree-hash slow path → per-skill status) was written out three times. It now lives once in
internal/check/resolve.go.cmd/skillshare/check.go:collectCheckItemsgrouping,resolveSkillStatuses, theurlInputs/urlOrder/urlHashMapplumbing inrunCheckandrunCheckFilteredinternal/check/resolve.gointernal/server/handler_check.go: grouping loop, per-group resolution,urlBranchGroup,skillWithMetaEntry,localCheckResultinternal/check/resolve.gointernal/server/handler_check_stream.go: the same loop withchecked.Add(1)internal/check/resolve.goInterface:
check.Plan(skills, projectRoot) *Resolutionresolves skills without a remote and groups the rest by{RepoURL, Branch}.(*Resolution).Remotes()/.RemoteSkills()give the counts callers need before the run (SSEstartevent, CLI progress total).(*Resolution).Run(ctx, Options) ([]SkillResult, error)asks each remote once and returns a status per skill.Options{Remote, Parallel, OnRemoteDone}:Remoteis the injectable hash source (nil meansGitRemote),OnRemoteDoneis the progress callback.Adapters:
resolveCheckSkillsruns the plan withParallel: trueand feeds the progress bar.OnRemoteDoneadvances thecheckedcounter; the request context cancels the run.Server.planSkillCheckanddashboardSkillResults.ParallelCheckURLs(now used only by agent checks) callsGitRemote{}.Hashinstead of its own branch/HEAD switch.Intentional behaviour changes
Statuses and payloads are unchanged; pin tests written against the old code pass on the new code. These differences remain:
url + "\t" + branch; all callers now use a struct key. Only arepo_urlcontaining a tab behaves differently, and that is not a usable git URL.The dashboard handlers still resolve one remote at a time, on the request goroutine.
Open questions for the maintainer
Two disagreements between the CLI and the dashboard existed before this change. Both are kept as they were and are now isolated in
dashboardSkillResults(internal/server/handler_check.go):stale. For a skill whose subdir was removed upstream, the CLI reportsstaleand the dashboard reportsupdate_available. Should the dashboard showstale?ui/src/pages/UpdatePage.tsxcurrently treats any status other thanupdate_available/erroras up to date, so sendingstaleneeds a UI change too.source,versionandinstalled_at; the dashboard sends onlyname,statusandmessage. Should the dashboard carry them?Left out of scope:
check.URLCheckInput.Branchis no longer set by any production caller.GitRemote.Hashcould be a singlegit.GetRemoteRefHashWithAuthcall (an empty branch already resolves HEAD), but that would leavegit.GetRemoteHeadHashWithAuthunused, so it was not done here.cmd/skillshare/update_batch.gokeeps its own URL+branch grouping; it is a different flow (clone and update).Review before opening
/code-reviewfound thatRunresolved every remote in a spawned goroutine even when sequential. A panic during a dashboard check would then end the server process instead of being recovered bynet/httpfor that request. Fixed: the sequential path runs on the caller's goroutine (TestResolution_SequentialRunStaysOnTheCallersGoroutine)./simplifysplitRuninto separate sequential and parallel loops. Its other suggestions (unexportingRemote/GitRemote, merging duplicated test tables) were not applied, to keep the pin tests as written.Checks
Run in a task-owned container from the devcontainer image, on the final commit:
make check— pass, exit 0 (docs-check,fmt-check,go vet, unit and integration tests;tests/integration62.9s)go test ./internal/check/... -count=1 -race— passgo test ./internal/server ./cmd/skillshare -run Check -count=1— passNot run: online tests (
-tags online), the dashboard UI against a live server, Windows, and a real-terminal view of the CLI progress bar. Changes 3 and 4 above follow from the code and were not observed on a terminal.Checklist
make check) — for code changes