@happyvertical/smrt-facts 0.49.3 → 0.49.4
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/README.md +122 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +229 -39
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +466 -45
- package/dist/smrt-knowledge.json +58 -9
- package/dist/types.d.ts +4 -0
- package/package.json +5 -5
package/dist/smrt-knowledge.json
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
"sensitiveFieldsExcluded": true,
|
|
4
4
|
"generatedAt": "1970-01-01T00:00:00.000Z",
|
|
5
5
|
"packageName": "@happyvertical/smrt-facts",
|
|
6
|
-
"packageVersion": "0.49.
|
|
6
|
+
"packageVersion": "0.49.4",
|
|
7
7
|
"sourceManifestPath": "dist/manifest.json",
|
|
8
8
|
"agentDocPath": "AGENTS.md",
|
|
9
9
|
"sourceHashes": {
|
|
10
|
-
"manifest": "
|
|
11
|
-
"packageJson": "
|
|
10
|
+
"manifest": "8314b8775e8f20cb502ba30d1b19b580bb8c6c572bea3699b7a7369dc9ab167a",
|
|
11
|
+
"packageJson": "dbc23f9a82d8e89f5c787df3b7c0cf803949376225020611a912fd7a6d8684f2",
|
|
12
12
|
"agents": "3dff097c8282b094889f06247bdab664e75e54c85c4025219c82007f57b3a1bd"
|
|
13
13
|
},
|
|
14
14
|
"exports": [
|
|
@@ -325,7 +325,7 @@
|
|
|
325
325
|
"name": "FactContentCollection",
|
|
326
326
|
"qualifiedName": "@happyvertical/smrt-facts:FactContentCollection",
|
|
327
327
|
"collection": "factcontents",
|
|
328
|
-
"tableName": "
|
|
328
|
+
"tableName": "fact_contents",
|
|
329
329
|
"packageName": "@happyvertical/smrt-facts",
|
|
330
330
|
"extends": "SmrtJunction",
|
|
331
331
|
"fields": [],
|
|
@@ -1349,7 +1349,7 @@
|
|
|
1349
1349
|
"name": "FactSourceCollection",
|
|
1350
1350
|
"qualifiedName": "@happyvertical/smrt-facts:FactSourceCollection",
|
|
1351
1351
|
"collection": "factsources",
|
|
1352
|
-
"tableName": "
|
|
1352
|
+
"tableName": "fact_sources",
|
|
1353
1353
|
"packageName": "@happyvertical/smrt-facts",
|
|
1354
1354
|
"extends": "SmrtCollection",
|
|
1355
1355
|
"fields": [],
|
|
@@ -1872,7 +1872,7 @@
|
|
|
1872
1872
|
"name": "FactSubjectCollection",
|
|
1873
1873
|
"qualifiedName": "@happyvertical/smrt-facts:FactSubjectCollection",
|
|
1874
1874
|
"collection": "factsubjects",
|
|
1875
|
-
"tableName": "
|
|
1875
|
+
"tableName": "fact_subjects",
|
|
1876
1876
|
"packageName": "@happyvertical/smrt-facts",
|
|
1877
1877
|
"extends": "SmrtCollection",
|
|
1878
1878
|
"fields": [],
|
|
@@ -2398,7 +2398,7 @@
|
|
|
2398
2398
|
"name": "FactTagCollection",
|
|
2399
2399
|
"qualifiedName": "@happyvertical/smrt-facts:FactTagCollection",
|
|
2400
2400
|
"collection": "facttags",
|
|
2401
|
-
"tableName": "
|
|
2401
|
+
"tableName": "fact_tags",
|
|
2402
2402
|
"packageName": "@happyvertical/smrt-facts",
|
|
2403
2403
|
"extends": "SmrtCollection",
|
|
2404
2404
|
"fields": [],
|
|
@@ -3133,13 +3133,14 @@
|
|
|
3133
3133
|
"name": "FactCollection",
|
|
3134
3134
|
"qualifiedName": "@happyvertical/smrt-facts:FactCollection",
|
|
3135
3135
|
"collection": "facts",
|
|
3136
|
-
"tableName": "
|
|
3136
|
+
"tableName": "facts",
|
|
3137
3137
|
"packageName": "@happyvertical/smrt-facts",
|
|
3138
3138
|
"extends": "SmrtCollection",
|
|
3139
3139
|
"fields": [],
|
|
3140
3140
|
"relationships": [],
|
|
3141
3141
|
"methods": [
|
|
3142
3142
|
"assessClaimSupport",
|
|
3143
|
+
"backfillCatalogSearch",
|
|
3143
3144
|
"branch",
|
|
3144
3145
|
"browseCatalog",
|
|
3145
3146
|
"extractArticleClaims",
|
|
@@ -3172,6 +3173,14 @@
|
|
|
3172
3173
|
],
|
|
3173
3174
|
"returns": "Promise<FactClaimSupportAssessment>"
|
|
3174
3175
|
},
|
|
3176
|
+
{
|
|
3177
|
+
"name": "backfillCatalogSearch",
|
|
3178
|
+
"async": true,
|
|
3179
|
+
"params": [
|
|
3180
|
+
"batchSize?: any"
|
|
3181
|
+
],
|
|
3182
|
+
"returns": "Promise<object>"
|
|
3183
|
+
},
|
|
3175
3184
|
{
|
|
3176
3185
|
"name": "branch",
|
|
3177
3186
|
"async": true,
|
|
@@ -3412,6 +3421,14 @@
|
|
|
3412
3421
|
"path": "/facts/browseCatalog",
|
|
3413
3422
|
"method": "POST"
|
|
3414
3423
|
},
|
|
3424
|
+
{
|
|
3425
|
+
"kind": "api",
|
|
3426
|
+
"name": "facts.backfillCatalogSearch",
|
|
3427
|
+
"operation": "backfillCatalogSearch",
|
|
3428
|
+
"objectName": "@happyvertical/smrt-facts:FactCollection",
|
|
3429
|
+
"path": "/facts/backfillCatalogSearch",
|
|
3430
|
+
"method": "POST"
|
|
3431
|
+
},
|
|
3415
3432
|
{
|
|
3416
3433
|
"kind": "api",
|
|
3417
3434
|
"name": "facts.getForContent",
|
|
@@ -3560,6 +3577,12 @@
|
|
|
3560
3577
|
"operation": "browseCatalog",
|
|
3561
3578
|
"objectName": "@happyvertical/smrt-facts:FactCollection"
|
|
3562
3579
|
},
|
|
3580
|
+
{
|
|
3581
|
+
"kind": "cli",
|
|
3582
|
+
"name": "factcollection_backfillCatalogSearch",
|
|
3583
|
+
"operation": "backfillCatalogSearch",
|
|
3584
|
+
"objectName": "@happyvertical/smrt-facts:FactCollection"
|
|
3585
|
+
},
|
|
3563
3586
|
{
|
|
3564
3587
|
"kind": "cli",
|
|
3565
3588
|
"name": "factcollection_getForContent",
|
|
@@ -3686,6 +3709,12 @@
|
|
|
3686
3709
|
"operation": "browseCatalog",
|
|
3687
3710
|
"objectName": "@happyvertical/smrt-facts:FactCollection"
|
|
3688
3711
|
},
|
|
3712
|
+
{
|
|
3713
|
+
"kind": "mcp",
|
|
3714
|
+
"name": "factcollection_backfillcatalogsearch",
|
|
3715
|
+
"operation": "backfillCatalogSearch",
|
|
3716
|
+
"objectName": "@happyvertical/smrt-facts:FactCollection"
|
|
3717
|
+
},
|
|
3689
3718
|
{
|
|
3690
3719
|
"kind": "mcp",
|
|
3691
3720
|
"name": "factcollection_getforcontent",
|
|
@@ -5319,6 +5348,14 @@
|
|
|
5319
5348
|
"path": "/facts/browseCatalog",
|
|
5320
5349
|
"method": "POST"
|
|
5321
5350
|
},
|
|
5351
|
+
{
|
|
5352
|
+
"kind": "api",
|
|
5353
|
+
"name": "facts.backfillCatalogSearch",
|
|
5354
|
+
"operation": "backfillCatalogSearch",
|
|
5355
|
+
"objectName": "@happyvertical/smrt-facts:FactCollection",
|
|
5356
|
+
"path": "/facts/backfillCatalogSearch",
|
|
5357
|
+
"method": "POST"
|
|
5358
|
+
},
|
|
5322
5359
|
{
|
|
5323
5360
|
"kind": "api",
|
|
5324
5361
|
"name": "facts.getForContent",
|
|
@@ -5467,6 +5504,12 @@
|
|
|
5467
5504
|
"operation": "browseCatalog",
|
|
5468
5505
|
"objectName": "@happyvertical/smrt-facts:FactCollection"
|
|
5469
5506
|
},
|
|
5507
|
+
{
|
|
5508
|
+
"kind": "cli",
|
|
5509
|
+
"name": "factcollection_backfillCatalogSearch",
|
|
5510
|
+
"operation": "backfillCatalogSearch",
|
|
5511
|
+
"objectName": "@happyvertical/smrt-facts:FactCollection"
|
|
5512
|
+
},
|
|
5470
5513
|
{
|
|
5471
5514
|
"kind": "cli",
|
|
5472
5515
|
"name": "factcollection_getForContent",
|
|
@@ -5593,6 +5636,12 @@
|
|
|
5593
5636
|
"operation": "browseCatalog",
|
|
5594
5637
|
"objectName": "@happyvertical/smrt-facts:FactCollection"
|
|
5595
5638
|
},
|
|
5639
|
+
{
|
|
5640
|
+
"kind": "mcp",
|
|
5641
|
+
"name": "factcollection_backfillcatalogsearch",
|
|
5642
|
+
"operation": "backfillCatalogSearch",
|
|
5643
|
+
"objectName": "@happyvertical/smrt-facts:FactCollection"
|
|
5644
|
+
},
|
|
5596
5645
|
{
|
|
5597
5646
|
"kind": "mcp",
|
|
5598
5647
|
"name": "factcollection_getforcontent",
|
|
@@ -5671,7 +5720,7 @@
|
|
|
5671
5720
|
"junctionCollections": 1,
|
|
5672
5721
|
"hierarchicalObjects": 0,
|
|
5673
5722
|
"polymorphicAssociations": 0,
|
|
5674
|
-
"uuidColumns":
|
|
5723
|
+
"uuidColumns": 38
|
|
5675
5724
|
},
|
|
5676
5725
|
"agentDoc": "# @happyvertical/smrt-facts\n\nDistributed knowledge base with semantic deduplication, provenance tracking, and evolution chains.\n\n## Models\n\n- **Fact**: atomic knowledge unit with `textRefined`, auto-generated embeddings, status (active/pending/superseded), confidence score. Evolution via `previousFactId` (predecessor→successor with corrections/contradictions/refinements). NOT a structural hierarchy — Fact deliberately does not extend `SmrtHierarchical`; `parentId` is reserved for true structural parents elsewhere in the framework.\n- **FactSource**: provenance — URL, type, `credibility` (0-1), extraction timestamp.\n- **FactSubject**: polymorphic entity linking — `entityType` + `entityId` (no FK, string-based). `conflictColumns: ['fact_id', 'entity_type', 'entity_id']`.\n- **FactContent**: join table linking facts to Content. `conflictColumns: ['fact_id', 'content_id', 'relationship']`.\n\n## Semantic Reconciliation\n\n`reconcile()` uses three zones:\n- **≥0.85 similarity**: auto-merge (same fact, update metadata)\n- **0.60–0.85**: AI disambiguation — asks model to decide create/merge/branch\n- **<0.60**: new fact (no match)\n\n## Evolution Chains\n\n`getEvolutionChain()` (root→current), `getLatestInChain()` (highest confidence leaf), `getEvolutionTree()` (BFS all descendants). All traversals use `visited` Set for cycle detection.\n\n## Confidence Scoring\n\n`recalculateConfidence()`: weighted formula from `sourceCount`, `avgSourceCredibility`, `daysSinceLastSource`, `corroborationScore`.\n\n## Gotchas\n\n- **Embedding failures non-fatal**: try/catch with silent fail — doesn't block fact creation\n- **Metadata auto-stringify**: constructor `JSON.stringify`s objects; getters return parsed objects\n- **AI disambiguation fallback**: if AI fails, defaults to branch (safer than merge)\n- **Embeddings config**: `fields: ['textRefined'], autoGenerate: true, combinedField: {...}`\n- **Optional tenancy** with nullable tenantId. `findWithGlobals(tenantId)` for tenant + global facts\n- **Confidence/credibility must initialize `0.0`, never `0`**: they are rates, not money — inherently fractional. An integer literal compiles to an INTEGER column and a `[0, 1]` score becomes unstorable, so PostgreSQL raises `22P02` while SQLite silently accepts it. `FactEvidence.confidence` carried that bug until #2361; `pnpm --filter @happyvertical/smrt-facts test:postgres` is the lane that holds the line. (Money elsewhere in the framework goes the other way — integer minor units.)\n"
|
|
5677
5726
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export declare type EvolutionType = 'original' | 'correction' | 'refinement' | '
|
|
|
22
22
|
declare class Fact extends SmrtObject {
|
|
23
23
|
textRefined: string;
|
|
24
24
|
textRaw: string;
|
|
25
|
+
/** Derived search storage. NULL requires the explicit catalog backfill. */
|
|
26
|
+
catalogSearch: string | null;
|
|
25
27
|
type: string;
|
|
26
28
|
status: string;
|
|
27
29
|
domain: string;
|
|
@@ -42,6 +44,8 @@ declare class Fact extends SmrtObject {
|
|
|
42
44
|
createdAt: Date;
|
|
43
45
|
updatedAt: Date;
|
|
44
46
|
constructor(options?: FactOptions);
|
|
47
|
+
protected getPersistenceDerivedColumns(): readonly string[];
|
|
48
|
+
protected normalizePersistenceData(data: Readonly<Record<string, unknown>>): Record<string, unknown>;
|
|
45
49
|
getMetadata(): FactMetadata;
|
|
46
50
|
setMetadata(data: FactMetadata): void;
|
|
47
51
|
updateMetadata(updates: Partial<FactMetadata>): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-facts",
|
|
3
|
-
"version": "0.49.
|
|
3
|
+
"version": "0.49.4",
|
|
4
4
|
"description": "Distributed memory and knowledge management with provenance tracking for SMRT framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"@happyvertical/ai": "^0.89.6",
|
|
23
23
|
"@happyvertical/files": "^0.89.6",
|
|
24
24
|
"@happyvertical/logger": "^0.89.6",
|
|
25
|
-
"@happyvertical/smrt-core": "0.49.
|
|
26
|
-
"@happyvertical/smrt-prompts": "0.49.
|
|
27
|
-
"@happyvertical/smrt-tenancy": "0.49.
|
|
25
|
+
"@happyvertical/smrt-core": "0.49.4",
|
|
26
|
+
"@happyvertical/smrt-prompts": "0.49.4",
|
|
27
|
+
"@happyvertical/smrt-tenancy": "0.49.4",
|
|
28
28
|
"@happyvertical/sql": "^0.89.6",
|
|
29
29
|
"@happyvertical/utils": "^0.89.6"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@happyvertical/smrt-vitest": "0.49.
|
|
32
|
+
"@happyvertical/smrt-vitest": "0.49.4",
|
|
33
33
|
"@types/node": "24.13.2",
|
|
34
34
|
"typescript": "5.9.3",
|
|
35
35
|
"vite": "8.1.4",
|