evidential-protocol 2.0.0 → 3.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/dist/attestation.d.ts +80 -0
- package/dist/attestation.d.ts.map +1 -0
- package/dist/attestation.js +115 -0
- package/dist/attestation.js.map +1 -0
- package/dist/audit-ledger.d.ts +96 -0
- package/dist/audit-ledger.d.ts.map +1 -0
- package/dist/audit-ledger.js +152 -0
- package/dist/audit-ledger.js.map +1 -0
- package/dist/dormant.d.ts +59 -0
- package/dist/dormant.d.ts.map +1 -0
- package/dist/dormant.js +256 -0
- package/dist/dormant.js.map +1 -0
- package/dist/ergative.d.ts +75 -0
- package/dist/ergative.d.ts.map +1 -0
- package/dist/ergative.js +203 -0
- package/dist/ergative.js.map +1 -0
- package/dist/fingerprint.d.ts +126 -0
- package/dist/fingerprint.d.ts.map +1 -0
- package/dist/fingerprint.js +315 -0
- package/dist/fingerprint.js.map +1 -0
- package/dist/index.d.ts +14 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -3
- package/dist/index.js.map +1 -1
- package/dist/provenance.d.ts +101 -0
- package/dist/provenance.d.ts.map +1 -0
- package/dist/provenance.js +197 -0
- package/dist/provenance.js.map +1 -0
- package/dist/purity.d.ts +85 -0
- package/dist/purity.d.ts.map +1 -0
- package/dist/purity.js +124 -0
- package/dist/purity.js.map +1 -0
- package/dist/resilience.d.ts +63 -0
- package/dist/resilience.d.ts.map +1 -0
- package/dist/resilience.js +241 -0
- package/dist/resilience.js.map +1 -0
- package/dist/scoring.d.ts +87 -0
- package/dist/scoring.d.ts.map +1 -0
- package/dist/scoring.js +202 -0
- package/dist/scoring.js.map +1 -0
- package/dist/self-describing.d.ts +71 -0
- package/dist/self-describing.d.ts.map +1 -0
- package/dist/self-describing.js +153 -0
- package/dist/self-describing.js.map +1 -0
- package/dist/tests/kusunda.test.d.ts +2 -0
- package/dist/tests/kusunda.test.d.ts.map +1 -0
- package/dist/tests/kusunda.test.js +342 -0
- package/dist/tests/kusunda.test.js.map +1 -0
- package/package.json +49 -3
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EP-2: Behavioral Fingerprinting (Kusunda phonological uniqueness)
|
|
3
|
+
*
|
|
4
|
+
* Each agent develops a fingerprint from its behavioral patterns.
|
|
5
|
+
* Supports anomaly detection, cross-agent similarity scoring,
|
|
6
|
+
* and health reporting.
|
|
7
|
+
*/
|
|
8
|
+
import type { EvidenceClass } from "./types.js";
|
|
9
|
+
/** A single behavioral observation of an agent. */
|
|
10
|
+
export interface BehaviorSample {
|
|
11
|
+
/** Agent identifier. */
|
|
12
|
+
agent_id: string;
|
|
13
|
+
/** ISO 8601 timestamp of the observation. */
|
|
14
|
+
timestamp: string;
|
|
15
|
+
/** Tool that was used. */
|
|
16
|
+
tool_used: string;
|
|
17
|
+
/** Evidence class of the action's output. */
|
|
18
|
+
evidence_class: EvidenceClass;
|
|
19
|
+
/** Confidence score of the action. */
|
|
20
|
+
confidence: number;
|
|
21
|
+
/** Response time in milliseconds. */
|
|
22
|
+
response_time_ms: number;
|
|
23
|
+
/** Whether the action succeeded. */
|
|
24
|
+
success: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** Computed behavioral fingerprint for an agent. */
|
|
27
|
+
export interface AgentFingerprint {
|
|
28
|
+
/** Agent identifier. */
|
|
29
|
+
agent_id: string;
|
|
30
|
+
/** Total number of samples ingested. */
|
|
31
|
+
sample_count: number;
|
|
32
|
+
/** Average response time in milliseconds. */
|
|
33
|
+
avg_response_time: number;
|
|
34
|
+
/** Fraction of samples that failed (0.0 - 1.0). */
|
|
35
|
+
error_rate: number;
|
|
36
|
+
/** Percentage distribution across evidence classes (sums to ~100). */
|
|
37
|
+
evidence_distribution: Record<EvidenceClass, number>;
|
|
38
|
+
/** Most frequently used tools, sorted by frequency descending. */
|
|
39
|
+
top_tools: string[];
|
|
40
|
+
/** Mean confidence across all samples. */
|
|
41
|
+
confidence_mean: number;
|
|
42
|
+
/** Standard deviation of confidence. */
|
|
43
|
+
confidence_stddev: number;
|
|
44
|
+
/** ISO 8601 timestamp of the most recent sample. */
|
|
45
|
+
last_active: string;
|
|
46
|
+
}
|
|
47
|
+
/** Result of anomaly detection for a single sample. */
|
|
48
|
+
export interface AnomalyResult {
|
|
49
|
+
/** Whether the sample is anomalous. */
|
|
50
|
+
anomalous: boolean;
|
|
51
|
+
/** Human-readable reasons for the anomaly. */
|
|
52
|
+
reasons: string[];
|
|
53
|
+
/** Severity score (0.0 = normal, 1.0 = extreme anomaly). */
|
|
54
|
+
severity: number;
|
|
55
|
+
}
|
|
56
|
+
/** Health status for a single agent. */
|
|
57
|
+
export type HealthStatus = "healthy" | "degraded" | "anomalous" | "inactive";
|
|
58
|
+
/** Health report entry for a single agent. */
|
|
59
|
+
export interface AgentHealthEntry {
|
|
60
|
+
agent_id: string;
|
|
61
|
+
fingerprint: AgentFingerprint;
|
|
62
|
+
status: HealthStatus;
|
|
63
|
+
issues: string[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Behavioral fingerprinting engine.
|
|
67
|
+
*
|
|
68
|
+
* Ingests behavioral samples, computes fingerprints, detects anomalies
|
|
69
|
+
* by comparing new samples against established behavioral baselines,
|
|
70
|
+
* and measures cross-agent similarity.
|
|
71
|
+
*/
|
|
72
|
+
export declare class FingerprintEngine {
|
|
73
|
+
private samples;
|
|
74
|
+
/** Total number of samples across all agents. */
|
|
75
|
+
get totalSamples(): number;
|
|
76
|
+
/** Total number of distinct agents tracked. */
|
|
77
|
+
get agentCount(): number;
|
|
78
|
+
/** Add a behavioral observation. */
|
|
79
|
+
ingest(sample: BehaviorSample): void;
|
|
80
|
+
/**
|
|
81
|
+
* Compute the current fingerprint for an agent.
|
|
82
|
+
*
|
|
83
|
+
* @returns The fingerprint, or undefined if no samples exist.
|
|
84
|
+
*/
|
|
85
|
+
getFingerprint(agentId: string): AgentFingerprint | undefined;
|
|
86
|
+
/** Compute fingerprints for all tracked agents. */
|
|
87
|
+
getAllFingerprints(): AgentFingerprint[];
|
|
88
|
+
/**
|
|
89
|
+
* Detect whether a new sample is anomalous for the given agent.
|
|
90
|
+
*
|
|
91
|
+
* Checks:
|
|
92
|
+
* - Response time > 2x established average
|
|
93
|
+
* - Error rate spike > 3x established rate (via recent window)
|
|
94
|
+
* - Evidence class distribution shift > 30%
|
|
95
|
+
* - Confidence drop > 0.2 below established mean
|
|
96
|
+
*
|
|
97
|
+
* @returns Anomaly result. If the agent has fewer than 5 samples,
|
|
98
|
+
* returns non-anomalous (insufficient baseline).
|
|
99
|
+
*/
|
|
100
|
+
detectAnomaly(agentId: string, sample: BehaviorSample): AnomalyResult;
|
|
101
|
+
/**
|
|
102
|
+
* Compute a similarity score between two agents (0.0 - 1.0).
|
|
103
|
+
*
|
|
104
|
+
* Compares: response time profile, error rate, evidence distribution,
|
|
105
|
+
* confidence mean, and tool overlap.
|
|
106
|
+
*
|
|
107
|
+
* @returns Similarity score, or 0 if either agent has no data.
|
|
108
|
+
*/
|
|
109
|
+
similarity(agentA: string, agentB: string): number;
|
|
110
|
+
/**
|
|
111
|
+
* Generate a health report for all tracked agents.
|
|
112
|
+
*
|
|
113
|
+
* Status classification:
|
|
114
|
+
* - inactive: no samples in last 24 hours
|
|
115
|
+
* - anomalous: error rate > 30% or avg confidence < 0.3
|
|
116
|
+
* - degraded: error rate > 15% or avg confidence < 0.5
|
|
117
|
+
* - healthy: otherwise
|
|
118
|
+
*/
|
|
119
|
+
getHealthReport(): AgentHealthEntry[];
|
|
120
|
+
private computeFingerprint;
|
|
121
|
+
/** Cosine similarity between two evidence distributions. */
|
|
122
|
+
private cosineDistribution;
|
|
123
|
+
/** Jaccard similarity between two sets. */
|
|
124
|
+
private jaccardSimilarity;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=fingerprint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":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,UAAU,CAAC;AAE7E,8CAA8C;AAC9C,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,gBAAgB,CAAC;IAC9B,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;;;;GAMG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,OAAO,CAAuC;IAEtD,iDAAiD;IACjD,IAAI,YAAY,IAAI,MAAM,CAMzB;IAED,+CAA+C;IAC/C,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,oCAAoC;IACpC,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IASpC;;;;OAIG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAM7D,mDAAmD;IACnD,kBAAkB,IAAI,gBAAgB,EAAE;IAUxC;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,aAAa;IAwErE;;;;;;;OAOG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;IAmClD;;;;;;;;OAQG;IACH,eAAe,IAAI,gBAAgB,EAAE;IAsDrC,OAAO,CAAC,kBAAkB;IAwF1B,4DAA4D;IAC5D,OAAO,CAAC,kBAAkB;IAmB1B,2CAA2C;IAC3C,OAAO,CAAC,iBAAiB;CAY1B"}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EP-2: Behavioral Fingerprinting (Kusunda phonological uniqueness)
|
|
3
|
+
*
|
|
4
|
+
* Each agent develops a fingerprint from its behavioral patterns.
|
|
5
|
+
* Supports anomaly detection, cross-agent similarity scoring,
|
|
6
|
+
* and health reporting.
|
|
7
|
+
*/
|
|
8
|
+
/** All evidence classes for iteration. */
|
|
9
|
+
const ALL_CLASSES = [
|
|
10
|
+
"direct",
|
|
11
|
+
"inferred",
|
|
12
|
+
"reported",
|
|
13
|
+
"conjecture",
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* Behavioral fingerprinting engine.
|
|
17
|
+
*
|
|
18
|
+
* Ingests behavioral samples, computes fingerprints, detects anomalies
|
|
19
|
+
* by comparing new samples against established behavioral baselines,
|
|
20
|
+
* and measures cross-agent similarity.
|
|
21
|
+
*/
|
|
22
|
+
export class FingerprintEngine {
|
|
23
|
+
samples = new Map();
|
|
24
|
+
/** Total number of samples across all agents. */
|
|
25
|
+
get totalSamples() {
|
|
26
|
+
let count = 0;
|
|
27
|
+
for (const arr of this.samples.values()) {
|
|
28
|
+
count += arr.length;
|
|
29
|
+
}
|
|
30
|
+
return count;
|
|
31
|
+
}
|
|
32
|
+
/** Total number of distinct agents tracked. */
|
|
33
|
+
get agentCount() {
|
|
34
|
+
return this.samples.size;
|
|
35
|
+
}
|
|
36
|
+
/** Add a behavioral observation. */
|
|
37
|
+
ingest(sample) {
|
|
38
|
+
const arr = this.samples.get(sample.agent_id);
|
|
39
|
+
if (arr) {
|
|
40
|
+
arr.push(sample);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.samples.set(sample.agent_id, [sample]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Compute the current fingerprint for an agent.
|
|
48
|
+
*
|
|
49
|
+
* @returns The fingerprint, or undefined if no samples exist.
|
|
50
|
+
*/
|
|
51
|
+
getFingerprint(agentId) {
|
|
52
|
+
const agentSamples = this.samples.get(agentId);
|
|
53
|
+
if (!agentSamples || agentSamples.length === 0)
|
|
54
|
+
return undefined;
|
|
55
|
+
return this.computeFingerprint(agentId, agentSamples);
|
|
56
|
+
}
|
|
57
|
+
/** Compute fingerprints for all tracked agents. */
|
|
58
|
+
getAllFingerprints() {
|
|
59
|
+
const results = [];
|
|
60
|
+
for (const [agentId, agentSamples] of this.samples) {
|
|
61
|
+
if (agentSamples.length > 0) {
|
|
62
|
+
results.push(this.computeFingerprint(agentId, agentSamples));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return results;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Detect whether a new sample is anomalous for the given agent.
|
|
69
|
+
*
|
|
70
|
+
* Checks:
|
|
71
|
+
* - Response time > 2x established average
|
|
72
|
+
* - Error rate spike > 3x established rate (via recent window)
|
|
73
|
+
* - Evidence class distribution shift > 30%
|
|
74
|
+
* - Confidence drop > 0.2 below established mean
|
|
75
|
+
*
|
|
76
|
+
* @returns Anomaly result. If the agent has fewer than 5 samples,
|
|
77
|
+
* returns non-anomalous (insufficient baseline).
|
|
78
|
+
*/
|
|
79
|
+
detectAnomaly(agentId, sample) {
|
|
80
|
+
const baseline = this.getFingerprint(agentId);
|
|
81
|
+
if (!baseline || baseline.sample_count < 5) {
|
|
82
|
+
return { anomalous: false, reasons: [], severity: 0 };
|
|
83
|
+
}
|
|
84
|
+
const reasons = [];
|
|
85
|
+
let severity = 0;
|
|
86
|
+
// Check 1: Response time > 2x average
|
|
87
|
+
if (sample.response_time_ms > baseline.avg_response_time * 2) {
|
|
88
|
+
const ratio = sample.response_time_ms / baseline.avg_response_time;
|
|
89
|
+
reasons.push(`Response time ${sample.response_time_ms}ms is ${ratio.toFixed(1)}x the average ${baseline.avg_response_time.toFixed(0)}ms`);
|
|
90
|
+
severity += Math.min((ratio - 2) / 3, 0.4);
|
|
91
|
+
}
|
|
92
|
+
// Check 2: Error rate spike > 3x (check recent 10-sample window)
|
|
93
|
+
if (!sample.success) {
|
|
94
|
+
const agentSamples = this.samples.get(agentId);
|
|
95
|
+
const recentWindow = agentSamples.slice(-10);
|
|
96
|
+
const recentErrorRate = recentWindow.filter((s) => !s.success).length / recentWindow.length;
|
|
97
|
+
if (baseline.error_rate > 0 &&
|
|
98
|
+
recentErrorRate > baseline.error_rate * 3) {
|
|
99
|
+
reasons.push(`Recent error rate ${(recentErrorRate * 100).toFixed(1)}% is >${(baseline.error_rate * 300).toFixed(0)}% of baseline ${(baseline.error_rate * 100).toFixed(1)}%`);
|
|
100
|
+
severity += 0.3;
|
|
101
|
+
}
|
|
102
|
+
else if (baseline.error_rate === 0 && recentErrorRate > 0.3) {
|
|
103
|
+
reasons.push(`Error rate spike to ${(recentErrorRate * 100).toFixed(1)}% from a previously error-free baseline`);
|
|
104
|
+
severity += 0.3;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Check 3: Evidence class distribution shift > 30%
|
|
108
|
+
const classPct = baseline.evidence_distribution[sample.evidence_class];
|
|
109
|
+
if (classPct < 5) {
|
|
110
|
+
// This class is rarely used — potential distribution shift
|
|
111
|
+
const totalOtherPct = 100 - classPct;
|
|
112
|
+
if (totalOtherPct > 30) {
|
|
113
|
+
reasons.push(`Evidence class "${sample.evidence_class}" represents only ${classPct.toFixed(1)}% of established behavior`);
|
|
114
|
+
severity += 0.2;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Check 4: Confidence drop > 0.2 below mean
|
|
118
|
+
const confidenceDrop = baseline.confidence_mean - sample.confidence;
|
|
119
|
+
if (confidenceDrop > 0.2) {
|
|
120
|
+
reasons.push(`Confidence ${sample.confidence.toFixed(3)} is ${confidenceDrop.toFixed(3)} below mean ${baseline.confidence_mean.toFixed(3)}`);
|
|
121
|
+
severity += Math.min(confidenceDrop / 0.5, 0.3);
|
|
122
|
+
}
|
|
123
|
+
severity = Math.min(Math.round(severity * 1000) / 1000, 1.0);
|
|
124
|
+
return {
|
|
125
|
+
anomalous: reasons.length > 0,
|
|
126
|
+
reasons,
|
|
127
|
+
severity,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Compute a similarity score between two agents (0.0 - 1.0).
|
|
132
|
+
*
|
|
133
|
+
* Compares: response time profile, error rate, evidence distribution,
|
|
134
|
+
* confidence mean, and tool overlap.
|
|
135
|
+
*
|
|
136
|
+
* @returns Similarity score, or 0 if either agent has no data.
|
|
137
|
+
*/
|
|
138
|
+
similarity(agentA, agentB) {
|
|
139
|
+
const fpA = this.getFingerprint(agentA);
|
|
140
|
+
const fpB = this.getFingerprint(agentB);
|
|
141
|
+
if (!fpA || !fpB)
|
|
142
|
+
return 0;
|
|
143
|
+
// Component 1: Response time similarity (weight 0.2)
|
|
144
|
+
const maxRt = Math.max(fpA.avg_response_time, fpB.avg_response_time, 1);
|
|
145
|
+
const rtSim = 1 - Math.abs(fpA.avg_response_time - fpB.avg_response_time) / maxRt;
|
|
146
|
+
// Component 2: Error rate similarity (weight 0.15)
|
|
147
|
+
const erSim = 1 - Math.abs(fpA.error_rate - fpB.error_rate);
|
|
148
|
+
// Component 3: Evidence distribution similarity via cosine (weight 0.3)
|
|
149
|
+
const distSim = this.cosineDistribution(fpA.evidence_distribution, fpB.evidence_distribution);
|
|
150
|
+
// Component 4: Confidence similarity (weight 0.2)
|
|
151
|
+
const confSim = 1 - Math.abs(fpA.confidence_mean - fpB.confidence_mean);
|
|
152
|
+
// Component 5: Tool overlap via Jaccard (weight 0.15)
|
|
153
|
+
const toolSim = this.jaccardSimilarity(new Set(fpA.top_tools), new Set(fpB.top_tools));
|
|
154
|
+
const weighted = rtSim * 0.2 + erSim * 0.15 + distSim * 0.3 + confSim * 0.2 + toolSim * 0.15;
|
|
155
|
+
return Math.round(Math.max(0, Math.min(1, weighted)) * 1000) / 1000;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Generate a health report for all tracked agents.
|
|
159
|
+
*
|
|
160
|
+
* Status classification:
|
|
161
|
+
* - inactive: no samples in last 24 hours
|
|
162
|
+
* - anomalous: error rate > 30% or avg confidence < 0.3
|
|
163
|
+
* - degraded: error rate > 15% or avg confidence < 0.5
|
|
164
|
+
* - healthy: otherwise
|
|
165
|
+
*/
|
|
166
|
+
getHealthReport() {
|
|
167
|
+
const now = Date.now();
|
|
168
|
+
const twentyFourHours = 24 * 60 * 60 * 1000;
|
|
169
|
+
const report = [];
|
|
170
|
+
for (const [agentId, agentSamples] of this.samples) {
|
|
171
|
+
if (agentSamples.length === 0)
|
|
172
|
+
continue;
|
|
173
|
+
const fp = this.computeFingerprint(agentId, agentSamples);
|
|
174
|
+
const issues = [];
|
|
175
|
+
let status = "healthy";
|
|
176
|
+
// Check inactivity
|
|
177
|
+
const lastActiveMs = new Date(fp.last_active).getTime();
|
|
178
|
+
if (now - lastActiveMs > twentyFourHours) {
|
|
179
|
+
status = "inactive";
|
|
180
|
+
const hoursAgo = ((now - lastActiveMs) / (60 * 60 * 1000)).toFixed(1);
|
|
181
|
+
issues.push(`No activity for ${hoursAgo} hours`);
|
|
182
|
+
}
|
|
183
|
+
// Check error rate
|
|
184
|
+
if (fp.error_rate > 0.3) {
|
|
185
|
+
status = "anomalous";
|
|
186
|
+
issues.push(`Error rate ${(fp.error_rate * 100).toFixed(1)}% exceeds 30% threshold`);
|
|
187
|
+
}
|
|
188
|
+
else if (fp.error_rate > 0.15) {
|
|
189
|
+
if (status === "healthy")
|
|
190
|
+
status = "degraded";
|
|
191
|
+
issues.push(`Error rate ${(fp.error_rate * 100).toFixed(1)}% exceeds 15% threshold`);
|
|
192
|
+
}
|
|
193
|
+
// Check confidence
|
|
194
|
+
if (fp.confidence_mean < 0.3) {
|
|
195
|
+
status = "anomalous";
|
|
196
|
+
issues.push(`Mean confidence ${fp.confidence_mean.toFixed(3)} below 0.3 threshold`);
|
|
197
|
+
}
|
|
198
|
+
else if (fp.confidence_mean < 0.5) {
|
|
199
|
+
if (status === "healthy")
|
|
200
|
+
status = "degraded";
|
|
201
|
+
issues.push(`Mean confidence ${fp.confidence_mean.toFixed(3)} below 0.5 threshold`);
|
|
202
|
+
}
|
|
203
|
+
report.push({ agent_id: agentId, fingerprint: fp, status, issues });
|
|
204
|
+
}
|
|
205
|
+
return report;
|
|
206
|
+
}
|
|
207
|
+
// ---- Internal computation ----
|
|
208
|
+
computeFingerprint(agentId, agentSamples) {
|
|
209
|
+
const n = agentSamples.length;
|
|
210
|
+
// Response time
|
|
211
|
+
let rtSum = 0;
|
|
212
|
+
for (const s of agentSamples) {
|
|
213
|
+
rtSum += s.response_time_ms;
|
|
214
|
+
}
|
|
215
|
+
const avgResponseTime = rtSum / n;
|
|
216
|
+
// Error rate
|
|
217
|
+
let errorCount = 0;
|
|
218
|
+
for (const s of agentSamples) {
|
|
219
|
+
if (!s.success)
|
|
220
|
+
errorCount++;
|
|
221
|
+
}
|
|
222
|
+
const errorRate = errorCount / n;
|
|
223
|
+
// Evidence distribution (percentages)
|
|
224
|
+
const classCounts = {
|
|
225
|
+
direct: 0,
|
|
226
|
+
inferred: 0,
|
|
227
|
+
reported: 0,
|
|
228
|
+
conjecture: 0,
|
|
229
|
+
};
|
|
230
|
+
for (const s of agentSamples) {
|
|
231
|
+
classCounts[s.evidence_class]++;
|
|
232
|
+
}
|
|
233
|
+
const evidenceDistribution = {
|
|
234
|
+
direct: 0,
|
|
235
|
+
inferred: 0,
|
|
236
|
+
reported: 0,
|
|
237
|
+
conjecture: 0,
|
|
238
|
+
};
|
|
239
|
+
for (const cls of ALL_CLASSES) {
|
|
240
|
+
evidenceDistribution[cls] =
|
|
241
|
+
Math.round((classCounts[cls] / n) * 1000) / 10;
|
|
242
|
+
}
|
|
243
|
+
// Top tools by frequency
|
|
244
|
+
const toolCounts = new Map();
|
|
245
|
+
for (const s of agentSamples) {
|
|
246
|
+
toolCounts.set(s.tool_used, (toolCounts.get(s.tool_used) ?? 0) + 1);
|
|
247
|
+
}
|
|
248
|
+
const topTools = Array.from(toolCounts.entries())
|
|
249
|
+
.sort((a, b) => b[1] - a[1])
|
|
250
|
+
.map(([tool]) => tool);
|
|
251
|
+
// Confidence mean and stddev
|
|
252
|
+
let confSum = 0;
|
|
253
|
+
for (const s of agentSamples) {
|
|
254
|
+
confSum += s.confidence;
|
|
255
|
+
}
|
|
256
|
+
const confidenceMean = confSum / n;
|
|
257
|
+
let varianceSum = 0;
|
|
258
|
+
for (const s of agentSamples) {
|
|
259
|
+
const diff = s.confidence - confidenceMean;
|
|
260
|
+
varianceSum += diff * diff;
|
|
261
|
+
}
|
|
262
|
+
const confidenceStddev = Math.sqrt(varianceSum / n);
|
|
263
|
+
// Last active
|
|
264
|
+
let lastActiveTs = "";
|
|
265
|
+
let lastActiveMs = 0;
|
|
266
|
+
for (const s of agentSamples) {
|
|
267
|
+
const ms = new Date(s.timestamp).getTime();
|
|
268
|
+
if (ms > lastActiveMs) {
|
|
269
|
+
lastActiveMs = ms;
|
|
270
|
+
lastActiveTs = s.timestamp;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return {
|
|
274
|
+
agent_id: agentId,
|
|
275
|
+
sample_count: n,
|
|
276
|
+
avg_response_time: Math.round(avgResponseTime * 100) / 100,
|
|
277
|
+
error_rate: Math.round(errorRate * 10000) / 10000,
|
|
278
|
+
evidence_distribution: evidenceDistribution,
|
|
279
|
+
top_tools: topTools,
|
|
280
|
+
confidence_mean: Math.round(confidenceMean * 10000) / 10000,
|
|
281
|
+
confidence_stddev: Math.round(confidenceStddev * 10000) / 10000,
|
|
282
|
+
last_active: lastActiveTs,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
/** Cosine similarity between two evidence distributions. */
|
|
286
|
+
cosineDistribution(a, b) {
|
|
287
|
+
let dot = 0;
|
|
288
|
+
let magA = 0;
|
|
289
|
+
let magB = 0;
|
|
290
|
+
for (const cls of ALL_CLASSES) {
|
|
291
|
+
dot += a[cls] * b[cls];
|
|
292
|
+
magA += a[cls] * a[cls];
|
|
293
|
+
magB += b[cls] * b[cls];
|
|
294
|
+
}
|
|
295
|
+
const denom = Math.sqrt(magA) * Math.sqrt(magB);
|
|
296
|
+
if (denom === 0)
|
|
297
|
+
return 0;
|
|
298
|
+
return dot / denom;
|
|
299
|
+
}
|
|
300
|
+
/** Jaccard similarity between two sets. */
|
|
301
|
+
jaccardSimilarity(a, b) {
|
|
302
|
+
if (a.size === 0 && b.size === 0)
|
|
303
|
+
return 1;
|
|
304
|
+
let intersection = 0;
|
|
305
|
+
for (const item of a) {
|
|
306
|
+
if (b.has(item))
|
|
307
|
+
intersection++;
|
|
308
|
+
}
|
|
309
|
+
const union = a.size + b.size - intersection;
|
|
310
|
+
if (union === 0)
|
|
311
|
+
return 1;
|
|
312
|
+
return intersection / union;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
//# sourceMappingURL=fingerprint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fingerprint.js","sourceRoot":"","sources":["../src/fingerprint.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,0CAA0C;AAC1C,MAAM,WAAW,GAAoB;IACnC,QAAQ;IACR,UAAU;IACV,UAAU;IACV,YAAY;CACb,CAAC;AA+DF;;;;;;GAMG;AACH,MAAM,OAAO,iBAAiB;IACpB,OAAO,GAAG,IAAI,GAAG,EAA4B,CAAC;IAEtD,iDAAiD;IACjD,IAAI,YAAY;QACd,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YACxC,KAAK,IAAI,GAAG,CAAC,MAAM,CAAC;QACtB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,+CAA+C;IAC/C,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED,oCAAoC;IACpC,MAAM,CAAC,MAAsB;QAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,GAAG,EAAE,CAAC;YACR,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9C,CAAC;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;QAED,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,GAAG,YAAY,CAAC;QAC7C,IAAI,KAAK,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC;QAC1B,OAAO,YAAY,GAAG,KAAK,CAAC;IAC9B,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* evidential-protocol — EP-1
|
|
2
|
+
* evidential-protocol — EP-1 + Kusunda Extensions
|
|
3
3
|
*
|
|
4
|
-
* Matsés-inspired evidential metadata
|
|
5
|
-
*
|
|
4
|
+
* Matsés-inspired evidential metadata + Kusunda-inspired
|
|
5
|
+
* system architecture for AI agent systems.
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
@@ -13,5 +13,15 @@ export { wrapToolResult, buildAgentResponse, directClaim, inferredClaim, reporte
|
|
|
13
13
|
export { McpEvidenceWrapper, EvidenceCache, createMcpMiddleware, type ToolHandler, type WrappedToolResult, type WrapperConfig, type McpToolCall, type McpToolResponse, } from "./mcp-wrapper.js";
|
|
14
14
|
export { AgentOutputBuilder, runAgentTeam, runPipeline, generateReport, type AgentIdentity, type TeamRunResult, type PipelineStep, } from "./agent-wrapper.js";
|
|
15
15
|
export { isClaim, stripMarkers, analyzeContent, tagSentence, autoTag, publishGate, renderForReview, type TaggedSentence, type ContentAnalysis, type PublishGateResult, } from "./content.js";
|
|
16
|
-
export { extractAudit, buildDashboardData, renderDashboardHtml, type AuditEntry, type DashboardData, type ProducerSummary, } from "./dashboard.js";
|
|
16
|
+
export { extractAudit, buildDashboardData, renderDashboardHtml, type AuditEntry as DashboardAuditEntry, type DashboardData, type ProducerSummary, } from "./dashboard.js";
|
|
17
|
+
export { AuditLedger, type AuditEntry, type AuditAction, } from "./audit-ledger.js";
|
|
18
|
+
export { ProvenanceChain, type ProvenanceNode, } from "./provenance.js";
|
|
19
|
+
export { FingerprintEngine, type BehaviorSample, type AgentFingerprint, type AnomalyResult, type HealthStatus, type AgentHealthEntry, } from "./fingerprint.js";
|
|
20
|
+
export { ErgativeGate, meetsEvidenceRequirement, type AgentRole, type ToolPermission, type PermissionManifest, } from "./ergative.js";
|
|
21
|
+
export { PurityScanner, computePurityScore, type SourceOrigin, type ContentSegment, type PurityAnalysis, } from "./purity.js";
|
|
22
|
+
export { AttestationBuilder, formatForSigning, attestationToMemo, type ContentAttestation, } from "./attestation.js";
|
|
23
|
+
export { ResilienceAnalyzer, type SystemComponent, type ResilienceReport, } from "./resilience.js";
|
|
24
|
+
export { DormantScanner, type AssetProfile, type DormantScore, } from "./dormant.js";
|
|
25
|
+
export { ScoringEngine, type ScoringAxis, type ContinuousScore, } from "./scoring.js";
|
|
26
|
+
export { PayloadBuilder, isExpired as isPayloadExpired, describe as describePayload, validate as validatePayload, type PayloadMeta, type SelfDescribingPayload, } from "./self-describing.js";
|
|
17
27
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,iBAAiB,EACjB,aAAa,EACb,cAAc,GACf,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,WAAW,EACX,aAAa,EACb,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,MAAM,EACN,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,aAAa,EACb,eAAe,EACf,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,OAAO,EACP,YAAY,EACZ,cAAc,EACd,WAAW,EACX,OAAO,EACP,WAAW,EACX,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,iBAAiB,GACvB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B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
2
|
-
* evidential-protocol — EP-1
|
|
2
|
+
* evidential-protocol — EP-1 + Kusunda Extensions
|
|
3
3
|
*
|
|
4
|
-
* Matsés-inspired evidential metadata
|
|
5
|
-
*
|
|
4
|
+
* Matsés-inspired evidential metadata + Kusunda-inspired
|
|
5
|
+
* system architecture for AI agent systems.
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
@@ -22,4 +22,25 @@ export { AgentOutputBuilder, runAgentTeam, runPipeline, generateReport, } from "
|
|
|
22
22
|
export { isClaim, stripMarkers, analyzeContent, tagSentence, autoTag, publishGate, renderForReview, } from "./content.js";
|
|
23
23
|
// Dashboard & Audit Trail (Phase 5)
|
|
24
24
|
export { extractAudit, buildDashboardData, renderDashboardHtml, } from "./dashboard.js";
|
|
25
|
+
// --- Kusunda Extensions ---
|
|
26
|
+
// K1: Bilateral Audit Ledger (dual-person marking)
|
|
27
|
+
export { AuditLedger, } from "./audit-ledger.js";
|
|
28
|
+
// K2: Root Provenance Tracing (pre-family lineage)
|
|
29
|
+
export { ProvenanceChain, } from "./provenance.js";
|
|
30
|
+
// K3: Behavioral Fingerprinting (phonological uniqueness)
|
|
31
|
+
export { FingerprintEngine, } from "./fingerprint.js";
|
|
32
|
+
// K4: Ergative Permission Model (ergative alignment)
|
|
33
|
+
export { ErgativeGate, meetsEvidenceRequirement, } from "./ergative.js";
|
|
34
|
+
// K5: Content Contamination Detection (loanword resistance)
|
|
35
|
+
export { PurityScanner, computePurityScore, } from "./purity.js";
|
|
36
|
+
// K6: Content Attestation (isolate identity)
|
|
37
|
+
export { AttestationBuilder, formatForSigning, attestationToMemo, } from "./attestation.js";
|
|
38
|
+
// K7: Bus Factor / SPOF Detection (last-speaker problem)
|
|
39
|
+
export { ResilienceAnalyzer, } from "./resilience.js";
|
|
40
|
+
// K8: Dormant Asset Scanner (rediscovery)
|
|
41
|
+
export { DormantScanner, } from "./dormant.js";
|
|
42
|
+
// K9: Continuous Scoring (no-gender / bias-free)
|
|
43
|
+
export { ScoringEngine, } from "./scoring.js";
|
|
44
|
+
// K10: Self-Describing Payloads (verb morphology)
|
|
45
|
+
export { PayloadBuilder, isExpired as isPayloadExpired, describe as describePayload, validate as validatePayload, } from "./self-describing.js";
|
|
25
46
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,aAAa;AACb,OAAO,EAWL,iBAAiB,EACjB,aAAa,EACb,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,8BAA8B;AAC9B,OAAO,EACL,WAAW,EACX,aAAa,EACb,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,MAAM,EACN,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AAErB,aAAa;AACb,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,cAAc,GAGf,MAAM,eAAe,CAAC;AAEvB,aAAa;AACb,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,aAAa,EACb,eAAe,EACf,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,gBAAgB,GAIjB,MAAM,iBAAiB,CAAC;AAEzB,wBAAwB;AACxB,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,mBAAmB,GAMpB,MAAM,kBAAkB,CAAC;AAE1B,mCAAmC;AACnC,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,cAAc,GAIf,MAAM,oBAAoB,CAAC;AAE5B,6BAA6B;AAC7B,OAAO,EACL,OAAO,EACP,YAAY,EACZ,cAAc,EACd,WAAW,EACX,OAAO,EACP,WAAW,EACX,eAAe,GAIhB,MAAM,cAAc,CAAC;AAEtB,oCAAoC;AACpC,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,GAIpB,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,aAAa;AACb,OAAO,EAWL,iBAAiB,EACjB,aAAa,EACb,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,8BAA8B;AAC9B,OAAO,EACL,WAAW,EACX,aAAa,EACb,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,MAAM,EACN,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AAErB,aAAa;AACb,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,cAAc,GAGf,MAAM,eAAe,CAAC;AAEvB,aAAa;AACb,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,aAAa,EACb,eAAe,EACf,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,gBAAgB,GAIjB,MAAM,iBAAiB,CAAC;AAEzB,wBAAwB;AACxB,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,mBAAmB,GAMpB,MAAM,kBAAkB,CAAC;AAE1B,mCAAmC;AACnC,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,cAAc,GAIf,MAAM,oBAAoB,CAAC;AAE5B,6BAA6B;AAC7B,OAAO,EACL,OAAO,EACP,YAAY,EACZ,cAAc,EACd,WAAW,EACX,OAAO,EACP,WAAW,EACX,eAAe,GAIhB,MAAM,cAAc,CAAC;AAEtB,oCAAoC;AACpC,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,GAIpB,MAAM,gBAAgB,CAAC;AAExB,6BAA6B;AAE7B,mDAAmD;AACnD,OAAO,EACL,WAAW,GAGZ,MAAM,mBAAmB,CAAC;AAE3B,mDAAmD;AACnD,OAAO,EACL,eAAe,GAEhB,MAAM,iBAAiB,CAAC;AAEzB,0DAA0D;AAC1D,OAAO,EACL,iBAAiB,GAMlB,MAAM,kBAAkB,CAAC;AAE1B,qDAAqD;AACrD,OAAO,EACL,YAAY,EACZ,wBAAwB,GAIzB,MAAM,eAAe,CAAC;AAEvB,4DAA4D;AAC5D,OAAO,EACL,aAAa,EACb,kBAAkB,GAInB,MAAM,aAAa,CAAC;AAErB,6CAA6C;AAC7C,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,GAElB,MAAM,kBAAkB,CAAC;AAE1B,yDAAyD;AACzD,OAAO,EACL,kBAAkB,GAGnB,MAAM,iBAAiB,CAAC;AAEzB,0CAA0C;AAC1C,OAAO,EACL,cAAc,GAGf,MAAM,cAAc,CAAC;AAEtB,iDAAiD;AACjD,OAAO,EACL,aAAa,GAGd,MAAM,cAAc,CAAC;AAEtB,kDAAkD;AAClD,OAAO,EACL,cAAc,EACd,SAAS,IAAI,gBAAgB,EAC7B,QAAQ,IAAI,eAAe,EAC3B,QAAQ,IAAI,eAAe,GAG5B,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EP-2: Root Provenance Tracing (Kusunda pre-family lineage)
|
|
3
|
+
*
|
|
4
|
+
* Traces any claim back through the full agent chain to its absolute
|
|
5
|
+
* origin. Supports depth queries, weakest-link analysis, compounding
|
|
6
|
+
* confidence degradation, and Mermaid diagram rendering.
|
|
7
|
+
*/
|
|
8
|
+
import type { Evidence, EvidenceClass } from "./types.js";
|
|
9
|
+
/** A single node in the provenance chain. */
|
|
10
|
+
export interface ProvenanceNode {
|
|
11
|
+
/** Unique node identifier. */
|
|
12
|
+
id: string;
|
|
13
|
+
/** The claim or assertion at this point in the chain. */
|
|
14
|
+
claim: string;
|
|
15
|
+
/** Evidence supporting this claim. */
|
|
16
|
+
evidence: Evidence;
|
|
17
|
+
/** Agent or tool that produced this node. */
|
|
18
|
+
producer: string;
|
|
19
|
+
/** ISO 8601 timestamp of when this node was created. */
|
|
20
|
+
timestamp: string;
|
|
21
|
+
/** ID of the parent node, or null if this is a root. */
|
|
22
|
+
parent_id: string | null;
|
|
23
|
+
}
|
|
24
|
+
/** Serialized form for persistence. */
|
|
25
|
+
export interface ProvenanceChainSnapshot {
|
|
26
|
+
version: "1.0";
|
|
27
|
+
nodes: ProvenanceNode[];
|
|
28
|
+
created_at: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Manages a directed acyclic provenance chain.
|
|
32
|
+
*
|
|
33
|
+
* Each node records a claim, its evidence, and a link to its parent.
|
|
34
|
+
* Root nodes represent original observations; leaves are terminal claims.
|
|
35
|
+
*/
|
|
36
|
+
export declare class ProvenanceChain {
|
|
37
|
+
private nodes;
|
|
38
|
+
private childrenIndex;
|
|
39
|
+
/** Total number of nodes in the chain. */
|
|
40
|
+
get size(): number;
|
|
41
|
+
/**
|
|
42
|
+
* Add a new node to the provenance chain.
|
|
43
|
+
*
|
|
44
|
+
* @param claim - The assertion being made.
|
|
45
|
+
* @param evidence - Evidence supporting the claim.
|
|
46
|
+
* @param producer - Agent or tool that produced this node.
|
|
47
|
+
* @param parentId - ID of the parent node (omit for root nodes).
|
|
48
|
+
* @returns The created ProvenanceNode.
|
|
49
|
+
* @throws If parentId is provided but does not exist in the chain.
|
|
50
|
+
*/
|
|
51
|
+
addNode(claim: string, evidence: Evidence, producer: string, parentId?: string): ProvenanceNode;
|
|
52
|
+
/** Get a node by ID, or undefined if not found. */
|
|
53
|
+
getNode(nodeId: string): ProvenanceNode | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Walk back from a node to the absolute origin.
|
|
56
|
+
*
|
|
57
|
+
* @returns Array of nodes from the given node to the root (inclusive).
|
|
58
|
+
* @throws If nodeId does not exist.
|
|
59
|
+
*/
|
|
60
|
+
traceToRoot(nodeId: string): ProvenanceNode[];
|
|
61
|
+
/**
|
|
62
|
+
* Get the depth (number of hops from the root) for a node.
|
|
63
|
+
*
|
|
64
|
+
* Root nodes have depth 0.
|
|
65
|
+
* @throws If nodeId does not exist.
|
|
66
|
+
*/
|
|
67
|
+
getDepth(nodeId: string): number;
|
|
68
|
+
/** Get all root nodes (original observations with no parent). */
|
|
69
|
+
getRoots(): ProvenanceNode[];
|
|
70
|
+
/** Get all leaf nodes (terminal claims with no children). */
|
|
71
|
+
getLeaves(): ProvenanceNode[];
|
|
72
|
+
/**
|
|
73
|
+
* Find the weakest evidence class in the chain from a node to its root.
|
|
74
|
+
*
|
|
75
|
+
* @returns The lowest evidence class found along the path.
|
|
76
|
+
* @throws If nodeId does not exist.
|
|
77
|
+
*/
|
|
78
|
+
weakestLink(nodeId: string): EvidenceClass;
|
|
79
|
+
/**
|
|
80
|
+
* Compute compounding confidence through the chain to root.
|
|
81
|
+
*
|
|
82
|
+
* Each hop multiplies confidence, modeling degradation: the further
|
|
83
|
+
* from the source, the lower the total confidence.
|
|
84
|
+
*
|
|
85
|
+
* @returns Compounded confidence score (0.0 - 1.0).
|
|
86
|
+
* @throws If nodeId does not exist.
|
|
87
|
+
*/
|
|
88
|
+
chainConfidence(nodeId: string): number;
|
|
89
|
+
/**
|
|
90
|
+
* Render the entire provenance chain as a Mermaid flowchart.
|
|
91
|
+
*
|
|
92
|
+
* Direction: bottom-to-top (roots at bottom, leaves at top).
|
|
93
|
+
*/
|
|
94
|
+
toMermaid(): string;
|
|
95
|
+
/** Serialize the chain to a JSON-safe snapshot. */
|
|
96
|
+
toJSON(): ProvenanceChainSnapshot;
|
|
97
|
+
/** Restore a chain from a serialized snapshot. */
|
|
98
|
+
static fromJSON(snapshot: ProvenanceChainSnapshot): ProvenanceChain;
|
|
99
|
+
private escapeMermaid;
|
|
100
|
+
}
|
|
101
|
+
//# s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