Skip to content

check: update-status resolution is duplicated across the CLI and two dashboard handlers #444

Closed

Description

@runkids

Problem

internal/check exposes only leaf helpers (ParallelCheckURLs, FetchRemoteTreeHashesForRef, local checks). The actual status resolution — group by URL + branch → remote hash → all-match fast path → tree-hash slow path → per-skill status — is written out in three callers. The helpers are tested; the sequencing, where the bugs occur, is not testable without real repositories.

Evidence (v0.25.0, aeaea40e)

  • cmd/skillshare/check.go (1008 lines) — collectCheckItems, resolveSkillStatuses
  • internal/server/handler_check.go (200 lines) :60-185
  • internal/server/handler_check_stream.go (224 lines) :46-195
  • internal/check/parallel.go, tree_check.go, local_check.go

The two handlers share roughly 100 near-identical lines; the differences are mostly SSE event output. The CLI copy was confirmed to have the same structure but was not compared line by line.

efcc3e6 had to add branch handling to batch update, web check and web update separately.

Proposed change

internal/check owns the whole resolution ("given metadata entries, return each skill's status") and accepts a progress callback. The CLI progress bar and the SSE handler become adapters on that callback — two adapters already exist, so the seam is real. With the remote-hash source injected, the resolution can be table-tested with fake hashes.

Risks

  • The CLI and the server use different grouping key types (string vs urlBranchGroup); semantic equivalence needs confirming.
  • Lower change frequency than the uninstall and update flows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    architecture

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions