Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(desktop): quarantine outbox appends the host keeps refusing

vastsad5071d187d6a
diff --git a/apps/desktop/electron/main/persistence-outbox.ts b/apps/desktop/electron/main/persistence-outbox.ts
index 3aa8b0223..69feacaea 100644
--- a/apps/desktop/electron/main/persistence-outbox.ts
+++ b/apps/desktop/electron/main/persistence-outbox.ts
@@ -10,9 +10,38 @@ type MessageAppend = {
turnId?: string;
};
+/**
+ * An append the outbox gave up on. The payload is kept verbatim so a user (or
+ * a later build) can replay it by hand; quarantined appends are never replayed
+ * automatically.
+ */
+type QuarantinedAppend = MessageAppend & {
+ quarantinedAt: string;
+ reason: string;
+};
+
type OutboxLogger = (level: "warn" | "error", message: string, data?: unknown) => void;
+type OutboxOptions = {
+ /** Current time in ms; a test seam for the retry backoff. */
+ now?: () => number;
+ /** Quarantined appends retained on disk, oldest discarded first. */
+ maxDeadLetters?: number;
+};
+
const MAX_ENTRIES = 1024;
+/**
+ * Consecutive unclassified failures allowed on one queued head before it is
+ * quarantined. Bounded so an append the host rejects forever cannot starve
+ * every later append from every session (#1560).
+ */
+const MAX_TRANSIENT_ATTEMPTS = 5;
+/** First backoff step before the same head is retried; doubles per attempt. */
+const RETRY_BACKOFF_MS = 5_000;
+/** Upper bound for one backoff step. */
+const MAX_RETRY_BACKOFF_MS = 60_000;
+/** Quarantined appends retained for manual recovery. */
+const MAX_DEAD_LETTERS = 256;
/**
* Keeps transcript appends away from a dead host pipe. The file is an
@@ -22,16 +51,31 @@ const MAX_ENTRIES = 1024;
export class PersistenceOutbox {
private readonly path: string;
private readonly tempPath: string;
+ private readonly deadLetterPath: string;
+ private readonly tempDeadLetterPath: string;
private readonly logger: OutboxLogger;
+ private readonly now: () => number;
+ private readonly maxDeadLetters: number;
private entries: MessageAppend[] = [];
+ private deadLetters: QuarantinedAppend[] = [];
private flushing: Promise<void> | null = null;
private persistChain = Promise.resolve();
+ private headRetry: {
+ entry: MessageAppend;
+ attempts: number;
+ nextAttemptAt: number;
+ host: HostProcess;
+ } | null = null;
private readonly loaded: Promise<void>;
- constructor(dataDir: string, logger: OutboxLogger) {
+ constructor(dataDir: string, logger: OutboxLogger, options: OutboxOptions = {}) {
this.path = join(dataDir, "session-message-outbox.json");
this.tempPath = `${this.path}.tmp`;
+ this.deadLetterPath = join(dataDir, "session-message-outbox.dead-letter.json");
+ this.tempDeadLetterPath = `${this.deadLetterPath}.tmp`;
this.logger = logger;
+ this.now = options.now ?? Date.now;
+ this.maxDeadLetters = options.maxDeadLetters ?? MAX_DEAD_LETTERS;
this.loaded = this.load();
}
@@ -70,14 +114,20 @@ export class PersistenceOutbox {
/**
* Drop queued appends for a session that the user deleted so a later
- * host-side stub recreate cannot resurrect it (D318).
+ * host-side stub recreate cannot resurrect it (D318). Its quarantined
+ * appends go with it: they belong to the same deleted conversation.
*/
async dropSession(sessionId: string): Promise<void> {
await this.loaded;
const next = this.entries.filter((entry) => entry.sessionId !== sessionId);
- if (next.length === this.entries.length) return;
+ const nextDeadLetters = this.deadLetters.filter((entry) => entry.sessionId !== sessionId);
+ const entriesChanged = next.length !== this.entries.length;
+ const deadLettersChanged = nextDeadLetters.length !== this.deadLetters.length;
+ if (!entriesChanged && !deadLettersChanged) return;
this.entries = next;
- await this.persist();
+ this.deadLetters = nextDeadLetters;
+ if (entriesChanged) await this.persist();
+ if (deadLettersChanged) await this.persistDeadLetters();
}
size(): number {
@@ -89,6 +139,16 @@ export class PersistenceOutbox {
const current = this.entries[0];
const currentHost = getHost();
if (!currentHost || !currentHost.isAvailable()) return;
+ // Bounded backoff: a head that just failed is not retried on every
+ // enqueue, so a struggling host is not hammered by a burst. A restarted
+ // host is a new generation and retries at once (#1560).
+ if (
+ this.headRetry?.entry === current &&
+ this.headRetry.host === currentHost &&
+ this.headRetry.nextAttemptAt > this.now()
+ ) {
+ return;
+ }
try {
await currentHost.call(current.usage ? "session.recordUsage" : "session.appendMessage", {
sessionId: current.sessionId,
@@ -121,23 +181,78 @@ export class PersistenceOutbox {
data: String(error),
});
} else {
- // Transient failure (host busy/overloaded/pipe dead). Keep the head
- // and retry on the next enqueue.
- this.logger("warn", "session persistence flush paused", {
- key: current.key,
- data: String(error),
- });
- return;
+ const attempts = this.noteTransientFailure(current, currentHost);
+ if (attempts < MAX_TRANSIENT_ATTEMPTS) {
+ // Transient failure (host busy/overloaded/pipe dead). Keep the head
+ // and retry it after this attempt's backoff.
+ this.logger("warn", "session persistence flush paused", {
+ key: current.key,
+ sessionId: current.sessionId,
+ attempts,
+ maxAttempts: MAX_TRANSIENT_ATTEMPTS,
+ retryInMs: this.headRetry ? this.headRetry.nextAttemptAt - this.now() : 0,
+ data: String(error),
+ });
+ return;
+ }
+ // An error the outbox cannot classify as permanent or as a
+ // duplicate recurs on every retry. Quarantine the head instead of
+ // blocking the whole application queue behind it forever (#1560).
+ await this.quarantine(current, attempts, error);
+ continue;
}
}
// A newer snapshot may have replaced this key while the host wrote it.
// Only remove the exact entry acknowledged by that write.
if (this.entries[0] === current) this.entries.shift();
+ this.headRetry = null;
await this.persist();
}
}
+ /** Count one failure of the given head and schedule its next attempt. */
+ private noteTransientFailure(entry: MessageAppend, host: HostProcess): number {
+ const attempts = (this.headRetry?.entry === entry ? this.headRetry.attempts : 0) + 1;
+ const backoff = Math.min(RETRY_BACKOFF_MS * 2 ** (attempts - 1), MAX_RETRY_BACKOFF_MS);
+ this.headRetry = { entry, attempts, nextAttemptAt: this.now() + backoff, host };
+ return attempts;
+ }
+
+ /** Move a head the host keeps refusing into the dead-letter file. */
+ private async quarantine(entry: MessageAppend, attempts: number, error: unknown): Promise<void> {
+ this.deadLetters.push({
+ ...entry,
+ quarantinedAt: new Date(this.now()).toISOString(),
+ reason: String(error),
+ });
+ while (this.deadLetters.length > this.maxDeadLetters) {
+ const dropped = this.deadLetters.shift();
+ this.logger("warn", "session persistence outbox dead letter discarded", {
+ key: dropped?.key,
+ sessionId: dropped?.sessionId,
+ max: this.maxDeadLetters,
+ file: this.deadLetterPath,
+ });
+ }
+ this.logger("error", "session persistence flush quarantined entry", {
+ key: entry.key,
+ sessionId: entry.sessionId,
+ attempts,
+ file: this.deadLetterPath,
+ data: String(error),
+ });
+ if (this.entries[0] === entry) this.entries.shift();
+ this.headRetry = null;
+ await this.persist();
+ await this.persistDeadLetters();
+ }
+
private async load(): Promise<void> {
+ await this.loadEntries();
+ await this.loadDeadLetters();
+ }
+
+ private async loadEntries(): Promise<void> {
try {
const raw = await readFile(this.path, "utf8");
const parsed = JSON.parse(raw);
@@ -158,6 +273,28 @@ export class PersistenceOutbox {
}
}
+ private async loadDeadLetters(): Promise<void> {
+ try {
+ const raw = await readFile(this.deadLetterPath, "utf8");
+ const parsed = JSON.parse(raw);
+ if (Array.isArray(parsed)) {
+ this.deadLetters = parsed.filter((entry): entry is QuarantinedAppend => {
+ return (
+ entry &&
+ typeof entry.key === "string" &&
+ typeof entry.sessionId === "string" &&
+ typeof entry.quarantinedAt === "string" &&
+ ("message" in entry || ("usage" in entry && typeof entry.turnId === "string"))
+ );
+ });
+ }
+ } catch (error: any) {
+ if (error?.code !== "ENOENT") {
+ this.logger("warn", "session persistence outbox dead letter load failed", String(error));
+ }
+ }
+ }
+
private async persist(): Promise<void> {
const write = this.persistChain.then(async () => {
await mkdir(dirname(this.path), { recursive: true });
@@ -175,6 +312,24 @@ export class PersistenceOutbox {
this.persistChain = write.catch(() => undefined);
await write;
}
+
+ private async persistDeadLetters(): Promise<void> {
+ const write = this.persistChain.then(async () => {
+ await mkdir(dirname(this.deadLetterPath), { recursive: true });
+ if (this.deadLetters.length === 0) {
+ try {
+ await writeFile(this.deadLetterPath, "[]\n", "utf8");
+ } catch (error) {
+ this.logger("warn", "session persistence outbox dead letter clear failed", String(error));
+ }
+ return;
+ }
+ await writeFile(this.tempDeadLetterPath, `${JSON.stringify(this.deadLetters)}\n`, "utf8");
+ await rename(this.tempDeadLetterPath, this.deadLetterPath);
+ });
+ this.persistChain = write.catch(() => undefined);
+ await write;
+ }
}
function isDuplicateMessageIdError(error: unknown): boolean {
diff --git a/apps/desktop/test/persistence-outbox.test.mjs b/apps/desktop/test/persistence-outbox.test.mjs
index 72eaede49..b1a77734c 100644
--- a/apps/desktop/test/persistence-outbox.test.mjs
+++ b/apps/desktop/test/persistence-outbox.test.mjs
@@ -252,3 +252,218 @@ test("FOREIGN KEY constraint failed drops the orphaned entry and keeps draining
logs.some((row) => row.message === "session persistence flush dropped orphaned message"),
);
});
+
+const DEAD_LETTER_FILE = "session-message-outbox.dead-letter.json";
+
+/** Let every pending microtask settle before counting host calls. */
+function settle() {
+ return new Promise((resolve) => setImmediate(resolve));
+}
+
+/**
+ * Drain with the retry backoff clock advanced past every window, returning the
+ * number of appends still queued.
+ */
+async function drain(outbox, host, now, steps = 12) {
+ for (let step = 0; step < steps && outbox.size() > 0; step += 1) {
+ now.value += 60_000;
+ await outbox.flush(() => host);
+ }
+ return outbox.size();
+}
+
+test("an unclassifiable head failure drains later entries instead of stalling them (#1560)", async () => {
+ const dir = await mkdtemp(join(tmpdir(), "pi-outbox-"));
+ const now = { value: 0 };
+ const logs = [];
+ const outbox = new PersistenceOutbox(
+ dir,
+ (level, message, data) => {
+ logs.push({ level, message, data });
+ },
+ { now: () => now.value },
+ );
+ const calls = [];
+ const host = mockHost(async (_method, params) => {
+ calls.push(params);
+ if (params.message.id === "torn") {
+ throw new Error("Error: stream did not contain valid UTF-8");
+ }
+ });
+ await outbox.enqueue(
+ { key: "message:s1:torn", sessionId: "s1", message: { id: "torn" } },
+ () => host,
+ );
+ await outbox.enqueue(
+ { key: "message:s2:healthy", sessionId: "s2", message: { id: "healthy" } },
+ () => host,
+ );
+ assert.equal(outbox.size(), 2, "the bad head keeps its retry budget before quarantine");
+
+ const remaining = await drain(outbox, host, now);
+ assert.equal(remaining, 0, "the queue drains instead of blocking forever");
+ assert.ok(
+ calls.some((params) => params.message?.id === "healthy"),
+ "a later entry reaches the host despite the bad head",
+ );
+ assert.ok(
+ logs.some(
+ (row) =>
+ row.message === "session persistence flush quarantined entry" &&
+ row.data?.key === "message:s1:torn",
+ ),
+ "quarantine is observable in the persistence log",
+ );
+ const dead = JSON.parse(await readFile(join(dir, DEAD_LETTER_FILE), "utf8"));
+ assert.deepEqual(
+ dead.map((entry) => entry.key),
+ ["message:s1:torn"],
+ );
+ assert.equal(dead[0].sessionId, "s1");
+ assert.match(dead[0].reason, /valid UTF-8/);
+ assert.equal(dead[0].message.id, "torn", "the quarantined payload is kept verbatim");
+ assert.equal(typeof dead[0].quarantinedAt, "string");
+});
+
+test("a failing head waits out its backoff before the host is called again (#1560)", async () => {
+ const dir = await mkdtemp(join(tmpdir(), "pi-outbox-"));
+ const now = { value: 0 };
+ const outbox = new PersistenceOutbox(dir, silent, { now: () => now.value });
+ const calls = [];
+ const host = mockHost(async (_method, params) => {
+ calls.push(params);
+ throw new Error("host is busy");
+ });
+ const getHost = () => host;
+ await outbox.enqueue({ key: "message:s1:a", sessionId: "s1", message: { id: "a" } }, getHost);
+ await outbox.flush(getHost);
+ await settle();
+ const afterFirstFailure = calls.length;
+ assert.ok(afterFirstFailure >= 1);
+
+ for (let attempt = 0; attempt < 5; attempt += 1) {
+ await outbox.flush(getHost);
+ }
+ await settle();
+ assert.equal(calls.length, afterFirstFailure, "no retry inside the backoff window");
+
+ now.value += 120_000;
+ await outbox.flush(getHost);
+ await settle();
+ assert.equal(calls.length, afterFirstFailure + 1, "the head is retried once its backoff elapses");
+ assert.equal(outbox.size(), 1, "an unclassified failure still pauses instead of dropping");
+});
+
+test("quarantined appends survive a restart without being replayed (#1560)", async () => {
+ const dir = await mkdtemp(join(tmpdir(), "pi-outbox-"));
+ const now = { value: 0 };
+ const logs = [];
+ const log = (level, message, data) => {
+ logs.push({ level, message, data });
+ };
+ const outbox = new PersistenceOutbox(dir, log, { now: () => now.value });
+ const calls = [];
+ const host = mockHost(async (_method, params) => {
+ calls.push(params);
+ if (params.message.id === "torn") {
+ throw new Error("Error: stream did not contain valid UTF-8");
+ }
+ });
+ await outbox.enqueue(
+ { key: "message:s1:torn", sessionId: "s1", message: { id: "torn" } },
+ () => host,
+ );
+ assert.equal(await drain(outbox, host, now), 0);
+
+ const reopened = new PersistenceOutbox(dir, log, { now: () => now.value });
+ assert.equal(reopened.size(), 0, "the dead letter is not queued again");
+ assert.equal(
+ JSON.parse(await readFile(join(dir, "session-message-outbox.json"), "utf8")).length,
+ 0,
+ );
+ const before = calls.length;
+ await reopened.flush(() => host);
+ assert.equal(calls.length, before, "no replay against the host");
+ const dead = JSON.parse(await readFile(join(dir, DEAD_LETTER_FILE), "utf8"));
+ assert.deepEqual(
+ dead.map((entry) => entry.key),
+ ["message:s1:torn"],
+ );
+});
+
+test("the dead-letter file keeps its newest appends at the cap (#1560)", async () => {
+ const dir = await mkdtemp(join(tmpdir(), "pi-outbox-"));
+ const now = { value: 0 };
+ const logs = [];
+ const outbox = new PersistenceOutbox(
+ dir,
+ (level, message, data) => {
+ logs.push({ level, message, data });
+ },
+ { now: () => now.value, maxDeadLetters: 2 },
+ );
+ const host = mockHost(async (_method, params) => {
+ if (["m1", "m2", "m3"].includes(params.message.id)) {
+ throw new Error("Error: stream did not contain valid UTF-8");
+ }
+ });
+ for (const id of ["m1", "m2", "m3"]) {
+ await outbox.enqueue({ key: `message:s1:${id}`, sessionId: "s1", message: { id } }, () => host);
+ assert.equal(await drain(outbox, host, now), 0, `${id} is quarantined and the queue drains`);
+ }
+ const dead = JSON.parse(await readFile(join(dir, DEAD_LETTER_FILE), "utf8"));
+ assert.deepEqual(
+ dead.map((entry) => entry.key),
+ ["message:s1:m2", "message:s1:m3"],
+ );
+ assert.ok(
+ logs.some(
+ (row) =>
+ row.message === "session persistence outbox dead letter discarded" &&
+ row.data?.key === "message:s1:m1",
+ ),
+ "a discarded dead letter is observable",
+ );
+});
+
+test("deleting a session drops its quarantined appends too (#1560)", async () => {
+ const dir = await mkdtemp(join(tmpdir(), "pi-outbox-"));
+ const now = { value: 0 };
+ const outbox = new PersistenceOutbox(dir, silent, { now: () => now.value });
+ const host = mockHost(async () => {
+ throw new Error("Error: stream did not contain valid UTF-8");
+ });
+ await outbox.enqueue(
+ { key: "message:gone:torn", sessionId: "gone", message: { id: "torn" } },
+ () => host,
+ );
+ assert.equal(await drain(outbox, host, now), 0);
+ await outbox.dropSession("gone");
+ assert.deepEqual(JSON.parse(await readFile(join(dir, DEAD_LETTER_FILE), "utf8")), []);
+});
+
+test("a restarted host retries the paused head without waiting out the backoff (#1560)", async () => {
+ const dir = await mkdtemp(join(tmpdir(), "pi-outbox-"));
+ const now = { value: 0 };
+ const outbox = new PersistenceOutbox(dir, silent, { now: () => now.value });
+ const calls = [];
+ const failing = mockHost(async (_method, params) => {
+ calls.push(params.message.id);
+ throw new Error("host is busy");
+ });
+ await outbox.enqueue({ key: "message:s1:a", sessionId: "s1", message: { id: "a" } }, () => failing);
+ await outbox.flush(() => failing);
+ await settle();
+ const paused = calls.length;
+ assert.ok(paused >= 1, "the head was attempted against the failing generation");
+
+ await outbox.flush(() => failing);
+ assert.equal(calls.length, paused, "the same generation waits out the backoff");
+
+ const restarted = mockHost(async (_method, params) => {
+ calls.push(params.message.id);
+ });
+ await outbox.flush(() => restarted);
+ assert.equal(outbox.size(), 0, "a fresh host generation drains the paused head at once");
+ assert.equal(calls.length, paused + 1);
+});
diff --git a/docs/adr/0041-bounded-host-runtime-and-persistence-outbox.md b/docs/adr/0041-bounded-host-runtime-and-persistence-outbox.md
index fc8d4e51e..ef0cf4c10 100644
--- a/docs/adr/0041-bounded-host-runtime-and-persistence-outbox.md
+++ b/docs/adr/0041-bounded-host-runtime-and-persistence-outbox.md
@@ -30,7 +30,11 @@ to another session is remapped to `{sessionId}:{id}` before the JSONL write
(D444). The outbox treats `UNIQUE constraint failed: messages.id` as an ack,
not a pause. A permanently rejected append (`PERMISSION_DENIED:` provenance
or permission on that row) is dropped the same way so one poison head cannot
-fill the 1024-entry cap and discard every later row (D597).
+fill the 1024-entry cap and discard every later row (D597). An append the host
+keeps refusing with an error the outbox cannot classify is retried on a bounded
+backoff and then quarantined into an application-owned dead-letter file, so no
+append can hold the FIFO head long enough to fill the cap for every session
+(D656).
## Consequences
diff --git a/docs/spec/03-runtime/04-data-storage.md b/docs/spec/03-runtime/04-data-storage.md
index deb978b09..667cbcd5d 100644
--- a/docs/spec/03-runtime/04-data-storage.md
+++ b/docs/spec/03-runtime/04-data-storage.md
@@ -1715,7 +1715,16 @@ no-op against that remapped row. The outbox treats
`UNIQUE constraint failed: messages.id` as an ack and keeps draining (D444).
A permanently rejected append whose host error carries a `PERMISSION_DENIED:`
prefix is likewise dropped so the FIFO can continue; `PLUGIN_PERMISSION_DENIED`
-and other host failures still pause (D597). When the 1024-entry cap remains
+and other host failures still pause while their retry budget lasts (D597). A
+failure the outbox cannot classify is retried within the same host generation
+on a bounded backoff (5s doubling to 60s) and quarantined after five
+consecutive failures into `session-message-outbox.dead-letter.json` (newest 256
+appends, oldest discarded first), carrying its payload, session id, timestamp,
+and host error, so one unclassifiable head cannot starve every session's writes
+(D656). A restarted host is a new generation and retries the head at once.
+Quarantined appends are never replayed automatically, and `session.delete`
+drops that session's quarantined appends too.
+When the 1024-entry cap remains
full after a flush attempt, enqueue logs the rejected key/session and rejects;
it does not report that entry as queued. Generic foreign-key errors are not
treated as acknowledgements. Steering into a claimed collaboration delivery
diff --git a/docs/spec/03-runtime/06-host-rpc-protocol.md b/docs/spec/03-runtime/06-host-rpc-protocol.md
index 55bbb155e..ac7bf3986 100644
--- a/docs/spec/03-runtime/06-host-rpc-protocol.md
+++ b/docs/spec/03-runtime/06-host-rpc-protocol.md
@@ -625,7 +625,10 @@ message appends in its application-owned outbox while host-core is restarting;
the outbox flushes in order after a successful handshake and treats
`UNIQUE constraint failed: messages.id` as an ack rather than pausing the
queue. A `PERMISSION_DENIED:` append is dropped the same way so a poison head
-cannot stall the FIFO (D597). A missing sessions row is restored from the live JSONL (or created as a
+cannot stall the FIFO (D597). An append the outbox cannot classify is retried
+on a bounded backoff and then quarantined to an application-owned dead-letter
+file instead of holding that head, so one refused append cannot stall every
+session's writes (D656). A missing sessions row is restored from the live JSONL (or created as a
stub under the same id when the file is gone) so a queued outbox can drain
(D318). `session.delete` drops that session's outbox entries. In-flight
checkpoints never go through the outbox: a checkpoint is only meaningful
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 4a6297bf6..0f768c6da 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -1766,6 +1766,36 @@ identify the platform validation still needed.
`persistence-outbox.test.mjs`); desktop journey outstanding
+#### E2E-SESSION-outbox-unclassifiable-failure-does-not-stall-the-queue
+
+- **Preconditions**: One queued outbox append fails with an error the outbox
+ cannot classify (`Error: stream did not contain valid UTF-8` from a torn host
+ transcript), while later appends from other sessions queue behind it.
+ Optionally the outbox is already at its 1024-entry cap and the flush log
+ shows repeated `session persistence flush paused` for that key.
+- **Steps**: 1) Produce the unclassifiable append failure. 2) Keep sending
+ messages in two other sessions. 3) Observe `logs/app/persistence.log` for
+ `session persistence flush paused` (bounded attempts), then
+ `session persistence flush quarantined entry`, and for the absence of
+ `session.persistence.outbox.is.full`. 4) Confirm
+ `session-message-outbox.dead-letter.json` holds that key with its payload and
+ error, and that `session-message-outbox.json` drops below the cap. 5) Restart
+ the app and confirm the quarantined append is not replayed. 6) Optional:
+ delete the failing session and confirm its dead letter is dropped.
+- **Expected**: The failing append is paused four times with a growing backoff
+ and quarantined on the fifth consecutive failure, then skipped. Later
+ appends from every session drain, no enqueue is rejected with `outbox is
+ full`, and the queued outbox file empties. The dead letter survives a
+ restart without being replayed.
+- **Specs linked**: `03-runtime/04-data-storage.md`,
+ `03-runtime/06-host-rpc-protocol.md`, ADR 0041, D318, D444, D597, D656
+- **Acceptance**: F (persistence)
+- **Milestone**: M2
+- **Status**: Unit-covered (`persistence-outbox.test.mjs` bounded retry,
+ quarantine, dead-letter persistence and cap tests); desktop journey
+ outstanding
+
+
#### E2E-011: Switch between project and temporary sessions
- **Preconditions**: One retained project session and one path-less Temporary
@@ -9654,7 +9684,7 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
| D — Workspace | E2E-012, E2E-013, E2E-022B, E2E-024I, E2E-047, E2E-049, E2E-057, E2E-058, E2E-060, E2E-068, E2E-075, E2E-078, E2E-153, E2E-158, E2E-182, E2E-187, E2E-252 |
| D — Workspace (project ordering) | E2E-253 |
| E — Tools & permissions | E2E-008a, E2E-014, E2E-015, E2E-016, E2E-017, E2E-018, E2E-019, E2E-024I, E2E-024K, E2E-040, E2E-049, E2E-074, E2E-093, E2E-097, E2E-099, E2E-100, E2E-101, E2E-102, E2E-102d, E2E-102e, E2E-102g, E2E-103, E2E-105, E2E-106, E2E-107, E2E-111, E2E-112, E2E-113, E2E-114, E2E-115, E2E-116, E2E-119, E2E-121, E2E-122, E2E-142, E2E-145, E2E-147, E2E-155, E2E-158, E2E-166, E2E-181, E2E-PLUGIN-imported-pi-package-skills |
-| F — Persistence | E2E-020, E2E-021, E2E-021a, E2E-038, E2E-SETTINGS-inline-capability-imports, E2E-040, E2E-042, E2E-047, E2E-048, E2E-051, E2E-054, E2E-056, E2E-061, E2E-062, E2E-064, E2E-066, E2E-068, E2E-071, E2E-072, E2E-073, E2E-082, E2E-084, E2E-096, E2E-098, E2E-102, E2E-102b, E2E-102c, E2E-102d, E2E-102g, E2E-102i, E2E-103, E2E-AGENTS-001, E2E-061a, E2E-073a, E2E-104, E2E-106, E2E-107, E2E-108, E2E-109, E2E-110, E2E-112, E2E-118, E2E-119, E2E-120, E2E-121, E2E-123, E2E-142, E2E-146, E2E-146a, E2E-148, E2E-151, E2E-158, E2E-160, E2E-168, E2E-171, E2E-177, E2E-178, E2E-183, E2E-186, E2E-005J, E2E-PLUGIN-session-orchestrator-real-workers, E2E-PLUGIN-provider-catalog-add-service |
+| F — Persistence | E2E-020, E2E-021, E2E-021a, E2E-038, E2E-SETTINGS-inline-capability-imports, E2E-040, E2E-042, E2E-047, E2E-048, E2E-051, E2E-054, E2E-056, E2E-061, E2E-062, E2E-064, E2E-066, E2E-068, E2E-071, E2E-072, E2E-073, E2E-082, E2E-084, E2E-096, E2E-098, E2E-102, E2E-102b, E2E-102c, E2E-102d, E2E-102g, E2E-102i, E2E-103, E2E-AGENTS-001, E2E-061a, E2E-073a, E2E-104, E2E-106, E2E-107, E2E-108, E2E-109, E2E-110, E2E-112, E2E-118, E2E-119, E2E-120, E2E-121, E2E-123, E2E-142, E2E-146, E2E-146a, E2E-148, E2E-151, E2E-158, E2E-160, E2E-168, E2E-171, E2E-177, E2E-178, E2E-183, E2E-186, E2E-005J, E2E-PLUGIN-session-orchestrator-real-workers, E2E-PLUGIN-provider-catalog-add-service, E2E-SESSION-outbox-unclassifiable-failure-does-not-stall-the-queue |
| F — Persistence (project ordering) | E2E-251 |
| G / Security — Fetch redirect policy | E2E-PLUGIN-fetch-redirect-policy |
| G — Plugins | E2E-022, E2E-022A, E2E-022B, E2E-022C, E2E-023, E2E-024, E2E-024B, E2E-024C, E2E-024D, E2E-024AA, E2E-024E, E2E-024W, E2E-024F, E2E-024G, E2E-024H, E2E-024I, E2E-024J, E2E-024K, E2E-024L, E2E-024M, E2E-024N, E2E-024O, E2E-024P, E2E-025, E2E-026, E2E-105, E2E-117, E2E-120, E2E-122, E2E-123, E2E-024Q, E2E-148, E2E-152, E2E-153, E2E-PLUGIN-imported-pi-package-skills, E2E-PLUGIN-imported-pi-package-wrapper, E2E-PLUGIN-import-extension-installs-dependencies, E2E-PLUGIN-import-extension-reports-missing-dependency, E2E-PLUGIN-global-shortcut-owns-only-its-own-command, E2E-PLUGIN-permission-gate-for-real-time-capabilities, E2E-PLUGIN-background-audio-and-realtime-connection, E2E-PLUGIN-fs-root-follows-the-calling-session, E2E-PLUGIN-provider-catalog-add-service |
diff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.md
index eec2e9e48..ac17bfd70 100644
--- a/docs/spec/08-meta/decisions-log.md
+++ b/docs/spec/08-meta/decisions-log.md
@@ -49,6 +49,7 @@ This log freezes previously open questions into concrete decisions.
| D653 | Make Composer prompt enhancement an optional plugin | **Supersede ADR 0121: remove host-owned prompt-enhancement UI, settings, direct completion IPC, and MCP action. Add the permission-gated `composer.transform` contribution and plugin callback, passing only the current draft plus an optional model key, with bounded input/output, audit, file-reference restoration, one-step undo, and stale session/draft guards. Keep `vastsa/pi-prompt-enhancement` in its own repository and require explicit user installation; do not bundle or enable it by default. On first plugin load, copy valid legacy preferences into unset plugin settings and write a private migration marker; preserve old host values for rollback. See ADR 0324, E2E-218 / E2E-259, and the plugin API/permission specs.** | Prompt enhancement is optional behavior that belongs to a separately installed plugin, while the host needs a narrow safe transform contract and a one-time path for existing settings. |
| D654 | Keep the deterministic first-prompt session title in the core | **Amend D652 / ADR 0323: a session whose stored title is still a recognized placeholder derives a whitespace-collapsed 48-character fallback from the first prompt, written through the host RPC and IPC `session/deriveTitle`. Host-core applies it only while the title is still a placeholder with the `default` source, and the derived text keeps that source, so an installed title plugin may still replace it and only a manual rename opts out. No model call, no new permission, no schema or protocol version change; `updated_at`, transcript content, and message count stay unchanged. See `03-runtime/01-ipc-protocol.md`, `03-runtime/02-agent-runtime.md`, `03-runtime/06-host-rpc-protocol.md`, `03-runtime/04-data-storage.md`, `04-ux/08-component-spec.md`, and E2E-021a.** | Removing every automatic write left an untouched session showing a placeholder until a plugin ran, so offline readability depended on installing optional software. |
| D655 | Cloud sync opens in packaged builds as Experimental | **Amend D649: remove the packaged-build visibility gate from Settings `sync` and restore its `Experimental` badge on the rail row and page title. Cloud sync and Remote Hosts are both available in packaged and development builds with Experimental badges. The S3 sync behavior, protocol, Host schema, and persisted data are unchanged. See `04-ux/06-settings-ia.md`, `03-runtime/22-config-sync.md`, and E2E-CONFIG-SYNC-s3-portable-configuration.** | The existing encrypted backup is useful to packaged-build users; the Experimental badge communicates its current maturity without keeping the feature hidden. |
+| D656 | Quarantine appends the host keeps refusing instead of stalling the outbox | **Amend ADR 0041 / D318 / D444 / D597: an append whose `session.appendMessage` or `session.recordUsage` call fails with an error the outbox cannot classify as a duplicate message id, a `PERMISSION_DENIED:` poison row, or a foreign-key orphan is retried on a bounded backoff (5s, doubling to a 60s cap) instead of ending the flush. The fifth consecutive failure on that head moves it into an application-owned dead-letter file, `session-message-outbox.dead-letter.json`, with its payload, session id, quarantine timestamp, and host error; only the newest 256 quarantined appends are kept, and the oldest is discarded with a warn. The flush then continues with the next entry, so one refused append can no longer hold the FIFO head, fill the 1024-entry cap, or fail every session's writes. Quarantined appends are never replayed automatically, and `session.delete` drops that session's quarantined appends too. No protocol version, storage schema, or queued-outbox format change.** | A `stream did not contain valid UTF-8` append stayed at the FIFO head for 14.8 hours while `session.persistence.outbox.is.full` fired 5990 times, so every session's appends failed until restart. Only three error classes had a drain, and every other error was treated as transient forever (#1560). |
## B. Secondary implementation defaults
@@ -7615,3 +7616,27 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
`config-sync-settings.test.mjs`, and the packaged Settings acceptance
scenario in E2E-CONFIG-SYNC-s3-portable-configuration. See
`04-ux/06-settings-ia.md` and `03-runtime/22-config-sync.md`.
+
+## 2026-10-11 — Quarantine appends the host keeps refusing (D656)
+
+- D656 amends ADR 0041, D318, D444, and D597: the outbox retries an
+ unclassifiable host failure on a bounded backoff (5s, doubling to a 60s cap)
+ and, after five consecutive failures on the same head, quarantines that
+ append into an application-owned dead-letter file and keeps draining the
+ later entries. Previously any error outside the three known drains ended the
+ flush, so the head was retried forever, the 1024-entry cap stayed full, and
+ every session's writes failed until restart.
+- The backoff applies within one Host generation: the gate compares the Host
+ instance that failed the head, so a restarted Host retries the paused head at
+ once instead of waiting the remaining window.
+- A quarantined append keeps its payload, session id, quarantine timestamp,
+ and host error in `session-message-outbox.dead-letter.json`. It is never
+ replayed automatically, `session.delete` drops that session's quarantined
+ appends with its queued ones, and only the newest 256 are retained — a
+ discarded one is logged with its key, session, and the file path. The queued
+ outbox format, storage schema, and host protocol are unchanged.
+- Covered by `apps/desktop/test/persistence-outbox.test.mjs` (bounded retry and
+ backoff, quarantine and continued drain, dead-letter persistence across a
+ restart, dead-letter cap, session delete) and
+ E2E-SESSION-outbox-unclassifiable-failure-does-not-stall-the-queue. See ADR
+ 0041, `03-runtime/04-data-storage.md`, and `03-runtime/06-host-rpc-protocol.md`.