Skip to content

fix(strategies): keep playbook tools up when a user id spans two type dirs - #89

Merged
sourcehawk merged 1 commit into
mainfrom
fix/strategies-loader-tolerates-duplicate-type-dirs
Sep 2, 2026
Merged

fix(strategies): keep playbook tools up when a user id spans two type dirs#89
sourcehawk merged 1 commit into
mainfrom
fix/strategies-loader-tolerates-duplicate-type-dirs

Conversation

@sourcehawk

Copy link
Copy Markdown
Owner

Description

An id with a copy under two type dirs in the user playbook vault made loadUserDir return an error, and that error failed the whole strategies MCP at startup, so every new session reported triagent-strategies as CONNECTION_CLOSED and lost all playbook tools. This PR keeps the copy in the first type dir (directory order is stable) and soft-skips the later one with a stderr warning naming both files, the same treatment the loader already gives invalid and legacy files. The stray copy stays on disk until the operator deletes it; the warning tells them which one.

Changes

  • loadUserDir soft-skips a second copy of an id under another type dir instead of failing the load.

Related

Testing

TestLoadPlaybooksFrom_IdInTwoTypeDirs builds a vault with investigation/dup.yaml, verification/dup.yaml and a neighbour, and asserts the load succeeds, the investigation copy wins, and the neighbour still loads. Reproduced the original failure by running the v0.4.0 triagent-mcp serve --kind=strategies with a real session's env against a vault in this state. make test-go and make lint pass.

🤖 Generated with Claude Code

…dirs

loadUserDir returned an error when one id had a copy under two type dirs, and that error failed the whole strategies MCP at startup. Every new session then reported the server as CONNECTION_CLOSED and lost all playbook tools. A vault in that state is what an approve from before WriteUserPlaybook refused the second slot leaves behind, so any operator who approved a cross-type revision on an older build was locked out until they hand-repaired the directory.

Keep the copy in the first type dir (directory order is stable) and soft-skip the later one with a stderr warning naming both files, matching how the loader already treats invalid or legacy files.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 2, 2026 11:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The change is narrowly scoped, preserves existing warning/soft-skip behavior patterns, and includes a focused regression test for the previously fatal startup condition.

Pull request overview

This PR hardens the strategies playbook loader so that a user playbook vault containing the same playbook id under two different type directories no longer causes the entire strategies MCP to fail at startup. Instead, the loader deterministically keeps the first copy encountered (directory order) and soft-skips later duplicates with a stderr warning, preserving tool availability for new sessions.

Changes:

  • Update loadUserDir to soft-skip duplicate IDs spanning multiple type dirs (warn + continue) rather than returning an error.
  • Add a regression test covering the duplicate-ID-across-type-dirs scenario to ensure load succeeds and selection is deterministic.
File summaries
File Description
pkg/mcp/strategies/playbook.go Changes duplicate-ID handling in loadUserDir to warn and continue instead of failing the loader.
pkg/mcp/strategies/playbook_test.go Adds a test ensuring an ID duplicated across two type dirs doesn’t break load and that the “first dir wins” behavior holds.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@sourcehawk
sourcehawk merged commit 3f93540 into main Sep 2, 2026
6 checks passed
@sourcehawk
sourcehawk deleted the fix/strategies-loader-tolerates-duplicate-type-dirs branch September 2, 2026 12:19
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