@evomap/evolver-cli 2.0.32 → 2.0.34

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/atp.js CHANGED
@@ -300,7 +300,12 @@ export function createAtpClientFromEnv(env = process.env) {
300
300
  const senderId = () => resolvedSenderId;
301
301
  const connected = nodeSecret
302
302
  ? connectPublicHub({ hubUrl, authMode: 'legacy', evomapDir, nodeSecret, senderId })
303
- : connectPublicHub({ hubUrl, authMode: 'oauth', evomapDir, senderId });
303
+ : connectPublicHub({
304
+ hubUrl,
305
+ authMode: 'oauth',
306
+ evomapDir,
307
+ senderId,
308
+ });
304
309
  return new AtpHubClient({ baseUrl: hubUrl, auth: connected.auth, fetchFn: globalFetchLike, senderId });
305
310
  }
306
311
  export { resolveIdentityHome as resolveAtpIdentityHome } from './identityHome.js';
@@ -94,12 +94,8 @@ export declare function makeHubReuseSeam(cap: hubNs.HubCapability, cache: ReuseC
94
94
  * candidate.
95
95
  */
96
96
  export declare function makeHubSearchMissProbe(cap: hubNs.HubCapability, cache: ReuseCache, onVerifiedSearchMiss: VerifiedHubSearchMissHandler, enabled: () => boolean, env?: NodeJS.ProcessEnv, assetLog?: AssetCallLogger): exec.HubReuseSeam;
97
- /**
98
- * Append a `value.inject` root_event for a SessionStart gene injection (#123). Attribution-only — the payload
99
- * carries the injected gene ids (+ cycle/outcome when known) and NO savings number, exactly per the ledger's
100
- * weakest-signal contract. Never throws: injection is the agent's critical path, so a failed emission is
101
- * swallowed (the genes are still injected). Skips an empty gene set — there is nothing to attribute.
102
- */
97
+ /** Build the same event for byte-budget admission and durable emission. */
98
+ export declare function injectEvent(info: hooks.InjectInfo): events.RawEvent;
103
99
  export declare function emitInject(ingestor: events.Ingestor, info: hooks.InjectInfo): Promise<void>;
104
100
  /**
105
101
  * Build the SessionStart inject emission seam (#123) — the public-repo composition point that connects core's
package/dist/autoexec.js CHANGED
@@ -576,27 +576,28 @@ async function emitReuseHit(ingestor, hit) {
576
576
  }
577
577
  catch { /* emission must never break the reuse path */ }
578
578
  }
579
- /**
580
- * Append a `value.inject` root_event for a SessionStart gene injection (#123). Attribution-only — the payload
581
- * carries the injected gene ids (+ cycle/outcome when known) and NO savings number, exactly per the ledger's
582
- * weakest-signal contract. Never throws: injection is the agent's critical path, so a failed emission is
583
- * swallowed (the genes are still injected). Skips an empty gene set — there is nothing to attribute.
584
- */
579
+ /** Build the same event for byte-budget admission and durable emission. */
580
+ export function injectEvent(info) {
581
+ const payload = {
582
+ geneIds: info.geneIds,
583
+ ...(info.contentSchema ? { contentSchema: info.contentSchema } : {}),
584
+ ...(info.content ? { content: info.content } : {}),
585
+ ...(info.omittedByBudget !== undefined ? { omittedByBudget: info.omittedByBudget } : {}),
586
+ ...(info.cycleId ? { cycleId: info.cycleId } : {}),
587
+ ...(info.sessionId ? { sessionId: info.sessionId } : {}),
588
+ ...(info.outcome ? { outcome: info.outcome } : {}),
589
+ };
590
+ return {
591
+ type: ops.VALUE_INJECT_EVENT,
592
+ human: { title: `injected ${info.geneIds.length} gene(s)`, ...(info.cycleId ? { detail: `cycle ${info.cycleId}` } : {}) },
593
+ payload: payload,
594
+ };
595
+ }
585
596
  export async function emitInject(ingestor, info) {
586
597
  try {
587
598
  if (info.geneIds.length === 0)
588
599
  return;
589
- const payload = {
590
- geneIds: info.geneIds,
591
- ...(info.cycleId ? { cycleId: info.cycleId } : {}),
592
- ...(info.sessionId ? { sessionId: info.sessionId } : {}),
593
- ...(info.outcome ? { outcome: info.outcome } : {}),
594
- };
595
- await ingestor.ingest({
596
- type: ops.VALUE_INJECT_EVENT,
597
- human: { title: `injected ${info.geneIds.length} gene(s)`, ...(info.cycleId ? { detail: `cycle ${info.cycleId}` } : {}) },
598
- payload: payload,
599
- });
600
+ await ingestor.ingest(injectEvent(info));
600
601
  }
601
602
  catch { /* emission must never break the injection path */ }
602
603
  }
@@ -2,7 +2,7 @@
2
2
  // M1 material into quarantined gene drafts. Core owns the trigger policy (material.batch_ready + single-flight);
3
3
  // this layer owns the side effects core must not: claim from the consumer group, re-read + parse the session via
4
4
  // the runtime adapters, draft via the SHARED distill primitive, quarantine in the ReviewLedger, and emit
5
- // gene.distilled. It reuses the exact same `draftGeneCandidate` as `evolver ingest --distill`, so the one-shot and
5
+ // gene.distilled. It reuses the exact same `assessGeneDraft` as `evolver ingest --distill`, so the one-shot and
6
6
  // the auto path never drift.
7
7
  //
8
8
  // WIRING (#117 / #106): LIVE. `autoexec.ts` imports `resolveDistillObserver`, builds it inside
@@ -13,7 +13,8 @@
13
13
  // reads as a real gap, and a 2026-08 audit did misreport this composition as unwired on the strength of it.)
14
14
  import { assetstore, events, observers, signals, algo } from '@evomap/evolver-core';
15
15
  import { readFileSync } from 'node:fs';
16
- import { draftGeneCandidate } from './distillPrimitives.js';
16
+ import { Console } from 'node:console';
17
+ import { assessGeneDraft } from './distillPrimitives.js';
17
18
  import { assessDraftAdmissionFromStore } from './distillAdmission.js';
18
19
  import { reviewLedgerForStore } from './reviewFilter.js';
19
20
  import { runtimeSessionSourcesForMaterial } from './materialSnapshot.js';
@@ -31,6 +32,7 @@ export function makeDistillDrain(c) {
31
32
  const review = c.review ?? reviewLedgerForStore(c.store);
32
33
  const maxPerTick = c.maxPerTick ?? DEFAULT_MAX_PER_TICK;
33
34
  const readSource = c.readSource ?? ((p) => readFileSync(p, 'utf8'));
35
+ let diagnosticConsole;
34
36
  // Process ONE claimed material. `ack:true` ⇒ advance the cursor past it; `ack:false` ⇒ either a persist/audit
35
37
  // write failed OR the remaining per-tick draft budget was reached — leave it for a retry tick. A bad/unparseable/
36
38
  // missing source, a proxy_trace, a too-thin session, or a duplicate are all "handled" (skip + ack).
@@ -46,12 +48,24 @@ export function makeDistillDrain(c) {
46
48
  return { ack: true, drafted: 0 }; // bad / missing / unparseable source — nothing to retry
47
49
  }
48
50
  let drafted = 0;
49
- for (const source of sources) {
51
+ for (const [sourceIndex, source] of sources.entries()) {
50
52
  if (drafted >= draftLimit)
51
53
  return { ack: false, drafted };
52
- const draftedCandidate = draftGeneCandidate(source.turns, signals.extractSignals(source.turns), source.agent);
53
- if (!draftedCandidate)
54
- continue; // too thin to distill
54
+ const { candidate: draftedCandidate, diagnostics } = assessGeneDraft(source.turns, signals.extractSignals(source.turns), source.agent);
55
+ if (!draftedCandidate) {
56
+ // daemon 的实际日志入口也报告不足;不创建假 Gene 或改变 ack/retry 语义。
57
+ try {
58
+ if (!diagnosticConsole) {
59
+ const stderr = process.stderr;
60
+ diagnosticConsole = new Console({ stdout: stderr, stderr, ignoreErrors: true });
61
+ }
62
+ diagnosticConsole.error(`distill-observer: ${JSON.stringify({ materialId: m.materialId, sourceIndex, strategyDraft: diagnostics })}`);
63
+ }
64
+ catch {
65
+ // Console处理本次write的同步/异步错误;格式化或初始化失败也不能阻塞薄材料ack。
66
+ }
67
+ continue;
68
+ }
55
69
  // Carry producer-resolved task domain into draft signals_match so selection can score domain evidence.
56
70
  // Only attach when the source already carries a resolved slug (fail-closed stamp at ingest).
57
71
  let candidate = draftedCandidate;
@@ -87,7 +101,7 @@ export function makeDistillDrain(c) {
87
101
  if (!audited.has(assetId)) {
88
102
  await c.ingestor.ingest({
89
103
  type: 'gene.distilled',
90
- payload: { geneId: r.gene.id, assetId: r.gene.asset_id, category: r.gene.category, source: 'distill-observer', materialId: m.materialId, ...(source.sessionId ? { sessionId: source.sessionId } : {}) },
104
+ payload: { geneId: r.gene.id, assetId: r.gene.asset_id, category: r.gene.category, source: 'distill-observer', materialId: m.materialId, sourceIndex, strategyDraft: diagnostics, ...(source.sessionId ? { sessionId: source.sessionId } : {}) },
91
105
  human: { title: `auto-distilled gene ${r.gene.id} (UNPROVEN — awaiting review)`, severity: 'info' },
92
106
  actor: { kind: 'machine', id: 'distill-observer' },
93
107
  });
@@ -7,11 +7,37 @@ import type { NormalizedTurn } from '@evomap/evolver-runtime-adapters';
7
7
  * Success signals (#578) also produce tokens so a purely successful session can yield a matchable gene.
8
8
  * Deduped, ≤8. */
9
9
  export declare function signalTokens(sigs: readonly signals.ExtractedSignal[]): string[];
10
- /** Draft strategy steps = the agent's own substantive (non-meta) turns — boundary-trimmed (never chopped
11
- * mid-word); turns that are PURELY narration ("let me look around" with no cause/action) are dropped, and a
12
- * narration-opening turn that also states a cause/fix keeps that substance (its narration opener is stripped so
13
- * the capped step leads with the fix). NOT fabricated: real transcript excerpts; the gene lands UNPROVEN and is
14
- * curated by `review` + pruned by the cycle, so a noisy draft self-corrects. */
10
+ /** 位置属于调用方传入的 normalized turn,使用原始 UTF-16 半开区间;不是 JSONL 文件行号。 */
11
+ interface StrategySourcePosition {
12
+ turnIndex: number;
13
+ field: 'text' | 'toolResult';
14
+ start: number;
15
+ end: number;
16
+ }
17
+ type UnitRejection = 'unit_too_long' | 'incomplete_unit' | 'source_truncated';
18
+ export interface StrategyDraftDiagnostics {
19
+ status: 'ready' | 'insufficient';
20
+ reason: 'complete_units' | 'no_actionable_units' | UnitRejection | 'no_eligible_signal' | 'no_discriminating_topic';
21
+ evidence: StrategySourcePosition[];
22
+ rejected: Array<StrategySourcePosition & {
23
+ reason: UnitRejection;
24
+ }>;
25
+ omitted: {
26
+ nonActionable: number;
27
+ duplicate: number;
28
+ overBudget: number;
29
+ incomplete: number;
30
+ sourceTruncated: number;
31
+ capacity: number;
32
+ };
33
+ }
34
+ export interface StrategyDraft {
35
+ strategy: string[];
36
+ diagnostics: StrategyDraftDiagnostics;
37
+ }
38
+ /** 最多六个完整且已脱敏的操作单元。拒绝信息只含位置/原因/计数,不保存秘密原文。 */
39
+ export declare function draftStrategyWithEvidence(turns: readonly NormalizedTurn[], toolWorkflowsOnly?: boolean): StrategyDraft;
40
+ /** 兼容旧调用方;实际入口使用带位置和不足原因的同一实现。 */
15
41
  export declare function draftStrategy(turns: readonly NormalizedTurn[]): string[];
16
42
  /**
17
43
  * Assemble an UNPROVEN draft GeneCandidate from a parsed session, or null when too thin to distill (no strong
@@ -20,6 +46,12 @@ export declare function draftStrategy(turns: readonly NormalizedTurn[]): string[
20
46
  * (already extracted by the caller) to avoid a second extraction pass.
21
47
  */
22
48
  export declare function draftGeneCandidate(turns: readonly NormalizedTurn[], sigs: readonly signals.ExtractedSignal[], agent: string): algo.GeneCandidate | null;
49
+ export interface GeneDraftAssessment {
50
+ candidate: algo.GeneCandidate | null;
51
+ diagnostics: StrategyDraftDiagnostics;
52
+ }
53
+ /** 共享 caller 的实际入口;diagnostics 不进入 Gene 内容或 asset_id。 */
54
+ export declare function assessGeneDraft(turns: readonly NormalizedTurn[], sigs: readonly signals.ExtractedSignal[], agent: string): GeneDraftAssessment;
23
55
  /** Minimal reference to an existing pool gene for the novelty check (id + its signals). */
24
56
  export interface ExistingGeneSignals {
25
57
  id?: string;
@@ -48,4 +80,5 @@ export interface DraftAdmission {
48
80
  * into a flood, and a review gate nobody reads is no gate. Pure and deterministic; the caller decides what to do
49
81
  * with a non-admit (skip, never an error).
50
82
  */
51
- export declare function assessDraftAdmission(candidate: algo.GeneCandidate, existing?: readonly ExistingGeneSignals[], opts?: DraftAdmissionOptions): DraftAdmission;
83
+ export declare function assessDraftAdmission(candidate: algo.GeneCandidate, existing?: readonly ExistingGeneSignals[], opts?: DraftAdmissionOptions): DraftAdmission;
84
+ export {};