comisai 1.0.10 → 1.0.12

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 (251) hide show
  1. package/README.md +3 -3
  2. package/node_modules/@comis/agent/dist/executor/pi-executor.d.ts +1 -4
  3. package/node_modules/@comis/agent/package.json +1 -1
  4. package/node_modules/@comis/channels/package.json +1 -1
  5. package/node_modules/@comis/cli/dist/wizard/steps/06-channels.js +88 -11
  6. package/node_modules/@comis/cli/dist/wizard/steps/10-write-config.js +4 -0
  7. package/node_modules/@comis/cli/dist/wizard/types.d.ts +1 -0
  8. package/node_modules/@comis/cli/package.json +1 -1
  9. package/node_modules/@comis/core/package.json +1 -1
  10. package/node_modules/@comis/daemon/package.json +1 -1
  11. package/node_modules/@comis/gateway/package.json +1 -1
  12. package/node_modules/@comis/infra/package.json +1 -1
  13. package/node_modules/@comis/memory/package.json +1 -1
  14. package/node_modules/@comis/scheduler/package.json +1 -1
  15. package/node_modules/@comis/shared/package.json +1 -1
  16. package/node_modules/@comis/skills/package.json +1 -1
  17. package/package.json +18 -18
  18. package/node_modules/@comis/core/dist/approval/approval-gate.test.d.ts +0 -1
  19. package/node_modules/@comis/core/dist/approval/approval-gate.test.js +0 -1003
  20. package/node_modules/@comis/core/dist/bootstrap.test.d.ts +0 -1
  21. package/node_modules/@comis/core/dist/bootstrap.test.js +0 -150
  22. package/node_modules/@comis/core/dist/config/backup.test.d.ts +0 -1
  23. package/node_modules/@comis/core/dist/config/backup.test.js +0 -160
  24. package/node_modules/@comis/core/dist/config/env-substitution.test.d.ts +0 -1
  25. package/node_modules/@comis/core/dist/config/env-substitution.test.js +0 -259
  26. package/node_modules/@comis/core/dist/config/field-metadata.test.d.ts +0 -1
  27. package/node_modules/@comis/core/dist/config/field-metadata.test.js +0 -72
  28. package/node_modules/@comis/core/dist/config/git-manager.test.d.ts +0 -1
  29. package/node_modules/@comis/core/dist/config/git-manager.test.js +0 -1042
  30. package/node_modules/@comis/core/dist/config/immutable-keys.test.d.ts +0 -1
  31. package/node_modules/@comis/core/dist/config/immutable-keys.test.js +0 -283
  32. package/node_modules/@comis/core/dist/config/include-resolver.test.d.ts +0 -1
  33. package/node_modules/@comis/core/dist/config/include-resolver.test.js +0 -292
  34. package/node_modules/@comis/core/dist/config/layered.test.d.ts +0 -1
  35. package/node_modules/@comis/core/dist/config/layered.test.js +0 -211
  36. package/node_modules/@comis/core/dist/config/loader.test.d.ts +0 -1
  37. package/node_modules/@comis/core/dist/config/loader.test.js +0 -300
  38. package/node_modules/@comis/core/dist/config/migrate.test.d.ts +0 -1
  39. package/node_modules/@comis/core/dist/config/migrate.test.js +0 -244
  40. package/node_modules/@comis/core/dist/config/partial-validator.test.d.ts +0 -1
  41. package/node_modules/@comis/core/dist/config/partial-validator.test.js +0 -98
  42. package/node_modules/@comis/core/dist/config/schema-agent-model.test.d.ts +0 -1
  43. package/node_modules/@comis/core/dist/config/schema-agent-model.test.js +0 -279
  44. package/node_modules/@comis/core/dist/config/schema-agent-session.test.d.ts +0 -1
  45. package/node_modules/@comis/core/dist/config/schema-agent-session.test.js +0 -242
  46. package/node_modules/@comis/core/dist/config/schema-agent.test.d.ts +0 -1
  47. package/node_modules/@comis/core/dist/config/schema-agent.test.js +0 -645
  48. package/node_modules/@comis/core/dist/config/schema-channel.test.d.ts +0 -1
  49. package/node_modules/@comis/core/dist/config/schema-channel.test.js +0 -341
  50. package/node_modules/@comis/core/dist/config/schema-coalescer.test.d.ts +0 -1
  51. package/node_modules/@comis/core/dist/config/schema-coalescer.test.js +0 -51
  52. package/node_modules/@comis/core/dist/config/schema-context-engine.test.d.ts +0 -1
  53. package/node_modules/@comis/core/dist/config/schema-context-engine.test.js +0 -797
  54. package/node_modules/@comis/core/dist/config/schema-context-guard.test.d.ts +0 -1
  55. package/node_modules/@comis/core/dist/config/schema-context-guard.test.js +0 -111
  56. package/node_modules/@comis/core/dist/config/schema-daemon.test.d.ts +0 -1
  57. package/node_modules/@comis/core/dist/config/schema-daemon.test.js +0 -107
  58. package/node_modules/@comis/core/dist/config/schema-delivery-timing.test.d.ts +0 -1
  59. package/node_modules/@comis/core/dist/config/schema-delivery-timing.test.js +0 -51
  60. package/node_modules/@comis/core/dist/config/schema-documentation.test.d.ts +0 -1
  61. package/node_modules/@comis/core/dist/config/schema-documentation.test.js +0 -63
  62. package/node_modules/@comis/core/dist/config/schema-gateway.test.d.ts +0 -1
  63. package/node_modules/@comis/core/dist/config/schema-gateway.test.js +0 -219
  64. package/node_modules/@comis/core/dist/config/schema-gemini-cache.test.d.ts +0 -1
  65. package/node_modules/@comis/core/dist/config/schema-gemini-cache.test.js +0 -41
  66. package/node_modules/@comis/core/dist/config/schema-integrations.test.d.ts +0 -1
  67. package/node_modules/@comis/core/dist/config/schema-integrations.test.js +0 -92
  68. package/node_modules/@comis/core/dist/config/schema-lifecycle-reactions.test.d.ts +0 -1
  69. package/node_modules/@comis/core/dist/config/schema-lifecycle-reactions.test.js +0 -61
  70. package/node_modules/@comis/core/dist/config/schema-misc.test.d.ts +0 -1
  71. package/node_modules/@comis/core/dist/config/schema-misc.test.js +0 -394
  72. package/node_modules/@comis/core/dist/config/schema-observability.test.d.ts +0 -1
  73. package/node_modules/@comis/core/dist/config/schema-observability.test.js +0 -76
  74. package/node_modules/@comis/core/dist/config/schema-providers.test.d.ts +0 -1
  75. package/node_modules/@comis/core/dist/config/schema-providers.test.js +0 -294
  76. package/node_modules/@comis/core/dist/config/schema-queue.test.d.ts +0 -1
  77. package/node_modules/@comis/core/dist/config/schema-queue.test.js +0 -234
  78. package/node_modules/@comis/core/dist/config/schema-response-prefix.test.d.ts +0 -1
  79. package/node_modules/@comis/core/dist/config/schema-response-prefix.test.js +0 -36
  80. package/node_modules/@comis/core/dist/config/schema-security.test.d.ts +0 -1
  81. package/node_modules/@comis/core/dist/config/schema-security.test.js +0 -54
  82. package/node_modules/@comis/core/dist/config/schema-sender-trust-display.test.d.ts +0 -1
  83. package/node_modules/@comis/core/dist/config/schema-sender-trust-display.test.js +0 -60
  84. package/node_modules/@comis/core/dist/config/schema-serializer.test.d.ts +0 -1
  85. package/node_modules/@comis/core/dist/config/schema-serializer.test.js +0 -73
  86. package/node_modules/@comis/core/dist/config/schema-telegram-file-guard.test.d.ts +0 -1
  87. package/node_modules/@comis/core/dist/config/schema-telegram-file-guard.test.js +0 -39
  88. package/node_modules/@comis/core/dist/context/context.test.d.ts +0 -1
  89. package/node_modules/@comis/core/dist/context/context.test.js +0 -276
  90. package/node_modules/@comis/core/dist/domain/agent-response.test.d.ts +0 -1
  91. package/node_modules/@comis/core/dist/domain/agent-response.test.js +0 -159
  92. package/node_modules/@comis/core/dist/domain/credential-mapping.test.d.ts +0 -1
  93. package/node_modules/@comis/core/dist/domain/credential-mapping.test.js +0 -135
  94. package/node_modules/@comis/core/dist/domain/delivery-origin.test.d.ts +0 -1
  95. package/node_modules/@comis/core/dist/domain/delivery-origin.test.js +0 -68
  96. package/node_modules/@comis/core/dist/domain/execution-graph.test.d.ts +0 -1
  97. package/node_modules/@comis/core/dist/domain/execution-graph.test.js +0 -441
  98. package/node_modules/@comis/core/dist/domain/memory-entry.test.d.ts +0 -1
  99. package/node_modules/@comis/core/dist/domain/memory-entry.test.js +0 -193
  100. package/node_modules/@comis/core/dist/domain/normalized-message.test.d.ts +0 -1
  101. package/node_modules/@comis/core/dist/domain/normalized-message.test.js +0 -255
  102. package/node_modules/@comis/core/dist/domain/session-key.test.d.ts +0 -1
  103. package/node_modules/@comis/core/dist/domain/session-key.test.js +0 -291
  104. package/node_modules/@comis/core/dist/domain/subagent-context-config.test.d.ts +0 -1
  105. package/node_modules/@comis/core/dist/domain/subagent-context-config.test.js +0 -131
  106. package/node_modules/@comis/core/dist/domain/subagent-context-types.test.d.ts +0 -1
  107. package/node_modules/@comis/core/dist/domain/subagent-context-types.test.js +0 -182
  108. package/node_modules/@comis/core/dist/event-bus/bus.test.d.ts +0 -1
  109. package/node_modules/@comis/core/dist/event-bus/bus.test.js +0 -152
  110. package/node_modules/@comis/core/dist/event-bus/events-agent.test.d.ts +0 -1
  111. package/node_modules/@comis/core/dist/event-bus/events-agent.test.js +0 -409
  112. package/node_modules/@comis/core/dist/event-bus/events-channel.test.d.ts +0 -1
  113. package/node_modules/@comis/core/dist/event-bus/events-channel.test.js +0 -240
  114. package/node_modules/@comis/core/dist/event-bus/events-infra.test.d.ts +0 -1
  115. package/node_modules/@comis/core/dist/event-bus/events-infra.test.js +0 -416
  116. package/node_modules/@comis/core/dist/event-bus/events-messaging.test.d.ts +0 -1
  117. package/node_modules/@comis/core/dist/event-bus/events-messaging.test.js +0 -433
  118. package/node_modules/@comis/core/dist/event-bus/events.test.d.ts +0 -1
  119. package/node_modules/@comis/core/dist/event-bus/events.test.js +0 -93
  120. package/node_modules/@comis/core/dist/hooks/hook-runner-global.test.d.ts +0 -1
  121. package/node_modules/@comis/core/dist/hooks/hook-runner-global.test.js +0 -29
  122. package/node_modules/@comis/core/dist/hooks/hook-runner.test.d.ts +0 -1
  123. package/node_modules/@comis/core/dist/hooks/hook-runner.test.js +0 -490
  124. package/node_modules/@comis/core/dist/hooks/hook-strategies.test.d.ts +0 -1
  125. package/node_modules/@comis/core/dist/hooks/hook-strategies.test.js +0 -209
  126. package/node_modules/@comis/core/dist/hooks/integration.test.d.ts +0 -1
  127. package/node_modules/@comis/core/dist/hooks/integration.test.js +0 -235
  128. package/node_modules/@comis/core/dist/hooks/plugin-registry.test.d.ts +0 -1
  129. package/node_modules/@comis/core/dist/hooks/plugin-registry.test.js +0 -470
  130. package/node_modules/@comis/core/dist/load-env.test.d.ts +0 -1
  131. package/node_modules/@comis/core/dist/load-env.test.js +0 -21
  132. package/node_modules/@comis/core/dist/security/action-classifier.test.d.ts +0 -1
  133. package/node_modules/@comis/core/dist/security/action-classifier.test.js +0 -298
  134. package/node_modules/@comis/core/dist/security/audit-aggregator.test.d.ts +0 -1
  135. package/node_modules/@comis/core/dist/security/audit-aggregator.test.js +0 -128
  136. package/node_modules/@comis/core/dist/security/audit.test.d.ts +0 -1
  137. package/node_modules/@comis/core/dist/security/audit.test.js +0 -154
  138. package/node_modules/@comis/core/dist/security/canary-token.test.d.ts +0 -1
  139. package/node_modules/@comis/core/dist/security/canary-token.test.js +0 -45
  140. package/node_modules/@comis/core/dist/security/config-redaction.test.d.ts +0 -1
  141. package/node_modules/@comis/core/dist/security/config-redaction.test.js +0 -107
  142. package/node_modules/@comis/core/dist/security/external-content.test.d.ts +0 -1
  143. package/node_modules/@comis/core/dist/security/external-content.test.js +0 -210
  144. package/node_modules/@comis/core/dist/security/injection-patterns.test.d.ts +0 -1
  145. package/node_modules/@comis/core/dist/security/injection-patterns.test.js +0 -213
  146. package/node_modules/@comis/core/dist/security/injection-rate-limiter.test.d.ts +0 -1
  147. package/node_modules/@comis/core/dist/security/injection-rate-limiter.test.js +0 -194
  148. package/node_modules/@comis/core/dist/security/input-guard.test.d.ts +0 -1
  149. package/node_modules/@comis/core/dist/security/input-guard.test.js +0 -215
  150. package/node_modules/@comis/core/dist/security/input-security-guard.test.d.ts +0 -1
  151. package/node_modules/@comis/core/dist/security/input-security-guard.test.js +0 -215
  152. package/node_modules/@comis/core/dist/security/input-validator.test.d.ts +0 -1
  153. package/node_modules/@comis/core/dist/security/input-validator.test.js +0 -133
  154. package/node_modules/@comis/core/dist/security/log-sanitizer.test.d.ts +0 -1
  155. package/node_modules/@comis/core/dist/security/log-sanitizer.test.js +0 -260
  156. package/node_modules/@comis/core/dist/security/memory-write-validator.test.d.ts +0 -1
  157. package/node_modules/@comis/core/dist/security/memory-write-validator.test.js +0 -62
  158. package/node_modules/@comis/core/dist/security/output-guard.test.d.ts +0 -1
  159. package/node_modules/@comis/core/dist/security/output-guard.test.js +0 -397
  160. package/node_modules/@comis/core/dist/security/safe-path.test.d.ts +0 -1
  161. package/node_modules/@comis/core/dist/security/safe-path.test.js +0 -95
  162. package/node_modules/@comis/core/dist/security/scoped-secret-manager.test.d.ts +0 -1
  163. package/node_modules/@comis/core/dist/security/scoped-secret-manager.test.js +0 -231
  164. package/node_modules/@comis/core/dist/security/secret-access.test.d.ts +0 -1
  165. package/node_modules/@comis/core/dist/security/secret-access.test.js +0 -41
  166. package/node_modules/@comis/core/dist/security/secret-crypto.test.d.ts +0 -1
  167. package/node_modules/@comis/core/dist/security/secret-crypto.test.js +0 -113
  168. package/node_modules/@comis/core/dist/security/secret-manager.test.d.ts +0 -1
  169. package/node_modules/@comis/core/dist/security/secret-manager.test.js +0 -394
  170. package/node_modules/@comis/core/dist/security/secret-ref-resolver.test.d.ts +0 -1
  171. package/node_modules/@comis/core/dist/security/secret-ref-resolver.test.js +0 -268
  172. package/node_modules/@comis/core/dist/security/secrets-audit.test.d.ts +0 -10
  173. package/node_modules/@comis/core/dist/security/secrets-audit.test.js +0 -295
  174. package/node_modules/@comis/core/dist/security/ssrf-guard.test.d.ts +0 -1
  175. package/node_modules/@comis/core/dist/security/ssrf-guard.test.js +0 -127
  176. package/node_modules/@comis/core/dist/security/token-generator.test.d.ts +0 -1
  177. package/node_modules/@comis/core/dist/security/token-generator.test.js +0 -35
  178. package/node_modules/@comis/core/dist/tool-metadata.test.d.ts +0 -1
  179. package/node_modules/@comis/core/dist/tool-metadata.test.js +0 -112
  180. package/node_modules/@comis/memory/dist/compaction.test.d.ts +0 -1
  181. package/node_modules/@comis/memory/dist/compaction.test.js +0 -298
  182. package/node_modules/@comis/memory/dist/context-schema.test.d.ts +0 -1
  183. package/node_modules/@comis/memory/dist/context-schema.test.js +0 -246
  184. package/node_modules/@comis/memory/dist/context-store.test.d.ts +0 -1
  185. package/node_modules/@comis/memory/dist/context-store.test.js +0 -708
  186. package/node_modules/@comis/memory/dist/credential-mapping-schema.test.d.ts +0 -7
  187. package/node_modules/@comis/memory/dist/credential-mapping-schema.test.js +0 -73
  188. package/node_modules/@comis/memory/dist/credential-mapping-store.test.d.ts +0 -8
  189. package/node_modules/@comis/memory/dist/credential-mapping-store.test.js +0 -340
  190. package/node_modules/@comis/memory/dist/delivery-mirror-adapter.test.d.ts +0 -1
  191. package/node_modules/@comis/memory/dist/delivery-mirror-adapter.test.js +0 -165
  192. package/node_modules/@comis/memory/dist/delivery-queue-adapter.test.d.ts +0 -1
  193. package/node_modules/@comis/memory/dist/delivery-queue-adapter.test.js +0 -263
  194. package/node_modules/@comis/memory/dist/embedding-batch-indexer.test.d.ts +0 -1
  195. package/node_modules/@comis/memory/dist/embedding-batch-indexer.test.js +0 -202
  196. package/node_modules/@comis/memory/dist/embedding-cache-lru.test.d.ts +0 -1
  197. package/node_modules/@comis/memory/dist/embedding-cache-lru.test.js +0 -241
  198. package/node_modules/@comis/memory/dist/embedding-cache-sqlite.test.d.ts +0 -8
  199. package/node_modules/@comis/memory/dist/embedding-cache-sqlite.test.js +0 -678
  200. package/node_modules/@comis/memory/dist/embedding-cache.test.d.ts +0 -1
  201. package/node_modules/@comis/memory/dist/embedding-cache.test.js +0 -213
  202. package/node_modules/@comis/memory/dist/embedding-fingerprint.test.d.ts +0 -1
  203. package/node_modules/@comis/memory/dist/embedding-fingerprint.test.js +0 -87
  204. package/node_modules/@comis/memory/dist/embedding-hash.test.d.ts +0 -1
  205. package/node_modules/@comis/memory/dist/embedding-hash.test.js +0 -31
  206. package/node_modules/@comis/memory/dist/embedding-integration.test.d.ts +0 -8
  207. package/node_modules/@comis/memory/dist/embedding-integration.test.js +0 -232
  208. package/node_modules/@comis/memory/dist/embedding-provider-factory.test.d.ts +0 -1
  209. package/node_modules/@comis/memory/dist/embedding-provider-factory.test.js +0 -176
  210. package/node_modules/@comis/memory/dist/embedding-provider-local.test.d.ts +0 -8
  211. package/node_modules/@comis/memory/dist/embedding-provider-local.test.js +0 -76
  212. package/node_modules/@comis/memory/dist/embedding-provider-openai.test.d.ts +0 -8
  213. package/node_modules/@comis/memory/dist/embedding-provider-openai.test.js +0 -100
  214. package/node_modules/@comis/memory/dist/embedding-queue.test.d.ts +0 -1
  215. package/node_modules/@comis/memory/dist/embedding-queue.test.js +0 -236
  216. package/node_modules/@comis/memory/dist/hybrid-search.test.d.ts +0 -1
  217. package/node_modules/@comis/memory/dist/hybrid-search.test.js +0 -476
  218. package/node_modules/@comis/memory/dist/identity-link-store.test.d.ts +0 -1
  219. package/node_modules/@comis/memory/dist/identity-link-store.test.js +0 -88
  220. package/node_modules/@comis/memory/dist/memory-api.test.d.ts +0 -1
  221. package/node_modules/@comis/memory/dist/memory-api.test.js +0 -495
  222. package/node_modules/@comis/memory/dist/memory-concurrency.test.d.ts +0 -20
  223. package/node_modules/@comis/memory/dist/memory-concurrency.test.js +0 -222
  224. package/node_modules/@comis/memory/dist/named-graph-store.test.d.ts +0 -1
  225. package/node_modules/@comis/memory/dist/named-graph-store.test.js +0 -227
  226. package/node_modules/@comis/memory/dist/observability-store.test.d.ts +0 -1
  227. package/node_modules/@comis/memory/dist/observability-store.test.js +0 -704
  228. package/node_modules/@comis/memory/dist/row-mapper.test.d.ts +0 -1
  229. package/node_modules/@comis/memory/dist/row-mapper.test.js +0 -409
  230. package/node_modules/@comis/memory/dist/schema.test.d.ts +0 -1
  231. package/node_modules/@comis/memory/dist/schema.test.js +0 -240
  232. package/node_modules/@comis/memory/dist/secret-store-schema.test.d.ts +0 -7
  233. package/node_modules/@comis/memory/dist/secret-store-schema.test.js +0 -90
  234. package/node_modules/@comis/memory/dist/session-store.test.d.ts +0 -1
  235. package/node_modules/@comis/memory/dist/session-store.test.js +0 -262
  236. package/node_modules/@comis/memory/dist/setup-secrets.test.d.ts +0 -1
  237. package/node_modules/@comis/memory/dist/setup-secrets.test.js +0 -140
  238. package/node_modules/@comis/memory/dist/sqlite-memory-adapter.test.d.ts +0 -1
  239. package/node_modules/@comis/memory/dist/sqlite-memory-adapter.test.js +0 -888
  240. package/node_modules/@comis/memory/dist/sqlite-secret-store.test.d.ts +0 -8
  241. package/node_modules/@comis/memory/dist/sqlite-secret-store.test.js +0 -245
  242. package/node_modules/@comis/shared/dist/abort.test.d.ts +0 -1
  243. package/node_modules/@comis/shared/dist/abort.test.js +0 -71
  244. package/node_modules/@comis/shared/dist/result.test.d.ts +0 -1
  245. package/node_modules/@comis/shared/dist/result.test.js +0 -178
  246. package/node_modules/@comis/shared/dist/suppress-error.test.d.ts +0 -1
  247. package/node_modules/@comis/shared/dist/suppress-error.test.js +0 -50
  248. package/node_modules/@comis/shared/dist/timeout.test.d.ts +0 -1
  249. package/node_modules/@comis/shared/dist/timeout.test.js +0 -75
  250. package/node_modules/@comis/shared/dist/ttl-cache.test.d.ts +0 -1
  251. package/node_modules/@comis/shared/dist/ttl-cache.test.js +0 -81
@@ -1,797 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import { ContextEngineConfigSchema } from "./schema-agent.js";
3
- // ---------------------------------------------------------------------------
4
- // ContextEngineConfigSchema
5
- // ---------------------------------------------------------------------------
6
- describe("ContextEngineConfigSchema", () => {
7
- // -------------------------------------------------------------------------
8
- // Core defaults
9
- // -------------------------------------------------------------------------
10
- it("produces valid defaults from empty object", () => {
11
- const result = ContextEngineConfigSchema.parse({});
12
- expect(result).toEqual({
13
- // Core
14
- enabled: true,
15
- version: "pipeline",
16
- // Shared
17
- thinkingKeepTurns: 10,
18
- compactionModel: "anthropic:claude-haiku-4-5-20250929",
19
- evictionMinAge: 15,
20
- // Pipeline
21
- historyTurns: 15,
22
- observationKeepWindow: 25,
23
- observationTriggerChars: 120_000,
24
- observationDeactivationChars: 80_000,
25
- ephemeralKeepWindow: 10,
26
- compactionCooldownTurns: 5,
27
- outputEscalation: { enabled: true, escalatedMaxTokens: 32_768 },
28
- // DAG
29
- freshTailTurns: 8,
30
- contextThreshold: 0.75,
31
- leafMinFanout: 8,
32
- condensedMinFanout: 4,
33
- condensedMinFanoutHard: 2,
34
- incrementalMaxDepth: 0,
35
- leafChunkTokens: 20_000,
36
- leafTargetTokens: 1_200,
37
- condensedTargetTokens: 2_000,
38
- maxExpandTokens: 4_000,
39
- maxRecallsPerDay: 10,
40
- recallTimeoutMs: 120_000,
41
- largeFileTokenThreshold: 25_000,
42
- annotationKeepWindow: 15,
43
- annotationTriggerChars: 200_000,
44
- });
45
- });
46
- it("accepts full override including DAG fields", () => {
47
- const result = ContextEngineConfigSchema.parse({
48
- enabled: false,
49
- version: "dag",
50
- thinkingKeepTurns: 5,
51
- compactionModel: "groq:llama-3.3-70b-versatile",
52
- evictionMinAge: 20,
53
- historyTurns: 20,
54
- historyTurnOverrides: { dm: 10, group: 5, "trader-1": 30 },
55
- observationKeepWindow: 30,
56
- observationTriggerChars: 300_000,
57
- observationDeactivationChars: 200_000,
58
- compactionCooldownTurns: 10,
59
- outputEscalation: { enabled: false, escalatedMaxTokens: 16_384 },
60
- freshTailTurns: 12,
61
- contextThreshold: 0.85,
62
- leafMinFanout: 10,
63
- condensedMinFanout: 6,
64
- condensedMinFanoutHard: 3,
65
- incrementalMaxDepth: 5,
66
- leafChunkTokens: 30_000,
67
- leafTargetTokens: 2_000,
68
- condensedTargetTokens: 3_000,
69
- maxExpandTokens: 8_000,
70
- maxRecallsPerDay: 20,
71
- recallTimeoutMs: 300_000,
72
- largeFileTokenThreshold: 50_000,
73
- annotationKeepWindow: 20,
74
- annotationTriggerChars: 400_000,
75
- summaryModel: "anthropic:claude-sonnet-4-5-20250929",
76
- summaryProvider: "anthropic",
77
- });
78
- expect(result).toEqual({
79
- enabled: false,
80
- version: "dag",
81
- thinkingKeepTurns: 5,
82
- compactionModel: "groq:llama-3.3-70b-versatile",
83
- evictionMinAge: 20,
84
- historyTurns: 20,
85
- historyTurnOverrides: { dm: 10, group: 5, "trader-1": 30 },
86
- observationKeepWindow: 30,
87
- observationTriggerChars: 300_000,
88
- observationDeactivationChars: 200_000,
89
- ephemeralKeepWindow: 10,
90
- compactionCooldownTurns: 10,
91
- outputEscalation: { enabled: false, escalatedMaxTokens: 16_384 },
92
- freshTailTurns: 12,
93
- contextThreshold: 0.85,
94
- leafMinFanout: 10,
95
- condensedMinFanout: 6,
96
- condensedMinFanoutHard: 3,
97
- incrementalMaxDepth: 5,
98
- leafChunkTokens: 30_000,
99
- leafTargetTokens: 2_000,
100
- condensedTargetTokens: 3_000,
101
- maxExpandTokens: 8_000,
102
- maxRecallsPerDay: 20,
103
- recallTimeoutMs: 300_000,
104
- largeFileTokenThreshold: 50_000,
105
- annotationKeepWindow: 20,
106
- annotationTriggerChars: 400_000,
107
- summaryModel: "anthropic:claude-sonnet-4-5-20250929",
108
- summaryProvider: "anthropic",
109
- });
110
- });
111
- it("rejects unknown keys (strictObject enforcement)", () => {
112
- const result = ContextEngineConfigSchema.safeParse({
113
- enabled: true,
114
- unknownField: "should be rejected",
115
- });
116
- expect(result.success).toBe(false);
117
- });
118
- // CACHE-01 regression: ensure no new required fields were added by Phase 407
119
- it("Phase 394 regression: empty object still valid (no new required fields)", () => {
120
- const result = ContextEngineConfigSchema.safeParse({});
121
- expect(result.success).toBe(true);
122
- });
123
- // -------------------------------------------------------------------------
124
- // version
125
- // -------------------------------------------------------------------------
126
- describe("version", () => {
127
- it("defaults to 'pipeline'", () => {
128
- const result = ContextEngineConfigSchema.parse({});
129
- expect(result.version).toBe("pipeline");
130
- });
131
- it("accepts 'pipeline'", () => {
132
- const result = ContextEngineConfigSchema.parse({ version: "pipeline" });
133
- expect(result.version).toBe("pipeline");
134
- });
135
- it("accepts 'dag'", () => {
136
- const result = ContextEngineConfigSchema.parse({ version: "dag" });
137
- expect(result.version).toBe("dag");
138
- });
139
- it("rejects unknown version string", () => {
140
- const result = ContextEngineConfigSchema.safeParse({ version: "unknown" });
141
- expect(result.success).toBe(false);
142
- });
143
- });
144
- // -------------------------------------------------------------------------
145
- // thinkingKeepTurns
146
- // -------------------------------------------------------------------------
147
- describe("thinkingKeepTurns", () => {
148
- it("defaults to 10", () => {
149
- const result = ContextEngineConfigSchema.parse({});
150
- expect(result.thinkingKeepTurns).toBe(10);
151
- });
152
- it("accepts boundary values (1 and 50)", () => {
153
- const min = ContextEngineConfigSchema.parse({ thinkingKeepTurns: 1 });
154
- expect(min.thinkingKeepTurns).toBe(1);
155
- const max = ContextEngineConfigSchema.parse({ thinkingKeepTurns: 50 });
156
- expect(max.thinkingKeepTurns).toBe(50);
157
- });
158
- it("rejects below minimum (0)", () => {
159
- const result = ContextEngineConfigSchema.safeParse({ thinkingKeepTurns: 0 });
160
- expect(result.success).toBe(false);
161
- });
162
- it("rejects above maximum (51)", () => {
163
- const result = ContextEngineConfigSchema.safeParse({ thinkingKeepTurns: 51 });
164
- expect(result.success).toBe(false);
165
- });
166
- it("rejects non-integer values", () => {
167
- const result = ContextEngineConfigSchema.safeParse({ thinkingKeepTurns: 5.5 });
168
- expect(result.success).toBe(false);
169
- });
170
- });
171
- // -------------------------------------------------------------------------
172
- // compactionModel (CFG-05)
173
- // -------------------------------------------------------------------------
174
- describe("compactionModel", () => {
175
- it("defaults to Haiku", () => {
176
- const result = ContextEngineConfigSchema.parse({});
177
- expect(result.compactionModel).toBe("anthropic:claude-haiku-4-5-20250929");
178
- });
179
- it("accepts a provider:modelId string", () => {
180
- const result = ContextEngineConfigSchema.parse({ compactionModel: "groq:llama-3.3-70b-versatile" });
181
- expect(result.compactionModel).toBe("groq:llama-3.3-70b-versatile");
182
- });
183
- it("accepts empty string (falsy fallback to session model)", () => {
184
- const result = ContextEngineConfigSchema.parse({ compactionModel: "" });
185
- expect(result.compactionModel).toBe("");
186
- });
187
- });
188
- // -------------------------------------------------------------------------
189
- // evictionMinAge
190
- // -------------------------------------------------------------------------
191
- describe("evictionMinAge", () => {
192
- it("defaults to 15 (user-locked, not design's 10)", () => {
193
- const result = ContextEngineConfigSchema.parse({});
194
- expect(result.evictionMinAge).toBe(15);
195
- });
196
- it("accepts boundary values (3 and 50)", () => {
197
- const min = ContextEngineConfigSchema.parse({ evictionMinAge: 3 });
198
- expect(min.evictionMinAge).toBe(3);
199
- const max = ContextEngineConfigSchema.parse({ evictionMinAge: 50 });
200
- expect(max.evictionMinAge).toBe(50);
201
- });
202
- it("rejects below minimum (2)", () => {
203
- const result = ContextEngineConfigSchema.safeParse({ evictionMinAge: 2 });
204
- expect(result.success).toBe(false);
205
- });
206
- it("rejects above maximum (51)", () => {
207
- const result = ContextEngineConfigSchema.safeParse({ evictionMinAge: 51 });
208
- expect(result.success).toBe(false);
209
- });
210
- it("rejects non-integer values", () => {
211
- const result = ContextEngineConfigSchema.safeParse({ evictionMinAge: 10.5 });
212
- expect(result.success).toBe(false);
213
- });
214
- });
215
- // -------------------------------------------------------------------------
216
- // historyTurns
217
- // -------------------------------------------------------------------------
218
- describe("historyTurns", () => {
219
- it("defaults to 15", () => {
220
- const result = ContextEngineConfigSchema.parse({});
221
- expect(result.historyTurns).toBe(15);
222
- });
223
- it("accepts valid int in range [3, 100]", () => {
224
- const low = ContextEngineConfigSchema.parse({ historyTurns: 3 });
225
- expect(low.historyTurns).toBe(3);
226
- const mid = ContextEngineConfigSchema.parse({ historyTurns: 50 });
227
- expect(mid.historyTurns).toBe(50);
228
- const high = ContextEngineConfigSchema.parse({ historyTurns: 100 });
229
- expect(high.historyTurns).toBe(100);
230
- });
231
- it("rejects values below 3", () => {
232
- const result = ContextEngineConfigSchema.safeParse({ historyTurns: 2 });
233
- expect(result.success).toBe(false);
234
- });
235
- it("rejects values above 100", () => {
236
- const result = ContextEngineConfigSchema.safeParse({ historyTurns: 101 });
237
- expect(result.success).toBe(false);
238
- });
239
- it("rejects non-integer values", () => {
240
- const result = ContextEngineConfigSchema.safeParse({ historyTurns: 10.5 });
241
- expect(result.success).toBe(false);
242
- });
243
- });
244
- // -------------------------------------------------------------------------
245
- // historyTurnOverrides
246
- // -------------------------------------------------------------------------
247
- describe("historyTurnOverrides", () => {
248
- it("accepts { dm: 10, group: 5 }", () => {
249
- const result = ContextEngineConfigSchema.parse({
250
- historyTurnOverrides: { dm: 10, group: 5 },
251
- });
252
- expect(result.historyTurnOverrides).toEqual({ dm: 10, group: 5 });
253
- });
254
- it("is optional (omission is valid)", () => {
255
- const result = ContextEngineConfigSchema.parse({});
256
- expect(result.historyTurnOverrides).toBeUndefined();
257
- });
258
- it("rejects override values below 1", () => {
259
- const result = ContextEngineConfigSchema.safeParse({
260
- historyTurnOverrides: { dm: 0 },
261
- });
262
- expect(result.success).toBe(false);
263
- });
264
- it("rejects override values above 100", () => {
265
- const result = ContextEngineConfigSchema.safeParse({
266
- historyTurnOverrides: { dm: 101 },
267
- });
268
- expect(result.success).toBe(false);
269
- });
270
- it("accepts per-agent overrides (Record<string, number>)", () => {
271
- const result = ContextEngineConfigSchema.parse({
272
- historyTurnOverrides: { "trader-1": 30, "trader-2": 25 },
273
- });
274
- expect(result.historyTurnOverrides).toEqual({ "trader-1": 30, "trader-2": 25 });
275
- });
276
- });
277
- // -------------------------------------------------------------------------
278
- // observationKeepWindow
279
- // -------------------------------------------------------------------------
280
- describe("observationKeepWindow", () => {
281
- it("defaults to 25 (updated from 15)", () => {
282
- const result = ContextEngineConfigSchema.parse({});
283
- expect(result.observationKeepWindow).toBe(25);
284
- });
285
- it("accepts custom override", () => {
286
- const result = ContextEngineConfigSchema.parse({ observationKeepWindow: 30 });
287
- expect(result.observationKeepWindow).toBe(30);
288
- });
289
- it("accepts boundary values (1 and 50)", () => {
290
- const min = ContextEngineConfigSchema.parse({ observationKeepWindow: 1 });
291
- expect(min.observationKeepWindow).toBe(1);
292
- const max = ContextEngineConfigSchema.parse({ observationKeepWindow: 50 });
293
- expect(max.observationKeepWindow).toBe(50);
294
- });
295
- it("rejects 0 (below minimum)", () => {
296
- const result = ContextEngineConfigSchema.safeParse({ observationKeepWindow: 0 });
297
- expect(result.success).toBe(false);
298
- });
299
- it("rejects 51 (above maximum)", () => {
300
- const result = ContextEngineConfigSchema.safeParse({ observationKeepWindow: 51 });
301
- expect(result.success).toBe(false);
302
- });
303
- });
304
- // -------------------------------------------------------------------------
305
- // observationTriggerChars
306
- // -------------------------------------------------------------------------
307
- describe("observationTriggerChars", () => {
308
- it("defaults to 120000 (updated from 200000)", () => {
309
- const result = ContextEngineConfigSchema.parse({});
310
- expect(result.observationTriggerChars).toBe(120_000);
311
- });
312
- it("accepts custom override", () => {
313
- const result = ContextEngineConfigSchema.parse({ observationTriggerChars: 500_000 });
314
- expect(result.observationTriggerChars).toBe(500_000);
315
- });
316
- it("accepts boundary values (50000 and 1000000)", () => {
317
- const min = ContextEngineConfigSchema.parse({ observationTriggerChars: 50_000 });
318
- expect(min.observationTriggerChars).toBe(50_000);
319
- const max = ContextEngineConfigSchema.parse({ observationTriggerChars: 1_000_000 });
320
- expect(max.observationTriggerChars).toBe(1_000_000);
321
- });
322
- it("rejects 49999 (below minimum)", () => {
323
- const result = ContextEngineConfigSchema.safeParse({ observationTriggerChars: 49_999 });
324
- expect(result.success).toBe(false);
325
- });
326
- it("rejects 1000001 (above maximum)", () => {
327
- const result = ContextEngineConfigSchema.safeParse({ observationTriggerChars: 1_000_001 });
328
- expect(result.success).toBe(false);
329
- });
330
- });
331
- // -------------------------------------------------------------------------
332
- // compactionCooldownTurns
333
- // -------------------------------------------------------------------------
334
- describe("compactionCooldownTurns", () => {
335
- it("defaults to 5", () => {
336
- const result = ContextEngineConfigSchema.parse({});
337
- expect(result.compactionCooldownTurns).toBe(5);
338
- });
339
- it("accepts custom override", () => {
340
- const result = ContextEngineConfigSchema.parse({ compactionCooldownTurns: 10 });
341
- expect(result.compactionCooldownTurns).toBe(10);
342
- });
343
- it("accepts boundary values (1 and 50)", () => {
344
- const min = ContextEngineConfigSchema.parse({ compactionCooldownTurns: 1 });
345
- expect(min.compactionCooldownTurns).toBe(1);
346
- const max = ContextEngineConfigSchema.parse({ compactionCooldownTurns: 50 });
347
- expect(max.compactionCooldownTurns).toBe(50);
348
- });
349
- it("rejects 0 (below minimum)", () => {
350
- const result = ContextEngineConfigSchema.safeParse({ compactionCooldownTurns: 0 });
351
- expect(result.success).toBe(false);
352
- });
353
- it("rejects 51 (above maximum)", () => {
354
- const result = ContextEngineConfigSchema.safeParse({ compactionCooldownTurns: 51 });
355
- expect(result.success).toBe(false);
356
- });
357
- it("rejects non-integer values", () => {
358
- const result = ContextEngineConfigSchema.safeParse({ compactionCooldownTurns: 3.5 });
359
- expect(result.success).toBe(false);
360
- });
361
- });
362
- // -------------------------------------------------------------------------
363
- // freshTailTurns (DAG)
364
- // -------------------------------------------------------------------------
365
- describe("freshTailTurns", () => {
366
- it("defaults to 8", () => {
367
- const result = ContextEngineConfigSchema.parse({});
368
- expect(result.freshTailTurns).toBe(8);
369
- });
370
- it("accepts boundary values (1 and 50)", () => {
371
- const min = ContextEngineConfigSchema.parse({ freshTailTurns: 1 });
372
- expect(min.freshTailTurns).toBe(1);
373
- const max = ContextEngineConfigSchema.parse({ freshTailTurns: 50 });
374
- expect(max.freshTailTurns).toBe(50);
375
- });
376
- it("rejects below minimum (0)", () => {
377
- const result = ContextEngineConfigSchema.safeParse({ freshTailTurns: 0 });
378
- expect(result.success).toBe(false);
379
- });
380
- it("rejects above maximum (51)", () => {
381
- const result = ContextEngineConfigSchema.safeParse({ freshTailTurns: 51 });
382
- expect(result.success).toBe(false);
383
- });
384
- });
385
- // -------------------------------------------------------------------------
386
- // contextThreshold (DAG)
387
- // -------------------------------------------------------------------------
388
- describe("contextThreshold", () => {
389
- it("defaults to 0.75", () => {
390
- const result = ContextEngineConfigSchema.parse({});
391
- expect(result.contextThreshold).toBe(0.75);
392
- });
393
- it("accepts boundary values (0.1 and 0.95)", () => {
394
- const min = ContextEngineConfigSchema.parse({ contextThreshold: 0.1 });
395
- expect(min.contextThreshold).toBe(0.1);
396
- const max = ContextEngineConfigSchema.parse({ contextThreshold: 0.95 });
397
- expect(max.contextThreshold).toBe(0.95);
398
- });
399
- it("rejects below minimum (0.09)", () => {
400
- const result = ContextEngineConfigSchema.safeParse({ contextThreshold: 0.09 });
401
- expect(result.success).toBe(false);
402
- });
403
- it("rejects above maximum (0.96)", () => {
404
- const result = ContextEngineConfigSchema.safeParse({ contextThreshold: 0.96 });
405
- expect(result.success).toBe(false);
406
- });
407
- });
408
- // -------------------------------------------------------------------------
409
- // leafMinFanout (DAG)
410
- // -------------------------------------------------------------------------
411
- describe("leafMinFanout", () => {
412
- it("defaults to 8", () => {
413
- const result = ContextEngineConfigSchema.parse({});
414
- expect(result.leafMinFanout).toBe(8);
415
- });
416
- it("accepts boundary values (2 and 20)", () => {
417
- const min = ContextEngineConfigSchema.parse({ leafMinFanout: 2 });
418
- expect(min.leafMinFanout).toBe(2);
419
- const max = ContextEngineConfigSchema.parse({ leafMinFanout: 20 });
420
- expect(max.leafMinFanout).toBe(20);
421
- });
422
- it("rejects below minimum (1)", () => {
423
- const result = ContextEngineConfigSchema.safeParse({ leafMinFanout: 1 });
424
- expect(result.success).toBe(false);
425
- });
426
- it("rejects above maximum (21)", () => {
427
- const result = ContextEngineConfigSchema.safeParse({ leafMinFanout: 21 });
428
- expect(result.success).toBe(false);
429
- });
430
- });
431
- // -------------------------------------------------------------------------
432
- // condensedMinFanout (DAG)
433
- // -------------------------------------------------------------------------
434
- describe("condensedMinFanout", () => {
435
- it("defaults to 4", () => {
436
- const result = ContextEngineConfigSchema.parse({});
437
- expect(result.condensedMinFanout).toBe(4);
438
- });
439
- it("accepts boundary values (2 and 20)", () => {
440
- const min = ContextEngineConfigSchema.parse({ condensedMinFanout: 2 });
441
- expect(min.condensedMinFanout).toBe(2);
442
- const max = ContextEngineConfigSchema.parse({ condensedMinFanout: 20 });
443
- expect(max.condensedMinFanout).toBe(20);
444
- });
445
- it("rejects below minimum (1)", () => {
446
- const result = ContextEngineConfigSchema.safeParse({ condensedMinFanout: 1 });
447
- expect(result.success).toBe(false);
448
- });
449
- it("rejects above maximum (21)", () => {
450
- const result = ContextEngineConfigSchema.safeParse({ condensedMinFanout: 21 });
451
- expect(result.success).toBe(false);
452
- });
453
- });
454
- // -------------------------------------------------------------------------
455
- // condensedMinFanoutHard (DAG)
456
- // -------------------------------------------------------------------------
457
- describe("condensedMinFanoutHard", () => {
458
- it("defaults to 2", () => {
459
- const result = ContextEngineConfigSchema.parse({});
460
- expect(result.condensedMinFanoutHard).toBe(2);
461
- });
462
- it("accepts boundary values (2 and 10)", () => {
463
- const min = ContextEngineConfigSchema.parse({ condensedMinFanoutHard: 2 });
464
- expect(min.condensedMinFanoutHard).toBe(2);
465
- const max = ContextEngineConfigSchema.parse({ condensedMinFanoutHard: 10 });
466
- expect(max.condensedMinFanoutHard).toBe(10);
467
- });
468
- it("rejects below minimum (1)", () => {
469
- const result = ContextEngineConfigSchema.safeParse({ condensedMinFanoutHard: 1 });
470
- expect(result.success).toBe(false);
471
- });
472
- it("rejects above maximum (11)", () => {
473
- const result = ContextEngineConfigSchema.safeParse({ condensedMinFanoutHard: 11 });
474
- expect(result.success).toBe(false);
475
- });
476
- });
477
- // -------------------------------------------------------------------------
478
- // incrementalMaxDepth (DAG)
479
- // -------------------------------------------------------------------------
480
- describe("incrementalMaxDepth", () => {
481
- it("defaults to 0", () => {
482
- const result = ContextEngineConfigSchema.parse({});
483
- expect(result.incrementalMaxDepth).toBe(0);
484
- });
485
- it("accepts boundary values (-1 and 10)", () => {
486
- const min = ContextEngineConfigSchema.parse({ incrementalMaxDepth: -1 });
487
- expect(min.incrementalMaxDepth).toBe(-1);
488
- const max = ContextEngineConfigSchema.parse({ incrementalMaxDepth: 10 });
489
- expect(max.incrementalMaxDepth).toBe(10);
490
- });
491
- it("rejects below minimum (-2)", () => {
492
- const result = ContextEngineConfigSchema.safeParse({ incrementalMaxDepth: -2 });
493
- expect(result.success).toBe(false);
494
- });
495
- it("rejects above maximum (11)", () => {
496
- const result = ContextEngineConfigSchema.safeParse({ incrementalMaxDepth: 11 });
497
- expect(result.success).toBe(false);
498
- });
499
- });
500
- // -------------------------------------------------------------------------
501
- // leafChunkTokens (DAG)
502
- // -------------------------------------------------------------------------
503
- describe("leafChunkTokens", () => {
504
- it("defaults to 20000", () => {
505
- const result = ContextEngineConfigSchema.parse({});
506
- expect(result.leafChunkTokens).toBe(20_000);
507
- });
508
- it("accepts boundary values (1000 and 100000)", () => {
509
- const min = ContextEngineConfigSchema.parse({ leafChunkTokens: 1000 });
510
- expect(min.leafChunkTokens).toBe(1000);
511
- const max = ContextEngineConfigSchema.parse({ leafChunkTokens: 100_000 });
512
- expect(max.leafChunkTokens).toBe(100_000);
513
- });
514
- it("rejects below minimum (999)", () => {
515
- const result = ContextEngineConfigSchema.safeParse({ leafChunkTokens: 999 });
516
- expect(result.success).toBe(false);
517
- });
518
- it("rejects above maximum (100001)", () => {
519
- const result = ContextEngineConfigSchema.safeParse({ leafChunkTokens: 100_001 });
520
- expect(result.success).toBe(false);
521
- });
522
- });
523
- // -------------------------------------------------------------------------
524
- // leafTargetTokens (DAG)
525
- // -------------------------------------------------------------------------
526
- describe("leafTargetTokens", () => {
527
- it("defaults to 1200", () => {
528
- const result = ContextEngineConfigSchema.parse({});
529
- expect(result.leafTargetTokens).toBe(1_200);
530
- });
531
- it("accepts boundary values (96 and 5000)", () => {
532
- const min = ContextEngineConfigSchema.parse({ leafTargetTokens: 96 });
533
- expect(min.leafTargetTokens).toBe(96);
534
- const max = ContextEngineConfigSchema.parse({ leafTargetTokens: 5_000 });
535
- expect(max.leafTargetTokens).toBe(5_000);
536
- });
537
- it("rejects below minimum (95)", () => {
538
- const result = ContextEngineConfigSchema.safeParse({ leafTargetTokens: 95 });
539
- expect(result.success).toBe(false);
540
- });
541
- it("rejects above maximum (5001)", () => {
542
- const result = ContextEngineConfigSchema.safeParse({ leafTargetTokens: 5_001 });
543
- expect(result.success).toBe(false);
544
- });
545
- });
546
- // -------------------------------------------------------------------------
547
- // condensedTargetTokens (DAG)
548
- // -------------------------------------------------------------------------
549
- describe("condensedTargetTokens", () => {
550
- it("defaults to 2000", () => {
551
- const result = ContextEngineConfigSchema.parse({});
552
- expect(result.condensedTargetTokens).toBe(2_000);
553
- });
554
- it("accepts boundary values (256 and 10000)", () => {
555
- const min = ContextEngineConfigSchema.parse({ condensedTargetTokens: 256 });
556
- expect(min.condensedTargetTokens).toBe(256);
557
- const max = ContextEngineConfigSchema.parse({ condensedTargetTokens: 10_000 });
558
- expect(max.condensedTargetTokens).toBe(10_000);
559
- });
560
- it("rejects below minimum (255)", () => {
561
- const result = ContextEngineConfigSchema.safeParse({ condensedTargetTokens: 255 });
562
- expect(result.success).toBe(false);
563
- });
564
- it("rejects above maximum (10001)", () => {
565
- const result = ContextEngineConfigSchema.safeParse({ condensedTargetTokens: 10_001 });
566
- expect(result.success).toBe(false);
567
- });
568
- });
569
- // -------------------------------------------------------------------------
570
- // maxExpandTokens (DAG)
571
- // -------------------------------------------------------------------------
572
- describe("maxExpandTokens", () => {
573
- it("defaults to 4000", () => {
574
- const result = ContextEngineConfigSchema.parse({});
575
- expect(result.maxExpandTokens).toBe(4_000);
576
- });
577
- it("accepts boundary values (500 and 50000)", () => {
578
- const min = ContextEngineConfigSchema.parse({ maxExpandTokens: 500 });
579
- expect(min.maxExpandTokens).toBe(500);
580
- const max = ContextEngineConfigSchema.parse({ maxExpandTokens: 50_000 });
581
- expect(max.maxExpandTokens).toBe(50_000);
582
- });
583
- it("rejects below minimum (499)", () => {
584
- const result = ContextEngineConfigSchema.safeParse({ maxExpandTokens: 499 });
585
- expect(result.success).toBe(false);
586
- });
587
- it("rejects above maximum (50001)", () => {
588
- const result = ContextEngineConfigSchema.safeParse({ maxExpandTokens: 50_001 });
589
- expect(result.success).toBe(false);
590
- });
591
- });
592
- // -------------------------------------------------------------------------
593
- // maxRecallsPerDay (DAG)
594
- // -------------------------------------------------------------------------
595
- describe("maxRecallsPerDay", () => {
596
- it("defaults to 10", () => {
597
- const result = ContextEngineConfigSchema.parse({});
598
- expect(result.maxRecallsPerDay).toBe(10);
599
- });
600
- it("accepts boundary values (1 and 100)", () => {
601
- const min = ContextEngineConfigSchema.parse({ maxRecallsPerDay: 1 });
602
- expect(min.maxRecallsPerDay).toBe(1);
603
- const max = ContextEngineConfigSchema.parse({ maxRecallsPerDay: 100 });
604
- expect(max.maxRecallsPerDay).toBe(100);
605
- });
606
- it("rejects below minimum (0)", () => {
607
- const result = ContextEngineConfigSchema.safeParse({ maxRecallsPerDay: 0 });
608
- expect(result.success).toBe(false);
609
- });
610
- it("rejects above maximum (101)", () => {
611
- const result = ContextEngineConfigSchema.safeParse({ maxRecallsPerDay: 101 });
612
- expect(result.success).toBe(false);
613
- });
614
- });
615
- // -------------------------------------------------------------------------
616
- // recallTimeoutMs (DAG)
617
- // -------------------------------------------------------------------------
618
- describe("recallTimeoutMs", () => {
619
- it("defaults to 120000", () => {
620
- const result = ContextEngineConfigSchema.parse({});
621
- expect(result.recallTimeoutMs).toBe(120_000);
622
- });
623
- it("accepts boundary values (10000 and 600000)", () => {
624
- const min = ContextEngineConfigSchema.parse({ recallTimeoutMs: 10_000 });
625
- expect(min.recallTimeoutMs).toBe(10_000);
626
- const max = ContextEngineConfigSchema.parse({ recallTimeoutMs: 600_000 });
627
- expect(max.recallTimeoutMs).toBe(600_000);
628
- });
629
- it("rejects below minimum (9999)", () => {
630
- const result = ContextEngineConfigSchema.safeParse({ recallTimeoutMs: 9_999 });
631
- expect(result.success).toBe(false);
632
- });
633
- it("rejects above maximum (600001)", () => {
634
- const result = ContextEngineConfigSchema.safeParse({ recallTimeoutMs: 600_001 });
635
- expect(result.success).toBe(false);
636
- });
637
- });
638
- // -------------------------------------------------------------------------
639
- // largeFileTokenThreshold (DAG)
640
- // -------------------------------------------------------------------------
641
- describe("largeFileTokenThreshold", () => {
642
- it("defaults to 25000", () => {
643
- const result = ContextEngineConfigSchema.parse({});
644
- expect(result.largeFileTokenThreshold).toBe(25_000);
645
- });
646
- it("accepts boundary values (1000 and 200000)", () => {
647
- const min = ContextEngineConfigSchema.parse({ largeFileTokenThreshold: 1000 });
648
- expect(min.largeFileTokenThreshold).toBe(1000);
649
- const max = ContextEngineConfigSchema.parse({ largeFileTokenThreshold: 200_000 });
650
- expect(max.largeFileTokenThreshold).toBe(200_000);
651
- });
652
- it("rejects below minimum (999)", () => {
653
- const result = ContextEngineConfigSchema.safeParse({ largeFileTokenThreshold: 999 });
654
- expect(result.success).toBe(false);
655
- });
656
- it("rejects above maximum (200001)", () => {
657
- const result = ContextEngineConfigSchema.safeParse({ largeFileTokenThreshold: 200_001 });
658
- expect(result.success).toBe(false);
659
- });
660
- });
661
- // -------------------------------------------------------------------------
662
- // annotationKeepWindow (DAG)
663
- // -------------------------------------------------------------------------
664
- describe("annotationKeepWindow", () => {
665
- it("defaults to 15", () => {
666
- const result = ContextEngineConfigSchema.parse({});
667
- expect(result.annotationKeepWindow).toBe(15);
668
- });
669
- it("accepts boundary values (1 and 50)", () => {
670
- const min = ContextEngineConfigSchema.parse({ annotationKeepWindow: 1 });
671
- expect(min.annotationKeepWindow).toBe(1);
672
- const max = ContextEngineConfigSchema.parse({ annotationKeepWindow: 50 });
673
- expect(max.annotationKeepWindow).toBe(50);
674
- });
675
- it("rejects below minimum (0)", () => {
676
- const result = ContextEngineConfigSchema.safeParse({ annotationKeepWindow: 0 });
677
- expect(result.success).toBe(false);
678
- });
679
- it("rejects above maximum (51)", () => {
680
- const result = ContextEngineConfigSchema.safeParse({ annotationKeepWindow: 51 });
681
- expect(result.success).toBe(false);
682
- });
683
- });
684
- // -------------------------------------------------------------------------
685
- // annotationTriggerChars (DAG)
686
- // -------------------------------------------------------------------------
687
- describe("annotationTriggerChars", () => {
688
- it("defaults to 200000", () => {
689
- const result = ContextEngineConfigSchema.parse({});
690
- expect(result.annotationTriggerChars).toBe(200_000);
691
- });
692
- it("accepts boundary values (10000 and 1000000)", () => {
693
- const min = ContextEngineConfigSchema.parse({ annotationTriggerChars: 10_000 });
694
- expect(min.annotationTriggerChars).toBe(10_000);
695
- const max = ContextEngineConfigSchema.parse({ annotationTriggerChars: 1_000_000 });
696
- expect(max.annotationTriggerChars).toBe(1_000_000);
697
- });
698
- it("rejects below minimum (9999)", () => {
699
- const result = ContextEngineConfigSchema.safeParse({ annotationTriggerChars: 9_999 });
700
- expect(result.success).toBe(false);
701
- });
702
- it("rejects above maximum (1000001)", () => {
703
- const result = ContextEngineConfigSchema.safeParse({ annotationTriggerChars: 1_000_001 });
704
- expect(result.success).toBe(false);
705
- });
706
- });
707
- // -------------------------------------------------------------------------
708
- // summaryModel and summaryProvider (DAG optional)
709
- // -------------------------------------------------------------------------
710
- // -------------------------------------------------------------------------
711
- // outputEscalation (CTX-04/CTX-08)
712
- // -------------------------------------------------------------------------
713
- describe("outputEscalation", () => {
714
- it("defaults to { enabled: true, escalatedMaxTokens: 32768 }", () => {
715
- const result = ContextEngineConfigSchema.parse({});
716
- expect(result.outputEscalation).toEqual({
717
- enabled: true,
718
- escalatedMaxTokens: 32_768,
719
- });
720
- });
721
- it("accepts custom override", () => {
722
- const result = ContextEngineConfigSchema.parse({
723
- outputEscalation: { enabled: false, escalatedMaxTokens: 16_384 },
724
- });
725
- expect(result.outputEscalation).toEqual({
726
- enabled: false,
727
- escalatedMaxTokens: 16_384,
728
- });
729
- });
730
- it("accepts partial override (defaults fill in)", () => {
731
- const result = ContextEngineConfigSchema.parse({
732
- outputEscalation: { enabled: false },
733
- });
734
- expect(result.outputEscalation).toEqual({
735
- enabled: false,
736
- escalatedMaxTokens: 32_768,
737
- });
738
- });
739
- it("accepts boundary values for escalatedMaxTokens (4096 and 128000)", () => {
740
- const min = ContextEngineConfigSchema.parse({
741
- outputEscalation: { escalatedMaxTokens: 4096 },
742
- });
743
- expect(min.outputEscalation.escalatedMaxTokens).toBe(4096);
744
- const max = ContextEngineConfigSchema.parse({
745
- outputEscalation: { escalatedMaxTokens: 128_000 },
746
- });
747
- expect(max.outputEscalation.escalatedMaxTokens).toBe(128_000);
748
- });
749
- it("rejects escalatedMaxTokens below minimum (4095)", () => {
750
- const result = ContextEngineConfigSchema.safeParse({
751
- outputEscalation: { escalatedMaxTokens: 4095 },
752
- });
753
- expect(result.success).toBe(false);
754
- });
755
- it("rejects escalatedMaxTokens above maximum (128001)", () => {
756
- const result = ContextEngineConfigSchema.safeParse({
757
- outputEscalation: { escalatedMaxTokens: 128_001 },
758
- });
759
- expect(result.success).toBe(false);
760
- });
761
- it("rejects non-integer escalatedMaxTokens", () => {
762
- const result = ContextEngineConfigSchema.safeParse({
763
- outputEscalation: { escalatedMaxTokens: 8192.5 },
764
- });
765
- expect(result.success).toBe(false);
766
- });
767
- it("rejects unknown keys inside outputEscalation (strictObject)", () => {
768
- const result = ContextEngineConfigSchema.safeParse({
769
- outputEscalation: { enabled: true, unknownField: "bad" },
770
- });
771
- expect(result.success).toBe(false);
772
- });
773
- });
774
- // -------------------------------------------------------------------------
775
- // summaryModel and summaryProvider (DAG optional)
776
- // -------------------------------------------------------------------------
777
- describe("summaryModel", () => {
778
- it("is optional (omission valid)", () => {
779
- const result = ContextEngineConfigSchema.parse({});
780
- expect(result.summaryModel).toBeUndefined();
781
- });
782
- it("accepts a string value", () => {
783
- const result = ContextEngineConfigSchema.parse({ summaryModel: "anthropic:claude-sonnet-4-5-20250929" });
784
- expect(result.summaryModel).toBe("anthropic:claude-sonnet-4-5-20250929");
785
- });
786
- });
787
- describe("summaryProvider", () => {
788
- it("is optional (omission valid)", () => {
789
- const result = ContextEngineConfigSchema.parse({});
790
- expect(result.summaryProvider).toBeUndefined();
791
- });
792
- it("accepts a string value", () => {
793
- const result = ContextEngineConfigSchema.parse({ summaryProvider: "anthropic" });
794
- expect(result.summaryProvider).toBe("anthropic");
795
- });
796
- });
797
- });