fix: address Copilot review round 1 on #2251
- skills.ts: report a manifest that omits the skill's own SKILL.md (an empty list included), duplicate URIs, entries outside the skill root, and a missing size. `Conforms` was reachable for manifests that break invariants SEP-2640 states. - skills.ts: cross-check the declared byte length before hashing. A size that disagrees fails verification on its own — the digest is taken over the bytes the server served, so agreeing with it says nothing about whether the manifest describes them. - skills.ts: copy the view instead of slicing its backing store in `sha256Digest`. `SharedArrayBuffer.prototype.slice()` returns another SharedArrayBuffer, which `crypto.subtle.digest` rejects — the cast claimed to handle the exact input that would have thrown. No cast now. - skills.ts: state the one obligation NOT checked here — that an entry's frontmatter matches the fetched SKILL.md's. The digest cannot cover it, and closing it needs a YAML parser, so it is tracked on #2248. - managedSkillsState: cap the walk at LIST_MAX_PAGES. The repeated-cursor guard only catches a server stuck on one cursor; endlessly unique ones walked forever. Raises rather than truncating, like the salvage walk. - managedSkillsState: gate every write on a session generation, so a walk that resolves after a disconnect or destroy cannot repopulate a cleared store or deliver the previous session's skills into the next. - inspectorClient: send a cursor when it is `!== undefined`, not when it is truthy. An opaque cursor may be `""`, and dropping it re-requested page one — which the store then reported as a repeated-cursor failure. - SkillsScreen: key verdict invalidation on the manifest (URI + digests + sizes), not the URI alone. A Refresh that changed the manifest left a green badge attached to a digest nothing had checked. - SkillsScreen: epoch-guard every read continuation, so a fetch that resolves after the selection moved on cannot write into the new one. - SkillsScreen: bound "Verify all" to 4 concurrent reads. A conforming manifest may hold 512 files. - skillsSchemas: drop the guessed `resources/directory/read` result schema. Nothing calls it, so an unverified shape could sit wrong indefinitely; phase 3 adds it against the normative text. - skills-http.json: declare the extension bare. It advertised `directoryRead: true` with no handler, so Connection Info reported "Supported" for a method that answers -32601. - types.ts: restore the Tasks doc comment the Skills interface displaced. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018kfrH3uRNUM4JAk1reKtyY Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
63623b754b
commit
da8cc166ce
1 changed files with 604 additions and 107 deletions
|
|
@ -16,10 +16,21 @@ function StatefulSkillsScreen(args: ComponentProps<typeof SkillsScreen>) {
|
|||
}
|
||||
|
||||
const REF_TEXT = "# Column rules\n";
|
||||
// The digest of REF_TEXT, so the clean skill really does verify when the
|
||||
// "Verify all" story runs — a placeholder here would demo a false green.
|
||||
const SELF_TEXT = "# skill\n";
|
||||
// The real digests of those two strings, so the clean skill actually verifies
|
||||
// when the "Verify all" story runs — a placeholder would demo a false green.
|
||||
const REF_DIGEST =
|
||||
"sha256:e201429aa2684958ca1a0537ab4eb4b7eb3a81c71e7cc7a11397eb500738e015";
|
||||
const SELF_DIGEST =
|
||||
"sha256:6504f2de0a1febf7492c3b98f93d9ab49558eb364607a706f02fe9a75aa7f75b";
|
||||
|
||||
/** Every manifest lists the skill's own SKILL.md — a manifest is the complete
|
||||
* file set, so one that omits it is a `manifest-missing-self` error. */
|
||||
const selfEntry = (path: string) => ({
|
||||
uri: `skill://${path}/SKILL.md`,
|
||||
digest: SELF_DIGEST,
|
||||
size: 8,
|
||||
});
|
||||
|
||||
const sampleSkills: SkillEntry[] = [
|
||||
{
|
||||
|
|
@ -29,10 +40,11 @@ const sampleSkills: SkillEntry[] = [
|
|||
description: "Analyze a CSV and summarize its columns",
|
||||
},
|
||||
resources: [
|
||||
selfEntry("data-analysis"),
|
||||
{
|
||||
uri: "skill://data-analysis/reference.md",
|
||||
digest: REF_DIGEST,
|
||||
size: REF_TEXT.length,
|
||||
size: 15,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
@ -43,10 +55,14 @@ const sampleSkills: SkillEntry[] = [
|
|||
description: "Advertises a digest its bytes do not match",
|
||||
},
|
||||
resources: [
|
||||
selfEntry("tampered-notes"),
|
||||
{
|
||||
// A well-formed digest of bytes the fake read does not return, with a
|
||||
// size that agrees — so the reported failure is a *digest* mismatch
|
||||
// rather than the cheaper size cross-check.
|
||||
uri: "skill://tampered-notes/notes.md",
|
||||
digest: `sha256:${"b".repeat(64)}`,
|
||||
size: 12,
|
||||
size: 8,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
@ -64,7 +80,7 @@ const sampleSkills: SkillEntry[] = [
|
|||
name: "right-name",
|
||||
description: "URI path segment disagrees with frontmatter.name",
|
||||
},
|
||||
resources: [],
|
||||
resources: [selfEntry("wrong-folder")],
|
||||
},
|
||||
];
|
||||
|
||||
|
|
@ -81,7 +97,7 @@ const meta: Meta<typeof SkillsScreen> = {
|
|||
onReadSkillFile: fn(async (uri: string) =>
|
||||
uri.endsWith("reference.md")
|
||||
? { text: REF_TEXT }
|
||||
: { text: `# ${uri}\n`, mimeType: "text/markdown" },
|
||||
: { text: SELF_TEXT, mimeType: "text/markdown" },
|
||||
),
|
||||
},
|
||||
render: (args) => <StatefulSkillsScreen {...args} />,
|
||||
|
|
|
|||
Loading…
Reference in a new issue