File size: 3,321 Bytes
fc93158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import { describe, expect, it } from "vitest";
import {
  mergeOmegaDriveSignalWithEngineScore,
  scoreOmegaEngineSignals,
} from "./score-engine-signal.js";
import type { OmegaEngineSignal } from "./types.js";

describe("omega engine signal scoring", () => {
  it("promotes strong contradiction clusters into a homeostasis drive", () => {
    const score = scoreOmegaEngineSignals([
      {
        source: "entropy-minimization",
        kind: "contradiction",
        severity: 0.5,
        summary: "stale goals contradict claimed completion",
        contradictionKind: "goal_conflict",
      },
    ] satisfies OmegaEngineSignal[]);

    expect(score.dominantCategory).toBe("homeostasis");
    expect(score.dominantScore).toBeGreaterThan(0.45);
    expect(score.recommendedDrive).toMatchObject({
      kind: "homeostasis",
    });
  });

  it("keeps low-grade speculative thoughts below activation threshold", () => {
    const score = scoreOmegaEngineSignals([
      {
        source: "continuous-thinking",
        kind: "thought",
        severity: 0.3,
        summary: "what single question would reduce uncertainty most?",
        thoughtId: "thought_1",
        drive: "adaptive_depth",
      },
    ] satisfies OmegaEngineSignal[]);

    expect(score.dominantCategory).toBe("curiosity");
    expect(score.dominantScore).toBeLessThan(0.45);
    expect(score.recommendedDrive).toEqual({ kind: "idle" });
  });

  it("uses engine guidance when the base drive is idle", () => {
    const engineScore = scoreOmegaEngineSignals([
      {
        source: "jepa-empirical",
        kind: "correlation",
        severity: 0.5,
        summary: "jepa_correlation=0.5 events=12",
        correlationScore: 0.5,
        totalEvents: 12,
      },
    ] satisfies OmegaEngineSignal[]);

    const merged = mergeOmegaDriveSignalWithEngineScore({
      baseDriveSignal: { kind: "idle" },
      engineScore,
    });

    expect(merged).toMatchObject({
      kind: "entropy_alert",
      silentMs: 0,
    });
  });

  it("does not activate a fresh drive from hypothesis bookkeeping alone", () => {
    const score = scoreOmegaEngineSignals([
      {
        source: "active-learning",
        kind: "hypothesis_tested",
        severity: 1,
        summary: "jepa_correlation:0.40, events:8",
        hypothesisId: "hyp_1",
        confirmed: true,
      },
    ] satisfies OmegaEngineSignal[]);

    expect(score.dominantCategory).toBe("curiosity");
    expect(score.recommendedDrive).toEqual({ kind: "idle" });
  });

  it("preserves the base drive kind while boosting urgency when engine evidence agrees", () => {
    const engineScore = scoreOmegaEngineSignals([
      {
        source: "continuous-thinking",
        kind: "thought",
        severity: 0.6,
        summary: "a memory gap should be explored",
        thoughtId: "thought_2",
        drive: "learning",
      },
    ] satisfies OmegaEngineSignal[]);

    const merged = mergeOmegaDriveSignalWithEngineScore({
      baseDriveSignal: {
        kind: "curiosity",
        target: "memory/2026-03-25.md",
        reason: "base_curiosity",
        urgency: 0.4,
      },
      engineScore,
    });

    expect(merged).toMatchObject({
      kind: "curiosity",
    });
    expect(merged.kind === "curiosity" ? merged.urgency : 0).toBeGreaterThan(0.4);
  });
});