@agent-teams/engineering-foundation 0.12.0 → 0.13.1

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.
Files changed (137) hide show
  1. package/dist/cli.js +23 -12
  2. package/dist/cli.js.map +1 -1
  3. package/dist/foundation-state-contract.d.ts +7 -0
  4. package/dist/foundation-state-contract.d.ts.map +1 -0
  5. package/dist/foundation-state-contract.js +7 -0
  6. package/dist/foundation-state-contract.js.map +1 -0
  7. package/dist/index.d.ts +2 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +1 -0
  10. package/dist/index.js.map +1 -1
  11. package/dist/local-mode/attach-transaction.d.ts.map +1 -1
  12. package/dist/local-mode/attach-transaction.js +13 -7
  13. package/dist/local-mode/attach-transaction.js.map +1 -1
  14. package/dist/local-mode/inspection.d.ts +4 -1
  15. package/dist/local-mode/inspection.d.ts.map +1 -1
  16. package/dist/local-mode/inspection.js +20 -0
  17. package/dist/local-mode/inspection.js.map +1 -1
  18. package/dist/local-mode/local-state-store.d.ts.map +1 -1
  19. package/dist/local-mode/local-state-store.js +8 -105
  20. package/dist/local-mode/local-state-store.js.map +1 -1
  21. package/dist/local-mode/service.d.ts.map +1 -1
  22. package/dist/local-mode/service.js +17 -4
  23. package/dist/local-mode/service.js.map +1 -1
  24. package/dist/local-mode/types.d.ts +7 -4
  25. package/dist/local-mode/types.d.ts.map +1 -1
  26. package/dist/local-mode/types.js +1 -4
  27. package/dist/local-mode/types.js.map +1 -1
  28. package/dist/package-version.d.ts +2 -0
  29. package/dist/package-version.d.ts.map +1 -0
  30. package/dist/package-version.js +10 -0
  31. package/dist/package-version.js.map +1 -0
  32. package/dist/process-execution/windows-managed-process.d.ts.map +1 -1
  33. package/dist/process-execution/windows-managed-process.js +1 -0
  34. package/dist/process-execution/windows-managed-process.js.map +1 -1
  35. package/dist/repository-mutation/adapters/node/node-absent-file-publication.d.ts +31 -0
  36. package/dist/repository-mutation/adapters/node/node-absent-file-publication.d.ts.map +1 -0
  37. package/dist/repository-mutation/adapters/node/node-absent-file-publication.js +272 -0
  38. package/dist/repository-mutation/adapters/node/node-absent-file-publication.js.map +1 -0
  39. package/dist/repository-mutation/adapters/node/node-bounded-regular-file.d.ts +20 -0
  40. package/dist/repository-mutation/adapters/node/node-bounded-regular-file.d.ts.map +1 -0
  41. package/dist/repository-mutation/adapters/node/node-bounded-regular-file.js +123 -0
  42. package/dist/repository-mutation/adapters/node/node-bounded-regular-file.js.map +1 -0
  43. package/dist/repository-mutation/adapters/node/node-directory-durability.d.ts +12 -0
  44. package/dist/repository-mutation/adapters/node/node-directory-durability.d.ts.map +1 -0
  45. package/dist/repository-mutation/adapters/node/node-directory-durability.js +32 -0
  46. package/dist/repository-mutation/adapters/node/node-directory-durability.js.map +1 -0
  47. package/dist/repository-mutation/adapters/node/node-existing-repository-ancestors.d.ts +13 -0
  48. package/dist/repository-mutation/adapters/node/node-existing-repository-ancestors.d.ts.map +1 -0
  49. package/dist/repository-mutation/adapters/node/node-existing-repository-ancestors.js +67 -0
  50. package/dist/repository-mutation/adapters/node/node-existing-repository-ancestors.js.map +1 -0
  51. package/dist/repository-mutation/adapters/node/node-repository-path.d.ts +2 -0
  52. package/dist/repository-mutation/adapters/node/node-repository-path.d.ts.map +1 -0
  53. package/dist/repository-mutation/adapters/node/node-repository-path.js +7 -0
  54. package/dist/repository-mutation/adapters/node/node-repository-path.js.map +1 -0
  55. package/dist/repository-mutation/application/model/exact-postimage.d.ts +17 -0
  56. package/dist/repository-mutation/application/model/exact-postimage.d.ts.map +1 -0
  57. package/dist/repository-mutation/application/model/exact-postimage.js +11 -0
  58. package/dist/repository-mutation/application/model/exact-postimage.js.map +1 -0
  59. package/dist/repository-mutation/application/model/path-identity.d.ts +7 -0
  60. package/dist/repository-mutation/application/model/path-identity.d.ts.map +1 -0
  61. package/dist/repository-mutation/application/model/path-identity.js +2 -0
  62. package/dist/repository-mutation/application/model/path-identity.js.map +1 -0
  63. package/dist/repository-mutation/application/model/repository-path.d.ts +8 -0
  64. package/dist/repository-mutation/application/model/repository-path.d.ts.map +1 -0
  65. package/dist/repository-mutation/application/model/repository-path.js +74 -0
  66. package/dist/repository-mutation/application/model/repository-path.js.map +1 -0
  67. package/dist/scaffolding/adapters/node/filesystem-authority-workspace.d.ts.map +1 -1
  68. package/dist/scaffolding/adapters/node/filesystem-authority-workspace.js +52 -8
  69. package/dist/scaffolding/adapters/node/filesystem-authority-workspace.js.map +1 -1
  70. package/dist/scaffolding/adapters/node/filesystem-file-identity.d.ts +3 -19
  71. package/dist/scaffolding/adapters/node/filesystem-file-identity.d.ts.map +1 -1
  72. package/dist/scaffolding/adapters/node/filesystem-file-identity.js +1 -121
  73. package/dist/scaffolding/adapters/node/filesystem-file-identity.js.map +1 -1
  74. package/dist/scaffolding/adapters/node/filesystem-journal.d.ts +1 -1
  75. package/dist/scaffolding/adapters/node/filesystem-journal.d.ts.map +1 -1
  76. package/dist/scaffolding/adapters/node/filesystem-journal.js +4 -20
  77. package/dist/scaffolding/adapters/node/filesystem-journal.js.map +1 -1
  78. package/dist/scaffolding/adapters/node/filesystem-operation-state.d.ts +2 -1
  79. package/dist/scaffolding/adapters/node/filesystem-operation-state.d.ts.map +1 -1
  80. package/dist/scaffolding/adapters/node/filesystem-operation-state.js +73 -122
  81. package/dist/scaffolding/adapters/node/filesystem-operation-state.js.map +1 -1
  82. package/dist/scaffolding/adapters/node/filesystem-path-guard.d.ts.map +1 -1
  83. package/dist/scaffolding/adapters/node/filesystem-path-guard.js +27 -68
  84. package/dist/scaffolding/adapters/node/filesystem-path-guard.js.map +1 -1
  85. package/dist/scaffolding/adapters/node/installed-foundation-version.d.ts +1 -1
  86. package/dist/scaffolding/adapters/node/installed-foundation-version.d.ts.map +1 -1
  87. package/dist/scaffolding/adapters/node/installed-foundation-version.js +1 -9
  88. package/dist/scaffolding/adapters/node/installed-foundation-version.js.map +1 -1
  89. package/dist/scaffolding/application/policies/legacy-scaffolding-repository-path.d.ts +4 -0
  90. package/dist/scaffolding/application/policies/legacy-scaffolding-repository-path.d.ts.map +1 -0
  91. package/dist/scaffolding/application/policies/legacy-scaffolding-repository-path.js +48 -0
  92. package/dist/scaffolding/application/policies/legacy-scaffolding-repository-path.js.map +1 -0
  93. package/dist/scaffolding/kernel/authority-journal-validation.d.ts +4 -0
  94. package/dist/scaffolding/kernel/authority-journal-validation.d.ts.map +1 -0
  95. package/dist/scaffolding/kernel/authority-journal-validation.js +24 -0
  96. package/dist/scaffolding/kernel/authority-journal-validation.js.map +1 -0
  97. package/dist/transaction-coordination/adapters/node/installed-foundation-build-identity.d.ts +11 -0
  98. package/dist/transaction-coordination/adapters/node/installed-foundation-build-identity.d.ts.map +1 -0
  99. package/dist/transaction-coordination/adapters/node/installed-foundation-build-identity.js +130 -0
  100. package/dist/transaction-coordination/adapters/node/installed-foundation-build-identity.js.map +1 -0
  101. package/dist/transaction-coordination/adapters/node/node-foundation-operation-lock.d.ts +7 -0
  102. package/dist/transaction-coordination/adapters/node/node-foundation-operation-lock.d.ts.map +1 -0
  103. package/dist/transaction-coordination/adapters/node/node-foundation-operation-lock.js +336 -0
  104. package/dist/transaction-coordination/adapters/node/node-foundation-operation-lock.js.map +1 -0
  105. package/dist/transaction-coordination/adapters/node/node-foundation-state-directory.d.ts +4 -0
  106. package/dist/transaction-coordination/adapters/node/node-foundation-state-directory.d.ts.map +1 -0
  107. package/dist/transaction-coordination/adapters/node/node-foundation-state-directory.js +76 -0
  108. package/dist/transaction-coordination/adapters/node/node-foundation-state-directory.js.map +1 -0
  109. package/dist/transaction-coordination/adapters/node/node-foundation-transaction-coordinator.d.ts +3 -0
  110. package/dist/transaction-coordination/adapters/node/node-foundation-transaction-coordinator.d.ts.map +1 -0
  111. package/dist/transaction-coordination/adapters/node/node-foundation-transaction-coordinator.js +23 -0
  112. package/dist/transaction-coordination/adapters/node/node-foundation-transaction-coordinator.js.map +1 -0
  113. package/dist/transaction-coordination/adapters/node/node-foundation-transaction-slot.d.ts +12 -0
  114. package/dist/transaction-coordination/adapters/node/node-foundation-transaction-slot.d.ts.map +1 -0
  115. package/dist/transaction-coordination/adapters/node/node-foundation-transaction-slot.js +332 -0
  116. package/dist/transaction-coordination/adapters/node/node-foundation-transaction-slot.js.map +1 -0
  117. package/dist/transaction-coordination/application/foundation-transaction-coordinator.d.ts +22 -0
  118. package/dist/transaction-coordination/application/foundation-transaction-coordinator.d.ts.map +1 -0
  119. package/dist/transaction-coordination/application/foundation-transaction-coordinator.js +78 -0
  120. package/dist/transaction-coordination/application/foundation-transaction-coordinator.js.map +1 -0
  121. package/dist/transaction-coordination/application/foundation-transaction-error.d.ts +16 -0
  122. package/dist/transaction-coordination/application/foundation-transaction-error.d.ts.map +1 -0
  123. package/dist/transaction-coordination/application/foundation-transaction-error.js +19 -0
  124. package/dist/transaction-coordination/application/foundation-transaction-error.js.map +1 -0
  125. package/dist/transaction-coordination/application/model/transaction-status.d.ts +47 -0
  126. package/dist/transaction-coordination/application/model/transaction-status.d.ts.map +1 -0
  127. package/dist/transaction-coordination/application/model/transaction-status.js +2 -0
  128. package/dist/transaction-coordination/application/model/transaction-status.js.map +1 -0
  129. package/dist/transaction-coordination/application/ports/foundation-operation-lock.d.ts +7 -0
  130. package/dist/transaction-coordination/application/ports/foundation-operation-lock.d.ts.map +1 -0
  131. package/dist/transaction-coordination/application/ports/foundation-operation-lock.js +2 -0
  132. package/dist/transaction-coordination/application/ports/foundation-operation-lock.js.map +1 -0
  133. package/dist/transaction-coordination/application/ports/foundation-transaction-slot.d.ts +5 -0
  134. package/dist/transaction-coordination/application/ports/foundation-transaction-slot.d.ts.map +1 -0
  135. package/dist/transaction-coordination/application/ports/foundation-transaction-slot.js +2 -0
  136. package/dist/transaction-coordination/application/ports/foundation-transaction-slot.js.map +1 -0
  137. package/package.json +1 -1
@@ -0,0 +1,332 @@
1
+ import { lstat, readdir } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { TextDecoder } from "node:util";
4
+ import { FOUNDATION_TRANSACTION_FILE, FOUNDATION_TRANSACTION_TEMPORARY_FILE, FOUNDATION_LINK_STATE_FILE, FOUNDATION_REGISTRY_BACKUP, LOCAL_STATE_DIRECTORY } from "../../../foundation-state-contract.js";
5
+ import { assertSchema } from "../../../schema-catalog.js";
6
+ import { sha256Bytes, sha256Json } from "../../../scaffolding/kernel/canonical-json.js";
7
+ import { assertAuthorityScaffoldJournal } from "../../../scaffolding/kernel/authority-journal-validation.js";
8
+ import { parseStrictJson } from "../../../strict-json.js";
9
+ import { readBoundedRegularFile } from "../../../repository-mutation/adapters/node/node-bounded-regular-file.js";
10
+ const maximumTransactionBytes = 32 * 1024 * 1024;
11
+ const maximumLinkStateBytes = 64 * 1024;
12
+ const maximumStateDirectoryEntries = 1024;
13
+ const strictUtf8 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
14
+ function isMissing(error) {
15
+ return (error instanceof Error &&
16
+ "code" in error &&
17
+ error.code === "ENOENT");
18
+ }
19
+ function isRecord(value) {
20
+ return typeof value === "object" && value !== null && !Array.isArray(value);
21
+ }
22
+ async function pathExists(path) {
23
+ try {
24
+ await lstat(path);
25
+ return true;
26
+ }
27
+ catch (error) {
28
+ if (isMissing(error)) {
29
+ return false;
30
+ }
31
+ throw error;
32
+ }
33
+ }
34
+ function manual(reason, message) {
35
+ return {
36
+ state: "manual-recovery-required",
37
+ reason,
38
+ diagnostics: [
39
+ {
40
+ code: "FOUNDATION_TRANSACTION_MANUAL_RECOVERY_REQUIRED",
41
+ message
42
+ }
43
+ ]
44
+ };
45
+ }
46
+ function recoveryRoute(exactFoundationVersion) {
47
+ return {
48
+ commandId: "scaffold-recover",
49
+ exactFoundationVersion
50
+ };
51
+ }
52
+ function pending(options) {
53
+ const diagnostics = [];
54
+ if (options.foundationVersion !== options.installedVersion) {
55
+ diagnostics.push({
56
+ code: "FOUNDATION_TRANSACTION_VERSION_MISMATCH",
57
+ message: `Foundation ${options.foundationVersion} must recover the pending ${options.operationKind} transaction before package ${options.installedVersion} (${options.installedBuildIdentity}) can mutate this repository.`
58
+ });
59
+ }
60
+ else {
61
+ diagnostics.push({
62
+ code: "FOUNDATION_TRANSACTION_ACTIVE",
63
+ message: `A pending ${options.operationKind} transaction must be recovered before another Foundation mutation can start.`
64
+ });
65
+ }
66
+ return {
67
+ state: "pending",
68
+ operationKind: options.operationKind,
69
+ format: options.format,
70
+ foundationVersion: options.foundationVersion,
71
+ recovery: recoveryRoute(options.foundationVersion),
72
+ diagnostics
73
+ };
74
+ }
75
+ function localModePending(message) {
76
+ return {
77
+ state: "pending",
78
+ operationKind: "local-mode",
79
+ format: "local-mode-v1",
80
+ recovery: { commandId: "detach" },
81
+ diagnostics: [{ code: "FOUNDATION_TRANSACTION_ACTIVE", message }]
82
+ };
83
+ }
84
+ function parseLinkPhase(value) {
85
+ if (!isRecord(value)) {
86
+ throw new Error("Foundation local-mode recovery state is invalid.");
87
+ }
88
+ const expectedKeys = [
89
+ "attachedAt",
90
+ "consumerRoot",
91
+ "gitCommit",
92
+ "gitDirty",
93
+ "packageVersion",
94
+ "phase",
95
+ "registryBackupPath",
96
+ "registryEntryKind",
97
+ "registryPackageRoot",
98
+ "schemaVersion",
99
+ "targetPackageRoot"
100
+ ];
101
+ if (value["schemaVersion"] !== 1 ||
102
+ !["ATTACHING", "DETACHING", "LOCAL"].includes(String(value["phase"])) ||
103
+ typeof value["consumerRoot"] !== "string" ||
104
+ typeof value["targetPackageRoot"] !== "string" ||
105
+ typeof value["registryBackupPath"] !== "string" ||
106
+ !["directory", "symbolic-link"].includes(String(value["registryEntryKind"])) ||
107
+ typeof value["registryPackageRoot"] !== "string" ||
108
+ typeof value["packageVersion"] !== "string" ||
109
+ typeof value["gitCommit"] !== "string" ||
110
+ typeof value["gitDirty"] !== "boolean" ||
111
+ typeof value["attachedAt"] !== "string" ||
112
+ Object.keys(value).toSorted().join(",") !== expectedKeys.join(",")) {
113
+ throw new Error("Foundation local-mode recovery state is invalid.");
114
+ }
115
+ return value["phase"];
116
+ }
117
+ async function inspectLocalModeEvidence(stateDirectory) {
118
+ let entries;
119
+ try {
120
+ entries = await readdir(stateDirectory);
121
+ }
122
+ catch (error) {
123
+ if (isMissing(error)) {
124
+ return { state: "idle", diagnostics: [] };
125
+ }
126
+ return manual("local-mode-evidence-invalid", "Foundation local-mode recovery evidence cannot be inspected safely.");
127
+ }
128
+ if (entries.length > maximumStateDirectoryEntries) {
129
+ return manual("local-mode-evidence-invalid", "Foundation local-mode state contains too many entries.");
130
+ }
131
+ if (entries.some((entry) => entry.startsWith(`${FOUNDATION_LINK_STATE_FILE}.`) &&
132
+ entry.endsWith(".tmp"))) {
133
+ return manual("local-mode-evidence-invalid", "An incomplete Foundation local-mode state write requires manual recovery.");
134
+ }
135
+ const hasBackup = entries.includes(FOUNDATION_REGISTRY_BACKUP);
136
+ if (!entries.includes(FOUNDATION_LINK_STATE_FILE)) {
137
+ return hasBackup
138
+ ? localModePending("An orphan Foundation registry backup must be recovered with detach before another mutation can start.")
139
+ : { state: "idle", diagnostics: [] };
140
+ }
141
+ try {
142
+ const record = await readBoundedRegularFile(join(stateDirectory, FOUNDATION_LINK_STATE_FILE), maximumLinkStateBytes);
143
+ if (record.outcome !== "read") {
144
+ throw new Error("Foundation local-mode state is not a stable regular file.");
145
+ }
146
+ const phase = parseLinkPhase(parseStrictJson(strictUtf8.decode(record.bytes)));
147
+ if (phase === "LOCAL" && hasBackup) {
148
+ return { state: "idle", diagnostics: [] };
149
+ }
150
+ return localModePending(`Foundation local-mode recovery is required (${phase}${hasBackup ? "" : ", registry backup missing"}) before another mutation can start.`);
151
+ }
152
+ catch {
153
+ return manual("local-mode-evidence-invalid", "Foundation local-mode recovery evidence is invalid and was preserved.");
154
+ }
155
+ }
156
+ function assertEnvelopeDigests(envelope) {
157
+ const journal = envelope["journal"];
158
+ if (envelope["payloadDigest"] !== sha256Json(journal)) {
159
+ throw new Error("Foundation transaction payload digest is invalid.");
160
+ }
161
+ const { envelopeDigest, ...body } = envelope;
162
+ if (envelopeDigest !== sha256Json(body)) {
163
+ throw new Error("Foundation transaction envelope digest is invalid.");
164
+ }
165
+ }
166
+ function assertDocumentPlanDigest(plan) {
167
+ const { planDigest, ...body } = plan;
168
+ if (planDigest !== sha256Json(body)) {
169
+ throw new Error("Document Plan digest is invalid.");
170
+ }
171
+ }
172
+ function assertDocumentTransactionBindings(journal, plan, envelopeState) {
173
+ const intent = plan["intent"];
174
+ const output = plan["output"];
175
+ const destination = journal["destination"];
176
+ if (!isRecord(intent) ||
177
+ plan["intentDigest"] !== sha256Json(intent) ||
178
+ !isRecord(output) ||
179
+ typeof output["contentBase64"] !== "string" ||
180
+ !isRecord(destination) ||
181
+ destination["path"] !== plan["destination"]) {
182
+ throw new Error("Document transaction semantic binding is invalid.");
183
+ }
184
+ const outputBytes = Buffer.from(output["contentBase64"], "base64");
185
+ if (outputBytes.toString("base64") !== output["contentBase64"] ||
186
+ output["size"] !== outputBytes.byteLength ||
187
+ output["digest"] !== sha256Bytes(outputBytes)) {
188
+ throw new Error("Document transaction output binding is invalid.");
189
+ }
190
+ const ownedTemporary = journal["ownedTemporary"];
191
+ if (ownedTemporary !== undefined) {
192
+ if (!isRecord(ownedTemporary) ||
193
+ ownedTemporary["digest"] !== output["digest"] ||
194
+ typeof ownedTemporary["path"] !== "string" ||
195
+ ownedTemporary["path"] !== `${String(plan["destination"])}.foundation-document.tmp`) {
196
+ throw new Error("Document transaction temporary binding is invalid.");
197
+ }
198
+ }
199
+ const precondition = plan["destinationPrecondition"];
200
+ if (!isRecord(precondition)) {
201
+ throw new Error("Document transaction destination precondition is invalid.");
202
+ }
203
+ const lifecycle = `${String(precondition["state"])}:${String(destination["state"])}:${String(ownedTemporary !== undefined)}`;
204
+ const expectedLifecycle = new Map([
205
+ ["PREPARED", new Set(["absent:pending:false", "absent:preexisting:false"])],
206
+ ["PUBLISHING", new Set(["absent:publishing:true"])],
207
+ ["PUBLISHED", new Set(["absent:published:false"])],
208
+ ]).get(String(envelopeState));
209
+ if (expectedLifecycle === undefined || !expectedLifecycle.has(lifecycle)) {
210
+ throw new Error("Document transaction lifecycle binding is invalid.");
211
+ }
212
+ }
213
+ async function inspectParsedTransaction(value, installedVersion, installedBuildIdentity) {
214
+ if (!isRecord(value) || typeof value["schemaVersion"] !== "number") {
215
+ return manual("invalid-slot", "The Foundation transaction slot is invalid and was preserved.");
216
+ }
217
+ if (value["schemaVersion"] === 1) {
218
+ await assertSchema("scaffold-recovery-journal/v1", value, "foundation-transaction-slot");
219
+ const journal = value;
220
+ assertAuthorityScaffoldJournal(journal);
221
+ const plan = journal.plan;
222
+ const compiler = plan["compiler"];
223
+ if (!isRecord(compiler) || typeof compiler["version"] !== "string") {
224
+ throw new Error("Legacy scaffolding journal compiler version is invalid.");
225
+ }
226
+ return pending({
227
+ operationKind: "scaffolding",
228
+ format: "legacy-scaffolding-v1",
229
+ foundationVersion: compiler["version"],
230
+ installedVersion,
231
+ installedBuildIdentity
232
+ });
233
+ }
234
+ if (value["schemaVersion"] === 2) {
235
+ await assertSchema("foundation-transaction-envelope/v2", value, "foundation-transaction-slot");
236
+ assertEnvelopeDigests(value);
237
+ const foundation = value["foundation"];
238
+ const operationKind = value["operationKind"];
239
+ const journal = value["journal"];
240
+ if (!isRecord(foundation) ||
241
+ typeof foundation["version"] !== "string" ||
242
+ typeof foundation["buildIdentity"] !== "string" ||
243
+ !isRecord(journal) ||
244
+ !["document-authoring", "scaffolding"].includes(String(operationKind))) {
245
+ throw new Error("Foundation transaction envelope binding is invalid.");
246
+ }
247
+ const plan = journal["plan"];
248
+ if (!isRecord(plan)) {
249
+ throw new Error("Foundation transaction Plan binding is invalid.");
250
+ }
251
+ const compiler = plan["compiler"];
252
+ if (!isRecord(compiler) ||
253
+ compiler["version"] !== foundation["version"] ||
254
+ (operationKind === "document-authoring" &&
255
+ compiler["buildIdentity"] !== foundation["buildIdentity"])) {
256
+ throw new Error("Foundation transaction compiler binding is invalid.");
257
+ }
258
+ if (operationKind === "document-authoring") {
259
+ assertDocumentPlanDigest(plan);
260
+ assertDocumentTransactionBindings(journal, plan, value["state"]);
261
+ }
262
+ else {
263
+ assertAuthorityScaffoldJournal(journal);
264
+ }
265
+ return {
266
+ state: "manual-recovery-required",
267
+ reason: "recovery-handler-unavailable",
268
+ operationKind: operationKind,
269
+ format: "envelope-v2",
270
+ foundationVersion: foundation["version"],
271
+ foundationBuildIdentity: foundation["buildIdentity"],
272
+ diagnostics: [
273
+ {
274
+ code: "FOUNDATION_TRANSACTION_MANUAL_RECOVERY_REQUIRED",
275
+ message: `A verified ${String(operationKind)} envelope v2 from Foundation ${foundation["version"]} (${foundation["buildIdentity"]}) was preserved, but this release does not yet provide its recovery handler.`
276
+ }
277
+ ]
278
+ };
279
+ }
280
+ return manual("unsupported-schema", `Foundation transaction schema version ${String(value["schemaVersion"])} is unsupported and was preserved.`);
281
+ }
282
+ export class NodeFoundationTransactionSlot {
283
+ #installedBuildIdentity;
284
+ #installedVersion;
285
+ #stateDirectory;
286
+ #slotPath;
287
+ #temporaryPath;
288
+ constructor(options) {
289
+ this.#installedBuildIdentity = options.installedBuildIdentity;
290
+ this.#installedVersion = options.installedVersion;
291
+ const stateDirectory = join(options.consumerRoot, LOCAL_STATE_DIRECTORY);
292
+ this.#stateDirectory = stateDirectory;
293
+ this.#slotPath = join(stateDirectory, FOUNDATION_TRANSACTION_FILE);
294
+ this.#temporaryPath = join(stateDirectory, FOUNDATION_TRANSACTION_TEMPORARY_FILE);
295
+ }
296
+ async #inspectTransactionEvidence() {
297
+ if (await pathExists(this.#temporaryPath)) {
298
+ return manual("orphan-temporary", "An orphan Foundation transaction temporary exists; it was preserved and requires manual recovery.");
299
+ }
300
+ let record;
301
+ try {
302
+ record = await readBoundedRegularFile(this.#slotPath, maximumTransactionBytes);
303
+ }
304
+ catch (error) {
305
+ if (isMissing(error)) {
306
+ return { state: "idle", diagnostics: [] };
307
+ }
308
+ return manual("invalid-slot", "The Foundation transaction slot could not be read safely and was preserved.");
309
+ }
310
+ if (record.outcome !== "read") {
311
+ return manual("unstable-slot", "The Foundation transaction slot is not a stable bounded regular file and was preserved.");
312
+ }
313
+ try {
314
+ const source = strictUtf8.decode(record.bytes);
315
+ return await inspectParsedTransaction(parseStrictJson(source), this.#installedVersion, this.#installedBuildIdentity);
316
+ }
317
+ catch {
318
+ return manual("corrupt-or-incompatible", "The Foundation transaction slot is corrupt, tampered, or incompatible; it was preserved.");
319
+ }
320
+ }
321
+ async inspect() {
322
+ const [localMode, transaction] = await Promise.all([
323
+ inspectLocalModeEvidence(this.#stateDirectory),
324
+ this.#inspectTransactionEvidence()
325
+ ]);
326
+ if (localMode.state !== "idle" && transaction.state !== "idle") {
327
+ return manual("multiple-transactions", "Local-mode and transaction-slot recovery evidence coexist; both were preserved and require manual recovery.");
328
+ }
329
+ return transaction.state === "idle" ? localMode : transaction;
330
+ }
331
+ }
332
+ //# sourceMappingURL=node-foundation-transaction-slot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-foundation-transaction-slot.js","sourceRoot":"","sources":["../../../../src/transaction-coordination/adapters/node/node-foundation-transaction-slot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EACL,2BAA2B,EAC3B,qCAAqC,EACrC,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,EACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EACL,WAAW,EACX,UAAU,EACX,MAAM,+CAA+C,CAAC;AAKvD,OAAO,EAAE,8BAA8B,EAAE,MAAM,6DAA6D,CAAC;AAC7G,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAQ1D,OAAO,EAAE,sBAAsB,EAAE,MAA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AM,wBAAwB,CACnC,eAAe,CAAC,MAAM,CAAC,EACvB,IAAI,CAAC,iBAAiB,EACtB,IAAI,CAAC,uBAAuB,CAC7B,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,MAAM,CACX,yBAAyB,EACzB,0FAA0F,CAC3F,CAAC;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACjD,wBAAwB,CAAC,IAAI,CAAC,eAAe,CAAC;YAC9C,IAAI,CAAC,2BAA2B,EAAE;SACnC,CAAC,CAAC;QACH,IAAI,SAAS,CAAC,KAAK,KAAK,MAAM,IAAI,WAAW,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;YAC/D,OAAO,MAAM,CACX,uBAAuB,EACvB,6GAA6G,CAC9G,CAAC;QACJ,CAAC;QACD,OAAO,WAAW,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;IAChE,CAAC;CACF"}
@@ -0,0 +1,22 @@
1
+ import type { FoundationMutationKind, FoundationTransactionStatus } from "./model/transaction-status.js";
2
+ import type { FoundationOperationLock } from "./ports/foundation-operation-lock.js";
3
+ import type { FoundationTransactionSlot } from "./ports/foundation-transaction-slot.js";
4
+ export interface FoundationTransactionLease {
5
+ readonly status: FoundationTransactionStatus;
6
+ release(options?: {
7
+ readonly retainTransactionBarrier?: boolean;
8
+ }): Promise<void>;
9
+ }
10
+ export declare class FoundationTransactionCoordinator {
11
+ #private;
12
+ constructor(options: {
13
+ readonly lock: FoundationOperationLock;
14
+ readonly slot: FoundationTransactionSlot;
15
+ });
16
+ inspect(): Promise<FoundationTransactionStatus>;
17
+ acquire(options: {
18
+ readonly requestedMutation: FoundationMutationKind;
19
+ readonly allowRecoveryOf?: "local-mode" | "scaffolding";
20
+ }): Promise<FoundationTransactionLease>;
21
+ }
22
+ //# sourceMappingURL=foundation-transaction-coordinator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foundation-transaction-coordinator.d.ts","sourceRoot":"","sources":["../../../src/transaction-coordination/application/foundation-transaction-coordinator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EACtB,2BAA2B,EAC5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AAsCxF,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,MAAM,EAAE,2BAA2B,CAAC;IAC7C,OAAO,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,wBAAwB,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnF;AAED,qBAAa,gCAAgC;;IAI3C,YAAY,OAAO,EAAE;QACnB,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAC;QACvC,QAAQ,CAAC,IAAI,EAAE,yBAAyB,CAAC;KAC1C,EAGA;IAEK,OAAO,IAAI,OAAO,CAAC,2BAA2B,CAAC,CAEpD;IAEK,OAAO,CAAC,OAAO,EAAE;QACrB,QAAQ,CAAC,iBAAiB,EAAE,sBAAsB,CAAC;QACnD,QAAQ,CAAC,eAAe,CAAC,EAAE,YAAY,GAAG,aAAa,CAAC;KACzD,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAgDtC;CACF"}
@@ -0,0 +1,78 @@
1
+ import { FoundationTransactionError } from "./foundation-transaction-error.js";
2
+ function preservePrimaryFailure(primaryFailure, releaseFailure) {
3
+ if (!(primaryFailure instanceof Error)) {
4
+ return new AggregateError([primaryFailure, releaseFailure], "Foundation transaction and operation-lock release both failed.");
5
+ }
6
+ const previousCause = primaryFailure.cause;
7
+ const releaseEvidence = previousCause === undefined
8
+ ? releaseFailure
9
+ : new AggregateError([previousCause, releaseFailure], "The primary failure cause and operation-lock release both failed.");
10
+ const attached = Reflect.defineProperty(primaryFailure, "cause", {
11
+ configurable: true,
12
+ value: releaseEvidence,
13
+ writable: true
14
+ });
15
+ return attached
16
+ ? primaryFailure
17
+ : new AggregateError([primaryFailure, releaseFailure], "Foundation transaction and operation-lock release both failed.");
18
+ }
19
+ function observedStatusFormat(status) {
20
+ return Reflect.get(status, "format");
21
+ }
22
+ export class FoundationTransactionCoordinator {
23
+ #lock;
24
+ #slot;
25
+ constructor(options) {
26
+ this.#lock = options.lock;
27
+ this.#slot = options.slot;
28
+ }
29
+ async inspect() {
30
+ return this.#slot.inspect();
31
+ }
32
+ async acquire(options) {
33
+ const release = await this.#lock.acquire();
34
+ let held = true;
35
+ try {
36
+ const status = await this.#slot.inspect();
37
+ const scaffoldingRecoveryAllowed = status.state === "pending" &&
38
+ status.operationKind === "scaffolding" &&
39
+ observedStatusFormat(status) === "legacy-scaffolding-v1" &&
40
+ options.allowRecoveryOf === status.operationKind &&
41
+ options.requestedMutation === status.operationKind &&
42
+ !status.diagnostics.some(({ code }) => code === "FOUNDATION_TRANSACTION_VERSION_MISMATCH");
43
+ const localModeRecoveryAllowed = status.state === "pending" &&
44
+ status.operationKind === "local-mode" &&
45
+ observedStatusFormat(status) === "local-mode-v1" &&
46
+ options.allowRecoveryOf === "local-mode" &&
47
+ options.requestedMutation === "detach";
48
+ if (status.state !== "idle" &&
49
+ !scaffoldingRecoveryAllowed &&
50
+ !localModeRecoveryAllowed) {
51
+ throw new FoundationTransactionError({
52
+ requestedMutation: options.requestedMutation,
53
+ status
54
+ });
55
+ }
56
+ return {
57
+ status,
58
+ async release(releaseOptions) {
59
+ if (held) {
60
+ await release(releaseOptions);
61
+ held = false;
62
+ }
63
+ }
64
+ };
65
+ }
66
+ catch (error) {
67
+ try {
68
+ await release({ retainTransactionBarrier: true });
69
+ held = false;
70
+ }
71
+ catch (releaseError) {
72
+ throw preservePrimaryFailure(error, releaseError);
73
+ }
74
+ throw error;
75
+ }
76
+ }
77
+ }
78
+ //# sourceMappingURL=foundation-transaction-coordinator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foundation-transaction-coordinator.js","sourceRoot":"","sources":["../../../src/transaction-coordination/application/foundation-transaction-coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAQ/E,SAAS,sBAAsB,CAC7B,cAAuB,EACvB,cAAuB;IAEvB,IAAI,CAAC,CAAC,cAAc,YAAY,KAAK,CAAC,EAAE,CAAC;QACvC,OAAO,IAAI,cAAc,CACvB,CAAC,cAAc,EAAE,cAAc,CAAC,EAChC,gEAAgE,CACjE,CAAC;IACJ,CAAC;IAED,MAAM,aAAa,GAAG,cAAc,CAAC,KAAK,CAAC;IAC3C,MAAM,eAAe,GACnB,aAAa,KAAK,SAAS;QACzB,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,IAAI,cAAc,CAChB,CAAC,aAAa,EAAE,cAAc,CAAC,EAC/B,mEAAmE,CACpE,CAAC;IACR,MAAM,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,cAAc,EAAE,OAAO,EAAE;QAC/D,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,eAAe;QACtB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;IACH,OAAO,QAAQ;QACb,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,IAAI,cAAc,CAChB,CAAC,cAAc,EAAE,cAAc,CAAC,EAChC,gEAAgE,CACjE,CAAC;AACR,CAAC;AAED,SAAS,oBAAoB,CAAC,MAAmC;IAC/D,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAY,CAAC;AAClD,CAAC;AAOD,MAAM,OAAO,gCAAgC;IAClC,KAAK,CAA0B;IAC/B,KAAK,CAA4B;IAE1C,YAAY,OAGX;QACC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;QAC1B,IA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,OAAO,CAAC,cAAc;oBAC1B,IAAI,IAAI,EAAE,CAAC;wBACT,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;wBAC9B,IAAI,GAAG,KAAK,CAAC;oBACf,CAAC;gBACH,CAAC;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC;gBACH,MAAM,OAAO,CAAC,EAAE,wBAAwB,EAAE,IAAI,EAAE,CAAC,CAAC;gBAClD,IAAI,GAAG,KAAK,CAAC;YACf,CAAC;YAAC,OAAO,YAAY,EAAE,CAAC;gBACtB,MAAM,sBAAsB,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;YACpD,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ import type { FoundationMutationKind, FoundationTransactionDiagnostic, FoundationTransactionStatus } from "./model/transaction-status.js";
2
+ export declare class FoundationTransactionError extends Error {
3
+ readonly code: "FOUNDATION_TRANSACTION_ACTIVE" | "FOUNDATION_TRANSACTION_MANUAL_RECOVERY_REQUIRED" | "FOUNDATION_TRANSACTION_VERSION_MISMATCH";
4
+ readonly diagnostics: readonly FoundationTransactionDiagnostic[];
5
+ readonly requestedMutation: FoundationMutationKind;
6
+ readonly status: Exclude<FoundationTransactionStatus, {
7
+ readonly state: "idle";
8
+ }>;
9
+ constructor(options: {
10
+ readonly requestedMutation: FoundationMutationKind;
11
+ readonly status: Exclude<FoundationTransactionStatus, {
12
+ readonly state: "idle";
13
+ }>;
14
+ });
15
+ }
16
+ //# sourceMappingURL=foundation-transaction-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foundation-transaction-error.d.ts","sourceRoot":"","sources":["../../../src/transaction-coordination/application/foundation-transaction-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,+BAA+B,EAC/B,2BAA2B,EAC5B,MAAM,+BAA+B,CAAC;AAEvC,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,QAAQ,CAAC,IAAI,EACT,+BAA+B,GAC/B,iDAAiD,GACjD,yCAAyC,CAAC;IAC9C,QAAQ,CAAC,WAAW,EAAE,SAAS,+BAA+B,EAAE,CAAC;IACjE,QAAQ,CAAC,iBAAiB,EAAE,sBAAsB,CAAC;IACnD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,2BAA2B,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAElF,YAAY,OAAO,EAAE;QACnB,QAAQ,CAAC,iBAAiB,EAAE,sBAAsB,CAAC;QACnD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,2BAA2B,EAAE;YAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KACnF,EAWA;CACF"}
@@ -0,0 +1,19 @@
1
+ export class FoundationTransactionError extends Error {
2
+ code;
3
+ diagnostics;
4
+ requestedMutation;
5
+ status;
6
+ constructor(options) {
7
+ const primary = options.status.diagnostics[0] ?? {
8
+ code: "FOUNDATION_TRANSACTION_ACTIVE",
9
+ message: "A Foundation transaction requires recovery before another mutation can start."
10
+ };
11
+ super(primary.message);
12
+ this.name = "FoundationTransactionError";
13
+ this.code = primary.code;
14
+ this.diagnostics = options.status.diagnostics;
15
+ this.requestedMutation = options.requestedMutation;
16
+ this.status = options.status;
17
+ }
18
+ }
19
+ //# sourceMappingURL=foundation-transaction-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foundation-transaction-error.js","sourceRoot":"","sources":["../../../src/transaction-coordination/application/foundation-transaction-error.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAC1C,IAAI,CAGiC;IACrC,WAAW,CAA6C;IACxD,iBAAiB,CAAyB;IAC1C,MAAM,CAAmE;IAElF,YAAY,OAGX;QACC,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI;YAC/C,IAAI,EAAE,+BAAwC;YAC9C,OAAO,EAAE,+EAA+E;SACzF,CAAC;QACF,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC;QAC9C,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;QACnD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC/B,CAAC;CACF"}
@@ -0,0 +1,47 @@
1
+ export type FoundationMutationKind = "attach" | "detach" | "document-authoring" | "scaffolding";
2
+ export type FoundationRecoveryRoute = {
3
+ readonly commandId: "scaffold-recover";
4
+ readonly exactFoundationVersion: string;
5
+ readonly exactFoundationBuildIdentity?: string;
6
+ } | {
7
+ readonly commandId: "detach";
8
+ };
9
+ export type FoundationTransactionDiagnostic = {
10
+ readonly code: "FOUNDATION_TRANSACTION_ACTIVE";
11
+ readonly message: string;
12
+ } | {
13
+ readonly code: "FOUNDATION_TRANSACTION_MANUAL_RECOVERY_REQUIRED";
14
+ readonly message: string;
15
+ } | {
16
+ readonly code: "FOUNDATION_TRANSACTION_VERSION_MISMATCH";
17
+ readonly message: string;
18
+ };
19
+ export type FoundationManualRecoveryReason = "corrupt-or-incompatible" | "invalid-slot" | "local-mode-evidence-invalid" | "multiple-transactions" | "orphan-temporary" | "recovery-handler-unavailable" | "unstable-slot" | "unsupported-schema";
20
+ export type FoundationTransactionStatus = {
21
+ readonly state: "idle";
22
+ readonly diagnostics: readonly [];
23
+ } | {
24
+ readonly state: "pending";
25
+ readonly operationKind: "scaffolding";
26
+ readonly format: "legacy-scaffolding-v1";
27
+ readonly foundationVersion: string;
28
+ readonly recovery: FoundationRecoveryRoute;
29
+ readonly diagnostics: readonly FoundationTransactionDiagnostic[];
30
+ } | {
31
+ readonly state: "pending";
32
+ readonly operationKind: "local-mode";
33
+ readonly format: "local-mode-v1";
34
+ readonly recovery: {
35
+ readonly commandId: "detach";
36
+ };
37
+ readonly diagnostics: readonly FoundationTransactionDiagnostic[];
38
+ } | {
39
+ readonly state: "manual-recovery-required";
40
+ readonly reason: FoundationManualRecoveryReason;
41
+ readonly operationKind?: "document-authoring" | "scaffolding";
42
+ readonly format?: "envelope-v2";
43
+ readonly foundationVersion?: string;
44
+ readonly foundationBuildIdentity?: string;
45
+ readonly diagnostics: readonly FoundationTransactionDiagnostic[];
46
+ };
47
+ //# sourceMappingURL=transaction-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-status.d.ts","sourceRoot":"","sources":["../../../../src/transaction-coordination/application/model/transaction-status.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAC9B,QAAQ,GACR,QAAQ,GACR,oBAAoB,GACpB,aAAa,CAAC;AAElB,MAAM,MAAM,uBAAuB,GAC/B;IACE,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;IACvC,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;IACxC,QAAQ,CAAC,4BAA4B,CAAC,EAAE,MAAM,CAAC;CAChD,GACD;IACE,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC;CAC9B,CAAC;AAEN,MAAM,MAAM,+BAA+B,GACvC;IACE,QAAQ,CAAC,IAAI,EAAE,+BAA+B,CAAC;IAC/C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,iDAAiD,CAAC;IACjE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,yCAAyC,CAAC;IACzD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEN,MAAM,MAAM,8BAA8B,GACtC,yBAAyB,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2
+ //# sourceMappingURL=transaction-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-status.js","sourceRoot":"","sources":["../../../../src/transaction-coordination/application/model/transaction-status.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export interface FoundationOperationReleaseOptions {
2
+ readonly retainTransactionBarrier?: boolean;
3
+ }
4
+ export interface FoundationOperationLock {
5
+ acquire(): Promise<(options?: FoundationOperationReleaseOptions) => Promise<void>>;
6
+ }
7
+ //# sourceMappingURL=foundation-operation-lock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foundation-operation-lock.d.ts","sourceRoot":"","sources":["../../../../src/transaction-coordination/application/ports/foundation-operation-lock.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iCAAiC;IAChD,QAAQ,CAAC,wBAAwB,CAAC,EAAE,OAAO,CAAC;CAC7C;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,IAAI,OAAO,CAChB,CAAC,OAAO,CAAC,EAAE,iCAAiC,KAAK,OAAO,CAAC,IAAI,CAAC,CAC/D,CAAC;CACH"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=foundation-operation-lock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foundation-operation-lock.js","sourceRoot":"","sources":["../../../../src/transaction-coordination/application/ports/foundation-operation-lock.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { FoundationTransactionStatus } from "../model/transaction-status.js";
2
+ export interface FoundationTransactionSlot {
3
+ inspect(): Promise<FoundationTransactionStatus>;
4
+ }
5
+ //# sourceMappingURL=foundation-transaction-slot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foundation-transaction-slot.d.ts","sourceRoot":"","sources":["../../../../src/transaction-coordination/application/ports/foundation-transaction-slot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAElF,MAAM,WAAW,yBAAyB;IACxC,OAAO,IAAI,OAAO,CAAC,2BAA2B,CAAC,CAAC;CACjD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=foundation-transaction-slot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foundation-transaction-slot.js","sourceRoot":"","sources":["../../../../src/transaction-coordination/application/ports/foundation-transaction-slot.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-teams/engineering-foundation",
3
- "version": "0.12.0",
3
+ "version": "0.13.1",
4
4
  "description": "Versioned engineering policy, tooling, and conformance for Agent Teams repositories.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",