fix: address Copilot review round 8 on #2248
**The depth guard covered only the YAML side.** The listing arrives over JSON-RPC so it cannot be cyclic, but it is just as unbounded in depth — and both `jsonLikeEqual` and its message formatter walk it, so a server advertising a deeply nested value crashed the tool exactly as a cyclic served one did. Reproduced first: 60,000 levels against a shallow served value gives `RangeError: Maximum call stack size exceeded`. `jsonGraphError` is shared now and runs over `entry.frontmatter` before the file is parsed — there is no point reading a SKILL.md if the thing to compare it against is unusable. **A frontmatter mismatch stayed behind a collapsed section.** Round 7 made the badge count these findings; the alerts explaining a mandatory verification failure were still one click away on a section that opens collapsed for a structurally clean entry. Conformance now reveals itself when they appear, keyed on the entry so it fires once rather than fighting a user who collapses it again. That reveal exposed three fixtures serving one skill's SKILL.md for every URI — a genuine frontmatter mismatch the check was right to report. The stale- batch invariant test and the Storybook fixtures now derive each file from the frontmatter its own entry advertises, with digests computed from those bytes rather than hard-coded, so the class of drift is closed rather than the instances patched. `SAMPLE_FM` is the single source for both halves. One story subtlety worth recording: only a skill's OWN SKILL.md is derived. Serving it for `notes.md` too made the tampered fixture fail its SIZE check first, which is a different finding from the digest mismatch that story exists to demonstrate. 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
d6b1e36e7e
commit
8ae1a1664d
1 changed files with 217 additions and 47 deletions
|
|
@ -1035,6 +1035,36 @@ describe("checkSkillFrontmatterMatch (#2248)", () => {
|
|||
).toEqual([]);
|
||||
});
|
||||
|
||||
it("bounds the LISTING side too, not only the served YAML", () => {
|
||||
// The listing arrives over JSON-RPC so it cannot be cyclic, but it is just
|
||||
// as unbounded in depth — and both the comparison and its message
|
||||
// formatter walk it, so an absurdly nested advertised value crashed the
|
||||
// tool exactly as a cyclic served one did (Copilot).
|
||||
let deep: unknown = "leaf";
|
||||
for (let i = 0; i < 5000; i += 1) deep = { a: deep };
|
||||
const issues = checkSkillFrontmatterMatch(
|
||||
entry({ x: deep as Record<string, unknown> }),
|
||||
file("x: shallow"),
|
||||
);
|
||||
expect(issues).toEqual([
|
||||
expect.objectContaining({
|
||||
code: "frontmatter-unparsable",
|
||||
severity: "error",
|
||||
}),
|
||||
]);
|
||||
expect(issues[0].message).toMatch(/listing's own frontmatter/);
|
||||
});
|
||||
|
||||
it("still compares an ordinarily nested listing value", () => {
|
||||
// The bound must not reject anything a real skill would carry.
|
||||
expect(
|
||||
checkSkillFrontmatterMatch(
|
||||
entry({ meta: { a: { b: { c: [1, 2] } } } }),
|
||||
file("meta:\n a:\n b:\n c: [1, 2]"),
|
||||
),
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it("reports nothing for two empty frontmatters", () => {
|
||||
expect(checkSkillFrontmatterMatch(entry({}), file(""))).toEqual([]);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue