@unrdf/kgc-probe 26.4.2
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 +414 -0
- package/package.json +81 -0
- package/src/agents/index.mjs +1402 -0
- package/src/artifact.mjs +405 -0
- package/src/cli.mjs +932 -0
- package/src/config.mjs +115 -0
- package/src/guards.mjs +1213 -0
- package/src/index.mjs +347 -0
- package/src/merge.mjs +196 -0
- package/src/observation.mjs +193 -0
- package/src/orchestrator.mjs +315 -0
- package/src/probe.mjs +58 -0
- package/src/probes/CONCURRENCY-PROBE.md +256 -0
- package/src/probes/README.md +275 -0
- package/src/probes/concurrency.mjs +1175 -0
- package/src/probes/filesystem.mjs +731 -0
- package/src/probes/filesystem.test.mjs +244 -0
- package/src/probes/network.mjs +503 -0
- package/src/probes/performance.mjs +816 -0
- package/src/probes/persistence.mjs +785 -0
- package/src/probes/runtime.mjs +589 -0
- package/src/probes/tooling.mjs +454 -0
- package/src/probes/tooling.test.mjs +372 -0
- package/src/probes/verify-execution.mjs +131 -0
- package/src/probes/verify-guards.mjs +73 -0
- package/src/probes/wasm.mjs +715 -0
- package/src/receipt.mjs +197 -0
- package/src/receipts/index.mjs +813 -0
- package/src/reporter.example.mjs +223 -0
- package/src/reporter.mjs +555 -0
- package/src/reporters/markdown.mjs +355 -0
- package/src/reporters/rdf.mjs +383 -0
- package/src/storage/index.mjs +827 -0
- package/src/types.mjs +1028 -0
- package/src/utils/errors.mjs +397 -0
- package/src/utils/index.mjs +32 -0
- package/src/utils/logger.mjs +236 -0
- package/src/vocabulary.ttl +169 -0
package/src/config.mjs
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Configuration parsing and validation for KGC Probe
|
|
4
|
+
*
|
|
5
|
+
* Centralizes config logic with Zod validation for type safety.
|
|
6
|
+
*
|
|
7
|
+
* Design principles:
|
|
8
|
+
* - Fail fast: Invalid config = immediate error
|
|
9
|
+
* - Defaults: Sensible defaults for all options
|
|
10
|
+
* - Composable: Can be used by CLI, API, or tests
|
|
11
|
+
* - Validated: Zod schemas ensure type correctness
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
import { resolve, normalize } from 'node:path';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Probe configuration schema
|
|
19
|
+
*/
|
|
20
|
+
export const ProbeConfigSchema = z.object({
|
|
21
|
+
// Output directory for probe results
|
|
22
|
+
outputDir: z.string().default('./kgc-output'),
|
|
23
|
+
|
|
24
|
+
// Allowed filesystem roots (sandboxing)
|
|
25
|
+
allowedRoots: z.array(z.string()).default([process.cwd()]),
|
|
26
|
+
|
|
27
|
+
// Allowed network hosts (for network probes)
|
|
28
|
+
allowedHosts: z.array(z.string()).default([]),
|
|
29
|
+
|
|
30
|
+
// Time budget per agent (ms)
|
|
31
|
+
budgetMs: z.number().int().positive().default(5000),
|
|
32
|
+
|
|
33
|
+
// Benchmark sample count
|
|
34
|
+
samples: z.number().int().positive().default(10),
|
|
35
|
+
|
|
36
|
+
// Enforce timeouts
|
|
37
|
+
enforceTimeouts: z.boolean().default(true),
|
|
38
|
+
|
|
39
|
+
// Maximum timeout limit (ms)
|
|
40
|
+
maxTimeoutMs: z.number().int().positive().default(50000),
|
|
41
|
+
|
|
42
|
+
// Probe version
|
|
43
|
+
probeVersion: z.string().default('1.0.0')
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Validated probe configuration
|
|
48
|
+
*
|
|
49
|
+
* @typedef {z.infer<typeof ProbeConfigSchema>} ProbeConfig
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Parse and validate CLI options into ProbeConfig
|
|
54
|
+
*
|
|
55
|
+
* @param {Object} options - Raw CLI options
|
|
56
|
+
* @param {string} options.out - Output directory
|
|
57
|
+
* @param {string[]} options.root - Allowed root paths
|
|
58
|
+
* @param {string[]} [options.netAllow] - Allowed network hosts
|
|
59
|
+
* @param {number} options.budgetMs - Time budget (ms)
|
|
60
|
+
* @param {number} options.samples - Benchmark samples
|
|
61
|
+
* @returns {ProbeConfig}
|
|
62
|
+
*/
|
|
63
|
+
export function parseConfig(options) {
|
|
64
|
+
const config = {
|
|
65
|
+
outputDir: options.out,
|
|
66
|
+
allowedRoots: (options.root || [process.cwd()]).map(r => resolve(normalize(r))),
|
|
67
|
+
allowedHosts: options.netAllow || [],
|
|
68
|
+
budgetMs: options.budgetMs,
|
|
69
|
+
samples: options.samples,
|
|
70
|
+
enforceTimeouts: true,
|
|
71
|
+
maxTimeoutMs: (options.budgetMs || 5000) * 10,
|
|
72
|
+
probeVersion: '1.0.0'
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return ProbeConfigSchema.parse(config);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Validate ProbeConfig
|
|
80
|
+
*
|
|
81
|
+
* @param {unknown} config - Config to validate
|
|
82
|
+
* @returns {ProbeConfig}
|
|
83
|
+
* @throws {z.ZodError} if validation fails
|
|
84
|
+
*/
|
|
85
|
+
export function validateConfig(config) {
|
|
86
|
+
return ProbeConfigSchema.parse(config);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Create default ProbeConfig
|
|
91
|
+
*
|
|
92
|
+
* @returns {ProbeConfig}
|
|
93
|
+
*/
|
|
94
|
+
export function createDefaultConfig() {
|
|
95
|
+
return ProbeConfigSchema.parse({});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Merge configs (right overrides left)
|
|
100
|
+
*
|
|
101
|
+
* @param {Partial<ProbeConfig>} base - Base config
|
|
102
|
+
* @param {Partial<ProbeConfig>} override - Override config
|
|
103
|
+
* @returns {ProbeConfig}
|
|
104
|
+
*/
|
|
105
|
+
export function mergeConfigs(base, override) {
|
|
106
|
+
return ProbeConfigSchema.parse({ ...base, ...override });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export default {
|
|
110
|
+
ProbeConfigSchema,
|
|
111
|
+
parseConfig,
|
|
112
|
+
validateConfig,
|
|
113
|
+
createDefaultConfig,
|
|
114
|
+
mergeConfigs
|
|
115
|
+
};
|