Compare commits

...
Author SHA1 Message Date
Gabriel De Andrade aadd5f0327 fix(server): tombstone deletion of missing threads
- Make thread deletion idempotent for stale client entries
- Add coverage for emitting a deletion tombstone when the thread is missing
2026-07-30 21:49:09 -04:00
2 changed files with 30 additions and 5 deletions

No files matched your search

@@ -137,6 +137,34 @@ function normalizeDeleteEvent(event: PlannedEvent | ReadonlyArray<PlannedEvent>)
}
it.layer(NodeServices.layer)("decider deletion flows", (it) => {
it.effect("emits a deletion tombstone for a missing thread", () =>
Effect.gen(function* () {
const threadId = asThreadId("ghost-thread");
const commandId = asCommandId("cmd-delete-ghost-thread");
const readModel = yield* seedReadModel;
const result = yield* decideOrchestrationCommand({
command: {
type: "thread.delete",
commandId,
threadId,
},
readModel,
});
expect(normalizeDeleteEvent(result)).toEqual([
{
type: "thread.deleted",
aggregateKind: "thread",
aggregateId: threadId,
commandId,
correlationId: commandId,
payload: { threadId },
},
]);
}),
);
it.effect("rejects deleting a non-empty project without force", () =>
Effect.gen(function* () {
const readModel = yield* seedReadModel;
+2 -5
View File
@@ -379,11 +379,8 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
}
case "thread.delete": {
yield* requireThread({
readModel,
command,
threadId: command.threadId,
});
// Keep deletion idempotent for clients holding a stale shell entry. The
// tombstone advances the stream and lets every client remove that ghost.
const occurredAt = yield* nowIso;
return {
...(yield* withEventBase({