Skip to content

Track shallow flag on index and audit runs#68

Merged
mbertschler merged 2 commits into
mainfrom
claude/index-shallow-run-tracking-nK7DY
May 22, 2026
Merged

Track shallow flag on index and audit runs#68
mbertschler merged 2 commits into
mainfrom
claude/index-shallow-run-tracking-nK7DY

Conversation

@mbertschler
Copy link
Copy Markdown
Owner

Summary

Index and audit runs can take a (size, mtime) shortcut instead of rehashing every file. Whether a given run used the shortcut was previously only a runtime option — neither squirrel runs, the TUI runs view, nor the desktop runs page distinguished a shallow-skip pass from a full integrity check. That hides a meaningful difference: a "200 unchanged" line means very different things depending on how unchanged-ness was decided.

This PR persists the choice on the runs row and surfaces it in both UIs.

  • Schema v10: adds a nullable shallow column to runs with a CHECK (shallow IS NULL OR shallow IN (0, 1)) guard. The migration is additive — no table rebuild.
  • Store: new BeginIndexRun(kind, volumeID, shallow) helper that index and audit runs route through. Sync and restore continue to use BeginRun and leave the column NULL (the flag has no meaning there). Pre-v10 rows stay NULL ("unknown") rather than being backfilled to a guess.
  • Index / scheduler: index.Index records opts.Shallow on its runs row. The agent scheduler's synthesised failed-index row records shallow=true so the watermark matches the mode that was actually attempted.
  • TUI: adds a MODE column to the runs table and a Shallow row to the detail view.
  • Desktop: adds a Mode column to the runs list and a row to the run detail status panel, rendered as a shallow / full badge with NULL shown as a muted dash.

Test plan

  • go test ./... — all packages green
  • go vet ./... clean
  • New TestBeginIndexRunRecordsShallow covers shallow=true/false on index, audit kinds, and NULL on sync
  • New TestBeginIndexRunRejectsWrongKind pins the kind validation
  • New TestIndexRecordsShallowFlag confirms index.Index writes the flag based on Options.Shallow
  • Manual smoke: open the TUI runs screen and desktop /runs page on a DB migrated through v10

Generated by Claude Code

Index and audit runs can take a (size, mtime) shortcut instead of
rehashing every file. Whether a run used the shortcut was previously
only a runtime option — `squirrel runs`, the TUI runs view, and the
desktop runs page all surfaced run history without ever distinguishing
a shallow-skip pass from a full integrity check. That hides a
meaningful difference: a "200 unchanged" line means very different
things depending on how the unchanged-ness was decided.

Add a nullable `shallow` column to the runs table (schema v10) plus a
new `BeginIndexRun(kind, volumeID, shallow)` store helper that index
and audit runs route through. Sync and restore continue to use
`BeginRun` and leave the column NULL — the flag has no meaning there.
Pre-v10 history is also NULL ("unknown") rather than backfilled to a
guessed value.

Surface the flag in both UIs: the TUI runs table gains a MODE column
and the detail view a Shallow row; the desktop runs list and detail
panel gain a "shallow" / "full" badge with NULL rendered as a muted
dash. The agent scheduler's synthesised failed-index row records
shallow=true so the watermark matches the attempted mode.
Copilot AI review requested due to automatic review settings May 22, 2026 14:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR persists whether index/audit runs used the “shallow” (size/mtime shortcut) mode on the runs row and surfaces that mode in both the TUI and desktop UI so run history clearly distinguishes shallow vs full integrity passes.

Changes:

  • Schema v10: adds nullable runs.shallow with a CHECK constraint, and bumps schema version.
  • Store/index/scheduler: introduces BeginIndexRun(kind, volumeID, shallow) and routes index/audit run creation through it (including scheduler-synthesized failed index rows).
  • UIs: adds a Mode/MODE column plus shallow/full/unknown rendering for runs in both TUI and desktop pages.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tui/runs.go Adds MODE column and (conditional) Shallow detail rendering for runs in the TUI.
store/store_test.go Adds tests covering shallow persistence, NULL behavior for sync, and kind validation.
store/runs.go Adds Run.Shallow, adds BeginIndexRun, and extends run projections/scans to include shallow.
store/migrations.go Bumps schema to v10 and adds migration to append runs.shallow.
index/index.go Records Options.Shallow by using BeginIndexRun when starting runs.
index/index_test.go Adds test asserting index.Index persists shallow=true/false on the run row.
cmd/squirrel-desktop/app/templates/runs.templ Adds Mode column and shallow/full badge rendering to desktop runs list/detail.
cmd/squirrel-desktop/app/templates/runs_templ.go Regenerated templ output for the runs templates.
agent/scheduler.go Ensures scheduler-synthesized failed index rows also record shallow=true.
Files not reviewed (1)
  • cmd/squirrel-desktop/app/templates/runs_templ.go: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +150 to +152
if row.Run.Shallow.Valid {
<dt class="text-muted-foreground">Mode</dt><dd>@shallowBadge(row.Run.Shallow)</dd>
}
Comment thread tui/runs.go Outdated
Comment on lines +188 to +190
if r.Shallow.Valid {
lines = append(lines, [2]string{"Shallow", shallowLabel(r.Shallow.Bool)})
}
Comment thread store/runs.go
Comment on lines +88 to +99
// BeginIndexRun is BeginRun's sibling for kind='index' or kind='audit'
// rows that additionally records whether the walk ran in shallow mode
// (skip rehash when size/mtime match). Index and audit are the only run
// kinds where the shortcut applies; sync/restore go through BeginRun and
// leave runs.shallow NULL. The kind argument is validated to be one of
// the two index-shaped kinds so this entry point can't silently widen
// shallow's meaning later.
func (s *Store) BeginIndexRun(ctx context.Context, kind string, volumeID int64, shallow bool) (int64, error) {
if kind != RunKindIndex && kind != RunKindAudit {
return 0, fmt.Errorf("BeginIndexRun: kind must be %q or %q, got %q", RunKindIndex, RunKindAudit, kind)
}
res, err := s.db.ExecContext(ctx, `
Three Copilot review findings on #68:

- runs.templ and tui/runs.go skipped the Mode row when runs.shallow was
  NULL, so pre-v10 history and sync/restore runs dropped the field
  entirely. Render the row unconditionally and let the badge/label
  render the dash for the NULL case.
- BeginRun was a footgun for index/audit callers: it would insert a row
  with shallow=NULL, and the UIs would show "unknown" for a run that
  did know its mode. Validate the kind so the API rejects index/audit
  outright and directs callers to BeginIndexRun.

The BeginRun guard rippled into ~30 test sites that used it as a generic
"insert an index run" helper; those now route through BeginIndexRun
with shallow=false (the historical default). Adds tests for both the
new BeginRun rejection and the existing BeginIndexRun rejection of
sync/restore kinds.
@mbertschler mbertschler merged commit 55e167f into main May 22, 2026
2 checks passed
@mbertschler mbertschler deleted the claude/index-shallow-run-tracking-nK7DY branch May 22, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants