@agent-teams/engineering-foundation 0.17.0-rc.0 → 0.17.0-rc.2
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/README.md +11 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/changesets-prerelease-state.d.ts +10 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/changesets-prerelease-state.d.ts.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/changesets-prerelease-state.js +69 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/changesets-prerelease-state.js.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/filesystem-public-api-repository.d.ts.map +1 -1
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/filesystem-public-api-repository.js +27 -7
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/filesystem-public-api-repository.js.map +1 -1
- package/dist/capabilities/public-api-compatibility/application/model/public-api.d.ts +2 -0
- package/dist/capabilities/public-api-compatibility/application/model/public-api.d.ts.map +1 -1
- package/dist/capabilities/public-api-compatibility/application/use-cases/promote-public-api-baselines.d.ts.map +1 -1
- package/dist/capabilities/public-api-compatibility/application/use-cases/promote-public-api-baselines.js +21 -3
- package/dist/capabilities/public-api-compatibility/application/use-cases/promote-public-api-baselines.js.map +1 -1
- package/dist/document-authoring/composition/inspect-document-transaction.d.ts.map +1 -1
- package/dist/document-authoring/composition/inspect-document-transaction.js +11 -12
- package/dist/document-authoring/composition/inspect-document-transaction.js.map +1 -1
- package/dist/foundation-state-contract.d.ts +1 -0
- package/dist/foundation-state-contract.d.ts.map +1 -1
- package/dist/foundation-state-contract.js +1 -0
- package/dist/foundation-state-contract.js.map +1 -1
- package/dist/local-mode/inspection.d.ts.map +1 -1
- package/dist/local-mode/inspection.js +11 -1
- package/dist/local-mode/inspection.js.map +1 -1
- package/dist/mutation/index.d.ts +8 -0
- package/dist/mutation/index.d.ts.map +1 -1
- package/dist/mutation/index.js +4 -1
- package/dist/mutation/index.js.map +1 -1
- package/dist/repository-mutation/adapters/node/node-bounded-regular-file.d.ts +2 -0
- package/dist/repository-mutation/adapters/node/node-bounded-regular-file.d.ts.map +1 -1
- package/dist/repository-mutation/adapters/node/node-bounded-regular-file.js +31 -23
- package/dist/repository-mutation/adapters/node/node-bounded-regular-file.js.map +1 -1
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-filesystem.d.ts +28 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-filesystem.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-filesystem.js +194 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-filesystem.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-filesystem.d.ts +25 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-filesystem.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-filesystem.js +129 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-filesystem.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-inspection.d.ts +12 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-inspection.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-inspection.js +46 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-inspection.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-journal-store.d.ts +21 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-journal-store.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-journal-store.js +178 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-journal-store.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-receipt.d.ts +4 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-receipt.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-receipt.js +43 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-receipt.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-recovery.d.ts +11 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-recovery.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-recovery.js +888 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-recovery.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction.d.ts +20 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction.js +546 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction.js.map +1 -0
- package/dist/repository-mutation/application/model/known-file-transaction-journal.d.ts +63 -0
- package/dist/repository-mutation/application/model/known-file-transaction-journal.d.ts.map +1 -0
- package/dist/repository-mutation/application/model/known-file-transaction-journal.js +15 -0
- package/dist/repository-mutation/application/model/known-file-transaction-journal.js.map +1 -0
- package/dist/repository-mutation/application/model/known-file-transaction.d.ts +64 -0
- package/dist/repository-mutation/application/model/known-file-transaction.d.ts.map +1 -0
- package/dist/repository-mutation/application/model/known-file-transaction.js +2 -0
- package/dist/repository-mutation/application/model/known-file-transaction.js.map +1 -0
- package/dist/repository-mutation/application/policies/known-file-transaction-envelope.d.ts +8 -0
- package/dist/repository-mutation/application/policies/known-file-transaction-envelope.d.ts.map +1 -0
- package/dist/repository-mutation/application/policies/known-file-transaction-envelope.js +241 -0
- package/dist/repository-mutation/application/policies/known-file-transaction-envelope.js.map +1 -0
- package/dist/repository-mutation/application/policies/known-file-transaction-plan.d.ts +7 -0
- package/dist/repository-mutation/application/policies/known-file-transaction-plan.d.ts.map +1 -0
- package/dist/repository-mutation/application/policies/known-file-transaction-plan.js +215 -0
- package/dist/repository-mutation/application/policies/known-file-transaction-plan.js.map +1 -0
- package/dist/schema-catalog.d.ts.map +1 -1
- package/dist/schema-catalog.js +3 -0
- package/dist/schema-catalog.js.map +1 -1
- package/dist/schema-ids.d.ts +1 -1
- package/dist/schema-ids.d.ts.map +1 -1
- package/dist/schema-ids.js +3 -0
- package/dist/schema-ids.js.map +1 -1
- package/dist/semantic-version.d.ts +1 -0
- package/dist/semantic-version.d.ts.map +1 -1
- package/dist/semantic-version.js +11 -0
- package/dist/semantic-version.js.map +1 -1
- package/dist/transaction-coordination/adapters/node/document-transaction-status.d.ts +9 -0
- package/dist/transaction-coordination/adapters/node/document-transaction-status.d.ts.map +1 -0
- package/dist/transaction-coordination/adapters/node/document-transaction-status.js +26 -0
- package/dist/transaction-coordination/adapters/node/document-transaction-status.js.map +1 -0
- package/dist/transaction-coordination/adapters/node/known-file-transaction-status.d.ts +8 -0
- package/dist/transaction-coordination/adapters/node/known-file-transaction-status.d.ts.map +1 -0
- package/dist/transaction-coordination/adapters/node/known-file-transaction-status.js +50 -0
- package/dist/transaction-coordination/adapters/node/known-file-transaction-status.js.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-foundation-transaction-slot.d.ts.map +1 -1
- package/dist/transaction-coordination/adapters/node/node-foundation-transaction-slot.js +33 -37
- package/dist/transaction-coordination/adapters/node/node-foundation-transaction-slot.js.map +1 -1
- package/dist/transaction-coordination/application/foundation-transaction-coordinator.d.ts +1 -1
- package/dist/transaction-coordination/application/foundation-transaction-coordinator.d.ts.map +1 -1
- package/dist/transaction-coordination/application/foundation-transaction-coordinator.js +12 -1
- package/dist/transaction-coordination/application/foundation-transaction-coordinator.js.map +1 -1
- package/dist/transaction-coordination/application/model/internal-transaction-status.d.ts +14 -2
- package/dist/transaction-coordination/application/model/internal-transaction-status.d.ts.map +1 -1
- package/dist/transaction-coordination/application/model/transaction-status.d.ts +6 -2
- package/dist/transaction-coordination/application/model/transaction-status.d.ts.map +1 -1
- package/package.json +4 -1
- package/schemas/foundation-transaction-envelope/v5.schema.json +94 -0
- package/schemas/known-file-transaction-plan/v1.schema.json +65 -0
- package/schemas/known-file-transaction-receipt/v1.schema.json +36 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { open, rename, unlink } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { TextDecoder } from "node:util";
|
|
5
|
+
import { canonicalJson } from "../../../canonical-json.js";
|
|
6
|
+
import { FOUNDATION_TRANSACTION_FILE, KNOWN_FILE_TRANSACTION_TEMPORARY_FILE } from "../../../foundation-state-contract.js";
|
|
7
|
+
import { parseStrictJson } from "../../../strict-json.js";
|
|
8
|
+
import { assertKnownFileTransactionEnvelope } from "../../application/policies/known-file-transaction-envelope.js";
|
|
9
|
+
import { captureFileHandleIdentity, pathMatchesRegularFileIdentity, readBoundedRegularFile } from "./node-bounded-regular-file.js";
|
|
10
|
+
import { cleanupIdentityMatchingOwnedTemporary } from "./node-cleanup-owned-temporary.js";
|
|
11
|
+
import { syncDirectoryDurably, syncDirectoryStrictly } from "./node-directory-durability.js";
|
|
12
|
+
const MAXIMUM_JOURNAL_BYTES = 32 * 1024 * 1024;
|
|
13
|
+
const strictUtf8 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
14
|
+
function errorCode(error) {
|
|
15
|
+
return error instanceof Error && "code" in error
|
|
16
|
+
? error.code
|
|
17
|
+
: undefined;
|
|
18
|
+
}
|
|
19
|
+
function digest(content) {
|
|
20
|
+
return `sha256:${createHash("sha256").update(content).digest("hex")}`;
|
|
21
|
+
}
|
|
22
|
+
function bytes(envelope) {
|
|
23
|
+
assertKnownFileTransactionEnvelope(envelope);
|
|
24
|
+
const result = Buffer.from(`${canonicalJson(envelope)}\n`, "utf8");
|
|
25
|
+
if (result.byteLength > MAXIMUM_JOURNAL_BYTES) {
|
|
26
|
+
throw new Error("Known-file transaction journal exceeds its byte limit.");
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
async function readEnvelope(path) {
|
|
31
|
+
let observed;
|
|
32
|
+
try {
|
|
33
|
+
observed = await readBoundedRegularFile(path, MAXIMUM_JOURNAL_BYTES);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (errorCode(error) === "ENOENT") {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
if (observed.outcome !== "read") {
|
|
42
|
+
throw new Error("Known-file transaction journal is not one stable regular file.");
|
|
43
|
+
}
|
|
44
|
+
const parsed = parseStrictJson(strictUtf8.decode(observed.bytes));
|
|
45
|
+
assertKnownFileTransactionEnvelope(parsed);
|
|
46
|
+
if (!observed.bytes.equals(bytes(parsed))) {
|
|
47
|
+
throw new Error("Known-file transaction journal bytes are not canonical.");
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
envelope: parsed,
|
|
51
|
+
authority: { digest: digest(observed.bytes), identity: observed.identity }
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async function prove(path, authority) {
|
|
55
|
+
const observed = await readBoundedRegularFile(path, MAXIMUM_JOURNAL_BYTES);
|
|
56
|
+
if (observed.outcome !== "read" || digest(observed.bytes) !== authority.digest ||
|
|
57
|
+
await pathMatchesRegularFileIdentity(path, authority.identity) !== "match") {
|
|
58
|
+
throw new Error("Known-file transaction journal authority changed concurrently.");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export class NodeKnownFileTransactionJournalStore {
|
|
62
|
+
#journalPath;
|
|
63
|
+
#parent;
|
|
64
|
+
#temporaryPath;
|
|
65
|
+
constructor(stateDirectory) {
|
|
66
|
+
this.#parent = stateDirectory;
|
|
67
|
+
this.#journalPath = join(stateDirectory, FOUNDATION_TRANSACTION_FILE);
|
|
68
|
+
this.#temporaryPath = join(stateDirectory, KNOWN_FILE_TRANSACTION_TEMPORARY_FILE);
|
|
69
|
+
}
|
|
70
|
+
async read() {
|
|
71
|
+
const canonical = await readEnvelope(this.#journalPath);
|
|
72
|
+
if (canonical !== undefined) {
|
|
73
|
+
return canonical;
|
|
74
|
+
}
|
|
75
|
+
return readEnvelope(this.#temporaryPath);
|
|
76
|
+
}
|
|
77
|
+
async #writeTemporary(envelope) {
|
|
78
|
+
const content = bytes(envelope);
|
|
79
|
+
let handle;
|
|
80
|
+
try {
|
|
81
|
+
handle = await open(this.#temporaryPath, "wx", 0o600);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
if (errorCode(error) === "EEXIST") {
|
|
85
|
+
const stale = await readEnvelope(this.#temporaryPath);
|
|
86
|
+
if (stale === undefined) {
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
await prove(this.#temporaryPath, stale.authority);
|
|
90
|
+
await unlink(this.#temporaryPath);
|
|
91
|
+
await syncDirectoryStrictly(this.#parent);
|
|
92
|
+
handle = await open(this.#temporaryPath, "wx", 0o600);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
await handle.writeFile(content);
|
|
100
|
+
await handle.sync();
|
|
101
|
+
return { digest: digest(content), identity: await captureFileHandleIdentity(handle) };
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
await handle.close();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async create(envelope) {
|
|
108
|
+
if (await readEnvelope(this.#journalPath) !== undefined) {
|
|
109
|
+
throw new Error("Foundation transaction slot is already occupied.");
|
|
110
|
+
}
|
|
111
|
+
const authority = await this.#writeTemporary(envelope);
|
|
112
|
+
await prove(this.#temporaryPath, authority);
|
|
113
|
+
await rename(this.#temporaryPath, this.#journalPath);
|
|
114
|
+
await syncDirectoryStrictly(this.#parent);
|
|
115
|
+
await prove(this.#journalPath, authority);
|
|
116
|
+
return authority;
|
|
117
|
+
}
|
|
118
|
+
async replace(expected, envelope) {
|
|
119
|
+
await prove(this.#journalPath, expected);
|
|
120
|
+
const authority = await this.#writeTemporary(envelope);
|
|
121
|
+
await prove(this.#journalPath, expected);
|
|
122
|
+
await prove(this.#temporaryPath, authority);
|
|
123
|
+
await rename(this.#temporaryPath, this.#journalPath);
|
|
124
|
+
await syncDirectoryStrictly(this.#parent);
|
|
125
|
+
await prove(this.#journalPath, authority);
|
|
126
|
+
return authority;
|
|
127
|
+
}
|
|
128
|
+
async remove(expected) {
|
|
129
|
+
await prove(this.#journalPath, expected);
|
|
130
|
+
await unlink(this.#journalPath);
|
|
131
|
+
await syncDirectoryStrictly(this.#parent);
|
|
132
|
+
}
|
|
133
|
+
async canonicalizeTemporary() {
|
|
134
|
+
const canonical = await readEnvelope(this.#journalPath);
|
|
135
|
+
if (canonical !== undefined) {
|
|
136
|
+
// The canonical envelope remains authoritative during replacement. A
|
|
137
|
+
// crash can leave an unbound candidate torn or foreign; recovery must
|
|
138
|
+
// neither parse nor mutate that pathname. It remains preserved evidence
|
|
139
|
+
// and must not be parsed as authority. Capture a stable regular
|
|
140
|
+
// candidate by identity and retire it into terminal evidence so neither
|
|
141
|
+
// a torn write nor a concurrent pathname replacement can block replay.
|
|
142
|
+
let candidate;
|
|
143
|
+
try {
|
|
144
|
+
candidate = await readBoundedRegularFile(this.#temporaryPath, MAXIMUM_JOURNAL_BYTES);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
if (errorCode(error) === "ENOENT") {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
if (candidate.outcome !== "read") {
|
|
153
|
+
throw new Error("Known-file transaction candidate cannot be retired safely.");
|
|
154
|
+
}
|
|
155
|
+
const retired = await cleanupIdentityMatchingOwnedTemporary({
|
|
156
|
+
allowUnsupportedDirectoryDurability: false,
|
|
157
|
+
displayPath: KNOWN_FILE_TRANSACTION_TEMPORARY_FILE,
|
|
158
|
+
expectedIdentity: candidate.identity,
|
|
159
|
+
parent: this.#parent,
|
|
160
|
+
rm: async () => { },
|
|
161
|
+
syncDirectory: syncDirectoryDurably,
|
|
162
|
+
temporaryPath: this.#temporaryPath
|
|
163
|
+
});
|
|
164
|
+
if (retired === "different") {
|
|
165
|
+
throw new Error("Known-file transaction candidate changed during retirement.");
|
|
166
|
+
}
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const temporary = await readEnvelope(this.#temporaryPath);
|
|
170
|
+
if (temporary === undefined) {
|
|
171
|
+
throw new Error("Known-file recovery journal is absent.");
|
|
172
|
+
}
|
|
173
|
+
await prove(this.#temporaryPath, temporary.authority);
|
|
174
|
+
await rename(this.#temporaryPath, this.#journalPath);
|
|
175
|
+
await syncDirectoryStrictly(this.#parent);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=node-known-file-transaction-journal-store.js.map
|
package/dist/repository-mutation/adapters/node/node-known-file-transaction-journal-store.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-known-file-transaction-journal-store.js","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-known-file-transaction-journal-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAmB,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,aAAa,EAA2B,MAAM,4BAA4B,CAAC;AACpF,OAAO,EACL,2BAA2B,EAC3B,qCAAqC,EACtC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,kCAAkC,EAAE,MAAM,+DAA+D,CAAC;AACnH,OAAO,EACL,yBAAyB,EACzB,8BAA8B,EAC9B,sBAAsB,EACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,qCAAqC,EAAE,MAAM,mCAAmC,CAAC;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a,EAAE,oBAAoB;gBACnC,aAAa,EAAE,IAAI,CAAC,cAAc;aACnC,CAAC,CAAC;YACH,IAAI,OAAO,KAAK,WAAW,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;YACjF,CAAC;YACD,OAAO;QACT,CAAC;QACD,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC1D,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,CAAC;QACD,MAAM,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QACtD,MAAM,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACrD,MAAM,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;CACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { KnownFileTransactionReceiptV1 } from "../../application/model/known-file-transaction.js";
|
|
2
|
+
import type { KnownFileTransactionJournalV1 } from "../../application/model/known-file-transaction-journal.js";
|
|
3
|
+
export declare function compileRolledBackReceipt(journal: KnownFileTransactionJournalV1): KnownFileTransactionReceiptV1;
|
|
4
|
+
//# sourceMappingURL=node-known-file-transaction-receipt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-known-file-transaction-receipt.d.ts","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-known-file-transaction-receipt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mDAAmD,CAAC;AACvG,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,2DAA2D,CAAC;AAG/G,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,6BAA6B,GACrC,6BAA6B,CA0C/B"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { sha256Json } from "../../../canonical-json.js";
|
|
2
|
+
import { KnownFileTransactionError } from "./node-known-file-transaction-filesystem.js";
|
|
3
|
+
export function compileRolledBackReceipt(journal) {
|
|
4
|
+
const operations = journal.operations.map((entry, index) => {
|
|
5
|
+
const planOperation = journal.plan.operations[index];
|
|
6
|
+
if (entry.state === "already-satisfied") {
|
|
7
|
+
return Object.freeze({
|
|
8
|
+
path: entry.path,
|
|
9
|
+
outcome: "already-satisfied",
|
|
10
|
+
resultDigest: planOperation.postimage.digest
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
if (planOperation.precondition.state === "absent") {
|
|
14
|
+
return Object.freeze({
|
|
15
|
+
path: entry.path,
|
|
16
|
+
outcome: "rolled-back-to-absent"
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
if (entry.matchedPreimage === undefined) {
|
|
20
|
+
throw new KnownFileTransactionError("KNOWN_FILE_JOURNAL_INVALID", `Replacement preimage binding is absent: ${entry.path}.`);
|
|
21
|
+
}
|
|
22
|
+
return Object.freeze({
|
|
23
|
+
path: entry.path,
|
|
24
|
+
outcome: "rolled-back-to-preimage",
|
|
25
|
+
resultDigest: planOperation.precondition.acceptedPreimages[entry.matchedPreimage].digest
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
const body = {
|
|
29
|
+
schemaVersion: 1,
|
|
30
|
+
protocol: "foundation.replace-known-file/v1",
|
|
31
|
+
planDigest: journal.plan.planDigest,
|
|
32
|
+
outcome: "rolled-back",
|
|
33
|
+
operations: Object.freeze(operations)
|
|
34
|
+
};
|
|
35
|
+
return Object.freeze({
|
|
36
|
+
...body,
|
|
37
|
+
receiptDigest: sha256Json({
|
|
38
|
+
domain: "agent-teams.foundation.known-file-transaction-receipt/v1",
|
|
39
|
+
body
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=node-known-file-transaction-receipt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-known-file-transaction-receipt.js","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-known-file-transaction-receipt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AAExF,MAAM,UAAU,wBAAwB,CACtC,OAAsC;IAEtC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACzD,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAE,CAAC;QACtD,IAAI,KAAK,CAAC,KAAK,KAAK,mBAAmB,EAAE,CAAC;YACxC,OAAO,MAAM,CAAC,MAAM,CAAC;gBACnB,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,OAAO,EAAE,mBAA4B;gBACrC,YAAY,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM;aAC7C,CAAC,CAAC;QACL,CAAC;QACD,IAAI,aAAa,CAAC,YAAY,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YAClD,OAAO,MAAM,CAAC,MAAM,CAAC;gBACnB,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,OAAO,EAAE,uBAAgC;aAC1C,CAAC,CAAC;QACL,CAAC;QACD,IAAI,KAAK,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YACxC,MAAM,IAAI,yBAAyB,CACjC,4BAA4B,EAC5B,2CAA2C,KAAK,CAAC,IAAI,GAAG,CACzD,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC;YACnB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,yBAAkC;YAC3C,YAAY,EAAE,aAAa,CAAC,YAAY,CAAC,iBAAiB,CAAC,KAAK,CAAC,eAAe,CAAE,CAAC,MAAM;SAC1F,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,MAAM,IAAI,GAAG;QACX,aAAa,EAAE,CAAU;QACzB,QAAQ,EAAE,kCAA2C;QACrD,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU;QACnC,OAAO,EAAE,aAAsB;QAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;KACtC,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,GAAG,IAAI;QACP,aAAa,EAAE,UAAU,CAAC;YACxB,MAAM,EAAE,0DAA0D;YAClE,IAAI;SACL,CAAC;KACH,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { KnownFileTransactionReceiptV1 } from "../../application/model/known-file-transaction.js";
|
|
2
|
+
export type KnownFileRecoveryFaultInjector = (point: {
|
|
3
|
+
readonly phase: "after-committed-capture-unlinked" | "after-destination-retired" | "after-rollback-linked" | "after-rollback-capture-unlinked" | "after-retirement-directory-bound" | "after-retirement-captured" | "after-retirement-unlink-authorized";
|
|
4
|
+
readonly operationIndex: number;
|
|
5
|
+
readonly path: string;
|
|
6
|
+
}) => Promise<void> | void;
|
|
7
|
+
export declare function recoverKnownFileTransaction(options: {
|
|
8
|
+
readonly consumerRoot: string;
|
|
9
|
+
readonly faultInjector?: KnownFileRecoveryFaultInjector;
|
|
10
|
+
}): Promise<KnownFileTransactionReceiptV1>;
|
|
11
|
+
//# sourceMappingURL=node-known-file-transaction-recovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-known-file-transaction-recovery.d.ts","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-known-file-transaction-recovery.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAGV,6BAA6B,EAC9B,MAAM,mDAAmD,CAAC;AA8C3D,MAAM,MAAM,8BAA8B,GAAG,CAAC,KAAK,EAAE;IACnD,QAAQ,CAAC,KAAK,EACV,kCAAkC,GAClC,2BAA2B,GAC3B,uBAAuB,GACvB,iCAAiC,GACjC,kCAAkC,GAClC,2BAA2B,GAC3B,oCAAoC,CAAC;IACzC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAgqC3B,wBAAsB,2BAA2B,CAAC,OAAO,EAAE;IACzD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,8BAA8B,CAAC;CACzD,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAqEzC"}
|