[Feat] Self-heal stored repository default branches from the worker#636
Merged
Conversation
Contributor
|
No new code issues found. See task
Reviewed 0558f32 |
daniel-lxs
force-pushed
the
codex/report-resolved-default-branch
branch
3 times, most recently
from
July 20, 2026 22:16
fd88037 to
673693d
Compare
When an implicit-branch task resolves origin/HEAD to a branch that differs from the stored repository default, report it back through the SDK so stale metadata self-heals instead of persisting until a manual installation resync. Review follow-ups: refresh origin/HEAD before trusting the clone-time symbolic ref, target the update by repository row id, and authorize run tokens against the run's own workspace (selected repo, repo set, all-repositories, or environment mappings). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
daniel-lxs
force-pushed
the
codex/report-resolved-default-branch
branch
from
July 20, 2026 22:22
673693d to
0558f32
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changed
repositories.reportDefaultBranchSDK mutation that updates a stored repository row'sdefault_branch, targeted by repository row id and only when the value actually differs.origin/HEADto a branch that differs from the stored default, the worker reports the resolved branch back through the SDK. Fire-and-forget: it never blocks or fails repository preparation, and explicit branch selections never report.git remote set-head origin --autobefore trusting the clone-timeorigin/HEADsymbolic ref, so reused workspaces follow remote default-branch changes; on failure (offline, rate-limited) it falls back to the cached ref, which is still verified against remote-tracking refs.Why
Stored repository metadata can go stale (or be born wrong via the schema-level
default('main')) and nothing refreshes it outside a manual installation resync. The worker already computes the authoritative default branch fromorigin/HEADduring checkout resolution and then discards that knowledge. Reporting it back lets wrong rows self-heal organically for every provider, including self-hosted deployments where webhook delivery may be broken.Follow-up to #635; addresses the stale-
origin/HEADfinding from its review as well.Validation
pnpm exec dotenvx run -f .env.test -- pnpm --filter @roomote/worker exec vitest run src/workspace/__tests__ src/commands/setup/__tests__/workspace.test.ts(70 tests)pnpm exec dotenvx run -f .env.test -- pnpm --filter @roomote/sdk exec vitest run src/server/lib/repositories/__tests__/update-default-branch.test.ts(8 real-database tests: auth-token update, run-token workspace scoping across repo/set/all/environment shapes, cross-repo and terminal-run rejection, no-op match, unknown/inactive rows)pnpm --filter @roomote/worker check-types,pnpm --filter @roomote/sdk check-types,pnpm lint🤖 Generated with Claude Code