fix: address Copilot review round 16 on #2248
**A hole my own round-13 change opened.** The byte budget added a `break`, and `manifestListsSelf` described the bounded slice rather than the rows the walk reached — so breaking before a later self-entry left the flag true, suppressed the fallback, and skipped the mandatory frontmatter check entirely. It is `selfAttempted` now, set inside the loop, and marked before the read: a row the walk reached but could not read has still been attempted, and its failure belongs to the loop rather than to a second fetch. **A preview could overwrite a verification's own bytes.** The digest verdict on screen was computed from the verification's fetch; replacing only the text let the frontmatter findings describe different bytes, recreating the mixed-fetch verdict that state exists to prevent. `entryTextVerified` marks which read produced it, and a preview no longer wins over a verification. 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
89438d1a4b
commit
5a1f0efb5a
2 changed files with 141 additions and 23 deletions
|
|
@ -2529,6 +2529,50 @@ describe("SkillsScreen frontmatter cross-check (#2248)", () => {
|
|||
);
|
||||
});
|
||||
|
||||
it("does not let a later preview overwrite a verification's own bytes", async () => {
|
||||
// The digest verdict on screen was computed from the verification's fetch;
|
||||
// replacing only the text would let the frontmatter findings describe
|
||||
// different bytes, recreating the mixed-fetch verdict this state exists to
|
||||
// prevent (Copilot).
|
||||
const user = userEvent.setup();
|
||||
let served = skillMdFor({ ...CLEAN_FM, description: "As verified" });
|
||||
const onReadSkillFile = vi.fn(async (uri: string) => {
|
||||
if (uri === "skill://data-analysis/reference.md") {
|
||||
return { text: REF_TEXT };
|
||||
}
|
||||
return { text: served, mimeType: "text/markdown" };
|
||||
});
|
||||
renderWithMantine(
|
||||
<ControlledSkillsScreen onReadSkillFile={onReadSkillFile} />,
|
||||
);
|
||||
await user.click(screen.getByText("data-analysis"));
|
||||
await user.click(
|
||||
screen.getByRole("button", {
|
||||
name: "Verify skill://data-analysis/SKILL.md",
|
||||
}),
|
||||
);
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
within(screen.getByTestId("skill-frontmatter-issues")).getByText(
|
||||
/As verified/,
|
||||
),
|
||||
).toBeInTheDocument(),
|
||||
);
|
||||
|
||||
// The server changes, and the reader re-opens the file in the viewer. The
|
||||
// verification's text must survive, since its digest verdict still shows.
|
||||
served = skillMdFor({ ...CLEAN_FM, description: "Changed after" });
|
||||
await user.click(
|
||||
screen.getByRole("button", { name: "skill://data-analysis/SKILL.md" }),
|
||||
);
|
||||
await waitFor(() => expect(onReadSkillFile).toHaveBeenCalledTimes(3));
|
||||
expect(
|
||||
within(screen.getByTestId("skill-frontmatter-issues")).getByText(
|
||||
/As verified/,
|
||||
),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("keeps a frontmatter finding when the reader opens another file", async () => {
|
||||
// The check ran off whatever the viewer was showing, so opening a
|
||||
// supporting file made `showingSkillMd` false and silently dropped the
|
||||
|
|
|
|||
|
|
@ -105,6 +105,18 @@ interface VerificationState {
|
|||
* has not clicked Verify should still get the check.
|
||||
*/
|
||||
entryText?: string;
|
||||
/**
|
||||
* True when {@link entryText} came from a **verification** rather than the
|
||||
* preview read.
|
||||
*
|
||||
* A later preview of the same `SKILL.md` must not overwrite text a
|
||||
* verification produced: the digest verdict on screen was computed from that
|
||||
* fetch, and replacing only the text would let the frontmatter findings
|
||||
* describe different bytes — recreating the mixed-fetch verdict this state
|
||||
* exists to prevent (Copilot). A verification always wins, since it brings a
|
||||
* matching digest verdict with it.
|
||||
*/
|
||||
entryTextVerified?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -963,9 +975,12 @@ export function SkillsScreen({
|
|||
// anything not named here is dropped — which silently discarded the
|
||||
// verified `SKILL.md` text the frontmatter check depends on.
|
||||
...(entryText !== undefined
|
||||
? { entryText }
|
||||
? { entryText, entryTextVerified: true }
|
||||
: prev.key === key && prev.entryText !== undefined
|
||||
? { entryText: prev.entryText }
|
||||
? {
|
||||
entryText: prev.entryText,
|
||||
entryTextVerified: prev.entryTextVerified,
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
});
|
||||
|
|
@ -1076,16 +1091,19 @@ export function SkillsScreen({
|
|||
} catch {
|
||||
return; // neither text nor blob; the viewer reports it
|
||||
}
|
||||
setVerification((prev) =>
|
||||
prev.key !== null && prev.key !== key
|
||||
? prev
|
||||
: {
|
||||
...prev,
|
||||
key,
|
||||
files: prev.key === key ? prev.files : {},
|
||||
entryText: text,
|
||||
},
|
||||
);
|
||||
setVerification((prev) => {
|
||||
if (prev.key !== null && prev.key !== key) return prev;
|
||||
const sameKey = prev.key === key;
|
||||
// Never over a verification's own text — see
|
||||
// `entryTextVerified`.
|
||||
if (sameKey && prev.entryTextVerified) return prev;
|
||||
return {
|
||||
...prev,
|
||||
key,
|
||||
files: sameKey ? prev.files : {},
|
||||
entryText: text,
|
||||
};
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err: unknown) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue