opencode-swarm 7.130.1 → 7.131.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.
- package/dist/cli/{config-doctor-489wej17.js → config-doctor-rjvb0hhn.js} +2 -2
- package/dist/cli/{curation-policy-aaz0hap6.js → curation-policy-f5bybzmh.js} +2 -2
- package/dist/cli/{curator-by14m5fc.js → curator-kjzqa5m7.js} +14 -14
- package/dist/cli/{curator-llm-factory-7rz7mvcr.js → curator-llm-factory-ezq4fakt.js} +14 -14
- package/dist/cli/{evidence-summary-service-hf7qq777.js → evidence-summary-service-jfagmvrh.js} +1 -1
- package/dist/cli/{guardrail-explain-mvct2n9f.js → guardrail-explain-n93qh8k6.js} +15 -15
- package/dist/cli/{guardrail-log-2cejc33f.js → guardrail-log-h4tmcjwx.js} +3 -3
- package/dist/cli/{hive-promoter-trezcyrd.js → hive-promoter-mammxe5p.js} +14 -14
- package/dist/cli/{index-jvyn76xe.js → index-01nyrk95.js} +3 -3
- package/dist/cli/{index-kzvwb2se.js → index-03zyn94g.js} +110 -85
- package/dist/cli/{index-xa29259t.js → index-1atz85c8.js} +1 -1
- package/dist/cli/{index-j0py44fv.js → index-6vg0qczz.js} +2 -2
- package/dist/cli/{index-zft4hp35.js → index-cnwh164k.js} +1 -1
- package/dist/cli/{index-hjar4crm.js → index-cq22pnd2.js} +1 -1
- package/dist/cli/{index-4qrbvrz5.js → index-d2tgc580.js} +2689 -1241
- package/dist/cli/{index-jxha73tm.js → index-fepakwhp.js} +1 -1
- package/dist/cli/{index-f2y46pda.js → index-h3k62043.js} +20 -6
- package/dist/cli/{index-5xxgeksy.js → index-hynbzh7s.js} +46 -2
- package/dist/cli/{index-p6qgjkbt.js → index-kbfhyxtv.js} +9 -1
- package/dist/cli/{index-3rnkyb60.js → index-m6zfm7cm.js} +5 -5
- package/dist/cli/{index-s8h2cedv.js → index-pft1qxqh.js} +1 -1
- package/dist/cli/{index-ts9wh1ba.js → index-q68sprcy.js} +60 -8
- package/dist/cli/{index-agte9w1e.js → index-szkswbqf.js} +2 -2
- package/dist/cli/{index-nr5pr54q.js → index-tw33v84d.js} +1 -1
- package/dist/cli/{index-xdx5b4s1.js → index-xhd797bz.js} +16 -16
- package/dist/cli/{index-wy3q73j2.js → index-xv2ydncg.js} +18 -14
- package/dist/cli/index.js +14 -14
- package/dist/cli/{knowledge-escalator-1ypz0266.js → knowledge-escalator-cf1kkmfe.js} +3 -3
- package/dist/cli/{knowledge-events-yvcczmja.js → knowledge-events-p8t5ev44.js} +1 -1
- package/dist/cli/{knowledge-store-h8bp9eje.js → knowledge-store-vpdmcwem.js} +3 -1
- package/dist/cli/{knowledge-validator-sz9v1fdq.js → knowledge-validator-w1t0sw5f.js} +4 -4
- package/dist/cli/{scan-cursor-k9zyt374.js → scan-cursor-z4c51902.js} +2 -2
- package/dist/cli/{schema-fkpn2r1s.js → schema-yqzzfavj.js} +5 -1
- package/dist/cli/{skill-generator-a6a9jxfd.js → skill-generator-aaabj00n.js} +5 -5
- package/dist/cli/{workspace-snapshot-jwkjg790.js → workspace-snapshot-35qc0y8a.js} +1 -1
- package/dist/commands/consolidate.d.ts +14 -0
- package/dist/commands/curate.d.ts +2 -0
- package/dist/commands/promote.d.ts +25 -0
- package/dist/commands/registry.d.ts +2 -2
- package/dist/config/schema.d.ts +101 -0
- package/dist/consensus/contracts.d.ts +479 -0
- package/dist/consensus/corpus.d.ts +261 -0
- package/dist/consensus/miner.d.ts +200 -0
- package/dist/consensus/public-api.d.ts +42 -0
- package/dist/consensus/store.d.ts +119 -0
- package/dist/evidence/immutable-store.d.ts +86 -0
- package/dist/evidence/manager.d.ts +31 -1
- package/dist/hooks/actionability-predicate.d.ts +36 -0
- package/dist/hooks/curator.d.ts +3 -0
- package/dist/hooks/hive-policy.d.ts +11 -0
- package/dist/hooks/hive-promoter.d.ts +27 -1
- package/dist/hooks/knowledge-dedup-sweep.d.ts +145 -0
- package/dist/hooks/knowledge-injector.d.ts +4 -0
- package/dist/hooks/knowledge-store.d.ts +26 -0
- package/dist/hooks/knowledge-types.d.ts +6 -0
- package/dist/hooks/knowledge-validator.d.ts +10 -14
- package/dist/hooks/micro-reflector.d.ts +106 -2
- package/dist/hooks/realtime-learning-nudge.d.ts +19 -0
- package/dist/index.js +427 -419
- package/dist/knowledge/entry-merge.d.ts +112 -0
- package/dist/knowledge/family-migration.d.ts +6 -2
- package/dist/learning/admission.d.ts +154 -0
- package/dist/learning/candidate-queue.d.ts +178 -0
- package/dist/learning/fingerprint.d.ts +56 -0
- package/dist/learning/prm-pattern-support.d.ts +124 -0
- package/dist/learning/provenance.d.ts +86 -0
- package/dist/prm/index.d.ts +46 -1
- package/dist/services/recommendation-ledger.d.ts +266 -0
- package/dist/services/skill-improver.d.ts +4 -0
- package/dist/services/status-service.d.ts +13 -0
- package/dist/services/trajectory-cluster.d.ts +65 -2
- package/dist/tools/consensus-mine.d.ts +172 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/knowledge-add.d.ts +34 -0
- package/dist/tools/manifest.d.ts +1 -0
- package/dist/tools/tool-metadata.d.ts +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Versioned contracts for the consensus miner (issue #1821, Workstream C).
|
|
3
|
+
*
|
|
4
|
+
* Style mirrors `src/evaluation/contracts.ts`: every persisted shape is a
|
|
5
|
+
* `.strict()` Zod object carrying an explicit `v: z.literal(1)` discriminant, so
|
|
6
|
+
* an unknown key or a future schema version fails loudly at the store boundary
|
|
7
|
+
* instead of silently round-tripping through a partially-understood artifact.
|
|
8
|
+
*
|
|
9
|
+
* The interfaces below are hand-written rather than `z.infer`-derived because
|
|
10
|
+
* the issue specifies them verbatim; the `satisfies`-style compile assertions at
|
|
11
|
+
* the bottom of each block keep the schema and the interface from drifting apart
|
|
12
|
+
* without forcing consumers to read Zod inference to learn the shape.
|
|
13
|
+
*/
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
/** Upper bound on any single reference list. Keeps a report bounded on disk. */
|
|
16
|
+
export declare const MAX_CONSENSUS_REFS = 200;
|
|
17
|
+
/**
|
|
18
|
+
* Upper bound on a rendered statement, and the hard REJECTION bound on an LLM
|
|
19
|
+
* restatement. Model output is never truncated to fit — a half-sentence is
|
|
20
|
+
* exactly how a fragment of reasoning survives a length cut — so an
|
|
21
|
+
* over-long restatement is discarded and the deterministic statement stands.
|
|
22
|
+
*/
|
|
23
|
+
export declare const MAX_CONSENSUS_STATEMENT_CHARS = 600;
|
|
24
|
+
/**
|
|
25
|
+
* Upper bound on the attribute and proposal arrays of a single report.
|
|
26
|
+
*
|
|
27
|
+
* `MAX_CONSENSUS_ATTRIBUTES` is exported because the PRODUCER must enforce it
|
|
28
|
+
* too: a schema-only cap turns a large `maxEvidenceItems` into a hard
|
|
29
|
+
* `ConsensusReportV1Schema.parse` throw at the end of mining, which means NO
|
|
30
|
+
* report is written at all — the caller loses every finding rather than the tail
|
|
31
|
+
* of a ranked list. `src/consensus/miner.ts` therefore caps first, ranked, and
|
|
32
|
+
* records how many it dropped in `report.truncation`.
|
|
33
|
+
*
|
|
34
|
+
* `MAX_CONSENSUS_PROPOSALS` has no producer-side counterpart, by design: the
|
|
35
|
+
* miner emits at most one proposal per attribute and deduplication only removes,
|
|
36
|
+
* so `proposals.length <= attributes.length <= MAX_CONSENSUS_ATTRIBUTES` holds
|
|
37
|
+
* structurally while the two constants are equal. It is exported so that
|
|
38
|
+
* equality — which the argument depends on — is asserted by a test rather than
|
|
39
|
+
* assumed.
|
|
40
|
+
*/
|
|
41
|
+
export declare const MAX_CONSENSUS_ATTRIBUTES = 1000;
|
|
42
|
+
export declare const MAX_CONSENSUS_PROPOSALS = 1000;
|
|
43
|
+
/**
|
|
44
|
+
* Mining request. Every filter is optional and intersective: omitting `runIds`
|
|
45
|
+
* means "every run in the corpus", supplying it means "only these runs".
|
|
46
|
+
*
|
|
47
|
+
* Specified verbatim by issue #1821 Workstream C — do not reorder or rename.
|
|
48
|
+
*/
|
|
49
|
+
export interface ConsensusMineRequest {
|
|
50
|
+
runIds?: string[];
|
|
51
|
+
taskCategories?: string[];
|
|
52
|
+
agentRoles?: string[];
|
|
53
|
+
modelIds?: string[];
|
|
54
|
+
minSupport: number;
|
|
55
|
+
minSuccessfulRuns: number;
|
|
56
|
+
maxEvidenceItems: number;
|
|
57
|
+
}
|
|
58
|
+
export declare const ConsensusMineRequestSchema: z.ZodObject<{
|
|
59
|
+
runIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
60
|
+
taskCategories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
61
|
+
agentRoles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
62
|
+
modelIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
+
minSupport: z.ZodNumber;
|
|
64
|
+
minSuccessfulRuns: z.ZodNumber;
|
|
65
|
+
maxEvidenceItems: z.ZodNumber;
|
|
66
|
+
}, z.core.$strict>;
|
|
67
|
+
/** Where a mined attribute would be actioned, if it qualifies as a proposal. */
|
|
68
|
+
declare const ConsensusProposedTargetSchema: z.ZodEnum<{
|
|
69
|
+
tooling: "tooling";
|
|
70
|
+
none: "none";
|
|
71
|
+
prompt: "prompt";
|
|
72
|
+
skill: "skill";
|
|
73
|
+
orchestration: "orchestration";
|
|
74
|
+
}>;
|
|
75
|
+
export type ConsensusProposedTarget = z.infer<typeof ConsensusProposedTargetSchema>;
|
|
76
|
+
/**
|
|
77
|
+
* One mined consensus attribute.
|
|
78
|
+
*
|
|
79
|
+
* Specified verbatim by issue #1821 Workstream C — do not reorder or rename.
|
|
80
|
+
*
|
|
81
|
+
* Field semantics that are easy to get wrong:
|
|
82
|
+
* - `support` counts DISTINCT RUNS carrying the signal. A run that emits the
|
|
83
|
+
* same signal fifty times still contributes exactly one.
|
|
84
|
+
* - `successSupport` / `failureSupport` are likewise distinct-run counts, and a
|
|
85
|
+
* single run may appear in both when it carries the signal on a successful and
|
|
86
|
+
* a failing observation. They therefore do not have to sum to `support`.
|
|
87
|
+
* - `taskDiversity` counts distinct task identities (task id, else task
|
|
88
|
+
* category) among the contributing observations. It is the anecdote gate:
|
|
89
|
+
* below 2 the attribute is emitted as an investigation note only.
|
|
90
|
+
* - `modelDiversity` counts distinct model ids among the contributing
|
|
91
|
+
* observations, and is **0 when no contributing observation carries a model
|
|
92
|
+
* id at all** — trajectory-, usage-, and knowledge-derived attributes have no
|
|
93
|
+
* model attribution in the corpus. Zero therefore means "not measurable from
|
|
94
|
+
* this corpus", NOT "measured as none", and it must never gate emission on its
|
|
95
|
+
* own. See `docs/consensus-mining.md`.
|
|
96
|
+
* - `statement` is ALWAYS the deterministic rendering of the arithmetic. A model
|
|
97
|
+
* never replaces it. An optional model restatement lives in `llmSummary`,
|
|
98
|
+
* which is excluded from the report's integrity hash — see below.
|
|
99
|
+
*/
|
|
100
|
+
export interface ConsensusAttributeV1 {
|
|
101
|
+
v: 1;
|
|
102
|
+
id: string;
|
|
103
|
+
statement: string;
|
|
104
|
+
/**
|
|
105
|
+
* Optional LLM restatement of `statement`, admitted only through the miner's
|
|
106
|
+
* `FINDING:` whitelist: the first `FINDING:` line of one dispatch, carrying no
|
|
107
|
+
* bracket markup, no forged `[REDACTED:…]` marker, no listed reasoning marker
|
|
108
|
+
* and — once decimal points and at most one lower-case-continued
|
|
109
|
+
* abbreviation are masked — at most one sentence-terminator run, within
|
|
110
|
+
* `MAX_CONSENSUS_STATEMENT_CHARS` and never trimmed to fit. That bounds the
|
|
111
|
+
* SHAPE and SIZE of what a model can put here; it is not a claim that the
|
|
112
|
+
* admitted text cannot read as a multi-step narration — a semicolon- or
|
|
113
|
+
* dash-chained sentence can, and the guard does not stop it. See
|
|
114
|
+
* `extractRestatement` in `./miner.ts`.
|
|
115
|
+
*
|
|
116
|
+
* Separate from `statement`, and **excluded from `integrityHash`**, for one
|
|
117
|
+
* reason: `llm_summarization_enabled` defaults to `true`, and a model's
|
|
118
|
+
* wording is not reproducible. Folding it into the hashed content made "same
|
|
119
|
+
* inputs ⇒ identical hash" false by default, which in turn made `reportId`
|
|
120
|
+
* non-deterministic and defeated the point of a content-addressed immutable
|
|
121
|
+
* report. Cosmetic output does not get to move a content address.
|
|
122
|
+
*
|
|
123
|
+
* Absent whenever summarization is disabled, unavailable, or rejected by the
|
|
124
|
+
* restatement guard. Readers should render it as a convenience and treat
|
|
125
|
+
* `statement` as the authoritative text.
|
|
126
|
+
*/
|
|
127
|
+
llmSummary?: string;
|
|
128
|
+
support: number;
|
|
129
|
+
successSupport: number;
|
|
130
|
+
failureSupport: number;
|
|
131
|
+
taskDiversity: number;
|
|
132
|
+
modelDiversity: number;
|
|
133
|
+
evidenceRefs: string[];
|
|
134
|
+
counterexampleRefs: string[];
|
|
135
|
+
confidence: number;
|
|
136
|
+
proposedTarget: 'skill' | 'prompt' | 'tooling' | 'orchestration' | 'none';
|
|
137
|
+
}
|
|
138
|
+
export declare const ConsensusAttributeV1Schema: z.ZodObject<{
|
|
139
|
+
v: z.ZodLiteral<1>;
|
|
140
|
+
id: z.ZodString;
|
|
141
|
+
statement: z.ZodString;
|
|
142
|
+
llmSummary: z.ZodOptional<z.ZodString>;
|
|
143
|
+
support: z.ZodNumber;
|
|
144
|
+
successSupport: z.ZodNumber;
|
|
145
|
+
failureSupport: z.ZodNumber;
|
|
146
|
+
taskDiversity: z.ZodNumber;
|
|
147
|
+
modelDiversity: z.ZodNumber;
|
|
148
|
+
evidenceRefs: z.ZodArray<z.ZodString>;
|
|
149
|
+
counterexampleRefs: z.ZodArray<z.ZodString>;
|
|
150
|
+
confidence: z.ZodNumber;
|
|
151
|
+
proposedTarget: z.ZodEnum<{
|
|
152
|
+
tooling: "tooling";
|
|
153
|
+
none: "none";
|
|
154
|
+
prompt: "prompt";
|
|
155
|
+
skill: "skill";
|
|
156
|
+
orchestration: "orchestration";
|
|
157
|
+
}>;
|
|
158
|
+
}, z.core.$strict>;
|
|
159
|
+
/**
|
|
160
|
+
* A proposals-only change suggestion. The miner never applies one: it records
|
|
161
|
+
* what a human or a downstream gated workflow could choose to do.
|
|
162
|
+
*
|
|
163
|
+
* `intent` is deliberately *minimal* — one sentence describing the smallest
|
|
164
|
+
* change that would test the attribute. Anything longer invites the reader to
|
|
165
|
+
* treat a mined correlation as a specification.
|
|
166
|
+
*/
|
|
167
|
+
export interface ProposedSkillChange {
|
|
168
|
+
/**
|
|
169
|
+
* The `ConsensusAttributeV1.id` this proposal was derived from.
|
|
170
|
+
*
|
|
171
|
+
* Load-bearing, not decorative. It is what makes a report provenance-auditable
|
|
172
|
+
* — a reader can point at the exact attribute whose arithmetic produced the
|
|
173
|
+
* recommendation — and it is what
|
|
174
|
+
* `ConsensusReportV1Schema`'s investigation-note guard compares against. That
|
|
175
|
+
* guard previously tested `provenance.sourceEvidenceRefs` (corpus refs, e.g.
|
|
176
|
+
* `evaluation-run:r1:t1:0`) for membership in the set of attribute ids
|
|
177
|
+
* (`cattr_<16hex>`). Those namespaces are disjoint, so the check could never
|
|
178
|
+
* fire on real miner output: it was a guard in name only.
|
|
179
|
+
*/
|
|
180
|
+
sourceAttributeId: string;
|
|
181
|
+
/** Where the change would land, e.g. a skill slug or subsystem name. */
|
|
182
|
+
target: string;
|
|
183
|
+
/** Minimal, one-sentence statement of the smallest change worth trying. */
|
|
184
|
+
intent: string;
|
|
185
|
+
/** Supporting observations (evidence refs from the corpus). */
|
|
186
|
+
evidenceRefs: string[];
|
|
187
|
+
/** Contradicting observations. Never empty when the attribute has failures. */
|
|
188
|
+
counterexampleRefs: string[];
|
|
189
|
+
/** Inherited from the attribute; in [0, 1]. */
|
|
190
|
+
confidence: number;
|
|
191
|
+
/** The metric a validation run should move if the intent is correct. */
|
|
192
|
+
expectedMetric: string;
|
|
193
|
+
/** Deterministic selector describing which slice to validate against. */
|
|
194
|
+
validationSelector: string;
|
|
195
|
+
/** `computeRecommendationFingerprint({ kind: 'miner', ... })`. */
|
|
196
|
+
fingerprint: string;
|
|
197
|
+
/** `stampLearningProvenance` output for the `consensus_mine` mechanism. */
|
|
198
|
+
provenance: ProposedSkillChangeProvenance;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Structural mirror of `LearningProvenanceV1` (`src/learning/provenance.ts`).
|
|
202
|
+
*
|
|
203
|
+
* Every `source*` list here is **scoped to the attribute that produced this
|
|
204
|
+
* proposal** (issue #1821 AC23), not to the whole filtered corpus. A proposal
|
|
205
|
+
* that claimed the run, model, and task ids of every observation the miner
|
|
206
|
+
* looked at would be asserting provenance it does not have — and would be
|
|
207
|
+
* indistinguishable from every other proposal in the same report.
|
|
208
|
+
*
|
|
209
|
+
* Restated here rather than imported so the consensus store's on-disk contract
|
|
210
|
+
* is self-describing and this module keeps zero non-Zod dependencies; the miner
|
|
211
|
+
* still *produces* the value via `stampLearningProvenance`, so the two shapes
|
|
212
|
+
* cannot drift silently — a change there fails this schema's parse in tests.
|
|
213
|
+
*/
|
|
214
|
+
export interface ProposedSkillChangeProvenance {
|
|
215
|
+
v: 1;
|
|
216
|
+
mechanism: 'consensus_mine';
|
|
217
|
+
sourceKnowledgeIds: string[];
|
|
218
|
+
sourceTaskIds: string[];
|
|
219
|
+
sourceEvidenceRefs: string[];
|
|
220
|
+
sourceRunIds: string[];
|
|
221
|
+
sourceModelIds: string[];
|
|
222
|
+
/**
|
|
223
|
+
* Structurally identical to the shared `LearningWriteOriginSchema`; neither
|
|
224
|
+
* admits an `agentId`. (This comment previously said this shape was
|
|
225
|
+
* "narrower", which was true only until the same phantom field was removed
|
|
226
|
+
* from the shared schema — the two were fixed in separate passes of the same
|
|
227
|
+
* change.) Nothing on the consensus path can produce one:
|
|
228
|
+
* `MineConsensusDeps` has no `agentId` field, `buildProposals`'s options bag
|
|
229
|
+
* has no slot for it, and its `stampLearningProvenance` call passes exactly
|
|
230
|
+
* `producedAt` / `sessionId` / `agentRole`. Declaring a field no code path can
|
|
231
|
+
* reach documented a value that never exists, so the schema below — which is
|
|
232
|
+
* `.strict()` — now rejects it rather than reserving room for it (issue #1821).
|
|
233
|
+
*/
|
|
234
|
+
writeOrigin: {
|
|
235
|
+
sessionId?: string;
|
|
236
|
+
agentRole?: string;
|
|
237
|
+
producedAt: string;
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
export declare const ProposedSkillChangeSchema: z.ZodObject<{
|
|
241
|
+
sourceAttributeId: z.ZodString;
|
|
242
|
+
target: z.ZodString;
|
|
243
|
+
intent: z.ZodString;
|
|
244
|
+
evidenceRefs: z.ZodArray<z.ZodString>;
|
|
245
|
+
counterexampleRefs: z.ZodArray<z.ZodString>;
|
|
246
|
+
confidence: z.ZodNumber;
|
|
247
|
+
expectedMetric: z.ZodString;
|
|
248
|
+
validationSelector: z.ZodString;
|
|
249
|
+
fingerprint: z.ZodString;
|
|
250
|
+
provenance: z.ZodObject<{
|
|
251
|
+
v: z.ZodLiteral<1>;
|
|
252
|
+
mechanism: z.ZodLiteral<"consensus_mine">;
|
|
253
|
+
sourceKnowledgeIds: z.ZodArray<z.ZodString>;
|
|
254
|
+
sourceTaskIds: z.ZodArray<z.ZodString>;
|
|
255
|
+
sourceEvidenceRefs: z.ZodArray<z.ZodString>;
|
|
256
|
+
sourceRunIds: z.ZodArray<z.ZodString>;
|
|
257
|
+
sourceModelIds: z.ZodArray<z.ZodString>;
|
|
258
|
+
writeOrigin: z.ZodObject<{
|
|
259
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
260
|
+
agentRole: z.ZodOptional<z.ZodString>;
|
|
261
|
+
producedAt: z.ZodISODateTime;
|
|
262
|
+
}, z.core.$strict>;
|
|
263
|
+
}, z.core.$strict>;
|
|
264
|
+
}, z.core.$strict>;
|
|
265
|
+
/** The corpus readers the miner is allowed to draw from. */
|
|
266
|
+
declare const ConsensusSourceKindSchema: z.ZodEnum<{
|
|
267
|
+
knowledge: "knowledge";
|
|
268
|
+
"gate-audit": "gate-audit";
|
|
269
|
+
"evaluation-run": "evaluation-run";
|
|
270
|
+
"gate-ground-truth": "gate-ground-truth";
|
|
271
|
+
"task-trajectory": "task-trajectory";
|
|
272
|
+
"prm-session": "prm-session";
|
|
273
|
+
"skill-usage": "skill-usage";
|
|
274
|
+
"evidence-bundle": "evidence-bundle";
|
|
275
|
+
"curated-failure": "curated-failure";
|
|
276
|
+
}>;
|
|
277
|
+
export type ConsensusSourceKind = z.infer<typeof ConsensusSourceKindSchema>;
|
|
278
|
+
/** Per-source content fingerprint, so a report declares what it actually read. */
|
|
279
|
+
export interface ConsensusCorpusHash {
|
|
280
|
+
source: ConsensusSourceKind;
|
|
281
|
+
hash: string;
|
|
282
|
+
observations: number;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Everything this report dropped, and why.
|
|
286
|
+
*
|
|
287
|
+
* Persisted rather than returned-only, because every one of these cuts changes
|
|
288
|
+
* what the report *means*. A reader who cannot tell that the corpus was capped
|
|
289
|
+
* cannot tell whether `failureSupport: 0` means "nothing failed" or "the
|
|
290
|
+
* failures were truncated away", and a reader who cannot see that the attribute
|
|
291
|
+
* array was capped will read a partial list as a complete one. Silence here is
|
|
292
|
+
* the difference between an incomplete report and a misleading one.
|
|
293
|
+
*/
|
|
294
|
+
export interface ConsensusTruncationV1 {
|
|
295
|
+
/** `maxEvidenceItems` cut the corpus before tallying. */
|
|
296
|
+
corpus: boolean;
|
|
297
|
+
/** Observations actually tallied, after filtering and after the corpus cut. */
|
|
298
|
+
observations: number;
|
|
299
|
+
/** `inputIds` was cut at `MAX_CONSENSUS_REFS`. */
|
|
300
|
+
inputIds: boolean;
|
|
301
|
+
/** Distinct run ids in the filtered corpus, before the `inputIds` cut. */
|
|
302
|
+
totalInputIds: number;
|
|
303
|
+
/**
|
|
304
|
+
* Attributes dropped by the producer-side `MAX_CONSENSUS_ATTRIBUTES` cap.
|
|
305
|
+
*
|
|
306
|
+
* There is deliberately no `proposalsDropped` counterpart. The miner emits at
|
|
307
|
+
* most one proposal per attribute and deduplication only removes, so
|
|
308
|
+
* `proposals.length <= attributes.length <= MAX_CONSENSUS_ATTRIBUTES`, and
|
|
309
|
+
* `MAX_CONSENSUS_PROPOSALS` equals `MAX_CONSENSUS_ATTRIBUTES`. A producer-side
|
|
310
|
+
* proposal cap would therefore be an unreachable branch reporting a
|
|
311
|
+
* permanently-zero count, which is worse than not having one.
|
|
312
|
+
*/
|
|
313
|
+
attributesDropped: number;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* One immutable mining report under `.swarm/evolution/consensus/<reportId>.json`.
|
|
317
|
+
*
|
|
318
|
+
* `integrityHash` covers every field EXCEPT `integrityHash`, `reportId`,
|
|
319
|
+
* `generatedAt`, each proposal's ENTIRE `provenance.writeOrigin` — `producedAt`
|
|
320
|
+
* *and* the `sessionId` / `agentRole`, which are the only three fields this
|
|
321
|
+
* path can populate — and each attribute's
|
|
322
|
+
* `llmSummary`. Each exclusion has its own reason: `integrityHash` cannot cover
|
|
323
|
+
* itself and `reportId` is derived from it, so both would be circular;
|
|
324
|
+
* `generatedAt` and `producedAt` are wall clocks; the `writeOrigin` identity
|
|
325
|
+
* fields say *who* ran the mine, which must not be able to change what the mine
|
|
326
|
+
* found (`sessionId` comes from `ctx.sessionID`, so while it was hashed two
|
|
327
|
+
* sessions mining a byte-identical corpus produced two different reports); and
|
|
328
|
+
* `llmSummary` is non-reproducible model prose that `llm_summarization_enabled`
|
|
329
|
+
* turns on by default, so hashing it would make "same inputs ⇒ identical hash"
|
|
330
|
+
* false in the default configuration. See `computeConsensusIntegrityHash`.
|
|
331
|
+
*/
|
|
332
|
+
export interface ConsensusReportV1 {
|
|
333
|
+
v: 1;
|
|
334
|
+
reportId: string;
|
|
335
|
+
generatedAt: string;
|
|
336
|
+
request: ConsensusMineRequest;
|
|
337
|
+
inputIds: string[];
|
|
338
|
+
corpusHashes: ConsensusCorpusHash[];
|
|
339
|
+
configHash: string;
|
|
340
|
+
integrityHash: string;
|
|
341
|
+
attributes: ConsensusAttributeV1[];
|
|
342
|
+
proposals: ProposedSkillChange[];
|
|
343
|
+
truncation: ConsensusTruncationV1;
|
|
344
|
+
redactionPolicyVersion: number;
|
|
345
|
+
}
|
|
346
|
+
export declare const ConsensusReportV1Schema: z.ZodObject<{
|
|
347
|
+
v: z.ZodLiteral<1>;
|
|
348
|
+
reportId: z.ZodString;
|
|
349
|
+
generatedAt: z.ZodISODateTime;
|
|
350
|
+
request: z.ZodObject<{
|
|
351
|
+
runIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
352
|
+
taskCategories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
353
|
+
agentRoles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
354
|
+
modelIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
355
|
+
minSupport: z.ZodNumber;
|
|
356
|
+
minSuccessfulRuns: z.ZodNumber;
|
|
357
|
+
maxEvidenceItems: z.ZodNumber;
|
|
358
|
+
}, z.core.$strict>;
|
|
359
|
+
inputIds: z.ZodArray<z.ZodString>;
|
|
360
|
+
corpusHashes: z.ZodArray<z.ZodObject<{
|
|
361
|
+
source: z.ZodEnum<{
|
|
362
|
+
knowledge: "knowledge";
|
|
363
|
+
"gate-audit": "gate-audit";
|
|
364
|
+
"evaluation-run": "evaluation-run";
|
|
365
|
+
"gate-ground-truth": "gate-ground-truth";
|
|
366
|
+
"task-trajectory": "task-trajectory";
|
|
367
|
+
"prm-session": "prm-session";
|
|
368
|
+
"skill-usage": "skill-usage";
|
|
369
|
+
"evidence-bundle": "evidence-bundle";
|
|
370
|
+
"curated-failure": "curated-failure";
|
|
371
|
+
}>;
|
|
372
|
+
hash: z.ZodString;
|
|
373
|
+
observations: z.ZodNumber;
|
|
374
|
+
}, z.core.$strict>>;
|
|
375
|
+
configHash: z.ZodString;
|
|
376
|
+
integrityHash: z.ZodString;
|
|
377
|
+
attributes: z.ZodArray<z.ZodObject<{
|
|
378
|
+
v: z.ZodLiteral<1>;
|
|
379
|
+
id: z.ZodString;
|
|
380
|
+
statement: z.ZodString;
|
|
381
|
+
llmSummary: z.ZodOptional<z.ZodString>;
|
|
382
|
+
support: z.ZodNumber;
|
|
383
|
+
successSupport: z.ZodNumber;
|
|
384
|
+
failureSupport: z.ZodNumber;
|
|
385
|
+
taskDiversity: z.ZodNumber;
|
|
386
|
+
modelDiversity: z.ZodNumber;
|
|
387
|
+
evidenceRefs: z.ZodArray<z.ZodString>;
|
|
388
|
+
counterexampleRefs: z.ZodArray<z.ZodString>;
|
|
389
|
+
confidence: z.ZodNumber;
|
|
390
|
+
proposedTarget: z.ZodEnum<{
|
|
391
|
+
tooling: "tooling";
|
|
392
|
+
none: "none";
|
|
393
|
+
prompt: "prompt";
|
|
394
|
+
skill: "skill";
|
|
395
|
+
orchestration: "orchestration";
|
|
396
|
+
}>;
|
|
397
|
+
}, z.core.$strict>>;
|
|
398
|
+
proposals: z.ZodArray<z.ZodObject<{
|
|
399
|
+
sourceAttributeId: z.ZodString;
|
|
400
|
+
target: z.ZodString;
|
|
401
|
+
intent: z.ZodString;
|
|
402
|
+
evidenceRefs: z.ZodArray<z.ZodString>;
|
|
403
|
+
counterexampleRefs: z.ZodArray<z.ZodString>;
|
|
404
|
+
confidence: z.ZodNumber;
|
|
405
|
+
expectedMetric: z.ZodString;
|
|
406
|
+
validationSelector: z.ZodString;
|
|
407
|
+
fingerprint: z.ZodString;
|
|
408
|
+
provenance: z.ZodObject<{
|
|
409
|
+
v: z.ZodLiteral<1>;
|
|
410
|
+
mechanism: z.ZodLiteral<"consensus_mine">;
|
|
411
|
+
sourceKnowledgeIds: z.ZodArray<z.ZodString>;
|
|
412
|
+
sourceTaskIds: z.ZodArray<z.ZodString>;
|
|
413
|
+
sourceEvidenceRefs: z.ZodArray<z.ZodString>;
|
|
414
|
+
sourceRunIds: z.ZodArray<z.ZodString>;
|
|
415
|
+
sourceModelIds: z.ZodArray<z.ZodString>;
|
|
416
|
+
writeOrigin: z.ZodObject<{
|
|
417
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
418
|
+
agentRole: z.ZodOptional<z.ZodString>;
|
|
419
|
+
producedAt: z.ZodISODateTime;
|
|
420
|
+
}, z.core.$strict>;
|
|
421
|
+
}, z.core.$strict>;
|
|
422
|
+
}, z.core.$strict>>;
|
|
423
|
+
truncation: z.ZodObject<{
|
|
424
|
+
corpus: z.ZodBoolean;
|
|
425
|
+
observations: z.ZodNumber;
|
|
426
|
+
inputIds: z.ZodBoolean;
|
|
427
|
+
totalInputIds: z.ZodNumber;
|
|
428
|
+
attributesDropped: z.ZodNumber;
|
|
429
|
+
}, z.core.$strict>;
|
|
430
|
+
redactionPolicyVersion: z.ZodNumber;
|
|
431
|
+
}, z.core.$strict>;
|
|
432
|
+
/**
|
|
433
|
+
* Compile-time assertions that each Zod schema's inferred output is assignable
|
|
434
|
+
* to the hand-written interface the issue specified verbatim. A renamed field or
|
|
435
|
+
* a widened type on either side becomes a type error here rather than a runtime
|
|
436
|
+
* surprise at the store boundary.
|
|
437
|
+
*
|
|
438
|
+
* These four are `export`ed with no importer ON PURPOSE. They are type-level
|
|
439
|
+
* assertions, not API: the `export` is what keeps them from reading as unused
|
|
440
|
+
* locals, and they are erased entirely at build time.
|
|
441
|
+
*
|
|
442
|
+
* ## Declared export carve-out for the whole subsystem
|
|
443
|
+
*
|
|
444
|
+
* The carve-out covers TYPES ONLY, and that boundary is the whole point. Every
|
|
445
|
+
* runtime VALUE `src/consensus/` exports — every schema, constant, function,
|
|
446
|
+
* and error class — has a by-name importer, in a sibling module or a test.
|
|
447
|
+
* `ProposedSkillChangeSchema` was the one exception and is no longer one:
|
|
448
|
+
* `tests/unit/consensus/contracts-proposal.test.ts` exercises the bounds the
|
|
449
|
+
* miner mirrors (the `lrec_<16hex>` fingerprint shape and the 1024-character
|
|
450
|
+
* `validationSelector` cap), which is coverage the embedding
|
|
451
|
+
* `ConsensusReportV1Schema` tests did not provide. A value export with no
|
|
452
|
+
* importer is unwired code, not a carve-out candidate — that is exactly why the
|
|
453
|
+
* `consensusV1` namespace and the `index.ts` barrel were deleted.
|
|
454
|
+
*
|
|
455
|
+
* Those four assertions are, however, not the only exported TYPES with no
|
|
456
|
+
* by-name importer. Eight more have none either:
|
|
457
|
+
*
|
|
458
|
+
* - `KnowledgeLike` and `LoadCorpusOptions` (`./corpus.ts`)
|
|
459
|
+
* - `MineConsensusResult` and `ConsensusReportIntegrityInput` (`./miner.ts`)
|
|
460
|
+
* - `MineAndStoreConsensusOptions` / `MineAndStoreConsensusResult`
|
|
461
|
+
* (`./public-api.ts`)
|
|
462
|
+
* - `ConsensusListSummary` and `ConsensusPruneResult` (`./store.ts`)
|
|
463
|
+
*
|
|
464
|
+
* They stay exported because every one is the declared parameter or return
|
|
465
|
+
* shape of an exported function (`loadConsensusCorpus`, `mineConsensus`,
|
|
466
|
+
* `computeConsensusIntegrityHash`, `mineAndStoreConsensusV1`,
|
|
467
|
+
* `listConsensusReports`, `pruneConsensusReports`) or a field type of an
|
|
468
|
+
* exported interface (`CorpusReaders`). A caller cannot annotate a variable
|
|
469
|
+
* holding one of those results without them, and hiding them would break
|
|
470
|
+
* `declaration`-emitting builds. Deleting a type that an exported signature
|
|
471
|
+
* already hands out removes a name, not a surface — and unlike a value, it is
|
|
472
|
+
* erased at build time, so it ships nothing.
|
|
473
|
+
*/
|
|
474
|
+
type AssertAssignable<Actual extends Expected, Expected> = Actual;
|
|
475
|
+
export type _ConsensusMineRequestAssignable = AssertAssignable<z.infer<typeof ConsensusMineRequestSchema>, ConsensusMineRequest>;
|
|
476
|
+
export type _ConsensusAttributeAssignable = AssertAssignable<z.infer<typeof ConsensusAttributeV1Schema>, ConsensusAttributeV1>;
|
|
477
|
+
export type _ProposedSkillChangeAssignable = AssertAssignable<z.infer<typeof ProposedSkillChangeSchema>, ProposedSkillChange>;
|
|
478
|
+
export type _ConsensusReportAssignable = AssertAssignable<z.infer<typeof ConsensusReportV1Schema>, ConsensusReportV1>;
|
|
479
|
+
export {};
|