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
|
@@ -1,24 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Dream health —
|
|
2
|
+
* Dream health — uptime AND yield for the nightly dreaming pipeline.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* History: this module originally only counted consecutive failure days from
|
|
5
|
+
* the AAM run logs ("did the log say Dream complete") — uptime. That let the
|
|
6
|
+
* broken admission math run 22+ consecutive ZERO-OUTPUT nights (2026-08-20 →
|
|
7
|
+
* 09-12) with every night green: the cron fired, the log said complete, and
|
|
8
|
+
* nothing anywhere recorded that every candidate had been silently discarded.
|
|
7
9
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
10
|
+
* fix10 (2026-09-12) adds the YIELD dimension. dream-admission writes one
|
|
11
|
+
* yield record per night (<root>/dreams/yield-YYYY-MM-DD.json — see
|
|
12
|
+
* storage/dream-yield.ts); this module classifies each night and keeps a
|
|
13
|
+
* zero-yield streak with a CAUSE breakdown, so a silent-empty streak is
|
|
14
|
+
* structurally impossible:
|
|
15
|
+
*
|
|
16
|
+
* "filtered" — candidates seen, math rejected them → banner at ≥3 nights
|
|
17
|
+
* "errored" — run recorded errors, zero yield → banner at ≥3 nights
|
|
18
|
+
* "no-yield-data" — run completed but wrote no yield record (SOP not yet
|
|
19
|
+
* repointed / instrumentation gap) → banner at ≥3 nights
|
|
20
|
+
* "empty-corpus" — zero candidates in the corpus → banner at ≥7 nights
|
|
21
|
+
* "already-known" — candidates seen, all already counted → banner at ≥7 nights
|
|
22
|
+
*
|
|
23
|
+
* Uptime logs: ~/.aam/dreams/run-YYYY-MM-DD.log (AAM-orchestrated dreams).
|
|
24
|
+
* A day's log "succeeded" if it contains "Dream complete"/"Dream run complete".
|
|
11
25
|
*/
|
|
12
26
|
import * as fs from "node:fs";
|
|
13
27
|
import * as path from "node:path";
|
|
14
28
|
import * as os from "node:os";
|
|
15
|
-
|
|
29
|
+
import { readDreamYield, classifyNight } from "./dream-yield.js";
|
|
30
|
+
const DEFAULT_DREAMS_DIR = path.join(os.homedir(), ".aam", "dreams");
|
|
16
31
|
const LOOKBACK_DAYS = 7;
|
|
17
32
|
const BANNER_THRESHOLD = 2; // surface when N or more consecutive failures
|
|
18
|
-
|
|
19
|
-
|
|
33
|
+
/** Yield lookback must be long enough that a 22-night silent streak can never
|
|
34
|
+
* hide inside it again. */
|
|
35
|
+
const YIELD_LOOKBACK_DAYS = 30;
|
|
36
|
+
/** Zero-yield streaks containing a "filtered", "errored" or "no-yield-data"
|
|
37
|
+
* night banner here. */
|
|
38
|
+
const ZERO_YIELD_BANNER_THRESHOLD = 3;
|
|
39
|
+
/** Pure thin-corpus / already-known streaks banner here (a quiet week is
|
|
40
|
+
* legitimate; a quiet-plus week deserves a look). */
|
|
41
|
+
const THIN_CORPUS_BANNER_THRESHOLD = 7;
|
|
42
|
+
function dateNDaysAgo(n, now) {
|
|
43
|
+
const d = new Date(now.getTime());
|
|
20
44
|
d.setDate(d.getDate() - n);
|
|
21
|
-
|
|
45
|
+
const y = d.getFullYear();
|
|
46
|
+
const m = String(d.getMonth() + 1).padStart(2, "0");
|
|
47
|
+
const day = String(d.getDate()).padStart(2, "0");
|
|
48
|
+
return `${y}-${m}-${day}`;
|
|
22
49
|
}
|
|
23
50
|
function isSuccess(logPath) {
|
|
24
51
|
try {
|
|
@@ -29,50 +56,118 @@ function isSuccess(logPath) {
|
|
|
29
56
|
return false;
|
|
30
57
|
}
|
|
31
58
|
}
|
|
32
|
-
export function getDreamHealth() {
|
|
59
|
+
export function getDreamHealth(opts = {}) {
|
|
60
|
+
const dreamsDir = opts.aamDreamsDir ?? process.env.AGENT_RECALL_AAM_DREAMS_DIR ?? DEFAULT_DREAMS_DIR;
|
|
61
|
+
const now = opts.now ?? new Date();
|
|
33
62
|
const out = {
|
|
34
63
|
consecutive_failures: 0,
|
|
35
64
|
last_failed_date: null,
|
|
36
65
|
last_success_date: null,
|
|
66
|
+
consecutive_zero_yield: 0,
|
|
67
|
+
last_night_class: null,
|
|
68
|
+
zero_yield_causes: {},
|
|
69
|
+
yield_last_night: null,
|
|
37
70
|
banner: null,
|
|
71
|
+
banner_kind: null,
|
|
38
72
|
};
|
|
39
|
-
|
|
40
|
-
return out;
|
|
73
|
+
// ── uptime streak (unchanged behavior) ──────────────────────────────────
|
|
41
74
|
// Walk yesterday → 7 days ago. Today is in-progress so we don't count it.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
75
|
+
if (fs.existsSync(dreamsDir)) {
|
|
76
|
+
for (let i = 1; i <= LOOKBACK_DAYS; i++) {
|
|
77
|
+
const dateStr = dateNDaysAgo(i, now);
|
|
78
|
+
const logPath = path.join(dreamsDir, `run-${dateStr}.log`);
|
|
79
|
+
if (!fs.existsSync(logPath)) {
|
|
80
|
+
// No log = no run that night; treat as a failure (cron didn't fire OR
|
|
81
|
+
// it crashed before writing). Stops the streak if we'd been counting,
|
|
82
|
+
// since "no log" + "missing" are both signs of unhealthy automation.
|
|
83
|
+
if (out.last_success_date === null) {
|
|
84
|
+
out.consecutive_failures++;
|
|
85
|
+
if (out.last_failed_date === null)
|
|
86
|
+
out.last_failed_date = dateStr;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (isSuccess(logPath)) {
|
|
94
|
+
if (out.last_success_date === null)
|
|
95
|
+
out.last_success_date = dateStr;
|
|
96
|
+
break; // streak ended
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
50
99
|
out.consecutive_failures++;
|
|
51
100
|
if (out.last_failed_date === null)
|
|
52
101
|
out.last_failed_date = dateStr;
|
|
53
102
|
}
|
|
54
|
-
|
|
55
|
-
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// ── yield streak (fix10) ────────────────────────────────────────────────
|
|
106
|
+
// Walk yesterday → 30 days ago. A night participates when it RAN (success
|
|
107
|
+
// log present) or left a yield record; cron-dead nights belong to the
|
|
108
|
+
// uptime streak above and neither extend nor break the yield streak.
|
|
109
|
+
let candidatesSeenInStreak = 0;
|
|
110
|
+
for (let i = 1; i <= YIELD_LOOKBACK_DAYS; i++) {
|
|
111
|
+
const dateStr = dateNDaysAgo(i, now);
|
|
112
|
+
const record = readDreamYield(dateStr);
|
|
113
|
+
const ranPerLog = fs.existsSync(path.join(dreamsDir, `run-${dateStr}.log`))
|
|
114
|
+
&& isSuccess(path.join(dreamsDir, `run-${dateStr}.log`));
|
|
115
|
+
if (!record && !ranPerLog)
|
|
116
|
+
continue; // no run that night
|
|
117
|
+
const klass = classifyNight(record);
|
|
118
|
+
if (out.last_night_class === null) {
|
|
119
|
+
out.last_night_class = klass;
|
|
120
|
+
if (record) {
|
|
121
|
+
out.yield_last_night = {
|
|
122
|
+
date: record.date,
|
|
123
|
+
candidates_seen: record.candidates_seen,
|
|
124
|
+
admitted: record.admitted,
|
|
125
|
+
promoted: record.promoted,
|
|
126
|
+
already_known: record.already_known,
|
|
127
|
+
rejected: record.rejected,
|
|
128
|
+
};
|
|
56
129
|
}
|
|
57
|
-
continue;
|
|
58
130
|
}
|
|
59
|
-
if (
|
|
60
|
-
if (out.last_success_date === null)
|
|
61
|
-
out.last_success_date = dateStr;
|
|
131
|
+
if (klass === "productive")
|
|
62
132
|
break; // streak ended
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
out.last_failed_date = dateStr;
|
|
68
|
-
}
|
|
133
|
+
out.consecutive_zero_yield++;
|
|
134
|
+
out.zero_yield_causes[klass] = (out.zero_yield_causes[klass] ?? 0) + 1;
|
|
135
|
+
if (record)
|
|
136
|
+
candidatesSeenInStreak += record.candidates_seen;
|
|
69
137
|
}
|
|
138
|
+
// ── banners (failure streak wins — a dead cron is the louder problem) ───
|
|
70
139
|
if (out.consecutive_failures >= BANNER_THRESHOLD) {
|
|
71
140
|
const lastSuccess = out.last_success_date ?? `>${LOOKBACK_DAYS} days ago`;
|
|
72
141
|
out.banner =
|
|
73
142
|
`⚠ Dream cron failed ${out.consecutive_failures} nights in a row ` +
|
|
74
143
|
`(last success: ${lastSuccess}). The awareness backfill is broken — ` +
|
|
75
|
-
`check
|
|
144
|
+
`check ${path.join(dreamsDir, `run-${out.last_failed_date}.log`)} for auth or network errors.`;
|
|
145
|
+
out.banner_kind = "failure";
|
|
146
|
+
return out;
|
|
147
|
+
}
|
|
148
|
+
const filtered = out.zero_yield_causes["filtered"] ?? 0;
|
|
149
|
+
const errored = out.zero_yield_causes["errored"] ?? 0;
|
|
150
|
+
const noData = out.zero_yield_causes["no-yield-data"] ?? 0;
|
|
151
|
+
if (out.consecutive_zero_yield >= ZERO_YIELD_BANNER_THRESHOLD && (filtered > 0 || errored > 0 || noData > 0)) {
|
|
152
|
+
const causes = [];
|
|
153
|
+
if (filtered > 0)
|
|
154
|
+
causes.push(`${filtered} night(s) the admission math rejected every candidate (${candidatesSeenInStreak} candidates seen, 0 admitted)`);
|
|
155
|
+
if (errored > 0)
|
|
156
|
+
causes.push(`${errored} night(s) ran with errors (see errors[] in the yield files)`);
|
|
157
|
+
if (noData > 0)
|
|
158
|
+
causes.push(`${noData} night(s) ran without writing a yield record (SOP not repointed to \`ar dream admit\`?)`);
|
|
159
|
+
out.banner =
|
|
160
|
+
`⚠ Dream ran ${out.consecutive_zero_yield} nights in a row with ZERO yield — ` +
|
|
161
|
+
`not a thin corpus: ${causes.join("; ")}. ` +
|
|
162
|
+
`Inspect the yield files under <root>/dreams/yield-*.json.`;
|
|
163
|
+
out.banner_kind = "zero-yield";
|
|
164
|
+
}
|
|
165
|
+
else if (out.consecutive_zero_yield >= THIN_CORPUS_BANNER_THRESHOLD) {
|
|
166
|
+
out.banner =
|
|
167
|
+
`ℹ Dream yielded nothing for ${out.consecutive_zero_yield} consecutive nights — ` +
|
|
168
|
+
`corpus genuinely thin (no candidates were filtered out). ` +
|
|
169
|
+
`Fine if activity has been low; otherwise check capture volume.`;
|
|
170
|
+
out.banner_kind = "thin-corpus";
|
|
76
171
|
}
|
|
77
172
|
return out;
|
|
78
173
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dream-health.js","sourceRoot":"","sources":["../../src/storage/dream-health.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"dream-health.js","sourceRoot":"","sources":["../../src/storage/dream-health.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,aAAa,EAA+C,MAAM,kBAAkB,CAAC;AAgC9G,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AACrE,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,gBAAgB,GAAG,CAAC,CAAC,CAAE,8CAA8C;AAE3E;4BAC4B;AAC5B,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B;yBACyB;AACzB,MAAM,2BAA2B,GAAG,CAAC,CAAC;AACtC;sDACsD;AACtD,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAavC,SAAS,YAAY,CAAC,CAAS,EAAE,GAAS;IACxC,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IAClC,CAAC,C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C9D,GAAG,CAAC,WAAW,GAAG,YAAY,CAAC;IACjC,CAAC;SAAM,IAAI,GAAG,CAAC,sBAAsB,IAAI,4BAA4B,EAAE,CAAC;QACtE,GAAG,CAAC,MAAM;YACR,+BAA+B,GAAG,CAAC,sBAAsB,wBAAwB;gBACjF,2DAA2D;gBAC3D,gEAAgE,CAAC;QACnE,GAAG,CAAC,WAAW,GAAG,aAAa,CAAC;IAClC,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dream-yield.ts — per-night YIELD accounting for the dreaming pipeline (fix10).
|
|
3
|
+
*
|
|
4
|
+
* Why this exists: dream-health.ts historically measured UPTIME only ("did the
|
|
5
|
+
* log say Dream complete") — 22 consecutive zero-output nights were all green
|
|
6
|
+
* because the broken admission math (`(obs/7) × recency ≤ 0.85` — see
|
|
7
|
+
* tools-logic/dream-admission.ts) silently discarded every candidate and
|
|
8
|
+
* nothing recorded that a candidate had even been seen.
|
|
9
|
+
*
|
|
10
|
+
* This module is the structural fix for the SILENCE half of that bug: every
|
|
11
|
+
* dream-admission run writes one DreamYieldRecord per night, and every
|
|
12
|
+
* candidate appears in it with an explicit outcome + reason. A zero-output
|
|
13
|
+
* night is now CLASSIFIABLE:
|
|
14
|
+
*
|
|
15
|
+
* "empty-corpus" — the corpus genuinely produced no candidates
|
|
16
|
+
* "filtered" — candidates were seen but the math rejected them (RED —
|
|
17
|
+
* this is exactly the failure mode that ran silent for
|
|
18
|
+
* 22 nights)
|
|
19
|
+
* "already-known" — candidates were seen but every one was already counted
|
|
20
|
+
* or already promoted (nothing NEW, but nothing hidden)
|
|
21
|
+
* "errored" — the run recorded errors (ledger corruption/write
|
|
22
|
+
* failure, promotion-pass failure, …) and produced no
|
|
23
|
+
* yield; never benign (fix10 review MEDIUM-2 — errors[]
|
|
24
|
+
* used to be invisible to classification)
|
|
25
|
+
* "no-yield-data" — the run log says the dream completed but no yield
|
|
26
|
+
* record exists (instrumentation gap — e.g. the SOP has
|
|
27
|
+
* not been repointed to `ar dream admit` yet). Flagged,
|
|
28
|
+
* never treated as healthy.
|
|
29
|
+
*
|
|
30
|
+
* File location: <root>/dreams/yield-YYYY-MM-DD.json — co-located with the
|
|
31
|
+
* dream reports the nightly agent writes to <root>/dreams/YYYY-MM-DD.md.
|
|
32
|
+
*/
|
|
33
|
+
/** One candidate's final disposition inside a night's yield record. */
|
|
34
|
+
export interface DreamYieldDecision {
|
|
35
|
+
title: string;
|
|
36
|
+
/** Final disposition after ledger dedup + index recording + promotion. */
|
|
37
|
+
outcome: "promoted" | "already-promoted" | "admitted" | "already-counted" | "rejected";
|
|
38
|
+
/** Distinct (day, project) observations inside the trailing window. */
|
|
39
|
+
observations_in_window: number;
|
|
40
|
+
/** Observations that were NEW tonight (not counted on a previous night). */
|
|
41
|
+
new_observations: number;
|
|
42
|
+
/** ALWAYS non-empty. A silent discard is structurally impossible. */
|
|
43
|
+
reason: string;
|
|
44
|
+
}
|
|
45
|
+
export interface DreamYieldCorpus {
|
|
46
|
+
journal_files?: number;
|
|
47
|
+
journal_bytes?: number;
|
|
48
|
+
corrections_new?: number;
|
|
49
|
+
notes?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface DreamYieldRecord {
|
|
52
|
+
version: 1;
|
|
53
|
+
/** Run date (local calendar day the dream ran), YYYY-MM-DD. */
|
|
54
|
+
date: string;
|
|
55
|
+
generated_at: string;
|
|
56
|
+
candidates_seen: number;
|
|
57
|
+
admitted: number;
|
|
58
|
+
promoted: number;
|
|
59
|
+
already_known: number;
|
|
60
|
+
rejected: number;
|
|
61
|
+
/** reason → count, over every non-yield outcome (rejected + already-counted). */
|
|
62
|
+
discarded_by_reason: Record<string, number>;
|
|
63
|
+
decisions: DreamYieldDecision[];
|
|
64
|
+
/** Full list of titles promoteConfirmedInsights promoted this run (may
|
|
65
|
+
* include index insights confirmed by the ONLINE path, not just tonight's
|
|
66
|
+
* candidates — promotion is shared machinery). */
|
|
67
|
+
promoted_titles: string[];
|
|
68
|
+
corpus?: DreamYieldCorpus;
|
|
69
|
+
errors?: string[];
|
|
70
|
+
}
|
|
71
|
+
export type NightYieldClass = "productive" | "empty-corpus" | "filtered" | "already-known" | "errored" | "no-yield-data";
|
|
72
|
+
export declare function dreamsDir(): string;
|
|
73
|
+
export declare function dreamYieldPath(date: string): string;
|
|
74
|
+
export declare function writeDreamYield(record: DreamYieldRecord): void;
|
|
75
|
+
export declare function readDreamYield(date: string): DreamYieldRecord | null;
|
|
76
|
+
/**
|
|
77
|
+
* Classify one night. `null` = the night ran but left no yield record
|
|
78
|
+
* ("no-yield-data" — an instrumentation gap is a finding, not health).
|
|
79
|
+
*/
|
|
80
|
+
export declare function classifyNight(record: DreamYieldRecord | null): NightYieldClass;
|
|
81
|
+
//# sourceMappingURL=dream-yield.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dream-yield.d.ts","sourceRoot":"","sources":["../../src/storage/dream-yield.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAOH,uEAAuE;AACvE,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,OAAO,EACH,UAAU,GACV,kBAAkB,GAClB,UAAU,GACV,iBAAiB,GACjB,UAAU,CAAC;IACf,uEAAuE;IACvE,sBAAsB,EAAE,MAAM,CAAC;IAC/B,4EAA4E;IAC5E,gBAAgB,EAAE,MAAM,CAAC;IACzB,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,CAAC,CAAC;IACX,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC;;uDAEmD;IACnD,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,MAAM,eAAe,GACvB,YAAY,GACZ,cAAc,GACd,UAAU,GACV,eAAe,GACf,SAAS,GACT,eAAe,CAAC;AAEpB,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAG9D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAKpE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,GAAG,eAAe,CAa9E"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dream-yield.ts — per-night YIELD accounting for the dreaming pipeline (fix10).
|
|
3
|
+
*
|
|
4
|
+
* Why this exists: dream-health.ts historically measured UPTIME only ("did the
|
|
5
|
+
* log say Dream complete") — 22 consecutive zero-output nights were all green
|
|
6
|
+
* because the broken admission math (`(obs/7) × recency ≤ 0.85` — see
|
|
7
|
+
* tools-logic/dream-admission.ts) silently discarded every candidate and
|
|
8
|
+
* nothing recorded that a candidate had even been seen.
|
|
9
|
+
*
|
|
10
|
+
* This module is the structural fix for the SILENCE half of that bug: every
|
|
11
|
+
* dream-admission run writes one DreamYieldRecord per night, and every
|
|
12
|
+
* candidate appears in it with an explicit outcome + reason. A zero-output
|
|
13
|
+
* night is now CLASSIFIABLE:
|
|
14
|
+
*
|
|
15
|
+
* "empty-corpus" — the corpus genuinely produced no candidates
|
|
16
|
+
* "filtered" — candidates were seen but the math rejected them (RED —
|
|
17
|
+
* this is exactly the failure mode that ran silent for
|
|
18
|
+
* 22 nights)
|
|
19
|
+
* "already-known" — candidates were seen but every one was already counted
|
|
20
|
+
* or already promoted (nothing NEW, but nothing hidden)
|
|
21
|
+
* "errored" — the run recorded errors (ledger corruption/write
|
|
22
|
+
* failure, promotion-pass failure, …) and produced no
|
|
23
|
+
* yield; never benign (fix10 review MEDIUM-2 — errors[]
|
|
24
|
+
* used to be invisible to classification)
|
|
25
|
+
* "no-yield-data" — the run log says the dream completed but no yield
|
|
26
|
+
* record exists (instrumentation gap — e.g. the SOP has
|
|
27
|
+
* not been repointed to `ar dream admit` yet). Flagged,
|
|
28
|
+
* never treated as healthy.
|
|
29
|
+
*
|
|
30
|
+
* File location: <root>/dreams/yield-YYYY-MM-DD.json — co-located with the
|
|
31
|
+
* dream reports the nightly agent writes to <root>/dreams/YYYY-MM-DD.md.
|
|
32
|
+
*/
|
|
33
|
+
import * as path from "node:path";
|
|
34
|
+
import { getRoot } from "../types.js";
|
|
35
|
+
import { ensureDir, readJsonSafe, writeJsonAtomic } from "./fs-utils.js";
|
|
36
|
+
export function dreamsDir() {
|
|
37
|
+
return path.join(getRoot(), "dreams");
|
|
38
|
+
}
|
|
39
|
+
export function dreamYieldPath(date) {
|
|
40
|
+
return path.join(dreamsDir(), `yield-${date}.json`);
|
|
41
|
+
}
|
|
42
|
+
export function writeDreamYield(record) {
|
|
43
|
+
ensureDir(dreamsDir());
|
|
44
|
+
writeJsonAtomic(dreamYieldPath(record.date), record);
|
|
45
|
+
}
|
|
46
|
+
export function readDreamYield(date) {
|
|
47
|
+
const rec = readJsonSafe(dreamYieldPath(date));
|
|
48
|
+
if (!rec || typeof rec !== "object")
|
|
49
|
+
return null;
|
|
50
|
+
if (typeof rec.date !== "string" || typeof rec.candidates_seen !== "number")
|
|
51
|
+
return null;
|
|
52
|
+
return rec;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Classify one night. `null` = the night ran but left no yield record
|
|
56
|
+
* ("no-yield-data" — an instrumentation gap is a finding, not health).
|
|
57
|
+
*/
|
|
58
|
+
export function classifyNight(record) {
|
|
59
|
+
if (!record)
|
|
60
|
+
return "no-yield-data";
|
|
61
|
+
if (record.promoted + record.admitted > 0)
|
|
62
|
+
return "productive";
|
|
63
|
+
// MEDIUM-2: a zero-yield night that recorded errors is NEVER benign — a
|
|
64
|
+
// ledger reset or failed promotion pass must not read as "corpus thin" or
|
|
65
|
+
// "already known".
|
|
66
|
+
if ((record.errors?.length ?? 0) > 0)
|
|
67
|
+
return "errored";
|
|
68
|
+
if (record.candidates_seen === 0)
|
|
69
|
+
return "empty-corpus";
|
|
70
|
+
// Zero yield with candidates present: if the MATH rejected anything, the
|
|
71
|
+
// math is the cause; only when nothing was rejected is "everything was
|
|
72
|
+
// already known" the honest read.
|
|
73
|
+
if (record.rejected > 0)
|
|
74
|
+
return "filtered";
|
|
75
|
+
return "already-known";
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=dream-yield.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dream-yield.js","sourceRoot":"","sources":["../../src/storage/dream-yield.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,MAA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CAAC,QAAQ,GAAG,CAAC;QAAE,OAAO,UAAU,CAAC;IAC3C,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -45,11 +45,19 @@
|
|
|
45
45
|
* Cross-process safety does not depend on the fn being sync: the mkdir lock
|
|
46
46
|
* itself excludes concurrent critical sections either way.
|
|
47
47
|
*
|
|
48
|
-
* LOCK ORDERING (deadlock discipline — the
|
|
48
|
+
* LOCK ORDERING (deadlock discipline — the complete nesting set):
|
|
49
49
|
* "awareness-state" → "awareness"
|
|
50
|
+
* "dream-admission" → "insights-index"
|
|
51
|
+
* "dream-admission" → "awareness-state" → "awareness"
|
|
50
52
|
* awareness.ts acquires "awareness" (awareness.md render) while holding
|
|
51
53
|
* "awareness-state" (awareness-state.json + awareness-archive.json RMW).
|
|
52
|
-
*
|
|
54
|
+
* fix10: dream-admission.ts wraps its whole nightly run (a long async
|
|
55
|
+
* critical section) in "dream-admission" and acquires "insights-index"
|
|
56
|
+
* (addIndexedInsight) and "awareness-state" (addInsight via
|
|
57
|
+
* promoteConfirmedInsights / the cap fallback) inside it. "dream-admission"
|
|
58
|
+
* has a SINGLE acquirer and is always the outermost lock — no cycle.
|
|
59
|
+
* Never acquire "awareness-state" while holding "awareness", and never
|
|
60
|
+
* acquire "dream-admission" while holding any other lock. Same-name
|
|
53
61
|
* nesting is a deadlock (the lock is NOT reentrant): modules expose
|
|
54
62
|
* *Unlocked internals for use inside their own critical sections instead.
|
|
55
63
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filelock.d.ts","sourceRoot":"","sources":["../../src/storage/filelock.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"filelock.d.ts","sourceRoot":"","sources":["../../src/storage/filelock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AASH;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,QAAQ,CAAC;AAgBnC;;;;kCAIkC;AAClC,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;gBAEtB,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;CAoBjF;AA6LD;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAyBnE;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAOpF"}
|
package/dist/storage/filelock.js
CHANGED
|
@@ -45,11 +45,19 @@
|
|
|
45
45
|
* Cross-process safety does not depend on the fn being sync: the mkdir lock
|
|
46
46
|
* itself excludes concurrent critical sections either way.
|
|
47
47
|
*
|
|
48
|
-
* LOCK ORDERING (deadlock discipline — the
|
|
48
|
+
* LOCK ORDERING (deadlock discipline — the complete nesting set):
|
|
49
49
|
* "awareness-state" → "awareness"
|
|
50
|
+
* "dream-admission" → "insights-index"
|
|
51
|
+
* "dream-admission" → "awareness-state" → "awareness"
|
|
50
52
|
* awareness.ts acquires "awareness" (awareness.md render) while holding
|
|
51
53
|
* "awareness-state" (awareness-state.json + awareness-archive.json RMW).
|
|
52
|
-
*
|
|
54
|
+
* fix10: dream-admission.ts wraps its whole nightly run (a long async
|
|
55
|
+
* critical section) in "dream-admission" and acquires "insights-index"
|
|
56
|
+
* (addIndexedInsight) and "awareness-state" (addInsight via
|
|
57
|
+
* promoteConfirmedInsights / the cap fallback) inside it. "dream-admission"
|
|
58
|
+
* has a SINGLE acquirer and is always the outermost lock — no cycle.
|
|
59
|
+
* Never acquire "awareness-state" while holding "awareness", and never
|
|
60
|
+
* acquire "dream-admission" while holding any other lock. Same-name
|
|
53
61
|
* nesting is a deadlock (the lock is NOT reentrant): modules expose
|
|
54
62
|
* *Unlocked internals for use inside their own critical sections instead.
|
|
55
63
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filelock.js","sourceRoot":"","sources":["../../src/storage/filelock.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"filelock.js","sourceRoot":"","sources":["../../src/storage/filelock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,MAAM,eAAe,GAAG,IAAI,CAAC;AAC7B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC;AACnC,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC;;;;;GAKG;AACH,MAAM,aAAa,GAAG,OAAO,CAAC;AAO9B;;;;kCAIkC;AAClC,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,QAAQ,CAAS;IACjB,SAAS,CAAgB;IACzB,SAAS,CAAgB;IAElC,YAAY,QAAgB,EAAE,SAAwB,EAAE,SAAwB;QAC9E,MAAM,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI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B,CAAC;YAAS,CAAC;QACT,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
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 { type PromotionResult } from "./insight-promotion.js";
|
|
47
|
+
import { type DreamYieldDecision, type DreamYieldCorpus } from "../storage/dream-yield.js";
|
|
48
|
+
/** Bump when the admission contract changes (SOP repoints pin this). */
|
|
49
|
+
export declare const DREAM_ADMISSION_VERSION = "v2";
|
|
50
|
+
/** Trailing observation window, in calendar days. */
|
|
51
|
+
export declare const DREAM_WINDOW_DAYS = 7;
|
|
52
|
+
/**
|
|
53
|
+
* Promotion bar — deliberately THE SAME value as promoteConfirmedInsights'
|
|
54
|
+
* default. One bar, two entry points (online session_end + offline dream);
|
|
55
|
+
* never duplicate it with harsher numbers. fix10 LOW-4: re-exported from the
|
|
56
|
+
* ONE constant instead of a second literal, so the bars cannot drift apart.
|
|
57
|
+
*/
|
|
58
|
+
export declare const DREAM_PROMOTION_THRESHOLD = 3;
|
|
59
|
+
export interface DreamObservation {
|
|
60
|
+
/** Calendar day the pattern was observed (journal date), YYYY-MM-DD. */
|
|
61
|
+
date: string;
|
|
62
|
+
/** Project slug the observation came from (optional but recommended). */
|
|
63
|
+
project?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface DreamCandidate {
|
|
66
|
+
title: string;
|
|
67
|
+
observations: DreamObservation[];
|
|
68
|
+
applies_when?: string[];
|
|
69
|
+
severity?: "critical" | "important" | "minor";
|
|
70
|
+
evidence?: string;
|
|
71
|
+
}
|
|
72
|
+
/** Pure-math outcome for one candidate (the unit-pinnable formula). */
|
|
73
|
+
export interface DreamDecision {
|
|
74
|
+
title: string;
|
|
75
|
+
outcome: "promote" | "admit" | "reject";
|
|
76
|
+
/** Distinct (day, project) observations inside the trailing window. */
|
|
77
|
+
observations_in_window: number;
|
|
78
|
+
/** ALWAYS non-empty — rejection without a reason is the bug this fixes. */
|
|
79
|
+
reason: string;
|
|
80
|
+
}
|
|
81
|
+
export interface DreamCandidateResult extends DreamYieldDecision {
|
|
82
|
+
/** The pure-math decision before ledger/index/promotion effects. */
|
|
83
|
+
math: DreamDecision;
|
|
84
|
+
/** Index title the observations were merged into (similarity merge may
|
|
85
|
+
* differ from the candidate title), when recording happened. */
|
|
86
|
+
index_title?: string;
|
|
87
|
+
/** confirmed_count after tonight's recording, when recording happened. */
|
|
88
|
+
confirmed_count?: number;
|
|
89
|
+
}
|
|
90
|
+
export interface DreamAdmissionReport {
|
|
91
|
+
version: typeof DREAM_ADMISSION_VERSION;
|
|
92
|
+
run_date: string;
|
|
93
|
+
threshold: number;
|
|
94
|
+
window_days: number;
|
|
95
|
+
candidates_seen: number;
|
|
96
|
+
admitted: number;
|
|
97
|
+
promoted: number;
|
|
98
|
+
already_known: number;
|
|
99
|
+
rejected: number;
|
|
100
|
+
results: DreamCandidateResult[];
|
|
101
|
+
promotion: PromotionResult;
|
|
102
|
+
yield_file: string;
|
|
103
|
+
errors: string[];
|
|
104
|
+
}
|
|
105
|
+
export interface DreamAdmissionOptions {
|
|
106
|
+
/** Run timestamp — defaults to now. A 2 AM run counts yesterday's journals
|
|
107
|
+
* at FULL weight (there is no weight — only window membership). */
|
|
108
|
+
runDate?: Date;
|
|
109
|
+
threshold?: number;
|
|
110
|
+
corpus?: DreamYieldCorpus;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The formula, replaced. Pure — no store access, unit-pinnable.
|
|
114
|
+
*
|
|
115
|
+
* 3 distinct (day, project) incidents within the window at a 2 AM run → "promote"
|
|
116
|
+
* (one day observed in three projects counts 3 — see the observation-unit note above).
|
|
117
|
+
* 1–2 → "admit" (retained candidate; confirmations accrue with no window).
|
|
118
|
+
* 0 → "reject", with the reason spelled out.
|
|
119
|
+
*/
|
|
120
|
+
export declare function evaluateDreamCandidate(candidate: DreamCandidate, opts?: {
|
|
121
|
+
runDate?: Date;
|
|
122
|
+
threshold?: number;
|
|
123
|
+
}): DreamDecision;
|
|
124
|
+
/**
|
|
125
|
+
* Run admission over tonight's extracted candidates: evaluate → record NEW
|
|
126
|
+
* observations into insights-index → promote via the SHARED
|
|
127
|
+
* promoteConfirmedInsights machinery → write the night's yield record.
|
|
128
|
+
*
|
|
129
|
+
* Guarantees:
|
|
130
|
+
* - every candidate appears in the returned results AND the yield file,
|
|
131
|
+
* with a non-empty reason (no silent discards, ever);
|
|
132
|
+
* - idempotent across nights (sliding 7-day windows overlap 6 days — the
|
|
133
|
+
* ledger ensures an observation is counted exactly once);
|
|
134
|
+
* - yield-file write failure never aborts the run (error surfaces in
|
|
135
|
+
* report.errors).
|
|
136
|
+
*/
|
|
137
|
+
export declare function runDreamAdmission(candidates: DreamCandidate[], opts?: DreamAdmissionOptions): Promise<DreamAdmissionReport>;
|
|
138
|
+
/**
|
|
139
|
+
* Versioned replacement text for the SOP's Step 3 (the deploy artifact for
|
|
140
|
+
* repointing ~/.aam/dreams/dream-prompt.md — printable via `ar dream sop`).
|
|
141
|
+
* The old prose formula is GONE; the math lives in code where it is tested.
|
|
142
|
+
*/
|
|
143
|
+
export declare const DREAM_STEP3_SOP = "## Step 3: Pattern Extraction (admit-then-vote \u2014 dream-admission v2)\n\nDiscover journal files from the last 7 days (same discovery as before).\nFor each recurring pattern, build ONE candidate object:\n { \"title\": \"When {situation}: {action}\",\n \"observations\": [ { \"date\": \"YYYY-MM-DD\", \"project\": \"slug\" }, ... ],\n \"applies_when\": [\"kw1\",\"kw2\",\"kw3\"],\n \"evidence\": \"observed across: ...\" }\nOne observation per (journal day, project) the pattern appeared in. Include EVERY\npattern you noticed \u2014 even 1x. Admission math is NOT your job.\n\nWrite all candidates to a temp file and run:\n ar dream admit --file /tmp/dream-candidates.json \\\n --journal-files {N} --journal-bytes {B} --corrections-new {C}\n\nThe command (deterministic, tested):\n - promotes any candidate with \u2265 3 distinct (journal-day, project) incidents in 7d\n (same day in two projects = 2 incidents; same-day repeats in one project = 1)\n (same bar as the online promoteConfirmedInsights path \u2014 no recency multiplier,\n a 2 AM run counts yesterday at full weight);\n - admits 1\u20132x candidates into insights-index where confirmations accrue all-time;\n - never discards silently: every candidate gets an outcome + reason;\n - writes the night's yield record (~/.agent-recall/dreams/yield-YYYY-MM-DD.json).\n\nPaste the command's decision table verbatim into the dream report under\n\"## Admission Decisions\". Do NOT compute confidence scores; do NOT skip\nlow-count patterns yourself.\n\nSteps 5/5.5 note: where the old SOP said \"confidence \u2265 0.9\", read\n\"confirmed_count \u2265 6\" (2\u00D7 the promotion bar).";
|
|
144
|
+
//# sourceMappingURL=dream-admission.d.ts.map
|