@fungi.computer/bonsai 0.9.13 → 0.10.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # @fungi.computer/bonsai
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Changes since 0.9.14:
8
+
9
+ - feat(apps): require one host-derived caller scope
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+ - Updated dependencies
15
+ - Updated dependencies
16
+ - Updated dependencies
17
+ - @fungi.computer/agar@0.20.0
18
+ - @fungi.computer/oyster@0.36.0
19
+ - @fungi.computer/puffball@0.10.0
20
+ - @fungi.computer/trellis@0.16.0
21
+ - @fungi.computer/braid@0.4.24
22
+ - @fungi.computer/nacre@0.7.2
23
+ - @fungi.computer/workflows-wire@0.4.24
24
+
25
+ ## 0.9.14
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies
30
+ - @fungi.computer/oyster@0.35.1
31
+ - @fungi.computer/braid@0.4.23
32
+ - @fungi.computer/trellis@0.15.7
33
+ - @fungi.computer/workflows-wire@0.4.23
34
+
3
35
  ## 0.9.13
4
36
 
5
37
  ### Patch Changes
package/backend/index.ts CHANGED
@@ -1,15 +1,8 @@
1
1
  /**
2
2
  * The Bonsai App facet: a Durable Object whose generated RPC methods are
3
- * Bonsai's App methods. `fetch` serves the App's own UI (a JSON PUT naming a
4
- * method, as agar's appBackend.request sends it). Native onGitPush receives
3
+ * Bonsai's App methods, called through host admission. Native onGitPush receives
5
4
  * accepted push facts from the host.
6
5
  */
7
- import {
8
- AppMethodRefusal,
9
- appBackendActorHeader,
10
- appBackendComputerHeader,
11
- appMethodRefusalStatus,
12
- } from "@fungi.computer/agar/backend";
13
6
  import {
14
7
  gitPushQuestionSchema,
15
8
  type GitPushQuestion,
@@ -17,7 +10,6 @@ import {
17
10
  type AppGitPushFact,
18
11
  } from "@fungi.computer/agar/git";
19
12
  import { DurableObject } from "cloudflare:workers";
20
- import * as z from "zod";
21
13
  import { gitStore, type GitBinding } from "./git.js";
22
14
  import { appBackend, type BonsaiAppsBinding } from "./methods.js";
23
15
  import {
@@ -47,30 +39,6 @@ export type BonsaiEnv = BuildWorkflowBindings &
47
39
  APPS?: BonsaiAppsBinding;
48
40
  }>;
49
41
 
50
- const uiRequest = z.strictObject({
51
- method: z.string().min(1).max(80),
52
- input: z.json(),
53
- });
54
-
55
- function declared(method: string): boolean {
56
- return Object.hasOwn(appBackend.methods, method);
57
- }
58
-
59
- function failure(error: Error): Response {
60
- if (error instanceof AppMethodRefusal)
61
- return Response.json(
62
- { error: error.code, message: error.message },
63
- { status: appMethodRefusalStatus[error.code] },
64
- );
65
- if (error instanceof z.ZodError)
66
- return Response.json({ error: "Invalid request" }, { status: 400 });
67
- console.error("bonsai backend error", error);
68
- return Response.json(
69
- { error: "Bonsai could not finish that request" },
70
- { status: 500 },
71
- );
72
- }
73
-
74
42
  class BonsaiFacet extends DurableObject<BonsaiEnv> {
75
43
  declare public readonly env: BonsaiEnv;
76
44
  readonly bonsai: BonsaiRuntime;
@@ -120,31 +88,6 @@ class BonsaiFacet extends DurableObject<BonsaiEnv> {
120
88
  };
121
89
  });
122
90
  }
123
-
124
- override async fetch(request: Request): Promise<Response> {
125
- try {
126
- if (request.method !== "PUT")
127
- return new Response(null, { status: 405, headers: { Allow: "PUT" } });
128
- const body = uiRequest.parse(await request.json());
129
- if (!declared(body.method))
130
- return Response.json({ error: "No such method" }, { status: 404 });
131
- const memberId = request.headers.get(appBackendActorHeader);
132
- if (memberId === null)
133
- return Response.json(
134
- { error: "App actor unavailable" },
135
- { status: 403 },
136
- );
137
- const result = await appBackend.call(body.method, body.input, this, {
138
- computerId: request.headers.get(appBackendComputerHeader),
139
- actor: { kind: "member", memberId },
140
- });
141
- return Response.json(result);
142
- } catch (error) {
143
- return failure(
144
- error instanceof Error ? error : new Error("Non-error thrown"),
145
- );
146
- }
147
- }
148
91
  }
149
92
 
150
93
  export const BonsaiApp = appBackend.implement(BonsaiFacet);
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@fungi.computer/bonsai",
3
- "version": "0.9.13",
3
+ "version": "0.10.0",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "type": "module",
6
6
  "description": "Bonsai: a git platform for many agents working at once, on Workers and Artifacts",
7
7
  "dependencies": {
8
- "@fungi.computer/agar": "0.19.0",
8
+ "@fungi.computer/agar": "0.20.0",
9
9
  "@fungi.computer/caps": "0.12.0",
10
10
  "@fungi.computer/issues": "0.2.0",
11
- "@fungi.computer/oyster": "0.35.0",
12
- "@fungi.computer/puffball": "0.9.1",
11
+ "@fungi.computer/oyster": "0.36.0",
12
+ "@fungi.computer/puffball": "0.10.0",
13
13
  "@fungi.computer/sigils": "0.3.2",
14
14
  "@fungi.computer/stipe": "0.1.1",
15
15
  "@pierre/diffs": "1.3.6",
@@ -29,10 +29,10 @@
29
29
  "@fungi.computer/maosaico": "0.1.2",
30
30
  "@visx/hierarchy": "3.12.0",
31
31
  "@fungi.computer/gills": "0.3.0",
32
- "@fungi.computer/nacre": "0.7.1",
33
- "@fungi.computer/trellis": "0.15.6",
34
- "@fungi.computer/braid": "0.4.22",
35
- "@fungi.computer/workflows-wire": "0.4.22"
32
+ "@fungi.computer/nacre": "0.7.2",
33
+ "@fungi.computer/trellis": "0.16.0",
34
+ "@fungi.computer/braid": "0.4.24",
35
+ "@fungi.computer/workflows-wire": "0.4.24"
36
36
  },
37
37
  "devDependencies": {
38
38
  "playwright": "1.62.1",
@@ -52,7 +52,7 @@
52
52
  "eslint": "10.9.1",
53
53
  "oxlint": "1.78.0",
54
54
  "jsdom": "29.0.1",
55
- "@fungi.computer/computer-contract": "0.5.1"
55
+ "@fungi.computer/computer-contract": "0.5.3"
56
56
  },
57
57
  "botanical": {
58
58
  "role": "app",
@@ -203,6 +203,7 @@ function fixture(
203
203
  input,
204
204
  { bonsai, env },
205
205
  {
206
+ scope: { kind: "standalone" as const, tenant: "default" },
206
207
  actor: { kind: "member", memberId: "Levi" },
207
208
  computerId: null,
208
209
  role: "owner" as const,
@@ -217,6 +218,7 @@ function fixture(
217
218
  input,
218
219
  { bonsai, env },
219
220
  {
221
+ scope: { kind: "standalone" as const, tenant: "default" },
220
222
  actor: { kind: "member", memberId: "Ren" },
221
223
  computerId: null,
222
224
  role: "member" as const,
@@ -636,6 +638,7 @@ describe("apps.fork", () => {
636
638
  input,
637
639
  { bonsai, env },
638
640
  {
641
+ scope: { kind: "standalone" as const, tenant: "default" },
639
642
  actor: { kind: "member", memberId: "Levi" },
640
643
  computerId: null,
641
644
  role,
@@ -43,7 +43,11 @@ it("shares the actor runner and completes discarded file jobs without touching a
43
43
  const key = await backgroundOriginKey("background-runtime-test-key");
44
44
  const caller = async (memberId: string) =>
45
45
  backgroundContext(
46
- { actor: { kind: "member", memberId }, computerId: null },
46
+ {
47
+ scope: { kind: "standalone" as const, tenant: "default" },
48
+ actor: { kind: "member", memberId },
49
+ computerId: null,
50
+ },
47
51
  [],
48
52
  { name: "files.save", effect: "write" },
49
53
  await sealBackgroundOrigin(key, {
@@ -125,7 +129,11 @@ it("projects a retained missing-branch failure through the completed job receipt
125
129
  events: { emit: () => Promise.resolve() },
126
130
  };
127
131
  const caller = backgroundContext(
128
- { actor: { kind: "member", memberId: "owner" }, computerId: null },
132
+ {
133
+ scope: { kind: "standalone" as const, tenant: "default" },
134
+ actor: { kind: "member", memberId: "owner" },
135
+ computerId: null,
136
+ },
129
137
  [],
130
138
  { name: "files.save", effect: "write" },
131
139
  await sealBackgroundOrigin(
@@ -230,7 +230,11 @@ describe("Stored Change lifecycle from accepted host pushes", () => {
230
230
  },
231
231
  },
232
232
  },
233
- { computerId: null, actor: { kind: "member", memberId: "Levi" } },
233
+ {
234
+ scope: { kind: "standalone" as const, tenant: "default" },
235
+ computerId: null,
236
+ actor: { kind: "member", memberId: "Levi" },
237
+ },
234
238
  );
235
239
  expect(reads).toHaveLength(0);
236
240
  expect(peak).toBe(0);
@@ -483,6 +487,7 @@ it("refuses an Agent merge before Git transport or a lease", async () => {
483
487
  { repo: "pond", number: 1, head: first },
484
488
  { bonsai: f.bonsai },
485
489
  {
490
+ scope: { kind: "standalone" as const, tenant: "default" },
486
491
  computerId: null,
487
492
  actor: { kind: "agent", agentId: "morel" },
488
493
  idempotencyKey: "agent-merge",
@@ -500,6 +505,7 @@ it("refuses an Agent merge before Git transport or a lease", async () => {
500
505
 
501
506
  function caller(key: string): AppMethodCallContext {
502
507
  return {
508
+ scope: { kind: "standalone" as const, tenant: "default" },
503
509
  computerId: null,
504
510
  actor: { kind: "member", memberId: "Levi" },
505
511
  idempotencyKey: key,
@@ -59,6 +59,7 @@ afterEach(() => {
59
59
  });
60
60
  const encode = (text: string) => new TextEncoder().encode(text);
61
61
  const member = {
62
+ scope: { kind: "standalone" as const, tenant: "default" },
62
63
  actor: { kind: "member" as const, memberId: "owner" },
63
64
  computerId: null,
64
65
  };
@@ -232,6 +233,7 @@ it("an Agent reads committed typed absence without another member's new-file tex
232
233
  });
233
234
  const before = f.counted.total();
234
235
  const absent = await f.call("files.read", input, {
236
+ scope: { kind: "standalone" as const, tenant: "default" },
235
237
  actor: { kind: "agent", agentId: "luna" },
236
238
  computerId: null,
237
239
  });
@@ -439,8 +441,16 @@ it.each(["deleted", "new"] as const)(
439
441
  version: null,
440
442
  });
441
443
  for (const caller of [
442
- { actor: { kind: "agent" as const, agentId: "luna" }, computerId: null },
443
- { actor: { kind: "team-key" as const, keyId: "key" }, computerId: null },
444
+ {
445
+ scope: { kind: "standalone" as const, tenant: "default" },
446
+ actor: { kind: "agent" as const, agentId: "luna" },
447
+ computerId: null,
448
+ },
449
+ {
450
+ scope: { kind: "standalone" as const, tenant: "default" },
451
+ actor: { kind: "team-key" as const, keyId: "key" },
452
+ computerId: null,
453
+ },
444
454
  {
445
455
  ...member,
446
456
  workflow: {
@@ -553,6 +563,7 @@ it.each(["agent", "team-key"] as const)(
553
563
  }),
554
564
  );
555
565
  const caller: AppMethodCallContext = {
566
+ scope: { kind: "standalone" as const, tenant: "default" },
556
567
  computerId: null,
557
568
  actor:
558
569
  kind === "agent"
@@ -594,6 +605,7 @@ it.each([false, true])(
594
605
  async (held) => {
595
606
  const f = await fixture();
596
607
  const other = {
608
+ scope: { kind: "standalone" as const, tenant: "default" },
597
609
  actor: { kind: "member" as const, memberId: "other" },
598
610
  computerId: null,
599
611
  };
@@ -1392,7 +1404,11 @@ it("public save/sync/discard keep lanes separate and more ignores another member
1392
1404
  await f.call(
1393
1405
  "files.read",
1394
1406
  { repo: "pond", ref: "main", path: "README.md" },
1395
- { actor: { kind: "agent", agentId: "luna" }, computerId: null },
1407
+ {
1408
+ scope: { kind: "standalone" as const, tenant: "default" },
1409
+ actor: { kind: "agent", agentId: "luna" },
1410
+ computerId: null,
1411
+ },
1396
1412
  ),
1397
1413
  ).not.toHaveProperty("pending");
1398
1414
  });
@@ -1472,6 +1488,7 @@ it("Agents cannot use private file saves even on their own fork", async () => {
1472
1488
  revision: null,
1473
1489
  };
1474
1490
  const agent = {
1491
+ scope: { kind: "standalone" as const, tenant: "default" },
1475
1492
  actor: { kind: "agent" as const, agentId: "luna" },
1476
1493
  computerId: null,
1477
1494
  };
@@ -8,6 +8,7 @@ import { gitStore } from "../backend/git.js";
8
8
  import { BonsaiState, ensureBonsaiTables } from "../backend/state.js";
9
9
 
10
10
  const caller: AppMethodCallContext = {
11
+ scope: { kind: "standalone" as const, tenant: "default" },
11
12
  computerId: null,
12
13
  actor: { kind: "member", memberId: "Levi" },
13
14
  role: "owner",
@@ -6,7 +6,6 @@ import { tmpdir } from "node:os";
6
6
  import { join } from "node:path";
7
7
  import { unstable_dev } from "wrangler";
8
8
  import * as z from "zod";
9
- import { appBackendActorHeader } from "@fungi.computer/agar/backend";
10
9
  import { codeInsights, savedLayout } from "../shared/insights.ts";
11
10
  import { buildAppDeclaration } from "@fungi.computer/agar/backend-declaration";
12
11
  import { appBackend as bonsaiBackend } from "../backend/methods.ts";
@@ -152,8 +151,7 @@ try {
152
151
  `${origin}/methods?probe=${probe}`,
153
152
  {
154
153
  method: "PUT",
155
- headers: { [appBackendActorHeader]: actor },
156
- body: JSON.stringify({ method: name, input }),
154
+ body: JSON.stringify({ method: name, input, memberId: actor }),
157
155
  signal: globalThis.AbortSignal.timeout(10_000),
158
156
  },
159
157
  );
@@ -233,7 +231,7 @@ try {
233
231
  });
234
232
  assert.equal(
235
233
  legacy.status,
236
- 405,
234
+ 500,
237
235
  "the retired push POST must not remain a second router",
238
236
  );
239
237
 
@@ -4,7 +4,9 @@ import {
4
4
  ReadCopyBudgetExceeded,
5
5
  countingGit,
6
6
  } from "@fungi.computer/agar/read-copy";
7
- import { appBackendActorHeader } from "@fungi.computer/agar/backend";
7
+ import * as z from "zod";
8
+ import { jsonValue } from "../shared/contract.js";
9
+ import { appBackend } from "../backend/methods.js";
8
10
  import {
9
11
  gitPushQuestionSchema,
10
12
  type AppGitPushFact,
@@ -225,21 +227,24 @@ export class BonsaiPushProbe extends BonsaiApp {
225
227
  ["repos.create", { name: "pond" }, "levi"],
226
228
  ["repos.fork", { repo: "pond" }, "ada"],
227
229
  ] as const) {
228
- const response = await this.fetch(
229
- new Request("https://app.internal/", {
230
- method: "PUT",
231
- headers: {
232
- "Content-Type": "application/json",
233
- [appBackendActorHeader]: actor,
234
- },
235
- body: JSON.stringify({ method, input }),
236
- }),
237
- );
238
- if (!response.ok)
239
- throw new Error(`Seed failed: ${await response.text()}`);
230
+ await this.fixtureMethod(method, input, actor);
240
231
  }
241
232
  this.emitted.length = 0;
242
233
  }
234
+ /** The test host supplies attribution; the App has no HTTP identity bridge. */
235
+ /** Returns JSON text so the RPC stub stays shallowly typed. */
236
+ async fixtureMethod(
237
+ method: string,
238
+ input: unknown,
239
+ memberId: string,
240
+ ): Promise<string> {
241
+ const result = await appBackend.call(method, jsonValue.parse(input), this, {
242
+ scope: { kind: "standalone", tenant: "default" },
243
+ actor: { kind: "member", memberId },
244
+ computerId: null,
245
+ });
246
+ return JSON.stringify(result);
247
+ }
243
248
  async grow(): Promise<{ exhausted: boolean; pending: boolean }> {
244
249
  this.ctx.storage.sql.exec(
245
250
  "UPDATE native_git_fixture SET large=1 WHERE id=1",
@@ -303,7 +308,19 @@ export default {
303
308
  if (url.pathname === "/grow") return Response.json(await probe.grow());
304
309
  if (url.pathname === "/calls")
305
310
  return Response.json({ calls: await probe.calls() });
306
- if (url.pathname === "/methods") return probe.fetch(request);
311
+ if (url.pathname === "/methods") {
312
+ const input = z
313
+ .object({
314
+ method: z.string(),
315
+ input: z.json(),
316
+ memberId: z.string(),
317
+ })
318
+ .parse(await request.json());
319
+ return new Response(
320
+ await probe.fixtureMethod(input.method, input.input, input.memberId),
321
+ { headers: { "Content-Type": "application/json" } },
322
+ );
323
+ }
307
324
  if (url.pathname === "/authorize") {
308
325
  const question = gitPushQuestionSchema.safeParse(await request.json());
309
326
  if (!question.success) return new Response(null, { status: 400 });
@@ -110,6 +110,7 @@ test("App methods retain layouts by trusted caller and repository across reopeni
110
110
  },
111
111
  };
112
112
  const member = (memberId) => ({
113
+ scope: { kind: "standalone", tenant: "default" },
113
114
  computerId: null,
114
115
  actor: { kind: "member", memberId },
115
116
  });
@@ -142,7 +143,11 @@ test("App methods retain layouts by trusted caller and repository across reopeni
142
143
  await call(
143
144
  "insights.layout.get",
144
145
  { repo: "pond" },
145
- { computerId: null, actor: { kind: "agent", agentId: "a" } },
146
+ {
147
+ scope: { kind: "standalone", tenant: "default" },
148
+ computerId: null,
149
+ actor: { kind: "agent", agentId: "a" },
150
+ },
146
151
  ),
147
152
  { tiles: null },
148
153
  );
@@ -70,6 +70,7 @@ function replayBinding(
70
70
 
71
71
  const author = { name: "Morel", email: "morel@test.invalid" };
72
72
  const caller = (name: string) => ({
73
+ scope: { kind: "standalone" as const, tenant: "default" },
73
74
  actor: { kind: "member" as const, memberId: name },
74
75
  computerId: null,
75
76
  role: "owner" as const,
@@ -219,6 +220,7 @@ it("rechecks failed rows on replay, refuses the merge and releases its lease wit
219
220
  }),
220
221
  );
221
222
  const checker = {
223
+ scope: { kind: "standalone" as const, tenant: "default" },
222
224
  actor: { kind: "agent" as const, agentId: "ci" },
223
225
  computerId: null,
224
226
  };
@@ -36,11 +36,13 @@ const testKey = backgroundOriginKey("bonsai-merge-conflict-test-key");
36
36
  const instanceId = "bonsai-test-instance";
37
37
  const author = { name: "Owner", email: "owner@test.invalid" };
38
38
  const owner = (name: string) => ({
39
+ scope: { kind: "standalone" as const, tenant: "default" },
39
40
  actor: { kind: "member" as const, memberId: name },
40
41
  computerId: null,
41
42
  role: "owner" as const,
42
43
  });
43
44
  const agent = (name: string) => ({
45
+ scope: { kind: "standalone" as const, tenant: "default" },
44
46
  actor: { kind: "agent" as const, agentId: name },
45
47
  computerId: null,
46
48
  role: "member" as const,
@@ -56,6 +56,7 @@ function replayBinding(
56
56
 
57
57
  const author = { name: "Morel", email: "morel@test.invalid" };
58
58
  const caller = (name: string) => ({
59
+ scope: { kind: "standalone" as const, tenant: "default" },
59
60
  actor: { kind: "member" as const, memberId: name },
60
61
  computerId: null,
61
62
  role: "owner" as const,
@@ -92,7 +92,11 @@ describe("Bonsai transactional receipts and outbox", () => {
92
92
  "activity.list",
93
93
  {},
94
94
  { bonsai: { state, store, events: { emit } } },
95
- { computerId: null, actor: { kind: "member", memberId: "Levi" } },
95
+ {
96
+ scope: { kind: "standalone" as const, tenant: "default" },
97
+ computerId: null,
98
+ actor: { kind: "member", memberId: "Levi" },
99
+ },
96
100
  );
97
101
  expect(emit).not.toHaveBeenCalled();
98
102
  expect(state.pendingEvents()).toHaveLength(1);
@@ -119,6 +123,7 @@ describe("Bonsai transactional receipts and outbox", () => {
119
123
  events: { emit },
120
124
  };
121
125
  const caller = {
126
+ scope: { kind: "standalone" as const, tenant: "default" },
122
127
  computerId: null,
123
128
  actor: { kind: "member", memberId: "Levi" },
124
129
  } as const;
@@ -191,7 +196,11 @@ describe("Bonsai transactional receipts and outbox", () => {
191
196
  "repos.create",
192
197
  { name: "reed-pond" },
193
198
  { bonsai },
194
- { computerId: null, actor: { kind: "member", memberId: "Levi" } },
199
+ {
200
+ scope: { kind: "standalone" as const, tenant: "default" },
201
+ computerId: null,
202
+ actor: { kind: "member", memberId: "Levi" },
203
+ },
195
204
  ),
196
205
  ).resolves.toMatchObject({ name: "reed-pond" });
197
206
  expect(state.repo("reed-pond")).not.toBeNull();
@@ -320,14 +329,22 @@ describe("Bonsai transactional receipts and outbox", () => {
320
329
  "activity.list",
321
330
  {},
322
331
  { bonsai },
323
- { computerId: null, actor: { kind: "member", memberId: "Levi" } },
332
+ {
333
+ scope: { kind: "standalone" as const, tenant: "default" },
334
+ computerId: null,
335
+ actor: { kind: "member", memberId: "Levi" },
336
+ },
324
337
  );
325
338
  expect(delivered).toHaveLength(1);
326
339
  await appBackend.call(
327
340
  "insights.layout.save",
328
341
  { repo: "notes", tiles: { view: "overview", placements: [] } },
329
342
  { bonsai },
330
- { computerId: null, actor: { kind: "member", memberId: "Levi" } },
343
+ {
344
+ scope: { kind: "standalone" as const, tenant: "default" },
345
+ computerId: null,
346
+ actor: { kind: "member", memberId: "Levi" },
347
+ },
331
348
  );
332
349
  expect(delivered).toHaveLength(2);
333
350
  expect(delivered[1]).toEqual(delivered[0]);
@@ -395,6 +412,7 @@ describe("Bonsai transactional receipts and outbox", () => {
395
412
  events: { emit },
396
413
  };
397
414
  const caller = {
415
+ scope: { kind: "standalone" as const, tenant: "default" },
398
416
  computerId: null,
399
417
  actor: { kind: "member", memberId: "Levi" },
400
418
  } as const;
@@ -99,7 +99,11 @@ function fixture() {
99
99
  method,
100
100
  input,
101
101
  { bonsai },
102
- { actor: { kind: "member", memberId: "Levi" }, computerId: null },
102
+ {
103
+ scope: { kind: "standalone" as const, tenant: "default" },
104
+ actor: { kind: "member", memberId: "Levi" },
105
+ computerId: null,
106
+ },
103
107
  );
104
108
  return {
105
109
  database,
@@ -130,7 +134,11 @@ test("a repository created in this frame reads its saved copy after reopen witho
130
134
  "repos.get",
131
135
  { repo: "pond" },
132
136
  { bonsai: reopened },
133
- { actor: { kind: "member", memberId: "Levi" }, computerId: null },
137
+ {
138
+ scope: { kind: "standalone" as const, tenant: "default" },
139
+ actor: { kind: "member", memberId: "Levi" },
140
+ computerId: null,
141
+ },
134
142
  );
135
143
  expect(result).toMatchObject({
136
144
  defaultBranch: "main",
@@ -174,7 +182,11 @@ test("accepted pushes prepare Change summaries and details so screens do not cal
174
182
  const changesGill = await appBackend.gill(
175
183
  { id: "open-changes", params: { repo: "pond" } },
176
184
  { bonsai: f.bonsai },
177
- { actor: { kind: "member", memberId: "Levi" }, computerId: null },
185
+ {
186
+ scope: { kind: "standalone" as const, tenant: "default" },
187
+ actor: { kind: "member", memberId: "Levi" },
188
+ computerId: null,
189
+ },
178
190
  );
179
191
  expect(changesGill).toMatchObject({
180
192
  state: "full",
@@ -475,7 +487,11 @@ test("Commit pages use the saved window at the requested size and reject stale a
475
487
  const commitsGill = await appBackend.gill(
476
488
  { id: "recent-commits", params: { repo: "pond", branch: "main" } },
477
489
  { bonsai: f.bonsai },
478
- { actor: { kind: "member", memberId: "Levi" }, computerId: null },
490
+ {
491
+ scope: { kind: "standalone" as const, tenant: "default" },
492
+ actor: { kind: "member", memberId: "Levi" },
493
+ computerId: null,
494
+ },
479
495
  );
480
496
  if (!("rows" in commitsGill) || commitsGill.state !== "full")
481
497
  throw new Error("Expected a full commit page");
@@ -550,7 +566,11 @@ test("repository picker pages the saved canonical catalog after facet reconstruc
550
566
  "repos.options",
551
567
  { params: {}, limit: 1 },
552
568
  { bonsai: reopened },
553
- { actor: { kind: "member", memberId: "Levi" }, computerId: null },
569
+ {
570
+ scope: { kind: "standalone" as const, tenant: "default" },
571
+ actor: { kind: "member", memberId: "Levi" },
572
+ computerId: null,
573
+ },
554
574
  );
555
575
  expect(result).toMatchObject({
556
576
  options: [{ value: "forest", label: "forest", detail: "Trees" }],
@@ -631,7 +651,11 @@ test("branch options use the chosen repo's saved refs, page without tags and ref
631
651
  ? { params, limit: 1 }
632
652
  : { params, limit: 1, after },
633
653
  { bonsai: reopened },
634
- { actor: { kind: "member", memberId: "Levi" }, computerId: null },
654
+ {
655
+ scope: { kind: "standalone" as const, tenant: "default" },
656
+ actor: { kind: "member", memberId: "Levi" },
657
+ computerId: null,
658
+ },
635
659
  );
636
660
  const before = f.counted.total();
637
661
  const first = decodeGillOptionsResponse(await read({ repo: "pond" }));
@@ -26,6 +26,7 @@ import { commitDetail, graph, type JsonValue } from "../shared/contract.js";
26
26
  import { copyRebuildPage, fileList } from "@fungi.computer/agar/roles/files";
27
27
 
28
28
  const actor = {
29
+ scope: { kind: "standalone" as const, tenant: "default" },
29
30
  actor: { kind: "member" as const, memberId: "owner" },
30
31
  computerId: null,
31
32
  };
@@ -17,6 +17,7 @@ import { invalidateFilesCopies } from "../backend/files-copy.js";
17
17
  import { invalidateGraphCommitCopies } from "../backend/graph-commit-copies.js";
18
18
 
19
19
  const caller = {
20
+ scope: { kind: "standalone" as const, tenant: "default" },
20
21
  actor: { kind: "member" as const, memberId: "Levi" },
21
22
  computerId: null,
22
23
  role: "owner" as const,
@@ -53,18 +53,25 @@ function fixture() {
53
53
 
54
54
  it("refuses repository deletion before state or provider writes for every non-owner caller", async () => {
55
55
  const callers: readonly AppMethodCallContext[] = [
56
- { computerId: null, actor: { kind: "member", memberId: "Owner" } },
57
56
  {
57
+ scope: { kind: "standalone" as const, tenant: "default" },
58
+ computerId: null,
59
+ actor: { kind: "member", memberId: "Owner" },
60
+ },
61
+ {
62
+ scope: { kind: "standalone" as const, tenant: "default" },
58
63
  computerId: null,
59
64
  actor: { kind: "member", memberId: "member" },
60
65
  role: "member",
61
66
  },
62
67
  {
68
+ scope: { kind: "standalone" as const, tenant: "default" },
63
69
  computerId: null,
64
70
  actor: { kind: "agent", agentId: "agent" },
65
71
  role: "owner",
66
72
  },
67
73
  {
74
+ scope: { kind: "standalone" as const, tenant: "default" },
68
75
  computerId: null,
69
76
  actor: { kind: "team-key", keyId: "key" },
70
77
  role: "owner",
@@ -345,6 +352,7 @@ it("preserves the readiness generation so an in-flight refresh cannot republish
345
352
  });
346
353
 
347
354
  const owner: AppMethodCallContext = {
355
+ scope: { kind: "standalone" as const, tenant: "default" },
348
356
  computerId: null,
349
357
  actor: { kind: "member", memberId: "Levi" },
350
358
  role: "owner",
@@ -311,7 +311,12 @@ test("the Save to git flow runs through Shed's real run handler and Inkcap's rea
311
311
  ]);
312
312
 
313
313
  async function runShed(command, idempotencyKey) {
314
- const caller = { actor, computerId, idempotencyKey };
314
+ const caller = {
315
+ scope: { kind: "standalone", tenant: "default" },
316
+ actor,
317
+ computerId,
318
+ idempotencyKey,
319
+ };
315
320
  const input = { command, gitAccess };
316
321
  const deadline = Date.now() + 20000;
317
322
  for (;;) {
@@ -355,7 +360,7 @@ test("the Save to git flow runs through Shed's real run handler and Inkcap's rea
355
360
  "writeFile",
356
361
  { path: setup.filePath, content: contactSheet },
357
362
  inkcapContext,
358
- { actor, computerId },
363
+ { scope: { kind: "standalone", tenant: "default" }, actor, computerId },
359
364
  ),
360
365
  );
361
366
  assert.ok(
package/web/transport.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  /**
2
2
  * How the UI reaches Bonsai's App methods: agar's `app.methods` capability
3
- * when the host offers it, otherwise the admitted App backend. The host attributes every call
4
- * to the signed-in person.
3
+ * through the host's admitted method route. Only the host attributes a call.
5
4
  */
6
5
  import { appsOpen, type AppRoleChoice } from "@fungi.computer/agar/apps";
7
6
  import { AppError, type AppRoot } from "@fungi.computer/agar";
8
- import { appBackend, appMethods } from "@fungi.computer/agar/backend";
7
+ import { appMethods } from "@fungi.computer/agar/backend";
9
8
  import type * as z from "zod";
10
9
  import { errorBody, jsonValue, type JsonValue } from "../shared/contract.js";
11
10
  import {
@@ -84,18 +83,13 @@ export async function callMethod<S extends z.ZodType>(
84
83
  ): Promise<z.infer<S>> {
85
84
  if (connection === null)
86
85
  throw new ApiError(503, "Open Bonsai from an App host such as Oyster");
87
- // Typed method calls let the host apply each method's effect (public
88
- // visitors may call read methods); hosts without them get the backend.
86
+ // The host applies each method's effect and supplies caller identity.
89
87
  const capabilities = connection.capabilities;
90
88
  let result;
91
89
  try {
92
- result = capabilities.has(appMethods)
93
- ? await capabilities
94
- .require(appMethods)
95
- .call(method, JSON.stringify(input))
96
- : await capabilities
97
- .require(appBackend)
98
- .request(JSON.stringify({ method, input }));
90
+ result = await capabilities
91
+ .require(appMethods)
92
+ .call(method, JSON.stringify(input));
99
93
  } catch (error) {
100
94
  if (error instanceof AppError && error.code === "CAPABILITY_DENIED")
101
95
  throw new ApiError(403, "Sign in to this Oyster to do that");