Phase 12: recalculate pending on each compact — SPEC §16.6.
Every session_compact replans pendingReinject in defer mode; skipped reinject clears the queue unless manual compaction is waiting for the next user prompt. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { createCompactionRuntime } from "../src/compaction";
|
||||
import { applyPendingReinjectAfterCompact } from "../src/reinject";
|
||||
import { createInitialState } from "../src/state";
|
||||
|
||||
describe("applyPendingReinjectAfterCompact", () => {
|
||||
it("replaces pending with a new plan on each compact", () => {
|
||||
const runtime = createCompactionRuntime();
|
||||
const state = createInitialState();
|
||||
state.pendingReinject = ["alpha"];
|
||||
|
||||
applyPendingReinjectAfterCompact(state, runtime, true, ["beta", "gamma"]);
|
||||
|
||||
expect(state.pendingReinject).toEqual(["beta", "gamma"]);
|
||||
});
|
||||
|
||||
it("clears pending when reinject is skipped", () => {
|
||||
const runtime = createCompactionRuntime();
|
||||
const state = createInitialState();
|
||||
state.pendingReinject = ["alpha"];
|
||||
|
||||
applyPendingReinjectAfterCompact(state, runtime, false, ["beta"]);
|
||||
|
||||
expect(state.pendingReinject).toEqual([]);
|
||||
});
|
||||
|
||||
it("keeps stale pending when manual compaction scheduled a user-prompt clear", () => {
|
||||
const runtime = createCompactionRuntime();
|
||||
runtime.clearPendingReinjectOnNextUserInput = true;
|
||||
const state = createInitialState();
|
||||
state.pendingReinject = ["alpha"];
|
||||
|
||||
applyPendingReinjectAfterCompact(state, runtime, false, ["beta"]);
|
||||
|
||||
expect(state.pendingReinject).toEqual(["alpha"]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user