Skip to content

feat(ci): reuse lane across PR commits + adopt-on-conflict for concurrent runs#10388

Open
davidfirst wants to merge 3 commits into
masterfrom
ci-pr-reuse-lane-and-rebase-on-conflict
Open

feat(ci): reuse lane across PR commits + adopt-on-conflict for concurrent runs#10388
davidfirst wants to merge 3 commits into
masterfrom
ci-pr-reuse-lane-and-rebase-on-conflict

Conversation

@davidfirst
Copy link
Copy Markdown
Member

`bit ci pr` now reuses the existing remote lane on subsequent commits to the same PR rather than deleting and recreating it. This preserves lane history, lane-based cloud UI edits, and prevents archived-lane pileup. When two CI runners race the first push, the loser adopts the winner's lane and rebases its snapped Version parents onto the remote heads — preserving both runners' snaps chained on the lane and avoiding a costly re-snap with `--build`.

Changes

  • snapPrCommit (`scopes/git/ci/ci.main.runtime.ts`): switch to existing lane if remote has it, then merge main into the lane to bring forward config-only changes (deps/env set) that aren't git-tracked. Otherwise create fresh fork from main.
  • adopt-on-conflict: catch the "different hash" error during export, fetch the remote lane, rewrite snapped Versions' parents to point at the remote heads (in-place — Bit Versions aren't content-addressed), swap the local lane for the remote one, re-export.
  • scope-index LaneId uniqueness: new `validateLaneIdUniqueness` check, invoked before `writeObjectsToTheFS` writes files — surfaces the concurrent-push conflict early and leaves no stale objects on the remote.
  • export persist cleanup: `pushToRemotesCarefully` now removes pending dirs when persist fails, so a retry isn't blocked behind a dead client in the queue.

Test plan

  • `bit ci pr workflow` — baseline still passes.
  • `bit ci pr reuses the existing remote lane across subsequent PR commits` — sequential commits stay on one lane.
  • `bit ci pr merges main into the lane on subsequent runs (config-change propagation)` — `bit deps set` on main flows onto the lane via `bit lane merge main`.
  • `bit ci pr with concurrent runners on the same PR branch` — two cloned workspaces race; loser detects conflict, rebases, retries; both snaps end up chained on a single lane.
  • All 48 ci-commands e2e tests pass.
  • Lint clean.

…rent runs

bit ci pr now reuses the existing remote lane on subsequent commits to the
same PR, preserving lane history and any cloud-side edits. When two CI
runners race the first push, the loser fetches the winner's lane, rebases
its snapped Version parents onto the remote heads, and re-exports.

- snapPrCommit: switch-to-existing-lane + merge-main-into-lane (brings forward
  config-only changes like deps/env set that landed on main during the PR).
- writeObjectsToTheFS: validate LaneId uniqueness before writing files so a
  rejected concurrent push leaves no stale objects on the remote.
- export.pushToRemotesCarefully: clean up pending dirs on persist failure
  so a retry isn't blocked by the export queue.
Copilot AI review requested due to automatic review settings May 21, 2026 14:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the bit ci pr flow to preserve and reuse a PR’s remote lane across subsequent commits, and adds a conflict-recovery path for concurrent CI exports so racing runners can converge on a single remote lane without forcing a costly re-snap/build.

Changes:

  • Reuse existing remote PR lanes (instead of delete/recreate) and merge main into the PR lane to propagate non-git-tracked config changes.
  • Add “adopt-on-conflict” recovery for concurrent lane export hash mismatches by rebasing local snapped Version parents onto the remote lane heads and retrying export.
  • Add early LaneId uniqueness validation before writing objects to disk, and improve export pending-dir cleanup on persist failures.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
scopes/scope/objects/objects/scope-index.ts Adds a pre-write LaneId uniqueness validator and strengthens lane indexing against same-id/different-hash races.
scopes/scope/objects/objects/repository.ts Reloads scope-index and runs LaneId uniqueness validation before persisting lane-related objects.
scopes/scope/export/export.main.runtime.ts Ensures pending dirs are cleaned up when persistRemotes() fails to avoid stuck export queues.
scopes/git/ci/ci.main.runtime.ts Reuses remote lanes across PR commits, merges main into PR lanes, and implements adopt-on-conflict export recovery for concurrent runs.
e2e/harmony/ci-commands.e2e.ts Adds/updates E2E coverage for lane reuse, main→lane config propagation, and concurrent CI runner behavior.

Comment thread scopes/scope/objects/objects/scope-index.ts
Comment thread scopes/scope/export/export.main.runtime.ts Outdated
Comment thread scopes/git/ci/ci.main.runtime.ts
- scope-index: validateLaneIdUniqueness and addOne now also reject the
  rename case where the target LaneId already belongs to a different
  lane (different hash).
- export: wrap pending-dir cleanup in try/catch so a cleanup failure
  logs a warning instead of masking the original persist error.
- ci: add TODO documenting the older-runner-wins regression case for
  the adopt-on-conflict rebase.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants