@harperfast/harper 5.2.13 → 5.3.0-beta.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/agent/mcpTools.ts +1 -1
- package/agent/session.ts +25 -14
- package/bin/cliOperations.ts +58 -9
- package/bin/copyDb.ts +282 -59
- package/bin/deploySetup.ts +16 -5
- package/bin/harper.ts +1 -1
- package/bin/help.ts +4 -1
- package/bin/lite.ts +4 -1
- package/bin/restart.ts +120 -4
- package/bin/run.ts +6 -11
- package/bin/upgrade.js +7 -3
- package/bin/workloadIdentity.ts +119 -0
- package/components/Application.ts +3436 -242
- package/components/ApplicationScope.ts +8 -0
- package/components/EntryHandler.ts +59 -39
- package/components/OptionsWatcher.ts +440 -98
- package/components/RuntimeModuleTracker.ts +38 -7
- package/components/Scope.ts +56 -15
- package/components/awaitRestart.ts +84 -0
- package/components/componentLoader.ts +381 -32
- package/components/componentPreparationLock.ts +16 -5
- package/components/deploymentOperations.ts +4 -1
- package/components/deploymentRecorder.ts +9 -2
- package/components/mcp/adapters/harperHttp.ts +4 -0
- package/components/mcp/listChanged.ts +4 -0
- package/components/mcp/toolRegistry.ts +2 -0
- package/components/mcp/tools/operations.ts +9 -0
- package/components/mcp/tools/schemas/operationDescriptions.ts +2 -2
- package/components/operations.js +537 -113
- package/components/operationsValidation.js +98 -3
- package/components/packageComponent.ts +25 -1
- package/components/requestRestart.ts +11 -0
- package/components/status/ComponentStatusRegistry.ts +59 -0
- package/config/RootConfigWatcher.ts +240 -40
- package/config/configReadRetry.ts +62 -0
- package/config/configUtils.ts +357 -48
- package/config/harperConfigEnvVars.ts +170 -27
- package/config/parseConfigFile.ts +34 -0
- package/config/readConfigFileSync.ts +44 -0
- package/config/watcherArming.ts +59 -0
- package/config-root.schema.json +33 -0
- package/dataLayer/blobBackup.ts +160 -50
- package/dataLayer/delete.ts +6 -1
- package/dataLayer/harperBridge/ResourceBridge.ts +80 -10
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/DeleteAuditLogsBeforeResults.js +3 -1
- package/dataLayer/hdbInfoController.ts +34 -1
- package/dataLayer/insert.ts +44 -1
- package/dataLayer/rocksdbBackup.ts +53 -10
- package/dataLayer/schema.ts +11 -1
- package/dataLayer/schemaDescribe.ts +8 -1
- package/dist/agent/mcpTools.js +1 -1
- package/dist/agent/mcpTools.js.map +1 -1
- package/dist/agent/session.d.ts +22 -0
- package/dist/agent/session.js +26 -15
- package/dist/agent/session.js.map +1 -1
- package/dist/bin/cliOperations.js +61 -9
- package/dist/bin/cliOperations.js.map +1 -1
- package/dist/bin/copyDb.d.ts +12 -1
- package/dist/bin/copyDb.js +248 -60
- package/dist/bin/copyDb.js.map +1 -1
- package/dist/bin/deploySetup.d.ts +2 -0
- package/dist/bin/deploySetup.js +11 -3
- package/dist/bin/deploySetup.js.map +1 -1
- package/dist/bin/harper.js +1 -1
- package/dist/bin/harper.js.map +1 -1
- package/dist/bin/help.js +4 -1
- package/dist/bin/help.js.map +1 -1
- package/dist/bin/lite.js +4 -1
- package/dist/bin/lite.js.map +1 -1
- package/dist/bin/restart.js +91 -6
- package/dist/bin/restart.js.map +1 -1
- package/dist/bin/run.js +4 -10
- package/dist/bin/run.js.map +1 -1
- package/dist/bin/upgrade.js +4 -3
- package/dist/bin/upgrade.js.map +1 -1
- package/dist/bin/workloadIdentity.d.ts +18 -0
- package/dist/bin/workloadIdentity.js +100 -0
- package/dist/bin/workloadIdentity.js.map +1 -0
- package/dist/components/Application.d.ts +235 -17
- package/dist/components/Application.js +3038 -238
- package/dist/components/Application.js.map +1 -1
- package/dist/components/ApplicationScope.d.ts +8 -0
- package/dist/components/ApplicationScope.js +7 -0
- package/dist/components/ApplicationScope.js.map +1 -1
- package/dist/components/EntryHandler.js +26 -10
- package/dist/components/EntryHandler.js.map +1 -1
- package/dist/components/OptionsWatcher.d.ts +4 -0
- package/dist/components/OptionsWatcher.js +440 -99
- package/dist/components/OptionsWatcher.js.map +1 -1
- package/dist/components/RuntimeModuleTracker.js +40 -6
- package/dist/components/RuntimeModuleTracker.js.map +1 -1
- package/dist/components/Scope.js +52 -13
- package/dist/components/Scope.js.map +1 -1
- package/dist/components/awaitRestart.d.ts +33 -0
- package/dist/components/awaitRestart.js +61 -0
- package/dist/components/awaitRestart.js.map +1 -0
- package/dist/components/componentLoader.d.ts +38 -1
- package/dist/components/componentLoader.js +313 -24
- package/dist/components/componentLoader.js.map +1 -1
- package/dist/components/componentPreparationLock.d.ts +5 -0
- package/dist/components/componentPreparationLock.js +14 -6
- package/dist/components/componentPreparationLock.js.map +1 -1
- package/dist/components/deploymentOperations.js +4 -1
- package/dist/components/deploymentOperations.js.map +1 -1
- package/dist/components/deploymentRecorder.d.ts +4 -2
- package/dist/components/deploymentRecorder.js +1 -0
- package/dist/components/deploymentRecorder.js.map +1 -1
- package/dist/components/mcp/adapters/harperHttp.js +4 -0
- package/dist/components/mcp/adapters/harperHttp.js.map +1 -1
- package/dist/components/mcp/listChanged.js +5 -0
- package/dist/components/mcp/listChanged.js.map +1 -1
- package/dist/components/mcp/toolRegistry.d.ts +1 -0
- package/dist/components/mcp/toolRegistry.js.map +1 -1
- package/dist/components/mcp/tools/operations.d.ts +5 -0
- package/dist/components/mcp/tools/operations.js +9 -0
- package/dist/components/mcp/tools/operations.js.map +1 -1
- package/dist/components/mcp/tools/schemas/operationDescriptions.js +2 -2
- package/dist/components/mcp/tools/schemas/operationDescriptions.js.map +1 -1
- package/dist/components/operations.d.ts +28 -0
- package/dist/components/operations.js +476 -113
- package/dist/components/operations.js.map +1 -1
- package/dist/components/operationsValidation.js +97 -3
- package/dist/components/operationsValidation.js.map +1 -1
- package/dist/components/packageComponent.js +24 -0
- package/dist/components/packageComponent.js.map +1 -1
- package/dist/components/requestRestart.d.ts +1 -0
- package/dist/components/requestRestart.js +7 -0
- package/dist/components/requestRestart.js.map +1 -1
- package/dist/components/status/ComponentStatusRegistry.d.ts +0 -4
- package/dist/components/status/ComponentStatusRegistry.js +63 -0
- package/dist/components/status/ComponentStatusRegistry.js.map +1 -1
- package/dist/config/RootConfigWatcher.d.ts +9 -1
- package/dist/config/RootConfigWatcher.js +228 -37
- package/dist/config/RootConfigWatcher.js.map +1 -1
- package/dist/config/configReadRetry.d.ts +8 -0
- package/dist/config/configReadRetry.js +62 -0
- package/dist/config/configReadRetry.js.map +1 -0
- package/dist/config/configUtils.d.ts +11 -2
- package/dist/config/configUtils.js +304 -47
- package/dist/config/configUtils.js.map +1 -1
- package/dist/config/harperConfigEnvVars.d.ts +16 -0
- package/dist/config/harperConfigEnvVars.js +162 -25
- package/dist/config/harperConfigEnvVars.js.map +1 -1
- package/dist/config/parseConfigFile.d.ts +4 -0
- package/dist/config/parseConfigFile.js +35 -0
- package/dist/config/parseConfigFile.js.map +1 -0
- package/dist/config/readConfigFileSync.d.ts +1 -0
- package/dist/config/readConfigFileSync.js +47 -0
- package/dist/config/readConfigFileSync.js.map +1 -0
- package/dist/config/watcherArming.d.ts +15 -0
- package/dist/config/watcherArming.js +59 -0
- package/dist/config/watcherArming.js.map +1 -0
- package/dist/dataLayer/blobBackup.d.ts +49 -20
- package/dist/dataLayer/blobBackup.js +139 -50
- package/dist/dataLayer/blobBackup.js.map +1 -1
- package/dist/dataLayer/delete.js +1 -1
- package/dist/dataLayer/delete.js.map +1 -1
- package/dist/dataLayer/harperBridge/ResourceBridge.d.ts +14 -1
- package/dist/dataLayer/harperBridge/ResourceBridge.js +72 -12
- package/dist/dataLayer/harperBridge/ResourceBridge.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/DeleteAuditLogsBeforeResults.d.ts +3 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/DeleteAuditLogsBeforeResults.js +3 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/DeleteAuditLogsBeforeResults.js.map +1 -1
- package/dist/dataLayer/hdbInfoController.d.ts +10 -0
- package/dist/dataLayer/hdbInfoController.js +30 -1
- package/dist/dataLayer/hdbInfoController.js.map +1 -1
- package/dist/dataLayer/insert.d.ts +9 -1
- package/dist/dataLayer/insert.js +30 -0
- package/dist/dataLayer/insert.js.map +1 -1
- package/dist/dataLayer/rocksdbBackup.d.ts +2 -2
- package/dist/dataLayer/rocksdbBackup.js +45 -8
- package/dist/dataLayer/rocksdbBackup.js.map +1 -1
- package/dist/dataLayer/schema.js +8 -0
- package/dist/dataLayer/schema.js.map +1 -1
- package/dist/dataLayer/schemaDescribe.js +8 -1
- package/dist/dataLayer/schemaDescribe.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/json/systemSchema.json +55 -0
- package/dist/resources/DatabaseTransaction.d.ts +77 -0
- package/dist/resources/DatabaseTransaction.js +586 -54
- package/dist/resources/DatabaseTransaction.js.map +1 -1
- package/dist/resources/LMDBTransaction.d.ts +2 -1
- package/dist/resources/LMDBTransaction.js +43 -6
- package/dist/resources/LMDBTransaction.js.map +1 -1
- package/dist/resources/PrimaryRocksDatabase.d.ts +1 -0
- package/dist/resources/PrimaryRocksDatabase.js +49 -5
- package/dist/resources/PrimaryRocksDatabase.js.map +1 -1
- package/dist/resources/RecordEncoder.d.ts +20 -0
- package/dist/resources/RecordEncoder.js +110 -9
- package/dist/resources/RecordEncoder.js.map +1 -1
- package/dist/resources/RequestTarget.d.ts +2 -0
- package/dist/resources/RequestTarget.js.map +1 -1
- package/dist/resources/Resource.js +117 -24
- package/dist/resources/Resource.js.map +1 -1
- package/dist/resources/ResourceInterface.d.ts +28 -1
- package/dist/resources/ResourceInterface.js.map +1 -1
- package/dist/resources/RocksIndexStore.d.ts +6 -1
- package/dist/resources/RocksIndexStore.js +24 -9
- package/dist/resources/RocksIndexStore.js.map +1 -1
- package/dist/resources/RocksTransactionLogStore.d.ts +24 -1
- package/dist/resources/RocksTransactionLogStore.js +160 -49
- package/dist/resources/RocksTransactionLogStore.js.map +1 -1
- package/dist/resources/Table.d.ts +165 -10
- package/dist/resources/Table.js +1805 -303
- package/dist/resources/Table.js.map +1 -1
- package/dist/resources/analytics/write.js +10 -3
- package/dist/resources/analytics/write.js.map +1 -1
- package/dist/resources/auditStore.d.ts +181 -2
- package/dist/resources/auditStore.js +640 -29
- package/dist/resources/auditStore.js.map +1 -1
- package/dist/resources/blob.d.ts +129 -9
- package/dist/resources/blob.js +992 -114
- package/dist/resources/blob.js.map +1 -1
- package/dist/resources/branchDatabase.d.ts +48 -0
- package/dist/resources/branchDatabase.js +892 -0
- package/dist/resources/branchDatabase.js.map +1 -0
- package/dist/resources/crdt.js +50 -12
- package/dist/resources/crdt.js.map +1 -1
- package/dist/resources/dataLoader.js +3 -4
- package/dist/resources/dataLoader.js.map +1 -1
- package/dist/resources/databases.d.ts +157 -14
- package/dist/resources/databases.js +1462 -325
- package/dist/resources/databases.js.map +1 -1
- package/dist/resources/defineTable.d.ts +10 -2
- package/dist/resources/defineTable.js +9 -1
- package/dist/resources/defineTable.js.map +1 -1
- package/dist/resources/derivedIndexRegistry.d.ts +5 -0
- package/dist/resources/derivedIndexRegistry.js +68 -0
- package/dist/resources/derivedIndexRegistry.js.map +1 -0
- package/dist/resources/derivedIndexRuntime.d.ts +215 -0
- package/dist/resources/derivedIndexRuntime.js +2027 -0
- package/dist/resources/derivedIndexRuntime.js.map +1 -0
- package/dist/resources/graphql.d.ts +1 -1
- package/dist/resources/graphql.js +52 -16
- package/dist/resources/graphql.js.map +1 -1
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.d.ts +103 -9
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js +854 -41
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js.map +1 -1
- package/dist/resources/indexes/hnswDerivedIndex.d.ts +67 -0
- package/dist/resources/indexes/hnswDerivedIndex.js +464 -0
- package/dist/resources/indexes/hnswDerivedIndex.js.map +1 -0
- package/dist/resources/indexes/hnswPlaneBinding.d.ts +65 -0
- package/dist/resources/indexes/hnswPlaneBinding.js +91 -0
- package/dist/resources/indexes/hnswPlaneBinding.js.map +1 -0
- package/dist/resources/longLivedTransactions.d.ts +71 -0
- package/dist/resources/longLivedTransactions.js +358 -0
- package/dist/resources/longLivedTransactions.js.map +1 -0
- package/dist/resources/models/backendRegistry.d.ts +26 -0
- package/dist/resources/models/backendRegistry.js +60 -2
- package/dist/resources/models/backendRegistry.js.map +1 -1
- package/dist/resources/models/bootstrap.d.ts +33 -1
- package/dist/resources/models/bootstrap.js +416 -31
- package/dist/resources/models/bootstrap.js.map +1 -1
- package/dist/resources/nodeIdMapping.d.ts +5 -0
- package/dist/resources/nodeIdMapping.js +49 -0
- package/dist/resources/nodeIdMapping.js.map +1 -1
- package/dist/resources/recordLock.d.ts +123 -0
- package/dist/resources/recordLock.js +315 -0
- package/dist/resources/recordLock.js.map +1 -0
- package/dist/resources/recordLockCoordinator.d.ts +557 -0
- package/dist/resources/recordLockCoordinator.js +2565 -0
- package/dist/resources/recordLockCoordinator.js.map +1 -0
- package/dist/resources/replayLogs.d.ts +14 -1
- package/dist/resources/replayLogs.js +157 -24
- package/dist/resources/replayLogs.js.map +1 -1
- package/dist/resources/replayLogsGuards.d.ts +94 -7
- package/dist/resources/replayLogsGuards.js +111 -7
- package/dist/resources/replayLogsGuards.js.map +1 -1
- package/dist/resources/replicatedApplyFailure.d.ts +16 -0
- package/dist/resources/replicatedApplyFailure.js +63 -0
- package/dist/resources/replicatedApplyFailure.js.map +1 -0
- package/dist/resources/scheduler/scheduler.js +3 -3
- package/dist/resources/scheduler/scheduler.js.map +1 -1
- package/dist/resources/search.d.ts +10 -4
- package/dist/resources/search.js +283 -37
- package/dist/resources/search.js.map +1 -1
- package/dist/resources/tracked.d.ts +5 -1
- package/dist/resources/tracked.js +74 -23
- package/dist/resources/tracked.js.map +1 -1
- package/dist/resources/transactionBroadcast.d.ts +1 -1
- package/dist/resources/transactionBroadcast.js +2 -2
- package/dist/resources/transactionBroadcast.js.map +1 -1
- package/dist/security/auth.js +61 -30
- package/dist/security/auth.js.map +1 -1
- package/dist/security/authn/oidc/claims.d.ts +22 -0
- package/dist/security/authn/oidc/claims.js +71 -0
- package/dist/security/authn/oidc/claims.js.map +1 -0
- package/dist/security/authn/oidc/identityToken.d.ts +27 -0
- package/dist/security/authn/oidc/identityToken.js +111 -0
- package/dist/security/authn/oidc/identityToken.js.map +1 -0
- package/dist/security/authn/oidc/jwks.d.ts +25 -0
- package/dist/security/authn/oidc/jwks.js +261 -0
- package/dist/security/authn/oidc/jwks.js.map +1 -0
- package/dist/security/authn/oidc/providers/generic.d.ts +13 -0
- package/dist/security/authn/oidc/providers/generic.js +34 -0
- package/dist/security/authn/oidc/providers/generic.js.map +1 -0
- package/dist/security/authn/oidc/providers/githubActions.d.ts +11 -0
- package/dist/security/authn/oidc/providers/githubActions.js +129 -0
- package/dist/security/authn/oidc/providers/githubActions.js.map +1 -0
- package/dist/security/authn/oidc/providers/index.d.ts +37 -0
- package/dist/security/authn/oidc/providers/index.js +24 -0
- package/dist/security/authn/oidc/providers/index.js.map +1 -0
- package/dist/security/authn/oidc/tokenExchange.d.ts +12 -0
- package/dist/security/authn/oidc/tokenExchange.js +306 -0
- package/dist/security/authn/oidc/tokenExchange.js.map +1 -0
- package/dist/security/authn/oidc/trustPolicyOperations.d.ts +49 -0
- package/dist/security/authn/oidc/trustPolicyOperations.js +358 -0
- package/dist/security/authn/oidc/trustPolicyOperations.js.map +1 -0
- package/dist/security/authn/oidc/types.d.ts +38 -0
- package/dist/security/authn/oidc/types.js +6 -0
- package/dist/security/authn/oidc/types.js.map +1 -0
- package/dist/security/certificateVerification/index.js +40 -11
- package/dist/security/certificateVerification/index.js.map +1 -1
- package/dist/security/certificateVerification/trustedIssuers.d.ts +24 -0
- package/dist/security/certificateVerification/trustedIssuers.js +79 -0
- package/dist/security/certificateVerification/trustedIssuers.js.map +1 -0
- package/dist/security/certificateVerification/types.d.ts +1 -0
- package/dist/security/credentialProvenance.d.ts +35 -0
- package/dist/security/credentialProvenance.js +51 -0
- package/dist/security/credentialProvenance.js.map +1 -0
- package/dist/security/credentialRejection.d.ts +4 -0
- package/dist/security/credentialRejection.js +24 -0
- package/dist/security/credentialRejection.js.map +1 -0
- package/dist/security/deferredAuthentication.d.ts +36 -0
- package/dist/security/deferredAuthentication.js +70 -0
- package/dist/security/deferredAuthentication.js.map +1 -0
- package/dist/security/impersonation.d.ts +21 -0
- package/dist/security/impersonation.js +108 -9
- package/dist/security/impersonation.js.map +1 -1
- package/dist/security/jsLoader.d.ts +6 -0
- package/dist/security/jsLoader.js +77 -15
- package/dist/security/jsLoader.js.map +1 -1
- package/dist/security/keys.js +301 -71
- package/dist/security/keys.js.map +1 -1
- package/dist/security/operationScope.d.ts +21 -0
- package/dist/security/operationScope.js +36 -0
- package/dist/security/operationScope.js.map +1 -0
- package/dist/security/permissionsTranslator.js +21 -0
- package/dist/security/permissionsTranslator.js.map +1 -1
- package/dist/security/tokenAuthentication.d.ts +19 -1
- package/dist/security/tokenAuthentication.js +191 -10
- package/dist/security/tokenAuthentication.js.map +1 -1
- package/dist/security/user.js +4 -3
- package/dist/security/user.js.map +1 -1
- package/dist/server/DurableSubscriptionsSession.d.ts +2 -2
- package/dist/server/DurableSubscriptionsSession.js +67 -10
- package/dist/server/DurableSubscriptionsSession.js.map +1 -1
- package/dist/server/REST.js +106 -2
- package/dist/server/REST.js.map +1 -1
- package/dist/server/graphqlQuerying.js +4 -0
- package/dist/server/graphqlQuerying.js.map +1 -1
- package/dist/server/http.d.ts +16 -1
- package/dist/server/http.js +122 -17
- package/dist/server/http.js.map +1 -1
- package/dist/server/itc/serverHandlers.js +8 -1
- package/dist/server/itc/serverHandlers.js.map +1 -1
- package/dist/server/jobs/jobProcess.js +6 -2
- package/dist/server/jobs/jobProcess.js.map +1 -1
- package/dist/server/jobs/jobs.js +4 -1
- package/dist/server/jobs/jobs.js.map +1 -1
- package/dist/server/liveSubscriptionAuth.d.ts +26 -4
- package/dist/server/liveSubscriptionAuth.js +105 -39
- package/dist/server/liveSubscriptionAuth.js.map +1 -1
- package/dist/server/loadRootComponents.js +49 -10
- package/dist/server/loadRootComponents.js.map +1 -1
- package/dist/server/mqtt.d.ts +2 -0
- package/dist/server/mqtt.js +165 -30
- package/dist/server/mqtt.js.map +1 -1
- package/dist/server/nodeName.d.ts +2 -0
- package/dist/server/nodeName.js +107 -23
- package/dist/server/nodeName.js.map +1 -1
- package/dist/server/serverHelpers/Headers.d.ts +27 -0
- package/dist/server/serverHelpers/Headers.js +145 -1
- package/dist/server/serverHelpers/Headers.js.map +1 -1
- package/dist/server/serverHelpers/NodeAdapterResponse.d.ts +48 -0
- package/dist/server/serverHelpers/NodeAdapterResponse.js +220 -0
- package/dist/server/serverHelpers/NodeAdapterResponse.js.map +1 -0
- package/dist/server/serverHelpers/Request.d.ts +5 -10
- package/dist/server/serverHelpers/Request.js +38 -136
- package/dist/server/serverHelpers/Request.js.map +1 -1
- package/dist/server/serverHelpers/contentTypes.d.ts +11 -0
- package/dist/server/serverHelpers/contentTypes.js +221 -40
- package/dist/server/serverHelpers/contentTypes.js.map +1 -1
- package/dist/server/serverHelpers/deployValidationState.d.ts +3 -0
- package/dist/server/serverHelpers/deployValidationState.js +9 -19
- package/dist/server/serverHelpers/deployValidationState.js.map +1 -1
- package/dist/server/serverHelpers/operationAuthorizationState.d.ts +12 -0
- package/dist/server/serverHelpers/operationAuthorizationState.js +24 -2
- package/dist/server/serverHelpers/operationAuthorizationState.js.map +1 -1
- package/dist/server/serverHelpers/registeredOperations.d.ts +5 -4
- package/dist/server/serverHelpers/registeredOperations.js +74 -21
- package/dist/server/serverHelpers/registeredOperations.js.map +1 -1
- package/dist/server/serverHelpers/requestSanitization.d.ts +11 -0
- package/dist/server/serverHelpers/requestSanitization.js +20 -0
- package/dist/server/serverHelpers/requestSanitization.js.map +1 -0
- package/dist/server/serverHelpers/serverHandlers.js +6 -3
- package/dist/server/serverHelpers/serverHandlers.js.map +1 -1
- package/dist/server/serverHelpers/serverUtilities.d.ts +18 -0
- package/dist/server/serverHelpers/serverUtilities.js +178 -29
- package/dist/server/serverHelpers/serverUtilities.js.map +1 -1
- package/dist/server/serverHelpers/sharedMessageEncoding.d.ts +67 -0
- package/dist/server/serverHelpers/sharedMessageEncoding.js +280 -0
- package/dist/server/serverHelpers/sharedMessageEncoding.js.map +1 -0
- package/dist/server/serverHelpers/uwsServer.js +19 -1
- package/dist/server/serverHelpers/uwsServer.js.map +1 -1
- package/dist/server/static.js +24 -28
- package/dist/server/static.js.map +1 -1
- package/dist/server/storageReclamation.d.ts +5 -0
- package/dist/server/storageReclamation.js +17 -1
- package/dist/server/storageReclamation.js.map +1 -1
- package/dist/server/threads/isolatedApplications.d.ts +47 -0
- package/dist/server/threads/isolatedApplications.js +171 -0
- package/dist/server/threads/isolatedApplications.js.map +1 -0
- package/dist/server/threads/itc.d.ts +7 -2
- package/dist/server/threads/itc.js +5 -1
- package/dist/server/threads/itc.js.map +1 -1
- package/dist/server/threads/logRotationTransport.d.ts +1 -0
- package/dist/server/threads/logRotationTransport.js +33 -0
- package/dist/server/threads/logRotationTransport.js.map +1 -0
- package/dist/server/threads/manageThreads.d.ts +83 -3
- package/dist/server/threads/manageThreads.js +769 -75
- package/dist/server/threads/manageThreads.js.map +1 -1
- package/dist/server/threads/socketRouter.d.ts +1 -0
- package/dist/server/threads/socketRouter.js +277 -31
- package/dist/server/threads/socketRouter.js.map +1 -1
- package/dist/server/threads/threadHeapMemory.d.ts +2 -0
- package/dist/server/threads/threadHeapMemory.js +31 -0
- package/dist/server/threads/threadHeapMemory.js.map +1 -0
- package/dist/server/threads/threadServer.js +76 -22
- package/dist/server/threads/threadServer.js.map +1 -1
- package/dist/sqlEngine/config.d.ts +1 -3
- package/dist/sqlEngine/config.js +19 -16
- package/dist/sqlEngine/config.js.map +1 -1
- package/dist/sqlTranslator/index.d.ts +1 -1
- package/dist/sqlTranslator/index.js +30 -7
- package/dist/sqlTranslator/index.js.map +1 -1
- package/dist/upgrade/directives/5-3-0.d.ts +7 -0
- package/dist/upgrade/directives/5-3-0.js +148 -0
- package/dist/upgrade/directives/5-3-0.js.map +1 -0
- package/dist/upgrade/directives/directivesController.js +2 -1
- package/dist/upgrade/directives/directivesController.js.map +1 -1
- package/dist/utility/OperationFunctionCaller.js +2 -1
- package/dist/utility/OperationFunctionCaller.js.map +1 -1
- package/dist/utility/common_utils.d.ts +16 -0
- package/dist/utility/common_utils.js +32 -6
- package/dist/utility/common_utils.js.map +1 -1
- package/dist/utility/componentNames.d.ts +8 -0
- package/dist/utility/componentNames.js +12 -1
- package/dist/utility/componentNames.js.map +1 -1
- package/dist/utility/environment/environmentManager.js +3 -6
- package/dist/utility/environment/environmentManager.js.map +1 -1
- package/dist/utility/environment/systemInformation.d.ts +1 -0
- package/dist/utility/environment/systemInformation.js +1 -0
- package/dist/utility/environment/systemInformation.js.map +1 -1
- package/dist/utility/errors/commonErrors.d.ts +2 -0
- package/dist/utility/errors/commonErrors.js +2 -0
- package/dist/utility/errors/commonErrors.js.map +1 -1
- package/dist/utility/errors/hdbError.d.ts +33 -0
- package/dist/utility/errors/hdbError.js +58 -1
- package/dist/utility/errors/hdbError.js.map +1 -1
- package/dist/utility/globalSchema.d.ts +18 -0
- package/dist/utility/hdbTerms.d.ts +18 -0
- package/dist/utility/hdbTerms.js +20 -2
- package/dist/utility/hdbTerms.js.map +1 -1
- package/dist/utility/logging/harper_logger.d.ts +2 -0
- package/dist/utility/logging/harper_logger.js +286 -30
- package/dist/utility/logging/harper_logger.js.map +1 -1
- package/dist/utility/logging/logGenerationCoordinator.d.ts +35 -0
- package/dist/utility/logging/logGenerationCoordinator.js +184 -0
- package/dist/utility/logging/logGenerationCoordinator.js.map +1 -0
- package/dist/utility/logging/logRotation.d.ts +46 -0
- package/dist/utility/logging/logRotation.js +365 -0
- package/dist/utility/logging/logRotation.js.map +1 -0
- package/dist/utility/logging/logRotator.d.ts +1 -1
- package/dist/utility/logging/logRotator.js +192 -85
- package/dist/utility/logging/logRotator.js.map +1 -1
- package/dist/utility/nodeIdentity.d.ts +9 -0
- package/dist/utility/nodeIdentity.js +58 -0
- package/dist/utility/nodeIdentity.js.map +1 -0
- package/dist/utility/npmUtilities.js +11 -7
- package/dist/utility/npmUtilities.js.map +1 -1
- package/dist/utility/operationPermissions.d.ts +3 -1
- package/dist/utility/operationPermissions.js +16 -1
- package/dist/utility/operationPermissions.js.map +1 -1
- package/dist/utility/operation_authorization.d.ts +10 -7
- package/dist/utility/operation_authorization.js +212 -41
- package/dist/utility/operation_authorization.js.map +1 -1
- package/dist/utility/watchPath.d.ts +29 -0
- package/dist/utility/watchPath.js +68 -0
- package/dist/utility/watchPath.js.map +1 -0
- package/dist/utility/watcherFallback.d.ts +41 -0
- package/dist/utility/watcherFallback.js +153 -0
- package/dist/utility/watcherFallback.js.map +1 -1
- package/dist/validation/configValidator.d.ts +12 -0
- package/dist/validation/configValidator.js +205 -75
- package/dist/validation/configValidator.js.map +1 -1
- package/dist/validation/installValidator.js +12 -0
- package/dist/validation/installValidator.js.map +1 -1
- package/dist/validation/validationWrapper.d.ts +11 -0
- package/dist/validation/validationWrapper.js +16 -3
- package/dist/validation/validationWrapper.js.map +1 -1
- package/index.ts +8 -0
- package/json/systemSchema.json +55 -0
- package/npm-shrinkwrap.json +286 -194
- package/package.json +15 -7
- package/resources/DESIGN.md +219 -52
- package/resources/DatabaseTransaction.ts +657 -52
- package/resources/LMDBTransaction.ts +46 -6
- package/resources/PrimaryRocksDatabase.ts +46 -7
- package/resources/RecordEncoder.ts +124 -9
- package/resources/RequestTarget.ts +2 -0
- package/resources/Resource.ts +114 -22
- package/resources/ResourceInterface.ts +31 -0
- package/resources/RocksIndexStore.ts +30 -9
- package/resources/RocksTransactionLogStore.ts +188 -51
- package/resources/Table.ts +1960 -301
- package/resources/analytics/write.ts +10 -3
- package/resources/auditStore.ts +647 -32
- package/resources/blob.ts +1029 -110
- package/resources/branchDatabase.ts +941 -0
- package/resources/crdt.ts +76 -12
- package/resources/dataLoader.ts +3 -4
- package/resources/databases.ts +1584 -320
- package/resources/defineTable.ts +18 -2
- package/resources/derivedIndexRegistry.ts +56 -0
- package/resources/derivedIndexRuntime.ts +2292 -0
- package/resources/graphql.ts +72 -17
- package/resources/indexes/HierarchicalNavigableSmallWorld.ts +911 -48
- package/resources/indexes/hnswDerivedIndex.ts +531 -0
- package/resources/indexes/hnswPlaneBinding.ts +174 -0
- package/resources/longLivedTransactions.ts +360 -0
- package/resources/models/backendRegistry.ts +84 -2
- package/resources/models/bootstrap.ts +473 -28
- package/resources/nodeIdMapping.ts +50 -0
- package/resources/recordLock.ts +419 -0
- package/resources/recordLockCoordinator.ts +3043 -0
- package/resources/replayLogs.ts +152 -26
- package/resources/replayLogsGuards.ts +171 -8
- package/resources/replicatedApplyFailure.ts +77 -0
- package/resources/scheduler/scheduler.ts +4 -4
- package/resources/search.ts +288 -46
- package/resources/tracked.ts +73 -22
- package/resources/transactionBroadcast.ts +3 -3
- package/security/auth.ts +68 -29
- package/security/authn/oidc/claims.ts +72 -0
- package/security/authn/oidc/identityToken.ts +129 -0
- package/security/authn/oidc/jwks.ts +260 -0
- package/security/authn/oidc/providers/generic.ts +40 -0
- package/security/authn/oidc/providers/githubActions.ts +137 -0
- package/security/authn/oidc/providers/index.ts +52 -0
- package/security/authn/oidc/tokenExchange.ts +300 -0
- package/security/authn/oidc/trustPolicyOperations.ts +343 -0
- package/security/authn/oidc/types.ts +41 -0
- package/security/certificateVerification/index.ts +54 -13
- package/security/certificateVerification/trustedIssuers.ts +76 -0
- package/security/certificateVerification/types.ts +1 -0
- package/security/credentialProvenance.ts +47 -0
- package/security/credentialRejection.ts +22 -0
- package/security/deferredAuthentication.ts +71 -0
- package/security/impersonation.ts +117 -12
- package/security/jsLoader.ts +83 -18
- package/security/keys.ts +298 -72
- package/security/operationScope.ts +33 -0
- package/security/permissionsTranslator.js +23 -0
- package/security/tokenAuthentication.ts +233 -12
- package/security/user.ts +4 -3
- package/server/DESIGN.md +194 -16
- package/server/DurableSubscriptionsSession.ts +71 -11
- package/server/REST.ts +115 -4
- package/server/graphqlQuerying.ts +4 -0
- package/server/http.ts +133 -20
- package/server/itc/serverHandlers.js +8 -1
- package/server/jobs/jobProcess.ts +8 -2
- package/server/jobs/jobs.ts +4 -1
- package/server/liveSubscriptionAuth.ts +129 -46
- package/server/loadRootComponents.js +50 -8
- package/server/mqtt.ts +179 -38
- package/server/nodeName.ts +103 -21
- package/server/serverHelpers/Headers.ts +135 -0
- package/server/serverHelpers/NodeAdapterResponse.ts +221 -0
- package/server/serverHelpers/Request.ts +33 -131
- package/server/serverHelpers/contentTypes.ts +217 -36
- package/server/serverHelpers/deployValidationState.ts +24 -13
- package/server/serverHelpers/operationAuthorizationState.ts +34 -3
- package/server/serverHelpers/registeredOperations.ts +79 -22
- package/server/serverHelpers/requestSanitization.ts +15 -0
- package/server/serverHelpers/serverHandlers.js +6 -3
- package/server/serverHelpers/serverUtilities.ts +232 -40
- package/server/serverHelpers/sharedMessageEncoding.ts +307 -0
- package/server/serverHelpers/uwsServer.ts +17 -2
- package/server/static.ts +23 -29
- package/server/storageReclamation.ts +15 -2
- package/server/threads/isolatedApplications.ts +157 -0
- package/server/threads/itc.js +11 -1
- package/server/threads/logRotationTransport.ts +40 -0
- package/server/threads/manageThreads.js +771 -66
- package/server/threads/socketRouter.ts +291 -30
- package/server/threads/threadHeapMemory.ts +26 -0
- package/server/threads/threadServer.js +73 -22
- package/sqlTranslator/index.ts +31 -8
- package/studio/web/assets/{Chat-4RrB5134.js → Chat-D3j-1yY1.js} +1 -1
- package/studio/web/assets/{FloatingChat-omlNMDcJ.js → FloatingChat-BxJGYcfB.js} +3 -3
- package/studio/web/assets/{apiToken-Bke3wvfZ.js → apiToken-CT55oWOe.js} +1 -1
- package/studio/web/assets/{applications-DvFDYJgK.js → applications-D9Ct9_vm.js} +1 -1
- package/studio/web/assets/{cssMode-C1vRa7zh.js → cssMode-DV8H7VwA.js} +1 -1
- package/studio/web/assets/{editor-3XRWEDWX.js → editor-uatc0unt.js} +1 -1
- package/studio/web/assets/{html-CTY5tdMr.js → html-Bm6D6paN.js} +1 -1
- package/studio/web/assets/{htmlMode-CG1vSD9t.js → htmlMode-CEn7tpLG.js} +1 -1
- package/studio/web/assets/{index-Dfpeofdu.js → index-BIXW6Pu4.js} +5 -5
- package/studio/web/assets/{index.lazy-B1VOIv-t.js → index.lazy-UI7L-Vrk.js} +1 -1
- package/studio/web/assets/{javascript-CJeJzGnI.js → javascript-CJ0G3AFZ.js} +1 -1
- package/studio/web/assets/{jsonMode-CYPBwM82.js → jsonMode-DQADAYEa.js} +1 -1
- package/studio/web/assets/{languageServices-IKH4GUHl.js → languageServices-CAQJXWcI.js} +1 -1
- package/studio/web/assets/{lspLanguageFeatures-BC8_gxKG.js → lspLanguageFeatures-CCQ8P5sY.js} +1 -1
- package/studio/web/assets/{notifications-BfKBpYcq.js → notifications-BbxTU6Aw.js} +1 -1
- package/studio/web/assets/{notifications-DFbArTfC.js → notifications-Cvb3P1lB.js} +1 -1
- package/studio/web/assets/{profile-Q4-T6c-S.js → profile-Yyb7gsvL.js} +1 -1
- package/studio/web/assets/{regions-CtkV0xje.js → regions-OgjGHlU5.js} +1 -1
- package/studio/web/assets/{register-1ZZuMsiA.js → register-6qwNEOY3.js} +2 -2
- package/studio/web/assets/{setComponentFile-ZWLcWv5X.js → setComponentFile-BilDMtgB.js} +1 -1
- package/studio/web/assets/{setup-DWprJyJy.js → setup-J6qJ7OIU.js} +2 -2
- package/studio/web/assets/{status--aNm8isn.js → status-0RWGcfyD.js} +1 -1
- package/studio/web/assets/{toggleHighContrast-Cq_lt3XD.js → toggleHighContrast-BIn-vErT.js} +1 -1
- package/studio/web/assets/{tsMode-pjgytARx.js → tsMode-DgUXku4d.js} +1 -1
- package/studio/web/assets/{typescript-Cdg0mqUh.js → typescript-C9orXcsM.js} +1 -1
- package/studio/web/assets/{useEntityRestURL-RZhaY8Rn.js → useEntityRestURL-BEoXXbUB.js} +1 -1
- package/studio/web/assets/{workers-BgoXIqQe.js → workers-JVzSDmgx.js} +1 -1
- package/studio/web/assets/{xml-BwSeDMiP.js → xml-Cq-S8S4X.js} +1 -1
- package/studio/web/assets/{yaml-DotCUG5l.js → yaml-sfoRdh1M.js} +1 -1
- package/studio/web/index.html +1 -1
- package/upgrade/directives/5-3-0.ts +132 -0
- package/upgrade/directives/directivesController.ts +2 -1
- package/utility/OperationFunctionCaller.ts +2 -1
- package/utility/common_utils.ts +30 -5
- package/utility/componentNames.ts +12 -0
- package/utility/environment/environmentManager.ts +3 -7
- package/utility/environment/systemInformation.ts +7 -0
- package/utility/errors/commonErrors.ts +4 -0
- package/utility/errors/hdbError.ts +57 -0
- package/utility/hdbTerms.ts +19 -0
- package/utility/logging/harper_logger.ts +278 -26
- package/utility/logging/logGenerationCoordinator.ts +196 -0
- package/utility/logging/logRotation.ts +367 -0
- package/utility/logging/logRotator.ts +213 -81
- package/utility/nodeIdentity.ts +45 -0
- package/utility/npmUtilities.ts +12 -8
- package/utility/operationPermissions.ts +18 -1
- package/utility/operation_authorization.ts +231 -42
- package/utility/watchPath.ts +63 -0
- package/utility/watcherFallback.ts +148 -0
- package/validation/configValidator.ts +215 -75
- package/validation/installValidator.ts +15 -0
- package/validation/validationWrapper.ts +18 -4
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cluster-wide record locks (harper#483, Phase 1): amortized per-record ownership.
|
|
3
|
+
* Design note: `docs/record-lock-ownership.md`.
|
|
4
|
+
*
|
|
5
|
+
* `Table.lock()` acquires the node's rocksdb-js key lock first, which bounds this process to one
|
|
6
|
+
* outstanding acquisition per key; only then does it run the cluster step here. That step has three
|
|
7
|
+
* levels at three very different rates:
|
|
8
|
+
*
|
|
9
|
+
* - **The home map** — `(generation, homes[])`, published by an operator through harper-pro and
|
|
10
|
+
* handed to core through `transport.homeMap()`. It is immutable for the life of its generation:
|
|
11
|
+
* core never computes it, never advances it, and never proceeds without it.
|
|
12
|
+
* - **The home node** — within a generation, a key's arbiter is a rendezvous hash over `homes[]`
|
|
13
|
+
* (§4.4). One arbiter per key is trivially exclusive, so there is no grant state machine at all:
|
|
14
|
+
* no deferral queues, no `(tsR, nodeId)` tiebreak, no synthesized grants, no split votes, no
|
|
15
|
+
* revocation protocol between peers.
|
|
16
|
+
* - **The delegation** — the exclusive right to admit critical sections on one key for a bounded
|
|
17
|
+
* time. While one is live, `lock()`/`unlock()` are pure Phase 0: the local key lock and **zero
|
|
18
|
+
* cluster messages**. Releasing the application lock does not release the delegation, so a node
|
|
19
|
+
* writing the same record repeatedly pays one round and then nothing.
|
|
20
|
+
*
|
|
21
|
+
* Two properties carry the safety argument, and both are enforced rather than assumed:
|
|
22
|
+
*
|
|
23
|
+
* - **One delegate per key per home.** A home never has two live delegations for a key, and a
|
|
24
|
+
* successor delegation is issued only after the predecessor's has been recalled-and-drained or has
|
|
25
|
+
* provably expired on the home's own clock plus skew. Every expiry decision on both sides is made
|
|
26
|
+
* on that side's monotonic clock; no remote timestamp is ever compared against a local one.
|
|
27
|
+
* - **A delegation bounds every handle it admitted.** An admission may not outlive its delegation, so
|
|
28
|
+
* recall revokes capability rather than merely closing the door (§6): the commit-time lease fence
|
|
29
|
+
* in `DatabaseTransaction` rejects a staged write whose handle has expired, and a recall expires
|
|
30
|
+
* those handles before the release is acknowledged.
|
|
31
|
+
*
|
|
32
|
+
* `nodeId` here is the globally stable node NAME. It is deliberately not the audit entry's `nodeId`:
|
|
33
|
+
* `nodeIdMapping.ts` hands out per-node short ids (0 is always local), so the same node has different
|
|
34
|
+
* ids on different nodes and any ordering built on them would order the same pair differently on two
|
|
35
|
+
* nodes.
|
|
36
|
+
*
|
|
37
|
+
* Successor freshness follows §7: a clean release carries inherited origin-log dependencies, the
|
|
38
|
+
* home advances the releasing origin to that entry's own position, and the next delegate cannot
|
|
39
|
+
* admit until its transport has made the set visible. Missing lineage takes the weaker recovery
|
|
40
|
+
* barrier and fails closed if that barrier cannot be established.
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* How long a home waits before re-sending a recall that FAILED. A recall the delegate confirmed is
|
|
44
|
+
* never re-sent: it has stopped admitting, and the grant is then cleared by its release or by its own
|
|
45
|
+
* deadline. Without both rules a contender polling at 25 ms re-armed the recall on every pass and
|
|
46
|
+
* turned one handoff into an RPC storm lasting the rest of the delegation.
|
|
47
|
+
*/
|
|
48
|
+
export declare const RECALL_RETRY_MS = 1000;
|
|
49
|
+
/** Margin a home adds to a delegation it issued, so the delegate always stops admitting first. */
|
|
50
|
+
export declare const LOCK_LEASE_SKEW_MS = 5000;
|
|
51
|
+
/**
|
|
52
|
+
* How long a delegation runs, independent of any one caller's lock lease. It MUST be longer than the
|
|
53
|
+
* longest lease it will admit, or the amortization does not exist: a delegation sized to the caller's
|
|
54
|
+
* lease has no room left for the next lock, so every repeat `lock()` renews and pays a round trip —
|
|
55
|
+
* exactly the cost this design is built to remove.
|
|
56
|
+
*/
|
|
57
|
+
export declare const DELEGATION_LEASE_MS: number;
|
|
58
|
+
/**
|
|
59
|
+
* The two control entries. `lockRequest`/`lockGrant` belonged to the Ricart–Agrawala rule the
|
|
60
|
+
* design note replaces; they never shipped enabled, so their nibbles were retired rather than
|
|
61
|
+
* migrated (`auditStore.ts`). Delegation request/grant/recall are unicast over the transport, not
|
|
62
|
+
* entries — the release stays on the replicated log because it is what orders a handoff behind the
|
|
63
|
+
* delegate's own data writes, and the barrier is on it because being replicated is its whole
|
|
64
|
+
* purpose (§7.2): a member commits one on request, and its position is the point a peer must have
|
|
65
|
+
* applied that origin through before a recovery-mode successor may admit.
|
|
66
|
+
*/
|
|
67
|
+
export type LockControlType = 'lockRelease' | 'lockBarrier';
|
|
68
|
+
/**
|
|
69
|
+
* The operator-agreed map a key's home is derived from. Supplied by harper-pro; core never computes
|
|
70
|
+
* it and never advances it. Immutable for the life of a generation — nothing a node observes changes
|
|
71
|
+
* it, which is why no agreement protocol runs here (§4).
|
|
72
|
+
*/
|
|
73
|
+
export interface LockHomeMap {
|
|
74
|
+
/** Monotonic per database. Part of the fencing token, so it must never go backwards. */
|
|
75
|
+
generation: number;
|
|
76
|
+
/**
|
|
77
|
+
* Every node that participates in cluster record locks for this database — not only the ones an
|
|
78
|
+
* operator thinks of as arbiters. Order is irrelevant; the ring hashes each name independently.
|
|
79
|
+
*
|
|
80
|
+
* It is one set and not two because a home refuses a delegation to any node this list does not
|
|
81
|
+
* name (that is what keeps a decommissioned node from taking one), so a node absent from it can
|
|
82
|
+
* neither home a key nor lock one. Rendezvous hashing then makes every listed node the arbiter for
|
|
83
|
+
* its share of the ring, which is the property that costs a second list nothing.
|
|
84
|
+
*/
|
|
85
|
+
homes: string[];
|
|
86
|
+
/**
|
|
87
|
+
* This node's durably persisted, monotonic incarnation counter as a home (§5.1). A random value
|
|
88
|
+
* makes a stale reply identifiable but not ORDERABLE: a home that restarts and re-issues counter 1
|
|
89
|
+
* after having issued counter 50 would let a delayed counter-50 write defeat its successor.
|
|
90
|
+
*
|
|
91
|
+
* **Per coordination incarnation, not per process.** Coordinator state — including the delegation
|
|
92
|
+
* counter — is per-thread, so a replacement coordinating worker starts counting from zero. If the
|
|
93
|
+
* incarnation did not advance with it, the new worker would re-mint tokens its predecessor already
|
|
94
|
+
* issued, and §4.3's incarnation-bound quiescence acknowledgements would survive a restart that
|
|
95
|
+
* discarded everything they attested to.
|
|
96
|
+
*/
|
|
97
|
+
homeIncarnation: number;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* A delegation's fencing token, ordered lexicographically as
|
|
101
|
+
* `(generation, homeIncarnation, counter)`. Comparable across homes only within a generation, which
|
|
102
|
+
* is all that is needed: a key has exactly one home per generation.
|
|
103
|
+
*/
|
|
104
|
+
export type FencingToken = readonly [generation: number, homeIncarnation: number, counter: number];
|
|
105
|
+
export type LockDependency = readonly [origin: string, position: number];
|
|
106
|
+
export type LockDependencySet = readonly LockDependency[];
|
|
107
|
+
export declare function compareTokens(a: FencingToken, b: FencingToken): number;
|
|
108
|
+
export interface LockReleaseEntry {
|
|
109
|
+
type: 'lockRelease';
|
|
110
|
+
/** The locked record's id. Control entries carry it here, never as the audit entry's recordId. */
|
|
111
|
+
key: any;
|
|
112
|
+
/** Node that held the delegation being released. */
|
|
113
|
+
requester: string;
|
|
114
|
+
/**
|
|
115
|
+
* The released delegation's whole fencing token. The counter alone is NOT enough to identify it: a
|
|
116
|
+
* home that restarts, or whose coordinator is recreated, begins counting again, so a delayed
|
|
117
|
+
* release from a previous incarnation would match a live grant's counter and clear it while its
|
|
118
|
+
* delegate is still admitting.
|
|
119
|
+
*/
|
|
120
|
+
token: FencingToken;
|
|
121
|
+
/**
|
|
122
|
+
* Inherited clean-handoff lineage. Null hands back an unused first grant without advancing it; a
|
|
123
|
+
* renewed grant still drops retained lineage because its earlier token may have admitted writes.
|
|
124
|
+
* Absent means legacy/unknown.
|
|
125
|
+
*/
|
|
126
|
+
dependencies?: LockDependencySet | null;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* The §7.2 recovery fence. It names no key and no token: it is appended after every transaction the
|
|
130
|
+
* writing node had committed when it was requested, so a peer that has applied that origin's log
|
|
131
|
+
* through this entry has applied all of them. The coordinator never acts on one.
|
|
132
|
+
*/
|
|
133
|
+
export interface LockBarrierEntry {
|
|
134
|
+
type: 'lockBarrier';
|
|
135
|
+
/** Supplied by the requesting transport; distinguishes barriers an origin stamped identically across a restart. */
|
|
136
|
+
nonce: number;
|
|
137
|
+
}
|
|
138
|
+
export type LockControlEntry = LockReleaseEntry | LockBarrierEntry;
|
|
139
|
+
/**
|
|
140
|
+
* What a home replies to a delegation request. One shape rather than a discriminated union: the
|
|
141
|
+
* repo compiles with `strict: false`, where TypeScript does not narrow a union on a boolean literal,
|
|
142
|
+
* so a union here would type-check the denial fields as absent on every branch and then not enforce
|
|
143
|
+
* it. `granted` says which half is populated.
|
|
144
|
+
*/
|
|
145
|
+
export interface DelegationReply {
|
|
146
|
+
granted: boolean;
|
|
147
|
+
/** Granted only. */
|
|
148
|
+
token?: FencingToken;
|
|
149
|
+
/** Granted only. How long the delegate may admit for, as a DURATION — never a remote clock reading. */
|
|
150
|
+
leaseMs?: number;
|
|
151
|
+
/** Granted only. Null selects the recovery barrier; an array is the exact clean-handoff fence. */
|
|
152
|
+
dependencies?: LockDependencySet | null;
|
|
153
|
+
/**
|
|
154
|
+
* Denied only. `contended` is the one reason that means another node holds the key, and so the only
|
|
155
|
+
* one a timeout may report as 423. `generation` (the two sides hold different home maps),
|
|
156
|
+
* `unknown-node` (this node is not named in the map), `quarantine` (the home is inside its §4.3
|
|
157
|
+
* restart interval) and `timeout` (the home never answered) all describe something other than
|
|
158
|
+
* contention, so each ends as a retryable 503 rather than telling the caller a key nobody holds is
|
|
159
|
+
* held.
|
|
160
|
+
*/
|
|
161
|
+
reason?: 'contended' | 'generation' | 'unknown-node' | 'capacity' | 'not-home' | 'quarantine' | 'timeout';
|
|
162
|
+
/** Denied with `generation`, so a stale requester can re-derive the ring without another round trip. */
|
|
163
|
+
generation?: number;
|
|
164
|
+
retryAfterMs?: number;
|
|
165
|
+
}
|
|
166
|
+
export interface DelegationRequest {
|
|
167
|
+
key: any;
|
|
168
|
+
/** The asking node. Established by the transport, never read from an untrusted payload. */
|
|
169
|
+
requester: string;
|
|
170
|
+
generation: number;
|
|
171
|
+
leaseMs: number;
|
|
172
|
+
}
|
|
173
|
+
export interface DelegationRecall {
|
|
174
|
+
key: any;
|
|
175
|
+
token: FencingToken;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Supplied by harper-pro. Core never computes cluster topology; it only refuses to promise a
|
|
179
|
+
* cluster-wide lock that this contract cannot back.
|
|
180
|
+
*/
|
|
181
|
+
export interface ClusterLockTransport {
|
|
182
|
+
/**
|
|
183
|
+
* The operator-agreed home map for the database, or undefined while none is available — before the
|
|
184
|
+
* node has the current generation, or while peers disagree about its digest. Core fails closed on
|
|
185
|
+
* undefined rather than guessing a ring.
|
|
186
|
+
*
|
|
187
|
+
* **One obligation core cannot check, and relies on** (§4.3): a generation change is
|
|
188
|
+
* operator-sequenced, so `g+1` may only be answered here once the control plane's one-shot
|
|
189
|
+
* activation record is active — every old home quiesced (each acknowledgement bound to the
|
|
190
|
+
* acknowledger's `homeIncarnation`, so a restart during the drain invalidates it) or externally
|
|
191
|
+
* fenced, then `DELEGATION_LEASE_MS + skew` elapsed. Core cannot observe what happened on other
|
|
192
|
+
* nodes; the operator can.
|
|
193
|
+
*
|
|
194
|
+
* The other interval — a restart of *this* process — is core's own, because a generation does not
|
|
195
|
+
* advance on a restart and there is no external event to hang it on. See `#grantableAfterMono`.
|
|
196
|
+
*/
|
|
197
|
+
homeMap(database: string): LockHomeMap | undefined;
|
|
198
|
+
/**
|
|
199
|
+
* Overrides core's cold-start grant quarantine (§4.3). Set it only where a previous incarnation
|
|
200
|
+
* of this process provably issued nothing — a fresh database, a first start, or a test. Because the
|
|
201
|
+
* same attestation enables the virgin-key freshness fast path, it must prove that no earlier
|
|
202
|
+
* incarnation delegated any key under the current home-map generation at any time, not merely that
|
|
203
|
+
* its last delegation lease has elapsed. Omitted means core enforces the full
|
|
204
|
+
* `DELEGATION_LEASE_MS + skew` from that coordinator's construction — see `#grantableAfterMono` for
|
|
205
|
+
* why neither process start nor thread start is a sound anchor.
|
|
206
|
+
*/
|
|
207
|
+
grantableAfterMono?: number;
|
|
208
|
+
/**
|
|
209
|
+
* Whether this worker thread owns lock coordination for the process. Coordinator state is
|
|
210
|
+
* per-thread while the key lock it arbitrates is process-wide, so a second thread running its own
|
|
211
|
+
* delegations would arbitrate against a different view. Core fails closed off the owner thread.
|
|
212
|
+
*/
|
|
213
|
+
ownsCoordination(): boolean;
|
|
214
|
+
/** Ask `node` (the key's home) for a delegation. Unicast; rejects if the node is unreachable. */
|
|
215
|
+
requestDelegation(node: string, database: string, table: string, request: DelegationRequest): Promise<DelegationReply>;
|
|
216
|
+
/** Home → delegate. Resolves once the delegate has drained and stopped admitting. */
|
|
217
|
+
recallDelegation(node: string, database: string, table: string, recall: DelegationRecall): Promise<void>;
|
|
218
|
+
/**
|
|
219
|
+
* Obtain an admission from the worker thread that coordinates this database, for a `lock()` served
|
|
220
|
+
* on a thread that is not the owner. Present only when the transport can relay across threads
|
|
221
|
+
* (harper-pro#852); a transport without it makes `acquire()` fail closed off the owner thread, as
|
|
222
|
+
* before. The returned `LockRound` was minted by the owner's coordinator; the caller's coordinator
|
|
223
|
+
* records it as a REMOTE admission and installs the handle's revoker locally, so a recall on the
|
|
224
|
+
* owner fences a write this thread's handle staged. `mintedMono` is comparable across threads
|
|
225
|
+
* because `performance.now()` shares one time origin process-wide.
|
|
226
|
+
*/
|
|
227
|
+
acquireOnOwner?(database: string, table: string, key: any, leaseMs: number, waitMs: number): Promise<LockRound>;
|
|
228
|
+
/** Release a remote admission on the owner thread (the counterpart of `acquireOnOwner`). */
|
|
229
|
+
releaseOnOwner?(database: string, table: string, key: any, admissionId: number): Promise<void> | void;
|
|
230
|
+
/**
|
|
231
|
+
* Establish an exact clean-handoff dependency set, or recover the strongest reachable-member
|
|
232
|
+
* barrier when `dependencies` is null. Recovery returns the captured positions for current lock
|
|
233
|
+
* participants that were made visible; it may drain additional replication peers without carrying
|
|
234
|
+
* them in the key's lineage. Clean waits may return void. Concurrent recovery snapshots should be
|
|
235
|
+
* coalesced.
|
|
236
|
+
*
|
|
237
|
+
* Recovery asks each reachable member for a `lockBarrier` entry (`writeLockBarrier`) and drains
|
|
238
|
+
* that member's stream through the position it returns. Core races this promise against the
|
|
239
|
+
* lock's own deadline but cannot cancel it; `deadlineMs` is the wait remaining at the call, so the
|
|
240
|
+
* transport can bound its own work to it instead of outliving the lock that asked.
|
|
241
|
+
*/
|
|
242
|
+
establishLockFreshness(database: string, table: string, key: any, dependencies: LockDependencySet | null, deadlineMs: number): Promise<LockDependencySet | void>;
|
|
243
|
+
/** Emit a control entry and return the committed entry's local origin-log position when available. */
|
|
244
|
+
writeControl?(table: string, entry: LockControlEntry): Promise<number | void> | number | void;
|
|
245
|
+
/**
|
|
246
|
+
* Assigned at registration so a transport can push a received entry in directly. `author` and
|
|
247
|
+
* `position` come from the authenticated origin-log header, never from the payload.
|
|
248
|
+
*/
|
|
249
|
+
onControlEntry?(database: string, table: string, entry: LockControlEntry, author: string, position: number): void;
|
|
250
|
+
/** Assigned at registration. Inbound delegation request from a peer, for a key this node homes. */
|
|
251
|
+
onDelegationRequest?(database: string, table: string, request: DelegationRequest): Promise<DelegationReply>;
|
|
252
|
+
/** Assigned at registration. Inbound recall from a key's home. */
|
|
253
|
+
onDelegationRecall?(database: string, table: string, recall: DelegationRecall): Promise<void>;
|
|
254
|
+
}
|
|
255
|
+
export declare function encodeLockControlPayload(entry: LockControlEntry): Uint8Array;
|
|
256
|
+
/**
|
|
257
|
+
* Decode a received control payload, or undefined when it is not one this version understands. The
|
|
258
|
+
* tuple length is validated exactly: a future version that grows the payload must bump the type
|
|
259
|
+
* rather than widen this one, since a partially-understood release would clear a delegation on terms
|
|
260
|
+
* the sender did not intend.
|
|
261
|
+
*/
|
|
262
|
+
export declare function decodeLockControlPayload(type: unknown, value: unknown): LockControlEntry | undefined;
|
|
263
|
+
/**
|
|
264
|
+
* The string the ring hashes for a key. §4.4 scopes it by database and table: hashing the record id
|
|
265
|
+
* alone would home id `42` in every table of every database on the same node, concentrating unrelated
|
|
266
|
+
* hot keys on one arbiter. The separator cannot appear in a name or a stringified key id.
|
|
267
|
+
*/
|
|
268
|
+
export declare function ringKeyFor(database: string, table: string, keyId: unknown): string;
|
|
269
|
+
export declare function homeFor(keyId: string, homes: string[]): string | undefined;
|
|
270
|
+
export interface LockRound {
|
|
271
|
+
/** The identity to stamp the holder's writes with. */
|
|
272
|
+
tsR: number;
|
|
273
|
+
/** The monotonic reading the admission's lease is measured from. */
|
|
274
|
+
mintedMono: number;
|
|
275
|
+
/**
|
|
276
|
+
* Identifies THIS admission for the life of the handle it produced. The caller hands it back on
|
|
277
|
+
* registration and on release. An id rather than the delegation's token, because the token changes
|
|
278
|
+
* on renewal while the admission does not: addressing by token made a renewed delegation lose
|
|
279
|
+
* track of handles it was still responsible for.
|
|
280
|
+
*/
|
|
281
|
+
admissionId: number;
|
|
282
|
+
}
|
|
283
|
+
export interface LockCoordinatorOptions {
|
|
284
|
+
database: string;
|
|
285
|
+
table: string;
|
|
286
|
+
/** This node's globally stable name. */
|
|
287
|
+
nodeId: string;
|
|
288
|
+
transport: ClusterLockTransport;
|
|
289
|
+
/**
|
|
290
|
+
* Emit one control entry. Core passes the transport's own `writeControl` when it has one and its
|
|
291
|
+
* transaction-log writer otherwise, since writing to the local log IS the send.
|
|
292
|
+
*/
|
|
293
|
+
writeControl: (entry: LockControlEntry) => Promise<number | void> | number | void;
|
|
294
|
+
/** Stable map key for a record id; core passes `writeKeyId`. */
|
|
295
|
+
keyIdOf: (key: any) => unknown;
|
|
296
|
+
/** Mints the holder's stamp; core passes the primary store's monotonic timestamp. */
|
|
297
|
+
nextTimestamp: () => number;
|
|
298
|
+
/** Monotonic clock. Every expiry decision is made on this. */
|
|
299
|
+
monotonic?: () => number;
|
|
300
|
+
skewMs?: number;
|
|
301
|
+
/**
|
|
302
|
+
* The coordinator this one replaces, when a transport is re-registered (a component reload is
|
|
303
|
+
* enough). Its live authority is MOVED here rather than discarded: the transport changed, but the
|
|
304
|
+
* handles it admitted did not, and a successor that started with an empty grant table could hand
|
|
305
|
+
* the same key to another node with no lease time elapsed. That is the "a home may never forget a
|
|
306
|
+
* grant before its expiry" rule (§8) applied across the swap rather than only within one
|
|
307
|
+
* coordinator's life. §11 of the design note calls for exactly this — carry live authority across,
|
|
308
|
+
* or fence and settle every outstanding handle before granting; carrying it across costs nothing.
|
|
309
|
+
*/
|
|
310
|
+
adopt?: LockCoordinator;
|
|
311
|
+
/**
|
|
312
|
+
* Overrides the cold-start grant quarantine (§4.3). Pass `-Infinity` only where a previous
|
|
313
|
+
* incarnation provably issued nothing — a fresh database, or a test. Required when `monotonic` is
|
|
314
|
+
* an injected clock the test drives itself. See `#grantableAfterMono`.
|
|
315
|
+
*/
|
|
316
|
+
grantableAfterMono?: number;
|
|
317
|
+
/** False in tests, which drive `tick()` themselves. */
|
|
318
|
+
autoTick?: boolean;
|
|
319
|
+
}
|
|
320
|
+
export declare class LockCoordinator {
|
|
321
|
+
#private;
|
|
322
|
+
readonly database: string;
|
|
323
|
+
readonly table: string;
|
|
324
|
+
readonly nodeId: string;
|
|
325
|
+
readonly transport: ClusterLockTransport;
|
|
326
|
+
/**
|
|
327
|
+
* How long until this coordinator can rule out authority issued before it took over — 0 when it
|
|
328
|
+
* already can. Non-mutating, unlike `#ownershipHorizon`, which records ownership as a side effect.
|
|
329
|
+
*
|
|
330
|
+
* The waiver is deliberately NOT consulted. `grantableAfterMono` attests that no previous
|
|
331
|
+
* INCARNATION OF THIS PROCESS delegated; it says nothing about a sibling thread that was
|
|
332
|
+
* coordinating until this instant, and a coordinator built while already owning keeps the waiver
|
|
333
|
+
* without ever observing that handoff — which let a takeover worker in a first-incarnation process
|
|
334
|
+
* report a clean drain while the previous owner's delegates were still admitting.
|
|
335
|
+
*
|
|
336
|
+
* The cost is that a freshly built coordinator cannot prove quiescence for a full lease. That falls
|
|
337
|
+
* only on the case that does not need the proof: a node with no delegations yet is bootstrapping
|
|
338
|
+
* generation 1, where there is nothing to drain and no interval to skip.
|
|
339
|
+
*/
|
|
340
|
+
unprovenOwnershipMs(): number;
|
|
341
|
+
constructor(options: LockCoordinatorOptions);
|
|
342
|
+
/**
|
|
343
|
+
* Move this coordinator's live authority to the coordinator replacing it. Called from the
|
|
344
|
+
* successor's constructor, before `close()`, so nothing is dropped in between. Both coordinators
|
|
345
|
+
* run in the same thread for the same node, so the delegations and grants are still this node's —
|
|
346
|
+
* only the transport object underneath them changed.
|
|
347
|
+
*/
|
|
348
|
+
handOffTo(successor: LockCoordinator): void;
|
|
349
|
+
/**
|
|
350
|
+
* For `cluster_status`: delegations held, delegations issued, live admissions, admissions still
|
|
351
|
+
* revocable, misrouted calls. `revocable` counts the ones an unlock left fenceable as well, so the
|
|
352
|
+
* retention `#pruneAdmissions` bounds is visible rather than inferred from `admitted`.
|
|
353
|
+
*/
|
|
354
|
+
get stats(): {
|
|
355
|
+
delegations: number;
|
|
356
|
+
granted: number;
|
|
357
|
+
admitted: number;
|
|
358
|
+
revocable: number;
|
|
359
|
+
droppedOffOwner: number;
|
|
360
|
+
relayedAdmissions: number;
|
|
361
|
+
};
|
|
362
|
+
/**
|
|
363
|
+
* Admit a critical section for a key whose native lock this thread already holds. Resolves with
|
|
364
|
+
* the stamp and the monotonic reading the lease runs from; rejects 423 when no delegation could be
|
|
365
|
+
* obtained in time, or 503 when the guarantee cannot be established at all.
|
|
366
|
+
*
|
|
367
|
+
* The amortization is the first branch: a live, un-recalled delegation with enough time left costs
|
|
368
|
+
* zero cluster messages.
|
|
369
|
+
*/
|
|
370
|
+
acquire(key: any, leaseMs: number, waitMs: number): Promise<LockRound>;
|
|
371
|
+
/**
|
|
372
|
+
* Fence a remote admission's handle on this thread, driven by a recall or surrender on the owner
|
|
373
|
+
* (harper-pro#852), addressed by the OWNER's admission id. Resolves once the handle is provably
|
|
374
|
+
* fenced — its `revokeLease` has run — so the owner's ack cannot claim a fence the handle has not
|
|
375
|
+
* taken; the owner waits on this before writing the release. A revoke that arrives before the handle
|
|
376
|
+
* is installed, or before `registerAdmission` supplies the real revoker, resolves only when the fence
|
|
377
|
+
* finally lands. A revoker that throws, or whose promise rejects, fails this promise rather than
|
|
378
|
+
* resolving it, so the owner falls back to its own lease bound rather than being told the fence
|
|
379
|
+
* succeeded.
|
|
380
|
+
*/
|
|
381
|
+
revokeRemoteAdmission(ownerAdmissionId: number): Promise<void>;
|
|
382
|
+
/**
|
|
383
|
+
* Fence every relayed handle this thread holds, fail-closed (harper-pro#852). Called when the owner
|
|
384
|
+
* worker that granted them is gone (its thread exited, so its delegation table died with it): the
|
|
385
|
+
* handles are no longer backed by any delegation, so nothing here may keep committing. There is no
|
|
386
|
+
* owner left to tell, so this only revokes locally and drops the entries; a still-pending ack is
|
|
387
|
+
* resolved, since the handle can no longer commit.
|
|
388
|
+
*/
|
|
389
|
+
fenceAllRemoteAdmissions(): void;
|
|
390
|
+
/**
|
|
391
|
+
* End this node's admission for a key. The delegation is deliberately KEPT: that is the
|
|
392
|
+
* amortization, and the next `lock()` on this node costs nothing. Returns the durable release
|
|
393
|
+
* write only when the delegation is actually being given up.
|
|
394
|
+
*/
|
|
395
|
+
release(key: any, admissionId: number): Promise<void> | void;
|
|
396
|
+
/**
|
|
397
|
+
* Apply a control entry from a peer (or a replayed one). Idempotent by `(requester, tsR)`: a
|
|
398
|
+
* release that arrives twice, or is replayed from the log long after its producer is gone, must be
|
|
399
|
+
* harmless.
|
|
400
|
+
*
|
|
401
|
+
* `author` is the node the entry was actually written by, taken from the audit header rather than
|
|
402
|
+
* the payload — without it a peer could write a release naming any other node and clear a
|
|
403
|
+
* delegation it does not hold.
|
|
404
|
+
*/
|
|
405
|
+
applyEntry(entry: LockControlEntry, author: string, position?: number): void;
|
|
406
|
+
/**
|
|
407
|
+
* Inbound delegation request from a peer, for a key this node homes. The home is the single
|
|
408
|
+
* arbiter, so this is the whole of the exclusion argument: one live grant per key, and a successor
|
|
409
|
+
* only after the predecessor is recalled-and-drained or provably expired here.
|
|
410
|
+
*/
|
|
411
|
+
onDelegationRequest(request: DelegationRequest): Promise<DelegationReply>;
|
|
412
|
+
/**
|
|
413
|
+
* Inbound recall from a key's home. Revokes capability rather than closing the door: no new
|
|
414
|
+
* admission may start, live ones are drained, and the release is written only once the delegation
|
|
415
|
+
* can no longer admit or commit. A recall for a token we no longer hold is a no-op, not an error.
|
|
416
|
+
*/
|
|
417
|
+
onDelegationRecall(recall: DelegationRecall): Promise<void>;
|
|
418
|
+
/** Expire delegations and grants whose deadlines have passed. Bounded work per call. */
|
|
419
|
+
tick(): void;
|
|
420
|
+
/**
|
|
421
|
+
* One table's half of `quiesceDelegations`. Never throws for a single grant: a transition needs to
|
|
422
|
+
* know exactly what is still live, and one unreachable delegate must not hide the rest.
|
|
423
|
+
*/
|
|
424
|
+
quiesce(result: QuiesceResult, remaining: () => number): Promise<void>;
|
|
425
|
+
/**
|
|
426
|
+
* Stop this coordinator and invalidate what it issued. Expiring every delegation is the part that
|
|
427
|
+
* matters: `close()` runs when a transport is replaced (a component reload is enough), and a
|
|
428
|
+
* successor coordinator must not be able to grant a key whose predecessor handles are still live.
|
|
429
|
+
*/
|
|
430
|
+
close(): void;
|
|
431
|
+
/**
|
|
432
|
+
* Register how to revoke the handle an admission produced. `Table.lock()` calls this once the
|
|
433
|
+
* handle has joined the round, so a recall can fence a write that was staged and then unlocked.
|
|
434
|
+
*/
|
|
435
|
+
registerAdmission(admissionId: number, revoke: () => void | Promise<void>): void;
|
|
436
|
+
}
|
|
437
|
+
type CoordinatorResolver = (database: string, table: string) => LockCoordinator | undefined;
|
|
438
|
+
type ControlWriter = (entry: LockControlEntry) => Promise<number | void> | number | void;
|
|
439
|
+
type ControlWriterResolver = (database: string, table: string) => ControlWriter | undefined;
|
|
440
|
+
/** Installed by Table.ts so a transport can push received entries in without importing Table. */
|
|
441
|
+
export declare function setLockCoordinatorResolver(resolve: CoordinatorResolver, resolveAdmitting?: CoordinatorResolver, resolveControlWriter?: ControlWriterResolver): void;
|
|
442
|
+
export interface QuiesceOutstanding {
|
|
443
|
+
table: string;
|
|
444
|
+
key: unknown;
|
|
445
|
+
/** Present when this node was the HOME and the delegate did not confirm. */
|
|
446
|
+
delegate?: string;
|
|
447
|
+
reason: string;
|
|
448
|
+
}
|
|
449
|
+
export interface QuiesceResult {
|
|
450
|
+
/**
|
|
451
|
+
* Whether this result is a PROOF of quiescence, or merely a report of what was swept.
|
|
452
|
+
*
|
|
453
|
+
* A sweep can only visit coordinators that exist on this thread, and they are built lazily — a
|
|
454
|
+
* table nothing has touched since a restart has none, so an empty `outstanding` would otherwise
|
|
455
|
+
* read as "nothing is live" when the previous incarnation's delegations are still running
|
|
456
|
+
* elsewhere. An orchestrator must require `complete && outstanding.length === 0`; anything else
|
|
457
|
+
* means fall back to the drain interval for this node.
|
|
458
|
+
*/
|
|
459
|
+
complete: boolean;
|
|
460
|
+
/** Delegations this node held and gave up, so it can no longer admit under them. */
|
|
461
|
+
surrendered: number;
|
|
462
|
+
/** Grants this node issued whose delegate confirmed it stopped admitting. */
|
|
463
|
+
recalled: number;
|
|
464
|
+
/**
|
|
465
|
+
* What is still live, or unprovable. Empty means this node is provably quiesced for the database —
|
|
466
|
+
* and ONLY then, which is why a coordinator still inside its restart quarantine contributes an
|
|
467
|
+
* entry here rather than reporting a clean sweep it cannot back.
|
|
468
|
+
*/
|
|
469
|
+
outstanding: QuiesceOutstanding[];
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Stop this node admitting under the current generation for `database`, and say whether it is
|
|
473
|
+
* provably done (harper-pro#856).
|
|
474
|
+
*
|
|
475
|
+
* A membership change otherwise has to wait out `DELEGATION_LEASE_MS + LOCK_LEASE_SKEW_MS` before the
|
|
476
|
+
* next generation may activate, because authority already issued under the old one has to expire —
|
|
477
|
+
* roughly six minutes during which the staged nodes serve no cluster locks at all. That interval is a
|
|
478
|
+
* TIMER, chosen because you cannot recall what you cannot reach. In a planned transition every
|
|
479
|
+
* participant is reachable, so the same guarantee can be *established* instead of waited out: this
|
|
480
|
+
* drains both directions and reports what, if anything, is left.
|
|
481
|
+
*
|
|
482
|
+
* - **As a delegate** it surrenders every delegation it holds. This is the load-bearing half: a
|
|
483
|
+
* delegate is what admits, and `onDelegationRecall` is the existing path whose resolution means
|
|
484
|
+
* "nothing on this node can admit on that token" — live critical sections are drained, not cut.
|
|
485
|
+
* - **As a home** it recalls every grant it issued, so delegates elsewhere stop too. Redundant when
|
|
486
|
+
* every node is quiescing at once, and the reason this still terminates when one is not.
|
|
487
|
+
*
|
|
488
|
+
* `outstanding` empty on every node in `homes(g) ∪ homes(g+1)` is the operator's evidence that the
|
|
489
|
+
* next generation may be activated immediately. Anything left is a node to fall back to the timer for,
|
|
490
|
+
* or to fence externally — this never claims a drain it did not get, and never throws for one grant.
|
|
491
|
+
*/
|
|
492
|
+
export declare function quiesceDelegations(database: string, budgetMs: number): Promise<QuiesceResult>;
|
|
493
|
+
/**
|
|
494
|
+
* Commit a `lockBarrier` entry for the table and resolve to its transaction-log position — the §7.2
|
|
495
|
+
* recovery fence, for a transport answering a peer's recovery probe. The entry is appended after
|
|
496
|
+
* every transaction this node had committed when the call was made, so a peer that has applied this
|
|
497
|
+
* origin's log through the returned position has applied all of them.
|
|
498
|
+
*
|
|
499
|
+
* The transport supplies the nonce it will match the entry on, since a position alone is not an
|
|
500
|
+
* identity: a restart after the wall clock moved backwards can reissue a log key, and a drain that
|
|
501
|
+
* matched the earlier entry at that key would declare this origin drained with its post-restart
|
|
502
|
+
* commits unapplied.
|
|
503
|
+
*
|
|
504
|
+
* Strictly this node's own commit, never the transport's `writeControl`: the fence is a position in
|
|
505
|
+
* THIS origin's log, and the caller is the transport itself — a relaying hook would answer with a
|
|
506
|
+
* position that is not local, or re-enter the operation that called here. A write that commits
|
|
507
|
+
* without a position rejects rather than resolve, since a barrier nobody can wait on is not a fence.
|
|
508
|
+
*/
|
|
509
|
+
export declare function writeLockBarrier(database: string, table: string, nonce: number): Promise<number>;
|
|
510
|
+
/**
|
|
511
|
+
* Register harper-pro's transport for a database, on THIS thread.
|
|
512
|
+
*
|
|
513
|
+
* **It must be registered on every worker that can serve a `lock()`, not only the coordinating one**
|
|
514
|
+
* — including a dedicated application worker (harper#2524) — and core cannot check that. `clusterRequiredDatabases` is module state, so a worker that never registers never latches —
|
|
515
|
+
* and a default-scoped `lock()` there takes the Phase 0 node lock alone while a peer runs the cluster
|
|
516
|
+
* protocol, which is two nodes admitting one key. The `ownsCoordination()` fail-closed path only
|
|
517
|
+
* reaches a worker that has a transport. Registering everywhere also makes that path the one a
|
|
518
|
+
* non-owner worker takes, which is what it exists for.
|
|
519
|
+
*/
|
|
520
|
+
export declare function registerClusterLockTransport(database: string, transport: ClusterLockTransport): void;
|
|
521
|
+
export declare function unregisterClusterLockTransport(database: string, standalone?: boolean): void;
|
|
522
|
+
/** True once a transport has been registered for this database and no standalone claim has cleared it. */
|
|
523
|
+
export declare function isClusterLockRequired(database: string): boolean;
|
|
524
|
+
/**
|
|
525
|
+
* The registered transport, if any. The `size` check keeps the Phase 0 path free of a map lookup on
|
|
526
|
+
* every `lock()` in a build where no transport is ever registered.
|
|
527
|
+
*/
|
|
528
|
+
export declare function getClusterLockTransport(database: string): ClusterLockTransport | undefined;
|
|
529
|
+
export declare function hasClusterLockTransports(): boolean;
|
|
530
|
+
export declare function deliverLockControlEntry(database: string, table: string, entry: LockControlEntry, author: string, position: number): void;
|
|
531
|
+
export declare function deliverDelegationRequest(database: string, table: string, request: DelegationRequest): Promise<DelegationReply>;
|
|
532
|
+
export declare function deliverDelegationRecall(database: string, table: string, recall: DelegationRecall): Promise<void>;
|
|
533
|
+
/**
|
|
534
|
+
* The owner thread's end of `acquireOnOwner`: mint an admission for a `lock()` served on another
|
|
535
|
+
* worker thread, and register `revoke` as the way to fence that thread's handle. `revoke` is what the
|
|
536
|
+
* transport wires to a cross-thread message; a recall or surrender here calls it and waits for the
|
|
537
|
+
* fence before writing the release. Runs on the coordinating thread, resolved through the transport-
|
|
538
|
+
* gated resolver so it fails when this thread does not coordinate the database — the same shape as
|
|
539
|
+
* `deliverDelegationRequest`. Returns the round the calling worker installs as a remote admission.
|
|
540
|
+
*/
|
|
541
|
+
export declare function acquireForRelay(database: string, table: string, key: any, leaseMs: number, waitMs: number, makeRevoke: (round: LockRound) => () => void | Promise<void>): Promise<LockRound>;
|
|
542
|
+
/** The owner thread's end of `releaseOnOwner`: end a relayed admission the owner minted. */
|
|
543
|
+
export declare function releaseForRelay(database: string, table: string, key: any, admissionId: number): Promise<void> | void;
|
|
544
|
+
/**
|
|
545
|
+
* The calling thread's end of an owner `revoke`: fence the handle for a relayed admission this thread
|
|
546
|
+
* holds. Resolves once the handle's `revokeLease` has run, so the owner may wait for the fence before
|
|
547
|
+
* it writes the release. The admitting resolver answers the coordinator that adopted the admission
|
|
548
|
+
* across a transport swap.
|
|
549
|
+
*/
|
|
550
|
+
export declare function revokeRelayedAdmission(database: string, table: string, admissionId: number): Promise<void>;
|
|
551
|
+
/**
|
|
552
|
+
* Fail-closed fence for every relayed handle a table's coordinator holds (harper-pro#852), for when
|
|
553
|
+
* the owner worker that granted them has exited and its delegations are gone. Harper-pro calls this
|
|
554
|
+
* per table when it learns the coordinating thread for a database changed.
|
|
555
|
+
*/
|
|
556
|
+
export declare function fenceRelayedAdmissions(database: string, table: string): void;
|
|
557
|
+
export {};
|