@aibuildinfra/proofgraph 1.0.0
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/LICENSE +21 -0
- package/PRIVACY.md +8 -0
- package/README.md +193 -0
- package/SECURITY.md +27 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.js +273 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/dashboard/server.d.ts +5 -0
- package/dist/dashboard/server.js +271 -0
- package/dist/dashboard/server.js.map +1 -0
- package/dist/data/seed.d.ts +6 -0
- package/dist/data/seed.js +325 -0
- package/dist/data/seed.js.map +1 -0
- package/dist/engine/aiDiscoverability.d.ts +11 -0
- package/dist/engine/aiDiscoverability.js +135 -0
- package/dist/engine/aiDiscoverability.js.map +1 -0
- package/dist/engine/claimVerifier.d.ts +26 -0
- package/dist/engine/claimVerifier.js +130 -0
- package/dist/engine/claimVerifier.js.map +1 -0
- package/dist/engine/consistencyAudit.d.ts +11 -0
- package/dist/engine/consistencyAudit.js +172 -0
- package/dist/engine/consistencyAudit.js.map +1 -0
- package/dist/engine/exporter.d.ts +17 -0
- package/dist/engine/exporter.js +83 -0
- package/dist/engine/exporter.js.map +1 -0
- package/dist/engine/graphTraversal.d.ts +25 -0
- package/dist/engine/graphTraversal.js +74 -0
- package/dist/engine/graphTraversal.js.map +1 -0
- package/dist/engine/resolver.d.ts +20 -0
- package/dist/engine/resolver.js +168 -0
- package/dist/engine/resolver.js.map +1 -0
- package/dist/engine/schemaOrg.d.ts +12 -0
- package/dist/engine/schemaOrg.js +105 -0
- package/dist/engine/schemaOrg.js.map +1 -0
- package/dist/engine/tokenOptimizer.d.ts +25 -0
- package/dist/engine/tokenOptimizer.js +166 -0
- package/dist/engine/tokenOptimizer.js.map +1 -0
- package/dist/engine/webPresence.d.ts +32 -0
- package/dist/engine/webPresence.js +63 -0
- package/dist/engine/webPresence.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/prompts.d.ts +25 -0
- package/dist/mcp/prompts.js +136 -0
- package/dist/mcp/prompts.js.map +1 -0
- package/dist/mcp/resources.d.ts +27 -0
- package/dist/mcp/resources.js +118 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/server.d.ts +15 -0
- package/dist/mcp/server.js +88 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +256 -0
- package/dist/mcp/tools.js +391 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/security/robots.d.ts +15 -0
- package/dist/security/robots.js +78 -0
- package/dist/security/robots.js.map +1 -0
- package/dist/security/safeFetch.d.ts +23 -0
- package/dist/security/safeFetch.js +122 -0
- package/dist/security/safeFetch.js.map +1 -0
- package/dist/storage/graphStore.d.ts +70 -0
- package/dist/storage/graphStore.js +275 -0
- package/dist/storage/graphStore.js.map +1 -0
- package/dist/storage/sqliteAdapter.d.ts +14 -0
- package/dist/storage/sqliteAdapter.js +137 -0
- package/dist/storage/sqliteAdapter.js.map +1 -0
- package/dist/tests/proofgraph.test.d.ts +5 -0
- package/dist/tests/proofgraph.test.js +249 -0
- package/dist/tests/proofgraph.test.js.map +1 -0
- package/dist/types/index.d.ts +206 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +65 -0
- package/server.json +24 -0
- package/smithery.yaml +6 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProofGraph SQLite Storage Adapter
|
|
3
|
+
* Provides persistent SQLite storage using node:sqlite DatabaseSync
|
|
4
|
+
*/
|
|
5
|
+
export class SQLiteAdapter {
|
|
6
|
+
dbPath;
|
|
7
|
+
db = null;
|
|
8
|
+
constructor(dbPath = ':memory:') {
|
|
9
|
+
this.dbPath = dbPath;
|
|
10
|
+
}
|
|
11
|
+
async init() {
|
|
12
|
+
try {
|
|
13
|
+
// Dynamic import to support Node 22 node:sqlite
|
|
14
|
+
const { DatabaseSync } = await import('node:sqlite');
|
|
15
|
+
this.db = new DatabaseSync(this.dbPath);
|
|
16
|
+
this.createSchema();
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
// If node:sqlite is unavailable, fallback silently (in-memory GraphStore handles data)
|
|
20
|
+
console.warn('[ProofGraph] SQLite initialization note: In-memory mode active');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
createSchema() {
|
|
24
|
+
if (!this.db)
|
|
25
|
+
return;
|
|
26
|
+
this.db.exec(`
|
|
27
|
+
CREATE TABLE IF NOT EXISTS entities (
|
|
28
|
+
id TEXT PRIMARY KEY,
|
|
29
|
+
name TEXT NOT NULL,
|
|
30
|
+
type TEXT NOT NULL,
|
|
31
|
+
description TEXT,
|
|
32
|
+
canonical_url TEXT,
|
|
33
|
+
aliases TEXT,
|
|
34
|
+
metadata TEXT,
|
|
35
|
+
created_at TEXT,
|
|
36
|
+
updated_at TEXT
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
CREATE TABLE IF NOT EXISTS sources (
|
|
40
|
+
id TEXT PRIMARY KEY,
|
|
41
|
+
source_type TEXT NOT NULL,
|
|
42
|
+
url TEXT NOT NULL,
|
|
43
|
+
domain TEXT NOT NULL,
|
|
44
|
+
title TEXT NOT NULL,
|
|
45
|
+
publisher TEXT NOT NULL,
|
|
46
|
+
trust_class TEXT NOT NULL,
|
|
47
|
+
reliability_score REAL NOT NULL,
|
|
48
|
+
published_at TEXT,
|
|
49
|
+
retrieved_at TEXT NOT NULL,
|
|
50
|
+
content_hash TEXT NOT NULL,
|
|
51
|
+
etag TEXT,
|
|
52
|
+
last_verified TEXT NOT NULL,
|
|
53
|
+
freshness TEXT NOT NULL,
|
|
54
|
+
metadata TEXT
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
CREATE TABLE IF NOT EXISTS claims (
|
|
58
|
+
id TEXT PRIMARY KEY,
|
|
59
|
+
subject_id TEXT NOT NULL,
|
|
60
|
+
predicate TEXT NOT NULL,
|
|
61
|
+
object_id TEXT,
|
|
62
|
+
object_value TEXT,
|
|
63
|
+
statement TEXT NOT NULL,
|
|
64
|
+
status TEXT NOT NULL,
|
|
65
|
+
confidence REAL NOT NULL,
|
|
66
|
+
evidence_ids TEXT,
|
|
67
|
+
created_at TEXT,
|
|
68
|
+
updated_at TEXT
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
CREATE TABLE IF NOT EXISTS evidence (
|
|
72
|
+
id TEXT PRIMARY KEY,
|
|
73
|
+
claim_id TEXT,
|
|
74
|
+
source_id TEXT NOT NULL,
|
|
75
|
+
source_type TEXT NOT NULL,
|
|
76
|
+
url TEXT NOT NULL,
|
|
77
|
+
title TEXT NOT NULL,
|
|
78
|
+
publisher TEXT NOT NULL,
|
|
79
|
+
retrieved_at TEXT NOT NULL,
|
|
80
|
+
published_at TEXT,
|
|
81
|
+
content_hash TEXT NOT NULL,
|
|
82
|
+
excerpt TEXT NOT NULL,
|
|
83
|
+
supports_claim INTEGER NOT NULL,
|
|
84
|
+
confidence REAL NOT NULL,
|
|
85
|
+
directness REAL NOT NULL,
|
|
86
|
+
corroborating_sources TEXT
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
CREATE TABLE IF NOT EXISTS relationships (
|
|
90
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
91
|
+
source_id TEXT NOT NULL,
|
|
92
|
+
target_id TEXT NOT NULL,
|
|
93
|
+
relationship TEXT NOT NULL,
|
|
94
|
+
confidence REAL NOT NULL,
|
|
95
|
+
evidence_ids TEXT,
|
|
96
|
+
metadata TEXT,
|
|
97
|
+
created_at TEXT
|
|
98
|
+
);
|
|
99
|
+
`);
|
|
100
|
+
}
|
|
101
|
+
saveGraph(store) {
|
|
102
|
+
if (!this.db)
|
|
103
|
+
return;
|
|
104
|
+
const data = store.toJSON();
|
|
105
|
+
const insertEntity = this.db.prepare(`
|
|
106
|
+
INSERT OR REPLACE INTO entities (id, name, type, description, canonical_url, aliases, metadata, created_at, updated_at)
|
|
107
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
108
|
+
`);
|
|
109
|
+
for (const e of data.entities) {
|
|
110
|
+
insertEntity.run(e.id, e.name, e.type, e.description, e.canonical_url || null, JSON.stringify(e.aliases), JSON.stringify(e.metadata), e.created_at, e.updated_at);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
loadGraph(store) {
|
|
114
|
+
if (!this.db)
|
|
115
|
+
return;
|
|
116
|
+
try {
|
|
117
|
+
const entities = this.db.prepare(`SELECT * FROM entities`).all();
|
|
118
|
+
for (const row of entities) {
|
|
119
|
+
store.addEntity({
|
|
120
|
+
id: row.id,
|
|
121
|
+
name: row.name,
|
|
122
|
+
type: row.type,
|
|
123
|
+
description: row.description,
|
|
124
|
+
canonical_url: row.canonical_url,
|
|
125
|
+
aliases: JSON.parse(row.aliases || '[]'),
|
|
126
|
+
metadata: JSON.parse(row.metadata || '{}'),
|
|
127
|
+
created_at: row.created_at,
|
|
128
|
+
updated_at: row.updated_at,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
// Ignore query errors if empty
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=sqliteAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqliteAdapter.js","sourceRoot":"","sources":["../../src/storage/sqliteAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,OAAO,aAAa;IAGJ;IAFZ,EAAE,GAAQ,IAAI,CAAC;IAEvB,YAAoB,SAAiB,UAAU;QAA3B,WAAM,GAAN,MAAM,CAAqB;IAAG,CAAC;IAE5C,KAAK,CAAC,IAAI;QACf,IAAI,CAAC;YACH,gDAAgD;YAChD,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;YACrD,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B,CAAC,CAAC,GAAG,EAAE,CAAC;YACjE,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;gBAC3B,KAAK,CAAC,SAAS,CAAC;oBACd,EAAE,EAAE,GAAG,CAAC,EAAE;oBACV,IAAI,EAAE,GAAG,CAAC,IAAI;oBACd,IAAI,EAAE,GAAG,CAAC,IAAI;oBACd,WAAW,EAAE,GAAG,CAAC,WAAW;oBAC5B,aAAa,EAAE,GAAG,CAAC,aAAa;oBAChC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC;oBACxC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,IAAI,IAAI,CAAC;oBAC1C,UAAU,EAAE,GAAG,CAAC,UAAU;oBAC1B,UAAU,EAAE,GAAG,CAAC,UAAU;iBAC3B,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,+BAA+B;QACjC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProofGraph Comprehensive Test Suite
|
|
3
|
+
* Validates Entity Resolution, Claim Verification, Token Budget, Traversal, SSRF & MCP Tools
|
|
4
|
+
*/
|
|
5
|
+
import { describe, it, before } from 'node:test';
|
|
6
|
+
import assert from 'node:assert/strict';
|
|
7
|
+
import { GraphStore, makeCanonicalId } from '../storage/graphStore.js';
|
|
8
|
+
import { seedStandardGraph } from '../data/seed.js';
|
|
9
|
+
import { EntityResolver, jaroWinklerSimilarity } from '../engine/resolver.js';
|
|
10
|
+
import { ClaimVerifier } from '../engine/claimVerifier.js';
|
|
11
|
+
import { TokenOptimizer } from '../engine/tokenOptimizer.js';
|
|
12
|
+
import { GraphTraversalEngine } from '../engine/graphTraversal.js';
|
|
13
|
+
import { isPrivateOrForbiddenHost, validateSafeUrl } from '../security/safeFetch.js';
|
|
14
|
+
import { RobotsParser } from '../security/robots.js';
|
|
15
|
+
import { ToolHandler } from '../mcp/tools.js';
|
|
16
|
+
describe('ProofGraph Core Test Suite', () => {
|
|
17
|
+
let store;
|
|
18
|
+
let resolver;
|
|
19
|
+
let verifier;
|
|
20
|
+
let traversal;
|
|
21
|
+
let toolHandler;
|
|
22
|
+
before(() => {
|
|
23
|
+
store = new GraphStore();
|
|
24
|
+
seedStandardGraph(store);
|
|
25
|
+
resolver = new EntityResolver(store);
|
|
26
|
+
verifier = new ClaimVerifier(store);
|
|
27
|
+
traversal = new GraphTraversalEngine(store);
|
|
28
|
+
toolHandler = new ToolHandler(store);
|
|
29
|
+
});
|
|
30
|
+
describe('1. Canonical Entity Identifiers & Store', () => {
|
|
31
|
+
it('should generate standardized lowercase canonical IDs', () => {
|
|
32
|
+
const id1 = makeCanonicalId('Organization', 'AI Build Infra');
|
|
33
|
+
const id2 = makeCanonicalId('project', 'ProofGraph_MCP');
|
|
34
|
+
assert.equal(id1, 'entity:organization:ai-build-infra');
|
|
35
|
+
assert.equal(id2, 'entity:project:proofgraph-mcp');
|
|
36
|
+
});
|
|
37
|
+
it('should retrieve seeded entities by canonical ID', () => {
|
|
38
|
+
const entity = store.getEntity('entity:organization:ai-build-infra');
|
|
39
|
+
assert.ok(entity);
|
|
40
|
+
assert.equal(entity.name, 'AI Build Infra');
|
|
41
|
+
assert.equal(entity.type, 'Organization');
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
describe('2. Multi-Signal Entity Resolution', () => {
|
|
45
|
+
it('should calculate string similarity correctly', () => {
|
|
46
|
+
assert.equal(jaroWinklerSimilarity('AI Build Infra', 'AI Build Infra'), 1.0);
|
|
47
|
+
assert.ok(jaroWinklerSimilarity('AI Build Infra', 'AI BuildInfra') > 0.90);
|
|
48
|
+
});
|
|
49
|
+
it('should resolve name variations and aliases without false merges', () => {
|
|
50
|
+
const candidates = resolver.resolve({ name: 'aibuildinfra' });
|
|
51
|
+
assert.ok(candidates.length > 0);
|
|
52
|
+
assert.equal(candidates[0].entity.id, 'entity:organization:ai-build-infra');
|
|
53
|
+
assert.ok(candidates[0].match_score >= 0.85);
|
|
54
|
+
});
|
|
55
|
+
it('should incorporate domain and github signals into match score', () => {
|
|
56
|
+
const candidates = resolver.resolve({
|
|
57
|
+
name: 'AI Build',
|
|
58
|
+
domain: 'aibuildinfra.com',
|
|
59
|
+
github: 'AI-BuildInfra',
|
|
60
|
+
});
|
|
61
|
+
assert.ok(candidates.length > 0);
|
|
62
|
+
assert.equal(candidates[0].entity.id, 'entity:organization:ai-build-infra');
|
|
63
|
+
assert.equal(candidates[0].signals.domain, 1.0);
|
|
64
|
+
assert.equal(candidates[0].signals.github, 1.0);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
describe('3. Claim Verification & Contradiction Detection', () => {
|
|
68
|
+
it('should verify supported claims with grounded confidence', () => {
|
|
69
|
+
const result = verifier.verify('AI Build Infra develops MCP servers');
|
|
70
|
+
assert.equal(result.status, 'supported');
|
|
71
|
+
assert.ok(result.confidence >= 0.90);
|
|
72
|
+
assert.ok(result.supporting_evidence.length >= 2);
|
|
73
|
+
});
|
|
74
|
+
it('should return unverified for claims without proof in graph', () => {
|
|
75
|
+
const result = verifier.verify('AI Build Infra manufactures quantum computing chips');
|
|
76
|
+
assert.equal(result.status, 'unverified');
|
|
77
|
+
assert.equal(result.confidence, 0.0);
|
|
78
|
+
});
|
|
79
|
+
it('should detect conflicting claims when contradictory evidence exists', () => {
|
|
80
|
+
// Add artificial contradicting evidence to test contradiction detection
|
|
81
|
+
store.addEvidence({
|
|
82
|
+
id: 'ev:test-contradiction',
|
|
83
|
+
claim_id: 'claim:test-conflict',
|
|
84
|
+
source_id: 'source:website:aibuildinfra-about',
|
|
85
|
+
source_type: 'community_source',
|
|
86
|
+
url: 'https://unverified-blog.example/post',
|
|
87
|
+
title: 'Blog Post',
|
|
88
|
+
publisher: 'Anonymous',
|
|
89
|
+
retrieved_at: '2026-09-25T00:00:00Z',
|
|
90
|
+
content_hash: 'abc123hash',
|
|
91
|
+
excerpt: 'AI Build Infra is strictly a real-estate holding firm and does not do software.',
|
|
92
|
+
supports_claim: false,
|
|
93
|
+
confidence: 0.8,
|
|
94
|
+
directness: 0.9,
|
|
95
|
+
});
|
|
96
|
+
store.addClaim({
|
|
97
|
+
id: 'claim:test-conflict',
|
|
98
|
+
subject_id: 'entity:organization:ai-build-infra',
|
|
99
|
+
predicate: 'DOES',
|
|
100
|
+
statement: 'AI Build Infra is strictly a real-estate holding firm',
|
|
101
|
+
status: 'contradicted',
|
|
102
|
+
confidence: 0.8,
|
|
103
|
+
evidence_ids: ['ev:test-contradiction', 'ev:official-services-page'],
|
|
104
|
+
});
|
|
105
|
+
const comparison = verifier.compareClaims([
|
|
106
|
+
'AI Build Infra develops MCP servers',
|
|
107
|
+
'AI Build Infra is strictly a real-estate holding firm',
|
|
108
|
+
]);
|
|
109
|
+
assert.equal(comparison.comparisons.length, 2);
|
|
110
|
+
assert.ok(comparison.discrepancies.length > 0);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
describe('4. Token Optimization & Evidence Compression', () => {
|
|
114
|
+
it('should enforce token budget and pack compact evidence packets', () => {
|
|
115
|
+
const entities = [store.getEntity('entity:organization:ai-build-infra')];
|
|
116
|
+
const claims = store.getClaimsForEntity('entity:organization:ai-build-infra');
|
|
117
|
+
const allEvidence = store.getAllEvidence();
|
|
118
|
+
const sourcesMap = new Map(store.getAllSources().map(s => [s.id, s]));
|
|
119
|
+
const packet = TokenOptimizer.buildPacket({
|
|
120
|
+
question: 'What is AI Build Infra and what does it build?',
|
|
121
|
+
entities,
|
|
122
|
+
claims,
|
|
123
|
+
evidence: allEvidence,
|
|
124
|
+
sources: sourcesMap,
|
|
125
|
+
maxTokens: 1500,
|
|
126
|
+
});
|
|
127
|
+
assert.ok(packet.metrics.returned_tokens <= 1500);
|
|
128
|
+
assert.ok(packet.evidence.length > 0);
|
|
129
|
+
assert.ok(packet.provenance.length > 0);
|
|
130
|
+
assert.ok(packet.metrics.compression_ratio < 1.0);
|
|
131
|
+
});
|
|
132
|
+
it('should deduplicate redundant evidence excerpts into primary + corroboration', () => {
|
|
133
|
+
const duplicateEvidence = [
|
|
134
|
+
{
|
|
135
|
+
id: 'ev:dup-1',
|
|
136
|
+
source_id: 'source:1',
|
|
137
|
+
source_type: 'official_registry',
|
|
138
|
+
url: 'https://example.com/1',
|
|
139
|
+
title: 'Source 1',
|
|
140
|
+
publisher: 'Pub 1',
|
|
141
|
+
retrieved_at: '2026-09-25T00:00:00Z',
|
|
142
|
+
content_hash: 'hash1',
|
|
143
|
+
excerpt: 'AI Build Infra develops high-integrity Model Context Protocol servers.',
|
|
144
|
+
supports_claim: true,
|
|
145
|
+
confidence: 0.95,
|
|
146
|
+
directness: 0.95,
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
id: 'ev:dup-2',
|
|
150
|
+
source_id: 'source:2',
|
|
151
|
+
source_type: 'github_repository',
|
|
152
|
+
url: 'https://example.com/2',
|
|
153
|
+
title: 'Source 2',
|
|
154
|
+
publisher: 'Pub 2',
|
|
155
|
+
retrieved_at: '2026-09-25T00:00:00Z',
|
|
156
|
+
content_hash: 'hash2',
|
|
157
|
+
excerpt: 'AI Build Infra develops high-integrity Model Context Protocol servers.',
|
|
158
|
+
supports_claim: true,
|
|
159
|
+
confidence: 0.95,
|
|
160
|
+
directness: 0.95,
|
|
161
|
+
},
|
|
162
|
+
];
|
|
163
|
+
const deduped = TokenOptimizer.deduplicateEvidence(duplicateEvidence);
|
|
164
|
+
assert.equal(deduped.length, 1);
|
|
165
|
+
assert.ok(deduped[0].corroborating_sources?.includes('source:2'));
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
describe('5. Graph Traversal & Path Discovery', () => {
|
|
169
|
+
it('should traverse 1-hop and 2-hop relationships', () => {
|
|
170
|
+
const traversalRes = traversal.findRelationships('entity:organization:ai-build-infra', undefined, 2);
|
|
171
|
+
assert.ok(traversalRes.direct_relationships.length >= 2);
|
|
172
|
+
assert.ok(traversalRes.traversal_nodes.length >= 3);
|
|
173
|
+
});
|
|
174
|
+
it('should explain multi-hop connection paths between entities', () => {
|
|
175
|
+
const connection = traversal.explainConnection('entity:organization:ai-build-infra', 'entity:technology:model-context-protocol');
|
|
176
|
+
assert.ok(connection);
|
|
177
|
+
assert.ok(connection.hops >= 2);
|
|
178
|
+
assert.ok(connection.summary.includes('DEVELOPS') || connection.summary.includes('DEPENDS_ON'));
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
describe('6. Security & SSRF Protection', () => {
|
|
182
|
+
it('should block localhost, loopback, private RFC1918, and metadata IPs', () => {
|
|
183
|
+
assert.equal(isPrivateOrForbiddenHost('localhost'), true);
|
|
184
|
+
assert.equal(isPrivateOrForbiddenHost('127.0.0.1'), true);
|
|
185
|
+
assert.equal(isPrivateOrForbiddenHost('10.0.0.1'), true);
|
|
186
|
+
assert.equal(isPrivateOrForbiddenHost('172.16.5.1'), true);
|
|
187
|
+
assert.equal(isPrivateOrForbiddenHost('192.168.1.1'), true);
|
|
188
|
+
assert.equal(isPrivateOrForbiddenHost('169.254.169.254'), true);
|
|
189
|
+
assert.equal(isPrivateOrForbiddenHost('metadata.google.internal'), true);
|
|
190
|
+
});
|
|
191
|
+
it('should allow legitimate public domains', () => {
|
|
192
|
+
assert.equal(isPrivateOrForbiddenHost('aibuildinfra.com'), false);
|
|
193
|
+
assert.equal(isPrivateOrForbiddenHost('github.com'), false);
|
|
194
|
+
assert.equal(isPrivateOrForbiddenHost('modelcontextprotocol.io'), false);
|
|
195
|
+
});
|
|
196
|
+
it('should throw SecurityError on illegal URL protocols or forbidden targets', () => {
|
|
197
|
+
assert.throws(() => validateSafeUrl('file:///etc/passwd'));
|
|
198
|
+
assert.throws(() => validateSafeUrl('http://169.254.169.254/latest/meta-data'));
|
|
199
|
+
});
|
|
200
|
+
it('should correctly parse robots.txt and enforce path disallows', () => {
|
|
201
|
+
const robots = new RobotsParser(`
|
|
202
|
+
User-agent: *
|
|
203
|
+
Disallow: /private/
|
|
204
|
+
Disallow: /admin
|
|
205
|
+
Allow: /private/public-doc
|
|
206
|
+
`);
|
|
207
|
+
assert.equal(robots.isAllowed('/blog/post-1'), true);
|
|
208
|
+
assert.equal(robots.isAllowed('/admin/settings'), false);
|
|
209
|
+
assert.equal(robots.isAllowed('/private/secret'), false);
|
|
210
|
+
assert.equal(robots.isAllowed('/private/public-doc'), true);
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
describe('7. MCP Tool Handlers', () => {
|
|
214
|
+
it('should execute search_entities tool', async () => {
|
|
215
|
+
const res = await toolHandler.handleTool('search_entities', { query: 'AI Build Infra' });
|
|
216
|
+
assert.ok(res.candidates.length > 0);
|
|
217
|
+
assert.equal(res.candidates[0].entity.id, 'entity:organization:ai-build-infra');
|
|
218
|
+
});
|
|
219
|
+
it('should execute get_entity tool and return schema.org structured data', async () => {
|
|
220
|
+
const res = await toolHandler.handleTool('get_entity', { entity_id: 'entity:organization:ai-build-infra' });
|
|
221
|
+
assert.ok(res.entity);
|
|
222
|
+
assert.equal(res.schema_org['@type'], 'Organization');
|
|
223
|
+
});
|
|
224
|
+
it('should execute get_evidence_packet tool', async () => {
|
|
225
|
+
const res = await toolHandler.handleTool('get_evidence_packet', {
|
|
226
|
+
question: 'What does AI Build Infra develop?',
|
|
227
|
+
max_tokens: 1500,
|
|
228
|
+
});
|
|
229
|
+
assert.ok(res.evidence.length > 0);
|
|
230
|
+
assert.ok(res.provenance.length > 0);
|
|
231
|
+
assert.ok(res.metrics.returned_tokens > 0);
|
|
232
|
+
});
|
|
233
|
+
it('should execute trace_claim tool', async () => {
|
|
234
|
+
const res = await toolHandler.handleTool('trace_claim', {
|
|
235
|
+
claim: 'AI Build Infra develops MCP servers',
|
|
236
|
+
});
|
|
237
|
+
assert.equal(res.status, 'supported');
|
|
238
|
+
assert.ok(res.provenance_chain.length > 0);
|
|
239
|
+
});
|
|
240
|
+
it('should execute audit_entity_consistency tool', async () => {
|
|
241
|
+
const res = await toolHandler.handleTool('audit_entity_consistency', {
|
|
242
|
+
entity_id: 'entity:organization:ai-build-infra',
|
|
243
|
+
});
|
|
244
|
+
assert.ok(res.consistency_score >= 0.85);
|
|
245
|
+
assert.ok(res.footprint.website);
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
//# sourceMappingURL=proofgraph.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proofgraph.test.js","sourceRoot":"","sources":["../../src/tests/proofgraph.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAExC,OAAO,EAAE,UAAU,EAAoB,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAkB,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAGnE,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,IAAI,KAAiB,CAAC;IACtB,IAAI,QAAwB,CAAC;IAC7B,IAAI,QAAuB,CAAC;IAC5B,IAAI,SAA+B,CAAC;IACpC,IAAI,WAAwB,CAAC;IAE7B,MAAM,CAAC,GAAG,EAAE;QACV,KAAK,GA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,CAAC,CAAC;YACnC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACrC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;YAC/C,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,UAAU,CAAC,aAAa,EAAE;gBACtD,KAAK,EAAE,qCAAqC;aAC7C,CAAC,CAAC;YACH,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YACtC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8CAA8C,EAAE,KAAK,IAAI,EAAE;YAC5D,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,UAAU,CAAC,0BAA0B,EAAE;gBACnE,SAAS,EAAE,oCAAoC;aAChD,CAAC,CAAC;YACH,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,iBAAiB,IAAI,IAAI,CAAC,CAAC;YACzC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProofGraph Type System
|
|
3
|
+
* Evidence-first knowledge & entity graph by AI Build Infra
|
|
4
|
+
*/
|
|
5
|
+
export type EntityType = 'Organization' | 'Person' | 'Project' | 'Repository' | 'Package' | 'Website' | 'Product' | 'Service' | 'Article' | 'Publication' | 'Technology' | 'Claim' | 'Evidence' | 'Source' | 'Document';
|
|
6
|
+
export type RelationshipType = 'OWNS' | 'OPERATES' | 'PUBLISHES' | 'DEVELOPS' | 'MAINTAINS' | 'AUTHORED_BY' | 'BUILT_BY' | 'ABOUT' | 'MENTIONS' | 'REFERENCES' | 'SUPPORTS' | 'CONTRADICTS' | 'VERIFIES' | 'DEPENDS_ON' | 'HOSTED_ON' | 'PUBLISHED_ON' | 'AVAILABLE_ON' | 'HAS_DOCUMENTATION' | 'HAS_CASE_STUDY' | 'HAS_REPOSITORY' | 'HAS_PACKAGE' | 'HAS_WEBSITE' | string;
|
|
7
|
+
export type SourceTrustClass = 'official_source' | 'government_source' | 'standards_body' | 'official_registry' | 'github_repository' | 'package_registry' | 'academic_source' | 'established_publication' | 'industry_directory' | 'community_source' | 'social_media' | 'unknown_source';
|
|
8
|
+
export type ClaimStatus = 'supported' | 'contradicted' | 'conflicting' | 'unverified';
|
|
9
|
+
export type FreshnessStatus = 'fresh' | 'stale' | 'unknown';
|
|
10
|
+
export interface Entity {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
type: EntityType;
|
|
14
|
+
description: string;
|
|
15
|
+
canonical_url?: string;
|
|
16
|
+
aliases: string[];
|
|
17
|
+
metadata: Record<string, any>;
|
|
18
|
+
created_at: string;
|
|
19
|
+
updated_at: string;
|
|
20
|
+
}
|
|
21
|
+
export interface Source {
|
|
22
|
+
id: string;
|
|
23
|
+
source_type: SourceTrustClass;
|
|
24
|
+
url: string;
|
|
25
|
+
domain: string;
|
|
26
|
+
title: string;
|
|
27
|
+
publisher: string;
|
|
28
|
+
trust_class: SourceTrustClass;
|
|
29
|
+
reliability_score: number;
|
|
30
|
+
published_at?: string;
|
|
31
|
+
retrieved_at: string;
|
|
32
|
+
content_hash: string;
|
|
33
|
+
etag?: string;
|
|
34
|
+
last_verified: string;
|
|
35
|
+
freshness: FreshnessStatus;
|
|
36
|
+
metadata?: Record<string, any>;
|
|
37
|
+
}
|
|
38
|
+
export interface Evidence {
|
|
39
|
+
id: string;
|
|
40
|
+
claim_id?: string;
|
|
41
|
+
source_id: string;
|
|
42
|
+
source_type: SourceTrustClass;
|
|
43
|
+
url: string;
|
|
44
|
+
title: string;
|
|
45
|
+
publisher: string;
|
|
46
|
+
retrieved_at: string;
|
|
47
|
+
published_at?: string;
|
|
48
|
+
content_hash: string;
|
|
49
|
+
excerpt: string;
|
|
50
|
+
supports_claim: boolean;
|
|
51
|
+
confidence: number;
|
|
52
|
+
directness: number;
|
|
53
|
+
corroborating_sources?: string[];
|
|
54
|
+
}
|
|
55
|
+
export interface Claim {
|
|
56
|
+
id: string;
|
|
57
|
+
subject_id: string;
|
|
58
|
+
predicate: string;
|
|
59
|
+
object_id?: string;
|
|
60
|
+
object_value?: string;
|
|
61
|
+
statement: string;
|
|
62
|
+
status: ClaimStatus;
|
|
63
|
+
confidence: number;
|
|
64
|
+
evidence_ids: string[];
|
|
65
|
+
created_at: string;
|
|
66
|
+
updated_at: string;
|
|
67
|
+
}
|
|
68
|
+
export interface Relationship {
|
|
69
|
+
id?: string;
|
|
70
|
+
source_id: string;
|
|
71
|
+
target_id: string;
|
|
72
|
+
relationship: RelationshipType;
|
|
73
|
+
confidence: number;
|
|
74
|
+
evidence_ids?: string[];
|
|
75
|
+
metadata?: Record<string, any>;
|
|
76
|
+
created_at?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface EntityResolutionCandidate {
|
|
79
|
+
entity: Entity;
|
|
80
|
+
match_score: number;
|
|
81
|
+
signals: {
|
|
82
|
+
name: number;
|
|
83
|
+
domain: number;
|
|
84
|
+
github: number;
|
|
85
|
+
npm: number;
|
|
86
|
+
email?: number;
|
|
87
|
+
publisher?: number;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export interface EvidencePacket {
|
|
91
|
+
question?: string;
|
|
92
|
+
entities: Array<{
|
|
93
|
+
id: string;
|
|
94
|
+
name: string;
|
|
95
|
+
type: EntityType;
|
|
96
|
+
canonical_url?: string;
|
|
97
|
+
description: string;
|
|
98
|
+
}>;
|
|
99
|
+
claims: Array<{
|
|
100
|
+
id: string;
|
|
101
|
+
claim: string;
|
|
102
|
+
status: ClaimStatus;
|
|
103
|
+
confidence: number;
|
|
104
|
+
}>;
|
|
105
|
+
relationships: Array<{
|
|
106
|
+
source_id: string;
|
|
107
|
+
target_id: string;
|
|
108
|
+
relationship: string;
|
|
109
|
+
confidence: number;
|
|
110
|
+
}>;
|
|
111
|
+
evidence: Array<{
|
|
112
|
+
evidence_id: string;
|
|
113
|
+
source: string;
|
|
114
|
+
source_type: SourceTrustClass;
|
|
115
|
+
url: string;
|
|
116
|
+
excerpt: string;
|
|
117
|
+
confidence: number;
|
|
118
|
+
retrieved_at: string;
|
|
119
|
+
corroborating_count?: number;
|
|
120
|
+
}>;
|
|
121
|
+
provenance: Array<{
|
|
122
|
+
claim_id: string;
|
|
123
|
+
evidence_id: string;
|
|
124
|
+
source_id: string;
|
|
125
|
+
url: string;
|
|
126
|
+
content_hash: string;
|
|
127
|
+
retrieved_at: string;
|
|
128
|
+
}>;
|
|
129
|
+
metrics: TokenMetrics;
|
|
130
|
+
}
|
|
131
|
+
export interface TokenMetrics {
|
|
132
|
+
sources_considered: number;
|
|
133
|
+
sources_returned: number;
|
|
134
|
+
raw_estimated_tokens: number;
|
|
135
|
+
returned_tokens: number;
|
|
136
|
+
compression_ratio: number;
|
|
137
|
+
}
|
|
138
|
+
export interface ConsistencyAuditResult {
|
|
139
|
+
entity: string;
|
|
140
|
+
entity_id: string;
|
|
141
|
+
consistency_score: number;
|
|
142
|
+
footprint: {
|
|
143
|
+
company_name: boolean;
|
|
144
|
+
website: boolean;
|
|
145
|
+
github_organization: boolean;
|
|
146
|
+
npm_scope: boolean;
|
|
147
|
+
mcp_registry: boolean;
|
|
148
|
+
schema_org: boolean;
|
|
149
|
+
email_domain: boolean;
|
|
150
|
+
};
|
|
151
|
+
issues: Array<{
|
|
152
|
+
severity: 'high' | 'medium' | 'low';
|
|
153
|
+
component: string;
|
|
154
|
+
message: string;
|
|
155
|
+
recommendation: string;
|
|
156
|
+
}>;
|
|
157
|
+
verified_presence: Record<string, string>;
|
|
158
|
+
}
|
|
159
|
+
export interface AIDiscoverabilityResult {
|
|
160
|
+
entity: string;
|
|
161
|
+
entity_id: string;
|
|
162
|
+
overall_score: number;
|
|
163
|
+
checklist: {
|
|
164
|
+
identity_clarity: {
|
|
165
|
+
score: number;
|
|
166
|
+
status: 'pass' | 'partial' | 'fail';
|
|
167
|
+
detail: string;
|
|
168
|
+
};
|
|
169
|
+
source_coverage: {
|
|
170
|
+
score: number;
|
|
171
|
+
status: 'pass' | 'partial' | 'fail';
|
|
172
|
+
detail: string;
|
|
173
|
+
};
|
|
174
|
+
entity_consistency: {
|
|
175
|
+
score: number;
|
|
176
|
+
status: 'pass' | 'partial' | 'fail';
|
|
177
|
+
detail: string;
|
|
178
|
+
};
|
|
179
|
+
relationship_coverage: {
|
|
180
|
+
score: number;
|
|
181
|
+
status: 'pass' | 'partial' | 'fail';
|
|
182
|
+
detail: string;
|
|
183
|
+
};
|
|
184
|
+
evidence_availability: {
|
|
185
|
+
score: number;
|
|
186
|
+
status: 'pass' | 'partial' | 'fail';
|
|
187
|
+
detail: string;
|
|
188
|
+
};
|
|
189
|
+
freshness: {
|
|
190
|
+
score: number;
|
|
191
|
+
status: 'pass' | 'partial' | 'fail';
|
|
192
|
+
detail: string;
|
|
193
|
+
};
|
|
194
|
+
technical_footprint: {
|
|
195
|
+
score: number;
|
|
196
|
+
status: 'pass' | 'partial' | 'fail';
|
|
197
|
+
detail: string;
|
|
198
|
+
};
|
|
199
|
+
third_party_corroboration: {
|
|
200
|
+
score: number;
|
|
201
|
+
status: 'pass' | 'partial' | 'fail';
|
|
202
|
+
detail: string;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
recommendations: string[];
|
|
206
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|