@harperfast/harper 5.2.9 → 5.3.0-alpha.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.
Files changed (668) hide show
  1. package/agent/mcpTools.ts +1 -1
  2. package/agent/session.ts +25 -14
  3. package/bin/cliOperations.ts +46 -9
  4. package/bin/copyDb.ts +282 -59
  5. package/bin/deploySetup.ts +16 -5
  6. package/bin/harper.ts +1 -1
  7. package/bin/help.ts +4 -1
  8. package/bin/lite.ts +4 -1
  9. package/bin/restart.ts +59 -3
  10. package/bin/run.ts +6 -11
  11. package/bin/upgrade.js +7 -3
  12. package/bin/workloadIdentity.ts +119 -0
  13. package/components/Application.ts +2414 -242
  14. package/components/ApplicationScope.ts +8 -0
  15. package/components/EntryHandler.ts +59 -39
  16. package/components/OptionsWatcher.ts +150 -74
  17. package/components/RuntimeModuleTracker.ts +38 -7
  18. package/components/Scope.ts +37 -15
  19. package/components/awaitRestart.ts +84 -0
  20. package/components/componentLoader.ts +340 -30
  21. package/components/componentPreparationLock.ts +16 -5
  22. package/components/mcp/adapters/harperHttp.ts +4 -0
  23. package/components/mcp/listChanged.ts +4 -0
  24. package/components/mcp/toolRegistry.ts +2 -0
  25. package/components/mcp/tools/operations.ts +9 -0
  26. package/components/mcp/tools/schemas/operationDescriptions.ts +2 -2
  27. package/components/operations.js +270 -78
  28. package/components/operationsValidation.js +49 -1
  29. package/components/status/ComponentStatusRegistry.ts +59 -0
  30. package/config/RootConfigWatcher.ts +80 -34
  31. package/config/configUtils.ts +291 -34
  32. package/config/harperConfigEnvVars.ts +170 -27
  33. package/config-root.schema.json +29 -0
  34. package/dataLayer/blobBackup.ts +160 -50
  35. package/dataLayer/delete.ts +6 -1
  36. package/dataLayer/harperBridge/ResourceBridge.ts +52 -8
  37. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/DeleteAuditLogsBeforeResults.js +3 -1
  38. package/dataLayer/hdbInfoController.ts +34 -1
  39. package/dataLayer/insert.ts +44 -1
  40. package/dataLayer/rocksdbBackup.ts +53 -10
  41. package/dataLayer/schema.ts +11 -1
  42. package/dataLayer/schemaDescribe.ts +8 -1
  43. package/dist/agent/mcpTools.js +1 -1
  44. package/dist/agent/mcpTools.js.map +1 -1
  45. package/dist/agent/session.d.ts +22 -0
  46. package/dist/agent/session.js +26 -15
  47. package/dist/agent/session.js.map +1 -1
  48. package/dist/bin/cliOperations.js +48 -9
  49. package/dist/bin/cliOperations.js.map +1 -1
  50. package/dist/bin/copyDb.d.ts +12 -1
  51. package/dist/bin/copyDb.js +248 -60
  52. package/dist/bin/copyDb.js.map +1 -1
  53. package/dist/bin/deploySetup.d.ts +2 -0
  54. package/dist/bin/deploySetup.js +11 -3
  55. package/dist/bin/deploySetup.js.map +1 -1
  56. package/dist/bin/harper.js +1 -1
  57. package/dist/bin/harper.js.map +1 -1
  58. package/dist/bin/help.js +4 -1
  59. package/dist/bin/help.js.map +1 -1
  60. package/dist/bin/lite.js +4 -1
  61. package/dist/bin/lite.js.map +1 -1
  62. package/dist/bin/restart.js +54 -5
  63. package/dist/bin/restart.js.map +1 -1
  64. package/dist/bin/run.js +4 -10
  65. package/dist/bin/run.js.map +1 -1
  66. package/dist/bin/upgrade.js +4 -3
  67. package/dist/bin/upgrade.js.map +1 -1
  68. package/dist/bin/workloadIdentity.d.ts +18 -0
  69. package/dist/bin/workloadIdentity.js +100 -0
  70. package/dist/bin/workloadIdentity.js.map +1 -0
  71. package/dist/components/Application.d.ts +139 -16
  72. package/dist/components/Application.js +2215 -267
  73. package/dist/components/Application.js.map +1 -1
  74. package/dist/components/ApplicationScope.d.ts +8 -0
  75. package/dist/components/ApplicationScope.js +7 -0
  76. package/dist/components/ApplicationScope.js.map +1 -1
  77. package/dist/components/EntryHandler.js +26 -10
  78. package/dist/components/EntryHandler.js.map +1 -1
  79. package/dist/components/OptionsWatcher.d.ts +1 -0
  80. package/dist/components/OptionsWatcher.js +141 -74
  81. package/dist/components/OptionsWatcher.js.map +1 -1
  82. package/dist/components/RuntimeModuleTracker.js +40 -6
  83. package/dist/components/RuntimeModuleTracker.js.map +1 -1
  84. package/dist/components/Scope.js +38 -13
  85. package/dist/components/Scope.js.map +1 -1
  86. package/dist/components/awaitRestart.d.ts +33 -0
  87. package/dist/components/awaitRestart.js +61 -0
  88. package/dist/components/awaitRestart.js.map +1 -0
  89. package/dist/components/componentLoader.d.ts +38 -1
  90. package/dist/components/componentLoader.js +279 -22
  91. package/dist/components/componentLoader.js.map +1 -1
  92. package/dist/components/componentPreparationLock.d.ts +5 -0
  93. package/dist/components/componentPreparationLock.js +14 -6
  94. package/dist/components/componentPreparationLock.js.map +1 -1
  95. package/dist/components/mcp/adapters/harperHttp.js +4 -0
  96. package/dist/components/mcp/adapters/harperHttp.js.map +1 -1
  97. package/dist/components/mcp/listChanged.js +5 -0
  98. package/dist/components/mcp/listChanged.js.map +1 -1
  99. package/dist/components/mcp/toolRegistry.d.ts +1 -0
  100. package/dist/components/mcp/toolRegistry.js.map +1 -1
  101. package/dist/components/mcp/tools/operations.d.ts +5 -0
  102. package/dist/components/mcp/tools/operations.js +9 -0
  103. package/dist/components/mcp/tools/operations.js.map +1 -1
  104. package/dist/components/mcp/tools/schemas/operationDescriptions.js +2 -2
  105. package/dist/components/mcp/tools/schemas/operationDescriptions.js.map +1 -1
  106. package/dist/components/operations.js +231 -77
  107. package/dist/components/operations.js.map +1 -1
  108. package/dist/components/operationsValidation.js +49 -1
  109. package/dist/components/operationsValidation.js.map +1 -1
  110. package/dist/components/status/ComponentStatusRegistry.d.ts +0 -4
  111. package/dist/components/status/ComponentStatusRegistry.js +63 -0
  112. package/dist/components/status/ComponentStatusRegistry.js.map +1 -1
  113. package/dist/config/RootConfigWatcher.d.ts +7 -1
  114. package/dist/config/RootConfigWatcher.js +64 -27
  115. package/dist/config/RootConfigWatcher.js.map +1 -1
  116. package/dist/config/configUtils.d.ts +9 -1
  117. package/dist/config/configUtils.js +254 -33
  118. package/dist/config/configUtils.js.map +1 -1
  119. package/dist/config/harperConfigEnvVars.d.ts +16 -0
  120. package/dist/config/harperConfigEnvVars.js +162 -25
  121. package/dist/config/harperConfigEnvVars.js.map +1 -1
  122. package/dist/dataLayer/blobBackup.d.ts +49 -20
  123. package/dist/dataLayer/blobBackup.js +139 -50
  124. package/dist/dataLayer/blobBackup.js.map +1 -1
  125. package/dist/dataLayer/delete.js +1 -1
  126. package/dist/dataLayer/delete.js.map +1 -1
  127. package/dist/dataLayer/harperBridge/ResourceBridge.d.ts +14 -1
  128. package/dist/dataLayer/harperBridge/ResourceBridge.js +51 -10
  129. package/dist/dataLayer/harperBridge/ResourceBridge.js.map +1 -1
  130. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/DeleteAuditLogsBeforeResults.d.ts +3 -1
  131. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/DeleteAuditLogsBeforeResults.js +3 -1
  132. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/DeleteAuditLogsBeforeResults.js.map +1 -1
  133. package/dist/dataLayer/hdbInfoController.d.ts +10 -0
  134. package/dist/dataLayer/hdbInfoController.js +30 -1
  135. package/dist/dataLayer/hdbInfoController.js.map +1 -1
  136. package/dist/dataLayer/insert.d.ts +9 -1
  137. package/dist/dataLayer/insert.js +30 -0
  138. package/dist/dataLayer/insert.js.map +1 -1
  139. package/dist/dataLayer/rocksdbBackup.d.ts +2 -2
  140. package/dist/dataLayer/rocksdbBackup.js +45 -8
  141. package/dist/dataLayer/rocksdbBackup.js.map +1 -1
  142. package/dist/dataLayer/schema.js +8 -0
  143. package/dist/dataLayer/schema.js.map +1 -1
  144. package/dist/dataLayer/schemaDescribe.js +8 -1
  145. package/dist/dataLayer/schemaDescribe.js.map +1 -1
  146. package/dist/index.d.ts +1 -1
  147. package/dist/index.js.map +1 -1
  148. package/dist/json/systemSchema.json +52 -0
  149. package/dist/resources/DatabaseTransaction.d.ts +55 -0
  150. package/dist/resources/DatabaseTransaction.js +459 -45
  151. package/dist/resources/DatabaseTransaction.js.map +1 -1
  152. package/dist/resources/LMDBTransaction.js +22 -4
  153. package/dist/resources/LMDBTransaction.js.map +1 -1
  154. package/dist/resources/PrimaryRocksDatabase.d.ts +1 -0
  155. package/dist/resources/PrimaryRocksDatabase.js +29 -0
  156. package/dist/resources/PrimaryRocksDatabase.js.map +1 -1
  157. package/dist/resources/RecordEncoder.d.ts +20 -0
  158. package/dist/resources/RecordEncoder.js +94 -9
  159. package/dist/resources/RecordEncoder.js.map +1 -1
  160. package/dist/resources/RequestTarget.d.ts +2 -0
  161. package/dist/resources/RequestTarget.js.map +1 -1
  162. package/dist/resources/Resource.js +20 -11
  163. package/dist/resources/Resource.js.map +1 -1
  164. package/dist/resources/ResourceInterface.d.ts +20 -1
  165. package/dist/resources/ResourceInterface.js.map +1 -1
  166. package/dist/resources/RocksIndexStore.d.ts +6 -1
  167. package/dist/resources/RocksIndexStore.js +24 -9
  168. package/dist/resources/RocksIndexStore.js.map +1 -1
  169. package/dist/resources/RocksTransactionLogStore.d.ts +14 -1
  170. package/dist/resources/RocksTransactionLogStore.js +57 -17
  171. package/dist/resources/RocksTransactionLogStore.js.map +1 -1
  172. package/dist/resources/Table.d.ts +112 -8
  173. package/dist/resources/Table.js +1073 -191
  174. package/dist/resources/Table.js.map +1 -1
  175. package/dist/resources/auditStore.d.ts +11 -2
  176. package/dist/resources/auditStore.js +325 -71
  177. package/dist/resources/auditStore.js.map +1 -1
  178. package/dist/resources/blob.d.ts +129 -9
  179. package/dist/resources/blob.js +992 -114
  180. package/dist/resources/blob.js.map +1 -1
  181. package/dist/resources/branchDatabase.d.ts +48 -0
  182. package/dist/resources/branchDatabase.js +892 -0
  183. package/dist/resources/branchDatabase.js.map +1 -0
  184. package/dist/resources/crdt.js +50 -12
  185. package/dist/resources/crdt.js.map +1 -1
  186. package/dist/resources/databases.d.ts +150 -0
  187. package/dist/resources/databases.js +1200 -239
  188. package/dist/resources/databases.js.map +1 -1
  189. package/dist/resources/defineTable.d.ts +10 -2
  190. package/dist/resources/defineTable.js +9 -1
  191. package/dist/resources/defineTable.js.map +1 -1
  192. package/dist/resources/graphql.d.ts +1 -1
  193. package/dist/resources/graphql.js +50 -15
  194. package/dist/resources/graphql.js.map +1 -1
  195. package/dist/resources/indexes/HierarchicalNavigableSmallWorld.d.ts +1 -0
  196. package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js +6 -2
  197. package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js.map +1 -1
  198. package/dist/resources/longLivedTransactions.d.ts +71 -0
  199. package/dist/resources/longLivedTransactions.js +358 -0
  200. package/dist/resources/longLivedTransactions.js.map +1 -0
  201. package/dist/resources/models/backendRegistry.d.ts +26 -0
  202. package/dist/resources/models/backendRegistry.js +60 -2
  203. package/dist/resources/models/backendRegistry.js.map +1 -1
  204. package/dist/resources/models/bootstrap.d.ts +33 -1
  205. package/dist/resources/models/bootstrap.js +416 -31
  206. package/dist/resources/models/bootstrap.js.map +1 -1
  207. package/dist/resources/recordLock.d.ts +80 -0
  208. package/dist/resources/recordLock.js +184 -0
  209. package/dist/resources/recordLock.js.map +1 -0
  210. package/dist/resources/replayLogs.d.ts +14 -1
  211. package/dist/resources/replayLogs.js +152 -24
  212. package/dist/resources/replayLogs.js.map +1 -1
  213. package/dist/resources/replayLogsGuards.d.ts +94 -7
  214. package/dist/resources/replayLogsGuards.js +111 -7
  215. package/dist/resources/replayLogsGuards.js.map +1 -1
  216. package/dist/resources/search.js +158 -6
  217. package/dist/resources/search.js.map +1 -1
  218. package/dist/resources/transactionBroadcast.d.ts +1 -1
  219. package/dist/resources/transactionBroadcast.js +2 -2
  220. package/dist/resources/transactionBroadcast.js.map +1 -1
  221. package/dist/security/auth.js +61 -30
  222. package/dist/security/auth.js.map +1 -1
  223. package/dist/security/authn/oidc/claims.d.ts +22 -0
  224. package/dist/security/authn/oidc/claims.js +71 -0
  225. package/dist/security/authn/oidc/claims.js.map +1 -0
  226. package/dist/security/authn/oidc/identityToken.d.ts +27 -0
  227. package/dist/security/authn/oidc/identityToken.js +111 -0
  228. package/dist/security/authn/oidc/identityToken.js.map +1 -0
  229. package/dist/security/authn/oidc/jwks.d.ts +25 -0
  230. package/dist/security/authn/oidc/jwks.js +261 -0
  231. package/dist/security/authn/oidc/jwks.js.map +1 -0
  232. package/dist/security/authn/oidc/providers/generic.d.ts +13 -0
  233. package/dist/security/authn/oidc/providers/generic.js +34 -0
  234. package/dist/security/authn/oidc/providers/generic.js.map +1 -0
  235. package/dist/security/authn/oidc/providers/githubActions.d.ts +11 -0
  236. package/dist/security/authn/oidc/providers/githubActions.js +129 -0
  237. package/dist/security/authn/oidc/providers/githubActions.js.map +1 -0
  238. package/dist/security/authn/oidc/providers/index.d.ts +37 -0
  239. package/dist/security/authn/oidc/providers/index.js +24 -0
  240. package/dist/security/authn/oidc/providers/index.js.map +1 -0
  241. package/dist/security/authn/oidc/tokenExchange.d.ts +12 -0
  242. package/dist/security/authn/oidc/tokenExchange.js +306 -0
  243. package/dist/security/authn/oidc/tokenExchange.js.map +1 -0
  244. package/dist/security/authn/oidc/trustPolicyOperations.d.ts +49 -0
  245. package/dist/security/authn/oidc/trustPolicyOperations.js +358 -0
  246. package/dist/security/authn/oidc/trustPolicyOperations.js.map +1 -0
  247. package/dist/security/authn/oidc/types.d.ts +38 -0
  248. package/dist/security/authn/oidc/types.js +6 -0
  249. package/dist/security/authn/oidc/types.js.map +1 -0
  250. package/dist/security/certificateVerification/index.js +40 -11
  251. package/dist/security/certificateVerification/index.js.map +1 -1
  252. package/dist/security/certificateVerification/trustedIssuers.d.ts +24 -0
  253. package/dist/security/certificateVerification/trustedIssuers.js +79 -0
  254. package/dist/security/certificateVerification/trustedIssuers.js.map +1 -0
  255. package/dist/security/certificateVerification/types.d.ts +1 -0
  256. package/dist/security/credentialProvenance.d.ts +35 -0
  257. package/dist/security/credentialProvenance.js +51 -0
  258. package/dist/security/credentialProvenance.js.map +1 -0
  259. package/dist/security/credentialRejection.d.ts +4 -0
  260. package/dist/security/credentialRejection.js +24 -0
  261. package/dist/security/credentialRejection.js.map +1 -0
  262. package/dist/security/deferredAuthentication.d.ts +36 -0
  263. package/dist/security/deferredAuthentication.js +70 -0
  264. package/dist/security/deferredAuthentication.js.map +1 -0
  265. package/dist/security/impersonation.d.ts +21 -0
  266. package/dist/security/impersonation.js +108 -9
  267. package/dist/security/impersonation.js.map +1 -1
  268. package/dist/security/jsLoader.d.ts +6 -0
  269. package/dist/security/jsLoader.js +75 -15
  270. package/dist/security/jsLoader.js.map +1 -1
  271. package/dist/security/keys.js +301 -71
  272. package/dist/security/keys.js.map +1 -1
  273. package/dist/security/operationScope.d.ts +21 -0
  274. package/dist/security/operationScope.js +36 -0
  275. package/dist/security/operationScope.js.map +1 -0
  276. package/dist/security/permissionsTranslator.js +21 -0
  277. package/dist/security/permissionsTranslator.js.map +1 -1
  278. package/dist/security/tokenAuthentication.d.ts +19 -1
  279. package/dist/security/tokenAuthentication.js +191 -10
  280. package/dist/security/tokenAuthentication.js.map +1 -1
  281. package/dist/security/user.js +4 -3
  282. package/dist/security/user.js.map +1 -1
  283. package/dist/server/DurableSubscriptionsSession.d.ts +2 -2
  284. package/dist/server/DurableSubscriptionsSession.js +67 -10
  285. package/dist/server/DurableSubscriptionsSession.js.map +1 -1
  286. package/dist/server/REST.js +73 -0
  287. package/dist/server/REST.js.map +1 -1
  288. package/dist/server/graphqlQuerying.js +4 -0
  289. package/dist/server/graphqlQuerying.js.map +1 -1
  290. package/dist/server/http.d.ts +11 -0
  291. package/dist/server/http.js +88 -15
  292. package/dist/server/http.js.map +1 -1
  293. package/dist/server/itc/serverHandlers.js +8 -1
  294. package/dist/server/itc/serverHandlers.js.map +1 -1
  295. package/dist/server/jobs/jobProcess.js +6 -2
  296. package/dist/server/jobs/jobProcess.js.map +1 -1
  297. package/dist/server/jobs/jobs.js +4 -1
  298. package/dist/server/jobs/jobs.js.map +1 -1
  299. package/dist/server/liveSubscriptionAuth.d.ts +26 -4
  300. package/dist/server/liveSubscriptionAuth.js +105 -39
  301. package/dist/server/liveSubscriptionAuth.js.map +1 -1
  302. package/dist/server/loadRootComponents.js +49 -10
  303. package/dist/server/loadRootComponents.js.map +1 -1
  304. package/dist/server/mqtt.d.ts +2 -0
  305. package/dist/server/mqtt.js +165 -30
  306. package/dist/server/mqtt.js.map +1 -1
  307. package/dist/server/nodeName.d.ts +2 -0
  308. package/dist/server/nodeName.js +107 -23
  309. package/dist/server/nodeName.js.map +1 -1
  310. package/dist/server/serverHelpers/Headers.d.ts +25 -0
  311. package/dist/server/serverHelpers/Headers.js +139 -1
  312. package/dist/server/serverHelpers/Headers.js.map +1 -1
  313. package/dist/server/serverHelpers/contentTypes.d.ts +9 -0
  314. package/dist/server/serverHelpers/contentTypes.js +32 -25
  315. package/dist/server/serverHelpers/contentTypes.js.map +1 -1
  316. package/dist/server/serverHelpers/deployValidationState.d.ts +3 -0
  317. package/dist/server/serverHelpers/deployValidationState.js +9 -19
  318. package/dist/server/serverHelpers/deployValidationState.js.map +1 -1
  319. package/dist/server/serverHelpers/operationAuthorizationState.d.ts +12 -0
  320. package/dist/server/serverHelpers/operationAuthorizationState.js +24 -2
  321. package/dist/server/serverHelpers/operationAuthorizationState.js.map +1 -1
  322. package/dist/server/serverHelpers/registeredOperations.d.ts +5 -4
  323. package/dist/server/serverHelpers/registeredOperations.js +74 -21
  324. package/dist/server/serverHelpers/registeredOperations.js.map +1 -1
  325. package/dist/server/serverHelpers/requestSanitization.d.ts +11 -0
  326. package/dist/server/serverHelpers/requestSanitization.js +20 -0
  327. package/dist/server/serverHelpers/requestSanitization.js.map +1 -0
  328. package/dist/server/serverHelpers/serverHandlers.js +6 -3
  329. package/dist/server/serverHelpers/serverHandlers.js.map +1 -1
  330. package/dist/server/serverHelpers/serverUtilities.d.ts +18 -0
  331. package/dist/server/serverHelpers/serverUtilities.js +90 -20
  332. package/dist/server/serverHelpers/serverUtilities.js.map +1 -1
  333. package/dist/server/serverHelpers/sharedMessageEncoding.d.ts +67 -0
  334. package/dist/server/serverHelpers/sharedMessageEncoding.js +280 -0
  335. package/dist/server/serverHelpers/sharedMessageEncoding.js.map +1 -0
  336. package/dist/server/serverHelpers/uwsServer.js +19 -1
  337. package/dist/server/serverHelpers/uwsServer.js.map +1 -1
  338. package/dist/server/static.js +24 -28
  339. package/dist/server/static.js.map +1 -1
  340. package/dist/server/storageReclamation.d.ts +12 -0
  341. package/dist/server/storageReclamation.js +26 -0
  342. package/dist/server/storageReclamation.js.map +1 -1
  343. package/dist/server/threads/itc.d.ts +7 -2
  344. package/dist/server/threads/itc.js +5 -1
  345. package/dist/server/threads/itc.js.map +1 -1
  346. package/dist/server/threads/manageThreads.d.ts +26 -3
  347. package/dist/server/threads/manageThreads.js +517 -65
  348. package/dist/server/threads/manageThreads.js.map +1 -1
  349. package/dist/server/threads/socketRouter.js +89 -26
  350. package/dist/server/threads/socketRouter.js.map +1 -1
  351. package/dist/server/threads/threadHeapMemory.d.ts +2 -0
  352. package/dist/server/threads/threadHeapMemory.js +31 -0
  353. package/dist/server/threads/threadHeapMemory.js.map +1 -0
  354. package/dist/server/threads/threadServer.js +46 -15
  355. package/dist/server/threads/threadServer.js.map +1 -1
  356. package/dist/sqlEngine/config.d.ts +1 -3
  357. package/dist/sqlEngine/config.js +19 -16
  358. package/dist/sqlEngine/config.js.map +1 -1
  359. package/dist/sqlTranslator/index.d.ts +1 -1
  360. package/dist/sqlTranslator/index.js +30 -7
  361. package/dist/sqlTranslator/index.js.map +1 -1
  362. package/dist/upgrade/directives/5-3-0.d.ts +7 -0
  363. package/dist/upgrade/directives/5-3-0.js +148 -0
  364. package/dist/upgrade/directives/5-3-0.js.map +1 -0
  365. package/dist/upgrade/directives/directivesController.js +2 -1
  366. package/dist/upgrade/directives/directivesController.js.map +1 -1
  367. package/dist/utility/OperationFunctionCaller.js +2 -1
  368. package/dist/utility/OperationFunctionCaller.js.map +1 -1
  369. package/dist/utility/common_utils.d.ts +16 -0
  370. package/dist/utility/common_utils.js +32 -6
  371. package/dist/utility/common_utils.js.map +1 -1
  372. package/dist/utility/componentNames.d.ts +8 -0
  373. package/dist/utility/componentNames.js +12 -1
  374. package/dist/utility/componentNames.js.map +1 -1
  375. package/dist/utility/environment/environmentManager.js +3 -6
  376. package/dist/utility/environment/environmentManager.js.map +1 -1
  377. package/dist/utility/environment/systemInformation.d.ts +1 -0
  378. package/dist/utility/environment/systemInformation.js +1 -0
  379. package/dist/utility/environment/systemInformation.js.map +1 -1
  380. package/dist/utility/errors/commonErrors.d.ts +2 -0
  381. package/dist/utility/errors/commonErrors.js +2 -0
  382. package/dist/utility/errors/commonErrors.js.map +1 -1
  383. package/dist/utility/errors/hdbError.d.ts +17 -0
  384. package/dist/utility/errors/hdbError.js +30 -1
  385. package/dist/utility/errors/hdbError.js.map +1 -1
  386. package/dist/utility/globalSchema.d.ts +18 -0
  387. package/dist/utility/hdbTerms.d.ts +16 -0
  388. package/dist/utility/hdbTerms.js +18 -2
  389. package/dist/utility/hdbTerms.js.map +1 -1
  390. package/dist/utility/logging/harper_logger.d.ts +2 -0
  391. package/dist/utility/logging/harper_logger.js +91 -14
  392. package/dist/utility/logging/harper_logger.js.map +1 -1
  393. package/dist/utility/logging/logRotator.js +76 -49
  394. package/dist/utility/logging/logRotator.js.map +1 -1
  395. package/dist/utility/nodeIdentity.d.ts +9 -0
  396. package/dist/utility/nodeIdentity.js +58 -0
  397. package/dist/utility/nodeIdentity.js.map +1 -0
  398. package/dist/utility/npmUtilities.js +9 -7
  399. package/dist/utility/npmUtilities.js.map +1 -1
  400. package/dist/utility/operationPermissions.d.ts +3 -1
  401. package/dist/utility/operationPermissions.js +16 -1
  402. package/dist/utility/operationPermissions.js.map +1 -1
  403. package/dist/utility/operation_authorization.d.ts +10 -7
  404. package/dist/utility/operation_authorization.js +212 -41
  405. package/dist/utility/operation_authorization.js.map +1 -1
  406. package/dist/utility/watchPath.d.ts +29 -0
  407. package/dist/utility/watchPath.js +68 -0
  408. package/dist/utility/watchPath.js.map +1 -0
  409. package/dist/utility/watcherFallback.d.ts +86 -0
  410. package/dist/utility/watcherFallback.js +278 -1
  411. package/dist/utility/watcherFallback.js.map +1 -1
  412. package/dist/validation/configValidator.d.ts +12 -0
  413. package/dist/validation/configValidator.js +199 -72
  414. package/dist/validation/configValidator.js.map +1 -1
  415. package/dist/validation/installValidator.js +12 -0
  416. package/dist/validation/installValidator.js.map +1 -1
  417. package/dist/validation/validationWrapper.d.ts +11 -0
  418. package/dist/validation/validationWrapper.js +16 -3
  419. package/dist/validation/validationWrapper.js.map +1 -1
  420. package/index.ts +2 -0
  421. package/json/systemSchema.json +52 -0
  422. package/npm-shrinkwrap.json +196 -194
  423. package/package.json +7 -6
  424. package/resources/DESIGN.md +114 -52
  425. package/resources/DatabaseTransaction.ts +521 -43
  426. package/resources/LMDBTransaction.ts +26 -4
  427. package/resources/PrimaryRocksDatabase.ts +28 -1
  428. package/resources/RecordEncoder.ts +103 -8
  429. package/resources/RequestTarget.ts +2 -0
  430. package/resources/Resource.ts +17 -9
  431. package/resources/ResourceInterface.ts +23 -0
  432. package/resources/RocksIndexStore.ts +30 -9
  433. package/resources/RocksTransactionLogStore.ts +78 -21
  434. package/resources/Table.ts +1110 -159
  435. package/resources/auditStore.ts +331 -73
  436. package/resources/blob.ts +1029 -110
  437. package/resources/branchDatabase.ts +941 -0
  438. package/resources/crdt.ts +76 -12
  439. package/resources/databases.ts +1310 -252
  440. package/resources/defineTable.ts +18 -2
  441. package/resources/graphql.ts +70 -16
  442. package/resources/indexes/HierarchicalNavigableSmallWorld.ts +6 -2
  443. package/resources/longLivedTransactions.ts +360 -0
  444. package/resources/models/backendRegistry.ts +84 -2
  445. package/resources/models/bootstrap.ts +473 -28
  446. package/resources/recordLock.ts +253 -0
  447. package/resources/replayLogs.ts +147 -26
  448. package/resources/replayLogsGuards.ts +171 -8
  449. package/resources/search.ts +154 -7
  450. package/resources/transactionBroadcast.ts +3 -3
  451. package/security/auth.ts +68 -29
  452. package/security/authn/oidc/claims.ts +72 -0
  453. package/security/authn/oidc/identityToken.ts +129 -0
  454. package/security/authn/oidc/jwks.ts +260 -0
  455. package/security/authn/oidc/providers/generic.ts +40 -0
  456. package/security/authn/oidc/providers/githubActions.ts +137 -0
  457. package/security/authn/oidc/providers/index.ts +52 -0
  458. package/security/authn/oidc/tokenExchange.ts +300 -0
  459. package/security/authn/oidc/trustPolicyOperations.ts +343 -0
  460. package/security/authn/oidc/types.ts +41 -0
  461. package/security/certificateVerification/index.ts +54 -13
  462. package/security/certificateVerification/trustedIssuers.ts +76 -0
  463. package/security/certificateVerification/types.ts +1 -0
  464. package/security/credentialProvenance.ts +47 -0
  465. package/security/credentialRejection.ts +22 -0
  466. package/security/deferredAuthentication.ts +71 -0
  467. package/security/impersonation.ts +117 -12
  468. package/security/jsLoader.ts +81 -18
  469. package/security/keys.ts +298 -72
  470. package/security/operationScope.ts +33 -0
  471. package/security/permissionsTranslator.js +23 -0
  472. package/security/tokenAuthentication.ts +233 -12
  473. package/security/user.ts +4 -3
  474. package/server/DESIGN.md +183 -16
  475. package/server/DurableSubscriptionsSession.ts +71 -11
  476. package/server/REST.ts +79 -1
  477. package/server/graphqlQuerying.ts +4 -0
  478. package/server/http.ts +99 -18
  479. package/server/itc/serverHandlers.js +8 -1
  480. package/server/jobs/jobProcess.ts +8 -2
  481. package/server/jobs/jobs.ts +4 -1
  482. package/server/liveSubscriptionAuth.ts +129 -46
  483. package/server/loadRootComponents.js +50 -8
  484. package/server/mqtt.ts +179 -38
  485. package/server/nodeName.ts +103 -21
  486. package/server/serverHelpers/Headers.ts +131 -0
  487. package/server/serverHelpers/contentTypes.ts +29 -21
  488. package/server/serverHelpers/deployValidationState.ts +24 -13
  489. package/server/serverHelpers/operationAuthorizationState.ts +34 -3
  490. package/server/serverHelpers/registeredOperations.ts +79 -22
  491. package/server/serverHelpers/requestSanitization.ts +15 -0
  492. package/server/serverHelpers/serverHandlers.js +6 -3
  493. package/server/serverHelpers/serverUtilities.ts +104 -31
  494. package/server/serverHelpers/sharedMessageEncoding.ts +307 -0
  495. package/server/serverHelpers/uwsServer.ts +17 -2
  496. package/server/static.ts +23 -29
  497. package/server/storageReclamation.ts +23 -0
  498. package/server/threads/itc.js +11 -1
  499. package/server/threads/manageThreads.js +526 -56
  500. package/server/threads/socketRouter.ts +81 -26
  501. package/server/threads/threadHeapMemory.ts +26 -0
  502. package/server/threads/threadServer.js +43 -15
  503. package/sqlTranslator/index.ts +31 -8
  504. package/studio/web/assets/Chat-BnCBegQz.js +2267 -0
  505. package/studio/web/assets/FloatingChat-CoDW1ySS.js +23 -0
  506. package/studio/web/assets/{abnfDiagram-VCTEODGH-C0_BAZyO.js → abnfDiagram-VCTEODGH-B0BebmD2.js} +1 -1
  507. package/studio/web/assets/{alertDialog-DIHt7Z0r.js → alertDialog-CQyAJJhl.js} +1 -1
  508. package/studio/web/assets/{apiToken-c3Rd-w6g.js → apiToken-Bwk5BLXW.js} +1 -1
  509. package/studio/web/assets/applications-DHxGi7JH.js +296 -0
  510. package/studio/web/assets/architecture-7GRP2DOG-LB-MLAAb.js +1 -0
  511. package/studio/web/assets/{architectureDiagram-5GKGNRK7-BWzrASgm.js → architectureDiagram-5GKGNRK7-7SW3GD-K.js} +1 -1
  512. package/studio/web/assets/authStore-C3Nfubqr.js +3 -0
  513. package/studio/web/assets/{blockDiagram-NRAW4CY4-BdJX9Khj.js → blockDiagram-I7D4REHJ-BqguiadH.js} +2 -2
  514. package/studio/web/assets/{button-DhiX-njv.js → button-BIsUKRZq.js} +2 -2
  515. package/studio/web/assets/{c4Diagram-UCG6FXSJ-CI6MzGmQ.js → c4Diagram-7LVT6UL2-LBNf8t_X.js} +1 -1
  516. package/studio/web/assets/channel-yictG-U-.js +1 -0
  517. package/studio/web/assets/{chevron-up-Df2c8uoU.js → chevron-up-DtKGqDn3.js} +1 -1
  518. package/studio/web/assets/{chunk-TEH6E4GO-P87k5mNi.js → chunk-4HAMMTFA-DWtTut21.js} +1 -1
  519. package/studio/web/assets/{chunk-75Z2AOVW-BT8tVmks.js → chunk-75Z2AOVW-QGQD6th2.js} +1 -1
  520. package/studio/web/assets/{chunk-DU6HZSFF-9kAOOmI6.js → chunk-DU6HZSFF-Chq20Ba5.js} +1 -1
  521. package/studio/web/assets/{chunk-F27PBJKO-BW7ao8AY.js → chunk-F27PBJKO-BVA5EPhV.js} +1 -1
  522. package/studio/web/assets/{chunk-GMAD6QVW-BNyXpoQO.js → chunk-GMAD6QVW-BeS7S07A.js} +1 -1
  523. package/studio/web/assets/{chunk-OBVCFTLP-D4wWOqDQ.js → chunk-GVQU2GXP-sbwVIQ8i.js} +1 -1
  524. package/studio/web/assets/{chunk-G27WJ6UU-COyLMcgK.js → chunk-IMKFNOWR-Bnh3tAVd.js} +1 -1
  525. package/studio/web/assets/{chunk-JQ64N6SF-Cyz1IeLf.js → chunk-L3NEJ4N5-COfUyKII.js} +1 -1
  526. package/studio/web/assets/chunk-OSK3NFVY-ByciRftO.js +10 -0
  527. package/studio/web/assets/{chunk-P2QGCYS3-DmIFY4d7.js → chunk-P2QGCYS3-CP1VhG_c.js} +1 -1
  528. package/studio/web/assets/{chunk-POPQ4Y6H-BPrvMyKz.js → chunk-POPQ4Y6H-ClWhhkwW.js} +1 -1
  529. package/studio/web/assets/{chunk-PWAF6VOD-2zB6IW9i.js → chunk-PWAF6VOD-1z1THyS5.js} +1 -1
  530. package/studio/web/assets/{chunk-RHFEMEQ7-2FgyI8YU.js → chunk-SHT3W25Y-LpQkMsah.js} +2 -2
  531. package/studio/web/assets/{chunk-SVP7TREG-FwtbH2QC.js → chunk-SVP7TREG-jtdAHw0S.js} +1 -1
  532. package/studio/web/assets/{chunk-LCL6LL3I-HOzK_ppE.js → chunk-TICWLB2K-VOwzetX-.js} +1 -1
  533. package/studio/web/assets/classDiagram-ZZMXUADV-VaEwSy_g.js +1 -0
  534. package/studio/web/assets/classDiagram-v2-VYDZK3BY-VaEwSy_g.js +1 -0
  535. package/studio/web/assets/{createLucideIcon-BKGPfjm2.js → createLucideIcon-CzW9508A.js} +1 -1
  536. package/studio/web/assets/{cssMode-CEN2mzSA.js → cssMode-s0cWI-_M.js} +1 -1
  537. package/studio/web/assets/{cynefin-OW5HDTMX-BRkpLFQV.js → cynefin-OW5HDTMX-BbdbCvub.js} +1 -1
  538. package/studio/web/assets/{cynefinDiagram-5FMLGOSQ-CHT1DaX6.js → cynefinDiagram-5FMLGOSQ-TP-aIqbt.js} +1 -1
  539. package/studio/web/assets/{dagre-3AP2YEHR-DpUXBh63.js → dagre-GXQ25YYZ-DShnGpGo.js} +1 -1
  540. package/studio/web/assets/{diagram-S7CK7UJ4-BuymVFZT.js → diagram-S7CK7UJ4-aoCVTtcy.js} +1 -1
  541. package/studio/web/assets/{diagram-UQ7AKVKN-CyP148RM.js → diagram-UQ7AKVKN-DglXtQ6x.js} +1 -1
  542. package/studio/web/assets/{diagram-VSXAHHWV-CoCAg3M9.js → diagram-VSXAHHWV-fhEdmkwM.js} +1 -1
  543. package/studio/web/assets/{diagram-VX7I27RA-BpOqCFca.js → diagram-VX7I27RA-DccVJet6.js} +1 -1
  544. package/studio/web/assets/{diagram-Z3DM3KII-Bfpw7Vbj.js → diagram-Z3DM3KII-D-RyJJb7.js} +1 -1
  545. package/studio/web/assets/{dialog-CBf0Mr1d.js → dialog-Cn2uWgD4.js} +1 -1
  546. package/studio/web/assets/{dist-lkA3O3eM.js → dist-DP8UjMB_.js} +1 -1
  547. package/studio/web/assets/{download-BtTOBem-.js → download-B5T5r7ss.js} +1 -1
  548. package/studio/web/assets/{ebnfDiagram-PWID7BFC-DS_6aWqL.js → ebnfDiagram-PWID7BFC-DJGpIpz_.js} +1 -1
  549. package/studio/web/assets/{editor-D8oDeCTL.js → editor-DNcRHK54.js} +1 -1
  550. package/studio/web/assets/{erDiagram-SSCWMZ5O-DJNk6Fgw.js → erDiagram-RLTQ6QDP-CIfNlgkC.js} +1 -1
  551. package/studio/web/assets/eventmodeling-NTZA5JFV-CLxnp2CR.js +1 -0
  552. package/studio/web/assets/flowDiagram-HODETNUW-BIbhmz9f.js +1 -0
  553. package/studio/web/assets/{ganttDiagram-EL5Y4UJY-2pOExxMY.js → ganttDiagram-EL5Y4UJY-BxToTzzD.js} +1 -1
  554. package/studio/web/assets/{getAnalytics-D4LKGeVy.js → getAnalytics-GHK8ORfM.js} +1 -1
  555. package/studio/web/assets/{gitGraph-4MIJSDKK-CH5ZxwzF.js → gitGraph-4MIJSDKK-D2s2w8lE.js} +1 -1
  556. package/studio/web/assets/{gitGraphDiagram-WWUBYQGX-DVIsIhbO.js → gitGraphDiagram-WWUBYQGX-Dwntd4-x.js} +1 -1
  557. package/studio/web/assets/{html-u3vOg7LJ.js → html-Bdssedlg.js} +1 -1
  558. package/studio/web/assets/{htmlMode-DyO31v-P.js → htmlMode-CoDlJ3fw.js} +1 -1
  559. package/studio/web/assets/{index-Cxj2_wsl.css → index-7RMEgVG1.css} +1 -1
  560. package/studio/web/assets/index-D6sxmFLR.js +824 -0
  561. package/studio/web/assets/index.lazy-tmU5BS8s.js +2 -0
  562. package/studio/web/assets/{info-A6RAGUB7-CPQfTnaG.js → info-A6RAGUB7-DYjkvb0C.js} +1 -1
  563. package/studio/web/assets/{infoDiagram-RXCK75RN-DlwLYlwm.js → infoDiagram-27XIBGKW-Bnp1FJE5.js} +1 -1
  564. package/studio/web/assets/{ishikawaDiagram-5VMMS53U-BRXRp29U.js → ishikawaDiagram-5VMMS53U-D9Xh2r6X.js} +1 -1
  565. package/studio/web/assets/{javascript-CUvxOyTC.js → javascript-B8meVSTH.js} +1 -1
  566. package/studio/web/assets/{journeyDiagram-EYS64GPL-B0ou8k0n.js → journeyDiagram-3NMN7TZE-CokIi6ll.js} +2 -2
  567. package/studio/web/assets/{jsonMode-f_IwbF3D.js → jsonMode-DpIPd35T.js} +1 -1
  568. package/studio/web/assets/{kanban-definition-3QL26DDD-uYg7iYzp.js → kanban-definition-UXKFOSKX-CukSFJfX.js} +1 -1
  569. package/studio/web/assets/{languageServices-DXtZ6rEF.js → languageServices-C_5FMJzQ.js} +1 -1
  570. package/studio/web/assets/{lspLanguageFeatures-B4pCF1zO.js → lspLanguageFeatures-BIzNBzPK.js} +1 -1
  571. package/studio/web/assets/{mermaid-parser.core-Ck-fC8b7.js → mermaid-parser.core-BlEsOWNO.js} +3 -3
  572. package/studio/web/assets/{mermaid.core-CP8aNNYm.js → mermaid.core-BlkGaMIH.js} +5 -5
  573. package/studio/web/assets/{mindmap-definition-FBJOCRG2-CgTZ-rit.js → mindmap-definition-YA3MSWOX-IprMc_0j.js} +1 -1
  574. package/studio/web/assets/{notifications-D3tIQ4sg.js → notifications-CQf18QKb.js} +1 -1
  575. package/studio/web/assets/notifications-CvZivSbh.js +1 -0
  576. package/studio/web/assets/{packet-AYTQ26CC-DEyoPtPb.js → packet-AYTQ26CC-Bi3V04Zi.js} +1 -1
  577. package/studio/web/assets/{pegDiagram-XKGWAZYB-DrD-7sD9.js → pegDiagram-XKGWAZYB-BNuPDLZY.js} +1 -1
  578. package/studio/web/assets/{pie-WAS4IAKB-wjj-EI1d.js → pie-WAS4IAKB-_6DoDbng.js} +1 -1
  579. package/studio/web/assets/{pieDiagram-E7YTZNPT-GntqDCzv.js → pieDiagram-E7YTZNPT-DqNb6Ht2.js} +1 -1
  580. package/studio/web/assets/{profile-DZWU7MgT.js → profile-DdOwtntb.js} +1 -1
  581. package/studio/web/assets/{quadrantDiagram-AXDQQJYC-0UeqXQGd.js → quadrantDiagram-AXDQQJYC-BGH9E2YR.js} +1 -1
  582. package/studio/web/assets/{radar-RG4KPBEZ-DFSA5h7k.js → radar-RG4KPBEZ-DDdVczcL.js} +1 -1
  583. package/studio/web/assets/{railroad-74A4TZTK-CaOUG9wR.js → railroad-74A4TZTK-BJUP4Jds.js} +1 -1
  584. package/studio/web/assets/railroad-abnf-HS5TGJTU-Bm3L1L0h.js +1 -0
  585. package/studio/web/assets/railroad-ebnf-LZEXJU2U-CKzLGlkw.js +1 -0
  586. package/studio/web/assets/railroad-peg-WCYAUIDC-S8xLjslx.js +1 -0
  587. package/studio/web/assets/{railroadDiagram-O6MQD6OU-yHUELZaV.js → railroadDiagram-O6MQD6OU-DGTPh2KZ.js} +1 -1
  588. package/studio/web/assets/{regions-CkyurXzE.js → regions-n69fwagr.js} +1 -1
  589. package/studio/web/assets/{register-BUyhWjBO.js → register-PfWTCXWB.js} +3 -3
  590. package/studio/web/assets/{requirementDiagram-EFPCY7ZU-DNEGFjuW.js → requirementDiagram-BXWQKSXE-BJnO6uLz.js} +1 -1
  591. package/studio/web/assets/{sankeyDiagram-P5KCCOFB-DpyAmSVR.js → sankeyDiagram-P5KCCOFB-0vSOdymH.js} +1 -1
  592. package/studio/web/assets/{sequenceDiagram-WJ2MYXX4-TyaT7xNk.js → sequenceDiagram-WJ2MYXX4-hETizDWE.js} +1 -1
  593. package/studio/web/assets/{setComponentFile-CeyKSZAa.js → setComponentFile-Bg6O7X0S.js} +1 -1
  594. package/studio/web/assets/{setup-D2kn7cAA.js → setup-CUx_aUDl.js} +2 -2
  595. package/studio/web/assets/{stateDiagram-HBIQ2CUA-CeEdTArZ.js → stateDiagram-D77RDMKH-CdYQ_KtC.js} +1 -1
  596. package/studio/web/assets/stateDiagram-v2-MP3YSRHH-CdKuzQMT.js +1 -0
  597. package/studio/web/assets/status-D7BVKqX9.js +61 -0
  598. package/studio/web/assets/{swimlanes-XN3QIQJK-B54FmF46.js → swimlanes-42K2YHIH-B8cHIpU4.js} +1 -1
  599. package/studio/web/assets/swimlanesDiagram-VR7AAH4N-DmOSJwaH.js +8 -0
  600. package/studio/web/assets/{tabs-B_G5zscN.js → tabs-BrHu7gJi.js} +1 -1
  601. package/studio/web/assets/{timeline-definition-24CTP7MA-D-a9ujbo.js → timeline-definition-24CTP7MA-BJWYSXqF.js} +1 -1
  602. package/studio/web/assets/{toggleHighContrast-C0UW6rI2.js → toggleHighContrast-DBSyXzMr.js} +1 -1
  603. package/studio/web/assets/{treeView-Q6P3EWNA-CrW_6JnS.js → treeView-Q6P3EWNA-qxe_v6CQ.js} +1 -1
  604. package/studio/web/assets/{treemap-WGGIJYW6-BxyYLdP_.js → treemap-WGGIJYW6-dDo97XXF.js} +1 -1
  605. package/studio/web/assets/{tsMode-DBC0zmDx.js → tsMode-BByKCjBS.js} +1 -1
  606. package/studio/web/assets/{typescript-DApRQir3.js → typescript-DDLnLpw9.js} +1 -1
  607. package/studio/web/assets/{useEntityRestURL-DB6JStU1.js → useEntityRestURL-31CHGaHk.js} +1 -1
  608. package/studio/web/assets/{useLocalStorage-Dtj1QS8_.js → useLocalStorage-BqMR3D8_.js} +1 -1
  609. package/studio/web/assets/vendor-core-c2JRRJpV.js +58 -0
  610. package/studio/web/assets/vendor-datadog-CLUcJXOo.js +6 -0
  611. package/studio/web/assets/{vendor-react-Dyj4O3HE.js → vendor-react-CJV_K1u4.js} +1 -1
  612. package/studio/web/assets/vendor-tanstack-DxzraizX.js +1 -0
  613. package/studio/web/assets/{vendor-ui-vhu-UHhF.js → vendor-ui-BUjK0h8a.js} +2 -2
  614. package/studio/web/assets/{vennDiagram-4TSXK5OY-Cy7s7Mpy.js → vennDiagram-4TSXK5OY-A3i-lCdl.js} +1 -1
  615. package/studio/web/assets/{wardley-WFR3VGLG-BeBL35g2.js → wardley-WFR3VGLG-B0ik-_6g.js} +1 -1
  616. package/studio/web/assets/{wardleyDiagram-VM6X3IG4-BylmIGSg.js → wardleyDiagram-VM6X3IG4-CjrkKWUR.js} +1 -1
  617. package/studio/web/assets/{workers-C0bFIedw.js → workers-pR3jRY9D.js} +1 -1
  618. package/studio/web/assets/x-DIzaLEdK.js +1 -0
  619. package/studio/web/assets/{xml-HWd01lU-.js → xml-2iRnMhQO.js} +1 -1
  620. package/studio/web/assets/{xychartDiagram-S5SC5T6Z-CoKALMXr.js → xychartDiagram-S5SC5T6Z-Biok4GYV.js} +1 -1
  621. package/studio/web/assets/{yaml-CIH0Nt-h.js → yaml-Bf92gJpd.js} +1 -1
  622. package/studio/web/index.html +14 -14
  623. package/upgrade/directives/5-3-0.ts +132 -0
  624. package/upgrade/directives/directivesController.ts +2 -1
  625. package/utility/OperationFunctionCaller.ts +2 -1
  626. package/utility/common_utils.ts +30 -5
  627. package/utility/componentNames.ts +12 -0
  628. package/utility/environment/environmentManager.ts +3 -7
  629. package/utility/environment/systemInformation.ts +7 -0
  630. package/utility/errors/commonErrors.ts +4 -0
  631. package/utility/errors/hdbError.ts +29 -0
  632. package/utility/hdbTerms.ts +17 -0
  633. package/utility/logging/harper_logger.ts +87 -14
  634. package/utility/logging/logRotator.ts +72 -45
  635. package/utility/nodeIdentity.ts +45 -0
  636. package/utility/npmUtilities.ts +10 -8
  637. package/utility/operationPermissions.ts +18 -1
  638. package/utility/operation_authorization.ts +231 -42
  639. package/utility/watchPath.ts +63 -0
  640. package/utility/watcherFallback.ts +270 -0
  641. package/validation/configValidator.ts +209 -72
  642. package/validation/installValidator.ts +15 -0
  643. package/validation/validationWrapper.ts +18 -4
  644. package/studio/web/assets/Chat-JpO8EtUu.js +0 -2067
  645. package/studio/web/assets/FloatingChat-Bcj3xSZu.js +0 -23
  646. package/studio/web/assets/applications-ByqLRKyZ.js +0 -296
  647. package/studio/web/assets/architecture-7GRP2DOG-DNdx5tEU.js +0 -1
  648. package/studio/web/assets/authStore-qKmCZcaf.js +0 -3
  649. package/studio/web/assets/channel-DtCV8PTL.js +0 -1
  650. package/studio/web/assets/chunk-R7TYR2AO-Irip67yr.js +0 -10
  651. package/studio/web/assets/classDiagram-DTDB5LWJ-DbO_dCNE.js +0 -1
  652. package/studio/web/assets/classDiagram-v2-JRS7N3AN-DbO_dCNE.js +0 -1
  653. package/studio/web/assets/eventmodeling-NTZA5JFV-5jbe4A5P.js +0 -1
  654. package/studio/web/assets/flowDiagram-A5DVABFB-Dp9Ezlow.js +0 -1
  655. package/studio/web/assets/index-aSt5tY-L.js +0 -824
  656. package/studio/web/assets/index.lazy-B9jiPwT8.js +0 -2
  657. package/studio/web/assets/notifications-CUoYgU98.js +0 -1
  658. package/studio/web/assets/railroad-abnf-HS5TGJTU-Bc0Qi0WH.js +0 -1
  659. package/studio/web/assets/railroad-ebnf-LZEXJU2U-G8rVVZ2C.js +0 -1
  660. package/studio/web/assets/railroad-peg-WCYAUIDC-CrehKBhC.js +0 -1
  661. package/studio/web/assets/stateDiagram-v2-4QOOHH4V-D4tuw9Su.js +0 -1
  662. package/studio/web/assets/status-D7Xn5ePA.js +0 -61
  663. package/studio/web/assets/swimlanesDiagram-VK2B7HYN-XOhmNEvq.js +0 -8
  664. package/studio/web/assets/vendor-core-RCcadM3e.js +0 -73
  665. package/studio/web/assets/vendor-datadog-BRv-mOv1.js +0 -6
  666. package/studio/web/assets/vendor-tanstack-BiFWSB3W.js +0 -1
  667. package/studio/web/assets/x-B9o9hsep.js +0 -1
  668. /package/studio/web/assets/{sizeCapture-X5ZJPWSS-B0uUizjq.js → sizeCapture-INFHLROL-B0uUizjq.js} +0 -0
@@ -23,6 +23,7 @@ export interface ComponentPreparationLockOwner {
23
23
  processInstanceId: string;
24
24
  token: string;
25
25
  ticket?: number;
26
+ purpose?: string;
26
27
  }
27
28
 
28
29
  export interface ComponentPreparationLockOptions {
@@ -30,8 +31,12 @@ export interface ComponentPreparationLockOptions {
30
31
  onWait?: (owner: ComponentPreparationLockOwner | null) => void;
31
32
  onReleaseError?: (error: unknown) => void;
32
33
  isOwnerAlive?: (owner: ComponentPreparationLockOwner) => boolean | Promise<boolean>;
34
+ purpose?: string;
35
+ renewTimeoutWhileOwnerAlive?: boolean | ((owner: ComponentPreparationLockOwner) => boolean | Promise<boolean>);
33
36
  }
34
37
 
38
+ export class ComponentPreparationLockTimeoutError extends Error {}
39
+
35
40
  export function componentPreparationLockIdentity(
36
41
  componentDirPath: string,
37
42
  platform: NodeJS.Platform = process.platform
@@ -244,10 +249,12 @@ async function acquireComponentPreparationLock(
244
249
  threadId,
245
250
  processInstanceId: COMPONENT_PREPARATION_PROCESS_INSTANCE_ID,
246
251
  token: randomUUID(),
252
+ purpose: options.purpose,
247
253
  };
248
254
  const choosingPath = join(lockRoot, `${lockName}.choosing.${owner.token}.json`);
249
255
  let ticketPath: string | undefined;
250
256
  const timeoutMs = options.timeoutMs ?? DEFAULT_LOCK_WAIT_TIMEOUT_MS;
257
+ const renewTimeoutWhileOwnerAlive = options.renewTimeoutWhileOwnerAlive ?? timeoutMs > 0;
251
258
  let deadline = performance.now() + timeoutMs;
252
259
 
253
260
  await mkdir(lockRoot, { recursive: true, mode: 0o700 });
@@ -264,7 +271,7 @@ async function acquireComponentPreparationLock(
264
271
  await rm(choosingPath, { force: true }).catch(() => {});
265
272
  }
266
273
 
267
- let waitingReported = false;
274
+ let waitingReportedForToken: string | undefined;
268
275
  try {
269
276
  for (;;) {
270
277
  const claims = await scanLiveClaims(lockRoot, lockName, options, owner.token);
@@ -276,17 +283,21 @@ async function acquireComponentPreparationLock(
276
283
  })[0];
277
284
  const blocker = claims.choosing[0] ?? precedingTicket;
278
285
  if (!blocker) break;
279
- if (!waitingReported) {
280
- waitingReported = true;
286
+ if (waitingReportedForToken !== blocker.token) {
287
+ waitingReportedForToken = blocker.token;
281
288
  options.onWait?.(blocker);
282
289
  }
283
290
  if (performance.now() >= deadline) {
284
- if (await ownerLivenessConfirmed(blocker, options)) {
291
+ const renewForOwner =
292
+ typeof renewTimeoutWhileOwnerAlive === 'function'
293
+ ? await renewTimeoutWhileOwnerAlive(blocker)
294
+ : renewTimeoutWhileOwnerAlive;
295
+ if (renewForOwner && (await ownerLivenessConfirmed(blocker, options))) {
285
296
  // A confirmed-live holder is allowed to finish; the deadline only bounds owners whose
286
297
  // liveness cannot be positively established.
287
298
  deadline = performance.now() + timeoutMs;
288
299
  } else {
289
- throw new Error(
300
+ throw new ComponentPreparationLockTimeoutError(
290
301
  `Timed out waiting for component preparation lock for ${canonicalPath}` +
291
302
  ` held by process ${blocker.pid}, thread ${blocker.threadId}`
292
303
  );
@@ -12,6 +12,7 @@
12
12
  * automatically and pipes the iterable to the wire.
13
13
  */
14
14
  import { handleMcpRequest, type McpProfile, type NormRequest, type NormResponse } from '../transport.ts';
15
+ import { settleDeferredCredentialRejection } from '../../../security/deferredAuthentication.ts';
15
16
  import { toSseStream, type SseFrameSource } from '../sse.ts';
16
17
 
17
18
  /**
@@ -56,6 +57,9 @@ export function createHarperHttpHandler(profile: McpProfile) {
56
57
  // WebSocket upgrades aren't ours — let the next handler take it.
57
58
  if (request.isWebSocket) return nextHandler(request);
58
59
 
60
+ const settledCredentialRejection = settleDeferredCredentialRejection(request);
61
+ if (settledCredentialRejection) return settledCredentialRejection;
62
+
59
63
  const norm: NormRequest = {
60
64
  method: request.method,
61
65
  headers: normalizeHeaders(request.headers),
@@ -215,6 +215,10 @@ function snapshotSessions(profile: McpProfile): RegisteredSession[] {
215
215
  }
216
216
 
217
217
  async function refreshSessionUser(record: RegisteredSession): Promise<void> {
218
+ // A scoped token's username is attribution only — re-resolving it against hdb_user could
219
+ // substitute a real principal (created later with that name) and advertise a surface the token
220
+ // never granted. Its embedded role is fixed for the token's life, so there is nothing to refresh.
221
+ if (record.user?._scopedToken) return;
218
222
  const fresh = await resolveUser(record.user?.username);
219
223
  if (fresh) record.user = fresh;
220
224
  }
@@ -60,6 +60,8 @@ export interface ToolDescriptor {
60
60
  /** Authenticated user object as Harper builds it (subset we touch). */
61
61
  export interface AuthedUser {
62
62
  username?: string;
63
+ // Attribution-only principal that must not be re-resolved against hdb_user (see refreshSessionUser).
64
+ _scopedToken?: boolean;
63
65
  role?: {
64
66
  role?: string;
65
67
  permission?: {
@@ -144,6 +144,11 @@ export const DEFAULT_ALLOW: readonly string[] = [
144
144
  * `mcp.operations.allow` (an explicit allow list replaces the default and is
145
145
  * not filtered by this set), where the audit-log redaction of
146
146
  * `value`/`values`/`envelope` applies.
147
+ *
148
+ * OIDC trust policies (#2171) are excluded on the same grounds and then some: a
149
+ * policy grants an external CI workflow the right to authenticate as a Harper
150
+ * user, so reading the set tells an attacker exactly which repository and
151
+ * workflow to compromise, and writing one is a way to grant itself access.
147
152
  */
148
153
  export const DEFAULT_EXCLUDED: ReadonlySet<string> = new Set([
149
154
  'set_secret',
@@ -152,6 +157,10 @@ export const DEFAULT_EXCLUDED: ReadonlySet<string> = new Set([
152
157
  'list_secrets',
153
158
  'delete_secret',
154
159
  'get_secrets_public_key',
160
+ 'add_oidc_trust',
161
+ 'list_oidc_trust',
162
+ 'drop_oidc_trust',
163
+ 'exchange_oidc_token',
155
164
  ]);
156
165
 
157
166
  /**
@@ -195,9 +195,9 @@ export const OPERATION_DESCRIPTIONS: Record<string, string> = {
195
195
  // drop_role: security/role.ts:126 — Delete a role; refuses if assigned.
196
196
  drop_role:
197
197
  'Deletes a role. Refused if any active user is still assigned to the role — drop or reassign those users first.',
198
- // create_authentication_tokens: security/tokenAuthentication.ts:108 — Mint operation + refresh token pair, or (purpose: 'login') a login-exchange token.
198
+ // create_authentication_tokens: security/tokenAuthentication.ts:108 — Mint operation + refresh token pair, (purpose: 'login') a login-exchange token, or (role object) a scoped token.
199
199
  create_authentication_tokens:
200
- "Creates a JWT operation token and a refresh token after validating credentials. Stores the refresh token on the user record. With purpose: 'login', instead mints a single short-lived login-exchange token (not usable as a Bearer API credential) intended for the `login` operation.",
200
+ "Creates a JWT operation token and a refresh token after validating credentials. Stores the refresh token on the user record. With purpose: 'login', instead mints a single short-lived login-exchange token (not usable as a Bearer API credential) intended for the `login` operation. With `role` as an inline role object (e.g. { permission: { operations: ['read_only'] } }), instead mints a single scoped token whose bearer is limited to the embedded permissions — requires a super_user caller; `username` is attribution only and must NOT name an existing user (defaults to 'scoped:<minter>'); no refresh token is issued and the token cannot be revoked before expiry. The operations allowlist gates the operations API (including sql); application/REST endpoints are governed by the embedded table permissions, so make those restrictive too.",
201
201
  // refresh_operation_token: security/tokenAuthentication.ts:171 — Mint new operation token from refresh.
202
202
  refresh_operation_token:
203
203
  'Issues a new operation token using a valid refresh token, without re-authenticating with username/password.',
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const path = require('node:path');
4
- const { isMainThread } = require('node:worker_threads');
4
+ const { isMainThread, parentPort } = require('node:worker_threads');
5
5
  const fs = require('fs-extra');
6
6
  const fg = require('fast-glob');
7
7
  const normalize = require('normalize-path');
@@ -29,8 +29,14 @@ const {
29
29
  streamPackagedDirectory,
30
30
  } = require('../components/packageComponent.ts');
31
31
  const { Resources } = require('../resources/Resources.ts');
32
- const { Application, prepareApplication, ASIDE_STAGING_DIR } = require('./Application.ts');
33
- const { COMPONENT_PREPARATION_LOCK_DIR } = require('./componentPreparationLock.ts');
32
+ const {
33
+ Application,
34
+ prepareApplication,
35
+ ASIDE_STAGING_DIR,
36
+ DEPLOY_STAGING_DIR,
37
+ dropComponentDirectory,
38
+ } = require('./Application.ts');
39
+ const { COMPONENT_PREPARATION_LOCK_DIR, withComponentPreparationLock } = require('./componentPreparationLock.ts');
34
40
  const { server } = require('../server/Server.ts');
35
41
  const {
36
42
  DeploymentRecorder,
@@ -41,6 +47,21 @@ const {
41
47
  } = require('./deploymentRecorder.ts');
42
48
  const { ProgressEmitter } = require('../server/serverHelpers/progressEmitter.ts');
43
49
 
50
+ const DROP_COMPONENT_LOCK_TIMEOUT_MS = 5 * 60 * 1000;
51
+
52
+ function componentDropLockOptions(project) {
53
+ return {
54
+ timeoutMs: DROP_COMPONENT_LOCK_TIMEOUT_MS,
55
+ onWait: (owner) =>
56
+ log.info(
57
+ `Waiting to drop ${project} while component preparation is in progress` +
58
+ (owner ? ` in process ${owner.pid}, thread ${owner.threadId}` : '')
59
+ ),
60
+ onReleaseError: (error) => log.error(`Failed to release the component preparation lock for ${project}:`, error),
61
+ isOwnerAlive: (owner) => owner.pid !== process.pid || manageThreads.isThreadRunning(owner.threadId),
62
+ };
63
+ }
64
+
44
65
  /**
45
66
  * Read the settings.js file and return the
46
67
  *
@@ -238,14 +259,12 @@ async function addComponent(req) {
238
259
  }
239
260
 
240
261
  log.trace(`adding component`);
241
- const cfDir = configUtils.getConfigPath(hdbTerms.CONFIG_PARAMS.COMPONENTSROOT);
242
262
  const { project, install_command, install_timeout, install_allow_scripts } = req;
243
263
 
244
264
  const template = req.template || 'https://github.com/harperdb/application-template';
245
265
 
246
266
  try {
247
- const projectDir = path.join(cfDir, project);
248
- fs.mkdirSync(projectDir, { recursive: true });
267
+ await fs.mkdir(configUtils.getConfigPath(hdbTerms.CONFIG_PARAMS.COMPONENTSROOT), { recursive: true });
249
268
  const application = new Application({
250
269
  name: project,
251
270
  packageIdentifier: template,
@@ -310,8 +329,16 @@ async function dropCustomFunctionProject(req) {
310
329
 
311
330
  try {
312
331
  const projectDir = path.join(cfDir, project);
313
- fs.rmSync(projectDir, { recursive: true });
314
- let response = await server.replication.replicateOperation(req);
332
+ const stagingDir = path.join(cfDir, ASIDE_STAGING_DIR, project);
333
+ if (!(await fs.pathExists(projectDir)) && !(await fs.pathExists(stagingDir))) await fs.stat(projectDir);
334
+ await withComponentPreparationLock(
335
+ projectDir,
336
+ async () => {
337
+ await dropComponentDirectory(projectDir, project, log);
338
+ },
339
+ componentDropLockOptions(project)
340
+ );
341
+ const response = await server.replication.replicateOperation(req);
315
342
  response.message = `Successfully deleted project: ${project}`;
316
343
  return response;
317
344
  } catch (err) {
@@ -410,6 +437,134 @@ async function packageComponent(req) {
410
437
  return { project, payload };
411
438
  }
412
439
 
440
+ /**
441
+ * Load the built candidate to surface load-time errors. A load-ERROR PROBE, not a safety guarantee: it runs
442
+ * the component's own top-level code with incomplete side-effect isolation.
443
+ *
444
+ * A no-op on the main thread, and the operations API deploys there — so operator deploys are unvalidated
445
+ * (#2315 step 2). What this guarantees is ORDER: where validation runs, a rejected candidate never goes live.
446
+ */
447
+ // `componentLoader.setErrorReporter` is ONE process-global callback, so two components validating
448
+ // concurrently on the same worker cross-attribute their failures: B installs its reporter while A is
449
+ // loading, A's load error lands in B, and A then activates broken code while B rejects a good candidate.
450
+ // Validation is serialized (it is already the slow path) and the previous reporter is restored, so the
451
+ // global is only ever owned by one in-flight validation.
452
+ let validationChain = Promise.resolve();
453
+
454
+ async function validateComponentLoads(candidateDirPath, emit) {
455
+ const run = validationChain.then(
456
+ () => validateComponentLoadsExclusive(candidateDirPath, emit),
457
+ () => validateComponentLoadsExclusive(candidateDirPath, emit)
458
+ );
459
+ validationChain = run.then(
460
+ () => {},
461
+ () => {}
462
+ );
463
+ return run;
464
+ }
465
+
466
+ async function validateComponentLoadsExclusive(candidateDirPath, emit) {
467
+ // now we attempt to actually load the component in case there is
468
+ // an error we can immediately detect and report, but app code should not run on the main thread
469
+ if (!isMainThread && !process.env.HARPER_SAFE_MODE) {
470
+ const pseudoResources = new Resources();
471
+ pseudoResources.isWorker = true;
472
+
473
+ const componentLoader = require('./componentLoader.ts').default || require('./componentLoader.ts');
474
+ const { trackScopeClose } = require('./scopeShutdown.ts');
475
+ let lastError;
476
+ const priorErrorReporter = componentLoader.getErrorReporter?.();
477
+ componentLoader.setErrorReporter((error) => (lastError = error));
478
+ emit('phase', { phase: 'load', status: 'start' });
479
+ // This load exists only to surface load-time errors early; the Scopes it creates are
480
+ // throwaway. They are collected (instead of registered for worker-shutdown auto-close) so we
481
+ // can close them here once validation completes — otherwise each deploy leaks the Scope's
482
+ // deploy-lifecycle listeners on this worker, eventually tripping MaxListenersExceededWarning
483
+ // (#1462).
484
+ const validationScopes = new Set();
485
+ // Process-wide `server.*` registrations (registerOperation, setMcpQuotaHandler) are not owned by
486
+ // a Scope, so a candidate's top-level registration during this throwaway load would otherwise
487
+ // outlive it and pollute the live worker on a failed/rolled-back deploy. The guard makes those
488
+ // registration methods no-op for the duration of the load.
489
+ const { runWithDeployValidationGuard } = require('../server/serverHelpers/deployValidationState.ts');
490
+ // The candidate loads under the REAL component's name, so a candidate that throws would mark the live
491
+ // component ERROR. Its status writes are diverted into the guard's throwaway sink instead — see
492
+ // `deployValidationState.ts` for why this is context-scoped rather than captured and reverted here.
493
+ const componentName = path.basename(candidateDirPath);
494
+ // Extension modules the candidate load pulls in are registered in the loader's module registry keyed by
495
+ // module, so forgetting only the candidate's realpath leaves those behind — one set per deploy. Their
496
+ // identities are collected by the load itself; diffing the global registry instead would delete a live
497
+ // module registered by an interleaving real load, since validations serialize only with each other.
498
+ const validationModules = new Set();
499
+ const validation = runWithDeployValidationGuard(async () => {
500
+ try {
501
+ await componentLoader.loadComponent(candidateDirPath, pseudoResources, undefined, {
502
+ collectScopes: validationScopes,
503
+ collectLoadedModules: validationModules,
504
+ });
505
+ } finally {
506
+ const closeResults = await Promise.allSettled(Array.from(validationScopes, (scope) => scope.close()));
507
+ const failedCloses = closeResults.filter((result) => result.status === 'rejected');
508
+ for (const result of failedCloses) {
509
+ log.warn('Failed to close a deploy-validation Scope', result.reason);
510
+ }
511
+ // A rejected close is a REJECTED VALIDATION, not a warning. `Scope.close()` stops at the
512
+ // throwing listener, so its remaining internal listener removal and subscription-hold release
513
+ // never run and the throwaway scope stays partially live — one leak per deploy, on the worker
514
+ // that serves the component.
515
+ if (failedCloses.length) {
516
+ throw new AggregateError(
517
+ failedCloses.map((result) => result.reason),
518
+ `Could not tear down deploy validation for ${componentName}: ${failedCloses.length} scope(s) failed to close`
519
+ );
520
+ }
521
+ }
522
+ });
523
+ // Track the load+close so a concurrent worker shutdown waits for these scopes to finish
524
+ // disposing — a plugin may start a native runtime in handleApplication — before realExit.
525
+ trackScopeClose(validation);
526
+ try {
527
+ await validation;
528
+ } finally {
529
+ componentLoader.setErrorReporter(priorErrorReporter);
530
+ // The candidate path is unique per deploy, so leaving it in the loader's realpath registry leaks
531
+ // one dead entry per deploy for the life of the process.
532
+ componentLoader.forgetLoadedPath?.(candidateDirPath);
533
+ componentLoader.forgetLoadedModules?.(validationModules);
534
+ }
535
+ emit('phase', { phase: 'load', status: 'done' });
536
+
537
+ if (lastError) throw lastError;
538
+ }
539
+ }
540
+
541
+ const BRANCH_STORAGE_RETAINED =
542
+ '. Any branched database storage this application owns was left in place; drop it again with restart: true to discard that data';
543
+
544
+ /** Report a restart outcome the operation's own success message cannot convey. */
545
+ function logRestartOutcome(restart, what) {
546
+ const { RESTART_IDLE_TIMEOUT_MS, RESTART_WAIT_CEILING_MS } = require('./awaitRestart.ts');
547
+ if (restart.replacementsNotStarted)
548
+ log.warn(
549
+ `${restart.replacementsNotStarted} replacement worker thread(s) did not report starting after ${what}; the pool is short until they are restarted`
550
+ );
551
+ if (restart.error) log.error(`Restart after ${what} failed`, restart.error);
552
+ else if (restart.workersKeptOnOldCode)
553
+ log.warn(
554
+ `${restart.workersKeptOnOldCode} worker thread(s) could not be replaced after ${what} and are still running the previous code`
555
+ );
556
+ else if (restart.declined) log.warn(`No restart was performed after ${what}: the process is already shutting down`);
557
+ else if (restart.handedOff)
558
+ log.debug?.(`The restart after ${what} was handed to the main thread, which reports its own completion`);
559
+ else if (restart.stalled)
560
+ log.warn(
561
+ `The restart after ${what} stopped making progress for ${RESTART_IDLE_TIMEOUT_MS}ms; worker threads may still be running the previous code`
562
+ );
563
+ else if (!restart.completed)
564
+ log.warn(
565
+ `The restart after ${what} was still running after ${RESTART_WAIT_CEILING_MS}ms; worker threads may still be running the previous code`
566
+ );
567
+ }
413
568
  /**
414
569
  * Can deploy a component in multiple ways. If a 'package' is provided all it will do is write that package to
415
570
  * harperdb-config, when HDB is restarted the package will be installed in hdb/nodeModules. If a base64 encoded string is passed it
@@ -463,6 +618,12 @@ async function deployComponent(req) {
463
618
  }
464
619
  if (req.urlPath !== undefined) applicationConfig.urlPath = req.urlPath;
465
620
  if (req.host !== undefined) applicationConfig.host = req.host;
621
+ // Same convention as host/urlPath above, and for the same reason: a package redeploy rebuilds
622
+ // this application's whole root-config entry from request fields, so a deployment-level key that
623
+ // isn't re-supplied here is silently dropped -- for branchedDatabases specifically, that means an
624
+ // application which believed it had a private fork resumes sharing the base after the next
625
+ // restart, with nothing in this operation to say so.
626
+ if (req.branchedDatabases !== undefined) applicationConfig.branchedDatabases = req.branchedDatabases;
466
627
  // Persist credential references (never tokens) so every cold install of this component —
467
628
  // reboot, new peer, rollback — re-resolves the credential from the store.
468
629
  if (credentialReferences.length) applicationConfig.credentials = credentialReferences;
@@ -587,52 +748,19 @@ async function deployComponent(req) {
587
748
  if (credentialReferences.length) req.credentials = credentialReferences;
588
749
  else delete req.credentials;
589
750
 
751
+ // Validated INSIDE preparation, between build and swap, so a component that installs cleanly but
752
+ // throws at load never becomes live.
753
+ //
754
+ // Phase ORDER is unchanged for clients, but `prepare:done` means "candidate built", not "swap
755
+ // committed" — so a later failure arrives after both phases reported success. The operation's error
756
+ // is the authority on whether the deploy landed, not the phase stream.
590
757
  emit('phase', { phase: 'prepare', status: 'start' });
591
- await prepareApplication(application);
592
- emit('phase', { phase: 'prepare', status: 'done' });
593
-
594
- // now we attempt to actually load the component in case there is
595
- // an error we can immediately detect and report, but app code should not run on the main thread
596
- if (!isMainThread && !process.env.HARPER_SAFE_MODE) {
597
- const pseudoResources = new Resources();
598
- pseudoResources.isWorker = true;
599
-
600
- const componentLoader = require('./componentLoader.ts').default || require('./componentLoader.ts');
601
- const { trackScopeClose } = require('./scopeShutdown.ts');
602
- let lastError;
603
- componentLoader.setErrorReporter((error) => (lastError = error));
604
- emit('phase', { phase: 'load', status: 'start' });
605
- // This load exists only to surface load-time errors early; the Scopes it creates are
606
- // throwaway. They are collected (instead of registered for worker-shutdown auto-close) so we
607
- // can close them here once validation completes — otherwise each deploy leaks the Scope's
608
- // deploy-lifecycle listeners on this worker, eventually tripping MaxListenersExceededWarning
609
- // (#1462).
610
- const validationScopes = new Set();
611
- // Process-wide `server.*` registrations (registerOperation, setMcpQuotaHandler) are not owned by
612
- // a Scope, so a candidate's top-level registration during this throwaway load would otherwise
613
- // outlive it and pollute the live worker on a failed/rolled-back deploy. The guard makes those
614
- // registration methods no-op for the duration of the load.
615
- const { runWithDeployValidationGuard } = require('../server/serverHelpers/deployValidationState.ts');
616
- const validation = runWithDeployValidationGuard(async () => {
617
- try {
618
- await componentLoader.loadComponent(application.dirPath, pseudoResources, undefined, {
619
- collectScopes: validationScopes,
620
- });
621
- } finally {
622
- const closeResults = await Promise.allSettled(Array.from(validationScopes, (scope) => scope.close()));
623
- for (const result of closeResults) {
624
- if (result.status === 'rejected') log.warn('Failed to close a deploy-validation Scope', result.reason);
625
- }
626
- }
627
- });
628
- // Track the load+close so a concurrent worker shutdown waits for these scopes to finish
629
- // disposing — a plugin may start a native runtime in handleApplication — before realExit.
630
- trackScopeClose(validation);
631
- await validation;
632
- emit('phase', { phase: 'load', status: 'done' });
633
-
634
- if (lastError) throw lastError;
635
- }
758
+ await prepareApplication(application, {
759
+ validateCandidate: async (candidateDirPath) => {
760
+ emit('phase', { phase: 'prepare', status: 'done' });
761
+ await validateComponentLoads(candidateDirPath, emit);
762
+ },
763
+ });
636
764
  const rollingRestart = req.restart === 'rolling';
637
765
  // if doing a rolling restart set restart to false so that other nodes don't also restart.
638
766
  req.restart = rollingRestart ? false : req.restart;
@@ -677,8 +805,16 @@ async function deployComponent(req) {
677
805
  }
678
806
  if (req.restart === true) {
679
807
  emit('phase', { phase: 'restart', status: 'start' });
680
- manageThreads.restartWorkers('http');
808
+ // Workers not yet replaced keep serving the pre-deploy component set, and where the OS lets
809
+ // replacements share a port they keep accepting connections for the whole rolling restart, so
810
+ // a caller that reads success as "the component is live" can be served by a worker that has
811
+ // never heard of it.
812
+ const { awaitRestart } = require('./awaitRestart.ts');
813
+ const restart = await awaitRestart((onProgress) =>
814
+ manageThreads.restartWorkers('http', undefined, undefined, onProgress)
815
+ );
681
816
  emit('phase', { phase: 'restart', status: 'done' });
817
+ logRestartOutcome(restart, `deploying ${application.name}`);
682
818
  response.message = `Successfully deployed: ${application.name}, restarting Harper`;
683
819
  } else if (rollingRestart) {
684
820
  const serverUtilities = require('../server/serverHelpers/serverUtilities.ts');
@@ -869,9 +1005,13 @@ async function getComponents() {
869
1005
  const list = await fs.readdir(dir, { withFileTypes: true });
870
1006
  for (let item of list) {
871
1007
  const itemName = item.name;
1008
+ // Deny-list, not a dot-prefix skip: component CONTENTS legitimately include dot-files
1009
+ // (`.aiignore`, `.env.example`) that callers expect to see, so only Harper's own
1010
+ // bookkeeping directories are excluded by name.
872
1011
  if (
873
1012
  itemName === 'node_modules' ||
874
1013
  itemName === ASIDE_STAGING_DIR ||
1014
+ itemName === DEPLOY_STAGING_DIR ||
875
1015
  itemName === COMPONENT_PREPARATION_LOCK_DIR
876
1016
  )
877
1017
  continue;
@@ -1168,33 +1308,85 @@ async function dropComponent(req) {
1168
1308
 
1169
1309
  const { project, file } = req;
1170
1310
  const projectPath = req.file ? path.join(project, file) : project;
1171
- const pathToComponent = path.join(configUtils.getConfigPath(hdbTerms.CONFIG_PARAMS.COMPONENTSROOT), projectPath);
1172
-
1173
- const componentSymlink = path.join(env.get(hdbTerms.CONFIG_PARAMS.ROOTPATH), 'node_modules', project);
1174
- if (await fs.pathExists(componentSymlink)) {
1175
- await fs.unlink(componentSymlink);
1176
- }
1311
+ const componentsRoot = configUtils.getConfigPath(hdbTerms.CONFIG_PARAMS.COMPONENTSROOT);
1312
+ const componentPath = path.join(componentsRoot, project);
1313
+ const pathToComponent = path.join(componentsRoot, projectPath);
1314
+
1315
+ let response;
1316
+ await withComponentPreparationLock(
1317
+ componentPath,
1318
+ async () => {
1319
+ const componentSymlink = path.join(env.get(hdbTerms.CONFIG_PARAMS.ROOTPATH), 'node_modules', project);
1320
+ if (await fs.pathExists(componentSymlink)) {
1321
+ await fs.unlink(componentSymlink);
1322
+ }
1177
1323
 
1178
- if (await fs.pathExists(pathToComponent)) {
1179
- await fs.remove(pathToComponent);
1180
- }
1324
+ if (!file) {
1325
+ await dropComponentDirectory(componentPath, project, log);
1326
+ } else if (await fs.pathExists(pathToComponent)) {
1327
+ await fs.remove(pathToComponent);
1328
+ }
1181
1329
 
1182
- // Remove the component from the package.json file
1183
- const packageJsonPath = path.join(env.get(hdbTerms.CONFIG_PARAMS.ROOTPATH), 'package.json');
1184
- if (await fs.pathExists(packageJsonPath)) {
1185
- const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
1186
- if (packageJson?.dependencies?.[project]) {
1187
- delete packageJson.dependencies[project];
1188
- }
1189
- await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');
1190
- }
1330
+ const packageJsonPath = path.join(env.get(hdbTerms.CONFIG_PARAMS.ROOTPATH), 'package.json');
1331
+ if (await fs.pathExists(packageJsonPath)) {
1332
+ const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
1333
+ if (packageJson?.dependencies?.[project]) {
1334
+ delete packageJson.dependencies[project];
1335
+ }
1336
+ await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');
1337
+ }
1191
1338
 
1192
- configUtils.deleteConfigFromFile([project]);
1193
- let response = await server.replication.replicateOperation(req);
1194
- if (req.restart === true) {
1195
- manageThreads.restartWorkers('http');
1196
- response.message = `Successfully dropped: ${projectPath}, restarting Harper`;
1197
- } else response.message = `Successfully dropped: ${projectPath}`;
1339
+ configUtils.deleteConfigFromFile([project]);
1340
+ // The main thread's cached config still names the project; the restart below installs every
1341
+ // package application in that cache, and installing this one would take the lock held here.
1342
+ // (A worker's RESTART message refreshes main's config the same way.)
1343
+ if (isMainThread) env.initSync(true);
1344
+ response = await server.replication.replicateOperation(req);
1345
+ const { applicationHasBranchStorage, removeBranchesForApplication } = require('../resources/branchDatabase.ts');
1346
+ const branched = !file && applicationHasBranchStorage(project);
1347
+ if (req.restart !== true) {
1348
+ response.message = `Successfully dropped: ${projectPath}`;
1349
+ if (branched) response.message += BRANCH_STORAGE_RETAINED;
1350
+ return;
1351
+ }
1352
+ // The branches go after the restart, under this lock; a worker is one of the threads being
1353
+ // replaced, so it hands both to the main thread.
1354
+ response.message = `Successfully dropped: ${projectPath}, restarting Harper`;
1355
+ if (!isMainThread) {
1356
+ parentPort.postMessage({
1357
+ type: hdbTerms.ITC_EVENT_TYPES.RESTART,
1358
+ workerType: 'http',
1359
+ removeBranchesFor: file ? undefined : project,
1360
+ });
1361
+ if (branched) {
1362
+ response.message +=
1363
+ '; the main thread removes its branched database storage after the restart and logs the outcome';
1364
+ }
1365
+ return;
1366
+ }
1367
+ const { awaitRestart } = require('./awaitRestart.ts');
1368
+ const restart = await awaitRestart((onProgress) =>
1369
+ manageThreads.restartWorkers('http', undefined, undefined, onProgress)
1370
+ );
1371
+ logRestartOutcome(restart, `dropping ${projectPath}`);
1372
+ if (!branched) return;
1373
+ if (restart.completed && !restart.workersKeptOnOldCode) {
1374
+ try {
1375
+ await removeBranchesForApplication(project);
1376
+ } catch (error) {
1377
+ log.error(`Branched database storage of ${project} could not be removed`, error);
1378
+ throw new Error(
1379
+ `Successfully dropped: ${projectPath}, but its branched database storage could not be removed and ` +
1380
+ `was left in place: ${error.message}. Drop it again with restart: true to retry.`
1381
+ );
1382
+ }
1383
+ } else {
1384
+ log.warn(`Branched database storage of ${project} was left in place: the restart did not complete`);
1385
+ response.message += BRANCH_STORAGE_RETAINED;
1386
+ }
1387
+ },
1388
+ componentDropLockOptions(project)
1389
+ );
1198
1390
  return response;
1199
1391
  }
1200
1392