Skip to content

Commit 9fb5b50

Browse files
committed
fix(skills): add old-snapshot upgrade refresh test for missing skillKey
When a persisted session snapshot from before #94146 has skills[] entries without skillKey, resolveReusableWorkspaceSkillSnapshot must force a rebuild so the new snapshot carries skillKey for correct env-override lookup. Add the direct regression test ClawSweeper requested. Refs #94146
1 parent 2fe6abf commit 9fb5b50

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

‎src/skills/runtime/session-snapshot.test.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,35 @@ describe("resolveReusableWorkspaceSkillSnapshot", () => {
234234
>;
235235
expect(snapshotParams.snapshotVersion).toBe(0);
236236
});
237+
238+
it("refreshes persisted snapshots missing skills[].skillKey after #94146 upgrade", () => {
239+
// Simulate a pre-#94146 persisted snapshot whose skills array entries
240+
// have name but no skillKey. The resolver must detect the missing
241+
// fields and force a rebuild so the new snapshot carries skillKey for
242+
// env-override resolution.
243+
ensureSkillsWatcherMock.mockImplementation(() => undefined);
244+
getSkillsSnapshotVersionMock.mockReturnValue(1);
245+
shouldRefreshSnapshotForVersionMock.mockReturnValue(false);
246+
247+
const oldSnapshot: SkillSnapshot = {
248+
prompt: "skills prompt",
249+
// skillKey intentionally omitted — pre-#94146 serialized snapshot
250+
skills: [{ name: "old-skill", primaryEnv: "OLD_KEY" }],
251+
version: 1,
252+
promptFormatVersion: WORKSPACE_SKILLS_PROMPT_FORMAT_VERSION,
253+
};
254+
255+
const result = resolveReusableWorkspaceSkillSnapshot({
256+
workspaceDir: TEST_WORKSPACE_DIR,
257+
config: { skills: { entries: { "old-skill": { apiKey: "k" } } } }, // pragma: allowlist secret
258+
existingSnapshot: oldSnapshot,
259+
});
260+
261+
expect(result.shouldRefresh).toBe(true);
262+
expect(buildWorkspaceSkillSnapshotMock).toHaveBeenCalledTimes(1);
263+
const [[, snapshotParams]] = buildWorkspaceSkillSnapshotMock.mock.calls as unknown as Array<
264+
[string, { snapshotVersion?: number }]
265+
>;
266+
expect(snapshotParams.snapshotVersion).toBe(1);
267+
});
237268
});

0 commit comments

Comments
 (0)