@tpsdev-ai/agent 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/bun.lock +27 -15
  2. package/dist/bin.js +4 -3
  3. package/dist/bin.js.map +1 -1
  4. package/dist/config.d.ts +8 -1
  5. package/dist/config.d.ts.map +1 -1
  6. package/dist/config.js +38 -3
  7. package/dist/config.js.map +1 -1
  8. package/dist/home.d.ts +3 -0
  9. package/dist/home.d.ts.map +1 -0
  10. package/dist/home.js +18 -0
  11. package/dist/home.js.map +1 -0
  12. package/dist/index.d.ts +16 -3
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +12 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/io/flair.d.ts +1 -10
  17. package/dist/io/flair.d.ts.map +1 -1
  18. package/dist/io/flair.js +29 -28
  19. package/dist/io/flair.js.map +1 -1
  20. package/dist/io/mail.d.ts +184 -30
  21. package/dist/io/mail.d.ts.map +1 -1
  22. package/dist/io/mail.js +944 -185
  23. package/dist/io/mail.js.map +1 -1
  24. package/dist/lib/agent-keys.d.ts +106 -0
  25. package/dist/lib/agent-keys.d.ts.map +1 -0
  26. package/dist/lib/agent-keys.js +298 -0
  27. package/dist/lib/agent-keys.js.map +1 -0
  28. package/dist/lib/bridge-identity.d.ts +10 -0
  29. package/dist/lib/bridge-identity.d.ts.map +1 -0
  30. package/dist/lib/bridge-identity.js +56 -0
  31. package/dist/lib/bridge-identity.js.map +1 -0
  32. package/dist/lib/mail-lock-namespace.d.ts +19 -0
  33. package/dist/lib/mail-lock-namespace.d.ts.map +1 -0
  34. package/dist/lib/mail-lock-namespace.js +58 -0
  35. package/dist/lib/mail-lock-namespace.js.map +1 -0
  36. package/dist/lib/mail-lock.d.ts +81 -0
  37. package/dist/lib/mail-lock.d.ts.map +1 -0
  38. package/dist/lib/mail-lock.js +319 -0
  39. package/dist/lib/mail-lock.js.map +1 -0
  40. package/dist/lib/mailbox-filename.d.ts +2 -0
  41. package/dist/lib/mailbox-filename.d.ts.map +1 -0
  42. package/dist/lib/mailbox-filename.js +4 -0
  43. package/dist/lib/mailbox-filename.js.map +1 -0
  44. package/dist/lib/mailbox-policy.d.ts +245 -0
  45. package/dist/lib/mailbox-policy.d.ts.map +1 -0
  46. package/dist/lib/mailbox-policy.js +949 -0
  47. package/dist/lib/mailbox-policy.js.map +1 -0
  48. package/dist/lib/public-key.d.ts +6 -0
  49. package/dist/lib/public-key.d.ts.map +1 -0
  50. package/dist/lib/public-key.js +45 -0
  51. package/dist/lib/public-key.js.map +1 -0
  52. package/dist/lib/registry-key.d.ts +2 -0
  53. package/dist/lib/registry-key.d.ts.map +1 -0
  54. package/dist/lib/registry-key.js +10 -0
  55. package/dist/lib/registry-key.js.map +1 -0
  56. package/dist/lib/relay-lock.d.ts +7 -0
  57. package/dist/lib/relay-lock.d.ts.map +1 -0
  58. package/dist/lib/relay-lock.js +19 -0
  59. package/dist/lib/relay-lock.js.map +1 -0
  60. package/dist/lib/signEnvelope.d.ts +2 -0
  61. package/dist/lib/signEnvelope.d.ts.map +1 -1
  62. package/dist/lib/signEnvelope.js.map +1 -1
  63. package/dist/lib/signing-key.d.ts +2 -0
  64. package/dist/lib/signing-key.d.ts.map +1 -0
  65. package/dist/lib/signing-key.js +9 -0
  66. package/dist/lib/signing-key.js.map +1 -0
  67. package/dist/lib/topic-recipient.d.ts +2 -0
  68. package/dist/lib/topic-recipient.d.ts.map +1 -0
  69. package/dist/lib/topic-recipient.js +2 -0
  70. package/dist/lib/topic-recipient.js.map +1 -0
  71. package/dist/llm/provider.d.ts.map +1 -1
  72. package/dist/llm/provider.js +9 -7
  73. package/dist/llm/provider.js.map +1 -1
  74. package/dist/runtime/agent.d.ts.map +1 -1
  75. package/dist/runtime/agent.js +32 -25
  76. package/dist/runtime/agent.js.map +1 -1
  77. package/dist/runtime/event-loop.d.ts +21 -2
  78. package/dist/runtime/event-loop.d.ts.map +1 -1
  79. package/dist/runtime/event-loop.js +199 -54
  80. package/dist/runtime/event-loop.js.map +1 -1
  81. package/dist/runtime/types.d.ts +11 -0
  82. package/dist/runtime/types.d.ts.map +1 -1
  83. package/dist/runtime/types.js +13 -1
  84. package/dist/runtime/types.js.map +1 -1
  85. package/package.json +2 -3
  86. package/src/bin.ts +4 -3
  87. package/src/config.ts +46 -3
  88. package/src/home.ts +18 -0
  89. package/src/index.ts +33 -2
  90. package/src/io/flair.ts +23 -28
  91. package/src/io/mail.ts +1007 -200
  92. package/src/lib/agent-keys.ts +308 -0
  93. package/src/lib/bridge-identity.ts +49 -0
  94. package/src/lib/mail-lock-namespace.ts +64 -0
  95. package/src/lib/mail-lock.ts +337 -0
  96. package/src/lib/mailbox-filename.ts +3 -0
  97. package/src/lib/mailbox-policy.ts +1085 -0
  98. package/src/lib/public-key.ts +49 -0
  99. package/src/lib/registry-key.ts +8 -0
  100. package/src/lib/relay-lock.ts +20 -0
  101. package/src/lib/signEnvelope.ts +2 -0
  102. package/src/lib/signing-key.ts +8 -0
  103. package/src/lib/topic-recipient.ts +1 -0
  104. package/src/llm/provider.ts +9 -7
  105. package/src/runtime/agent.ts +30 -27
  106. package/src/runtime/event-loop.ts +221 -68
  107. package/src/runtime/types.ts +14 -0
  108. package/test/config.test.ts +85 -2
  109. package/test/core-loop.test.ts +6 -4
  110. package/test/governance.test.ts +4 -1
  111. package/test/helpers/event-loop-child.mjs +50 -0
  112. package/test/helpers/mail-delivery-worker.mjs +16 -0
  113. package/test/helpers/mail-kill-child.mjs +104 -0
  114. package/test/helpers/signed-relay-record.ts +31 -0
  115. package/test/home-per-call.test.ts +72 -0
  116. package/test/io.test.ts +81 -14
  117. package/test/mail-client-lock-namespace.test.ts +155 -0
  118. package/test/mail-client-repoint-root.test.ts +368 -0
  119. package/test/mail-delivery-at-least-once.test.ts +1238 -0
  120. package/test/mail-event-loop-delivery.test.ts +769 -0
  121. package/test/mail-intent-phases.test.ts +304 -0
  122. package/test/mail-interrupted-recovery.test.ts +393 -0
  123. package/test/mail-lock-pid-state.test.ts +238 -0
  124. package/test/mail-lock.test.ts +96 -0
  125. package/test/mail-partial-flair.test.ts +102 -0
  126. package/test/mail-placement-replay.test.ts +116 -0
  127. package/test/mail-promote-guard.test.ts +305 -21
  128. package/test/mail-relay-reservation.test.ts +60 -0
  129. package/test/mailbox-filename.test.ts +16 -0
  130. package/test/public-key.test.ts +108 -0
  131. package/test/runtime-key-encoding.test.ts +105 -0
  132. package/test/runtime-pending-key.test.ts +117 -0
  133. package/test/security/mail-trust.test.ts +406 -109
@@ -0,0 +1,304 @@
1
+ /**
2
+ * cli#617 slice (a): placement intents carry a phase, and MailClient recovery
3
+ * and the store keep an intent whose declared phase is not `placing`. Nothing
4
+ * writes `in_progress` or `failed` yet, so these fixtures write them directly.
5
+ */
6
+
7
+ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
8
+ import { createHash } from "node:crypto";
9
+ import { copyFileSync, existsSync, linkSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
10
+ import { tmpdir } from "node:os";
11
+ import { join } from "node:path";
12
+ import * as ed from "@noble/ed25519";
13
+ import { MailClient } from "../src/io/mail.js";
14
+ import { hasCommittedMessageId, mailboxReplayStore, pendingPlacementEntries } from "../src/lib/mailbox-policy.js";
15
+ import { signEnvelope, type FlairClient } from "../src/lib/signEnvelope.js";
16
+ import type { EventLogger } from "../src/telemetry/events.js";
17
+
18
+ const AGENT = "agent-a";
19
+ const FROM = "agent-b";
20
+ const SEED = Buffer.alloc(32, 0x31);
21
+
22
+ let mailDir: string;
23
+ let root: string;
24
+ let verifierCalls: number;
25
+ let onVerify: (() => void) | undefined;
26
+
27
+ const cur = (file = "m1.json") => join(root, "cur", file);
28
+ const fresh = (file = "m1.json") => join(root, "new", file);
29
+ const intentPath = (file = "m1.json") =>
30
+ join(root, `.placement-${createHash("sha256").update(file).digest("hex")}.json`);
31
+
32
+ function verifier(): FlairClient {
33
+ return {
34
+ async getAgent(name: string) {
35
+ verifierCalls++;
36
+ onVerify?.();
37
+ return name === FROM ? { publicKey: Buffer.from(ed.getPublicKey(SEED)) } : null;
38
+ },
39
+ };
40
+ }
41
+
42
+ const client = () => new MailClient(mailDir, undefined, AGENT, verifier());
43
+
44
+ beforeEach(() => {
45
+ mailDir = mkdtempSync(join(tmpdir(), "mail-intent-phases-"));
46
+ root = join(mailDir, AGENT);
47
+ mkdirSync(join(root, "new"), { recursive: true });
48
+ mkdirSync(join(root, "cur"), { recursive: true });
49
+ verifierCalls = 0;
50
+ onVerify = undefined;
51
+ });
52
+
53
+ afterEach(() => rmSync(mailDir, { recursive: true, force: true }));
54
+
55
+ /** Write one signed record to `path`. */
56
+ function signedRecord(path: string, messageId: string, body = "phase-body"): void {
57
+ const timestamp = new Date().toISOString();
58
+ const envelope = signEnvelope(
59
+ {
60
+ v: 1, from: FROM, to: AGENT, body, messageId, timestamp,
61
+ delegationChain: [
62
+ { agent: "system", kind: "human", timestamp, rationale: "originates", signature: null },
63
+ { agent: FROM, kind: "agent", timestamp, rationale: "sends", signature: null },
64
+ ],
65
+ },
66
+ { [FROM]: SEED },
67
+ );
68
+ writeFileSync(path, JSON.stringify({ from: FROM, body: JSON.stringify(envelope) }));
69
+ }
70
+
71
+ /** Rewrite the intent for `file` with these extra fields (a writer this slice does not ship). */
72
+ function setPhase(fields: Record<string, unknown>, file = "m1.json"): Buffer {
73
+ const path = intentPath(file);
74
+ writeFileSync(path, JSON.stringify({ ...JSON.parse(readFileSync(path, "utf8")), ...fields }));
75
+ return readFileSync(path);
76
+ }
77
+
78
+ /**
79
+ * A committed message as design rev 2 leaves it: the payload in cur/, its ID
80
+ * in the consumed ledger, and its intent in the given phase.
81
+ */
82
+ function committed(messageId: string, fields: Record<string, unknown>): Buffer {
83
+ signedRecord(fresh(), messageId);
84
+ const replay = mailboxReplayStore(root);
85
+ linkSync(fresh(), cur());
86
+ unlinkSync(fresh());
87
+ replay.beginPlacement(messageId, "m1.json", cur());
88
+ replay.recordConsumed(messageId);
89
+ return setPhase(fields);
90
+ }
91
+
92
+ const quarantined = (file = "m1.json") => existsSync(`${intentPath(file)}.quarantined`);
93
+ /** A file's text, or null when it is absent, so a removal fails an assertion rather than throwing. */
94
+ const textOf = (path: string) => (existsSync(path) ? readFileSync(path, "utf8") : null);
95
+ const intentText = (file = "m1.json") => textOf(intentPath(file));
96
+ const ids = (messages: Awaited<ReturnType<MailClient["checkNewMail"]>>) => messages.map((m) => m.verifiedEnvelope?.messageId);
97
+ const jsonFiles = (dir: string) => (existsSync(dir) ? readdirSync(dir).filter((n) => n.endsWith(".json")) : []);
98
+
99
+ const now = () => new Date().toISOString();
100
+ const PRESERVED: Record<string, Record<string, unknown>> = {
101
+ in_progress: { version: 1, phase: "in_progress", presentations: 1, firstPresentedAt: now() },
102
+ "an unknown phase": { version: 1, phase: "awaiting-review" },
103
+ "a future schema version": { version: 2, phase: "placing" },
104
+ "a phase field it cannot read": { version: 1, phase: "in_progress", presentations: -1 },
105
+ };
106
+
107
+ describe("agent recovery keeps an in_progress or unknown intent (io/mail.ts recoverInterruptedPlacements)", () => {
108
+ for (const [name, fields] of Object.entries(PRESERVED)) {
109
+ for (const copy of ["present", "absent"] as const) {
110
+ test(`${name}, cur copy ${copy}: skipped at listing, not presented, finished or quarantined; other mail flows`, async () => {
111
+ const bytes = committed(`phase-${copy}`, fields);
112
+ if (copy === "absent") unlinkSync(cur());
113
+ const payload = copy === "present" ? textOf(cur()) : null;
114
+ signedRecord(fresh("m2.json"), "unrelated");
115
+
116
+ const c = client();
117
+ expect(ids(await c.checkNewMail())).toEqual(["unrelated"]);
118
+ expect(await c.checkNewMail()).toEqual([]);
119
+
120
+ expect(intentText()).toBe(bytes.toString("utf8"));
121
+ expect(quarantined()).toBe(false);
122
+ expect(verifierCalls).toBe(1); // the unrelated message only: a phase seen at listing skips the payload
123
+ expect(textOf(cur())).toBe(payload);
124
+ expect(jsonFiles(join(root, "dlq"))).toEqual([]);
125
+ });
126
+ }
127
+ }
128
+
129
+ test("a placing intent that turns in_progress before the recovery lock is not presented", async () => {
130
+ committed("raced", {});
131
+ let raced: Buffer | undefined;
132
+ onVerify = () => {
133
+ raced ??= setPhase({ version: 1, phase: "in_progress", presentations: 1, firstPresentedAt: now() });
134
+ };
135
+ expect(await client().checkNewMail()).toEqual([]);
136
+ expect(raced).toBeDefined();
137
+ expect(intentText()).toBe(raced!.toString("utf8"));
138
+ });
139
+
140
+ test("a placing intent still recovers exactly as before", async () => {
141
+ committed("still-placing", {});
142
+ const c = client();
143
+ expect(ids(await c.checkNewMail())).toEqual(["still-placing"]);
144
+ expect(await c.checkNewMail()).toEqual([]);
145
+ expect(existsSync(intentPath())).toBe(false);
146
+ });
147
+ });
148
+
149
+ describe("the quarantine path keeps an unknown phase (mailbox-policy.ts readPlacementIntent)", () => {
150
+ for (const [name, fields] of Object.entries(PRESERVED).filter(([n]) => n !== "in_progress")) {
151
+ test(`${name} is listed as unknown, gates its own file and is not quarantined for its phase`, () => {
152
+ const bytes = committed("kept-unknown", fields);
153
+ const replay = mailboxReplayStore(root);
154
+ expect(pendingPlacementEntries(root)).toEqual([{ messageId: "kept-unknown", file: "m1.json", phase: "unknown" }]);
155
+ expect(replay.hasPendingFile("m1.json")).toBe(true);
156
+ expect(replay.isConsumed("some-other-id")).toBe(false); // the ledger read that quarantines malformed intents
157
+ expect(quarantined()).toBe(false);
158
+ expect(intentText()).toBe(bytes.toString("utf8"));
159
+ });
160
+ }
161
+ });
162
+
163
+ describe("a failed intent does not close the per-file gate", () => {
164
+ test("not presented, a same-name duplicate is refused as replay, other mail flows, intent and payload kept", async () => {
165
+ const bytes = committed("poisoned", { version: 1, phase: "failed", presentations: 5, firstPresentedAt: now() });
166
+ const payload = textOf(cur());
167
+ expect(pendingPlacementEntries(root)).toEqual([]);
168
+ expect(mailboxReplayStore(root).hasPendingFile("m1.json")).toBe(false);
169
+
170
+ copyFileSync(cur(), fresh()); // the same signed record again, under the same name
171
+ signedRecord(fresh("m2.json"), "after-the-poison");
172
+ const c = client();
173
+ expect(ids(await c.checkNewMail())).toEqual(["after-the-poison"]);
174
+ expect(await c.checkNewMail()).toEqual([]);
175
+
176
+ expect(existsSync(fresh())).toBe(false);
177
+ expect(textOf(join(root, "dlq", "m1.json.reason")) ?? "").toContain("class: replay");
178
+ expect(textOf(cur())).toBe(payload);
179
+ expect(intentText()).toBe(bytes.toString("utf8"));
180
+ expect(hasCommittedMessageId(root, "poisoned")).toBe(true);
181
+ });
182
+
183
+ const FAILED = { version: 1, phase: "failed", presentations: 5, firstPresentedAt: now() };
184
+ const tombstone = (id: string) => intentPath().replace(/\.json$/, `.failed-${id}.json`);
185
+
186
+ test("once the failed payload is archived and its tombstone name is unoccupied, a different message at the same name is delivered; the marker moves to that tombstone, which keeps its consumed ID", async () => {
187
+ const bytes = committed("poisoned", FAILED);
188
+ const archived = join(root, "archive", "2026-01");
189
+ mkdirSync(archived, { recursive: true });
190
+ renameSync(cur(), join(archived, "m1.json")); // what archiveOldCur does with an aged cur/ record
191
+ signedRecord(fresh(), "reused-name");
192
+
193
+ const c = client();
194
+ expect(ids(await c.checkNewMail())).toEqual(["reused-name"]);
195
+ expect(await c.checkNewMail()).toEqual([]);
196
+
197
+ expect(existsSync(fresh())).toBe(false);
198
+ expect(textOf(tombstone("poisoned"))).toBe(bytes.toString("utf8"));
199
+ expect(intentText()).toBeNull();
200
+ expect(pendingPlacementEntries(root)).toEqual([]);
201
+ expect(hasCommittedMessageId(root, "reused-name")).toBe(true);
202
+
203
+ // The tombstone keeps the old consumed ID through a ledger prune.
204
+ const old = new Date(Date.now() - 200 * 24 * 60 * 60 * 1000).toISOString();
205
+ writeFileSync(join(root, "consumed.jsonl"), `${[
206
+ JSON.stringify({ id: "poisoned", at: old }), JSON.stringify({ id: "reused-name", at: now() }),
207
+ ].join("\n")}\n`);
208
+ expect(mailboxReplayStore(root).isConsumed("absent-id")).toBe(false);
209
+ expect(hasCommittedMessageId(root, "poisoned")).toBe(true);
210
+ });
211
+
212
+ /** A failed marker whose payload has been archived, plus a different message waiting under its name. */
213
+ function archivedFailedWithReuse(): Buffer {
214
+ const bytes = committed("poisoned", FAILED);
215
+ const archived = join(root, "archive", "2026-01");
216
+ mkdirSync(archived, { recursive: true });
217
+ renameSync(cur(), join(archived, "m1.json"));
218
+ signedRecord(fresh(), "reused-name");
219
+ return bytes;
220
+ }
221
+
222
+ test("an occupied tombstone refuses the reuse by name: marker and tombstone stay byte-identical, nothing is presented", async () => {
223
+ const marker = archivedFailedWithReuse();
224
+ const retained = JSON.stringify({ messageId: "poisoned", file: "m1.json", phase: "failed", note: "an operator's retained record" });
225
+ writeFileSync(tombstone("poisoned"), retained);
226
+ const errors: string[] = [];
227
+ const events = { emit: (e: { status?: string; error?: string }) => { if (e.status === "error") errors.push(e.error ?? ""); } };
228
+ const c = new MailClient(mailDir, events as unknown as EventLogger, AGENT, verifier());
229
+
230
+ expect(await c.checkNewMail()).toEqual([]);
231
+ expect(await c.checkNewMail()).toEqual([]);
232
+
233
+ expect(errors.some((e) => e.includes("failed tombstone occupied for m1.json"))).toBe(true);
234
+ expect(existsSync(fresh())).toBe(true);
235
+ expect(existsSync(cur())).toBe(false);
236
+ expect(intentText()).toBe(marker.toString("utf8"));
237
+ expect(textOf(tombstone("poisoned"))).toBe(retained);
238
+ expect(hasCommittedMessageId(root, "reused-name")).toBe(false);
239
+ expect(() => mailboxReplayStore(root).beginPlacement("reused-name", "m1.json", fresh())).toThrow("failed tombstone occupied for m1.json");
240
+ expect(intentText()).toBe(marker.toString("utf8"));
241
+ expect(textOf(tombstone("poisoned"))).toBe(retained);
242
+ });
243
+
244
+ test("a tombstone that is the marker's own inode is treated as an interrupted move and finished, and the reuse proceeds", async () => {
245
+ const marker = archivedFailedWithReuse();
246
+ linkSync(intentPath(), tombstone("poisoned"));
247
+
248
+ expect(ids(await client().checkNewMail())).toEqual(["reused-name"]);
249
+
250
+ expect(textOf(tombstone("poisoned"))).toBe(marker.toString("utf8"));
251
+ expect(intentText()).toBeNull();
252
+ });
253
+
254
+ test("while the failed payload is still in cur/, a different message at the same name waits and the marker stays", async () => {
255
+ const bytes = committed("poisoned", FAILED);
256
+ const payload = textOf(cur());
257
+ signedRecord(fresh(), "reused-too-soon");
258
+
259
+ expect(await client().checkNewMail()).toEqual([]);
260
+
261
+ expect(existsSync(fresh())).toBe(true);
262
+ expect(intentText()).toBe(bytes.toString("utf8"));
263
+ expect(textOf(cur())).toBe(payload);
264
+ expect(existsSync(tombstone("poisoned"))).toBe(false);
265
+ });
266
+ });
267
+
268
+ describe("the store never finishes or replaces a same-message intent in another phase", () => {
269
+ const OTHER = { ...PRESERVED, failed: { version: 1, phase: "failed", presentations: 5, firstPresentedAt: now() } };
270
+ for (const [name, fields] of Object.entries(OTHER)) {
271
+ test(`${name}: finishPlacement and beginPlacement leave it byte-identical`, () => {
272
+ const bytes = committed("kept", fields);
273
+ const replay = mailboxReplayStore(root);
274
+ replay.finishPlacement("kept", "m1.json");
275
+ expect(intentText()).toBe(bytes.toString("utf8"));
276
+ expect(() => replay.beginPlacement("kept", "m1.json", cur())).toThrow("not replaced");
277
+ expect(intentText()).toBe(bytes.toString("utf8"));
278
+ });
279
+ }
280
+ });
281
+
282
+ describe("parsePlacement requires intent.file to be a plain basename", () => {
283
+ test("a non-basename intent is quarantined and never recovered", async () => {
284
+ const file = "../escape.json";
285
+ const outside = join(root, "escape.json");
286
+ signedRecord(outside, "outside-cur");
287
+ const st = statSync(outside, { bigint: true });
288
+ writeFileSync(intentPath(file), JSON.stringify({
289
+ messageId: "outside-cur", file, identity: { dev: st.dev.toString(), ino: st.ino.toString() },
290
+ }));
291
+ expect(await client().checkNewMail()).toEqual([]);
292
+ expect(quarantined(file)).toBe(true);
293
+ expect(hasCommittedMessageId(root, "outside-cur")).toBe(false);
294
+ });
295
+
296
+ for (const file of ["", ".", "..", "a/b.json", "a\\b.json"]) {
297
+ test(`${JSON.stringify(file)} is refused on write and on read`, () => {
298
+ expect(() => mailboxReplayStore(root).beginPlacement("not-a-name", file)).toThrow("plain basename");
299
+ writeFileSync(intentPath(file), JSON.stringify({ messageId: "not-a-name", file }));
300
+ expect(pendingPlacementEntries(root)).toEqual([]);
301
+ expect(quarantined(file)).toBe(true);
302
+ });
303
+ }
304
+ });