agent-recall-core 3.4.49 → 3.4.50
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/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/palace/awareness.d.ts +22 -0
- package/dist/palace/awareness.d.ts.map +1 -1
- package/dist/palace/awareness.js +30 -2
- package/dist/palace/awareness.js.map +1 -1
- package/dist/prompts/consolidation-prompt.d.ts.map +1 -1
- package/dist/prompts/consolidation-prompt.js +5 -0
- package/dist/prompts/consolidation-prompt.js.map +1 -1
- package/dist/storage/dream-health.d.ts +56 -8
- package/dist/storage/dream-health.d.ts.map +1 -1
- package/dist/storage/dream-health.js +130 -35
- package/dist/storage/dream-health.js.map +1 -1
- package/dist/storage/dream-yield.d.ts +81 -0
- package/dist/storage/dream-yield.d.ts.map +1 -0
- package/dist/storage/dream-yield.js +77 -0
- package/dist/storage/dream-yield.js.map +1 -0
- package/dist/storage/filelock.d.ts +10 -2
- package/dist/storage/filelock.d.ts.map +1 -1
- package/dist/storage/filelock.js +10 -2
- package/dist/storage/filelock.js.map +1 -1
- package/dist/tools-logic/dream-admission.d.ts +144 -0
- package/dist/tools-logic/dream-admission.d.ts.map +1 -0
- package/dist/tools-logic/dream-admission.js +537 -0
- package/dist/tools-logic/dream-admission.js.map +1 -0
- package/dist/tools-logic/insight-promotion.d.ts +18 -0
- package/dist/tools-logic/insight-promotion.d.ts.map +1 -1
- package/dist/tools-logic/insight-promotion.js +37 -14
- package/dist/tools-logic/insight-promotion.js.map +1 -1
- package/dist/tools-logic/safety-consolidation.d.ts +15 -0
- package/dist/tools-logic/safety-consolidation.d.ts.map +1 -1
- package/dist/tools-logic/safety-consolidation.js +13 -2
- package/dist/tools-logic/safety-consolidation.js.map +1 -1
- package/dist/tools-logic/session-end-reflect.d.ts.map +1 -1
- package/dist/tools-logic/session-end-reflect.js +4 -1
- package/dist/tools-logic/session-end-reflect.js.map +1 -1
- package/dist/tools-logic/store-doctor.d.ts.map +1 -1
- package/dist/tools-logic/store-doctor.js +7 -1
- package/dist/tools-logic/store-doctor.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dream-admission.d.ts","sourceRoot":"","sources":["../../src/tools-logic/dream-admission.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAIH,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AAInC,wEAAwE;AACxE,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C,qDAAqD;AACrD,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,IAAmC,CAAC;AAO1E,MAAM,WAAW,gBAAgB;IAC/B,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,gBAAgB,EAAE,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;IACxC,uEAAuE;IACvE,sBAAsB,EAAE,MAAM,CAAC;IAC/B,2EAA2E;IAC3E,MAAM,EAAE,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|
|
|
1
|
+
/**
|
|
2
|
+
* dream-admission.ts — deterministic admission math for the nightly dreaming
|
|
3
|
+
* pipeline (fix10, 2026-09-12).
|
|
4
|
+
*
|
|
5
|
+
* ── The bug this replaces ────────────────────────────────────────────────────
|
|
6
|
+
* The external SOP (~/.aam/dreams/dream-prompt.md Step 3) gated pattern
|
|
7
|
+
* admission on:
|
|
8
|
+
*
|
|
9
|
+
* confidence = (observation_count / 7) × recency_weight
|
|
10
|
+
* recency_weight: today=1.0, 1–2d ago=0.85, 3–4d=0.7, 5–7d=0.4
|
|
11
|
+
* ≥ 0.8 write · 0.5–0.8 report-only "pending" · < 0.5 SILENT discard
|
|
12
|
+
*
|
|
13
|
+
* The dream runs at 2 AM, so the freshest journal is YESTERDAY → the effective
|
|
14
|
+
* maximum recency_weight is 0.85. The advertised "3 observations in 7 days"
|
|
15
|
+
* bar therefore scored (3/7) × 0.85 = 0.36 — below even the 0.5 pending band —
|
|
16
|
+
* and was discarded WITHOUT A TRACE. Effective bar: ~7 observations/7d for an
|
|
17
|
+
* awareness write, ~8 for the shortcut→skill cascade. This single formula
|
|
18
|
+
* explains 22+ consecutive zero-output nights (2026-08-20 → 09-12), all of
|
|
19
|
+
* which dream-health reported green because it measured uptime, not yield.
|
|
20
|
+
*
|
|
21
|
+
* ── The fix: admit-then-vote (ExpeL / Mem0 model) ────────────────────────────
|
|
22
|
+
* Admission and promotion are SEPARATED, and promotion reuses the machinery
|
|
23
|
+
* the ONLINE path already proved at volume (promoteConfirmedInsights(3),
|
|
24
|
+
* all-time window — it produced a 362×-confirmed insight while the dream
|
|
25
|
+
* produced nothing):
|
|
26
|
+
*
|
|
27
|
+
* 1. Every candidate the dream extracts is EVALUATED — never silently
|
|
28
|
+
* dropped. Every decision carries a reason destined for the run log.
|
|
29
|
+
* 2. Each NEW (observation-day, project) incident is recorded into
|
|
30
|
+
* insights-index as one confirmation (idempotent across nights via a
|
|
31
|
+
* ledger — re-reading the same 7-day window tomorrow adds nothing).
|
|
32
|
+
* 3. promoteConfirmedInsights(DREAM_PROMOTION_THRESHOLD) then promotes
|
|
33
|
+
* anything at ≥3 all-time confirmations — the SAME code path, the SAME
|
|
34
|
+
* bar as the online path. 3 observations in 7 days now promotes the
|
|
35
|
+
* same night: the advertised bar is real. 2 observations are RETAINED
|
|
36
|
+
* as a candidate (count 2) and cross the bar whenever one more
|
|
37
|
+
* confirmation arrives — from a later night or from the online path.
|
|
38
|
+
*
|
|
39
|
+
* There is no recency multiplier: recency defines the observation WINDOW
|
|
40
|
+
* (nothing older than DREAM_WINDOW_DAYS counts), it never scales the count.
|
|
41
|
+
*
|
|
42
|
+
* Observation unit: one distinct (calendar-day, project) pair. A pattern
|
|
43
|
+
* repeated three times inside one project's same-day journal is ONE incident;
|
|
44
|
+
* the same pattern in two projects on the same day is TWO.
|
|
45
|
+
*/
|
|
46
|
+
import { addIndexedInsight, findSimilarInsight, readInsightsIndex, normalizeTitle, tokenOverlap } from "../palace/insights-index.js";
|
|
47
|
+
import { addInsight, readAwarenessState } from "../palace/awareness.js";
|
|
48
|
+
import { promoteConfirmedInsights, titlePresentInAwareness, PROMOTION_CONFIRMATION_THRESHOLD, } from "./insight-promotion.js";
|
|
49
|
+
import { withLock } from "../storage/filelock.js";
|
|
50
|
+
import { readJsonSafe, writeJsonAtomic, ensureDir } from "../storage/fs-utils.js";
|
|
51
|
+
import { writeDreamYield, dreamsDir, } from "../storage/dream-yield.js";
|
|
52
|
+
import * as fs from "node:fs";
|
|
53
|
+
import * as path from "node:path";
|
|
54
|
+
/** Bump when the admission contract changes (SOP repoints pin this). */
|
|
55
|
+
export const DREAM_ADMISSION_VERSION = "v2";
|
|
56
|
+
/** Trailing observation window, in calendar days. */
|
|
57
|
+
export const DREAM_WINDOW_DAYS = 7;
|
|
58
|
+
/**
|
|
59
|
+
* Promotion bar — deliberately THE SAME value as promoteConfirmedInsights'
|
|
60
|
+
* default. One bar, two entry points (online session_end + offline dream);
|
|
61
|
+
* never duplicate it with harsher numbers. fix10 LOW-4: re-exported from the
|
|
62
|
+
* ONE constant instead of a second literal, so the bars cannot drift apart.
|
|
63
|
+
*/
|
|
64
|
+
export const DREAM_PROMOTION_THRESHOLD = PROMOTION_CONFIRMATION_THRESHOLD;
|
|
65
|
+
/** Ledger keeps counted observation keys this many days (> window, so an
|
|
66
|
+
* observation can never be double-counted while still inside any window). */
|
|
67
|
+
const LEDGER_RETENTION_DAYS = 30;
|
|
68
|
+
const LEDGER_MAX_ENTRIES = 500;
|
|
69
|
+
// ── date helpers (local calendar days; journals are local-dated) ─────────────
|
|
70
|
+
function localDay(d) {
|
|
71
|
+
const y = d.getFullYear();
|
|
72
|
+
const m = String(d.getMonth() + 1).padStart(2, "0");
|
|
73
|
+
const day = String(d.getDate()).padStart(2, "0");
|
|
74
|
+
return `${y}-${m}-${day}`;
|
|
75
|
+
}
|
|
76
|
+
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
77
|
+
function dayToUtcMs(day) {
|
|
78
|
+
if (!DATE_RE.test(day))
|
|
79
|
+
return null;
|
|
80
|
+
const [y, m, d] = day.split("-").map(Number);
|
|
81
|
+
const ms = Date.UTC(y, m - 1, d);
|
|
82
|
+
// Reject impossible dates (e.g. 2026-02-31 rolls over in Date.UTC)
|
|
83
|
+
const check = new Date(ms);
|
|
84
|
+
if (check.getUTCFullYear() !== y || check.getUTCMonth() !== m - 1 || check.getUTCDate() !== d)
|
|
85
|
+
return null;
|
|
86
|
+
return ms;
|
|
87
|
+
}
|
|
88
|
+
const DAY_MS = 86_400_000;
|
|
89
|
+
/** Distinct in-window (day|project) keys for a candidate. */
|
|
90
|
+
function inWindowKeys(candidate, runDay) {
|
|
91
|
+
const runMs = dayToUtcMs(runDay);
|
|
92
|
+
const keys = new Set();
|
|
93
|
+
const dropped = [];
|
|
94
|
+
for (const obs of candidate.observations ?? []) {
|
|
95
|
+
const obsMs = dayToUtcMs(obs.date ?? "");
|
|
96
|
+
if (obsMs === null || runMs === null) {
|
|
97
|
+
dropped.push(`${obs?.date ?? "(missing date)"} (invalid date)`);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const diffDays = Math.round((runMs - obsMs) / DAY_MS);
|
|
101
|
+
if (diffDays < 0) {
|
|
102
|
+
dropped.push(`${obs.date} (future-dated relative to run day ${runDay})`);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (diffDays > DREAM_WINDOW_DAYS) {
|
|
106
|
+
dropped.push(`${obs.date} (outside ${DREAM_WINDOW_DAYS}d window)`);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
keys.add(`${obs.date}|${(obs.project ?? "").trim()}`);
|
|
110
|
+
}
|
|
111
|
+
return { keys: [...keys].sort(), dropped };
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The formula, replaced. Pure — no store access, unit-pinnable.
|
|
115
|
+
*
|
|
116
|
+
* 3 distinct (day, project) incidents within the window at a 2 AM run → "promote"
|
|
117
|
+
* (one day observed in three projects counts 3 — see the observation-unit note above).
|
|
118
|
+
* 1–2 → "admit" (retained candidate; confirmations accrue with no window).
|
|
119
|
+
* 0 → "reject", with the reason spelled out.
|
|
120
|
+
*/
|
|
121
|
+
export function evaluateDreamCandidate(candidate, opts = {}) {
|
|
122
|
+
const threshold = opts.threshold ?? DREAM_PROMOTION_THRESHOLD;
|
|
123
|
+
const runDay = localDay(opts.runDate ?? new Date());
|
|
124
|
+
const title = (candidate?.title ?? "").trim();
|
|
125
|
+
if (!title) {
|
|
126
|
+
return { title: "(untitled)", outcome: "reject", observations_in_window: 0, reason: "invalid candidate: empty title" };
|
|
127
|
+
}
|
|
128
|
+
if (!Array.isArray(candidate.observations) || candidate.observations.length === 0) {
|
|
129
|
+
return { title, outcome: "reject", observations_in_window: 0, reason: "invalid candidate: no observations supplied" };
|
|
130
|
+
}
|
|
131
|
+
const { keys, dropped } = inWindowKeys(candidate, runDay);
|
|
132
|
+
const n = keys.length;
|
|
133
|
+
const droppedNote = dropped.length > 0 ? ` (dropped: ${dropped.join(", ")})` : "";
|
|
134
|
+
if (n >= threshold) {
|
|
135
|
+
return {
|
|
136
|
+
title,
|
|
137
|
+
outcome: "promote",
|
|
138
|
+
observations_in_window: n,
|
|
139
|
+
reason: `clears advertised bar: ${n} distinct (day, project) incidents in ${DREAM_WINDOW_DAYS}d ≥ ${threshold}${droppedNote}`,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
if (n >= 1) {
|
|
143
|
+
return {
|
|
144
|
+
title,
|
|
145
|
+
outcome: "admit",
|
|
146
|
+
observations_in_window: n,
|
|
147
|
+
reason: `below promotion bar (${n}/${threshold}) — admitted as candidate; confirmations accrue all-time (no window)${droppedNote}`,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
title,
|
|
152
|
+
outcome: "reject",
|
|
153
|
+
observations_in_window: 0,
|
|
154
|
+
reason: `0 observations inside the ${DREAM_WINDOW_DAYS}-day window ending ${runDay}${droppedNote}`,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function ledgerPath() {
|
|
158
|
+
return path.join(dreamsDir(), "admission-ledger.json");
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* fix10 LOW-9: a ledger that EXISTS but cannot be parsed must not silently
|
|
162
|
+
* reset — losing dedup state means overlapping windows can re-count
|
|
163
|
+
* (bounded confirmation inflation). Corruption is reported so the night's
|
|
164
|
+
* yield record carries it in errors[] and health classifies the night as
|
|
165
|
+
* "errored", never benign.
|
|
166
|
+
*/
|
|
167
|
+
function readLedger() {
|
|
168
|
+
const p = ledgerPath();
|
|
169
|
+
const l = readJsonSafe(p);
|
|
170
|
+
if (!l || !Array.isArray(l.entries)) {
|
|
171
|
+
let corrupted = false;
|
|
172
|
+
try {
|
|
173
|
+
corrupted = fs.existsSync(p); // present but unreadable/malformed
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
corrupted = false;
|
|
177
|
+
}
|
|
178
|
+
return { ledger: { version: 1, entries: [] }, corrupted };
|
|
179
|
+
}
|
|
180
|
+
return { ledger: l, corrupted: false };
|
|
181
|
+
}
|
|
182
|
+
function findLedgerEntry(ledger, title) {
|
|
183
|
+
const incoming = normalizeTitle(title);
|
|
184
|
+
if (incoming.size === 0)
|
|
185
|
+
return null;
|
|
186
|
+
let best = null;
|
|
187
|
+
let bestScore = 0;
|
|
188
|
+
for (const e of ledger.entries) {
|
|
189
|
+
const score = tokenOverlap(incoming, normalizeTitle(e.title));
|
|
190
|
+
if (score >= 0.6 && score > bestScore) {
|
|
191
|
+
best = e;
|
|
192
|
+
bestScore = score;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return best;
|
|
196
|
+
}
|
|
197
|
+
function pruneLedger(ledger, runDay) {
|
|
198
|
+
const runMs = dayToUtcMs(runDay) ?? Date.now();
|
|
199
|
+
for (const e of ledger.entries) {
|
|
200
|
+
e.keys = e.keys.filter((k) => {
|
|
201
|
+
const day = k.split("|")[0];
|
|
202
|
+
const ms = dayToUtcMs(day);
|
|
203
|
+
return ms !== null && (runMs - ms) / DAY_MS <= LEDGER_RETENTION_DAYS;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
ledger.entries = ledger.entries.filter((e) => e.keys.length > 0);
|
|
207
|
+
if (ledger.entries.length > LEDGER_MAX_ENTRIES) {
|
|
208
|
+
ledger.entries.sort((a, b) => (a.last_run < b.last_run ? 1 : -1));
|
|
209
|
+
ledger.entries = ledger.entries.slice(0, LEDGER_MAX_ENTRIES);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// ── the impure run ───────────────────────────────────────────────────────────
|
|
213
|
+
/**
|
|
214
|
+
* Run admission over tonight's extracted candidates: evaluate → record NEW
|
|
215
|
+
* observations into insights-index → promote via the SHARED
|
|
216
|
+
* promoteConfirmedInsights machinery → write the night's yield record.
|
|
217
|
+
*
|
|
218
|
+
* Guarantees:
|
|
219
|
+
* - every candidate appears in the returned results AND the yield file,
|
|
220
|
+
* with a non-empty reason (no silent discards, ever);
|
|
221
|
+
* - idempotent across nights (sliding 7-day windows overlap 6 days — the
|
|
222
|
+
* ledger ensures an observation is counted exactly once);
|
|
223
|
+
* - yield-file write failure never aborts the run (error surfaces in
|
|
224
|
+
* report.errors).
|
|
225
|
+
*/
|
|
226
|
+
export async function runDreamAdmission(candidates, opts = {}) {
|
|
227
|
+
const runDate = opts.runDate ?? new Date();
|
|
228
|
+
const runDay = localDay(runDate);
|
|
229
|
+
const threshold = opts.threshold ?? DREAM_PROMOTION_THRESHOLD;
|
|
230
|
+
const errors = [];
|
|
231
|
+
return withLock("dream-admission", async () => {
|
|
232
|
+
const { ledger, corrupted: ledgerCorrupted } = readLedger();
|
|
233
|
+
if (ledgerCorrupted) {
|
|
234
|
+
// LOW-9: surfaced, never silent — lands in the yield record's errors[]
|
|
235
|
+
// and turns the night's health class to "errored".
|
|
236
|
+
errors.push("admission ledger was corrupt and has been reset — overlapping-window dedup state lost; " +
|
|
237
|
+
"tonight's observations may re-count once (bounded confirmation inflation)");
|
|
238
|
+
}
|
|
239
|
+
const results = [];
|
|
240
|
+
for (const candidate of candidates ?? []) {
|
|
241
|
+
const math = evaluateDreamCandidate(candidate, { runDate, threshold });
|
|
242
|
+
const base = {
|
|
243
|
+
title: math.title,
|
|
244
|
+
math,
|
|
245
|
+
observations_in_window: math.observations_in_window,
|
|
246
|
+
};
|
|
247
|
+
if (math.outcome === "reject") {
|
|
248
|
+
results.push({ ...base, outcome: "rejected", new_observations: 0, reason: math.reason });
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
try {
|
|
252
|
+
// Ledger dedup: count only observations no previous night counted.
|
|
253
|
+
const { keys } = inWindowKeys(candidate, runDay);
|
|
254
|
+
let entry = findLedgerEntry(ledger, math.title);
|
|
255
|
+
const counted = new Set(entry?.keys ?? []);
|
|
256
|
+
const newKeys = keys.filter((k) => !counted.has(k));
|
|
257
|
+
if (newKeys.length === 0) {
|
|
258
|
+
results.push({
|
|
259
|
+
...base,
|
|
260
|
+
outcome: "already-counted",
|
|
261
|
+
new_observations: 0,
|
|
262
|
+
reason: `all ${keys.length} in-window observation(s) already counted on a previous night (last: ${entry?.last_run ?? "unknown"}) — idempotent skip`,
|
|
263
|
+
});
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
// Record one confirmation per NEW (day, project) incident. The index
|
|
267
|
+
// merges on ≥0.6 title similarity, so repeats strengthen one entry.
|
|
268
|
+
const projects = [...new Set(newKeys.map((k) => k.split("|")[1]).filter(Boolean))];
|
|
269
|
+
let merged = null;
|
|
270
|
+
let capBlocked = false;
|
|
271
|
+
for (let i = 0; i < newKeys.length; i++) {
|
|
272
|
+
const res = await addIndexedInsight({
|
|
273
|
+
title: math.title,
|
|
274
|
+
source: `dream-admission ${runDay}`,
|
|
275
|
+
applies_when: candidate.applies_when ?? [],
|
|
276
|
+
projects: projects.length > 0 ? projects : undefined,
|
|
277
|
+
severity: candidate.severity ?? "important",
|
|
278
|
+
});
|
|
279
|
+
if (res === null) {
|
|
280
|
+
// Index at cap (200 entries, all ≥2 confirmations). Policy: never
|
|
281
|
+
// evict a confirmed entry for a count-1 candidate.
|
|
282
|
+
capBlocked = true;
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
merged = res;
|
|
286
|
+
}
|
|
287
|
+
if (capBlocked && merged === null) {
|
|
288
|
+
if (math.outcome === "promote") {
|
|
289
|
+
// The bar is CLEARED — the index is only the pending-candidate
|
|
290
|
+
// ledger, so a full index must not deny an earned promotion.
|
|
291
|
+
// Write to awareness directly (same sink promoteConfirmedInsights
|
|
292
|
+
// uses underneath).
|
|
293
|
+
const r = await addInsight({
|
|
294
|
+
title: math.title,
|
|
295
|
+
evidence: candidate.evidence ?? `dream-admission: ${math.observations_in_window} distinct (day, project) incidents in ${DREAM_WINDOW_DAYS}d (projects: ${projects.join(", ") || "unknown"})`,
|
|
296
|
+
appliesWhen: candidate.applies_when ?? [],
|
|
297
|
+
source: "dream-admission",
|
|
298
|
+
source_project: projects[0] ?? "_global",
|
|
299
|
+
});
|
|
300
|
+
const accepted = !("accepted" in r);
|
|
301
|
+
results.push({
|
|
302
|
+
...base,
|
|
303
|
+
outcome: accepted ? "promoted" : "rejected",
|
|
304
|
+
new_observations: newKeys.length,
|
|
305
|
+
reason: accepted
|
|
306
|
+
? `${math.reason}; insights-index at cap — promoted directly to awareness`
|
|
307
|
+
: `${math.reason}; insights-index at cap and awareness quality gate rejected the direct write`,
|
|
308
|
+
});
|
|
309
|
+
if (accepted) {
|
|
310
|
+
upsertLedger(ledger, math.title, newKeys, runDay, entry);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
results.push({
|
|
315
|
+
...base,
|
|
316
|
+
outcome: "rejected",
|
|
317
|
+
new_observations: 0,
|
|
318
|
+
reason: `insights-index at cap (200 entries, all ≥2 confirmations) — below-bar candidate not recorded; evidence NOT counted (will retry when the cap clears)`,
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
if (capBlocked && merged !== null) {
|
|
324
|
+
// LOW-8: defensive invariant. Unreachable under current index
|
|
325
|
+
// semantics (once the first call merged/created an entry, later
|
|
326
|
+
// calls confirm that entry and never hit the cap) — but if it ever
|
|
327
|
+
// fires, ledgering ALL newKeys while only some confirmations were
|
|
328
|
+
// recorded would silently undercount forever. Surface instead.
|
|
329
|
+
results.push({
|
|
330
|
+
...base,
|
|
331
|
+
outcome: "rejected",
|
|
332
|
+
new_observations: 0,
|
|
333
|
+
reason: "internal invariant violated: index cap hit AFTER a successful merge — confirmations partially recorded, nothing ledgered (will retry next night)",
|
|
334
|
+
});
|
|
335
|
+
errors.push(`candidate "${math.title}": cap-after-merge invariant violated`);
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
entry = upsertLedger(ledger, math.title, newKeys, runDay, entry);
|
|
339
|
+
results.push({
|
|
340
|
+
...base,
|
|
341
|
+
outcome: "admitted", // provisional — promotion pass below upgrades it
|
|
342
|
+
new_observations: newKeys.length,
|
|
343
|
+
reason: math.reason,
|
|
344
|
+
index_title: merged?.title,
|
|
345
|
+
confirmed_count: merged?.confirmed_count,
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
catch (err) {
|
|
349
|
+
// Error path is still a VISIBLE decision — never a silent drop.
|
|
350
|
+
results.push({
|
|
351
|
+
...base,
|
|
352
|
+
outcome: "rejected",
|
|
353
|
+
new_observations: 0,
|
|
354
|
+
reason: `recording failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
355
|
+
});
|
|
356
|
+
errors.push(`candidate "${math.title}": ${err instanceof Error ? err.message : String(err)}`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
pruneLedger(ledger, runDay);
|
|
360
|
+
try {
|
|
361
|
+
ensureDir(dreamsDir());
|
|
362
|
+
writeJsonAtomic(ledgerPath(), ledger);
|
|
363
|
+
}
|
|
364
|
+
catch (err) {
|
|
365
|
+
errors.push(`ledger write failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
366
|
+
}
|
|
367
|
+
// Promotion — the SHARED bar. Anything at ≥ threshold all-time
|
|
368
|
+
// confirmations (tonight's recording included) enters awareness.
|
|
369
|
+
let promotion = { promoted: [], skipped: [] };
|
|
370
|
+
let promotionError = null;
|
|
371
|
+
try {
|
|
372
|
+
promotion = await promoteConfirmedInsights(threshold);
|
|
373
|
+
}
|
|
374
|
+
catch (err) {
|
|
375
|
+
promotionError = err instanceof Error ? err.message : String(err);
|
|
376
|
+
errors.push(`promotion pass failed: ${promotionError}`);
|
|
377
|
+
}
|
|
378
|
+
// Upgrade tonight's admitted candidates that crossed the bar.
|
|
379
|
+
//
|
|
380
|
+
// HIGH-1 (review 2026-09-12): "absent from promotion.promoted" is NOT
|
|
381
|
+
// proof of "already in awareness" — promoteConfirmedInsights also skips
|
|
382
|
+
// on its addInsight QUALITY GATE (e.g. title_too_short), and the whole
|
|
383
|
+
// pass can THROW (2 AM lock contention with a concurrent session_end).
|
|
384
|
+
// The old label filed both as benign "already-promoted", sticking the
|
|
385
|
+
// candidate forever and letting a filtered store reach the ≥7-night
|
|
386
|
+
// "corpus genuinely thin" banner. Claim "already in awareness" only
|
|
387
|
+
// after VERIFYING presence with the promotion pass's own predicate;
|
|
388
|
+
// otherwise the candidate is `rejected` with the real reason, and the
|
|
389
|
+
// night classifies as filtered/errored — loud, not benign.
|
|
390
|
+
const index = readInsightsIndex();
|
|
391
|
+
const awarenessTitlesLower = (readAwarenessState()?.topInsights ?? []).map((i) => (i.title ?? "").toLowerCase());
|
|
392
|
+
// "already-counted" is verified too: a quality-gate-stuck candidate has
|
|
393
|
+
// no new observations on later nights and would otherwise re-file as
|
|
394
|
+
// benign already-known EVERY night after the first loud one.
|
|
395
|
+
for (const r of results) {
|
|
396
|
+
if (r.outcome !== "admitted" && r.outcome !== "already-counted")
|
|
397
|
+
continue;
|
|
398
|
+
const wasAlreadyCounted = r.outcome === "already-counted";
|
|
399
|
+
const indexed = r.index_title
|
|
400
|
+
? index.insights.find((i) => i.title === r.index_title) ?? findSimilarInsight(r.title, index.insights)
|
|
401
|
+
: findSimilarInsight(r.title, index.insights);
|
|
402
|
+
const count = indexed?.confirmed_count ?? r.confirmed_count ?? 0;
|
|
403
|
+
r.confirmed_count = count;
|
|
404
|
+
if (count < threshold) {
|
|
405
|
+
if (!wasAlreadyCounted)
|
|
406
|
+
r.reason = `${r.reason}; now at ${count}/${threshold} confirmations`;
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
const effectiveTitle = r.index_title ?? r.title;
|
|
410
|
+
const promotedMatch = promotion.promoted.some((t) => titleMatches(t, effectiveTitle));
|
|
411
|
+
if (promotedMatch) {
|
|
412
|
+
r.outcome = "promoted";
|
|
413
|
+
r.reason = `${r.math.reason}; promoted to awareness (confirmed ${count}× ≥ ${threshold})`;
|
|
414
|
+
}
|
|
415
|
+
else if (titlePresentInAwareness(effectiveTitle, awarenessTitlesLower) ||
|
|
416
|
+
(effectiveTitle !== r.title && titlePresentInAwareness(r.title, awarenessTitlesLower))) {
|
|
417
|
+
if (!wasAlreadyCounted) {
|
|
418
|
+
r.outcome = "already-promoted";
|
|
419
|
+
r.reason = `${r.math.reason}; bar cleared (confirmed ${count}×) and an equivalent insight is VERIFIED present in awareness`;
|
|
420
|
+
}
|
|
421
|
+
// already-counted + verified present = genuinely benign; keep as-is.
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
// Taxonomy: a quality-gate refusal is the GATE filtering the
|
|
425
|
+
// candidate → rejected only (night classifies "filtered"); a thrown
|
|
426
|
+
// promotion pass already sits in errors[] via the catch above (night
|
|
427
|
+
// classifies "errored"). Both are loud; neither is benign.
|
|
428
|
+
r.outcome = "rejected";
|
|
429
|
+
r.reason = promotionError
|
|
430
|
+
? `${r.math.reason}; bar cleared (confirmed ${count}×) but the promotion pass FAILED (${promotionError}) — NOT in awareness; will retry next night`
|
|
431
|
+
: `${r.math.reason}; bar cleared (confirmed ${count}×) but promotion was refused by the awareness quality gate (e.g. title too short / no evidence) — NOT in awareness; rewrite the candidate title/evidence`;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
const counts = {
|
|
435
|
+
admitted: results.filter((r) => r.outcome === "admitted").length,
|
|
436
|
+
promoted: results.filter((r) => r.outcome === "promoted").length,
|
|
437
|
+
already_known: results.filter((r) => r.outcome === "already-promoted" || r.outcome === "already-counted").length,
|
|
438
|
+
rejected: results.filter((r) => r.outcome === "rejected").length,
|
|
439
|
+
};
|
|
440
|
+
const discardedByReason = {};
|
|
441
|
+
for (const r of results) {
|
|
442
|
+
if (r.outcome === "rejected" || r.outcome === "already-counted") {
|
|
443
|
+
discardedByReason[r.reason] = (discardedByReason[r.reason] ?? 0) + 1;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
const yieldRecord = {
|
|
447
|
+
version: 1,
|
|
448
|
+
date: runDay,
|
|
449
|
+
generated_at: new Date().toISOString(),
|
|
450
|
+
candidates_seen: results.length,
|
|
451
|
+
admitted: counts.admitted,
|
|
452
|
+
promoted: counts.promoted,
|
|
453
|
+
already_known: counts.already_known,
|
|
454
|
+
rejected: counts.rejected,
|
|
455
|
+
discarded_by_reason: discardedByReason,
|
|
456
|
+
decisions: results.map(({ title, outcome, observations_in_window, new_observations, reason }) => ({
|
|
457
|
+
title, outcome, observations_in_window, new_observations, reason,
|
|
458
|
+
})),
|
|
459
|
+
promoted_titles: promotion.promoted,
|
|
460
|
+
...(opts.corpus ? { corpus: opts.corpus } : {}),
|
|
461
|
+
...(errors.length > 0 ? { errors } : {}),
|
|
462
|
+
};
|
|
463
|
+
let yieldFile = "";
|
|
464
|
+
try {
|
|
465
|
+
writeDreamYield(yieldRecord);
|
|
466
|
+
yieldFile = path.join(dreamsDir(), `yield-${runDay}.json`);
|
|
467
|
+
}
|
|
468
|
+
catch (err) {
|
|
469
|
+
errors.push(`yield write failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
470
|
+
}
|
|
471
|
+
return {
|
|
472
|
+
version: DREAM_ADMISSION_VERSION,
|
|
473
|
+
run_date: runDay,
|
|
474
|
+
threshold,
|
|
475
|
+
window_days: DREAM_WINDOW_DAYS,
|
|
476
|
+
candidates_seen: results.length,
|
|
477
|
+
...counts,
|
|
478
|
+
results,
|
|
479
|
+
promotion,
|
|
480
|
+
yield_file: yieldFile,
|
|
481
|
+
errors,
|
|
482
|
+
};
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
function titleMatches(a, b) {
|
|
486
|
+
if (a.toLowerCase() === b.toLowerCase())
|
|
487
|
+
return true;
|
|
488
|
+
const na = normalizeTitle(a);
|
|
489
|
+
const nb = normalizeTitle(b);
|
|
490
|
+
return tokenOverlap(na, nb) >= 0.6;
|
|
491
|
+
}
|
|
492
|
+
function upsertLedger(ledger, title, newKeys, runDay, existing) {
|
|
493
|
+
if (existing) {
|
|
494
|
+
existing.keys = [...new Set([...existing.keys, ...newKeys])].sort();
|
|
495
|
+
existing.last_run = runDay;
|
|
496
|
+
return existing;
|
|
497
|
+
}
|
|
498
|
+
const entry = { title, keys: [...newKeys].sort(), last_run: runDay };
|
|
499
|
+
ledger.entries.push(entry);
|
|
500
|
+
return entry;
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Versioned replacement text for the SOP's Step 3 (the deploy artifact for
|
|
504
|
+
* repointing ~/.aam/dreams/dream-prompt.md — printable via `ar dream sop`).
|
|
505
|
+
* The old prose formula is GONE; the math lives in code where it is tested.
|
|
506
|
+
*/
|
|
507
|
+
export const DREAM_STEP3_SOP = `## Step 3: Pattern Extraction (admit-then-vote — dream-admission ${DREAM_ADMISSION_VERSION})
|
|
508
|
+
|
|
509
|
+
Discover journal files from the last ${DREAM_WINDOW_DAYS} days (same discovery as before).
|
|
510
|
+
For each recurring pattern, build ONE candidate object:
|
|
511
|
+
{ "title": "When {situation}: {action}",
|
|
512
|
+
"observations": [ { "date": "YYYY-MM-DD", "project": "slug" }, ... ],
|
|
513
|
+
"applies_when": ["kw1","kw2","kw3"],
|
|
514
|
+
"evidence": "observed across: ..." }
|
|
515
|
+
One observation per (journal day, project) the pattern appeared in. Include EVERY
|
|
516
|
+
pattern you noticed — even 1x. Admission math is NOT your job.
|
|
517
|
+
|
|
518
|
+
Write all candidates to a temp file and run:
|
|
519
|
+
ar dream admit --file /tmp/dream-candidates.json \\
|
|
520
|
+
--journal-files {N} --journal-bytes {B} --corrections-new {C}
|
|
521
|
+
|
|
522
|
+
The command (deterministic, tested):
|
|
523
|
+
- promotes any candidate with ≥ ${DREAM_PROMOTION_THRESHOLD} distinct (journal-day, project) incidents in ${DREAM_WINDOW_DAYS}d
|
|
524
|
+
(same day in two projects = 2 incidents; same-day repeats in one project = 1)
|
|
525
|
+
(same bar as the online promoteConfirmedInsights path — no recency multiplier,
|
|
526
|
+
a 2 AM run counts yesterday at full weight);
|
|
527
|
+
- admits 1–2x candidates into insights-index where confirmations accrue all-time;
|
|
528
|
+
- never discards silently: every candidate gets an outcome + reason;
|
|
529
|
+
- writes the night's yield record (~/.agent-recall/dreams/yield-YYYY-MM-DD.json).
|
|
530
|
+
|
|
531
|
+
Paste the command's decision table verbatim into the dream report under
|
|
532
|
+
"## Admission Decisions". Do NOT compute confidence scores; do NOT skip
|
|
533
|
+
low-count patterns yourself.
|
|
534
|
+
|
|
535
|
+
Steps 5/5.5 note: where the old SOP said "confidence ≥ 0.9", read
|
|
536
|
+
"confirmed_count ≥ ${DREAM_PROMOTION_THRESHOLD * 2}" (2× the promotion bar).`;
|
|
537
|
+
//# sourceMappingURL=dream-admission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dream-admission.js","sourceRoot":"","sources":["../../src/tools-logic/dream-admission.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AACrI,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,gCAAgC,GAEjC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EACL,eAAe,EACf,SAAS,GAIV,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,wEAAwE;AACxE,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAE5C,qDAAqD;AACrD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CA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AC3B,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,oEAAoE,uBAAuB;;uCAEnF,iBAAiB;;;;;;;;;;;;;;oCAcpB,yBAAyB,iDAAiD,iBAAiB;;;;;;;;;;;;;qBAa1G,yBAAyB,GAAG,CAAC,2BAA2B,CAAC"}
|
|
@@ -11,6 +11,24 @@ export interface PromotionResult {
|
|
|
11
11
|
promoted: string[];
|
|
12
12
|
skipped: string[];
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* The promotion bar. ONE constant, TWO entry points: the online path
|
|
16
|
+
* (session_end → promoteConfirmedInsights default) and the offline dream
|
|
17
|
+
* (dream-admission.ts re-exports it as DREAM_PROMOTION_THRESHOLD). fix10
|
|
18
|
+
* LOW-4: previously duplicated as two literals — raising one silently forked
|
|
19
|
+
* the bar.
|
|
20
|
+
*/
|
|
21
|
+
export declare const PROMOTION_CONFIRMATION_THRESHOLD = 3;
|
|
22
|
+
/**
|
|
23
|
+
* The awareness-presence predicate promoteConfirmedInsights uses for its
|
|
24
|
+
* dedup skip — exported (fix10 HIGH-1) so dream-admission can verify a
|
|
25
|
+
* bar-clearing candidate ACTUALLY landed in awareness instead of inferring
|
|
26
|
+
* "already present" from mere absence in `promoted` (which also happens on
|
|
27
|
+
* quality-gate rejection or a thrown promotion pass).
|
|
28
|
+
*
|
|
29
|
+
* `existingTitlesLower` must be LOWERCASED awareness titles.
|
|
30
|
+
*/
|
|
31
|
+
export declare function titlePresentInAwareness(title: string, existingTitlesLower: Iterable<string>): boolean;
|
|
14
32
|
/**
|
|
15
33
|
* Promote insights from insights-index into awareness when confirmed_count >= threshold.
|
|
16
34
|
* @param threshold minimum confirmations required (default 3)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insight-promotion.d.ts","sourceRoot":"","sources":["../../src/tools-logic/insight-promotion.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"insight-promotion.d.ts","sourceRoot":"","sources":["../../src/tools-logic/insight-promotion.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,IAAI,CAAC;AAElD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,OAAO,CAWrG;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,SAAS,SAAmC,GAAG,OAAO,CAAC,eAAe,CAAC,CAqDrH"}
|