forked from kunchenguid/no-mistakes
-
Notifications
You must be signed in to change notification settings - Fork 0
feat(daemon): add worktree_roots, Gitea/Forgejo SCM, and Grok/Antigravity agents #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KooshaPari
wants to merge
17
commits into
integration/fork-main-sync-20260827
Choose a base branch
from
worktrees/upstream-diagnostics-reconcile-20260827
base: integration/fork-main-sync-20260827
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0468b04
docs: define cached repository state rebuild
27d9d0b
feat(status): show cached repository state
94bd61f
test(status): cover cached state command output
a36683c
test(status): prove cached state is read-only
f931eac
fix(status): keep cached inspection read-only
0ca442d
fix(status): retain cached sync guidance
b41e23d
fix(sync): defer cached gate recovery proof
ded68be
fix(status): show guarded recovery command
c6f627a
fix(telemetry): stabilize status read fingerprints
a03784d
fix(tui): offer guarded recovery for explicit verification
49698a8
fix(tui): require custody action before recovery
dcb1406
test(e2e): give expanded matrix realistic timeout
3730aab
docs(fork): record semantic main reconciliation
5ce8819
fix(review): resolve recovery and docs findings
17deb73
merge: integrate fork reconciliation base
c050d71
fix(review): harden recovery status guidance
a12ab6c
test(e2e): allow realistic package runtime
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
194 changes: 194 additions & 0 deletions
194
docs/superpowers/plans/2026-08-26-cached-repository-state.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| # Cached Repository State Implementation Plan | ||
|
|
||
| > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. | ||
|
|
||
| **Goal:** Make `no-mistakes status` always render cached, local-only repository branch evidence without adding a pipeline or network operation. | ||
|
|
||
| **Architecture:** `internal/cli/status.go` already obtains `branchsync.State` through `InspectCached`. Add one small presenter for that state and render it unconditionally after repository discovery. Include the rendered cached summary in the existing status telemetry fingerprint so sampled status events correspond to visible state. | ||
|
|
||
| **Tech Stack:** Go, Cobra, existing `branchsync.Service`, existing CLI test helpers. | ||
|
|
||
| --- | ||
|
|
||
| ## File structure | ||
|
|
||
| - Modify: `internal/cli/status.go` - render cached evidence and fingerprint it. | ||
| - Create: `internal/cli/status_test.go` - table tests for the pure cached-state presenter and fingerprint coverage. | ||
|
|
||
| ### Task 1: Write the failing presenter test | ||
|
|
||
| **Files:** | ||
|
|
||
| - Create: `internal/cli/status_test.go` | ||
|
|
||
| - [ ] **Step 1: Define clean, dirty, and unavailable cases** | ||
|
|
||
| ```go | ||
| func TestCachedBranchSummary(t *testing.T) { | ||
| tests := []struct { name string; state branchsync.State; want string }{ | ||
| {"clean branch", branchsync.State{State: branchsync.StateSynchronized, Local: branchsync.LocalState{Branch: "feature/state", Head: "0123456789abcdef", Clean: true}}, "cached: feature/state 01234567 (clean; already synchronized with the pipeline-pushed head)"}, | ||
| {"dirty branch", branchsync.State{State: branchsync.StateDirty, Local: branchsync.LocalState{Branch: "feature/state", Head: "fedcba9876543210", Reason: "uncommitted changes"}}, "cached: feature/state fedcba98 (dirty: uncommitted changes; dirty)"}, | ||
| {"unavailable", branchsync.State{State: branchsync.StateAmbiguousContext}, "cached: unavailable (ambiguous context)"}, | ||
| } | ||
| for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { | ||
| if got := cachedBranchSummary(tt.state); got != tt.want { t.Fatalf("cachedBranchSummary() = %q, want %q", got, tt.want) } | ||
| }) } | ||
| } | ||
| ``` | ||
|
|
||
| - [ ] **Step 2: Verify red** | ||
|
|
||
| Run: `go test ./internal/cli -run '^TestCachedBranchSummary$'` | ||
|
|
||
| Expected: compile failure because `cachedBranchSummary` does not exist. | ||
|
|
||
| ### Task 2: Add the local-only presenter and render it | ||
|
|
||
| **Files:** | ||
|
|
||
| - Modify: `internal/cli/status.go` | ||
| - Test: `internal/cli/status_test.go` | ||
|
|
||
| - [ ] **Step 1: Implement the presenter** | ||
|
|
||
| ```go | ||
| func cachedBranchSummary(state branchsync.State) string { | ||
| summary := humanSyncSummary(state) | ||
| if state.Local.Branch == "" || state.Local.Head == "" { return "cached: unavailable (" + summary + ")" } | ||
| head := state.Local.Head[:minLen(len(state.Local.Head), 8)] | ||
| cleanliness := "clean" | ||
| if !state.Local.Clean { cleanliness = "dirty"; if state.Local.Reason != "" { cleanliness += ": " + state.Local.Reason } } | ||
| return fmt.Sprintf("cached: %s %s (%s; %s)", state.Local.Branch, head, cleanliness, summary) | ||
| } | ||
| ``` | ||
|
|
||
| - [ ] **Step 2: Replace the conditional cached-state rendering** | ||
|
|
||
| ```go | ||
| syncState := (&branchsync.Service{DB: d, Repo: repo, WorkDir: "."}).InspectCached(cmd.Context()) | ||
| cachedSummary := cachedBranchSummary(syncState) | ||
| fmt.Fprintf(w, "\n %s %s\n", sDim.Render("local state:"), cachedSummary) | ||
| ``` | ||
|
|
||
| - [ ] **Step 3: Verify green** | ||
|
|
||
| Run: `go test ./internal/cli -run '^TestCachedBranchSummary$'` | ||
|
|
||
| Expected: PASS. | ||
|
|
||
| ### Task 3: Keep telemetry aligned with rendered evidence | ||
|
|
||
| **Files:** | ||
|
|
||
| - Modify: `internal/cli/status.go` | ||
| - Modify: `internal/cli/status_test.go` | ||
|
|
||
| - [ ] **Step 1: Add a failing fingerprint regression test** | ||
|
|
||
| ```go | ||
| func TestStatusFingerprintIncludesCachedSummary(t *testing.T) { | ||
| run := &db.Run{ID: "run-1", Branch: "feature/test", Status: "running", HeadSHA: "head-one"} | ||
| before := statusFingerprint("repo", "running", run, "cached: main 01234567 (clean; synchronized)") | ||
| after := statusFingerprint("repo", "running", run, "cached: main 89abcdef (dirty; dirty)") | ||
| if before == after { t.Fatal("changing displayed cached evidence must change the status fingerprint") } | ||
| } | ||
| ``` | ||
|
|
||
| - [ ] **Step 2: Verify red** | ||
|
|
||
| Run: `go test ./internal/cli -run '^TestStatusFingerprintIncludesCachedSummary$'` | ||
|
|
||
| Expected: compile failure until `statusFingerprint` accepts the cached summary. | ||
|
|
||
| - [ ] **Step 3: Update signature and call site** | ||
|
|
||
| ```go | ||
| fingerprint := statusFingerprint(repo.ID, daemonState, activeRun, cachedSummary) | ||
| ``` | ||
|
|
||
| Build the fingerprint from repository id, daemon state, cached summary, and | ||
| the existing active-run fields. Update the existing active-run-head test with | ||
| the fourth argument. | ||
|
|
||
| - [ ] **Step 4: Verify focused tests** | ||
|
|
||
| Run: `go test ./internal/cli -run 'Test(CachedBranchSummary|StatusFingerprint)'` | ||
|
|
||
| Expected: PASS. | ||
|
|
||
| ### Task 4: Validate and prepare review | ||
|
|
||
| **Files:** | ||
|
|
||
| - Modify: `internal/cli/status.go` | ||
| - Create: `internal/cli/status_test.go` | ||
|
|
||
| - [ ] **Step 1: Add command-level status coverage** | ||
|
|
||
| Use `setupTestRepo`, `executeCmd("init")`, and `executeCmd("status")` to | ||
| assert the clean and a newly dirty worktree both retain `repo`, `daemon`, and | ||
| `no active run` output and always include `local state: cached:`. The clean | ||
| case must include `(clean;`; the dirty case must include `(dirty:`. | ||
|
|
||
| Run: `go test ./internal/cli -run '^TestStatusAlwaysRendersCachedLocalState$' -count=1` | ||
|
|
||
| Expected: PASS. | ||
|
|
||
| - [ ] **Step 2: Format and run full gates** | ||
|
|
||
| Run: `gofmt -w internal/cli/status.go internal/cli/status_test.go && make lint && go test -race ./... && go build -o ./bin/no-mistakes ./cmd/no-mistakes` | ||
|
|
||
| Expected: each command exits 0. | ||
|
|
||
| - [ ] **Step 3: Inspect the review diff** | ||
|
|
||
| Run: `git diff --check && git diff -- internal/cli/status.go internal/cli/status_test.go` | ||
|
|
||
| Expected: no whitespace errors and no source file outside the planned scope. | ||
|
|
||
| - [ ] **Step 4: Commit after fresh evidence** | ||
|
|
||
| ```bash | ||
| git add internal/cli/status.go internal/cli/status_test.go | ||
| git commit -m "feat(status): show cached repository state" | ||
| ``` | ||
|
|
||
| ### Task 5: Review-remediation safety proof | ||
|
|
||
| **Files:** | ||
|
|
||
| - Modify: `internal/cli/status_test.go` | ||
| - Modify: `docs/src/content/docs/reference/cli.md` | ||
|
|
||
| - [x] **Step 1: Add a command-level cached-only safety regression** | ||
|
|
||
| Run `status` after `init` through a test-local Git wrapper that records any | ||
| `fetch` or `ls-remote` invocation. Snapshot `.git/FETCH_HEAD`, `.git/index`, | ||
| refs, worktree state, and the gate database before and after the command. | ||
| Assert that the command renders cached state, makes no remote Git call, and | ||
| does not change any snapshot. Also exercise a locally available diverged head | ||
| and snapshot `.git/objects`: cached inspection must conservatively report | ||
| `blocked_diverged` without constructing a merge tree. Cover the terminal | ||
| recovery shape where both divergent heads exist only in the local gate and | ||
| snapshot that bare repository's `objects` directory: cached inspection must | ||
| defer semantic verification to explicit recovery. | ||
|
|
||
| - [x] **Step 2: State the user-facing freshness boundary** | ||
|
|
||
| Document that the always-rendered cached local-state line's Git inspection is | ||
| local evidence, does not fetch or query a Git remote, does not mutate local | ||
| Git state, and does not assert remote freshness. Existing command telemetry | ||
| is a separate concern. A Git-status failure must render cleanliness as | ||
| unavailable, never as a confirmed dirty worktree. | ||
|
|
||
| - [x] **Step 3: Run focused and full verification** | ||
|
|
||
| Run: | ||
|
|
||
| ```bash | ||
| gofmt -w internal/cli/status_test.go | ||
| go test ./internal/cli -run 'TestStatus' -count=1 | ||
| make lint && go test -race ./... && go build -o ./bin/no-mistakes ./cmd/no-mistakes && git diff --check | ||
| ``` | ||
|
|
||
| Expected: each command exits 0 before updating the PR. | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.