fix(pipeline): a slug used in two places is refused even when one is the wing's own (#208)
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user