agent-recall-core 3.4.38 → 3.4.40

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 (101) hide show
  1. package/README.md +1 -1
  2. package/dist/helpers/journal-files.d.ts +29 -1
  3. package/dist/helpers/journal-files.d.ts.map +1 -1
  4. package/dist/helpers/journal-files.js +124 -33
  5. package/dist/helpers/journal-files.js.map +1 -1
  6. package/dist/helpers/journal-sig-theme.d.ts.map +1 -1
  7. package/dist/helpers/journal-sig-theme.js +40 -4
  8. package/dist/helpers/journal-sig-theme.js.map +1 -1
  9. package/dist/host-profile.d.ts +69 -0
  10. package/dist/host-profile.d.ts.map +1 -0
  11. package/dist/host-profile.js +107 -0
  12. package/dist/host-profile.js.map +1 -0
  13. package/dist/index.d.ts +9 -2
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +16 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/storage/archive-write.d.ts.map +1 -1
  18. package/dist/storage/archive-write.js +7 -1
  19. package/dist/storage/archive-write.js.map +1 -1
  20. package/dist/storage/blind-spots-store.d.ts +9 -1
  21. package/dist/storage/blind-spots-store.d.ts.map +1 -1
  22. package/dist/storage/blind-spots-store.js +9 -2
  23. package/dist/storage/blind-spots-store.js.map +1 -1
  24. package/dist/storage/corrections.d.ts +175 -3
  25. package/dist/storage/corrections.d.ts.map +1 -1
  26. package/dist/storage/corrections.js +615 -153
  27. package/dist/storage/corrections.js.map +1 -1
  28. package/dist/storage/hygiene.d.ts +111 -0
  29. package/dist/storage/hygiene.d.ts.map +1 -0
  30. package/dist/storage/hygiene.js +422 -0
  31. package/dist/storage/hygiene.js.map +1 -0
  32. package/dist/storage/lifecycle-telemetry.d.ts +56 -0
  33. package/dist/storage/lifecycle-telemetry.d.ts.map +1 -0
  34. package/dist/storage/lifecycle-telemetry.js +134 -0
  35. package/dist/storage/lifecycle-telemetry.js.map +1 -0
  36. package/dist/storage/memory-protocol.d.ts.map +1 -1
  37. package/dist/storage/memory-protocol.js +4 -1
  38. package/dist/storage/memory-protocol.js.map +1 -1
  39. package/dist/storage/sanitize.d.ts +2 -1
  40. package/dist/storage/sanitize.d.ts.map +1 -1
  41. package/dist/storage/sanitize.js +19 -2
  42. package/dist/storage/sanitize.js.map +1 -1
  43. package/dist/storage/session.d.ts +25 -1
  44. package/dist/storage/session.d.ts.map +1 -1
  45. package/dist/storage/session.js +60 -1
  46. package/dist/storage/session.js.map +1 -1
  47. package/dist/storage/store-manifest.d.ts +31 -0
  48. package/dist/storage/store-manifest.d.ts.map +1 -0
  49. package/dist/storage/store-manifest.js +108 -0
  50. package/dist/storage/store-manifest.js.map +1 -0
  51. package/dist/tools-logic/check-action.d.ts.map +1 -1
  52. package/dist/tools-logic/check-action.js +97 -3
  53. package/dist/tools-logic/check-action.js.map +1 -1
  54. package/dist/tools-logic/check.d.ts +22 -0
  55. package/dist/tools-logic/check.d.ts.map +1 -1
  56. package/dist/tools-logic/check.js +31 -1
  57. package/dist/tools-logic/check.js.map +1 -1
  58. package/dist/tools-logic/predict-correction.d.ts +10 -0
  59. package/dist/tools-logic/predict-correction.d.ts.map +1 -1
  60. package/dist/tools-logic/predict-correction.js +6 -2
  61. package/dist/tools-logic/predict-correction.js.map +1 -1
  62. package/dist/tools-logic/recognition-builder.d.ts +9 -0
  63. package/dist/tools-logic/recognition-builder.d.ts.map +1 -1
  64. package/dist/tools-logic/recognition-builder.js +5 -3
  65. package/dist/tools-logic/recognition-builder.js.map +1 -1
  66. package/dist/tools-logic/session-end.d.ts.map +1 -1
  67. package/dist/tools-logic/session-end.js +49 -4
  68. package/dist/tools-logic/session-end.js.map +1 -1
  69. package/dist/tools-logic/session-start.d.ts.map +1 -1
  70. package/dist/tools-logic/session-start.js +64 -10
  71. package/dist/tools-logic/session-start.js.map +1 -1
  72. package/dist/tools-logic/smart-recall.d.ts +93 -1
  73. package/dist/tools-logic/smart-recall.d.ts.map +1 -1
  74. package/dist/tools-logic/smart-recall.js +199 -11
  75. package/dist/tools-logic/smart-recall.js.map +1 -1
  76. package/dist/tools-logic/smart-remember.d.ts.map +1 -1
  77. package/dist/tools-logic/smart-remember.js +12 -0
  78. package/dist/tools-logic/smart-remember.js.map +1 -1
  79. package/dist/tools-logic/store-doctor.d.ts +1 -1
  80. package/dist/tools-logic/store-doctor.d.ts.map +1 -1
  81. package/dist/tools-logic/store-doctor.js +64 -0
  82. package/dist/tools-logic/store-doctor.js.map +1 -1
  83. package/dist/types.d.ts +1 -1
  84. package/dist/types.js +1 -1
  85. package/package.json +4 -3
  86. package/dist/tools-logic/brief.d.ts +0 -84
  87. package/dist/tools-logic/brief.d.ts.map +0 -1
  88. package/dist/tools-logic/brief.js +0 -193
  89. package/dist/tools-logic/brief.js.map +0 -1
  90. package/dist/tools-logic/dashboard-export.d.ts +0 -130
  91. package/dist/tools-logic/dashboard-export.d.ts.map +0 -1
  92. package/dist/tools-logic/dashboard-export.js +0 -485
  93. package/dist/tools-logic/dashboard-export.js.map +0 -1
  94. package/dist/tools-logic/memory-query.d.ts +0 -43
  95. package/dist/tools-logic/memory-query.d.ts.map +0 -1
  96. package/dist/tools-logic/memory-query.js +0 -77
  97. package/dist/tools-logic/memory-query.js.map +0 -1
  98. package/dist/tools-logic/project-status.d.ts +0 -24
  99. package/dist/tools-logic/project-status.d.ts.map +0 -1
  100. package/dist/tools-logic/project-status.js +0 -155
  101. package/dist/tools-logic/project-status.js.map +0 -1
@@ -0,0 +1,422 @@
1
+ /**
2
+ * hygiene.ts — DETECTION-ONLY store trash audit ("ar hygiene").
3
+ *
4
+ * Sibling to store-doctor.ts, but a different axis:
5
+ * - store-doctor = STRUCTURAL integrity (index drift, stale locks, stalled
6
+ * consolidation seam, orphaned markers, ledger divergence).
7
+ * - hygiene = STORE TRASH (junk project dirs, unbounded counter files,
8
+ * recurring-theme epidemics, case-fold forks, stale derived caches,
9
+ * leaked-secret-shaped strings, missing materialized indexes, reserved-
10
+ * word slug collisions).
11
+ *
12
+ * HARD INVARIANTS (owner-approved 2026-07-27):
13
+ * 1. Scan != clean. `runHygieneScan` NEVER deletes, renames, or quarantines
14
+ * anything — findings only. No mkdir, no unlink, no rename, no write of
15
+ * any kind. Only fs reads (existsSync/readdirSync/readFileSync/statSync).
16
+ * 2. The ONLY write this module ever performs is its own baseline file
17
+ * (`hygiene-baseline.json`), and ONLY via the explicit `updateBaseline`
18
+ * call — never as a side effect of scanning or of `applyBaseline`.
19
+ * 3. Each check runs independently try/caught inside `runHygieneScan` — one
20
+ * failing check (unreadable dir, permissions, malformed file) degrades
21
+ * that check to zero findings; it never kills the whole scan.
22
+ * 4. `runHygieneScan(root)` is PURE with respect to global state: unlike
23
+ * store-doctor.ts (which reads the process-global root via getRoot()),
24
+ * every path here is built from the explicit `root` parameter. This is
25
+ * deliberate — it lets tests exercise the scanner against a temp
26
+ * directory without mutating (or restoring) any global root state.
27
+ *
28
+ * Baseline: without one, every pre-existing finding (e.g. ~985 stray counter
29
+ * files) would resurface on every run and drown out anything NEW. The first
30
+ * invocation of `ar hygiene --baseline-update` snapshots every current
31
+ * finding's `stable_id`; subsequent bare `ar hygiene` runs report only
32
+ * findings whose `stable_id` is NOT in that snapshot ("fresh"), plus a
33
+ * one-line count of how many are already known.
34
+ */
35
+ import * as fs from "node:fs";
36
+ import * as path from "node:path";
37
+ import { createHash } from "node:crypto";
38
+ import { ensureDir } from "./fs-utils.js";
39
+ import { listCaseVariantForks, PROJECTS_DIRNAME } from "./paths.js";
40
+ import { parseJournalFileName } from "../helpers/journal-name-parser.js";
41
+ // ---------------------------------------------------------------------------
42
+ // Constants
43
+ // ---------------------------------------------------------------------------
44
+ /** The baseline file lives at the store root, alongside `projects/`. */
45
+ export const HYGIENE_BASELINE_FILENAME = "hygiene-baseline.json";
46
+ export function hygieneBaselinePath(root) {
47
+ return path.join(root, HYGIENE_BASELINE_FILENAME);
48
+ }
49
+ const CHECK_NAMES = [
50
+ "junk-project-dirs",
51
+ "counter-accumulation",
52
+ "theme-epidemic",
53
+ "case-fold-forks",
54
+ "stale-derived-caches",
55
+ "root-secret-patterns",
56
+ "missing-corrections-index",
57
+ "reserved-word-slugs",
58
+ ];
59
+ // (a) junk-project-dirs
60
+ const UUID_PREFIX_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-/i;
61
+ const DOT_DOT_RE = /\.\./;
62
+ const JUNK_LITERAL_RE = /^(test-|this-project-does-not-exist|not-a-real-project)/i;
63
+ const EPOCH_SUFFIX_RE = /-\d{13}$/;
64
+ // (b) counter-accumulation
65
+ const COUNTER_PREFIX = ".ambient-counter-";
66
+ const COUNTER_YELLOW_THRESHOLD = 100;
67
+ const COUNTER_RED_THRESHOLD = 500;
68
+ // (c) theme-epidemic
69
+ const THEME_EPIDEMIC_MIN_FILES = 10;
70
+ const THEME_EPIDEMIC_SHARE = 0.5;
71
+ // (e) stale-derived-caches
72
+ const STALE_CACHE_AGE_MS = 30 * 24 * 60 * 60 * 1000;
73
+ const SECRET_PATTERNS = [
74
+ { name: "openai-sk-proj", regex: /sk-proj-/ },
75
+ { name: "openai-or-anthropic-sk", regex: /sk-[A-Za-z0-9_-]{20,}/ },
76
+ { name: "supabase-secret-key", regex: /sb_secret_/ },
77
+ { name: "supabase-service-role-key", regex: /sbp_[a-f0-9]{40}/ },
78
+ { name: "aws-access-key-id", regex: /AKIA[A-Z0-9]{16}/ },
79
+ { name: "github-pat", regex: /ghp_[A-Za-z0-9]{36}/ },
80
+ { name: "slack-token", regex: /xox[bap]-/ },
81
+ ];
82
+ // (h) reserved-word-slugs
83
+ const RESERVED_SLUGS = new Set([
84
+ "palace", "journal", "corrections", "tmp", "insights", "rooms", "skills",
85
+ ]);
86
+ // ---------------------------------------------------------------------------
87
+ // Internal helpers
88
+ // ---------------------------------------------------------------------------
89
+ function stableId(check, findingPath) {
90
+ return createHash("sha256").update(`${check}:${findingPath}`).digest("hex").slice(0, 16);
91
+ }
92
+ function mkFinding(check, severity, findingPath, evidence, agentInstruction) {
93
+ return {
94
+ check,
95
+ severity,
96
+ path: findingPath,
97
+ evidence,
98
+ stable_id: stableId(check, findingPath),
99
+ agent_instruction: agentInstruction,
100
+ };
101
+ }
102
+ function safeReaddirNames(dir) {
103
+ try {
104
+ return fs.readdirSync(dir);
105
+ }
106
+ catch {
107
+ return [];
108
+ }
109
+ }
110
+ function safeReaddirEntries(dir) {
111
+ try {
112
+ return fs.readdirSync(dir, { withFileTypes: true });
113
+ }
114
+ catch {
115
+ return [];
116
+ }
117
+ }
118
+ /** Every directory entry directly under `<root>/projects` (junk dirs included). */
119
+ function listProjectDirNames(root) {
120
+ return safeReaddirEntries(path.join(root, PROJECTS_DIRNAME))
121
+ .filter((e) => e.isDirectory())
122
+ .map((e) => e.name);
123
+ }
124
+ // ---------------------------------------------------------------------------
125
+ // Check (a) — junk-project-dirs
126
+ // ---------------------------------------------------------------------------
127
+ function checkJunkProjectDirs(projectNames) {
128
+ const out = [];
129
+ for (const name of projectNames) {
130
+ const isUuid = UUID_PREFIX_RE.test(name);
131
+ const isDotDot = DOT_DOT_RE.test(name);
132
+ const isLiteralJunk = JUNK_LITERAL_RE.test(name);
133
+ const isEpoch = EPOCH_SUFFIX_RE.test(name);
134
+ if (!isUuid && !isDotDot && !isLiteralJunk && !isEpoch)
135
+ continue;
136
+ const severity = isUuid || isDotDot ? "red" : "yellow";
137
+ const reasons = [
138
+ isUuid && "uuid-shaped name",
139
+ isDotDot && "path-traversal-shaped (contains '..')",
140
+ isLiteralJunk && "literal test/placeholder slug",
141
+ isEpoch && "epoch-timestamp-suffixed name",
142
+ ]
143
+ .filter((r) => Boolean(r))
144
+ .join(", ");
145
+ out.push(mkFinding("junk-project-dirs", severity, `${PROJECTS_DIRNAME}/${name}`, `${PROJECTS_DIRNAME}/${name}: ${reasons}`, "Likely a stray/test project directory, not real project data. Confirm with the owner before removing it — this scan never mutates the store and an agent must never auto-delete a project directory."));
146
+ }
147
+ return out;
148
+ }
149
+ // ---------------------------------------------------------------------------
150
+ // Check (b) — counter-accumulation (ONE aggregate finding, never per-file)
151
+ // ---------------------------------------------------------------------------
152
+ function checkCounterAccumulation(root) {
153
+ const n = safeReaddirNames(root).filter((f) => f.startsWith(COUNTER_PREFIX)).length;
154
+ if (n <= COUNTER_YELLOW_THRESHOLD)
155
+ return [];
156
+ const severity = n > COUNTER_RED_THRESHOLD ? "red" : "yellow";
157
+ return [
158
+ mkFinding("counter-accumulation", severity, `${COUNTER_PREFIX}*`, `${n} ${COUNTER_PREFIX}* file(s) at store root (thresholds: yellow>${COUNTER_YELLOW_THRESHOLD}, red>${COUNTER_RED_THRESHOLD})`, "These are per-session ambient-injection counters that accumulate forever with no automatic cleanup. Confirm with the owner before bulk-deleting files matching this exact prefix — never auto-delete from an agent."),
159
+ ];
160
+ }
161
+ // ---------------------------------------------------------------------------
162
+ // Check (c) — theme-epidemic
163
+ // ---------------------------------------------------------------------------
164
+ function checkThemeEpidemic(root, projectNames) {
165
+ const out = [];
166
+ for (const name of projectNames) {
167
+ const journalDirPath = path.join(root, PROJECTS_DIRNAME, name, "journal");
168
+ const files = safeReaddirNames(journalDirPath).filter((f) => f.endsWith(".md") && f !== "index.md");
169
+ if (files.length === 0)
170
+ continue;
171
+ const themeCounts = new Map();
172
+ let parseableCount = 0;
173
+ for (const f of files) {
174
+ let parsed;
175
+ try {
176
+ parsed = parseJournalFileName(f);
177
+ }
178
+ catch {
179
+ continue;
180
+ }
181
+ if (parsed.isLegacy)
182
+ continue; // only v2/current parseable names count
183
+ parseableCount++;
184
+ if (parsed.theme && parsed.theme !== "none") {
185
+ themeCounts.set(parsed.theme, (themeCounts.get(parsed.theme) ?? 0) + 1);
186
+ }
187
+ }
188
+ if (parseableCount < THEME_EPIDEMIC_MIN_FILES)
189
+ continue;
190
+ let topTheme = null;
191
+ let topCount = 0;
192
+ for (const [theme, count] of themeCounts) {
193
+ if (count > topCount) {
194
+ topTheme = theme;
195
+ topCount = count;
196
+ }
197
+ }
198
+ if (!topTheme)
199
+ continue;
200
+ const share = topCount / parseableCount;
201
+ if (share <= THEME_EPIDEMIC_SHARE)
202
+ continue;
203
+ out.push(mkFinding("theme-epidemic", "yellow", `${PROJECTS_DIRNAME}/${name}`, `theme="${topTheme}" in ${topCount}/${parseableCount} (${Math.round(share * 100)}%) of parseable journal filenames`, "One recurring theme dominates this project's journal — likely the same unresolved issue recurring across sessions. Surface it to the owner as a candidate for a durable correction/fix rather than more journal notes; never delete or merge journal files."));
204
+ }
205
+ return out;
206
+ }
207
+ // ---------------------------------------------------------------------------
208
+ // Check (d) — case-fold-forks (reuses paths.ts's listCaseVariantForks)
209
+ // ---------------------------------------------------------------------------
210
+ /**
211
+ * Pure mapping from case-variant fork groups (as returned by
212
+ * `listCaseVariantForks`) to HygieneFinding objects. Extracted for fs-free
213
+ * testability — real case-variant sibling directories cannot be fabricated on
214
+ * a case-insensitive-but-case-preserving filesystem (macOS APFS default: a
215
+ * second `mkdirSync("agentrecall")` silently collides with an existing
216
+ * "AgentRecall"). Same constraint documented on `pickProjectDirEntry` in
217
+ * paths.ts; same fix (test the pure mapping directly). Not part of the
218
+ * public core barrel — internal/test-only export.
219
+ */
220
+ export function caseFoldForksToFindings(forks) {
221
+ return forks.map((fork) => mkFinding("case-fold-forks", "red", `${PROJECTS_DIRNAME}/${fork.project}`, `${fork.variants.length} case-variant directories for one project: ${fork.variants.join(", ")} (diverges on case-sensitive filesystems)`, "These directories are the SAME project split by a case-fold mismatch. Merging requires combining journal/palace/corrections content by hand — confirm with the owner first; never auto-delete or auto-merge either directory."));
222
+ }
223
+ function checkCaseFoldForks(root) {
224
+ try {
225
+ return caseFoldForksToFindings(listCaseVariantForks(root));
226
+ }
227
+ catch {
228
+ return [];
229
+ }
230
+ }
231
+ // ---------------------------------------------------------------------------
232
+ // Check (e) — stale-derived-caches
233
+ // ---------------------------------------------------------------------------
234
+ function checkStaleDerivedCaches(root) {
235
+ const out = [];
236
+ const now = Date.now();
237
+ for (const entry of safeReaddirEntries(root)) {
238
+ if (!entry.isFile())
239
+ continue;
240
+ const name = entry.name;
241
+ if (name === HYGIENE_BASELINE_FILENAME)
242
+ continue;
243
+ const isCacheJson = /-cache\.json$/.test(name);
244
+ const isKnownDerived = name === "dashboard.json" || name === "scoreboard.json";
245
+ if (!isCacheJson && !isKnownDerived)
246
+ continue;
247
+ let mtimeMs;
248
+ try {
249
+ mtimeMs = fs.statSync(path.join(root, name)).mtimeMs;
250
+ }
251
+ catch {
252
+ continue;
253
+ }
254
+ const ageMs = now - mtimeMs;
255
+ if (ageMs <= STALE_CACHE_AGE_MS)
256
+ continue;
257
+ out.push(mkFinding("stale-derived-caches", "yellow", name, `${name} is ${Math.round(ageMs / (24 * 60 * 60 * 1000))}d old (derived cache — regeneratable from the store)`, "This is a DERIVED cache file, not source data — it is safe to delete or let its producer overwrite it. Confirm with the owner before deleting; never auto-delete from an agent without confirmation."));
258
+ }
259
+ return out;
260
+ }
261
+ // ---------------------------------------------------------------------------
262
+ // Check (f) — root-secret-patterns
263
+ // ---------------------------------------------------------------------------
264
+ function checkRootSecretPatterns(root) {
265
+ const out = [];
266
+ for (const entry of safeReaddirEntries(root)) {
267
+ if (!entry.isFile())
268
+ continue;
269
+ if (!entry.name.endsWith(".json"))
270
+ continue;
271
+ if (entry.name === HYGIENE_BASELINE_FILENAME)
272
+ continue;
273
+ let content;
274
+ try {
275
+ content = fs.readFileSync(path.join(root, entry.name), "utf-8");
276
+ }
277
+ catch {
278
+ continue;
279
+ }
280
+ const lines = content.split(/\r?\n/);
281
+ for (let i = 0; i < lines.length; i++) {
282
+ const line = lines[i];
283
+ for (const pattern of SECRET_PATTERNS) {
284
+ if (!pattern.regex.test(line))
285
+ continue;
286
+ const lineNo = i + 1;
287
+ out.push(mkFinding("root-secret-patterns", "red", `${entry.name}#L${lineNo}`,
288
+ // Evidence is file + pattern NAME + line number ONLY — NEVER the
289
+ // matched secret text itself.
290
+ `${entry.name}: pattern=${pattern.name}, line=${lineNo}`, "A credential-shaped string was found in a root-level store file. NEVER echo, log, or paste the matched value anywhere. Confirm with the owner and rotate the credential immediately, then move it out of this file (env var / secret manager)."));
291
+ break; // one finding per matching line — avoid double-reporting the
292
+ // same secret under two overlapping pattern names (e.g. sk-proj- is
293
+ // also a valid match of the generic openai-or-anthropic-sk pattern).
294
+ }
295
+ }
296
+ }
297
+ return out;
298
+ }
299
+ // ---------------------------------------------------------------------------
300
+ // Check (g) — missing-corrections-index
301
+ // ---------------------------------------------------------------------------
302
+ function checkMissingCorrectionsIndex(root, projectNames) {
303
+ const out = [];
304
+ for (const name of projectNames) {
305
+ const correctionsDirPath = path.join(root, PROJECTS_DIRNAME, name, "corrections");
306
+ const jsonCount = safeReaddirNames(correctionsDirPath).filter((f) => f.endsWith(".json") && !f.startsWith("_")).length;
307
+ if (jsonCount < 1)
308
+ continue;
309
+ if (fs.existsSync(path.join(correctionsDirPath, "_index.md")))
310
+ continue;
311
+ out.push(mkFinding("missing-corrections-index", "yellow", `${PROJECTS_DIRNAME}/${name}/corrections`, `${jsonCount} correction record(s) but no _index.md`, "Regenerate the materialized index by writing (or retracting) any correction for this project — regenerateCorrectionsIndex() runs automatically on every corrections mutation. No manual file edit is needed or advised."));
312
+ }
313
+ return out;
314
+ }
315
+ // ---------------------------------------------------------------------------
316
+ // Check (h) — reserved-word-slugs
317
+ // ---------------------------------------------------------------------------
318
+ function checkReservedWordSlugs(projectNames) {
319
+ const out = [];
320
+ for (const name of projectNames) {
321
+ if (!RESERVED_SLUGS.has(name.toLowerCase()))
322
+ continue;
323
+ out.push(mkFinding("reserved-word-slugs", "red", `${PROJECTS_DIRNAME}/${name}`, `${PROJECTS_DIRNAME}/${name} collides with a reserved internal directory name (${[...RESERVED_SLUGS].join("/")})`, "A project slug that shadows a reserved internal name can corrupt path resolution for every project. Confirm with the owner and migrate this project to a different slug — never auto-rename or auto-delete."));
324
+ }
325
+ return out;
326
+ }
327
+ // ---------------------------------------------------------------------------
328
+ // Rollup + public entry point
329
+ // ---------------------------------------------------------------------------
330
+ function rollupGrade(findings) {
331
+ let grade = "clean";
332
+ for (const f of findings) {
333
+ if (f.severity === "red")
334
+ return "red";
335
+ if (f.severity === "yellow")
336
+ grade = "yellow";
337
+ }
338
+ return grade;
339
+ }
340
+ /**
341
+ * Run every hygiene check against `root`. READ-ONLY: never writes, never
342
+ * mkdirs, never renames, never acquires a lock. Each check is independently
343
+ * try/caught — one failing check degrades to zero findings for that check,
344
+ * never throws out of the scan as a whole.
345
+ */
346
+ export function runHygieneScan(root) {
347
+ const counts = {};
348
+ for (const name of CHECK_NAMES)
349
+ counts[name] = 0;
350
+ const findings = [];
351
+ const projectNames = listProjectDirNames(root);
352
+ const runners = [
353
+ ["junk-project-dirs", () => checkJunkProjectDirs(projectNames)],
354
+ ["counter-accumulation", () => checkCounterAccumulation(root)],
355
+ ["theme-epidemic", () => checkThemeEpidemic(root, projectNames)],
356
+ ["case-fold-forks", () => checkCaseFoldForks(root)],
357
+ ["stale-derived-caches", () => checkStaleDerivedCaches(root)],
358
+ ["root-secret-patterns", () => checkRootSecretPatterns(root)],
359
+ ["missing-corrections-index", () => checkMissingCorrectionsIndex(root, projectNames)],
360
+ ["reserved-word-slugs", () => checkReservedWordSlugs(projectNames)],
361
+ ];
362
+ for (const [name, run] of runners) {
363
+ try {
364
+ const results = run();
365
+ counts[name] = results.length;
366
+ findings.push(...results);
367
+ }
368
+ catch {
369
+ // One failing check must never kill the whole scan.
370
+ counts[name] = 0;
371
+ }
372
+ }
373
+ return { findings, grade: rollupGrade(findings), counts };
374
+ }
375
+ // ---------------------------------------------------------------------------
376
+ // Baseline (separate from the pure scan — the ONLY write path in this file)
377
+ // ---------------------------------------------------------------------------
378
+ function readBaselineSafe(baselinePath) {
379
+ try {
380
+ if (!fs.existsSync(baselinePath))
381
+ return null;
382
+ const parsed = JSON.parse(fs.readFileSync(baselinePath, "utf-8"));
383
+ if (!parsed || !Array.isArray(parsed.stable_ids))
384
+ return null;
385
+ return parsed;
386
+ }
387
+ catch {
388
+ return null;
389
+ }
390
+ }
391
+ /**
392
+ * Partition `findings` into `fresh` (stable_id NOT in the baseline) and
393
+ * `known` (stable_id IS in the baseline). READ-ONLY — only reads the
394
+ * baseline file; never writes it. Missing/malformed baseline degrades to
395
+ * "everything is fresh" (the honest first-run state).
396
+ */
397
+ export function applyBaseline(findings, baselinePath) {
398
+ const baseline = readBaselineSafe(baselinePath);
399
+ const knownIds = new Set(baseline?.stable_ids ?? []);
400
+ const fresh = [];
401
+ const known = [];
402
+ for (const f of findings) {
403
+ (knownIds.has(f.stable_id) ? known : fresh).push(f);
404
+ }
405
+ return { fresh, known };
406
+ }
407
+ /**
408
+ * Snapshot every current finding's stable_id into the baseline file. This is
409
+ * the ONLY write this module ever performs, and it only happens when a
410
+ * caller explicitly invokes this function (CLI: `ar hygiene --baseline-update`).
411
+ * Atomic (tmp + rename), mode 0600.
412
+ */
413
+ export function updateBaseline(findings, baselinePath) {
414
+ const stable_ids = Array.from(new Set(findings.map((f) => f.stable_id))).sort();
415
+ const baseline = { created_at: new Date().toISOString(), stable_ids };
416
+ ensureDir(path.dirname(baselinePath));
417
+ const tmp = `${baselinePath}.tmp.${process.pid}.${Date.now()}`;
418
+ fs.writeFileSync(tmp, JSON.stringify(baseline, null, 2), { encoding: "utf-8", mode: 0o600 });
419
+ fs.renameSync(tmp, baselinePath);
420
+ return baseline;
421
+ }
422
+ //# sourceMappingURL=hygiene.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hygiene.js","sourceRoot":"","sources":["../../src/storage/hygiene.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,YAAY,C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AK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,QAA0B,EAAE,YAAoB;IAC7E,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAChF,MAAM,QAAQ,GAAoB,EAAE,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,CAAC;IACvF,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;IACtC,MAAM,GAAG,GAAG,GAAG,YAAY,QAAQ,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;IAC/D,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7F,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IACjC,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Lifecycle telemetry — zero-cloud, privacy-safe counters for the 4 memory
3
+ * lifecycle tools (session_start, session_end, remember, check).
4
+ *
5
+ * DOCTRINE (owner, 2026-07-26): the memory lifecycle must be invisible and
6
+ * AUTOMATIC. On non-hook hosts the agent itself drives it — which means
7
+ * double-calls WILL happen (an agent that calls session_start twice in one
8
+ * session, or session_end on every "save" plus at exit). Idempotency
9
+ * (storage/session.ts: claimSessionStartOnce / getCachedSessionEnd) is what
10
+ * makes over-calling SAFE; this telemetry is what PROVES the doctrine's
11
+ * acceptance test ("customer does nothing and it works") quantitatively — it
12
+ * is the foundation for measuring firing rate and duplicate-suppression rate.
13
+ *
14
+ * PRIVACY: counters + identifiers only. NEVER transcript content, summaries,
15
+ * correction text, or insight titles. `host_tier` is the raw AR_HOST env
16
+ * string (or "unknown") — a sibling worker owns the full host-profile
17
+ * classification; this module deliberately does NOT import it, to avoid
18
+ * coupling two in-flight work packages.
19
+ *
20
+ * Storage: append-only JSONL at <root>/telemetry/lifecycle.jsonl. Rotates to
21
+ * a single `.1` generation when the live file exceeds 1MB (simple, documented
22
+ * — no multi-generation history).
23
+ */
24
+ export type LifecycleEvent = "session_start" | "session_end" | "remember" | "check";
25
+ export interface LifecycleTelemetryRow {
26
+ event: LifecycleEvent;
27
+ sessionId: string;
28
+ project: string;
29
+ /** Raw AR_HOST env value, or "unknown" when unset. Never classified here. */
30
+ host_tier: string;
31
+ /** ISO timestamp of the call. */
32
+ at: string;
33
+ /** True when this call was an idempotent-suppressed duplicate. */
34
+ dup: boolean;
35
+ }
36
+ /**
37
+ * Append one lifecycle event row. Best-effort: NEVER throws into the caller —
38
+ * telemetry must never break a lifecycle tool call.
39
+ */
40
+ export declare function recordLifecycleEvent(event: LifecycleEvent, sessionId: string, project: string, dup: boolean): void;
41
+ export interface LifecycleStats {
42
+ total: number;
43
+ byEvent: Record<LifecycleEvent, number>;
44
+ dupCount: number;
45
+ /** dupCount / total, rounded to 3 decimals. 0 when total is 0. */
46
+ dupRate: number;
47
+ }
48
+ /**
49
+ * Read aggregate lifecycle stats from the LIVE telemetry file (rotated `.1`
50
+ * history is not included — it is archival, by design, per the "simple,
51
+ * documented" rotation contract). Pass `project` to scope to one project;
52
+ * omit for workspace-wide stats. Never throws — returns zeroed stats on any
53
+ * read error (missing/corrupt file).
54
+ */
55
+ export declare function lifecycleStats(project?: string): LifecycleStats;
56
+ //# sourceMappingURL=lifecycle-telemetry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle-telemetry.d.ts","sourceRoot":"","sources":["../../src/storage/lifecycle-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAOH,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG,aAAa,GAAG,UAAU,GAAG,OAAO,CAAC;AAEpF,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,cAAc,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,kEAAkE;IAClE,GAAG,EAAE,OAAO,CAAC;CACd;AAoCD;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,cAAc,EACrB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,OAAO,GACX,IAAI,CAkBN;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;CACjB;AAWD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,cAAc,CA0B/D"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Lifecycle telemetry — zero-cloud, privacy-safe counters for the 4 memory
3
+ * lifecycle tools (session_start, session_end, remember, check).
4
+ *
5
+ * DOCTRINE (owner, 2026-07-26): the memory lifecycle must be invisible and
6
+ * AUTOMATIC. On non-hook hosts the agent itself drives it — which means
7
+ * double-calls WILL happen (an agent that calls session_start twice in one
8
+ * session, or session_end on every "save" plus at exit). Idempotency
9
+ * (storage/session.ts: claimSessionStartOnce / getCachedSessionEnd) is what
10
+ * makes over-calling SAFE; this telemetry is what PROVES the doctrine's
11
+ * acceptance test ("customer does nothing and it works") quantitatively — it
12
+ * is the foundation for measuring firing rate and duplicate-suppression rate.
13
+ *
14
+ * PRIVACY: counters + identifiers only. NEVER transcript content, summaries,
15
+ * correction text, or insight titles. `host_tier` is the raw AR_HOST env
16
+ * string (or "unknown") — a sibling worker owns the full host-profile
17
+ * classification; this module deliberately does NOT import it, to avoid
18
+ * coupling two in-flight work packages.
19
+ *
20
+ * Storage: append-only JSONL at <root>/telemetry/lifecycle.jsonl. Rotates to
21
+ * a single `.1` generation when the live file exceeds 1MB (simple, documented
22
+ * — no multi-generation history).
23
+ */
24
+ import * as fs from "node:fs";
25
+ import * as path from "node:path";
26
+ import { getRoot } from "../types.js";
27
+ import { ensureDir } from "./fs-utils.js";
28
+ const ROTATE_BYTES = 1024 * 1024; // 1MB
29
+ function telemetryDir() {
30
+ return path.join(getRoot(), "telemetry");
31
+ }
32
+ function telemetryPath() {
33
+ return path.join(telemetryDir(), "lifecycle.jsonl");
34
+ }
35
+ /**
36
+ * Single-generation rotation: when the live file exceeds ROTATE_BYTES, move
37
+ * it to `.1` (dropping any prior `.1`) so the next append starts a fresh
38
+ * file. Simple and documented — no multi-generation retention. Best-effort:
39
+ * a rotation failure is swallowed by the caller's try/catch.
40
+ */
41
+ function rotateIfNeeded(p) {
42
+ let size = 0;
43
+ try {
44
+ size = fs.statSync(p).size;
45
+ }
46
+ catch {
47
+ return; // file doesn't exist yet — nothing to rotate
48
+ }
49
+ if (size <= ROTATE_BYTES)
50
+ return;
51
+ const rotated = `${p}.1`;
52
+ try {
53
+ fs.rmSync(rotated, { force: true });
54
+ }
55
+ catch {
56
+ // best-effort — if the old .1 can't be removed, renameSync below will throw
57
+ // and get swallowed by the caller
58
+ }
59
+ fs.renameSync(p, rotated);
60
+ }
61
+ /**
62
+ * Append one lifecycle event row. Best-effort: NEVER throws into the caller —
63
+ * telemetry must never break a lifecycle tool call.
64
+ */
65
+ export function recordLifecycleEvent(event, sessionId, project, dup) {
66
+ try {
67
+ const dir = telemetryDir();
68
+ ensureDir(dir);
69
+ const p = telemetryPath();
70
+ rotateIfNeeded(p);
71
+ const row = {
72
+ event,
73
+ sessionId,
74
+ project,
75
+ host_tier: process.env["AR_HOST"] ?? "unknown",
76
+ at: new Date().toISOString(),
77
+ dup,
78
+ };
79
+ fs.appendFileSync(p, JSON.stringify(row) + "\n", "utf-8");
80
+ }
81
+ catch {
82
+ // best-effort — never break the caller
83
+ }
84
+ }
85
+ function emptyStats() {
86
+ return {
87
+ total: 0,
88
+ byEvent: { session_start: 0, session_end: 0, remember: 0, check: 0 },
89
+ dupCount: 0,
90
+ dupRate: 0,
91
+ };
92
+ }
93
+ /**
94
+ * Read aggregate lifecycle stats from the LIVE telemetry file (rotated `.1`
95
+ * history is not included — it is archival, by design, per the "simple,
96
+ * documented" rotation contract). Pass `project` to scope to one project;
97
+ * omit for workspace-wide stats. Never throws — returns zeroed stats on any
98
+ * read error (missing/corrupt file).
99
+ */
100
+ export function lifecycleStats(project) {
101
+ const stats = emptyStats();
102
+ try {
103
+ const p = telemetryPath();
104
+ if (!fs.existsSync(p))
105
+ return stats;
106
+ const raw = fs.readFileSync(p, "utf-8");
107
+ for (const line of raw.split("\n")) {
108
+ const trimmed = line.trim();
109
+ if (!trimmed)
110
+ continue;
111
+ let row;
112
+ try {
113
+ row = JSON.parse(trimmed);
114
+ }
115
+ catch {
116
+ continue; // skip malformed line
117
+ }
118
+ if (project && row.project !== project)
119
+ continue;
120
+ if (!(row.event in stats.byEvent))
121
+ continue;
122
+ stats.total++;
123
+ stats.byEvent[row.event]++;
124
+ if (row.dup)
125
+ stats.dupCount++;
126
+ }
127
+ stats.dupRate = stats.total > 0 ? Number((stats.dupCount / stats.total).toFixed(3)) : 0;
128
+ return stats;
129
+ }
130
+ catch {
131
+ return emptyStats();
132
+ }
133
+ }
134
+ //# sourceMappingURL=lifecycle-telemetry.js.map
@@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O,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5B,IAAI,CAAC,OAAO;gBAAE,SAAS;YACvB,IAAI,GAA0B,CAAC;YAC/B,IAAI,CAAC;gBACH,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAA0B,CAAC;YACrD,CAAC;YAAC,MAAM,CAAC;gBACP,SAAS,CAAC,sBAAsB;YAClC,CAAC;YACD,IAAI,OAAO,IAAI,GAAG,CAAC,OAAO,KAAK,OAAO;gBAAE,SAAS;YACjD,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC;gBAAE,SAAS;YAC5C,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3B,IAAI,GAAG,CAAC,GAAG;gBAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;QAChC,CAAC;QACD,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxF,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,UAAU,EAAE,CAAC;IACtB,CAAC;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"memory-protocol.d.ts","sourceRoot":"","sources":["../../src/storage/memory-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAuEH;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAW3D"}
1
+ {"version":3,"file":"memory-protocol.d.ts","sourceRoot":"","sources":["../../src/storage/memory-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA0EH;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAW3D"}