@vorionsys/atsf-core 0.2.3 → 0.2.4

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 (325) hide show
  1. package/dist/api/index.d.ts +1 -1
  2. package/dist/api/index.js +1 -1
  3. package/dist/api/server.d.ts +2 -2
  4. package/dist/api/server.d.ts.map +1 -1
  5. package/dist/api/server.js +147 -184
  6. package/dist/api/server.js.map +1 -1
  7. package/dist/arbitration/index.d.ts +4 -4
  8. package/dist/arbitration/index.d.ts.map +1 -1
  9. package/dist/arbitration/index.js +41 -46
  10. package/dist/arbitration/index.js.map +1 -1
  11. package/dist/arbitration/types.d.ts +10 -10
  12. package/dist/arbitration/types.d.ts.map +1 -1
  13. package/dist/basis/evaluator.d.ts +1 -1
  14. package/dist/basis/evaluator.d.ts.map +1 -1
  15. package/dist/basis/evaluator.js +54 -56
  16. package/dist/basis/evaluator.js.map +1 -1
  17. package/dist/basis/index.d.ts +3 -3
  18. package/dist/basis/index.js +3 -3
  19. package/dist/basis/parser.d.ts +2 -2
  20. package/dist/basis/parser.d.ts.map +1 -1
  21. package/dist/basis/parser.js +25 -32
  22. package/dist/basis/parser.js.map +1 -1
  23. package/dist/basis/types.d.ts +2 -2
  24. package/dist/chain/index.d.ts.map +1 -1
  25. package/dist/chain/index.js +16 -16
  26. package/dist/chain/index.js.map +1 -1
  27. package/dist/cognigate/index.d.ts +1 -1
  28. package/dist/cognigate/index.d.ts.map +1 -1
  29. package/dist/cognigate/index.js +33 -44
  30. package/dist/cognigate/index.js.map +1 -1
  31. package/dist/common/adapters.d.ts +4 -4
  32. package/dist/common/adapters.d.ts.map +1 -1
  33. package/dist/common/adapters.js +52 -62
  34. package/dist/common/adapters.js.map +1 -1
  35. package/dist/common/config.d.ts +69 -68
  36. package/dist/common/config.d.ts.map +1 -1
  37. package/dist/common/config.js +50 -50
  38. package/dist/common/config.js.map +1 -1
  39. package/dist/common/index.d.ts +4 -4
  40. package/dist/common/index.js +4 -4
  41. package/dist/common/logger.d.ts +1 -1
  42. package/dist/common/logger.js +8 -8
  43. package/dist/common/types.d.ts +5 -5
  44. package/dist/common/types.js +5 -5
  45. package/dist/containment/index.d.ts +3 -3
  46. package/dist/containment/index.d.ts.map +1 -1
  47. package/dist/containment/index.js +105 -119
  48. package/dist/containment/index.js.map +1 -1
  49. package/dist/containment/types.d.ts +11 -11
  50. package/dist/containment/types.d.ts.map +1 -1
  51. package/dist/contracts/index.d.ts +9 -9
  52. package/dist/contracts/index.d.ts.map +1 -1
  53. package/dist/contracts/index.js +54 -59
  54. package/dist/contracts/index.js.map +1 -1
  55. package/dist/contracts/types.d.ts +12 -12
  56. package/dist/contracts/types.d.ts.map +1 -1
  57. package/dist/crewai/callback.d.ts +2 -2
  58. package/dist/crewai/callback.d.ts.map +1 -1
  59. package/dist/crewai/callback.js +27 -27
  60. package/dist/crewai/callback.js.map +1 -1
  61. package/dist/crewai/executor.d.ts +95 -4
  62. package/dist/crewai/executor.d.ts.map +1 -1
  63. package/dist/crewai/executor.js +457 -16
  64. package/dist/crewai/executor.js.map +1 -1
  65. package/dist/crewai/index.d.ts +4 -4
  66. package/dist/crewai/index.js +4 -4
  67. package/dist/crewai/tools.d.ts +1 -1
  68. package/dist/crewai/tools.d.ts.map +1 -1
  69. package/dist/crewai/tools.js +38 -39
  70. package/dist/crewai/tools.js.map +1 -1
  71. package/dist/crewai/types.d.ts +66 -3
  72. package/dist/crewai/types.d.ts.map +1 -1
  73. package/dist/enforce/index.d.ts +229 -7
  74. package/dist/enforce/index.d.ts.map +1 -1
  75. package/dist/enforce/index.js +52 -80
  76. package/dist/enforce/index.js.map +1 -1
  77. package/dist/enforce/trust-aware-enforcement-service.d.ts +8 -8
  78. package/dist/enforce/trust-aware-enforcement-service.d.ts.map +1 -1
  79. package/dist/enforce/trust-aware-enforcement-service.js +107 -125
  80. package/dist/enforce/trust-aware-enforcement-service.js.map +1 -1
  81. package/dist/governance/fluid-workflow.d.ts +8 -8
  82. package/dist/governance/fluid-workflow.d.ts.map +1 -1
  83. package/dist/governance/fluid-workflow.js +86 -114
  84. package/dist/governance/fluid-workflow.js.map +1 -1
  85. package/dist/governance/index.d.ts +7 -7
  86. package/dist/governance/index.d.ts.map +1 -1
  87. package/dist/governance/index.js +74 -81
  88. package/dist/governance/index.js.map +1 -1
  89. package/dist/governance/proof-bridge.d.ts +6 -6
  90. package/dist/governance/proof-bridge.d.ts.map +1 -1
  91. package/dist/governance/proof-bridge.js +5 -5
  92. package/dist/governance/proof-bridge.js.map +1 -1
  93. package/dist/governance/types.d.ts +9 -16
  94. package/dist/governance/types.d.ts.map +1 -1
  95. package/dist/governance/types.js.map +1 -1
  96. package/dist/index.d.ts +27 -29
  97. package/dist/index.d.ts.map +1 -1
  98. package/dist/index.js +25 -31
  99. package/dist/index.js.map +1 -1
  100. package/dist/intent/index.d.ts +55 -5
  101. package/dist/intent/index.d.ts.map +1 -1
  102. package/dist/intent/index.js +21 -24
  103. package/dist/intent/index.js.map +1 -1
  104. package/dist/intent/persistent-intent-service.d.ts +2 -2
  105. package/dist/intent/persistent-intent-service.d.ts.map +1 -1
  106. package/dist/intent/persistent-intent-service.js +31 -43
  107. package/dist/intent/persistent-intent-service.js.map +1 -1
  108. package/dist/intent/supabase-intent-repository.d.ts +124 -0
  109. package/dist/intent/supabase-intent-repository.d.ts.map +1 -0
  110. package/dist/intent/supabase-intent-repository.js +404 -0
  111. package/dist/intent/supabase-intent-repository.js.map +1 -0
  112. package/dist/langchain/callback.d.ts +2 -2
  113. package/dist/langchain/callback.d.ts.map +1 -1
  114. package/dist/langchain/callback.js +30 -30
  115. package/dist/langchain/callback.js.map +1 -1
  116. package/dist/langchain/executor.d.ts +4 -4
  117. package/dist/langchain/executor.d.ts.map +1 -1
  118. package/dist/langchain/executor.js +80 -82
  119. package/dist/langchain/executor.js.map +1 -1
  120. package/dist/langchain/index.d.ts +5 -5
  121. package/dist/langchain/index.js +5 -5
  122. package/dist/langchain/tools.d.ts +1 -1
  123. package/dist/langchain/tools.d.ts.map +1 -1
  124. package/dist/langchain/tools.js +34 -36
  125. package/dist/langchain/tools.js.map +1 -1
  126. package/dist/langchain/types.d.ts +3 -3
  127. package/dist/langchain/types.d.ts.map +1 -1
  128. package/dist/layers/implementations/L0-request-format.d.ts +2 -2
  129. package/dist/layers/implementations/L0-request-format.d.ts.map +1 -1
  130. package/dist/layers/implementations/L0-request-format.js +52 -54
  131. package/dist/layers/implementations/L0-request-format.js.map +1 -1
  132. package/dist/layers/implementations/L1-input-size.d.ts +2 -2
  133. package/dist/layers/implementations/L1-input-size.d.ts.map +1 -1
  134. package/dist/layers/implementations/L1-input-size.js +39 -49
  135. package/dist/layers/implementations/L1-input-size.js.map +1 -1
  136. package/dist/layers/implementations/L2-charset-sanitizer.d.ts +2 -2
  137. package/dist/layers/implementations/L2-charset-sanitizer.d.ts.map +1 -1
  138. package/dist/layers/implementations/L2-charset-sanitizer.js +71 -81
  139. package/dist/layers/implementations/L2-charset-sanitizer.js.map +1 -1
  140. package/dist/layers/implementations/L3-schema-conformance.d.ts +3 -3
  141. package/dist/layers/implementations/L3-schema-conformance.d.ts.map +1 -1
  142. package/dist/layers/implementations/L3-schema-conformance.js +73 -82
  143. package/dist/layers/implementations/L3-schema-conformance.js.map +1 -1
  144. package/dist/layers/implementations/L4-injection-detector.d.ts +4 -4
  145. package/dist/layers/implementations/L4-injection-detector.d.ts.map +1 -1
  146. package/dist/layers/implementations/L4-injection-detector.js +81 -85
  147. package/dist/layers/implementations/L4-injection-detector.js.map +1 -1
  148. package/dist/layers/implementations/L5-rate-limiter.d.ts +2 -2
  149. package/dist/layers/implementations/L5-rate-limiter.d.ts.map +1 -1
  150. package/dist/layers/implementations/L5-rate-limiter.js +20 -20
  151. package/dist/layers/implementations/L5-rate-limiter.js.map +1 -1
  152. package/dist/layers/implementations/index.d.ts +6 -6
  153. package/dist/layers/implementations/index.d.ts.map +1 -1
  154. package/dist/layers/implementations/index.js +6 -6
  155. package/dist/layers/implementations/index.js.map +1 -1
  156. package/dist/layers/index.d.ts +3 -3
  157. package/dist/layers/index.d.ts.map +1 -1
  158. package/dist/layers/index.js +71 -99
  159. package/dist/layers/index.js.map +1 -1
  160. package/dist/layers/types.d.ts +16 -16
  161. package/dist/layers/types.d.ts.map +1 -1
  162. package/dist/persistence/file.d.ts +3 -3
  163. package/dist/persistence/file.d.ts.map +1 -1
  164. package/dist/persistence/file.js +28 -32
  165. package/dist/persistence/file.js.map +1 -1
  166. package/dist/persistence/index.d.ts +7 -7
  167. package/dist/persistence/index.d.ts.map +1 -1
  168. package/dist/persistence/index.js +18 -18
  169. package/dist/persistence/index.js.map +1 -1
  170. package/dist/persistence/memory.d.ts +3 -3
  171. package/dist/persistence/memory.d.ts.map +1 -1
  172. package/dist/persistence/memory.js +8 -10
  173. package/dist/persistence/memory.js.map +1 -1
  174. package/dist/persistence/sqlite.d.ts +3 -3
  175. package/dist/persistence/sqlite.d.ts.map +1 -1
  176. package/dist/persistence/sqlite.js +40 -39
  177. package/dist/persistence/sqlite.js.map +1 -1
  178. package/dist/persistence/supabase.d.ts +3 -3
  179. package/dist/persistence/supabase.d.ts.map +1 -1
  180. package/dist/persistence/supabase.js +45 -43
  181. package/dist/persistence/supabase.js.map +1 -1
  182. package/dist/persistence/types.d.ts +5 -5
  183. package/dist/phase6/ceiling.d.ts +5 -5
  184. package/dist/phase6/ceiling.d.ts.map +1 -1
  185. package/dist/phase6/ceiling.js +36 -69
  186. package/dist/phase6/ceiling.js.map +1 -1
  187. package/dist/phase6/context.d.ts +3 -3
  188. package/dist/phase6/context.d.ts.map +1 -1
  189. package/dist/phase6/context.js +47 -93
  190. package/dist/phase6/context.js.map +1 -1
  191. package/dist/phase6/index.d.ts +12 -12
  192. package/dist/phase6/index.d.ts.map +1 -1
  193. package/dist/phase6/index.js +15 -15
  194. package/dist/phase6/index.js.map +1 -1
  195. package/dist/phase6/presets.d.ts +2 -2
  196. package/dist/phase6/presets.d.ts.map +1 -1
  197. package/dist/phase6/presets.js +33 -39
  198. package/dist/phase6/presets.js.map +1 -1
  199. package/dist/phase6/provenance.d.ts +4 -4
  200. package/dist/phase6/provenance.d.ts.map +1 -1
  201. package/dist/phase6/provenance.js +35 -42
  202. package/dist/phase6/provenance.js.map +1 -1
  203. package/dist/phase6/role-gates/index.d.ts +2 -2
  204. package/dist/phase6/role-gates/index.js +2 -2
  205. package/dist/phase6/role-gates/kernel.d.ts.map +1 -1
  206. package/dist/phase6/role-gates/kernel.js +16 -16
  207. package/dist/phase6/role-gates/kernel.js.map +1 -1
  208. package/dist/phase6/role-gates/policy.d.ts +2 -2
  209. package/dist/phase6/role-gates/policy.js +6 -6
  210. package/dist/phase6/role-gates.d.ts +4 -4
  211. package/dist/phase6/role-gates.d.ts.map +1 -1
  212. package/dist/phase6/role-gates.js +58 -80
  213. package/dist/phase6/role-gates.js.map +1 -1
  214. package/dist/phase6/types.d.ts +20 -19
  215. package/dist/phase6/types.d.ts.map +1 -1
  216. package/dist/phase6/types.js +82 -177
  217. package/dist/phase6/types.js.map +1 -1
  218. package/dist/phase6/weight-presets/canonical.d.ts.map +1 -1
  219. package/dist/phase6/weight-presets/canonical.js +10 -10
  220. package/dist/phase6/weight-presets/canonical.js.map +1 -1
  221. package/dist/phase6/weight-presets/deltas.d.ts +2 -2
  222. package/dist/phase6/weight-presets/deltas.d.ts.map +1 -1
  223. package/dist/phase6/weight-presets/deltas.js +27 -27
  224. package/dist/phase6/weight-presets/deltas.js.map +1 -1
  225. package/dist/phase6/weight-presets/index.d.ts +3 -3
  226. package/dist/phase6/weight-presets/index.js +3 -3
  227. package/dist/phase6/weight-presets/merger.d.ts +2 -2
  228. package/dist/phase6/weight-presets/merger.d.ts.map +1 -1
  229. package/dist/phase6/weight-presets/merger.js +43 -39
  230. package/dist/phase6/weight-presets/merger.js.map +1 -1
  231. package/dist/proof/index.d.ts +3 -3
  232. package/dist/proof/index.d.ts.map +1 -1
  233. package/dist/proof/index.js +38 -44
  234. package/dist/proof/index.js.map +1 -1
  235. package/dist/proof/merkle.d.ts +24 -3
  236. package/dist/proof/merkle.d.ts.map +1 -1
  237. package/dist/proof/merkle.js +116 -32
  238. package/dist/proof/merkle.js.map +1 -1
  239. package/dist/proof/zk-proofs.d.ts +6 -6
  240. package/dist/proof/zk-proofs.d.ts.map +1 -1
  241. package/dist/proof/zk-proofs.js +43 -42
  242. package/dist/proof/zk-proofs.js.map +1 -1
  243. package/dist/provenance/index.d.ts +3 -3
  244. package/dist/provenance/index.d.ts.map +1 -1
  245. package/dist/provenance/index.js +17 -19
  246. package/dist/provenance/index.js.map +1 -1
  247. package/dist/provenance/types.d.ts +4 -4
  248. package/dist/provenance/types.d.ts.map +1 -1
  249. package/dist/sandbox-training/challenges.d.ts +1 -1
  250. package/dist/sandbox-training/challenges.d.ts.map +1 -1
  251. package/dist/sandbox-training/challenges.js +228 -228
  252. package/dist/sandbox-training/challenges.js.map +1 -1
  253. package/dist/sandbox-training/graduation.d.ts +1 -1
  254. package/dist/sandbox-training/graduation.d.ts.map +1 -1
  255. package/dist/sandbox-training/graduation.js +15 -14
  256. package/dist/sandbox-training/graduation.js.map +1 -1
  257. package/dist/sandbox-training/index.d.ts +9 -9
  258. package/dist/sandbox-training/index.d.ts.map +1 -1
  259. package/dist/sandbox-training/index.js +6 -6
  260. package/dist/sandbox-training/index.js.map +1 -1
  261. package/dist/sandbox-training/promotion-service.d.ts +4 -4
  262. package/dist/sandbox-training/promotion-service.d.ts.map +1 -1
  263. package/dist/sandbox-training/promotion-service.js +5 -5
  264. package/dist/sandbox-training/promotion-service.js.map +1 -1
  265. package/dist/sandbox-training/runner.d.ts +1 -1
  266. package/dist/sandbox-training/runner.d.ts.map +1 -1
  267. package/dist/sandbox-training/runner.js +73 -74
  268. package/dist/sandbox-training/runner.js.map +1 -1
  269. package/dist/sandbox-training/scorer.d.ts +4 -4
  270. package/dist/sandbox-training/scorer.js +5 -5
  271. package/dist/sandbox-training/types.d.ts +4 -4
  272. package/dist/sandbox-training/types.d.ts.map +1 -1
  273. package/dist/sandbox-training/types.js +7 -11
  274. package/dist/sandbox-training/types.js.map +1 -1
  275. package/dist/trust-engine/ceiling-enforcement/audit.d.ts +1 -1
  276. package/dist/trust-engine/ceiling-enforcement/audit.d.ts.map +1 -1
  277. package/dist/trust-engine/ceiling-enforcement/audit.js +4 -3
  278. package/dist/trust-engine/ceiling-enforcement/audit.js.map +1 -1
  279. package/dist/trust-engine/ceiling-enforcement/index.d.ts +2 -2
  280. package/dist/trust-engine/ceiling-enforcement/index.js +2 -2
  281. package/dist/trust-engine/ceiling-enforcement/kernel.d.ts +12 -10
  282. package/dist/trust-engine/ceiling-enforcement/kernel.d.ts.map +1 -1
  283. package/dist/trust-engine/ceiling-enforcement/kernel.js +26 -20
  284. package/dist/trust-engine/ceiling-enforcement/kernel.js.map +1 -1
  285. package/dist/trust-engine/context-policy/enforcement.d.ts.map +1 -1
  286. package/dist/trust-engine/context-policy/factory.d.ts +1 -1
  287. package/dist/trust-engine/context-policy/factory.d.ts.map +1 -1
  288. package/dist/trust-engine/context-policy/factory.js +1 -1
  289. package/dist/trust-engine/context-policy/factory.js.map +1 -1
  290. package/dist/trust-engine/context-policy/index.d.ts +2 -2
  291. package/dist/trust-engine/context-policy/index.js +2 -2
  292. package/dist/trust-engine/creation-modifiers/index.d.ts +1 -1
  293. package/dist/trust-engine/creation-modifiers/index.js +1 -1
  294. package/dist/trust-engine/creation-modifiers/types.d.ts.map +1 -1
  295. package/dist/trust-engine/creation-modifiers/types.js +3 -2
  296. package/dist/trust-engine/creation-modifiers/types.js.map +1 -1
  297. package/dist/trust-engine/decay-profiles.d.ts +37 -136
  298. package/dist/trust-engine/decay-profiles.d.ts.map +1 -1
  299. package/dist/trust-engine/decay-profiles.js +68 -178
  300. package/dist/trust-engine/decay-profiles.js.map +1 -1
  301. package/dist/trust-engine/index.d.ts +135 -168
  302. package/dist/trust-engine/index.d.ts.map +1 -1
  303. package/dist/trust-engine/index.js +239 -525
  304. package/dist/trust-engine/index.js.map +1 -1
  305. package/dist/trust-engine/phase6-types.d.ts +18 -11
  306. package/dist/trust-engine/phase6-types.d.ts.map +1 -1
  307. package/dist/trust-engine/phase6-types.js +33 -29
  308. package/dist/trust-engine/phase6-types.js.map +1 -1
  309. package/package.json +1 -1
  310. package/dist/enforce/types.d.ts +0 -234
  311. package/dist/enforce/types.d.ts.map +0 -1
  312. package/dist/enforce/types.js +0 -10
  313. package/dist/enforce/types.js.map +0 -1
  314. package/dist/intent/types.d.ts +0 -69
  315. package/dist/intent/types.d.ts.map +0 -1
  316. package/dist/intent/types.js +0 -10
  317. package/dist/intent/types.js.map +0 -1
  318. package/dist/intent-gateway/index.d.ts +0 -522
  319. package/dist/intent-gateway/index.d.ts.map +0 -1
  320. package/dist/intent-gateway/index.js +0 -1499
  321. package/dist/intent-gateway/index.js.map +0 -1
  322. package/dist/trust-engine/types.d.ts +0 -77
  323. package/dist/trust-engine/types.d.ts.map +0 -1
  324. package/dist/trust-engine/types.js +0 -20
  325. package/dist/trust-engine/types.js.map +0 -1
@@ -5,19 +5,19 @@
5
5
  *
6
6
  * @packageDocumentation
7
7
  */
8
- import Fastify from "fastify";
9
- import cors from "@fastify/cors";
10
- import helmet from "@fastify/helmet";
11
- import rateLimit from "@fastify/rate-limit";
12
- import { createLogger } from "../common/logger.js";
13
- import { getConfig } from "../common/config.js";
14
- import { PersistentIntentService } from "../intent/persistent-intent-service.js";
15
- import { createProofService } from "../proof/index.js";
16
- import { createTrustEngine } from "../trust-engine/index.js";
17
- import { createEvaluator } from "../basis/evaluator.js";
18
- import { createGovernanceEngine } from "../governance/index.js";
19
- import { GovernanceProofBridge } from "../governance/proof-bridge.js";
20
- const apiLogger = createLogger({ component: "api" });
8
+ import Fastify from 'fastify';
9
+ import cors from '@fastify/cors';
10
+ import helmet from '@fastify/helmet';
11
+ import rateLimit from '@fastify/rate-limit';
12
+ import { createLogger } from '../common/logger.js';
13
+ import { getConfig } from '../common/config.js';
14
+ import { PersistentIntentService } from '../intent/persistent-intent-service.js';
15
+ import { createProofService } from '../proof/index.js';
16
+ import { createTrustEngine } from '../trust-engine/index.js';
17
+ import { createEvaluator } from '../basis/evaluator.js';
18
+ import { createGovernanceEngine } from '../governance/index.js';
19
+ import { GovernanceProofBridge } from '../governance/proof-bridge.js';
20
+ const apiLogger = createLogger({ component: 'api' });
21
21
  // ============================================================
22
22
  // Health Check Implementation
23
23
  // ============================================================
@@ -43,15 +43,15 @@ function checkSystemHealth(startTime) {
43
43
  const metrics = getSystemMetrics(startTime);
44
44
  // Warning threshold: 80% memory usage
45
45
  // Error threshold: 95% memory usage
46
- let status = "ok";
47
- let message = "System healthy";
46
+ let status = 'ok';
47
+ let message = 'System healthy';
48
48
  if (metrics.memoryUsagePercent > 95) {
49
- status = "error";
50
- message = "Critical memory pressure";
49
+ status = 'error';
50
+ message = 'Critical memory pressure';
51
51
  }
52
52
  else if (metrics.memoryUsagePercent > 80) {
53
- status = "degraded";
54
- message = "High memory usage";
53
+ status = 'degraded';
54
+ message = 'High memory usage';
55
55
  }
56
56
  return {
57
57
  status,
@@ -71,16 +71,16 @@ async function checkService(name, checkFn) {
71
71
  try {
72
72
  await checkFn();
73
73
  return {
74
- status: "ok",
74
+ status: 'ok',
75
75
  latencyMs: Date.now() - start,
76
76
  message: `${name} operational`,
77
77
  };
78
78
  }
79
79
  catch (error) {
80
80
  return {
81
- status: "error",
81
+ status: 'error',
82
82
  latencyMs: Date.now() - start,
83
- message: `${name} error: ${error instanceof Error ? error.message : "Unknown error"}`,
83
+ message: `${name} error: ${error instanceof Error ? error.message : 'Unknown error'}`,
84
84
  };
85
85
  }
86
86
  }
@@ -101,45 +101,41 @@ export async function createServer(deps) {
101
101
  const proof = await proofService.create(req);
102
102
  return { id: proof.id };
103
103
  },
104
- tenantId: "__system__",
104
+ tenantId: '__system__',
105
105
  });
106
106
  // Use pino logger config for Fastify 5
107
- const isTest = process.env["NODE_ENV"] === "test" || process.env["VITEST"];
107
+ const isTest = process.env['NODE_ENV'] === 'test' || process.env['VITEST'];
108
108
  const server = Fastify({
109
- logger: isTest
110
- ? false
111
- : {
112
- level: config.env === "production" ? "info" : "debug",
113
- transport: config.env !== "production"
114
- ? {
115
- target: "pino-pretty",
116
- options: { colorize: true },
117
- }
118
- : undefined,
119
- },
120
- requestIdHeader: "x-request-id",
121
- requestIdLogLabel: "requestId",
109
+ logger: isTest ? false : {
110
+ level: config.env === 'production' ? 'info' : 'debug',
111
+ transport: config.env !== 'production' ? {
112
+ target: 'pino-pretty',
113
+ options: { colorize: true },
114
+ } : undefined,
115
+ },
116
+ requestIdHeader: 'x-request-id',
117
+ requestIdLogLabel: 'requestId',
122
118
  });
123
119
  // Register plugins
124
120
  await server.register(cors, {
125
- origin: config.env === "production" ? false : true,
121
+ origin: config.env === 'production' ? false : true,
126
122
  credentials: true,
127
123
  });
128
124
  await server.register(helmet, {
129
- contentSecurityPolicy: config.env === "production",
125
+ contentSecurityPolicy: config.env === 'production',
130
126
  });
131
127
  await server.register(rateLimit, {
132
128
  max: config.api.rateLimit,
133
- timeWindow: "1 minute",
129
+ timeWindow: '1 minute',
134
130
  });
135
131
  // API Key authentication for protected routes
136
- const API_KEY = process.env["VORION_API_KEY"] || config.api.apiKey;
132
+ const API_KEY = process.env['VORION_API_KEY'] || config.api.apiKey;
137
133
  const requiresAuth = (url) => {
138
134
  // Public endpoints that don't require auth
139
- const publicPaths = ["/health", "/ready", "/live", "/api/v1/health"];
140
- return !publicPaths.some((path) => url === path || url.startsWith(path + "?"));
135
+ const publicPaths = ['/health', '/ready', '/live', '/api/v1/health'];
136
+ return !publicPaths.some(path => url === path || url.startsWith(path + '?'));
141
137
  };
142
- server.addHook("onRequest", async (request, reply) => {
138
+ server.addHook('onRequest', async (request, reply) => {
143
139
  // Skip auth in test mode or for public endpoints
144
140
  if (isTest || !requiresAuth(request.url)) {
145
141
  return;
@@ -148,113 +144,107 @@ export async function createServer(deps) {
148
144
  if (!API_KEY) {
149
145
  return;
150
146
  }
151
- const authHeader = request.headers["authorization"];
147
+ const authHeader = request.headers['authorization'];
152
148
  if (!authHeader) {
153
149
  return reply.status(401).send({
154
- error: {
155
- code: "UNAUTHORIZED",
156
- message: "Missing Authorization header",
157
- },
150
+ error: { code: 'UNAUTHORIZED', message: 'Missing Authorization header' },
158
151
  });
159
152
  }
160
- const [scheme, token] = authHeader.split(" ");
161
- if (scheme?.toLowerCase() !== "bearer" || token !== API_KEY) {
153
+ const [scheme, token] = authHeader.split(' ');
154
+ if (scheme?.toLowerCase() !== 'bearer' || token !== API_KEY) {
162
155
  return reply.status(401).send({
163
- error: { code: "UNAUTHORIZED", message: "Invalid API key" },
156
+ error: { code: 'UNAUTHORIZED', message: 'Invalid API key' },
164
157
  });
165
158
  }
166
159
  });
167
160
  // Health check endpoint - performs actual checks on all services
168
- server.get("/health", async () => {
161
+ server.get('/health', async () => {
169
162
  const checks = {};
170
163
  // Check trust engine
171
- checks.trustEngine = await checkService("Trust engine", async () => {
172
- await trustEngine.getScore("__health_check__");
164
+ checks.trustEngine = await checkService('Trust engine', async () => {
165
+ await trustEngine.getScore('__health_check__');
173
166
  });
174
167
  // Check proof service
175
- checks.proofService = await checkService("Proof service", async () => {
176
- await proofService.get("__health_check_proof__");
168
+ checks.proofService = await checkService('Proof service', async () => {
169
+ await proofService.get('__health_check_proof__');
177
170
  });
178
171
  // Check intent service
179
- checks.intentService = await checkService("Intent service", async () => {
180
- await intentService.get("__health_check_intent__", "__system__");
172
+ checks.intentService = await checkService('Intent service', async () => {
173
+ await intentService.get('__health_check_intent__', '__system__');
181
174
  });
182
175
  // Check system health
183
176
  checks.system = checkSystemHealth(startTime);
184
177
  // Determine overall status
185
178
  const statuses = Object.values(checks).map((c) => c.status);
186
179
  let status;
187
- if (statuses.every((s) => s === "ok")) {
188
- status = "healthy";
180
+ if (statuses.every((s) => s === 'ok')) {
181
+ status = 'healthy';
189
182
  }
190
- else if (statuses.some((s) => s === "error")) {
191
- status = "unhealthy";
183
+ else if (statuses.some((s) => s === 'error')) {
184
+ status = 'unhealthy';
192
185
  }
193
186
  else {
194
- status = "degraded";
187
+ status = 'degraded';
195
188
  }
196
189
  return {
197
190
  status,
198
191
  timestamp: new Date().toISOString(),
199
- version: process.env["npm_package_version"],
192
+ version: process.env['npm_package_version'],
200
193
  environment: config.env,
201
194
  checks,
202
195
  metrics: getSystemMetrics(startTime),
203
196
  };
204
197
  });
205
198
  // Ready check endpoint - verifies all critical services are ready
206
- server.get("/ready", async (_request, reply) => {
199
+ server.get('/ready', async (_request, reply) => {
207
200
  const checks = {};
208
201
  // Check trust engine (critical)
209
- checks.trustEngine = await checkService("Trust engine", async () => {
210
- await trustEngine.getScore("__health_check__");
202
+ checks.trustEngine = await checkService('Trust engine', async () => {
203
+ await trustEngine.getScore('__health_check__');
211
204
  });
212
205
  // Check proof service (critical)
213
- checks.proofService = await checkService("Proof service", async () => {
214
- await proofService.get("__health_check_proof__");
206
+ checks.proofService = await checkService('Proof service', async () => {
207
+ await proofService.get('__health_check_proof__');
215
208
  });
216
209
  // Check intent service (critical)
217
- checks.intentService = await checkService("Intent service", async () => {
218
- await intentService.get("__health_check_intent__", "__system__");
210
+ checks.intentService = await checkService('Intent service', async () => {
211
+ await intentService.get('__health_check_intent__', '__system__');
219
212
  });
220
- const allPassed = Object.values(checks).every((c) => c.status === "ok" || c.status === "degraded");
213
+ const allPassed = Object.values(checks).every((c) => c.status === 'ok' || c.status === 'degraded');
221
214
  // Return 503 if not ready (for Kubernetes probes)
222
215
  if (!allPassed) {
223
216
  reply.status(503);
224
217
  }
225
218
  return {
226
- status: allPassed ? "ready" : "not_ready",
219
+ status: allPassed ? 'ready' : 'not_ready',
227
220
  timestamp: new Date().toISOString(),
228
221
  checks,
229
222
  allPassed,
230
223
  };
231
224
  });
232
225
  // Liveness probe endpoint - simple alive check (no deep checks)
233
- server.get("/live", async () => ({
234
- status: "alive",
226
+ server.get('/live', async () => ({
227
+ status: 'alive',
235
228
  timestamp: new Date().toISOString(),
236
229
  }));
237
230
  // API routes
238
231
  server.register(async (api) => {
239
232
  // SDK: Health check endpoint
240
- api.get("/health", async () => ({
241
- status: "healthy",
242
- version: process.env["npm_package_version"] ?? "0.1.0",
233
+ api.get('/health', async () => ({
234
+ status: 'healthy',
235
+ version: process.env['npm_package_version'] ?? '0.1.0',
243
236
  }));
244
237
  // Intent routes - unified handler for both legacy and SDK formats
245
- api.post("/intents", async (request, reply) => {
238
+ api.post('/intents', async (request, reply) => {
246
239
  const body = request.body;
247
240
  // Detect format: SDK format has 'agentId' and 'action', legacy has 'entityId' and 'goal'
248
- if ("agentId" in body && "action" in body) {
241
+ if ('agentId' in body && 'action' in body) {
249
242
  // SDK format
250
243
  const startTime = Date.now();
251
- const { agentId, capabilities = [], action, } = body;
244
+ const { agentId, capabilities = [], action } = body;
252
245
  if (!agentId || !action?.type || !action?.resource) {
253
246
  return reply.status(400).send({
254
- error: {
255
- code: "INVALID_REQUEST",
256
- message: "Missing required fields: agentId, action.type, action.resource",
257
- },
247
+ error: { code: 'INVALID_REQUEST', message: 'Missing required fields: agentId, action.type, action.resource' },
258
248
  });
259
249
  }
260
250
  // Get or create agent trust record
@@ -264,10 +254,10 @@ export async function createServer(deps) {
264
254
  trustRecord = await trustEngine.getScore(agentId);
265
255
  }
266
256
  // Check capability
267
- const hasCapability = capabilities.some((cap) => cap === "*" ||
257
+ const hasCapability = capabilities.some(cap => cap === '*' ||
268
258
  cap === action.type ||
269
259
  cap === `${action.type}:*` ||
270
- cap === `${action.type}:${action.resource.split("/")[0]}`);
260
+ cap === `${action.type}:${action.resource.split('/')[0]}`);
271
261
  // Determine decision
272
262
  const trustLevel = trustRecord?.level ?? 3;
273
263
  const trustScore = trustRecord?.score ?? 500;
@@ -275,13 +265,13 @@ export async function createServer(deps) {
275
265
  // Decision tier based on trust level
276
266
  let tier;
277
267
  if (!allowed) {
278
- tier = "RED";
268
+ tier = 'RED';
279
269
  }
280
270
  else if (trustLevel >= 5) {
281
- tier = "GREEN";
271
+ tier = 'GREEN';
282
272
  }
283
273
  else {
284
- tier = "YELLOW";
274
+ tier = 'YELLOW';
285
275
  }
286
276
  // Create proof record
287
277
  const proofId = `proof-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
@@ -289,20 +279,20 @@ export async function createServer(deps) {
289
279
  // Determine constraints based on tier
290
280
  const constraints = [];
291
281
  if (trustLevel <= 1) {
292
- constraints.push("rate_limit:10/min", "audit:full", "sandbox:true");
282
+ constraints.push('rate_limit:10/min', 'audit:full', 'sandbox:true');
293
283
  }
294
284
  else if (trustLevel <= 3) {
295
- constraints.push("rate_limit:100/min", "audit:standard");
285
+ constraints.push('rate_limit:100/min', 'audit:standard');
296
286
  }
297
287
  else if (trustLevel <= 5) {
298
- constraints.push("rate_limit:1000/min", "audit:light");
288
+ constraints.push('rate_limit:1000/min', 'audit:light');
299
289
  }
300
290
  const reason = allowed
301
- ? "Action permitted based on capabilities and trust level"
291
+ ? 'Action permitted based on capabilities and trust level'
302
292
  : hasCapability
303
293
  ? `Trust score ${trustScore} below minimum threshold (200)`
304
- : `Missing capability for ${action.type}:${action.resource.split("/")[0]}`;
305
- apiLogger.info({ intentId, agentId, action: action.type, allowed, tier }, "Intent processed");
294
+ : `Missing capability for ${action.type}:${action.resource.split('/')[0]}`;
295
+ apiLogger.info({ intentId, agentId, action: action.type, allowed, tier }, 'Intent processed');
306
296
  return {
307
297
  intentId,
308
298
  allowed,
@@ -318,10 +308,7 @@ export async function createServer(deps) {
318
308
  const { entityId, goal, context, metadata } = body;
319
309
  if (!entityId || !goal) {
320
310
  return reply.status(400).send({
321
- error: {
322
- code: "INVALID_REQUEST",
323
- message: "Missing required fields: entityId, goal",
324
- },
311
+ error: { code: 'INVALID_REQUEST', message: 'Missing required fields: entityId, goal' },
325
312
  });
326
313
  }
327
314
  const intent = await intentService.submit({
@@ -329,29 +316,26 @@ export async function createServer(deps) {
329
316
  goal,
330
317
  context: context ?? {},
331
318
  metadata,
332
- }, { tenantId: "__system__" });
333
- apiLogger.info({ intentId: intent.id, entityId }, "Intent submitted");
319
+ }, { tenantId: '__system__' });
320
+ apiLogger.info({ intentId: intent.id, entityId }, 'Intent submitted');
334
321
  return reply.status(201).send({ intent });
335
322
  }
336
323
  });
337
- api.get("/intents/:id", async (request, reply) => {
338
- const intent = await intentService.get(request.params.id, "__system__");
324
+ api.get('/intents/:id', async (request, reply) => {
325
+ const intent = await intentService.get(request.params.id, '__system__');
339
326
  if (!intent) {
340
327
  return reply.status(404).send({
341
- error: { code: "NOT_FOUND", message: "Intent not found" },
328
+ error: { code: 'NOT_FOUND', message: 'Intent not found' },
342
329
  });
343
330
  }
344
331
  return { intent };
345
332
  });
346
333
  // SDK: Check intent (pre-flight, no side effects)
347
- api.post("/intents/check", async (request, reply) => {
334
+ api.post('/intents/check', async (request, reply) => {
348
335
  const { agentId, capabilities = [], action } = request.body;
349
336
  if (!agentId || !action?.type || !action?.resource) {
350
337
  return reply.status(400).send({
351
- error: {
352
- code: "INVALID_REQUEST",
353
- message: "Missing required fields",
354
- },
338
+ error: { code: 'INVALID_REQUEST', message: 'Missing required fields' },
355
339
  });
356
340
  }
357
341
  // Get agent trust record
@@ -359,49 +343,49 @@ export async function createServer(deps) {
359
343
  const trustScore = trustRecord?.score ?? 0;
360
344
  const trustLevel = trustRecord?.level ?? 0;
361
345
  // Check capability
362
- const hasCapability = capabilities.some((cap) => cap === "*" ||
346
+ const hasCapability = capabilities.some(cap => cap === '*' ||
363
347
  cap === action.type ||
364
348
  cap === `${action.type}:*` ||
365
- cap === `${action.type}:${action.resource.split("/")[0]}`);
349
+ cap === `${action.type}:${action.resource.split('/')[0]}`);
366
350
  const wouldAllow = hasCapability && trustScore >= 200;
367
351
  let tier;
368
352
  if (!wouldAllow) {
369
- tier = "RED";
353
+ tier = 'RED';
370
354
  }
371
355
  else if (trustLevel >= 5) {
372
- tier = "GREEN";
356
+ tier = 'GREEN';
373
357
  }
374
358
  else {
375
- tier = "YELLOW";
359
+ tier = 'YELLOW';
376
360
  }
377
361
  const reason = wouldAllow
378
- ? "Action would be permitted"
362
+ ? 'Action would be permitted'
379
363
  : hasCapability
380
364
  ? `Trust score ${trustScore} below minimum threshold`
381
365
  : `Missing capability for ${action.type}`;
382
366
  return { wouldAllow, tier, reason };
383
367
  });
384
368
  // Proof routes
385
- api.get("/proofs/:id", async (request, reply) => {
369
+ api.get('/proofs/:id', async (request, reply) => {
386
370
  const proof = await proofService.get(request.params.id);
387
371
  if (!proof) {
388
372
  return reply.status(404).send({
389
- error: { code: "NOT_FOUND", message: "Proof not found" },
373
+ error: { code: 'NOT_FOUND', message: 'Proof not found' },
390
374
  });
391
375
  }
392
376
  return { proof };
393
377
  });
394
- api.post("/proofs/:id/verify", async (request, reply) => {
378
+ api.post('/proofs/:id/verify', async (request, reply) => {
395
379
  const result = await proofService.verify(request.params.id);
396
380
  if (result.chainPosition === -1) {
397
381
  return reply.status(404).send({
398
- error: { code: "NOT_FOUND", message: "Proof not found" },
382
+ error: { code: 'NOT_FOUND', message: 'Proof not found' },
399
383
  });
400
384
  }
401
385
  return { verification: result };
402
386
  });
403
387
  // Trust routes
404
- api.get("/trust/:entityId", async (request) => {
388
+ api.get('/trust/:entityId', async (request) => {
405
389
  const record = await trustEngine.getScore(request.params.entityId);
406
390
  if (!record) {
407
391
  // Return null values for non-existent agents (SDK compatible)
@@ -410,7 +394,7 @@ export async function createServer(deps) {
410
394
  score: null,
411
395
  tier: null,
412
396
  tierName: null,
413
- message: "Agent not found",
397
+ message: 'Agent not found',
414
398
  };
415
399
  }
416
400
  return {
@@ -422,14 +406,11 @@ export async function createServer(deps) {
422
406
  };
423
407
  });
424
408
  // SDK: Admit agent endpoint
425
- api.post("/trust/admit", async (request, reply) => {
409
+ api.post('/trust/admit', async (request, reply) => {
426
410
  const { agentId, name, capabilities, observationTier } = request.body;
427
411
  if (!agentId || !name) {
428
412
  return reply.status(400).send({
429
- error: {
430
- code: "INVALID_REQUEST",
431
- message: "Missing required fields: agentId, name",
432
- },
413
+ error: { code: 'INVALID_REQUEST', message: 'Missing required fields: agentId, name' },
433
414
  });
434
415
  }
435
416
  // Initialize agent in trust engine at T3 (Monitored)
@@ -437,35 +418,31 @@ export async function createServer(deps) {
437
418
  await trustEngine.initializeEntity(agentId, initialLevel);
438
419
  const record = await trustEngine.getScore(agentId);
439
420
  const expiresAt = new Date(Date.now() + 365 * 24 * 60 * 60 * 1000).toISOString(); // 1 year
440
- apiLogger.info({ agentId, name, initialLevel }, "Agent admitted");
421
+ apiLogger.info({ agentId, name, initialLevel }, 'Agent admitted');
441
422
  return reply.status(201).send({
442
423
  admitted: true,
443
424
  initialTier: record?.level ?? initialLevel,
444
425
  initialScore: record?.score ?? 500,
445
- observationCeiling: observationTier === "WHITE_BOX"
446
- ? 7
447
- : observationTier === "GRAY_BOX"
448
- ? 5
449
- : 3,
426
+ observationCeiling: observationTier === 'WHITE_BOX' ? 7 : observationTier === 'GRAY_BOX' ? 5 : 3,
450
427
  capabilities: capabilities ?? [],
451
428
  expiresAt,
452
429
  });
453
430
  });
454
431
  // SDK: Record trust signal
455
- api.post("/trust/:agentId/signal", async (request, reply) => {
432
+ api.post('/trust/:agentId/signal', async (request, reply) => {
456
433
  const { agentId } = request.params;
457
434
  const { type, source, weight = 0.1, context } = request.body;
458
435
  const recordBefore = await trustEngine.getScore(agentId);
459
436
  if (!recordBefore) {
460
437
  return reply.status(404).send({
461
- error: { code: "NOT_FOUND", message: "Agent not found" },
438
+ error: { code: 'NOT_FOUND', message: 'Agent not found' },
462
439
  });
463
440
  }
464
441
  const scoreBefore = recordBefore.score;
465
442
  // Map signal type to trust value
466
443
  const valueMap = {
467
- success: 0.8 + weight * 0.2,
468
- failure: 0.2 - weight * 0.1,
444
+ success: 0.8 + (weight * 0.2),
445
+ failure: 0.2 - (weight * 0.1),
469
446
  violation: 0.0,
470
447
  neutral: 0.5,
471
448
  };
@@ -487,23 +464,18 @@ export async function createServer(deps) {
487
464
  scoreAfter,
488
465
  change: scoreAfter - scoreBefore,
489
466
  newTier: recordAfter?.level ?? null,
490
- newTierName: recordAfter
491
- ? trustEngine.getLevelName(recordAfter.level)
492
- : null,
467
+ newTierName: recordAfter ? trustEngine.getLevelName(recordAfter.level) : null,
493
468
  };
494
469
  });
495
470
  // ================================================================
496
471
  // Governance routes
497
472
  // ================================================================
498
473
  // Evaluate governance request (with proof chain)
499
- api.post("/governance/evaluate", async (request, reply) => {
474
+ api.post('/governance/evaluate', async (request, reply) => {
500
475
  const body = request.body;
501
476
  if (!body.requestId || !body.entityId || !body.action) {
502
477
  return reply.status(400).send({
503
- error: {
504
- code: "INVALID_REQUEST",
505
- message: "Missing required fields: requestId, entityId, action",
506
- },
478
+ error: { code: 'INVALID_REQUEST', message: 'Missing required fields: requestId, entityId, action' },
507
479
  });
508
480
  }
509
481
  const startTime = Date.now();
@@ -513,7 +485,7 @@ export async function createServer(deps) {
513
485
  entityId: body.entityId,
514
486
  decision: result.decision,
515
487
  proofId,
516
- }, "Governance evaluation completed");
488
+ }, 'Governance evaluation completed');
517
489
  return {
518
490
  result,
519
491
  proofId,
@@ -521,96 +493,85 @@ export async function createServer(deps) {
521
493
  };
522
494
  });
523
495
  // Query governance rules
524
- api.get("/governance/rules", async (request) => {
496
+ api.get('/governance/rules', async (request) => {
525
497
  const rules = await governanceEngine.queryRules(request.query);
526
498
  return { rules, count: rules.length };
527
499
  });
528
500
  // Register governance rule
529
- api.post("/governance/rules", async (request, reply) => {
501
+ api.post('/governance/rules', async (request, reply) => {
530
502
  const rule = request.body;
531
503
  if (!rule.ruleId || !rule.name || !rule.condition || !rule.effect) {
532
504
  return reply.status(400).send({
533
- error: {
534
- code: "INVALID_REQUEST",
535
- message: "Missing required rule fields",
536
- },
505
+ error: { code: 'INVALID_REQUEST', message: 'Missing required rule fields' },
537
506
  });
538
507
  }
539
508
  governanceEngine.registerRule(rule);
540
- apiLogger.info({ ruleId: rule.ruleId, name: rule.name }, "Governance rule registered");
541
- return reply
542
- .status(201)
543
- .send({ registered: true, ruleId: rule.ruleId });
509
+ apiLogger.info({ ruleId: rule.ruleId, name: rule.name }, 'Governance rule registered');
510
+ return reply.status(201).send({ registered: true, ruleId: rule.ruleId });
544
511
  });
545
512
  // ================================================================
546
513
  // Boot Camp routes
547
514
  // ================================================================
548
515
  // Run boot camp for an agent
549
- api.post("/agents/:agentId/bootcamp", async (request, reply) => {
516
+ api.post('/agents/:agentId/bootcamp', async (request, reply) => {
550
517
  const { agentId } = request.params;
551
518
  const { tenantId } = request.body;
552
519
  if (!tenantId) {
553
520
  return reply.status(400).send({
554
- error: {
555
- code: "INVALID_REQUEST",
556
- message: "Missing required field: tenantId",
557
- },
521
+ error: { code: 'INVALID_REQUEST', message: 'Missing required field: tenantId' },
558
522
  });
559
523
  }
560
524
  // The agent must implement handleChallenge — for API usage,
561
525
  // this is a placeholder that indicates the boot camp needs
562
526
  // to be driven by the calling service with a real agent adapter.
563
527
  // For now, return the service configuration info.
564
- apiLogger.info({ agentId, tenantId }, "Boot camp requested");
528
+ apiLogger.info({ agentId, tenantId }, 'Boot camp requested');
565
529
  return reply.status(501).send({
566
530
  error: {
567
- code: "NOT_IMPLEMENTED",
568
- message: "Boot camp must be run programmatically via PromotionService. " +
569
- "Use the @vorionsys/atsf-core SDK to run boot camp with a BootCampAgent implementation.",
531
+ code: 'NOT_IMPLEMENTED',
532
+ message: 'Boot camp must be run programmatically via PromotionService. ' +
533
+ 'Use the @vorionsys/atsf-core SDK to run boot camp with a BootCampAgent implementation.',
570
534
  },
571
535
  hint: {
572
- sdk: "@vorionsys/atsf-core",
573
- import: "PromotionService",
574
- usage: "new PromotionService(trustEngine).runAndEvaluate(agent)",
536
+ sdk: '@vorionsys/atsf-core',
537
+ import: 'PromotionService',
538
+ usage: 'new PromotionService(trustEngine).runAndEvaluate(agent)',
575
539
  },
576
540
  });
577
541
  });
578
542
  // Constraint routes
579
- api.post("/constraints/validate", async (request, reply) => {
543
+ api.post('/constraints/validate', async (request, reply) => {
580
544
  const { entityId, intentType, context } = request.body;
581
545
  if (!entityId || !intentType) {
582
546
  return reply.status(400).send({
583
- error: {
584
- code: "INVALID_REQUEST",
585
- message: "Missing required fields",
586
- },
547
+ error: { code: 'INVALID_REQUEST', message: 'Missing required fields' },
587
548
  });
588
549
  }
589
550
  // Get entity trust record
590
551
  const trustRecord = await trustEngine.getScore(entityId);
591
552
  if (!trustRecord) {
592
553
  return reply.status(404).send({
593
- error: { code: "NOT_FOUND", message: "Entity not found" },
554
+ error: { code: 'NOT_FOUND', message: 'Entity not found' },
594
555
  });
595
556
  }
596
557
  // Create evaluation context
597
558
  const evalContext = {
598
559
  intent: {
599
- id: "validation-check",
560
+ id: 'validation-check',
600
561
  type: intentType,
601
- goal: "constraint-validation",
562
+ goal: 'constraint-validation',
602
563
  context: context ?? {},
603
564
  },
604
565
  entity: {
605
566
  id: entityId,
606
- type: "agent",
567
+ type: 'agent',
607
568
  trustScore: trustRecord.score,
608
569
  trustLevel: trustRecord.level,
609
570
  attributes: {},
610
571
  },
611
572
  environment: {
612
573
  timestamp: new Date().toISOString(),
613
- timezone: "UTC",
574
+ timezone: 'UTC',
614
575
  requestId: request.id,
615
576
  },
616
577
  custom: {},
@@ -636,11 +597,13 @@ export async function createServer(deps) {
636
597
  error: error.message,
637
598
  stack: error.stack,
638
599
  requestId: request.id,
639
- }, "Request error");
600
+ }, 'Request error');
640
601
  reply.status(error.statusCode ?? 500).send({
641
602
  error: {
642
- code: error.code ?? "INTERNAL_ERROR",
643
- message: config.env === "production" ? "An error occurred" : error.message,
603
+ code: error.code ?? 'INTERNAL_ERROR',
604
+ message: config.env === 'production'
605
+ ? 'An error occurred'
606
+ : error.message,
644
607
  },
645
608
  });
646
609
  });
@@ -661,10 +624,10 @@ export async function startServer() {
661
624
  port: config.api.port,
662
625
  host: config.api.host,
663
626
  environment: config.env,
664
- }, "Server started");
627
+ }, 'Server started');
665
628
  }
666
629
  catch (error) {
667
- apiLogger.error({ error }, "Failed to start server");
630
+ apiLogger.error({ error }, 'Failed to start server');
668
631
  process.exit(1);
669
632
  }
670
633
  }