Repository navigation
refactor(update): one operation for tracked-repo update and the post-pull audit gate - #454
Conversation
The dashboard's pull flow for tracked repos had no tests of its own, and the CLI had none for uncommitted changes. Both flows are about to be replaced by one shared operation, so their current results are pinned first: clean update, blocked and rolled back, skip-audit, force not remembering findings, dirty repos, and the pull error hint. Refs #443
Updating a tracked repo is a fail-closed sequence: check for uncommitted changes, pull, audit what was pulled, reset to the pre-pull commit when the audit blocks. The CLI had two copies of the pull flow, the dashboard a third, and the audit gate existed four times (CLI, dashboard, and two in install). The copies had drifted: the dashboard ignored a failed git status and never refreshed root-skill metadata, and each copy worded a failed rollback on its own. update.TrackedRepo now owns the sequence and returns a structured result; install.AuditGate is the only gate. internal/update is a new package because internal/git already imports internal/install. The CLI keeps its spinner, rows and the "Apply anyway?" prompt, passed in as one Confirm callback; the dashboard turns the result into its JSON item. Behaviour changes, all towards the stricter copy: - the dashboard reports a failed git status as an error instead of pulling; - the dashboard refreshes root-skill metadata after an update, like the CLI; - a prompt that fails rolls the update back instead of leaving it applied; - the rollback-failed and rollback-unavailable texts come from one place. Accepted findings stay as they were (CLI honours and records them, the dashboard does neither), now as the explicit AcceptedFindings input. The "blocked and rolled back" texts are unchanged per caller because the dashboard matches on them. Refs #443
Review of the shared tracked-repo update found two regressions. `install --track --update` lost "in tracked repository" from its message when findings blocked and the rollback failed. The CLI builds its summary from that phrase, so the old sentence is back, with the rollback part still coming from AuditGateError.RollbackNote. The dashboard dropped a failed metadata refresh without a trace, while the CLI prints a warning. It is now logged. trackedBlockMessage also gets a test: the dashboard offers Force Retry based on its exact wording, and the server-level tests for the failed-rollback branches went away with the old gate. Refs #443
The dashboard update of N tracked repos loaded the metadata store 2N times under the server lock, and each load walks the whole source tree. The refresh now returns before loading when the repo has no root SKILL.md, reports whether it saved a change, and the server reloads its store only then, through the existing reloadSkillsStore. The CLI single-repo path tracked its output with two flags and a OnceFunc. The caller hook now runs once for every outcome, so the spinner stop, the discard warning and the pull summary live in one place and print in the same order as before. auditGateFailClosed rebuilt three of its messages by hand; they are AuditGateError's own wording with another subject, so both now come from one function. Refs #443
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. |
|
Could the dashboard honor findings already accepted through the CLI? I saw this listed as an open question in this PR and ran into it on Windows with v0.26.0. Dashboard updates blocked Is there a reason to keep this behavior different between the CLI and dashboard? Honoring existing records would help users who switch between them. Whether the dashboard's Force Retry should also save acceptances could be decided separately. If you plan to support this in the dashboard, showing when a finding was accepted, allowing an optional review note, and offering a way to revoke individual acceptances would also help. These could follow later. Would you prefer a separate issue to track this? |
|
Thanks for testing this on Windows and for the clear write-up with real repos — that made the problem easy to confirm. There was no good reason to keep the two paths different. It was left as an open question in this PR, and your report settles it. #599 makes the dashboard behave like the CLI for tracked repos:
For the other ideas (showing when a finding was accepted, an optional review note, and revoking individual acceptances), I opened #598 so they don't get lost. They need a small change to how acceptances are stored, so they'll come separately. Once #599 is released, I'd love to hear whether switching between the CLI and the dashboard works smoothly for you on Windows. |
Type
proposals/only — see CONTRIBUTING.md)Linked Issue
Closes #443
What moved where
"Update one tracked repo" is now one operation,
update.TrackedRepo(new packageinternal/update): check for uncommitted changes → pull / force pull → audit what was pulled → reset to the pre-pull commit when the audit blocks → refresh root-skill metadata. It returns a structured result. The post-pull audit gate isinstall.AuditGate.cmd/skillshare/update_handlers.goauditGateAfterPullinstall.AuditGate.Runinternal/server/handler_update.goauditGateTrackedRepoinstall.AuditGate.Run; dashboard wording intrackedBlockMessageinternal/install/install_audit.goauditGateFailClosedAuditGate.Runthat keeps thepost-update audit …wordinginternal/install/install_audit.goauditTrackedRepoUpdateAuditGate.Run; keeps its warnings and the… in tracked repositorywordingupdateTrackedRepo,updateTrackedRepoQuick, serverupdateTrackedRepopull flowsupdate.TrackedRepoThe package is new, not part of
internal/install, becauseinternal/gitalready importsinternal/install. The gate stays ininstallbecause install's own update and relock paths use it.The CLI keeps the spinner, rows and the "Apply anyway?" prompt. The prompt reaches the operation as one callback,
Confirm func(*TrackedRepoResult) (bool, error); neitherinternal/updatenorinternal/installimports UI code. The server turns the result into its JSON item.Intentional behaviour changes
Where the copies differed, the stricter one was kept.
git statusis now an error. It used to be ignored and the pull went ahead. The item isaction: "error",message: "failed to check git status: …". With force it is still ignored, as in the CLI, because force resets the checkout anyway.SKILL.md, so a broken.metadata.jsonno longer produces a "Failed to refresh metadata" warning for such repos.(confirmation failed: …).auditGateFailCloseddid so). Not reachable today: every caller takes the hash from a successfulrev-parse HEAD.AuditGateError.RollbackNote). The only reachable text change: dashboard findings + failed reset saysrollback also failed(wasrollback failed). The rollback-unavailable texts are one sentence now, but that case is not reachable.Unchanged on purpose:
isForceRetryable:post-update audit failedmeans force will not help,blocked by security auditmeans retryable), and the CLI parsesin tracked repository.TrackedRepoOptions.AcceptedFindingsinput (CLItrue, serverfalse) and is pinned by tests on both sides.Fetching <repo>...(it showedChecking <repo>...duringgit status) and keeps spinning during the audit scan.Open questions for the maintainer
AcceptedFindings: trueinServer.updateTrackedRepois a one-line change, but it relaxes the dashboard gate, so it is left off.trackedBlockMessageexists only becauseUpdatePage.tsxandauditMessage.tsmatch on substrings. If the UI read structured fields (scan error vs findings, rollback state), the four wordings could becomeAuditGateError.Error().install --track --updatehas no dirty check.install.updateTrackedRepopulls without checking for uncommitted changes (except followed checkouts), and a blocked audit then runsgit reset --hard, which discards them. It cannot callupdate.TrackedRepofrom insideinstall(import cycle), and adding the check changes behaviour, so it is left.update --allwould be a small change.Checks
Run in a temporary container from the devcontainer image with this worktree mounted at
/workspace:go test ./internal/server -run 'TestUpdateTrackedRepo_' -count=1andgo test ./tests/integration -run 'TestUpdate_TrackedRepo_Dirty|TestUpdate_Batch_Dirty' -count=1on the old code, before any production change: ok (commitea83840bpins the behaviour).go test ./internal/update ./internal/install ./internal/server ./cmd/skillshare -count=1: ok.make check(docs check, gofmt,go vet, unit and integration tests) at7bc61698: exit 0, no failing test.python3 scripts/ai-context.py check: ok./code-reviewand/simplifyonorigin/main...HEAD; their results are commits277b2831and7bc61698.Not run: the interactive prompt on a real terminal (integration tests have no TTY; accept / decline / error are covered through
Confirmininternal/update), Windows, and the dashboard in a browser (no UI code changed).Checklist
make check) — for code changes