@agent-teams/repository-mutation 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/LICENSE +201 -0
- package/README.md +10 -0
- package/dist/canonical-json.d.ts +12 -0
- package/dist/canonical-json.d.ts.map +1 -0
- package/dist/canonical-json.js +137 -0
- package/dist/canonical-json.js.map +1 -0
- package/dist/errors.d.ts +6 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +9 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/installed-artifact-identity.d.ts +15 -0
- package/dist/installed-artifact-identity.d.ts.map +1 -0
- package/dist/installed-artifact-identity.js +127 -0
- package/dist/installed-artifact-identity.js.map +1 -0
- package/dist/node.d.ts +29 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +19 -0
- package/dist/node.js.map +1 -0
- package/dist/package-version.d.ts +3 -0
- package/dist/package-version.d.ts.map +1 -0
- package/dist/package-version.js +11 -0
- package/dist/package-version.js.map +1 -0
- package/dist/qualification/index.d.ts +24 -0
- package/dist/qualification/index.d.ts.map +1 -0
- package/dist/qualification/index.js +11 -0
- package/dist/qualification/index.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-absent-file-publication-private.d.ts +19 -0
- package/dist/repository-mutation/adapters/node/node-absent-file-publication-private.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-absent-file-publication-private.js +74 -0
- package/dist/repository-mutation/adapters/node/node-absent-file-publication-private.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-absent-file-publication.d.ts +35 -0
- package/dist/repository-mutation/adapters/node/node-absent-file-publication.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-absent-file-publication.js +181 -0
- package/dist/repository-mutation/adapters/node/node-absent-file-publication.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-bounded-regular-file.d.ts +23 -0
- package/dist/repository-mutation/adapters/node/node-bounded-regular-file.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-bounded-regular-file.js +134 -0
- package/dist/repository-mutation/adapters/node/node-bounded-regular-file.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-cleanup-owned-temporary.d.ts +26 -0
- package/dist/repository-mutation/adapters/node/node-cleanup-owned-temporary.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-cleanup-owned-temporary.js +172 -0
- package/dist/repository-mutation/adapters/node/node-cleanup-owned-temporary.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-create-and-bind-directory.d.ts +14 -0
- package/dist/repository-mutation/adapters/node/node-create-and-bind-directory.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-create-and-bind-directory.js +23 -0
- package/dist/repository-mutation/adapters/node/node-create-and-bind-directory.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-directory-durability.d.ts +17 -0
- package/dist/repository-mutation/adapters/node/node-directory-durability.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-directory-durability.js +47 -0
- package/dist/repository-mutation/adapters/node/node-directory-durability.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-directory-materialization.d.ts +37 -0
- package/dist/repository-mutation/adapters/node/node-directory-materialization.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-directory-materialization.js +244 -0
- package/dist/repository-mutation/adapters/node/node-directory-materialization.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-existing-repository-ancestors.d.ts +13 -0
- package/dist/repository-mutation/adapters/node/node-existing-repository-ancestors.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-existing-repository-ancestors.js +67 -0
- package/dist/repository-mutation/adapters/node/node-existing-repository-ancestors.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-effects.d.ts +84 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-effects.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-effects.js +232 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-effects.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-faults.d.ts +9 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-faults.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-faults.js +2 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-faults.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-observation.d.ts +6 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-observation.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-observation.js +30 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-observation.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-operation.d.ts +11 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-operation.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-operation.js +159 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-operation.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-state.d.ts +9 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-state.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-state.js +22 -0
- package/dist/repository-mutation/adapters/node/node-known-file-apply-state.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-cleanup.d.ts +9 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-cleanup.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-cleanup.js +203 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-cleanup.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-executor.d.ts +17 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-executor.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-executor.js +22 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-executor.js.map +1 -0
- 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 +213 -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-recovery-observation.d.ts +15 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-observation.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-observation.js +51 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-observation.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-preimage-captured-cleanup.d.ts +29 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-preimage-captured-cleanup.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-preimage-captured-cleanup.js +72 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-preimage-captured-cleanup.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-preimage-captured.d.ts +31 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-preimage-captured.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-preimage-captured.js +254 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-preimage-captured.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-preimage.d.ts +13 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-preimage.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-preimage.js +210 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-preimage.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-retirement.d.ts +15 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-retirement.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-retirement.js +181 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-retirement.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-state.d.ts +12 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-state.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-state.js +18 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-state.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 +150 -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 +56 -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 +22 -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 +246 -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-lease-release.d.ts +21 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-lease-release.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-lease-release.js +34 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-lease-release.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 +14 -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 +109 -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 +21 -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 +215 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-prepare-exact-sibling-temporary.d.ts +18 -0
- package/dist/repository-mutation/adapters/node/node-prepare-exact-sibling-temporary.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-prepare-exact-sibling-temporary.js +30 -0
- package/dist/repository-mutation/adapters/node/node-prepare-exact-sibling-temporary.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-publish-prepared-absent-file.d.ts +31 -0
- package/dist/repository-mutation/adapters/node/node-publish-prepared-absent-file.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-publish-prepared-absent-file.js +50 -0
- package/dist/repository-mutation/adapters/node/node-publish-prepared-absent-file.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-repository-path.d.ts +2 -0
- package/dist/repository-mutation/adapters/node/node-repository-path.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-repository-path.js +7 -0
- package/dist/repository-mutation/adapters/node/node-repository-path.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-terminal-evidence-directory.d.ts +21 -0
- package/dist/repository-mutation/adapters/node/node-terminal-evidence-directory.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-terminal-evidence-directory.js +59 -0
- package/dist/repository-mutation/adapters/node/node-terminal-evidence-directory.js.map +1 -0
- package/dist/repository-mutation/application/model/directory-materialization.d.ts +35 -0
- package/dist/repository-mutation/application/model/directory-materialization.d.ts.map +1 -0
- package/dist/repository-mutation/application/model/directory-materialization.js +11 -0
- package/dist/repository-mutation/application/model/directory-materialization.js.map +1 -0
- package/dist/repository-mutation/application/model/exact-postimage.d.ts +17 -0
- package/dist/repository-mutation/application/model/exact-postimage.d.ts.map +1 -0
- package/dist/repository-mutation/application/model/exact-postimage.js +11 -0
- package/dist/repository-mutation/application/model/exact-postimage.js.map +1 -0
- package/dist/repository-mutation/application/model/known-file-transaction-journal.d.ts +69 -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/model/path-identity.d.ts +7 -0
- package/dist/repository-mutation/application/model/path-identity.d.ts.map +1 -0
- package/dist/repository-mutation/application/model/path-identity.js +2 -0
- package/dist/repository-mutation/application/model/path-identity.js.map +1 -0
- package/dist/repository-mutation/application/model/repository-path.d.ts +8 -0
- package/dist/repository-mutation/application/model/repository-path.d.ts.map +1 -0
- package/dist/repository-mutation/application/model/repository-path.js +74 -0
- package/dist/repository-mutation/application/model/repository-path.js.map +1 -0
- package/dist/repository-mutation/application/policies/classify-known-file-recovery-transition.d.ts +33 -0
- package/dist/repository-mutation/application/policies/classify-known-file-recovery-transition.d.ts.map +1 -0
- package/dist/repository-mutation/application/policies/classify-known-file-recovery-transition.js +21 -0
- package/dist/repository-mutation/application/policies/classify-known-file-recovery-transition.js.map +1 -0
- package/dist/repository-mutation/application/policies/known-file-transaction-envelope.d.ts +9 -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 +214 -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 +253 -0
- package/dist/repository-mutation/application/policies/known-file-transaction-plan.js.map +1 -0
- package/dist/repository-mutation/application/ports/owned-temporary-cleanup-transition.d.ts +7 -0
- package/dist/repository-mutation/application/ports/owned-temporary-cleanup-transition.d.ts.map +1 -0
- package/dist/repository-mutation/application/ports/owned-temporary-cleanup-transition.js +2 -0
- package/dist/repository-mutation/application/ports/owned-temporary-cleanup-transition.js.map +1 -0
- package/dist/repository-mutation-envelope.d.ts +32 -0
- package/dist/repository-mutation-envelope.d.ts.map +1 -0
- package/dist/repository-mutation-envelope.js +292 -0
- package/dist/repository-mutation-envelope.js.map +1 -0
- package/dist/state-contract.d.ts +6 -0
- package/dist/state-contract.d.ts.map +1 -0
- package/dist/state-contract.js +6 -0
- package/dist/state-contract.js.map +1 -0
- package/dist/strict-json.d.ts +7 -0
- package/dist/strict-json.d.ts.map +1 -0
- package/dist/strict-json.js +131 -0
- package/dist/strict-json.js.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-journal-slot-evidence.d.ts +29 -0
- package/dist/transaction-coordination/adapters/node/node-journal-slot-evidence.d.ts.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-journal-slot-evidence.js +139 -0
- package/dist/transaction-coordination/adapters/node/node-journal-slot-evidence.js.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-journal-slot-profile.d.ts +151 -0
- package/dist/transaction-coordination/adapters/node/node-journal-slot-profile.d.ts.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-journal-slot-profile.js +29 -0
- package/dist/transaction-coordination/adapters/node/node-journal-slot-profile.js.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-journal-slot-store.d.ts +25 -0
- package/dist/transaction-coordination/adapters/node/node-journal-slot-store.d.ts.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-journal-slot-store.js +303 -0
- package/dist/transaction-coordination/adapters/node/node-journal-slot-store.js.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-operation-lock.d.ts +16 -0
- package/dist/transaction-coordination/adapters/node/node-operation-lock.d.ts.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-operation-lock.js +359 -0
- package/dist/transaction-coordination/adapters/node/node-operation-lock.js.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-state-directory.d.ts +11 -0
- package/dist/transaction-coordination/adapters/node/node-state-directory.d.ts.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-state-directory.js +91 -0
- package/dist/transaction-coordination/adapters/node/node-state-directory.js.map +1 -0
- package/dist/transaction-coordination/mutation-lease.d.ts +38 -0
- package/dist/transaction-coordination/mutation-lease.d.ts.map +1 -0
- package/dist/transaction-coordination/mutation-lease.js +351 -0
- package/dist/transaction-coordination/mutation-lease.js.map +1 -0
- package/package.json +52 -0
- package/schemas/known-file-transaction-plan/v1.schema.json +65 -0
- package/schemas/known-file-transaction-receipt/v1.schema.json +36 -0
- package/schemas/repository-mutation-transaction-envelope/v1.schema.json +46 -0
|
@@ -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: "agent-teams.repository-mutation.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.repository-mutation.known-file-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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AAC;YACxB,MAAM,EAAE,uDAAuD;YAC/D,IAAI;SACL,CAAC;KACH,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type MutationClaim } from "../../../transaction-coordination/mutation-lease.js";
|
|
2
|
+
import type { KnownFileTransactionReceiptV1 } from "../../application/model/known-file-transaction.js";
|
|
3
|
+
import { type KnownFileRecoveryFaultInjector } from "./node-known-file-recovery-executor.js";
|
|
4
|
+
export type { KnownFileRecoveryFaultInjector } from "./node-known-file-recovery-executor.js";
|
|
5
|
+
export declare function recoverKnownFileTransactionWithFaults(options: {
|
|
6
|
+
readonly consumerRoot: string;
|
|
7
|
+
readonly claim?: MutationClaim;
|
|
8
|
+
readonly faultInjector?: KnownFileRecoveryFaultInjector;
|
|
9
|
+
}): Promise<KnownFileTransactionReceiptV1>;
|
|
10
|
+
export declare function recoverKnownFileTransaction(options: {
|
|
11
|
+
readonly consumerRoot: string;
|
|
12
|
+
readonly claim?: MutationClaim;
|
|
13
|
+
}): Promise<KnownFileTransactionReceiptV1>;
|
|
14
|
+
//# 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":"AAGA,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,qDAAqD,CAAC;AAC7D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mDAAmD,CAAC;AAEvG,OAAO,EAGL,KAAK,8BAA8B,EACpC,MAAM,wCAAwC,CAAC;AAUhD,YAAY,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AAE7F,wBAAsB,qCAAqC,CAAC,OAAO,EAAE;IACnE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,aAAa,CAAC,EAAE,8BAA8B,CAAC;CACzD,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAkEzC;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE;IACnD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;CAChC,GAAG,OAAO,CAAC,6BAA6B,CAAC,CA4BzC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { installedRepositoryMutationBuildIdentity } from "../../../installed-artifact-identity.js";
|
|
2
|
+
import { installedRepositoryMutationVersion, REPOSITORY_MUTATION_PACKAGE_NAME } from "../../../package-version.js";
|
|
3
|
+
import { pruneMutationStateDirectory } from "../../../transaction-coordination/adapters/node/node-state-directory.js";
|
|
4
|
+
import { acquireMutationLease, claimMutation, consumeMutationClaim, mutationClaimIntent, observeMutationState, retainMutationBarrierOnEvidence, retainMutationClaimBarrierOnEvidence } from "../../../transaction-coordination/mutation-lease.js";
|
|
5
|
+
import { classifyKnownFileRecoveryTransition } from "../../application/policies/classify-known-file-recovery-transition.js";
|
|
6
|
+
import { executeApplyingKnownFileRollback, executeCommittedKnownFileRecovery } from "./node-known-file-recovery-executor.js";
|
|
7
|
+
import { observeKnownFileRecoveryEvidence } from "./node-known-file-recovery-observation.js";
|
|
8
|
+
import { canonicalKnownFileRoot, KnownFileTransactionError } from "./node-known-file-transaction-filesystem.js";
|
|
9
|
+
import { releaseKnownFileTransactionLease } from "./node-known-file-transaction-lease-release.js";
|
|
10
|
+
export async function recoverKnownFileTransactionWithFaults(options) {
|
|
11
|
+
if (process.platform === "win32") {
|
|
12
|
+
throw new KnownFileTransactionError("KNOWN_FILE_APPLY_UNSUPPORTED", "Known-file recovery requires strict directory durability and is not qualified on Windows.");
|
|
13
|
+
}
|
|
14
|
+
const root = await canonicalKnownFileRoot(options.consumerRoot);
|
|
15
|
+
let ownedLease;
|
|
16
|
+
let claim = options.claim;
|
|
17
|
+
ownedLease = claim === undefined ? await acquireMutationLease(root) : undefined;
|
|
18
|
+
let retainBarrier = true;
|
|
19
|
+
let primaryFailure;
|
|
20
|
+
try {
|
|
21
|
+
const [version, buildIdentity] = await Promise.all([
|
|
22
|
+
installedRepositoryMutationVersion(), installedRepositoryMutationBuildIdentity()
|
|
23
|
+
]);
|
|
24
|
+
const artifact = { name: REPOSITORY_MUTATION_PACKAGE_NAME, version, buildIdentity };
|
|
25
|
+
if (claim === undefined) {
|
|
26
|
+
const lease = ownedLease;
|
|
27
|
+
claim = await claimMutation(lease, await observeMutationState(lease), {
|
|
28
|
+
kind: "recover-known-file", ownerArtifact: artifact, kernelArtifact: artifact
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const claimedIntent = mutationClaimIntent(claim);
|
|
32
|
+
const exactArtifact = (candidate) => candidate.name === artifact.name && candidate.version === artifact.version &&
|
|
33
|
+
candidate.buildIdentity === artifact.buildIdentity;
|
|
34
|
+
if (claimedIntent.kind !== "recover-known-file" || !exactArtifact(claimedIntent.ownerArtifact) ||
|
|
35
|
+
!exactArtifact(claimedIntent.kernelArtifact) ||
|
|
36
|
+
await consumeMutationClaim(claim, "recover-known-file") !== root) {
|
|
37
|
+
throw new KnownFileTransactionError("KNOWN_FILE_RECOVERY_CONFLICT", "Mutation claim has the wrong root, owner, or kernel identity.");
|
|
38
|
+
}
|
|
39
|
+
const evidence = await observeKnownFileRecoveryEvidence(root);
|
|
40
|
+
const transition = classifyKnownFileRecoveryTransition({
|
|
41
|
+
envelope: evidence.stored.envelope,
|
|
42
|
+
installedBuild: evidence.installedBuild
|
|
43
|
+
});
|
|
44
|
+
if (transition.action === "reject") {
|
|
45
|
+
throw new KnownFileTransactionError(transition.code, transition.message);
|
|
46
|
+
}
|
|
47
|
+
const execution = {
|
|
48
|
+
...(options.faultInjector === undefined ? {} : { faultInjector: options.faultInjector }),
|
|
49
|
+
root,
|
|
50
|
+
store: evidence.store,
|
|
51
|
+
stored: evidence.stored
|
|
52
|
+
};
|
|
53
|
+
const result = transition.action === "resume-committed-cleanup"
|
|
54
|
+
? await executeCommittedKnownFileRecovery(execution)
|
|
55
|
+
: await executeApplyingKnownFileRollback(execution);
|
|
56
|
+
retainBarrier = false;
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
if (claim !== undefined) {
|
|
61
|
+
await retainMutationClaimBarrierOnEvidence(claim);
|
|
62
|
+
}
|
|
63
|
+
if (ownedLease !== undefined) {
|
|
64
|
+
await retainMutationBarrierOnEvidence(ownedLease);
|
|
65
|
+
}
|
|
66
|
+
primaryFailure = { reason: error };
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
if (ownedLease !== undefined) {
|
|
71
|
+
await releaseKnownFileTransactionLease({
|
|
72
|
+
jointFailureMessage: "Known-file recovery and transaction lease release both failed.",
|
|
73
|
+
lease: ownedLease,
|
|
74
|
+
...(primaryFailure === undefined ? {} : { primaryFailure }),
|
|
75
|
+
retainTransactionBarrier: retainBarrier
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (!retainBarrier) {
|
|
79
|
+
await pruneMutationStateDirectory(root);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export function recoverKnownFileTransaction(options) {
|
|
84
|
+
const keys = typeof options === "object" && options !== null
|
|
85
|
+
? Reflect.ownKeys(options)
|
|
86
|
+
: [];
|
|
87
|
+
const expectedKeys = keys.includes("claim")
|
|
88
|
+
? ["claim", "consumerRoot"]
|
|
89
|
+
: ["consumerRoot"];
|
|
90
|
+
if (typeof options !== "object" || options === null || Array.isArray(options) ||
|
|
91
|
+
![Object.prototype, null].includes(Object.getPrototypeOf(options)) ||
|
|
92
|
+
keys.some((key) => typeof key !== "string") ||
|
|
93
|
+
keys.toSorted().join("\0") !== expectedKeys.toSorted().join("\0") ||
|
|
94
|
+
keys.some((key) => {
|
|
95
|
+
const descriptor = Object.getOwnPropertyDescriptor(options, key);
|
|
96
|
+
return descriptor === undefined || !("value" in descriptor) || !descriptor.enumerable;
|
|
97
|
+
})) {
|
|
98
|
+
return Promise.reject(new KnownFileTransactionError("KNOWN_FILE_RECOVERY_CONFLICT", "Known-file recovery options contain unknown, missing, or executable properties."));
|
|
99
|
+
}
|
|
100
|
+
const values = Object.fromEntries(keys.map((key) => [
|
|
101
|
+
key,
|
|
102
|
+
Object.getOwnPropertyDescriptor(options, key).value
|
|
103
|
+
]));
|
|
104
|
+
const input = Object.hasOwn(values, "claim")
|
|
105
|
+
? { consumerRoot: values["consumerRoot"], claim: values["claim"] }
|
|
106
|
+
: { consumerRoot: values["consumerRoot"] };
|
|
107
|
+
return recoverKnownFileTransactionWithFaults(input);
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=node-known-file-transaction-recovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-known-file-transaction-recovery.js","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-known-file-transaction-recovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wCAAwC,EAAE,MAAM,yCAAyC,CAAC;AACnG,OAAO,EAAE,kCAAkC,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AACnH,OAAO,EAAE,2BAA2B,EAAE,MAAM,yEAAyE,CAAC;AACtH,OAAO,EACL,oBAAoB,EAAE,aAAa,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,oBAAoB,EACpG,+BAA+B,EAAE,oCAAoC,EAEtE,MAAM,qDAAqD,CAAC;AAE7D,OAAO,EAAE,mCAAmC,EAAE,MAAM,uEAAuE,CAAC;AAC5H,OAAO,EACL,gCAAgC,EAChC,iCAAiC,EAElC,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,gCAAgC,EACjC,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,6CAA6C,CAAC;AACr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+1,21 @@
|
|
|
1
|
+
import { type MutationClaim } from "../../../transaction-coordination/mutation-lease.js";
|
|
2
|
+
import type { KnownFileTransactionPlanV1, KnownFileTransactionReceiptV1 } from "../../application/model/known-file-transaction.js";
|
|
3
|
+
import type { KnownFileTransactionJournalV1 } from "../../application/model/known-file-transaction-journal.js";
|
|
4
|
+
import type { KnownFileTransactionFaultInjector, KnownFileTransactionFaultPoint } from "./node-known-file-apply-faults.js";
|
|
5
|
+
export { KnownFileTransactionError } from "./node-known-file-transaction-filesystem.js";
|
|
6
|
+
export type { KnownFileTransactionFaultInjector, KnownFileTransactionFaultPoint };
|
|
7
|
+
export declare function compileKnownFileTransactionReceipt(journal: KnownFileTransactionJournalV1, outcome: "already-satisfied" | "applied"): KnownFileTransactionReceiptV1;
|
|
8
|
+
export { verifyCommittedKnownFilePostimages } from "./node-known-file-apply-observation.js";
|
|
9
|
+
export declare function applyKnownFileTransactionWithFaults(options: {
|
|
10
|
+
readonly consumerRoot: string;
|
|
11
|
+
readonly plan: KnownFileTransactionPlanV1;
|
|
12
|
+
readonly claim?: MutationClaim;
|
|
13
|
+
readonly faultInjector?: KnownFileTransactionFaultInjector;
|
|
14
|
+
}): Promise<KnownFileTransactionReceiptV1>;
|
|
15
|
+
export declare function applyKnownFileTransaction(options: {
|
|
16
|
+
readonly consumerRoot: string;
|
|
17
|
+
readonly plan: KnownFileTransactionPlanV1;
|
|
18
|
+
readonly claim?: MutationClaim;
|
|
19
|
+
}): Promise<KnownFileTransactionReceiptV1>;
|
|
20
|
+
export declare function canonicalKnownFileTransactionReceipt(value: KnownFileTransactionReceiptV1): string;
|
|
21
|
+
//# sourceMappingURL=node-known-file-transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-known-file-transaction.d.ts","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-known-file-transaction.ts"],"names":[],"mappings":"AAIA,OAAO,EAG0B,KAAK,aAAa,EAClD,MAAM,qDAAqD,CAAC;AAC7D,OAAO,KAAK,EAEV,0BAA0B,EAC1B,6BAA6B,EAC9B,MAAM,mDAAmD,CAAC;AAC3D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,2DAA2D,CAAC;AAI/G,OAAO,KAAK,EACV,iCAAiC,EACjC,8BAA8B,EAC/B,MAAM,mCAAmC,CAAC;AAkB3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,YAAY,EAAE,iCAAiC,EAAE,8BAA8B,EAAE,CAAC;AAElF,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,6BAA6B,EACtC,OAAO,EAAE,mBAAmB,GAAG,SAAS,GACvC,6BAA6B,CA2B/B;AAED,OAAO,EAAE,kCAAkC,EAAE,MAAM,wCAAwC,CAAC;AA+G5F,wBAAsB,mCAAmC,CAAC,OAAO,EAAE;IACjE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,0BAA0B,CAAC;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,aAAa,CAAC,EAAE,iCAAiC,CAAC;CAC5D,GAAG,OAAO,CAAC,6BAA6B,CAAC,CA6EzC;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE;IACjD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,0BAA0B,CAAC;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;CAChC,GAAG,OAAO,CAAC,6BAA6B,CAAC,CA4BzC;AAED,wBAAgB,oCAAoC,CAClD,KAAK,EAAE,6BAA6B,GACnC,MAAM,CAER"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { canonicalJson, sha256Json } from "../../../canonical-json.js";
|
|
2
|
+
import { installedRepositoryMutationBuildIdentity } from "../../../installed-artifact-identity.js";
|
|
3
|
+
import { installedRepositoryMutationVersion, REPOSITORY_MUTATION_PACKAGE_NAME } from "../../../package-version.js";
|
|
4
|
+
import { ensureMutationStateDirectory } from "../../../transaction-coordination/adapters/node/node-state-directory.js";
|
|
5
|
+
import { acquireMutationLease, claimMutation, consumeMutationClaim, mutationClaimIntent, observeMutationState, retainMutationBarrierOnEvidence, retainMutationClaimBarrierOnEvidence } from "../../../transaction-coordination/mutation-lease.js";
|
|
6
|
+
import { compileKnownFileTransactionEnvelope } from "../../application/policies/known-file-transaction-envelope.js";
|
|
7
|
+
import { assertKnownFileTransactionPlan } from "../../application/policies/known-file-transaction-plan.js";
|
|
8
|
+
import { cleanupCommittedKnownFileCaptures } from "./node-known-file-recovery-filesystem.js";
|
|
9
|
+
import { observeInitialKnownFileJournal, verifyApplyingKnownFilePostimages, verifyCommittedKnownFilePostimages } from "./node-known-file-apply-observation.js";
|
|
10
|
+
import { executeKnownFileOperation } from "./node-known-file-apply-operation.js";
|
|
11
|
+
import { persistKnownFileApplyState } from "./node-known-file-apply-state.js";
|
|
12
|
+
import { canonicalKnownFileRoot, KnownFileTransactionError } from "./node-known-file-transaction-filesystem.js";
|
|
13
|
+
import { NodeKnownFileTransactionJournalStore } from "./node-known-file-transaction-journal-store.js";
|
|
14
|
+
import { releaseKnownFileTransactionLease } from "./node-known-file-transaction-lease-release.js";
|
|
15
|
+
export { KnownFileTransactionError } from "./node-known-file-transaction-filesystem.js";
|
|
16
|
+
export function compileKnownFileTransactionReceipt(journal, outcome) {
|
|
17
|
+
const operations = journal.operations.map((entry, index) => {
|
|
18
|
+
const planOperation = journal.plan.operations[index];
|
|
19
|
+
const operationOutcome = entry.state === "already-satisfied"
|
|
20
|
+
? "already-satisfied"
|
|
21
|
+
: planOperation.precondition.state === "absent" ? "created" : "replaced";
|
|
22
|
+
return Object.freeze({
|
|
23
|
+
path: entry.path,
|
|
24
|
+
outcome: operationOutcome,
|
|
25
|
+
resultDigest: planOperation.postimage.digest
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
const body = {
|
|
29
|
+
schemaVersion: 1,
|
|
30
|
+
protocol: "agent-teams.repository-mutation.known-file/v1",
|
|
31
|
+
planDigest: journal.plan.planDigest,
|
|
32
|
+
outcome,
|
|
33
|
+
operations: Object.freeze(operations)
|
|
34
|
+
};
|
|
35
|
+
return Object.freeze({
|
|
36
|
+
...body,
|
|
37
|
+
receiptDigest: sha256Json({
|
|
38
|
+
domain: "agent-teams.repository-mutation.known-file-receipt/v1",
|
|
39
|
+
body
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export { verifyCommittedKnownFilePostimages } from "./node-known-file-apply-observation.js";
|
|
44
|
+
async function executeKnownFileApply(options) {
|
|
45
|
+
for (let index = 0; index < options.stored.envelope.payload.plan.operations.length; index += 1) {
|
|
46
|
+
await executeKnownFileOperation({ ...options, index });
|
|
47
|
+
}
|
|
48
|
+
await verifyApplyingKnownFilePostimages(options.root, options.stored.envelope.payload);
|
|
49
|
+
await persistKnownFileApplyState(options.store, options.stored, options.stored.envelope.payload, "COMMITTED");
|
|
50
|
+
await options.faultInjector?.({ phase: "after-journal-committed" });
|
|
51
|
+
await verifyCommittedKnownFilePostimages(options.root, options.stored.envelope.payload);
|
|
52
|
+
await cleanupCommittedKnownFileCaptures(options.root, options.stored.envelope.payload, options.faultInjector);
|
|
53
|
+
await verifyCommittedKnownFilePostimages(options.root, options.stored.envelope.payload);
|
|
54
|
+
return compileKnownFileTransactionReceipt(options.stored.envelope.payload, "applied");
|
|
55
|
+
}
|
|
56
|
+
async function refreshBarrierRetention(store) {
|
|
57
|
+
if (store === undefined) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
return await store.read() !== undefined;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function installedMutationArtifact() {
|
|
68
|
+
const [version, buildIdentity] = await Promise.all([
|
|
69
|
+
installedRepositoryMutationVersion(),
|
|
70
|
+
installedRepositoryMutationBuildIdentity()
|
|
71
|
+
]);
|
|
72
|
+
return { name: REPOSITORY_MUTATION_PACKAGE_NAME, version, buildIdentity };
|
|
73
|
+
}
|
|
74
|
+
async function ensureApplyClaim(options) {
|
|
75
|
+
if (options.claim !== undefined) {
|
|
76
|
+
return options.claim;
|
|
77
|
+
}
|
|
78
|
+
if (options.lease === undefined) {
|
|
79
|
+
throw new KnownFileTransactionError("KNOWN_FILE_PLAN_INVALID", "Known-file apply did not acquire its mutation lease.");
|
|
80
|
+
}
|
|
81
|
+
return claimMutation(options.lease, await observeMutationState(options.lease), {
|
|
82
|
+
kind: "apply-known-file",
|
|
83
|
+
planDigest: options.planDigest,
|
|
84
|
+
ownerArtifact: options.artifact,
|
|
85
|
+
kernelArtifact: options.artifact
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function sameArtifact(candidate, expected) {
|
|
89
|
+
return candidate.name === expected.name &&
|
|
90
|
+
candidate.version === expected.version &&
|
|
91
|
+
candidate.buildIdentity === expected.buildIdentity;
|
|
92
|
+
}
|
|
93
|
+
async function assertApplyClaim(options) {
|
|
94
|
+
const intent = mutationClaimIntent(options.claim);
|
|
95
|
+
if (intent.kind !== "apply-known-file" ||
|
|
96
|
+
intent.planDigest !== options.planDigest ||
|
|
97
|
+
!sameArtifact(intent.ownerArtifact, options.artifact) ||
|
|
98
|
+
!sameArtifact(intent.kernelArtifact, options.artifact) ||
|
|
99
|
+
await consumeMutationClaim(options.claim, "apply-known-file") !== options.root) {
|
|
100
|
+
throw new KnownFileTransactionError("KNOWN_FILE_PLAN_INVALID", "Mutation claim belongs to another repository root, plan, owner, or kernel identity.");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function translateApplyAdmissionFailure(error) {
|
|
104
|
+
if (error instanceof Error && /Common transaction evidence/u.test(error.message)) {
|
|
105
|
+
throw new KnownFileTransactionError("KNOWN_FILE_RECOVERY_REQUIRED", "Common transaction evidence must be recovered before known-file apply.");
|
|
106
|
+
}
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
export async function applyKnownFileTransactionWithFaults(options) {
|
|
110
|
+
assertKnownFileTransactionPlan(options.plan);
|
|
111
|
+
if (process.platform === "win32") {
|
|
112
|
+
throw new KnownFileTransactionError("KNOWN_FILE_APPLY_UNSUPPORTED", "Known-file apply requires strict directory durability and is not qualified on Windows.");
|
|
113
|
+
}
|
|
114
|
+
const root = await canonicalKnownFileRoot(options.consumerRoot);
|
|
115
|
+
let ownedLease;
|
|
116
|
+
let claim = options.claim;
|
|
117
|
+
ownedLease = claim === undefined ? await acquireMutationLease(root) : undefined;
|
|
118
|
+
let retainBarrier = false;
|
|
119
|
+
let store;
|
|
120
|
+
let primaryFailure;
|
|
121
|
+
try {
|
|
122
|
+
const mutationArtifact = await installedMutationArtifact();
|
|
123
|
+
claim = await ensureApplyClaim({
|
|
124
|
+
artifact: mutationArtifact,
|
|
125
|
+
claim,
|
|
126
|
+
lease: ownedLease,
|
|
127
|
+
planDigest: options.plan.planDigest
|
|
128
|
+
});
|
|
129
|
+
await assertApplyClaim({
|
|
130
|
+
artifact: mutationArtifact,
|
|
131
|
+
claim,
|
|
132
|
+
planDigest: options.plan.planDigest,
|
|
133
|
+
root
|
|
134
|
+
});
|
|
135
|
+
await options.faultInjector?.({ phase: "after-barrier-acquired" });
|
|
136
|
+
const journal = await observeInitialKnownFileJournal(root, options.plan);
|
|
137
|
+
if (journal.operations.every(({ state }) => state === "already-satisfied")) {
|
|
138
|
+
return compileKnownFileTransactionReceipt(journal, "already-satisfied");
|
|
139
|
+
}
|
|
140
|
+
const envelope = compileKnownFileTransactionEnvelope({
|
|
141
|
+
ownerArtifact: mutationArtifact,
|
|
142
|
+
kernelArtifact: mutationArtifact,
|
|
143
|
+
journal,
|
|
144
|
+
state: "APPLYING"
|
|
145
|
+
});
|
|
146
|
+
store = new NodeKnownFileTransactionJournalStore(await ensureMutationStateDirectory(root), mutationArtifact, mutationArtifact);
|
|
147
|
+
const stored = {
|
|
148
|
+
authority: await store.create(envelope),
|
|
149
|
+
envelope
|
|
150
|
+
};
|
|
151
|
+
retainBarrier = true;
|
|
152
|
+
await options.faultInjector?.({ phase: "after-journal-created" });
|
|
153
|
+
const result = await executeKnownFileApply({
|
|
154
|
+
...(options.faultInjector === undefined ? {} : { faultInjector: options.faultInjector }),
|
|
155
|
+
root,
|
|
156
|
+
store,
|
|
157
|
+
stored
|
|
158
|
+
});
|
|
159
|
+
await store.remove(stored.authority);
|
|
160
|
+
await options.faultInjector?.({ phase: "after-journal-retired" });
|
|
161
|
+
retainBarrier = false;
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
retainBarrier = await refreshBarrierRetention(store);
|
|
166
|
+
if (claim !== undefined) {
|
|
167
|
+
await retainMutationClaimBarrierOnEvidence(claim);
|
|
168
|
+
}
|
|
169
|
+
if (ownedLease !== undefined && !retainBarrier) {
|
|
170
|
+
retainBarrier = await retainMutationBarrierOnEvidence(ownedLease);
|
|
171
|
+
}
|
|
172
|
+
primaryFailure = { reason: error };
|
|
173
|
+
return translateApplyAdmissionFailure(error);
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
if (ownedLease !== undefined) {
|
|
177
|
+
await releaseKnownFileTransactionLease({
|
|
178
|
+
jointFailureMessage: "Known-file apply and transaction lease release both failed.",
|
|
179
|
+
lease: ownedLease,
|
|
180
|
+
...(primaryFailure === undefined ? {} : { primaryFailure }),
|
|
181
|
+
retainTransactionBarrier: retainBarrier
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
export function applyKnownFileTransaction(options) {
|
|
187
|
+
const keys = typeof options === "object" && options !== null
|
|
188
|
+
? Reflect.ownKeys(options)
|
|
189
|
+
: [];
|
|
190
|
+
const expectedKeys = keys.includes("claim")
|
|
191
|
+
? ["claim", "consumerRoot", "plan"]
|
|
192
|
+
: ["consumerRoot", "plan"];
|
|
193
|
+
if (typeof options !== "object" || options === null || Array.isArray(options) ||
|
|
194
|
+
![Object.prototype, null].includes(Object.getPrototypeOf(options)) ||
|
|
195
|
+
keys.some((key) => typeof key !== "string") ||
|
|
196
|
+
keys.toSorted().join("\0") !== expectedKeys.toSorted().join("\0") ||
|
|
197
|
+
keys.some((key) => {
|
|
198
|
+
const descriptor = Object.getOwnPropertyDescriptor(options, key);
|
|
199
|
+
return descriptor === undefined || !("value" in descriptor) || !descriptor.enumerable;
|
|
200
|
+
})) {
|
|
201
|
+
return Promise.reject(new KnownFileTransactionError("KNOWN_FILE_PLAN_INVALID", "Known-file apply options contain unknown, missing, or executable properties."));
|
|
202
|
+
}
|
|
203
|
+
const values = Object.fromEntries(keys.map((key) => [
|
|
204
|
+
key,
|
|
205
|
+
Object.getOwnPropertyDescriptor(options, key).value
|
|
206
|
+
]));
|
|
207
|
+
const input = Object.hasOwn(values, "claim")
|
|
208
|
+
? { consumerRoot: values["consumerRoot"], plan: values["plan"], claim: values["claim"] }
|
|
209
|
+
: { consumerRoot: values["consumerRoot"], plan: values["plan"] };
|
|
210
|
+
return applyKnownFileTransactionWithFaults(input);
|
|
211
|
+
}
|
|
212
|
+
export function canonicalKnownFileTransactionReceipt(value) {
|
|
213
|
+
return `${canonicalJson(value)}\n`;
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=node-known-file-transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-known-file-transaction.js","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-known-file-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAA2B,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAE,wCAAwC,EAAE,MAAM,yCAAyC,CAAC;AACnG,OAAO,EAAE,kCAAkC,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AACnH,OAAO,EAAE,4BAA4B,EAAE,MAAM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|
|
1
|
+
import type { FileHandle } from "node:fs/promises";
|
|
2
|
+
import { type ExactFilePostimage } from "../../application/model/exact-postimage.js";
|
|
3
|
+
import type { PortablePathIdentity } from "../../application/model/path-identity.js";
|
|
4
|
+
export interface PrepareExactSiblingTemporaryOptions {
|
|
5
|
+
readonly displayPath: string;
|
|
6
|
+
readonly onIdentityCaptured: (identity: PortablePathIdentity) => void;
|
|
7
|
+
readonly validateOpenedPath?: (identity: PortablePathIdentity) => Promise<void>;
|
|
8
|
+
readonly open: (path: string, flags: "wx", mode: number) => Promise<FileHandle>;
|
|
9
|
+
readonly postimage: ExactFilePostimage;
|
|
10
|
+
readonly temporaryPath: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function prepareExactSiblingTemporaryWithFaults(options: PrepareExactSiblingTemporaryOptions & {
|
|
13
|
+
readonly faultInjector?: (point: {
|
|
14
|
+
readonly phase: "after-temporary-written";
|
|
15
|
+
}) => Promise<void> | void;
|
|
16
|
+
}): Promise<PortablePathIdentity>;
|
|
17
|
+
export declare function prepareExactSiblingTemporary(options: PrepareExactSiblingTemporaryOptions): Promise<PortablePathIdentity>;
|
|
18
|
+
//# sourceMappingURL=node-prepare-exact-sibling-temporary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-prepare-exact-sibling-temporary.d.ts","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-prepare-exact-sibling-temporary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAA8B,KAAK,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AACjH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAIrF,MAAM,WAAW,mCAAmC;IAClD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,kBAAkB,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACtE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAC5B,QAAQ,EAAE,oBAAoB,KAC3B,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,QAAQ,CAAC,IAAI,EAAE,CACb,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,IAAI,EACX,IAAI,EAAE,MAAM,KACT,OAAO,CAAC,UAAU,CAAC,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;IACvC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED,wBAAsB,sCAAsC,CAC1D,OAAO,EAAE,mCAAmC,GAAG;IAC7C,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE;QAC/B,QAAQ,CAAC,KAAK,EAAE,yBAAyB,CAAC;KAC3C,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC5B,GACA,OAAO,CAAC,oBAAoB,CAAC,CAyB/B;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,mCAAmC,GAC3C,OAAO,CAAC,oBAAoB,CAAC,CAE/B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AbsentFilePublicationError } from "../../application/model/exact-postimage.js";
|
|
2
|
+
import { captureFileHandleIdentity } from "./node-bounded-regular-file.js";
|
|
3
|
+
import { publicationErrorCode } from "./node-absent-file-publication-private.js";
|
|
4
|
+
export async function prepareExactSiblingTemporaryWithFaults(options) {
|
|
5
|
+
const handle = await options
|
|
6
|
+
.open(options.temporaryPath, "wx", 0o600)
|
|
7
|
+
.catch((error) => {
|
|
8
|
+
if (publicationErrorCode(error) === "EEXIST") {
|
|
9
|
+
throw new AbsentFilePublicationError("TEMPORARY_EXISTS", `Temporary path already exists: ${options.displayPath}.`, { cause: error });
|
|
10
|
+
}
|
|
11
|
+
throw error;
|
|
12
|
+
});
|
|
13
|
+
try {
|
|
14
|
+
const identity = await captureFileHandleIdentity(handle);
|
|
15
|
+
options.onIdentityCaptured(identity);
|
|
16
|
+
await options.validateOpenedPath?.(identity);
|
|
17
|
+
await handle.writeFile(options.postimage.bytes);
|
|
18
|
+
await options.faultInjector?.({ phase: "after-temporary-written" });
|
|
19
|
+
await handle.chmod(options.postimage.mode);
|
|
20
|
+
await handle.sync();
|
|
21
|
+
return identity;
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
await handle.close();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function prepareExactSiblingTemporary(options) {
|
|
28
|
+
return prepareExactSiblingTemporaryWithFaults(options);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=node-prepare-exact-sibling-temporary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-prepare-exact-sibling-temporary.js","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-prepare-exact-sibling-temporary.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAA2B,MAAM,4CAA4C,CAAC;AAEjH,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAiBjF,MAAM,CAAC,KAAK,UAAU,sCAAsC,CAC1D,OAIC;IAED,MAAM,MAAM,GAAG,MAAM,OAAO;SACzB,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,EAAE,KAAK,CAAC;SACxC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;QACxB,IAAI,oBAAoB,CAAC,KAAK,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC7C,MAAM,IAAI,0BAA0B,CAClC,kBAAkB,EAClB,kCAAkC,OAAO,CAAC,WAAW,GAAG,EACxD,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC,CAAC,CAAC;IACL,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,yBAAyB,CAAC,MAAM,CAAC,CAAC;QACzD,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QACrC,MAAM,OAAO,CAAC,kBAAkB,EAAE,CAAC,QAAQ,CAAC,CAAC;QAC7C,MAAM,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAChD,MAAM,OAAO,CAAC,aAAa,EAAE,CAAC,EAAE,KAAK,EAAE,yBAAyB,EAAE,CAAC,CAAC;QACpE,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC3C,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,OAAO,QAAQ,CAAC;IAClB,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,OAA4C;IAE5C,OAAO,sCAAsC,CAAC,OAAO,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ExactFilePostimage } from "../../application/model/exact-postimage.js";
|
|
2
|
+
import type { PortablePathIdentity } from "../../application/model/path-identity.js";
|
|
3
|
+
import { readBoundedRegularFile } from "./node-bounded-regular-file.js";
|
|
4
|
+
import type { DirectoryDurability } from "./node-directory-durability.js";
|
|
5
|
+
export declare function verifyPublishedAbsentFile(options: {
|
|
6
|
+
readonly destinationPath: string;
|
|
7
|
+
readonly displayPath: string;
|
|
8
|
+
readonly expectedIdentity: PortablePathIdentity;
|
|
9
|
+
readonly postimage: ExactFilePostimage;
|
|
10
|
+
readonly readBoundedRegularFile: typeof readBoundedRegularFile;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
export interface PublishPreparedAbsentFileOptions {
|
|
13
|
+
readonly allowUnsupportedDirectoryDurability: boolean;
|
|
14
|
+
readonly classifyBoundedRegularFile: typeof readBoundedRegularFile;
|
|
15
|
+
readonly destinationPath: string;
|
|
16
|
+
readonly displayPath: string;
|
|
17
|
+
readonly expectedIdentity: PortablePathIdentity;
|
|
18
|
+
readonly link: (source: string, destination: string) => Promise<void>;
|
|
19
|
+
readonly parent: string;
|
|
20
|
+
readonly postimage: ExactFilePostimage;
|
|
21
|
+
readonly readBoundedRegularFile: typeof readBoundedRegularFile;
|
|
22
|
+
readonly syncDirectory: (path: string) => Promise<DirectoryDurability>;
|
|
23
|
+
readonly temporaryPath: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function publishPreparedAbsentFileWithFaults(options: PublishPreparedAbsentFileOptions & {
|
|
26
|
+
readonly faultInjector?: (point: {
|
|
27
|
+
readonly phase: "after-hard-link";
|
|
28
|
+
}) => Promise<void> | void;
|
|
29
|
+
}): Promise<"already-satisfied" | "published">;
|
|
30
|
+
export declare function publishPreparedAbsentFile(options: PublishPreparedAbsentFileOptions): Promise<"already-satisfied" | "published">;
|
|
31
|
+
//# sourceMappingURL=node-publish-prepared-absent-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-publish-prepared-absent-file.d.ts","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-publish-prepared-absent-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAErF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAsC1E,wBAAsB,yBAAyB,CAAC,OAAO,EAAE;IACvD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,oBAAoB,CAAC;IAChD,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;IAC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File } from "./node-bounded-regular-file.js";
|
|
3
|
+
import { classifyExactFilePostimageWith, exactReadMatchesPostimage, publicationErrorCode, samePublicationIdentity, syncPublicationDirectory } from "./node-absent-file-publication-private.js";
|
|
4
|
+
function isUnsupportedLink(error) {
|
|
5
|
+
return ["ENOSYS", "ENOTSUP", "EOPNOTSUPP", "EPERM", "EXDEV"].includes(publicationErrorCode(error) ?? "");
|
|
6
|
+
}
|
|
7
|
+
async function verifyPreparedTemporary(options) {
|
|
8
|
+
const stableTemporary = await options.readBoundedRegularFile(options.temporaryPath, options.postimage.size);
|
|
9
|
+
if (exactReadMatchesPostimage(stableTemporary, options.postimage) &&
|
|
10
|
+
samePublicationIdentity(stableTemporary.identity, options.expectedIdentity)) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
throw new AbsentFilePublicationError("TEMPORARY_REPLACED", `Temporary path was replaced or modified concurrently: ${options.displayPath}.`);
|
|
14
|
+
}
|
|
15
|
+
export async function verifyPublishedAbsentFile(options) {
|
|
16
|
+
const publishedFile = await options.readBoundedRegularFile(options.destinationPath, options.postimage.size);
|
|
17
|
+
if (exactReadMatchesPostimage(publishedFile, options.postimage) &&
|
|
18
|
+
samePublicationIdentity(publishedFile.identity, options.expectedIdentity)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
throw new AbsentFilePublicationError("VERIFICATION_FAILED", `Published file failed identity or content verification: ${options.displayPath}.`);
|
|
22
|
+
}
|
|
23
|
+
export async function publishPreparedAbsentFileWithFaults(options) {
|
|
24
|
+
await verifyPreparedTemporary(options);
|
|
25
|
+
try {
|
|
26
|
+
await options.link(options.temporaryPath, options.destinationPath);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
if (publicationErrorCode(error) === "EEXIST") {
|
|
30
|
+
const state = await classifyExactFilePostimageWith(options.classifyBoundedRegularFile, options.destinationPath, options.postimage);
|
|
31
|
+
if (state === "exact") {
|
|
32
|
+
await syncPublicationDirectory(options);
|
|
33
|
+
return "already-satisfied";
|
|
34
|
+
}
|
|
35
|
+
throw new AbsentFilePublicationError("CONFLICT", `Destination changed concurrently: ${options.displayPath}.`, { cause: error });
|
|
36
|
+
}
|
|
37
|
+
if (isUnsupportedLink(error)) {
|
|
38
|
+
throw new AbsentFilePublicationError("PUBLICATION_UNSUPPORTED", `Atomic absent-only publication is unsupported: ${options.displayPath}.`, { cause: error });
|
|
39
|
+
}
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
await options.faultInjector?.({ phase: "after-hard-link" });
|
|
43
|
+
await verifyPublishedAbsentFile(options);
|
|
44
|
+
await syncPublicationDirectory(options);
|
|
45
|
+
return "published";
|
|
46
|
+
}
|
|
47
|
+
export function publishPreparedAbsentFile(options) {
|
|
48
|
+
return publishPreparedAbsentFileWithFaults(options);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=node-publish-prepared-absent-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-publish-prepared-absent-file.js","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-publish-prepared-absent-file.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAC;AAExF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,EACzB,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,2CAA2C,CAAC;AAEnD,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,QAAQ,CACnE,oBAAoB,CAAC,KAAK,CAAC,IAAI,EAAE,CAClC,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,uBAAuB,CAAC,OAMtC;IACC,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,sBAAsB,CAC1D,OAAO,CAAC,a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,CAAC;gBACtB,MAAM,wBAAwB,CAAC,OAAO,CAAC,CAAC;gBACxC,OAAO,mBAAmB,CAAC;YAC7B,CAAC;YACD,MAAM,IAAI,0BAA0B,CAClC,UAAU,EACV,qCAAqC,OAAO,CAAC,WAAW,GAAG,EAC3D,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;QACJ,CAAC;QACD,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,0BAA0B,CAClC,yBAAyB,EACzB,kDAAkD,OAAO,CAAC,WAAW,GAAG,EACxE,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;IACD,MAAM,OAAO,CAAC,aAAa,EAAE,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC,CAAC;IAC5D,MAAM,yBAAyB,CAAC,OAAO,CAAC,CAAC;IACzC,MAAM,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACxC,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,OAAyC;IAEzC,OAAO,mCAAmC,CAAC,OAAO,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-repository-path.d.ts","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-repository-path.ts"],"names":[],"mappings":"AAEA,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAMjF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { isAbsolute, relative, sep } from "node:path";
|
|
2
|
+
export function isLexicallyContainedPath(root, candidate) {
|
|
3
|
+
const relation = relative(root, candidate);
|
|
4
|
+
return (relation === "" ||
|
|
5
|
+
(!relation.startsWith(`..${sep}`) && relation !== ".." && !isAbsolute(relation)));
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=node-repository-path.js.map
|