@earendil-works/pi-durable 0.99.1 → 1.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.
- package/CHANGELOG.md +7 -0
- package/README.md +557 -46
- package/dist/entries.d.ts +20 -2
- package/dist/entries.d.ts.map +1 -1
- package/dist/entries.js +14 -1
- package/dist/entries.js.map +1 -1
- package/dist/env/index.d.ts +18 -38
- package/dist/env/index.d.ts.map +1 -1
- package/dist/env/index.js +2 -0
- package/dist/env/index.js.map +1 -1
- package/dist/env/node.d.ts +2 -0
- package/dist/env/node.d.ts.map +1 -1
- package/dist/env/node.js +53 -58
- package/dist/env/node.js.map +1 -1
- package/dist/harness/agent.d.ts +31 -0
- package/dist/harness/agent.d.ts.map +1 -0
- package/dist/harness/agent.js +209 -0
- package/dist/harness/agent.js.map +1 -0
- package/dist/harness/compaction.d.ts +56 -0
- package/dist/harness/compaction.d.ts.map +1 -0
- package/dist/harness/compaction.js +382 -0
- package/dist/harness/compaction.js.map +1 -0
- package/dist/harness/context.d.ts +8 -0
- package/dist/harness/context.d.ts.map +1 -1
- package/dist/harness/context.js +32 -21
- package/dist/harness/context.js.map +1 -1
- package/dist/harness/define.d.ts +18 -0
- package/dist/harness/define.d.ts.map +1 -0
- package/dist/harness/define.js +25 -0
- package/dist/harness/define.js.map +1 -0
- package/dist/harness/events.d.ts +166 -0
- package/dist/harness/events.d.ts.map +1 -0
- package/dist/harness/events.js +319 -0
- package/dist/harness/events.js.map +1 -0
- package/dist/harness/generation.d.ts +36 -7
- package/dist/harness/generation.d.ts.map +1 -1
- package/dist/harness/generation.js +356 -82
- package/dist/harness/generation.js.map +1 -1
- package/dist/harness/harness.d.ts.map +1 -1
- package/dist/harness/harness.js +141 -106
- package/dist/harness/harness.js.map +1 -1
- package/dist/harness/inbox.d.ts +59 -0
- package/dist/harness/inbox.d.ts.map +1 -0
- package/dist/harness/inbox.js +97 -0
- package/dist/harness/inbox.js.map +1 -0
- package/dist/harness/json.d.ts +10 -0
- package/dist/harness/json.d.ts.map +1 -0
- package/dist/harness/json.js +33 -0
- package/dist/harness/json.js.map +1 -0
- package/dist/harness/live.d.ts +66 -7
- package/dist/harness/live.d.ts.map +1 -1
- package/dist/harness/live.js +71 -7
- package/dist/harness/live.js.map +1 -1
- package/dist/harness/output.d.ts +62 -0
- package/dist/harness/output.d.ts.map +1 -0
- package/dist/harness/output.js +261 -0
- package/dist/harness/output.js.map +1 -0
- package/dist/harness/prompt.d.ts +9 -6
- package/dist/harness/prompt.d.ts.map +1 -1
- package/dist/harness/prompt.js +57 -14
- package/dist/harness/prompt.js.map +1 -1
- package/dist/harness/registry.d.ts +2 -3
- package/dist/harness/registry.d.ts.map +1 -1
- package/dist/harness/registry.js +69 -277
- package/dist/harness/registry.js.map +1 -1
- package/dist/harness/scheduler.d.ts +42 -12
- package/dist/harness/scheduler.d.ts.map +1 -1
- package/dist/harness/scheduler.js +649 -75
- package/dist/harness/scheduler.js.map +1 -1
- package/dist/harness/submissions.d.ts +14 -9
- package/dist/harness/submissions.d.ts.map +1 -1
- package/dist/harness/submissions.js +76 -34
- package/dist/harness/submissions.js.map +1 -1
- package/dist/harness/task-graph.d.ts +49 -0
- package/dist/harness/task-graph.d.ts.map +1 -0
- package/dist/harness/task-graph.js +163 -0
- package/dist/harness/task-graph.js.map +1 -0
- package/dist/harness/tool.d.ts +36 -0
- package/dist/harness/tool.d.ts.map +1 -0
- package/dist/harness/tool.js +415 -0
- package/dist/harness/tool.js.map +1 -0
- package/dist/harness/types.d.ts +330 -125
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/harness/types.js.map +1 -1
- package/dist/harness/usage.d.ts +18 -0
- package/dist/harness/usage.d.ts.map +1 -0
- package/dist/harness/usage.js +57 -0
- package/dist/harness/usage.js.map +1 -0
- package/dist/harness/view.d.ts +43 -0
- package/dist/harness/view.d.ts.map +1 -0
- package/dist/harness/view.js +189 -0
- package/dist/harness/view.js.map +1 -0
- package/dist/index.d.ts +13 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/session/observation.d.ts +18 -11
- package/dist/session/observation.d.ts.map +1 -1
- package/dist/session/observation.js +24 -13
- package/dist/session/observation.js.map +1 -1
- package/dist/session/session.d.ts +10 -1
- package/dist/session/session.d.ts.map +1 -1
- package/dist/session/session.js +23 -5
- package/dist/session/session.js.map +1 -1
- package/dist/session/transaction.d.ts +12 -3
- package/dist/session/transaction.d.ts.map +1 -1
- package/dist/session/transaction.js +90 -31
- package/dist/session/transaction.js.map +1 -1
- package/dist/storage/jsonl/storage.d.ts +22 -2
- package/dist/storage/jsonl/storage.d.ts.map +1 -1
- package/dist/storage/jsonl/storage.js +1 -1
- package/dist/storage/jsonl/storage.js.map +1 -1
- package/dist/storage/memory.js +1 -1
- package/dist/storage/memory.js.map +1 -1
- package/dist/storage/sqlite/database.d.ts +26 -19
- package/dist/storage/sqlite/database.d.ts.map +1 -1
- package/dist/storage/sqlite/database.js.map +1 -1
- package/dist/storage/sqlite/index.d.ts +1 -1
- package/dist/storage/sqlite/index.d.ts.map +1 -1
- package/dist/storage/sqlite/index.js.map +1 -1
- package/dist/storage/sqlite/migrations.js +7 -7
- package/dist/storage/sqlite/migrations.js.map +1 -1
- package/dist/storage/sqlite/node.d.ts +23 -7
- package/dist/storage/sqlite/node.d.ts.map +1 -1
- package/dist/storage/sqlite/node.js +129 -47
- package/dist/storage/sqlite/node.js.map +1 -1
- package/dist/storage/sqlite/storage.d.ts +12 -0
- package/dist/storage/sqlite/storage.d.ts.map +1 -1
- package/dist/storage/sqlite/storage.js +121 -129
- package/dist/storage/sqlite/storage.js.map +1 -1
- package/dist/testing/storage-benchmark.d.ts.map +1 -1
- package/dist/testing/storage-benchmark.js +0 -1
- package/dist/testing/storage-benchmark.js.map +1 -1
- package/dist/testing/storage-conformance.d.ts.map +1 -1
- package/dist/testing/storage-conformance.js +34 -2
- package/dist/testing/storage-conformance.js.map +1 -1
- package/dist/tools/bash.d.ts +28 -0
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +70 -0
- package/dist/tools/bash.js.map +1 -0
- package/dist/tools/edit-diff.d.ts +89 -0
- package/dist/tools/edit-diff.d.ts.map +1 -0
- package/dist/tools/edit-diff.js +386 -0
- package/dist/tools/edit-diff.js.map +1 -0
- package/dist/tools/edit.d.ts +18 -0
- package/dist/tools/edit.d.ts.map +1 -0
- package/dist/tools/edit.js +117 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/env.d.ts +5 -0
- package/dist/tools/env.d.ts.map +1 -0
- package/dist/tools/env.js +7 -0
- package/dist/tools/env.js.map +1 -0
- package/dist/tools/file-mutation-queue.d.ts +9 -0
- package/dist/tools/file-mutation-queue.d.ts.map +1 -0
- package/dist/tools/file-mutation-queue.js +52 -0
- package/dist/tools/file-mutation-queue.js.map +1 -0
- package/dist/tools/image.d.ts +2 -0
- package/dist/tools/image.d.ts.map +1 -0
- package/dist/tools/image.js +92 -0
- package/dist/tools/image.js.map +1 -0
- package/dist/tools/index.d.ts +23 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +15 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/path-utils.d.ts +5 -0
- package/dist/tools/path-utils.d.ts.map +1 -0
- package/dist/tools/path-utils.js +26 -0
- package/dist/tools/path-utils.js.map +1 -0
- package/dist/tools/read.d.ts +17 -0
- package/dist/tools/read.d.ts.map +1 -0
- package/dist/tools/read.js +101 -0
- package/dist/tools/read.js.map +1 -0
- package/dist/tools/write.d.ts +10 -0
- package/dist/tools/write.d.ts.map +1 -0
- package/dist/tools/write.js +31 -0
- package/dist/tools/write.js.map +1 -0
- package/dist/{env/utils/truncate.d.ts → truncate.d.ts} +1 -17
- package/dist/truncate.d.ts.map +1 -0
- package/dist/truncate.js +146 -0
- package/dist/truncate.js.map +1 -0
- package/dist/types.d.ts +97 -19
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +32 -14
- package/dist/env/utils/adaptive-publisher.d.ts +0 -24
- package/dist/env/utils/adaptive-publisher.d.ts.map +0 -1
- package/dist/env/utils/adaptive-publisher.js +0 -79
- package/dist/env/utils/adaptive-publisher.js.map +0 -1
- package/dist/env/utils/output-capture.d.ts +0 -31
- package/dist/env/utils/output-capture.d.ts.map +0 -1
- package/dist/env/utils/output-capture.js +0 -238
- package/dist/env/utils/output-capture.js.map +0 -1
- package/dist/env/utils/truncate.d.ts.map +0 -1
- package/dist/env/utils/truncate.js +0 -294
- package/dist/env/utils/truncate.js.map +0 -1
- package/dist/harness/config.d.ts +0 -20
- package/dist/harness/config.d.ts.map +0 -1
- package/dist/harness/config.js +0 -18
- package/dist/harness/config.js.map +0 -1
- package/docs/chord-delta-findings.md +0 -358
- package/docs/pico-v5-chord-usage.md +0 -373
- package/docs/pico-v5-handoff.md +0 -581
- package/docs/pico-v5.md +0 -3084
|
@@ -50,10 +50,13 @@ export declare class Transaction implements Tx {
|
|
|
50
50
|
task(id: TaskId): Promise<AnyTaskRecord | undefined>;
|
|
51
51
|
scanConversations(query: ConversationQuery, limit: number, cursor?: Cursor): Promise<import("../types.ts").Page<ConversationRecord, Readonly<Record<string, JsonValue>>>>;
|
|
52
52
|
scanEntries(query: EntryQuery, limit: number, cursor?: Cursor): Promise<import("../types.ts").Page<EntryRecord, Readonly<Record<string, JsonValue>>>>;
|
|
53
|
+
latestHeadMarker(conversationId: ConversationId): Promise<(EntryRecord & {
|
|
54
|
+
readonly head: EntryId;
|
|
55
|
+
}) | undefined>;
|
|
53
56
|
scanTasks(query: TaskQuery, limit: number, cursor?: Cursor): Promise<import("../types.ts").Page<TaskRecord<JsonValue, JsonValue, JsonValue>, Readonly<Record<string, JsonValue>>>>;
|
|
54
57
|
/** Internal: committed submission record. */
|
|
55
58
|
submission(id: SubmissionId): Promise<SubmissionRecord | undefined>;
|
|
56
|
-
/**
|
|
59
|
+
/** Committed submission with a conversation-scoped request ID. */
|
|
57
60
|
submissionByRequest(conversationId: ConversationId, requestId: string): Promise<SubmissionRecord | undefined>;
|
|
58
61
|
createConversation(options: {
|
|
59
62
|
readonly ownership: ConversationOwnership;
|
|
@@ -67,16 +70,22 @@ export declare class Transaction implements Tx {
|
|
|
67
70
|
appendEntry<D extends JsonValue>(token: Entry<D>, conversationId: ConversationId, value: TypedEntryDraft<NoInfer<D>>): Promise<TypedEntry<D>>;
|
|
68
71
|
createTask<I, S extends {
|
|
69
72
|
phase: string;
|
|
70
|
-
}, R, H extends object>(task: Task<I, S, R, H>, input: I, options
|
|
71
|
-
/**
|
|
73
|
+
}, R, H extends object>(task: Task<I, S, R, H>, input: I, options: TaskOptions): Promise<TaskId<R>>;
|
|
74
|
+
/** Create a raw submission record with a fresh ID; no admission rules apply. */
|
|
72
75
|
createSubmission(create: SubmissionCreate): Promise<SubmissionRecord>;
|
|
73
76
|
/**
|
|
74
77
|
* Settle a submission. Resolved during assembly against the transaction's latest candidate record, falling back to
|
|
75
78
|
* committed state, so it is not a caller table read and works after the first table write.
|
|
76
79
|
*/
|
|
77
80
|
settleSubmission(id: SubmissionId, settlement: SubmissionSettlement): void;
|
|
81
|
+
/** Place a queued submission at `entry`; resolved during assembly like `settleSubmission()`. */
|
|
82
|
+
placeSubmission(id: SubmissionId, entry: EntryId): void;
|
|
78
83
|
/** Internal: replace one task record completely. Tasks change their own state through their runtime. */
|
|
79
84
|
setTask(value: AnyTaskRecord): void;
|
|
85
|
+
/** Internal: candidate records of the tasks this transaction created or replaced so far. */
|
|
86
|
+
stagedTasks(): AnyTaskRecord[];
|
|
87
|
+
/** Internal: conversations this transaction created or forked so far. */
|
|
88
|
+
stagedConversations(): ConversationRecord[];
|
|
80
89
|
doc<T extends JsonObject>(token: SessionDocToken<T>): Promise<Draft<T>>;
|
|
81
90
|
doc<T extends JsonObject>(token: ConversationDocToken<T>, conversationId: ConversationId): Promise<Draft<T>>;
|
|
82
91
|
doc<T extends JsonObject>(token: TaskDocToken<T>, taskId: TaskId): Promise<Draft<T>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/session/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAY,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC3F,OAAO,EAAuC,KAAK,OAAO,EAAS,MAAM,6BAA6B,CAAC;AACvG,OAAO,EACN,KAAK,gBAAgB,EASrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EACX,0BAA0B,EAC1B,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,MAAM,EACN,eAAe,EACf,oBAAoB,EAGpB,UAAU,EACV,cAAc,EACd,KAAK,EACL,UAAU,EACV,OAAO,EACP,UAAU,EACV,WAAW,EACX,UAAU,EACV,GAAG,EACH,qBAAqB,EACrB,eAAe,EACf,OAAO,EACP,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,EACpB,IAAI,EACJ,kBAAkB,EAClB,YAAY,EACZ,MAAM,EACN,WAAW,EACX,SAAS,EACT,UAAU,EACV,EAAE,EACF,UAAU,EACV,eAAe,EACf,MAAM,aAAa,CAAC;AAIrB,KAAK,aAAa,GAAG,UAAU,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/session/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAY,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC3F,OAAO,EAAuC,KAAK,OAAO,EAAS,MAAM,6BAA6B,CAAC;AACvG,OAAO,EACN,KAAK,gBAAgB,EASrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EACX,0BAA0B,EAC1B,oBAAo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AAC,CAAC;IACjB,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,SAAS,EAClD,KAAK,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,EAC/B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC,CAAC;IA4GjB,2FAA2F;IACrF,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAInC;IAED;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC,CAiBtD;IAED,sFAAsF;IACtF,OAAO,IAAI,IAAI,CAEd;IAED,sGAAsG;IACtG,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,oBAAoB,EAAE,CAsDtC;CAsND"}
|
|
@@ -4,15 +4,24 @@ import { addressId, checkRecordScope, checkRecordVersion, documentCreate, materi
|
|
|
4
4
|
import { ReadAfterWrite } from "../errors.js";
|
|
5
5
|
import { ROOT_CONVERSATION_ID } from "../types.js";
|
|
6
6
|
import { prepareForkDocumentCopies } from "./forks.js";
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Complete record after applying one change. Placement turns a queued input `placed` and a queued write `done`; only a
|
|
9
|
+
* placed input can be answered. A settled record stays.
|
|
10
|
+
*/
|
|
11
|
+
function applySubmissionChange(current, change) {
|
|
9
12
|
if (current.status === "done" || current.status === "unanswered")
|
|
10
13
|
return current;
|
|
11
|
-
if (
|
|
14
|
+
if (change.status === "placed") {
|
|
15
|
+
if (current.status !== "queued")
|
|
16
|
+
throw new Error(`Submission ${current.id} is not queued`);
|
|
17
|
+
const status = current.type === "input" ? "placed" : "done";
|
|
18
|
+
return { ...current, status, entry: change.entry };
|
|
19
|
+
}
|
|
20
|
+
if (change.status === "done" && current.status !== "placed") {
|
|
12
21
|
throw new Error(`Submission ${current.id} is not a placed input`);
|
|
13
22
|
}
|
|
14
23
|
// Queued and placed records carry no answer, reason, or detail; an unanswered input keeps its entry.
|
|
15
|
-
return { ...current, ...
|
|
24
|
+
return { ...current, ...change };
|
|
16
25
|
}
|
|
17
26
|
const INTERNAL_SCAN_PAGE_SIZE = 256;
|
|
18
27
|
const EMPTY_OPERATIONS = [];
|
|
@@ -39,8 +48,8 @@ export class Transaction {
|
|
|
39
48
|
#tasksById = new Map();
|
|
40
49
|
/** Submissions created by this transaction, by ID. */
|
|
41
50
|
#submissions = new Map();
|
|
42
|
-
/**
|
|
43
|
-
#
|
|
51
|
+
/** Submission settlements and placements in staging order; resolved against the latest candidate record during assembly. */
|
|
52
|
+
#submissionChanges = [];
|
|
44
53
|
/** Write and publication plans of every staged incarnation, built during assembly. */
|
|
45
54
|
#plans = [];
|
|
46
55
|
/** Every document acquisition or retirement marker in staging order. */
|
|
@@ -73,6 +82,9 @@ export class Transaction {
|
|
|
73
82
|
scanEntries(query, limit, cursor) {
|
|
74
83
|
return this.#read("scanEntries", () => this.#host.storage.scanEntries(query, limit, cursor, this.#context));
|
|
75
84
|
}
|
|
85
|
+
latestHeadMarker(conversationId) {
|
|
86
|
+
return this.#read("latestHeadMarker", () => this.#host.storage.findLatestHeadMarker(conversationId, undefined, this.#context));
|
|
87
|
+
}
|
|
76
88
|
scanTasks(query, limit, cursor) {
|
|
77
89
|
return this.#read("scanTasks", () => this.#host.storage.scanTasks(query, limit, cursor, this.#context));
|
|
78
90
|
}
|
|
@@ -80,7 +92,7 @@ export class Transaction {
|
|
|
80
92
|
submission(id) {
|
|
81
93
|
return this.#read("submission", () => this.#host.storage.submission(id, this.#context));
|
|
82
94
|
}
|
|
83
|
-
/**
|
|
95
|
+
/** Committed submission with a conversation-scoped request ID. */
|
|
84
96
|
submissionByRequest(conversationId, requestId) {
|
|
85
97
|
return this.#read("submissionByRequest", () => this.#host.storage.submissionByRequest(conversationId, requestId, this.#context));
|
|
86
98
|
}
|
|
@@ -161,7 +173,21 @@ export class Transaction {
|
|
|
161
173
|
}
|
|
162
174
|
createTask(task, input, options) {
|
|
163
175
|
return this.#write(async () => {
|
|
164
|
-
const
|
|
176
|
+
const ownership = options.ownership;
|
|
177
|
+
let owner;
|
|
178
|
+
if (ownership.kind === "task") {
|
|
179
|
+
// Validated again against the owner's final candidate during assembly.
|
|
180
|
+
owner = await this.#currentTask(ownership.taskId);
|
|
181
|
+
this.#assertOpen();
|
|
182
|
+
if (owner === undefined)
|
|
183
|
+
throw new Error(`Task owner ${ownership.taskId} does not exist`);
|
|
184
|
+
if (options.background === true)
|
|
185
|
+
throw new TypeError("A child task cannot be background");
|
|
186
|
+
if (options.conversationId !== undefined && options.conversationId !== owner.conversationId) {
|
|
187
|
+
throw new Error(`A child task lives in its owner's conversation ${owner.conversationId}`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const conversationId = owner?.conversationId ?? options.conversationId ?? this.#scope.conversationId;
|
|
165
191
|
if (conversationId === undefined)
|
|
166
192
|
throw new TypeError("Tx.createTask() requires options.conversationId");
|
|
167
193
|
await this.#requireConversation(conversationId);
|
|
@@ -176,8 +202,8 @@ export class Transaction {
|
|
|
176
202
|
kind: definition.name,
|
|
177
203
|
version: definition.version,
|
|
178
204
|
input,
|
|
179
|
-
|
|
180
|
-
background: options
|
|
205
|
+
...(owner === undefined ? {} : { owner: owner.id }),
|
|
206
|
+
background: options.background ?? false,
|
|
181
207
|
abortRequested: false,
|
|
182
208
|
state: { status: "pending", checkpoint },
|
|
183
209
|
}, TABLE_JSON_COPY_OPTIONS);
|
|
@@ -185,7 +211,7 @@ export class Transaction {
|
|
|
185
211
|
return id;
|
|
186
212
|
});
|
|
187
213
|
}
|
|
188
|
-
/**
|
|
214
|
+
/** Create a raw submission record with a fresh ID; no admission rules apply. */
|
|
189
215
|
createSubmission(create) {
|
|
190
216
|
return this.#write(async () => {
|
|
191
217
|
await this.#requireConversation(create.conversationId);
|
|
@@ -204,7 +230,13 @@ export class Transaction {
|
|
|
204
230
|
settleSubmission(id, settlement) {
|
|
205
231
|
this.#assertOpen();
|
|
206
232
|
this.#hasTableWrite = true;
|
|
207
|
-
this.#
|
|
233
|
+
this.#submissionChanges.push({ id, change: copyJson(settlement) });
|
|
234
|
+
}
|
|
235
|
+
/** Place a queued submission at `entry`; resolved during assembly like `settleSubmission()`. */
|
|
236
|
+
placeSubmission(id, entry) {
|
|
237
|
+
this.#assertOpen();
|
|
238
|
+
this.#hasTableWrite = true;
|
|
239
|
+
this.#submissionChanges.push({ id, change: { status: "placed", entry } });
|
|
208
240
|
}
|
|
209
241
|
/** Internal: replace one task record completely. Tasks change their own state through their runtime. */
|
|
210
242
|
setTask(value) {
|
|
@@ -223,6 +255,22 @@ export class Transaction {
|
|
|
223
255
|
record: copyJson(value, TABLE_JSON_COPY_OPTIONS),
|
|
224
256
|
};
|
|
225
257
|
}
|
|
258
|
+
/** Internal: candidate records of the tasks this transaction created or replaced so far. */
|
|
259
|
+
stagedTasks() {
|
|
260
|
+
const records = [];
|
|
261
|
+
for (const task of this.#tasksById.values())
|
|
262
|
+
if (task.write !== undefined)
|
|
263
|
+
records.push(task.write.record);
|
|
264
|
+
return records;
|
|
265
|
+
}
|
|
266
|
+
/** Internal: conversations this transaction created or forked so far. */
|
|
267
|
+
stagedConversations() {
|
|
268
|
+
const records = [];
|
|
269
|
+
for (const write of this.#writes)
|
|
270
|
+
if (write.type === "conversation")
|
|
271
|
+
records.push(write.value);
|
|
272
|
+
return records;
|
|
273
|
+
}
|
|
226
274
|
doc(token, ...args) {
|
|
227
275
|
try {
|
|
228
276
|
this.#assertOpen();
|
|
@@ -463,7 +511,7 @@ export class Transaction {
|
|
|
463
511
|
plans.push(plan);
|
|
464
512
|
}
|
|
465
513
|
this.#rejectForkSourceWrites(plans);
|
|
466
|
-
await this.#
|
|
514
|
+
await this.#validateOwners();
|
|
467
515
|
for (const [id, task] of this.#tasksById) {
|
|
468
516
|
if (task.write?.kind !== "replace")
|
|
469
517
|
continue;
|
|
@@ -524,13 +572,13 @@ export class Transaction {
|
|
|
524
572
|
}
|
|
525
573
|
plan.conversationId = task.publicationConversationId;
|
|
526
574
|
}
|
|
527
|
-
for (const { id,
|
|
575
|
+
for (const { id, change } of this.#submissionChanges) {
|
|
528
576
|
const current = this.#submissions.get(id) ?? (await storage.submission(id, this.#context));
|
|
529
577
|
if (current === undefined)
|
|
530
578
|
throw new Error(`Submission ${id} does not exist`);
|
|
531
|
-
const
|
|
532
|
-
if (
|
|
533
|
-
this.#submissions.set(id,
|
|
579
|
+
const next = applySubmissionChange(current, change);
|
|
580
|
+
if (next !== current)
|
|
581
|
+
this.#submissions.set(id, next);
|
|
534
582
|
}
|
|
535
583
|
const writes = this.#writes;
|
|
536
584
|
for (const value of this.#submissions.values())
|
|
@@ -557,23 +605,31 @@ export class Transaction {
|
|
|
557
605
|
return writes;
|
|
558
606
|
}
|
|
559
607
|
// ─── Helpers ────────────────────────────────────────────────────────────
|
|
560
|
-
|
|
608
|
+
/**
|
|
609
|
+
* New owned work needs a live owner, judged on the owner's final candidate: not `completing`, terminal, or
|
|
610
|
+
* abort-marked. A task therefore cannot create owned work in the commit that finishes it (spec §5.5).
|
|
611
|
+
*/
|
|
612
|
+
async #validateOwners() {
|
|
613
|
+
const owners = [];
|
|
561
614
|
for (const write of this.#writes) {
|
|
562
615
|
if (write.type !== "conversation" || write.value.owner === undefined)
|
|
563
616
|
continue;
|
|
564
|
-
|
|
565
|
-
|
|
617
|
+
owners.push({ what: "Conversation owner task", taskId: write.value.owner.taskId });
|
|
618
|
+
}
|
|
619
|
+
for (const task of this.#tasksById.values()) {
|
|
620
|
+
const record = task.write?.kind === "create" ? task.write.record : undefined;
|
|
621
|
+
if (record?.owner !== undefined)
|
|
622
|
+
owners.push({ what: "Task owner", taskId: record.owner });
|
|
623
|
+
}
|
|
624
|
+
for (const { what, taskId } of owners) {
|
|
625
|
+
const task = await this.#currentTask(taskId);
|
|
566
626
|
if (task === undefined)
|
|
567
|
-
throw new Error(
|
|
568
|
-
if (task.
|
|
569
|
-
throw new Error(
|
|
570
|
-
}
|
|
571
|
-
if (task.state.status === "terminal") {
|
|
572
|
-
throw new Error(`Conversation owner task ${owner.taskId} is terminal`);
|
|
573
|
-
}
|
|
574
|
-
if (task.abortRequested) {
|
|
575
|
-
throw new Error(`Conversation owner task ${owner.taskId} is abort-marked`);
|
|
627
|
+
throw new Error(`${what} ${taskId} does not exist`);
|
|
628
|
+
if (task.state.status === "terminal" || task.state.status === "completing") {
|
|
629
|
+
throw new Error(`${what} ${taskId} is ${task.state.status}`);
|
|
576
630
|
}
|
|
631
|
+
if (task.abortRequested)
|
|
632
|
+
throw new Error(`${what} ${taskId} is abort-marked`);
|
|
577
633
|
}
|
|
578
634
|
}
|
|
579
635
|
#rejectForkSourceWrites(plans) {
|
|
@@ -711,8 +767,11 @@ function planDocument(document) {
|
|
|
711
767
|
}
|
|
712
768
|
}
|
|
713
769
|
}
|
|
714
|
-
/**
|
|
770
|
+
/**
|
|
771
|
+
* Whether adoption publishes the plan: every creation, copy, and retirement, and a loaded incarnation that writes
|
|
772
|
+
* content, which includes a migration-only base so observers of the older shape receive the new value.
|
|
773
|
+
*/
|
|
715
774
|
function publishes(plan) {
|
|
716
|
-
return plan.retire || plan.change?.loaded === undefined || plan.
|
|
775
|
+
return plan.retire || plan.change?.loaded === undefined || plan.content !== undefined;
|
|
717
776
|
}
|
|
718
777
|
//# sourceMappingURL=transaction.js.map
|