@futdevpro/fdp-agent-memory 1.1.30 → 1.1.112

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 (81) hide show
  1. package/build/package.json +1 -1
  2. package/build/src/_cli/_commands/find-duplicates.command.js +41 -16
  3. package/build/src/_cli/_commands/scan-projects.command.js +113 -113
  4. package/build/src/_cli/_commands/scan.command.js +2 -0
  5. package/build/src/_cli/_commands/serve.command.js +110 -10
  6. package/build/src/_cli/_services/fam-client.service.js +25 -1
  7. package/build/src/_cli/register-commands.js +28 -0
  8. package/build/src/_collections/config-catalog.const.js +148 -6
  9. package/build/src/_collections/error-codes.const.js +2 -0
  10. package/build/src/_collections/fam-console.util.js +38 -260
  11. package/build/src/_collections/fam-db-models.const.js +2 -0
  12. package/build/src/_collections/fam-entry-bootstrap.util.js +20 -6
  13. package/build/src/_collections/fam-error-context.util.js +1 -0
  14. package/build/src/_collections/fam-mcp-bridge.util.js +15 -1
  15. package/build/src/_collections/fam-operation-queue.service.js +85 -0
  16. package/build/src/_collections/fam-project-discovery.util.js +148 -0
  17. package/build/src/_collections/fam-request-origin.util.js +41 -0
  18. package/build/src/_collections/fam-retry.util.js +48 -0
  19. package/build/src/_collections/fam-scan-progress-sink.service.js +26 -0
  20. package/build/src/_enums/fam-rule-scope.type-enum.js +25 -0
  21. package/build/src/_models/data-models/fam-entry.data-model.js +29 -0
  22. package/build/src/_models/data-models/fam-memory.data-model.js +5 -0
  23. package/build/src/_models/data-models/fam-rules.data-model.js +24 -0
  24. package/build/src/_models/data-models/fam-scan-job.data-model.js +73 -0
  25. package/build/src/_models/data-models/fam-scope.data-model.js +9 -0
  26. package/build/src/_modules/embedding/_services/fam-dedup-warn.control-service.js +40 -0
  27. package/build/src/_modules/embedding/_services/fam-duplicate-scan.control-service.js +74 -16
  28. package/build/src/_modules/embedding/_services/fam-embedding-bootstrap.control-service.js +50 -0
  29. package/build/src/_modules/embedding/_services/fam-embedding-pipeline.control-service.js +31 -5
  30. package/build/src/_modules/embedding/_services/fam-embedding.control-service.js +142 -9
  31. package/build/src/_modules/embedding/_services/fam-entry.data-service.js +9 -0
  32. package/build/src/_modules/embedding/_services/fam-hydration-coordinator.control-service.js +159 -0
  33. package/build/src/_modules/embedding/_services/fam-lmstudio-embedding.provider.js +41 -4
  34. package/build/src/_modules/embedding/_services/fam-vector-search.control-service.js +67 -12
  35. package/build/src/_modules/embedding/index.js +5 -1
  36. package/build/src/_modules/ingest/_collections/fam-file-routing.util.js +10 -0
  37. package/build/src/_modules/ingest/_collections/fam-frontmatter.util.js +134 -0
  38. package/build/src/_modules/ingest/_collections/fam-project-identity.util.js +30 -0
  39. package/build/src/_modules/ingest/_collections/fam-scan-progress.util.js +5 -2
  40. package/build/src/_modules/ingest/_collections/fam-scan-summary.util.js +55 -29
  41. package/build/src/_modules/ingest/_collections/fam-split-chunker.util.js +139 -0
  42. package/build/src/_modules/ingest/_models/interfaces/fam-scan-job.interface.js +2 -0
  43. package/build/src/_modules/ingest/_services/fam-chunker.control-service.js +10 -0
  44. package/build/src/_modules/ingest/_services/fam-delta-compare.util.js +68 -1
  45. package/build/src/_modules/ingest/_services/fam-ingest-run.data-service.js +1 -1
  46. package/build/src/_modules/ingest/_services/fam-ingest.control-service.js +173 -37
  47. package/build/src/_modules/ingest/_services/fam-scan-job.control-service.js +429 -0
  48. package/build/src/_modules/ingest/_services/fam-scan-job.data-service.js +34 -0
  49. package/build/src/_modules/ingest/_services/fam-scan.control-service.js +6 -4
  50. package/build/src/_modules/ingest/index.js +6 -1
  51. package/build/src/_modules/mcp/_services/fam-capability-registry.service.js +151 -8
  52. package/build/src/_modules/mcp/_services/fam-read-tool.service.js +70 -0
  53. package/build/src/_modules/mcp/_services/fam-write-tool.service.js +36 -0
  54. package/build/src/_modules/retrieval/_collections/fam-lexical-match.util.js +69 -0
  55. package/build/src/_modules/retrieval/_collections/fam-memory-activation.util.js +66 -0
  56. package/build/src/_modules/retrieval/_collections/fam-rule-injection.util.js +125 -0
  57. package/build/src/_modules/retrieval/_collections/fam-rule-propagation.util.js +95 -0
  58. package/build/src/_modules/retrieval/_collections/fam-rule-scope-context.util.js +74 -0
  59. package/build/src/_modules/retrieval/_services/fam-global-rule.control-service.js +82 -0
  60. package/build/src/_modules/retrieval/_services/fam-memory-cold-search.control-service.js +121 -0
  61. package/build/src/_modules/retrieval/_services/fam-memory-dormancy.control-service.js +99 -0
  62. package/build/src/_modules/retrieval/_services/fam-memory-reactivation.control-service.js +68 -0
  63. package/build/src/_modules/retrieval/_services/fam-retrieval-candidate.data-service.js +15 -2
  64. package/build/src/_modules/retrieval/_services/fam-retrieval.control-service.js +197 -5
  65. package/build/src/_modules/retrieval/_services/fam-rule-injection.control-service.js +102 -0
  66. package/build/src/_modules/retrieval/index.js +12 -1
  67. package/build/src/_modules/scope-reference/_collections/fam-scope-maintenance.util.js +76 -0
  68. package/build/src/_modules/scope-reference/_services/fam-scope-maintenance.control-service.js +233 -0
  69. package/build/src/_modules/scope-reference/_services/fam-scope.data-service.js +25 -0
  70. package/build/src/_routes/server/api/api.controller.js +270 -0
  71. package/build/src/_routes/server/api/fam-doctor.control-service.js +156 -0
  72. package/build/src/app.server.js +13 -10
  73. package/client-dist/{chunk-YXHWCJ5O.js → chunk-GF3FJP7E.js} +71 -71
  74. package/client-dist/chunk-NMUCMQY6.js +1 -0
  75. package/client-dist/favicon.ico +0 -0
  76. package/client-dist/index.html +3 -3
  77. package/client-dist/main-YK4YIVAQ.js +2 -0
  78. package/package.json +1 -1
  79. package/build/src/_cli/_collections/fam-project-discovery.util.js +0 -98
  80. package/client-dist/chunk-I77GXVAQ.js +0 -1
  81. package/client-dist/main-PJPEDVJT.js +0 -2
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FAM_Doctor_ControlService = void 0;
4
+ const mcp_1 = require("../../../_modules/mcp");
5
+ const scope_reference_1 = require("../../../_modules/scope-reference");
6
+ /** A 6 doctor al-check ↔ capability-eszköz mátrix (dsgn-010 §5.2; a `fam doctor` CLI-mátrixával egyező). */
7
+ const CHECK_MATRIX = [
8
+ { name: 'env', capability: 'validate_environment', fixHint: 'Hiányzó env (pl. MONGODB_URI) → `fam init` vagy állítsd be a `.env`-ben.' },
9
+ { name: 'mongodb', capability: 'test_mongodb_connection', fixHint: 'Mongo nem elérhető → indítsd a Mongo-t, ellenőrizd a portot / MONGODB_URI-t.' },
10
+ { name: 'config', capability: 'get_config_status', fixHint: 'Nincs fam_config global rekord → `fam init` vagy `fam config set …`.' },
11
+ { name: 'embedding', capability: 'test_embedding_provider', fixHint: 'OpenAI 401 → ellenőrizd OPENAI_API_KEY-t; LM Studio: indítsd a szervert + tölts be modellt.' },
12
+ { name: 'vector', capability: 'test_vector_search', fixHint: 'Vektor-pool üres/nem-hidratált → `fam write … re-embed` vagy ellenőrizd a Mongo-persist réteget.' },
13
+ { name: 'collections', capability: 'get_table_stats', fixHint: 'Hiányzó collection → indítsd a szervert egyszer (auto-create), majd `fam doctor`.' },
14
+ ];
15
+ /**
16
+ * `FAM_Doctor_ControlService` (#2 diagnosztikai végpont, user-FR 2026-06-24) — a `fam doctor` aggregátorának
17
+ * **SZERVER-OLDALI** változata (server-centric / thin-CLI, ADR-015). A 6 capability-diagnosztikát IN-PROCESS futtatja
18
+ * (`FAM_CapabilitiesTool_Service.handle`, nem HTTP-round-trip), és aggregált health-report-ot ad (+ best-effort
19
+ * scope-integritás). A `/api/doctor` ezt szolgálja ki; a CLI/kliens/UI/külső eszköz ezt hívhatja (nem 6 külön
20
+ * capability-hívást). Az `interpret` PURE (a capability szemantikus hiba-jelzéseit — `available/reachable/ok:false`,
21
+ * `missing[]` — fail-ként ismeri fel, nem csak a throw-t; a CLI csak a throw-t fogta).
22
+ */
23
+ class FAM_Doctor_ControlService {
24
+ static _instance;
25
+ static getInstance() {
26
+ if (!FAM_Doctor_ControlService._instance) {
27
+ FAM_Doctor_ControlService._instance = new FAM_Doctor_ControlService();
28
+ }
29
+ return FAM_Doctor_ControlService._instance;
30
+ }
31
+ /**
32
+ * A capability-eredmény SZEMANTIKUS hiba-jelzése (PURE, tesztelhető): a technikailag sikeres hívás is jelezhet
33
+ * hibát (`available:false` = embedding down; `reachable:false` = Mongo down; `ok:false`; `missing[]` = hiányzó env).
34
+ * A wrapper-réteget (`data`/`result`) is megnézi. `true` = egészségtelen (→ FAIL).
35
+ */
36
+ static interpretUnhealthy(result) {
37
+ const root = (result && typeof result === 'object') ? result : {};
38
+ const inner = root.data ?? root.result ?? root;
39
+ const flat = (inner && typeof inner === 'object') ? inner : root;
40
+ return flat.available === false
41
+ || flat.reachable === false
42
+ || flat.ok === false
43
+ || (Array.isArray(flat.missing) && flat.missing.length > 0);
44
+ }
45
+ /** A teljes (vagy `skip`-elt) check-szett lefuttatása + aggregált health-report. */
46
+ async runDoctor(set) {
47
+ const skip = set?.skip ?? [];
48
+ const checks = [];
49
+ for (const descriptor of CHECK_MATRIX) {
50
+ if (skip.includes(descriptor.name)) {
51
+ continue;
52
+ }
53
+ checks.push(await this.runCheck(descriptor));
54
+ }
55
+ const summary = { ok: 0, warn: 0, fail: 0 };
56
+ for (const check of checks) {
57
+ summary[check.status] += 1;
58
+ }
59
+ const health = summary.fail ? 'fail' : summary.warn ? 'warn' : 'ok';
60
+ return {
61
+ health: health,
62
+ checks: checks,
63
+ summary: summary,
64
+ scopeIntegrity: await this.scopeIntegrity(),
65
+ database: await this.databaseInfo(),
66
+ };
67
+ }
68
+ /**
69
+ * Best-effort DB-diagnosztika (user-FR 2026-06-24): a 6 fő tár elem-számai + embedding-státusza (get_table_stats)
70
+ * + a helper-collection-ök mérete + az összes aktív doc (get_storage_usage). A hiba NEM buktatja a report-ot.
71
+ */
72
+ async databaseInfo() {
73
+ try {
74
+ const statsRaw = await mcp_1.FAM_CapabilitiesTool_Service.getInstance().handle({ action: 'invoke', name: 'get_table_stats' });
75
+ const storageRaw = await mcp_1.FAM_CapabilitiesTool_Service.getInstance().handle({ action: 'invoke', name: 'get_storage_usage' });
76
+ const statsList = FAM_Doctor_ControlService.unwrapArray(statsRaw);
77
+ const storage = FAM_Doctor_ControlService.unwrapRecord(storageRaw);
78
+ const tables = (Array.isArray(statsList) ? statsList : []).map((raw) => {
79
+ const item = (raw && typeof raw === 'object') ? raw : {};
80
+ const es = (item.embeddingStatus && typeof item.embeddingStatus === 'object')
81
+ ? item.embeddingStatus : {};
82
+ return {
83
+ table: String(item.table ?? ''),
84
+ count: Number(item.count) || 0,
85
+ completed: Number(es.completed) || 0,
86
+ pending: Number(es.pending) || 0,
87
+ error: Number(es.error) || 0,
88
+ };
89
+ });
90
+ const mainCollections = /^fam_(rules|documents|codebases|knowledges|coding_patterns|memories)$/;
91
+ const collectionsRaw = storage.collections;
92
+ const helperCollections = (Array.isArray(collectionsRaw) ? collectionsRaw : [])
93
+ .map((raw) => {
94
+ const item = (raw && typeof raw === 'object') ? raw : {};
95
+ return { collection: String(item.collection ?? ''), activeDocs: Number(item.activeDocs) || 0 };
96
+ })
97
+ .filter((entry) => entry.collection && !mainCollections.test(entry.collection));
98
+ return {
99
+ tables: tables,
100
+ totalActiveDocs: typeof storage.totalActiveDocs === 'number' ? storage.totalActiveDocs : undefined,
101
+ helperCollections: helperCollections,
102
+ };
103
+ }
104
+ catch {
105
+ return undefined;
106
+ }
107
+ }
108
+ /** A capability-eredmény tömb-payloadja (a `this.ok` wrapper-réteget is megnézve). */
109
+ static unwrapArray(result) {
110
+ if (Array.isArray(result)) {
111
+ return result;
112
+ }
113
+ const root = (result && typeof result === 'object') ? result : {};
114
+ const inner = root.data ?? root.result ?? root;
115
+ return Array.isArray(inner) ? inner : [];
116
+ }
117
+ /** A capability-eredmény objektum-payloadja (a `this.ok` wrapper-réteget is megnézve). */
118
+ static unwrapRecord(result) {
119
+ const root = (result && typeof result === 'object') ? result : {};
120
+ const inner = root.data ?? root.result ?? root;
121
+ return (inner && typeof inner === 'object') ? inner : root;
122
+ }
123
+ /** Egy capability-check IN-PROCESS futtatása → `FAM_DoctorCheck` (throw → FAIL/WARN; szemantikus hiba → FAIL). */
124
+ async runCheck(descriptor) {
125
+ try {
126
+ const result = await mcp_1.FAM_CapabilitiesTool_Service.getInstance()
127
+ .handle({ action: 'invoke', name: descriptor.capability });
128
+ if (FAM_Doctor_ControlService.interpretUnhealthy(result)) {
129
+ return { name: descriptor.name, status: 'fail', detail: JSON.stringify(result).slice(0, 240), fixHint: descriptor.fixHint };
130
+ }
131
+ return { name: descriptor.name, status: 'ok' };
132
+ }
133
+ catch (error) {
134
+ const message = error?.message ?? 'ismeretlen hiba';
135
+ // A late-bind eszközök clear "pending MP-X" hibája → WARN (nem FAIL, nem néma).
136
+ const isPending = message.toLowerCase().includes('pending');
137
+ return { name: descriptor.name, status: isPending ? 'warn' : 'fail', detail: message, fixHint: descriptor.fixHint };
138
+ }
139
+ }
140
+ /** Best-effort scope-integritás-összegzés (a detect_scope_issues hibája NEM buktatja a doctor-report-ot). */
141
+ async scopeIntegrity() {
142
+ try {
143
+ const issues = await scope_reference_1.FAM_ScopeMaintenance_ControlService.getInstance().detectIssues();
144
+ return {
145
+ hasIssues: issues.hasIssues,
146
+ orphanScopes: issues.orphanProjectScopes.length,
147
+ duplicateScopes: issues.duplicateScopes.length,
148
+ repoKeyDuplicates: issues.repoKeyDuplicates.length,
149
+ };
150
+ }
151
+ catch {
152
+ return undefined;
153
+ }
154
+ }
155
+ }
156
+ exports.FAM_Doctor_ControlService = FAM_Doctor_ControlService;
@@ -53,14 +53,17 @@ class App extends nts_dynamo_1.DyNTS_App {
53
53
  nts_dynamo_1.DyNTS_global_settings.log_settings.logs_endpoint = { enabled: true };
54
54
  logs_1.DyNTS_Logs_Service.getInstance().install();
55
55
  // OOM-hibakezelés a BEDROCK `DyNTS_MemoryGuard`-ból (a base App auto-installálja a startup-ban). FAM-specifikus
56
- // hangolás: a GC-thrash a fő OOM-jel (a FAM korpusza nagy, a heap-% csak ~85%-on ütött, de GC ~0.87-en thrash-elt),
57
- // ezért a GC-fraction-küszöbök a kritikusak; a `%`-küszöböt magasra tesszük (csak genuine-danger). A critical
58
- // nyomás load-shed-eli a nehéz write-eket (scan/import) az api-controllerben, + crash-handler (uncaughtException
59
- // teljes-részletű error-entry) ON. **`exitOnSustainedCritical` ON** (nts-dynamo 1.15.74 boot-grace-szel): a FAM
60
- // boot-hidratálása (126k vektor) ELEVE GC-thrash-el (mért gc≈0.87), ezért `bootGraceMs: 120000` a ~80s hidratálás
61
- // + margó alatt a sustained-critical NEM lép ki (csak logol + load-shed); a grace UTÁN a tartós critical TISZTÁN
62
- // kilép (exit 137) a `fam serve` ps1-wrapper prediktíven újraindít (a kriptikus OOM exit-134 helyett). Az eredeti
63
- // OOM uptime 771s-nél volt jóval a grace után, tehát kezelve.
56
+ // hangolás. **LELET (2026-06-22, L6 full-workspace scan):** a GC-fraction-alapú kritikusság ÖNMAGÁBAN
57
+ // FALSE-POSITIVE a bulk-embedding alatt a guard 33–43% heap-nél (5–7 GB / 16 GB, rengeteg szabad) lőtt ki,
58
+ // mert a tömeges embedding természetes throughput-churn-je GC-fraction 100%-ra ugratja. Ez NEM OOM-precursor:
59
+ // a GC-thrash CSAK a heap-plafon közelében (~≥85%) valódi OOM-jel (akkor nem tud felszabadítani). 43% heap-en a
60
+ // V8-nak 9+ GB tartaléka van. Az `exitOnSustainedCritical` ezért egészséges szervert ölt ~100s rehidratálás
61
+ // (most 248k vektor) a scan-CLI a holt-ablakban projekteket veszít (L6: 36/49 „szerver-down"). **JAVÍTÁS:** a
62
+ // GC-fraction-küszöböt ELÉRHETETLENRE tesszük (`gcCriticalFraction: 1.01`, `gcWarningFraction: 0.95`) a guard a
63
+ // HEAP-%-ra támaszkodik (heap-warn 80 / heap-crit 90), aminek itt hatalmas tartaléka van (43% csúcs). A valódi
64
+ // heap-OOM-védelem + graceful-exit(137) MEGMARAD (csak genuine heap≥90%-nál lép ki, a kriptikus 134 helyett),
65
+ // de a scan-embedding GC-thrash-ét IGNORÁLJA. **TODO (bedrock, futás után):** a GC-kritikusságot heap-%-hez
66
+ // KÖTNI (`gcCriticalMinHeapPct`, pl. ≥75%) — akkor a GC-jel újra bekapcsolható, mert csak a plafon közelében hat.
64
67
  nts_dynamo_1.DyNTS_global_settings.memoryGuard = {
65
68
  enabled: true,
66
69
  pollIntervalMs: 3000,
@@ -68,8 +71,8 @@ class App extends nts_dynamo_1.DyNTS_App {
68
71
  heapCriticalThreshold: 90,
69
72
  recoveryMargin: 10,
70
73
  maxHistoryCount: 100,
71
- gcWarningFraction: 0.40,
72
- gcCriticalFraction: 0.60,
74
+ gcWarningFraction: 0.95,
75
+ gcCriticalFraction: 1.01,
73
76
  installCrashHandlers: true,
74
77
  exitOnSustainedCritical: true,
75
78
  sustainedCriticalPolls: 3,