@jagilber-org/index-server 1.19.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 (360) hide show
  1. package/CHANGELOG.md +1218 -0
  2. package/CODE_OF_CONDUCT.md +49 -0
  3. package/CONTRIBUTING.md +75 -0
  4. package/LICENSE +21 -0
  5. package/README.md +523 -0
  6. package/SECURITY.md +50 -0
  7. package/dist/config/configUtils.d.ts +11 -0
  8. package/dist/config/configUtils.js +87 -0
  9. package/dist/config/dashboardConfig.d.ts +45 -0
  10. package/dist/config/dashboardConfig.js +63 -0
  11. package/dist/config/defaultValues.d.ts +61 -0
  12. package/dist/config/defaultValues.js +70 -0
  13. package/dist/config/dirConstants.d.ts +17 -0
  14. package/dist/config/dirConstants.js +28 -0
  15. package/dist/config/featureConfig.d.ts +61 -0
  16. package/dist/config/featureConfig.js +121 -0
  17. package/dist/config/runtimeConfig.d.ts +145 -0
  18. package/dist/config/runtimeConfig.js +334 -0
  19. package/dist/config/serverConfig.d.ts +90 -0
  20. package/dist/config/serverConfig.js +164 -0
  21. package/dist/dashboard/analytics/AnalyticsEngine.d.ts +142 -0
  22. package/dist/dashboard/analytics/AnalyticsEngine.js +373 -0
  23. package/dist/dashboard/analytics/BusinessIntelligence.d.ts +187 -0
  24. package/dist/dashboard/analytics/BusinessIntelligence.js +594 -0
  25. package/dist/dashboard/client/admin.html +2150 -0
  26. package/dist/dashboard/client/chunks/mermaid-layout-elk.esm.min/chunk-SP2CHFBE.mjs +1 -0
  27. package/dist/dashboard/client/chunks/mermaid-layout-elk.esm.min/render-T6MDALS3.mjs +27 -0
  28. package/dist/dashboard/client/css/admin.css +1466 -0
  29. package/dist/dashboard/client/js/admin.boot.js +359 -0
  30. package/dist/dashboard/client/js/admin.config.js +196 -0
  31. package/dist/dashboard/client/js/admin.embeddings.js +425 -0
  32. package/dist/dashboard/client/js/admin.graph.js +583 -0
  33. package/dist/dashboard/client/js/admin.instances.js +120 -0
  34. package/dist/dashboard/client/js/admin.instructions.js +552 -0
  35. package/dist/dashboard/client/js/admin.logs.js +113 -0
  36. package/dist/dashboard/client/js/admin.maintenance.js +354 -0
  37. package/dist/dashboard/client/js/admin.messaging.js +635 -0
  38. package/dist/dashboard/client/js/admin.monitor.js +181 -0
  39. package/dist/dashboard/client/js/admin.overview.js +221 -0
  40. package/dist/dashboard/client/js/admin.performance.js +61 -0
  41. package/dist/dashboard/client/js/admin.sessions.js +293 -0
  42. package/dist/dashboard/client/js/admin.sqlite.js +366 -0
  43. package/dist/dashboard/client/js/admin.utils.js +49 -0
  44. package/dist/dashboard/client/js/chart.umd.js +14 -0
  45. package/dist/dashboard/client/js/elk.bundled.js +6696 -0
  46. package/dist/dashboard/client/js/marked.umd.js +74 -0
  47. package/dist/dashboard/client/js/mermaid.min.js +3022 -0
  48. package/dist/dashboard/client/mermaid-layout-elk.esm.min.mjs +1 -0
  49. package/dist/dashboard/export/DataExporter.d.ts +169 -0
  50. package/dist/dashboard/export/DataExporter.js +737 -0
  51. package/dist/dashboard/export/exporters/csvExporter.d.ts +11 -0
  52. package/dist/dashboard/export/exporters/csvExporter.js +46 -0
  53. package/dist/dashboard/export/exporters/exportTypes.d.ts +89 -0
  54. package/dist/dashboard/export/exporters/exportTypes.js +5 -0
  55. package/dist/dashboard/export/exporters/jsonExporter.d.ts +7 -0
  56. package/dist/dashboard/export/exporters/jsonExporter.js +22 -0
  57. package/dist/dashboard/export/exporters/xmlExporter.d.ts +17 -0
  58. package/dist/dashboard/export/exporters/xmlExporter.js +175 -0
  59. package/dist/dashboard/integration/APIIntegration.d.ts +41 -0
  60. package/dist/dashboard/integration/APIIntegration.js +95 -0
  61. package/dist/dashboard/security/SecurityMonitor.d.ts +167 -0
  62. package/dist/dashboard/security/SecurityMonitor.js +559 -0
  63. package/dist/dashboard/server/AdminPanel.d.ts +183 -0
  64. package/dist/dashboard/server/AdminPanel.js +792 -0
  65. package/dist/dashboard/server/AdminPanelConfig.d.ts +42 -0
  66. package/dist/dashboard/server/AdminPanelConfig.js +80 -0
  67. package/dist/dashboard/server/AdminPanelState.d.ts +47 -0
  68. package/dist/dashboard/server/AdminPanelState.js +214 -0
  69. package/dist/dashboard/server/ApiRoutes.d.ts +17 -0
  70. package/dist/dashboard/server/ApiRoutes.js +149 -0
  71. package/dist/dashboard/server/DashboardServer.d.ts +49 -0
  72. package/dist/dashboard/server/DashboardServer.js +159 -0
  73. package/dist/dashboard/server/FileMetricsStorage.d.ts +49 -0
  74. package/dist/dashboard/server/FileMetricsStorage.js +195 -0
  75. package/dist/dashboard/server/HttpTransport.d.ts +23 -0
  76. package/dist/dashboard/server/HttpTransport.js +116 -0
  77. package/dist/dashboard/server/InstanceManager.d.ts +53 -0
  78. package/dist/dashboard/server/InstanceManager.js +284 -0
  79. package/dist/dashboard/server/KnowledgeStore.d.ts +35 -0
  80. package/dist/dashboard/server/KnowledgeStore.js +105 -0
  81. package/dist/dashboard/server/LeaderElection.d.ts +81 -0
  82. package/dist/dashboard/server/LeaderElection.js +268 -0
  83. package/dist/dashboard/server/MetricsCollector.d.ts +200 -0
  84. package/dist/dashboard/server/MetricsCollector.js +803 -0
  85. package/dist/dashboard/server/SessionPersistenceManager.d.ts +88 -0
  86. package/dist/dashboard/server/SessionPersistenceManager.js +457 -0
  87. package/dist/dashboard/server/ThinClient.d.ts +64 -0
  88. package/dist/dashboard/server/ThinClient.js +237 -0
  89. package/dist/dashboard/server/WebSocketManager.d.ts +161 -0
  90. package/dist/dashboard/server/WebSocketManager.js +463 -0
  91. package/dist/dashboard/server/httpLifecycle.d.ts +17 -0
  92. package/dist/dashboard/server/httpLifecycle.js +35 -0
  93. package/dist/dashboard/server/legacyDashboardHtml.d.ts +9 -0
  94. package/dist/dashboard/server/legacyDashboardHtml.js +618 -0
  95. package/dist/dashboard/server/legacyDashboardStyles.d.ts +5 -0
  96. package/dist/dashboard/server/legacyDashboardStyles.js +490 -0
  97. package/dist/dashboard/server/metricsAggregation.d.ts +252 -0
  98. package/dist/dashboard/server/metricsAggregation.js +206 -0
  99. package/dist/dashboard/server/metricsSerializer.d.ts +25 -0
  100. package/dist/dashboard/server/metricsSerializer.js +195 -0
  101. package/dist/dashboard/server/routes/admin.routes.d.ts +16 -0
  102. package/dist/dashboard/server/routes/admin.routes.js +596 -0
  103. package/dist/dashboard/server/routes/alerts.routes.d.ts +7 -0
  104. package/dist/dashboard/server/routes/alerts.routes.js +93 -0
  105. package/dist/dashboard/server/routes/api.feedback.routes.d.ts +73 -0
  106. package/dist/dashboard/server/routes/api.feedback.routes.js +171 -0
  107. package/dist/dashboard/server/routes/api.instructions.routes.d.ts +101 -0
  108. package/dist/dashboard/server/routes/api.instructions.routes.js +213 -0
  109. package/dist/dashboard/server/routes/api.usage.routes.d.ts +57 -0
  110. package/dist/dashboard/server/routes/api.usage.routes.js +374 -0
  111. package/dist/dashboard/server/routes/embeddings.routes.d.ts +6 -0
  112. package/dist/dashboard/server/routes/embeddings.routes.js +246 -0
  113. package/dist/dashboard/server/routes/graph.routes.d.ts +6 -0
  114. package/dist/dashboard/server/routes/graph.routes.js +280 -0
  115. package/dist/dashboard/server/routes/index.d.ts +38 -0
  116. package/dist/dashboard/server/routes/index.js +194 -0
  117. package/dist/dashboard/server/routes/instances.routes.d.ts +6 -0
  118. package/dist/dashboard/server/routes/instances.routes.js +35 -0
  119. package/dist/dashboard/server/routes/instructions.routes.d.ts +8 -0
  120. package/dist/dashboard/server/routes/instructions.routes.js +336 -0
  121. package/dist/dashboard/server/routes/knowledge.routes.d.ts +6 -0
  122. package/dist/dashboard/server/routes/knowledge.routes.js +82 -0
  123. package/dist/dashboard/server/routes/logs.routes.d.ts +6 -0
  124. package/dist/dashboard/server/routes/logs.routes.js +164 -0
  125. package/dist/dashboard/server/routes/messaging.routes.d.ts +16 -0
  126. package/dist/dashboard/server/routes/messaging.routes.js +293 -0
  127. package/dist/dashboard/server/routes/metrics.routes.d.ts +10 -0
  128. package/dist/dashboard/server/routes/metrics.routes.js +346 -0
  129. package/dist/dashboard/server/routes/scripts.routes.d.ts +9 -0
  130. package/dist/dashboard/server/routes/scripts.routes.js +84 -0
  131. package/dist/dashboard/server/routes/sqlite.routes.d.ts +9 -0
  132. package/dist/dashboard/server/routes/sqlite.routes.js +569 -0
  133. package/dist/dashboard/server/routes/status.routes.d.ts +7 -0
  134. package/dist/dashboard/server/routes/status.routes.js +183 -0
  135. package/dist/dashboard/server/routes/synthetic.routes.d.ts +7 -0
  136. package/dist/dashboard/server/routes/synthetic.routes.js +195 -0
  137. package/dist/dashboard/server/routes/tools.routes.d.ts +6 -0
  138. package/dist/dashboard/server/routes/tools.routes.js +46 -0
  139. package/dist/dashboard/server/routes/usage.routes.d.ts +6 -0
  140. package/dist/dashboard/server/routes/usage.routes.js +25 -0
  141. package/dist/dashboard/server/wsInit.d.ts +16 -0
  142. package/dist/dashboard/server/wsInit.js +35 -0
  143. package/dist/externalClientLib.d.ts +1 -0
  144. package/dist/externalClientLib.js +2 -0
  145. package/dist/minimal/index.d.ts +1 -0
  146. package/dist/minimal/index.js +140 -0
  147. package/dist/models/SessionPersistence.d.ts +115 -0
  148. package/dist/models/SessionPersistence.js +66 -0
  149. package/dist/models/instruction.d.ts +45 -0
  150. package/dist/models/instruction.js +2 -0
  151. package/dist/perf/benchmark.d.ts +1 -0
  152. package/dist/perf/benchmark.js +50 -0
  153. package/dist/portableClientWrapper.d.ts +1 -0
  154. package/dist/portableClientWrapper.js +2 -0
  155. package/dist/schemas/index.d.ts +128 -0
  156. package/dist/schemas/index.js +371 -0
  157. package/dist/scripts/runPerformanceBaseline.d.ts +1 -0
  158. package/dist/scripts/runPerformanceBaseline.js +17 -0
  159. package/dist/server/handshakeManager.d.ts +25 -0
  160. package/dist/server/handshakeManager.js +472 -0
  161. package/dist/server/index-server.d.ts +56 -0
  162. package/dist/server/index-server.js +822 -0
  163. package/dist/server/registry.d.ts +44 -0
  164. package/dist/server/registry.js +236 -0
  165. package/dist/server/sdkServer.d.ts +8 -0
  166. package/dist/server/sdkServer.js +299 -0
  167. package/dist/server/shutdownGuard.d.ts +41 -0
  168. package/dist/server/shutdownGuard.js +52 -0
  169. package/dist/server/thin-client.d.ts +22 -0
  170. package/dist/server/thin-client.js +111 -0
  171. package/dist/server/transport.d.ts +41 -0
  172. package/dist/server/transport.js +312 -0
  173. package/dist/server/transportFactory.d.ts +21 -0
  174. package/dist/server/transportFactory.js +429 -0
  175. package/dist/services/atomicFs.d.ts +22 -0
  176. package/dist/services/atomicFs.js +103 -0
  177. package/dist/services/auditLog.d.ts +38 -0
  178. package/dist/services/auditLog.js +142 -0
  179. package/dist/services/autoBackup.d.ts +14 -0
  180. package/dist/services/autoBackup.js +171 -0
  181. package/dist/services/autoSplit.d.ts +32 -0
  182. package/dist/services/autoSplit.js +113 -0
  183. package/dist/services/backupZip.d.ts +25 -0
  184. package/dist/services/backupZip.js +110 -0
  185. package/dist/services/bootstrapGating.d.ts +123 -0
  186. package/dist/services/bootstrapGating.js +221 -0
  187. package/dist/services/canonical.d.ts +23 -0
  188. package/dist/services/canonical.js +65 -0
  189. package/dist/services/categoryRules.d.ts +7 -0
  190. package/dist/services/categoryRules.js +37 -0
  191. package/dist/services/classificationService.d.ts +42 -0
  192. package/dist/services/classificationService.js +168 -0
  193. package/dist/services/embeddingService.d.ts +62 -0
  194. package/dist/services/embeddingService.js +259 -0
  195. package/dist/services/errors.d.ts +22 -0
  196. package/dist/services/errors.js +31 -0
  197. package/dist/services/featureFlags.d.ts +25 -0
  198. package/dist/services/featureFlags.js +89 -0
  199. package/dist/services/features.d.ts +13 -0
  200. package/dist/services/features.js +35 -0
  201. package/dist/services/handlers/instructions.add.d.ts +1 -0
  202. package/dist/services/handlers/instructions.add.js +496 -0
  203. package/dist/services/handlers/instructions.groom.d.ts +1 -0
  204. package/dist/services/handlers/instructions.groom.js +523 -0
  205. package/dist/services/handlers/instructions.import.d.ts +1 -0
  206. package/dist/services/handlers/instructions.import.js +173 -0
  207. package/dist/services/handlers/instructions.patch.d.ts +1 -0
  208. package/dist/services/handlers/instructions.patch.js +167 -0
  209. package/dist/services/handlers/instructions.query.d.ts +163 -0
  210. package/dist/services/handlers/instructions.query.js +522 -0
  211. package/dist/services/handlers/instructions.reload.d.ts +1 -0
  212. package/dist/services/handlers/instructions.reload.js +13 -0
  213. package/dist/services/handlers/instructions.remove.d.ts +1 -0
  214. package/dist/services/handlers/instructions.remove.js +118 -0
  215. package/dist/services/handlers/instructions.shared.d.ts +31 -0
  216. package/dist/services/handlers/instructions.shared.js +124 -0
  217. package/dist/services/handlers.activation.d.ts +1 -0
  218. package/dist/services/handlers.activation.js +203 -0
  219. package/dist/services/handlers.bootstrap.d.ts +1 -0
  220. package/dist/services/handlers.bootstrap.js +38 -0
  221. package/dist/services/handlers.dashboardConfig.d.ts +34 -0
  222. package/dist/services/handlers.dashboardConfig.js +108 -0
  223. package/dist/services/handlers.diagnostics.d.ts +1 -0
  224. package/dist/services/handlers.diagnostics.js +64 -0
  225. package/dist/services/handlers.feedback.d.ts +15 -0
  226. package/dist/services/handlers.feedback.js +378 -0
  227. package/dist/services/handlers.gates.d.ts +1 -0
  228. package/dist/services/handlers.gates.js +46 -0
  229. package/dist/services/handlers.graph.d.ts +53 -0
  230. package/dist/services/handlers.graph.js +231 -0
  231. package/dist/services/handlers.help.d.ts +1 -0
  232. package/dist/services/handlers.help.js +119 -0
  233. package/dist/services/handlers.instructionSchema.d.ts +1 -0
  234. package/dist/services/handlers.instructionSchema.js +227 -0
  235. package/dist/services/handlers.instructions.d.ts +8 -0
  236. package/dist/services/handlers.instructions.js +14 -0
  237. package/dist/services/handlers.instructionsDiagnostics.d.ts +1 -0
  238. package/dist/services/handlers.instructionsDiagnostics.js +14 -0
  239. package/dist/services/handlers.integrity.d.ts +1 -0
  240. package/dist/services/handlers.integrity.js +35 -0
  241. package/dist/services/handlers.manifest.d.ts +1 -0
  242. package/dist/services/handlers.manifest.js +24 -0
  243. package/dist/services/handlers.messaging.d.ts +12 -0
  244. package/dist/services/handlers.messaging.js +203 -0
  245. package/dist/services/handlers.metrics.d.ts +1 -0
  246. package/dist/services/handlers.metrics.js +43 -0
  247. package/dist/services/handlers.promote.d.ts +1 -0
  248. package/dist/services/handlers.promote.js +306 -0
  249. package/dist/services/handlers.prompt.d.ts +1 -0
  250. package/dist/services/handlers.prompt.js +7 -0
  251. package/dist/services/handlers.search.d.ts +69 -0
  252. package/dist/services/handlers.search.js +645 -0
  253. package/dist/services/handlers.testPrimitive.d.ts +1 -0
  254. package/dist/services/handlers.testPrimitive.js +5 -0
  255. package/dist/services/handlers.trace.d.ts +1 -0
  256. package/dist/services/handlers.trace.js +31 -0
  257. package/dist/services/handlers.usage.d.ts +1 -0
  258. package/dist/services/handlers.usage.js +11 -0
  259. package/dist/services/hotScore.d.ts +137 -0
  260. package/dist/services/hotScore.js +244 -0
  261. package/dist/services/indexContext.d.ts +117 -0
  262. package/dist/services/indexContext.js +968 -0
  263. package/dist/services/indexLoader.d.ts +44 -0
  264. package/dist/services/indexLoader.js +921 -0
  265. package/dist/services/indexRepository.d.ts +32 -0
  266. package/dist/services/indexRepository.js +71 -0
  267. package/dist/services/indexingService.d.ts +1 -0
  268. package/dist/services/indexingService.js +2 -0
  269. package/dist/services/instructions.dispatcher.d.ts +1 -0
  270. package/dist/services/instructions.dispatcher.js +231 -0
  271. package/dist/services/logPrefix.d.ts +1 -0
  272. package/dist/services/logPrefix.js +30 -0
  273. package/dist/services/logger.d.ts +52 -0
  274. package/dist/services/logger.js +268 -0
  275. package/dist/services/manifestManager.d.ts +82 -0
  276. package/dist/services/manifestManager.js +200 -0
  277. package/dist/services/messaging/agentMailbox.d.ts +60 -0
  278. package/dist/services/messaging/agentMailbox.js +353 -0
  279. package/dist/services/messaging/messagingPersistence.d.ts +20 -0
  280. package/dist/services/messaging/messagingPersistence.js +111 -0
  281. package/dist/services/messaging/messagingTypes.d.ts +150 -0
  282. package/dist/services/messaging/messagingTypes.js +66 -0
  283. package/dist/services/ownershipService.d.ts +1 -0
  284. package/dist/services/ownershipService.js +38 -0
  285. package/dist/services/performanceBaseline.d.ts +19 -0
  286. package/dist/services/performanceBaseline.js +210 -0
  287. package/dist/services/preflight.d.ts +12 -0
  288. package/dist/services/preflight.js +79 -0
  289. package/dist/services/promptReviewService.d.ts +44 -0
  290. package/dist/services/promptReviewService.js +101 -0
  291. package/dist/services/responseEnvelope.d.ts +6 -0
  292. package/dist/services/responseEnvelope.js +25 -0
  293. package/dist/services/seedBootstrap.d.ts +34 -0
  294. package/dist/services/seedBootstrap.js +427 -0
  295. package/dist/services/storage/factory.d.ts +17 -0
  296. package/dist/services/storage/factory.js +35 -0
  297. package/dist/services/storage/hashUtils.d.ts +11 -0
  298. package/dist/services/storage/hashUtils.js +35 -0
  299. package/dist/services/storage/index.d.ts +12 -0
  300. package/dist/services/storage/index.js +18 -0
  301. package/dist/services/storage/jsonFileStore.d.ts +32 -0
  302. package/dist/services/storage/jsonFileStore.js +241 -0
  303. package/dist/services/storage/migrationEngine.d.ts +35 -0
  304. package/dist/services/storage/migrationEngine.js +93 -0
  305. package/dist/services/storage/sqliteMessageStore.d.ts +53 -0
  306. package/dist/services/storage/sqliteMessageStore.js +146 -0
  307. package/dist/services/storage/sqliteSchema.d.ts +12 -0
  308. package/dist/services/storage/sqliteSchema.js +122 -0
  309. package/dist/services/storage/sqliteStore.d.ts +41 -0
  310. package/dist/services/storage/sqliteStore.js +339 -0
  311. package/dist/services/storage/sqliteUsageStore.d.ts +35 -0
  312. package/dist/services/storage/sqliteUsageStore.js +94 -0
  313. package/dist/services/storage/types.d.ts +171 -0
  314. package/dist/services/storage/types.js +12 -0
  315. package/dist/services/toolHandlers.d.ts +23 -0
  316. package/dist/services/toolHandlers.js +50 -0
  317. package/dist/services/toolRegistry.d.ts +20 -0
  318. package/dist/services/toolRegistry.js +490 -0
  319. package/dist/services/toolRegistry.zod.d.ts +10 -0
  320. package/dist/services/toolRegistry.zod.js +323 -0
  321. package/dist/services/tracing.d.ts +26 -0
  322. package/dist/services/tracing.js +260 -0
  323. package/dist/services/usageBuckets.d.ts +161 -0
  324. package/dist/services/usageBuckets.js +364 -0
  325. package/dist/services/validationService.d.ts +38 -0
  326. package/dist/services/validationService.js +125 -0
  327. package/dist/utils/BufferRing.d.ts +203 -0
  328. package/dist/utils/BufferRing.js +551 -0
  329. package/dist/utils/BufferRingExamples.d.ts +55 -0
  330. package/dist/utils/BufferRingExamples.js +188 -0
  331. package/dist/utils/envUtils.d.ts +42 -0
  332. package/dist/utils/envUtils.js +80 -0
  333. package/dist/utils/memoryMonitor.d.ts +83 -0
  334. package/dist/utils/memoryMonitor.js +275 -0
  335. package/dist/versioning/schemaVersion.d.ts +6 -0
  336. package/dist/versioning/schemaVersion.js +93 -0
  337. package/package.json +134 -0
  338. package/schemas/README.md +13 -0
  339. package/schemas/feedback-entry.schema.json +27 -0
  340. package/schemas/graph-export-v2.schema.json +60 -0
  341. package/schemas/index-server.code-schema.json +38477 -0
  342. package/schemas/instruction.schema.json +262 -0
  343. package/schemas/json-schema/SessionPersistence-persisted-admin-session.schema.json +54 -0
  344. package/schemas/json-schema/SessionPersistence-persisted-session-history-entry.schema.json +51 -0
  345. package/schemas/json-schema/SessionPersistence-persisted-web-socket-connection.schema.json +54 -0
  346. package/schemas/json-schema/SessionPersistence-session-persistence-config.schema.json +110 -0
  347. package/schemas/json-schema/SessionPersistence-session-persistence-data.schema.json +229 -0
  348. package/schemas/json-schema/SessionPersistence-session-persistence-manifest.schema.json +109 -0
  349. package/schemas/json-schema/SessionPersistence-session-persistence-metadata.schema.json +55 -0
  350. package/schemas/json-schema/instruction-audience-scope.schema.json +14 -0
  351. package/schemas/json-schema/instruction-content-type.schema.json +17 -0
  352. package/schemas/json-schema/instruction-instruction-entry.schema.json +206 -0
  353. package/schemas/json-schema/instruction-requirement-level.schema.json +16 -0
  354. package/schemas/manifest.json +78 -0
  355. package/schemas/manifest.schema.json +33 -0
  356. package/schemas/usage-batch.schema.json +16 -0
  357. package/schemas/usage-buckets.schema.json +30 -0
  358. package/schemas/usage-event.schema.json +17 -0
  359. package/scripts/copy-dashboard-assets.mjs +170 -0
  360. package/scripts/setup-hooks.cjs +28 -0
@@ -0,0 +1,123 @@
1
+ /** Returns `true` when the server is running in reference (read-only) mode. */
2
+ export declare function isReferenceMode(): boolean;
3
+ /** Returns `true` if bootstrap confirmation has been persisted or confirmed in memory. */
4
+ export declare function isBootstrapConfirmed(): boolean;
5
+ /**
6
+ * Returns `true` if the loaded index contains at least one instruction that is not a
7
+ * canonical bootstrap seed (i.e. the workspace has been customized beyond the defaults).
8
+ * @returns `true` when non-bootstrap instructions are present, `false` on empty or seed-only index
9
+ */
10
+ export declare function hasNonBootstrapInstructions(): boolean;
11
+ /**
12
+ * Returns `true` when the server must ask the operator to confirm before accepting mutations.
13
+ * Confirmation is required only when: not in reference mode, not already confirmed, and the
14
+ * index contains only bootstrap seed instructions.
15
+ * @returns `true` when mutation confirmation is still required, `false` otherwise
16
+ */
17
+ export declare function shouldRequireConfirmation(): boolean;
18
+ /**
19
+ * Returns the reason mutations are gated, or `null` when mutations are freely allowed.
20
+ * @returns A short reason string (`'reference_mode_read_only'` or `'bootstrap_confirmation_required'`),
21
+ * or `null` if no gate is active
22
+ */
23
+ export declare function mutationGatedReason(): string | null;
24
+ /**
25
+ * Issue a short-lived one-time token that an operator must confirm to unlock mutations.
26
+ * Safe to call multiple times — returns the existing pending token if still valid.
27
+ * @param rationale - Optional hint text describing why bootstrap confirmation is being requested
28
+ * @returns An object with `token` (raw OTP for the operator) or a status flag when already confirmed/reference-mode
29
+ */
30
+ export declare function requestBootstrapToken(rationale?: string): {
31
+ readonly referenceMode: true;
32
+ readonly mutation: false;
33
+ readonly alreadyConfirmed?: undefined;
34
+ readonly token?: undefined;
35
+ readonly hint?: undefined;
36
+ readonly expiresAt?: undefined;
37
+ readonly pending?: undefined;
38
+ } | {
39
+ readonly alreadyConfirmed: true;
40
+ readonly referenceMode?: undefined;
41
+ readonly mutation?: undefined;
42
+ readonly token?: undefined;
43
+ readonly hint?: undefined;
44
+ readonly expiresAt?: undefined;
45
+ readonly pending?: undefined;
46
+ } | {
47
+ readonly token: "(reissued)";
48
+ readonly hint: string;
49
+ readonly expiresAt: number;
50
+ readonly pending: true;
51
+ readonly referenceMode?: undefined;
52
+ readonly mutation?: undefined;
53
+ readonly alreadyConfirmed?: undefined;
54
+ } | {
55
+ readonly token: string;
56
+ readonly expiresAt: number;
57
+ readonly hint: string;
58
+ readonly referenceMode?: undefined;
59
+ readonly mutation?: undefined;
60
+ readonly alreadyConfirmed?: undefined;
61
+ readonly pending?: undefined;
62
+ };
63
+ /**
64
+ * Validate the provided token against the pending OTP and, on success, persist confirmation.
65
+ * Once confirmed the workspace remains unlocked across process restarts until the file is removed.
66
+ * @param token - Raw OTP previously issued by {@link requestBootstrapToken}
67
+ * @returns An object with `confirmed: true` on success, or an `error` key describing the failure
68
+ */
69
+ export declare function finalizeBootstrapToken(token: string): {
70
+ readonly referenceMode: true;
71
+ readonly mutation: false;
72
+ readonly alreadyConfirmed?: undefined;
73
+ error?: undefined;
74
+ readonly confirmed?: undefined;
75
+ } | {
76
+ readonly alreadyConfirmed: true;
77
+ readonly referenceMode?: undefined;
78
+ readonly mutation?: undefined;
79
+ error?: undefined;
80
+ readonly confirmed?: undefined;
81
+ } | {
82
+ readonly error: "no_pending_token";
83
+ readonly referenceMode?: undefined;
84
+ readonly mutation?: undefined;
85
+ readonly alreadyConfirmed?: undefined;
86
+ readonly confirmed?: undefined;
87
+ } | {
88
+ readonly error: "token_expired";
89
+ readonly referenceMode?: undefined;
90
+ readonly mutation?: undefined;
91
+ readonly alreadyConfirmed?: undefined;
92
+ readonly confirmed?: undefined;
93
+ } | {
94
+ readonly error: "invalid_token";
95
+ readonly referenceMode?: undefined;
96
+ readonly mutation?: undefined;
97
+ readonly alreadyConfirmed?: undefined;
98
+ readonly confirmed?: undefined;
99
+ } | {
100
+ readonly confirmed: true;
101
+ readonly referenceMode?: undefined;
102
+ readonly mutation?: undefined;
103
+ readonly alreadyConfirmed?: undefined;
104
+ error?: undefined;
105
+ };
106
+ /**
107
+ * Return the current bootstrap gating status as a plain object.
108
+ * @returns Object with `referenceMode`, `confirmed`, `requireConfirmation`, and `nonBootstrapInstructions` flags
109
+ */
110
+ export declare function getBootstrapStatus(): {
111
+ referenceMode: boolean;
112
+ confirmed: boolean;
113
+ requireConfirmation: boolean;
114
+ nonBootstrapInstructions: boolean;
115
+ };
116
+ export declare const BOOTSTRAP_ALLOWLIST: Set<string>;
117
+ /**
118
+ * Force bootstrap confirmation for test environments. Only runs when
119
+ * `INDEX_SERVER_BOOTSTRAP_AUTOCONFIRM=1` is set. Has no effect in reference mode.
120
+ * @param reason - Descriptive label written to the confirmation artifact (default: `'auto-confirm (test)'`)
121
+ * @returns `true` if confirmation was set successfully, `false` if already confirmed or an error occurred
122
+ */
123
+ export declare function forceBootstrapConfirmForTests(reason?: string): boolean;
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.BOOTSTRAP_ALLOWLIST = void 0;
7
+ exports.isReferenceMode = isReferenceMode;
8
+ exports.isBootstrapConfirmed = isBootstrapConfirmed;
9
+ exports.hasNonBootstrapInstructions = hasNonBootstrapInstructions;
10
+ exports.shouldRequireConfirmation = shouldRequireConfirmation;
11
+ exports.mutationGatedReason = mutationGatedReason;
12
+ exports.requestBootstrapToken = requestBootstrapToken;
13
+ exports.finalizeBootstrapToken = finalizeBootstrapToken;
14
+ exports.getBootstrapStatus = getBootstrapStatus;
15
+ exports.forceBootstrapConfirmForTests = forceBootstrapConfirmForTests;
16
+ const fs_1 = __importDefault(require("fs"));
17
+ const path_1 = __importDefault(require("path"));
18
+ const crypto_1 = __importDefault(require("crypto"));
19
+ const indexContext_1 = require("./indexContext");
20
+ const runtimeConfig_1 = require("../config/runtimeConfig");
21
+ /**
22
+ * Bootstrap / confirmation gating logic.
23
+ * States:
24
+ * - reference mode (INDEX_SERVER_REFERENCE_MODE=1): index is read-only, all mutation blocked permanently
25
+ * - new workspace: only bootstrap seed instructions present (000-bootstrapper / 001-lifecycle-bootstrap) → require confirmation
26
+ * - existing workspace: any non-bootstrap instruction present OR confirmation file exists -> mutation allowed (subject to INDEX_SERVER_MUTATION rules)
27
+ * - confirmed: confirmation file created after successful finalize → persists across restarts
28
+ */
29
+ const BOOTSTRAP_IDS = new Set(['000-bootstrapper', '001-lifecycle-bootstrap']);
30
+ const CONFIRM_FILE = 'bootstrap.confirmed.json';
31
+ const PENDING_FILE = 'bootstrap.pending.json';
32
+ let inMemoryPending = null;
33
+ let confirmed = false;
34
+ let loaded = false;
35
+ function bootstrapConfig() {
36
+ return (0, runtimeConfig_1.getRuntimeConfig)().server.bootstrap;
37
+ }
38
+ function instructionsDirSafe() {
39
+ try {
40
+ return (0, indexContext_1.getInstructionsDir)();
41
+ }
42
+ catch {
43
+ return process.cwd();
44
+ }
45
+ }
46
+ function loadState() {
47
+ if (loaded)
48
+ return;
49
+ loaded = true;
50
+ if (isReferenceMode())
51
+ return; // nothing to load
52
+ try {
53
+ const dir = instructionsDirSafe();
54
+ const file = path_1.default.join(dir, CONFIRM_FILE);
55
+ if (fs_1.default.existsSync(file)) {
56
+ confirmed = true; // minimal persistence flag
57
+ }
58
+ }
59
+ catch { /* ignore */ }
60
+ }
61
+ /** Returns `true` when the server is running in reference (read-only) mode. */
62
+ function isReferenceMode() { return bootstrapConfig().referenceMode; }
63
+ /** Returns `true` if bootstrap confirmation has been persisted or confirmed in memory. */
64
+ function isBootstrapConfirmed() { loadState(); return confirmed; }
65
+ /**
66
+ * Returns `true` if the loaded index contains at least one instruction that is not a
67
+ * canonical bootstrap seed (i.e. the workspace has been customized beyond the defaults).
68
+ * @returns `true` when non-bootstrap instructions are present, `false` on empty or seed-only index
69
+ */
70
+ function hasNonBootstrapInstructions() {
71
+ try {
72
+ const st = (0, indexContext_1.ensureLoaded)();
73
+ for (const e of st.list) {
74
+ if (!BOOTSTRAP_IDS.has(e.id))
75
+ return true;
76
+ }
77
+ return false;
78
+ }
79
+ catch {
80
+ return false;
81
+ }
82
+ }
83
+ /**
84
+ * Returns `true` when the server must ask the operator to confirm before accepting mutations.
85
+ * Confirmation is required only when: not in reference mode, not already confirmed, and the
86
+ * index contains only bootstrap seed instructions.
87
+ * @returns `true` when mutation confirmation is still required, `false` otherwise
88
+ */
89
+ function shouldRequireConfirmation() {
90
+ if (isReferenceMode())
91
+ return false; // immutable anyway
92
+ if (isBootstrapConfirmed())
93
+ return false;
94
+ if (hasNonBootstrapInstructions())
95
+ return false; // existing workspace
96
+ return true; // only seeds present
97
+ }
98
+ /**
99
+ * Returns the reason mutations are gated, or `null` when mutations are freely allowed.
100
+ * @returns A short reason string (`'reference_mode_read_only'` or `'bootstrap_confirmation_required'`),
101
+ * or `null` if no gate is active
102
+ */
103
+ function mutationGatedReason() {
104
+ if (isReferenceMode())
105
+ return 'reference_mode_read_only';
106
+ if (shouldRequireConfirmation())
107
+ return 'bootstrap_confirmation_required';
108
+ return null;
109
+ }
110
+ /**
111
+ * Issue a short-lived one-time token that an operator must confirm to unlock mutations.
112
+ * Safe to call multiple times — returns the existing pending token if still valid.
113
+ * @param rationale - Optional hint text describing why bootstrap confirmation is being requested
114
+ * @returns An object with `token` (raw OTP for the operator) or a status flag when already confirmed/reference-mode
115
+ */
116
+ function requestBootstrapToken(rationale) {
117
+ if (isReferenceMode())
118
+ return { referenceMode: true, mutation: false };
119
+ if (isBootstrapConfirmed())
120
+ return { alreadyConfirmed: true };
121
+ // issue or reuse pending if still valid
122
+ const now = Date.now();
123
+ if (inMemoryPending && inMemoryPending.expiresAt > now) {
124
+ return { token: '(reissued)', hint: inMemoryPending.hint, expiresAt: inMemoryPending.expiresAt, pending: true };
125
+ }
126
+ const raw = crypto_1.default.randomBytes(6).toString('hex');
127
+ const hash = crypto_1.default.createHash('sha256').update(raw, 'utf8').digest('hex');
128
+ const expiresSec = Math.max(1, bootstrapConfig().tokenTtlSec);
129
+ const rec = { hash, expiresAt: now + (expiresSec * 1000), issuedAt: now, hint: rationale || 'Human operator: review context, then provide token to bootstrap_confirmFinalize.' };
130
+ inMemoryPending = rec;
131
+ // Persist (best-effort): do not write the raw token, only its hash
132
+ try {
133
+ const dir = instructionsDirSafe();
134
+ fs_1.default.writeFileSync(path_1.default.join(dir, PENDING_FILE), JSON.stringify({ issuedAt: rec.issuedAt, expiresAt: rec.expiresAt }, null, 2));
135
+ }
136
+ catch { /* ignore */ }
137
+ return { token: raw, expiresAt: rec.expiresAt, hint: rec.hint };
138
+ }
139
+ /**
140
+ * Validate the provided token against the pending OTP and, on success, persist confirmation.
141
+ * Once confirmed the workspace remains unlocked across process restarts until the file is removed.
142
+ * @param token - Raw OTP previously issued by {@link requestBootstrapToken}
143
+ * @returns An object with `confirmed: true` on success, or an `error` key describing the failure
144
+ */
145
+ function finalizeBootstrapToken(token) {
146
+ if (isReferenceMode())
147
+ return { referenceMode: true, mutation: false };
148
+ if (isBootstrapConfirmed())
149
+ return { alreadyConfirmed: true };
150
+ if (!inMemoryPending)
151
+ return { error: 'no_pending_token' };
152
+ const now = Date.now();
153
+ if (inMemoryPending.expiresAt <= now) {
154
+ inMemoryPending = null;
155
+ return { error: 'token_expired' };
156
+ }
157
+ const hash = crypto_1.default.createHash('sha256').update(token, 'utf8').digest('hex');
158
+ const pendingHashBuf = Buffer.from(inMemoryPending.hash, 'hex');
159
+ const tokenHashBuf = Buffer.from(hash, 'hex');
160
+ if (pendingHashBuf.length !== tokenHashBuf.length || !crypto_1.default.timingSafeEqual(pendingHashBuf, tokenHashBuf))
161
+ return { error: 'invalid_token' };
162
+ confirmed = true;
163
+ try {
164
+ const dir = instructionsDirSafe();
165
+ const rec = { confirmedAt: new Date().toISOString(), tokenHint: inMemoryPending.hint };
166
+ fs_1.default.writeFileSync(path_1.default.join(dir, CONFIRM_FILE), JSON.stringify(rec, null, 2));
167
+ }
168
+ catch { /* ignore */ }
169
+ inMemoryPending = null;
170
+ return { confirmed: true };
171
+ }
172
+ /**
173
+ * Return the current bootstrap gating status as a plain object.
174
+ * @returns Object with `referenceMode`, `confirmed`, `requireConfirmation`, and `nonBootstrapInstructions` flags
175
+ */
176
+ function getBootstrapStatus() {
177
+ return {
178
+ referenceMode: isReferenceMode(),
179
+ confirmed: isBootstrapConfirmed(),
180
+ requireConfirmation: shouldRequireConfirmation(),
181
+ nonBootstrapInstructions: hasNonBootstrapInstructions()
182
+ };
183
+ }
184
+ exports.BOOTSTRAP_ALLOWLIST = BOOTSTRAP_IDS; // re-export for risk computation allowlist
185
+ // ----------------------------------------------------------------------------------
186
+ // Test Support: Optional force-confirm path (never used in production flows)
187
+ // ----------------------------------------------------------------------------------
188
+ // Some integration tests pre-date bootstrap confirmation and expect immediate
189
+ // mutation capability. To avoid invasive edits across dozens of tests we expose
190
+ // a narrow helper that marks the workspace as confirmed when an opt‑in
191
+ // environment variable (INDEX_SERVER_BOOTSTRAP_AUTOCONFIRM=1) is set. This writes the
192
+ // same confirmation artifact the manual token flow would create so subsequent
193
+ // real runs still observe the confirmed state. Reference mode intentionally
194
+ // bypasses any force confirmation.
195
+ //
196
+ // IMPORTANT: This function is intentionally not exported via tool surfaces and
197
+ // should only be invoked programmatically by the server on startup when the
198
+ // explicit test environment variable is present. It is safe because it requires
199
+ // direct code execution (cannot be triggered by an MCP client) and mirrors the
200
+ // final persisted shape of a legitimate confirmation.
201
+ /**
202
+ * Force bootstrap confirmation for test environments. Only runs when
203
+ * `INDEX_SERVER_BOOTSTRAP_AUTOCONFIRM=1` is set. Has no effect in reference mode.
204
+ * @param reason - Descriptive label written to the confirmation artifact (default: `'auto-confirm (test)'`)
205
+ * @returns `true` if confirmation was set successfully, `false` if already confirmed or an error occurred
206
+ */
207
+ function forceBootstrapConfirmForTests(reason = 'auto-confirm (test)') {
208
+ if (isReferenceMode())
209
+ return false;
210
+ if (confirmed)
211
+ return true;
212
+ try {
213
+ const dir = instructionsDirSafe();
214
+ const rec = { confirmedAt: new Date().toISOString(), tokenHint: reason };
215
+ fs_1.default.writeFileSync(path_1.default.join(dir, CONFIRM_FILE), JSON.stringify(rec, null, 2));
216
+ confirmed = true;
217
+ return true;
218
+ }
219
+ catch { /* ignore */ }
220
+ return false;
221
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Canonicalize instruction body text for hashing & comparison.
3
+ * Non-destructive normalization choices are intentionally conservative to avoid
4
+ * retroactive hash churn across existing index entries while still removing
5
+ * accidental instability sources (line ending variance, trailing spaces, outer blank lines).
6
+ *
7
+ * Rules:
8
+ * - Normalize CRLF/CR to LF
9
+ * - Strip trailing spaces / tabs from each line
10
+ * - Trim leading & trailing blank lines
11
+ * - Collapse runs of >2 blank lines to a single blank line (optional; disabled by default)
12
+ *
13
+ * NOTE: We do NOT reorder semantic list blocks or collapse internal single blank lines so that
14
+ * meaningful ordering (e.g., link lists) still produces distinct hashes.
15
+ * @param body - Raw instruction body text to normalize
16
+ * @param options - Optional normalization options
17
+ * @param options.collapseMultipleBlankLines - When `true`, runs of more than one blank line are collapsed to a single blank line
18
+ * @returns Canonicalized body string
19
+ */
20
+ export declare function canonicalizeBody(body: string, options?: {
21
+ collapseMultipleBlankLines?: boolean;
22
+ }): string;
23
+ export declare function hashBody(body: string): string;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.canonicalizeBody = canonicalizeBody;
7
+ exports.hashBody = hashBody;
8
+ /**
9
+ * Canonicalize instruction body text for hashing & comparison.
10
+ * Non-destructive normalization choices are intentionally conservative to avoid
11
+ * retroactive hash churn across existing index entries while still removing
12
+ * accidental instability sources (line ending variance, trailing spaces, outer blank lines).
13
+ *
14
+ * Rules:
15
+ * - Normalize CRLF/CR to LF
16
+ * - Strip trailing spaces / tabs from each line
17
+ * - Trim leading & trailing blank lines
18
+ * - Collapse runs of >2 blank lines to a single blank line (optional; disabled by default)
19
+ *
20
+ * NOTE: We do NOT reorder semantic list blocks or collapse internal single blank lines so that
21
+ * meaningful ordering (e.g., link lists) still produces distinct hashes.
22
+ * @param body - Raw instruction body text to normalize
23
+ * @param options - Optional normalization options
24
+ * @param options.collapseMultipleBlankLines - When `true`, runs of more than one blank line are collapsed to a single blank line
25
+ * @returns Canonicalized body string
26
+ */
27
+ function canonicalizeBody(body, options) {
28
+ if (typeof body !== 'string')
29
+ body = String(body || '');
30
+ // Normalize line endings
31
+ const text = body.replace(/\r\n?|\u2028|\u2029/g, '\n');
32
+ // Split & trim right side whitespace
33
+ const lines = text.split('\n').map(l => l.replace(/[ \t]+$/, ''));
34
+ // Trim leading blank lines
35
+ while (lines.length && lines[0].trim() === '')
36
+ lines.shift();
37
+ // Trim trailing blank lines
38
+ while (lines.length && lines[lines.length - 1].trim() === '')
39
+ lines.pop();
40
+ if (options?.collapseMultipleBlankLines) {
41
+ const collapsed = [];
42
+ let blankRun = 0;
43
+ for (const l of lines) {
44
+ if (l.trim() === '') {
45
+ blankRun++;
46
+ if (blankRun > 1)
47
+ continue; // keep only one
48
+ }
49
+ else
50
+ blankRun = 0;
51
+ collapsed.push(l);
52
+ }
53
+ return collapsed.join('\n');
54
+ }
55
+ return lines.join('\n');
56
+ }
57
+ /** Compute stable SHA-256 hash over canonicalized body.
58
+ * @param body - Raw instruction body text
59
+ * @returns Hex-encoded SHA-256 digest of the canonicalized body
60
+ */
61
+ const crypto_1 = __importDefault(require("crypto"));
62
+ function hashBody(body) {
63
+ const canon = canonicalizeBody(body);
64
+ return crypto_1.default.createHash('sha256').update(canon, 'utf8').digest('hex');
65
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Shared category derivation rules for instruction classification.
3
+ * Used by the embeddings dashboard and the groom remapCategories mode.
4
+ * Order matters — first match wins.
5
+ */
6
+ export declare const CATEGORY_RULES: [RegExp, string][];
7
+ export declare function deriveCategory(id: string): string;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ /**
3
+ * Shared category derivation rules for instruction classification.
4
+ * Used by the embeddings dashboard and the groom remapCategories mode.
5
+ * Order matters — first match wins.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.CATEGORY_RULES = void 0;
9
+ exports.deriveCategory = deriveCategory;
10
+ exports.CATEGORY_RULES = [
11
+ [/azure|arm-template|apim|batch|vmss/, 'Azure'],
12
+ [/\bsf[-_]|service-fabric|servicefabric|collectsf|sfrp/, 'Service Fabric'],
13
+ [/\bagent\b|agent[-_]/, 'Agent'],
14
+ [/\bmcp\b|mcp[-_]/, 'MCP'],
15
+ [/powershell|pwsh/, 'PowerShell'],
16
+ [/vscode|vs-code|copilot/, 'VS Code'],
17
+ [/\bai[-_]|\bml[-_]|\bllm\b|openai|gpt\d/, 'AI/ML'],
18
+ [/\bgit[-_]|\brepo[-_]|github/, 'Git/Repo'],
19
+ [/\btest|\bspec[-_]|vitest|playwright/, 'Testing'],
20
+ [/kusto|\bkql\b/, 'Kusto'],
21
+ [/dotnet|csharp/, '.NET'],
22
+ [/mermaid/, 'Mermaid'],
23
+ [/debug|troubleshoot/, 'Debugging'],
24
+ [/docker|container/, 'Containers'],
25
+ [/security|\bauth[-_]|authentication|secret-protection/, 'Security'],
26
+ [/runbook|\bguide\b/, 'Runbooks/Guides'],
27
+ [/\bgov[-_]|governance/, 'Governance'],
28
+ [/\bicm[-_]|incident/, 'Operations'],
29
+ [/onenote|markdown/, 'Documentation'],
30
+ ];
31
+ function deriveCategory(id) {
32
+ for (const [pattern, category] of exports.CATEGORY_RULES) {
33
+ if (pattern.test(id))
34
+ return category;
35
+ }
36
+ return 'Other';
37
+ }
@@ -0,0 +1,42 @@
1
+ import { InstructionEntry, RequirementLevel } from '../models/instruction';
2
+ export interface NormalizedInstruction extends InstructionEntry {
3
+ }
4
+ export declare class ClassificationService {
5
+ /**
6
+ * Normalize an instruction entry by filling governance defaults, deriving scope fields,
7
+ * computing hashes, and canonicalizing text fields.
8
+ * @param entry - Raw instruction entry to normalize
9
+ * @returns A fully normalized {@link NormalizedInstruction} with all governance defaults applied
10
+ */
11
+ normalize(entry: InstructionEntry): NormalizedInstruction;
12
+ /**
13
+ * Validate an instruction entry for required fields and logical consistency.
14
+ * @param entry - Instruction entry to validate
15
+ * @returns Array of human-readable issue strings; empty when the entry is valid
16
+ */
17
+ validate(entry: InstructionEntry): string[];
18
+ /**
19
+ * Compute a numeric risk score for an instruction entry (higher = riskier).
20
+ * Score is derived from priority and requirement level.
21
+ * @param entry - Instruction entry to score
22
+ * @returns Numeric risk score
23
+ */
24
+ computeRisk(entry: InstructionEntry): number;
25
+ private requirementWeight;
26
+ /**
27
+ * Compute a SHA-256 hex digest of the given content string.
28
+ * @param content - UTF-8 string to hash
29
+ * @returns 64-character hex-encoded SHA-256 digest
30
+ */
31
+ computeHash(content: string): string;
32
+ private computePriorityTier;
33
+ private reviewIntervalDays;
34
+ /**
35
+ * Compute the recommended review interval in days for a given priority tier and requirement level.
36
+ * @param tier - Priority tier (`'P1'`–`'P4'`; P1 is highest priority)
37
+ * @param requirement - Requirement level for the instruction
38
+ * @returns Number of days until the next review should occur
39
+ */
40
+ computeReviewIntervalDays(tier: 'P1' | 'P2' | 'P3' | 'P4', requirement: RequirementLevel): number;
41
+ private deriveSummary;
42
+ }