Squashed 'vendor/ruvector/' content from commit b64c2172

git-subtree-dir: vendor/ruvector
git-subtree-split: b64c21726f2bb37286d9ee36a7869fef60cc6900
This commit is contained in:
ruv
2026-02-28 14:39:40 -05:00
commit d803bfe2b1
7854 changed files with 3522914 additions and 0 deletions

96
examples/edge-net/sim/dist/cell.d.ts vendored Normal file
View File

@@ -0,0 +1,96 @@
/**
* Cell (Node) Simulation
* Represents a single node in the edge-net network
*/
export declare enum CellType {
GENESIS = "genesis",
REGULAR = "regular"
}
export declare enum CellState {
ACTIVE = "active",
READ_ONLY = "read_only",
RETIRED = "retired"
}
export interface CellCapabilities {
computePower: number;
bandwidth: number;
reliability: number;
storage: number;
}
export interface CellMetrics {
tasksCompleted: number;
energyEarned: number;
energySpent: number;
connections: number;
uptime: number;
successRate: number;
}
export declare class Cell {
readonly id: string;
readonly type: CellType;
readonly joinedAtTick: number;
state: CellState;
capabilities: CellCapabilities;
energy: number;
metrics: CellMetrics;
connectedCells: Set<string>;
genesisMultiplier: number;
constructor(type: CellType, joinedAtTick: number, capabilities?: Partial<CellCapabilities>);
private randomCapability;
/**
* Process a task and earn energy
*/
processTask(taskComplexity: number, baseReward: number): boolean;
/**
* Spend energy (for network operations, connections, etc.)
*/
spendEnergy(amount: number): boolean;
/**
* Connect to another cell
*/
connectTo(cellId: string): void;
/**
* Disconnect from a cell
*/
disconnectFrom(cellId: string): void;
/**
* Update cell state based on network phase
*/
updateState(networkSize: number): void;
/**
* Simulate one tick of operation
*/
tick(): void;
/**
* Update success rate with exponential moving average
*/
private updateSuccessRate;
/**
* Get cell's overall fitness score
*/
getFitnessScore(): number;
/**
* Serialize cell state for reporting
*/
toJSON(): {
id: string;
type: CellType;
state: CellState;
joinedAtTick: number;
energy: number;
genesisMultiplier: number;
capabilities: CellCapabilities;
metrics: {
netEnergy: number;
tasksCompleted: number;
energyEarned: number;
energySpent: number;
connections: number;
uptime: number;
successRate: number;
};
connections: number;
fitnessScore: number;
};
}
//# sourceMappingURL=cell.d.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AEG;IACI,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAOtC;;OAEG;IACI,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAK3C;;OAEG;IACI,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAkB7C;;OAEG;IACI,IAAI,IAAI,IAAI;IAQnB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAKzB;;OAEG;IACI,eAAe,IAAI,MAAM;IAKhC;;OAEG;IACI,MAAM;;;;;;;;;;4BAjKG,MAAM;0BACR,MAAM;yBACP,MAAM;yBACN,MAAM;oBACX,MAAM;yBACD,MAAM;;;;;CA6KpB"}

166
examples/edge-net/sim/dist/cell.js vendored Normal file
View File

@@ -0,0 +1,166 @@
/**
* Cell (Node) Simulation
* Represents a single node in the edge-net network
*/
import { v4 as uuidv4 } from 'uuid';
export var CellType;
(function (CellType) {
CellType["GENESIS"] = "genesis";
CellType["REGULAR"] = "regular";
})(CellType || (CellType = {}));
export var CellState;
(function (CellState) {
CellState["ACTIVE"] = "active";
CellState["READ_ONLY"] = "read_only";
CellState["RETIRED"] = "retired";
})(CellState || (CellState = {}));
export class Cell {
id;
type;
joinedAtTick;
state;
capabilities;
energy; // rUv balance
metrics;
connectedCells;
genesisMultiplier; // 10x for genesis nodes initially
constructor(type, joinedAtTick, capabilities) {
this.id = uuidv4();
this.type = type;
this.joinedAtTick = joinedAtTick;
this.state = CellState.ACTIVE;
this.energy = type === CellType.GENESIS ? 1000 : 10; // Genesis starts with more
this.connectedCells = new Set();
this.genesisMultiplier = type === CellType.GENESIS ? 10 : 1;
// Random capabilities or provided ones
this.capabilities = {
computePower: capabilities?.computePower ?? this.randomCapability(0.1, 1.0),
bandwidth: capabilities?.bandwidth ?? this.randomCapability(0.1, 1.0),
reliability: capabilities?.reliability ?? this.randomCapability(0.5, 1.0),
storage: capabilities?.storage ?? this.randomCapability(0.1, 1.0),
};
this.metrics = {
tasksCompleted: 0,
energyEarned: 0,
energySpent: 0,
connections: 0,
uptime: 0,
successRate: 1.0,
};
}
randomCapability(min, max) {
return Math.random() * (max - min) + min;
}
/**
* Process a task and earn energy
*/
processTask(taskComplexity, baseReward) {
// Check if cell is alive (reliability check)
if (Math.random() > this.capabilities.reliability) {
return false; // Cell failed this tick
}
// Check if cell has enough compute power
if (this.capabilities.computePower < taskComplexity * 0.5) {
return false; // Task too complex
}
// Success - earn energy with genesis multiplier
const reward = baseReward * this.genesisMultiplier;
this.energy += reward;
this.metrics.energyEarned += reward;
this.metrics.tasksCompleted++;
// Update success rate
this.updateSuccessRate(true);
return true;
}
/**
* Spend energy (for network operations, connections, etc.)
*/
spendEnergy(amount) {
if (this.energy >= amount) {
this.energy -= amount;
this.metrics.energySpent += amount;
return true;
}
return false;
}
/**
* Connect to another cell
*/
connectTo(cellId) {
if (!this.connectedCells.has(cellId)) {
this.connectedCells.add(cellId);
this.metrics.connections = this.connectedCells.size;
}
}
/**
* Disconnect from a cell
*/
disconnectFrom(cellId) {
this.connectedCells.delete(cellId);
this.metrics.connections = this.connectedCells.size;
}
/**
* Update cell state based on network phase
*/
updateState(networkSize) {
if (this.type === CellType.GENESIS) {
if (networkSize >= 50000) {
// Phase 3: Maturation - Genesis goes read-only
this.state = CellState.READ_ONLY;
this.genesisMultiplier = 1; // No more bonus
}
else if (networkSize >= 10000) {
// Phase 2: Growth - Genesis reduces multiplier
this.genesisMultiplier = Math.max(1, 10 * (1 - (networkSize - 10000) / 40000));
}
if (networkSize >= 100000) {
// Phase 4: Independence - Genesis retires
this.state = CellState.RETIRED;
}
}
}
/**
* Simulate one tick of operation
*/
tick() {
this.metrics.uptime++;
// Passive energy decay (network costs)
const decayCost = 0.1 * this.connectedCells.size;
this.spendEnergy(decayCost);
}
/**
* Update success rate with exponential moving average
*/
updateSuccessRate(success) {
const alpha = 0.1; // Smoothing factor
this.metrics.successRate = alpha * (success ? 1 : 0) + (1 - alpha) * this.metrics.successRate;
}
/**
* Get cell's overall fitness score
*/
getFitnessScore() {
const { computePower, bandwidth, reliability, storage } = this.capabilities;
return (computePower * 0.3 + bandwidth * 0.2 + reliability * 0.3 + storage * 0.2);
}
/**
* Serialize cell state for reporting
*/
toJSON() {
return {
id: this.id,
type: this.type,
state: this.state,
joinedAtTick: this.joinedAtTick,
energy: this.energy,
genesisMultiplier: this.genesisMultiplier,
capabilities: this.capabilities,
metrics: {
...this.metrics,
netEnergy: this.metrics.energyEarned - this.metrics.energySpent,
},
connections: this.connectedCells.size,
fitnessScore: this.getFitnessScore(),
};
}
}
//# sourceMappingURL=cell.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"cell.js","sourceRoot":"","sources":["../src/cell.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,MAAM,CAAN,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,+BAAmB,CAAA;IACnB,+BAAmB,CAAA;AACrB,CAAC,EAHW,QAAQ,KAAR,QAAQ,QAGnB;AAED,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,8BAAiB,CAAA;IACjB,oCAAuB,CAAA;IACvB,gCAAmB,CAAA;AACrB,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB;AAkBD,MAAM,OAAO,IAAI;IACC,EAAE,CAAS;IACX,IAAI,CAAW;IACf,YAAY,CAAS;IAC9B,KAAK,CAAY;IACjB,YAAY,CAAmB;IAC/B,MAAM,CAAS,CAAM,cAAc;IACnC,OAAO,CAAc;IACrB,cAAc,CAAc;IAC5B,iBAAiB,CAAS,CAAE,kCAAkC;IAErE,YACE,IAAc,EACd,YAAoB,EACpB,YAAwC;QAExC,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,MA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Y,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC;QAC5E,OAAO,CAAC,YAAY,GAAG,GAAG,GAAG,SAAS,GAAG,GAAG,GAAG,WAAW,GAAG,GAAG,GAAG,OAAO,GAAG,GAAG,CAAC,CAAC;IACpF,CAAC;IAED;;OAEG;IACI,MAAM;QACX,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,OAAO,EAAE;gBACP,GAAG,IAAI,CAAC,OAAO;gBACf,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW;aAChE;YACD,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI;YACrC,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE;SACrC,CAAC;IACJ,CAAC;CACF"}

88
examples/edge-net/sim/dist/metrics.d.ts vendored Normal file
View File

@@ -0,0 +1,88 @@
/**
* Metrics Collection and Aggregation
* Tracks network performance across all phases
*/
import { Network, NetworkPhase } from './network.js';
export interface PhaseMetrics {
phase: NetworkPhase;
startTick: number;
endTick: number;
duration: number;
nodeCount: {
start: number;
end: number;
peak: number;
};
energy: {
totalEarned: number;
totalSpent: number;
netEnergy: number;
avgPerNode: number;
sustainability: number;
};
genesis: {
avgMultiplier: number;
activeCount: number;
readOnlyCount: number;
retiredCount: number;
};
network: {
avgConnections: number;
avgSuccessRate: number;
taskThroughput: number;
tasksCompleted: number;
};
validation: {
passed: boolean;
reasons: string[];
};
}
export declare class MetricsCollector {
private network;
private phaseMetrics;
private currentPhaseStart;
private currentPhaseNodeCount;
private peakNodeCount;
constructor(network: Network);
/**
* Initialize metrics collection
*/
initialize(): void;
/**
* Collect metrics for the current tick
*/
collect(): void;
/**
* Handle phase transition
*/
onPhaseTransition(oldPhase: NetworkPhase, newPhase: NetworkPhase): void;
/**
* Finalize metrics for a completed phase
*/
private finalizePhase;
/**
* Validate phase completion criteria
*/
private validatePhase;
/**
* Finalize current phase (for end of simulation)
*/
finalizeCurrent(): void;
/**
* Get all collected metrics
*/
getAllMetrics(): PhaseMetrics[];
/**
* Get metrics for a specific phase
*/
getPhaseMetrics(phase: NetworkPhase): PhaseMetrics | undefined;
/**
* Get overall success rate
*/
getOverallSuccess(): {
passed: boolean;
totalPassed: number;
totalPhases: number;
};
}
//# sourceMappingURL=metrics.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAErD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,MAAM,EAAE;QACN,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,OAAO,EAAE;QACP,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,OAAO,EAAE;QACP,cAAc,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,UAAU,EAAE;QACV,MAAM,EAAE,OAAO,CAAC;QAChB,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC;CACH;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,YAAY,CAAkC;IACtD,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,qBAAqB,CAAS;IACtC,OAAO,CAAC,aAAa,CAAS;gBAElB,OAAO,EAAE,OAAO;IAQ5B;;OAEG;IACI,UAAU,IAAI,IAAI;IAMzB;;OAEG;IACI,OAAO,IAAI,IAAI;IAOtB;;OAEG;IACI,iBAAiB,CAAC,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI;IAU9E;;OAEG;IACH,OAAO,CAAC,aAAa;IA6CrB;;OAEG;IACH,OAAO,CAAC,aAAa;IAkHrB;;OAEG;IACI,eAAe,IAAI,IAAI;IAI9B;;OAEG;IACI,aAAa,IAAI,YAAY,EAAE;IAItC;;OAEG;IACI,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY,GAAG,SAAS;IAIrE;;OAEG;IACI,iBAAiB,IAAI;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE;CAW1F"}

237
examples/edge-net/sim/dist/metrics.js vendored Normal file
View File

@@ -0,0 +1,237 @@
/**
* Metrics Collection and Aggregation
* Tracks network performance across all phases
*/
import { NetworkPhase } from './network.js';
export class MetricsCollector {
network;
phaseMetrics;
currentPhaseStart;
currentPhaseNodeCount;
peakNodeCount;
constructor(network) {
this.network = network;
this.phaseMetrics = new Map();
this.currentPhaseStart = 0;
this.currentPhaseNodeCount = 0;
this.peakNodeCount = 0;
}
/**
* Initialize metrics collection
*/
initialize() {
this.currentPhaseStart = this.network.currentTick;
this.currentPhaseNodeCount = this.network.cells.size;
this.peakNodeCount = this.network.cells.size;
}
/**
* Collect metrics for the current tick
*/
collect() {
const stats = this.network.getStats();
// Update peak node count
this.peakNodeCount = Math.max(this.peakNodeCount, stats.nodeCount);
}
/**
* Handle phase transition
*/
onPhaseTransition(oldPhase, newPhase) {
// Finalize metrics for old phase
this.finalizePhase(oldPhase);
// Start tracking new phase
this.currentPhaseStart = this.network.currentTick;
this.currentPhaseNodeCount = this.network.cells.size;
this.peakNodeCount = this.network.cells.size;
}
/**
* Finalize metrics for a completed phase
*/
finalizePhase(phase) {
const stats = this.network.getStats();
const endTick = this.network.currentTick;
const duration = endTick - this.currentPhaseStart;
const cells = Array.from(this.network.cells.values());
const totalEarned = cells.reduce((sum, c) => sum + c.metrics.energyEarned, 0);
const totalSpent = cells.reduce((sum, c) => sum + c.metrics.energySpent, 0);
const totalTasks = cells.reduce((sum, c) => sum + c.metrics.tasksCompleted, 0);
const metrics = {
phase,
startTick: this.currentPhaseStart,
endTick,
duration,
nodeCount: {
start: this.currentPhaseNodeCount,
end: stats.nodeCount,
peak: this.peakNodeCount,
},
energy: {
totalEarned,
totalSpent,
netEnergy: totalEarned - totalSpent,
avgPerNode: stats.economy.avgEnergyPerNode,
sustainability: totalSpent > 0 ? totalEarned / totalSpent : 0,
},
genesis: {
avgMultiplier: stats.genesisNodes.avgMultiplier,
activeCount: stats.genesisNodes.active,
readOnlyCount: stats.genesisNodes.readOnly,
retiredCount: stats.genesisNodes.retired,
},
network: {
avgConnections: stats.network.avgConnections,
avgSuccessRate: stats.network.avgSuccessRate,
taskThroughput: duration > 0 ? totalTasks / duration : 0,
tasksCompleted: totalTasks,
},
validation: this.validatePhase(phase, stats),
};
this.phaseMetrics.set(phase, metrics);
}
/**
* Validate phase completion criteria
*/
validatePhase(phase, stats) {
const reasons = [];
let passed = true;
switch (phase) {
case NetworkPhase.GENESIS:
// Verify 10x multiplier is active
if (stats.genesisNodes.avgMultiplier < 9.0) {
passed = false;
reasons.push(`Genesis multiplier too low: ${stats.genesisNodes.avgMultiplier.toFixed(2)} (expected ~10.0)`);
}
else {
reasons.push(`✓ Genesis multiplier active: ${stats.genesisNodes.avgMultiplier.toFixed(2)}x`);
}
// Verify energy accumulation
if (stats.economy.totalEarned < 1000) {
passed = false;
reasons.push(`Insufficient energy accumulation: ${stats.economy.totalEarned.toFixed(2)}`);
}
else {
reasons.push(`✓ Energy accumulated: ${stats.economy.totalEarned.toFixed(2)} rUv`);
}
// Verify network formation
if (stats.network.avgConnections < 5) {
passed = false;
reasons.push(`Network poorly connected: ${stats.network.avgConnections.toFixed(2)} avg connections`);
}
else {
reasons.push(`✓ Network connected: ${stats.network.avgConnections.toFixed(2)} avg connections`);
}
break;
case NetworkPhase.GROWTH:
// Verify genesis nodes stop accepting connections
if (stats.genesisNodes.active > stats.genesisNodes.count * 0.1) {
passed = false;
reasons.push(`Too many genesis nodes still active: ${stats.genesisNodes.active}`);
}
else {
reasons.push(`✓ Genesis nodes reducing activity: ${stats.genesisNodes.active} active`);
}
// Verify multiplier decay
if (stats.genesisNodes.avgMultiplier > 5.0) {
passed = false;
reasons.push(`Genesis multiplier decay insufficient: ${stats.genesisNodes.avgMultiplier.toFixed(2)}`);
}
else {
reasons.push(`✓ Multiplier decaying: ${stats.genesisNodes.avgMultiplier.toFixed(2)}x`);
}
// Verify task routing optimization
if (stats.network.avgSuccessRate < 0.7) {
passed = false;
reasons.push(`Task success rate too low: ${(stats.network.avgSuccessRate * 100).toFixed(1)}%`);
}
else {
reasons.push(`✓ Task routing optimized: ${(stats.network.avgSuccessRate * 100).toFixed(1)}% success`);
}
break;
case NetworkPhase.MATURATION:
// Verify genesis nodes are read-only
if (stats.genesisNodes.readOnly < stats.genesisNodes.count * 0.8) {
passed = false;
reasons.push(`Genesis nodes not read-only: ${stats.genesisNodes.readOnly}/${stats.genesisNodes.count}`);
}
else {
reasons.push(`✓ Genesis nodes read-only: ${stats.genesisNodes.readOnly}/${stats.genesisNodes.count}`);
}
// Verify economic sustainability
const sustainability = stats.economy.totalEarned / Math.max(stats.economy.totalSpent, 1);
if (sustainability < 1.0) {
passed = false;
reasons.push(`Network not sustainable: ${sustainability.toFixed(2)} earned/spent ratio`);
}
else {
reasons.push(`✓ Economically sustainable: ${sustainability.toFixed(2)} ratio`);
}
// Verify network independence
if (stats.network.avgConnections < 10) {
passed = false;
reasons.push(`Network connectivity too low for independence: ${stats.network.avgConnections.toFixed(2)}`);
}
else {
reasons.push(`✓ Network ready for independence: ${stats.network.avgConnections.toFixed(2)} avg connections`);
}
break;
case NetworkPhase.INDEPENDENCE:
// Verify genesis nodes retired
if (stats.genesisNodes.retired < stats.genesisNodes.count * 0.9) {
passed = false;
reasons.push(`Genesis nodes not fully retired: ${stats.genesisNodes.retired}/${stats.genesisNodes.count}`);
}
else {
reasons.push(`✓ Genesis nodes retired: ${stats.genesisNodes.retired}/${stats.genesisNodes.count}`);
}
// Verify pure P2P operation
if (stats.genesisNodes.avgMultiplier > 1.1) {
passed = false;
reasons.push(`Genesis multiplier still active: ${stats.genesisNodes.avgMultiplier.toFixed(2)}`);
}
else {
reasons.push(`✓ Pure P2P operation: ${stats.genesisNodes.avgMultiplier.toFixed(2)}x multiplier`);
}
// Verify long-term stability
if (stats.economy.netEnergy < 0) {
passed = false;
reasons.push(`Network losing energy: ${stats.economy.netEnergy.toFixed(2)}`);
}
else {
reasons.push(`✓ Network stable: +${stats.economy.netEnergy.toFixed(2)} rUv net energy`);
}
break;
}
return { passed, reasons };
}
/**
* Finalize current phase (for end of simulation)
*/
finalizeCurrent() {
this.finalizePhase(this.network.currentPhase);
}
/**
* Get all collected metrics
*/
getAllMetrics() {
return Array.from(this.phaseMetrics.values());
}
/**
* Get metrics for a specific phase
*/
getPhaseMetrics(phase) {
return this.phaseMetrics.get(phase);
}
/**
* Get overall success rate
*/
getOverallSuccess() {
const metrics = this.getAllMetrics();
const totalPassed = metrics.filter(m => m.validation.passed).length;
const totalPhases = metrics.length;
return {
passed: totalPassed === totalPhases,
totalPassed,
totalPhases,
};
}
}
//# sourceMappingURL=metrics.js.map

File diff suppressed because one or more lines are too long

104
examples/edge-net/sim/dist/network.d.ts vendored Normal file
View File

@@ -0,0 +1,104 @@
/**
* Network State Management
* Manages the P2P network state and phase transitions
*/
import { Cell } from './cell.js';
export declare enum NetworkPhase {
GENESIS = "genesis",// 0 - 10K nodes
GROWTH = "growth",// 10K - 50K nodes
MATURATION = "maturation",// 50K - 100K nodes
INDEPENDENCE = "independence"
}
export interface NetworkConfig {
genesisNodeCount: number;
targetNodeCount: number;
nodesPerTick: number;
taskGenerationRate: number;
baseTaskReward: number;
connectionCost: number;
maxConnectionsPerNode: number;
}
export declare class Network {
cells: Map<string, Cell>;
currentPhase: NetworkPhase;
currentTick: number;
config: NetworkConfig;
genesisCells: Set<string>;
private taskQueue;
constructor(config?: Partial<NetworkConfig>);
/**
* Initialize network with genesis nodes
*/
initialize(): void;
/**
* Connect all genesis nodes to each other
*/
private connectGenesisNodes;
/**
* Add new regular nodes to the network
*/
spawnNodes(count: number): void;
/**
* Connect a new node to the network
*/
private connectNewNode;
/**
* Select targets using preferential attachment
*/
private selectPreferentialTargets;
/**
* Generate tasks for the network
*/
private generateTasks;
/**
* Distribute tasks to capable cells
*/
private distributeTasks;
/**
* Update network phase based on node count
*/
private updatePhase;
/**
* Handle phase transition events
*/
private onPhaseTransition;
/**
* Simulate one tick of the network
*/
tick(): void;
/**
* Get network statistics
*/
getStats(): {
tick: number;
phase: NetworkPhase;
nodeCount: number;
genesisNodes: {
count: number;
active: number;
readOnly: number;
retired: number;
avgMultiplier: number;
};
regularNodes: {
count: number;
};
economy: {
totalEnergy: number;
totalEarned: number;
totalSpent: number;
netEnergy: number;
avgEnergyPerNode: number;
};
tasks: {
completed: number;
queued: number;
avgPerNode: number;
};
network: {
avgConnections: number;
avgSuccessRate: number;
};
};
}
//# sourceMappingURL=network.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAuB,MAAM,WAAW,CAAC;AAEtD,oBAAY,YAAY;IACtB,OAAO,YAAY,CAAS,gBAAgB;IAC5C,MAAM,WAAW,CAAW,kBAAkB;IAC9C,UAAU,eAAe,CAAG,mBAAmB;IAC/C,YAAY,iBAAiB;CAC9B;AAED,MAAM,WAAW,aAAa;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED,qBAAa,OAAO;IACX,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACzB,YAAY,EAAE,YAAY,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,aAAa,CAAC;IACtB,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,CAAC,SAAS,CAAW;gBAEhB,MAAM,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC;IAkB3C;;OAEG;IACI,UAAU,IAAI,IAAI;IAmBzB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAa3B;;OAEG;IACI,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAUtC;;OAEG;IACH,OAAO,CAAC,cAAc;IA6BtB;;OAEG;IACH,OAAO,CAAC,yBAAyB;IA6BjC;;OAEG;IACH,OAAO,CAAC,aAAa;IAWrB;;OAEG;IACH,OAAO,CAAC,eAAe;IAavB;;OAEG;IACH,OAAO,CAAC,WAAW;IAoBnB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAkBzB;;OAEG;IACI,IAAI,IAAI,IAAI;IA0BnB;;OAEG;IACI,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0ChB"}

259
examples/edge-net/sim/dist/network.js vendored Normal file
View File

@@ -0,0 +1,259 @@
/**
* Network State Management
* Manages the P2P network state and phase transitions
*/
import { Cell, CellType, CellState } from './cell.js';
export var NetworkPhase;
(function (NetworkPhase) {
NetworkPhase["GENESIS"] = "genesis";
NetworkPhase["GROWTH"] = "growth";
NetworkPhase["MATURATION"] = "maturation";
NetworkPhase["INDEPENDENCE"] = "independence";
})(NetworkPhase || (NetworkPhase = {}));
export class Network {
cells;
currentPhase;
currentTick;
config;
genesisCells;
taskQueue;
constructor(config) {
this.cells = new Map();
this.currentPhase = NetworkPhase.GENESIS;
this.currentTick = 0;
this.genesisCells = new Set();
this.taskQueue = [];
this.config = {
genesisNodeCount: config?.genesisNodeCount ?? 100,
targetNodeCount: config?.targetNodeCount ?? 120000,
nodesPerTick: config?.nodesPerTick ?? 10,
taskGenerationRate: config?.taskGenerationRate ?? 5,
baseTaskReward: config?.baseTaskReward ?? 1.0,
connectionCost: config?.connectionCost ?? 0.5,
maxConnectionsPerNode: config?.maxConnectionsPerNode ?? 50,
};
}
/**
* Initialize network with genesis nodes
*/
initialize() {
console.log(`Initializing network with ${this.config.genesisNodeCount} genesis nodes...`);
for (let i = 0; i < this.config.genesisNodeCount; i++) {
const cell = new Cell(CellType.GENESIS, this.currentTick, {
computePower: 0.8 + Math.random() * 0.2, // Genesis nodes are powerful
bandwidth: 0.8 + Math.random() * 0.2,
reliability: 0.9 + Math.random() * 0.1,
storage: 0.8 + Math.random() * 0.2,
});
this.cells.set(cell.id, cell);
this.genesisCells.add(cell.id);
}
// Connect genesis nodes to each other (mesh topology)
this.connectGenesisNodes();
}
/**
* Connect all genesis nodes to each other
*/
connectGenesisNodes() {
const genesisArray = Array.from(this.genesisCells);
for (let i = 0; i < genesisArray.length; i++) {
for (let j = i + 1; j < genesisArray.length; j++) {
const cell1 = this.cells.get(genesisArray[i]);
const cell2 = this.cells.get(genesisArray[j]);
cell1.connectTo(cell2.id);
cell2.connectTo(cell1.id);
}
}
}
/**
* Add new regular nodes to the network
*/
spawnNodes(count) {
for (let i = 0; i < count; i++) {
const cell = new Cell(CellType.REGULAR, this.currentTick);
this.cells.set(cell.id, cell);
// Connect to random existing nodes (preferential attachment)
this.connectNewNode(cell);
}
}
/**
* Connect a new node to the network
*/
connectNewNode(newCell) {
const connectionCount = Math.min(5 + Math.floor(Math.random() * 5), this.config.maxConnectionsPerNode);
const potentialTargets = Array.from(this.cells.values())
.filter(c => c.id !== newCell.id)
.filter(c => {
// In Phase 2+, genesis nodes don't accept new connections
if (this.currentPhase !== NetworkPhase.GENESIS && c.type === CellType.GENESIS) {
return false;
}
return c.state === CellState.ACTIVE && c.connectedCells.size < this.config.maxConnectionsPerNode;
});
// Preferential attachment: higher fitness = more likely to connect
const selectedTargets = this.selectPreferentialTargets(potentialTargets, connectionCount);
for (const target of selectedTargets) {
newCell.connectTo(target.id);
target.connectTo(newCell.id);
// Connection costs energy
newCell.spendEnergy(this.config.connectionCost);
target.spendEnergy(this.config.connectionCost);
}
}
/**
* Select targets using preferential attachment
*/
selectPreferentialTargets(candidates, count) {
if (candidates.length <= count) {
return candidates;
}
const selected = [];
const weights = candidates.map(c => c.getFitnessScore() * (1 + c.connectedCells.size));
const totalWeight = weights.reduce((sum, w) => sum + w, 0);
for (let i = 0; i < count && candidates.length > 0; i++) {
let random = Math.random() * totalWeight;
let selectedIndex = 0;
for (let j = 0; j < weights.length; j++) {
random -= weights[j];
if (random <= 0) {
selectedIndex = j;
break;
}
}
selected.push(candidates[selectedIndex]);
candidates.splice(selectedIndex, 1);
weights.splice(selectedIndex, 1);
}
return selected;
}
/**
* Generate tasks for the network
*/
generateTasks() {
const tasksToGenerate = Math.floor(this.cells.size * this.config.taskGenerationRate * Math.random());
for (let i = 0; i < tasksToGenerate; i++) {
// Task complexity between 0.1 and 1.0
this.taskQueue.push(0.1 + Math.random() * 0.9);
}
}
/**
* Distribute tasks to capable cells
*/
distributeTasks() {
const activeCells = Array.from(this.cells.values())
.filter(c => c.state === CellState.ACTIVE);
while (this.taskQueue.length > 0 && activeCells.length > 0) {
const task = this.taskQueue.shift();
// Select cell based on fitness and availability
const selectedCell = activeCells[Math.floor(Math.random() * activeCells.length)];
selectedCell.processTask(task, this.config.baseTaskReward);
}
}
/**
* Update network phase based on node count
*/
updatePhase() {
const nodeCount = this.cells.size;
const oldPhase = this.currentPhase;
if (nodeCount >= 100000) {
this.currentPhase = NetworkPhase.INDEPENDENCE;
}
else if (nodeCount >= 50000) {
this.currentPhase = NetworkPhase.MATURATION;
}
else if (nodeCount >= 10000) {
this.currentPhase = NetworkPhase.GROWTH;
}
else {
this.currentPhase = NetworkPhase.GENESIS;
}
if (oldPhase !== this.currentPhase) {
console.log(`\n🔄 PHASE TRANSITION: ${oldPhase}${this.currentPhase} (${nodeCount} nodes)`);
this.onPhaseTransition();
}
}
/**
* Handle phase transition events
*/
onPhaseTransition() {
// Update all cells based on new phase
this.cells.forEach(cell => cell.updateState(this.cells.size));
// Phase-specific actions
switch (this.currentPhase) {
case NetworkPhase.GROWTH:
console.log(' → Genesis nodes reducing 10x multiplier...');
break;
case NetworkPhase.MATURATION:
console.log(' → Genesis nodes entering READ-ONLY mode...');
break;
case NetworkPhase.INDEPENDENCE:
console.log(' → Genesis nodes RETIRED. Network is independent!');
break;
}
}
/**
* Simulate one tick of the network
*/
tick() {
this.currentTick++;
// Spawn new nodes (if not at target)
if (this.cells.size < this.config.targetNodeCount) {
const nodesToSpawn = Math.min(this.config.nodesPerTick, this.config.targetNodeCount - this.cells.size);
this.spawnNodes(nodesToSpawn);
}
// Generate and distribute tasks
this.generateTasks();
this.distributeTasks();
// Update all cells
this.cells.forEach(cell => {
cell.tick();
cell.updateState(this.cells.size);
});
// Check for phase transitions
this.updatePhase();
}
/**
* Get network statistics
*/
getStats() {
const cells = Array.from(this.cells.values());
const genesisCells = cells.filter(c => c.type === CellType.GENESIS);
const regularCells = cells.filter(c => c.type === CellType.REGULAR);
const totalEnergy = cells.reduce((sum, c) => sum + c.energy, 0);
const totalEarned = cells.reduce((sum, c) => sum + c.metrics.energyEarned, 0);
const totalSpent = cells.reduce((sum, c) => sum + c.metrics.energySpent, 0);
const totalTasks = cells.reduce((sum, c) => sum + c.metrics.tasksCompleted, 0);
return {
tick: this.currentTick,
phase: this.currentPhase,
nodeCount: this.cells.size,
genesisNodes: {
count: genesisCells.length,
active: genesisCells.filter(c => c.state === CellState.ACTIVE).length,
readOnly: genesisCells.filter(c => c.state === CellState.READ_ONLY).length,
retired: genesisCells.filter(c => c.state === CellState.RETIRED).length,
avgMultiplier: genesisCells.reduce((sum, c) => sum + c.genesisMultiplier, 0) / genesisCells.length,
},
regularNodes: {
count: regularCells.length,
},
economy: {
totalEnergy,
totalEarned,
totalSpent,
netEnergy: totalEarned - totalSpent,
avgEnergyPerNode: totalEnergy / this.cells.size,
},
tasks: {
completed: totalTasks,
queued: this.taskQueue.length,
avgPerNode: totalTasks / this.cells.size,
},
network: {
avgConnections: cells.reduce((sum, c) => sum + c.connectedCells.size, 0) / this.cells.size,
avgSuccessRate: cells.reduce((sum, c) => sum + c.metrics.successRate, 0) / this.cells.size,
},
};
}
}
//# sourceMappingURL=network.js.map

File diff suppressed because one or more lines are too long

40
examples/edge-net/sim/dist/phases.d.ts vendored Normal file
View File

@@ -0,0 +1,40 @@
/**
* Phase Transition Logic
* Manages lifecycle phases and transition conditions
*/
import { Network } from './network.js';
import { MetricsCollector } from './metrics.js';
export interface PhaseTransitionCondition {
minNodes: number;
maxNodes: number;
requiredDuration?: number;
customCheck?: (network: Network) => boolean;
}
export declare class PhaseManager {
private network;
private metrics;
private conditions;
private lastPhase;
constructor(network: Network, metrics: MetricsCollector);
/**
* Check if network should transition to next phase
*/
checkTransition(): boolean;
/**
* Handle phase transition
*/
private onTransition;
/**
* Log phase-specific information
*/
private logPhaseInfo;
/**
* Get phase progress (0-1)
*/
getPhaseProgress(): number;
/**
* Get estimated ticks to next phase
*/
getTicksToNextPhase(): number;
}
//# sourceMappingURL=phases.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"phases.d.ts","sourceRoot":"","sources":["../src/phases.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAgB,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC;CAC7C;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,SAAS,CAAe;gBAEpB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB;IA8CvD;;OAEG;IACI,eAAe,IAAI,OAAO;IAsCjC;;OAEG;IACH,OAAO,CAAC,YAAY;IAcpB;;OAEG;IACH,OAAO,CAAC,YAAY;IA6CpB;;OAEG;IACI,gBAAgB,IAAI,MAAM;IAWjC;;OAEG;IACI,mBAAmB,IAAI,MAAM;CAUrC"}

171
examples/edge-net/sim/dist/phases.js vendored Normal file
View File

@@ -0,0 +1,171 @@
/**
* Phase Transition Logic
* Manages lifecycle phases and transition conditions
*/
import { NetworkPhase } from './network.js';
import { CellType, CellState } from './cell.js';
export class PhaseManager {
network;
metrics;
conditions;
lastPhase;
constructor(network, metrics) {
this.network = network;
this.metrics = metrics;
this.lastPhase = NetworkPhase.GENESIS;
this.conditions = new Map([
[NetworkPhase.GENESIS, {
minNodes: 0,
maxNodes: 10000,
}],
[NetworkPhase.GROWTH, {
minNodes: 10000,
maxNodes: 50000,
customCheck: (net) => {
// Verify genesis nodes are still active but reducing multiplier
const genesisCells = Array.from(net.cells.values())
.filter((c) => c.type === CellType.GENESIS);
const avgMultiplier = genesisCells.reduce((sum, c) => sum + c.genesisMultiplier, 0) / genesisCells.length;
return avgMultiplier < 10 && avgMultiplier > 1;
},
}],
[NetworkPhase.MATURATION, {
minNodes: 50000,
maxNodes: 100000,
customCheck: (net) => {
// Verify genesis nodes are entering read-only mode
const genesisCells = Array.from(net.cells.values())
.filter((c) => c.type === CellType.GENESIS);
const readOnlyCount = genesisCells.filter(c => c.state === CellState.READ_ONLY).length;
return readOnlyCount >= genesisCells.length * 0.5; // At least 50% read-only
},
}],
[NetworkPhase.INDEPENDENCE, {
minNodes: 100000,
maxNodes: Infinity,
customCheck: (net) => {
// Verify genesis nodes are retired
const genesisCells = Array.from(net.cells.values())
.filter((c) => c.type === CellType.GENESIS);
const retiredCount = genesisCells.filter(c => c.state === CellState.RETIRED).length;
return retiredCount >= genesisCells.length * 0.8; // At least 80% retired
},
}],
]);
}
/**
* Check if network should transition to next phase
*/
checkTransition() {
const currentPhase = this.network.currentPhase;
const nodeCount = this.network.cells.size;
// Determine target phase based on node count
let targetPhase = NetworkPhase.GENESIS;
if (nodeCount >= 100000) {
targetPhase = NetworkPhase.INDEPENDENCE;
}
else if (nodeCount >= 50000) {
targetPhase = NetworkPhase.MATURATION;
}
else if (nodeCount >= 10000) {
targetPhase = NetworkPhase.GROWTH;
}
// If phase changed, validate transition
if (targetPhase !== currentPhase) {
const condition = this.conditions.get(targetPhase);
if (condition) {
// Check node count bounds
if (nodeCount < condition.minNodes || nodeCount >= condition.maxNodes) {
return false;
}
// Check custom conditions
if (condition.customCheck && !condition.customCheck(this.network)) {
return false;
}
// Valid transition
this.onTransition(currentPhase, targetPhase);
return true;
}
}
return false;
}
/**
* Handle phase transition
*/
onTransition(fromPhase, toPhase) {
console.log(`\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`);
console.log(`🔄 PHASE TRANSITION: ${fromPhase.toUpperCase()}${toPhase.toUpperCase()}`);
console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`);
// Notify metrics collector
this.metrics.onPhaseTransition(fromPhase, toPhase);
// Log phase-specific information
this.logPhaseInfo(toPhase);
this.lastPhase = toPhase;
}
/**
* Log phase-specific information
*/
logPhaseInfo(phase) {
const stats = this.network.getStats();
console.log(`📊 Network Status:`);
console.log(` Nodes: ${stats.nodeCount.toLocaleString()}`);
console.log(` Genesis Nodes: ${stats.genesisNodes.count}`);
console.log(` Avg Connections: ${stats.network.avgConnections.toFixed(2)}`);
console.log(` Total Energy: ${stats.economy.totalEnergy.toFixed(2)} rUv`);
switch (phase) {
case NetworkPhase.GENESIS:
console.log(`\n🌱 Genesis Phase:`);
console.log(` - Genesis nodes establishing network`);
console.log(` - 10x energy multiplier active`);
console.log(` - Target: 10,000 nodes`);
break;
case NetworkPhase.GROWTH:
console.log(`\n🌿 Growth Phase:`);
console.log(` - Genesis multiplier: ${stats.genesisNodes.avgMultiplier.toFixed(2)}x`);
console.log(` - Genesis nodes reducing connections`);
console.log(` - Network self-organizing`);
console.log(` - Target: 50,000 nodes`);
break;
case NetworkPhase.MATURATION:
console.log(`\n🌳 Maturation Phase:`);
console.log(` - Genesis nodes: ${stats.genesisNodes.readOnly} read-only`);
console.log(` - Network operating independently`);
console.log(` - Economic sustainability: ${(stats.economy.totalEarned / Math.max(stats.economy.totalSpent, 1)).toFixed(2)}x`);
console.log(` - Target: 100,000 nodes`);
break;
case NetworkPhase.INDEPENDENCE:
console.log(`\n🚀 Independence Phase:`);
console.log(` - Genesis nodes: ${stats.genesisNodes.retired} retired`);
console.log(` - Pure P2P operation`);
console.log(` - Network fully autonomous`);
console.log(` - Target: Long-term stability`);
break;
}
console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n`);
}
/**
* Get phase progress (0-1)
*/
getPhaseProgress() {
const condition = this.conditions.get(this.network.currentPhase);
if (!condition)
return 0;
const nodeCount = this.network.cells.size;
const range = condition.maxNodes - condition.minNodes;
const progress = (nodeCount - condition.minNodes) / range;
return Math.max(0, Math.min(1, progress));
}
/**
* Get estimated ticks to next phase
*/
getTicksToNextPhase() {
const condition = this.conditions.get(this.network.currentPhase);
if (!condition || condition.maxNodes === Infinity)
return -1;
const nodeCount = this.network.cells.size;
const nodesNeeded = condition.maxNodes - nodeCount;
const ticksNeeded = Math.ceil(nodesNeeded / this.network.config.nodesPerTick);
return Math.max(0, ticksNeeded);
}
}
//# sourceMappingURL=phases.js.map

File diff suppressed because one or more lines are too long

72
examples/edge-net/sim/dist/report.d.ts vendored Normal file
View File

@@ -0,0 +1,72 @@
/**
* Report Generation
* Generates comprehensive JSON reports of simulation results
*/
import { Network } from './network.js';
import { MetricsCollector, PhaseMetrics } from './metrics.js';
export interface SimulationReport {
metadata: {
timestamp: string;
simulationVersion: string;
duration: number;
totalTicks: number;
};
configuration: {
genesisNodeCount: number;
targetNodeCount: number;
nodesPerTick: number;
taskGenerationRate: number;
baseTaskReward: number;
};
summary: {
phasesCompleted: number;
totalPassed: boolean;
phasesPassed: number;
phasesTotal: number;
finalNodeCount: number;
finalPhase: string;
};
phases: {
[key: string]: PhaseMetrics;
};
finalState: {
nodeCount: number;
genesisNodes: any;
economy: any;
network: any;
topPerformers: any[];
};
validation: {
overallPassed: boolean;
criticalIssues: string[];
warnings: string[];
successes: string[];
};
}
export declare class ReportGenerator {
private network;
private metrics;
private startTime;
constructor(network: Network, metrics: MetricsCollector);
/**
* Generate comprehensive simulation report
*/
generateReport(): SimulationReport;
/**
* Get top performing nodes
*/
private getTopPerformers;
/**
* Collect all validation issues
*/
private collectValidation;
/**
* Save report to file
*/
saveReport(filepath: string): void;
/**
* Print summary to console
*/
printSummary(): void;
}
//# sourceMappingURL=report.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"report.d.ts","sourceRoot":"","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O,CAAmB;IAClC,OAAO,CAAC,SAAS,CAAS;gBAEd,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB;IAMvD;;OAEG;IACI,cAAc,IAAI,gBAAgB;IAsDzC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAqBxB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAkCzB;;OAEG;IACI,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAMzC;;OAEG;IACI,YAAY,IAAI,IAAI;CAuD5B"}

177
examples/edge-net/sim/dist/report.js vendored Normal file
View File

@@ -0,0 +1,177 @@
/**
* Report Generation
* Generates comprehensive JSON reports of simulation results
*/
import { writeFileSync } from 'fs';
export class ReportGenerator {
network;
metrics;
startTime;
constructor(network, metrics) {
this.network = network;
this.metrics = metrics;
this.startTime = Date.now();
}
/**
* Generate comprehensive simulation report
*/
generateReport() {
const endTime = Date.now();
const stats = this.network.getStats();
const allMetrics = this.metrics.getAllMetrics();
const overallSuccess = this.metrics.getOverallSuccess();
// Organize metrics by phase
const phaseMetrics = {};
allMetrics.forEach(m => {
phaseMetrics[m.phase] = m;
});
// Get top performing nodes
const topPerformers = this.getTopPerformers(10);
// Collect validation issues
const validation = this.collectValidation(allMetrics);
const report = {
metadata: {
timestamp: new Date().toISOString(),
simulationVersion: '1.0.0',
duration: endTime - this.startTime,
totalTicks: this.network.currentTick,
},
configuration: {
genesisNodeCount: this.network.config.genesisNodeCount,
targetNodeCount: this.network.config.targetNodeCount,
nodesPerTick: this.network.config.nodesPerTick,
taskGenerationRate: this.network.config.taskGenerationRate,
baseTaskReward: this.network.config.baseTaskReward,
},
summary: {
phasesCompleted: allMetrics.length,
totalPassed: overallSuccess.passed,
phasesPassed: overallSuccess.totalPassed,
phasesTotal: overallSuccess.totalPhases,
finalNodeCount: stats.nodeCount,
finalPhase: this.network.currentPhase,
},
phases: phaseMetrics,
finalState: {
nodeCount: stats.nodeCount,
genesisNodes: stats.genesisNodes,
economy: stats.economy,
network: stats.network,
topPerformers,
},
validation,
};
return report;
}
/**
* Get top performing nodes
*/
getTopPerformers(count) {
const cells = Array.from(this.network.cells.values());
return cells
.sort((a, b) => {
const scoreA = a.metrics.energyEarned - a.metrics.energySpent;
const scoreB = b.metrics.energyEarned - b.metrics.energySpent;
return scoreB - scoreA;
})
.slice(0, count)
.map(cell => ({
id: cell.id.substring(0, 8),
type: cell.type,
netEnergy: cell.metrics.energyEarned - cell.metrics.energySpent,
tasksCompleted: cell.metrics.tasksCompleted,
successRate: (cell.metrics.successRate * 100).toFixed(1) + '%',
connections: cell.connectedCells.size,
fitnessScore: cell.getFitnessScore().toFixed(3),
}));
}
/**
* Collect all validation issues
*/
collectValidation(allMetrics) {
const criticalIssues = [];
const warnings = [];
const successes = [];
allMetrics.forEach(metrics => {
if (!metrics.validation.passed) {
criticalIssues.push(`${metrics.phase.toUpperCase()} phase failed validation`);
}
metrics.validation.reasons.forEach(reason => {
if (reason.startsWith('✓')) {
successes.push(`${metrics.phase}: ${reason}`);
}
else if (reason.includes('too low') || reason.includes('insufficient')) {
warnings.push(`${metrics.phase}: ${reason}`);
}
else {
criticalIssues.push(`${metrics.phase}: ${reason}`);
}
});
});
return {
overallPassed: criticalIssues.length === 0,
criticalIssues,
warnings,
successes,
};
}
/**
* Save report to file
*/
saveReport(filepath) {
const report = this.generateReport();
writeFileSync(filepath, JSON.stringify(report, null, 2), 'utf-8');
console.log(`\n📄 Report saved to: ${filepath}`);
}
/**
* Print summary to console
*/
printSummary() {
const report = this.generateReport();
console.log('\n╔════════════════════════════════════════════════════════════╗');
console.log('║ EDGE-NET LIFECYCLE SIMULATION REPORT ║');
console.log('╚════════════════════════════════════════════════════════════╝\n');
console.log('📊 SUMMARY:');
console.log(` Duration: ${(report.metadata.duration / 1000).toFixed(2)}s`);
console.log(` Total Ticks: ${report.metadata.totalTicks.toLocaleString()}`);
console.log(` Final Nodes: ${report.summary.finalNodeCount.toLocaleString()}`);
console.log(` Final Phase: ${report.summary.finalPhase.toUpperCase()}`);
console.log(` Phases Passed: ${report.summary.phasesPassed}/${report.summary.phasesTotal}`);
console.log(` Overall Result: ${report.summary.totalPassed ? '✅ PASSED' : '❌ FAILED'}\n`);
console.log('📈 PHASE RESULTS:');
Object.entries(report.phases).forEach(([phase, metrics]) => {
const icon = metrics.validation.passed ? '✅' : '❌';
console.log(` ${icon} ${phase.toUpperCase()}:`);
console.log(` Nodes: ${metrics.nodeCount.start.toLocaleString()}${metrics.nodeCount.end.toLocaleString()}`);
console.log(` Energy: ${metrics.energy.netEnergy.toFixed(2)} rUv (${metrics.energy.sustainability.toFixed(2)}x sustainable)`);
console.log(` Tasks: ${metrics.network.tasksCompleted.toLocaleString()} completed`);
console.log(` Success Rate: ${(metrics.network.avgSuccessRate * 100).toFixed(1)}%`);
});
console.log('\n🏆 TOP PERFORMERS:');
report.finalState.topPerformers.slice(0, 5).forEach((node, i) => {
console.log(` ${i + 1}. ${node.id} (${node.type})`);
console.log(` Net Energy: ${node.netEnergy.toFixed(2)} rUv | Tasks: ${node.tasksCompleted} | Success: ${node.successRate}`);
});
if (report.validation.criticalIssues.length > 0) {
console.log('\n🚨 CRITICAL ISSUES:');
report.validation.criticalIssues.forEach(issue => {
console.log(`${issue}`);
});
}
if (report.validation.warnings.length > 0) {
console.log('\n⚠ WARNINGS:');
report.validation.warnings.slice(0, 5).forEach(warning => {
console.log(` ⚠️ ${warning}`);
});
if (report.validation.warnings.length > 5) {
console.log(` ... and ${report.validation.warnings.length - 5} more warnings`);
}
}
console.log('\n✅ SUCCESSES:');
report.validation.successes.slice(0, 10).forEach(success => {
console.log(` ${success}`);
});
console.log('\n╚════════════════════════════════════════════════════════════╝\n');
}
}
//# sourceMappingURL=report.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
#!/usr/bin/env node
/**
* Main Simulation Engine
* Orchestrates the complete edge-net lifecycle simulation
*/
export {};
//# sourceMappingURL=simulator.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"simulator.d.ts","sourceRoot":"","sources":["../src/simulator.ts"],"names":[],"mappings":";AACA;;;GAGG"}

131
examples/edge-net/sim/dist/simulator.js vendored Normal file
View File

@@ -0,0 +1,131 @@
#!/usr/bin/env node
/**
* Main Simulation Engine
* Orchestrates the complete edge-net lifecycle simulation
*/
import { Network, NetworkPhase } from './network.js';
import { MetricsCollector } from './metrics.js';
import { PhaseManager } from './phases.js';
import { ReportGenerator } from './report.js';
class EdgeNetSimulator {
network;
metrics;
phaseManager;
reportGenerator;
config;
progressInterval;
constructor(config) {
this.config = config;
this.progressInterval = config.fast ? 1000 : 100;
// Initialize components
this.network = new Network({
genesisNodeCount: 100,
targetNodeCount: 120000,
nodesPerTick: config.fast ? 100 : 10, // Faster node spawning in fast mode
taskGenerationRate: 5,
baseTaskReward: 1.0,
connectionCost: 0.5,
maxConnectionsPerNode: 50,
});
this.metrics = new MetricsCollector(this.network);
this.phaseManager = new PhaseManager(this.network, this.metrics);
this.reportGenerator = new ReportGenerator(this.network, this.metrics);
}
/**
* Run the complete simulation
*/
async run() {
console.log('╔════════════════════════════════════════════════════════════╗');
console.log('║ EDGE-NET LIFECYCLE SIMULATION - Starting... ║');
console.log('╚════════════════════════════════════════════════════════════╝\n');
console.log('⚙️ Configuration:');
console.log(` Genesis Nodes: ${this.network.config.genesisNodeCount}`);
console.log(` Target Nodes: ${this.network.config.targetNodeCount.toLocaleString()}`);
console.log(` Nodes/Tick: ${this.network.config.nodesPerTick}`);
console.log(` Mode: ${this.config.fast ? 'FAST' : 'NORMAL'}`);
console.log('');
// Initialize network with genesis nodes
this.network.initialize();
this.metrics.initialize();
console.log('🌱 Genesis nodes deployed. Starting simulation...\n');
let lastProgressUpdate = 0;
const startTime = Date.now();
// Main simulation loop
while (this.network.currentPhase !== NetworkPhase.INDEPENDENCE ||
this.network.cells.size < this.network.config.targetNodeCount) {
// Simulate one tick
this.network.tick();
this.metrics.collect();
this.phaseManager.checkTransition();
// Progress updates
if (this.network.currentTick - lastProgressUpdate >= this.progressInterval) {
this.printProgress();
lastProgressUpdate = this.network.currentTick;
}
// Safety check - don't run forever
if (this.network.currentTick > 50000) {
console.log('\n⚠ Simulation timeout reached (50,000 ticks)');
break;
}
}
const endTime = Date.now();
const duration = (endTime - startTime) / 1000;
console.log('\n✨ Simulation complete!\n');
console.log(` Total Ticks: ${this.network.currentTick.toLocaleString()}`);
console.log(` Duration: ${duration.toFixed(2)}s`);
console.log(` Final Nodes: ${this.network.cells.size.toLocaleString()}`);
console.log(` Final Phase: ${this.network.currentPhase.toUpperCase()}\n`);
// Finalize metrics
this.metrics.finalizeCurrent();
// Generate and save report
this.reportGenerator.printSummary();
this.reportGenerator.saveReport(this.config.outputFile);
// Exit with appropriate code
const report = this.reportGenerator.generateReport();
process.exit(report.summary.totalPassed ? 0 : 1);
}
/**
* Print simulation progress
*/
printProgress() {
const stats = this.network.getStats();
const progress = this.phaseManager.getPhaseProgress();
const ticksToNext = this.phaseManager.getTicksToNextPhase();
if (this.config.verbose) {
console.log(`[Tick ${this.network.currentTick}] ${this.network.currentPhase.toUpperCase()}`);
console.log(` Nodes: ${stats.nodeCount.toLocaleString()} | Energy: ${stats.economy.totalEnergy.toFixed(2)} rUv`);
console.log(` Tasks: ${stats.tasks.completed.toLocaleString()} | Success: ${(stats.network.avgSuccessRate * 100).toFixed(1)}%`);
console.log(` Genesis: ${stats.genesisNodes.active} active, ${stats.genesisNodes.readOnly} read-only, ${stats.genesisNodes.retired} retired`);
console.log(` Progress: ${(progress * 100).toFixed(1)}% | Next phase: ${ticksToNext >= 0 ? `~${ticksToNext} ticks` : 'N/A'}`);
console.log('');
}
else {
// Compact progress bar
const barLength = 40;
const filled = Math.floor(progress * barLength);
const bar = '█'.repeat(filled) + '░'.repeat(barLength - filled);
process.stdout.write(`\r[${bar}] ${this.network.currentPhase.padEnd(12)} | ` +
`${stats.nodeCount.toLocaleString().padStart(7)} nodes | ` +
`${stats.tasks.completed.toLocaleString().padStart(8)} tasks | ` +
`Genesis: ${stats.genesisNodes.retired}/${stats.genesisNodes.count} retired`);
}
}
}
// Parse command line arguments
function parseArgs() {
const args = process.argv.slice(2);
return {
verbose: args.includes('--verbose') || args.includes('-v'),
fast: args.includes('--fast') || args.includes('-f'),
outputFile: args.find(arg => arg.startsWith('--output='))?.split('=')[1] ||
'/workspaces/ruvector/examples/edge-net/sim/simulation-report.json',
};
}
// Run simulation
const config = parseArgs();
const simulator = new EdgeNetSimulator(config);
simulator.run().catch(error => {
console.error('❌ Simulation failed:', error);
process.exit(1);
});
//# sourceMappingURL=simulator.js.map

File diff suppressed because one or more lines are too long