feat: report a skill-name collision across the listing (#2248)

SEP-2640: hosts MUST NOT assume name uniqueness, and when two entries in one
listing collide on `name` a host MUST disambiguate them rather than silently
discarding or preferring one.

`checkSkillConformance` structurally cannot see this — it takes one entry and
a collision is a property of the pair — so `checkSkillNameCollisions` walks
the listing and returns a finding per colliding entry, each naming the
others. All three clients merge it into the entry's own findings, so it
carries through the header badge, the CLI report and the TUI row marks with
no new surface.

**It is a `warning`, not an `error`,** and that is the severity split doing
its job. The obligation is on the *consumer*: a server may legitimately
publish two skills with the same name under different paths, and the SEP's
own `acme/billing/refunds` example is exactly that shape. Calling it an error
would tell a conforming author their catalog is invalid. `--verify` therefore
still exits 0 for a collision.

In the web screen it renders as a banner directly under the Conformance
header and is filtered out of the findings list, the same treatment
`dynamic-resources` gets: it changes how everything below it should be read,
and stating one fact twice reads as two findings.

Fixed while adding it: an entry whose only finding was a banner one rendered
an EMPTY findings container instead of "no structural issues", because the
list's presence was decided on the unfiltered set while its contents were
filtered. `listedIssues` is now derived once and used for both.

The fixture gains `acme/reports` + `globex/reports`, both fully conforming
and sharing the name `reports` — also the only fixture with a multi-segment
skill path, which nothing else exercised. Eight skills over four pages now,
and the integration test walks the cursor to exhaustion rather than asserting
a fixed page count, so a future fixture does not require editing it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ND46Ci64DC3tzBy9aG81Nc
Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
cliffhall 2026-09-07 19:02:18 -04:00
commit 4fa00d1cfd

View file

@ -115,6 +115,36 @@ const MISMATCHED_SKILL: SkillEntry = {
resources: [await selfEntry("skill://wrong-folder/SKILL.md", MISMATCHED_FM)],
};
// Two skills sharing a name, and otherwise **fully conforming** — SEP-2640
// requires only that the segment before /SKILL.md equal `frontmatter.name`,
// which multi-segment paths satisfy while still sharing a final segment. Their
// manifests list their own SKILL.md and their served files are derived from
// their frontmatter, so the collision is genuinely their ONLY finding; a
// fixture with an incidental `manifest-missing-self` would make the tests below
// pass for the wrong reason.
const ACME_REPORTS_FM: Frontmatter = {
name: "reports",
description: "Build the weekly report from the acme ledger",
};
const GLOBEX_REPORTS_FM: Frontmatter = {
name: "reports",
description: "Build the weekly report from the globex ledger",
};
const ACME: SkillEntry = {
uri: "skill://acme/reports/SKILL.md",
frontmatter: ACME_REPORTS_FM,
resources: [
await selfEntry("skill://acme/reports/SKILL.md", ACME_REPORTS_FM),
],
};
const GLOBEX: SkillEntry = {
uri: "skill://globex/reports/SKILL.md",
frontmatter: GLOBEX_REPORTS_FM,
resources: [
await selfEntry("skill://globex/reports/SKILL.md", GLOBEX_REPORTS_FM),
],
};
const ALL_SKILLS = [
CLEAN_SKILL,
TAMPERED_SKILL,
@ -2184,6 +2214,87 @@ describe("SkillsScreen directory browsing (#2248)", () => {
});
});
describe("SkillsScreen name collisions (#2248)", () => {
it("reports the collision on both entries, each naming the other", async () => {
const user = userEvent.setup();
renderWithMantine(<ControlledSkillsScreen skills={[ACME, GLOBEX]} />);
await user.click(screen.getByText(ACME.uri));
// Stated as a banner at the top of Conformance, not as a bare code in the
// findings list — it changes how everything under it should be read.
const banner = screen.getByTestId("skill-name-collision");
expect(banner).toHaveTextContent("skill://globex/reports/SKILL.md");
expect(banner).not.toHaveTextContent("skill://acme/reports/SKILL.md");
// …and it is NOT also repeated in the list, which would read as two
// findings for one fact.
expect(screen.queryByTestId("skill-issues")).not.toBeInTheDocument();
});
it("states it on the other entry too, naming the first", async () => {
const user = userEvent.setup();
renderWithMantine(<ControlledSkillsScreen skills={[ACME, GLOBEX]} />);
await user.click(screen.getByText(GLOBEX.uri));
expect(screen.getByTestId("skill-name-collision")).toHaveTextContent(
"skill://acme/reports/SKILL.md",
);
});
it("counts it as a warning, not an error", async () => {
// The server did nothing wrong — the obligation is on the consumer — so an
// error badge would tell a conforming author their catalog is invalid.
const user = userEvent.setup();
renderWithMantine(<ControlledSkillsScreen skills={[ACME, GLOBEX]} />);
await user.click(screen.getByText(ACME.uri));
// The count carries through the header badge like every other finding, and
// the badge is yellow — green would read as "nothing to see" for something
// meant to be noticed, red would call a conforming server broken.
const control = screen.getByRole("button", { name: /Conformance/ });
expect(control).toHaveTextContent("0 error(s), 1 warning(s)");
const style = badgeStyle(/warning\(s\)/);
expect(style).toContain("yellow");
expect(style).not.toContain("red");
});
it("opens Conformance for a skill whose only finding is the collision", async () => {
// Selected before mount, so this exercises `initialOpenSections` rather
// than the `useValueChange` path — the entry is otherwise clean, so
// `checkSkillConformance` alone would have collapsed the section while the
// badge said there was something to see.
renderWithMantine(
<SkillsScreen
{...baseProps}
skills={[ACME, GLOBEX]}
ui={{ ...EMPTY_SKILLS_UI, selectedSkillUri: ACME.uri }}
/>,
);
expect(screen.getByRole("button", { name: /Conformance/ })).toHaveAttribute(
"aria-expanded",
"true",
);
});
it("computes collisions over the whole catalog, not the filtered view", async () => {
// A finding that disappeared because the sidebar search excluded the other
// half would depend on what the reader typed.
const user = userEvent.setup();
renderWithMantine(
<ControlledSkillsScreen
skills={[ACME, GLOBEX]}
ui={{ ...EMPTY_SKILLS_UI, search: "acme" }}
/>,
);
await user.click(screen.getByText(ACME.uri));
expect(screen.getByTestId("skill-name-collision")).toBeInTheDocument();
});
it("says nothing when the names are distinct", async () => {
const user = userEvent.setup();
renderWithMantine(<ControlledSkillsScreen />);
await user.click(screen.getByText("data-analysis"));
await user.click(screen.getByRole("button", { name: /Conformance/ }));
expect(screen.getByText("No structural issues")).toBeInTheDocument();
});
});
describe("SkillsScreen frontmatter cross-check (#2248)", () => {
it("reports a listing whose frontmatter disagrees with the served SKILL.md", async () => {
// The violation no digest can catch — the digest is over the bytes served