Repository navigation
feat(sync): skip variations that LaunchDarkly owns (AIC-3901) - #1032
nkester-ld wants to merge 3 commits into
Conversation
e93b237 to
4e53436
Compare
There was a problem hiding this comment.
I think we can avoid having the ldcli write to the sync settings API entirely, since the sync settings can be inferred automatically.
For example, the sync settings API can determine whether a variation is code canonical or server canonical by checking whether the resource belongs to a synced manifest. Since only code-synced resources can be part of a manifest, the presence of the resource in a synced manifest tells us it's code canonical.
This allows sync to continue working as it does today without requiring ldcli to explicitly update the sync settings API.
This is also better from a permissions standpoint. The sync settings API requires specific permissions, and we shouldn't need to grant those permissions to every API token, especially since engineers will typically be the ones running sync commands.
With this, ldcli never needs to write to the sync settings API. Gonfalon can automatically determine and resolve the appropriate sync settings internally, keeping the CLI simpler and avoiding additional permission requirements.
There was a problem hiding this comment.
This does simplify things quite a bit. I will update the stack and lyk when it's ready.
There was a problem hiding this comment.
commented on the ticket what we removed from the ticket's responsibilities 👍
Read each variation's ownership together with the rule that produced it. A variation with an explicit server_canonical rule is pulled and never pushed, with a note that says how to move it to code. A variation without a rule may push: the server_canonical default does not make it pull, and gonfalon records code as the owner once the variation is in a synced manifest, so ldcli writes no sync settings and needs no updateSyncSettings permission. Also: read sync settings 100 at a time, fail closed when the settings read leaves out a variation, and name syncAIConfigVariation when the server rejects a variation write with 403. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A 403 with code managed_in_code comes from the sync lock, not a missing permission, so it reports LaunchDarkly's message instead of asking for syncAIConfigVariation. A create that an explicit LaunchDarkly rule turns into an error no longer gets the "pulled, not pushed" note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A row that later planning turns into a conflict no longer says "pulled, not pushed". A lock rejection now names the variation it is about and uses ldcli's own message, since the client always rewrites LaunchDarkly's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4e53436 to
162272e
Compare
Human
LaunchDarkly works out ownership from the synced manifest, so ldcli doesn't write ownership rules. It only reads them, so that it never pushes over a variation someone kept in LaunchDarkly.
tldr of changes:
Why
LaunchDarkly now treats a variation in a synced manifest as owned by code, unless someone has set it to LaunchDarkly in the UI. ldcli still reads the setting literally. A variation with no rule reads as "LaunchDarkly", so a linked variation gets pulled when it should be pushed. A variation someone deliberately kept in LaunchDarkly still gets pushed.
Related: launchdarkly/gonfalon#75851 (the server lock) · AIC-3901
Open questions
LD-Sync-Source? Until one of these happens, pushes to code-owned variations fail while the lock is on, now with a clear "managed in code" error.What changes
Before, for a variation set to LaunchDarkly in the UI:
After:
updateSyncSettingspermission.--output jsoncarries the same message undernotes. A row that ends up as an error or conflict gets no note.syncAIConfigVariationaction. If the lock rejected it, the error says the variation is managed in code instead.Review focus
enforceOwnershipinprompt/state.gorequireNoSettingsWriteinprompt/ownership_test.goTesting
go test ./...passes, andgolangci-lintreports 0 issues. The skip and linked-push tests fail when the old literal handling is put back. All five acceptance criteria are covered on the ldcli side; three of them also need gonfalon#75851 to land. A staging check with the lock on is still to do.Requirements
Note
Overview
ldcli now reads sync ownership from LaunchDarkly (direction plus matched rule pattern) and uses that to decide whether variations can be pushed, without writing any ownership rules itself.
Variations with an explicit LaunchDarkly rule are treated as server-canonical: planned pushes become pulls/skips, and users see a note (stderr /
--output jsonnotes) explaining the variation is managed in LaunchDarkly. Variations without a matching rule still push and pull as before—the defaultserver_canonicaldirection alone does not block push.The settings client gains
ResolveOwnership, batches requests beyond 100 resources, andSyncDirectionsis implemented on top of it. 403 variation writes are classified:managed_in_codebecomesvariation_managed_in_code; other forbidden responses name the missingsyncAIConfigVariationpermission. Sync fails closed when settings are missing or unreadable (except 404, which preserves legacy behavior).Reviewed by Cursor Bugbot for commit 162272e. 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