Skip to content

feat(sync): push, link and create make a variation code-owned (AIC-3901, 2/5) - #1033

Closed
nkester-ld wants to merge 2 commits into
AIC-3901/nkester/code-ownership-1-foundationfrom
AIC-3901/nkester/code-ownership-2-push
Closed

nkester-ld wants to merge 2 commits into
AIC-3901/nkester/code-ownership-1-foundationfrom
AIC-3901/nkester/code-ownership-2-push

Conversation

@nkester-ld

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

Copy link
Copy Markdown

Human

Take current variations that we're pushing/linking/syncing and attempt to make them code owned! Don't make them code owned if explicitly LD owned.

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 ← this PR
  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
  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

Start with internal/sync/prompt/state.go (applyVariationOwnership, enforceOwnership): it marks each planned variation to claim, skip or leave. Then sync.go (claimOwnership): claims are written before the plan writes anything. create.go claims a new variation before it's created. plan.go, output.go and review.go add the one-line skip message and the JSON notes.

Summary

  • Push, link and create write an exact code_canonical rule before writing content. A forbidden claim stops the run before anything is pushed.
    • A variation that already has an exact code rule isn't written again. One matched only by a wildcard gets pinned.
  • A variation with an explicit server_canonical rule is pulled but never claimed or pushed. Each one gets one line saying to switch it to Code in LaunchDarkly, and a notes entry in JSON output.
  • When the backend lock rejects a write, the error names syncAIConfigVariation on proj/<key>:env/*:aiconfig/<config>.

Testing

go test ./... -count=1 passes, and lint reports 0 issues on this branch with part 1 below it. Key tests in prompt/ownership_test.go: TestPushClaimsAVariationWithoutARuleBeforeWritingIt, TestLinkClaimsAVariationWithoutARule, TestPushSkipsAVariationManagedInLaunchDarkly, TestPullOfAVariationManagedInLaunchDarkly, TestPushStopsWhenTheClaimIsForbidden, TestPromptPushNamesSyncAIConfigVariationWhenTheVariationWriteIsForbidden; and prompt/create_test.go: TestCreateVariationClaimsItBeforeTheCreate.

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

🤖 Generated with Claude Code


Note

Overview
Push, link, and create now treat LaunchDarkly sync ownership rules as the source of truth for variations: planning resolves ownership via ResolveOwnership, marks rows to claim (code_canonical), skip push when LaunchDarkly-managed, or proceed when already code-owned.

Before any variation mutation, claimOwnership writes sync settings (ClaimForCode) per project; forbidden or non-404 read/write failures stop the run; missing settings warn and may still push after --yes. Create/link paths refresh ownership at review time so claims happen before variation POST/PATCH.

User-facing output adds managed-in-LaunchDarkly notes (plain text + JSON notes), ownership-unrecorded warnings, and clearer 403 messages naming updateSyncSettings vs syncAIConfigVariation. Watch mode no longer auto-applies when ownership cannot be recorded.

Tests extend the fake API for sync settings PATCH and add ownership_test.go plus acceptance/create coverage for claim ordering and skip behavior.

Reviewed by Cursor Bugbot for commit 679ee14. 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 and others added 2 commits November 17, 2026 07:55
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nkester-ld
nkester-ld force-pushed the AIC-3901/nkester/code-ownership-1-foundation branch from e93b237 to 4e53436 Compare November 17, 2026 15:03
@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 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 btesfamariam 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 2 potential issues.

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 679ee14. Configure here.

Comment thread internal/sync/prompt/state.go Resolved
Comment thread internal/sync/prompt/plan.go Resolved
@nkester-ld
nkester-ld force-pushed the AIC-3901/nkester/code-ownership-1-foundation branch from 4e53436 to 162272e Compare November 17, 2026 23:26
@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