Skip to content

fix(link-daintree): correct family-gate fallback in fan-out import#153

Merged
jobordu merged 1 commit intomainfrom
fix/link-daintree-family-gate-v2
May 3, 2026
Merged

fix(link-daintree): correct family-gate fallback in fan-out import#153
jobordu merged 1 commit intomainfrom
fix/link-daintree-family-gate-v2

Conversation

@jobordu
Copy link
Copy Markdown

@jobordu jobordu commented May 3, 2026

Summary

  • Fix fan-out import logic in /nf:link-daintree where presets were silently skipped because findVanilla() returned [] when the inferred family didn't match any vanilla slot's provider field
  • When family match exists → use it; when it doesn't → fall back to all candidates (not an empty array)

Test plan

  • Run /nf:link-daintree with a Daintree config that has presets for an agent whose vanilla slots have provider=claude (not anthropic) — confirm presets are imported, not skipped
  • Re-run /nf:link-daintree — confirm idempotency (existing preset-linked slots updated in place, no duplicates)

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes - Version 0.43.1

  • Bug Fixes
    • Fixed fallback logic that could silently drop presets when certain provider matching conditions weren't met. Presets are now properly retained and processed using an improved fallback mechanism.

When inferring a family from preset env (e.g. ANTHROPIC_* → "anthropic"),
the findVanilla() pool construction erroneously returned [] instead of all
candidates when no vanilla slot matched the inferred family.

Fix: change pool construction from:
  familyMatch.length ? familyMatch : (family ? [] : candidates)
to:
  familyMatch.length ? familyMatch : candidates

The family gate is still respected when matches exist; when it doesn't,
we correctly fall back to all candidates sorted by daintree_preset_id
then numeric suffix.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 3, 2026 08:35
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 3, 2026

Walkthrough

Documentation updates for a bug fix in the link-daintree fan-out fallback logic, where the family gate is now bypassed when no vanilla provider matches the inferred family, allowing fallback to all candidates sorted by daintree_preset_id and numeric suffix instead of silently dropping presets.

Changes

Link-Daintree Fan-Out Fallback Fix Documentation

Layer / File(s) Summary
Release Notes
CHANGELOG.md
Version 0.43.1 entry added documenting the fix: fan-out fallback no longer silently drops presets when no vanilla provider matches the inferred provider field; family gate is bypassed with fallback to sorted candidates.
Command Documentation
commands/nf/link-daintree.md
findVanilla() behavior updated to reflect that when familyMatch is empty, all candidates are used as the fallback pool instead of an empty pool, making family inference non-blocking during preset-linked slot creation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the main issue and solution but lacks coverage of required template sections like Windows testing, GSD style compliance, and agent-skill workflow consideration. Complete the template sections: check testing platforms (macOS, Windows, Linux), confirm GSD style compliance, verify Windows path handling, and document relevant agent-skill workflows.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing family-gate fallback logic in the fan-out import for link-daintree.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/link-daintree-family-gate-v2

Review rate limit: 9/10 reviews remaining, refill in 6 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes /nf:link-daintree fan-out import behavior so Daintree presets are not silently skipped when the inferred provider “family” doesn’t match any vanilla slot provider.

Changes:

  • Update findVanilla() fallback logic to use all vanilla candidates when no family match exists (instead of an empty pool).
  • Add a changelog entry for version 0.43.1 documenting the fix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
commands/nf/link-daintree.md Fixes the vanilla-slot selection fallback so family mismatch no longer prevents preset import.
CHANGELOG.md Documents the patch release and describes the link-daintree fan-out fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CHANGELOG.md
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
commands/nf/link-daintree.md (1)

482-496: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Ensure findVanilla() really searches “vanilla slots” (exclude preset-linked clones).

Right now findVanilla() defines candidates as all providers with mainTool === agentName, which includes preset-linked clones (daintree_preset_id set). The new fallback (pool = familyMatch.length ? familyMatch : candidates) means that if there are no true vanilla providers for that mainTool, pool[0] can come back as a clone. Then the “add” path will clone that provider and append — Daintree preset: ..., which can compound descriptions and use clone env/model as the base.

To align with the stated objective (“fall back to all candidate vanilla slots”), filter candidates to only those without daintree_preset_id:

🔧 Proposed change
function findVanilla(agentName, family) {
-  const candidates = providersData.providers.filter(p => p.mainTool === agentName);
-  const familyMatch = family ? candidates.filter(p => p.provider === family) : candidates;
-  const pool = familyMatch.length ? familyMatch : candidates;
-  // Prefer provider without daintree_preset_id, then lowest numeric suffix
+  const candidates = providersData.providers.filter(
+    p => p.mainTool === agentName && !p.daintree_preset_id
+  );
+  const familyMatch = family ? candidates.filter(p => p.provider === family) : candidates;
+  const pool = familyMatch.length ? familyMatch : candidates;
+  // Prefer the lowest numeric suffix (all in this pool are true vanilla slots)
   pool.sort((a, b) => {
-    const aIsClone = !!a.daintree_preset_id;
-    const bIsClone = !!b.daintree_preset_id;
-    if (aIsClone !== bIsClone) return aIsClone ? 1 : -1;
     const an = parseInt((a.name.match(/-(\d+)$/) || [])[1] || '0', 10);
     const bn = parseInt((b.name.match(/-(\d+)$/) || [])[1] || '0', 10);
     return an - bn;
   });
   return pool[0] || null;
}

This keeps your family-mismatch fallback behavior, while preventing clone-as-base edge cases.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@commands/nf/link-daintree.md` around lines 482 - 496, The function
findVanilla currently builds candidates from providersData.providers using
mainTool === agentName but does not exclude providers that have
daintree_preset_id, so the fallback can pick preset-linked clones; modify
findVanilla to filter candidates to only providers without daintree_preset_id
(i.e., exclude entries where daintree_preset_id is truthy) before applying the
family filter/sorting, preserving the existing familyMatch and pool fallback
logic and leaving the sort/return behavior unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@commands/nf/link-daintree.md`:
- Around line 482-496: The function findVanilla currently builds candidates from
providersData.providers using mainTool === agentName but does not exclude
providers that have daintree_preset_id, so the fallback can pick preset-linked
clones; modify findVanilla to filter candidates to only providers without
daintree_preset_id (i.e., exclude entries where daintree_preset_id is truthy)
before applying the family filter/sorting, preserving the existing familyMatch
and pool fallback logic and leaving the sort/return behavior unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0b23e4d3-9b8b-4923-9e0c-8ca91df3e938

📥 Commits

Reviewing files that changed from the base of the PR and between 35d1118 and 8e21ef3.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • commands/nf/link-daintree.md

@jobordu jobordu merged commit 0d36204 into main May 3, 2026
25 checks passed
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.

2 participants