Skip to content

feat(sync): detach returns a variation to LaunchDarkly (AIC-3901, 4/5) - #1030

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

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

Conversation

@nkester-ld

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

Copy link
Copy Markdown

Human

Ensure that if we detach a variation, we make LD the SoT before removing it.

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
  4. feat(sync): detach returns a variation to LaunchDarkly (AIC-3901, 4/5) #1030 detach returns a variation to LaunchDarkly ← this PR
  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/detach/detach.go. Read returnToLaunchDarkly: it reads every project's ownership first, asks once if the settings API is unavailable, then writes an exact server_canonical rule per project before any file is removed. A forbidden or failed return stops before anything is deleted, and names the projects already returned. prompt/runner.go passes the settings client and error stream into detach.

Summary

  • Detach writes an exact server_canonical rule before removing files, so the variation returns to LaunchDarkly, can be edited in the UI, and isn't claimed again by a later push.
  • A missing updateSyncSettings permission names the action and resource and leaves everything in place.

Testing

go test ./... -count=1 passes, and lint reports 0 issues with parts 1–3 below. Key tests: detach/ownership_test.go TestRunReturnsADetachedVariationToLaunchDarklyBeforeTheDelete, and prompt/ownership_test.go TestDetachNamesTheMissingPermissionWhenReturningToLaunchDarklyIsForbidden.

Review findings not addressed (medium, test coverage only): detach's ownership read returning 403 or another error has no test, and neither does a prompt error after some projects were already returned (returnToLaunchDarkly, confirmWithoutOwnership).

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

🤖 Generated with Claude Code


Note

Overview
Detach now hands variation ownership back to LaunchDarkly before any local files or lock entries are removed, by writing server_canonical sync settings rules (one read pass per project, then one write per project). Tools and skills are unchanged—no ownership rules.

If sync settings are missing (404), detach warns on the error stream and prompts Detach anyway? unless --yes is set; multi-project runs resolve all projects before any write so a cancel leaves no partial rules. Forbidden or other API failures stop the operation without detaching and surface actionable permission errors (e.g. updateSyncSettings).

The prompt sync runner passes the API client as Settings plus ErrorOutput into detach. New unit and prompt integration tests cover ordering, multi-project edge cases, and permission failures.

Reviewed by Cursor Bugbot for commit 36d1b56. 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

@nkester-ld nkester-ld changed the title AIC-3901: syncing a variation from code makes it code-owned; detach returns it to LaunchDarkly feat(sync): syncing a variation from code makes it code-owned; detach returns it to LaunchDarkly (AIC-3901) Nov 16, 2026
@nkester-ld
nkester-ld force-pushed the AIC-3901/nkester/code-ownership branch from d3cb2c3 to e910801 Compare November 16, 2026 20:12
@nkester-ld nkester-ld changed the title feat(sync): syncing a variation from code makes it code-owned; detach returns it to LaunchDarkly (AIC-3901) feat(sync): the first pull makes a variation code-owned (AIC-3901, 4/5) Nov 16, 2026
@nkester-ld
nkester-ld changed the base branch from main to AIC-3901/nkester/code-ownership-3-first-pull November 16, 2026 20:12
@nkester-ld nkester-ld changed the title feat(sync): the first pull makes a variation code-owned (AIC-3901, 4/5) feat(sync): detach returns a variation to LaunchDarkly (AIC-3901, 4/5) Nov 16, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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 force-pushed the AIC-3901/nkester/code-ownership branch from e910801 to 36d1b56 Compare November 17, 2026 15:03
@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 davidbrackbill 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 36d1b56. Configure here.

Comment thread internal/sync/detach/detach.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