test(sf): lock continueWithDefault memory persistence contract

Two new tests covering the symmetric write shipped in 7a5b12540:

1. writeEscalationArtifact with continueWithDefault=true → memory
   created with "[escalation:T##]" prefix, "auto-applied default:"
   rationale marker, and Fail option label (the recommendation).
2. writeEscalationArtifact with continueWithDefault=false → NO memory
   at write time (pending entries defer persistence to resolveEscalation
   per existing behavior).

Together with the resolve-time tests in 3b5e6588e, all three
escalation flows (resolved, auto-accepted, default-applied) have
locked memory-persistence contracts. 23 → 25 tests in the file.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mikael Hugo 2026-05-02 23:47:08 +02:00
parent 7a5b125405
commit e2e708fc11

View file

@ -348,4 +348,49 @@ describe("claimOverrideForInjection (carry-forward)", () => {
"empty user rationale should fall back to recommendationRationale",
);
});
test("writeEscalationArtifact with continueWithDefault=true also persists a memory", async () => {
writeEscalationArtifact(
dir,
buildEscalationArtifact({
...baseArtifact,
continueWithDefault: true,
}),
);
const { getActiveMemories } = await import("../memory-store.ts");
const memories = getActiveMemories();
const escalationMemory = memories.find((m) =>
m.content.startsWith("[escalation:T01]"),
);
assert.ok(
escalationMemory,
"continueWithDefault=true should write a memory at artifact-write time",
);
assert.equal(escalationMemory!.category, "architecture");
// Recommendation was "fail" → memory should reference the Fail option label.
assert.match(escalationMemory!.content, /Fail/);
// Rationale prefix distinguishes auto-applied defaults from operator-
// resolved entries on a journal scan.
assert.match(escalationMemory!.content, /auto-applied default:/);
});
test("writeEscalationArtifact with continueWithDefault=false does NOT persist a memory at write time", async () => {
writeEscalationArtifact(
dir,
buildEscalationArtifact({
...baseArtifact,
continueWithDefault: false,
}),
);
const { getActiveMemories } = await import("../memory-store.ts");
const memories = getActiveMemories();
const escalationMemory = memories.find((m) =>
m.content.startsWith("[escalation:T01]"),
);
assert.equal(
escalationMemory,
undefined,
"pending escalations defer memory persistence to resolveEscalation",
);
});
});