@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,71 @@
|
|
|
1
|
+
import { registryStatus } from '@harperfast/rocksdb-js';
|
|
2
|
+
export declare const MAX_LONG_LIVED_TRANSACTION_REPORTS_PER_PASS = 10;
|
|
3
|
+
type RegistryStatusFn = typeof registryStatus;
|
|
4
|
+
/**
|
|
5
|
+
* Apply a live threshold at the start of every reporting pass, including one that finds no eligible
|
|
6
|
+
* holder. Otherwise a threshold raised above a holder's age leaves its old attribution backoff in
|
|
7
|
+
* place when the threshold is lowered again.
|
|
8
|
+
*/
|
|
9
|
+
export declare function rebaseLongLivedTransactionReports(thresholdMs: number): void;
|
|
10
|
+
/**
|
|
11
|
+
* How old a native transaction handle must be before it is reported, in ms; 0 disables every surface
|
|
12
|
+
* here. Read per pass rather than cached so a live config reload takes effect. A value that cannot
|
|
13
|
+
* be a duration falls back to the default instead of silently disabling reporting.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getReportThresholdMs(): number;
|
|
16
|
+
/**
|
|
17
|
+
* Report every native transaction handle in the process-global rocksdb-js registry that has been open
|
|
18
|
+
* past the threshold — including handles no `DatabaseTransaction` owns, which is the one class of
|
|
19
|
+
* holder no other surface can see (harper#2471). The registry spans worker threads, so this runs on
|
|
20
|
+
* the main thread only; a per-thread sweep would report each handle once per worker.
|
|
21
|
+
*/
|
|
22
|
+
export declare function runLongLivedTransactionSweep(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Start the periodic sweep. Armed unconditionally on the main thread — the pass itself honors a live
|
|
25
|
+
* threshold change, including one that disables it — and idempotent because the thread startup path
|
|
26
|
+
* that calls it can run more than once.
|
|
27
|
+
*/
|
|
28
|
+
export declare function startLongLivedTransactionReporting(): void;
|
|
29
|
+
export type LongLivedHolder = {
|
|
30
|
+
databasePath: string | undefined;
|
|
31
|
+
nativeId: number;
|
|
32
|
+
openedAt: number;
|
|
33
|
+
ageMs: number;
|
|
34
|
+
databaseName?: string;
|
|
35
|
+
tableName?: string;
|
|
36
|
+
countPendingWrites: () => number;
|
|
37
|
+
states: string[];
|
|
38
|
+
timeoutBudget?: number;
|
|
39
|
+
startedFrom?: {
|
|
40
|
+
resourceName: string;
|
|
41
|
+
method: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export type LongLivedHolderReportBudget = {
|
|
45
|
+
remaining: number;
|
|
46
|
+
skipped: number;
|
|
47
|
+
thresholdMs: number;
|
|
48
|
+
};
|
|
49
|
+
export declare function createLongLivedHolderReportBudget(thresholdMs: number): LongLivedHolderReportBudget;
|
|
50
|
+
export declare function finishLongLivedHolderReports(reportBudget: LongLivedHolderReportBudget): void;
|
|
51
|
+
/**
|
|
52
|
+
* Report a handle this thread owns, with the attribution the registry sweep cannot supply. The native
|
|
53
|
+
* id is the join key between the two: the sweep names an id, this names who holds it and which state
|
|
54
|
+
* kept the open-transaction monitor from reaping it (harper#2471). Never throws — the monitor
|
|
55
|
+
* interval that calls it has no handler.
|
|
56
|
+
*/
|
|
57
|
+
export declare function reportLongLivedHolder(holder: LongLivedHolder, reportBudget?: LongLivedHolderReportBudget): void;
|
|
58
|
+
/**
|
|
59
|
+
* The live handles that could be holding the write intent a stuck commit is parked on, as a sentence
|
|
60
|
+
* to append to that commit's log. A handle on another database is offered too, labelled with its path:
|
|
61
|
+
* the verification table is one process-global slot array whose hash mixes in the database id, so a
|
|
62
|
+
* holder in `system` or `oauth` collides with — and parks — a `data` commit at the same rate two `data`
|
|
63
|
+
* keys do. Rank puts the stuck commit's own database first, then age. Age only ranks: a coordinated
|
|
64
|
+
* retry parks on whichever transaction holds the slot when the commit reaches it, which can be younger
|
|
65
|
+
* than the commit itself, so filtering by age could drop the real holder.
|
|
66
|
+
* Returns '' rather than throwing — the caller's own 503 must survive a failure here.
|
|
67
|
+
*/
|
|
68
|
+
export declare function describeHolderCandidates(databasePath: string | undefined, excludeNativeId: number | undefined): string;
|
|
69
|
+
export declare function setRegistryStatusForTests(fn?: RegistryStatusFn): void;
|
|
70
|
+
export declare function resetLongLivedTransactionReportsForTests(): void;
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.MAX_LONG_LIVED_TRANSACTION_REPORTS_PER_PASS = void 0;
|
|
37
|
+
exports.rebaseLongLivedTransactionReports = rebaseLongLivedTransactionReports;
|
|
38
|
+
exports.getReportThresholdMs = getReportThresholdMs;
|
|
39
|
+
exports.runLongLivedTransactionSweep = runLongLivedTransactionSweep;
|
|
40
|
+
exports.startLongLivedTransactionReporting = startLongLivedTransactionReporting;
|
|
41
|
+
exports.createLongLivedHolderReportBudget = createLongLivedHolderReportBudget;
|
|
42
|
+
exports.finishLongLivedHolderReports = finishLongLivedHolderReports;
|
|
43
|
+
exports.reportLongLivedHolder = reportLongLivedHolder;
|
|
44
|
+
exports.describeHolderCandidates = describeHolderCandidates;
|
|
45
|
+
exports.setRegistryStatusForTests = setRegistryStatusForTests;
|
|
46
|
+
exports.resetLongLivedTransactionReportsForTests = resetLongLivedTransactionReportsForTests;
|
|
47
|
+
const node_worker_threads_1 = require("node:worker_threads");
|
|
48
|
+
const node_path_1 = require("node:path");
|
|
49
|
+
const rocksdb_js_1 = require("@harperfast/rocksdb-js");
|
|
50
|
+
const logger_ts_1 = require("../utility/logging/logger.js");
|
|
51
|
+
const hdbTerms_ts_1 = require("../utility/hdbTerms.js");
|
|
52
|
+
const envMngr = __importStar(require("../utility/environment/environmentManager.js"));
|
|
53
|
+
const common_utils_ts_1 = require("../utility/common_utils.js");
|
|
54
|
+
const DEFAULT_REPORT_THRESHOLD_MS = 300000;
|
|
55
|
+
const SWEEP_INTERVAL_MS = 60000;
|
|
56
|
+
// One line per over-age handle would, against a large leak, block the main thread's socket routing
|
|
57
|
+
// for as long as it took to format them. The per-handle backoff below rotates the cap over the whole
|
|
58
|
+
// set across passes, so every holder is still named eventually.
|
|
59
|
+
exports.MAX_LONG_LIVED_TRANSACTION_REPORTS_PER_PASS = 10;
|
|
60
|
+
const MAX_HOLDER_CANDIDATES = 3;
|
|
61
|
+
// The sweep prunes against the handles it just enumerated; the attribution map has no such
|
|
62
|
+
// enumeration, so its entries expire instead. Far longer than a sweep interval, so a still-live
|
|
63
|
+
// holder keeps its backoff.
|
|
64
|
+
const ATTRIBUTION_STATE_TTL_MS = 3600000;
|
|
65
|
+
// The prune is O(map) and the monitor calls reportLongLivedHolder once per over-threshold transaction
|
|
66
|
+
// per tick, so pruning per call is O(N^2) in exactly the leak this reporting exists to describe.
|
|
67
|
+
const ATTRIBUTION_PRUNE_INTERVAL_MS = 60000;
|
|
68
|
+
let registryStatusFn = typeof rocksdb_js_1.registryStatus === 'function' ? rocksdb_js_1.registryStatus : undefined;
|
|
69
|
+
const sweepReports = new Map();
|
|
70
|
+
const attributionReports = new Map();
|
|
71
|
+
let sweepTimer;
|
|
72
|
+
let invalidThresholdWarned = false;
|
|
73
|
+
let missingDetailsWarned = false;
|
|
74
|
+
let lastAttributionPruneAt = 0;
|
|
75
|
+
let thresholdInEffectMs = -1;
|
|
76
|
+
function reportKey(databasePath, nativeId, openedAt) {
|
|
77
|
+
return `${databasePath ?? '?'} ${nativeId}${openedAt == null ? '' : ` ${openedAt}`}`;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Record this observation of a handle and return its report state. A shrinking age means the id was
|
|
81
|
+
* reused by a reopened descriptor, so the previous holder's backoff must not suppress the new one.
|
|
82
|
+
*/
|
|
83
|
+
function observeHandle(reports, key, ageMs, thresholdMs) {
|
|
84
|
+
let state = reports.get(key);
|
|
85
|
+
if (state && ageMs < state.lastAgeMs)
|
|
86
|
+
state = undefined;
|
|
87
|
+
if (!state) {
|
|
88
|
+
state = { nextReportAgeMs: thresholdMs, lastAgeMs: ageMs, touchedAt: 0 };
|
|
89
|
+
reports.set(key, state);
|
|
90
|
+
}
|
|
91
|
+
state.lastAgeMs = ageMs;
|
|
92
|
+
state.touchedAt = Date.now();
|
|
93
|
+
return state;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Drop the accrued backoff when the configured threshold changes, so a handle already under
|
|
97
|
+
* observation is re-measured against the new one. Without this, `nextReportAgeMs` keeps whatever it
|
|
98
|
+
* was given at first observation: lowering the threshold during an incident would not bring a
|
|
99
|
+
* silent handle's first report forward, and raising it would not quiet one. Reporting each live
|
|
100
|
+
* holder once more at the new threshold is what an operator who just changed it is asking for.
|
|
101
|
+
*/
|
|
102
|
+
function rebaseIfThresholdChanged(thresholdMs) {
|
|
103
|
+
if (thresholdMs === thresholdInEffectMs)
|
|
104
|
+
return;
|
|
105
|
+
thresholdInEffectMs = thresholdMs;
|
|
106
|
+
sweepReports.clear();
|
|
107
|
+
attributionReports.clear();
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Apply a live threshold at the start of every reporting pass, including one that finds no eligible
|
|
111
|
+
* holder. Otherwise a threshold raised above a holder's age leaves its old attribution backoff in
|
|
112
|
+
* place when the threshold is lowered again.
|
|
113
|
+
*/
|
|
114
|
+
function rebaseLongLivedTransactionReports(thresholdMs) {
|
|
115
|
+
rebaseIfThresholdChanged(thresholdMs);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Push this handle's next report out to twice its current age, so one held for hours produces a
|
|
119
|
+
* handful of lines rather than one per pass. Called only where a line was actually emitted: advancing
|
|
120
|
+
* it for a handle the per-pass cap skipped would silence that handle without ever naming it.
|
|
121
|
+
*/
|
|
122
|
+
function markReported(state, ageMs) {
|
|
123
|
+
state.nextReportAgeMs = ageMs * 2;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* How old a native transaction handle must be before it is reported, in ms; 0 disables every surface
|
|
127
|
+
* here. Read per pass rather than cached so a live config reload takes effect. A value that cannot
|
|
128
|
+
* be a duration falls back to the default instead of silently disabling reporting.
|
|
129
|
+
*/
|
|
130
|
+
function getReportThresholdMs() {
|
|
131
|
+
const configured = envMngr.get(hdbTerms_ts_1.CONFIG_PARAMS.STORAGE_LONGTRANSACTIONREPORTTHRESHOLD);
|
|
132
|
+
if (configured == null)
|
|
133
|
+
return DEFAULT_REPORT_THRESHOLD_MS;
|
|
134
|
+
// convertToMS returns 0 for anything that is neither string nor number, which YAML hands us for
|
|
135
|
+
// `yes`/`no` (booleans) and for an object left by a config merge — indistinguishable from the
|
|
136
|
+
// documented 0 that disables reporting, so it would silently switch off what the operator configured.
|
|
137
|
+
const ms = typeof configured === 'string' || typeof configured === 'number' ? (0, common_utils_ts_1.convertToMS)(configured) : NaN;
|
|
138
|
+
if (ms === 0)
|
|
139
|
+
return 0;
|
|
140
|
+
if (!Number.isFinite(ms) || ms < 0) {
|
|
141
|
+
if (!invalidThresholdWarned) {
|
|
142
|
+
invalidThresholdWarned = true;
|
|
143
|
+
logger_ts_1.logger.warn?.(`Invalid storage.longTransactionReportThreshold "${configured}"; using default ${DEFAULT_REPORT_THRESHOLD_MS}ms`);
|
|
144
|
+
}
|
|
145
|
+
return DEFAULT_REPORT_THRESHOLD_MS;
|
|
146
|
+
}
|
|
147
|
+
return ms;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Report every native transaction handle in the process-global rocksdb-js registry that has been open
|
|
151
|
+
* past the threshold — including handles no `DatabaseTransaction` owns, which is the one class of
|
|
152
|
+
* holder no other surface can see (harper#2471). The registry spans worker threads, so this runs on
|
|
153
|
+
* the main thread only; a per-thread sweep would report each handle once per worker.
|
|
154
|
+
*/
|
|
155
|
+
function runLongLivedTransactionSweep() {
|
|
156
|
+
try {
|
|
157
|
+
const thresholdMs = getReportThresholdMs();
|
|
158
|
+
rebaseLongLivedTransactionReports(thresholdMs);
|
|
159
|
+
if (thresholdMs === 0 || !registryStatusFn)
|
|
160
|
+
return;
|
|
161
|
+
const status = registryStatusFn();
|
|
162
|
+
const seen = new Set();
|
|
163
|
+
const due = [];
|
|
164
|
+
let missingDetails = false;
|
|
165
|
+
for (const database of status) {
|
|
166
|
+
const details = database.transactionDetails;
|
|
167
|
+
if (!details) {
|
|
168
|
+
missingDetails = true;
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
for (const handle of details) {
|
|
172
|
+
if (handle.ageMs < thresholdMs)
|
|
173
|
+
continue;
|
|
174
|
+
const key = reportKey(database.path, handle.id);
|
|
175
|
+
seen.add(key);
|
|
176
|
+
const state = observeHandle(sweepReports, key, handle.ageMs, thresholdMs);
|
|
177
|
+
if (handle.ageMs >= state.nextReportAgeMs)
|
|
178
|
+
due.push({ path: database.path, id: handle.id, ageMs: handle.ageMs, state });
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
for (const key of sweepReports.keys())
|
|
182
|
+
if (!seen.has(key))
|
|
183
|
+
sweepReports.delete(key);
|
|
184
|
+
if (missingDetails && !missingDetailsWarned) {
|
|
185
|
+
missingDetailsWarned = true;
|
|
186
|
+
logger_ts_1.logger.warn?.('Long-lived transaction reporting is degraded: the installed @harperfast/rocksdb-js does not expose registryStatus().transactionDetails (requires 2.8.0)');
|
|
187
|
+
}
|
|
188
|
+
if (due.length === 0)
|
|
189
|
+
return;
|
|
190
|
+
due.sort((a, b) => b.ageMs - a.ageMs);
|
|
191
|
+
for (const handle of due.slice(0, exports.MAX_LONG_LIVED_TRANSACTION_REPORTS_PER_PASS)) {
|
|
192
|
+
markReported(handle.state, handle.ageMs);
|
|
193
|
+
logger_ts_1.logger.warn?.(`Long-lived RocksDB transaction handle: id ${handle.id} has been open for ${(0, common_utils_ts_1.prettyDuration)(handle.ageMs)} on database ${handle.path ?? '?'}. ` +
|
|
194
|
+
`A handle this old can hold write intents that park other writers' commits, and may pin a read snapshot that blocks version reclamation.`);
|
|
195
|
+
}
|
|
196
|
+
if (due.length > exports.MAX_LONG_LIVED_TRANSACTION_REPORTS_PER_PASS) {
|
|
197
|
+
logger_ts_1.logger.warn?.(`${due.length - exports.MAX_LONG_LIVED_TRANSACTION_REPORTS_PER_PASS} further RocksDB transaction handle(s) are open past the ${(0, common_utils_ts_1.prettyDuration)(thresholdMs)} reporting threshold and were not listed individually.`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
logger_ts_1.logger.error?.('Error sweeping for long-lived transaction handles', error);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Start the periodic sweep. Armed unconditionally on the main thread — the pass itself honors a live
|
|
206
|
+
* threshold change, including one that disables it — and idempotent because the thread startup path
|
|
207
|
+
* that calls it can run more than once.
|
|
208
|
+
*/
|
|
209
|
+
function startLongLivedTransactionReporting() {
|
|
210
|
+
if (!node_worker_threads_1.isMainThread || sweepTimer)
|
|
211
|
+
return;
|
|
212
|
+
if (!registryStatusFn) {
|
|
213
|
+
logger_ts_1.logger.debug?.('Long-lived transaction reporting unavailable; @harperfast/rocksdb-js exposes no registryStatus()');
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
sweepTimer = setInterval(runLongLivedTransactionSweep, SWEEP_INTERVAL_MS).unref();
|
|
217
|
+
}
|
|
218
|
+
function createLongLivedHolderReportBudget(thresholdMs) {
|
|
219
|
+
return { remaining: exports.MAX_LONG_LIVED_TRANSACTION_REPORTS_PER_PASS, skipped: 0, thresholdMs };
|
|
220
|
+
}
|
|
221
|
+
function finishLongLivedHolderReports(reportBudget) {
|
|
222
|
+
if (reportBudget.skipped === 0)
|
|
223
|
+
return;
|
|
224
|
+
try {
|
|
225
|
+
logger_ts_1.logger.warn?.(`${reportBudget.skipped} further Harper transaction holder(s) are open past the ${(0, common_utils_ts_1.prettyDuration)(reportBudget.thresholdMs)} reporting threshold and were deferred.`);
|
|
226
|
+
}
|
|
227
|
+
catch { }
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Report a handle this thread owns, with the attribution the registry sweep cannot supply. The native
|
|
231
|
+
* id is the join key between the two: the sweep names an id, this names who holds it and which state
|
|
232
|
+
* kept the open-transaction monitor from reaping it (harper#2471). Never throws — the monitor
|
|
233
|
+
* interval that calls it has no handler.
|
|
234
|
+
*/
|
|
235
|
+
function reportLongLivedHolder(holder, reportBudget) {
|
|
236
|
+
try {
|
|
237
|
+
if (!registryStatusFn)
|
|
238
|
+
return;
|
|
239
|
+
const thresholdMs = reportBudget?.thresholdMs ?? getReportThresholdMs();
|
|
240
|
+
rebaseLongLivedTransactionReports(thresholdMs);
|
|
241
|
+
if (thresholdMs === 0)
|
|
242
|
+
return;
|
|
243
|
+
const now = Date.now();
|
|
244
|
+
if (now - lastAttributionPruneAt >= ATTRIBUTION_PRUNE_INTERVAL_MS) {
|
|
245
|
+
lastAttributionPruneAt = now;
|
|
246
|
+
const expiredBefore = now - ATTRIBUTION_STATE_TTL_MS;
|
|
247
|
+
for (const [key, state] of attributionReports)
|
|
248
|
+
if (state.touchedAt < expiredBefore)
|
|
249
|
+
attributionReports.delete(key);
|
|
250
|
+
}
|
|
251
|
+
const state = observeHandle(attributionReports, reportKey(holder.databasePath, holder.nativeId, holder.openedAt), holder.ageMs, thresholdMs);
|
|
252
|
+
if (holder.ageMs < state.nextReportAgeMs)
|
|
253
|
+
return;
|
|
254
|
+
if (reportBudget && reportBudget.remaining <= 0) {
|
|
255
|
+
reportBudget.skipped++;
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
markReported(state, holder.ageMs);
|
|
259
|
+
if (reportBudget)
|
|
260
|
+
reportBudget.remaining--;
|
|
261
|
+
const table = holder.tableName ? `.${holder.tableName}` : '';
|
|
262
|
+
logger_ts_1.logger.warn?.(`Harper transaction has held RocksDB transaction ${holder.nativeId} for ${(0, common_utils_ts_1.prettyDuration)(holder.ageMs)} ` +
|
|
263
|
+
`on thread ${node_worker_threads_1.threadId}, database ${holder.databaseName ?? '?'}${table} (${holder.databasePath ?? '?'}), ` +
|
|
264
|
+
`holding ${holder.countPendingWrites()} staged write(s), state: ${holder.states.join('+')}` +
|
|
265
|
+
(holder.timeoutBudget ? `, open-transaction budget ${holder.timeoutBudget}ms` : '') +
|
|
266
|
+
(holder.startedFrom?.resourceName
|
|
267
|
+
? `, started from ${holder.startedFrom.resourceName}${holder.startedFrom.method ? '.' + holder.startedFrom.method : ''}`
|
|
268
|
+
: '') +
|
|
269
|
+
'. It is not being reaped by the open-transaction monitor; the state tells you why.');
|
|
270
|
+
}
|
|
271
|
+
catch (error) {
|
|
272
|
+
logger_ts_1.logger.debug?.('Failed to report a long-lived transaction holder', error);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* The live handles that could be holding the write intent a stuck commit is parked on, as a sentence
|
|
277
|
+
* to append to that commit's log. A handle on another database is offered too, labelled with its path:
|
|
278
|
+
* the verification table is one process-global slot array whose hash mixes in the database id, so a
|
|
279
|
+
* holder in `system` or `oauth` collides with — and parks — a `data` commit at the same rate two `data`
|
|
280
|
+
* keys do. Rank puts the stuck commit's own database first, then age. Age only ranks: a coordinated
|
|
281
|
+
* retry parks on whichever transaction holds the slot when the commit reaches it, which can be younger
|
|
282
|
+
* than the commit itself, so filtering by age could drop the real holder.
|
|
283
|
+
* Returns '' rather than throwing — the caller's own 503 must survive a failure here.
|
|
284
|
+
*/
|
|
285
|
+
function describeHolderCandidates(databasePath, excludeNativeId) {
|
|
286
|
+
if (!databasePath || !registryStatusFn)
|
|
287
|
+
return '';
|
|
288
|
+
try {
|
|
289
|
+
if (getReportThresholdMs() === 0)
|
|
290
|
+
return '';
|
|
291
|
+
const target = (0, node_path_1.resolve)(databasePath);
|
|
292
|
+
const candidates = [];
|
|
293
|
+
let targetSeen = false;
|
|
294
|
+
let targetHasDetails = false;
|
|
295
|
+
for (const database of registryStatusFn()) {
|
|
296
|
+
// An entry with no path can never be the target, and resolve() would throw on it — which,
|
|
297
|
+
// inside this loop, would drop the candidate list for every database rather than just this one.
|
|
298
|
+
const sameDatabase = database.path != null && (0, node_path_1.resolve)(database.path) === target;
|
|
299
|
+
const details = database.transactionDetails;
|
|
300
|
+
if (sameDatabase) {
|
|
301
|
+
targetSeen = true;
|
|
302
|
+
if (details)
|
|
303
|
+
targetHasDetails = true;
|
|
304
|
+
}
|
|
305
|
+
if (!details)
|
|
306
|
+
continue;
|
|
307
|
+
for (const handle of details)
|
|
308
|
+
if (!sameDatabase || handle.id !== excludeNativeId)
|
|
309
|
+
candidates.push({ id: handle.id, ageMs: handle.ageMs, sameDatabase, path: database.path });
|
|
310
|
+
}
|
|
311
|
+
if (!targetHasDetails) {
|
|
312
|
+
// A database with no other handles is normal; no entry at all means the join between a store's
|
|
313
|
+
// path and the registry's path has drifted, which is the one worth telling an operator apart.
|
|
314
|
+
logger_ts_1.logger.debug?.(targetSeen
|
|
315
|
+
? `Registry entry for ${target} exposes no transactionDetails; only other databases' handles can be offered as holder candidates for its stuck commit`
|
|
316
|
+
: `No registry entry for ${target}; only other databases' handles can be offered as holder candidates for its stuck commit`);
|
|
317
|
+
}
|
|
318
|
+
if (candidates.length === 0)
|
|
319
|
+
return '';
|
|
320
|
+
candidates.sort((a, b) => Number(b.sameDatabase) - Number(a.sameDatabase) || b.ageMs - a.ageMs);
|
|
321
|
+
const shortlist = candidates.slice(0, MAX_HOLDER_CANDIDATES);
|
|
322
|
+
// Ranking this database first and then capping can bury the one candidate the cross-database
|
|
323
|
+
// search exists to surface: a busy database routinely has MAX_HOLDER_CANDIDATES handles of its
|
|
324
|
+
// own, so a foreign holder would only ever appear inside the "and N more" count. Give the oldest
|
|
325
|
+
// one the last slot instead.
|
|
326
|
+
if (shortlist.length === MAX_HOLDER_CANDIDATES && shortlist.every((candidate) => candidate.sameDatabase)) {
|
|
327
|
+
const foreign = candidates.find((candidate) => !candidate.sameDatabase);
|
|
328
|
+
if (foreign)
|
|
329
|
+
shortlist[MAX_HOLDER_CANDIDATES - 1] = foreign;
|
|
330
|
+
}
|
|
331
|
+
const named = shortlist
|
|
332
|
+
.map((candidate) => `${candidate.id} (open ${(0, common_utils_ts_1.prettyDuration)(candidate.ageMs)}${candidate.sameDatabase ? '' : ` on ${candidate.path ?? '?'}`})`)
|
|
333
|
+
.join(', ');
|
|
334
|
+
return (` Live transaction handles, any of which could hold the write intent this commit is parked on ` +
|
|
335
|
+
`(the verification table is one process-global slot array, so a handle on another database can hold it), ` +
|
|
336
|
+
`this database first, oldest first: ${named}` +
|
|
337
|
+
(candidates.length > MAX_HOLDER_CANDIDATES ? `, and ${candidates.length - MAX_HOLDER_CANDIDATES} more.` : '.'));
|
|
338
|
+
}
|
|
339
|
+
catch {
|
|
340
|
+
return '';
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
function setRegistryStatusForTests(fn) {
|
|
344
|
+
registryStatusFn = fn;
|
|
345
|
+
}
|
|
346
|
+
function resetLongLivedTransactionReportsForTests() {
|
|
347
|
+
sweepReports.clear();
|
|
348
|
+
attributionReports.clear();
|
|
349
|
+
invalidThresholdWarned = false;
|
|
350
|
+
missingDetailsWarned = false;
|
|
351
|
+
lastAttributionPruneAt = 0;
|
|
352
|
+
thresholdInEffectMs = -1;
|
|
353
|
+
if (sweepTimer) {
|
|
354
|
+
clearInterval(sweepTimer);
|
|
355
|
+
sweepTimer = undefined;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
//# sourceMappingURL=longLivedTransactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"longLivedTransactions.js","sourceRoot":"","sources":["../../resources/longLivedTransactions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiFA,8EAEC;AAgBD,oDAkBC;AAQD,oEAgDC;AAOD,gFAOC;AAwBD,8EAEC;AAED,oEAOC;AAQD,sDAwCC;AAYD,4DA4DC;AAED,8DAEC;AAED,4FAWC;AAvWD,6DAA6D;AAC7D,yCAAoC;AACpC,uDAAwD;AACxD,4DAAsD;AACtD,wDAAuD;AACvD,sFAAwE;AACxE,gEAAyE;AAEzE,MAAM,2BAA2B,GAAG,MAAM,CAAC;AAC3C,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAChC,mGAAmG;AACnG,qGAAqG;AACrG,gEAAgE;AACnD,QAAA,2CAA2C,GAAG,EAAE,CAAC;AAC9D,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,2FAA2F;AAC3F,gGAAgG;AAChG,4BAA4B;AAC5B,MAAM,wBAAwB,GAAG,OAAO,CAAC;AACzC,sGAAsG;AACtG,iGAAiG;AACjG,MAAM,6BAA6B,GAAG,KAAK,CAAC;AAG5C,IAAI,gBAAgB,GAAiC,OAAO,2BAAc,KAAK,UAAU,CAAC,CAAC,CAAC,2BAAc,CAAC,CAAC,CAAC,SAAS,CAAC;AAKvH,MAAM,YAAY,GAAG,IAAI,GAAG,EAAuB,CAAC;AACpD,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAuB,CAAC;AAC1D,IAAI,UAAsC,CAAC;AAC3C,IAAI,sBAAsB,GAAG,KAAK,CAAC;AACnC,IAAI,oBAAoB,GAAG,KAAK,CAAC;AACjC,IAAI,sBAAsB,GAAG,CAAC,CAAC;AAC/B,IAAI,mBAAmB,GAAG,CAAC,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AAC;QACR,OAAO,EAAE,CAAC;IACX,CAAC;AACF,CAAC;AAED,SAAgB,yBAAyB,CAAC,EAAqB;IAC9D,gBAAgB,GAAG,EAAE,CAAC;AACvB,CAAC;AAED,SAAgB,wCAAwC;IACvD,YAAY,CAAC,KAAK,EAAE,CAAC;IACrB,kBAAkB,CAAC,KAAK,EAAE,CAAC;IAC3B,sBAAsB,GAAG,KAAK,CAAC;IAC/B,oBAAoB,GAAG,KAAK,CAAC;IAC7B,sBAAsB,GAAG,CAAC,CAAC;IAC3B,mBAAmB,GAAG,CAAC,CAAC,CAAC;IACzB,IAAI,UAAU,EAAE,CAAC;QAChB,aAAa,CAAC,UAAU,CAAC,CAAC;QAC1B,UAAU,GAAG,SAAS,CAAC;IACxB,CAAC;AACF,CAAC"}
|
|
@@ -18,10 +18,36 @@ import type { DefineBackendSpec, ModelBackend } from './types.ts';
|
|
|
18
18
|
* step) lands in Phase 2 alongside the first real backend.
|
|
19
19
|
*/
|
|
20
20
|
type ModelKind = 'embedding' | 'generative';
|
|
21
|
+
/** A registration a factory made during construction, deferred to the caller. */
|
|
22
|
+
export interface CapturedInstall {
|
|
23
|
+
kind: ModelKind;
|
|
24
|
+
logicalName: string;
|
|
25
|
+
backend: ModelBackend;
|
|
26
|
+
}
|
|
21
27
|
/** Map `logicalName` to a backend for embedding calls. Re-set replaces. */
|
|
22
28
|
export declare function setEmbedding(logicalName: string, backend: ModelBackend): void;
|
|
23
29
|
/** Map `logicalName` to a backend for generative calls. Re-set replaces. */
|
|
24
30
|
export declare function setGenerative(logicalName: string, backend: ModelBackend): void;
|
|
31
|
+
/**
|
|
32
|
+
* Build a backend through its normal registration path but return it instead of installing it, so a
|
|
33
|
+
* config reload can install it conditionally. A scratch logical name would be briefly visible
|
|
34
|
+
* through `listBackends`, which backs the public `GET /v1/models`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function constructBackend(kind: ModelKind, logicalName: string, register: () => void | Promise<void>): Promise<{
|
|
37
|
+
backend?: ModelBackend;
|
|
38
|
+
extras: CapturedInstall[];
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Replace `logicalName`'s backend for `kind` only if it is still `expected`. A plain `set` is atomic
|
|
42
|
+
* but unconditional, so concurrent writers resolve by arrival order rather than by which value is
|
|
43
|
+
* newer. A caller that loses the swap must re-derive from current state rather than overwrite.
|
|
44
|
+
*/
|
|
45
|
+
export declare function replaceIfCurrent(kind: ModelKind, logicalName: string, expected: ModelBackend | undefined, next: ModelBackend): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Remove `logicalName`'s backend for `kind` only if it is still `expected`, returning whether it was
|
|
48
|
+
* removed. Withdrawing a credential must not delete a slot another writer has since taken over.
|
|
49
|
+
*/
|
|
50
|
+
export declare function removeIfCurrent(kind: ModelKind, logicalName: string, expected: ModelBackend | undefined): boolean;
|
|
25
51
|
/** Non-throwing lookup of the backend mapped to `logicalName` for `kind`, or `undefined`. Used by the router to assemble + filter candidate lists without exceptions. */
|
|
26
52
|
export declare function getBackend(kind: ModelKind, logicalName: string): ModelBackend | undefined;
|
|
27
53
|
/**
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ModelBackendRegistrationError = exports.ModelBackendNotFoundError = void 0;
|
|
4
4
|
exports.setEmbedding = setEmbedding;
|
|
5
5
|
exports.setGenerative = setGenerative;
|
|
6
|
+
exports.constructBackend = constructBackend;
|
|
7
|
+
exports.replaceIfCurrent = replaceIfCurrent;
|
|
8
|
+
exports.removeIfCurrent = removeIfCurrent;
|
|
6
9
|
exports.getBackend = getBackend;
|
|
7
10
|
exports.listBackends = listBackends;
|
|
8
11
|
exports.resolveEmbedding = resolveEmbedding;
|
|
@@ -10,16 +13,71 @@ exports.resolveGenerative = resolveGenerative;
|
|
|
10
13
|
exports.registerBackend = registerBackend;
|
|
11
14
|
exports.defineBackend = defineBackend;
|
|
12
15
|
exports.clearRegistry = clearRegistry;
|
|
16
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
13
17
|
const hdbError_ts_1 = require("../../utility/errors/hdbError.js");
|
|
14
18
|
const embedding = new Map();
|
|
15
19
|
const generative = new Map();
|
|
20
|
+
// Async-context scoped: a module-global slot would divert unrelated registrations and collide
|
|
21
|
+
// concurrent constructions.
|
|
22
|
+
const captureScope = new node_async_hooks_1.AsyncLocalStorage();
|
|
23
|
+
function install(kind, logicalName, backend) {
|
|
24
|
+
const slot = captureScope.getStore();
|
|
25
|
+
if (slot?.active) {
|
|
26
|
+
if (slot.kind === kind && slot.logicalName === logicalName)
|
|
27
|
+
slot.backend = backend;
|
|
28
|
+
else
|
|
29
|
+
slot.extras.push({ kind, logicalName, backend });
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
(kind === 'embedding' ? embedding : generative).set(logicalName, backend);
|
|
33
|
+
}
|
|
16
34
|
/** Map `logicalName` to a backend for embedding calls. Re-set replaces. */
|
|
17
35
|
function setEmbedding(logicalName, backend) {
|
|
18
|
-
embedding
|
|
36
|
+
install('embedding', logicalName, backend);
|
|
19
37
|
}
|
|
20
38
|
/** Map `logicalName` to a backend for generative calls. Re-set replaces. */
|
|
21
39
|
function setGenerative(logicalName, backend) {
|
|
22
|
-
generative
|
|
40
|
+
install('generative', logicalName, backend);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Build a backend through its normal registration path but return it instead of installing it, so a
|
|
44
|
+
* config reload can install it conditionally. A scratch logical name would be briefly visible
|
|
45
|
+
* through `listBackends`, which backs the public `GET /v1/models`.
|
|
46
|
+
*/
|
|
47
|
+
async function constructBackend(kind, logicalName, register) {
|
|
48
|
+
const slot = { kind, logicalName, extras: [], active: true };
|
|
49
|
+
try {
|
|
50
|
+
await captureScope.run(slot, async () => {
|
|
51
|
+
await register();
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
slot.active = false;
|
|
56
|
+
}
|
|
57
|
+
return { backend: slot.backend, extras: slot.extras };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Replace `logicalName`'s backend for `kind` only if it is still `expected`. A plain `set` is atomic
|
|
61
|
+
* but unconditional, so concurrent writers resolve by arrival order rather than by which value is
|
|
62
|
+
* newer. A caller that loses the swap must re-derive from current state rather than overwrite.
|
|
63
|
+
*/
|
|
64
|
+
function replaceIfCurrent(kind, logicalName, expected, next) {
|
|
65
|
+
const map = kind === 'embedding' ? embedding : generative;
|
|
66
|
+
if (map.get(logicalName) !== expected)
|
|
67
|
+
return false;
|
|
68
|
+
map.set(logicalName, next);
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Remove `logicalName`'s backend for `kind` only if it is still `expected`, returning whether it was
|
|
73
|
+
* removed. Withdrawing a credential must not delete a slot another writer has since taken over.
|
|
74
|
+
*/
|
|
75
|
+
function removeIfCurrent(kind, logicalName, expected) {
|
|
76
|
+
const map = kind === 'embedding' ? embedding : generative;
|
|
77
|
+
if (map.get(logicalName) !== expected)
|
|
78
|
+
return false;
|
|
79
|
+
map.delete(logicalName);
|
|
80
|
+
return true;
|
|
23
81
|
}
|
|
24
82
|
/** Non-throwing lookup of the backend mapped to `logicalName` for `kind`, or `undefined`. Used by the router to assemble + filter candidate lists without exceptions. */
|
|
25
83
|
function getBackend(kind, logicalName) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backendRegistry.js","sourceRoot":"","sources":["../../../resources/models/backendRegistry.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"backendRegistry.js","sourceRoot":"","sources":["../../../resources/models/backendRegistry.ts"],"names":[],"mappings":";;;AA4DA,oCAEC;AAGD,sCAEC;AAOD,4CAcC;AAOD,4CAUC;AAMD,0CAKC;AAGD,gCAEC;AAOD,oCAGC;AAMD,4CAIC;AAMD,8CAIC;AAoBD,0CAuBC;AASD,sCA6BC;AA8BD,sCAGC;AAzQD,uDAAqD;AACrD,kEAA+D;AAuB/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EAAE,CAAC,IAAI,KAAK,QAAQ;oBAAE,SAAS,CAAC,IAAI,CAAC,EAAc,CAAC,CAAC;YAC9F,CAAC;QACF,CAAC;QACD,MAAM,MAAM,GACX,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;QACzF,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;IACxC,CAAC,CAAC;AACH,CAAC;AAED,mDAAmD;AACnD,SAAgB,aAAa;IAC5B,SAAS,CAAC,KAAK,EAAE,CAAC;IAClB,UAAU,CAAC,KAAK,EAAE,CAAC;AACpB,CAAC;AAED,MAAa,yBAA0B,SAAQ,yBAAW;IACzD,0EAA0E;IAC1E,2EAA2E;IAC3E,YAAY,IAAe,EAAE,WAAmB;QAC/C,KAAK,CAAC,8BAA8B,IAAI,IAAI,WAAW,GAAG,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IACzC,CAAC;CACD;AAPD,8DAOC;AAED,mFAAmF;AACnF,MAAa,6BAA8B,SAAQ,yBAAW;IAC7D,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;IAC7C,CAAC;CACD;AALD,sEAKC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RootConfigWatcher } from '../../config/RootConfigWatcher.ts';
|
|
1
2
|
interface ModelEntry {
|
|
2
3
|
backend?: string;
|
|
3
4
|
host?: string;
|
|
@@ -20,7 +21,38 @@ interface RootConfig {
|
|
|
20
21
|
/**
|
|
21
22
|
* Populate the model registry from `rootConfig.models`. No-op if the block
|
|
22
23
|
* is absent or empty. Idempotent within a process: each entry overwrites any
|
|
23
|
-
* prior registration under the same logical name
|
|
24
|
+
* prior registration under the same logical name.
|
|
24
25
|
*/
|
|
25
26
|
export declare function bootstrapModels(rootConfig: RootConfig | undefined | null): Promise<void>;
|
|
27
|
+
/** Forget everything the projection installed. Test isolation only — never part of a reload. */
|
|
28
|
+
export declare function resetModelsProjection(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Apply a `models:` block as a hot reload: changed entries are rebuilt through the same factories
|
|
31
|
+
* boot uses and swapped in atomically, removed entries stop serving, and programmatic
|
|
32
|
+
* registrations that overrode a config entry are left in place. Serialized and coalesced —
|
|
33
|
+
* concurrent calls settle on the latest block.
|
|
34
|
+
*/
|
|
35
|
+
export declare function applyModelsConfig(models: ModelsConfig | undefined): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Watch the root config file and hot-apply `models:` changes. Follows `harper_logger`'s
|
|
38
|
+
* root-config-watch pattern: one watcher per worker, each worker reprojecting its own registry.
|
|
39
|
+
*
|
|
40
|
+
* The watcher sees the FILE, but `HARPER_DEFAULT_CONFIG` / `HARPER_CONFIG` / `HARPER_SET_CONFIG`
|
|
41
|
+
* compose with it at boot — so if any of those names `models`, the file alone is not authoritative
|
|
42
|
+
* for the block and hot reload stays off, preserving boot semantics unchanged. (That is also the
|
|
43
|
+
* compatibility gate: an orchestrator still injecting models through `HARPER_SET_CONFIG` gets
|
|
44
|
+
* today's restart behavior; one that writes the file instead gets live reload.)
|
|
45
|
+
*
|
|
46
|
+
* Returns whether the watch is active.
|
|
47
|
+
*/
|
|
48
|
+
export declare function startModelsConfigHotReload(options?: {
|
|
49
|
+
configFilePath?: string;
|
|
50
|
+
debounceMs?: number;
|
|
51
|
+
/** Test seam: invoked when a watcher snapshot is observed, before its settle timer is armed. */
|
|
52
|
+
onSnapshotObserved?: () => void;
|
|
53
|
+
/** Test seam: subscribe to this instance (caller-owned) instead of constructing or sharing. */
|
|
54
|
+
watcher?: RootConfigWatcher;
|
|
55
|
+
}): boolean;
|
|
56
|
+
/** Stop watching the config file. The current projection keeps serving. */
|
|
57
|
+
export declare function stopModelsConfigHotReload(): void;
|
|
26
58
|
export {};
|