@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
@@ -0,0 +1,187 @@
1
+ import { z } from 'zod';
2
+ import { extensions, sha256Hash } from './common.js';
3
+ export const EVOLUTION_GRAPH_SCHEMA_VERSION = '1.0.0';
4
+ export const evolutionGraphNodeKinds = [
5
+ 'prompt',
6
+ 'code',
7
+ 'spec',
8
+ 'test',
9
+ 'feedback',
10
+ 'run',
11
+ 'metric',
12
+ 'variant',
13
+ 'selection',
14
+ ];
15
+ export const evolutionGraphEdgeKinds = [
16
+ 'derivation',
17
+ 'evaluated_by',
18
+ 'regressed',
19
+ 'fixed',
20
+ 'selected',
21
+ ];
22
+ export const evolutionGraphProvenanceKinds = [
23
+ 'root_event',
24
+ 'asset',
25
+ 'material',
26
+ 'review',
27
+ 'cycle',
28
+ 'workflow',
29
+ 'runtime_trace',
30
+ 'plugin',
31
+ 'manual',
32
+ ];
33
+ export const evolutionGraphNodeKind = z.enum(evolutionGraphNodeKinds);
34
+ export const evolutionGraphEdgeKind = z.enum(evolutionGraphEdgeKinds);
35
+ export const evolutionGraphProvenanceKind = z.enum(evolutionGraphProvenanceKinds);
36
+ export const evolutionGraphNodeRef = z.string().min(1);
37
+ export const evolutionGraphArtifactRef = z.object({
38
+ kind: z.enum(['asset', 'material', 'root_event', 'file', 'runtime_trace', 'plugin_resource']),
39
+ ref: z.string().min(1),
40
+ sha256: sha256Hash.optional(),
41
+ });
42
+ export const evolutionGraphMetricValue = z.object({
43
+ metric: z.string().min(1),
44
+ value: z.number(),
45
+ unit: z.string().min(1).optional(),
46
+ direction: z.enum(['higher_is_better', 'lower_is_better', 'target']).default('higher_is_better'),
47
+ target: z.number().optional(),
48
+ });
49
+ export const evolutionGraphMetricDelta = z.object({
50
+ metric: z.string().min(1),
51
+ before: z.number().optional(),
52
+ after: z.number(),
53
+ delta: z.number().optional(),
54
+ direction: z.enum(['improved', 'regressed', 'unchanged', 'unknown']).default('unknown'),
55
+ });
56
+ export const evolutionGraphNode = z.object({
57
+ id: evolutionGraphNodeRef,
58
+ kind: evolutionGraphNodeKind,
59
+ label: z.string().min(1),
60
+ createdAt: z.string().datetime(),
61
+ artifact: evolutionGraphArtifactRef.optional(),
62
+ metrics: z.array(evolutionGraphMetricValue).default([]),
63
+ summary: z.string().optional(),
64
+ tags: z.array(z.string().min(1)).default([]),
65
+ extensions,
66
+ });
67
+ export const evolutionGraphProvenance = z.object({
68
+ kind: evolutionGraphProvenanceKind,
69
+ ref: z.string().min(1),
70
+ capturedAt: z.string().datetime(),
71
+ actor: z.string().min(1).optional(),
72
+ digest: sha256Hash.optional(),
73
+ summary: z.string().optional(),
74
+ });
75
+ export const evolutionGraphEdge = z.object({
76
+ id: z.string().min(1),
77
+ kind: evolutionGraphEdgeKind,
78
+ from: evolutionGraphNodeRef,
79
+ to: evolutionGraphNodeRef,
80
+ createdAt: z.string().datetime(),
81
+ provenance: z.array(evolutionGraphProvenance).min(1),
82
+ metricDelta: evolutionGraphMetricDelta.optional(),
83
+ reason: z.string().min(1).optional(),
84
+ confidence: z.number().min(0).max(1).optional(),
85
+ extensions,
86
+ });
87
+ export const evolutionGraphDashboardSummary = z.object({
88
+ nodeCount: z.number().int().nonnegative(),
89
+ edgeCount: z.number().int().nonnegative(),
90
+ variantCount: z.number().int().nonnegative(),
91
+ selectedCount: z.number().int().nonnegative(),
92
+ regressionCount: z.number().int().nonnegative(),
93
+ fixedCount: z.number().int().nonnegative(),
94
+ evaluatedVariantCount: z.number().int().nonnegative(),
95
+ unevaluatedVariantCount: z.number().int().nonnegative(),
96
+ orphanEdgeCount: z.number().int().nonnegative(),
97
+ provenanceGapCount: z.number().int().nonnegative(),
98
+ });
99
+ export const evolutionGraph = z.object({
100
+ schemaVersion: z.literal(EVOLUTION_GRAPH_SCHEMA_VERSION).default(EVOLUTION_GRAPH_SCHEMA_VERSION),
101
+ graphId: z.string().min(1),
102
+ generatedAt: z.string().datetime(),
103
+ nodes: z.array(evolutionGraphNode),
104
+ edges: z.array(evolutionGraphEdge),
105
+ dashboard: evolutionGraphDashboardSummary.optional(),
106
+ extensions,
107
+ }).superRefine((graph, ctx) => {
108
+ const nodesById = new Map();
109
+ for (const [index, node] of graph.nodes.entries()) {
110
+ if (nodesById.has(node.id)) {
111
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['nodes', index, 'id'], message: 'duplicate evolution graph node id' });
112
+ continue;
113
+ }
114
+ nodesById.set(node.id, node.kind);
115
+ }
116
+ const edgeIds = new Set();
117
+ for (const [index, edge] of graph.edges.entries()) {
118
+ if (edgeIds.has(edge.id)) {
119
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['edges', index, 'id'], message: 'duplicate evolution graph edge id' });
120
+ }
121
+ else {
122
+ edgeIds.add(edge.id);
123
+ }
124
+ const fromKind = nodesById.get(edge.from);
125
+ const toKind = nodesById.get(edge.to);
126
+ if (!fromKind)
127
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['edges', index, 'from'], message: 'edge source node is missing' });
128
+ if (!toKind)
129
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['edges', index, 'to'], message: 'edge target node is missing' });
130
+ if (!fromKind || !toKind)
131
+ continue;
132
+ validateEvolutionGraphEdgeShape(edge, fromKind, toKind, ctx, index);
133
+ }
134
+ });
135
+ export function deriveEvolutionGraphDashboardSummary(input) {
136
+ const variantIds = new Set(input.nodes.filter((node) => node.kind === 'variant').map((node) => node.id));
137
+ const evaluatedVariantIds = new Set();
138
+ let selectedCount = 0;
139
+ let regressionCount = 0;
140
+ let fixedCount = 0;
141
+ let orphanEdgeCount = 0;
142
+ let provenanceGapCount = 0;
143
+ const nodeIds = new Set(input.nodes.map((node) => node.id));
144
+ for (const edge of input.edges) {
145
+ if (!nodeIds.has(edge.from) || !nodeIds.has(edge.to))
146
+ orphanEdgeCount += 1;
147
+ if (edge.provenance.length === 0)
148
+ provenanceGapCount += 1;
149
+ if (edge.kind === 'evaluated_by' && variantIds.has(edge.from))
150
+ evaluatedVariantIds.add(edge.from);
151
+ if (edge.kind === 'selected')
152
+ selectedCount += 1;
153
+ if (edge.kind === 'regressed')
154
+ regressionCount += 1;
155
+ if (edge.kind === 'fixed')
156
+ fixedCount += 1;
157
+ }
158
+ return {
159
+ nodeCount: input.nodes.length,
160
+ edgeCount: input.edges.length,
161
+ variantCount: variantIds.size,
162
+ selectedCount,
163
+ regressionCount,
164
+ fixedCount,
165
+ evaluatedVariantCount: evaluatedVariantIds.size,
166
+ unevaluatedVariantCount: Math.max(0, variantIds.size - evaluatedVariantIds.size),
167
+ orphanEdgeCount,
168
+ provenanceGapCount,
169
+ };
170
+ }
171
+ function validateEvolutionGraphEdgeShape(edge, fromKind, toKind, ctx, edgeIndex) {
172
+ if (edge.kind === 'selected' && (fromKind !== 'variant' || toKind !== 'selection')) {
173
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['edges', edgeIndex, 'kind'], message: 'selected edges must connect variant -> selection' });
174
+ }
175
+ if (edge.kind === 'evaluated_by' && !['run', 'metric', 'test'].includes(toKind)) {
176
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['edges', edgeIndex, 'to'], message: 'evaluated_by target must be run, metric, or test' });
177
+ }
178
+ if ((edge.kind === 'regressed' || edge.kind === 'fixed') && !['run', 'metric', 'test'].includes(toKind)) {
179
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['edges', edgeIndex, 'to'], message: `${edge.kind} target must be run, metric, or test` });
180
+ }
181
+ if ((edge.kind === 'regressed' || edge.kind === 'fixed') && !edge.metricDelta) {
182
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['edges', edgeIndex, 'metricDelta'], message: `${edge.kind} edges require metricDelta` });
183
+ }
184
+ if (edge.kind === 'selected' && !edge.reason) {
185
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['edges', edgeIndex, 'reason'], message: 'selected edges require a reason' });
186
+ }
187
+ }
@@ -2,4 +2,5 @@ export * from './common.js';
2
2
  export * from './material.js';
3
3
  export * from './signal.js';
4
4
  export * from './problem.js';
5
+ export * from './evolutionGraph.js';
5
6
  export * from './proofOfWork.js';
@@ -2,4 +2,5 @@ export * from './common.js';
2
2
  export * from './material.js';
3
3
  export * from './signal.js';
4
4
  export * from './problem.js';
5
+ export * from './evolutionGraph.js';
5
6
  export * from './proofOfWork.js';
@@ -1,7 +1,55 @@
1
1
  import { z } from 'zod';
2
- /** 产出证据 (批注#19): 解锁非 coding agent, 不再"无 git 变动=没产出". */
3
2
  export declare const proofOfWork: z.ZodObject<{
4
3
  kind: z.ZodEnum<["git_diff", "artifact_hash", "external_receipt", "tool_call_trace"]>;
4
+ git_diff: z.ZodOptional<z.ZodObject<{
5
+ files: z.ZodOptional<z.ZodNumber>;
6
+ lines: z.ZodOptional<z.ZodNumber>;
7
+ patch_ref: z.ZodOptional<z.ZodString>;
8
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
9
+ files: z.ZodOptional<z.ZodNumber>;
10
+ lines: z.ZodOptional<z.ZodNumber>;
11
+ patch_ref: z.ZodOptional<z.ZodString>;
12
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
13
+ files: z.ZodOptional<z.ZodNumber>;
14
+ lines: z.ZodOptional<z.ZodNumber>;
15
+ patch_ref: z.ZodOptional<z.ZodString>;
16
+ }, z.ZodTypeAny, "passthrough">>>;
17
+ artifact_hash: z.ZodOptional<z.ZodObject<{
18
+ sha256: z.ZodOptional<z.ZodString>;
19
+ mime: z.ZodOptional<z.ZodString>;
20
+ size: z.ZodOptional<z.ZodNumber>;
21
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
22
+ sha256: z.ZodOptional<z.ZodString>;
23
+ mime: z.ZodOptional<z.ZodString>;
24
+ size: z.ZodOptional<z.ZodNumber>;
25
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
26
+ sha256: z.ZodOptional<z.ZodString>;
27
+ mime: z.ZodOptional<z.ZodString>;
28
+ size: z.ZodOptional<z.ZodNumber>;
29
+ }, z.ZodTypeAny, "passthrough">>>;
30
+ external_receipt: z.ZodOptional<z.ZodObject<{
31
+ provider: z.ZodOptional<z.ZodString>;
32
+ receipt_id: z.ZodOptional<z.ZodString>;
33
+ ts: z.ZodOptional<z.ZodString>;
34
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
35
+ provider: z.ZodOptional<z.ZodString>;
36
+ receipt_id: z.ZodOptional<z.ZodString>;
37
+ ts: z.ZodOptional<z.ZodString>;
38
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
39
+ provider: z.ZodOptional<z.ZodString>;
40
+ receipt_id: z.ZodOptional<z.ZodString>;
41
+ ts: z.ZodOptional<z.ZodString>;
42
+ }, z.ZodTypeAny, "passthrough">>>;
43
+ tool_call_trace: z.ZodOptional<z.ZodObject<{
44
+ calls: z.ZodOptional<z.ZodNumber>;
45
+ ref: z.ZodOptional<z.ZodString>;
46
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
47
+ calls: z.ZodOptional<z.ZodNumber>;
48
+ ref: z.ZodOptional<z.ZodString>;
49
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
50
+ calls: z.ZodOptional<z.ZodNumber>;
51
+ ref: z.ZodOptional<z.ZodString>;
52
+ }, z.ZodTypeAny, "passthrough">>>;
5
53
  gitDiff: z.ZodOptional<z.ZodObject<{
6
54
  files: z.ZodNumber;
7
55
  lines: z.ZodNumber;
@@ -34,12 +82,12 @@ export declare const proofOfWork: z.ZodObject<{
34
82
  ts: z.ZodString;
35
83
  }, "strip", z.ZodTypeAny, {
36
84
  provider: string;
37
- receiptId: string;
38
85
  ts: string;
86
+ receiptId: string;
39
87
  }, {
40
88
  provider: string;
41
- receiptId: string;
42
89
  ts: string;
90
+ receiptId: string;
43
91
  }>>;
44
92
  toolCallTrace: z.ZodOptional<z.ZodObject<{
45
93
  calls: z.ZodNumber;
@@ -53,6 +101,25 @@ export declare const proofOfWork: z.ZodObject<{
53
101
  }>>;
54
102
  }, "strip", z.ZodTypeAny, {
55
103
  kind: "git_diff" | "artifact_hash" | "external_receipt" | "tool_call_trace";
104
+ git_diff?: z.objectOutputType<{
105
+ files: z.ZodOptional<z.ZodNumber>;
106
+ lines: z.ZodOptional<z.ZodNumber>;
107
+ patch_ref: z.ZodOptional<z.ZodString>;
108
+ }, z.ZodTypeAny, "passthrough"> | undefined;
109
+ artifact_hash?: z.objectOutputType<{
110
+ sha256: z.ZodOptional<z.ZodString>;
111
+ mime: z.ZodOptional<z.ZodString>;
112
+ size: z.ZodOptional<z.ZodNumber>;
113
+ }, z.ZodTypeAny, "passthrough"> | undefined;
114
+ external_receipt?: z.objectOutputType<{
115
+ provider: z.ZodOptional<z.ZodString>;
116
+ receipt_id: z.ZodOptional<z.ZodString>;
117
+ ts: z.ZodOptional<z.ZodString>;
118
+ }, z.ZodTypeAny, "passthrough"> | undefined;
119
+ tool_call_trace?: z.objectOutputType<{
120
+ calls: z.ZodOptional<z.ZodNumber>;
121
+ ref: z.ZodOptional<z.ZodString>;
122
+ }, z.ZodTypeAny, "passthrough"> | undefined;
56
123
  gitDiff?: {
57
124
  files: number;
58
125
  lines: number;
@@ -65,8 +132,8 @@ export declare const proofOfWork: z.ZodObject<{
65
132
  } | undefined;
66
133
  externalReceipt?: {
67
134
  provider: string;
68
- receiptId: string;
69
135
  ts: string;
136
+ receiptId: string;
70
137
  } | undefined;
71
138
  toolCallTrace?: {
72
139
  calls: number;
@@ -74,6 +141,25 @@ export declare const proofOfWork: z.ZodObject<{
74
141
  } | undefined;
75
142
  }, {
76
143
  kind: "git_diff" | "artifact_hash" | "external_receipt" | "tool_call_trace";
144
+ git_diff?: z.objectInputType<{
145
+ files: z.ZodOptional<z.ZodNumber>;
146
+ lines: z.ZodOptional<z.ZodNumber>;
147
+ patch_ref: z.ZodOptional<z.ZodString>;
148
+ }, z.ZodTypeAny, "passthrough"> | undefined;
149
+ artifact_hash?: z.objectInputType<{
150
+ sha256: z.ZodOptional<z.ZodString>;
151
+ mime: z.ZodOptional<z.ZodString>;
152
+ size: z.ZodOptional<z.ZodNumber>;
153
+ }, z.ZodTypeAny, "passthrough"> | undefined;
154
+ external_receipt?: z.objectInputType<{
155
+ provider: z.ZodOptional<z.ZodString>;
156
+ receipt_id: z.ZodOptional<z.ZodString>;
157
+ ts: z.ZodOptional<z.ZodString>;
158
+ }, z.ZodTypeAny, "passthrough"> | undefined;
159
+ tool_call_trace?: z.objectInputType<{
160
+ calls: z.ZodOptional<z.ZodNumber>;
161
+ ref: z.ZodOptional<z.ZodString>;
162
+ }, z.ZodTypeAny, "passthrough"> | undefined;
77
163
  gitDiff?: {
78
164
  files: number;
79
165
  lines: number;
@@ -86,12 +172,45 @@ export declare const proofOfWork: z.ZodObject<{
86
172
  } | undefined;
87
173
  externalReceipt?: {
88
174
  provider: string;
89
- receiptId: string;
90
175
  ts: string;
176
+ receiptId: string;
91
177
  } | undefined;
92
178
  toolCallTrace?: {
93
179
  calls: number;
94
180
  ref?: string | undefined;
95
181
  } | undefined;
96
182
  }>;
97
- export type ProofOfWork = z.infer<typeof proofOfWork>;
183
+ export type ProofOfWork = z.infer<typeof proofOfWork>;
184
+ /** #961 兼容读: snake_case 优先, 旧别名只补齐部分迁移 payload 缺失的字段. */
185
+ export declare function gitDiffOf(p: ProofOfWork | undefined): ProofOfWork['git_diff'] | ProofOfWork['gitDiff'] | undefined;
186
+ export declare function artifactHashOf(p: ProofOfWork | undefined): ProofOfWork['artifact_hash'] | undefined;
187
+ export declare function externalReceiptOf(p: ProofOfWork | undefined): ProofOfWork['external_receipt'] | ProofOfWork['externalReceipt'] | undefined;
188
+ export declare function toolCallTraceOf(p: ProofOfWork | undefined): ProofOfWork['tool_call_trace'] | undefined;
189
+ /** #961 写边界: 兼容读到的旧 camelCase proof 必须规范化后才能进入新 Capsule。 */
190
+ export declare function proofOfWorkForWrite(p: ProofOfWork): ProofOfWork;
191
+ /** Accept either canonical snake_case or legacy camelCase stored proof without lossy conversion. */
192
+ export declare function normalizeProofOfWork(input: unknown): ProofOfWork | undefined;
193
+ export interface WireProofOfWork {
194
+ kind: ProofOfWork['kind'];
195
+ git_diff?: {
196
+ files?: number;
197
+ lines?: number;
198
+ patch_ref?: string;
199
+ };
200
+ artifact_hash?: {
201
+ sha256?: string;
202
+ mime?: string;
203
+ size?: number;
204
+ };
205
+ external_receipt?: {
206
+ provider?: string;
207
+ receipt_id?: string;
208
+ ts?: string;
209
+ };
210
+ tool_call_trace?: {
211
+ calls?: number;
212
+ ref?: string;
213
+ };
214
+ }
215
+ /** Convert a proof to the gep-sdk wire shape while preserving canonical nested fields and extensions. */
216
+ export declare function toWireProofOfWork(proof: ProofOfWork): WireProofOfWork;
@@ -1,9 +1,107 @@
1
1
  import { z } from 'zod';
2
2
  /** 产出证据 (批注#19): 解锁非 coding agent, 不再"无 git 变动=没产出". */
3
+ /**
4
+ * #961: 字段名对齐 gep-sdk 官方 capsule.schema.json(snake_case) —— evolver-core 曾是全生态唯一
5
+ * camelCase 偏离实现, 导致 Hub zod `.strip()` mutate payload 后 verifyAssetId 死锁、静态 proof
6
+ * 评估丢分。写路径一律 snake_case; camelCase 键仅为解析本地存量旧资产的兼容别名(不声明会被
7
+ * zod `.strip()` 剥掉 → canonicalize 漂移 → asset_id 对不上), 永不用于新写入, v3 major 移除。
8
+ */
9
+ const nonnegativeInteger = z.number().int().nonnegative();
10
+ const legacyInteger = z.number().int();
11
+ const gitDiffWire = z.object({
12
+ files: nonnegativeInteger.optional(),
13
+ lines: nonnegativeInteger.optional(),
14
+ patch_ref: z.string().optional(),
15
+ }).passthrough();
16
+ const artifactHashWire = z.object({
17
+ sha256: z.string().optional(),
18
+ mime: z.string().optional(),
19
+ size: nonnegativeInteger.optional(),
20
+ }).passthrough();
21
+ const externalReceiptWire = z.object({
22
+ provider: z.string().optional(),
23
+ receipt_id: z.string().optional(),
24
+ ts: z.string().optional(),
25
+ }).passthrough();
26
+ const toolCallTraceWire = z.object({
27
+ calls: nonnegativeInteger.optional(),
28
+ ref: z.string().optional(),
29
+ }).passthrough();
3
30
  export const proofOfWork = z.object({
4
31
  kind: z.enum(['git_diff', 'artifact_hash', 'external_receipt', 'tool_call_trace']),
5
- gitDiff: z.object({ files: z.number().int(), lines: z.number().int(), patchRef: z.string().optional() }).optional(),
6
- artifactHash: z.object({ sha256: z.string(), mime: z.string().optional(), size: z.number().int() }).optional(),
32
+ git_diff: gitDiffWire.optional(),
33
+ artifact_hash: artifactHashWire.optional(),
34
+ external_receipt: externalReceiptWire.optional(),
35
+ tool_call_trace: toolCallTraceWire.optional(),
36
+ // ── #961 兼容读别名(仅旧资产解析; 新写入禁止使用) ──
37
+ gitDiff: z.object({ files: legacyInteger, lines: legacyInteger, patchRef: z.string().optional() }).optional(),
38
+ artifactHash: z.object({ sha256: z.string(), mime: z.string().optional(), size: legacyInteger }).optional(),
7
39
  externalReceipt: z.object({ provider: z.string(), receiptId: z.string(), ts: z.string() }).optional(),
8
- toolCallTrace: z.object({ calls: z.number().int(), ref: z.string().optional() }).optional(),
9
- });
40
+ toolCallTrace: z.object({ calls: legacyInteger, ref: z.string().optional() }).optional(),
41
+ });
42
+ /** #961 兼容读: snake_case 优先, 旧别名只补齐部分迁移 payload 缺失的字段. */
43
+ export function gitDiffOf(p) {
44
+ const snake = p?.git_diff;
45
+ const legacy = p?.gitDiff;
46
+ if (!legacy)
47
+ return snake;
48
+ if (!snake)
49
+ return legacy;
50
+ return { files: legacy.files, lines: legacy.lines, ...(typeof legacy.patchRef === 'string' ? { patch_ref: legacy.patchRef } : {}), ...snake };
51
+ }
52
+ export function artifactHashOf(p) {
53
+ const snake = p?.artifact_hash;
54
+ const legacy = p?.artifactHash;
55
+ return legacy ? { ...legacy, ...snake } : snake;
56
+ }
57
+ export function externalReceiptOf(p) {
58
+ const snake = p?.external_receipt;
59
+ const legacy = p?.externalReceipt;
60
+ if (!legacy)
61
+ return snake;
62
+ if (!snake)
63
+ return legacy;
64
+ return { provider: legacy.provider, receipt_id: legacy.receiptId, ts: legacy.ts, ...snake };
65
+ }
66
+ export function toolCallTraceOf(p) {
67
+ const snake = p?.tool_call_trace;
68
+ const legacy = p?.toolCallTrace;
69
+ return legacy ? { ...legacy, ...snake } : snake;
70
+ }
71
+ function normalizeGitDiff(value) {
72
+ if (!value)
73
+ return undefined;
74
+ const raw = value;
75
+ const { patchRef, ...wire } = raw;
76
+ return { ...wire, ...(typeof raw.patch_ref === 'string' ? { patch_ref: raw.patch_ref } : typeof patchRef === 'string' ? { patch_ref: patchRef } : {}) };
77
+ }
78
+ function normalizeExternalReceipt(value) {
79
+ if (!value)
80
+ return undefined;
81
+ const raw = value;
82
+ const { receiptId, ...wire } = raw;
83
+ return { ...wire, ...(typeof raw.receipt_id === 'string' ? { receipt_id: raw.receipt_id } : typeof receiptId === 'string' ? { receipt_id: receiptId } : {}) };
84
+ }
85
+ /** #961 写边界: 兼容读到的旧 camelCase proof 必须规范化后才能进入新 Capsule。 */
86
+ export function proofOfWorkForWrite(p) {
87
+ const { gitDiff: _gitDiff, artifactHash: _artifactHash, externalReceipt: _externalReceipt, toolCallTrace: _toolCallTrace, ...wire } = p;
88
+ const normalized = {
89
+ ...wire,
90
+ ...(gitDiffOf(p) ? { git_diff: normalizeGitDiff(gitDiffOf(p)) } : {}),
91
+ ...(artifactHashOf(p) ? { artifact_hash: artifactHashOf(p) } : {}),
92
+ ...(externalReceiptOf(p) ? { external_receipt: normalizeExternalReceipt(externalReceiptOf(p)) } : {}),
93
+ ...(toolCallTraceOf(p) ? { tool_call_trace: toolCallTraceOf(p) } : {}),
94
+ };
95
+ return proofOfWork.parse(normalized);
96
+ }
97
+ /** Accept either canonical snake_case or legacy camelCase stored proof without lossy conversion. */
98
+ export function normalizeProofOfWork(input) {
99
+ const parsed = proofOfWork.safeParse(input);
100
+ return parsed.success ? parsed.data : undefined;
101
+ }
102
+ /** Convert a proof to the gep-sdk wire shape while preserving canonical nested fields and extensions. */
103
+ export function toWireProofOfWork(proof) {
104
+ const normalized = proofOfWorkForWrite(proof);
105
+ const { kind, ...fields } = normalized;
106
+ return { kind: kind, ...fields };
107
+ }
@@ -38,5 +38,6 @@ export function shadowHubCapability(cap, sink, mode) {
38
38
  },
39
39
  },
40
40
  ...(cap.capabilities ? { capabilities: () => cap.capabilities() } : {}),
41
+ ...(cap.recipes ? { recipes: cap.recipes } : {}),
41
42
  };
42
43
  }
@@ -31,4 +31,18 @@ export declare function geneTags(gene: GeneTagInput): string[];
31
31
  * literal=1.0 upstream in expandedMatchScore. v1 #99 gave CJK full literal credit via pipe-aliases; v2 reaches
32
32
  * the right gene at ~2/3 strength. Lifting this to parity is a scoring-design change beyond this signal port.
33
33
  */
34
- export declare function tagOverlapScore(signals: readonly string[], gene: GeneTagInput): number;
34
+ export declare function tagOverlapScore(signals: readonly string[], gene: GeneTagInput): number;
35
+ export interface SemanticIdfDocument {
36
+ readonly tags: readonly string[];
37
+ readonly text: string;
38
+ }
39
+ export interface SemanticIdfProfile {
40
+ readonly documentCount: number;
41
+ readonly tagIdf: ReadonlyMap<string, number>;
42
+ readonly tokenIdf: ReadonlyMap<string, number>;
43
+ /** Deterministic, data-free identity for replaying the exact document-frequency profile. */
44
+ readonly version: string;
45
+ }
46
+ export declare function buildSemanticIdfProfile(documents: readonly SemanticIdfDocument[]): SemanticIdfProfile;
47
+ export declare function idfTagOverlapScore(signals: readonly string[], gene: GeneTagInput, profile: SemanticIdfProfile): number;
48
+ export declare function idfBagCosine(a: string, b: string, profile: SemanticIdfProfile): number;