@fungi.computer/bonsai 0.12.1 → 0.12.3

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,41 @@
1
1
  # @fungi.computer/bonsai
2
2
 
3
+ ## 0.12.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Changes since 0.12.2:
8
+
9
+ - fix(bonsai): decode host workflow status across releases
10
+
11
+ - Updated dependencies
12
+ - Updated dependencies
13
+ - Updated dependencies
14
+ - @fungi.computer/agar@0.27.2
15
+ - @fungi.computer/caps@0.12.9
16
+ - @fungi.computer/oyster@0.57.0
17
+ - @fungi.computer/trellis@0.28.3
18
+ - @fungi.computer/braid@0.6.10
19
+ - @fungi.computer/nacre@0.9.3
20
+ - @fungi.computer/workflows-wire@0.7.11
21
+
22
+ ## 0.12.2
23
+
24
+ ### Patch Changes
25
+
26
+ - Changes since 0.12.1:
27
+
28
+ - fix(shed): name why a Shed, Bonsai, Inkcap or TUI action failed
29
+
30
+ - Updated dependencies
31
+ - Updated dependencies
32
+ - @fungi.computer/agar@0.27.1
33
+ - @fungi.computer/oyster@0.56.2
34
+ - @fungi.computer/trellis@0.28.2
35
+ - @fungi.computer/braid@0.6.9
36
+ - @fungi.computer/nacre@0.9.2
37
+ - @fungi.computer/workflows-wire@0.7.10
38
+
3
39
  ## 0.12.1
4
40
 
5
41
  ### Patch Changes
@@ -9,7 +9,6 @@ import type { GraphStartRequest } from "@fungi.computer/braid/runtime";
9
9
  import {
10
10
  repositoryWorkflowSourceSchema,
11
11
  runReply,
12
- statusReply,
13
12
  runsReplySchema,
14
13
  } from "@fungi.computer/workflows-wire";
15
14
  import { AppMethodRefusal } from "@fungi.computer/agar/backend";
@@ -31,9 +30,7 @@ export type BuildWorkflowBindings = Readonly<{
31
30
  workflowId?: string;
32
31
  }): Promise<ReturnType<typeof runsReplySchema.parse>>;
33
32
  runGraph(input: GraphStartRequest): Promise<BuildWorkflowRunReply>;
34
- graphStatus(input: {
35
- runId: string;
36
- }): Promise<ReturnType<typeof statusReply.parse>>;
33
+ graphStatus(input: { runId: string }): Promise<typeof S.Json.Type>;
37
34
  }>;
38
35
  }>;
39
36
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runReply,
3
- statusReply,
3
+ hostStatusReply,
4
4
  runsReplySchema,
5
5
  } from "@fungi.computer/workflows-wire";
6
6
  import {
@@ -301,7 +301,7 @@ const definition = defineAppBackend<BonsaiMethodContext>({
301
301
  effect: "read",
302
302
  requires: ["workflow.run"],
303
303
  input: z.strictObject({ runId: z.string().min(1).max(256) }),
304
- output: statusReply,
304
+ output: hostStatusReply,
305
305
  handler: async (input, context: BonsaiMethodContext, caller) => {
306
306
  if (caller.role !== "owner")
307
307
  throw new AppMethodRefusal("forbidden", "Owner only");
@@ -310,7 +310,7 @@ const definition = defineAppBackend<BonsaiMethodContext>({
310
310
  "unavailable",
311
311
  "Workflow access is not granted",
312
312
  );
313
- return statusReply.parse(
313
+ return hostStatusReply.parse(
314
314
  await context.env.WORKFLOWS.graphStatus(input),
315
315
  );
316
316
  },
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@fungi.computer/bonsai",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
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.27.0",
9
- "@fungi.computer/caps": "0.12.8",
8
+ "@fungi.computer/agar": "0.27.2",
9
+ "@fungi.computer/caps": "0.12.9",
10
10
  "@fungi.computer/issues": "0.2.0",
11
- "@fungi.computer/oyster": "0.56.1",
11
+ "@fungi.computer/oyster": "0.57.0",
12
12
  "@fungi.computer/puffball": "0.15.0",
13
13
  "@fungi.computer/sigils": "0.3.2",
14
14
  "@fungi.computer/stipe": "0.1.1",
@@ -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.4.0",
32
- "@fungi.computer/nacre": "0.9.1",
33
- "@fungi.computer/trellis": "0.28.1",
34
- "@fungi.computer/braid": "0.6.8",
35
- "@fungi.computer/workflows-wire": "0.7.9"
32
+ "@fungi.computer/nacre": "0.9.3",
33
+ "@fungi.computer/trellis": "0.28.3",
34
+ "@fungi.computer/braid": "0.6.10",
35
+ "@fungi.computer/workflows-wire": "0.7.11"
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.6.2"
55
+ "@fungi.computer/computer-contract": "0.6.4"
56
56
  },
57
57
  "botanical": {
58
58
  "role": "app",
@@ -14,7 +14,7 @@ import { appBackend, type AppsBindingReply } from "../backend/methods.js";
14
14
  import { gitStore } from "../backend/git.js";
15
15
  import { ensureBonsaiTables, BonsaiState } from "../backend/state.js";
16
16
  import type { Bonsai } from "../backend/service.js";
17
- import type { AppBuildInstallation } from "../shared/contract.js";
17
+ import type { AppBuildInstallation, JsonValue } from "../shared/contract.js";
18
18
  import {
19
19
  appBackendBindingOperation,
20
20
  scopeOperationToMethod,
@@ -66,6 +66,7 @@ function fixture(
66
66
  installation?: AppBuildInstallation,
67
67
  buildStatusReply?: AppsBindingReply,
68
68
  selectReply?: AppsBindingReply,
69
+ workflowStatusReply?: JsonValue,
69
70
  ) {
70
71
  const calls: Calls = {};
71
72
  const build = {
@@ -119,18 +120,19 @@ function fixture(
119
120
  },
120
121
  graphStatus: () =>
121
122
  Promise.resolve(
122
- statusReply.parse({
123
- runId: "run_manual",
124
- planDigest: "sha256:" + "d".repeat(64),
125
- outcome: "active",
126
- title: "Build on merge",
127
- input: {},
128
- status: "running",
129
- events: [],
130
- reviews: [],
131
- output: null,
132
- error: null,
133
- }),
123
+ workflowStatusReply ??
124
+ statusReply.parse({
125
+ runId: "run_manual",
126
+ planDigest: "sha256:" + "d".repeat(64),
127
+ outcome: "active",
128
+ title: "Build on merge",
129
+ input: {},
130
+ status: "running",
131
+ events: [],
132
+ reviews: [],
133
+ output: null,
134
+ error: null,
135
+ }),
134
136
  ),
135
137
  },
136
138
  APPS: {
@@ -335,6 +337,62 @@ describe("App authoring methods", () => {
335
337
  );
336
338
  });
337
339
 
340
+ it("reads build Workflow status from an older host without recorded input", async () => {
341
+ const status = {
342
+ runId: "run_manual",
343
+ planDigest: "sha256:" + "d".repeat(64),
344
+ outcome: "active",
345
+ title: "Build on merge",
346
+ status: "running",
347
+ events: [],
348
+ reviews: [],
349
+ output: null,
350
+ error: null,
351
+ };
352
+ const f = fixture(
353
+ undefined,
354
+ undefined,
355
+ undefined,
356
+ undefined,
357
+ undefined,
358
+ status,
359
+ );
360
+ await expect(
361
+ f.owner("apps.buildWorkflowRun", { runId: "run_manual" }),
362
+ ).resolves.toEqual({ ...status, input: null });
363
+ });
364
+
365
+ it("reads build Workflow status from a newer host without exposing its added fields", async () => {
366
+ const status = {
367
+ runId: "run_manual",
368
+ planDigest: "sha256:" + "d".repeat(64),
369
+ outcome: "active",
370
+ title: "Build on merge",
371
+ input: { repo: "my-fork" },
372
+ status: "running",
373
+ events: [],
374
+ reviews: [],
375
+ output: null,
376
+ error: null,
377
+ };
378
+ const f = fixture(undefined, undefined, undefined, undefined, undefined, {
379
+ ...status,
380
+ startedBy: { kind: "member", memberId: "Levi" },
381
+ });
382
+ await expect(
383
+ f.owner("apps.buildWorkflowRun", { runId: "run_manual" }),
384
+ ).resolves.toEqual(status);
385
+ });
386
+
387
+ it("preserves a host refusal while reading build Workflow status", async () => {
388
+ const f = fixture(undefined, undefined, undefined, undefined, undefined, {
389
+ error: "not_granted",
390
+ });
391
+ await expect(
392
+ f.owner("apps.buildWorkflowRun", { runId: "run_manual" }),
393
+ ).resolves.toEqual({ error: "not_granted" });
394
+ });
395
+
338
396
  it("the owner action starts the retained build/verify/install Workflow with its edited target", async () => {
339
397
  const f = fixture();
340
398
  const input = {
@@ -575,7 +575,7 @@ describe("Bonsai change page", () => {
575
575
  await Promise.resolve();
576
576
  });
577
577
  expect(container.querySelector('[role="status"]')?.textContent).toBe(
578
- "The merge did not complete. Review the Change and try again.",
578
+ "The merge did not complete: the Change is still open and reported no conflict. Review it before merging again.",
579
579
  );
580
580
  });
581
581
 
@@ -875,7 +875,7 @@ describe("Bonsai change page", () => {
875
875
  await Promise.resolve();
876
876
  });
877
877
  expect(container.querySelector('[role="status"]')?.textContent).toBe(
878
- "The merge did not complete. Review the Change and try again.",
878
+ "The merge did not complete: the Change is still open and reported no conflict. Review it before merging again.",
879
879
  );
880
880
 
881
881
  // Second click: sawMerging must reset, or this click's own optimistic
@@ -910,7 +910,7 @@ describe("Bonsai change page", () => {
910
910
  await Promise.resolve();
911
911
  });
912
912
  expect(container.querySelector('[role="status"]')?.textContent).toBe(
913
- "The merge did not complete. Review the Change and try again.",
913
+ "The merge did not complete: the Change is still open and reported no conflict. Review it before merging again.",
914
914
  );
915
915
  });
916
916
  });
@@ -105,7 +105,7 @@ it.each<FileSaveResult>([
105
105
  async (result) => {
106
106
  const f = fixture(empty, result);
107
107
  await expect(writeFirstIssue("pond", "main")).rejects.toThrow(
108
- "could not be created",
108
+ "The issue could not be created: ",
109
109
  );
110
110
  expect(f.open).not.toHaveBeenCalled();
111
111
  },
@@ -230,7 +230,7 @@ export function ChangePage({ repo, number }: { repo: string; number: number }) {
230
230
  change.head,
231
231
  )
232
232
  : sawMerging.current
233
- ? "The merge did not complete. Review the Change and try again."
233
+ ? "The merge did not complete: the Change is still open and reported no conflict. Review it before merging again."
234
234
  : outcome
235
235
  : outcome;
236
236
  const perform = async (action: "merge" | "approve" | "close") => {
@@ -1,6 +1,28 @@
1
- import { fileContent, fileSaveResult } from "@fungi.computer/agar/roles/files";
1
+ import {
2
+ fileContent,
3
+ fileSaveResult,
4
+ type FileSaveResult,
5
+ } from "@fungi.computer/agar/roles/files";
2
6
  import { callMethod, editInFilesEditor, filesEditor } from "./transport.js";
3
7
 
8
+ const saveReasons = {
9
+ branch_missing: "the branch no longer exists",
10
+ access_changed: "your access to it changed",
11
+ sync_failed: "the save could not be synced to the branch",
12
+ permanent_material: "the file holds material that can never be saved",
13
+ "not-source-writer": "you cannot write to this Source",
14
+ "background-unavailable": "background saving is unavailable",
15
+ } as const;
16
+
17
+ /** Why a save that did not land did not land, in plain words. */
18
+ function saveRefusal(
19
+ result: Exclude<FileSaveResult, { kind: "saved" | "synced" }>,
20
+ ): string {
21
+ return result.kind === "conflict"
22
+ ? "the file changed while it was being created"
23
+ : saveReasons[result.reason];
24
+ }
25
+
4
26
  export const firstIssuePath = "issues/general/01-first-issue.md";
5
27
 
6
28
  /** Create the first issue through the editor's save door, then open it there. */
@@ -57,7 +79,9 @@ Add any details that will help someone understand the issue.
57
79
  fileSaveResult,
58
80
  );
59
81
  if (result.kind !== "saved" && result.kind !== "synced")
60
- throw new Error("The issue could not be created. Try again.");
82
+ throw new Error(
83
+ `The issue could not be created: ${saveRefusal(result)}.`,
84
+ );
61
85
  }
62
86
  await editInFilesEditor(repo, branch, firstIssuePath);
63
87
  }