Phase 14: B-002 pre-fix RPC repro — filter snapshots and readSettings fix

RPC E2E with debug shows registered present at session_compact but planned=[]
because kept still contains the skill block; registered=[] still drops skills
absent from kept. Sync file readSettings avoids RPC hook deadlock on
SettingsManager/isProjectTrusted.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-17 15:21:53 +07:00
parent 8f48040eac
commit ef9b7a8c30
6 changed files with 333 additions and 11 deletions
+70
View File
@@ -0,0 +1,70 @@
import { describe, expect, it } from "vitest";
import { planReinject } from "../src/reinject.js";
import { createDefaultSettings } from "../src/settings.js";
import { createInitialState, trackSkill } from "../src/state.js";
describe("B-002 pre-fix filter hypothesis", () => {
it("planned empty when skill stays in kept window even if registered", () => {
const state = createInitialState();
trackSkill(state, {
name: "fup-blame-commits",
filePath: "/home/user/.cursor/skills/fup-blame-commits/SKILL.md",
baseDir: "/home/user/.cursor/skills/fup-blame-commits",
source: "slash",
});
const branch = [
{
id: "keep-1",
type: "message",
message: {
role: "user",
content:
'<skill name="fup-blame-commits" location="/path/SKILL.md">\nbody\n</skill>',
},
},
] as never;
const planned = planReinject(
state,
createDefaultSettings(),
{
sessionManager: { getBranch: () => branch },
} as never,
{ compactionEntry: { firstKeptEntryId: "keep-1" } } as never,
[{ name: "fup-blame-commits" }],
);
expect(planned).toEqual([]);
});
it("pre-fix: registered empty drops skill even when absent from kept (post-fix should reinject)", () => {
const state = createInitialState();
trackSkill(state, {
name: "fup-blame-commits",
filePath: "/home/user/.cursor/skills/fup-blame-commits/SKILL.md",
baseDir: "/home/user/.cursor/skills/fup-blame-commits",
source: "skill-block",
});
const branch = [
{
id: "keep-1",
type: "message",
message: { role: "user", content: "plain text after compact" },
},
] as never;
const planned = planReinject(
state,
createDefaultSettings(),
{
sessionManager: { getBranch: () => branch },
} as never,
{ compactionEntry: { firstKeptEntryId: "keep-1" } } as never,
[],
);
expect(planned).toEqual([]);
});
});
+5
View File
@@ -56,6 +56,7 @@ describe("notifyReinjectDiag", () => {
it("notifies with JSON snapshot when debug is on", () => {
const notify = vi.fn();
const stderrSpy = vi.spyOn(console, "error").mockImplementation(() => {});
const settings = { ...createDefaultSettings(), debug: true };
const snapshot = {
tracked: ["a"],
@@ -73,9 +74,13 @@ describe("notifyReinjectDiag", () => {
"before_agent_start",
snapshot,
);
expect(stderrSpy).toHaveBeenCalledWith(
`skill-reinject [before_agent_start]: ${JSON.stringify(snapshot)}`,
);
expect(notify).toHaveBeenCalledWith(
`skill-reinject [before_agent_start]: ${JSON.stringify(snapshot)}`,
"info",
);
stderrSpy.mockRestore();
});
});