fix: address Copilot review round 4 on #2248
Eight findings. Two were visible in a terminal capture I had already taken
and read past.
**A digest mismatch rendered with no digests.** `verifySkillResource` sets
`reason` for a SIZE mismatch — which short-circuits before hashing — while a
digest mismatch carries `expectedDigest` / `actualDigest` and no `reason`, so
the TUI printed a bare `✗ notes.md` with nothing to act on. `failureDetail`
now falls back to the expected/actual pair, truncated to fit the pane.
**A dynamic skill's read failure rendered nowhere.** Its synthetic
`read-error` row lives in the report, not the manifest, and the manifest is
empty for such a skill by definition — so the pane said only "Verification
FAILED". There is a Read failures block for any report file the manifest does
not cover, matched on normalized identity.
**The non-finite sentinel could be aliased.** A listing whose value genuinely
was `{"#non-finite":"NaN"}` canonicalized identically to a served `.nan`, so
the round-3 fix moved the bug rather than closing it. Any encoding into the
value space can be aliased by a document containing the encoding, so the
comparison is structural now (`jsonLikeEqual`) and there is no sentinel at
all; `Object.is` gives NaN === NaN while keeping ±Infinity distinct.
Serialization is used only for the message.
**`parseSkillFrontmatter("null")` returned `{ fields: {} }`,** contradicting
its own non-mapping contract: an explicit null scalar parses to exactly what
an empty block does. They are told apart by the source, since the parsed
value cannot.
Also: the `files` doc comment still claimed it is empty for a dynamic skill,
which the round-2 fix made untrue; and three inline Mantine elements with two
static styling props each are extracted to `.withProps()` constants, per the
convention the rest of the file follows.
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:
parent
6b83727332
commit
799763543f
2 changed files with 313 additions and 33 deletions
|
|
@ -670,6 +670,88 @@ describe("SkillsTab (#2248)", () => {
|
|||
expect(lastFrame() ?? "").toContain("skill://acme/reports/SKILL.md");
|
||||
});
|
||||
|
||||
it("shows the digests for a mismatch, not just the failed mark", async () => {
|
||||
// `verifySkillResource` sets `reason` for a SIZE mismatch but not a digest
|
||||
// one, so a pane rendering only `reason` left a bare `✗` with no diagnosis
|
||||
// — a failed verification the reader cannot act on (Copilot).
|
||||
// The declared size must be RIGHT, or the cheaper size cross-check
|
||||
// short-circuits before hashing and reports its own `reason` instead —
|
||||
// which is the path that already rendered.
|
||||
const digestOnly: SkillEntry = {
|
||||
...clean,
|
||||
resources: [
|
||||
{
|
||||
uri: "skill://clean/SKILL.md",
|
||||
digest: CLEAN_DIGEST,
|
||||
size: textToBytes(SKILL_MD).byteLength,
|
||||
},
|
||||
],
|
||||
};
|
||||
const { lastFrame, stdin } = render(
|
||||
<SkillsTab
|
||||
skills={[digestOnly]}
|
||||
pageCount={1}
|
||||
inspectorClient={mockClient()}
|
||||
width={160}
|
||||
height={30}
|
||||
focusedPane="list"
|
||||
/>,
|
||||
);
|
||||
stdin.write(ENTER);
|
||||
await tick();
|
||||
const frame = lastFrame() ?? "";
|
||||
expect(frame).toContain("Verification FAILED");
|
||||
// Truncated to keep the line inside a narrow pane; the CLI report carries
|
||||
// the digests in full.
|
||||
expect(frame).toMatch(/expected sha256:0+…/);
|
||||
expect(frame).toMatch(/got sha256:[0-9a-f]+…/);
|
||||
});
|
||||
|
||||
it("shows the reason for a size mismatch, which carries no digest", async () => {
|
||||
// The other arm: a length disagreement fails before the hash, so there is
|
||||
// no actual digest to print and the reason is the whole diagnosis.
|
||||
const { lastFrame, stdin } = render(
|
||||
<SkillsTab
|
||||
skills={[clean]}
|
||||
pageCount={1}
|
||||
inspectorClient={mockClient()}
|
||||
width={160}
|
||||
height={30}
|
||||
focusedPane="list"
|
||||
/>,
|
||||
);
|
||||
stdin.write(ENTER);
|
||||
await tick();
|
||||
expect(lastFrame() ?? "").toContain(
|
||||
"Manifest declares 51 bytes but the fetched file is 52.",
|
||||
);
|
||||
});
|
||||
|
||||
it("shows a read failure the manifest does not cover", async () => {
|
||||
// A dynamic skill has no manifest rows, so the synthetic read-error row
|
||||
// `verifySkills` records for its own SKILL.md was rendered nowhere and the
|
||||
// pane said only "Verification FAILED".
|
||||
const { lastFrame, stdin } = render(
|
||||
<SkillsTab
|
||||
skills={[dynamic]}
|
||||
pageCount={1}
|
||||
inspectorClient={mockClient(
|
||||
vi.fn().mockRejectedValue(new Error("upstream gone")),
|
||||
)}
|
||||
width={160}
|
||||
height={30}
|
||||
focusedPane="list"
|
||||
/>,
|
||||
);
|
||||
stdin.write(ENTER);
|
||||
await tick();
|
||||
const frame = lastFrame() ?? "";
|
||||
expect(frame).toContain("Read failures:");
|
||||
expect(frame).toContain("SKILL.md");
|
||||
expect(frame).toContain("upstream gone");
|
||||
expect(frame).toContain("Verification FAILED");
|
||||
});
|
||||
|
||||
it("shows the details footer only when the details pane is focused", () => {
|
||||
const unfocused = render(
|
||||
<SkillsTab
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import {
|
|||
} from "@inspector/core/mcp/skillsSchemas.js";
|
||||
import {
|
||||
verifySkills,
|
||||
type SkillFileReport,
|
||||
type SkillVerifyReport,
|
||||
} from "@inspector/core/mcp/skillsVerification.js";
|
||||
import { useSelectableList } from "../hooks/useSelectableList.js";
|
||||
|
|
@ -98,6 +99,23 @@ function entryKey(entry: SkillEntry): string {
|
|||
return JSON.stringify(entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* The explanation printed under a failed file row.
|
||||
*
|
||||
* `verifySkillResource` sets `reason` for a SIZE mismatch but not for a digest
|
||||
* one — that carries `expectedDigest` / `actualDigest` instead — so a pane that
|
||||
* rendered only `reason` showed a bare `✗ notes.md` and never said why, leaving
|
||||
* the failure unactionable (Copilot). Digests are truncated because the pane is
|
||||
* 40-odd columns wide and the first bytes are enough to see that two differ;
|
||||
* the CLI report carries them in full.
|
||||
*/
|
||||
function failureDetail(file: SkillFileReport): string | undefined {
|
||||
if (file.reason) return file.reason;
|
||||
if (file.status !== "mismatch") return undefined;
|
||||
const short = (d: string | undefined) => (d ? `${d.slice(0, 23)}…` : "—");
|
||||
return `expected ${short(file.expectedDigest)}, got ${short(file.actualDigest)}`;
|
||||
}
|
||||
|
||||
/** The file name a manifest URI ends in, for a list that must fit 40 columns. */
|
||||
function fileNameOf(uri: string): string {
|
||||
const cut = uri.lastIndexOf("/");
|
||||
|
|
@ -254,6 +272,14 @@ export function SkillsTab({
|
|||
selectedSkill && selectedSkill.resources !== DYNAMIC_RESOURCES
|
||||
? selectedSkill.resources
|
||||
: [];
|
||||
// Compared on normalized identity, like every other URI comparison here, so a
|
||||
// manifest entry written in an equivalent form is not reported twice.
|
||||
const manifestIdentities = new Set(
|
||||
manifest.map((resource) => skillUriIdentity(resource.uri)),
|
||||
);
|
||||
const extraReportFiles = (activeReport?.files ?? []).filter(
|
||||
(file) => !manifestIdentities.has(skillUriIdentity(file.uri)),
|
||||
);
|
||||
|
||||
return (
|
||||
<Box flexDirection="row" width={width} height={height}>
|
||||
|
|
@ -410,15 +436,48 @@ export function SkillsTab({
|
|||
<Text dimColor> ({resource.size} B)</Text>
|
||||
) : null}
|
||||
</Text>
|
||||
{fileReport?.reason && (
|
||||
{fileReport && failureDetail(fileReport) && (
|
||||
<Box paddingLeft={4} flexShrink={0}>
|
||||
<Text color="red">{fileReport.reason}</Text>
|
||||
<Text color="red">{failureDetail(fileReport)}</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* A report can carry a file the MANIFEST does not — a dynamic
|
||||
skill has no rows at all, yet a failed read of its own
|
||||
SKILL.md is recorded so the failure is visible. Rendering only
|
||||
manifest rows left "Verification FAILED" with no diagnosis
|
||||
anywhere on screen (Copilot). */}
|
||||
{extraReportFiles.length > 0 && (
|
||||
<>
|
||||
<Box marginTop={1} flexShrink={0}>
|
||||
<Text bold>Read failures:</Text>
|
||||
</Box>
|
||||
{extraReportFiles.map((file, idx) => (
|
||||
<Box
|
||||
key={`extra-${idx}`}
|
||||
paddingLeft={2}
|
||||
flexShrink={0}
|
||||
flexDirection="column"
|
||||
>
|
||||
<Text>
|
||||
<Text color={FILE_COLOR[file.status] ?? "white"}>
|
||||
{FILE_MARK[file.status] ?? "?"}{" "}
|
||||
</Text>
|
||||
{fileNameOf(file.uri)}
|
||||
</Text>
|
||||
{failureDetail(file) && (
|
||||
<Box paddingLeft={4} flexShrink={0}>
|
||||
<Text color="red">{failureDetail(file)}</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
|
||||
{activeReport && activeReport.frontmatter.length > 0 && (
|
||||
<>
|
||||
<Box marginTop={1} flexShrink={0}>
|
||||
|
|
|
|||
Loading…
Reference in a new issue