Skip to content

feat(sync): the first pull makes a variation code-owned (AIC-3901, 3/5) - #1034

Closed
nkester-ld wants to merge 1 commit into
AIC-3901/nkester/code-ownership-2-pushfrom
AIC-3901/nkester/code-ownership-3-first-pull
Closed

nkester-ld wants to merge 1 commit into
AIC-3901/nkester/code-ownership-2-pushfrom
AIC-3901/nkester/code-ownership-3-first-pull

Conversation

@nkester-ld

@nkester-ld nkester-ld commented Nov 16, 2026 •

Copy link
Copy Markdown

Human

This covers ldcli sync prompts add, the first time a variation comes into the repo we make it code sot.

Stack (merge in order):

  1. feat(sync): skip variations that LaunchDarkly owns (AIC-3901) #1032 read and write variation ownership rules
  2. feat(sync): push, link and create make a variation code-owned (AIC-3901, 2/5) #1033 push, link and create make a variation code-owned
  3. feat(sync): the first pull makes a variation code-owned (AIC-3901, 3/5) #1034 the first pull makes a variation code-owned ← this PR
  4. feat(sync): detach returns a variation to LaunchDarkly (AIC-3901, 4/5) #1030 detach returns a variation to LaunchDarkly
  5. fix(sync): fail closed on unsafe keys and missing sync settings (AIC-3901, 5/5) #1035 fail closed on unsafe keys and missing sync settings

Why

AI Config sync is moving to two sources of truth: every variation is owned by exactly one side, LaunchDarkly (UI and API) or code (ldcli). Today ldcli never writes ownership rules, so a variation synced from code stays editable in LaunchDarkly unless someone switches it by hand, and the two copies drift. Syncing a variation from code should make it code-owned. Detaching it should hand it back to LaunchDarkly. A variation someone explicitly kept in LaunchDarkly should never be taken over by a push.

Reviewer Guide

All in internal/sync/bootstrap/bootstrap.go. Read claimNewVariations first: it reads the ownership of every project before claiming anything, then claims the new variations before the files and manifest are written. If a write fails after the claim, the error says the variations are already code-owned and that running add again is safe. prompt/runner.go passes the settings client, --yes and the error stream into bootstrap.

Summary

  • The first pull of a variation into the repo (add) writes an exact code_canonical rule.
  • Variations with an explicit server_canonical rule are pulled but not claimed.
  • When a run spans several projects, it reads them all before writing, and a failure names the projects already changed.

Testing

go test ./... -count=1 passes, and lint reports 0 issues with parts 1–2 below. Key tests in bootstrap/ownership_test.go: TestRunClaimsAVariationWithoutARuleBeforeWritingIt, TestRunPullsButDoesNotClaimAVariationManagedInLaunchDarkly, TestRunWritesNothingWhenTheClaimIsForbidden.

Review findings not addressed (medium, test coverage only): the first pull's ownership read returning 403 has no test (claimNewVariations).

Acceptance table, open questions and release notes: see part 1 (#1032).

🤖 Generated with Claude Code


Note

Overview
First-time add now records code ownership before writing local files. Bootstrap accepts a Settings client plus context, --yes, and a separate error stream so ownership warnings and confirmations don’t mix with normal output.

claimNewVariations runs after the dry-run gate and before Store.Add / manifest updates: it groups new (not-yet-locked) variations by project, reads ownership for every project first, then issues at most one ClaimForCode per project. Variations explicitly managed in LaunchDarkly are still pulled but skipped for claiming, with a notice on the error stream. Missing sync settings (404) trigger ConfirmWithoutSettings unless --yes; forbidden or failed claims abort with structured sync problems, and partial multi-project failures name projects already claimed. If claiming succeeds but a later step fails, errors note that code ownership was already recorded and re-running add is safe.

prompt/runner passes the API client and CLI flags into bootstrap. New ownership_test.go covers claim ordering, dry-run, terminal/404 flows, and adoption tests now assert a PATCH to /configs/sync/settings with code_canonical rules.

Reviewed by Cursor Bugbot for commit 61ede04. Bugbot is set up for automated code reviews on this repo. Configure here.


Related Jira issue: AIC-3901: [ldcli] Pushing, linking or first-pulling a variation makes it code-owned; detach returns it to LaunchDarkly

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nkester-ld
nkester-ld force-pushed the AIC-3901/nkester/code-ownership-2-push branch from d6879c4 to 679ee14 Compare November 17, 2026 15:03
@nkester-ld
nkester-ld force-pushed the AIC-3901/nkester/code-ownership-3-first-pull branch from a887e92 to 61ede04 Compare November 17, 2026 15:03
@nkester-ld
nkester-ld requested a review from ctawiah November 17, 2026 16:01
@nkester-ld
nkester-ld marked this pull request as ready for review November 17, 2026 16:14
@nkester-ld
nkester-ld requested a review from a team as a code owner November 17, 2026 16:14
@nkester-ld
nkester-ld requested review from wchieng and removed request for a team November 17, 2026 16:14

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 61ede04. Configure here.

Comment thread internal/sync/bootstrap/bootstrap.go Resolved
@nkester-ld

Copy link
Copy Markdown
Author

Folded into #1032. ldcli no longer writes ownership rules: LaunchDarkly treats a variation in a synced manifest as code-owned, so this part isn't needed. See the discussion on #1032.

@nkester-ld nkester-ld closed this Nov 17, 2026
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.

1 participant