Repository navigation
Expand file tree
/
Copy pathmultiAgentNegotiator.ts
More file actions
111 lines (104 loc) · 6.1 KB
/
Copy pathmultiAgentNegotiator.ts
File metadata and controls
111 lines (104 loc) · 6.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/**
* GridVane Autonomous Multi-Agent Cyber-Physical Consensus Engine
* Simulates deterministic 5-Agent Pareto negotiation for every 15-minute IEEE P3271.01 epoch:
* 1. AGENT-01: DSO-Physics-Guardian (IEEE 33-Bus Voltage, IEEE C57.91 Hot-Spot & IEEE 738 Sag/DLR)
* 2. AGENT-02: LME-Carbon-Arbitrageur (Nodal dPloss/dPi Carbon & Triple-Silo CBAM/ITMO Maximizer)
* 3. AGENT-03: EV-Circularity-Steward (Lithium-Ion Arrhenius SEI Stress & Battery Passport SoH)
* 4. AGENT-04: Thermal-Equity-Ombudsman (Non-bypassable Veto protecting Buses 7, 14, and 29)
* 5. AGENT-05: PQC-SecOps-Watchdog (Kirchhoff AC Residual Firewall + NIST FIPS 204 ML-DSA-65 Gate)
*/
import { VPPOptimizationResult } from "../optimizer/vppOptimizer";
import { KirchhoffFirewallReport } from "../security/kirchhoffFirewall";
import { DLRAndSkyVisionReport } from "../physics/dlrAndSkyVision";
export interface AgentNegotiationStep {
round: number;
agentId: string;
agentName: string;
domain: string;
actionType: "PROPOSAL" | "CONSTITUTIONAL_VETO" | "COUNTER_OPTIMIZATION" | "CRYPTO_ATTESTATION" | "PARETO_CONSENSUS";
summary: string;
quantitativeConstraint: string;
latencyMs: number;
}
export interface MultiAgentConsensusReport {
epochNumber: number;
consensusReached: boolean;
totalNegotiationLatencyMs: number;
paretoEfficiencyScorePct: number;
steps: AgentNegotiationStep[];
}
export function runMultiAgentNegotiation(
vppResult: VPPOptimizationResult,
firewallReport: KirchhoffFirewallReport,
dlrReport: DLRAndSkyVisionReport
): MultiAgentConsensusReport {
const { metricsComparison, activeState } = vppResult;
const steps: AgentNegotiationStep[] = [
{
round: 1,
agentId: "AGENT-02",
agentName: "LME-Carbon-Arbitrageur",
domain: "Locational Marginal Emissions & Triple-Silo Yield",
actionType: "PROPOSAL",
summary: `Proposes maximum clean power dispatch across tail buses (14, 16, 18, 25, 30, 32, 33) where marginal loss sensitivity dPloss/dPi yields +${metricsComparison.gridvane.lmeBonusCarbonPct}% extra avoided CO2e (${activeState.maxLocationalMarginalEmissions} gCO2e/kWh peak LME). Initial proposal includes 93.6 kW demand curtailment across all large loads.`,
quantitativeConstraint: `Target Avoided CO2e: +${metricsComparison.gridvane.avoidedEmissionsKgCO2e} kg/hr | Line Loss Cut: -${metricsComparison.gridvane.lineLossReductionPct}%`,
latencyMs: 3.2,
},
{
round: 2,
agentId: "AGENT-04",
agentName: "Thermal-Equity-Ombudsman",
domain: "Responsible AI & Vulnerable Citizen Protection",
actionType: "CONSTITUTIONAL_VETO",
summary:
activeState.ambientTempC >= 31
? `VETOES any HVAC demand curtailment on Bus 7 (Public Clinic), Bus 14 (Senior Dialysis Housing), and Bus 29 (Maternal Hospital) because ambient temperature (${activeState.ambientTempC}°C) exceeds the 31.0°C heat-safety threshold. Mandates 0 kW curtailment for all 1,270 protected citizens.`
: `Approves flexible scheduling while maintaining standby thermal-equity lock on Buses 7, 14, and 29 (1,270 protected citizens).`,
quantitativeConstraint: `Buses [7, 14, 29] Curtailment = 0.0 kW (Rerouted 93.6 kW to Commercial Buses [6, 8, 24, 25, 30])`,
latencyMs: 1.8,
},
{
round: 3,
agentId: "AGENT-01",
agentName: "DSO-Physics-Guardian",
domain: "IEEE 33-Bus DistFlow, IEEE C57.91 Trafo & IEEE 738 DLR",
actionType: "COUNTER_OPTIMIZATION",
summary: `Enforces IEEE Std C57.91 transformer winding hot-spot ceiling (<110°C), cooling peak transformer Theta_H from ${metricsComparison.baseline.maxTransformerHotSpotC}°C to ${metricsComparison.gridvane.maxTransformerHotSpotC}°C (-${metricsComparison.gridvane.faaReductionPct}% aging F_AA). Incorporates IEEE Std 738 Dynamic Line Rating (${dlrReport.windSpeedMs} m/s wind -> ${dlrReport.avgDlrCapacityBonusPct >= 0 ? "+" : ""}${dlrReport.avgDlrCapacityBonusPct}% ampacity) and pre-ramps +${dlrReport.totalPreRampedBessKW} kW BESS for SkyVision 5-min cloud transient.`,
quantitativeConstraint: `Min Voltage: ${activeState.minVoltagePU} p.u. | Max Trafo Theta_H: ${metricsComparison.gridvane.maxTransformerHotSpotC}°C | Max Sag: ${dlrReport.maxSagMeters}m`,
latencyMs: 4.6,
},
{
round: 4,
agentId: "AGENT-03",
agentName: "EV-Circularity-Steward",
domain: "Li-Ion Arrhenius SEI Layer & Circular Battery Passport",
actionType: "COUNTER_OPTIMIZATION",
summary: `Modulates per-pack V2G C-rates to <=0.42C on thermal-exposed depots so Li-ion SEI film Arrhenius growth remains bounded ($${metricsComparison.gridvane.totalEVDegradationCostUSDPerHr}/hr total fleet wear across 13 storage hubs).`,
quantitativeConstraint: `Fleet SoH Wear Cost <= $${metricsComparison.gridvane.totalEVDegradationCostUSDPerHr}/hr | Max Pack Temp <= 39.8°C`,
latencyMs: 2.4,
},
{
round: 5,
agentId: "AGENT-05",
agentName: "PQC-SecOps-Watchdog",
domain: "Kirchhoff Residual Firewall & NIST FIPS 204 ML-DSA-65",
actionType: firewallReport.quarantinedCount > 0 ? "CRYPTO_ATTESTATION" : "PARETO_CONSENSUS",
summary:
firewallReport.quarantinedCount > 0
? `Detected Kirchhoff AC power balance violation (r_max = ${firewallReport.maxResidualKW} kW > 2.5 kW) on Bus #${firewallReport.maxResidualBusId}. Quarantined compromised node, blocked ${firewallReport.preventedFraudulentCO2Kg} kgCO2e of greenwashed credits, and signed clean 32-bus Merkle root with NIST FIPS 204 ML-DSA-65.`
: `Verified all 33 buses pass Kirchhoff DistFlow conservation (max r_ij = ${firewallReport.maxResidualKW} kW <= 2.5 kW) and NIST FIPS 204 ML-DSA-65 lattice signature verification. Anchoring IEEE P3271.01 epoch.`,
quantitativeConstraint: `Verified Meters: ${firewallReport.verifiedCleanCount}/33 | PQC Scheme: ML-DSA-65 (3,309B) + PP-PQB`,
latencyMs: 3.9,
},
];
const totalLatency = Number(
steps.reduce((s, step) => s + step.latencyMs, 0).toFixed(1)
);
return {
epochNumber: 14820,
consensusReached: true,
totalNegotiationLatencyMs: totalLatency,
paretoEfficiencyScorePct: 98.7,
steps,
};
}