@vorionsys/atsf-core 0.2.3 → 0.3.0

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 (437) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/LICENSE +1 -1
  3. package/README.md +82 -29
  4. package/dist/adapters/base-adapter.d.ts +94 -0
  5. package/dist/adapters/base-adapter.d.ts.map +1 -0
  6. package/dist/adapters/base-adapter.js +233 -0
  7. package/dist/adapters/base-adapter.js.map +1 -0
  8. package/dist/adapters/index.d.ts +9 -0
  9. package/dist/adapters/index.d.ts.map +1 -0
  10. package/dist/adapters/index.js +5 -0
  11. package/dist/adapters/index.js.map +1 -0
  12. package/dist/adapters/types.d.ts +83 -0
  13. package/dist/adapters/types.d.ts.map +1 -0
  14. package/dist/adapters/types.js +4 -0
  15. package/dist/adapters/types.js.map +1 -0
  16. package/dist/adapters/webhook-handler.d.ts +64 -0
  17. package/dist/adapters/webhook-handler.d.ts.map +1 -0
  18. package/dist/adapters/webhook-handler.js +170 -0
  19. package/dist/adapters/webhook-handler.js.map +1 -0
  20. package/dist/api/index.d.ts +1 -1
  21. package/dist/api/index.d.ts.map +1 -1
  22. package/dist/api/index.js +3 -1
  23. package/dist/api/index.js.map +1 -1
  24. package/dist/api/server.d.ts +2 -2
  25. package/dist/api/server.d.ts.map +1 -1
  26. package/dist/api/server.js +149 -184
  27. package/dist/api/server.js.map +1 -1
  28. package/dist/arbitration/index.d.ts +4 -12
  29. package/dist/arbitration/index.d.ts.map +1 -1
  30. package/dist/arbitration/index.js +43 -46
  31. package/dist/arbitration/index.js.map +1 -1
  32. package/dist/arbitration/types.d.ts +10 -10
  33. package/dist/arbitration/types.d.ts.map +1 -1
  34. package/dist/arbitration/types.js +2 -8
  35. package/dist/arbitration/types.js.map +1 -1
  36. package/dist/basis/evaluator.d.ts +1 -6
  37. package/dist/basis/evaluator.d.ts.map +1 -1
  38. package/dist/basis/evaluator.js +56 -56
  39. package/dist/basis/evaluator.js.map +1 -1
  40. package/dist/basis/index.d.ts +3 -3
  41. package/dist/basis/index.d.ts.map +1 -1
  42. package/dist/basis/index.js +5 -3
  43. package/dist/basis/index.js.map +1 -1
  44. package/dist/basis/parser.d.ts +30 -30
  45. package/dist/basis/parser.d.ts.map +1 -1
  46. package/dist/basis/parser.js +27 -32
  47. package/dist/basis/parser.js.map +1 -1
  48. package/dist/basis/types.d.ts +2 -2
  49. package/dist/basis/types.d.ts.map +1 -1
  50. package/dist/basis/types.js +2 -3
  51. package/dist/basis/types.js.map +1 -1
  52. package/dist/chain/index.d.ts +0 -8
  53. package/dist/chain/index.d.ts.map +1 -1
  54. package/dist/chain/index.js +18 -16
  55. package/dist/chain/index.js.map +1 -1
  56. package/dist/cognigate/index.d.ts +1 -9
  57. package/dist/cognigate/index.d.ts.map +1 -1
  58. package/dist/cognigate/index.js +35 -44
  59. package/dist/cognigate/index.js.map +1 -1
  60. package/dist/common/adapters.d.ts +4 -4
  61. package/dist/common/adapters.d.ts.map +1 -1
  62. package/dist/common/adapters.js +54 -70
  63. package/dist/common/adapters.js.map +1 -1
  64. package/dist/common/config.d.ts +69 -68
  65. package/dist/common/config.d.ts.map +1 -1
  66. package/dist/common/config.js +52 -50
  67. package/dist/common/config.js.map +1 -1
  68. package/dist/common/index.d.ts +4 -4
  69. package/dist/common/index.d.ts.map +1 -1
  70. package/dist/common/index.js +6 -4
  71. package/dist/common/index.js.map +1 -1
  72. package/dist/common/logger.d.ts +1 -1
  73. package/dist/common/logger.d.ts.map +1 -1
  74. package/dist/common/logger.js +10 -8
  75. package/dist/common/logger.js.map +1 -1
  76. package/dist/common/types.d.ts +12 -12
  77. package/dist/common/types.d.ts.map +1 -1
  78. package/dist/common/types.js +7 -14
  79. package/dist/common/types.js.map +1 -1
  80. package/dist/containment/index.d.ts +3 -11
  81. package/dist/containment/index.d.ts.map +1 -1
  82. package/dist/containment/index.js +107 -119
  83. package/dist/containment/index.js.map +1 -1
  84. package/dist/containment/types.d.ts +11 -11
  85. package/dist/containment/types.d.ts.map +1 -1
  86. package/dist/containment/types.js +2 -8
  87. package/dist/containment/types.js.map +1 -1
  88. package/dist/contracts/index.d.ts +9 -17
  89. package/dist/contracts/index.d.ts.map +1 -1
  90. package/dist/contracts/index.js +56 -59
  91. package/dist/contracts/index.js.map +1 -1
  92. package/dist/contracts/types.d.ts +12 -12
  93. package/dist/contracts/types.d.ts.map +1 -1
  94. package/dist/contracts/types.js +2 -8
  95. package/dist/contracts/types.js.map +1 -1
  96. package/dist/crewai/callback.d.ts +2 -9
  97. package/dist/crewai/callback.d.ts.map +1 -1
  98. package/dist/crewai/callback.js +29 -27
  99. package/dist/crewai/callback.js.map +1 -1
  100. package/dist/crewai/executor.d.ts +95 -11
  101. package/dist/crewai/executor.d.ts.map +1 -1
  102. package/dist/crewai/executor.js +459 -16
  103. package/dist/crewai/executor.js.map +1 -1
  104. package/dist/crewai/index.d.ts +4 -4
  105. package/dist/crewai/index.d.ts.map +1 -1
  106. package/dist/crewai/index.js +6 -4
  107. package/dist/crewai/index.js.map +1 -1
  108. package/dist/crewai/tools.d.ts +1 -1
  109. package/dist/crewai/tools.d.ts.map +1 -1
  110. package/dist/crewai/tools.js +40 -46
  111. package/dist/crewai/tools.js.map +1 -1
  112. package/dist/crewai/types.d.ts +66 -3
  113. package/dist/crewai/types.d.ts.map +1 -1
  114. package/dist/crewai/types.js +2 -7
  115. package/dist/crewai/types.js.map +1 -1
  116. package/dist/enforce/index.d.ts +226 -19
  117. package/dist/enforce/index.d.ts.map +1 -1
  118. package/dist/enforce/index.js +55 -81
  119. package/dist/enforce/index.js.map +1 -1
  120. package/dist/enforce/trust-aware-enforcement-service.d.ts +8 -23
  121. package/dist/enforce/trust-aware-enforcement-service.d.ts.map +1 -1
  122. package/dist/enforce/trust-aware-enforcement-service.js +109 -125
  123. package/dist/enforce/trust-aware-enforcement-service.js.map +1 -1
  124. package/dist/governance/fluid-workflow.d.ts +8 -16
  125. package/dist/governance/fluid-workflow.d.ts.map +1 -1
  126. package/dist/governance/fluid-workflow.js +88 -114
  127. package/dist/governance/fluid-workflow.js.map +1 -1
  128. package/dist/governance/index.d.ts +7 -15
  129. package/dist/governance/index.d.ts.map +1 -1
  130. package/dist/governance/index.js +76 -81
  131. package/dist/governance/index.js.map +1 -1
  132. package/dist/governance/proof-bridge.d.ts +6 -6
  133. package/dist/governance/proof-bridge.d.ts.map +1 -1
  134. package/dist/governance/proof-bridge.js +6 -16
  135. package/dist/governance/proof-bridge.js.map +1 -1
  136. package/dist/governance/types.d.ts +9 -16
  137. package/dist/governance/types.d.ts.map +1 -1
  138. package/dist/governance/types.js +2 -8
  139. package/dist/governance/types.js.map +1 -1
  140. package/dist/index.d.ts +30 -29
  141. package/dist/index.d.ts.map +1 -1
  142. package/dist/index.js +33 -31
  143. package/dist/index.js.map +1 -1
  144. package/dist/intent/index.d.ts +55 -18
  145. package/dist/intent/index.d.ts.map +1 -1
  146. package/dist/intent/index.js +25 -26
  147. package/dist/intent/index.js.map +1 -1
  148. package/dist/intent/persistent-intent-service.d.ts +2 -17
  149. package/dist/intent/persistent-intent-service.d.ts.map +1 -1
  150. package/dist/intent/persistent-intent-service.js +33 -43
  151. package/dist/intent/persistent-intent-service.js.map +1 -1
  152. package/dist/intent/supabase-intent-repository.d.ts +107 -0
  153. package/dist/intent/supabase-intent-repository.d.ts.map +1 -0
  154. package/dist/intent/supabase-intent-repository.js +406 -0
  155. package/dist/intent/supabase-intent-repository.js.map +1 -0
  156. package/dist/intent-gateway/index.d.ts +5 -28
  157. package/dist/intent-gateway/index.d.ts.map +1 -1
  158. package/dist/intent-gateway/index.js +341 -508
  159. package/dist/intent-gateway/index.js.map +1 -1
  160. package/dist/langchain/callback.d.ts +2 -9
  161. package/dist/langchain/callback.d.ts.map +1 -1
  162. package/dist/langchain/callback.js +32 -30
  163. package/dist/langchain/callback.js.map +1 -1
  164. package/dist/langchain/executor.d.ts +4 -11
  165. package/dist/langchain/executor.d.ts.map +1 -1
  166. package/dist/langchain/executor.js +82 -82
  167. package/dist/langchain/executor.js.map +1 -1
  168. package/dist/langchain/index.d.ts +5 -5
  169. package/dist/langchain/index.d.ts.map +1 -1
  170. package/dist/langchain/index.js +7 -5
  171. package/dist/langchain/index.js.map +1 -1
  172. package/dist/langchain/tools.d.ts +1 -1
  173. package/dist/langchain/tools.d.ts.map +1 -1
  174. package/dist/langchain/tools.js +36 -43
  175. package/dist/langchain/tools.js.map +1 -1
  176. package/dist/langchain/types.d.ts +3 -3
  177. package/dist/langchain/types.d.ts.map +1 -1
  178. package/dist/langchain/types.js +2 -7
  179. package/dist/langchain/types.js.map +1 -1
  180. package/dist/layers/implementations/L0-request-format.d.ts +2 -2
  181. package/dist/layers/implementations/L0-request-format.d.ts.map +1 -1
  182. package/dist/layers/implementations/L0-request-format.js +54 -54
  183. package/dist/layers/implementations/L0-request-format.js.map +1 -1
  184. package/dist/layers/implementations/L1-input-size.d.ts +2 -2
  185. package/dist/layers/implementations/L1-input-size.d.ts.map +1 -1
  186. package/dist/layers/implementations/L1-input-size.js +41 -49
  187. package/dist/layers/implementations/L1-input-size.js.map +1 -1
  188. package/dist/layers/implementations/L2-charset-sanitizer.d.ts +2 -2
  189. package/dist/layers/implementations/L2-charset-sanitizer.d.ts.map +1 -1
  190. package/dist/layers/implementations/L2-charset-sanitizer.js +73 -81
  191. package/dist/layers/implementations/L2-charset-sanitizer.js.map +1 -1
  192. package/dist/layers/implementations/L3-schema-conformance.d.ts +3 -3
  193. package/dist/layers/implementations/L3-schema-conformance.d.ts.map +1 -1
  194. package/dist/layers/implementations/L3-schema-conformance.js +75 -82
  195. package/dist/layers/implementations/L3-schema-conformance.js.map +1 -1
  196. package/dist/layers/implementations/L4-injection-detector.d.ts +4 -4
  197. package/dist/layers/implementations/L4-injection-detector.d.ts.map +1 -1
  198. package/dist/layers/implementations/L4-injection-detector.js +83 -85
  199. package/dist/layers/implementations/L4-injection-detector.js.map +1 -1
  200. package/dist/layers/implementations/L5-rate-limiter.d.ts +2 -2
  201. package/dist/layers/implementations/L5-rate-limiter.d.ts.map +1 -1
  202. package/dist/layers/implementations/L5-rate-limiter.js +22 -20
  203. package/dist/layers/implementations/L5-rate-limiter.js.map +1 -1
  204. package/dist/layers/implementations/index.d.ts +6 -6
  205. package/dist/layers/implementations/index.d.ts.map +1 -1
  206. package/dist/layers/implementations/index.js +8 -6
  207. package/dist/layers/implementations/index.js.map +1 -1
  208. package/dist/layers/index.d.ts +3 -11
  209. package/dist/layers/index.d.ts.map +1 -1
  210. package/dist/layers/index.js +73 -99
  211. package/dist/layers/index.js.map +1 -1
  212. package/dist/layers/types.d.ts +16 -16
  213. package/dist/layers/types.d.ts.map +1 -1
  214. package/dist/layers/types.js +2 -8
  215. package/dist/layers/types.js.map +1 -1
  216. package/dist/paramesphere/activation-collector.d.ts +128 -0
  217. package/dist/paramesphere/activation-collector.d.ts.map +1 -0
  218. package/dist/paramesphere/activation-collector.js +260 -0
  219. package/dist/paramesphere/activation-collector.js.map +1 -0
  220. package/dist/paramesphere/cognitive-envelope.d.ts +73 -0
  221. package/dist/paramesphere/cognitive-envelope.d.ts.map +1 -0
  222. package/dist/paramesphere/cognitive-envelope.js +209 -0
  223. package/dist/paramesphere/cognitive-envelope.js.map +1 -0
  224. package/dist/paramesphere/envelope-integration.d.ts +60 -0
  225. package/dist/paramesphere/envelope-integration.d.ts.map +1 -0
  226. package/dist/paramesphere/envelope-integration.js +93 -0
  227. package/dist/paramesphere/envelope-integration.js.map +1 -0
  228. package/dist/paramesphere/fingerprint-monitor.d.ts +136 -0
  229. package/dist/paramesphere/fingerprint-monitor.d.ts.map +1 -0
  230. package/dist/paramesphere/fingerprint-monitor.js +212 -0
  231. package/dist/paramesphere/fingerprint-monitor.js.map +1 -0
  232. package/dist/paramesphere/fingerprint-store.d.ts +85 -0
  233. package/dist/paramesphere/fingerprint-store.d.ts.map +1 -0
  234. package/dist/paramesphere/fingerprint-store.js +68 -0
  235. package/dist/paramesphere/fingerprint-store.js.map +1 -0
  236. package/dist/paramesphere/index.d.ts +21 -0
  237. package/dist/paramesphere/index.d.ts.map +1 -0
  238. package/dist/paramesphere/index.js +18 -0
  239. package/dist/paramesphere/index.js.map +1 -0
  240. package/dist/paramesphere/monitor-integration.d.ts +37 -0
  241. package/dist/paramesphere/monitor-integration.d.ts.map +1 -0
  242. package/dist/paramesphere/monitor-integration.js +81 -0
  243. package/dist/paramesphere/monitor-integration.js.map +1 -0
  244. package/dist/paramesphere/paramesphere-engine.d.ts +111 -0
  245. package/dist/paramesphere/paramesphere-engine.d.ts.map +1 -0
  246. package/dist/paramesphere/paramesphere-engine.js +542 -0
  247. package/dist/paramesphere/paramesphere-engine.js.map +1 -0
  248. package/dist/paramesphere/types.d.ts +142 -0
  249. package/dist/paramesphere/types.d.ts.map +1 -0
  250. package/dist/paramesphere/types.js +4 -0
  251. package/dist/paramesphere/types.js.map +1 -0
  252. package/dist/persistence/file.d.ts +3 -10
  253. package/dist/persistence/file.d.ts.map +1 -1
  254. package/dist/persistence/file.js +30 -32
  255. package/dist/persistence/file.js.map +1 -1
  256. package/dist/persistence/index.d.ts +7 -7
  257. package/dist/persistence/index.d.ts.map +1 -1
  258. package/dist/persistence/index.js +20 -18
  259. package/dist/persistence/index.js.map +1 -1
  260. package/dist/persistence/memory.d.ts +3 -3
  261. package/dist/persistence/memory.d.ts.map +1 -1
  262. package/dist/persistence/memory.js +10 -17
  263. package/dist/persistence/memory.js.map +1 -1
  264. package/dist/persistence/sqlite.d.ts +3 -11
  265. package/dist/persistence/sqlite.d.ts.map +1 -1
  266. package/dist/persistence/sqlite.js +42 -39
  267. package/dist/persistence/sqlite.js.map +1 -1
  268. package/dist/persistence/supabase.d.ts +3 -3
  269. package/dist/persistence/supabase.d.ts.map +1 -1
  270. package/dist/persistence/supabase.js +46 -49
  271. package/dist/persistence/supabase.js.map +1 -1
  272. package/dist/persistence/types.d.ts +5 -5
  273. package/dist/persistence/types.d.ts.map +1 -1
  274. package/dist/persistence/types.js +2 -7
  275. package/dist/persistence/types.js.map +1 -1
  276. package/dist/phase6/ceiling.d.ts +5 -21
  277. package/dist/phase6/ceiling.d.ts.map +1 -1
  278. package/dist/phase6/ceiling.js +38 -69
  279. package/dist/phase6/ceiling.js.map +1 -1
  280. package/dist/phase6/context.d.ts +3 -20
  281. package/dist/phase6/context.d.ts.map +1 -1
  282. package/dist/phase6/context.js +49 -93
  283. package/dist/phase6/context.js.map +1 -1
  284. package/dist/phase6/index.d.ts +12 -12
  285. package/dist/phase6/index.d.ts.map +1 -1
  286. package/dist/phase6/index.js +17 -15
  287. package/dist/phase6/index.js.map +1 -1
  288. package/dist/phase6/presets.d.ts +2 -18
  289. package/dist/phase6/presets.d.ts.map +1 -1
  290. package/dist/phase6/presets.js +35 -39
  291. package/dist/phase6/presets.js.map +1 -1
  292. package/dist/phase6/provenance.d.ts +4 -19
  293. package/dist/phase6/provenance.d.ts.map +1 -1
  294. package/dist/phase6/provenance.js +37 -42
  295. package/dist/phase6/provenance.js.map +1 -1
  296. package/dist/phase6/role-gates/index.d.ts +2 -2
  297. package/dist/phase6/role-gates/index.d.ts.map +1 -1
  298. package/dist/phase6/role-gates/index.js +4 -2
  299. package/dist/phase6/role-gates/index.js.map +1 -1
  300. package/dist/phase6/role-gates/kernel.d.ts.map +1 -1
  301. package/dist/phase6/role-gates/kernel.js +18 -16
  302. package/dist/phase6/role-gates/kernel.js.map +1 -1
  303. package/dist/phase6/role-gates/policy.d.ts +2 -2
  304. package/dist/phase6/role-gates/policy.d.ts.map +1 -1
  305. package/dist/phase6/role-gates/policy.js +8 -17
  306. package/dist/phase6/role-gates/policy.js.map +1 -1
  307. package/dist/phase6/role-gates.d.ts +4 -20
  308. package/dist/phase6/role-gates.d.ts.map +1 -1
  309. package/dist/phase6/role-gates.js +60 -80
  310. package/dist/phase6/role-gates.js.map +1 -1
  311. package/dist/phase6/types.d.ts +53 -23
  312. package/dist/phase6/types.d.ts.map +1 -1
  313. package/dist/phase6/types.js +131 -177
  314. package/dist/phase6/types.js.map +1 -1
  315. package/dist/phase6/weight-presets/canonical.d.ts.map +1 -1
  316. package/dist/phase6/weight-presets/canonical.js +12 -10
  317. package/dist/phase6/weight-presets/canonical.js.map +1 -1
  318. package/dist/phase6/weight-presets/deltas.d.ts +2 -2
  319. package/dist/phase6/weight-presets/deltas.d.ts.map +1 -1
  320. package/dist/phase6/weight-presets/deltas.js +29 -37
  321. package/dist/phase6/weight-presets/deltas.js.map +1 -1
  322. package/dist/phase6/weight-presets/index.d.ts +3 -3
  323. package/dist/phase6/weight-presets/index.d.ts.map +1 -1
  324. package/dist/phase6/weight-presets/index.js +5 -3
  325. package/dist/phase6/weight-presets/index.js.map +1 -1
  326. package/dist/phase6/weight-presets/merger.d.ts +2 -12
  327. package/dist/phase6/weight-presets/merger.d.ts.map +1 -1
  328. package/dist/phase6/weight-presets/merger.js +45 -39
  329. package/dist/phase6/weight-presets/merger.js.map +1 -1
  330. package/dist/proof/index.d.ts +6 -13
  331. package/dist/proof/index.d.ts.map +1 -1
  332. package/dist/proof/index.js +63 -51
  333. package/dist/proof/index.js.map +1 -1
  334. package/dist/proof/merkle.d.ts +24 -19
  335. package/dist/proof/merkle.d.ts.map +1 -1
  336. package/dist/proof/merkle.js +118 -32
  337. package/dist/proof/merkle.js.map +1 -1
  338. package/dist/proof/zk-proofs.d.ts +6 -24
  339. package/dist/proof/zk-proofs.d.ts.map +1 -1
  340. package/dist/proof/zk-proofs.js +45 -42
  341. package/dist/proof/zk-proofs.js.map +1 -1
  342. package/dist/provenance/index.d.ts +3 -11
  343. package/dist/provenance/index.d.ts.map +1 -1
  344. package/dist/provenance/index.js +19 -19
  345. package/dist/provenance/index.js.map +1 -1
  346. package/dist/provenance/types.d.ts +4 -4
  347. package/dist/provenance/types.d.ts.map +1 -1
  348. package/dist/provenance/types.js +2 -8
  349. package/dist/provenance/types.js.map +1 -1
  350. package/dist/sandbox-training/challenges.d.ts +1 -1
  351. package/dist/sandbox-training/challenges.d.ts.map +1 -1
  352. package/dist/sandbox-training/challenges.js +230 -236
  353. package/dist/sandbox-training/challenges.js.map +1 -1
  354. package/dist/sandbox-training/graduation.d.ts +1 -1
  355. package/dist/sandbox-training/graduation.d.ts.map +1 -1
  356. package/dist/sandbox-training/graduation.js +17 -22
  357. package/dist/sandbox-training/graduation.js.map +1 -1
  358. package/dist/sandbox-training/index.d.ts +9 -9
  359. package/dist/sandbox-training/index.d.ts.map +1 -1
  360. package/dist/sandbox-training/index.js +8 -6
  361. package/dist/sandbox-training/index.js.map +1 -1
  362. package/dist/sandbox-training/promotion-service.d.ts +4 -4
  363. package/dist/sandbox-training/promotion-service.d.ts.map +1 -1
  364. package/dist/sandbox-training/promotion-service.js +7 -16
  365. package/dist/sandbox-training/promotion-service.js.map +1 -1
  366. package/dist/sandbox-training/runner.d.ts +1 -1
  367. package/dist/sandbox-training/runner.d.ts.map +1 -1
  368. package/dist/sandbox-training/runner.js +75 -82
  369. package/dist/sandbox-training/runner.js.map +1 -1
  370. package/dist/sandbox-training/scorer.d.ts +4 -4
  371. package/dist/sandbox-training/scorer.d.ts.map +1 -1
  372. package/dist/sandbox-training/scorer.js +7 -13
  373. package/dist/sandbox-training/scorer.js.map +1 -1
  374. package/dist/sandbox-training/types.d.ts +4 -4
  375. package/dist/sandbox-training/types.d.ts.map +1 -1
  376. package/dist/sandbox-training/types.js +9 -19
  377. package/dist/sandbox-training/types.js.map +1 -1
  378. package/dist/trust-engine/ceiling-enforcement/audit.d.ts +1 -9
  379. package/dist/trust-engine/ceiling-enforcement/audit.d.ts.map +1 -1
  380. package/dist/trust-engine/ceiling-enforcement/audit.js +6 -11
  381. package/dist/trust-engine/ceiling-enforcement/audit.js.map +1 -1
  382. package/dist/trust-engine/ceiling-enforcement/index.d.ts +2 -2
  383. package/dist/trust-engine/ceiling-enforcement/index.d.ts.map +1 -1
  384. package/dist/trust-engine/ceiling-enforcement/index.js +4 -2
  385. package/dist/trust-engine/ceiling-enforcement/index.js.map +1 -1
  386. package/dist/trust-engine/ceiling-enforcement/kernel.d.ts +12 -10
  387. package/dist/trust-engine/ceiling-enforcement/kernel.d.ts.map +1 -1
  388. package/dist/trust-engine/ceiling-enforcement/kernel.js +28 -20
  389. package/dist/trust-engine/ceiling-enforcement/kernel.js.map +1 -1
  390. package/dist/trust-engine/context-policy/enforcement.d.ts +0 -9
  391. package/dist/trust-engine/context-policy/enforcement.d.ts.map +1 -1
  392. package/dist/trust-engine/context-policy/enforcement.js +2 -9
  393. package/dist/trust-engine/context-policy/enforcement.js.map +1 -1
  394. package/dist/trust-engine/context-policy/factory.d.ts +1 -1
  395. package/dist/trust-engine/context-policy/factory.d.ts.map +1 -1
  396. package/dist/trust-engine/context-policy/factory.js +3 -1
  397. package/dist/trust-engine/context-policy/factory.js.map +1 -1
  398. package/dist/trust-engine/context-policy/index.d.ts +2 -2
  399. package/dist/trust-engine/context-policy/index.d.ts.map +1 -1
  400. package/dist/trust-engine/context-policy/index.js +4 -2
  401. package/dist/trust-engine/context-policy/index.js.map +1 -1
  402. package/dist/trust-engine/creation-modifiers/index.d.ts +1 -1
  403. package/dist/trust-engine/creation-modifiers/index.d.ts.map +1 -1
  404. package/dist/trust-engine/creation-modifiers/index.js +3 -1
  405. package/dist/trust-engine/creation-modifiers/index.js.map +1 -1
  406. package/dist/trust-engine/creation-modifiers/types.d.ts.map +1 -1
  407. package/dist/trust-engine/creation-modifiers/types.js +5 -2
  408. package/dist/trust-engine/creation-modifiers/types.js.map +1 -1
  409. package/dist/trust-engine/decay-profiles.d.ts +37 -136
  410. package/dist/trust-engine/decay-profiles.d.ts.map +1 -1
  411. package/dist/trust-engine/decay-profiles.js +61 -183
  412. package/dist/trust-engine/decay-profiles.js.map +1 -1
  413. package/dist/trust-engine/index.d.ts +327 -22
  414. package/dist/trust-engine/index.d.ts.map +1 -1
  415. package/dist/trust-engine/index.js +706 -130
  416. package/dist/trust-engine/index.js.map +1 -1
  417. package/dist/trust-engine/phase6-types.d.ts +15 -18
  418. package/dist/trust-engine/phase6-types.d.ts.map +1 -1
  419. package/dist/trust-engine/phase6-types.js +32 -36
  420. package/dist/trust-engine/phase6-types.js.map +1 -1
  421. package/dist/trust-engine/trust-verifier.d.ts +121 -0
  422. package/dist/trust-engine/trust-verifier.d.ts.map +1 -0
  423. package/dist/trust-engine/trust-verifier.js +226 -0
  424. package/dist/trust-engine/trust-verifier.js.map +1 -0
  425. package/package.json +140 -135
  426. package/dist/enforce/types.d.ts +0 -234
  427. package/dist/enforce/types.d.ts.map +0 -1
  428. package/dist/enforce/types.js +0 -10
  429. package/dist/enforce/types.js.map +0 -1
  430. package/dist/intent/types.d.ts +0 -69
  431. package/dist/intent/types.d.ts.map +0 -1
  432. package/dist/intent/types.js +0 -10
  433. package/dist/intent/types.js.map +0 -1
  434. package/dist/trust-engine/types.d.ts +0 -77
  435. package/dist/trust-engine/types.d.ts.map +0 -1
  436. package/dist/trust-engine/types.js +0 -20
  437. package/dist/trust-engine/types.js.map +0 -1
@@ -1,159 +1,60 @@
1
1
  /**
2
- * Context-Aware Trust Decay Profiles
2
+ * Stepped Milestone Trust Decay
3
3
  *
4
- * Implements half-life based exponential decay with:
5
- * - Environment-aware profiles (volatile, standard, stable)
6
- * - Failure acceleration multipliers
7
- * - Entity-specific profile overrides
4
+ * Implements a simple stepped decay system where trust scores decay
5
+ * based on fixed milestones tied to days of inactivity. Interpolation
6
+ * between milestones provides smooth decay curves.
8
7
  *
9
- * @packageDocumentation
10
- */
11
- /**
12
- * Profile type names
13
- */
14
- export type EnvironmentProfileType = "volatile" | "standard" | "stable";
15
- /**
16
- * Environment profile configuration
8
+ * 9 milestones (not counting day 0):
9
+ * - Steps 1-5 drop 6% each (days 7, 14, 28, 42, 56)
10
+ * - Steps 6-9 drop 5% each (days 84, 112, 140, 182)
11
+ * - At 182 days = 50% of original score
17
12
  *
18
- * Defines decay characteristics for different operational contexts.
19
- */
20
- export interface EnvironmentProfile {
21
- /** Profile type identifier */
22
- type: EnvironmentProfileType;
23
- /** Base half-life in days (time for score to decay to 50%) */
24
- baseHalfLifeDays: number;
25
- /** Multiplier applied per failure (exponential: multiplier^failureCount) */
26
- failureMultiplier: number;
27
- }
28
- /**
29
- * Detailed result from decay calculation
30
- */
31
- export interface DecayCalculationResult {
32
- /** Final decayed score */
33
- decayedScore: number;
34
- /** Base decay factor before failure acceleration (0-1) */
35
- baseDecayFactor: number;
36
- /** Effective decay factor after failure acceleration */
37
- effectiveDecayFactor: number;
38
- /** Failure acceleration divisor (failureMultiplier^failureCount) */
39
- failureAcceleration: number;
40
- /** Name of profile used for calculation */
41
- profileUsed: EnvironmentProfileType;
42
- }
43
- /**
44
- * Configuration for decay profile resolution
13
+ * @packageDocumentation
45
14
  */
46
- export interface DecayConfig {
47
- /** Enable automatic classification based on activity rate */
48
- autoClassification: boolean;
49
- /** Manual profile overrides by entity ID */
50
- overrideByAgentId: Map<string, EnvironmentProfile>;
51
- }
52
15
  /**
53
- * Options for creating a DecayConfig
16
+ * A single decay milestone mapping days of inactivity to a multiplier
54
17
  */
55
- export interface DecayConfigOptions {
56
- autoClassification?: boolean;
57
- overrideByAgentId?: Map<string, EnvironmentProfile>;
18
+ export interface DecayMilestone {
19
+ /** Days since last activity */
20
+ days: number;
21
+ /** Score multiplier at this milestone (0.0 to 1.0) */
22
+ multiplier: number;
58
23
  }
59
24
  /**
60
- * Default decay profiles for different environment types
61
- *
62
- * - **Volatile**: High-frequency trading, real-time systems
63
- * - 30-day half-life (fast decay for frequently-used agents)
64
- * - 4x failure multiplier (harsh penalties for failures)
25
+ * Fixed decay milestones for inactivity-based trust decay
65
26
  *
66
- * - **Standard**: General-purpose agents, typical workloads
67
- * - 182-day half-life (~6 months)
68
- * - 3x failure multiplier (moderate penalties)
69
- *
70
- * - **Stable**: Audit systems, compliance agents, infrequent operations
71
- * - 365-day half-life (slow decay for long-running agents)
72
- * - 2x failure multiplier (lenient penalties)
27
+ * Steps 1-5 drop 6% each. Steps 6-9 drop 5% each.
28
+ * At 182 days of inactivity, score is 50% of original.
73
29
  */
74
- export declare const DEFAULT_DECAY_PROFILES: {
75
- readonly profiles: {
76
- readonly volatile: {
77
- readonly type: "volatile";
78
- readonly baseHalfLifeDays: 30;
79
- readonly failureMultiplier: 4;
80
- };
81
- readonly standard: {
82
- readonly type: "standard";
83
- readonly baseHalfLifeDays: 182;
84
- readonly failureMultiplier: 3;
85
- };
86
- readonly stable: {
87
- readonly type: "stable";
88
- readonly baseHalfLifeDays: 365;
89
- readonly failureMultiplier: 2;
90
- };
91
- };
92
- };
30
+ export declare const DECAY_MILESTONES: DecayMilestone[];
93
31
  /**
94
- * Calculate context-aware trust decay
32
+ * Calculate the decay multiplier for a given number of days since last activity
95
33
  *
96
- * Uses exponential decay formula with half-life:
97
- * `score * (0.5 ^ (days / halfLife)) / (failureMultiplier ^ failureCount)`
34
+ * Finds the two surrounding milestones and linearly interpolates between them
35
+ * for a smooth decay curve. Returns the floor multiplier (0.50) for days
36
+ * beyond the last milestone.
98
37
  *
99
- * @param initialScore - Starting trust score (0-1000)
100
- * @param daysSinceLastAction - Days since last trust-relevant action
101
- * @param profile - Environment profile to use for decay calculation
102
- * @param failureCount - Number of recent failures (0 for no failures)
103
- * @returns Decayed trust score, floored at 0
38
+ * @param daysSinceLastActivity - Days since the entity's last trust-relevant action
39
+ * @returns Decay multiplier between 0.50 and 1.00
104
40
  */
105
- export declare function calculateContextAwareDecay(initialScore: number, daysSinceLastAction: number, profile: EnvironmentProfile, failureCount: number): number;
41
+ export declare function calculateDecayMultiplier(daysSinceLastActivity: number): number;
106
42
  /**
107
- * Calculate context-aware decay with detailed breakdown
108
- *
109
- * Returns full calculation details for debugging, logging, and analysis.
43
+ * Apply decay to a base trust score based on days of inactivity
110
44
  *
111
- * @param initialScore - Starting trust score (0-1000)
112
- * @param daysSinceLastAction - Days since last trust-relevant action
113
- * @param profile - Environment profile to use
114
- * @param failureCount - Number of recent failures
115
- * @returns Detailed calculation result
45
+ * @param baseScore - The entity's base trust score (0-1000)
46
+ * @param daysSinceLastActivity - Days since the entity's last trust-relevant action
47
+ * @returns Decayed score as a rounded integer, minimum 0
116
48
  */
117
- export declare function calculateContextAwareDecayWithDetails(initialScore: number, daysSinceLastAction: number, profile: EnvironmentProfile, failureCount: number): DecayCalculationResult;
49
+ export declare function applyDecay(baseScore: number, daysSinceLastActivity: number): number;
118
50
  /**
119
- * Calculate days until score decays to target value
120
- *
121
- * Inverse of the decay formula to predict when a threshold will be reached.
122
- *
123
- * @param currentScore - Current trust score
124
- * @param targetScore - Target score to calculate time for
125
- * @param profile - Environment profile
126
- * @param failureCount - Number of recent failures
127
- * @returns Days until target is reached, or Infinity if unreachable
128
- */
129
- export declare function calculateDaysUntilDecay(currentScore: number, targetScore: number, profile: EnvironmentProfile, failureCount: number): number;
130
- /**
131
- * Classify environment profile based on activity rate
132
- *
133
- * Automatically determines the appropriate decay profile based on
134
- * how frequently an agent performs trust-relevant actions.
51
+ * Get the next decay milestone that the entity will hit
135
52
  *
136
- * @param actionsPerDay - Average number of actions per day
137
- * @returns Appropriate environment profile
138
- */
139
- export declare function classifyEnvironmentProfile(actionsPerDay: number): EnvironmentProfile;
140
- /**
141
- * Get the appropriate profile for a specific entity
142
- *
143
- * Checks for manual overrides first, then falls back to
144
- * auto-classification or default profile.
145
- *
146
- * @param entityId - Entity identifier
147
- * @param actionsPerDay - Activity rate for auto-classification
148
- * @param config - Decay configuration with overrides
149
- * @returns Environment profile for the entity
150
- */
151
- export declare function getProfileForEntity(entityId: string, actionsPerDay: number, config: DecayConfig): EnvironmentProfile;
152
- /**
153
- * Create a decay configuration with defaults
53
+ * Returns the next milestone after the entity's current inactivity period,
54
+ * or null if the entity has already passed the final milestone.
154
55
  *
155
- * @param options - Configuration options
156
- * @returns Complete decay configuration
56
+ * @param daysSinceLastActivity - Days since the entity's last trust-relevant action
57
+ * @returns The next DecayMilestone, or null if past the final milestone
157
58
  */
158
- export declare function createDecayConfig(options?: DecayConfigOptions): DecayConfig;
59
+ export declare function getNextDecayMilestone(daysSinceLastActivity: number): DecayMilestone | null;
159
60
  //# sourceMappingURL=decay-profiles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decay-profiles.d.ts","sourceRoot":"","sources":["../../src/trust-engine/decay-profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAC;AAExE;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,8BAA8B;IAC9B,IAAI,EAAE,sBAAsB,CAAC;IAE7B,8DAA8D;IAC9D,gBAAgB,EAAE,MAAM,CAAC;IAEzB,4EAA4E;IAC5E,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,0BAA0B;IAC1B,YAAY,EAAE,MAAM,CAAC;IAErB,0DAA0D;IAC1D,eAAe,EAAE,MAAM,CAAC;IAExB,wDAAwD;IACxD,oBAAoB,EAAE,MAAM,CAAC;IAE7B,oEAAoE;IACpE,mBAAmB,EAAE,MAAM,CAAC;IAE5B,2CAA2C;IAC3C,WAAW,EAAE,sBAAsB,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,6DAA6D;IAC7D,kBAAkB,EAAE,OAAO,CAAC;IAE5B,4CAA4C;IAC5C,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;CACrD;AAMD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;CAkBzB,CAAC;AAMX;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,MAAM,EACpB,mBAAmB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AGnF;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,qBAAqB,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAO1F"}
@@ -1,210 +1,88 @@
1
- /**
2
- * Context-Aware Trust Decay Profiles
3
- *
4
- * Implements half-life based exponential decay with:
5
- * - Environment-aware profiles (volatile, standard, stable)
6
- * - Failure acceleration multipliers
7
- * - Entity-specific profile overrides
8
- *
9
- * @packageDocumentation
10
- */
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright 2024-2026 Vorion LLC
11
3
  // ============================================================================
12
- // Default Profiles
4
+ // Milestones
13
5
  // ============================================================================
14
6
  /**
15
- * Default decay profiles for different environment types
7
+ * Fixed decay milestones for inactivity-based trust decay
16
8
  *
17
- * - **Volatile**: High-frequency trading, real-time systems
18
- * - 30-day half-life (fast decay for frequently-used agents)
19
- * - 4x failure multiplier (harsh penalties for failures)
20
- *
21
- * - **Standard**: General-purpose agents, typical workloads
22
- * - 182-day half-life (~6 months)
23
- * - 3x failure multiplier (moderate penalties)
24
- *
25
- * - **Stable**: Audit systems, compliance agents, infrequent operations
26
- * - 365-day half-life (slow decay for long-running agents)
27
- * - 2x failure multiplier (lenient penalties)
9
+ * Steps 1-5 drop 6% each. Steps 6-9 drop 5% each.
10
+ * At 182 days of inactivity, score is 50% of original.
28
11
  */
29
- export const DEFAULT_DECAY_PROFILES = {
30
- profiles: {
31
- volatile: {
32
- type: "volatile",
33
- baseHalfLifeDays: 30,
34
- failureMultiplier: 4.0,
35
- },
36
- standard: {
37
- type: "standard",
38
- baseHalfLifeDays: 182,
39
- failureMultiplier: 3.0,
40
- },
41
- stable: {
42
- type: "stable",
43
- baseHalfLifeDays: 365,
44
- failureMultiplier: 2.0,
45
- },
46
- },
47
- };
12
+ export const DECAY_MILESTONES = [
13
+ { days: 0, multiplier: 1.00 },
14
+ { days: 7, multiplier: 0.94 },
15
+ { days: 14, multiplier: 0.88 },
16
+ { days: 28, multiplier: 0.82 },
17
+ { days: 42, multiplier: 0.76 },
18
+ { days: 56, multiplier: 0.70 },
19
+ { days: 84, multiplier: 0.65 },
20
+ { days: 112, multiplier: 0.60 },
21
+ { days: 140, multiplier: 0.55 },
22
+ { days: 182, multiplier: 0.50 },
23
+ ];
48
24
  // ============================================================================
49
25
  // Core Decay Functions
50
26
  // ============================================================================
51
27
  /**
52
- * Calculate context-aware trust decay
53
- *
54
- * Uses exponential decay formula with half-life:
55
- * `score * (0.5 ^ (days / halfLife)) / (failureMultiplier ^ failureCount)`
56
- *
57
- * @param initialScore - Starting trust score (0-1000)
58
- * @param daysSinceLastAction - Days since last trust-relevant action
59
- * @param profile - Environment profile to use for decay calculation
60
- * @param failureCount - Number of recent failures (0 for no failures)
61
- * @returns Decayed trust score, floored at 0
62
- */
63
- export function calculateContextAwareDecay(initialScore, daysSinceLastAction, profile, failureCount) {
64
- // Calculate base decay factor using half-life formula
65
- // At half-life days, this equals 0.5 (50% remaining)
66
- const baseDecayFactor = Math.pow(0.5, daysSinceLastAction / profile.baseHalfLifeDays);
67
- // Calculate failure acceleration (exponential penalty)
68
- // Treat negative failure counts as 0
69
- const effectiveFailures = Math.max(0, failureCount);
70
- const failureAcceleration = Math.pow(profile.failureMultiplier, effectiveFailures);
71
- // Apply decay: score * baseFactor / failureAcceleration
72
- const decayedScore = (initialScore * baseDecayFactor) / failureAcceleration;
73
- // Floor at 0
74
- return Math.max(0, decayedScore);
75
- }
76
- /**
77
- * Calculate context-aware decay with detailed breakdown
78
- *
79
- * Returns full calculation details for debugging, logging, and analysis.
80
- *
81
- * @param initialScore - Starting trust score (0-1000)
82
- * @param daysSinceLastAction - Days since last trust-relevant action
83
- * @param profile - Environment profile to use
84
- * @param failureCount - Number of recent failures
85
- * @returns Detailed calculation result
86
- */
87
- export function calculateContextAwareDecayWithDetails(initialScore, daysSinceLastAction, profile, failureCount) {
88
- // Calculate base decay factor
89
- const baseDecayFactor = Math.pow(0.5, daysSinceLastAction / profile.baseHalfLifeDays);
90
- // Calculate failure acceleration
91
- const effectiveFailures = Math.max(0, failureCount);
92
- const failureAcceleration = Math.pow(profile.failureMultiplier, effectiveFailures);
93
- // Calculate effective decay factor (after failure penalty)
94
- const effectiveDecayFactor = baseDecayFactor / failureAcceleration;
95
- // Calculate final score
96
- const decayedScore = Math.max(0, initialScore * effectiveDecayFactor);
97
- return {
98
- decayedScore,
99
- baseDecayFactor,
100
- effectiveDecayFactor,
101
- failureAcceleration,
102
- profileUsed: profile.type,
103
- };
104
- }
105
- /**
106
- * Calculate days until score decays to target value
28
+ * Calculate the decay multiplier for a given number of days since last activity
107
29
  *
108
- * Inverse of the decay formula to predict when a threshold will be reached.
30
+ * Finds the two surrounding milestones and linearly interpolates between them
31
+ * for a smooth decay curve. Returns the floor multiplier (0.50) for days
32
+ * beyond the last milestone.
109
33
  *
110
- * @param currentScore - Current trust score
111
- * @param targetScore - Target score to calculate time for
112
- * @param profile - Environment profile
113
- * @param failureCount - Number of recent failures
114
- * @returns Days until target is reached, or Infinity if unreachable
34
+ * @param daysSinceLastActivity - Days since the entity's last trust-relevant action
35
+ * @returns Decay multiplier between 0.50 and 1.00
115
36
  */
116
- export function calculateDaysUntilDecay(currentScore, targetScore, profile, failureCount) {
117
- // If already at or below target, return Infinity (already there)
118
- if (currentScore <= targetScore) {
119
- return Infinity;
37
+ export function calculateDecayMultiplier(daysSinceLastActivity) {
38
+ // Negative or zero days = no decay
39
+ if (daysSinceLastActivity <= 0) {
40
+ return 1.0;
120
41
  }
121
- // If target is zero or negative, return Infinity (asymptotic)
122
- if (targetScore <= 0) {
123
- return Infinity;
42
+ // Beyond the last milestone = floor multiplier
43
+ const lastMilestone = DECAY_MILESTONES[DECAY_MILESTONES.length - 1];
44
+ if (daysSinceLastActivity >= lastMilestone.days) {
45
+ return lastMilestone.multiplier;
124
46
  }
125
- // Calculate failure acceleration
126
- const effectiveFailures = Math.max(0, failureCount);
127
- const failureAcceleration = Math.pow(profile.failureMultiplier, effectiveFailures);
128
- // Adjust current score for failure acceleration
129
- const effectiveCurrentScore = currentScore / failureAcceleration;
130
- // If effective current is already at or below target, return 0
131
- if (effectiveCurrentScore <= targetScore) {
132
- return 0;
47
+ // Find the two surrounding milestones and interpolate
48
+ for (let i = 0; i < DECAY_MILESTONES.length - 1; i++) {
49
+ const current = DECAY_MILESTONES[i];
50
+ const next = DECAY_MILESTONES[i + 1];
51
+ if (daysSinceLastActivity >= current.days && daysSinceLastActivity < next.days) {
52
+ // Linear interpolation between milestones
53
+ const progress = (daysSinceLastActivity - current.days) / (next.days - current.days);
54
+ return current.multiplier + progress * (next.multiplier - current.multiplier);
55
+ }
133
56
  }
134
- // Solve for days: target = current * (0.5 ^ (days / halfLife))
135
- // target / current = 0.5 ^ (days / halfLife)
136
- // log(target / current) = (days / halfLife) * log(0.5)
137
- // days = halfLife * log(target / current) / log(0.5)
138
- const ratio = targetScore / effectiveCurrentScore;
139
- const days = (profile.baseHalfLifeDays * Math.log(ratio)) / Math.log(0.5);
140
- return Math.max(0, days);
57
+ // Fallback (should not be reached)
58
+ return lastMilestone.multiplier;
141
59
  }
142
- // ============================================================================
143
- // Profile Classification
144
- // ============================================================================
145
- /**
146
- * Activity rate thresholds for profile classification
147
- */
148
- const ACTIVITY_THRESHOLDS = {
149
- volatile: 100, // >= 100 actions/day = volatile
150
- standard: 10, // >= 10 actions/day = standard
151
- // < 10 actions/day = stable
152
- };
153
60
  /**
154
- * Classify environment profile based on activity rate
155
- *
156
- * Automatically determines the appropriate decay profile based on
157
- * how frequently an agent performs trust-relevant actions.
61
+ * Apply decay to a base trust score based on days of inactivity
158
62
  *
159
- * @param actionsPerDay - Average number of actions per day
160
- * @returns Appropriate environment profile
63
+ * @param baseScore - The entity's base trust score (0-1000)
64
+ * @param daysSinceLastActivity - Days since the entity's last trust-relevant action
65
+ * @returns Decayed score as a rounded integer, minimum 0
161
66
  */
162
- export function classifyEnvironmentProfile(actionsPerDay) {
163
- if (actionsPerDay >= ACTIVITY_THRESHOLDS.volatile) {
164
- return DEFAULT_DECAY_PROFILES.profiles.volatile;
165
- }
166
- if (actionsPerDay >= ACTIVITY_THRESHOLDS.standard) {
167
- return DEFAULT_DECAY_PROFILES.profiles.standard;
168
- }
169
- return DEFAULT_DECAY_PROFILES.profiles.stable;
67
+ export function applyDecay(baseScore, daysSinceLastActivity) {
68
+ const multiplier = calculateDecayMultiplier(daysSinceLastActivity);
69
+ return Math.max(0, Math.round(baseScore * multiplier));
170
70
  }
171
71
  /**
172
- * Get the appropriate profile for a specific entity
72
+ * Get the next decay milestone that the entity will hit
173
73
  *
174
- * Checks for manual overrides first, then falls back to
175
- * auto-classification or default profile.
74
+ * Returns the next milestone after the entity's current inactivity period,
75
+ * or null if the entity has already passed the final milestone.
176
76
  *
177
- * @param entityId - Entity identifier
178
- * @param actionsPerDay - Activity rate for auto-classification
179
- * @param config - Decay configuration with overrides
180
- * @returns Environment profile for the entity
77
+ * @param daysSinceLastActivity - Days since the entity's last trust-relevant action
78
+ * @returns The next DecayMilestone, or null if past the final milestone
181
79
  */
182
- export function getProfileForEntity(entityId, actionsPerDay, config) {
183
- // Check for manual override first
184
- const override = config.overrideByAgentId.get(entityId);
185
- if (override) {
186
- return override;
80
+ export function getNextDecayMilestone(daysSinceLastActivity) {
81
+ for (const milestone of DECAY_MILESTONES) {
82
+ if (milestone.days > daysSinceLastActivity) {
83
+ return milestone;
84
+ }
187
85
  }
188
- // Use auto-classification if enabled
189
- if (config.autoClassification) {
190
- return classifyEnvironmentProfile(actionsPerDay);
191
- }
192
- // Default to standard profile
193
- return DEFAULT_DECAY_PROFILES.profiles.standard;
194
- }
195
- // ============================================================================
196
- // Configuration Factory
197
- // ============================================================================
198
- /**
199
- * Create a decay configuration with defaults
200
- *
201
- * @param options - Configuration options
202
- * @returns Complete decay configuration
203
- */
204
- export function createDecayConfig(options = {}) {
205
- return {
206
- autoClassification: options.autoClassification ?? true,
207
- overrideByAgentId: options.overrideByAgentId ?? new Map(),
208
- };
86
+ return null;
209
87
  }
210
88
  //# sourceMappingURL=decay-profiles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"decay-profiles.js","sourceRoot":"","sources":["../../src/trust-engine/decay-profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAkEH,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,QAAQ,EAAE;QACR,QAAQ,EAAE;YACR,IAAI,EAAE,UAAmB;YACzB,gBAAgB,EAAE,EAAE;YACpB,iBAAiB,EAAE,GAAG;SACvB;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,UAAmB;YACzB,gBAAgB,EAAE,GAAG;YACrB,iBAAiB,EAAE,GAAG;SACvB;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAiB;YACvB,gBAAgB,EAAE,GAAG;YACrB,iBAAiB,EAAE,GAAG;SACvB;KACF;CACO,CAAC;AAEX,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,0BAA0B,CACxC,YAAoB,EACpB,mBAA2B,EAC3B,OAA2B,EAC3B,YAAoB;IAEpB,sDAAsD;IACtD,qDAAqD;IACrD,MAAM,eAAe,GAAG,IAAI,CAAC,GAAG,CAC9B,GAAG,EACH,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,CAC/C,CAAC;IAEF,uDAAuD;IACvD,qCAAqC;IACrC,MAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IACpD,MAAM,mBAAmB,GAAG,IAAI,CAAC,GAAG,CAClC,OAAO,CAAC,iBAAiB,EACzB,iBAAiB,CAClB,CAAC;IAEF,wDAAwD;IACxD,MAAM,YAAY,GAAG,CAAC,YAAY,GAAG,eAAe,CAAC,GAAG,mBAAmB,CAAC;IAE5E,aAAa;IACb,OAAO,IAAI,CAAC,GAAG,CAAC,CAA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