@niwa-labs/sessions 0.0.0-stage → 0.0.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.
@@ -0,0 +1,175 @@
1
+ // The host program of the signs-of-life test: the signs of life of a session across a restart of the host.
2
+ //
3
+ // The fake control side reports the signs of life the test writes into a file of the home: one
4
+ // instruction per line, "turn-started <n>" or "turn-ended <n> [completed|failed|unknown]". The fake reads the file from
5
+ // where it left off, so a host that starts again reports only what is told to it after the
6
+ // restart. The cursor of the fake is a file of its own, so the instructions are only ever
7
+ // appended to.
8
+ //
9
+ // The home comes from argv[2]. The test imports this file for the names it needs, so the host
10
+ // only starts when the file is run directly.
11
+
12
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
13
+ import { join } from "node:path";
14
+ import { setTimeout as sleep } from "node:timers/promises";
15
+
16
+ import { TurnOutcomeSchema, harnessId, harnessKind, machineId, sessionId } from "@niwa-labs/harness";
17
+ import type {
18
+ AskAnswer,
19
+ AskOptions,
20
+ DeliveryReceipt,
21
+ Harness,
22
+ LifeEvent,
23
+ SessionControl,
24
+ SessionId,
25
+ SessionState,
26
+ } from "@niwa-labs/harness";
27
+ import { createNiwa } from "@niwa-labs/testing";
28
+
29
+ import { sessions } from "../../src/index.ts";
30
+
31
+ /** The harness the fake control side serves. */
32
+ export const HARNESS = "fake-harness";
33
+
34
+ /** The session the fake control side names. */
35
+ export const SESSION = `${HARNESS} session-1`;
36
+
37
+ /** The file of the home the instructions are in. */
38
+ export const INSTRUCTIONS = "life.log";
39
+
40
+ /** The file of the home the cursor of the fake is in. */
41
+ const CURSOR = "life.cursor";
42
+
43
+ /** How often the fake looks at its instructions. */
44
+ const POLL_MS = 25;
45
+
46
+ /** The fake control side: it reports the signs of life the test tells it to. */
47
+ class FakeControl implements SessionControl {
48
+ /** The file the instructions are in. */
49
+ private readonly log: string;
50
+ /** The file the cursor is in. */
51
+ private readonly cursor: string;
52
+ /** How many instructions were reported already. */
53
+ private reported: number;
54
+
55
+ constructor(log: string, cursor: string) {
56
+ this.log = log;
57
+ this.cursor = cursor;
58
+ this.reported = readCursor(cursor);
59
+ }
60
+
61
+ async start(): Promise<{ session: SessionId }> {
62
+ return { session: sessionId(harnessId(HARNESS), "session-1") };
63
+ }
64
+
65
+ async resume(): Promise<void> {}
66
+
67
+ async send(): Promise<DeliveryReceipt> {
68
+ return { status: "started", turn: 1 };
69
+ }
70
+
71
+ async interrupt(): Promise<void> {}
72
+
73
+ async ask<T>(_id: SessionId, _options: AskOptions<T>): Promise<AskAnswer<T>> {
74
+ throw new Error("the fake control side does not ask");
75
+ }
76
+
77
+ async state(): Promise<SessionState> {
78
+ return "idle";
79
+ }
80
+
81
+ /** The signs of life are the instructions of the file, one after another. */
82
+ async *life(): AsyncIterable<LifeEvent> {
83
+ for (;;) {
84
+ const lines = instructions(this.log);
85
+ while (this.reported < lines.length) {
86
+ const event = eventOf(lines[this.reported] ?? "");
87
+ this.reported += 1;
88
+ // The cursor is written before the sign of life is reported: a host that dies after this
89
+ // must not report the same instruction again.
90
+ writeCursor(this.cursor, this.reported);
91
+ if (event !== undefined) yield event;
92
+ }
93
+ await sleep(POLL_MS);
94
+ }
95
+ }
96
+ }
97
+
98
+ /** The instructions of the file, one per line. A line that is not finished yet is not one. */
99
+ function instructions(path: string): string[] {
100
+ if (!existsSync(path)) return [];
101
+ const lines = readFileSync(path, "utf8").split("\n");
102
+ lines.pop(); // what follows the last newline is a line that is still being written
103
+ return lines.map((line) => line.trim()).filter((line) => line !== "");
104
+ }
105
+
106
+ /** The sign of life one instruction names. */
107
+ function eventOf(line: string): LifeEvent | undefined {
108
+ const parts = line.split(" ");
109
+ const turn = Number(parts[1]);
110
+ if (!Number.isInteger(turn) || turn < 1) return undefined;
111
+ const kind = parts[0];
112
+ if (kind === "turn-started") return { kind: "turn-started", turn };
113
+ if (kind === "turn-ended") {
114
+ const outcome = TurnOutcomeSchema.safeParse(parts[2]);
115
+ return outcome.success ? { kind: "turn-ended", turn, outcome: outcome.data } : { kind: "turn-ended", turn };
116
+ }
117
+ return undefined;
118
+ }
119
+
120
+ /** How many instructions were reported already, by an earlier host or by this one. */
121
+ function readCursor(path: string): number {
122
+ if (!existsSync(path)) return 0;
123
+ const count = Number(readFileSync(path, "utf8").trim());
124
+ return Number.isInteger(count) && count >= 0 ? count : 0;
125
+ }
126
+
127
+ /** Write the cursor of the fake down. */
128
+ function writeCursor(path: string, count: number): void {
129
+ writeFileSync(path, String(count));
130
+ }
131
+
132
+ /** The installation the fake control side serves. */
133
+ function installation(): Harness {
134
+ return {
135
+ id: harnessId(HARNESS),
136
+ kind: harnessKind("fake-kind"),
137
+ machine: machineId("machine-1"),
138
+ home: "/tmp/fake-home",
139
+ sides: {
140
+ control: {
141
+ start: true,
142
+ resume: true,
143
+ send: true,
144
+ interrupt: false,
145
+ ask: false,
146
+ structuredOutput: false, launch: { model: false, effort: [], modes: [] },
147
+ },
148
+ },
149
+ };
150
+ }
151
+
152
+ if (import.meta.main) {
153
+ const home = process.argv[2];
154
+ if (home === undefined) {
155
+ console.error("usage: bun restart-host.ts <home>");
156
+ process.exit(2);
157
+ }
158
+
159
+ const niwa = createNiwa({ home });
160
+ niwa.use(
161
+ sessions({
162
+ harnesses: [
163
+ {
164
+ instance: installation(),
165
+ control: new FakeControl(join(home, INSTRUCTIONS), join(home, CURSOR)),
166
+ },
167
+ ],
168
+ }),
169
+ );
170
+ await niwa.serve();
171
+
172
+ process.on("SIGTERM", () => {
173
+ void niwa.close().then(() => process.exit(0));
174
+ });
175
+ }
@@ -0,0 +1,102 @@
1
+ // A session's box reaches the hosts it asks for, on a real machine.
2
+ //
3
+ // A session is started through `session.start` with a box that writes its directory and reaches
4
+ // example.com, and nothing else. The harness is a shell: its process is the real thing the
5
+ // funnel starts inside the real srt, so no model is asked, and what the box lets through is
6
+ // what the shell itself reaches. example.com answers, which shows the box lets the listed host
7
+ // through, and gitlab.com, which is not in the box, does not.
8
+ //
9
+ // Skipped unless NIWA_LIVE=1 and srt works on this machine.
10
+
11
+ import { afterAll, expect, test } from "bun:test";
12
+
13
+ import { readFile, realpath, rm } from "node:fs/promises";
14
+ import { join } from "node:path";
15
+
16
+ import { actionName } from "@niwa-labs/core";
17
+ import { harnessId, harnessKind, machineId } from "@niwa-labs/harness";
18
+ import type { Harness, SessionControl, StartOptions } from "@niwa-labs/harness";
19
+ import { sandbox, spawnAgent, srt } from "@niwa-labs/sandbox";
20
+ import { createNiwa, live, tempDir, tempHome } from "@niwa-labs/testing";
21
+
22
+ import { sessions } from "../src/index.ts";
23
+
24
+
25
+ const present = live && (await srt().available());
26
+
27
+ const HARNESS = "shell";
28
+
29
+ const cleanups: Array<() => Promise<void>> = [];
30
+ afterAll(async () => {
31
+ for (const cleanup of cleanups.splice(0).reverse()) await cleanup();
32
+ });
33
+
34
+ /** A control side whose session is one shell command, run by the funnel inside the box the grant made. */
35
+ class ShellControl implements SessionControl {
36
+ /** What the command was told: it writes what each host answered into this file. */
37
+ constructor(private readonly script: (out: string) => string) {}
38
+
39
+ async start(options: StartOptions) {
40
+ const child = await spawnAgent({
41
+ harness: HARNESS,
42
+ program: "/bin/sh",
43
+ args: ["-c", this.script(String(options.cwd))],
44
+ cwd: options.cwd,
45
+ env: options.env,
46
+ box: options.box,
47
+ });
48
+ await new Promise<void>((resolve) => child.once("close", () => resolve()));
49
+ return { session: { harness: harnessId(HARNESS), native: "s1" as never } };
50
+ }
51
+ async resume(): Promise<void> {}
52
+ async send() {
53
+ return { status: "started" as const };
54
+ }
55
+ async interrupt(): Promise<void> {}
56
+ async ask(): Promise<never> {
57
+ throw new Error("a shell is not asked");
58
+ }
59
+ async *life() {}
60
+ async state() {
61
+ return "idle" as const;
62
+ }
63
+ }
64
+
65
+ const probe = (url: string) => `echo "${url} $(curl -sS -m 10 -o /dev/null -w '%{http_code}' ${url} 2>&1)"`;
66
+
67
+ test.skipIf(!present)("a session whose box lacks gitlab.com cannot reach it from its shell", async () => {
68
+ const dir = await realpath(await tempDir("grant-box"));
69
+ cleanups.push(() => rm(dir, { recursive: true, force: true }));
70
+ const home = await tempHome();
71
+ const out = join(dir, "answers.txt");
72
+ const control = new ShellControl(() => `( ${probe("https://example.com")}; ${probe("https://gitlab.com")} ) > ${out}`);
73
+ const instance: Harness = {
74
+ id: harnessId(HARNESS),
75
+ kind: harnessKind("shell"),
76
+ machine: machineId("machine-1"),
77
+ home: dir,
78
+ sides: {
79
+ reading: { list: false, read: false, watch: false },
80
+ control: { start: true, resume: false, send: false, interrupt: false, ask: false, structuredOutput: false, launch: { model: false, effort: [], modes: [] } },
81
+ },
82
+ };
83
+ const host = createNiwa({ home: home.path });
84
+ host.use(sessions({ harnesses: [{ instance, control }], sandbox: sandbox({ adapter: "srt" }) }));
85
+ await host.serve();
86
+ cleanups.push(async () => {
87
+ await host.close();
88
+ await home.cleanup();
89
+ });
90
+
91
+ await host.call(actionName("session.start"), {
92
+ harness: HARNESS,
93
+ prompt: "",
94
+ cwd: dir,
95
+ box: { allow: [{ net: "example.com" }] },
96
+ });
97
+
98
+ const answers = await readFile(out, "utf8");
99
+ expect(answers).toContain("https://example.com 200");
100
+ expect(answers).toContain("https://gitlab.com");
101
+ expect(answers).not.toContain("https://gitlab.com 200");
102
+ });
@@ -0,0 +1,285 @@
1
+ // A tool permission question becomes a question for the owner: the approval of a tool is one of
2
+ // the things that waits for the owner.
3
+ //
4
+ // The insert plugin is served by a real host, with the requests module beside it, and a harness
5
+ // side that carries the answers back:
6
+ //
7
+ // 1. a report of a permission question creates a request to the owner, with the choices of the
8
+ // event and an id of the harness, the session and the request id
9
+ // 2. the owner answers: the side that asked carries the answer back, once
10
+ // 3. somebody who is not the owner cannot answer the request
11
+
12
+ import { expect, test } from "bun:test";
13
+
14
+ import { actionName, owner, principalOf, seq } from "@niwa-labs/core";
15
+ import type { StoredRecord } from "@niwa-labs/core";
16
+ import { harnessId, INSERT_REPORT_ACTION, sessionId } from "@niwa-labs/harness";
17
+ import type { HarnessInsert, PermissionAnswer, PermissionAskedEvent } from "@niwa-labs/harness";
18
+ import type { CallerBinding } from "@niwa-labs/plugin";
19
+ import {
20
+ REQUEST_ANSWER,
21
+ REQUEST_CANCEL,
22
+ RequestAnswered,
23
+ RequestCreated,
24
+ RequestExpiredRecord,
25
+ } from "@niwa-labs/requests/records";
26
+ import { connect, connectAsOwner, createNiwa, eventually, requests, tempHome } from "@niwa-labs/testing";
27
+
28
+ import { insertPlugin, PermissionRouter } from "../src/index.ts";
29
+
30
+ /** The action an insert calls to report what happened inside the harness. */
31
+ const REPORT = actionName(INSERT_REPORT_ACTION);
32
+
33
+ /** The label the owner's client connects with; the host adds the number of the connection. */
34
+ const OWNER_CLIENT = "owner-ui";
35
+
36
+ /** The owner's client speaks as the owner; every other client speaks as itself. */
37
+ const bind: CallerBinding = (caller) => {
38
+ if (caller.kind !== "client") return undefined;
39
+ return caller.id.startsWith(`${OWNER_CLIENT}#`) ? owner : { kind: "client", id: caller.id };
40
+ };
41
+
42
+ /** The harness the question comes from. */
43
+ const HARNESS = harnessId("claude-code");
44
+
45
+ /** The side of the harness: it carries the answers back to the harness that asked. */
46
+ function side(answered: PermissionAnswer[]): HarnessInsert {
47
+ return {
48
+ events: async function* () {},
49
+ answerPermission: async (answer) => void answered.push(answer),
50
+ };
51
+ }
52
+
53
+ /** The event of a tool that asks for permission. */
54
+ function asked(requestId = "tool-1"): PermissionAskedEvent {
55
+ return {
56
+ kind: "permission-asked",
57
+ session: sessionId(HARNESS, "s1"),
58
+ requestId,
59
+ tool: "Bash",
60
+ detail: "rm -rf build",
61
+ };
62
+ }
63
+
64
+ /** The records of one type, as the journal holds them. */
65
+ async function recordsOf(client: Awaited<ReturnType<typeof connect>>, type: string): Promise<StoredRecord[]> {
66
+ const found: StoredRecord[] = [];
67
+ const stream = client.records.since({ types: [type as never] }) as AsyncGenerator<StoredRecord>;
68
+ for (;;) {
69
+ const next = await Promise.race([stream.next(), Bun.sleep(500).then(() => "timed out" as const)]);
70
+ if (next === "timed out" || next.done === true) break;
71
+ found.push(next.value);
72
+ }
73
+ return found;
74
+ }
75
+
76
+ /** A host with the insert plugin and the requests module, and a client for the owner. */
77
+ async function serve(permissionTimeoutMs?: number) {
78
+ const home = await tempHome();
79
+ const answered: PermissionAnswer[] = [];
80
+ const router = new PermissionRouter();
81
+ router.register(HARNESS, side(answered));
82
+
83
+ const host = createNiwa({ home: home.path });
84
+ host.use(requests({ bind }));
85
+ host.use(insertPlugin({ router, ...(permissionTimeoutMs === undefined ? {} : { permissionTimeoutMs }) }));
86
+ await host.serve();
87
+
88
+ const ownerClient = await connectAsOwner(home.path, OWNER_CLIENT);
89
+ const reporter = await connect({ home: home.path, id: "insert-reporter" });
90
+ return {
91
+ home,
92
+ host,
93
+ answered,
94
+ ownerClient,
95
+ reporter,
96
+ async close() {
97
+ await ownerClient.close();
98
+ await reporter.close();
99
+ await host.close();
100
+ await home.cleanup();
101
+ },
102
+ };
103
+ }
104
+
105
+ test("a permission question becomes a request to the owner, and the answer goes back to the side that asked", async () => {
106
+ const world = await serve();
107
+ try {
108
+ await world.reporter.call(REPORT, asked());
109
+
110
+ // The question is a request to the owner, with the choices of the event.
111
+ await eventually(async () => (await recordsOf(world.ownerClient, RequestCreated.name)).length === 1, 10_000, "no request");
112
+ const created = (await recordsOf(world.ownerClient, RequestCreated.name))[0];
113
+ const data = created?.data as {
114
+ id: string;
115
+ to: { kind: string };
116
+ question: string;
117
+ input: { kind: string; title: string; options: Array<{ id: string; flavor: string }>; subject: { tool: string } };
118
+ };
119
+ expect(data.to).toEqual(owner);
120
+ expect(data.question).toBe("insert.permission");
121
+ expect(data.input.kind).toBe("permission");
122
+ expect(data.input.options.map((option) => option.id)).toEqual(["allow", "deny"]);
123
+ expect(data.input.options.map((option) => option.flavor)).toEqual(["allow_once", "reject_once"]);
124
+ expect(data.input.subject.tool).toBe("Bash");
125
+ expect(data.id).toMatch(/^req-[0-9a-f]{6,8}$/);
126
+ // The answer goes back to the side that asked, once.
127
+ await world.ownerClient.call(REQUEST_ANSWER, { id: data.id, answer: { ids: ["allow"] } });
128
+ await eventually(() => world.answered.length === 1, 10_000, "the answer did not reach the side");
129
+ expect(world.answered).toEqual([{ requestId: "tool-1", allow: true }]);
130
+
131
+ // The same answer again changes nothing: the side is asked once.
132
+ await world.ownerClient.call(REQUEST_ANSWER, { id: data.id, answer: { ids: ["allow"] } });
133
+ expect(world.answered).toHaveLength(1);
134
+ } finally {
135
+ await world.close();
136
+ }
137
+ });
138
+
139
+ test("a refusal by the owner is carried back as a refusal", async () => {
140
+ const world = await serve();
141
+ try {
142
+ await world.reporter.call(REPORT, asked("tool-2"));
143
+ await eventually(async () => (await recordsOf(world.ownerClient, RequestCreated.name)).length === 1, 10_000, "no request");
144
+ const created = (await recordsOf(world.ownerClient, RequestCreated.name))[0];
145
+ const id = (created?.data as { id: string }).id;
146
+
147
+ await world.ownerClient.call(REQUEST_ANSWER, { id, answer: { ids: ["deny"] } });
148
+ await eventually(() => world.answered.length === 1, 10_000, "the answer did not reach the side");
149
+ expect(world.answered).toEqual([{ requestId: "tool-2", allow: false }]);
150
+ } finally {
151
+ await world.close();
152
+ }
153
+ });
154
+
155
+ test("somebody who is not the owner cannot answer the question", async () => {
156
+ const world = await serve();
157
+ // A client the host issued a token with no grant: nothing limits it, and it is not the owner.
158
+ const intruder = await connect({
159
+ home: world.home.path,
160
+ id: "intruder",
161
+ token: world.host.issueToken(principalOf("client", "intruder")),
162
+ });
163
+ try {
164
+ await world.reporter.call(REPORT, asked("tool-3"));
165
+ await eventually(async () => (await recordsOf(world.ownerClient, RequestCreated.name)).length === 1, 10_000, "no request");
166
+ const created = (await recordsOf(world.ownerClient, RequestCreated.name))[0];
167
+ const id = (created?.data as { id: string }).id;
168
+
169
+ await expect(intruder.call(REQUEST_ANSWER, { id, answer: { ids: ["allow"] } })).rejects.toThrow(
170
+ "only the addressee",
171
+ );
172
+ expect(world.answered).toHaveLength(0);
173
+ expect(await recordsOf(world.ownerClient, RequestAnswered.name)).toHaveLength(0);
174
+ } finally {
175
+ await intruder.close();
176
+ await world.close();
177
+ }
178
+ });
179
+
180
+ test("a question nobody can carry the answer for is not asked", async () => {
181
+ const home = await tempHome();
182
+ const host = createNiwa({ home: home.path });
183
+ host.use(requests({ bind }));
184
+ // No side is registered for the harness: the answer would have nowhere to go.
185
+ host.use(insertPlugin({ router: new PermissionRouter() }));
186
+ await host.serve();
187
+ const client = await connect({ home: home.path, id: "insert-reporter" });
188
+ const observer = await connectAsOwner(home.path);
189
+
190
+ try {
191
+ await client.call(REPORT, asked("tool-4"));
192
+ await eventually(
193
+ async () => (await recordsOf(observer, "insert.permission-asked")).length === 1,
194
+ 10_000,
195
+ "the question was not recorded",
196
+ );
197
+ // The question is a record, and nobody waits for an answer to it.
198
+ expect(await recordsOf(observer, RequestCreated.name)).toHaveLength(0);
199
+ } finally {
200
+ await observer.close();
201
+ await client.close();
202
+ await host.close();
203
+ await home.cleanup();
204
+ }
205
+ });
206
+
207
+ test("an answer given after the host restarted while waiting reaches the side once", async () => {
208
+ const home = await tempHome();
209
+ const first = createNiwa({ home: home.path });
210
+ first.use(requests({ bind }));
211
+ const firstRouter = new PermissionRouter();
212
+ firstRouter.register(HARNESS, side([]));
213
+ first.use(insertPlugin({ router: firstRouter }));
214
+ await first.serve();
215
+ const reporter = await connect({ home: home.path, id: "insert-reporter" });
216
+ await reporter.call(REPORT, asked("tool-5"));
217
+ const observer = await connectAsOwner(home.path);
218
+ await eventually(async () => (await recordsOf(observer, RequestCreated.name)).length === 1, 10_000, "no request");
219
+ const id = ((await recordsOf(observer, RequestCreated.name))[0]?.data as { id: string }).id;
220
+ await observer.close();
221
+ await reporter.close();
222
+ await first.close();
223
+
224
+ // The host starts again: the side is new, and the question is still open.
225
+ const answered: PermissionAnswer[] = [];
226
+ const router = new PermissionRouter();
227
+ router.register(HARNESS, side(answered));
228
+ const second = createNiwa({ home: home.path });
229
+ second.use(requests({ bind }));
230
+ second.use(insertPlugin({ router }));
231
+ await second.serve();
232
+ const ownerClient = await connectAsOwner(home.path, OWNER_CLIENT);
233
+ try {
234
+ await ownerClient.call(REQUEST_ANSWER, { id, answer: { ids: ["allow"] } });
235
+ await eventually(() => answered.length === 1, 10_000, "the answer did not reach the side");
236
+ await Bun.sleep(500);
237
+ expect(answered).toEqual([{ requestId: "tool-5", allow: true }]);
238
+ expect(await recordsOf(ownerClient, RequestCreated.name)).toHaveLength(1);
239
+ } finally {
240
+ await ownerClient.close();
241
+ await second.close();
242
+ await home.cleanup();
243
+ }
244
+ });
245
+
246
+ test("a permission question that is cancelled answers the side deny, with the reason", async () => {
247
+ const world = await serve();
248
+ try {
249
+ await world.reporter.call(REPORT, asked("tool-6"));
250
+ await eventually(async () => (await recordsOf(world.ownerClient, RequestCreated.name)).length === 1, 10_000, "no request");
251
+ const id = ((await recordsOf(world.ownerClient, RequestCreated.name))[0]?.data as { id: string }).id;
252
+
253
+ // The owner cancels: the side that asked must not wait for ever.
254
+ await world.ownerClient.call(REQUEST_CANCEL, { id, reason: "not now" });
255
+
256
+ await eventually(() => world.answered.length === 1, 10_000, "the cancellation did not reach the side");
257
+ expect(world.answered).toEqual([{ requestId: "tool-6", allow: false, reason: "cancelled" }]);
258
+
259
+ // The side is told once: the question is not pending any more.
260
+ await Bun.sleep(500);
261
+ expect(world.answered).toHaveLength(1);
262
+ expect(await recordsOf(world.ownerClient, RequestAnswered.name)).toHaveLength(0);
263
+ } finally {
264
+ await world.close();
265
+ }
266
+ });
267
+
268
+ test("a permission question whose time runs out answers the side deny, with the reason", async () => {
269
+ // The question stops waiting in a moment, so nobody has to answer it.
270
+ const world = await serve(500);
271
+ try {
272
+ await world.reporter.call(REPORT, asked("tool-7"));
273
+
274
+ await eventually(() => world.answered.length === 1, 10_000, "the expiry did not reach the side");
275
+ expect(world.answered).toEqual([{ requestId: "tool-7", allow: false, reason: "expired" }]);
276
+
277
+ // The expiry is written once, and the side is told once.
278
+ await Bun.sleep(500);
279
+ expect(world.answered).toHaveLength(1);
280
+ expect(await recordsOf(world.ownerClient, RequestExpiredRecord.name)).toHaveLength(1);
281
+ expect(await recordsOf(world.ownerClient, RequestAnswered.name)).toHaveLength(0);
282
+ } finally {
283
+ await world.close();
284
+ }
285
+ });