@evomap/evolver 1.89.20 → 2.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/README.md +27 -564
  2. package/bin/evolver-llm-proxy.js +3 -0
  3. package/bin/evolver-mcp.js +2 -0
  4. package/bin/evolver-proxy.js +3 -0
  5. package/bin/evolver.js +4 -0
  6. package/index.js +1 -3586
  7. package/package.json +32 -62
  8. package/CONTRIBUTING.md +0 -19
  9. package/LICENSE +0 -641
  10. package/README.ja-JP.md +0 -521
  11. package/README.ko-KR.md +0 -520
  12. package/README.zh-CN.md +0 -531
  13. package/SKILL.md +0 -365
  14. package/assets/cover.png +0 -0
  15. package/assets/gep/genes.seed.json +0 -496
  16. package/conformance/savings-core/constants.json +0 -30
  17. package/conformance/savings-core/golden-vectors.json +0 -333
  18. package/scripts/a2a_export.js +0 -63
  19. package/scripts/a2a_ingest.js +0 -79
  20. package/scripts/a2a_promote.js +0 -118
  21. package/scripts/analyze_by_skill.js +0 -121
  22. package/scripts/build_binaries.js +0 -479
  23. package/scripts/check-changelog.js +0 -166
  24. package/scripts/extract_log.js +0 -85
  25. package/scripts/generate_history.js +0 -75
  26. package/scripts/gep_append_event.js +0 -96
  27. package/scripts/gep_personality_report.js +0 -234
  28. package/scripts/human_report.js +0 -147
  29. package/scripts/recall-verify-report.js +0 -234
  30. package/scripts/recover_loop.js +0 -61
  31. package/scripts/refresh_stars_badge.js +0 -168
  32. package/scripts/seed-merchants.js +0 -91
  33. package/scripts/skill2recipes.js +0 -118
  34. package/scripts/suggest_version.js +0 -89
  35. package/scripts/validate-modules.js +0 -38
  36. package/scripts/validate-suite.js +0 -78
  37. package/skills/_meta/SKILL.md +0 -41
  38. package/skills/index.json +0 -14
  39. package/src/adapters/claudeCode.js +0 -194
  40. package/src/adapters/codex.js +0 -216
  41. package/src/adapters/cursor.js +0 -91
  42. package/src/adapters/hookAdapter.js +0 -469
  43. package/src/adapters/kiro.js +0 -195
  44. package/src/adapters/opencode.js +0 -326
  45. package/src/adapters/scripts/_lockPaths.js +0 -74
  46. package/src/adapters/scripts/_memoryFiltering.js +0 -35
  47. package/src/adapters/scripts/_runtimePaths.js +0 -440
  48. package/src/adapters/scripts/evolver-session-end.js +0 -321
  49. package/src/adapters/scripts/evolver-session-start.js +0 -587
  50. package/src/adapters/scripts/evolver-signal-detect.js +0 -98
  51. package/src/adapters/scripts/evolver-task-recall.js +0 -173
  52. package/src/atp/atpExecute.js +0 -283
  53. package/src/atp/atpTaskPickup.js +0 -233
  54. package/src/atp/autoBuyer.js +0 -382
  55. package/src/atp/autoDeliver.js +0 -215
  56. package/src/atp/cli.js +0 -354
  57. package/src/atp/cliAutobuyPrompt.js +0 -154
  58. package/src/atp/consumerAgent.js +0 -157
  59. package/src/atp/defaultHandler.js +0 -69
  60. package/src/atp/heartbeatSignalsHandler.js +0 -254
  61. package/src/atp/hubClient.js +0 -317
  62. package/src/atp/index.js +0 -38
  63. package/src/atp/merchantAgent.js +0 -118
  64. package/src/atp/protocol.js +0 -41
  65. package/src/atp/questionComposer.js +0 -133
  66. package/src/atp/serviceHelper.js +0 -92
  67. package/src/canary.js +0 -13
  68. package/src/config.js +0 -351
  69. package/src/evolve/guards.js +0 -1
  70. package/src/evolve/pipeline/collect.js +0 -1
  71. package/src/evolve/pipeline/dispatch.js +0 -1
  72. package/src/evolve/pipeline/enrich.js +0 -1
  73. package/src/evolve/pipeline/hub.js +0 -1
  74. package/src/evolve/pipeline/select.js +0 -1
  75. package/src/evolve/pipeline/signals.js +0 -1
  76. package/src/evolve/utils.js +0 -1
  77. package/src/evolve.js +0 -1
  78. package/src/experiment/agentRunner.js +0 -229
  79. package/src/experiment/cli.js +0 -159
  80. package/src/experiment/comparison.js +0 -233
  81. package/src/experiment/metrics.js +0 -75
  82. package/src/forceUpdate.js +0 -991
  83. package/src/gep/a2a.js +0 -173
  84. package/src/gep/a2aProtocol.js +0 -1
  85. package/src/gep/analyzer.js +0 -35
  86. package/src/gep/antiAbuseTelemetry.js +0 -1
  87. package/src/gep/assetCallLog.js +0 -197
  88. package/src/gep/assetStore.js +0 -723
  89. package/src/gep/assets.js +0 -36
  90. package/src/gep/autoDistillConv.js +0 -1
  91. package/src/gep/autoDistillLlm.js +0 -1
  92. package/src/gep/bridge.js +0 -138
  93. package/src/gep/candidateEval.js +0 -1
  94. package/src/gep/candidates.js +0 -1
  95. package/src/gep/claimNudge.js +0 -121
  96. package/src/gep/cliContracts.js +0 -1190
  97. package/src/gep/contentHash.js +0 -1
  98. package/src/gep/conversationDistiller.js +0 -1
  99. package/src/gep/conversationSniffer.js +0 -1
  100. package/src/gep/crypto.js +0 -1
  101. package/src/gep/curriculum.js +0 -1
  102. package/src/gep/deviceId.js +0 -1
  103. package/src/gep/directoryClient.js +0 -115
  104. package/src/gep/envFingerprint.js +0 -1
  105. package/src/gep/epigenetics.js +0 -1
  106. package/src/gep/execBridge.js +0 -1
  107. package/src/gep/executionTrace.js +0 -291
  108. package/src/gep/explore.js +0 -1
  109. package/src/gep/featureFlags.js +0 -121
  110. package/src/gep/gitOps.js +0 -265
  111. package/src/gep/hash.js +0 -1
  112. package/src/gep/hostErrorClassifier.js +0 -34
  113. package/src/gep/hubFetch.js +0 -1
  114. package/src/gep/hubReview.js +0 -1
  115. package/src/gep/hubSearch.js +0 -1
  116. package/src/gep/hubVerify.js +0 -1
  117. package/src/gep/idleScheduler.js +0 -400
  118. package/src/gep/issueReporter.js +0 -416
  119. package/src/gep/learningSignals.js +0 -1
  120. package/src/gep/llmReview.js +0 -92
  121. package/src/gep/localStateAwareness.js +0 -243
  122. package/src/gep/mailboxTransport.js +0 -119
  123. package/src/gep/memoryGraph.js +0 -1
  124. package/src/gep/memoryGraphAdapter.js +0 -1
  125. package/src/gep/mutation.js +0 -1
  126. package/src/gep/narrativeMemory.js +0 -1
  127. package/src/gep/oauthLogin.js +0 -181
  128. package/src/gep/openPRRegistry.js +0 -1
  129. package/src/gep/paths.js +0 -522
  130. package/src/gep/personality.js +0 -1
  131. package/src/gep/policyCheck.js +0 -1
  132. package/src/gep/portable.js +0 -103
  133. package/src/gep/privacyClient.js +0 -235
  134. package/src/gep/prompt.js +0 -1
  135. package/src/gep/questionGenerator.js +0 -518
  136. package/src/gep/recallInject.js +0 -1
  137. package/src/gep/recallVerifier.js +0 -1
  138. package/src/gep/reflection.js +0 -1
  139. package/src/gep/sanitize.js +0 -264
  140. package/src/gep/savingsCore.js +0 -1
  141. package/src/gep/schemas/capsule.js +0 -170
  142. package/src/gep/schemas/gene.js +0 -154
  143. package/src/gep/schemas/index.js +0 -8
  144. package/src/gep/schemas/protocol.js +0 -51
  145. package/src/gep/schemas/task.js +0 -74
  146. package/src/gep/selector.js +0 -1
  147. package/src/gep/selfPR.js +0 -469
  148. package/src/gep/signals.js +0 -776
  149. package/src/gep/skill2gep.js +0 -1056
  150. package/src/gep/skill2gepAudit.js +0 -303
  151. package/src/gep/skill2recipes.js +0 -511
  152. package/src/gep/skillDistiller.js +0 -1
  153. package/src/gep/skillPublisher.js +0 -358
  154. package/src/gep/solidify.js +0 -1
  155. package/src/gep/strategy.js +0 -1
  156. package/src/gep/taskReceiver.js +0 -575
  157. package/src/gep/tokenSavings.js +0 -1
  158. package/src/gep/trajectoryExport.js +0 -1
  159. package/src/gep/validationReport.js +0 -55
  160. package/src/gep/validator/index.js +0 -411
  161. package/src/gep/validator/reporter.js +0 -210
  162. package/src/gep/validator/sandboxExecutor.js +0 -480
  163. package/src/gep/validator/stakeBootstrap.js +0 -357
  164. package/src/gep/workspaceKeychain.js +0 -1
  165. package/src/ops/cleanup.js +0 -80
  166. package/src/ops/commentary.js +0 -60
  167. package/src/ops/health_check.js +0 -104
  168. package/src/ops/index.js +0 -11
  169. package/src/ops/innovation.js +0 -67
  170. package/src/ops/lifecycle.js +0 -798
  171. package/src/ops/self_repair.js +0 -76
  172. package/src/ops/skills_monitor.js +0 -147
  173. package/src/ops/trigger.js +0 -33
  174. package/src/proxy/clientSettings.js +0 -405
  175. package/src/proxy/envelope.js +0 -59
  176. package/src/proxy/extensions/dmHandler.js +0 -45
  177. package/src/proxy/extensions/sessionHandler.js +0 -141
  178. package/src/proxy/extensions/skillUpdater.js +0 -64
  179. package/src/proxy/extensions/traceControl.js +0 -1
  180. package/src/proxy/index.js +0 -1395
  181. package/src/proxy/inject.js +0 -1
  182. package/src/proxy/lifecycle/manager.js +0 -1568
  183. package/src/proxy/mailbox/state.js +0 -207
  184. package/src/proxy/mailbox/store.js +0 -590
  185. package/src/proxy/router/cache_passthrough.js +0 -26
  186. package/src/proxy/router/features.js +0 -84
  187. package/src/proxy/router/gemini_route.js +0 -154
  188. package/src/proxy/router/messages_route.js +0 -535
  189. package/src/proxy/router/model_router.js +0 -113
  190. package/src/proxy/router/models_route.js +0 -52
  191. package/src/proxy/router/ollama_route.js +0 -103
  192. package/src/proxy/router/responses_route.js +0 -170
  193. package/src/proxy/router/vertex_route.js +0 -110
  194. package/src/proxy/server/http.js +0 -363
  195. package/src/proxy/server/routes.js +0 -558
  196. package/src/proxy/server/settings.js +0 -115
  197. package/src/proxy/sync/engine.js +0 -179
  198. package/src/proxy/sync/inbound.js +0 -211
  199. package/src/proxy/sync/outbound.js +0 -320
  200. package/src/proxy/task/monitor.js +0 -131
  201. package/src/proxy/trace/extractor.js +0 -1
  202. package/src/proxy/trace/usage.js +0 -1
  203. package/src/webui/client/clientJs/assets.js +0 -111
  204. package/src/webui/client/clientJs/bootstrap.js +0 -92
  205. package/src/webui/client/clientJs/common.js +0 -77
  206. package/src/webui/client/clientJs/i18n.js +0 -366
  207. package/src/webui/client/clientJs/index.js +0 -35
  208. package/src/webui/client/clientJs/interactions.js +0 -351
  209. package/src/webui/client/clientJs/overview.js +0 -152
  210. package/src/webui/client/clientJs/personality.js +0 -285
  211. package/src/webui/client/clientJs/pipelines.js +0 -330
  212. package/src/webui/client/indexHtml.js +0 -221
  213. package/src/webui/client/static.js +0 -23
  214. package/src/webui/client/stylesCss.js +0 -639
  215. package/src/webui/client/vendor/README.md +0 -15
  216. package/src/webui/client/vendor/echarts.min.js +0 -45
  217. package/src/webui/index.js +0 -14
  218. package/src/webui/observer/assets.js +0 -146
  219. package/src/webui/observer/index.js +0 -37
  220. package/src/webui/observer/interactions.js +0 -127
  221. package/src/webui/observer/jsonl.js +0 -75
  222. package/src/webui/observer/paths.js +0 -46
  223. package/src/webui/observer/personality.js +0 -43
  224. package/src/webui/observer/pipelineEvents.js +0 -58
  225. package/src/webui/observer/redact.js +0 -63
  226. package/src/webui/observer/runs.js +0 -356
  227. package/src/webui/observer/safety.js +0 -57
  228. package/src/webui/observer/skills.js +0 -70
  229. package/src/webui/observer/status.js +0 -71
  230. package/src/webui/server/http.js +0 -138
  231. package/src/webui/server/routes.js +0 -41
@@ -1,170 +0,0 @@
1
- 'use strict';
2
-
3
- // ---------------------------------------------------------------------------
4
- // Capsule Schema — single source of truth for the Capsule object shape.
5
- // All modules that create or consume Capsule objects should use
6
- // createCapsule() and validateCapsule() rather than assuming field presence.
7
- // ---------------------------------------------------------------------------
8
-
9
- const { SCHEMA_VERSION } = require('../contentHash');
10
-
11
- const VALID_OUTCOME_STATUSES = ['success', 'failed'];
12
- const VALID_SOURCE_TYPES = ['generated', 'reused', 'reference', 'user_authored'];
13
- const VALID_VISIBILITIES = ['private', 'unlisted', 'public'];
14
- const VALID_COST_TIERS = ['cheap', 'standard', 'premium'];
15
-
16
- const CAPSULE_DEFAULTS = {
17
- type: 'Capsule',
18
- id: null,
19
- schema_version: SCHEMA_VERSION,
20
- trigger: [],
21
- gene: null,
22
- summary: '',
23
- confidence: 0,
24
- blast_radius: { files: 0, lines: 0 },
25
- outcome: { status: 'failed', score: 0 },
26
- success_streak: 0,
27
- success_reason: null,
28
- gene_library_version: null,
29
- env_fingerprint: null,
30
- source_type: null,
31
- reused_asset_id: null,
32
- // Real measured token cost of deriving this capsule (input+output), captured
33
- // from the proxy trace meter at solidify time. null when the proxy was
34
- // inactive or usage was unobserved (consumers fall back to an estimate).
35
- // Shape: { input_tokens, output_tokens, total_tokens, basis:'measured' }.
36
- derivation_tokens: null,
37
- a2a: { eligible_to_broadcast: false },
38
- content: null,
39
- diff: null,
40
- strategy: [],
41
- execution_trace: [],
42
- asset_id: null,
43
- // Spec 1.8.0 §Appendix C user-authored fields. All default to null
44
- // so a generated capsule emits the same on-wire shape it always has;
45
- // /capsule save in evox sets these explicitly.
46
- visibility: null,
47
- scope: null,
48
- cost_tier: null,
49
- pack_of: null,
50
- author: null,
51
- };
52
-
53
- // createCapsule: merge partial with defaults and normalize array/object fields.
54
- // Safe to call with a fully-formed Capsule (idempotent).
55
- function createCapsule(partial) {
56
- const c = Object.assign({}, CAPSULE_DEFAULTS, partial);
57
-
58
- // Fresh array copies — never hold references to CAPSULE_DEFAULTS arrays.
59
- c.trigger = Array.isArray(c.trigger) ? c.trigger.slice() : [];
60
- c.strategy = Array.isArray(c.strategy) ? c.strategy.slice() : [];
61
- c.execution_trace = Array.isArray(c.execution_trace) ? c.execution_trace.slice() : [];
62
-
63
- // Normalize blast_radius
64
- if (!c.blast_radius || typeof c.blast_radius !== 'object') {
65
- c.blast_radius = { files: 0, lines: 0 };
66
- } else {
67
- c.blast_radius = Object.assign({ files: 0, lines: 0 }, c.blast_radius);
68
- }
69
-
70
- // Normalize outcome
71
- if (!c.outcome || typeof c.outcome !== 'object') {
72
- c.outcome = { status: 'failed', score: 0 };
73
- } else {
74
- c.outcome = Object.assign({ status: 'failed', score: 0 }, c.outcome);
75
- if (!VALID_OUTCOME_STATUSES.includes(c.outcome.status)) {
76
- c.outcome.status = 'failed';
77
- }
78
- }
79
-
80
- // Normalize a2a
81
- if (!c.a2a || typeof c.a2a !== 'object') {
82
- c.a2a = { eligible_to_broadcast: false };
83
- } else {
84
- c.a2a = Object.assign({ eligible_to_broadcast: false }, c.a2a);
85
- }
86
-
87
- // Normalize derivation_tokens (optional measured-cost object). Coerce a
88
- // malformed value to null so it never trips downstream schema validation.
89
- if (c.derivation_tokens != null) {
90
- const d = c.derivation_tokens;
91
- if (typeof d !== 'object' || Array.isArray(d)) {
92
- c.derivation_tokens = null;
93
- } else {
94
- const inp = Number(d.input_tokens);
95
- const out = Number(d.output_tokens);
96
- const tot = Number(d.total_tokens);
97
- const safeInp = Number.isFinite(inp) && inp >= 0 ? inp : 0;
98
- const safeOut = Number.isFinite(out) && out >= 0 ? out : 0;
99
- c.derivation_tokens = {
100
- input_tokens: safeInp,
101
- output_tokens: safeOut,
102
- total_tokens: Number.isFinite(tot) && tot >= 0 ? tot : safeInp + safeOut,
103
- basis: typeof d.basis === 'string' ? d.basis : 'measured',
104
- };
105
- }
106
- }
107
-
108
- // Normalize string fields
109
- if (typeof c.summary !== 'string') c.summary = '';
110
- if (typeof c.schema_version !== 'string') c.schema_version = SCHEMA_VERSION;
111
- if (typeof c.confidence !== 'number') c.confidence = 0;
112
-
113
- // Normalize spec 1.8.0 §Appendix C fields. Schema declares
114
- // additionalProperties:false so any unrecognized value here would
115
- // fail validation downstream — coerce malformed inputs to null
116
- // rather than letting them propagate.
117
- if (c.visibility != null && !VALID_VISIBILITIES.includes(c.visibility)) {
118
- c.visibility = null;
119
- }
120
- if (c.scope != null && !Array.isArray(c.scope)) {
121
- c.scope = null;
122
- } else if (Array.isArray(c.scope)) {
123
- c.scope = c.scope.slice();
124
- }
125
- if (c.cost_tier != null && !VALID_COST_TIERS.includes(c.cost_tier)) {
126
- c.cost_tier = null;
127
- }
128
- if (c.pack_of != null && !Array.isArray(c.pack_of)) {
129
- c.pack_of = null;
130
- } else if (Array.isArray(c.pack_of)) {
131
- c.pack_of = c.pack_of.slice();
132
- }
133
- // author: schema requires both `handle` and `evox_install_id` when
134
- // the field is present. A partial pair (e.g. handle without
135
- // install_id) would fail schema validation, so drop it.
136
- if (c.author != null) {
137
- if (typeof c.author !== 'object' || !c.author.handle || !c.author.evox_install_id) {
138
- c.author = null;
139
- } else {
140
- c.author = { handle: c.author.handle, evox_install_id: c.author.evox_install_id };
141
- }
142
- }
143
-
144
- return c;
145
- }
146
-
147
- // validateCapsule: throw if required fields are missing or malformed.
148
- // Use before broadcasting/publishing a Capsule to the Hub or writing to disk.
149
- function validateCapsule(c) {
150
- if (!c || typeof c !== 'object') throw new Error('Capsule must be an object');
151
- if (c.type !== 'Capsule') throw new Error('Capsule.type must be "Capsule", got: ' + c.type);
152
- if (!c.id || typeof c.id !== 'string') throw new Error('Capsule.id is required and must be a string');
153
- if (!c.outcome || typeof c.outcome !== 'object')
154
- throw new Error('Capsule.outcome must be an object');
155
- if (!VALID_OUTCOME_STATUSES.includes(c.outcome.status))
156
- throw new Error('Capsule.outcome.status must be one of: ' + VALID_OUTCOME_STATUSES.join(', ') + ', got: ' + c.outcome.status);
157
- if (!Array.isArray(c.trigger)) throw new Error('Capsule.trigger must be an array');
158
- if (!Array.isArray(c.execution_trace)) throw new Error('Capsule.execution_trace must be an array');
159
- return true;
160
- }
161
-
162
- module.exports = {
163
- createCapsule,
164
- validateCapsule,
165
- CAPSULE_DEFAULTS,
166
- VALID_OUTCOME_STATUSES,
167
- VALID_SOURCE_TYPES,
168
- VALID_VISIBILITIES,
169
- VALID_COST_TIERS,
170
- };
@@ -1,154 +0,0 @@
1
- 'use strict';
2
-
3
- // ---------------------------------------------------------------------------
4
- // Gene Schema — single source of truth for the Gene object shape.
5
- // All modules that create or consume Gene objects should use createGene() and
6
- // validateGene() rather than assuming field presence inline.
7
- // ---------------------------------------------------------------------------
8
-
9
- const VALID_CATEGORIES = ['repair', 'optimize', 'innovate', 'explore'];
10
-
11
- // EvoX agent-core enums consumed via the gene → router/tool-gate
12
- // pipeline (`crates/evox-evo-session/src/lifecycle.rs:345-388`). Keep
13
- // these strings exact — the Rust side does case-sensitive matching.
14
- const VALID_ROUTING_TIERS = ['cheap', 'mid', 'expensive'];
15
- const VALID_REASONING_LEVELS = ['off', 'low', 'medium', 'high'];
16
- const VALID_TOOL_POLICY_SEVERITIES = ['warn', 'block'];
17
-
18
- const GENE_DEFAULTS = {
19
- type: 'Gene',
20
- id: null,
21
- category: 'innovate',
22
- signals_match: [],
23
- strategy: [],
24
- validation: [],
25
- constraints: {
26
- max_files: 20,
27
- forbidden_paths: ['.git', 'node_modules'],
28
- },
29
- preconditions: [],
30
- summary: '',
31
- schema_version: '1.6.0',
32
- epigenetic_marks: [],
33
- learning_history: [],
34
- anti_patterns: [],
35
- // Optional EvoX-side hints. Null = "no opinion, let the router /
36
- // tool dispatcher take its historical fast path". Genes that
37
- // genuinely benefit from cheap-tier classification or restricted
38
- // tools opt in by setting these to a non-null object.
39
- routing_hint: null,
40
- tool_policy: null,
41
- };
42
-
43
- // createGene: merge partial with defaults and normalize array/object fields.
44
- // Safe to call with a fully-formed Gene (idempotent).
45
- function createGene(partial) {
46
- const g = Object.assign({}, GENE_DEFAULTS, partial);
47
-
48
- // Always create fresh array copies — never hold references to GENE_DEFAULTS arrays
49
- // or to partial's arrays, so downstream .push() calls cannot contaminate other genes.
50
- g.signals_match = Array.isArray(g.signals_match) ? g.signals_match.slice() : [];
51
- g.strategy = Array.isArray(g.strategy) ? g.strategy.slice() : [];
52
- g.validation = Array.isArray(g.validation) ? g.validation.slice() : [];
53
- g.preconditions = Array.isArray(g.preconditions) ? g.preconditions.slice() : [];
54
- g.epigenetic_marks = Array.isArray(g.epigenetic_marks) ? g.epigenetic_marks.slice() : [];
55
- g.learning_history = Array.isArray(g.learning_history) ? g.learning_history.slice() : [];
56
- g.anti_patterns = Array.isArray(g.anti_patterns) ? g.anti_patterns.slice() : [];
57
-
58
- // Normalize constraints
59
- if (!g.constraints || typeof g.constraints !== 'object') {
60
- g.constraints = Object.assign({}, GENE_DEFAULTS.constraints);
61
- } else {
62
- g.constraints = Object.assign({}, GENE_DEFAULTS.constraints, g.constraints);
63
- }
64
- if (!Array.isArray(g.constraints.forbidden_paths) || g.constraints.forbidden_paths.length === 0) {
65
- g.constraints.forbidden_paths = ['.git', 'node_modules'];
66
- } else {
67
- g.constraints.forbidden_paths = g.constraints.forbidden_paths.slice();
68
- }
69
- if (!g.constraints.max_files || typeof g.constraints.max_files !== 'number') {
70
- g.constraints.max_files = GENE_DEFAULTS.constraints.max_files;
71
- }
72
-
73
- // Normalize category
74
- if (!g.category || !VALID_CATEGORIES.includes(g.category)) {
75
- g.category = GENE_DEFAULTS.category;
76
- }
77
-
78
- // Normalize string fields
79
- if (typeof g.summary !== 'string') g.summary = '';
80
- if (typeof g.schema_version !== 'string') g.schema_version = GENE_DEFAULTS.schema_version;
81
-
82
- // Normalize optional routing_hint / tool_policy. The EvoX agent-core
83
- // side (`crates/evox-evo-session/src/lifecycle.rs`) treats absent
84
- // *or* empty hints as "no opinion" via `GeneRoutingHint::is_empty()`,
85
- // so dropping malformed fragments to `null` is the safer default —
86
- // a partial object would fail the strict tier-string match on the
87
- // Rust side and silently route as if no hint existed.
88
- g.routing_hint = normalizeRoutingHint(g.routing_hint);
89
- g.tool_policy = normalizeToolPolicy(g.tool_policy);
90
-
91
- return g;
92
- }
93
-
94
- function normalizeRoutingHint(raw) {
95
- if (!raw || typeof raw !== 'object') return null;
96
- const out = {};
97
- if (raw.tier && VALID_ROUTING_TIERS.includes(String(raw.tier))) {
98
- out.tier = String(raw.tier);
99
- }
100
- if (raw.reasoning_level && VALID_REASONING_LEVELS.includes(String(raw.reasoning_level))) {
101
- out.reasoning_level = String(raw.reasoning_level);
102
- }
103
- return Object.keys(out).length > 0 ? out : null;
104
- }
105
-
106
- function normalizeToolPolicy(raw) {
107
- if (!raw || typeof raw !== 'object') return null;
108
- const out = {};
109
- // Filter falsy entries first, then only keep the field if anything
110
- // survives. A raw input like { allow_only: ['', ''] } would otherwise
111
- // emit `allow_only: []` here; on the Rust executor gate
112
- // (`crates/evox-agent-core/src/types.rs::ToolGate`) an empty
113
- // `allow_only` means "allow zero tools" and blocks every tool call.
114
- if (Array.isArray(raw.allow_only)) {
115
- const cleaned = raw.allow_only.map(String).filter(Boolean);
116
- if (cleaned.length > 0) out.allow_only = cleaned;
117
- }
118
- if (Array.isArray(raw.deny)) {
119
- const cleaned = raw.deny.map(String).filter(Boolean);
120
- if (cleaned.length > 0) out.deny = cleaned;
121
- }
122
- // severity defaults to 'warn' when omitted but a list is present —
123
- // matches `GeneToolPolicy::default_severity()` on the Rust side.
124
- const hasList = !!(out.allow_only || out.deny);
125
- if (hasList) {
126
- out.severity = VALID_TOOL_POLICY_SEVERITIES.includes(String(raw.severity))
127
- ? String(raw.severity)
128
- : 'warn';
129
- }
130
- return hasList ? out : null;
131
- }
132
-
133
- // validateGene: throw if required fields are missing or malformed.
134
- // Use before broadcasting/publishing a Gene to the Hub or writing to disk.
135
- function validateGene(g) {
136
- if (!g || typeof g !== 'object') throw new Error('Gene must be an object');
137
- if (g.type !== 'Gene') throw new Error('Gene.type must be "Gene", got: ' + g.type);
138
- if (!g.id || typeof g.id !== 'string') throw new Error('Gene.id is required and must be a string');
139
- if (!VALID_CATEGORIES.includes(g.category))
140
- throw new Error('Gene.category must be one of: ' + VALID_CATEGORIES.join(', ') + ', got: ' + g.category);
141
- if (!Array.isArray(g.signals_match)) throw new Error('Gene.signals_match must be an array');
142
- if (!Array.isArray(g.strategy)) throw new Error('Gene.strategy must be an array');
143
- return true;
144
- }
145
-
146
- module.exports = {
147
- createGene,
148
- validateGene,
149
- GENE_DEFAULTS,
150
- VALID_CATEGORIES,
151
- VALID_ROUTING_TIERS,
152
- VALID_REASONING_LEVELS,
153
- VALID_TOOL_POLICY_SEVERITIES,
154
- };
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- const gene = require('./gene');
4
- const capsule = require('./capsule');
5
- const task = require('./task');
6
- const protocol = require('./protocol');
7
-
8
- module.exports = { ...gene, ...capsule, ...task, ...protocol };
@@ -1,51 +0,0 @@
1
- 'use strict';
2
-
3
- // ---------------------------------------------------------------------------
4
- // Protocol Schema — single source of truth for ALL string literal enums that
5
- // appear both in code (validation/normalization) and in the LLM prompt schema.
6
- //
7
- // Why this file exists: prior to 2026-05-16 the GEP prompt template (prompt.js)
8
- // hardcoded its own copies of category/intent/risk_level/outcome.status enums.
9
- // They drifted from src/gep/schemas/gene.js's VALID_CATEGORIES — when 'explore'
10
- // was added to the engine's whitelist, it was silently dropped from the LLM
11
- // prompt for months. v1.80.8 patched the literal; this module makes that class
12
- // of bug structurally impossible by routing every prompt enum through here.
13
- //
14
- // Rule: if a string literal enum is referenced both in JS validation code AND
15
- // in the prompt template, it MUST be defined here. NEVER duplicate it inline.
16
- // ---------------------------------------------------------------------------
17
-
18
- const {
19
- VALID_CATEGORIES,
20
- VALID_ROUTING_TIERS,
21
- VALID_REASONING_LEVELS,
22
- VALID_TOOL_POLICY_SEVERITIES,
23
- } = require('./gene');
24
- const { VALID_OUTCOME_STATUSES } = require('./capsule');
25
-
26
- const VALID_RISK_LEVELS = ['low', 'medium', 'high'];
27
- const VALID_TRACE_STAGES = ['build', 'validate', 'canary'];
28
-
29
- // renderEnum: format an enum array as a pipe-joined string for prompt schemas.
30
- // Example: ['repair', 'optimize', ...] -> 'repair|optimize|...'
31
- function renderEnum(arr) {
32
- return arr.join('|');
33
- }
34
-
35
- // renderEnumList: format an enum array as a quoted JSON-ish list for prompt schemas.
36
- // Example: ['build', 'validate', 'canary'] -> '"build","validate","canary"'
37
- function renderEnumList(arr) {
38
- return arr.map((s) => '"' + s + '"').join(',');
39
- }
40
-
41
- module.exports = {
42
- VALID_CATEGORIES,
43
- VALID_OUTCOME_STATUSES,
44
- VALID_RISK_LEVELS,
45
- VALID_TRACE_STAGES,
46
- VALID_ROUTING_TIERS,
47
- VALID_REASONING_LEVELS,
48
- VALID_TOOL_POLICY_SEVERITIES,
49
- renderEnum,
50
- renderEnumList,
51
- };
@@ -1,74 +0,0 @@
1
- 'use strict';
2
-
3
- // ---------------------------------------------------------------------------
4
- // Task Schema — single source of truth for the Task object shape.
5
- // Tasks are received from the Hub (not created locally), so createTask()
6
- // primarily normalizes fields for safe access. validateTask() guards the
7
- // pipeline entry points before any processing begins.
8
- // ---------------------------------------------------------------------------
9
-
10
- const VALID_TASK_STATUSES = ['open', 'claimed', 'completed', 'expired', 'cancelled'];
11
-
12
- const TASK_DEFAULTS = {
13
- type: 'Task',
14
- task_id: null,
15
- title: '',
16
- signals: '',
17
- status: 'open',
18
- claimed_by: null,
19
- bounty_id: null,
20
- bounty_amount: 0,
21
- complexity_score: null,
22
- historical_completion_rate: null,
23
- expires_at: null,
24
- body: '',
25
- description: '',
26
- nonce: null,
27
- validation_commands: [],
28
- result_asset_id: null,
29
- atp_order_id: null,
30
- _commitment_deadline: null,
31
- _worker_pending: false,
32
- };
33
-
34
- // createTask: normalize a Hub-received task object against known defaults.
35
- // Safe to call with a fully-formed Task (idempotent).
36
- function createTask(partial) {
37
- const t = Object.assign({}, TASK_DEFAULTS, partial);
38
-
39
- // Normalize validation_commands — the only array field
40
- t.validation_commands = Array.isArray(t.validation_commands)
41
- ? t.validation_commands.slice()
42
- : [];
43
-
44
- // Normalize string fields
45
- if (typeof t.title !== 'string') t.title = '';
46
- if (typeof t.signals !== 'string') t.signals = '';
47
- if (typeof t.body !== 'string') t.body = '';
48
- if (typeof t.description !== 'string') t.description = '';
49
-
50
- // Normalize numeric fields
51
- if (typeof t.bounty_amount !== 'number' || !isFinite(t.bounty_amount)) {
52
- t.bounty_amount = 0;
53
- }
54
-
55
- // Normalize status
56
- if (!VALID_TASK_STATUSES.includes(t.status)) {
57
- t.status = 'open';
58
- }
59
-
60
- return t;
61
- }
62
-
63
- // validateTask: throw if required fields are missing or malformed.
64
- // Use at pipeline entry points before processing or claiming a task.
65
- function validateTask(t) {
66
- if (!t || typeof t !== 'object') throw new Error('Task must be an object');
67
- if (!t.task_id || typeof t.task_id !== 'string')
68
- throw new Error('Task.task_id is required and must be a string');
69
- if (!VALID_TASK_STATUSES.includes(t.status))
70
- throw new Error('Task.status must be one of: ' + VALID_TASK_STATUSES.join(', ') + ', got: ' + t.status);
71
- return true;
72
- }
73
-
74
- module.exports = { createTask, validateTask, TASK_DEFAULTS, VALID_TASK_STATUSES };