fix: address Copilot review round 15 on #2248

**Verification is a tri-state now, because two states could not be right.**
Round 12 was correct that `ok: true` for a manifest whose unread 513th file
may be tampered with is a false pass. Round 15 is correct that forcing `ok:
false` calls a server nonconformant for exceeding limits SEP-2640 states as
SHOULD NOT, with hosts free to support more — contradicting this module's own
rule that a warning never fails a report. Both hold, so:

  verified   -> exit 0   everything checked, everything passed
  failed     -> exit 7   a MUST was broken
  incomplete -> exit 8   nothing checked was wrong; the walk was cut short

`ok` keeps its narrow meaning, `allSkillsVerified` is stricter than
`every(r => r.ok)` since it selects the exit code, and `anySkillFailed`
separates 7 from 8. A job that tolerates oversized catalogs can allow 8 and
still fail on 7.

**`manifestKey` still used `JSON.stringify` on the entry** — the same crash I
fixed in the TUI in round 12, one file over.

**Directory children were navigable outside the skill root.** A server could
return `skill://other-skill/...` and clicking it left the tree, with "Up"
only comparing equality against the root. Containment is checked on the
normalized URI now, and an outside child renders as text rather than a link.
Worth recording from the tests: `..` cannot escape the authority, so
`skill://a/nested/../x.md` resolves back inside and must stay navigable.

**The TUI matched report rows by raw URI**, which missed a row recorded under
an equivalent spelling while `extraReportFiles` suppressed it as covered.
Normalized, like the membership test beside 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 22:47:32 -04:00
commit 89438d1a4b

View file

@ -33,6 +33,7 @@ import {
checkSkillNameCollisions,
bytesToText,
skillDisplayName,
skillEntryKey,
skillFileBytes,
skillEntriesMatch,
normalizeSkillUri,
@ -844,7 +845,12 @@ export function SkillsScreen({
// and a fresh object every render would loop.
const manifestKey = useMemo(
() =>
`${sessionKey}\n${selected ? JSON.stringify(selected) : (selectedSkillUri ?? "")}`,
// `skillEntryKey`, not `JSON.stringify`: `selected` carries unbounded
// server-controlled frontmatter, and this runs during render — so a
// deeply nested entry threw `RangeError` before the screen could show
// the `frontmatter-unparsable` finding that describes it (Copilot). Same
// helper, and the same guard, the TUI uses.
`${sessionKey}\n${selected ? skillEntryKey(selected) : (selectedSkillUri ?? "")}`,
[selected, selectedSkillUri, sessionKey],
);
@ -2181,6 +2187,22 @@ export function SkillsScreen({
{directoryChildren.map((child, index) => {
const isDir =
child.mimeType === DIRECTORY_MIME_TYPE;
// A server can return a child pointing
// anywhere. Descending into one leaves the
// selected skill's tree, and the "Up" control
// only compares against `skillRoot` — so the
// walk could then continue outside it entirely
// (Copilot). Containment is decided on the
// NORMALIZED URI, like every containment check
// in `core/mcp/skills.ts`, so a `..` segment
// cannot walk out while still matching as a
// prefix.
const childUri = normalizeSkillUri(child.uri);
const inRoot =
childUri !== undefined &&
skillRoot !== undefined &&
(childUri === skillRoot ||
childUri.startsWith(`${skillRoot}/`));
// A directory is not a manifest entry in the
// first place — a manifest lists files — so it
// is neither listed nor unlisted and gets no
@ -2195,31 +2217,43 @@ export function SkillsScreen({
// collapse into one.
<Table.Tr key={index}>
<Table.Td>
<ResourceUriButton
// A directory descends; a file opens in
// the viewer below. One column, two
// destinations, so the label says which
// for a reader who cannot see the MIME
// column at a glance.
aria-label={
isDir
? `Open directory ${child.uri}`
: `View ${child.uri}`
}
onClick={() =>
isDir
? readDirectory(
child.uri,
manifestKey,
)
: showResource(
child.uri,
manifestKey,
)
}
>
{isDir ? `${child.name}/` : child.name}
</ResourceUriButton>
{!inRoot ? (
// Shown, never navigable. The reader
// should see what the server sent, and
// a child outside the skill it was
// asked about is itself the finding.
<NoVerdictText>
{child.name} (outside this skill)
</NoVerdictText>
) : (
<ResourceUriButton
// A directory descends; a file opens in
// the viewer below. One column, two
// destinations, so the label says which
// for a reader who cannot see the MIME
// column at a glance.
aria-label={
isDir
? `Open directory ${child.uri}`
: `View ${child.uri}`
}
onClick={() =>
isDir
? readDirectory(
child.uri,
manifestKey,
)
: showResource(
child.uri,
manifestKey,
)
}
>
{isDir
? `${child.name}/`
: child.name}
</ResourceUriButton>
)}
</Table.Td>
<Table.Td>
<MonoCaption>{child.uri}</MonoCaption>