@unrdf/kgc-probe 26.4.8 → 26.5.5
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/package.json +18 -19
- package/src/config.mjs +2 -2
- package/src/guards.mjs +3 -3
- package/src/index.mjs +1 -1
- package/src/observation.mjs +1 -1
- package/src/probes/README.md +1 -1
- package/src/probes/concurrency.mjs +2 -2
- package/src/probes/performance.mjs +5 -4
- package/src/probes/persistence.mjs +3 -3
- package/src/probes/tooling.mjs +2 -2
- package/src/probes/tooling.test.mjs +1 -1
- package/src/probes/verify-execution.mjs +0 -0
- package/src/probes/verify-guards.mjs +0 -0
- package/src/receipt.mjs +2 -2
- package/src/receipts/index.mjs +2 -2
- package/src/reporter.mjs +3 -3
- package/src/reporters/rdf.mjs +1 -1
- package/src/types.mjs +3 -3
- package/src/vocabulary.ttl +1 -1
- package/LICENSE +0 -21
- package/README.md +0 -414
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unrdf/kgc-probe",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.5.5",
|
|
4
4
|
"description": "KGC Probe - Automated knowledge graph integrity scanning with 10 agents and artifact validation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.mjs",
|
|
@@ -23,6 +23,17 @@
|
|
|
23
23
|
"README.md",
|
|
24
24
|
"LICENSE"
|
|
25
25
|
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "vitest run --coverage",
|
|
28
|
+
"test:fast": "vitest run --coverage",
|
|
29
|
+
"test:watch": "vitest --coverage",
|
|
30
|
+
"lint": "eslint src/ test/ --max-warnings=0",
|
|
31
|
+
"lint:fix": "eslint src/ test/ --fix",
|
|
32
|
+
"format": "prettier --write src/",
|
|
33
|
+
"format:check": "prettier --check src/",
|
|
34
|
+
"build": "echo 'Build complete (pure ESM, no compilation needed)'",
|
|
35
|
+
"validate": "npm run lint && npm run test"
|
|
36
|
+
},
|
|
26
37
|
"keywords": [
|
|
27
38
|
"rdf",
|
|
28
39
|
"knowledge-graph",
|
|
@@ -35,12 +46,11 @@
|
|
|
35
46
|
"artifact-verification"
|
|
36
47
|
],
|
|
37
48
|
"dependencies": {
|
|
38
|
-
"@unrdf/kgc-substrate": "
|
|
39
|
-
"@unrdf/kgc-4d": "
|
|
40
|
-
"@unrdf/v6-core": "
|
|
41
|
-
"@unrdf/oxigraph": "
|
|
42
|
-
"@unrdf/hooks": "
|
|
43
|
-
"@unrdf/yawl": "26.4.4",
|
|
49
|
+
"@unrdf/kgc-substrate": "workspace:*",
|
|
50
|
+
"@unrdf/kgc-4d": "workspace:*",
|
|
51
|
+
"@unrdf/v6-core": "workspace:*",
|
|
52
|
+
"@unrdf/oxigraph": "workspace:*",
|
|
53
|
+
"@unrdf/hooks": "workspace:*",
|
|
44
54
|
"hash-wasm": "^4.12.0",
|
|
45
55
|
"zod": "^4.1.13"
|
|
46
56
|
},
|
|
@@ -66,16 +76,5 @@
|
|
|
66
76
|
"author": "UNRDF Contributors",
|
|
67
77
|
"publishConfig": {
|
|
68
78
|
"access": "public"
|
|
69
|
-
},
|
|
70
|
-
"scripts": {
|
|
71
|
-
"test": "vitest run --coverage",
|
|
72
|
-
"test:fast": "vitest run --coverage",
|
|
73
|
-
"test:watch": "vitest --coverage",
|
|
74
|
-
"lint": "eslint src/ test/ --max-warnings=0",
|
|
75
|
-
"lint:fix": "eslint src/ test/ --fix",
|
|
76
|
-
"format": "prettier --write src/",
|
|
77
|
-
"format:check": "prettier --check src/",
|
|
78
|
-
"build": "echo 'Build complete (pure ESM, no compilation needed)'",
|
|
79
|
-
"validate": "npm run lint && npm run test"
|
|
80
79
|
}
|
|
81
|
-
}
|
|
80
|
+
}
|
package/src/config.mjs
CHANGED
|
@@ -40,7 +40,7 @@ export const ProbeConfigSchema = z.object({
|
|
|
40
40
|
maxTimeoutMs: z.number().int().positive().default(50000),
|
|
41
41
|
|
|
42
42
|
// Probe version
|
|
43
|
-
probeVersion: z.string().default('
|
|
43
|
+
probeVersion: z.string().default('[VERSION]'),
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -69,7 +69,7 @@ export function parseConfig(options) {
|
|
|
69
69
|
samples: options.samples,
|
|
70
70
|
enforceTimeouts: true,
|
|
71
71
|
maxTimeoutMs: (options.budgetMs || 5000) * 10,
|
|
72
|
-
probeVersion: '
|
|
72
|
+
probeVersion: '[VERSION]',
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
return ProbeConfigSchema.parse(config);
|
package/src/guards.mjs
CHANGED
|
@@ -353,7 +353,7 @@ const NETWORK_ALLOWED_HOSTS = [
|
|
|
353
353
|
{ hostname: 'github.com', paths: ['**'], methods: ['GET'] },
|
|
354
354
|
{ hostname: 'docs.github.com', paths: ['**'], methods: ['GET'] },
|
|
355
355
|
{ hostname: 'localhost', paths: ['**'], methods: ['GET', 'POST'] },
|
|
356
|
-
{ hostname: '
|
|
356
|
+
{ hostname: '[VERSION].1', paths: ['**'], methods: ['GET', 'POST'] },
|
|
357
357
|
];
|
|
358
358
|
|
|
359
359
|
/**
|
|
@@ -362,7 +362,7 @@ const NETWORK_ALLOWED_HOSTS = [
|
|
|
362
362
|
*/
|
|
363
363
|
const NETWORK_FORBIDDEN_DOMAINS = [
|
|
364
364
|
'metadata.google.internal',
|
|
365
|
-
'
|
|
365
|
+
'[VERSION].254', // AWS/Azure metadata
|
|
366
366
|
'169.254.*',
|
|
367
367
|
'*.internal',
|
|
368
368
|
'*.local',
|
|
@@ -729,7 +729,7 @@ export class GuardRegistry {
|
|
|
729
729
|
* @param {string} [method='GET'] - HTTP method
|
|
730
730
|
* @returns {{allowed: boolean, reason?: string, guardId?: string, hostname?: string, severity?: string, receipt?: Object}}
|
|
731
731
|
* @example
|
|
732
|
-
* const result = registry.checkNetworkURL('http://
|
|
732
|
+
* const result = registry.checkNetworkURL('http://[VERSION].254/latest/meta-data/');
|
|
733
733
|
* // { allowed: false, reason: 'Network access to metadata service forbidden', ... }
|
|
734
734
|
*/
|
|
735
735
|
checkNetworkURL(url, method = 'GET') {
|
package/src/index.mjs
CHANGED
package/src/observation.mjs
CHANGED
|
@@ -145,7 +145,7 @@ export function createGuardDenial({ guardName, reason, agentId, context = {} })
|
|
|
145
145
|
},
|
|
146
146
|
metadata: {
|
|
147
147
|
agentId,
|
|
148
|
-
probeVersion: '
|
|
148
|
+
probeVersion: '[VERSION]',
|
|
149
149
|
budgetMs: 1, // Guards have minimal overhead
|
|
150
150
|
actualMs: 0,
|
|
151
151
|
timestamp: new Date().toISOString(),
|
package/src/probes/README.md
CHANGED
|
@@ -32,7 +32,7 @@ The Tooling Surface Probe provides safe, API-based detection of CLI tools, versi
|
|
|
32
32
|
{
|
|
33
33
|
method: "tooling.git_version",
|
|
34
34
|
inputs: { command: "git", args: ["--version"] },
|
|
35
|
-
outputs: { version: "
|
|
35
|
+
outputs: { version: "[VERSION]", available: true },
|
|
36
36
|
guardDecision: "allowed",
|
|
37
37
|
metadata: {}
|
|
38
38
|
}
|
|
@@ -165,7 +165,7 @@ async function probeWorkerThreadsAvailability() {
|
|
|
165
165
|
// Check Node.js version
|
|
166
166
|
const nodeVersion = process.version;
|
|
167
167
|
outputs.nodeVersion = nodeVersion;
|
|
168
|
-
metadata.minVersion = '
|
|
168
|
+
metadata.minVersion = '[VERSION]'; // worker_threads introduced in Node [VERSION]
|
|
169
169
|
} catch (error) {
|
|
170
170
|
outputs.available = false;
|
|
171
171
|
metadata.error = error.message;
|
|
@@ -828,7 +828,7 @@ async function probeAsyncLocalStorage() {
|
|
|
828
828
|
}
|
|
829
829
|
|
|
830
830
|
metadata.nodeVersion = process.version;
|
|
831
|
-
metadata.note = 'AsyncLocalStorage available since Node.js
|
|
831
|
+
metadata.note = 'AsyncLocalStorage available since Node.js [VERSION]';
|
|
832
832
|
} catch (error) {
|
|
833
833
|
outputs.available = false;
|
|
834
834
|
outputs.functional = false;
|
|
@@ -39,7 +39,7 @@ import { readFile, writeFile, unlink, mkdir } from 'node:fs/promises';
|
|
|
39
39
|
import { Readable, Writable } from 'node:stream';
|
|
40
40
|
import { pipeline } from 'node:stream/promises';
|
|
41
41
|
import { join, resolve } from 'node:path';
|
|
42
|
-
import { blake3 } from '@noble/hashes/blake3';
|
|
42
|
+
import { blake3 } from '@noble/hashes/blake3.js';
|
|
43
43
|
import { ObservationSchema, ProbeConfigSchema } from '../types.mjs';
|
|
44
44
|
|
|
45
45
|
// =============================================================================
|
|
@@ -109,7 +109,7 @@ function createObservation(category, observation, value, guardDecision, metadata
|
|
|
109
109
|
metadata,
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
-
return
|
|
112
|
+
return obs;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
/**
|
|
@@ -485,8 +485,9 @@ async function benchmarkStringOperations(stringSize, options) {
|
|
|
485
485
|
*/
|
|
486
486
|
export async function probePerformance(config = {}) {
|
|
487
487
|
// Validate config
|
|
488
|
-
const validatedConfig =
|
|
489
|
-
const
|
|
488
|
+
const validatedConfig = config;
|
|
489
|
+
const out = validatedConfig.out || '/tmp';
|
|
490
|
+
const timeout = validatedConfig.timeout || 30000;
|
|
490
491
|
|
|
491
492
|
// Additional config defaults for performance benchmarking
|
|
492
493
|
const samples = config.samples || 100;
|
|
@@ -78,8 +78,8 @@ function createObservation(probeName, category, observation, value, guardDecisio
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
// Validate before returning
|
|
81
|
-
const validated = ObservationSchema.parse(obs);
|
|
82
|
-
return
|
|
81
|
+
// const validated = ObservationSchema.parse(obs);
|
|
82
|
+
return obs;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/**
|
|
@@ -773,7 +773,7 @@ async function probeStorageType(config) {
|
|
|
773
773
|
*/
|
|
774
774
|
export async function probePersistence(config) {
|
|
775
775
|
// Validate config
|
|
776
|
-
const validatedConfig =
|
|
776
|
+
const validatedConfig = config;
|
|
777
777
|
|
|
778
778
|
const observations = [];
|
|
779
779
|
|
package/src/probes/tooling.mjs
CHANGED
|
@@ -154,7 +154,7 @@ async function probeGit(timeout) {
|
|
|
154
154
|
const metadata = {};
|
|
155
155
|
|
|
156
156
|
if (result.success && result.stdout) {
|
|
157
|
-
// Parse version: "git version
|
|
157
|
+
// Parse version: "git version [VERSION]" -> "[VERSION]"
|
|
158
158
|
const match = result.stdout.match(/git version ([\d.]+)/);
|
|
159
159
|
if (match) {
|
|
160
160
|
outputs.version = match[1];
|
|
@@ -186,7 +186,7 @@ async function probeNode(timeout) {
|
|
|
186
186
|
const metadata = {};
|
|
187
187
|
|
|
188
188
|
if (result.success && result.stdout) {
|
|
189
|
-
// Parse version: "
|
|
189
|
+
// Parse version: "[VERSION]" -> "[VERSION]"
|
|
190
190
|
const version = result.stdout.replace(/^v/, '');
|
|
191
191
|
outputs.version = version;
|
|
192
192
|
outputs.available = true;
|
|
@@ -138,7 +138,7 @@ describe('ObservationSchema', () => {
|
|
|
138
138
|
const obs = {
|
|
139
139
|
method: 'tooling.git_version',
|
|
140
140
|
inputs: { command: 'git', args: ['--version'] },
|
|
141
|
-
outputs: { version: '
|
|
141
|
+
outputs: { version: '[VERSION]', available: true },
|
|
142
142
|
guardDecision: 'allowed',
|
|
143
143
|
metadata: { timestamp: Date.now() },
|
|
144
144
|
};
|
|
File without changes
|
|
File without changes
|
package/src/receipt.mjs
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
* - Verifiable: Can reconstruct and verify entire chain
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { blake3 } from '@noble/hashes/blake3';
|
|
18
|
-
import { bytesToHex } from '@noble/hashes/utils';
|
|
17
|
+
import { blake3 } from '@noble/hashes/blake3.js';
|
|
18
|
+
import { bytesToHex } from '@noble/hashes/utils.js';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Hash data deterministically using BLAKE3
|
package/src/receipts/index.mjs
CHANGED
|
@@ -21,7 +21,7 @@ import { randomUUID, createHash } from 'crypto';
|
|
|
21
21
|
export const HASH_ALGORITHM = 'sha256';
|
|
22
22
|
|
|
23
23
|
/** Receipt version */
|
|
24
|
-
export const RECEIPT_VERSION = '
|
|
24
|
+
export const RECEIPT_VERSION = '[VERSION]';
|
|
25
25
|
|
|
26
26
|
/** Receipt types */
|
|
27
27
|
export const RECEIPT_TYPES = Object.freeze({
|
|
@@ -302,7 +302,7 @@ export function createMergeReceipt({
|
|
|
302
302
|
proofPath,
|
|
303
303
|
mergeAlgorithm: {
|
|
304
304
|
algorithm: 'lww-deterministic',
|
|
305
|
-
version: '
|
|
305
|
+
version: '[VERSION]',
|
|
306
306
|
parameters: {
|
|
307
307
|
leafOrder: 'agentId-ascending',
|
|
308
308
|
hashFunction: HASH_ALGORITHM,
|
package/src/reporter.mjs
CHANGED
|
@@ -93,7 +93,7 @@ function generateHash(observation) {
|
|
|
93
93
|
* @returns {string} Turtle-formatted RDF string
|
|
94
94
|
*
|
|
95
95
|
* @example
|
|
96
|
-
* const obs = [{ method: 'probeRuntime', outputs: { node: '
|
|
96
|
+
* const obs = [{ method: 'probeRuntime', outputs: { node: '[VERSION]' } }];
|
|
97
97
|
* const turtle = observationsToRdf(obs);
|
|
98
98
|
* console.log(turtle); // @prefix kgc: <http://unrdf.dev/kgc#> . ...
|
|
99
99
|
*/
|
|
@@ -193,8 +193,8 @@ export function observationsToRdf(observations) {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
// Serialize to
|
|
197
|
-
return store.dump({ format: '
|
|
196
|
+
// Serialize to N-Quads
|
|
197
|
+
return store.dump({ format: 'application/n-quads' });
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
/**
|
package/src/reporters/rdf.mjs
CHANGED
|
@@ -186,7 +186,7 @@ function deriveConstraints(observations) {
|
|
|
186
186
|
* @returns {Promise<string>} Turtle-formatted RDF string
|
|
187
187
|
*
|
|
188
188
|
* @example
|
|
189
|
-
* const obs = [{ method: 'runtime.node-version', outputs: { version: '
|
|
189
|
+
* const obs = [{ method: 'runtime.node-version', outputs: { version: '[VERSION]' } }];
|
|
190
190
|
* const turtle = await convertToTurtle(obs);
|
|
191
191
|
* console.log(turtle); // @prefix kgc: <https://unrdf.org/kgc/probe#> . ...
|
|
192
192
|
*/
|
package/src/types.mjs
CHANGED
|
@@ -32,7 +32,7 @@ export const UUID_V4_REGEX =
|
|
|
32
32
|
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
* Semver pattern (e.g.,
|
|
35
|
+
* Semver pattern (e.g., [VERSION], [VERSION]-beta.1+build.123)
|
|
36
36
|
* @type {RegExp}
|
|
37
37
|
*/
|
|
38
38
|
export const SEMVER_REGEX =
|
|
@@ -725,7 +725,7 @@ export function createFrontmatter(data) {
|
|
|
725
725
|
bounds: { maxQueries: 100, maxRuntime: 5000, maxFileScans: 50 },
|
|
726
726
|
views: ['reference'],
|
|
727
727
|
sources: [],
|
|
728
|
-
version: '
|
|
728
|
+
version: '[VERSION]',
|
|
729
729
|
createdAt: now,
|
|
730
730
|
lastProved: now,
|
|
731
731
|
};
|
|
@@ -964,7 +964,7 @@ export function createProbeReport(data) {
|
|
|
964
964
|
coverage: 1.0,
|
|
965
965
|
},
|
|
966
966
|
metadata: {
|
|
967
|
-
probeVersion: '
|
|
967
|
+
probeVersion: '[VERSION]',
|
|
968
968
|
executionTimeMs: 0,
|
|
969
969
|
},
|
|
970
970
|
};
|
package/src/vocabulary.ttl
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
# - Provenance-focused: Every claim links to evidence (observations)
|
|
18
18
|
# - RDFS/OWL compatible: Standard semantics for tooling integration
|
|
19
19
|
#
|
|
20
|
-
# Version:
|
|
20
|
+
# Version: [VERSION]
|
|
21
21
|
# Author: KGC Probe Agent 10 (Reporter & RDF Modeler)
|
|
22
22
|
# License: MIT
|
|
23
23
|
# =============================================================================
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,414 +0,0 @@
|
|
|
1
|
-
# @unrdf/kgc-probe
|
|
2
|
-
|
|
3
|
-
Automated knowledge graph integrity scanning with 10 specialized agents and deterministic artifact validation.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
KGC Probe provides a comprehensive integrity scanning framework for RDF knowledge graphs with:
|
|
8
|
-
|
|
9
|
-
- **10 Specialized Agents**: Completeness, consistency, conformance, coverage, caching, coherence, clustering, classification, and collaboration analysis
|
|
10
|
-
- **Guard-Based Validation**: Quality checks, severity limits, and completeness verification
|
|
11
|
-
- **Deterministic Artifacts**: Blake3 hashed observations for reproducible scans
|
|
12
|
-
- **Distributed Shard Merging**: Multi-node probe result aggregation
|
|
13
|
-
- **Multiple Storage Backends**: Memory, file system, or database-backed
|
|
14
|
-
- **CLI Integration**: Full `kgc probe` command suite
|
|
15
|
-
|
|
16
|
-
## Installation
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
pnpm add @unrdf/kgc-probe
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Quick Start
|
|
23
|
-
|
|
24
|
-
### Basic Scan
|
|
25
|
-
|
|
26
|
-
```javascript
|
|
27
|
-
import { runProbe } from '@unrdf/kgc-probe';
|
|
28
|
-
|
|
29
|
-
const artifact = await runProbe({
|
|
30
|
-
universe_id: 'my-universe',
|
|
31
|
-
snapshot_id: 'snap_123'
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
console.log(artifact.summary);
|
|
35
|
-
// {
|
|
36
|
-
// total: 42,
|
|
37
|
-
// by_kind: { completeness: 15, consistency: 12, ... },
|
|
38
|
-
// by_severity: { critical: 2, warning: 8, info: 32 },
|
|
39
|
-
// confidence_mean: 0.89,
|
|
40
|
-
// coverage_mean: 0.92
|
|
41
|
-
// }
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### Advanced Orchestration
|
|
45
|
-
|
|
46
|
-
```javascript
|
|
47
|
-
import { createProbeOrchestrator, createMemoryStorage } from '@unrdf/kgc-probe';
|
|
48
|
-
|
|
49
|
-
const orchestrator = createProbeOrchestrator({
|
|
50
|
-
storage: createMemoryStorage()
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// Listen to events
|
|
54
|
-
orchestrator.on('agent_complete', (result) => {
|
|
55
|
-
console.log(`Agent ${result.agentId} found ${result.observationCount} observations`);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// Run scan
|
|
59
|
-
const result = await orchestrator.scan({
|
|
60
|
-
universe_id: 'my-universe',
|
|
61
|
-
agents: ['completion', 'consistency', 'conformance'], // Specific agents
|
|
62
|
-
distributed: true // Enable shard merging
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
console.log(result.status); // 'success' | 'partial' | 'failed'
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## CLI Usage
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
# Run full scan
|
|
72
|
-
kgc probe scan --args '{"universe":"my-universe"}' --json
|
|
73
|
-
|
|
74
|
-
# List agents
|
|
75
|
-
kgc agent list
|
|
76
|
-
|
|
77
|
-
# List guards
|
|
78
|
-
kgc guard list
|
|
79
|
-
|
|
80
|
-
# Validate artifact
|
|
81
|
-
kgc probe validate --args '{"artifact_id":"run-123"}'
|
|
82
|
-
|
|
83
|
-
# Diff two artifacts
|
|
84
|
-
kgc probe diff --args '{"artifact1_id":"run-1","artifact2_id":"run-2"}'
|
|
85
|
-
|
|
86
|
-
# Merge shards
|
|
87
|
-
kgc shard merge --args '{"universe":"my-universe"}'
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Architecture
|
|
91
|
-
|
|
92
|
-
### 10 Agents
|
|
93
|
-
|
|
94
|
-
| Agent | Kind | Purpose |
|
|
95
|
-
|-------|------|---------|
|
|
96
|
-
| **Completion** | completeness | Missing required properties |
|
|
97
|
-
| **Consistency** | consistency | Value conflicts and contradictions |
|
|
98
|
-
| **Conformance** | conformance | SHACL shape violations |
|
|
99
|
-
| **Coverage** | coverage | Triple density and reachability |
|
|
100
|
-
| **Caching** | caching | Cache staleness and efficiency |
|
|
101
|
-
| **Completeness** | completeness_level | Data population ratios |
|
|
102
|
-
| **Coherence** | coherence | Semantic inconsistencies |
|
|
103
|
-
| **Clustering** | clustering | Entity grouping patterns |
|
|
104
|
-
| **Classification** | classification | Type hierarchy issues |
|
|
105
|
-
| **Collaboration** | collaboration | Cross-agent finding fusion |
|
|
106
|
-
|
|
107
|
-
### 5 Guards
|
|
108
|
-
|
|
109
|
-
| Guard | Purpose |
|
|
110
|
-
|-------|---------|
|
|
111
|
-
| **quality_check** | Validates confidence and observation count |
|
|
112
|
-
| **completeness_check** | Verifies coverage thresholds |
|
|
113
|
-
| **severity_limit** | Enforces maximum critical observations |
|
|
114
|
-
| **integrity_check** | Validates observation structure |
|
|
115
|
-
| **agent_coverage** | Ensures agent diversity |
|
|
116
|
-
|
|
117
|
-
### Observation Schema
|
|
118
|
-
|
|
119
|
-
```typescript
|
|
120
|
-
interface Observation {
|
|
121
|
-
id: string; // UUID
|
|
122
|
-
agent: string; // Agent identifier
|
|
123
|
-
timestamp: ISO8601; // When observed
|
|
124
|
-
kind: string; // Observation type
|
|
125
|
-
severity: 'critical' | 'warning' | 'info';
|
|
126
|
-
subject: string; // RDF node
|
|
127
|
-
predicate?: string; // RDF property
|
|
128
|
-
object?: string; // RDF value
|
|
129
|
-
evidence: {
|
|
130
|
-
query: string; // SPARQL or algorithm
|
|
131
|
-
result: unknown; // Computation result
|
|
132
|
-
witnesses: string[]; // Confirming references
|
|
133
|
-
};
|
|
134
|
-
metrics: {
|
|
135
|
-
confidence: number; // [0, 1]
|
|
136
|
-
coverage: number; // [0, 1]
|
|
137
|
-
latency_ms: number;
|
|
138
|
-
};
|
|
139
|
-
tags?: string[];
|
|
140
|
-
xid?: string; // Correlation ID
|
|
141
|
-
}
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
### Artifact Schema
|
|
145
|
-
|
|
146
|
-
```typescript
|
|
147
|
-
interface Artifact {
|
|
148
|
-
version: '1.0';
|
|
149
|
-
universe_id: string;
|
|
150
|
-
snapshot_id: string;
|
|
151
|
-
generated_at: ISO8601;
|
|
152
|
-
probe_run_id: UUID;
|
|
153
|
-
shard_count: number;
|
|
154
|
-
shard_hash: hex64;
|
|
155
|
-
observations: Observation[];
|
|
156
|
-
summary: {
|
|
157
|
-
total: number;
|
|
158
|
-
by_kind: Record<string, number>;
|
|
159
|
-
by_severity: Record<'critical' | 'warning' | 'info', number>;
|
|
160
|
-
confidence_mean: number;
|
|
161
|
-
coverage_mean: number;
|
|
162
|
-
};
|
|
163
|
-
metadata: {
|
|
164
|
-
agents_run: string[];
|
|
165
|
-
guards_applied: string[];
|
|
166
|
-
execution_time_ms: number;
|
|
167
|
-
storage_backend: string;
|
|
168
|
-
config: ProbeConfig;
|
|
169
|
-
};
|
|
170
|
-
integrity: {
|
|
171
|
-
checksum: hex64;
|
|
172
|
-
signature?: string;
|
|
173
|
-
verified_at?: ISO8601;
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
## Storage Backends
|
|
179
|
-
|
|
180
|
-
### Memory Storage
|
|
181
|
-
|
|
182
|
-
In-process Map-based storage. Best for testing and single-process deployments.
|
|
183
|
-
|
|
184
|
-
```javascript
|
|
185
|
-
import { createMemoryStorage } from '@unrdf/kgc-probe';
|
|
186
|
-
|
|
187
|
-
const storage = createMemoryStorage();
|
|
188
|
-
await storage.saveArtifact(artifact);
|
|
189
|
-
const loaded = await storage.loadArtifact(artifact.probe_run_id);
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
### File Storage
|
|
193
|
-
|
|
194
|
-
Filesystem-based storage with JSON serialization.
|
|
195
|
-
|
|
196
|
-
```javascript
|
|
197
|
-
import { createFileStorage } from '@unrdf/kgc-probe';
|
|
198
|
-
|
|
199
|
-
const storage = createFileStorage('./artifacts');
|
|
200
|
-
await storage.saveArtifact(artifact);
|
|
201
|
-
const shards = await storage.fetchShards(); // Merge-ready artifacts
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
### Database Storage
|
|
205
|
-
|
|
206
|
-
KGC Substrate-backed storage using RDF quads (production).
|
|
207
|
-
|
|
208
|
-
```javascript
|
|
209
|
-
import { createDatabaseStorage } from '@unrdf/kgc-probe';
|
|
210
|
-
|
|
211
|
-
const storage = createDatabaseStorage({
|
|
212
|
-
store: kgcSubstrateStore,
|
|
213
|
-
namespace: 'https://probe.unrdf.org/'
|
|
214
|
-
});
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
## Operations
|
|
218
|
-
|
|
219
|
-
### Merge Shards
|
|
220
|
-
|
|
221
|
-
Deterministic merge of distributed probe results with deduplication:
|
|
222
|
-
|
|
223
|
-
```javascript
|
|
224
|
-
import { mergeShards } from '@unrdf/kgc-probe';
|
|
225
|
-
|
|
226
|
-
const artifacts = await storage.fetchShards();
|
|
227
|
-
const merged = await mergeShards(artifacts, newObservations);
|
|
228
|
-
// Merged observations are deduplicated and sorted deterministically
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
### Diff Artifacts
|
|
232
|
-
|
|
233
|
-
Compare two artifacts to identify changes:
|
|
234
|
-
|
|
235
|
-
```javascript
|
|
236
|
-
import { diffArtifacts } from '@unrdf/kgc-probe';
|
|
237
|
-
|
|
238
|
-
const diff = diffArtifacts(artifact1, artifact2);
|
|
239
|
-
// {
|
|
240
|
-
// added: Observation[],
|
|
241
|
-
// removed: Observation[],
|
|
242
|
-
// modified: { subject, predicate, before, after }[],
|
|
243
|
-
// summary: { total_changes, similarity_ratio }
|
|
244
|
-
// }
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
### Verify Artifact
|
|
248
|
-
|
|
249
|
-
Validate artifact integrity and schema compliance:
|
|
250
|
-
|
|
251
|
-
```javascript
|
|
252
|
-
import { verifyArtifact } from '@unrdf/kgc-probe';
|
|
253
|
-
|
|
254
|
-
const result = await verifyArtifact(artifact);
|
|
255
|
-
// {
|
|
256
|
-
// valid: boolean,
|
|
257
|
-
// errors: string[],
|
|
258
|
-
// verified_at: ISO8601
|
|
259
|
-
// }
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
## Complexity Analysis
|
|
263
|
-
|
|
264
|
-
| Operation | Time | Space |
|
|
265
|
-
|-----------|------|-------|
|
|
266
|
-
| scan() | O(n × m) | O(o) |
|
|
267
|
-
| mergeShards() | O(s log s) | O(s) |
|
|
268
|
-
| diffArtifacts() | O(o) | O(o) |
|
|
269
|
-
| hashObservations() | O(o log o) | O(o) |
|
|
270
|
-
|
|
271
|
-
- n = triples in graph
|
|
272
|
-
- m = agents (parallel)
|
|
273
|
-
- o = observations
|
|
274
|
-
- s = shard observations
|
|
275
|
-
|
|
276
|
-
## Configuration
|
|
277
|
-
|
|
278
|
-
### ProbeConfig
|
|
279
|
-
|
|
280
|
-
```typescript
|
|
281
|
-
interface ProbeConfig {
|
|
282
|
-
universe_id: string; // Required
|
|
283
|
-
snapshot_id?: string; // Optional snapshot reference
|
|
284
|
-
agents?: string[]; // Specific agent IDs (all if omitted)
|
|
285
|
-
guards?: string[]; // Specific guard IDs
|
|
286
|
-
distributed?: boolean; // Enable shard merging (default: false)
|
|
287
|
-
persist?: boolean; // Save to storage (default: true)
|
|
288
|
-
timeout_ms?: number; // Scan timeout (default: 300000)
|
|
289
|
-
batch_size?: number; // Observation batch size (default: 100)
|
|
290
|
-
}
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
## Examples
|
|
294
|
-
|
|
295
|
-
### Full Workflow
|
|
296
|
-
|
|
297
|
-
```javascript
|
|
298
|
-
import {
|
|
299
|
-
createProbeOrchestrator,
|
|
300
|
-
createFileStorage,
|
|
301
|
-
createGuardRegistry,
|
|
302
|
-
diffArtifacts,
|
|
303
|
-
verifyArtifact
|
|
304
|
-
} from '@unrdf/kgc-probe';
|
|
305
|
-
|
|
306
|
-
// Setup
|
|
307
|
-
const storage = createFileStorage('./probes');
|
|
308
|
-
const orchestrator = createProbeOrchestrator({ storage });
|
|
309
|
-
|
|
310
|
-
// Scan 1
|
|
311
|
-
const result1 = await orchestrator.scan({
|
|
312
|
-
universe_id: 'my-universe',
|
|
313
|
-
persist: true
|
|
314
|
-
});
|
|
315
|
-
const artifact1 = result1.artifact;
|
|
316
|
-
|
|
317
|
-
// Later: Scan 2
|
|
318
|
-
const result2 = await orchestrator.scan({
|
|
319
|
-
universe_id: 'my-universe',
|
|
320
|
-
persist: true
|
|
321
|
-
});
|
|
322
|
-
const artifact2 = result2.artifact;
|
|
323
|
-
|
|
324
|
-
// Compare
|
|
325
|
-
const diff = diffArtifacts(artifact1, artifact2);
|
|
326
|
-
console.log(`Changes: ${diff.summary.total_changes}`);
|
|
327
|
-
console.log(`Similarity: ${(diff.summary.similarity_ratio * 100).toFixed(1)}%`);
|
|
328
|
-
|
|
329
|
-
// Verify
|
|
330
|
-
const verification = await verifyArtifact(artifact2);
|
|
331
|
-
console.log(`Valid: ${verification.valid}`);
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
## Design Patterns
|
|
335
|
-
|
|
336
|
-
### Factory Pattern
|
|
337
|
-
|
|
338
|
-
All exports use factory functions for configuration flexibility:
|
|
339
|
-
|
|
340
|
-
```javascript
|
|
341
|
-
const orchestrator = createProbeOrchestrator({ storage });
|
|
342
|
-
const registry = createGuardRegistry();
|
|
343
|
-
const storage = createMemoryStorage();
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
### Registry Pattern
|
|
347
|
-
|
|
348
|
-
Agents and guards use registry for dynamic registration:
|
|
349
|
-
|
|
350
|
-
```javascript
|
|
351
|
-
const agents = createAgentRegistry();
|
|
352
|
-
agents.register('custom-agent', new MyAgent());
|
|
353
|
-
const agent = agents.get('custom-agent');
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
### Observer Pattern
|
|
357
|
-
|
|
358
|
-
Orchestrator emits events for monitoring:
|
|
359
|
-
|
|
360
|
-
```javascript
|
|
361
|
-
orchestrator.on('agent_complete', handler);
|
|
362
|
-
orchestrator.on('guard_violation', handler);
|
|
363
|
-
orchestrator.on('scan_complete', handler);
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
### Strategy Pattern
|
|
367
|
-
|
|
368
|
-
Storage is pluggable with multiple implementations:
|
|
369
|
-
|
|
370
|
-
```javascript
|
|
371
|
-
// Swap backends without changing code
|
|
372
|
-
const storage = process.env.NODE_ENV === 'production'
|
|
373
|
-
? createDatabaseStorage(opts)
|
|
374
|
-
: createMemoryStorage();
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
## Performance Characteristics
|
|
378
|
-
|
|
379
|
-
- **Scan time**: Dominated by agent SPARQL queries (varies by graph size)
|
|
380
|
-
- **Memory**: O(observations) - typically 10-100KB per 1000 observations
|
|
381
|
-
- **Determinism**: Blake3 hashing ensures identical results for same input
|
|
382
|
-
|
|
383
|
-
## Testing
|
|
384
|
-
|
|
385
|
-
```bash
|
|
386
|
-
pnpm test # Run all tests
|
|
387
|
-
pnpm test:watch # Watch mode
|
|
388
|
-
pnpm test coverage # Coverage report
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
## Dependencies
|
|
392
|
-
|
|
393
|
-
- `@unrdf/kgc-substrate` - Knowledge store interface
|
|
394
|
-
- `@unrdf/kgc-4d` - 4D snapshot and universe management
|
|
395
|
-
- `@unrdf/v6-core` - Core UNRDF types and utilities
|
|
396
|
-
- `@unrdf/oxigraph` - SPARQL query engine
|
|
397
|
-
- `@unrdf/hooks` - Hook and policy framework
|
|
398
|
-
- `@unrdf/yawl` - Workflow orchestration
|
|
399
|
-
- `hash-wasm` - Blake3 hashing
|
|
400
|
-
- `zod` - Runtime validation schemas
|
|
401
|
-
|
|
402
|
-
## License
|
|
403
|
-
|
|
404
|
-
MIT
|
|
405
|
-
|
|
406
|
-
## Contributing
|
|
407
|
-
|
|
408
|
-
See [CONTRIBUTING.md](../../CONTRIBUTING.md)
|
|
409
|
-
|
|
410
|
-
## References
|
|
411
|
-
|
|
412
|
-
- [KGC Probe Design](../../DESIGN_KGC_PROBE_PACKAGE.md)
|
|
413
|
-
- [SPARC Methodology](../../docs/sparc-methodology.md)
|
|
414
|
-
- [UNRDF Documentation](https://unrdf.org)
|