Skip to content

refactor(update): one operation for tracked-repo update and the post-pull audit gate - #454

Merged
runkids merged 5 commits into
mainfrom
runkids/arch-443-tracked-update
Oct 6, 2026
Merged

runkids merged 5 commits into
mainfrom
runkids/arch-443-tracked-update

Conversation

@runkids

@runkids runkids commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Type

  • Bug fix
  • Small improvement (docs, typo, minor refactor) — a refactor, but not a minor one: it replaces three pull flows and four audit gates with one operation, and changes a few behaviours listed below.
  • Feature proposal (proposals/ only — see CONTRIBUTING.md)

Linked Issue

Closes #443

What moved where

"Update one tracked repo" is now one operation, update.TrackedRepo (new package internal/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 is install.AuditGate.

Before After
cmd/skillshare/update_handlers.go auditGateAfterPull install.AuditGate.Run
internal/server/handler_update.go auditGateTrackedRepo install.AuditGate.Run; dashboard wording in trackedBlockMessage
internal/install/install_audit.go auditGateFailClosed thin adapter over AuditGate.Run that keeps the post-update audit … wording
internal/install/install_audit.go auditTrackedRepoUpdate calls AuditGate.Run; keeps its warnings and the … in tracked repository wording
CLI updateTrackedRepo, updateTrackedRepoQuick, server updateTrackedRepo pull flows update.TrackedRepo

The package is new, not part of internal/install, because internal/git already imports internal/install. The gate stays in install because 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); neither internal/update nor internal/install imports UI code. The server turns the result into its JSON item.

Intentional behaviour changes

Where the copies differed, the stricter one was kept.

  1. Dashboard: a failed git status is now an error. It used to be ignored and the pull went ahead. The item is action: "error", message: "failed to check git status: …". With force it is still ignored, as in the CLI, because force resets the checkout anyway.
  2. Dashboard: root-skill metadata is refreshed after a tracked-repo update, as the CLI already did, and the in-memory store is reloaded when the refresh wrote something. Agent repos are not refreshed, as before. A failed refresh is logged. For both callers the metadata store is no longer loaded when the repo has no root SKILL.md, so a broken .metadata.json no longer produces a "Failed to refresh metadata" warning for such repos.
  3. A failing prompt rolls back. If the confirmation itself returns an error, the CLI used to return it and leave the pulled content applied. It now counts as a decline: the checkout is reset and the error is the gate error plus (confirmation failed: …).
  4. Empty pre-pull commit blocks before scanning in every caller (only auditGateFailClosed did so). Not reachable today: every caller takes the hash from a successful rev-parse HEAD.
  5. One wording for a failed or unavailable rollback (AuditGateError.RollbackNote). The only reachable text change: dashboard findings + failed reset says rollback also failed (was rollback failed). The rollback-unavailable texts are one sentence now, but that case is not reachable.

Unchanged on purpose:

  • The "blocked and rolled back" texts are byte-identical per caller. The dashboard matches on them (isForceRetryable: post-update audit failed means force will not help, blocked by security audit means retryable), and the CLI parses in tracked repository.
  • Accepted findings: the CLI honours and records them, the dashboard does neither. This is now the explicit TrackedRepoOptions.AcceptedFindings input (CLI true, server false) and is pinned by tests on both sides.
  • Batch and agent updates still count a failed pull or failed discard as "skipped" without a message. Batch updates on a terminal still prompt per repo.
  • TTY-only cosmetic: the single-repo spinner starts as Fetching <repo>... (it showed Checking <repo>... during git status) and keeps spinning during the audit scan.

Open questions for the maintainer

  1. Should the dashboard use accepted findings? Today a repo force-updated in the CLI is blocked again by the dashboard, and every dashboard Force Retry has to be repeated on the next update. Setting AcceptedFindings: true in Server.updateTrackedRepo is a one-line change, but it relaxes the dashboard gate, so it is left off.
  2. Dashboard wording. trackedBlockMessage exists only because UpdatePage.tsx and auditMessage.ts match on substrings. If the UI read structured fields (scan error vs findings, rollback state), the four wordings could become AuditGateError.Error().
  3. install --track --update has no dirty check. install.updateTrackedRepo pulls without checking for uncommitted changes (except followed checkouts), and a blocked audit then runs git reset --hard, which discards them. It cannot call update.TrackedRepo from inside install (import cycle), and adding the check changes behaviour, so it is left.
  4. Silent batch pull failures. The operation now returns the pull error, so reporting it in update --all would be a small change.
  5. Force Retry for an unreadable git status in the dashboard. The new error has no Force Retry button, although a force update does get past it (as in the CLI). Offering force for a repo whose status cannot be read discards whatever is there, so no hint was added.

Checks

Run in a temporary container from the devcontainer image with this worktree mounted at /workspace:

  • go test ./internal/server -run 'TestUpdateTrackedRepo_' -count=1 and go test ./tests/integration -run 'TestUpdate_TrackedRepo_Dirty|TestUpdate_Batch_Dirty' -count=1 on the old code, before any production change: ok (commit ea83840b pins 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) at 7bc61698: exit 0, no failing test.
  • python3 scripts/ai-context.py check: ok.
  • /code-review and /simplify on origin/main...HEAD; their results are commits 277b2831 and 7bc61698.

Not run: the interactive prompt on a real terminal (integration tests have no TTY; accept / decline / error are covered through Confirm in internal/update), Windows, and the dashboard in a browser (no UI code changed).

Checklist

  • I've read CONTRIBUTING.md
  • Tests included and passing (make check) — for code changes
  • No unrelated changes in the diff
  • Scope is focused — one concern per PR

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
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T16:25:26.927877Z 7bc6169 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@runkids runkids added the architecture Deepening opportunity: restructure modules for locality and testability label Oct 6, 2026
@runkids
runkids merged commit 9d74bc0 into main Oct 6, 2026
8 checks passed
@runkids
runkids deleted the runkids/arch-443-tracked-update branch October 6, 2026 17:07
@483218131

Copy link
Copy Markdown

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 QingYunA/answer-me-with-html and cathrynlavery/diagram-design on findings that included attack strings in security tests and Python declarations such as root: Path. I reviewed and accepted them through the CLI, which saved the acceptance records. Since the dashboard ignores those records, using it for later updates can mean accepting the same unchanged findings again.

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?

@runkids

runkids commented Oct 21, 2026

Copy link
Copy Markdown
Owner Author

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:

  • Updates honor findings you already accepted through the CLI, so QingYunA/answer-me-with-html and cathrynlavery/diagram-design won't be blocked again on the same unchanged findings.
  • Force Retry in the dashboard now records the findings it lets through, the same way update --force does. Regular (non-tracked) skills already worked this way in the dashboard, so tracked repos were the odd one out.
  • It also fixes nested agent tracked repos, where the dashboard stored acceptances in a different place from the CLI.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

architecture Deepening opportunity: restructure modules for locality and testability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update: tracked-repo pull and the post-pull audit gate exist in three copies

2 participants