agent-recall-core 3.4.50 → 3.4.51

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.
Files changed (65) hide show
  1. package/dist/helpers/transcript-project.d.ts +69 -0
  2. package/dist/helpers/transcript-project.d.ts.map +1 -0
  3. package/dist/helpers/transcript-project.js +212 -0
  4. package/dist/helpers/transcript-project.js.map +1 -0
  5. package/dist/index.d.ts +20 -3
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +47 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/palace/awareness.d.ts +6 -0
  10. package/dist/palace/awareness.d.ts.map +1 -1
  11. package/dist/palace/awareness.js +10 -4
  12. package/dist/palace/awareness.js.map +1 -1
  13. package/dist/retrieval/activation.d.ts +202 -0
  14. package/dist/retrieval/activation.d.ts.map +1 -0
  15. package/dist/retrieval/activation.js +313 -0
  16. package/dist/retrieval/activation.js.map +1 -0
  17. package/dist/storage/corrections.d.ts +140 -2
  18. package/dist/storage/corrections.d.ts.map +1 -1
  19. package/dist/storage/corrections.js +97 -4
  20. package/dist/storage/corrections.js.map +1 -1
  21. package/dist/storage/heed-tiers.d.ts +206 -0
  22. package/dist/storage/heed-tiers.d.ts.map +1 -0
  23. package/dist/storage/heed-tiers.js +318 -0
  24. package/dist/storage/heed-tiers.js.map +1 -0
  25. package/dist/supabase/sync.d.ts +1 -1
  26. package/dist/supabase/sync.d.ts.map +1 -1
  27. package/dist/supabase/sync.js +47 -11
  28. package/dist/supabase/sync.js.map +1 -1
  29. package/dist/tools-logic/association.d.ts +260 -0
  30. package/dist/tools-logic/association.d.ts.map +1 -0
  31. package/dist/tools-logic/association.js +502 -0
  32. package/dist/tools-logic/association.js.map +1 -0
  33. package/dist/tools-logic/check-action.d.ts.map +1 -1
  34. package/dist/tools-logic/check-action.js +14 -0
  35. package/dist/tools-logic/check-action.js.map +1 -1
  36. package/dist/tools-logic/implicit-harvest.d.ts +196 -0
  37. package/dist/tools-logic/implicit-harvest.d.ts.map +1 -0
  38. package/dist/tools-logic/implicit-harvest.js +675 -0
  39. package/dist/tools-logic/implicit-harvest.js.map +1 -0
  40. package/dist/tools-logic/insight-promotion.d.ts.map +1 -1
  41. package/dist/tools-logic/insight-promotion.js +53 -1
  42. package/dist/tools-logic/insight-promotion.js.map +1 -1
  43. package/dist/tools-logic/retier.d.ts +274 -0
  44. package/dist/tools-logic/retier.d.ts.map +1 -0
  45. package/dist/tools-logic/retier.js +511 -0
  46. package/dist/tools-logic/retier.js.map +1 -0
  47. package/dist/tools-logic/session-end.d.ts +35 -0
  48. package/dist/tools-logic/session-end.d.ts.map +1 -1
  49. package/dist/tools-logic/session-end.js +26 -7
  50. package/dist/tools-logic/session-end.js.map +1 -1
  51. package/dist/tools-logic/session-start.d.ts +11 -0
  52. package/dist/tools-logic/session-start.d.ts.map +1 -1
  53. package/dist/tools-logic/session-start.js +34 -4
  54. package/dist/tools-logic/session-start.js.map +1 -1
  55. package/dist/tools-logic/smart-recall.d.ts +11 -0
  56. package/dist/tools-logic/smart-recall.d.ts.map +1 -1
  57. package/dist/tools-logic/smart-recall.js +11 -0
  58. package/dist/tools-logic/smart-recall.js.map +1 -1
  59. package/dist/tools-logic/transcript-audit.d.ts +128 -0
  60. package/dist/tools-logic/transcript-audit.d.ts.map +1 -0
  61. package/dist/tools-logic/transcript-audit.js +428 -0
  62. package/dist/tools-logic/transcript-audit.js.map +1 -0
  63. package/dist/types.d.ts +1 -1
  64. package/dist/types.js +1 -1
  65. package/package.json +1 -1
@@ -0,0 +1,128 @@
1
+ /**
2
+ * transcript-audit.ts — evolution p1a (Phase 1a): `ar outcomes audit`.
3
+ *
4
+ * The heed channel is starved because check_action is dormant (the C3 online
5
+ * "triggered" emission is a documented dormant channel — see corrections.ts's
6
+ * doc comments). This instrument produces injection-outcome events by reading
7
+ * the Claude Code session TRANSCRIPT for the day a correction was injected —
8
+ * never the agent's own end-of-session summary. Adjudication independence is
9
+ * the design law: the measured agent's own summary is NEVER evidence.
10
+ *
11
+ * Pipeline, per audit day D:
12
+ * 1. Per project: read corrections/_outcomes.jsonl for `retrieved` events
13
+ * whose `at` falls on day D (local-TZ, matching the rest of the ledger's
14
+ * day-bucketing convention) — the set of corrections INJECTED that day.
15
+ * 2. Scan the Claude Code transcript directory ONCE for the whole run;
16
+ * bucket every transcript's lines by day using each line's own
17
+ * `timestamp` field (falling back to the FILE's mtime day only when a
18
+ * transcript has NO per-line timestamps at all — never guessed
19
+ * per-line). A file that cannot be bounded either way is never silently
20
+ * attributed to any day — it is reported as ambiguous instead.
21
+ * 3. Map each transcript to a project via `resolveSessionProject` (the F1
22
+ * claim-not-generate namer) — never the old frequency-vote namer.
23
+ * 4. Extract user+assistant text for that day's lines, applying the SAME
24
+ * SYSTEM_PREFIXES/attachment filters transcript-reader.ts applies.
25
+ * 5. Adjudicate each injected correction against that day's matching
26
+ * project transcripts with a deterministic lexical ladder (strongest
27
+ * first): RECURRED > CITED > IGNORED.
28
+ * 6. Write "cited"/"ignored" (ledger-only) or "recurred" (counter-mutating,
29
+ * reusing the existing kind) via recordOutcome, evidence-prefixed
30
+ * "transcript-audit:" and gated at the core level (see corrections.ts).
31
+ * 7. Idempotent: a same-day re-run against the same transcript set writes
32
+ * zero new events.
33
+ */
34
+ export interface TranscriptAuditOptions {
35
+ /** Single audit day, YYYY-MM-DD. Mutually exclusive with since/until. */
36
+ date?: string;
37
+ /** Backfill range start (inclusive), YYYY-MM-DD. Requires --backfill semantics upstream. */
38
+ since?: string;
39
+ /** Backfill range end (inclusive), YYYY-MM-DD. Defaults to today (local-TZ) when since is set. */
40
+ until?: string;
41
+ /** Restrict to one project slug. Omit to scan every project under the store. */
42
+ project?: string;
43
+ /** Override the Claude Code transcript directory (default: same dir transcript-reader.ts uses). */
44
+ claudeDir?: string;
45
+ /** Adjudicate and report without writing any outcome events. */
46
+ dryRun?: boolean;
47
+ }
48
+ export type TranscriptAuditVerdict = "recurred" | "cited" | "ignored";
49
+ export interface TranscriptAuditAdjudication {
50
+ date: string;
51
+ project: string;
52
+ correction_id: string;
53
+ rule: string;
54
+ verdict: TranscriptAuditVerdict;
55
+ matched_words: string[];
56
+ /** Present only for a "recurred" verdict — the sentence that fired it. */
57
+ sentence?: string;
58
+ /** Transcript(s) this verdict's evidence is anchored to (idempotency key material). */
59
+ transcript_basenames: string[];
60
+ /** True iff an event was actually appended (false in --dry-run or on dedup-skip). */
61
+ written: boolean;
62
+ skipped_reason?: string;
63
+ }
64
+ export interface TranscriptAuditDaySummary {
65
+ date: string;
66
+ /** Project slugs that had ≥1 injected correction on this day. */
67
+ projects: string[];
68
+ injected: number;
69
+ cited: number;
70
+ ignored: number;
71
+ recurred: number;
72
+ dedup_skipped: number;
73
+ transcripts_scanned: number;
74
+ /** Transcript basenames whose day membership could not be bounded at all (never guessed). */
75
+ transcripts_ambiguous: string[];
76
+ /** Projects with ≥1 injected correction this day but zero matching transcripts. */
77
+ projects_without_transcripts: string[];
78
+ adjudications: TranscriptAuditAdjudication[];
79
+ }
80
+ export interface TranscriptAuditResult {
81
+ dry_run: boolean;
82
+ claude_dir: string;
83
+ days: TranscriptAuditDaySummary[];
84
+ /** Days in the range where transcripts_scanned === 0 across every project. */
85
+ transcripts_not_found_days: string[];
86
+ }
87
+ /**
88
+ * Exported for reuse (evolution p1b) — the day-range resolver is identical
89
+ * flag semantics (--date XOR --backfill --since/--until) for
90
+ * `ar corrections harvest-implicit`; TranscriptAuditOptions' date/since/until/
91
+ * project/claudeDir/dryRun shape is generic enough that implicit-harvest.ts's
92
+ * own options type is structurally compatible without a cast.
93
+ */
94
+ export declare function resolveDayRange(options: TranscriptAuditOptions): string[];
95
+ /** Same default the CLI's readTodaySessions() (transcript-reader.ts) uses. */
96
+ export declare function defaultClaudeDir(): string;
97
+ /**
98
+ * Exported for reuse (evolution p1b, `ar corrections harvest-implicit`) —
99
+ * this is the SAME day-bucketed/project-resolved scan p1a built; p1b must
100
+ * not fork a second transcript walker. See implicit-harvest.ts.
101
+ */
102
+ export interface ScannedTranscript {
103
+ basename: string;
104
+ /** Lines (parsed JSON records), bucketed by their own local-TZ day. */
105
+ byDay: Map<string, unknown[]>;
106
+ /** F1 claim-not-generate project resolution for the WHOLE session (never day-scoped). */
107
+ project: string;
108
+ }
109
+ /**
110
+ * Scan every `*.jsonl` transcript in `claudeDir` exactly once. Returns the
111
+ * per-file day-bucketed lines (for content extraction) plus the basenames of
112
+ * files that could not be bounded to ANY day (no per-line timestamps AND no
113
+ * usable mtime) — these are NEVER silently assigned to a day (ESCALATION
114
+ * clause in the brief: report the ambiguity, don't guess).
115
+ */
116
+ export declare function scanTranscripts(claudeDir: string): {
117
+ files: ScannedTranscript[];
118
+ ambiguous: string[];
119
+ };
120
+ /**
121
+ * `ar outcomes audit` — see this file's header doc for the full pipeline.
122
+ * Deterministic given the same transcripts + same store (no wall-clock in
123
+ * any adjudication decision — only recordOutcome's own recorded_at stamping
124
+ * touches wall-clock, and that is forensic metadata, never read back by the
125
+ * ladder or the idempotency check).
126
+ */
127
+ export declare function runTranscriptAudit(options: TranscriptAuditOptions): Promise<TranscriptAuditResult>;
128
+ //# sourceMappingURL=transcript-audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transcript-audit.d.ts","sourceRoot":"","sources":["../../src/tools-logic/transcript-audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AA6BH,MAAM,WAAW,sBAAsB;IACrC,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4FAA4F;IAC5F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kGAAkG;IAClG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gFAAgF;IAChF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mGAAmG;IACnG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,s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AAMD;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IAC9B,yFAAyF;IACzF,OAAO,EAAE,MAAM,CAAC;CACjB;AAYD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE,CAwEtG;AA2QD;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAgBxG"}
@@ -0,0 +1,428 @@
1
+ /**
2
+ * transcript-audit.ts — evolution p1a (Phase 1a): `ar outcomes audit`.
3
+ *
4
+ * The heed channel is starved because check_action is dormant (the C3 online
5
+ * "triggered" emission is a documented dormant channel — see corrections.ts's
6
+ * doc comments). This instrument produces injection-outcome events by reading
7
+ * the Claude Code session TRANSCRIPT for the day a correction was injected —
8
+ * never the agent's own end-of-session summary. Adjudication independence is
9
+ * the design law: the measured agent's own summary is NEVER evidence.
10
+ *
11
+ * Pipeline, per audit day D:
12
+ * 1. Per project: read corrections/_outcomes.jsonl for `retrieved` events
13
+ * whose `at` falls on day D (local-TZ, matching the rest of the ledger's
14
+ * day-bucketing convention) — the set of corrections INJECTED that day.
15
+ * 2. Scan the Claude Code transcript directory ONCE for the whole run;
16
+ * bucket every transcript's lines by day using each line's own
17
+ * `timestamp` field (falling back to the FILE's mtime day only when a
18
+ * transcript has NO per-line timestamps at all — never guessed
19
+ * per-line). A file that cannot be bounded either way is never silently
20
+ * attributed to any day — it is reported as ambiguous instead.
21
+ * 3. Map each transcript to a project via `resolveSessionProject` (the F1
22
+ * claim-not-generate namer) — never the old frequency-vote namer.
23
+ * 4. Extract user+assistant text for that day's lines, applying the SAME
24
+ * SYSTEM_PREFIXES/attachment filters transcript-reader.ts applies.
25
+ * 5. Adjudicate each injected correction against that day's matching
26
+ * project transcripts with a deterministic lexical ladder (strongest
27
+ * first): RECURRED > CITED > IGNORED.
28
+ * 6. Write "cited"/"ignored" (ledger-only) or "recurred" (counter-mutating,
29
+ * reusing the existing kind) via recordOutcome, evidence-prefixed
30
+ * "transcript-audit:" and gated at the core level (see corrections.ts).
31
+ * 7. Idempotent: a same-day re-run against the same transcript set writes
32
+ * zero new events.
33
+ */
34
+ import * as fs from "node:fs";
35
+ import * as path from "node:path";
36
+ import * as os from "node:os";
37
+ import { getRoot } from "../types.js";
38
+ import { projectsRootDir, resolveProjectDirName } from "../storage/paths.js";
39
+ import { isValidProjectSlug } from "../storage/project.js";
40
+ import { readCorrections, readOutcomesOnDate, readOutcomeEventsByCorrection, recordOutcome, splitSentences, } from "../storage/corrections.js";
41
+ import { RECURRENCE_MARKER, EVAL_VOCAB_ANCHOR, ruleContentWords } from "./session-end.js";
42
+ import { resolveSessionProject, isSystemText, textFromContent, isBoilerplateRecord, } from "../helpers/transcript-project.js";
43
+ // ---------------------------------------------------------------------------
44
+ // Day-range / default-dir helpers
45
+ // ---------------------------------------------------------------------------
46
+ /** Local-TZ day string ("sv" locale → YYYY-MM-DD), matching the ledger's day-bucketing convention. */
47
+ function localDay(iso) {
48
+ const d = new Date(iso);
49
+ if (isNaN(d.getTime()))
50
+ return null;
51
+ return d.toLocaleDateString("sv");
52
+ }
53
+ /** Inclusive day range [since, until], calendar-date arithmetic in UTC (no DST skips). */
54
+ function enumerateDays(since, until) {
55
+ const start = new Date(`${since}T00:00:00.000Z`).getTime();
56
+ const end = new Date(`${until}T00:00:00.000Z`).getTime();
57
+ if (isNaN(start) || isNaN(end))
58
+ return [];
59
+ const days = [];
60
+ for (let t = start; t <= end; t += 86_400_000) {
61
+ days.push(new Date(t).toISOString().slice(0, 10));
62
+ }
63
+ return days;
64
+ }
65
+ /**
66
+ * Exported for reuse (evolution p1b) — the day-range resolver is identical
67
+ * flag semantics (--date XOR --backfill --since/--until) for
68
+ * `ar corrections harvest-implicit`; TranscriptAuditOptions' date/since/until/
69
+ * project/claudeDir/dryRun shape is generic enough that implicit-harvest.ts's
70
+ * own options type is structurally compatible without a cast.
71
+ */
72
+ export function resolveDayRange(options) {
73
+ if (options.date)
74
+ return [options.date];
75
+ if (options.since) {
76
+ const until = options.until ?? new Date().toLocaleDateString("sv");
77
+ return enumerateDays(options.since, until);
78
+ }
79
+ throw new Error("runTranscriptAudit: either --date <YYYY-MM-DD> or --backfill --since <YYYY-MM-DD> is required");
80
+ }
81
+ /** Same default the CLI's readTodaySessions() (transcript-reader.ts) uses. */
82
+ export function defaultClaudeDir() {
83
+ const username = os.userInfo().username;
84
+ return path.join(os.homedir(), ".claude", "projects", `-Users-${username}`);
85
+ }
86
+ function readJsonLine(line) {
87
+ const trimmed = line.trim();
88
+ if (!trimmed)
89
+ return null;
90
+ try {
91
+ return JSON.parse(trimmed);
92
+ }
93
+ catch {
94
+ return null;
95
+ }
96
+ }
97
+ /**
98
+ * Scan every `*.jsonl` transcript in `claudeDir` exactly once. Returns the
99
+ * per-file day-bucketed lines (for content extraction) plus the basenames of
100
+ * files that could not be bounded to ANY day (no per-line timestamps AND no
101
+ * usable mtime) — these are NEVER silently assigned to a day (ESCALATION
102
+ * clause in the brief: report the ambiguity, don't guess).
103
+ */
104
+ export function scanTranscripts(claudeDir) {
105
+ let names;
106
+ try {
107
+ names = fs.readdirSync(claudeDir).filter((f) => f.endsWith(".jsonl")).sort();
108
+ }
109
+ catch {
110
+ return { files: [], ambiguous: [] };
111
+ }
112
+ const files = [];
113
+ const ambiguous = [];
114
+ for (const name of names) {
115
+ const filePath = path.join(claudeDir, name);
116
+ const basename = name.slice(0, -".jsonl".length);
117
+ let fullText;
118
+ try {
119
+ fullText = fs.readFileSync(filePath, "utf-8");
120
+ }
121
+ catch {
122
+ continue; // unreadable — skip, never guess
123
+ }
124
+ // Head/tail sample for project resolution. Sliced from the already-
125
+ // decoded string (not a raw byte buffer), so there is no UTF-8
126
+ // boundary-splitting risk the way a byte-offset window would have —
127
+ // JS string slicing operates on UTF-16 code units of already-valid text.
128
+ const headText = fullText.slice(0, 60_000);
129
+ const tailText = fullText.length > 25_000 ? fullText.slice(-25_000) : fullText;
130
+ const project = resolveSessionProject(headText, tailText).slug;
131
+ const byDay = new Map();
132
+ let sawAnyTimestamp = false;
133
+ const rawLines = [];
134
+ for (const line of fullText.split("\n")) {
135
+ const obj = readJsonLine(line);
136
+ if (obj === null)
137
+ continue;
138
+ rawLines.push(obj);
139
+ if (!obj || typeof obj !== "object")
140
+ continue;
141
+ const ts = obj.timestamp;
142
+ if (typeof ts !== "string")
143
+ continue;
144
+ const day = localDay(ts);
145
+ if (!day)
146
+ continue;
147
+ sawAnyTimestamp = true;
148
+ let arr = byDay.get(day);
149
+ if (!arr) {
150
+ arr = [];
151
+ byDay.set(day, arr);
152
+ }
153
+ arr.push(obj);
154
+ }
155
+ if (!sawAnyTimestamp) {
156
+ // Brief item 3: fall back to file mtime day ONLY when the file has no
157
+ // per-line timestamps at all — the whole file becomes one day-bucket.
158
+ let mtimeDay = null;
159
+ try {
160
+ mtimeDay = localDay(fs.statSync(filePath).mtime.toISOString());
161
+ }
162
+ catch {
163
+ mtimeDay = null;
164
+ }
165
+ if (mtimeDay) {
166
+ byDay.set(mtimeDay, rawLines);
167
+ files.push({ basename, byDay, project });
168
+ }
169
+ else {
170
+ // ESCALATION: no per-line timestamps AND mtime unusable — never guess.
171
+ ambiguous.push(basename);
172
+ }
173
+ }
174
+ else {
175
+ files.push({ basename, byDay, project });
176
+ }
177
+ }
178
+ return { files, ambiguous };
179
+ }
180
+ // ---------------------------------------------------------------------------
181
+ // Text extraction (mirrors transcript-reader.ts's SYSTEM_PREFIXES/attachment filters)
182
+ // ---------------------------------------------------------------------------
183
+ function extractDayText(lines) {
184
+ const combined = [];
185
+ const assistantOnly = [];
186
+ for (const d of lines) {
187
+ if (!d || typeof d !== "object")
188
+ continue;
189
+ const rec = d;
190
+ if (isBoilerplateRecord(rec))
191
+ continue;
192
+ if (rec.type === "user") {
193
+ if ("attachment" in rec)
194
+ continue;
195
+ const msg = rec.message;
196
+ const text = textFromContent(msg?.content);
197
+ if (!text || isSystemText(text))
198
+ continue;
199
+ combined.push(text);
200
+ }
201
+ else if (rec.type === "assistant") {
202
+ const msg = rec.message;
203
+ const content = msg?.content;
204
+ if (Array.isArray(content)) {
205
+ for (const c of content) {
206
+ const cr = c;
207
+ if (cr.type === "text" && typeof cr.text === "string" && cr.text.length > 0 && !isSystemText(cr.text)) {
208
+ combined.push(cr.text);
209
+ assistantOnly.push(cr.text);
210
+ }
211
+ }
212
+ }
213
+ else {
214
+ const text = textFromContent(content);
215
+ if (text && !isSystemText(text)) {
216
+ combined.push(text);
217
+ assistantOnly.push(text);
218
+ }
219
+ }
220
+ }
221
+ }
222
+ return { combinedText: combined.join("\n"), assistantText: assistantOnly.join("\n") };
223
+ }
224
+ /**
225
+ * Deterministic lexical ladder, strongest tier first, evaluated across ALL of
226
+ * a day's matching transcripts for one project (not per-transcript in
227
+ * isolation) — `projectFiles` must already be sorted by basename for
228
+ * byte-identical re-runs.
229
+ *
230
+ * CHALLENGE fix applied (brief's own CHALLENGE clause): the CITED tier's
231
+ * "≥2 unique ≥4-char content words" bar is degenerate for a rule whose rule
232
+ * text has FEWER than 2 such words (a 1-word rule could otherwise never be
233
+ * cited via the content-word path) — when `ruleWords.length < 2`, ALL of
234
+ * them are required instead of a fixed 2.
235
+ */
236
+ function adjudicate(record, projectFiles) {
237
+ const ruleWords = ruleContentWords(record.rule);
238
+ const idLower = record.id.toLowerCase();
239
+ // Tier (a) RECURRED — sentence with a genuine recurrence marker AND ≥1
240
+ // rule content-word co-occurring in that SAME sentence.
241
+ for (const file of projectFiles) {
242
+ const { combinedText } = extractDayText(file.byDay.get(file.day) ?? []);
243
+ for (const sentence of splitSentences(combinedText)) {
244
+ if (!RECURRENCE_MARKER.test(sentence) || EVAL_VOCAB_ANCHOR.test(sentence))
245
+ continue;
246
+ const lower = sentence.toLowerCase();
247
+ const hit = ruleWords.filter((w) => lower.includes(w));
248
+ if (hit.length > 0) {
249
+ return { verdict: "recurred", matchedWords: hit, sentence, basenameTag: file.basename };
250
+ }
251
+ }
252
+ }
253
+ // Tier (b) CITED — correction id literal anywhere, OR ≥2 (or all, if <2
254
+ // exist) unique rule content-words in ASSISTANT text.
255
+ for (const file of projectFiles) {
256
+ const { combinedText, assistantText } = extractDayText(file.byDay.get(file.day) ?? []);
257
+ if (idLower && combinedText.toLowerCase().includes(idLower)) {
258
+ return { verdict: "cited", matchedWords: [`id:${record.id}`], basenameTag: file.basename };
259
+ }
260
+ if (ruleWords.length > 0) {
261
+ const assistantLower = assistantText.toLowerCase();
262
+ const matched = ruleWords.filter((w) => assistantLower.includes(w));
263
+ const required = ruleWords.length < 2 ? ruleWords.length : 2;
264
+ if (matched.length >= required) {
265
+ return { verdict: "cited", matchedWords: matched, basenameTag: file.basename };
266
+ }
267
+ }
268
+ }
269
+ // Tier (c) IGNORED — neither. Evidence anchors to the FULL day-set of
270
+ // transcripts considered, so idempotency compares against the same set.
271
+ const basenameTag = [...projectFiles.map((f) => f.basename)].sort().join("+");
272
+ return { verdict: "ignored", matchedWords: [], basenameTag };
273
+ }
274
+ // ---------------------------------------------------------------------------
275
+ // Project enumeration
276
+ // ---------------------------------------------------------------------------
277
+ function resolveTargetProjects(projectFilter) {
278
+ const root = getRoot();
279
+ if (projectFilter) {
280
+ const slug = resolveProjectDirName(root, projectFilter);
281
+ return fs.existsSync(path.join(projectsRootDir(), slug)) ? [slug] : [];
282
+ }
283
+ let entries;
284
+ try {
285
+ entries = fs.readdirSync(projectsRootDir(), { withFileTypes: true });
286
+ }
287
+ catch {
288
+ return [];
289
+ }
290
+ return entries
291
+ .filter((e) => e.isDirectory())
292
+ .map((e) => e.name)
293
+ .filter((name) => isValidProjectSlug(name))
294
+ .sort();
295
+ }
296
+ /**
297
+ * Fix round (code review, MEDIUM): the brief's step 7 requires stamping
298
+ * `session_id` "when derivable from the transcript filename (uuid)" — the
299
+ * transcript basename IS the session uuid, so it's trivially available at
300
+ * every recordOutcome call site below. It's derivable ONLY when the verdict's
301
+ * evidence anchors to exactly ONE transcript — RECURRED/CITED always do
302
+ * (`ladder.basenameTag` is a single winning basename), but IGNORED can anchor
303
+ * to the full day-set of a project's transcripts when there is more than one
304
+ * (`basenameTag` is "+"-joined). In the multi-transcript case there is no
305
+ * single session to stamp, so session_id is omitted rather than guessed from
306
+ * an arbitrary member of the set.
307
+ */
308
+ function deriveSessionId(basenameTag) {
309
+ const basenames = basenameTag.split("+");
310
+ return basenames.length === 1 ? basenames[0] : undefined;
311
+ }
312
+ // ---------------------------------------------------------------------------
313
+ // Per-day audit
314
+ // ---------------------------------------------------------------------------
315
+ async function auditDay(day, allFiles, ambiguousBasenames, options) {
316
+ const summary = {
317
+ date: day,
318
+ projects: [],
319
+ injected: 0,
320
+ cited: 0,
321
+ ignored: 0,
322
+ recurred: 0,
323
+ dedup_skipped: 0,
324
+ transcripts_scanned: 0,
325
+ transcripts_ambiguous: [...ambiguousBasenames],
326
+ projects_without_transcripts: [],
327
+ adjudications: [],
328
+ };
329
+ const dayFiles = allFiles.filter((f) => f.byDay.has(day));
330
+ summary.transcripts_scanned = dayFiles.length;
331
+ const targetProjects = resolveTargetProjects(options.project);
332
+ for (const project of targetProjects) {
333
+ const onDate = readOutcomesOnDate(project, day);
334
+ const injectedIds = [...onDate.entries()]
335
+ .filter(([, kinds]) => kinds.has("retrieved"))
336
+ .map(([id]) => id)
337
+ .sort();
338
+ if (injectedIds.length === 0)
339
+ continue;
340
+ summary.projects.push(project);
341
+ summary.injected += injectedIds.length;
342
+ const projectFiles = dayFiles
343
+ .filter((f) => f.project === project)
344
+ .map((f) => ({ basename: f.basename, day, byDay: f.byDay }))
345
+ .sort((a, b) => a.basename.localeCompare(b.basename));
346
+ if (projectFiles.length === 0) {
347
+ summary.projects_without_transcripts.push(project);
348
+ continue;
349
+ }
350
+ const recordsById = new Map(readCorrections(project).map((r) => [r.id, r]));
351
+ const existingEvents = readOutcomeEventsByCorrection(project);
352
+ for (const correctionId of injectedIds) {
353
+ const record = recordsById.get(correctionId);
354
+ if (!record)
355
+ continue; // no on-disk correction file to adjudicate against
356
+ const ladder = adjudicate(record, projectFiles);
357
+ const evidence = `transcript-audit:${ladder.basenameTag}:${ladder.verdict}` +
358
+ (ladder.sentence ? ` — "${ladder.sentence.trim()}"` : ladder.matchedWords.length > 0
359
+ ? ` — matched [${ladder.matchedWords.join(",")}]`
360
+ : ` — no citation/recurrence across ${projectFiles.length} transcript(s)`);
361
+ const alreadyRecorded = (existingEvents.get(correctionId) ?? []).some((e) => e.kind === ladder.verdict &&
362
+ localDay(e.at) === day &&
363
+ (e.evidence ?? "").includes(ladder.basenameTag));
364
+ const entry = {
365
+ date: day,
366
+ project,
367
+ correction_id: correctionId,
368
+ rule: record.rule,
369
+ verdict: ladder.verdict,
370
+ matched_words: ladder.matchedWords,
371
+ sentence: ladder.sentence,
372
+ transcript_basenames: ladder.basenameTag.split("+"),
373
+ written: false,
374
+ };
375
+ if (alreadyRecorded) {
376
+ entry.skipped_reason = "dedup: an event of the same kind, day, and transcript-set already exists";
377
+ summary.dedup_skipped++;
378
+ }
379
+ else {
380
+ if (ladder.verdict === "recurred")
381
+ summary.recurred++;
382
+ else if (ladder.verdict === "cited")
383
+ summary.cited++;
384
+ else
385
+ summary.ignored++;
386
+ if (!options.dryRun) {
387
+ await recordOutcome({
388
+ correction_id: correctionId,
389
+ project,
390
+ kind: ladder.verdict,
391
+ at: `${day}T12:00:00.000Z`,
392
+ evidence,
393
+ session_id: deriveSessionId(ladder.basenameTag),
394
+ });
395
+ entry.written = true;
396
+ }
397
+ }
398
+ summary.adjudications.push(entry);
399
+ }
400
+ }
401
+ return summary;
402
+ }
403
+ // ---------------------------------------------------------------------------
404
+ // Public entry point
405
+ // ---------------------------------------------------------------------------
406
+ /**
407
+ * `ar outcomes audit` — see this file's header doc for the full pipeline.
408
+ * Deterministic given the same transcripts + same store (no wall-clock in
409
+ * any adjudication decision — only recordOutcome's own recorded_at stamping
410
+ * touches wall-clock, and that is forensic metadata, never read back by the
411
+ * ladder or the idempotency check).
412
+ */
413
+ export async function runTranscriptAudit(options) {
414
+ const days = resolveDayRange(options);
415
+ const claudeDir = options.claudeDir ?? defaultClaudeDir();
416
+ const { files, ambiguous } = scanTranscripts(claudeDir);
417
+ const dayResults = [];
418
+ for (const day of days) {
419
+ dayResults.push(await auditDay(day, files, ambiguous, options));
420
+ }
421
+ return {
422
+ dry_run: !!options.dryRun,
423
+ claude_dir: claudeDir,
424
+ days: dayResults,
425
+ transcripts_not_found_days: dayResults.filter((d) => d.transcripts_scanned === 0).map((d) => d.date),
426
+ };
427
+ }
428
+ //# sourceMappingURL=transcript-audit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transcript-audit.js","sourceRoot":"","sources":["../../src/tools-logic/transcript-audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,6BAA6B,EAC7B,aAAa,EACb,cAAc,GAGf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EACL,qBAAqB,EACrB,YAAY,EACZ,eAAe,EACf,mBAAmB,GACp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,CAAC;IAClE,CAAC;IAED,OAAO;QACL,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM;QACzB,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE,UAAU;QAChB,0BAA0B,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,mBAAmB,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;KACrG,CAAC;AACJ,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Shared types, interfaces, and constants for agent-recall-mcp.
3
3
  */
4
- export declare const VERSION = "3.4.50";
4
+ export declare const VERSION = "3.4.51";
5
5
  /**
6
6
  * Set the storage root directory. This is process-global state —
7
7
  * only one root is active at a time. Call before any other operations.
package/dist/types.js CHANGED
@@ -6,7 +6,7 @@ import * as os from "node:os";
6
6
  // ---------------------------------------------------------------------------
7
7
  // Constants
8
8
  // ---------------------------------------------------------------------------
9
- export const VERSION = "3.4.50";
9
+ export const VERSION = "3.4.51";
10
10
  // ---------------------------------------------------------------------------
11
11
  // Root directory (configurable at runtime for SDK usage)
12
12
  // ---------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-recall-core",
3
- "version": "3.4.50",
3
+ "version": "3.4.51",
4
4
  "description": "Core memory palace engine for AgentRecall",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",