@evomap/evolver-core 2.0.0-beta.19 → 2.0.0-beta.22

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 (160) hide show
  1. package/assets/gep/genes.jsonl +5 -5
  2. package/dist/algo/bans.d.ts +10 -1
  3. package/dist/algo/bans.js +56 -6
  4. package/dist/algo/candidateAssembly.d.ts +25 -2
  5. package/dist/algo/candidateAssembly.js +143 -20
  6. package/dist/algo/capabilityCandidates.js +10 -0
  7. package/dist/algo/cycleEngine.d.ts +40 -5
  8. package/dist/algo/cycleEngine.js +277 -37
  9. package/dist/algo/evolutionEvent.d.ts +26 -0
  10. package/dist/algo/evolutionEvent.js +32 -0
  11. package/dist/algo/exploration.d.ts +7 -0
  12. package/dist/algo/exploration.js +16 -3
  13. package/dist/algo/geneHealth.d.ts +34 -1
  14. package/dist/algo/geneHealth.js +42 -0
  15. package/dist/algo/geneIntake.d.ts +46 -1
  16. package/dist/algo/geneIntake.js +121 -10
  17. package/dist/algo/geneSelection.d.ts +115 -6
  18. package/dist/algo/geneSelection.js +459 -32
  19. package/dist/algo/index.d.ts +4 -1
  20. package/dist/algo/index.js +4 -1
  21. package/dist/algo/kautoProjection.d.ts +41 -0
  22. package/dist/algo/kautoProjection.js +95 -0
  23. package/dist/algo/kautoValidator.d.ts +68 -0
  24. package/dist/algo/kautoValidator.js +256 -0
  25. package/dist/algo/orchestrator.d.ts +14 -1
  26. package/dist/algo/orchestrator.js +9 -2
  27. package/dist/algo/solidify.d.ts +11 -2
  28. package/dist/algo/solidify.js +37 -7
  29. package/dist/algo/ucb1.d.ts +53 -0
  30. package/dist/algo/ucb1.js +156 -0
  31. package/dist/assetrepair/hubRejection.d.ts +12 -0
  32. package/dist/assetrepair/hubRejection.js +109 -0
  33. package/dist/assetrepair/index.d.ts +2 -0
  34. package/dist/assetrepair/index.js +2 -0
  35. package/dist/assetrepair/repair.d.ts +33 -0
  36. package/dist/assetrepair/repair.js +155 -0
  37. package/dist/assetstore/assetSidecarRecords.js +5 -1
  38. package/dist/assetstore/assetStoreHealth.d.ts +2 -3
  39. package/dist/assetstore/assetStoreHealth.js +4 -10
  40. package/dist/assetstore/foreignJsonlSource.d.ts +48 -0
  41. package/dist/assetstore/foreignJsonlSource.js +150 -0
  42. package/dist/assetstore/index.d.ts +3 -0
  43. package/dist/assetstore/index.js +3 -0
  44. package/dist/assetstore/learningHistory.js +3 -3
  45. package/dist/assetstore/localAssetStoreSnapshot.d.ts +51 -0
  46. package/dist/assetstore/localAssetStoreSnapshot.js +329 -0
  47. package/dist/assetstore/localJsonl.d.ts +8 -0
  48. package/dist/assetstore/localJsonl.js +128 -3
  49. package/dist/assetstore/provenance.d.ts +38 -3
  50. package/dist/assetstore/provenance.js +103 -45
  51. package/dist/assetstore/provider.d.ts +4 -0
  52. package/dist/assetstore/reviewFilter.d.ts +19 -1
  53. package/dist/assetstore/reviewFilter.js +36 -0
  54. package/dist/assetstore/unionReadStore.d.ts +25 -0
  55. package/dist/assetstore/unionReadStore.js +119 -0
  56. package/dist/benchmark/antiGeneBenchmark.d.ts +2 -0
  57. package/dist/benchmark/antiGeneBenchmark.js +4 -3
  58. package/dist/benchmark/antiGeneRollout.d.ts +2 -0
  59. package/dist/benchmark/antiGeneRollout.js +4 -3
  60. package/dist/benchmark/index.d.ts +2 -1
  61. package/dist/benchmark/index.js +2 -1
  62. package/dist/benchmark/selectionFlatAbstention.d.ts +152 -0
  63. package/dist/benchmark/selectionFlatAbstention.js +481 -0
  64. package/dist/bootstrap/envFingerprint.d.ts +9 -0
  65. package/dist/bootstrap/envFingerprint.js +5 -0
  66. package/dist/bootstrap/index.d.ts +2 -1
  67. package/dist/bootstrap/index.js +2 -1
  68. package/dist/bootstrap/lifecycleBootstrap.d.ts +111 -0
  69. package/dist/bootstrap/lifecycleBootstrap.js +433 -0
  70. package/dist/bootstrap/v1EnvCompat.d.ts +3 -0
  71. package/dist/bootstrap/v1EnvCompat.js +48 -1
  72. package/dist/events/eventArchive.d.ts +2 -0
  73. package/dist/events/eventArchive.js +13 -3
  74. package/dist/events/eventSchema.d.ts +7 -7
  75. package/dist/events/eventStore.d.ts +2 -0
  76. package/dist/events/eventStore.js +5 -1
  77. package/dist/events/ingest.d.ts +2 -1
  78. package/dist/events/ingest.js +6 -0
  79. package/dist/exec/autoExec.d.ts +30 -3
  80. package/dist/exec/autoExec.js +294 -29
  81. package/dist/exec/autonomousCycle.d.ts +7 -0
  82. package/dist/exec/autonomousCycle.js +2 -0
  83. package/dist/exec/claudeBridge.d.ts +28 -6
  84. package/dist/exec/claudeBridge.js +411 -258
  85. package/dist/exec/executionBinding.d.ts +414 -0
  86. package/dist/exec/executionBinding.js +588 -0
  87. package/dist/exec/index.d.ts +1 -0
  88. package/dist/exec/index.js +1 -0
  89. package/dist/exec/proofOfWork.d.ts +1 -1
  90. package/dist/exec/proofOfWork.js +2 -2
  91. package/dist/exec/runnerRegistry.d.ts +5 -0
  92. package/dist/exec/runnerRegistry.js +54 -14
  93. package/dist/hub/capability.d.ts +40 -1
  94. package/dist/hub/conversationDistiller.d.ts +19 -0
  95. package/dist/hub/conversationDistiller.js +115 -37
  96. package/dist/hub/fake.d.ts +1 -0
  97. package/dist/hub/fake.js +1 -0
  98. package/dist/hub/index.d.ts +1 -0
  99. package/dist/hub/index.js +1 -0
  100. package/dist/hub/recipeCompose.d.ts +27 -0
  101. package/dist/hub/recipeCompose.js +90 -0
  102. package/dist/hub/sanitize.js +119 -5
  103. package/dist/index.d.ts +2 -0
  104. package/dist/index.js +2 -0
  105. package/dist/mailbox/ipcServer.d.ts +2 -0
  106. package/dist/mailbox/ipcServer.js +20 -0
  107. package/dist/mailbox/store.d.ts +52 -2
  108. package/dist/mailbox/store.js +546 -81
  109. package/dist/modelCompatibility.d.ts +164 -0
  110. package/dist/modelCompatibility.js +309 -0
  111. package/dist/observers/valueDigestObserver.d.ts +9 -0
  112. package/dist/observers/valueDigestObserver.js +35 -2
  113. package/dist/ops/cleanup.js +1 -1
  114. package/dist/ops/evolutionGraphProjection.d.ts +20 -0
  115. package/dist/ops/evolutionGraphProjection.js +315 -0
  116. package/dist/ops/index.d.ts +2 -1
  117. package/dist/ops/index.js +2 -1
  118. package/dist/ops/selfUpdate.d.ts +8 -0
  119. package/dist/ops/selfUpdate.js +24 -8
  120. package/dist/ops/valueOutreach.d.ts +3 -1
  121. package/dist/ops/valueOutreach.js +5 -1
  122. package/dist/personality/schema.d.ts +18 -18
  123. package/dist/schema/evolutionGraph.d.ts +784 -0
  124. package/dist/schema/evolutionGraph.js +187 -0
  125. package/dist/schema/index.d.ts +1 -0
  126. package/dist/schema/index.js +1 -0
  127. package/dist/schema/proofOfWork.d.ts +125 -6
  128. package/dist/schema/proofOfWork.js +102 -4
  129. package/dist/shadow/shadowHub.js +1 -0
  130. package/dist/signals/expand.d.ts +15 -1
  131. package/dist/signals/expand.js +148 -0
  132. package/dist/signals/index.d.ts +3 -1
  133. package/dist/signals/index.js +3 -1
  134. package/dist/signals/scopeVocabulary.d.ts +75 -0
  135. package/dist/signals/scopeVocabulary.js +91 -0
  136. package/dist/signals/taskDomain.d.ts +22 -0
  137. package/dist/signals/taskDomain.js +43 -0
  138. package/dist/trace/learningTrace.d.ts +7 -0
  139. package/dist/trace/learningTrace.js +22 -0
  140. package/dist/trace/trajectory.d.ts +8 -0
  141. package/dist/trace/trajectory.js +14 -2
  142. package/dist/util/fileLock.d.ts +92 -5
  143. package/dist/util/fileLock.js +809 -70
  144. package/dist/util/index.d.ts +2 -1
  145. package/dist/util/index.js +1 -1
  146. package/dist/verify/index.d.ts +2 -1
  147. package/dist/verify/index.js +1 -1
  148. package/dist/verify/sandboxRunner.d.ts +2 -0
  149. package/dist/verify/sandboxRunner.js +154 -10
  150. package/dist/verify/sandboxedValidation.d.ts +7 -2
  151. package/dist/verify/sandboxedValidation.js +102 -24
  152. package/dist/verify/validation.d.ts +24 -3
  153. package/dist/verify/validation.js +141 -24
  154. package/dist/wire/geneHints.d.ts +88 -16
  155. package/dist/wire/geneHints.js +124 -15
  156. package/dist/wire/index.d.ts +8 -3
  157. package/dist/wire/index.js +2 -2
  158. package/dist/wire/schemaGate.d.ts +21 -0
  159. package/dist/wire/schemaGate.js +119 -10
  160. package/package.json +5 -4
@@ -1,5 +1,6 @@
1
1
  import { createRequire } from 'node:module';
2
2
  import { readFileSync } from 'node:fs';
3
+ import { Ajv } from 'ajv';
3
4
  const nodeRequire = createRequire(import.meta.url);
4
5
  const SCHEMA_SUBPATH = {
5
6
  Gene: '@evomap/gep-sdk/schemas/gene.schema.json',
@@ -19,6 +20,76 @@ function loadSchema(type) {
19
20
  cache.set(type, schema);
20
21
  return schema;
21
22
  }
23
+ function validateObjectShape(value, schema, path, errors) {
24
+ if (!schema.properties && schema.additionalProperties !== false)
25
+ return;
26
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
27
+ return;
28
+ const record = value;
29
+ for (const req of schema.required ?? []) {
30
+ if (record[req] === undefined || record[req] === null)
31
+ errors.push(`${path}: 缺 required 字段: ${req}`);
32
+ }
33
+ if (schema.additionalProperties === false && schema.properties) {
34
+ const allowed = new Set(Object.keys(schema.properties));
35
+ for (const k of Object.keys(record))
36
+ if (!allowed.has(k))
37
+ errors.push(`${path}: 多余字段(additionalProperties:false 会 reject): ${k}`);
38
+ }
39
+ for (const [key, child] of Object.entries(schema.properties ?? {})) {
40
+ const childValue = record[key];
41
+ if (childValue === undefined || childValue === null)
42
+ continue;
43
+ if (Array.isArray(childValue) && child.items) {
44
+ const itemSchema = child.items;
45
+ childValue.forEach((item, index) => validateObjectShape(item, itemSchema, `${path}.${key}[${index}]`, errors));
46
+ }
47
+ else {
48
+ validateObjectShape(childValue, child, `${path}.${key}`, errors);
49
+ }
50
+ }
51
+ }
52
+ const deepValidatorCache = new Map();
53
+ const issueValidatorCache = new Map();
54
+ const deepValidator = new Ajv({
55
+ allErrors: false,
56
+ coerceTypes: false,
57
+ removeAdditional: false,
58
+ useDefaults: false,
59
+ });
60
+ // Repair needs EVERY violation in one pass — a first-error validator would make repair converge one field per
61
+ // round-trip. Kept as a second instance so the gate's own fail-fast cost is unchanged.
62
+ const issueValidator = new Ajv({
63
+ allErrors: true,
64
+ coerceTypes: false,
65
+ removeAdditional: false,
66
+ useDefaults: false,
67
+ });
68
+ function loadDeepValidator(type) {
69
+ const schema = loadSchema(type);
70
+ if (!schema)
71
+ return undefined;
72
+ const cached = deepValidatorCache.get(type);
73
+ if (cached)
74
+ return cached;
75
+ const validator = deepValidator.compile(schema);
76
+ deepValidatorCache.set(type, validator);
77
+ return validator;
78
+ }
79
+ function loadIssueValidator(type) {
80
+ const schema = loadSchema(type);
81
+ if (!schema)
82
+ return undefined;
83
+ const cached = issueValidatorCache.get(type);
84
+ if (cached)
85
+ return cached;
86
+ const validator = issueValidator.compile(schema);
87
+ issueValidatorCache.set(type, validator);
88
+ return validator;
89
+ }
90
+ function stableSchemaError(error) {
91
+ return `wire schema violation: ${error.schemaPath} (${error.keyword})`;
92
+ }
22
93
  /**
23
94
  * 结构校验(required 齐 + additionalProperties:false 不许多字段). 轻量, 不做深类型校验(那是发版 CI conformance 的活).
24
95
  * 用途: 发 hub 前确认资产能被 gep-sdk schema 接受; v2-delta(proof_of_work/resolution_status)在 bump 前会在此暴露.
@@ -31,18 +102,56 @@ export function validateWire(asset) {
31
102
  const schema = loadSchema(type);
32
103
  if (!schema)
33
104
  return { ok: false, errors: [`未知资产类型: ${type}`] };
34
- for (const req of schema.required ?? []) {
35
- if (asset[req] === undefined || asset[req] === null)
36
- errors.push(`缺 required 字段: ${req}`);
37
- }
38
- if (schema.additionalProperties === false && schema.properties) {
39
- const allowed = new Set(Object.keys(schema.properties));
40
- for (const k of Object.keys(asset))
41
- if (!allowed.has(k))
42
- errors.push(`多余字段(additionalProperties:false 会 reject): ${k}`);
43
- }
105
+ validateObjectShape(asset, schema, type, errors);
44
106
  return { ok: errors.length === 0, errors };
45
107
  }
108
+ /**
109
+ * Full Draft-07 runtime validation against the gep-sdk JSON Schema SSOT.
110
+ * Validation is observational: values are never coerced, defaulted, stripped, or otherwise mutated.
111
+ */
112
+ export function validateWireDeep(asset) {
113
+ const type = asset['type'];
114
+ if (typeof type !== 'string')
115
+ return { ok: false, errors: ['wire schema requires a string type'] };
116
+ const validator = loadDeepValidator(type);
117
+ if (!validator)
118
+ return { ok: false, errors: ['unsupported wire type'] };
119
+ if (validator(asset))
120
+ return { ok: true, errors: [] };
121
+ return {
122
+ ok: false,
123
+ errors: (validator.errors ?? []).map(stableSchemaError),
124
+ };
125
+ }
126
+ function issueFrom(error) {
127
+ const property = error.keyword === 'required'
128
+ ? String(error.params.missingProperty ?? '')
129
+ : error.keyword === 'additionalProperties'
130
+ ? String(error.params.additionalProperty ?? '')
131
+ : '';
132
+ const instancePath = error.instancePath.replace(/^\//, '').replace(/\//g, '.');
133
+ return {
134
+ path: property ? [instancePath, property].filter(Boolean).join('.') : instancePath,
135
+ keyword: error.keyword,
136
+ ...(property ? { property } : {}),
137
+ message: error.message ?? stableSchemaError(error),
138
+ };
139
+ }
140
+ /**
141
+ * Every schema violation of `asset`, located by field. Same SSOT and same verdict as {@link validateWireDeep}
142
+ * (empty ⇔ ok) — this form exists for callers that must ACT on a specific field rather than only report.
143
+ */
144
+ export function wireSchemaIssues(asset) {
145
+ const type = asset['type'];
146
+ if (typeof type !== 'string')
147
+ return [{ path: 'type', keyword: 'type', property: 'type', message: 'wire schema requires a string type' }];
148
+ const validator = loadIssueValidator(type);
149
+ if (!validator)
150
+ return [{ path: 'type', keyword: 'enum', property: 'type', message: 'unsupported wire type' }];
151
+ if (validator(asset))
152
+ return [];
153
+ return (validator.errors ?? []).map(issueFrom);
154
+ }
46
155
  /** schema 已声明的字段白名单(给上层判断哪些 v2-delta 尚未进 SDK). */
47
156
  export function schemaProperties(type) {
48
157
  return Object.keys(loadSchema(type)?.properties ?? {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evomap/evolver-core",
3
- "version": "2.0.0-beta.19",
3
+ "version": "2.0.0-beta.22",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
@@ -16,9 +16,10 @@
16
16
  }
17
17
  },
18
18
  "dependencies": {
19
- "@evomap/gep-sdk": "1.12.1",
20
- "zod": "^3.24.1",
21
- "ulid": "^2.3.0"
19
+ "@evomap/gep-sdk": "1.13.0",
20
+ "ajv": "^8.20.0",
21
+ "ulid": "^2.3.0",
22
+ "zod": "^3.24.1"
22
23
  },
23
24
  "repository": {
24
25
  "type": "git",