fix: keep orchestrator respawn stable across prefix changes#135
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes orchestrator respawn instability caused by deriving the orchestrator’s canonical branch name from the mutable sessionPrefix. It decouples orchestrator branch identity from display/workspace prefixes, so a sessionPrefix change won’t strand a live orchestrator or break replacement/respawn flows.
Changes:
- Derive orchestrator default branch naming from a stable project-ID-derived prefix, while keeping
sessionPrefixfor user-facing/session/workspace naming. - Make orchestrator replacement verification non-fatal by emitting a structured telemetry warning instead of failing the respawn.
- Remove the prior
SESSION_PREFIX_LOCKEDguard path and the related store/service probe (HasActiveOrchestrator), plus associated tests.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| backend/internal/storage/sqlite/store/store_test.go | Removes tests for HasActiveOrchestrator after the feature is deleted. |
| backend/internal/storage/sqlite/store/session_store.go | Removes HasActiveOrchestrator EXISTS probe from the sqlite store. |
| backend/internal/session_manager/manager.go | Uses a stable prefix for orchestrator branch naming while keeping display prefix behavior for workspaces. |
| backend/internal/session_manager/manager_test.go | Adds coverage to ensure orchestrator branch ignores display sessionPrefix. |
| backend/internal/service/session/service.go | Makes replacement verification non-fatal and emits telemetry warnings; updates expected branch derivation. |
| backend/internal/service/session/service_test.go | Updates/adds tests for stable orchestrator branch behavior and non-fatal verification warnings. |
| backend/internal/service/project/service.go | Removes SESSION_PREFIX_LOCKED enforcement; switches default prefix derivation to shared helper. |
| backend/internal/service/project/service_test.go | Removes lock-related tests; keeps coverage for sessionPrefix updates and other config edits. |
| backend/internal/domain/project.go | Introduces DefaultProjectPrefix / DefaultProjectPrefixLength as the shared prefix derivation helper. |
| backend/internal/adapters/workspace/gitworktree/workspace.go | Uses domain.DefaultProjectPrefix when no explicit sessionPrefix is provided. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| sess, err := s.Spawn(ctx, ports.SpawnConfig{ProjectID: projectID, Kind: domain.KindOrchestrator}) | ||
| if err != nil { | ||
| return domain.Session{}, err | ||
| } | ||
| if err := verifyOrchestratorReplacement(project, sess); err != nil { | ||
| return domain.Session{}, err | ||
| s.emitOrchestratorReplacementVerificationFailed(project, sess, err) | ||
| } |
86cf03c to
bca51ea
Compare
|
INDEPENDENT RE-REVIEW — PR #135, cycle 2 Fixed finding verified: the unrelated sqlite regression test TestCreateSessionRejectsSecondLiveOrchestratorForProject is restored, while the obsolete HasActiveOrchestrator prefix-lock coverage remains removed. Claude left only low notes about an abnormal stale-worktree edge and documenting one-time branch migration; neither is a medium+ merge blocker. Local backend gate passed after the fix: go build ./..., go vet ./..., go test ./.... GitHub CI is green on this head. Active review threads: none. |
Summary
sessionPrefix, so changing that config could make respawn expect a different infra branch than the live orchestrator worktree used.sessionPrefixas the display/workspace prefix for user-facing names.ORCHESTRATOR_REPLACEMENT_VERIFICATION_FAILEDand remediation instead of blocking respawn.SESSION_PREFIX_LOCKEDconfig guard and its active-orchestrator store probe.Closes #113
Test plan
go test ./internal/service/session ./internal/session_manager ./internal/service/project ./internal/storage/sqlite/store -count=1go build ./... && go vet ./... && go test ./...frombackend/Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.