Skip to content

fix(EnsureAllMetadata): prevent ping-pong when two databases map to same rig#3221

Closed
baumgold wants to merge 9 commits intogastownhall:mainfrom
baumgold:polecat/gt-cn4-fix
Closed

fix(EnsureAllMetadata): prevent ping-pong when two databases map to same rig#3221
baumgold wants to merge 9 commits intogastownhall:mainfrom
baumgold:polecat/gt-cn4-fix

Conversation

@baumgold
Copy link
Copy Markdown
Contributor

@baumgold baumgold commented Mar 24, 2026

Fixes ping-pong when two Dolt databases map to the same rig (e.g. 'gastown' and 'gt' both mapping to gastown rig). When multiple databases resolve to the same rig, prefer the one metadata.json already points to. Eliminates Warning: metadata.json dolt_database was "X", correcting to "Y" spam during gt up.

Fixes #3222

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 24, 2026

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
9320 3 9317 48
View the top 3 failed test(s) by shortest run time
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.

furiosa added 2 commits March 24, 2026 13:14
…ame rig (gt-cn4)

When a rig has two Dolt databases (e.g., 'gastown' and 'gt' both mapping to
the gastown rig via routes.jsonl), EnsureAllMetadata previously called
EnsureMetadata for each database independently. Each call overwrote the
other's dolt_database value, producing alternating correcting warnings in
'gt up' output.

Fix: group databases by rig before processing. For rigs with multiple
databases, read the rig's existing metadata.json — if it already points to
one of the valid databases, keep it (stable, no rewrite). Only when no
stable value exists fall back to the lexicographically first candidate for
determinism. Each rig is now processed exactly once.

Add TestEnsureAllMetadata_NoPingPong regression test covering the two-DB
scenario for the same rig.
@baumgold baumgold force-pushed the polecat/gt-cn4-fix branch from ababea9 to 67c374d Compare March 24, 2026 13:15
furiosa and others added 7 commits March 24, 2026 14:54
…ent_enabled and review_depth vars (gt-lch)
…resolved (gt-lch)

When the configured agent binary (e.g. opencode) is not in PATH,
ResolveRoleAgentConfig falls back to claude and the plugin files are
never created. Switch to ResolveRoleAgentName (no binary validation)
so hooks are installed based on the configured agent regardless of
whether the binary is currently available on the machine.
… (gt-n8f)

TestStampLoop_SelfStampFails and TestStampLoop_InvalidValence both call
t.Parallel() while mutating shared wlStamp* package-level vars, causing
data races detected by -race. Remove the t.Parallel() calls; these tests
are sequential by nature given the save/restore pattern.
ResolveRoleAgentConfig falls back to 'claude' when the agent binary is
not found in PATH (e.g., opencode in CI), causing the doctor to skip
non-Claude template agent targets and falsely report all targets in sync.

Use ResolveRoleAgentName instead to get the configured agent name
regardless of whether its binary is installed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…(gt-xwr)

CanForceRemove() now returns true for CleanupUnpushed. Previously --force
only allowed uncommitted changes but still blocked on unpushed commits,
making it impossible to remove a polecat whose branch was synced with
its own tracking branch but whose repo contained other polecats' branches
with unpushed work.

GitHub: #3238

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e (gt-1at)

Windows paths contain backslashes which are invalid in JSON strings without
escaping. When {{GT_BIN}} was substituted into JSON templates, it produced
invalid JSON on Windows, causing TemplateContentEqual to fail to unmarshal
the content and incorrectly return false (triggering SyncUpdated instead
of SyncUnchanged).

Fix: escape backslashes before substitution.

Fixes TestSyncForRole_JSONWhitespaceInsensitive on Windows.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@baumgold
Copy link
Copy Markdown
Contributor Author

@baumgold baumgold closed this Mar 24, 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.

bug: EnsureAllMetadata ping-pong when two Dolt databases map to same rig

2 participants