Skip to content

fix: skip orphan databases in EnsureAllMetadata to prevent metadata flip-flop#3293

Closed
dannomayernotabot wants to merge 2 commits intogastownhall:mainfrom
dannomayernotabot:polecat/metadata-flipflop
Closed

fix: skip orphan databases in EnsureAllMetadata to prevent metadata flip-flop#3293
dannomayernotabot wants to merge 2 commits intogastownhall:mainfrom
dannomayernotabot:polecat/metadata-flipflop

Conversation

@dannomayernotabot
Copy link
Copy Markdown
Contributor

Summary

  • When both an orphan database (e.g., "gastown") and its canonical counterpart ("gt") exist in Dolt, EnsureAllMetadata processes both and writes different dolt_database values to the same metadata.json, causing confusing "identity mismatch repair" warnings that flip-flop on every gt up.
  • Builds a reverse rig→canonical-DB map and skips databases that share a rig's directory name but aren't the rig's canonical database.
  • Includes test covering the exact scenario.

Test plan

  • TestEnsureAllMetadata_SkipsOrphanDatabases — new test passes
  • All existing TestEnsureAllMetadata* tests pass (5/5)
  • gt up no longer shows flip-flop warnings

🤖 Generated with Claude Code

@github-actions github-actions bot added the status/needs-triage Inbox — we haven't looked at it yet label Mar 26, 2026
@codecov-commenter
Copy link
Copy Markdown

❌ 5 Tests Failed:

Tests completed Failed Passed Skipped
9320 5 9315 48
View the top 3 failed test(s) by shortest run time
github.com/steveyegge/gastown/internal/cmd::TestBuildRefineryPatrolVars_FullConfig
Stack Traces | 0s run time
=== RUN   TestBuildRefineryPatrolVars_FullConfig
    patrol_helpers_test.go:166: expected 5 vars, got 7: [target_branch=main integration_branch_refinery_enabled=true integration_branch_auto_land=false run_tests=true delete_merged_branches=true judgment_enabled=false review_depth=standard]
--- FAIL: TestBuildRefineryPatrolVars_FullConfig (0.00s)
github.com/steveyegge/gastown/internal/cmd::TestRunHooksSyncNonClaudeAgent
Stack Traces | 0.01s run time
=== RUN   TestRunHooksSyncNonClaudeAgent
Syncing hooks...
  ✓ mayor/.claude/settings.json (created)
  ✓ deacon/.claude/settings.json (created)
  ✓ myrig/crew/.claude/settings.json (created)
warning: role_agents[crew]=opencode - agent "opencode" binary "opencode" not found in PATH, falling back to default

Synced 3 targets (3 created, 0 updated, 0 unchanged)
    hooks_sync_test.go:366: opencode plugin not created in worktree alice
--- FAIL: TestRunHooksSyncNonClaudeAgent (0.01s)
github.com/steveyegge/gastown/internal/doctor::TestHooksSyncCheck_Fix_TemplateAgent
Stack Traces | 0.01s run time
=== RUN   TestHooksSyncCheck_Fix_TemplateAgent
warning: role_agents[crew]=opencode - agent "opencode" binary "opencode" not found in PATH, falling back to default
    hooks_sync_check_test.go:219: expected StatusWarning before fix, got OK
--- FAIL: TestHooksSyncCheck_Fix_TemplateAgent (0.01s)
github.com/steveyegge/gastown/internal/doctor::TestHooksSyncCheck_TemplateAgent_Missing
Stack Traces | 0.01s run time
=== RUN   TestHooksSyncCheck_TemplateAgent_Missing
warning: role_agents[crew]=opencode - agent "opencode" binary "opencode" not found in PATH, falling back to default
    hooks_sync_check_test.go:193: expected StatusWarning for missing template agent file, got OK: All 3 hook targets in sync
--- FAIL: TestHooksSyncCheck_TemplateAgent_Missing (0.01s)
github.com/steveyegge/gastown/internal/doctor::TestHooksSyncCheck_TemplateAgent_OutOfSync
Stack Traces | 0.01s run time
=== RUN   TestHooksSyncCheck_TemplateAgent_OutOfSync
warning: role_agents[crew]=opencode - agent "opencode" binary "opencode" not found in PATH, falling back to default
    hooks_sync_check_test.go:172: expected StatusWarning for out-of-sync template agent, got OK: All 3 hook targets in sync
--- FAIL: TestHooksSyncCheck_TemplateAgent_OutOfSync (0.01s)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

dannomayernotabot and others added 2 commits March 26, 2026 01:24
… binaries

- Add nolint:unparam to writeTemplate for unused hooksDir parameter
- Update TestBuildRefineryPatrolVars_FullConfig to expect judgment_enabled
  and review_depth vars added to buildRefineryPatrolVars
- Add dummy opencode binary to PATH in TestRunHooksSyncNonClaudeAgent so
  agent resolution doesn't fall back to claude
- Add dummy agent binaries to scaffoldWorkspace in doctor tests so
  template agent sync checks can actually detect non-Claude agents

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…lip-flop

When both an orphan database (e.g., "gastown") and its canonical counterpart
("gt") exist in Dolt, EnsureAllMetadata would process both, writing different
dolt_database values to the same metadata.json. This caused confusing
"identity mismatch repair" warnings that flip-flopped on every startup.

Build a reverse rig→canonical-DB map and skip databases that share a rig's
directory name but aren't the rig's canonical database.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dannomayernotabot dannomayernotabot force-pushed the polecat/metadata-flipflop branch from 12c0b70 to 3ae35a8 Compare March 26, 2026 01:25
@steveyegge
Copy link
Copy Markdown
Collaborator

Superseded by #3287 (fixes the same EnsureAllMetadata oscillation with DB-to-rig grouping) which was merged.

@steveyegge steveyegge closed this Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/needs-triage Inbox — we haven't looked at it yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants