Skip to content

fix(sync): fail closed on unsafe keys and missing sync settings (AIC-3901, 5/5) - #1035

Closed
nkester-ld wants to merge 3 commits into
AIC-3901/nkester/code-ownershipfrom
AIC-3901/nkester/code-ownership-5-fail-closed
Closed

nkester-ld wants to merge 3 commits into
AIC-3901/nkester/code-ownershipfrom
AIC-3901/nkester/code-ownership-5-fail-closed

Conversation

@nkester-ld

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

Copy link
Copy Markdown

Human

General bug fixes we found for the process:

  • wildcards are rejected for variations
  • missing ownership entry rejected
  • allow for reading ownership for more than 100 variations
  • if you push across several projects and it fails part way, we say which projects were already claimed

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

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

Two small fixes. Each test failed before the fix.

  1. internal/sync/api/settings_write.go: a key becomes part of a rule pattern, so a key that isn't a LaunchDarkly key (for example * in a manifest committed to the repo) would write a wildcard rule that claims many variations. The writer now rejects the whole batch, naming the bad key, before sending anything. IsLaunchDarklyKey in internal/sync/resource.go reuses the existing create-key pattern.
  2. prompt/state.go, bootstrap/bootstrap.go and detach/detach.go: when the settings API answers but leaves a requested variation out (or answers with "unsupported resource kind"), the empty default counted as "no rule", so the variation was claimed and pushed. Now it fails closed with "LaunchDarkly returned no sync setting" before anything is claimed or written. A 404 (the API is unavailable) keeps its warn-and-ask behavior.

prompt/conflict_test.go: its fake answered the settings read with an empty page, so four conflict tests passed only through the fail-open path. The fake now returns a setting for each resource it's asked about.

Summary

  • Rule writes reject keys that aren't LaunchDarkly keys, so a key in a repo file can't write a wildcard rule.
  • Push, first pull and detach fail closed when LaunchDarkly returns no setting for a variation.

Testing

go test ./... -count=1 passes, and lint reports 0 issues with parts 1–4 below. New tests: TestSetSyncDirectionRejectsAKeyThatIsNotALaunchDarklyKey, TestPushFailsClosedWhenTheSyncSettingIsMissing, and TestRunFailsClosedWhenTheSyncSettingIsMissing in bootstrap and in detach.

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

🤖 Generated with Claude Code


Note

Overview
Hardens sync ownership reads/writes and tightens when push, link, bootstrap, and detach are allowed to claim or return variations.

Rule writes now validate project/config/variation keys with IsLaunchDarklyKey before any PATCH, so manifest keys like * cannot create wildcard ownership rules; the whole batch aborts with a named bad key.

Ownership reads drop the hard 100-ID cap on ResolveOwnership and page requests per kind instead. Missing settings are treated as errors (ErrorSyncSettingUnavailable) when the API succeeds but omits a requested variation—bootstrap, detach, and prompt sync stop before claims or writes (404/unavailable still warn-and-continue where unchanged). New creates with nothing in LaunchDarkly yet remain exempt.

Push/link claims code ownership on link even when only the manifest changes (ActionUpdateManifest). Multi-project pushes report which projects were already claimed if a later claim fails (pushConsequence).

Reviewed by Cursor Bugbot for commit 79d2733. 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 fix(sync): detach returns a variation to LaunchDarkly (AIC-3901, 5/5) fix(sync): fail closed on unsafe keys and missing sync settings (AIC-3901, 5/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 branch from e910801 to 36d1b56 Compare November 17, 2026 15:03
@nkester-ld
nkester-ld force-pushed the AIC-3901/nkester/code-ownership-5-fail-closed branch from 69d0924 to ad62052 Compare November 17, 2026 15:03
…imed

The sync settings client read at most 100 resources per call, so a first
pull or a detach of more than 100 variations in one project failed before
doing anything. The client now reads any number, one page at a time, and
push drops its own batching.

A push across projects is not atomic. When a later project's claim fails,
the error now names the projects already recorded as code-owned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nkester-ld nkester-ld self-assigned this Nov 17, 2026
@nkester-ld
nkester-ld marked this pull request as ready for review November 17, 2026 16:13
@nkester-ld
nkester-ld requested a review from a team as a code owner November 17, 2026 16:13
@nkester-ld
nkester-ld requested review from tiffanylphan and removed request for a team November 17, 2026 16:13
A link of a variation whose content already matched LaunchDarkly only
updated the manifest, so it skipped the claim and the variation stayed
unowned. A linked row now claims on that path too. A plain sync that
adopts matching state still claims on its next push.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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