@agent-teams/engineering-foundation 0.16.1 → 0.17.0-rc.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.
- package/README.md +11 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/changesets-prerelease-state.d.ts +10 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/changesets-prerelease-state.d.ts.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/changesets-prerelease-state.js +69 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/changesets-prerelease-state.js.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/filesystem-public-api-repository.d.ts +3 -2
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/filesystem-public-api-repository.d.ts.map +1 -1
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/filesystem-public-api-repository.js +66 -13
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/filesystem-public-api-repository.js.map +1 -1
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/public-api-baseline-mapper.d.ts +1 -1
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/public-api-baseline-mapper.d.ts.map +1 -1
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/public-api-baseline-mapper.js +5 -2
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/public-api-baseline-mapper.js.map +1 -1
- package/dist/capabilities/public-api-compatibility/application/model/public-api.d.ts +2 -0
- package/dist/capabilities/public-api-compatibility/application/model/public-api.d.ts.map +1 -1
- package/dist/capabilities/public-api-compatibility/application/ports/public-api-repository.d.ts +3 -2
- package/dist/capabilities/public-api-compatibility/application/ports/public-api-repository.d.ts.map +1 -1
- package/dist/capabilities/public-api-compatibility/application/use-cases/promote-public-api-baselines.d.ts.map +1 -1
- package/dist/capabilities/public-api-compatibility/application/use-cases/promote-public-api-baselines.js +40 -5
- package/dist/capabilities/public-api-compatibility/application/use-cases/promote-public-api-baselines.js.map +1 -1
- package/dist/document-authoring/adapters/node/load-validated-document-authoring-profile-v2.d.ts +26 -0
- package/dist/document-authoring/adapters/node/load-validated-document-authoring-profile-v2.d.ts.map +1 -0
- package/dist/document-authoring/adapters/node/load-validated-document-authoring-profile-v2.js +74 -0
- package/dist/document-authoring/adapters/node/load-validated-document-authoring-profile-v2.js.map +1 -0
- package/dist/document-authoring/adapters/node/node-authoring-profile-reader-v2.d.ts +9 -0
- package/dist/document-authoring/adapters/node/node-authoring-profile-reader-v2.d.ts.map +1 -0
- package/dist/document-authoring/adapters/node/node-authoring-profile-reader-v2.js +41 -0
- package/dist/document-authoring/adapters/node/node-authoring-profile-reader-v2.js.map +1 -0
- package/dist/document-authoring/adapters/node/node-document-contract-validator.d.ts +1 -1
- package/dist/document-authoring/adapters/node/node-document-contract-validator.d.ts.map +1 -1
- package/dist/document-authoring/adapters/node/node-document-contract-validator.js +1 -1
- package/dist/document-authoring/adapters/node/node-document-contract-validator.js.map +1 -1
- package/dist/document-authoring/adapters/node/node-document-file-state.d.ts +1 -1
- package/dist/document-authoring/adapters/node/node-document-file-state.d.ts.map +1 -1
- package/dist/document-authoring/adapters/node/node-document-file-state.js +17 -1
- package/dist/document-authoring/adapters/node/node-document-file-state.js.map +1 -1
- package/dist/document-authoring/adapters/node/node-document-metadata-sidecar-reader.d.ts +9 -0
- package/dist/document-authoring/adapters/node/node-document-metadata-sidecar-reader.d.ts.map +1 -0
- package/dist/document-authoring/adapters/node/node-document-metadata-sidecar-reader.js +87 -0
- package/dist/document-authoring/adapters/node/node-document-metadata-sidecar-reader.js.map +1 -0
- package/dist/document-authoring/adapters/node/node-document-parent-materializer.d.ts +39 -0
- package/dist/document-authoring/adapters/node/node-document-parent-materializer.d.ts.map +1 -0
- package/dist/document-authoring/adapters/node/node-document-parent-materializer.js +270 -0
- package/dist/document-authoring/adapters/node/node-document-parent-materializer.js.map +1 -0
- package/dist/document-authoring/adapters/node/node-document-planning-profile-reader.d.ts.map +1 -1
- package/dist/document-authoring/adapters/node/node-document-planning-profile-reader.js +11 -3
- package/dist/document-authoring/adapters/node/node-document-planning-profile-reader.js.map +1 -1
- package/dist/document-authoring/adapters/node/node-document-planning-state-reader.d.ts +1 -0
- package/dist/document-authoring/adapters/node/node-document-planning-state-reader.d.ts.map +1 -1
- package/dist/document-authoring/adapters/node/node-document-planning-state-reader.js +18 -1
- package/dist/document-authoring/adapters/node/node-document-planning-state-reader.js.map +1 -1
- package/dist/document-authoring/adapters/node/node-document-publisher.d.ts +1 -1
- package/dist/document-authoring/adapters/node/node-document-publisher.d.ts.map +1 -1
- package/dist/document-authoring/adapters/node/node-document-publisher.js +102 -11
- package/dist/document-authoring/adapters/node/node-document-publisher.js.map +1 -1
- package/dist/document-authoring/adapters/node/node-document-reachability-projector.d.ts +1 -1
- package/dist/document-authoring/adapters/node/node-document-reachability-projector.d.ts.map +1 -1
- package/dist/document-authoring/adapters/node/node-document-structure-verifier.d.ts +1 -1
- package/dist/document-authoring/adapters/node/node-document-structure-verifier.d.ts.map +1 -1
- package/dist/document-authoring/adapters/node/node-document-transaction-coordinator.d.ts.map +1 -1
- package/dist/document-authoring/adapters/node/node-document-transaction-coordinator.js +1 -1
- package/dist/document-authoring/adapters/node/node-document-transaction-coordinator.js.map +1 -1
- package/dist/document-authoring/adapters/node/node-metadata-instance-validator.d.ts.map +1 -1
- package/dist/document-authoring/adapters/node/node-metadata-instance-validator.js +6 -0
- package/dist/document-authoring/adapters/node/node-metadata-instance-validator.js.map +1 -1
- package/dist/document-authoring/adapters/node/node-path-authority.d.ts +53 -0
- package/dist/document-authoring/adapters/node/node-path-authority.d.ts.map +1 -0
- package/dist/document-authoring/adapters/node/node-path-authority.js +186 -0
- package/dist/document-authoring/adapters/node/node-path-authority.js.map +1 -0
- package/dist/document-authoring/adapters/node/recapture-document-publication-paths.d.ts +2 -1
- package/dist/document-authoring/adapters/node/recapture-document-publication-paths.d.ts.map +1 -1
- package/dist/document-authoring/adapters/node/recapture-document-publication-paths.js +21 -77
- package/dist/document-authoring/adapters/node/recapture-document-publication-paths.js.map +1 -1
- package/dist/document-authoring/application/model/document-authoring-profile-description.d.ts +53 -0
- package/dist/document-authoring/application/model/document-authoring-profile-description.d.ts.map +1 -0
- package/dist/document-authoring/application/model/document-authoring-profile-description.js +2 -0
- package/dist/document-authoring/application/model/document-authoring-profile-description.js.map +1 -0
- package/dist/document-authoring/application/model/document-catalog.d.ts +29 -0
- package/dist/document-authoring/application/model/document-catalog.d.ts.map +1 -1
- package/dist/document-authoring/application/model/document-find.d.ts +5 -1
- package/dist/document-authoring/application/model/document-find.d.ts.map +1 -1
- package/dist/document-authoring/application/model/document-parent-materialization.d.ts +26 -0
- package/dist/document-authoring/application/model/document-parent-materialization.d.ts.map +1 -0
- package/dist/document-authoring/application/model/document-parent-materialization.js +2 -0
- package/dist/document-authoring/application/model/document-parent-materialization.js.map +1 -0
- package/dist/document-authoring/application/model/document-planning.d.ts +29 -2
- package/dist/document-authoring/application/model/document-planning.d.ts.map +1 -1
- package/dist/document-authoring/application/model/document-receipt.d.ts +28 -1
- package/dist/document-authoring/application/model/document-receipt.d.ts.map +1 -1
- package/dist/document-authoring/application/model/document-transaction-inspection.d.ts +23 -0
- package/dist/document-authoring/application/model/document-transaction-inspection.d.ts.map +1 -1
- package/dist/document-authoring/application/model/document-transaction.d.ts +91 -3
- package/dist/document-authoring/application/model/document-transaction.d.ts.map +1 -1
- package/dist/document-authoring/application/policies/assert-artifact-owner-allowed.d.ts +3 -0
- package/dist/document-authoring/application/policies/assert-artifact-owner-allowed.d.ts.map +1 -0
- package/dist/document-authoring/application/policies/assert-artifact-owner-allowed.js +8 -0
- package/dist/document-authoring/application/policies/assert-artifact-owner-allowed.js.map +1 -0
- package/dist/document-authoring/application/policies/assert-v2-planning-profile.d.ts +3 -0
- package/dist/document-authoring/application/policies/assert-v2-planning-profile.d.ts.map +1 -0
- package/dist/document-authoring/application/policies/assert-v2-planning-profile.js +7 -0
- package/dist/document-authoring/application/policies/assert-v2-planning-profile.js.map +1 -0
- package/dist/document-authoring/application/policies/document-authoring-semantic-digests.d.ts +30 -0
- package/dist/document-authoring/application/policies/document-authoring-semantic-digests.d.ts.map +1 -0
- package/dist/document-authoring/application/policies/document-authoring-semantic-digests.js +157 -0
- package/dist/document-authoring/application/policies/document-authoring-semantic-digests.js.map +1 -0
- package/dist/document-authoring/application/policies/document-catalog-authority-stability.d.ts +12 -0
- package/dist/document-authoring/application/policies/document-catalog-authority-stability.d.ts.map +1 -0
- package/dist/document-authoring/application/policies/document-catalog-authority-stability.js +16 -0
- package/dist/document-authoring/application/policies/document-catalog-authority-stability.js.map +1 -0
- package/dist/document-authoring/application/policies/document-catalog-sidecar.d.ts +10 -0
- package/dist/document-authoring/application/policies/document-catalog-sidecar.d.ts.map +1 -0
- package/dist/document-authoring/application/policies/document-catalog-sidecar.js +66 -0
- package/dist/document-authoring/application/policies/document-catalog-sidecar.js.map +1 -0
- package/dist/document-authoring/application/policies/document-command-projection.d.ts +1 -1
- package/dist/document-authoring/application/policies/document-command-projection.d.ts.map +1 -1
- package/dist/document-authoring/application/policies/document-contract-digests.d.ts.map +1 -1
- package/dist/document-authoring/application/policies/document-contract-digests.js +61 -7
- package/dist/document-authoring/application/policies/document-contract-digests.js.map +1 -1
- package/dist/document-authoring/application/policies/document-receipt-policy.d.ts +3 -3
- package/dist/document-authoring/application/policies/document-receipt-policy.d.ts.map +1 -1
- package/dist/document-authoring/application/policies/document-receipt-policy.js +43 -4
- package/dist/document-authoring/application/policies/document-receipt-policy.js.map +1 -1
- package/dist/document-authoring/application/policies/document-transaction-digests.d.ts +2 -2
- package/dist/document-authoring/application/policies/document-transaction-digests.d.ts.map +1 -1
- package/dist/document-authoring/application/policies/document-transaction-digests.js.map +1 -1
- package/dist/document-authoring/application/policies/document-transaction-envelope-body.d.ts +28 -0
- package/dist/document-authoring/application/policies/document-transaction-envelope-body.d.ts.map +1 -0
- package/dist/document-authoring/application/policies/document-transaction-envelope-body.js +140 -0
- package/dist/document-authoring/application/policies/document-transaction-envelope-body.js.map +1 -0
- package/dist/document-authoring/application/policies/document-transaction-envelope-policy.d.ts.map +1 -1
- package/dist/document-authoring/application/policies/document-transaction-envelope-policy.js +47 -6
- package/dist/document-authoring/application/policies/document-transaction-envelope-policy.js.map +1 -1
- package/dist/document-authoring/application/policies/inspect-catalog-document.d.ts +8 -1
- package/dist/document-authoring/application/policies/inspect-catalog-document.d.ts.map +1 -1
- package/dist/document-authoring/application/policies/inspect-catalog-document.js +48 -0
- package/dist/document-authoring/application/policies/inspect-catalog-document.js.map +1 -1
- package/dist/document-authoring/application/policies/project-catalog-metadata.d.ts +7 -0
- package/dist/document-authoring/application/policies/project-catalog-metadata.d.ts.map +1 -0
- package/dist/document-authoring/application/policies/project-catalog-metadata.js +165 -0
- package/dist/document-authoring/application/policies/project-catalog-metadata.js.map +1 -0
- package/dist/document-authoring/application/policies/same-document-catalog-snapshot.d.ts +3 -0
- package/dist/document-authoring/application/policies/same-document-catalog-snapshot.d.ts.map +1 -0
- package/dist/document-authoring/application/policies/same-document-catalog-snapshot.js +24 -0
- package/dist/document-authoring/application/policies/same-document-catalog-snapshot.js.map +1 -0
- package/dist/document-authoring/application/ports/authoring-profile-reader.d.ts +10 -0
- package/dist/document-authoring/application/ports/authoring-profile-reader.d.ts.map +1 -1
- package/dist/document-authoring/application/ports/document-authority-recompiler.d.ts +1 -1
- package/dist/document-authoring/application/ports/document-authority-recompiler.d.ts.map +1 -1
- package/dist/document-authoring/application/ports/document-contract-validator.d.ts +1 -1
- package/dist/document-authoring/application/ports/document-contract-validator.d.ts.map +1 -1
- package/dist/document-authoring/application/ports/document-file-state.d.ts +1 -1
- package/dist/document-authoring/application/ports/document-file-state.d.ts.map +1 -1
- package/dist/document-authoring/application/ports/document-metadata-sidecar-reader.d.ts +13 -0
- package/dist/document-authoring/application/ports/document-metadata-sidecar-reader.d.ts.map +1 -0
- package/dist/document-authoring/application/ports/document-metadata-sidecar-reader.js +2 -0
- package/dist/document-authoring/application/ports/document-metadata-sidecar-reader.js.map +1 -0
- package/dist/document-authoring/application/ports/document-parent-materializer.d.ts +24 -0
- package/dist/document-authoring/application/ports/document-parent-materializer.d.ts.map +1 -0
- package/dist/document-authoring/application/ports/document-parent-materializer.js +2 -0
- package/dist/document-authoring/application/ports/document-parent-materializer.js.map +1 -0
- package/dist/document-authoring/application/ports/document-planning-state-reader.d.ts +1 -0
- package/dist/document-authoring/application/ports/document-planning-state-reader.d.ts.map +1 -1
- package/dist/document-authoring/application/ports/document-publisher.d.ts +1 -1
- package/dist/document-authoring/application/ports/document-publisher.d.ts.map +1 -1
- package/dist/document-authoring/application/ports/document-reachability-projector.d.ts +1 -1
- package/dist/document-authoring/application/ports/document-reachability-projector.d.ts.map +1 -1
- package/dist/document-authoring/application/ports/document-structure-verifier.d.ts +1 -1
- package/dist/document-authoring/application/ports/document-structure-verifier.d.ts.map +1 -1
- package/dist/document-authoring/application/ports/documentation-catalog-reader-v2.d.ts +11 -0
- package/dist/document-authoring/application/ports/documentation-catalog-reader-v2.d.ts.map +1 -0
- package/dist/document-authoring/application/ports/documentation-catalog-reader-v2.js +2 -0
- package/dist/document-authoring/application/ports/documentation-catalog-reader-v2.js.map +1 -0
- package/dist/document-authoring/application/ports/documentation-catalog-reader.d.ts +2 -2
- package/dist/document-authoring/application/ports/documentation-catalog-reader.d.ts.map +1 -1
- package/dist/document-authoring/application/ports/documentation-search-catalog-reader-v2.d.ts +9 -0
- package/dist/document-authoring/application/ports/documentation-search-catalog-reader-v2.d.ts.map +1 -0
- package/dist/document-authoring/application/ports/documentation-search-catalog-reader-v2.js +2 -0
- package/dist/document-authoring/application/ports/documentation-search-catalog-reader-v2.js.map +1 -0
- package/dist/document-authoring/application/ports/metadata-instance-validator.d.ts +1 -0
- package/dist/document-authoring/application/ports/metadata-instance-validator.d.ts.map +1 -1
- package/dist/document-authoring/application/use-cases/apply-document-plan.d.ts +1 -1
- package/dist/document-authoring/application/use-cases/apply-document-plan.d.ts.map +1 -1
- package/dist/document-authoring/application/use-cases/apply-document-plan.js +150 -54
- package/dist/document-authoring/application/use-cases/apply-document-plan.js.map +1 -1
- package/dist/document-authoring/application/use-cases/apply-document-recovery-receipt.d.ts +14 -0
- package/dist/document-authoring/application/use-cases/apply-document-recovery-receipt.d.ts.map +1 -0
- package/dist/document-authoring/application/use-cases/apply-document-recovery-receipt.js +17 -0
- package/dist/document-authoring/application/use-cases/apply-document-recovery-receipt.js.map +1 -0
- package/dist/document-authoring/application/use-cases/build-documentation-catalog.d.ts +18 -1
- package/dist/document-authoring/application/use-cases/build-documentation-catalog.d.ts.map +1 -1
- package/dist/document-authoring/application/use-cases/build-documentation-catalog.js +81 -26
- package/dist/document-authoring/application/use-cases/build-documentation-catalog.js.map +1 -1
- package/dist/document-authoring/application/use-cases/compile-document-plan.d.ts +1 -1
- package/dist/document-authoring/application/use-cases/compile-document-plan.d.ts.map +1 -1
- package/dist/document-authoring/application/use-cases/compile-document-plan.js +50 -6
- package/dist/document-authoring/application/use-cases/compile-document-plan.js.map +1 -1
- package/dist/document-authoring/application/use-cases/document-parent-materialization-continuation.d.ts +3 -0
- package/dist/document-authoring/application/use-cases/document-parent-materialization-continuation.d.ts.map +1 -0
- package/dist/document-authoring/application/use-cases/document-parent-materialization-continuation.js +79 -0
- package/dist/document-authoring/application/use-cases/document-parent-materialization-continuation.js.map +1 -0
- package/dist/document-authoring/application/use-cases/document-transaction-continuation.d.ts +18 -13
- package/dist/document-authoring/application/use-cases/document-transaction-continuation.d.ts.map +1 -1
- package/dist/document-authoring/application/use-cases/document-transaction-continuation.js +88 -165
- package/dist/document-authoring/application/use-cases/document-transaction-continuation.js.map +1 -1
- package/dist/document-authoring/application/use-cases/document-transaction-receipts.d.ts +21 -0
- package/dist/document-authoring/application/use-cases/document-transaction-receipts.d.ts.map +1 -0
- package/dist/document-authoring/application/use-cases/document-transaction-receipts.js +180 -0
- package/dist/document-authoring/application/use-cases/document-transaction-receipts.js.map +1 -0
- package/dist/document-authoring/application/use-cases/find-documents.d.ts +7 -1
- package/dist/document-authoring/application/use-cases/find-documents.d.ts.map +1 -1
- package/dist/document-authoring/application/use-cases/find-documents.js +19 -0
- package/dist/document-authoring/application/use-cases/find-documents.js.map +1 -1
- package/dist/document-authoring/application/use-cases/load-v2-profile-description.d.ts +15 -0
- package/dist/document-authoring/application/use-cases/load-v2-profile-description.d.ts.map +1 -0
- package/dist/document-authoring/application/use-cases/load-v2-profile-description.js +12 -0
- package/dist/document-authoring/application/use-cases/load-v2-profile-description.js.map +1 -0
- package/dist/document-authoring/application/use-cases/plan-documentation-document.d.ts +12 -4
- package/dist/document-authoring/application/use-cases/plan-documentation-document.d.ts.map +1 -1
- package/dist/document-authoring/application/use-cases/plan-documentation-document.js +25 -28
- package/dist/document-authoring/application/use-cases/plan-documentation-document.js.map +1 -1
- package/dist/document-authoring/application/use-cases/recapture-directory-receipt-evidence.d.ts +8 -0
- package/dist/document-authoring/application/use-cases/recapture-directory-receipt-evidence.d.ts.map +1 -0
- package/dist/document-authoring/application/use-cases/recapture-directory-receipt-evidence.js +32 -0
- package/dist/document-authoring/application/use-cases/recapture-directory-receipt-evidence.js.map +1 -0
- package/dist/document-authoring/application/use-cases/recover-document-transaction.d.ts +1 -1
- package/dist/document-authoring/application/use-cases/recover-document-transaction.d.ts.map +1 -1
- package/dist/document-authoring/application/use-cases/recover-document-transaction.js +148 -20
- package/dist/document-authoring/application/use-cases/recover-document-transaction.js.map +1 -1
- package/dist/document-authoring/application/use-cases/run-document-doctor.d.ts +2 -2
- package/dist/document-authoring/application/use-cases/run-document-doctor.d.ts.map +1 -1
- package/dist/document-authoring/application/use-cases/run-document-doctor.js.map +1 -1
- package/dist/document-authoring/application/use-cases/run-document-new.d.ts +4 -4
- package/dist/document-authoring/application/use-cases/run-document-new.d.ts.map +1 -1
- package/dist/document-authoring/application/use-cases/run-document-new.js.map +1 -1
- package/dist/document-authoring/application/use-cases/run-document-recover.d.ts +3 -3
- package/dist/document-authoring/application/use-cases/run-document-recover.d.ts.map +1 -1
- package/dist/document-authoring/composition/describe-document-authoring-profile-v2.d.ts +8 -0
- package/dist/document-authoring/composition/describe-document-authoring-profile-v2.d.ts.map +1 -0
- package/dist/document-authoring/composition/describe-document-authoring-profile-v2.js +183 -0
- package/dist/document-authoring/composition/describe-document-authoring-profile-v2.js.map +1 -0
- package/dist/document-authoring/composition/inspect-document-authoring-environment-v1.d.ts +7 -0
- package/dist/document-authoring/composition/inspect-document-authoring-environment-v1.d.ts.map +1 -0
- package/dist/document-authoring/composition/inspect-document-authoring-environment-v1.js +10 -0
- package/dist/document-authoring/composition/inspect-document-authoring-environment-v1.js.map +1 -0
- package/dist/document-authoring/composition/inspect-document-transaction.d.ts +3 -1
- package/dist/document-authoring/composition/inspect-document-transaction.d.ts.map +1 -1
- package/dist/document-authoring/composition/inspect-document-transaction.js +50 -13
- package/dist/document-authoring/composition/inspect-document-transaction.js.map +1 -1
- package/dist/document-authoring/composition/node-document-authority-recompiler.d.ts +1 -1
- package/dist/document-authoring/composition/node-document-authority-recompiler.d.ts.map +1 -1
- package/dist/document-authoring/composition/node-document-authority-recompiler.js +22 -3
- package/dist/document-authoring/composition/node-document-authority-recompiler.js.map +1 -1
- package/dist/document-authoring/composition/node-document-commands.js +2 -2
- package/dist/document-authoring/composition/node-document-planning.d.ts +2 -2
- package/dist/document-authoring/composition/node-document-planning.d.ts.map +1 -1
- package/dist/document-authoring/composition/node-document-planning.js +28 -7
- package/dist/document-authoring/composition/node-document-planning.js.map +1 -1
- package/dist/document-authoring/composition/node-document-writing-private.d.ts +1 -1
- package/dist/document-authoring/composition/node-document-writing-private.d.ts.map +1 -1
- package/dist/document-authoring/composition/node-document-writing-private.js +5 -3
- package/dist/document-authoring/composition/node-document-writing-private.js.map +1 -1
- package/dist/document-authoring/composition/node-document-writing.d.ts +1 -1
- package/dist/document-authoring/composition/node-document-writing.d.ts.map +1 -1
- package/dist/document-authoring/index.d.ts +29 -8
- package/dist/document-authoring/index.d.ts.map +1 -1
- package/dist/document-authoring/index.js +50 -3
- package/dist/document-authoring/index.js.map +1 -1
- package/dist/document-authoring/qualification/index.d.ts +22 -0
- package/dist/document-authoring/qualification/index.d.ts.map +1 -0
- package/dist/document-authoring/qualification/index.js +131 -0
- package/dist/document-authoring/qualification/index.js.map +1 -0
- package/dist/foundation-state-contract.d.ts +1 -0
- package/dist/foundation-state-contract.d.ts.map +1 -1
- package/dist/foundation-state-contract.js +1 -0
- package/dist/foundation-state-contract.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/local-mode/inspection.d.ts.map +1 -1
- package/dist/local-mode/inspection.js +12 -1
- package/dist/local-mode/inspection.js.map +1 -1
- package/dist/mutation/index.d.ts +11 -0
- package/dist/mutation/index.d.ts.map +1 -0
- package/dist/mutation/index.js +5 -0
- package/dist/mutation/index.js.map +1 -0
- package/dist/package-self-check.d.ts +1 -1
- package/dist/package-self-check.d.ts.map +1 -1
- package/dist/package-self-check.js +12 -0
- package/dist/package-self-check.js.map +1 -1
- package/dist/public-api-surface.d.ts +1 -0
- package/dist/public-api-surface.d.ts.map +1 -1
- package/dist/public-api-surface.js +1 -0
- package/dist/public-api-surface.js.map +1 -1
- package/dist/repository-mutation/adapters/node/node-bounded-regular-file.d.ts +2 -0
- package/dist/repository-mutation/adapters/node/node-bounded-regular-file.d.ts.map +1 -1
- package/dist/repository-mutation/adapters/node/node-bounded-regular-file.js +31 -23
- package/dist/repository-mutation/adapters/node/node-bounded-regular-file.js.map +1 -1
- package/dist/repository-mutation/adapters/node/node-cleanup-owned-temporary.d.ts.map +1 -1
- package/dist/repository-mutation/adapters/node/node-cleanup-owned-temporary.js +21 -0
- package/dist/repository-mutation/adapters/node/node-cleanup-owned-temporary.js.map +1 -1
- package/dist/repository-mutation/adapters/node/node-create-and-bind-directory.d.ts +15 -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-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 +224 -0
- package/dist/repository-mutation/adapters/node/node-directory-materialization.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 +194 -0
- package/dist/repository-mutation/adapters/node/node-known-file-recovery-filesystem.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-filesystem.d.ts +25 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-filesystem.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-filesystem.js +129 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-filesystem.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-inspection.d.ts +12 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-inspection.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-inspection.js +46 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-inspection.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-journal-store.d.ts +21 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-journal-store.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-journal-store.js +178 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-journal-store.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-receipt.d.ts +4 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-receipt.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-receipt.js +43 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-receipt.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-recovery.d.ts +11 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-recovery.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-recovery.js +888 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction-recovery.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction.d.ts +20 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction.js +546 -0
- package/dist/repository-mutation/adapters/node/node-known-file-transaction.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-prepare-exact-sibling-temporary.d.ts +1 -0
- package/dist/repository-mutation/adapters/node/node-prepare-exact-sibling-temporary.d.ts.map +1 -1
- package/dist/repository-mutation/adapters/node/node-prepare-exact-sibling-temporary.js +1 -0
- package/dist/repository-mutation/adapters/node/node-prepare-exact-sibling-temporary.js.map +1 -1
- 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/known-file-transaction-journal.d.ts +63 -0
- package/dist/repository-mutation/application/model/known-file-transaction-journal.d.ts.map +1 -0
- package/dist/repository-mutation/application/model/known-file-transaction-journal.js +15 -0
- package/dist/repository-mutation/application/model/known-file-transaction-journal.js.map +1 -0
- package/dist/repository-mutation/application/model/known-file-transaction.d.ts +64 -0
- package/dist/repository-mutation/application/model/known-file-transaction.d.ts.map +1 -0
- package/dist/repository-mutation/application/model/known-file-transaction.js +2 -0
- package/dist/repository-mutation/application/model/known-file-transaction.js.map +1 -0
- package/dist/repository-mutation/application/policies/known-file-transaction-envelope.d.ts +8 -0
- package/dist/repository-mutation/application/policies/known-file-transaction-envelope.d.ts.map +1 -0
- package/dist/repository-mutation/application/policies/known-file-transaction-envelope.js +241 -0
- package/dist/repository-mutation/application/policies/known-file-transaction-envelope.js.map +1 -0
- package/dist/repository-mutation/application/policies/known-file-transaction-plan.d.ts +7 -0
- package/dist/repository-mutation/application/policies/known-file-transaction-plan.d.ts.map +1 -0
- package/dist/repository-mutation/application/policies/known-file-transaction-plan.js +215 -0
- package/dist/repository-mutation/application/policies/known-file-transaction-plan.js.map +1 -0
- package/dist/schema-catalog.d.ts.map +1 -1
- package/dist/schema-catalog.js +12 -0
- package/dist/schema-catalog.js.map +1 -1
- package/dist/schema-ids.d.ts +1 -1
- package/dist/schema-ids.d.ts.map +1 -1
- package/dist/schema-ids.js +8 -0
- package/dist/schema-ids.js.map +1 -1
- package/dist/semantic-version.d.ts +1 -0
- package/dist/semantic-version.d.ts.map +1 -1
- package/dist/semantic-version.js +11 -0
- package/dist/semantic-version.js.map +1 -1
- package/dist/transaction-coordination/adapters/node/document-envelope-bindings.d.ts +2 -2
- package/dist/transaction-coordination/adapters/node/document-envelope-bindings.d.ts.map +1 -1
- package/dist/transaction-coordination/adapters/node/document-envelope-bindings.js +33 -19
- package/dist/transaction-coordination/adapters/node/document-envelope-bindings.js.map +1 -1
- package/dist/transaction-coordination/adapters/node/document-temporary-identity.d.ts +1 -1
- package/dist/transaction-coordination/adapters/node/document-temporary-identity.d.ts.map +1 -1
- package/dist/transaction-coordination/adapters/node/document-temporary-identity.js.map +1 -1
- package/dist/transaction-coordination/adapters/node/document-transaction-status.d.ts +9 -0
- package/dist/transaction-coordination/adapters/node/document-transaction-status.d.ts.map +1 -0
- package/dist/transaction-coordination/adapters/node/document-transaction-status.js +26 -0
- package/dist/transaction-coordination/adapters/node/document-transaction-status.js.map +1 -0
- package/dist/transaction-coordination/adapters/node/known-file-transaction-status.d.ts +8 -0
- package/dist/transaction-coordination/adapters/node/known-file-transaction-status.d.ts.map +1 -0
- package/dist/transaction-coordination/adapters/node/known-file-transaction-status.js +50 -0
- package/dist/transaction-coordination/adapters/node/known-file-transaction-status.js.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-foundation-transaction-slot.d.ts.map +1 -1
- package/dist/transaction-coordination/adapters/node/node-foundation-transaction-slot.js +42 -36
- package/dist/transaction-coordination/adapters/node/node-foundation-transaction-slot.js.map +1 -1
- package/dist/transaction-coordination/application/foundation-transaction-coordinator.d.ts +1 -1
- package/dist/transaction-coordination/application/foundation-transaction-coordinator.d.ts.map +1 -1
- package/dist/transaction-coordination/application/foundation-transaction-coordinator.js +13 -2
- package/dist/transaction-coordination/application/foundation-transaction-coordinator.js.map +1 -1
- package/dist/transaction-coordination/application/model/internal-transaction-status.d.ts +15 -3
- package/dist/transaction-coordination/application/model/internal-transaction-status.d.ts.map +1 -1
- package/dist/transaction-coordination/application/model/transaction-status.d.ts +6 -2
- package/dist/transaction-coordination/application/model/transaction-status.d.ts.map +1 -1
- package/package.json +17 -1
- package/schemas/document-authoring-profile/v2.schema.json +168 -0
- package/schemas/document-parent-materialization/v2.schema.json +65 -0
- package/schemas/document-plan/v2.schema.json +85 -0
- package/schemas/document-receipt/v2.schema.json +108 -0
- package/schemas/foundation-transaction-envelope/v4.schema.json +164 -0
- package/schemas/foundation-transaction-envelope/v5.schema.json +94 -0
- package/schemas/known-file-transaction-plan/v1.schema.json +65 -0
- package/schemas/known-file-transaction-receipt/v1.schema.json +36 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { lstat, readdir, realpath } from "node:fs/promises";
|
|
3
|
+
import { basename, join, resolve } from "node:path";
|
|
4
|
+
import { portableRepositoryPathIdentity, portableRepositoryPathProblem } from "../../application/model/repository-path.js";
|
|
5
|
+
import { captureFileHandleIdentity, readBoundedRegularFile } from "./node-bounded-regular-file.js";
|
|
6
|
+
import { isLexicallyContainedPath } from "./node-repository-path.js";
|
|
7
|
+
const MAXIMUM_MANAGED_FILE_BYTES = 8 * 1024 * 1024;
|
|
8
|
+
export class KnownFileTransactionError extends Error {
|
|
9
|
+
code;
|
|
10
|
+
constructor(code, message, options) {
|
|
11
|
+
super(message, options);
|
|
12
|
+
this.name = "KnownFileTransactionError";
|
|
13
|
+
this.code = code;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function knownFileErrorCode(error) {
|
|
17
|
+
return error instanceof Error && "code" in error
|
|
18
|
+
? error.code
|
|
19
|
+
: undefined;
|
|
20
|
+
}
|
|
21
|
+
export function sameKnownFileIdentity(left, right) {
|
|
22
|
+
return left.birthtimeNs === right.birthtimeNs &&
|
|
23
|
+
left.dev === right.dev && left.ino === right.ino;
|
|
24
|
+
}
|
|
25
|
+
export function knownFileImageBytes(image) {
|
|
26
|
+
return Buffer.from(image.contentBase64, "base64");
|
|
27
|
+
}
|
|
28
|
+
export function matchesKnownFileImage(observed, image) {
|
|
29
|
+
return observed.state === "file" && observed.bytes !== undefined &&
|
|
30
|
+
observed.bytes.byteLength === image.size &&
|
|
31
|
+
`sha256:${createHash("sha256").update(observed.bytes).digest("hex")}` === image.digest &&
|
|
32
|
+
observed.mode === image.mode;
|
|
33
|
+
}
|
|
34
|
+
export function knownFileTemporaryName(path, planDigest, operationIndex) {
|
|
35
|
+
return `.${basename(path)}.agent-teams.${planDigest.slice(7, 23)}.${operationIndex}.tmp`;
|
|
36
|
+
}
|
|
37
|
+
export function knownFileCaptureDirectoryName(path, planDigest, operationIndex) {
|
|
38
|
+
return `.${basename(path)}.agent-teams.capture.${planDigest.slice(7, 23)}.${operationIndex}`;
|
|
39
|
+
}
|
|
40
|
+
export async function canonicalKnownFileRoot(consumerRoot) {
|
|
41
|
+
const requested = resolve(consumerRoot);
|
|
42
|
+
const metadata = await lstat(requested);
|
|
43
|
+
if (metadata.isSymbolicLink() || !metadata.isDirectory()) {
|
|
44
|
+
throw new KnownFileTransactionError("KNOWN_FILE_ROOT_INVALID", "Consumer root must be one real directory, not a symlink.");
|
|
45
|
+
}
|
|
46
|
+
return realpath(requested);
|
|
47
|
+
}
|
|
48
|
+
export async function knownFileAliasEntry(parent, requested) {
|
|
49
|
+
const identity = portableRepositoryPathIdentity(requested);
|
|
50
|
+
const matches = (await readdir(parent)).filter((entry) => portableRepositoryPathIdentity(entry) === identity);
|
|
51
|
+
if (matches.some((entry) => entry !== requested)) {
|
|
52
|
+
throw new KnownFileTransactionError("KNOWN_FILE_PATH_ALIAS", `Portable case or Unicode path collision blocks ${requested}.`);
|
|
53
|
+
}
|
|
54
|
+
return matches.find((entry) => entry === requested);
|
|
55
|
+
}
|
|
56
|
+
async function resolveExistingParent(root, repositoryPath) {
|
|
57
|
+
const problem = portableRepositoryPathProblem(repositoryPath);
|
|
58
|
+
if (problem !== undefined) {
|
|
59
|
+
throw new KnownFileTransactionError("KNOWN_FILE_PATH_INVALID", `Repository path is not portable (${problem}): ${repositoryPath}.`);
|
|
60
|
+
}
|
|
61
|
+
const segments = repositoryPath.split("/");
|
|
62
|
+
segments.pop();
|
|
63
|
+
let current = root;
|
|
64
|
+
for (const segment of segments) {
|
|
65
|
+
if (await knownFileAliasEntry(current, segment) === undefined) {
|
|
66
|
+
return { absolute: current, complete: false };
|
|
67
|
+
}
|
|
68
|
+
current = join(current, segment);
|
|
69
|
+
const metadata = await lstat(current);
|
|
70
|
+
if (metadata.isSymbolicLink() || !metadata.isDirectory()) {
|
|
71
|
+
throw new KnownFileTransactionError("KNOWN_FILE_ANCESTOR_INVALID", `Repository ancestor must be one real directory: ${repositoryPath}.`);
|
|
72
|
+
}
|
|
73
|
+
const canonical = await realpath(current);
|
|
74
|
+
if (!isLexicallyContainedPath(root, canonical) || canonical !== current) {
|
|
75
|
+
throw new KnownFileTransactionError("KNOWN_FILE_PATH_ESCAPE", `Repository ancestor escapes or aliases the root: ${repositoryPath}.`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return { absolute: current, complete: true };
|
|
79
|
+
}
|
|
80
|
+
export async function observeKnownFile(root, repositoryPath, maximumBytes) {
|
|
81
|
+
const parent = await resolveExistingParent(root, repositoryPath);
|
|
82
|
+
if (!parent.complete) {
|
|
83
|
+
return { state: "absent" };
|
|
84
|
+
}
|
|
85
|
+
const name = repositoryPath.split("/").at(-1);
|
|
86
|
+
if (await knownFileAliasEntry(parent.absolute, name) === undefined) {
|
|
87
|
+
return { state: "absent" };
|
|
88
|
+
}
|
|
89
|
+
const path = join(root, ...repositoryPath.split("/"));
|
|
90
|
+
const metadata = await lstat(path, { bigint: true });
|
|
91
|
+
if (metadata.isSymbolicLink() || !metadata.isFile()) {
|
|
92
|
+
throw new KnownFileTransactionError("KNOWN_FILE_DESTINATION_INVALID", `Managed path must be a real regular file: ${repositoryPath}.`);
|
|
93
|
+
}
|
|
94
|
+
const observed = await readBoundedRegularFile(path, Math.max(maximumBytes, MAXIMUM_MANAGED_FILE_BYTES));
|
|
95
|
+
if (observed.outcome !== "read") {
|
|
96
|
+
throw new KnownFileTransactionError("KNOWN_FILE_UNSTABLE", `Managed path is oversized, unstable, or invalid: ${repositoryPath}.`);
|
|
97
|
+
}
|
|
98
|
+
if (observed.linkCount !== 1n) {
|
|
99
|
+
throw new KnownFileTransactionError("KNOWN_FILE_HARDLINK", `Managed path has multiple hard links: ${repositoryPath}.`);
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
state: "file",
|
|
103
|
+
bytes: observed.bytes,
|
|
104
|
+
identity: observed.identity,
|
|
105
|
+
mode: observed.mode & 0o777
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export function maximumKnownFileEvidenceBytes(operation) {
|
|
109
|
+
return Math.max(operation.postimage.size, ...(operation.precondition.state === "known-file"
|
|
110
|
+
? operation.precondition.acceptedPreimages.map(({ size }) => size)
|
|
111
|
+
: [0]));
|
|
112
|
+
}
|
|
113
|
+
export function classifyKnownFileOperation(operation, observed) {
|
|
114
|
+
if (matchesKnownFileImage(observed, operation.postimage)) {
|
|
115
|
+
return { path: operation.path, state: "already-satisfied" };
|
|
116
|
+
}
|
|
117
|
+
if (operation.precondition.state === "absent") {
|
|
118
|
+
if (observed.state !== "absent") {
|
|
119
|
+
throw new KnownFileTransactionError("KNOWN_FILE_CAS_MISMATCH", `Expected an absent managed path: ${operation.path}.`);
|
|
120
|
+
}
|
|
121
|
+
return { path: operation.path, state: "pending" };
|
|
122
|
+
}
|
|
123
|
+
const matchedPreimage = operation.precondition.acceptedPreimages.findIndex((image) => matchesKnownFileImage(observed, image));
|
|
124
|
+
if (matchedPreimage === -1) {
|
|
125
|
+
throw new KnownFileTransactionError("KNOWN_FILE_CAS_MISMATCH", `Managed path does not match an exact accepted preimage: ${operation.path}.`);
|
|
126
|
+
}
|
|
127
|
+
return { path: operation.path, state: "pending", matchedPreimage };
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=node-known-file-transaction-filesystem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-known-file-transaction-filesystem.js","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-known-file-transaction-filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpD,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC9B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErE,MAAM,0BAA0B,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnD,MAAM,OAAO,yBAA0B,SAAQ,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,KAAK,EAAE,SAAS,EAAE,CAAC;IACpD,CAAC;IACD,MAAM,eAAe,GAAG,SAAS,CAAC,YAAY,CAAC,iBAAiB,CAAC,SAAS,CACxE,CAAC,KAAK,EAAE,EAAE,CAAC,qBAAqB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAClD,CAAC;IACF,IAAI,eAAe,KAAK,CAAC,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,yBAAyB,CACjC,yBAAyB,EACzB,2DAA2D,SAAS,CAAC,IAAI,GAAG,CAC7E,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type KnownFileTransactionBarrierInspection = {
|
|
2
|
+
readonly state: "idle";
|
|
3
|
+
} | {
|
|
4
|
+
readonly state: "recovery-required";
|
|
5
|
+
readonly code: "KNOWN_FILE_OPERATION_ACTIVE" | "KNOWN_FILE_RECOVERY_REQUIRED";
|
|
6
|
+
readonly recoverableByInstalledBuild: boolean;
|
|
7
|
+
readonly message: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function inspectKnownFileTransactionBarrier(options: {
|
|
10
|
+
readonly consumerRoot: string;
|
|
11
|
+
}): Promise<KnownFileTransactionBarrierInspection>;
|
|
12
|
+
//# sourceMappingURL=node-known-file-transaction-inspection.d.ts.map
|
package/dist/repository-mutation/adapters/node/node-known-file-transaction-inspection.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-known-file-transaction-inspection.d.ts","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-known-file-transaction-inspection.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,qCAAqC,GAC7C;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC1B;IACE,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;IACpC,QAAQ,CAAC,IAAI,EACT,6BAA6B,GAC7B,8BAA8B,CAAC;IACnC,QAAQ,CAAC,2BAA2B,EAAE,OAAO,CAAC;IAC9C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;AAYN,wBAAsB,kCAAkC,CAAC,OAAO,EAAE;IAChE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B,GAAG,OAAO,CAAC,qCAAqC,CAAC,CA6BjD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { lstat } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { LOCAL_OPERATION_LOCK, LOCAL_STATE_DIRECTORY } from "../../../foundation-state-contract.js";
|
|
4
|
+
import { createNodeFoundationTransactionCoordinator } from "../../../transaction-coordination/adapters/node/node-foundation-transaction-coordinator.js";
|
|
5
|
+
import { canonicalKnownFileRoot, knownFileErrorCode } from "./node-known-file-transaction-filesystem.js";
|
|
6
|
+
async function operationLockExists(root) {
|
|
7
|
+
try {
|
|
8
|
+
await lstat(join(root, LOCAL_STATE_DIRECTORY, LOCAL_OPERATION_LOCK));
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
if (knownFileErrorCode(error) === "ENOENT") {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export async function inspectKnownFileTransactionBarrier(options) {
|
|
19
|
+
const root = await canonicalKnownFileRoot(options.consumerRoot);
|
|
20
|
+
const [hasOperationLock, status] = await Promise.all([
|
|
21
|
+
operationLockExists(root),
|
|
22
|
+
createNodeFoundationTransactionCoordinator(root).then((coordinator) => coordinator.inspect())
|
|
23
|
+
]);
|
|
24
|
+
if (status.state !== "idle") {
|
|
25
|
+
const recoverableByInstalledBuild = status.state === "pending" &&
|
|
26
|
+
status.operationKind === "known-file-transaction" &&
|
|
27
|
+
!status.diagnostics.some(({ code }) => code === "FOUNDATION_TRANSACTION_VERSION_MISMATCH");
|
|
28
|
+
return Object.freeze({
|
|
29
|
+
state: "recovery-required",
|
|
30
|
+
code: "KNOWN_FILE_RECOVERY_REQUIRED",
|
|
31
|
+
recoverableByInstalledBuild,
|
|
32
|
+
message: status.diagnostics[0]?.message ??
|
|
33
|
+
"Foundation transaction evidence must be recovered before consumer integration can continue."
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (hasOperationLock) {
|
|
37
|
+
return Object.freeze({
|
|
38
|
+
state: "recovery-required",
|
|
39
|
+
code: "KNOWN_FILE_OPERATION_ACTIVE",
|
|
40
|
+
recoverableByInstalledBuild: false,
|
|
41
|
+
message: "A Foundation operation is active or interrupted; retry after it completes or recover its evidence."
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return Object.freeze({ state: "idle" });
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=node-known-file-transaction-inspection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-known-file-transaction-inspection.js","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-known-file-transaction-inspection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,0CAA0C,EAAE,MAAM,4FAA4F,CAAC;AACxJ,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAazG,KAAK,UAAU,mBAAmB,CAAC,IAAY;IAC7C,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,qBAAqB,EAAE,oBAAoB,CAAC,CAAC,CAAC;QACrE,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAA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AAO,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { KnownFileTransactionEnvelopeV1 } from "../../application/model/known-file-transaction-journal.js";
|
|
2
|
+
import { captureFileHandleIdentity } from "./node-bounded-regular-file.js";
|
|
3
|
+
export interface KnownFileJournalAuthority {
|
|
4
|
+
readonly digest: `sha256:${string}`;
|
|
5
|
+
readonly identity: Awaited<ReturnType<typeof captureFileHandleIdentity>>;
|
|
6
|
+
}
|
|
7
|
+
declare function readEnvelope(path: string): Promise<{
|
|
8
|
+
readonly authority: KnownFileJournalAuthority;
|
|
9
|
+
readonly envelope: KnownFileTransactionEnvelopeV1;
|
|
10
|
+
} | undefined>;
|
|
11
|
+
export declare class NodeKnownFileTransactionJournalStore {
|
|
12
|
+
#private;
|
|
13
|
+
constructor(stateDirectory: string);
|
|
14
|
+
read(): Promise<Awaited<ReturnType<typeof readEnvelope>>>;
|
|
15
|
+
create(envelope: KnownFileTransactionEnvelopeV1): Promise<KnownFileJournalAuthority>;
|
|
16
|
+
replace(expected: KnownFileJournalAuthority, envelope: KnownFileTransactionEnvelopeV1): Promise<KnownFileJournalAuthority>;
|
|
17
|
+
remove(expected: KnownFileJournalAuthority): Promise<void>;
|
|
18
|
+
canonicalizeTemporary(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=node-known-file-transaction-journal-store.d.ts.map
|
package/dist/repository-mutation/adapters/node/node-known-file-transaction-journal-store.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-known-file-transaction-journal-store.d.ts","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-known-file-transaction-journal-store.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,2DAA2D,CAAC;AAEhH,OAAO,EACL,yBAAyB,EAG1B,MAAM,gCAAgC,CAAC;AAOxC,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,EAAE,UAAU,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC;CAC1E;AAwBD,iBAAe,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACjD,QAAQ,CAAC,SAAS,EAAE,yBAAyB,CAAC;IAC9C,QAAQ,CAAC,QAAQ,EAAE,8BAA8B,CAAC;CACnD,GAAG,SAAS,CAAC,CAsBb;AAUD,qBAAa,oCAAoC;;IAK/C,YAAmB,cAAc,EAAE,MAAM,EAIxC;IAEY,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAMrE;IA8BY,MAAM,CAAC,QAAQ,EAAE,8BAA8B,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAUhG;IAEY,OAAO,CAClB,QAAQ,EAAE,yBAAyB,EACnC,QAAQ,EAAE,8BAA8B,GACvC,OAAO,CAAC,yBAAyB,CAAC,CASpC;IAEY,MAAM,CAAC,QAAQ,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAItE;IAEY,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CA2ClD;CACF"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { open, rename, unlink } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { TextDecoder } from "node:util";
|
|
5
|
+
import { canonicalJson } from "../../../canonical-json.js";
|
|
6
|
+
import { FOUNDATION_TRANSACTION_FILE, KNOWN_FILE_TRANSACTION_TEMPORARY_FILE } from "../../../foundation-state-contract.js";
|
|
7
|
+
import { parseStrictJson } from "../../../strict-json.js";
|
|
8
|
+
import { assertKnownFileTransactionEnvelope } from "../../application/policies/known-file-transaction-envelope.js";
|
|
9
|
+
import { captureFileHandleIdentity, pathMatchesRegularFileIdentity, readBoundedRegularFile } from "./node-bounded-regular-file.js";
|
|
10
|
+
import { cleanupIdentityMatchingOwnedTemporary } from "./node-cleanup-owned-temporary.js";
|
|
11
|
+
import { syncDirectoryDurably, syncDirectoryStrictly } from "./node-directory-durability.js";
|
|
12
|
+
const MAXIMUM_JOURNAL_BYTES = 32 * 1024 * 1024;
|
|
13
|
+
const strictUtf8 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
14
|
+
function errorCode(error) {
|
|
15
|
+
return error instanceof Error && "code" in error
|
|
16
|
+
? error.code
|
|
17
|
+
: undefined;
|
|
18
|
+
}
|
|
19
|
+
function digest(content) {
|
|
20
|
+
return `sha256:${createHash("sha256").update(content).digest("hex")}`;
|
|
21
|
+
}
|
|
22
|
+
function bytes(envelope) {
|
|
23
|
+
assertKnownFileTransactionEnvelope(envelope);
|
|
24
|
+
const result = Buffer.from(`${canonicalJson(envelope)}\n`, "utf8");
|
|
25
|
+
if (result.byteLength > MAXIMUM_JOURNAL_BYTES) {
|
|
26
|
+
throw new Error("Known-file transaction journal exceeds its byte limit.");
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
async function readEnvelope(path) {
|
|
31
|
+
let observed;
|
|
32
|
+
try {
|
|
33
|
+
observed = await readBoundedRegularFile(path, MAXIMUM_JOURNAL_BYTES);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (errorCode(error) === "ENOENT") {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
if (observed.outcome !== "read") {
|
|
42
|
+
throw new Error("Known-file transaction journal is not one stable regular file.");
|
|
43
|
+
}
|
|
44
|
+
const parsed = parseStrictJson(strictUtf8.decode(observed.bytes));
|
|
45
|
+
assertKnownFileTransactionEnvelope(parsed);
|
|
46
|
+
if (!observed.bytes.equals(bytes(parsed))) {
|
|
47
|
+
throw new Error("Known-file transaction journal bytes are not canonical.");
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
envelope: parsed,
|
|
51
|
+
authority: { digest: digest(observed.bytes), identity: observed.identity }
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async function prove(path, authority) {
|
|
55
|
+
const observed = await readBoundedRegularFile(path, MAXIMUM_JOURNAL_BYTES);
|
|
56
|
+
if (observed.outcome !== "read" || digest(observed.bytes) !== authority.digest ||
|
|
57
|
+
await pathMatchesRegularFileIdentity(path, authority.identity) !== "match") {
|
|
58
|
+
throw new Error("Known-file transaction journal authority changed concurrently.");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export class NodeKnownFileTransactionJournalStore {
|
|
62
|
+
#journalPath;
|
|
63
|
+
#parent;
|
|
64
|
+
#temporaryPath;
|
|
65
|
+
constructor(stateDirectory) {
|
|
66
|
+
this.#parent = stateDirectory;
|
|
67
|
+
this.#journalPath = join(stateDirectory, FOUNDATION_TRANSACTION_FILE);
|
|
68
|
+
this.#temporaryPath = join(stateDirectory, KNOWN_FILE_TRANSACTION_TEMPORARY_FILE);
|
|
69
|
+
}
|
|
70
|
+
async read() {
|
|
71
|
+
const canonical = await readEnvelope(this.#journalPath);
|
|
72
|
+
if (canonical !== undefined) {
|
|
73
|
+
return canonical;
|
|
74
|
+
}
|
|
75
|
+
return readEnvelope(this.#temporaryPath);
|
|
76
|
+
}
|
|
77
|
+
async #writeTemporary(envelope) {
|
|
78
|
+
const content = bytes(envelope);
|
|
79
|
+
let handle;
|
|
80
|
+
try {
|
|
81
|
+
handle = await open(this.#temporaryPath, "wx", 0o600);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
if (errorCode(error) === "EEXIST") {
|
|
85
|
+
const stale = await readEnvelope(this.#temporaryPath);
|
|
86
|
+
if (stale === undefined) {
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
await prove(this.#temporaryPath, stale.authority);
|
|
90
|
+
await unlink(this.#temporaryPath);
|
|
91
|
+
await syncDirectoryStrictly(this.#parent);
|
|
92
|
+
handle = await open(this.#temporaryPath, "wx", 0o600);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
await handle.writeFile(content);
|
|
100
|
+
await handle.sync();
|
|
101
|
+
return { digest: digest(content), identity: await captureFileHandleIdentity(handle) };
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
await handle.close();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async create(envelope) {
|
|
108
|
+
if (await readEnvelope(this.#journalPath) !== undefined) {
|
|
109
|
+
throw new Error("Foundation transaction slot is already occupied.");
|
|
110
|
+
}
|
|
111
|
+
const authority = await this.#writeTemporary(envelope);
|
|
112
|
+
await prove(this.#temporaryPath, authority);
|
|
113
|
+
await rename(this.#temporaryPath, this.#journalPath);
|
|
114
|
+
await syncDirectoryStrictly(this.#parent);
|
|
115
|
+
await prove(this.#journalPath, authority);
|
|
116
|
+
return authority;
|
|
117
|
+
}
|
|
118
|
+
async replace(expected, envelope) {
|
|
119
|
+
await prove(this.#journalPath, expected);
|
|
120
|
+
const authority = await this.#writeTemporary(envelope);
|
|
121
|
+
await prove(this.#journalPath, expected);
|
|
122
|
+
await prove(this.#temporaryPath, authority);
|
|
123
|
+
await rename(this.#temporaryPath, this.#journalPath);
|
|
124
|
+
await syncDirectoryStrictly(this.#parent);
|
|
125
|
+
await prove(this.#journalPath, authority);
|
|
126
|
+
return authority;
|
|
127
|
+
}
|
|
128
|
+
async remove(expected) {
|
|
129
|
+
await prove(this.#journalPath, expected);
|
|
130
|
+
await unlink(this.#journalPath);
|
|
131
|
+
await syncDirectoryStrictly(this.#parent);
|
|
132
|
+
}
|
|
133
|
+
async canonicalizeTemporary() {
|
|
134
|
+
const canonical = await readEnvelope(this.#journalPath);
|
|
135
|
+
if (canonical !== undefined) {
|
|
136
|
+
// The canonical envelope remains authoritative during replacement. A
|
|
137
|
+
// crash can leave an unbound candidate torn or foreign; recovery must
|
|
138
|
+
// neither parse nor mutate that pathname. It remains preserved evidence
|
|
139
|
+
// and must not be parsed as authority. Capture a stable regular
|
|
140
|
+
// candidate by identity and retire it into terminal evidence so neither
|
|
141
|
+
// a torn write nor a concurrent pathname replacement can block replay.
|
|
142
|
+
let candidate;
|
|
143
|
+
try {
|
|
144
|
+
candidate = await readBoundedRegularFile(this.#temporaryPath, MAXIMUM_JOURNAL_BYTES);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
if (errorCode(error) === "ENOENT") {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
if (candidate.outcome !== "read") {
|
|
153
|
+
throw new Error("Known-file transaction candidate cannot be retired safely.");
|
|
154
|
+
}
|
|
155
|
+
const retired = await cleanupIdentityMatchingOwnedTemporary({
|
|
156
|
+
allowUnsupportedDirectoryDurability: false,
|
|
157
|
+
displayPath: KNOWN_FILE_TRANSACTION_TEMPORARY_FILE,
|
|
158
|
+
expectedIdentity: candidate.identity,
|
|
159
|
+
parent: this.#parent,
|
|
160
|
+
rm: async () => { },
|
|
161
|
+
syncDirectory: syncDirectoryDurably,
|
|
162
|
+
temporaryPath: this.#temporaryPath
|
|
163
|
+
});
|
|
164
|
+
if (retired === "different") {
|
|
165
|
+
throw new Error("Known-file transaction candidate changed during retirement.");
|
|
166
|
+
}
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const temporary = await readEnvelope(this.#temporaryPath);
|
|
170
|
+
if (temporary === undefined) {
|
|
171
|
+
throw new Error("Known-file recovery journal is absent.");
|
|
172
|
+
}
|
|
173
|
+
await prove(this.#temporaryPath, temporary.authority);
|
|
174
|
+
await rename(this.#temporaryPath, this.#journalPath);
|
|
175
|
+
await syncDirectoryStrictly(this.#parent);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=node-known-file-transaction-journal-store.js.map
|
package/dist/repository-mutation/adapters/node/node-known-file-transaction-journal-store.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-known-file-transaction-journal-store.js","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-known-file-transaction-journal-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAmB,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,aAAa,EAA2B,MAAM,4BAA4B,CAAC;AACpF,OAAO,EACL,2BAA2B,EAC3B,qCAAqC,EACtC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,kCAAkC,EAAE,MAAM,+DAA+D,CAAC;AACnH,OAAO,EACL,yBAAyB,EACzB,8BAA8B,EAC9B,sBAAsB,EACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,qCAAqC,EAAE,MAAM,mCAAmC,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAE7F,MAAM,qBAAqB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAC/C,MAAM,UAAU,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAO9E,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK;QAC9C,CAAC,CAAE,KAA+B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QAC5D,CAAC;QACD,MAAM,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QACtD,MAAM,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACrD,MAAM,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;CACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { KnownFileTransactionReceiptV1 } from "../../application/model/known-file-transaction.js";
|
|
2
|
+
import type { KnownFileTransactionJournalV1 } from "../../application/model/known-file-transaction-journal.js";
|
|
3
|
+
export declare function compileRolledBackReceipt(journal: KnownFileTransactionJournalV1): KnownFileTransactionReceiptV1;
|
|
4
|
+
//# sourceMappingURL=node-known-file-transaction-receipt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-known-file-transaction-receipt.d.ts","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-known-file-transaction-receipt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mDAAmD,CAAC;AACvG,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,2DAA2D,CAAC;AAG/G,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,6BAA6B,GACrC,6BAA6B,CA0C/B"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { sha256Json } from "../../../canonical-json.js";
|
|
2
|
+
import { KnownFileTransactionError } from "./node-known-file-transaction-filesystem.js";
|
|
3
|
+
export function compileRolledBackReceipt(journal) {
|
|
4
|
+
const operations = journal.operations.map((entry, index) => {
|
|
5
|
+
const planOperation = journal.plan.operations[index];
|
|
6
|
+
if (entry.state === "already-satisfied") {
|
|
7
|
+
return Object.freeze({
|
|
8
|
+
path: entry.path,
|
|
9
|
+
outcome: "already-satisfied",
|
|
10
|
+
resultDigest: planOperation.postimage.digest
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
if (planOperation.precondition.state === "absent") {
|
|
14
|
+
return Object.freeze({
|
|
15
|
+
path: entry.path,
|
|
16
|
+
outcome: "rolled-back-to-absent"
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
if (entry.matchedPreimage === undefined) {
|
|
20
|
+
throw new KnownFileTransactionError("KNOWN_FILE_JOURNAL_INVALID", `Replacement preimage binding is absent: ${entry.path}.`);
|
|
21
|
+
}
|
|
22
|
+
return Object.freeze({
|
|
23
|
+
path: entry.path,
|
|
24
|
+
outcome: "rolled-back-to-preimage",
|
|
25
|
+
resultDigest: planOperation.precondition.acceptedPreimages[entry.matchedPreimage].digest
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
const body = {
|
|
29
|
+
schemaVersion: 1,
|
|
30
|
+
protocol: "foundation.replace-known-file/v1",
|
|
31
|
+
planDigest: journal.plan.planDigest,
|
|
32
|
+
outcome: "rolled-back",
|
|
33
|
+
operations: Object.freeze(operations)
|
|
34
|
+
};
|
|
35
|
+
return Object.freeze({
|
|
36
|
+
...body,
|
|
37
|
+
receiptDigest: sha256Json({
|
|
38
|
+
domain: "agent-teams.foundation.known-file-transaction-receipt/v1",
|
|
39
|
+
body
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=node-known-file-transaction-receipt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-known-file-transaction-receipt.js","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-known-file-transaction-receipt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AAExF,MAAM,UAAU,wBAAwB,CACtC,OAAsC;IAEtC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,E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AClE,IAAI;SACL,CAAC;KACH,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { KnownFileTransactionReceiptV1 } from "../../application/model/known-file-transaction.js";
|
|
2
|
+
export type KnownFileRecoveryFaultInjector = (point: {
|
|
3
|
+
readonly phase: "after-committed-capture-unlinked" | "after-destination-retired" | "after-rollback-linked" | "after-rollback-capture-unlinked" | "after-retirement-directory-bound" | "after-retirement-captured" | "after-retirement-unlink-authorized";
|
|
4
|
+
readonly operationIndex: number;
|
|
5
|
+
readonly path: string;
|
|
6
|
+
}) => Promise<void> | void;
|
|
7
|
+
export declare function recoverKnownFileTransaction(options: {
|
|
8
|
+
readonly consumerRoot: string;
|
|
9
|
+
readonly faultInjector?: KnownFileRecoveryFaultInjector;
|
|
10
|
+
}): Promise<KnownFileTransactionReceiptV1>;
|
|
11
|
+
//# sourceMappingURL=node-known-file-transaction-recovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-known-file-transaction-recovery.d.ts","sourceRoot":"","sources":["../../../../src/repository-mutation/adapters/node/node-known-file-transaction-recovery.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAGV,6BAA6B,EAC9B,MAAM,mDAAmD,CAAC;AA8C3D,MAAM,MAAM,8BAA8B,GAAG,CAAC,KAAK,EAAE;IACnD,QAAQ,CAAC,KAAK,EACV,kCAAkC,GAClC,2BAA2B,GAC3B,uBAAuB,GACvB,iCAAiC,GACjC,kCAAkC,GAClC,2BAA2B,GAC3B,oCAAoC,CAAC;IACzC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAgqC3B,wBAAsB,2BAA2B,CAAC,OAAO,EAAE;IACzD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,8BAA8B,CAAC;CACzD,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAqEzC"}
|