pi-web-ui 0.115.0 → 0.117.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 +65 -2
- package/bin/device-hub-cli.mjs +26 -3
- package/bin/pi-web-ui.mjs +159 -71
- package/dist/server/agent-service-daemon.js +136 -8
- package/dist/server/agent-service.js +594 -159
- package/dist/server/canvas/canvas-workspace.js +18 -86
- package/dist/server/client-state.js +52 -8
- package/dist/server/compaction-markers.js +43 -24
- package/dist/server/dangling-tools.js +172 -16
- package/dist/server/device-center/bot-execution.js +77 -2
- package/dist/server/device-center/collab-service.js +61 -12
- package/dist/server/device-center/collab-tool.js +482 -21
- package/dist/server/device-center/connector.js +107 -37
- package/dist/server/device-center/delivery-authority.js +98 -0
- package/dist/server/device-center/delivery-subject.js +30 -0
- package/dist/server/device-center/device-integration.js +453 -183
- package/dist/server/device-center/execution-guides.js +17 -7
- package/dist/server/device-center/execution-instructions.js +2 -1
- package/dist/server/device-center/execution-settings.js +138 -25
- package/dist/server/device-center/executor.js +51 -6
- package/dist/server/device-center/file-sync.js +14 -13
- package/dist/server/device-center/group-context-message.js +3 -1
- package/dist/server/device-center/group-context.js +73 -3
- package/dist/server/device-center/hub-conversations.js +71 -6
- package/dist/server/device-center/hub-deliveries.js +120 -15
- package/dist/server/device-center/hub-integration.js +655 -334
- package/dist/server/device-center/hub-locks.js +320 -0
- package/dist/server/device-center/hub-page.js +16 -35
- package/dist/server/device-center/hub-setup.js +23 -1
- package/dist/server/device-center/hub-transaction-log.js +197 -0
- package/dist/server/device-center/hub-webhooks.js +165 -0
- package/dist/server/device-center/hub.js +1531 -305
- package/dist/server/device-center/integration-verification.js +113 -0
- package/dist/server/device-center/local-hub.js +8 -3
- package/dist/server/device-center/local-publication.js +423 -0
- package/dist/server/device-center/local-verification-job.js +97 -0
- package/dist/server/device-center/local-verification.js +274 -0
- package/dist/server/device-center/local.js +181 -13
- package/dist/server/device-center/main.js +4 -1
- package/dist/server/device-center/partition-log.js +330 -0
- package/dist/server/device-center/publication-journal.js +312 -0
- package/dist/server/device-center/publish-intent.js +379 -0
- package/dist/server/device-center/relay.js +134 -24
- package/dist/server/device-center/runtime.js +475 -42
- package/dist/server/device-center/store.js +366 -89
- package/dist/server/device-center/task-outcome.js +81 -0
- package/dist/server/device-center/task-recovery.js +603 -178
- package/dist/server/device-center/task-scheduler.js +48 -3
- package/dist/server/device-center/task-settlement.js +353 -0
- package/dist/server/device-center/task-workspace.js +443 -0
- package/dist/server/device-center/transfers.js +41 -15
- package/dist/server/device-center/verification-limits.js +10 -0
- package/dist/server/device-center/work-contract.js +995 -0
- package/dist/server/dispatch-domain-handlers.js +29 -3
- package/dist/server/dsh/dsh-agent-service.js +9 -2
- package/dist/server/engine-probe.js +112 -1
- package/dist/server/global-loader.js +119 -19
- package/dist/server/index.js +159 -17
- package/dist/server/managed.js +2 -0
- package/dist/server/model-admin.js +48 -6
- package/dist/server/model-enrich.js +10 -1
- package/dist/server/patch-node-pty.js +3 -2
- package/dist/server/patch-remote-catalog.js +3 -2
- package/dist/server/plugins.js +64 -7
- package/dist/server/preset-fields.js +17 -1
- package/dist/server/preset-share.js +1 -0
- package/dist/server/prompt-composer.js +39 -0
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/quick-ask-settings.js +28 -0
- package/dist/server/quick-ask.js +164 -0
- package/dist/server/reasoning-registry.js +207 -0
- package/dist/server/resolve-global-sdk.js +61 -11
- package/dist/server/scheduler-tasks.js +35 -8
- package/dist/server/session-list-scan.js +223 -0
- package/dist/server/session-open.js +93 -0
- package/dist/server/session-parser.js +4 -0
- package/dist/server/session-scan.js +90 -38
- package/dist/server/settings-service.js +9 -1
- package/dist/server/soft-cap.js +5 -0
- package/dist/server/startup-banner.js +35 -0
- package/dist/server/subagents.js +2 -1
- package/dist/server/tool-manager.js +17 -9
- package/dist/server/transcript-prepare.js +73 -0
- package/dist/server/unauthorized-page.js +319 -0
- package/dist/server/universal/drivers/claude-code.js +98 -34
- package/dist/server/universal/universal-session.js +4 -0
- package/dist/server/workspace-handle.js +428 -0
- package/docs/architecture-plugins.md +959 -0
- package/docs/device-center.md +34 -20
- package/package.json +4 -4
- package/plugin-sdk/README.md +16 -8
- package/plugin-sdk/client.d.ts +27 -0
- package/plugin-sdk/client.mjs +82 -0
- package/plugin-sdk/index.d.ts +10 -0
- package/plugin-sdk/index.mjs +4 -683
- package/plugin-sdk/package.json +15 -4
- package/plugin-sdk/testing.d.ts +10 -0
- package/plugin-sdk/testing.mjs +566 -0
- package/themes/flow-cristallo.css +168 -0
- package/themes/flow-ink.css +169 -0
- package/themes/flow-obsidian.css +169 -0
- package/themes/flow-zurich.css +169 -0
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/{BgTasksModal-BYzPgmoq.js → BgTasksModal-BjNRIUIc.js} +1 -1
- package/web/dist/assets/{BgTasksModal-ni0VTmAQ.js → BgTasksModal-C0zuU8FE.js} +1 -1
- package/web/dist/assets/{CanvasStudio-DNmDNBod.js → CanvasStudio-BWvdmJ0M.js} +3 -3
- package/web/dist/assets/{CanvasStudio-BCUeEf25.js → CanvasStudio-VQFjmTGq.js} +3 -3
- package/web/dist/assets/DeviceCenter-DI9_0aBB.js +3 -0
- package/web/dist/assets/DeviceCenter-DsNtXqzY.js +3 -0
- package/web/dist/assets/DeviceExecutionSettings-BLP1Su5G.js +1 -0
- package/web/dist/assets/DeviceGroups-2Pvk0Cds.js +1 -0
- package/web/dist/assets/DeviceGroups-CP7CcyPD.js +1 -0
- package/web/dist/assets/{Dropdown-CGXD0DfT.js → Dropdown-CQtstPGv.js} +1 -1
- package/web/dist/assets/FilePreview-BMB2tNyT.js +2 -0
- package/web/dist/assets/FilePreview-RGFQUbJo.js +2 -0
- package/web/dist/assets/{GlobalSearchModal-mevF-ySi.js → GlobalSearchModal-BM5wxiqU.js} +1 -1
- package/web/dist/assets/{GlobalSearchModal-qL99FN_F.js → GlobalSearchModal-DGv_WINq.js} +1 -1
- package/web/dist/assets/GroupConversation-B7SnuXj1.js +61 -0
- package/web/dist/assets/GroupConversation-Dda69q-2.js +61 -0
- package/web/dist/assets/{HintTip-LHwkS2jV.js → HintTip-ChTW8o1m.js} +1 -1
- package/web/dist/assets/ModelConfigModal-C-0Z4hUZ.js +2 -0
- package/web/dist/assets/ModelConfigModal-yqeadyab.js +2 -0
- package/web/dist/assets/{PiSetupModal-DE5-gEtI.js → PiSetupModal-BX5rUuoI.js} +1 -1
- package/web/dist/assets/{ProviderOAuthControls-6UMARucA.js → ProviderOAuthControls-DY4SCfXg.js} +1 -1
- package/web/dist/assets/SCMPanel-C4KbQvvK.js +2 -0
- package/web/dist/assets/SCMPanel-DPAyY2sW.js +2 -0
- package/web/dist/assets/SettingsModal-DxZp6D_g.js +32 -0
- package/web/dist/assets/SettingsModal-WhQzaOPt.js +32 -0
- package/web/dist/assets/{TerminalPanel-CTp_BZ4S.js → TerminalPanel-D4By_RVc.js} +2 -2
- package/web/dist/assets/{TerminalPanel-CkYxC-Gh.js → TerminalPanel-lZw8-i3j.js} +2 -2
- package/web/dist/assets/{TuiOverlayModal-1cRLP8IF.js → TuiOverlayModal-C3pAVuC8.js} +1 -1
- package/web/dist/assets/{TuiOverlayModal-2xlptqWX.js → TuiOverlayModal-D7_rEXcJ.js} +1 -1
- package/web/dist/assets/app-globals-KqOVtmp1.js +123 -0
- package/web/dist/assets/{canvas-client-Bye9nSFO.js → canvas-client-BY6ojmle.js} +1 -1
- package/web/dist/assets/{desktop-kjBoE3Nu.js → desktop-CV6KKp9R.js} +1 -1
- package/web/dist/assets/index-BawF7ZP5.js +397 -0
- package/web/dist/assets/index-BoGCoq5X.js +397 -0
- package/web/dist/assets/index-CVW9FoY2.css +1 -0
- package/web/dist/assets/{plugin-host-C8mNgghx.js → plugin-host-Dn8Dd6SC.js} +1 -1
- package/web/dist/assets/{remote-ssh-client-CeP3CLUW.js → remote-ssh-client-Dzi-eEyE.js} +1 -1
- package/web/dist/assets/{theme-BXGpyTMh.js → theme-D_bihpdN.js} +1 -1
- package/web/dist/index.html +11 -11
- package/web/dist/sw.js +1 -1
- package/dist/server/patch-turn-end-boundary.js +0 -77
- package/web/dist/assets/DeviceCenter-BcBhRgL6.js +0 -3
- package/web/dist/assets/DeviceCenter-CmL5FZmt.js +0 -3
- package/web/dist/assets/DeviceGroups-CLdpdnI7.js +0 -1
- package/web/dist/assets/DeviceGroups-CgBaDPrD.js +0 -1
- package/web/dist/assets/FilePreview-B8iqnBjy.js +0 -2
- package/web/dist/assets/FilePreview-BqviZKCN.js +0 -2
- package/web/dist/assets/GroupConversation-B88Yy-lt.js +0 -3
- package/web/dist/assets/GroupConversation-BwP5NVOE.js +0 -3
- package/web/dist/assets/ModelConfigModal-Do3Fe3jH.js +0 -2
- package/web/dist/assets/SCMPanel-Hi6QqC1Q.js +0 -2
- package/web/dist/assets/SCMPanel-ezY_ZtCu.js +0 -2
- package/web/dist/assets/SettingsModal-6HgeEsJ8.js +0 -20
- package/web/dist/assets/SettingsModal-CF-7MwqS.js +0 -20
- package/web/dist/assets/app-globals-DZNa9v8u.js +0 -325
- package/web/dist/assets/index-CsFs_HMb.css +0 -1
- package/web/dist/assets/index-DHeeHS_l.js +0 -85
- package/web/dist/assets/index-DTZch8uz.js +0 -85
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { mkdir, open, readFile, readdir, rename, unlink } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
/**
|
|
5
|
+
* Append-only partitioned log for collections that dominate Hub state size.
|
|
6
|
+
*
|
|
7
|
+
* One file per partition (room or conversation), one JSON object per line:
|
|
8
|
+
* {"v":1,"op":"upsert","value":{...}}
|
|
9
|
+
* {"v":1,"op":"del","ids":["..."]}
|
|
10
|
+
*
|
|
11
|
+
* The owner commits its WAL before projecting collections here. Failed projections can be replayed
|
|
12
|
+
* from that WAL. Deletions use tombstones; compaction atomically replaces a partition with live rows.
|
|
13
|
+
* Cache misses reload and repair disk state before any further append.
|
|
14
|
+
*/
|
|
15
|
+
const PARTITION = /^[A-Za-z0-9_-]{1,128}$/;
|
|
16
|
+
const PARTITION_SUFFIX = ".jsonl";
|
|
17
|
+
export const LOG_MAX_DELETES = 200;
|
|
18
|
+
export class PartitionedAppendLog {
|
|
19
|
+
dir;
|
|
20
|
+
partitionOf;
|
|
21
|
+
idOf;
|
|
22
|
+
retention;
|
|
23
|
+
protect;
|
|
24
|
+
maxDeletes;
|
|
25
|
+
/** Digest of the rows already written, so a commit only serializes what changed. */
|
|
26
|
+
cache = new Map();
|
|
27
|
+
deletes = new Map();
|
|
28
|
+
lines = new Map();
|
|
29
|
+
constructor(options) {
|
|
30
|
+
this.dir = options.dir;
|
|
31
|
+
this.partitionOf = options.partition;
|
|
32
|
+
this.idOf = options.id;
|
|
33
|
+
this.retention = options.retention;
|
|
34
|
+
this.protect = options.protect;
|
|
35
|
+
this.maxDeletes = options.maxDeletes ?? LOG_MAX_DELETES;
|
|
36
|
+
}
|
|
37
|
+
file(partition) {
|
|
38
|
+
return PARTITION.test(partition) ? join(this.dir, `${partition}${PARTITION_SUFFIX}`) : null;
|
|
39
|
+
}
|
|
40
|
+
digest(value) {
|
|
41
|
+
return createHash("sha1").update(JSON.stringify(value)).digest("hex");
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Load every existing partition in the given parent set; rows of removed parents are ignored.
|
|
45
|
+
* `sweep` removes log files whose parent no longer exists (crash leftovers); read-only callers skip it.
|
|
46
|
+
*/
|
|
47
|
+
async load(partitions, options = {}) {
|
|
48
|
+
if (!options.readOnly) {
|
|
49
|
+
await mkdir(this.dir, { recursive: true, mode: 0o700 });
|
|
50
|
+
}
|
|
51
|
+
const existing = new Set();
|
|
52
|
+
for (const partition of partitions)
|
|
53
|
+
if (PARTITION.test(partition))
|
|
54
|
+
existing.add(partition);
|
|
55
|
+
// Files whose parent was removed by a committed transaction (crash between the two writes).
|
|
56
|
+
const shouldSweep = options.sweep !== false && !options.readOnly;
|
|
57
|
+
if (shouldSweep) {
|
|
58
|
+
let entries = [];
|
|
59
|
+
try {
|
|
60
|
+
entries = await readdir(this.dir);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
if (error.code !== "ENOENT")
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
for (const entry of entries) {
|
|
67
|
+
const partition = entry.endsWith(PARTITION_SUFFIX) ? entry.slice(0, -PARTITION_SUFFIX.length) : "";
|
|
68
|
+
if (!partition || !PARTITION.test(partition) || existing.has(partition))
|
|
69
|
+
continue;
|
|
70
|
+
await unlink(join(this.dir, entry)).catch(() => { });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const rows = [];
|
|
74
|
+
for (const partition of existing) {
|
|
75
|
+
const loaded = await this.readPartition(partition);
|
|
76
|
+
if (!loaded)
|
|
77
|
+
continue;
|
|
78
|
+
rows.push(...loaded.values);
|
|
79
|
+
// Repair a partition left oversized by a lost tombstone/compaction (skip if read-only).
|
|
80
|
+
const overRetention = this.retention !== undefined && loaded.rawRows > this.retention;
|
|
81
|
+
if (!options.readOnly && (loaded.needsRepair || overRetention || loaded.deletes > this.maxDeletes))
|
|
82
|
+
await this.rewrite(partition, loaded.values);
|
|
83
|
+
}
|
|
84
|
+
return rows;
|
|
85
|
+
}
|
|
86
|
+
withRetention(values) {
|
|
87
|
+
if (this.retention === undefined || values.length <= this.retention)
|
|
88
|
+
return values;
|
|
89
|
+
const kept = new Set();
|
|
90
|
+
const protectedRows = this.protect ? values.filter((value) => this.protect(value)) : [];
|
|
91
|
+
for (const row of protectedRows)
|
|
92
|
+
kept.add(this.idOf(row));
|
|
93
|
+
const rest = values.filter((value) => !kept.has(this.idOf(value)));
|
|
94
|
+
const remaining = Math.max(0, this.retention - kept.size);
|
|
95
|
+
// slice(-0) would return the whole array, so only take a window when there is room left.
|
|
96
|
+
for (const row of remaining > 0 ? rest.slice(-remaining) : [])
|
|
97
|
+
kept.add(this.idOf(row));
|
|
98
|
+
return values.filter((value) => kept.has(this.idOf(value)));
|
|
99
|
+
}
|
|
100
|
+
async readPartition(partition) {
|
|
101
|
+
const file = this.file(partition);
|
|
102
|
+
if (!file)
|
|
103
|
+
return null;
|
|
104
|
+
let raw;
|
|
105
|
+
try {
|
|
106
|
+
raw = await readFile(file, "utf8");
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
if (error.code === "ENOENT")
|
|
110
|
+
return null;
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
let complete = raw;
|
|
114
|
+
let needsRepair = false;
|
|
115
|
+
// A crash during append can leave a partial last line; ignore and truncate it before appending.
|
|
116
|
+
if (raw.length && !raw.endsWith("\n")) {
|
|
117
|
+
const cut = raw.lastIndexOf("\n");
|
|
118
|
+
complete = cut >= 0 ? raw.slice(0, cut + 1) : "";
|
|
119
|
+
needsRepair = true;
|
|
120
|
+
}
|
|
121
|
+
const live = new Map();
|
|
122
|
+
let deletes = 0;
|
|
123
|
+
let lines = 0;
|
|
124
|
+
for (const line of complete.split("\n")) {
|
|
125
|
+
if (!line)
|
|
126
|
+
continue;
|
|
127
|
+
lines++;
|
|
128
|
+
let parsed;
|
|
129
|
+
try {
|
|
130
|
+
parsed = JSON.parse(line);
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
// Only a torn tail is expected; anything else is corruption and is skipped explicitly.
|
|
134
|
+
needsRepair = true;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (!parsed || parsed.v !== 1) {
|
|
138
|
+
needsRepair = true;
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (parsed.op === "del" && Array.isArray(parsed.ids)) {
|
|
142
|
+
deletes += parsed.ids.length;
|
|
143
|
+
for (const id of parsed.ids)
|
|
144
|
+
if (typeof id === "string")
|
|
145
|
+
live.delete(id);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (parsed.op === "upsert" && parsed.value && typeof parsed.value === "object") {
|
|
149
|
+
const id = this.idOf(parsed.value);
|
|
150
|
+
if (typeof id !== "string" || !id) {
|
|
151
|
+
needsRepair = true;
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
live.set(id, parsed.value);
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
needsRepair = true;
|
|
158
|
+
}
|
|
159
|
+
const rawValues = [...live.values()];
|
|
160
|
+
const values = this.withRetention(rawValues);
|
|
161
|
+
const cache = new Map();
|
|
162
|
+
for (const value of values)
|
|
163
|
+
cache.set(this.idOf(value), this.digest(value));
|
|
164
|
+
this.cache.set(partition, cache);
|
|
165
|
+
this.deletes.set(partition, deletes);
|
|
166
|
+
this.lines.set(partition, lines);
|
|
167
|
+
return { values, rawRows: rawValues.length, deletes, needsRepair };
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Apply the diff between what is on disk (cache) and `next`. Partitions that no longer exist are
|
|
171
|
+
* removed. Failed appends are rolled back where possible; completed deletes/rewrites are retained
|
|
172
|
+
* because the owner's committed WAL can replay them. A retry reloads and repairs actual disk state.
|
|
173
|
+
*/
|
|
174
|
+
async commit(next, partitions) {
|
|
175
|
+
await mkdir(this.dir, { recursive: true, mode: 0o700 });
|
|
176
|
+
const grouped = new Map();
|
|
177
|
+
for (const value of next) {
|
|
178
|
+
const partition = this.partitionOf(value);
|
|
179
|
+
if (!partitions.has(partition) || !PARTITION.test(partition))
|
|
180
|
+
continue;
|
|
181
|
+
const bucket = grouped.get(partition) ?? [];
|
|
182
|
+
bucket.push({ value, digest: this.digest(value) });
|
|
183
|
+
grouped.set(partition, bucket);
|
|
184
|
+
}
|
|
185
|
+
// Cache invalidation must not hide existing files, including parents removed by this transaction.
|
|
186
|
+
const knownPartitions = new Set(this.cache.keys());
|
|
187
|
+
for (const entry of await readdir(this.dir)) {
|
|
188
|
+
if (entry.endsWith(PARTITION_SUFFIX)) {
|
|
189
|
+
const partition = entry.slice(0, -PARTITION_SUFFIX.length);
|
|
190
|
+
if (PARTITION.test(partition))
|
|
191
|
+
knownPartitions.add(partition);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const removedPartitions = new Set([...knownPartitions].filter((partition) => !partitions.has(partition)));
|
|
195
|
+
// Empty retained parents also need a disk reload and tombstones after cache invalidation.
|
|
196
|
+
const touched = new Set([...partitions, ...knownPartitions]);
|
|
197
|
+
// Only append offsets are safe to roll back; never truncate an atomically replaced snapshot.
|
|
198
|
+
const rollback = new Map();
|
|
199
|
+
try {
|
|
200
|
+
for (const partition of removedPartitions) {
|
|
201
|
+
const file = this.file(partition);
|
|
202
|
+
if (file)
|
|
203
|
+
await unlink(file).catch((error) => {
|
|
204
|
+
if (error.code !== "ENOENT")
|
|
205
|
+
throw error;
|
|
206
|
+
});
|
|
207
|
+
this.cache.delete(partition);
|
|
208
|
+
this.deletes.delete(partition);
|
|
209
|
+
this.lines.delete(partition);
|
|
210
|
+
}
|
|
211
|
+
for (const partition of [...touched].sort()) {
|
|
212
|
+
const file = this.file(partition);
|
|
213
|
+
if (!file || removedPartitions.has(partition))
|
|
214
|
+
continue;
|
|
215
|
+
if (!this.cache.has(partition)) {
|
|
216
|
+
const loaded = await this.readPartition(partition);
|
|
217
|
+
if (loaded &&
|
|
218
|
+
(loaded.needsRepair ||
|
|
219
|
+
(this.retention !== undefined && loaded.rawRows > this.retention) ||
|
|
220
|
+
loaded.deletes > this.maxDeletes)) {
|
|
221
|
+
await this.rewrite(partition, loaded.values);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
const previous = this.cache.get(partition) ?? new Map();
|
|
225
|
+
const bucket = grouped.get(partition) ?? [];
|
|
226
|
+
const present = new Set(bucket.map((entry) => this.idOf(entry.value)));
|
|
227
|
+
const added = bucket.filter((entry) => previous.get(this.idOf(entry.value)) !== entry.digest);
|
|
228
|
+
const removed = [...previous.keys()].filter((id) => !present.has(id));
|
|
229
|
+
if (!added.length && !removed.length)
|
|
230
|
+
continue;
|
|
231
|
+
rollback.set(file, await this.size(file));
|
|
232
|
+
const handle = await open(file, "a");
|
|
233
|
+
try {
|
|
234
|
+
let payload = "";
|
|
235
|
+
for (const entry of added)
|
|
236
|
+
payload += `${JSON.stringify({ v: 1, op: "upsert", value: entry.value })}\n`;
|
|
237
|
+
if (removed.length)
|
|
238
|
+
payload += `${JSON.stringify({ v: 1, op: "del", ids: removed })}\n`;
|
|
239
|
+
await handle.writeFile(payload);
|
|
240
|
+
await handle.sync();
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
await handle.close();
|
|
244
|
+
}
|
|
245
|
+
const cache = new Map();
|
|
246
|
+
for (const entry of bucket)
|
|
247
|
+
cache.set(this.idOf(entry.value), entry.digest);
|
|
248
|
+
this.cache.set(partition, cache);
|
|
249
|
+
const deletes = (this.deletes.get(partition) ?? 0) + removed.length;
|
|
250
|
+
const lines = (this.lines.get(partition) ?? previous.size) + added.length + (removed.length ? 1 : 0);
|
|
251
|
+
this.deletes.set(partition, deletes);
|
|
252
|
+
this.lines.set(partition, lines);
|
|
253
|
+
if (deletes >= this.maxDeletes || (this.retention && lines > this.retention * 2)) {
|
|
254
|
+
rollback.delete(file);
|
|
255
|
+
await this.rewrite(partition, bucket.map((entry) => entry.value));
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
for (const [file, size] of rollback)
|
|
261
|
+
await this.truncate(file, size).catch(() => { });
|
|
262
|
+
this.cache.clear();
|
|
263
|
+
this.deletes.clear();
|
|
264
|
+
this.lines.clear();
|
|
265
|
+
throw error;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
async size(file) {
|
|
269
|
+
try {
|
|
270
|
+
const handle = await open(file, "r");
|
|
271
|
+
try {
|
|
272
|
+
return (await handle.stat()).size;
|
|
273
|
+
}
|
|
274
|
+
finally {
|
|
275
|
+
await handle.close();
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
if (error.code === "ENOENT")
|
|
280
|
+
return 0;
|
|
281
|
+
throw error;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
async truncate(file, size) {
|
|
285
|
+
const handle = await open(file, "r+");
|
|
286
|
+
try {
|
|
287
|
+
await handle.truncate(size);
|
|
288
|
+
await handle.sync();
|
|
289
|
+
}
|
|
290
|
+
finally {
|
|
291
|
+
await handle.close();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
async rewrite(partition, values) {
|
|
295
|
+
const file = this.file(partition);
|
|
296
|
+
if (!file)
|
|
297
|
+
return;
|
|
298
|
+
const temporary = `${file}.${createHash("sha1").update(`${Date.now()}:${Math.random()}`).digest("hex")}.tmp`;
|
|
299
|
+
const payload = values.map((value) => `${JSON.stringify({ v: 1, op: "upsert", value })}\n`).join("");
|
|
300
|
+
const handle = await open(temporary, "w", 0o600);
|
|
301
|
+
try {
|
|
302
|
+
await handle.writeFile(payload);
|
|
303
|
+
await handle.sync();
|
|
304
|
+
}
|
|
305
|
+
finally {
|
|
306
|
+
await handle.close();
|
|
307
|
+
}
|
|
308
|
+
await rename(temporary, file);
|
|
309
|
+
const cache = new Map();
|
|
310
|
+
for (const value of values)
|
|
311
|
+
cache.set(this.idOf(value), this.digest(value));
|
|
312
|
+
this.cache.set(partition, cache);
|
|
313
|
+
this.deletes.set(partition, 0);
|
|
314
|
+
this.lines.set(partition, values.length);
|
|
315
|
+
}
|
|
316
|
+
/** Re-read a partition after an external change (used by tests and failure recovery). */
|
|
317
|
+
async reload(partitions) {
|
|
318
|
+
for (const partition of partitions) {
|
|
319
|
+
this.cache.delete(partition);
|
|
320
|
+
this.deletes.delete(partition);
|
|
321
|
+
this.lines.delete(partition);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/** Invalidate all in-memory caches so subsequent commits reload actual disk state. */
|
|
325
|
+
invalidateCache() {
|
|
326
|
+
this.cache.clear();
|
|
327
|
+
this.deletes.clear();
|
|
328
|
+
this.lines.clear();
|
|
329
|
+
}
|
|
330
|
+
}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { link, lstat, mkdir, open, opendir, readFile, rename, unlink } from "node:fs/promises";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import { validatePublishIntent } from "./publish-intent.js";
|
|
5
|
+
import { canonicalizeJson } from "./work-contract.js";
|
|
6
|
+
export const PUBLICATION_WRITER_EPOCH = randomUUID();
|
|
7
|
+
export const PUBLICATION_JOURNAL_LIMITS = {
|
|
8
|
+
entries: 512,
|
|
9
|
+
bytes: 512 * 1024,
|
|
10
|
+
headerBytes: 448 * 1024,
|
|
11
|
+
events: 16,
|
|
12
|
+
};
|
|
13
|
+
const queues = new Map();
|
|
14
|
+
/** One writer per data directory. Rejections do not poison subsequent read-only diagnostics. */
|
|
15
|
+
export async function serializePublication(dataDir, run) {
|
|
16
|
+
const key = resolve(dataDir);
|
|
17
|
+
const pending = (queues.get(key) ?? Promise.resolve()).catch(() => { }).then(run);
|
|
18
|
+
queues.set(key, pending);
|
|
19
|
+
try {
|
|
20
|
+
return await pending;
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
if (queues.get(key) === pending)
|
|
24
|
+
queues.delete(key);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function publicationJournalDirectory(dataDir) {
|
|
28
|
+
return join(dataDir, "publication-journal-v1");
|
|
29
|
+
}
|
|
30
|
+
function fileName(intent) {
|
|
31
|
+
return (createHash("sha256")
|
|
32
|
+
.update(canonicalizeJson([intent.accountId, intent.targetDeviceId, intent.integrationId]))
|
|
33
|
+
.digest("hex") + ".jsonl");
|
|
34
|
+
}
|
|
35
|
+
function digest(event) {
|
|
36
|
+
return createHash("sha256").update(canonicalizeJson(event)).digest("hex");
|
|
37
|
+
}
|
|
38
|
+
async function inspectDirectory(dataDir, create) {
|
|
39
|
+
const dir = publicationJournalDirectory(dataDir);
|
|
40
|
+
if (create)
|
|
41
|
+
await mkdir(dir, { recursive: true });
|
|
42
|
+
let names;
|
|
43
|
+
try {
|
|
44
|
+
const stat = await lstat(dir);
|
|
45
|
+
if (!stat.isDirectory() || stat.isSymbolicLink())
|
|
46
|
+
throw new Error("Publication journal directory is unsafe");
|
|
47
|
+
names = [];
|
|
48
|
+
for await (const entry of await opendir(dir)) {
|
|
49
|
+
names.push(entry.name);
|
|
50
|
+
if (names.length > PUBLICATION_JOURNAL_LIMITS.entries * 3)
|
|
51
|
+
throw new Error("Publication journal directory capacity exceeded");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (!create && error.code === "ENOENT")
|
|
56
|
+
return [];
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
if (names.filter((name) => name.endsWith(".jsonl")).length > PUBLICATION_JOURNAL_LIMITS.entries ||
|
|
60
|
+
names.some((name) => !/^[a-f0-9]{64}\.jsonl(?:\.tmp-[a-f0-9-]{36})?$/.test(name)))
|
|
61
|
+
throw new Error("Publication journal capacity or directory integrity failure");
|
|
62
|
+
return names;
|
|
63
|
+
}
|
|
64
|
+
function assertProof(intent, proof) {
|
|
65
|
+
if (proof.intentId !== intent.id ||
|
|
66
|
+
proof.intentDigest !== intent.digest ||
|
|
67
|
+
proof.candidateSha !== intent.candidateSha)
|
|
68
|
+
throw new Error("Publication journal proof identity mismatch");
|
|
69
|
+
}
|
|
70
|
+
/** Strict and bounded: unreadable, malformed and partial files are never interpreted as absence. */
|
|
71
|
+
export async function readPublicationJournal(dataDir, input) {
|
|
72
|
+
const intent = validatePublishIntent(input);
|
|
73
|
+
const directory = publicationJournalDirectory(dataDir);
|
|
74
|
+
let stat;
|
|
75
|
+
const path = join(directory, fileName(intent));
|
|
76
|
+
try {
|
|
77
|
+
const parent = await lstat(directory);
|
|
78
|
+
if (!parent.isDirectory() || parent.isSymbolicLink())
|
|
79
|
+
throw new Error("Publication journal directory is unsafe");
|
|
80
|
+
stat = await lstat(path);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (error.code === "ENOENT")
|
|
84
|
+
return undefined;
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > PUBLICATION_JOURNAL_LIMITS.bytes || stat.size === 0)
|
|
88
|
+
throw new Error("Publication journal file integrity failure");
|
|
89
|
+
const raw = await readFile(path, "utf8");
|
|
90
|
+
return parsePublicationJournal(raw, intent);
|
|
91
|
+
}
|
|
92
|
+
function parsePublicationJournal(raw, intent) {
|
|
93
|
+
if (!raw.endsWith("\n") || Buffer.byteLength(raw) > PUBLICATION_JOURNAL_LIMITS.bytes)
|
|
94
|
+
throw new Error("Publication journal is incomplete");
|
|
95
|
+
const lines = raw.slice(0, -1).split("\n");
|
|
96
|
+
if (lines.length > PUBLICATION_JOURNAL_LIMITS.events)
|
|
97
|
+
throw new Error("Publication journal event capacity exceeded");
|
|
98
|
+
let journal;
|
|
99
|
+
for (const [sequence, line] of lines.entries()) {
|
|
100
|
+
const event = JSON.parse(line);
|
|
101
|
+
const { hash, ...facts } = event;
|
|
102
|
+
if (event.version !== 1 ||
|
|
103
|
+
event.sequence !== sequence ||
|
|
104
|
+
event.previous !== (journal?.hash ?? "") ||
|
|
105
|
+
hash !== digest(facts))
|
|
106
|
+
throw new Error("Publication journal chain integrity failure");
|
|
107
|
+
if (sequence === 0) {
|
|
108
|
+
if (!event.intent || !["prepared", "closed"].includes(event.phase))
|
|
109
|
+
throw new Error("Invalid publication journal header");
|
|
110
|
+
const original = validatePublishIntent(event.intent);
|
|
111
|
+
if (canonicalizeJson(original) !== canonicalizeJson(intent))
|
|
112
|
+
throw new Error("Publication journal immutable intent mismatch");
|
|
113
|
+
if (event.phase === "prepared" && !event.repository)
|
|
114
|
+
throw new Error("Publication repository identity missing");
|
|
115
|
+
if (event.repository &&
|
|
116
|
+
(event.repository.repositoryId !== intent.repositoryId ||
|
|
117
|
+
event.repository.objectFormat !== intent.objectFormat ||
|
|
118
|
+
typeof event.repository.repoRoot !== "string" ||
|
|
119
|
+
typeof event.repository.commonDir !== "string"))
|
|
120
|
+
throw new Error("Publication repository identity mismatch");
|
|
121
|
+
journal = { intent: original, repository: event.repository, phase: event.phase, sequence, hash };
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
if (event.intent || event.repository)
|
|
125
|
+
throw new Error("Publication journal identity replacement");
|
|
126
|
+
assertTransition(journal, event.phase, event.receipt, event.stop, event.processStopped);
|
|
127
|
+
journal = { ...journal, phase: event.phase, sequence, hash };
|
|
128
|
+
}
|
|
129
|
+
if (event.phase === "cas_started" && !event.processStopped) {
|
|
130
|
+
if (typeof event.processEpoch !== "string" || !/^[a-f0-9-]{36}$/.test(event.processEpoch))
|
|
131
|
+
throw new Error("Publication CAS process identity missing");
|
|
132
|
+
journal.casStarted = true;
|
|
133
|
+
journal.processEpoch = event.processEpoch;
|
|
134
|
+
journal.processStopped = false;
|
|
135
|
+
}
|
|
136
|
+
if (event.processStopped === true)
|
|
137
|
+
journal.processStopped = true;
|
|
138
|
+
if (event.receipt) {
|
|
139
|
+
assertProof(intent, event.receipt);
|
|
140
|
+
if (event.receipt.outcome !== "applied" ||
|
|
141
|
+
!["cas_exit", "target_exact", "target_descendant"].includes(event.receipt.proof) ||
|
|
142
|
+
!Number.isFinite(event.receipt.observedAt))
|
|
143
|
+
throw new Error("Invalid publication receipt");
|
|
144
|
+
if (journal.receipt && canonicalizeJson(journal.receipt) !== canonicalizeJson(event.receipt))
|
|
145
|
+
throw new Error("Publication receipt is immutable");
|
|
146
|
+
journal.receipt = event.receipt;
|
|
147
|
+
}
|
|
148
|
+
if (event.stop) {
|
|
149
|
+
assertProof(intent, event.stop);
|
|
150
|
+
if (event.stop.closed !== true ||
|
|
151
|
+
!["applied", "not_applied", "unknown"].includes(event.stop.pastEffect) ||
|
|
152
|
+
typeof event.stop.stopConfirmed !== "boolean" ||
|
|
153
|
+
!Number.isFinite(event.stop.fencedAt) ||
|
|
154
|
+
(event.stop.stopConfirmed && !Number.isFinite(event.stop.stoppedAt)) ||
|
|
155
|
+
(!event.stop.stopConfirmed && event.stop.stoppedAt !== undefined))
|
|
156
|
+
throw new Error("Invalid publication stop");
|
|
157
|
+
journal.stop = event.stop;
|
|
158
|
+
}
|
|
159
|
+
if (event.receipt?.proof === "cas_exit" && event.processStopped !== true)
|
|
160
|
+
throw new Error("Publication actual-exit stop proof missing");
|
|
161
|
+
if (event.phase === "cas_rejected" && event.processStopped !== true)
|
|
162
|
+
throw new Error("Publication rejection stop proof missing");
|
|
163
|
+
if (journal.receipt && journal.stop?.pastEffect === "not_applied")
|
|
164
|
+
throw new Error("Contradictory publication proof");
|
|
165
|
+
if (journal.phase === "applied" && !journal.receipt)
|
|
166
|
+
throw new Error("Publication applied receipt missing");
|
|
167
|
+
if (journal.phase === "closed" && !journal.stop)
|
|
168
|
+
throw new Error("Publication stop missing");
|
|
169
|
+
}
|
|
170
|
+
return journal;
|
|
171
|
+
}
|
|
172
|
+
/** Admission must consult the independent journal, even after sessions were removed. */
|
|
173
|
+
export async function loadPublicationJournals(dataDir) {
|
|
174
|
+
const names = await inspectDirectory(dataDir, false);
|
|
175
|
+
const journals = [];
|
|
176
|
+
for (const name of names.filter((name) => name.endsWith(".jsonl"))) {
|
|
177
|
+
const path = join(publicationJournalDirectory(dataDir), name);
|
|
178
|
+
const stat = await lstat(path);
|
|
179
|
+
if (!stat.isFile() || stat.isSymbolicLink() || !stat.size || stat.size > PUBLICATION_JOURNAL_LIMITS.bytes)
|
|
180
|
+
throw new Error("Publication journal integrity failure during admission");
|
|
181
|
+
const raw = await readFile(path, "utf8");
|
|
182
|
+
const header = JSON.parse(raw.split("\n", 1)[0]);
|
|
183
|
+
const intent = validatePublishIntent(header.intent);
|
|
184
|
+
if (fileName(intent) !== name)
|
|
185
|
+
throw new Error("Publication journal filename identity mismatch");
|
|
186
|
+
const journal = await readPublicationJournal(dataDir, intent);
|
|
187
|
+
if (!journal)
|
|
188
|
+
throw new Error("Publication journal disappeared during admission");
|
|
189
|
+
journals.push(journal);
|
|
190
|
+
}
|
|
191
|
+
return journals;
|
|
192
|
+
}
|
|
193
|
+
function assertTransition(journal, next, proof, stop, processStopped) {
|
|
194
|
+
if (journal.phase === "cas_started" && next === "cas_started" && processStopped === true)
|
|
195
|
+
return;
|
|
196
|
+
if (journal.phase === "closed" && next === "closed" && !journal.stop?.stopConfirmed && stop?.stopConfirmed)
|
|
197
|
+
return;
|
|
198
|
+
if (!journal.receipt && next === "applied" && proof && ["target_exact", "target_descendant"].includes(proof.proof))
|
|
199
|
+
return;
|
|
200
|
+
if (journal.stop || (journal.receipt && next !== "closed"))
|
|
201
|
+
throw new Error("Publication journal is terminal");
|
|
202
|
+
const allowed = {
|
|
203
|
+
prepared: ["cas_started", "closed"],
|
|
204
|
+
cas_started: ["cas_rejected", "applied", "closed"],
|
|
205
|
+
cas_rejected: ["cas_started", "closed"],
|
|
206
|
+
applied: ["closed"],
|
|
207
|
+
closed: [],
|
|
208
|
+
};
|
|
209
|
+
if (!allowed[journal.phase].includes(next))
|
|
210
|
+
throw new Error("Invalid publication journal transition");
|
|
211
|
+
}
|
|
212
|
+
async function flushDirectory(path) {
|
|
213
|
+
let handle;
|
|
214
|
+
try {
|
|
215
|
+
handle = await open(path, "r");
|
|
216
|
+
await handle.sync();
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
// Windows cannot fsync directory handles. Files are fsynced: process-crash durability,
|
|
220
|
+
// with best-effort directory flushing, not a portable power-loss guarantee.
|
|
221
|
+
if (process.platform !== "win32" ||
|
|
222
|
+
!["EPERM", "EISDIR", "EINVAL", "EBADF", "EACCES"].includes(error.code ?? ""))
|
|
223
|
+
throw error;
|
|
224
|
+
}
|
|
225
|
+
finally {
|
|
226
|
+
await handle?.close();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
async function writeAtomicJournal(path, content, exclusive) {
|
|
230
|
+
const temp = `${path}.tmp-${randomUUID()}`;
|
|
231
|
+
const handle = await open(temp, "wx", 0o600);
|
|
232
|
+
try {
|
|
233
|
+
try {
|
|
234
|
+
await handle.writeFile(content);
|
|
235
|
+
await handle.sync();
|
|
236
|
+
}
|
|
237
|
+
finally {
|
|
238
|
+
await handle.close();
|
|
239
|
+
}
|
|
240
|
+
if (exclusive) {
|
|
241
|
+
await link(temp, path);
|
|
242
|
+
await unlink(temp);
|
|
243
|
+
}
|
|
244
|
+
else
|
|
245
|
+
await rename(temp, path);
|
|
246
|
+
await flushDirectory(resolve(path, ".."));
|
|
247
|
+
}
|
|
248
|
+
finally {
|
|
249
|
+
await unlink(temp).catch((error) => {
|
|
250
|
+
if (error.code !== "ENOENT")
|
|
251
|
+
throw error;
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
export async function createPublicationJournal(dataDir, input, repository, stop) {
|
|
256
|
+
const intent = validatePublishIntent(input);
|
|
257
|
+
const existing = await readPublicationJournal(dataDir, intent);
|
|
258
|
+
if (existing)
|
|
259
|
+
return existing;
|
|
260
|
+
const names = await inspectDirectory(dataDir, true);
|
|
261
|
+
if (names.length >= PUBLICATION_JOURNAL_LIMITS.entries * 3 - 1)
|
|
262
|
+
throw new Error("Publication journal temporary capacity exhausted");
|
|
263
|
+
if (names.filter((name) => name.endsWith(".jsonl")).length >= PUBLICATION_JOURNAL_LIMITS.entries)
|
|
264
|
+
throw new Error("Publication journal is full");
|
|
265
|
+
const facts = {
|
|
266
|
+
version: 1,
|
|
267
|
+
sequence: 0,
|
|
268
|
+
previous: "",
|
|
269
|
+
phase: stop ? "closed" : "prepared",
|
|
270
|
+
intent,
|
|
271
|
+
...(repository ? { repository } : {}),
|
|
272
|
+
...(stop ? { stop } : {}),
|
|
273
|
+
};
|
|
274
|
+
const event = { ...facts, hash: digest(facts) };
|
|
275
|
+
const line = JSON.stringify(event) + "\n";
|
|
276
|
+
// Reserve enough space for every terminal event before objects, refs or CAS are written.
|
|
277
|
+
if (Buffer.byteLength(line) > PUBLICATION_JOURNAL_LIMITS.headerBytes)
|
|
278
|
+
throw new Error("Publication journal intent exceeds reserved capacity");
|
|
279
|
+
parsePublicationJournal(line, intent);
|
|
280
|
+
await writeAtomicJournal(join(publicationJournalDirectory(dataDir), fileName(intent)), line, true);
|
|
281
|
+
return (await readPublicationJournal(dataDir, intent));
|
|
282
|
+
}
|
|
283
|
+
export async function appendPublicationJournal(dataDir, journal, phase, proof) {
|
|
284
|
+
const current = await readPublicationJournal(dataDir, journal.intent);
|
|
285
|
+
if (!current || current.hash !== journal.hash)
|
|
286
|
+
throw new Error("Publication journal changed concurrently");
|
|
287
|
+
assertTransition(current, phase, proof?.receipt, proof?.stop, proof?.processStopped);
|
|
288
|
+
// Two slots always remain for a receipt and cancellation after any CAS start.
|
|
289
|
+
if (current.sequence >=
|
|
290
|
+
PUBLICATION_JOURNAL_LIMITS.events - (phase === "cas_started" && !proof?.processStopped ? 5 : 1))
|
|
291
|
+
throw new Error("Publication journal reserved capacity exhausted");
|
|
292
|
+
const facts = {
|
|
293
|
+
version: 1,
|
|
294
|
+
sequence: current.sequence + 1,
|
|
295
|
+
previous: current.hash,
|
|
296
|
+
phase,
|
|
297
|
+
...proof,
|
|
298
|
+
};
|
|
299
|
+
const line = JSON.stringify({ ...facts, hash: digest(facts) }) + "\n";
|
|
300
|
+
if (Buffer.byteLength(line) > 4096)
|
|
301
|
+
throw new Error("Publication journal event too large");
|
|
302
|
+
const names = await inspectDirectory(dataDir, false);
|
|
303
|
+
if (names.length >= PUBLICATION_JOURNAL_LIMITS.entries * 3 - 1)
|
|
304
|
+
throw new Error("Publication journal temporary capacity exhausted");
|
|
305
|
+
const path = join(publicationJournalDirectory(dataDir), fileName(journal.intent));
|
|
306
|
+
const raw = await readFile(path, "utf8");
|
|
307
|
+
if (Buffer.byteLength(raw) + Buffer.byteLength(line) > PUBLICATION_JOURNAL_LIMITS.bytes)
|
|
308
|
+
throw new Error("Publication journal capacity exceeded");
|
|
309
|
+
parsePublicationJournal(raw + line, journal.intent);
|
|
310
|
+
await writeAtomicJournal(path, raw + line, false);
|
|
311
|
+
return (await readPublicationJournal(dataDir, journal.intent));
|
|
312
|
+
}
|