fix(pipeline): a slug used in two places is refused even when one is the wing's own (#208)
CI / Lint / Test / Vet (pull_request) Successful in 1m8s
CI / Mirror to GitHub (pull_request) Skipped

FindSlug returned the first hit, so a wing's own page of a name masked another
page of the same name (the retired dirs are searched before the wings, and wings
alphabetically). FindSlugs returns every match and callers refuse any that is
not their own. Found by the legacy-move planner's own test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 20:22:20 +02:00
co-authored by Claude Sonnet 5.5
parent 3ccf6b46ac
commit 8e488b6e4b
4 changed files with 65 additions and 39 deletions
+11 -4
View File
@@ -53,11 +53,18 @@ func Run(ctx context.Context, cfg Config, brainDir, content, source string, dryR
var err error
if cfg.Wing != "" {
// A source slug is a page's graph identity: refuse to take over a slug
// that lives anywhere but this wing's own sources/.
if existing, found, ferr := wiki.FindSlug(brainDir, wiki.Slug(source)); ferr != nil {
// that lives anywhere but this wing's own sources/ — including when
// this wing's own page of that name also exists.
slug := wiki.Slug(source)
own := "wiki/" + cfg.Wing + "/sources/" + slug + ".md"
existing, ferr := wiki.FindSlugs(brainDir, slug)
if ferr != nil {
return Result{}, fmt.Errorf("check source slug: %w", ferr)
} else if own := "wiki/" + cfg.Wing + "/sources/" + wiki.Slug(source) + ".md"; found && existing != own {
return Result{}, fmt.Errorf("source slug %q is already used by %s", wiki.Slug(source), existing)
}
for _, p := range existing {
if p != own {
return Result{}, fmt.Errorf("source slug %q is already used by %s", slug, p)
}
}
inventory, err = wiki.LoadWingInventory(brainDir, cfg.Wing)
} else {