fix(worktree): prevent stale-base worktree creation and dispatch#1390
Closed
fix(worktree): prevent stale-base worktree creation and dispatch#1390
Conversation
Addresses feedback #16 per DESIGN_DOC_STALE_BASE_FIX.md §0. Four v1 components coordinated by a single shared fetch cache on the runtime: 1. Concurrent-fetch-with-gate in UI create path: `createLocalWorktree` fires `git fetch` BEFORE the suffix loop / PR probe / path resolution, then awaits right before `addWorktree` so the new branch always spawns from a fresh remote tip. Renderer sees a two-phase spinner via the new `createWorktree:progress` IPC event. The cache is a `Map<repoPath::remote, Promise<void>>` + 30s success-only timestamp on `OrcaRuntimeService` (§7.1 — shared with dispatch). 2. Dispatch pre-flight drift guard in `Coordinator.dispatchTask`: probes `rev-list --left-right --count` against the target worktree and silently returns (preserves `ready`, no circuit-breaker burn) when `behind > 20` unless the task spec carries `allow-stale-base: true`. Parsing strips the flag so it never leaks into the worker's `--- TASK ---` block. 3. Preamble drift section: populated only when dispatch detected drift. Workers see `--- BASE DRIFT ---` with the N-most-recent subjects they don't have, so they can pull them in before running. 4. §3.3 Lifecycle: `.finally()` evicts Map entries on BOTH success and rejection; timestamp is written ONLY on success. Prevents a single DNS hiccup from wedging every future create on the repo until restart, and keeps the freshness window honest. Defers the DB `allow_stale_base` column (§0.2) and the create-time warn toast; both can layer in later without migration. Tests: 35 new/updated unit tests covering drift preamble, dispatch refusal, spec-text flag parsing, fetch Map eviction after rejection, freshness-window short-circuit, and concurrent-caller serialization. Co-authored-by: Orca <help@stably.ai>
15 tasks
Contributor
Author
|
Superseded by #1403, which bundles this PR with the other three orchestration improvement PRs and resolves the merge conflicts they shared. Branch preserved for diff comparison — not deleting. |
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.
Summary
ORCHESTRATOR_FEEDBACK.mditem 16awaitbeforeaddWorktree. Preserves the ~300ms warm-case perf win while guaranteeing fresh base in the cold casecreateWorktree:progressIPC events ('fetching' → 'creating') so 1-5s waits are legibleOrcaRuntimeService— renderer creates and dispatch drift probes share one cache.finally()eviction + success-only timestamp write prevents DNS hiccups from wedging future createsdispatchTaskpre-flight refusal: proberev-list --left-right --countvs tracking remote; silently skip dispatch (no circuit-breaker burn) when behind >DISPATCH_STALE_THRESHOLD(20) unless task spec text containsallow-stale-base: true--- BASE DRIFT ---section only whenbaseDrift.behind > 0(loud-but-rare)allow_stale_base(stored in task spec text v1)Test plan
pnpm typecheckclean