Skip to content

fix(sync): [AIC-4038] attach a tool or skill to a variation linked to code - #1049

Draft
nkester-ld wants to merge 12 commits into
mainfrom
TBD/nkester/attach-linked-variation
Draft

nkester-ld wants to merge 12 commits into
mainfrom
TBD/nkester/attach-linked-variation

Conversation

@nkester-ld

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

Copy link
Copy Markdown
Contributor

Human

The bug

ldcli sync prompts attach tool|skill only knew how to edit .prompt.md files. On a variation linked to code (a .ref.yaml), it failed with a raw filesystem error. The workaround, adding tools: to the descriptor by hand, replaced whatever tools LaunchDarkly already had, and the next plan claimed "the LaunchDarkly change is replaced" when nothing had changed in LaunchDarkly. This PR makes attach work on linked variations, keeps what LaunchDarkly already has, and plans the result as a plain push.

Failure and reason for change

  • What failed: stage tests SKL-3 and TL-5, 2026-11-25. attach skill and attach tool on a linked variation failed with inspect variation markdown-bot: lstat …/markdown-bot.prompt.md: no such file or directory. In TL-6, adding the list by hand dropped a tool that had been added in LaunchDarkly. In GAP-2, the push was labeled "the LaunchDarkly change is replaced".
  • Why this changes it: once a descriptor lists tools or skills, code owns that list, so the first list attach writes has to start from what LaunchDarkly has, or attaching one tool silently removes the others.

What changes

Before After
attach tool lookup --to <linked variation> lstat … .prompt.md: no such file or directory adds tools: to the .ref.yaml, pushes, pins the version
The descriptor had no tools: yet, LaunchDarkly has tool A — the list starts as A plus the new tool; A's file is written if the repo lacks it
Plan after the descriptor gains a list the repository owns it, the LaunchDarkly change is replaced tools changed

This folds in what was #1045 (closed), since that wording only shows up after this attach.

Review focus

  • Starting the list from LaunchDarkly's current attachments → descriptorAttachments in internal/sync/prompt/attach.go.
  • Telling a descriptor-only change from a LaunchDarkly change → baselineLacksRelationships in internal/sync/prompt/plan.go.
  • A hand-written tools: list still replaces LaunchDarkly's list on the next push. That's unchanged: code owns a list once it exists.

Testing

go test ./... and golangci-lint pass on current main. Retested locally on 2026-11-25: SKL-3, TL-5, TL-6 and GAP-2 pass.

Ticket: AIC-4038

🤖 Generated with Claude Code


Related Jira issue: AIC-4038: Fix medium sync bugs found in stage testing

nkester-ld and others added 12 commits November 19, 2026 15:40
A variation made by sync prompts link has only a .ref.yaml descriptor, so
attach failed reading the missing .prompt.md. Attach now adds the key to
the descriptor's top-level tools or skills list, keeping the rest of the
descriptor, and writes the attachment file in the same transaction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Attaching a key the descriptor already lists no longer re-renders the
list, and the attachment file's display path is repository-relative like
the descriptor's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lock baseline of a linked variation fingerprints a projection that
includes tools and skills only when the descriptor lists them. Adding a
list to the descriptor made LaunchDarkly's side look changed, so a
repository-only change planned as a conflict, or as a push that claimed
to replace a LaunchDarkly change. Compare LaunchDarkly's side against the
baseline without the newly listed fields too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the descriptor newly lists tools that LaunchDarkly already has, the
row was in sync and the lock kept the old baseline, so a later change
made only in LaunchDarkly was pushed over. Plan a lock update instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A link that rebinds a stale descriptor chooses the action again, which
dropped the lock update for a lifted baseline. Decide it in chooseAction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s a list

A linked descriptor without a tools or skills list leaves that list in
LaunchDarkly alone. The list that attach writes makes sync own it, so it
now starts with the keys the variation has in LaunchDarkly, and writes a
file for each one the repository has no file for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A seeded tool or skill that already has a local file is only listed in
the descriptor, a key LaunchDarkly lists twice is attached once, and a
variation that its config does not have seeds nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ew tool

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nked-variation

# Conflicts:
#	internal/sync/prompt/attach.go
…o TBD/nkester/attach-linked-variation

# Conflicts:
#	internal/sync/prompt/acceptance_test.go
@nkester-ld nkester-ld changed the title fix(sync): [TBD] attach a tool or skill to a variation linked to code fix(sync): [AIC-4038] attach a tool or skill to a variation linked to code Nov 25, 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