@yaag/runtime 0.8.2 → 0.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaag/runtime",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -30,7 +30,8 @@ export interface RunCheckpointOptions {
30
30
  * What one publication attempt did. `published` covers both a written artifact
31
31
  * and a Run that keeps none. `displaced` carries the error that must become the
32
32
  * Run's outcome. `lost` reports a Checkpoint the Run asked for and did not get,
33
- * while a primary program error keeps the outcome.
33
+ * while the Run keeps its own outcome — a completed result, or a primary
34
+ * program error (ADR-0021 amendment).
34
35
  */
35
36
  export type RunCheckpointResult =
36
37
  | { readonly kind: "published" }
@@ -66,18 +67,21 @@ export async function publishRunCheckpoint(
66
67
  writeRecordingDiagnostic(error);
67
68
  return { kind: "lost", message: String(error) };
68
69
  }
69
- if (options.outcome === "stopped") {
70
- return {
71
- kind: "displaced",
72
- error: new Error(`run stopped but is not restorable: ${String(error)}`, { cause: error }),
73
- };
70
+ // A completed Run keeps its outcome and its result: the work is done, and
71
+ // no restorability promise is broken. The lost Cassette rides
72
+ // run_end.checkpointLost and the stderr diagnostic instead of displacing
73
+ // the outcome (ADR-0021 amendment).
74
+ if (options.outcome === "completed") {
75
+ const message = `run completed but its Cassette could not be written: ${String(error)}`;
76
+ writeRecordingDiagnostic(message);
77
+ return { kind: "lost", message };
74
78
  }
75
- // A requested checkpoint silently going missing is worse than rejecting an
76
- // otherwise successful Run (ADR-0021). The two facts stay readable: the
77
- // program completed, and the Cassette did not land.
79
+ // A pausing or stopped Run promises restorability, and a Checkpoint that
80
+ // did not land makes that acknowledgement a lie, so the failure takes the
81
+ // outcome (ADR-0021: a flush failure is a hard failure there).
78
82
  return {
79
83
  kind: "displaced",
80
- error: new Error(`run completed but its Cassette could not be written: ${String(error)}`, {
84
+ error: new Error(`run ${options.outcome} but is not restorable: ${String(error)}`, {
81
85
  cause: error,
82
86
  }),
83
87
  };