@evomap/evolver-cli 2.0.0-beta.8 → 2.0.0-beta.9

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.
@@ -0,0 +1,13 @@
1
+ import { type algo, type assetstore } from '@evomap/evolver-core';
2
+ import { type DraftAdmission, type DraftAdmissionOptions, type ExistingGeneSignals } from './distillPrimitives.js';
3
+ export interface StoreDraftAdmission {
4
+ admission: DraftAdmission;
5
+ existing: ExistingGeneSignals[];
6
+ }
7
+ /**
8
+ * Build the complete dedupe context without loading the entire pool. Any subset or positive-Jaccard duplicate must
9
+ * share at least one candidate signal, so a store-side signalsAny query is complete for admission while excluding
10
+ * unrelated Genes. MAX_SAFE_INTEGER deliberately removes the provider's default result window; silently accepting
11
+ * a duplicate after row 1000 is worse than evaluating all signal-related rows in a mature pool.
12
+ */
13
+ export declare function assessDraftAdmissionFromStore(store: Pick<assetstore.AssetStoreProvider, 'search'>, candidate: algo.GeneCandidate, additional?: readonly ExistingGeneSignals[], opts?: DraftAdmissionOptions): Promise<StoreDraftAdmission>;
@@ -0,0 +1,35 @@
1
+ import {} from '@evomap/evolver-core';
2
+ import { assessDraftAdmission, } from './distillPrimitives.js';
3
+ function normalizedCandidateSignals(candidate) {
4
+ return [...new Set((candidate.signals_match ?? [])
5
+ .map((signal) => String(signal).trim().toLowerCase())
6
+ .filter(Boolean))];
7
+ }
8
+ function geneSignalRef(record) {
9
+ if (record.type !== 'Gene')
10
+ return null;
11
+ return {
12
+ id: typeof record['id'] === 'string' ? String(record['id']) : undefined,
13
+ signals_match: Array.isArray(record['signals_match']) ? record['signals_match'] : [],
14
+ };
15
+ }
16
+ /**
17
+ * Build the complete dedupe context without loading the entire pool. Any subset or positive-Jaccard duplicate must
18
+ * share at least one candidate signal, so a store-side signalsAny query is complete for admission while excluding
19
+ * unrelated Genes. MAX_SAFE_INTEGER deliberately removes the provider's default result window; silently accepting
20
+ * a duplicate after row 1000 is worse than evaluating all signal-related rows in a mature pool.
21
+ */
22
+ export async function assessDraftAdmissionFromStore(store, candidate, additional = [], opts = {}) {
23
+ const intrinsic = assessDraftAdmission(candidate, [], opts);
24
+ if (!intrinsic.admit)
25
+ return { admission: intrinsic, existing: [...additional] };
26
+ const signalsAny = normalizedCandidateSignals(candidate);
27
+ const stored = signalsAny.length > 0
28
+ ? await store.search({ kind: 'Gene', signalsAny, limit: Number.MAX_SAFE_INTEGER })
29
+ : [];
30
+ const existing = [
31
+ ...stored.map(geneSignalRef).filter((ref) => ref !== null),
32
+ ...additional,
33
+ ];
34
+ return { admission: assessDraftAdmission(candidate, existing, opts), existing };
35
+ }
@@ -11,7 +11,8 @@
11
11
  // wired into autoexec — a tracked dependency, not dead code. See distillObserver.test.ts.
12
12
  import { assetstore, events, observers, signals, algo } from '@evomap/evolver-core';
13
13
  import { readFileSync } from 'node:fs';
14
- import { draftGeneCandidate, assessDraftAdmission } from './distillPrimitives.js';
14
+ import { draftGeneCandidate } from './distillPrimitives.js';
15
+ import { assessDraftAdmissionFromStore } from './distillAdmission.js';
15
16
  import { reviewLedgerForStore } from './reviewFilter.js';
16
17
  import { runtimeSessionSourcesForMaterial } from './materialSnapshot.js';
17
18
  /** Consumer group the distill drain claims under — independent cursor from any other material consumer. */
@@ -49,13 +50,10 @@ export function makeDistillDrain(c) {
49
50
  const candidate = draftGeneCandidate(source.turns, signals.extractSignals(source.turns), source.agent);
50
51
  if (!candidate)
51
52
  continue; // too thin to distill
52
- const existing = (await c.store.list('Gene', 1000)).map((g) => ({
53
- id: typeof g['id'] === 'string' ? String(g['id']) : undefined,
54
- signals_match: Array.isArray(g['signals_match']) ? g['signals_match'] : [],
55
- }));
56
53
  // Value/novelty gate (#117 improvement 3): drop thin / near-duplicate drafts BEFORE they reach the human
57
54
  // review queue. Ack the material (a deliberate skip, not a failure — nothing to retry).
58
- if (!assessDraftAdmission(candidate, existing).admit)
55
+ const { admission, existing } = await assessDraftAdmissionFromStore(c.store, candidate);
56
+ if (!admission.admit)
59
57
  continue;
60
58
  const r = algo.intakeGene(candidate, existing);
61
59
  if (!r.ok || !r.gene)
@@ -30,11 +30,9 @@ export interface DraftAdmissionOptions {
30
30
  /** Reject a draft with fewer strategy steps than this (default 1, i.e. just non-empty like intakeGene; raise it
31
31
  * for a stricter substance floor). A real fix can be one concrete step, so the default does not over-filter. */
32
32
  minStrategy?: number;
33
- /** Reject a draft whose signal-set Jaccard similarity to ANY existing gene is >= this (default 0.6).
34
- * Signal sets are capped at 8 tokens, so two same-size sets differing by ONE token score 7/9 ≈ 0.78 —
35
- * the old 0.8 default could never fire on the dominant draft shape (#562: 118-draft flood, max pairwise
36
- * similarity exactly 0.78, zero rejections). 0.6 rejects shared-core near-dupes while genuinely
37
- * cross-domain drafts (less than half the tokens shared) still pass. */
33
+ /** Reject a draft whose discriminating-signal Jaccard similarity to ANY existing gene is >= this (default 0.6).
34
+ * Generated fallback markers and generic command runners are omitted from this SOFT comparison, while the
35
+ * exact-subset check still uses the complete signal sets. */
38
36
  maxSimilarity?: number;
39
37
  }
40
38
  export interface DraftAdmission {
@@ -43,10 +41,10 @@ export interface DraftAdmission {
43
41
  }
44
42
  /**
45
43
  * Value/novelty gate run BEFORE a draft is quarantined (#117 improvement 3). `intakeGene` already rejects
46
- * empty/structurally-invalid candidates and EXACT signal subsets (fullyOverlaps), but two kinds of noise still
47
- * reach the human review queue: drafts too thin to be worth reviewing (one weak signal, one vague step), and
48
- * near-duplicates that escape the subset check by carrying one extra signal. Unattended auto-distill turns that
49
- * trickle into a flood, and a review gate nobody reads is no gate. This adds a substance floor + a SOFT similarity
50
- * reject. Pure and deterministic; the caller decides what to do with a non-admit (skip, never an error).
44
+ * empty/structurally-invalid candidates and EXACT signal subsets (fullyOverlaps). Admission mirrors that subset
45
+ * check so a duplicate is a per-candidate skip instead of aborting a whole batch, then adds the two missing noise
46
+ * controls: a substance floor and a SOFT near-duplicate comparison. Unattended auto-distill turns that trickle
47
+ * into a flood, and a review gate nobody reads is no gate. Pure and deterministic; the caller decides what to do
48
+ * with a non-admit (skip, never an error).
51
49
  */
52
50
  export declare function assessDraftAdmission(candidate: algo.GeneCandidate, existing?: readonly ExistingGeneSignals[], opts?: DraftAdmissionOptions): DraftAdmission;
@@ -136,19 +136,40 @@ export function draftGeneCandidate(turns, sigs, agent) {
136
136
  generation_meta: { source: 'distilled' },
137
137
  };
138
138
  }
139
+ // Signals injected by the fallback itself, plus generic command runners, carry no domain identity. Including them
140
+ // in Jaccard makes unrelated capabilities (for example GitHub vs Playwright) look 60% identical even though their
141
+ // one discriminating signal differs. Keep them for exact-subset detection, but omit them from soft similarity.
142
+ const GENERIC_NOVELTY_SIGNALS = new Set([
143
+ 'reusable_capability',
144
+ 'verified_workflow',
145
+ 'shell_command',
146
+ 'bash',
147
+ 'powershell',
148
+ 'pwsh',
149
+ 'sh',
150
+ 'cmd',
151
+ 'command',
152
+ ]);
153
+ function normalizeSignalSet(values) {
154
+ return new Set((values ?? []).map((value) => String(value).trim().toLowerCase()).filter(Boolean));
155
+ }
156
+ function noveltySignalSet(signals) {
157
+ const discriminating = [...signals].filter((signal) => !GENERIC_NOVELTY_SIGNALS.has(signal));
158
+ return discriminating.length > 0 ? new Set(discriminating) : signals;
159
+ }
139
160
  /**
140
161
  * Value/novelty gate run BEFORE a draft is quarantined (#117 improvement 3). `intakeGene` already rejects
141
- * empty/structurally-invalid candidates and EXACT signal subsets (fullyOverlaps), but two kinds of noise still
142
- * reach the human review queue: drafts too thin to be worth reviewing (one weak signal, one vague step), and
143
- * near-duplicates that escape the subset check by carrying one extra signal. Unattended auto-distill turns that
144
- * trickle into a flood, and a review gate nobody reads is no gate. This adds a substance floor + a SOFT similarity
145
- * reject. Pure and deterministic; the caller decides what to do with a non-admit (skip, never an error).
162
+ * empty/structurally-invalid candidates and EXACT signal subsets (fullyOverlaps). Admission mirrors that subset
163
+ * check so a duplicate is a per-candidate skip instead of aborting a whole batch, then adds the two missing noise
164
+ * controls: a substance floor and a SOFT near-duplicate comparison. Unattended auto-distill turns that trickle
165
+ * into a flood, and a review gate nobody reads is no gate. Pure and deterministic; the caller decides what to do
166
+ * with a non-admit (skip, never an error).
146
167
  */
147
168
  export function assessDraftAdmission(candidate, existing = [], opts = {}) {
148
169
  const minSignals = opts.minSignals ?? 2;
149
170
  const minStrategy = opts.minStrategy ?? 1;
150
171
  const maxSimilarity = opts.maxSimilarity ?? 0.6;
151
- const sigs = [...new Set((candidate.signals_match ?? []).map((s) => String(s).toLowerCase()).filter(Boolean))];
172
+ const sigs = [...normalizeSignalSet(candidate.signals_match)];
152
173
  const strategy = (candidate.strategy ?? []).filter((s) => String(s).trim());
153
174
  if (sigs.length < minSignals)
154
175
  return { admit: false, reason: `too few signals (${sigs.length} < ${minSignals})` };
@@ -156,11 +177,16 @@ export function assessDraftAdmission(candidate, existing = [], opts = {}) {
156
177
  return { admit: false, reason: `strategy too thin (${strategy.length} < ${minStrategy} steps)` };
157
178
  const newSet = new Set(sigs);
158
179
  for (const eg of existing) {
159
- const egSet = new Set((eg.signals_match ?? []).map((s) => String(s).toLowerCase()).filter(Boolean));
180
+ const egSet = normalizeSignalSet(eg.signals_match);
160
181
  if (egSet.size === 0)
161
182
  continue;
162
- const inter = [...newSet].filter((s) => egSet.has(s)).length;
163
- const union = new Set([...newSet, ...egSet]).size;
183
+ if ([...newSet].every((signal) => egSet.has(signal))) {
184
+ return { admit: false, reason: `near-duplicate of ${eg.id ?? '?'} (candidate signal subset)` };
185
+ }
186
+ const comparableNew = noveltySignalSet(newSet);
187
+ const comparableExisting = noveltySignalSet(egSet);
188
+ const inter = [...comparableNew].filter((s) => comparableExisting.has(s)).length;
189
+ const union = new Set([...comparableNew, ...comparableExisting]).size;
164
190
  const jaccard = union ? inter / union : 0;
165
191
  if (jaccard >= maxSimilarity)
166
192
  return { admit: false, reason: `near-duplicate of ${eg.id ?? '?'} (similarity ${jaccard.toFixed(2)})` };
package/dist/index.js CHANGED
@@ -7,7 +7,8 @@ import { loadEnvFileFromEnv } from '@evomap/evolver-mcp';
7
7
  import { makeInjectEmitter } from './autoexec.js';
8
8
  import { listApprovedGenes, provenanceStoreForStore, reviewLedgerForStore } from './reviewFilter.js';
9
9
  import { ADAPTERS, parseJsonlLines } from '@evomap/evolver-runtime-adapters';
10
- import { assessDraftAdmission, draftGeneCandidate } from './distillPrimitives.js';
10
+ import { draftGeneCandidate } from './distillPrimitives.js';
11
+ import { assessDraftAdmissionFromStore } from './distillAdmission.js';
11
12
  import { emitSessionRecall } from './autoRecall.js';
12
13
  import { isRuntimeSessionSourcePath, parseRuntimeSessionSourcesWithDiagnostics } from './runtimeSessionSource.js';
13
14
  import { existsSync, readFileSync, readdirSync, statSync, unlinkSync } from 'node:fs';
@@ -706,10 +707,7 @@ export async function runIngest(argv, store, deps = {}, review) {
706
707
  // --distill: assemble + intake UNPROVEN draft genes per runtime session (shared draft logic — see distillPrimitives).
707
708
  const s = store ?? new assetstore.LocalJsonlProvider(events.assetsDir());
708
709
  const accepted = [];
709
- let existing = (await s.list('Gene', 1000)).map((g) => ({
710
- id: typeof g['id'] === 'string' ? String(g['id']) : undefined,
711
- signals_match: Array.isArray(g['signals_match']) ? g['signals_match'] : [],
712
- }));
710
+ const acceptedSignals = [];
713
711
  let candidateCount = 0;
714
712
  let admissionSkipped = 0;
715
713
  let lastAdmissionSkipReason = '';
@@ -721,7 +719,7 @@ export async function runIngest(argv, store, deps = {}, review) {
721
719
  // Same value/novelty gate as the live distillObserver (#562): without it, a bulk ingest over session
722
720
  // history floods the human review queue with thin / near-duplicate drafts (118 in one run). A non-admit
723
721
  // is a deliberate skip — the rest of the batch still distills; intake below stays the structural gate.
724
- const admission = assessDraftAdmission(candidate, existing);
722
+ const { admission, existing } = await assessDraftAdmissionFromStore(s, candidate, acceptedSignals);
725
723
  if (!admission.admit) {
726
724
  admissionSkipped += 1;
727
725
  lastAdmissionSkipReason = admission.reason ?? '';
@@ -734,7 +732,7 @@ export async function runIngest(argv, store, deps = {}, review) {
734
732
  return 1;
735
733
  }
736
734
  accepted.push({ source, candidate, gene: r.gene });
737
- existing = [...existing, { id: r.gene.id, signals_match: r.gene.signals_match }];
735
+ acceptedSignals.push({ id: r.gene.id, signals_match: r.gene.signals_match });
738
736
  }
739
737
  if (accepted.length === 0) {
740
738
  if (candidateCount > 0 && admissionSkipped === candidateCount) {
@@ -1,7 +1,8 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { assetstore, algo, events, hub, material as materialNs, schema, signals } from '@evomap/evolver-core';
3
3
  import { runtimeSessionSourcesForMaterial, runtimeSessionSourcesFromMaterialPayload } from './materialSnapshot.js';
4
- import { assessDraftAdmission, draftGeneCandidate } from './distillPrimitives.js';
4
+ import { draftGeneCandidate } from './distillPrimitives.js';
5
+ import { assessDraftAdmissionFromStore } from './distillAdmission.js';
5
6
  import { reviewLedgerForStore } from './reviewFilter.js';
6
7
  import { buildPublishBundle } from './cliContracts.js';
7
8
  const GROUP = 'material.package_gene';
@@ -165,10 +166,6 @@ async function draftGeneFromMaterial(material, store, readSource) {
165
166
  }
166
167
  if (sources.length === 0)
167
168
  return { blocker: 'source_unavailable', message: 'material has no usable runtime session source', sourceCount: 0, signalCount: 0 };
168
- const existing = (await store.list('Gene', 10_000)).map((g) => ({
169
- id: typeof g['id'] === 'string' ? String(g['id']) : undefined,
170
- signals_match: Array.isArray(g['signals_match']) ? g['signals_match'] : [],
171
- }));
172
169
  let signalCount = 0;
173
170
  let sawCandidate = false;
174
171
  let lastIntakeError = '';
@@ -188,7 +185,7 @@ async function draftGeneFromMaterial(material, store, readSource) {
188
185
  if (alreadyStored?.type === 'Gene') {
189
186
  return { gene: alreadyStored, sourceCount: sources.length, signalCount, stored: true };
190
187
  }
191
- const admission = assessDraftAdmission(candidate, existing);
188
+ const { admission, existing } = await assessDraftAdmissionFromStore(store, candidate);
192
189
  if (!admission.admit) {
193
190
  lastIntakeError = admission.reason ?? 'gene draft admission rejected the candidate';
194
191
  continue;
package/dist/reuse.js CHANGED
@@ -175,6 +175,7 @@ class ReuseIntegrityError extends Error {
175
175
  }
176
176
  const INTEGRITY_MISMATCH_MESSAGE = 'hub-delivered content does not match the asset content fingerprint';
177
177
  const INTEGRITY_BACKFILLED_MESSAGE = 'hub delivered a synthesized payload for this asset; the original published content is unavailable for verification';
178
+ const INTEGRITY_LOGICAL_ID_MESSAGE = 'hub-delivered asset does not match the requested logical id';
178
179
  function integrityError(content) {
179
180
  const backfilled = stringField(content, 'payload_backfill_reason') !== undefined;
180
181
  return new ReuseIntegrityError(backfilled ? INTEGRITY_BACKFILLED_MESSAGE : INTEGRITY_MISMATCH_MESSAGE);
@@ -190,7 +191,7 @@ async function ingestHubAsset(store, deps, asset, requestedId) {
190
191
  throw integrityError(cleaned);
191
192
  }
192
193
  if (!isContentAssetId(requestedId) && stringField(cleaned, 'id') !== requestedId) {
193
- throw integrityError(cleaned);
194
+ throw new ReuseIntegrityError(INTEGRITY_LOGICAL_ID_MESSAGE);
194
195
  }
195
196
  await assertNoLocalReuseIdConflict(cleaned, store);
196
197
  const provenance = new assetstore.ProvenanceStore(storeBaseDir(store, deps));
@@ -227,7 +228,12 @@ async function assertNoLocalReuseIdConflict(asset, store) {
227
228
  function unwrapHubAssetContent(asset) {
228
229
  const payload = asset.payload;
229
230
  if (payload && typeof payload === 'object' && !Array.isArray(payload) && stringField(payload, 'asset_id')) {
230
- return payload;
231
+ const content = payload;
232
+ const backfillReason = stringField(asset, 'payload_backfill_reason');
233
+ if (backfillReason && stringField(payload, 'payload_backfill_reason') === undefined) {
234
+ return { ...content, payload_backfill_reason: backfillReason };
235
+ }
236
+ return content;
231
237
  }
232
238
  return asset;
233
239
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evomap/evolver-cli",
3
- "version": "2.0.0-beta.8",
3
+ "version": "2.0.0-beta.9",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "evolver CLI (status/watch/cycles/rebuild-views/...)",
@@ -20,12 +20,12 @@
20
20
  }
21
21
  },
22
22
  "dependencies": {
23
- "@evomap/evolver-core": "2.0.0-beta.8",
24
- "@evomap/evolver-adapter-public": "2.0.0-beta.8",
25
- "@evomap/evolver-mcp": "2.0.0-beta.8",
26
- "@evomap/evolver-proxy": "2.0.0-beta.8",
27
- "@evomap/evolver-runtime-adapters": "2.0.0-beta.8",
28
- "@evomap/evolver-webui": "2.0.0-beta.8"
23
+ "@evomap/evolver-core": "2.0.0-beta.9",
24
+ "@evomap/evolver-adapter-public": "2.0.0-beta.9",
25
+ "@evomap/evolver-mcp": "2.0.0-beta.9",
26
+ "@evomap/evolver-proxy": "2.0.0-beta.9",
27
+ "@evomap/evolver-runtime-adapters": "2.0.0-beta.9",
28
+ "@evomap/evolver-webui": "2.0.0-beta.9"
29
29
  },
30
30
  "repository": {
31
31
  "type": "git",