@superbee/core 0.2.0-pre.8 → 0.4.10-pre.11
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/LICENSE +202 -0
- package/README.md +1345 -6
- package/dist/artifact-contract.d.ts +90 -0
- package/dist/artifact-contract.d.ts.map +1 -0
- package/dist/artifact-contract.js +205 -0
- package/dist/artifact-contract.js.map +1 -0
- package/dist/backend.d.ts +50 -2
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +311 -33
- package/dist/backend.js.map +1 -1
- package/dist/blob-contract.d.ts +82 -0
- package/dist/blob-contract.d.ts.map +1 -0
- package/dist/blob-contract.js +134 -0
- package/dist/blob-contract.js.map +1 -0
- package/dist/blob-journal.d.ts +303 -0
- package/dist/blob-journal.d.ts.map +1 -0
- package/dist/blob-journal.js +541 -0
- package/dist/blob-journal.js.map +1 -0
- package/dist/body-pages.d.ts +20 -0
- package/dist/body-pages.d.ts.map +1 -0
- package/dist/body-pages.js +56 -0
- package/dist/body-pages.js.map +1 -0
- package/dist/body-replace-guards.d.ts +81 -0
- package/dist/body-replace-guards.d.ts.map +1 -0
- package/dist/body-replace-guards.js +271 -0
- package/dist/body-replace-guards.js.map +1 -0
- package/dist/bounded-yaml.d.ts +28 -0
- package/dist/bounded-yaml.d.ts.map +1 -0
- package/dist/bounded-yaml.js +182 -0
- package/dist/bounded-yaml.js.map +1 -0
- package/dist/builtin-recipes/content.d.ts +93 -0
- package/dist/builtin-recipes/content.d.ts.map +1 -0
- package/dist/builtin-recipes/content.js +288 -0
- package/dist/builtin-recipes/content.js.map +1 -0
- package/dist/builtin-recipes/site.d.ts +5 -0
- package/dist/builtin-recipes/site.d.ts.map +1 -0
- package/dist/builtin-recipes/site.js +83 -0
- package/dist/builtin-recipes/site.js.map +1 -0
- package/dist/builtin-recipes.d.ts +13 -0
- package/dist/builtin-recipes.d.ts.map +1 -0
- package/dist/builtin-recipes.js +123 -0
- package/dist/builtin-recipes.js.map +1 -0
- package/dist/bundle-health/index.d.ts +14 -0
- package/dist/bundle-health/index.d.ts.map +1 -0
- package/dist/bundle-health/index.js +12 -0
- package/dist/bundle-health/index.js.map +1 -0
- package/dist/bundle-health/kind-findings.d.ts +45 -0
- package/dist/bundle-health/kind-findings.d.ts.map +1 -0
- package/dist/bundle-health/kind-findings.js +67 -0
- package/dist/bundle-health/kind-findings.js.map +1 -0
- package/dist/bundle-health/legacy-page.d.ts +21 -0
- package/dist/bundle-health/legacy-page.d.ts.map +1 -0
- package/dist/bundle-health/legacy-page.js +25 -0
- package/dist/bundle-health/legacy-page.js.map +1 -0
- package/dist/bundle-health/report.d.ts +191 -0
- package/dist/bundle-health/report.d.ts.map +1 -0
- package/dist/bundle-health/report.js +419 -0
- package/dist/bundle-health/report.js.map +1 -0
- package/dist/bundle-ops.d.ts +10 -4
- package/dist/bundle-ops.d.ts.map +1 -1
- package/dist/bundle-ops.js +15 -8
- package/dist/bundle-ops.js.map +1 -1
- package/dist/bundle.d.ts +2 -4
- package/dist/bundle.d.ts.map +1 -1
- package/dist/bundle.js +3 -12
- package/dist/bundle.js.map +1 -1
- package/dist/code-point-order.d.ts +8 -0
- package/dist/code-point-order.d.ts.map +1 -0
- package/dist/code-point-order.js +20 -0
- package/dist/code-point-order.js.map +1 -0
- package/dist/code-unit-order.d.ts +15 -0
- package/dist/code-unit-order.d.ts.map +1 -0
- package/dist/code-unit-order.js +17 -0
- package/dist/code-unit-order.js.map +1 -0
- package/dist/connector-request.d.ts +112 -0
- package/dist/connector-request.d.ts.map +1 -0
- package/dist/connector-request.js +495 -0
- package/dist/connector-request.js.map +1 -0
- package/dist/connectors.d.ts +297 -0
- package/dist/connectors.d.ts.map +1 -0
- package/dist/connectors.js +1233 -0
- package/dist/connectors.js.map +1 -0
- package/dist/convention-record.d.ts +9 -0
- package/dist/convention-record.d.ts.map +1 -0
- package/dist/convention-record.js +13 -0
- package/dist/convention-record.js.map +1 -0
- package/dist/cross-bundle.d.ts +135 -0
- package/dist/cross-bundle.d.ts.map +1 -0
- package/dist/cross-bundle.js +191 -0
- package/dist/cross-bundle.js.map +1 -0
- package/dist/dependencies.d.ts +208 -0
- package/dist/dependencies.d.ts.map +1 -0
- package/dist/dependencies.js +367 -0
- package/dist/dependencies.js.map +1 -0
- package/dist/document-codec.d.ts +4 -1
- package/dist/document-codec.d.ts.map +1 -1
- package/dist/document-codec.js +3 -1
- package/dist/document-codec.js.map +1 -1
- package/dist/document-field-actions.d.ts +34 -3
- package/dist/document-field-actions.d.ts.map +1 -1
- package/dist/document-field-actions.js +149 -43
- package/dist/document-field-actions.js.map +1 -1
- package/dist/document-mutation.d.ts +55 -18
- package/dist/document-mutation.d.ts.map +1 -1
- package/dist/document-mutation.js +210 -86
- package/dist/document-mutation.js.map +1 -1
- package/dist/document-persistence.d.ts +12 -0
- package/dist/document-persistence.d.ts.map +1 -0
- package/dist/document-persistence.js +44 -0
- package/dist/document-persistence.js.map +1 -0
- package/dist/document-replace-rules.d.ts +44 -0
- package/dist/document-replace-rules.d.ts.map +1 -0
- package/dist/document-replace-rules.js +41 -0
- package/dist/document-replace-rules.js.map +1 -0
- package/dist/document-scan.d.ts +26 -0
- package/dist/document-scan.d.ts.map +1 -0
- package/dist/document-scan.js +70 -0
- package/dist/document-scan.js.map +1 -0
- package/dist/document-transfer.d.ts +312 -0
- package/dist/document-transfer.d.ts.map +1 -0
- package/dist/document-transfer.js +1400 -0
- package/dist/document-transfer.js.map +1 -0
- package/dist/document-write-policy.d.ts +15 -4
- package/dist/document-write-policy.d.ts.map +1 -1
- package/dist/document-write-policy.js +41 -27
- package/dist/document-write-policy.js.map +1 -1
- package/dist/domain-model.d.ts +73 -0
- package/dist/domain-model.d.ts.map +1 -0
- package/dist/domain-model.js +169 -0
- package/dist/domain-model.js.map +1 -0
- package/dist/edge-harness/corpus.d.ts +9 -0
- package/dist/edge-harness/corpus.d.ts.map +1 -0
- package/dist/edge-harness/corpus.js +57 -0
- package/dist/edge-harness/corpus.js.map +1 -0
- package/dist/edge-harness/index.d.ts +21 -0
- package/dist/edge-harness/index.d.ts.map +1 -0
- package/dist/edge-harness/index.js +537 -0
- package/dist/edge-harness/index.js.map +1 -0
- package/dist/edges/find.d.ts +14 -0
- package/dist/edges/find.d.ts.map +1 -0
- package/dist/edges/find.js +46 -0
- package/dist/edges/find.js.map +1 -0
- package/dist/edges/index.d.ts +13 -0
- package/dist/edges/index.d.ts.map +1 -0
- package/dist/edges/index.js +5 -0
- package/dist/edges/index.js.map +1 -0
- package/dist/edges/memory-source.d.ts +8 -0
- package/dist/edges/memory-source.d.ts.map +1 -0
- package/dist/edges/memory-source.js +164 -0
- package/dist/edges/memory-source.js.map +1 -0
- package/dist/edges/read-bounds.d.ts +6 -0
- package/dist/edges/read-bounds.d.ts.map +1 -0
- package/dist/edges/read-bounds.js +13 -0
- package/dist/edges/read-bounds.js.map +1 -0
- package/dist/edges/source.d.ts +123 -0
- package/dist/edges/source.d.ts.map +1 -0
- package/dist/edges/source.js +2 -0
- package/dist/edges/source.js.map +1 -0
- package/dist/edges/walk.d.ts +7 -0
- package/dist/edges/walk.d.ts.map +1 -0
- package/dist/edges/walk.js +14 -0
- package/dist/edges/walk.js.map +1 -0
- package/dist/engine.d.ts +54 -18
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +137 -108
- package/dist/engine.js.map +1 -1
- package/dist/errors.d.ts +37 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +75 -3
- package/dist/errors.js.map +1 -1
- package/dist/file-journaled-backend-internal.d.ts +2 -0
- package/dist/file-journaled-backend-internal.d.ts.map +1 -1
- package/dist/file-journaled-backend-internal.js +2 -0
- package/dist/file-journaled-backend-internal.js.map +1 -1
- package/dist/file-journaled-backend.d.ts +38 -40
- package/dist/file-journaled-backend.d.ts.map +1 -1
- package/dist/file-journaled-backend.js +284 -52
- package/dist/file-journaled-backend.js.map +1 -1
- package/dist/filesystem-identity.d.ts +116 -17
- package/dist/filesystem-identity.d.ts.map +1 -1
- package/dist/filesystem-identity.js +532 -51
- package/dist/filesystem-identity.js.map +1 -1
- package/dist/filesystem-lock.d.ts +9 -2
- package/dist/filesystem-lock.d.ts.map +1 -1
- package/dist/filesystem-lock.js +134 -17
- package/dist/filesystem-lock.js.map +1 -1
- package/dist/filesystem-temp-name.d.ts +9 -0
- package/dist/filesystem-temp-name.d.ts.map +1 -0
- package/dist/filesystem-temp-name.js +20 -0
- package/dist/filesystem-temp-name.js.map +1 -0
- package/dist/filesystem.d.ts +6 -0
- package/dist/filesystem.d.ts.map +1 -1
- package/dist/filesystem.js +2 -1
- package/dist/filesystem.js.map +1 -1
- package/dist/freshness.d.ts +16 -1
- package/dist/freshness.d.ts.map +1 -1
- package/dist/freshness.js +47 -17
- package/dist/freshness.js.map +1 -1
- package/dist/frontmatter-contract.d.ts +14 -0
- package/dist/frontmatter-contract.d.ts.map +1 -1
- package/dist/frontmatter-contract.js +22 -0
- package/dist/frontmatter-contract.js.map +1 -1
- package/dist/frontmatter-splitter.d.ts +6 -0
- package/dist/frontmatter-splitter.d.ts.map +1 -1
- package/dist/frontmatter-splitter.js +8 -0
- package/dist/frontmatter-splitter.js.map +1 -1
- package/dist/frontmatter.d.ts +17 -7
- package/dist/frontmatter.d.ts.map +1 -1
- package/dist/frontmatter.js +52 -11
- package/dist/frontmatter.js.map +1 -1
- package/dist/governed-body-write.d.ts.map +1 -1
- package/dist/governed-body-write.js +13 -6
- package/dist/governed-body-write.js.map +1 -1
- package/dist/heads-digest.d.ts.map +1 -1
- package/dist/heads-digest.js +2 -1
- package/dist/heads-digest.js.map +1 -1
- package/dist/hosted-client/binding.d.ts +7 -0
- package/dist/hosted-client/binding.d.ts.map +1 -0
- package/dist/hosted-client/binding.js +10 -0
- package/dist/hosted-client/binding.js.map +1 -0
- package/dist/hosted-client/blob-delivery.d.ts +68 -0
- package/dist/hosted-client/blob-delivery.d.ts.map +1 -0
- package/dist/hosted-client/blob-delivery.js +170 -0
- package/dist/hosted-client/blob-delivery.js.map +1 -0
- package/dist/hosted-client/blob-write.d.ts +387 -0
- package/dist/hosted-client/blob-write.d.ts.map +1 -0
- package/dist/hosted-client/blob-write.js +770 -0
- package/dist/hosted-client/blob-write.js.map +1 -0
- package/dist/hosted-client/bundle-listing.d.ts +46 -0
- package/dist/hosted-client/bundle-listing.d.ts.map +1 -0
- package/dist/hosted-client/bundle-listing.js +36 -0
- package/dist/hosted-client/bundle-listing.js.map +1 -0
- package/dist/hosted-client/client.d.ts +249 -0
- package/dist/hosted-client/client.d.ts.map +1 -0
- package/dist/hosted-client/client.js +381 -0
- package/dist/hosted-client/client.js.map +1 -0
- package/dist/hosted-client/directory.d.ts +46 -0
- package/dist/hosted-client/directory.d.ts.map +1 -0
- package/dist/hosted-client/directory.js +74 -0
- package/dist/hosted-client/directory.js.map +1 -0
- package/dist/hosted-client/errors.d.ts +26 -0
- package/dist/hosted-client/errors.d.ts.map +1 -0
- package/dist/hosted-client/errors.js +35 -0
- package/dist/hosted-client/errors.js.map +1 -0
- package/dist/hosted-client/inbox.d.ts +320 -0
- package/dist/hosted-client/inbox.d.ts.map +1 -0
- package/dist/hosted-client/inbox.js +379 -0
- package/dist/hosted-client/inbox.js.map +1 -0
- package/dist/hosted-client/index.d.ts +31 -0
- package/dist/hosted-client/index.d.ts.map +1 -0
- package/dist/hosted-client/index.js +33 -0
- package/dist/hosted-client/index.js.map +1 -0
- package/dist/hosted-client/journal.d.ts +103 -0
- package/dist/hosted-client/journal.d.ts.map +1 -0
- package/dist/hosted-client/journal.js +464 -0
- package/dist/hosted-client/journal.js.map +1 -0
- package/dist/hosted-client/node.d.ts +74 -0
- package/dist/hosted-client/node.d.ts.map +1 -0
- package/dist/hosted-client/node.js +219 -0
- package/dist/hosted-client/node.js.map +1 -0
- package/dist/hosted-client/reference.d.ts +12 -0
- package/dist/hosted-client/reference.d.ts.map +1 -0
- package/dist/hosted-client/reference.js +29 -0
- package/dist/hosted-client/reference.js.map +1 -0
- package/dist/hosted-client/view-content.d.ts +184 -0
- package/dist/hosted-client/view-content.d.ts.map +1 -0
- package/dist/hosted-client/view-content.js +268 -0
- package/dist/hosted-client/view-content.js.map +1 -0
- package/dist/hosted-client/write.d.ts +219 -0
- package/dist/hosted-client/write.d.ts.map +1 -0
- package/dist/hosted-client/write.js +419 -0
- package/dist/hosted-client/write.js.map +1 -0
- package/dist/hosted-transport/answer-rows.d.ts +132 -4
- package/dist/hosted-transport/answer-rows.d.ts.map +1 -1
- package/dist/hosted-transport/answer-rows.js +211 -11
- package/dist/hosted-transport/answer-rows.js.map +1 -1
- package/dist/hosted-transport/attribution.d.ts +32 -0
- package/dist/hosted-transport/attribution.d.ts.map +1 -0
- package/dist/hosted-transport/attribution.js +38 -0
- package/dist/hosted-transport/attribution.js.map +1 -0
- package/dist/hosted-transport/blob-reads.d.ts +35 -0
- package/dist/hosted-transport/blob-reads.d.ts.map +1 -0
- package/dist/hosted-transport/blob-reads.js +179 -0
- package/dist/hosted-transport/blob-reads.js.map +1 -0
- package/dist/hosted-transport/blob-write.d.ts +34 -0
- package/dist/hosted-transport/blob-write.d.ts.map +1 -0
- package/dist/hosted-transport/blob-write.js +115 -0
- package/dist/hosted-transport/blob-write.js.map +1 -0
- package/dist/hosted-transport/carrier.d.ts +35 -11
- package/dist/hosted-transport/carrier.d.ts.map +1 -1
- package/dist/hosted-transport/carrier.js +101 -57
- package/dist/hosted-transport/carrier.js.map +1 -1
- package/dist/hosted-transport/document-backend.d.ts +74 -0
- package/dist/hosted-transport/document-backend.d.ts.map +1 -0
- package/dist/hosted-transport/document-backend.js +160 -0
- package/dist/hosted-transport/document-backend.js.map +1 -0
- package/dist/hosted-transport/index.d.ts +7 -4
- package/dist/hosted-transport/index.d.ts.map +1 -1
- package/dist/hosted-transport/index.js +7 -4
- package/dist/hosted-transport/index.js.map +1 -1
- package/dist/hosted-transport/operations.d.ts +6 -0
- package/dist/hosted-transport/operations.d.ts.map +1 -1
- package/dist/hosted-transport/operations.js +2 -1
- package/dist/hosted-transport/operations.js.map +1 -1
- package/dist/hosted-transport/port-run.d.ts +41 -0
- package/dist/hosted-transport/port-run.d.ts.map +1 -0
- package/dist/hosted-transport/port-run.js +92 -0
- package/dist/hosted-transport/port-run.js.map +1 -0
- package/dist/hosted-transport/read-adapter.d.ts +19 -3
- package/dist/hosted-transport/read-adapter.d.ts.map +1 -1
- package/dist/hosted-transport/read-adapter.js +18 -5
- package/dist/hosted-transport/read-adapter.js.map +1 -1
- package/dist/hosted-transport/root-write.d.ts.map +1 -1
- package/dist/hosted-transport/root-write.js +5 -2
- package/dist/hosted-transport/root-write.js.map +1 -1
- package/dist/hosted-transport/whole-document-transport.d.ts +56 -7
- package/dist/hosted-transport/whole-document-transport.d.ts.map +1 -1
- package/dist/hosted-transport/whole-document-transport.js +120 -31
- package/dist/hosted-transport/whole-document-transport.js.map +1 -1
- package/dist/identity-fold.d.ts +16 -0
- package/dist/identity-fold.d.ts.map +1 -0
- package/dist/identity-fold.js +24 -0
- package/dist/identity-fold.js.map +1 -0
- package/dist/index-projection.d.ts +2 -1
- package/dist/index-projection.d.ts.map +1 -1
- package/dist/index-projection.js +38 -28
- package/dist/index-projection.js.map +1 -1
- package/dist/index.d.ts +61 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +50 -21
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-backend.d.ts +0 -31
- package/dist/indexeddb-backend.d.ts.map +1 -1
- package/dist/indexeddb-backend.js +5 -2
- package/dist/indexeddb-backend.js.map +1 -1
- package/dist/inventory-guard.d.ts +58 -0
- package/dist/inventory-guard.d.ts.map +1 -0
- package/dist/inventory-guard.js +169 -0
- package/dist/inventory-guard.js.map +1 -0
- package/dist/journaled-backend.d.ts +14 -4
- package/dist/journaled-backend.d.ts.map +1 -1
- package/dist/journaled-backend.js +19 -78
- package/dist/journaled-backend.js.map +1 -1
- package/dist/json-data.d.ts +3 -0
- package/dist/json-data.d.ts.map +1 -0
- package/dist/json-data.js +19 -0
- package/dist/json-data.js.map +1 -0
- package/dist/kind-authoring.d.ts +188 -0
- package/dist/kind-authoring.d.ts.map +1 -0
- package/dist/kind-authoring.js +520 -0
- package/dist/kind-authoring.js.map +1 -0
- package/dist/kind-changes.d.ts +45 -0
- package/dist/kind-changes.d.ts.map +1 -0
- package/dist/kind-changes.js +96 -0
- package/dist/kind-changes.js.map +1 -0
- package/dist/kind-conformance-error.d.ts +16 -0
- package/dist/kind-conformance-error.d.ts.map +1 -0
- package/dist/kind-conformance-error.js +20 -0
- package/dist/kind-conformance-error.js.map +1 -0
- package/dist/kind-coverage.d.ts +100 -0
- package/dist/kind-coverage.d.ts.map +1 -0
- package/dist/kind-coverage.js +185 -0
- package/dist/kind-coverage.js.map +1 -0
- package/dist/kind-deprecation.d.ts +32 -0
- package/dist/kind-deprecation.d.ts.map +1 -0
- package/dist/kind-deprecation.js +141 -0
- package/dist/kind-deprecation.js.map +1 -0
- package/dist/kind-field-mutation.d.ts +7 -2
- package/dist/kind-field-mutation.d.ts.map +1 -1
- package/dist/kind-field-mutation.js +28 -3
- package/dist/kind-field-mutation.js.map +1 -1
- package/dist/kind-undeclared-fields.d.ts +72 -0
- package/dist/kind-undeclared-fields.d.ts.map +1 -0
- package/dist/kind-undeclared-fields.js +124 -0
- package/dist/kind-undeclared-fields.js.map +1 -0
- package/dist/kinds-load.d.ts.map +1 -1
- package/dist/kinds-load.js +8 -5
- package/dist/kinds-load.js.map +1 -1
- package/dist/kinds.d.ts +105 -13
- package/dist/kinds.d.ts.map +1 -1
- package/dist/kinds.js +369 -30
- package/dist/kinds.js.map +1 -1
- package/dist/link-add.d.ts +81 -0
- package/dist/link-add.d.ts.map +1 -0
- package/dist/link-add.js +94 -0
- package/dist/link-add.js.map +1 -0
- package/dist/link-emit.d.ts +29 -0
- package/dist/link-emit.d.ts.map +1 -0
- package/dist/link-emit.js +39 -0
- package/dist/link-emit.js.map +1 -0
- package/dist/link-findings.d.ts +132 -0
- package/dist/link-findings.d.ts.map +1 -0
- package/dist/link-findings.js +263 -0
- package/dist/link-findings.js.map +1 -0
- package/dist/link-types.d.ts +34 -0
- package/dist/link-types.d.ts.map +1 -0
- package/dist/link-types.js +79 -0
- package/dist/link-types.js.map +1 -0
- package/dist/links.d.ts +68 -9
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +370 -57
- package/dist/links.js.map +1 -1
- package/dist/local-search-index.d.ts +86 -0
- package/dist/local-search-index.d.ts.map +1 -0
- package/dist/local-search-index.js +1055 -0
- package/dist/local-search-index.js.map +1 -0
- package/dist/managed-document-metadata.d.ts +5 -0
- package/dist/managed-document-metadata.d.ts.map +1 -0
- package/dist/managed-document-metadata.js +10 -0
- package/dist/managed-document-metadata.js.map +1 -0
- package/dist/markdown-syntax.d.ts +39 -0
- package/dist/markdown-syntax.d.ts.map +1 -0
- package/dist/markdown-syntax.js +10170 -0
- package/dist/markdown-syntax.js.map +1 -0
- package/dist/memory-backend.d.ts +3 -0
- package/dist/memory-backend.d.ts.map +1 -1
- package/dist/memory-backend.js +40 -2
- package/dist/memory-backend.js.map +1 -1
- package/dist/mutation-attribution.d.ts +2 -1
- package/dist/mutation-attribution.d.ts.map +1 -1
- package/dist/mutation-attribution.js.map +1 -1
- package/dist/okf-actor.d.ts +14 -3
- package/dist/okf-actor.d.ts.map +1 -1
- package/dist/okf-actor.js +25 -4
- package/dist/okf-actor.js.map +1 -1
- package/dist/okf-authored-values.d.ts +2 -0
- package/dist/okf-authored-values.d.ts.map +1 -1
- package/dist/okf-authored-values.js +4 -0
- package/dist/okf-authored-values.js.map +1 -1
- package/dist/okf-authoring.d.ts +7 -0
- package/dist/okf-authoring.d.ts.map +1 -0
- package/dist/okf-authoring.js +30 -0
- package/dist/okf-authoring.js.map +1 -0
- package/dist/okf-standard-fields.d.ts +4 -0
- package/dist/okf-standard-fields.d.ts.map +1 -1
- package/dist/okf-standard-fields.js +24 -14
- package/dist/okf-standard-fields.js.map +1 -1
- package/dist/okf-timestamps.d.ts +2 -2
- package/dist/okf-timestamps.d.ts.map +1 -1
- package/dist/okf-timestamps.js +25 -15
- package/dist/okf-timestamps.js.map +1 -1
- package/dist/page.d.ts +3 -7
- package/dist/page.d.ts.map +1 -1
- package/dist/page.js +3 -7
- package/dist/page.js.map +1 -1
- package/dist/path-fold.d.ts +67 -0
- package/dist/path-fold.d.ts.map +1 -0
- package/dist/path-fold.js +107 -0
- package/dist/path-fold.js.map +1 -0
- package/dist/paths.d.ts +46 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +114 -1
- package/dist/paths.js.map +1 -1
- package/dist/platform.d.ts +13 -0
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +16 -0
- package/dist/platform.js.map +1 -1
- package/dist/portable-export-contract.d.ts +17 -0
- package/dist/portable-export-contract.d.ts.map +1 -0
- package/dist/portable-export-contract.js +59 -0
- package/dist/portable-export-contract.js.map +1 -0
- package/dist/portable-export.d.ts +115 -0
- package/dist/portable-export.d.ts.map +1 -0
- package/dist/portable-export.js +452 -0
- package/dist/portable-export.js.map +1 -0
- package/dist/portable-frontmatter.d.ts +17 -0
- package/dist/portable-frontmatter.d.ts.map +1 -1
- package/dist/portable-frontmatter.js +42 -5
- package/dist/portable-frontmatter.js.map +1 -1
- package/dist/publication-filesystem.d.ts +1 -1
- package/dist/publication-filesystem.d.ts.map +1 -1
- package/dist/publication-filesystem.js +1 -1
- package/dist/publication-filesystem.js.map +1 -1
- package/dist/qualified-links.d.ts +67 -0
- package/dist/qualified-links.d.ts.map +1 -0
- package/dist/qualified-links.js +121 -0
- package/dist/qualified-links.js.map +1 -0
- package/dist/query-filter.d.ts +16 -4
- package/dist/query-filter.d.ts.map +1 -1
- package/dist/query-filter.js +44 -2
- package/dist/query-filter.js.map +1 -1
- package/dist/query-order.d.ts.map +1 -1
- package/dist/query-order.js +2 -1
- package/dist/query-order.js.map +1 -1
- package/dist/recipe-lifecycle/errors.d.ts +96 -0
- package/dist/recipe-lifecycle/errors.d.ts.map +1 -0
- package/dist/recipe-lifecycle/errors.js +122 -0
- package/dist/recipe-lifecycle/errors.js.map +1 -0
- package/dist/recipe-lifecycle/evolution.d.ts +134 -0
- package/dist/recipe-lifecycle/evolution.d.ts.map +1 -0
- package/dist/recipe-lifecycle/evolution.js +1047 -0
- package/dist/recipe-lifecycle/evolution.js.map +1 -0
- package/dist/recipe-lifecycle/index.d.ts +38 -0
- package/dist/recipe-lifecycle/index.d.ts.map +1 -0
- package/dist/recipe-lifecycle/index.js +31 -0
- package/dist/recipe-lifecycle/index.js.map +1 -0
- package/dist/recipe-lifecycle/install.d.ts +172 -0
- package/dist/recipe-lifecycle/install.d.ts.map +1 -0
- package/dist/recipe-lifecycle/install.js +652 -0
- package/dist/recipe-lifecycle/install.js.map +1 -0
- package/dist/recipe-lifecycle/legacy-aliases.d.ts +4 -0
- package/dist/recipe-lifecycle/legacy-aliases.d.ts.map +1 -0
- package/dist/recipe-lifecycle/legacy-aliases.js +22 -0
- package/dist/recipe-lifecycle/legacy-aliases.js.map +1 -0
- package/dist/recipe-lifecycle/retirement-apply.d.ts +59 -0
- package/dist/recipe-lifecycle/retirement-apply.d.ts.map +1 -0
- package/dist/recipe-lifecycle/retirement-apply.js +165 -0
- package/dist/recipe-lifecycle/retirement-apply.js.map +1 -0
- package/dist/recipe-lifecycle/retirement.d.ts +89 -0
- package/dist/recipe-lifecycle/retirement.d.ts.map +1 -0
- package/dist/recipe-lifecycle/retirement.js +347 -0
- package/dist/recipe-lifecycle/retirement.js.map +1 -0
- package/dist/recipe-lifecycle/set-commit.d.ts +31 -0
- package/dist/recipe-lifecycle/set-commit.d.ts.map +1 -0
- package/dist/recipe-lifecycle/set-commit.js +37 -0
- package/dist/recipe-lifecycle/set-commit.js.map +1 -0
- package/dist/recipe-lifecycle/stamp.d.ts +146 -0
- package/dist/recipe-lifecycle/stamp.d.ts.map +1 -0
- package/dist/recipe-lifecycle/stamp.js +361 -0
- package/dist/recipe-lifecycle/stamp.js.map +1 -0
- package/dist/recipe-qualify.d.ts +80 -0
- package/dist/recipe-qualify.d.ts.map +1 -0
- package/dist/recipe-qualify.js +352 -0
- package/dist/recipe-qualify.js.map +1 -0
- package/dist/recipe-set-preflight.d.ts +139 -0
- package/dist/recipe-set-preflight.d.ts.map +1 -0
- package/dist/recipe-set-preflight.js +536 -0
- package/dist/recipe-set-preflight.js.map +1 -0
- package/dist/recipe-sources.d.ts +209 -0
- package/dist/recipe-sources.d.ts.map +1 -0
- package/dist/recipe-sources.js +607 -0
- package/dist/recipe-sources.js.map +1 -0
- package/dist/recipes.d.ts +45 -1
- package/dist/recipes.d.ts.map +1 -1
- package/dist/recipes.js +138 -1
- package/dist/recipes.js.map +1 -1
- package/dist/record-overlay/apply.d.ts +43 -0
- package/dist/record-overlay/apply.d.ts.map +1 -0
- package/dist/record-overlay/apply.js +523 -0
- package/dist/record-overlay/apply.js.map +1 -0
- package/dist/record-overlay/canonical.d.ts +22 -0
- package/dist/record-overlay/canonical.d.ts.map +1 -0
- package/dist/record-overlay/canonical.js +47 -0
- package/dist/record-overlay/canonical.js.map +1 -0
- package/dist/record-overlay/digest.d.ts +4 -0
- package/dist/record-overlay/digest.d.ts.map +1 -0
- package/dist/record-overlay/digest.js +11 -0
- package/dist/record-overlay/digest.js.map +1 -0
- package/dist/record-overlay/errors.d.ts +44 -0
- package/dist/record-overlay/errors.d.ts.map +1 -0
- package/dist/record-overlay/errors.js +55 -0
- package/dist/record-overlay/errors.js.map +1 -0
- package/dist/record-overlay/findings.d.ts +5 -0
- package/dist/record-overlay/findings.d.ts.map +1 -0
- package/dist/record-overlay/findings.js +86 -0
- package/dist/record-overlay/findings.js.map +1 -0
- package/dist/record-overlay/index.d.ts +23 -0
- package/dist/record-overlay/index.d.ts.map +1 -0
- package/dist/record-overlay/index.js +21 -0
- package/dist/record-overlay/index.js.map +1 -0
- package/dist/record-overlay/plan.d.ts +12 -0
- package/dist/record-overlay/plan.d.ts.map +1 -0
- package/dist/record-overlay/plan.js +285 -0
- package/dist/record-overlay/plan.js.map +1 -0
- package/dist/record-overlay/policy.d.ts +74 -0
- package/dist/record-overlay/policy.d.ts.map +1 -0
- package/dist/record-overlay/policy.js +235 -0
- package/dist/record-overlay/policy.js.map +1 -0
- package/dist/record-overlay/redact.d.ts +3 -0
- package/dist/record-overlay/redact.d.ts.map +1 -0
- package/dist/record-overlay/redact.js +27 -0
- package/dist/record-overlay/redact.js.map +1 -0
- package/dist/record-overlay/signal-kind.d.ts +30 -0
- package/dist/record-overlay/signal-kind.d.ts.map +1 -0
- package/dist/record-overlay/signal-kind.js +38 -0
- package/dist/record-overlay/signal-kind.js.map +1 -0
- package/dist/record-overlay/signal-text.d.ts +52 -0
- package/dist/record-overlay/signal-text.d.ts.map +1 -0
- package/dist/record-overlay/signal-text.js +126 -0
- package/dist/record-overlay/signal-text.js.map +1 -0
- package/dist/record-overlay/source-index.d.ts +19 -0
- package/dist/record-overlay/source-index.d.ts.map +1 -0
- package/dist/record-overlay/source-index.js +102 -0
- package/dist/record-overlay/source-index.js.map +1 -0
- package/dist/record-overlay/types.d.ts +291 -0
- package/dist/record-overlay/types.d.ts.map +1 -0
- package/dist/record-overlay/types.js +2 -0
- package/dist/record-overlay/types.js.map +1 -0
- package/dist/relationships.d.ts +71 -0
- package/dist/relationships.d.ts.map +1 -0
- package/dist/relationships.js +87 -0
- package/dist/relationships.js.map +1 -0
- package/dist/remote-backend.d.ts +11 -21
- package/dist/remote-backend.d.ts.map +1 -1
- package/dist/remote-backend.js +20 -15
- package/dist/remote-backend.js.map +1 -1
- package/dist/remote-document-codec.d.ts +2 -1
- package/dist/remote-document-codec.d.ts.map +1 -1
- package/dist/remote-document-codec.js +3 -2
- package/dist/remote-document-codec.js.map +1 -1
- package/dist/remote-operations.d.ts +0 -41
- package/dist/remote-operations.d.ts.map +1 -1
- package/dist/remote-operations.js +14 -2
- package/dist/remote-operations.js.map +1 -1
- package/dist/remote-parsers.d.ts +19 -0
- package/dist/remote-parsers.d.ts.map +1 -1
- package/dist/remote-parsers.js.map +1 -1
- package/dist/remote.d.ts +2 -4
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +2 -3
- package/dist/remote.js.map +1 -1
- package/dist/reserved-write.d.ts +9 -0
- package/dist/reserved-write.d.ts.map +1 -0
- package/dist/reserved-write.js +15 -0
- package/dist/reserved-write.js.map +1 -0
- package/dist/search/backend-source.d.ts +6 -0
- package/dist/search/backend-source.d.ts.map +1 -0
- package/dist/search/backend-source.js +57 -0
- package/dist/search/backend-source.js.map +1 -0
- package/dist/search/contract.d.ts +162 -0
- package/dist/search/contract.d.ts.map +1 -0
- package/dist/search/contract.js +82 -0
- package/dist/search/contract.js.map +1 -0
- package/dist/search/errors.d.ts +30 -0
- package/dist/search/errors.d.ts.map +1 -0
- package/dist/search/errors.js +50 -0
- package/dist/search/errors.js.map +1 -0
- package/dist/search/identity.d.ts +12 -0
- package/dist/search/identity.d.ts.map +1 -0
- package/dist/search/identity.js +90 -0
- package/dist/search/identity.js.map +1 -0
- package/dist/search/index.d.ts +16 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +15 -0
- package/dist/search/index.js.map +1 -0
- package/dist/search/memory-source.d.ts +36 -0
- package/dist/search/memory-source.d.ts.map +1 -0
- package/dist/search/memory-source.js +238 -0
- package/dist/search/memory-source.js.map +1 -0
- package/dist/search/rank.d.ts +29 -0
- package/dist/search/rank.d.ts.map +1 -0
- package/dist/search/rank.js +132 -0
- package/dist/search/rank.js.map +1 -0
- package/dist/search/row-text.d.ts +38 -0
- package/dist/search/row-text.d.ts.map +1 -0
- package/dist/search/row-text.js +88 -0
- package/dist/search/row-text.js.map +1 -0
- package/dist/search/search.d.ts +28 -0
- package/dist/search/search.d.ts.map +1 -0
- package/dist/search/search.js +265 -0
- package/dist/search/search.js.map +1 -0
- package/dist/search/source.d.ts +70 -0
- package/dist/search/source.d.ts.map +1 -0
- package/dist/search/source.js +2 -0
- package/dist/search/source.js.map +1 -0
- package/dist/search/text.d.ts +49 -0
- package/dist/search/text.d.ts.map +1 -0
- package/dist/search/text.js +165 -0
- package/dist/search/text.js.map +1 -0
- package/dist/search-index.d.ts +9 -0
- package/dist/search-index.d.ts.map +1 -0
- package/dist/search-index.js +9 -0
- package/dist/search-index.js.map +1 -0
- package/dist/sha256.d.ts.map +1 -1
- package/dist/sha256.js +3 -2
- package/dist/sha256.js.map +1 -1
- package/dist/site-capabilities.d.ts +345 -0
- package/dist/site-capabilities.d.ts.map +1 -0
- package/dist/site-capabilities.js +724 -0
- package/dist/site-capabilities.js.map +1 -0
- package/dist/site-manifest.d.ts +51 -0
- package/dist/site-manifest.d.ts.map +1 -0
- package/dist/site-manifest.js +115 -0
- package/dist/site-manifest.js.map +1 -0
- package/dist/skip-reasons.d.ts +12 -0
- package/dist/skip-reasons.d.ts.map +1 -0
- package/dist/skip-reasons.js +15 -0
- package/dist/skip-reasons.js.map +1 -0
- package/dist/source-engine/driver.d.ts +40 -0
- package/dist/source-engine/driver.d.ts.map +1 -0
- package/dist/source-engine/driver.js +513 -0
- package/dist/source-engine/driver.js.map +1 -0
- package/dist/source-engine/evidence.d.ts +39 -0
- package/dist/source-engine/evidence.d.ts.map +1 -0
- package/dist/source-engine/evidence.js +54 -0
- package/dist/source-engine/evidence.js.map +1 -0
- package/dist/source-engine/guard.d.ts +87 -0
- package/dist/source-engine/guard.d.ts.map +1 -0
- package/dist/source-engine/guard.js +427 -0
- package/dist/source-engine/guard.js.map +1 -0
- package/dist/source-engine/index.d.ts +35 -0
- package/dist/source-engine/index.d.ts.map +1 -0
- package/dist/source-engine/index.js +27 -0
- package/dist/source-engine/index.js.map +1 -0
- package/dist/source-engine/machine-state.d.ts +87 -0
- package/dist/source-engine/machine-state.d.ts.map +1 -0
- package/dist/source-engine/machine-state.js +94 -0
- package/dist/source-engine/machine-state.js.map +1 -0
- package/dist/source-engine/observe.d.ts +10 -0
- package/dist/source-engine/observe.d.ts.map +1 -0
- package/dist/source-engine/observe.js +276 -0
- package/dist/source-engine/observe.js.map +1 -0
- package/dist/source-engine/overlay.d.ts +50 -0
- package/dist/source-engine/overlay.d.ts.map +1 -0
- package/dist/source-engine/overlay.js +114 -0
- package/dist/source-engine/overlay.js.map +1 -0
- package/dist/source-engine/robots.d.ts +53 -0
- package/dist/source-engine/robots.d.ts.map +1 -0
- package/dist/source-engine/robots.js +158 -0
- package/dist/source-engine/robots.js.map +1 -0
- package/dist/source-engine/snapshot.d.ts +104 -0
- package/dist/source-engine/snapshot.d.ts.map +1 -0
- package/dist/source-engine/snapshot.js +240 -0
- package/dist/source-engine/snapshot.js.map +1 -0
- package/dist/source-engine/target-consumer.d.ts +12 -0
- package/dist/source-engine/target-consumer.d.ts.map +1 -0
- package/dist/source-engine/target-consumer.js +15 -0
- package/dist/source-engine/target-consumer.js.map +1 -0
- package/dist/source-engine/target-descriptor.d.ts +3 -0
- package/dist/source-engine/target-descriptor.d.ts.map +1 -0
- package/dist/source-engine/target-descriptor.js +26 -0
- package/dist/source-engine/target-descriptor.js.map +1 -0
- package/dist/source-engine/target.d.ts +82 -0
- package/dist/source-engine/target.d.ts.map +1 -0
- package/dist/source-engine/target.js +213 -0
- package/dist/source-engine/target.js.map +1 -0
- package/dist/source-engine/types.d.ts +296 -0
- package/dist/source-engine/types.d.ts.map +1 -0
- package/dist/source-engine/types.js +2 -0
- package/dist/source-engine/types.js.map +1 -0
- package/dist/source-harness/conformance.d.ts +16 -0
- package/dist/source-harness/conformance.d.ts.map +1 -0
- package/dist/source-harness/conformance.js +266 -0
- package/dist/source-harness/conformance.js.map +1 -0
- package/dist/source-harness/fixture.d.ts +97 -0
- package/dist/source-harness/fixture.d.ts.map +1 -0
- package/dist/source-harness/fixture.js +276 -0
- package/dist/source-harness/fixture.js.map +1 -0
- package/dist/source-harness/index.d.ts +22 -0
- package/dist/source-harness/index.d.ts.map +1 -0
- package/dist/source-harness/index.js +19 -0
- package/dist/source-harness/index.js.map +1 -0
- package/dist/source-harness/peer.d.ts +74 -0
- package/dist/source-harness/peer.d.ts.map +1 -0
- package/dist/source-harness/peer.js +106 -0
- package/dist/source-harness/peer.js.map +1 -0
- package/dist/source-profiles/index.d.ts +31 -0
- package/dist/source-profiles/index.d.ts.map +1 -0
- package/dist/source-profiles/index.js +206 -0
- package/dist/source-profiles/index.js.map +1 -0
- package/dist/source-profiles/link-header.d.ts +6 -0
- package/dist/source-profiles/link-header.d.ts.map +1 -0
- package/dist/source-profiles/link-header.js +131 -0
- package/dist/source-profiles/link-header.js.map +1 -0
- package/dist/storage-harness/contract.d.ts +109 -0
- package/dist/storage-harness/contract.d.ts.map +1 -0
- package/dist/storage-harness/contract.js +853 -0
- package/dist/storage-harness/contract.js.map +1 -0
- package/dist/storage-harness/index.d.ts +39 -0
- package/dist/storage-harness/index.d.ts.map +1 -0
- package/dist/storage-harness/index.js +55 -0
- package/dist/storage-harness/index.js.map +1 -0
- package/dist/storage.d.ts +10 -2
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +10 -2
- package/dist/storage.js.map +1 -1
- package/dist/string-identity-agreement.d.ts +35 -0
- package/dist/string-identity-agreement.d.ts.map +1 -0
- package/dist/string-identity-agreement.js +78 -0
- package/dist/string-identity-agreement.js.map +1 -0
- package/dist/system-documents.d.ts +82 -0
- package/dist/system-documents.d.ts.map +1 -0
- package/dist/system-documents.js +127 -0
- package/dist/system-documents.js.map +1 -0
- package/dist/types.d.ts +45 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -10
- package/dist/types.js.map +1 -1
- package/dist/uncertain-write.d.ts +119 -6
- package/dist/uncertain-write.d.ts.map +1 -1
- package/dist/uncertain-write.js +67 -32
- package/dist/uncertain-write.js.map +1 -1
- package/dist/validation.d.ts +5 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/verification.d.ts +22 -10
- package/dist/verification.d.ts.map +1 -1
- package/dist/verification.js +87 -39
- package/dist/verification.js.map +1 -1
- package/dist/view-launch-contract.d.ts +14 -0
- package/dist/view-launch-contract.d.ts.map +1 -0
- package/dist/view-launch-contract.js +23 -0
- package/dist/view-launch-contract.js.map +1 -0
- package/dist/write-identity.d.ts +5 -0
- package/dist/write-identity.d.ts.map +1 -0
- package/dist/write-identity.js +9 -0
- package/dist/write-identity.js.map +1 -0
- package/package.json +188 -10
|
@@ -15,6 +15,15 @@
|
|
|
15
15
|
* entirely between two probes of one observation can be traversed by the operating system
|
|
16
16
|
* during a listing or open, but its bytes can never be returned as EXACT, because the leaf
|
|
17
17
|
* witness at the post-walk must match the entry the requested path reaches.
|
|
18
|
+
* - A bulk read runs its observations inside one {@link ObservationPass}: the same protocol per
|
|
19
|
+
* path, but a directory's listing is taken once and reused while the directory's change
|
|
20
|
+
* witness proves its entry set unchanged, and every EXACT verdict that used a reused listing has
|
|
21
|
+
* its post-walk repeated at the end of the pass without trusting timestamps. Listing the parent
|
|
22
|
+
* per observation would make a pass over a directory of N documents read O(N²) directory
|
|
23
|
+
* entries. The speedup assumes local disks, whose directory times advance on every entry change;
|
|
24
|
+
* on Linux any other filesystem type lists per use, and elsewhere a mount whose times can lie
|
|
25
|
+
* (network or FUSE attribute caches, settable Windows directory times) is covered by the
|
|
26
|
+
* end-of-pass re-verification, short of an inode number reused within the pass.
|
|
18
27
|
* - Mutations hold one cross-process lock keyed by a pure fold of the root and `rel`, decide
|
|
19
28
|
* inside it, create directories one segment at a time with a spelling check, and publish a
|
|
20
29
|
* first-created leaf with `link` so the host's own equivalence refuses a second spelling the
|
|
@@ -44,10 +53,15 @@
|
|
|
44
53
|
*/
|
|
45
54
|
import { promises as fs } from "node:fs";
|
|
46
55
|
import path from "node:path";
|
|
47
|
-
import { createHash
|
|
56
|
+
import { createHash } from "node:crypto";
|
|
57
|
+
import { execFile } from "node:child_process";
|
|
58
|
+
import { promisify } from "node:util";
|
|
48
59
|
import { ConcurrentReplacementError, FilesystemIdentityAliasError, InvalidInputError } from "./errors.js";
|
|
49
|
-
import { acquireFilesystemIdentityLock } from "./filesystem-lock.js";
|
|
60
|
+
import { acquireFilesystemIdentityLock, filesystemMutationLockRoot, filesystemRelationshipCache } from "./filesystem-lock.js";
|
|
50
61
|
import { captureFilesystemHostPolicy } from "./filesystem-host.js";
|
|
62
|
+
import { foldSegment } from "./identity-fold.js";
|
|
63
|
+
import { identityTempName } from "./filesystem-temp-name.js";
|
|
64
|
+
export { foldSegment };
|
|
51
65
|
/**
|
|
52
66
|
* A host can transiently deny replacement while another process is closing a read handle or a
|
|
53
67
|
* scanner holds the destination. An in-place rename retry cannot remain bound to the complete
|
|
@@ -116,18 +130,6 @@ function relSegments(rel) {
|
|
|
116
130
|
return segments;
|
|
117
131
|
}
|
|
118
132
|
// ── identity key ──────────────────────────────────────────────────────────────
|
|
119
|
-
/**
|
|
120
|
-
* NFKD, then Unicode FULL case folding applied as lower-upper-lower (locale-independent). A plain
|
|
121
|
-
* lower-case fold misses the pairs a case-insensitive host equates through full case mapping
|
|
122
|
-
* (ß/ss, ẞ/SS, final sigma ς/σ, iota-subscript ᾈ/ἀι and its family): two such spellings would get
|
|
123
|
-
* different keys, both first-creation writers would realize ABSENT, and the second rename would
|
|
124
|
-
* silently replace the first document. The round trip through upper case expands every such
|
|
125
|
-
* pair to a common form, so the fold is a superset of every supported host's equivalence;
|
|
126
|
-
* over-folding (dotless ı with i) only adds serialization, never removes exclusion.
|
|
127
|
-
*/
|
|
128
|
-
export function foldSegment(segment) {
|
|
129
|
-
return segment.normalize("NFKD").toLowerCase().toUpperCase().toLowerCase();
|
|
130
|
-
}
|
|
131
133
|
/** The physical path of the longest existing ancestor of `resolved`, plus the absent remainder. */
|
|
132
134
|
async function existingAnchor(resolved) {
|
|
133
135
|
const tail = [];
|
|
@@ -154,12 +156,74 @@ async function existingAnchor(resolved) {
|
|
|
154
156
|
* and identical for every case or normalization spelling of any segment. It depends on nothing
|
|
155
157
|
* else: not the environment, the clock, the process, or the host name.
|
|
156
158
|
*/
|
|
157
|
-
|
|
158
|
-
const foldedRel = relSegments(rel).map(foldSegment).join("/");
|
|
159
|
+
async function foldedPhysicalRoot(root) {
|
|
159
160
|
const { anchor, tail } = await existingAnchor(path.resolve(root));
|
|
160
161
|
const anchorSegments = anchor.split(path.sep).filter((segment, index) => index === 0 || segment !== "");
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
return [...anchorSegments, ...tail].map(foldRootSegment).join("/");
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The bundle root's own segments fold with compatibility decomposition, which is wider than
|
|
166
|
+
* {@link foldSegment}. Every released build derives the root key this way, and processes on
|
|
167
|
+
* different builds exclude each other only while they derive the same root key. A wider root
|
|
168
|
+
* fold can only make two differently spelled roots share one lock.
|
|
169
|
+
*/
|
|
170
|
+
function foldRootSegment(segment) {
|
|
171
|
+
return segment.normalize("NFKD").toLowerCase().toUpperCase().toLowerCase();
|
|
172
|
+
}
|
|
173
|
+
export async function identityKey(root, rel) {
|
|
174
|
+
const foldedRel = relSegments(rel).map(foldSegment).join("/");
|
|
175
|
+
return createHash("sha256").update(`superbee-identity/v1\0${await foldedPhysicalRoot(root)}\0${foldedRel}`).digest("hex");
|
|
176
|
+
}
|
|
177
|
+
/** Same root key before/after directory creation; physical replacement is a separate witness. */
|
|
178
|
+
export async function filesystemRootMutationKey(root) {
|
|
179
|
+
return createHash("sha256").update(`superbee-root-mutation/v1\0${await foldedPhysicalRoot(root)}`).digest("hex");
|
|
180
|
+
}
|
|
181
|
+
/** Existing physical-root/ancestor witnesses supplement the stable coordination pathname. */
|
|
182
|
+
export async function filesystemRootWitness(port, root) {
|
|
183
|
+
const physical = await fs.realpath(root);
|
|
184
|
+
const witnesses = [];
|
|
185
|
+
let current = physical;
|
|
186
|
+
for (;;) {
|
|
187
|
+
const witness = await port.probe(current);
|
|
188
|
+
if (!witness || witness.kind !== "directory")
|
|
189
|
+
throw new InvalidInputError("Inventory guard root identity is unavailable.");
|
|
190
|
+
witnesses.push([current, witness.dev, witness.ino]);
|
|
191
|
+
const parent = path.dirname(current);
|
|
192
|
+
if (parent === current)
|
|
193
|
+
break;
|
|
194
|
+
current = parent;
|
|
195
|
+
}
|
|
196
|
+
return createHash("sha256").update(JSON.stringify(witnesses)).digest("hex");
|
|
197
|
+
}
|
|
198
|
+
const rootMutationQueues = new Map();
|
|
199
|
+
/** Internal per-backend root coordinator; never re-exported by a public entrypoint. */
|
|
200
|
+
export function createFilesystemMutationCoordinator(_port, root, hostPolicy) {
|
|
201
|
+
const policy = captureFilesystemHostPolicy(hostPolicy);
|
|
202
|
+
let lockRoot;
|
|
203
|
+
const namespace = () => lockRoot ??= filesystemMutationLockRoot(root, policy);
|
|
204
|
+
return Object.freeze({
|
|
205
|
+
namespace,
|
|
206
|
+
async run(body) {
|
|
207
|
+
const key = await filesystemRootMutationKey(root);
|
|
208
|
+
const lockRoot = namespace();
|
|
209
|
+
const queueKey = `${lockRoot}:${key}`;
|
|
210
|
+
const previous = rootMutationQueues.get(queueKey) ?? Promise.resolve();
|
|
211
|
+
const run = previous.then(async () => {
|
|
212
|
+
const release = await acquireFilesystemIdentityLock(key, root, { portableRoot: root, lockRoot, hostPolicy: policy });
|
|
213
|
+
try {
|
|
214
|
+
return await body();
|
|
215
|
+
}
|
|
216
|
+
finally {
|
|
217
|
+
await release();
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
const settled = run.then(() => { }, () => { });
|
|
221
|
+
rootMutationQueues.set(queueKey, settled);
|
|
222
|
+
void settled.then(() => { if (rootMutationQueues.get(queueKey) === settled)
|
|
223
|
+
rootMutationQueues.delete(queueKey); });
|
|
224
|
+
return run;
|
|
225
|
+
},
|
|
226
|
+
});
|
|
163
227
|
}
|
|
164
228
|
// ── pure decisions ────────────────────────────────────────────────────────────
|
|
165
229
|
function sameWitness(a, b) {
|
|
@@ -218,6 +282,39 @@ async function probeSegment(port, candidate, rel, segment) {
|
|
|
218
282
|
function hasExact(listing, segment) {
|
|
219
283
|
return listing.some((entry) => entry.name === segment);
|
|
220
284
|
}
|
|
285
|
+
/** The one listed spelling other than `segment` that folds to it, for the refusal message only. */
|
|
286
|
+
function existingSpelling(names, segment) {
|
|
287
|
+
const folded = foldSegment(segment);
|
|
288
|
+
const matches = [...names].filter((name) => name !== segment && foldSegment(name) === folded);
|
|
289
|
+
return matches.length === 1 ? matches[0] : undefined;
|
|
290
|
+
}
|
|
291
|
+
/** "folder" or "file" for the entry an alias spelling reaches; position decides when its kind is unknown. */
|
|
292
|
+
function entryNoun(kind, leaf) {
|
|
293
|
+
if (kind === undefined)
|
|
294
|
+
return leaf ? "file" : "folder";
|
|
295
|
+
return kind === "directory" ? "folder" : "file";
|
|
296
|
+
}
|
|
297
|
+
function aliasRefusal(rel, segments, index, names, kind) {
|
|
298
|
+
const segment = segments[index];
|
|
299
|
+
return new FilesystemIdentityAliasError(rel, segment, existingSpelling(names, segment), entryNoun(kind, index === segments.length - 1), index);
|
|
300
|
+
}
|
|
301
|
+
/** {@link aliasRefusal} from a listing with kinds: the folded match's own kind names it. */
|
|
302
|
+
function aliasRefusalFromListing(rel, index, listing, leaf) {
|
|
303
|
+
const segment = relSegments(rel)[index];
|
|
304
|
+
const existing = existingSpelling(listing.map((entry) => entry.name), segment);
|
|
305
|
+
const kind = existing === undefined ? undefined : listing.find((entry) => entry.name === existing)?.kind;
|
|
306
|
+
return new FilesystemIdentityAliasError(rel, segment, existing, entryNoun(kind, leaf), index);
|
|
307
|
+
}
|
|
308
|
+
function listingView(names) {
|
|
309
|
+
return { has: (name) => names.has(name), names: () => names };
|
|
310
|
+
}
|
|
311
|
+
/** One fresh `entries` call per use: the single-read protocol. */
|
|
312
|
+
function freshListings(port) {
|
|
313
|
+
return async (dir) => {
|
|
314
|
+
const listing = await port.entries(dir);
|
|
315
|
+
return listing === null ? null : { has: (name) => hasExact(listing, name), names: () => listing.map((entry) => entry.name) };
|
|
316
|
+
};
|
|
317
|
+
}
|
|
221
318
|
/**
|
|
222
319
|
* M-REALIZE: per segment, root to leaf, it must exist and the parent listing must carry its exact
|
|
223
320
|
* spelling. A listing-only alias decision is sound here because the identity lock is held: no
|
|
@@ -235,7 +332,7 @@ async function walkExact(port, rootResolved, segments, rel) {
|
|
|
235
332
|
if (listing === null)
|
|
236
333
|
return { state: "absent", depth: index };
|
|
237
334
|
if (!hasExact(listing, segment))
|
|
238
|
-
throw
|
|
335
|
+
throw aliasRefusal(rel, segments, index, listing.map((entry) => entry.name), probed.kind);
|
|
239
336
|
if (index === segments.length - 1)
|
|
240
337
|
return { state: "exact", leaf: probed };
|
|
241
338
|
if (probed.kind !== "directory")
|
|
@@ -246,7 +343,12 @@ async function walkExact(port, rootResolved, segments, rel) {
|
|
|
246
343
|
}
|
|
247
344
|
// ── observation ───────────────────────────────────────────────────────────────
|
|
248
345
|
const MAX_RESTARTS = 3;
|
|
249
|
-
/**
|
|
346
|
+
/**
|
|
347
|
+
* O-PROBE: walk `rel` root to leaf recording each segment's witness. `complete` is false when a
|
|
348
|
+
* segment is absent or a non-leaf segment is not a directory; `recorded` then holds every segment
|
|
349
|
+
* that exists (the non-directory included), which the caller still confirms so an alias spelling of an existing
|
|
350
|
+
* directory prefix is refused rather than reported as absent.
|
|
351
|
+
*/
|
|
250
352
|
async function recordWalk(port, rootResolved, segments, rel) {
|
|
251
353
|
const recorded = [];
|
|
252
354
|
let parent = rootResolved;
|
|
@@ -255,13 +357,13 @@ async function recordWalk(port, rootResolved, segments, rel) {
|
|
|
255
357
|
const candidate = path.join(parent, segment);
|
|
256
358
|
const probed = await probeSegment(port, candidate, rel, segment);
|
|
257
359
|
if (probed === null)
|
|
258
|
-
return
|
|
259
|
-
if (index < segments.length - 1 && probed.kind !== "directory")
|
|
260
|
-
return null;
|
|
360
|
+
return { recorded, complete: false };
|
|
261
361
|
recorded.push(probed);
|
|
362
|
+
if (index < segments.length - 1 && probed.kind !== "directory")
|
|
363
|
+
return { recorded, complete: false };
|
|
262
364
|
parent = candidate;
|
|
263
365
|
}
|
|
264
|
-
return recorded;
|
|
366
|
+
return { recorded, complete: true };
|
|
265
367
|
}
|
|
266
368
|
/**
|
|
267
369
|
* One listing walk under the confirmed-witness rule. Every DIRECTORY segment is probed and
|
|
@@ -276,25 +378,27 @@ async function recordWalk(port, rootResolved, segments, rel) {
|
|
|
276
378
|
* (`handle` given) applies that leaf table against the handle's inode, probing the leaf
|
|
277
379
|
* unconditionally.
|
|
278
380
|
*/
|
|
279
|
-
async function confirmedWalk(port, rootResolved, segments, rel, recorded, handle) {
|
|
381
|
+
async function confirmedWalk(port, rootResolved, segments, rel, recorded, handle, listings = freshListings(port), stopAt = segments.length) {
|
|
280
382
|
let parent = rootResolved;
|
|
281
|
-
for (let index = 0; index <
|
|
383
|
+
for (let index = 0; index < stopAt; index++) {
|
|
282
384
|
const segment = segments[index];
|
|
283
385
|
const candidate = path.join(parent, segment);
|
|
284
|
-
const listing = await
|
|
386
|
+
const listing = await listings(parent);
|
|
285
387
|
if (listing === null)
|
|
286
388
|
return "absent";
|
|
287
|
-
const listed =
|
|
389
|
+
const listed = listing.has(segment);
|
|
288
390
|
if (handle !== null && index === segments.length - 1) {
|
|
289
|
-
const
|
|
391
|
+
const probe = await probeSegment(port, candidate, rel, segment);
|
|
392
|
+
const verdict = classifyLeaf({ listed, probe, handle });
|
|
290
393
|
if (verdict === "aliased")
|
|
291
|
-
throw
|
|
394
|
+
throw aliasRefusal(rel, segments, index, listing.names(), probe?.kind);
|
|
292
395
|
return verdict === "replaced" ? "restart" : verdict;
|
|
293
396
|
}
|
|
294
397
|
if (index < segments.length - 1 || !listed) {
|
|
295
|
-
const
|
|
398
|
+
const probe = await probeSegment(port, candidate, rel, segment);
|
|
399
|
+
const verdict = confirmAlias(listed, probe, recorded[index]);
|
|
296
400
|
if (verdict === "aliased")
|
|
297
|
-
throw
|
|
401
|
+
throw aliasRefusal(rel, segments, index, listing.names(), probe?.kind);
|
|
298
402
|
if (verdict !== "continue")
|
|
299
403
|
return verdict;
|
|
300
404
|
}
|
|
@@ -302,6 +406,39 @@ async function confirmedWalk(port, rootResolved, segments, rel, recorded, handle
|
|
|
302
406
|
}
|
|
303
407
|
return "continue";
|
|
304
408
|
}
|
|
409
|
+
/**
|
|
410
|
+
* An incomplete O-PROBE is ABSENT only once the segments that did exist are confirmed under their
|
|
411
|
+
* exact spelling. Without this, `Concepts/new.md` beside an existing `concepts/` would read as
|
|
412
|
+
* absent while every mutation of it refuses the alias, so a caller that treats absence as
|
|
413
|
+
* "may be created later" would promise a write that can never succeed.
|
|
414
|
+
*
|
|
415
|
+
* Parent listings come from a per-port witnessed cache, so batches of absent probes do not list a
|
|
416
|
+
* large directory once each. Only ABSENT may rest on a reused listing: a refusal or restart reached
|
|
417
|
+
* through one is re-decided with fresh listings. Where a directory witness can lie (network
|
|
418
|
+
* attribute caches, settable Windows directory times), an absent verdict can therefore miss a
|
|
419
|
+
* directory renamed to another case within the cache's life; writes still refuse it.
|
|
420
|
+
*/
|
|
421
|
+
async function confirmPrefix(port, rootResolved, segments, rel, recorded) {
|
|
422
|
+
if (recorded.length === 0)
|
|
423
|
+
return "absent";
|
|
424
|
+
let kept = prefixListings.get(port);
|
|
425
|
+
if (kept === undefined)
|
|
426
|
+
prefixListings.set(port, (kept = new Map()));
|
|
427
|
+
const cached = witnessedListings(port, kept, Date.now, PREFIX_LISTING_CAPACITY);
|
|
428
|
+
let verdict;
|
|
429
|
+
try {
|
|
430
|
+
verdict = await confirmedWalk(port, rootResolved, segments, rel, recorded, null, cached.source, recorded.length);
|
|
431
|
+
}
|
|
432
|
+
catch (error) {
|
|
433
|
+
if (!cached.reused())
|
|
434
|
+
throw error;
|
|
435
|
+
kept.clear();
|
|
436
|
+
verdict = await confirmedWalk(port, rootResolved, segments, rel, recorded, null, freshListings(port), recorded.length);
|
|
437
|
+
}
|
|
438
|
+
if (verdict === "restart" && cached.reused())
|
|
439
|
+
kept.clear();
|
|
440
|
+
return verdict === "restart" ? "restart" : "absent";
|
|
441
|
+
}
|
|
305
442
|
function countRestart(restarts, rel) {
|
|
306
443
|
if (restarts >= MAX_RESTARTS)
|
|
307
444
|
throw new ConcurrentReplacementError(rel, restarts + 1);
|
|
@@ -315,14 +452,23 @@ function countRestart(restarts, rel) {
|
|
|
315
452
|
* from O-PROBE, bounded; the handle is closed before any restart opens another.
|
|
316
453
|
*/
|
|
317
454
|
export async function observeExact(port, root, rel, read) {
|
|
455
|
+
return observeWith(port, path.resolve(root), rel, read, freshListings(port));
|
|
456
|
+
}
|
|
457
|
+
/** The observation protocol of {@link observeExact}, with the parent listings drawn from `listings`. */
|
|
458
|
+
async function observeWith(port, rootResolved, rel, read, listings, onExact) {
|
|
318
459
|
const segments = relSegments(rel);
|
|
319
|
-
const rootResolved = path.resolve(root);
|
|
320
460
|
const target = path.join(rootResolved, ...segments);
|
|
321
461
|
for (let restarts = 0;;) {
|
|
322
|
-
const
|
|
323
|
-
if (
|
|
324
|
-
|
|
325
|
-
|
|
462
|
+
const walk = await recordWalk(port, rootResolved, segments, rel);
|
|
463
|
+
if (!walk.complete) {
|
|
464
|
+
const prefix = await confirmPrefix(port, rootResolved, segments, rel, walk.recorded);
|
|
465
|
+
if (prefix === "absent")
|
|
466
|
+
return { state: "absent" };
|
|
467
|
+
restarts = countRestart(restarts, rel);
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
const recorded = walk.recorded;
|
|
471
|
+
const verified = await confirmedWalk(port, rootResolved, segments, rel, recorded, null, listings);
|
|
326
472
|
if (verified === "absent")
|
|
327
473
|
return { state: "absent" };
|
|
328
474
|
if (verified === "restart") {
|
|
@@ -350,13 +496,15 @@ export async function observeExact(port, root, rel, read) {
|
|
|
350
496
|
value = await read(opened.handle, target);
|
|
351
497
|
if (value === null)
|
|
352
498
|
return { state: "absent" };
|
|
353
|
-
verdict = await confirmedWalk(port, rootResolved, segments, rel, recorded, opened);
|
|
499
|
+
verdict = await confirmedWalk(port, rootResolved, segments, rel, recorded, opened, listings);
|
|
354
500
|
}
|
|
355
501
|
finally {
|
|
356
502
|
await port.close(opened.handle);
|
|
357
503
|
}
|
|
358
|
-
if (verdict === "exact")
|
|
504
|
+
if (verdict === "exact") {
|
|
505
|
+
onExact?.(recorded, { dev: opened.dev, ino: opened.ino });
|
|
359
506
|
return { state: "exact", value };
|
|
507
|
+
}
|
|
360
508
|
if (verdict === "absent")
|
|
361
509
|
return { state: "absent" };
|
|
362
510
|
restarts = countRestart(restarts, rel);
|
|
@@ -370,9 +518,15 @@ export async function probeExact(port, root, rel) {
|
|
|
370
518
|
const segments = relSegments(rel);
|
|
371
519
|
const rootResolved = path.resolve(root);
|
|
372
520
|
for (let restarts = 0;;) {
|
|
373
|
-
const
|
|
374
|
-
if (
|
|
375
|
-
|
|
521
|
+
const walk = await recordWalk(port, rootResolved, segments, rel);
|
|
522
|
+
if (!walk.complete) {
|
|
523
|
+
const prefix = await confirmPrefix(port, rootResolved, segments, rel, walk.recorded);
|
|
524
|
+
if (prefix === "absent")
|
|
525
|
+
return { state: "absent" };
|
|
526
|
+
restarts = countRestart(restarts, rel);
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
const recorded = walk.recorded;
|
|
376
530
|
const leaf = recorded[recorded.length - 1];
|
|
377
531
|
const verified = await confirmedWalk(port, rootResolved, segments, rel, recorded, null);
|
|
378
532
|
const verdict = verified === "continue" ? await confirmedWalk(port, rootResolved, segments, rel, recorded, leaf) : verified;
|
|
@@ -383,6 +537,183 @@ export async function probeExact(port, root, rel) {
|
|
|
383
537
|
restarts = countRestart(restarts, rel);
|
|
384
538
|
}
|
|
385
539
|
}
|
|
540
|
+
// ── observation pass ──────────────────────────────────────────────────────────
|
|
541
|
+
/**
|
|
542
|
+
* How long a directory's modification and status-change times must have been still before a
|
|
543
|
+
* listing of it may be reused. A change that lands in the same timestamp tick as the directory's
|
|
544
|
+
* previous change leaves both times unchanged, so a witness is only a change detector once the
|
|
545
|
+
* clock has moved past that tick. Three seconds covers the coarsest supported granularity (FAT's
|
|
546
|
+
* two-second mtime) plus margin; finer clocks (APFS, ext4, NTFS) are covered with room to spare.
|
|
547
|
+
* A time in the future (clock skew) is never settled.
|
|
548
|
+
*/
|
|
549
|
+
const SETTLED_AFTER_NS = 3000000000n;
|
|
550
|
+
/**
|
|
551
|
+
* Whether a directory witness can detect change at all. Some volumes report times that never
|
|
552
|
+
* move: macOS gives an exFAT volume's root directory mtime and ctime 0 forever. A time at or
|
|
553
|
+
* before the epoch is never a real modification of a bundle directory, so such a witness is
|
|
554
|
+
* treated as absent and its listing is neither kept nor reused.
|
|
555
|
+
*/
|
|
556
|
+
export function witnessCanDetectChange(witness) {
|
|
557
|
+
return witness.mtimeNs > 0n && witness.ctimeNs > 0n;
|
|
558
|
+
}
|
|
559
|
+
function witnessKey(witness) {
|
|
560
|
+
return `${witness.dev}:${witness.ino}:${witness.mtimeNs}:${witness.ctimeNs}`;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* A listing source that keeps each directory's listing while its settled change witness is
|
|
564
|
+
* unchanged (see {@link openObservationPass} for why a settled witness is a change detector on
|
|
565
|
+
* local disks). `reused()` says whether any listing it returned came from `kept`. A port without
|
|
566
|
+
* directory witnesses lists afresh on every use.
|
|
567
|
+
*/
|
|
568
|
+
function witnessedListings(port, kept, now, capacity = Infinity) {
|
|
569
|
+
let reused = false;
|
|
570
|
+
const portWitness = port.directoryWitness?.bind(port);
|
|
571
|
+
if (portWitness === undefined)
|
|
572
|
+
return { source: freshListings(port), reused: () => false };
|
|
573
|
+
const witnessOf = async (dir) => {
|
|
574
|
+
const witness = await portWitness(dir);
|
|
575
|
+
return witness !== null && witnessCanDetectChange(witness) ? witness : null;
|
|
576
|
+
};
|
|
577
|
+
const settled = (witness) => {
|
|
578
|
+
const nowNs = BigInt(Math.floor(now())) * 1000000n;
|
|
579
|
+
const latest = witness.mtimeNs > witness.ctimeNs ? witness.mtimeNs : witness.ctimeNs;
|
|
580
|
+
return nowNs - latest >= SETTLED_AFTER_NS;
|
|
581
|
+
};
|
|
582
|
+
const source = async (dir) => {
|
|
583
|
+
const keep = kept.get(dir);
|
|
584
|
+
if (keep !== undefined) {
|
|
585
|
+
const current = await witnessOf(dir);
|
|
586
|
+
if (current !== null && witnessKey(current) === keep.witness) {
|
|
587
|
+
reused = true;
|
|
588
|
+
return listingView(keep.names);
|
|
589
|
+
}
|
|
590
|
+
kept.delete(dir);
|
|
591
|
+
}
|
|
592
|
+
const before = await witnessOf(dir);
|
|
593
|
+
const listing = await port.entries(dir);
|
|
594
|
+
if (listing === null)
|
|
595
|
+
return null;
|
|
596
|
+
const names = new Set(listing.map((entry) => entry.name));
|
|
597
|
+
const after = await witnessOf(dir);
|
|
598
|
+
if (before !== null && after !== null && witnessKey(before) === witnessKey(after) && settled(after)) {
|
|
599
|
+
kept.delete(dir);
|
|
600
|
+
kept.set(dir, { witness: witnessKey(after), names });
|
|
601
|
+
while (kept.size > capacity)
|
|
602
|
+
kept.delete(kept.keys().next().value);
|
|
603
|
+
}
|
|
604
|
+
return listingView(names);
|
|
605
|
+
};
|
|
606
|
+
return { source, reused: () => reused };
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Prefix-confirmation listings kept per port, so a run of absent probes under one directory (a
|
|
610
|
+
* batch of `exists` calls) lists each parent once rather than once per probe. Bounded; entries
|
|
611
|
+
* are only ever reused under an unchanged settled witness.
|
|
612
|
+
*/
|
|
613
|
+
const prefixListings = new WeakMap();
|
|
614
|
+
const PREFIX_LISTING_CAPACITY = 64;
|
|
615
|
+
/**
|
|
616
|
+
* Open an {@link ObservationPass} over `(port, root)`.
|
|
617
|
+
*
|
|
618
|
+
* Every observation runs the exact single-read protocol of {@link observeExact} — recorded walk,
|
|
619
|
+
* confirmed pre-walk, open, read, confirmed post-walk with the handle still open, bounded
|
|
620
|
+
* restarts — and differs only in where a walk's parent listing comes from. The first time a
|
|
621
|
+
* directory is needed the pass takes `witness, entries, witness`; when the two witnesses agree and
|
|
622
|
+
* the directory's times have settled, that listing is kept. Each later use re-takes the witness
|
|
623
|
+
* (one `stat`, constant cost) and reuses the kept listing only if the witness is unchanged;
|
|
624
|
+
* otherwise it lists afresh exactly as a single read would.
|
|
625
|
+
*
|
|
626
|
+
* Two independent arguments make a reused listing safe:
|
|
627
|
+
*
|
|
628
|
+
* 1. Timestamps (the fast path is right in the moment). Where a directory's times advance on every
|
|
629
|
+
* entry change — local APFS, HFS+, ext4, XFS, btrfs, NTFS, FAT — an unchanged settled witness
|
|
630
|
+
* means the entry set is the kept listing at the moment of use, so every verdict is the one a
|
|
631
|
+
* single read reaches against the same state.
|
|
632
|
+
* 2. Re-verification (no timestamps trusted). Where the witness can lie — attribute caches on
|
|
633
|
+
* network and FUSE mounts, settable directory times on Windows, a clock stepped backwards — an
|
|
634
|
+
* observation that used a reused listing may be wrong in the moment, so its verdict is not
|
|
635
|
+
* trusted: a refusal or absence reached through a reused listing is re-taken at once by
|
|
636
|
+
* {@link observeExact}, and `finish` repeats the post-walk of every EXACT verdict that used one
|
|
637
|
+
* against fresh listings (one per directory) and fresh probes. Each segment must still be
|
|
638
|
+
* listed under its exact spelling and reach the inode recorded for it, the leaf the inode the
|
|
639
|
+
* bytes were read from; anything else is returned for a fresh single read. Since published
|
|
640
|
+
* bytes are immutable per inode, a verdict that passes is a state of this identity at `finish`.
|
|
641
|
+
* What this cannot see is the read file being deleted and its inode NUMBER reused by a new file
|
|
642
|
+
* under the same spelling within the pass, because the handle is closed by then.
|
|
643
|
+
*
|
|
644
|
+
* On Linux, a mount whose filesystem type is not a known local one (NFS, SMB, FUSE, 9p, ...) gets
|
|
645
|
+
* no directory witness at all, so it lists exactly as single reads do.
|
|
646
|
+
*/
|
|
647
|
+
export function openObservationPass(port, root, now = Date.now) {
|
|
648
|
+
const rootResolved = path.resolve(root);
|
|
649
|
+
const kept = new Map();
|
|
650
|
+
const reusedVerdicts = [];
|
|
651
|
+
/** Listings for one observation; `reused()` says whether any came from the kept set. */
|
|
652
|
+
const listingsFor = () => witnessedListings(port, kept, now);
|
|
653
|
+
return {
|
|
654
|
+
async observe(rel, read) {
|
|
655
|
+
const listings = listingsFor();
|
|
656
|
+
let exact;
|
|
657
|
+
let observed;
|
|
658
|
+
try {
|
|
659
|
+
observed = await observeWith(port, rootResolved, rel, read, listings.source, (recorded, handle) => {
|
|
660
|
+
exact = { rel, segments: relSegments(rel), recorded, handle };
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
catch (error) {
|
|
664
|
+
if (!listings.reused())
|
|
665
|
+
throw error;
|
|
666
|
+
return observeExact(port, rootResolved, rel, read);
|
|
667
|
+
}
|
|
668
|
+
if (!listings.reused())
|
|
669
|
+
return observed;
|
|
670
|
+
if (observed.state === "absent")
|
|
671
|
+
return observeExact(port, rootResolved, rel, read);
|
|
672
|
+
if (exact !== undefined)
|
|
673
|
+
reusedVerdicts.push(exact);
|
|
674
|
+
return observed;
|
|
675
|
+
},
|
|
676
|
+
async finish() {
|
|
677
|
+
const retry = new Set();
|
|
678
|
+
const endListings = new Map();
|
|
679
|
+
const listedAtEnd = async (dir) => {
|
|
680
|
+
if (!endListings.has(dir)) {
|
|
681
|
+
const listing = await port.entries(dir);
|
|
682
|
+
endListings.set(dir, listing === null ? null : new Set(listing.map((entry) => entry.name)));
|
|
683
|
+
}
|
|
684
|
+
return endListings.get(dir);
|
|
685
|
+
};
|
|
686
|
+
try {
|
|
687
|
+
for (const verdict of reusedVerdicts) {
|
|
688
|
+
if (!(await holdsAtEnd(port, rootResolved, verdict, listedAtEnd)))
|
|
689
|
+
retry.add(verdict.rel);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
finally {
|
|
693
|
+
kept.clear();
|
|
694
|
+
reusedVerdicts.length = 0;
|
|
695
|
+
}
|
|
696
|
+
return [...retry];
|
|
697
|
+
},
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
/** The post-walk of one EXACT verdict, repeated against end-of-pass listings and fresh probes. */
|
|
701
|
+
async function holdsAtEnd(port, rootResolved, verdict, listedAtEnd) {
|
|
702
|
+
let parent = rootResolved;
|
|
703
|
+
for (let index = 0; index < verdict.segments.length; index++) {
|
|
704
|
+
const segment = verdict.segments[index];
|
|
705
|
+
const listing = await listedAtEnd(parent);
|
|
706
|
+
if (listing === null || !listing.has(segment))
|
|
707
|
+
return false;
|
|
708
|
+
const candidate = path.join(parent, segment);
|
|
709
|
+
const probed = await port.probe(candidate);
|
|
710
|
+
const expected = index === verdict.segments.length - 1 ? verdict.handle : verdict.recorded[index];
|
|
711
|
+
if (probed === null || probed.kind === "symlink" || !sameWitness(probed, expected))
|
|
712
|
+
return false;
|
|
713
|
+
parent = candidate;
|
|
714
|
+
}
|
|
715
|
+
return true;
|
|
716
|
+
}
|
|
386
717
|
// ── mutation ──────────────────────────────────────────────────────────────────
|
|
387
718
|
/**
|
|
388
719
|
* Roots (resolved) whose filesystem refused a hard link. Learned lazily on the first creation
|
|
@@ -449,7 +780,7 @@ async function readWhole(port, target) {
|
|
|
449
780
|
await port.close(opened.handle);
|
|
450
781
|
}
|
|
451
782
|
}
|
|
452
|
-
async function mkdirExact(port, parent, segment, isTail, rel) {
|
|
783
|
+
async function mkdirExact(port, parent, segment, isTail, rel, index = -1) {
|
|
453
784
|
const outcome = await port.mkdir(path.join(parent, segment));
|
|
454
785
|
if (outcome === "created")
|
|
455
786
|
return;
|
|
@@ -460,8 +791,9 @@ async function mkdirExact(port, parent, segment, isTail, rel) {
|
|
|
460
791
|
throw new FilesystemSymlinkEntryError(rel, segment);
|
|
461
792
|
}
|
|
462
793
|
const verdict = classifyMkdir(outcome, listing, segment, isTail);
|
|
463
|
-
if (verdict === "aliased")
|
|
464
|
-
throw
|
|
794
|
+
if (verdict === "aliased") {
|
|
795
|
+
throw aliasRefusalFromListing(rel, index, listing, false);
|
|
796
|
+
}
|
|
465
797
|
if (verdict === "shape-mismatch")
|
|
466
798
|
throw new FilesystemShapeMismatchError(rel, segment);
|
|
467
799
|
}
|
|
@@ -490,8 +822,9 @@ async function ensureExactDirectories(port, rootResolved, segments, existingDept
|
|
|
490
822
|
}
|
|
491
823
|
}
|
|
492
824
|
let parent = path.join(rootResolved, ...segments.slice(0, existingDepth));
|
|
493
|
-
for (
|
|
494
|
-
|
|
825
|
+
for (let index = existingDepth; index < segments.length - 1; index++) {
|
|
826
|
+
const segment = segments[index];
|
|
827
|
+
await mkdirExact(port, parent, segment, false, rel, index);
|
|
495
828
|
parent = path.join(parent, segment);
|
|
496
829
|
}
|
|
497
830
|
}
|
|
@@ -521,7 +854,7 @@ async function createExactLeaf(port, tmp, target, rel, leaf, rootResolved) {
|
|
|
521
854
|
const listing = (await port.entries(path.dirname(target))) ?? [];
|
|
522
855
|
if (hasExact(listing, leaf))
|
|
523
856
|
throw new ConcurrentReplacementError(rel, 1);
|
|
524
|
-
throw
|
|
857
|
+
throw aliasRefusalFromListing(rel, relSegments(rel).length - 1, listing, true);
|
|
525
858
|
}
|
|
526
859
|
/**
|
|
527
860
|
* Mutate `(root, rel)` inside its identity lock: claim the key, realize the exact state, and let
|
|
@@ -550,13 +883,13 @@ export async function mutateExact(port, root, rel, body) {
|
|
|
550
883
|
async replace(bytes) {
|
|
551
884
|
await ensureExactDirectories(port, rootResolved, segments, existingDepth, rel);
|
|
552
885
|
const dir = path.dirname(target);
|
|
553
|
-
|
|
554
|
-
// target within a millisecond, and the second's temp file must not clobber the first's.
|
|
555
|
-
const tmpName = `.${leaf}.${process.pid}.${Date.now()}.${randomUUID()}.tmp`;
|
|
886
|
+
const tmpName = identityTempName(leaf);
|
|
556
887
|
const tmp = path.join(dir, tmpName);
|
|
557
888
|
await port.writeTemp(dir, tmpName, bytes);
|
|
558
889
|
try {
|
|
559
890
|
if (realized.state === "exact") {
|
|
891
|
+
// Best effort: a replacement that cannot carry the old permission bits still lands.
|
|
892
|
+
await port.copyMode?.(target, tmp).catch(() => { });
|
|
560
893
|
// Replace: the target exists under our exact spelling, so any writer of an
|
|
561
894
|
// equated spelling is refused at its own M-REALIZE; an atomic rename is safe.
|
|
562
895
|
await replaceExistingLeaf(port, tmp, target, rel);
|
|
@@ -594,9 +927,115 @@ function kindOf(stats) {
|
|
|
594
927
|
return "file";
|
|
595
928
|
return "other";
|
|
596
929
|
}
|
|
930
|
+
/**
|
|
931
|
+
* Linux filesystem types (`statfs` magic numbers) whose directory times are kept by the local
|
|
932
|
+
* kernel and advance on every entry change. Anything else on Linux — NFS, SMB/CIFS, FUSE, 9p,
|
|
933
|
+
* Ceph, and every type not named here — gets no directory witness, so an observation pass lists it
|
|
934
|
+
* exactly as single reads do. Other platforms expose no stable type through Node, so their
|
|
935
|
+
* witnesses are offered and the pass's end-of-pass re-verification is what covers a remote mount.
|
|
936
|
+
*/
|
|
937
|
+
const LOCAL_LINUX_FILESYSTEMS = new Set([
|
|
938
|
+
0xef53, // ext2/3/4
|
|
939
|
+
0x58465342, // xfs
|
|
940
|
+
0x9123683e, // btrfs
|
|
941
|
+
0x01021994, // tmpfs
|
|
942
|
+
0x858458f6, // ramfs
|
|
943
|
+
0x794c7630, // overlayfs
|
|
944
|
+
0x2fc12fc1, // zfs
|
|
945
|
+
0xf2f52010, // f2fs
|
|
946
|
+
0xca451a4e, // bcachefs
|
|
947
|
+
0x4d44, // vfat
|
|
948
|
+
0x2011bab0, // exfat
|
|
949
|
+
0x7366746e, // ntfs3
|
|
950
|
+
0x482b, // hfsplus
|
|
951
|
+
]);
|
|
952
|
+
/** Whether a directory witness may be offered on `platform` for a filesystem of `filesystemType`. */
|
|
953
|
+
export function directoryWitnessTrusted(platform, filesystemType) {
|
|
954
|
+
if (platform !== "linux")
|
|
955
|
+
return true;
|
|
956
|
+
return filesystemType !== null && LOCAL_LINUX_FILESYSTEMS.has(filesystemType);
|
|
957
|
+
}
|
|
958
|
+
/** Whether `dir`'s filesystem may offer directory witnesses, asked once per device per port. */
|
|
959
|
+
function witnessTrust() {
|
|
960
|
+
const devices = new Map();
|
|
961
|
+
return (dev, dir) => {
|
|
962
|
+
if (process.platform !== "linux")
|
|
963
|
+
return Promise.resolve(true);
|
|
964
|
+
let trusted = devices.get(dev);
|
|
965
|
+
if (trusted === undefined) {
|
|
966
|
+
trusted = fs.statfs(dir).then((info) => directoryWitnessTrusted("linux", Number(info.type)), () => false);
|
|
967
|
+
devices.set(dev, trusted);
|
|
968
|
+
}
|
|
969
|
+
return trusted;
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
// Persistent reuse needs a reliable independent ctime, beyond directory enumeration semantics.
|
|
973
|
+
const CONTENT_LINUX_FILESYSTEMS = new Set([
|
|
974
|
+
0xef53, // ext2/3/4
|
|
975
|
+
0x58465342, // xfs
|
|
976
|
+
0x9123683e, // btrfs
|
|
977
|
+
0x01021994, // tmpfs
|
|
978
|
+
0x858458f6, // ramfs
|
|
979
|
+
0x2fc12fc1, // zfs
|
|
980
|
+
0xf2f52010, // f2fs
|
|
981
|
+
0xca451a4e, // bcachefs
|
|
982
|
+
]);
|
|
983
|
+
const DARWIN_DATA_VOLUME = "/System/Volumes/Data";
|
|
984
|
+
const runFile = promisify(execFile);
|
|
985
|
+
async function darwinDataVolumeDevice() {
|
|
986
|
+
try {
|
|
987
|
+
const before = await fs.lstat(DARWIN_DATA_VOLUME, { bigint: true });
|
|
988
|
+
if (!before.isDirectory())
|
|
989
|
+
return;
|
|
990
|
+
const { stdout } = await runFile("/usr/sbin/diskutil", ["info", "-plist", DARWIN_DATA_VOLUME], {
|
|
991
|
+
timeout: 2_000,
|
|
992
|
+
maxBuffer: 64 * 1024,
|
|
993
|
+
});
|
|
994
|
+
// Darwin's numeric statfs type is not a stable filesystem name. Only this OS-managed
|
|
995
|
+
// volume is qualified; a secondary or unreadable volume uses the body scan.
|
|
996
|
+
if (!/<key>FilesystemType<\/key>\s*<string>apfs<\/string>/.test(stdout) ||
|
|
997
|
+
!/<key>MountPoint<\/key>\s*<string>\/System\/Volumes\/Data<\/string>/.test(stdout))
|
|
998
|
+
return;
|
|
999
|
+
const after = await fs.lstat(DARWIN_DATA_VOLUME, { bigint: true });
|
|
1000
|
+
if (after.isDirectory() && before.dev === after.dev && before.ino === after.ino)
|
|
1001
|
+
return after.dev;
|
|
1002
|
+
}
|
|
1003
|
+
catch {
|
|
1004
|
+
// A device whose filesystem cannot be identified is unsuitable for persistent reuse.
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
/** `mount` names the file's mount for `statfs`: an open descriptor, or the file's own path. */
|
|
1008
|
+
function contentWitnessTrust() {
|
|
1009
|
+
let darwin;
|
|
1010
|
+
const linux = new Map();
|
|
1011
|
+
return async (dev, mount) => {
|
|
1012
|
+
if (process.platform === "darwin")
|
|
1013
|
+
return (await (darwin ??= darwinDataVolumeDevice())) === dev;
|
|
1014
|
+
if (process.platform !== "linux")
|
|
1015
|
+
return false;
|
|
1016
|
+
let trusted = linux.get(dev);
|
|
1017
|
+
if (trusted === undefined) {
|
|
1018
|
+
trusted = fs.statfs(mount).then(info => CONTENT_LINUX_FILESYSTEMS.has(Number(info.type)), () => false);
|
|
1019
|
+
linux.set(dev, trusted);
|
|
1020
|
+
}
|
|
1021
|
+
return trusted;
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
/** A regular file's content stamp from its stats, or `undefined` when the stats cannot vouch for it. */
|
|
1025
|
+
function contentStampOf(stat) {
|
|
1026
|
+
if (!stat.isFile() || stat.ctimeNs <= 0n)
|
|
1027
|
+
return undefined;
|
|
1028
|
+
const latest = stat.mtimeNs > stat.ctimeNs ? stat.mtimeNs : stat.ctimeNs;
|
|
1029
|
+
return {
|
|
1030
|
+
value: [stat.dev, stat.ino, stat.birthtimeNs, stat.ctimeNs, stat.mtimeNs, stat.size].join(":"),
|
|
1031
|
+
settled: BigInt(Date.now()) * 1000000n - latest >= SETTLED_AFTER_NS,
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
597
1034
|
/** The one production binding: `node:fs`, the temp-file convention, and the identity lock. */
|
|
598
1035
|
export function createNodeFilesystemIdentityPort(hostPolicy) {
|
|
599
1036
|
const policy = captureFilesystemHostPolicy(hostPolicy);
|
|
1037
|
+
const witnessTrustedOn = witnessTrust();
|
|
1038
|
+
const contentWitnessTrustedOn = contentWitnessTrust();
|
|
600
1039
|
return Object.freeze({
|
|
601
1040
|
isTransientOpenError: policy.isTransientOpenError,
|
|
602
1041
|
isReplacementConflict: policy.isReplacementConflict,
|
|
@@ -623,6 +1062,20 @@ export function createNodeFilesystemIdentityPort(hostPolicy) {
|
|
|
623
1062
|
throw err;
|
|
624
1063
|
}
|
|
625
1064
|
},
|
|
1065
|
+
async directoryWitness(dir) {
|
|
1066
|
+
let stats;
|
|
1067
|
+
try {
|
|
1068
|
+
stats = await fs.stat(dir, { bigint: true });
|
|
1069
|
+
}
|
|
1070
|
+
catch (err) {
|
|
1071
|
+
if (isAbsentPathError(err))
|
|
1072
|
+
return null;
|
|
1073
|
+
throw err;
|
|
1074
|
+
}
|
|
1075
|
+
if (!(await witnessTrustedOn(stats.dev, dir)))
|
|
1076
|
+
return null;
|
|
1077
|
+
return { dev: stats.dev, ino: stats.ino, mtimeNs: stats.mtimeNs, ctimeNs: stats.ctimeNs };
|
|
1078
|
+
},
|
|
626
1079
|
async open(target) {
|
|
627
1080
|
const handle = await fs.open(target, "r");
|
|
628
1081
|
try {
|
|
@@ -637,6 +1090,31 @@ export function createNodeFilesystemIdentityPort(hostPolicy) {
|
|
|
637
1090
|
readAll(handle) {
|
|
638
1091
|
return handle.readFile();
|
|
639
1092
|
},
|
|
1093
|
+
async contentStamp(handle) {
|
|
1094
|
+
const file = handle;
|
|
1095
|
+
const stat = await file.stat({ bigint: true });
|
|
1096
|
+
const stamp = contentStampOf(stat);
|
|
1097
|
+
// The descriptor identifies the file's mount even for a separately mounted leaf.
|
|
1098
|
+
if (stamp === undefined || !(await contentWitnessTrustedOn(stat.dev, `/proc/self/fd/${file.fd}`)))
|
|
1099
|
+
return undefined;
|
|
1100
|
+
return stamp;
|
|
1101
|
+
},
|
|
1102
|
+
async pathContentStamp(target) {
|
|
1103
|
+
let stat;
|
|
1104
|
+
try {
|
|
1105
|
+
stat = await fs.lstat(target, { bigint: true });
|
|
1106
|
+
}
|
|
1107
|
+
catch {
|
|
1108
|
+
return undefined;
|
|
1109
|
+
}
|
|
1110
|
+
const stamp = contentStampOf(stat);
|
|
1111
|
+
return stamp !== undefined && (await contentWitnessTrustedOn(stat.dev, target)) ? stamp : undefined;
|
|
1112
|
+
},
|
|
1113
|
+
relationshipCache(root, key) {
|
|
1114
|
+
if (!policy.enforcePrivateMode || process.getuid === undefined)
|
|
1115
|
+
return undefined;
|
|
1116
|
+
return filesystemRelationshipCache(root, policy, key);
|
|
1117
|
+
},
|
|
640
1118
|
close(handle) {
|
|
641
1119
|
return handle.close();
|
|
642
1120
|
},
|
|
@@ -674,6 +1152,9 @@ export function createNodeFilesystemIdentityPort(hostPolicy) {
|
|
|
674
1152
|
async rename(from, to) {
|
|
675
1153
|
await fs.rename(from, to);
|
|
676
1154
|
},
|
|
1155
|
+
async copyMode(from, to) {
|
|
1156
|
+
await fs.chmod(to, (await fs.lstat(from)).mode & 0o777);
|
|
1157
|
+
},
|
|
677
1158
|
async unlink(target) {
|
|
678
1159
|
await fs.unlink(target);
|
|
679
1160
|
},
|