import { readFileSync } from "fs"; import { join } from "path"; // --- Signal Policy Constants (Extracted from Lean) --- const SIGNAL_BANDS = { QUIET: { weight: 0.0, label: "Quiet" }, ACTIVE: { weight: 1.0, label: "Active" }, STRESSED: { weight: 2.0, label: "Stressed" }, EXTREME: { weight: 3.0, label: "Extreme" } }; // --- Mock Manifold Similarity (Simplified for Simulation) --- function getSim(v1, v2) { return v1.reduce((acc, val, i) => acc + val * (v2[i] || 0), 0); } async function runSimulation() { console.log("=========================================="); console.log("HUTTER SIGNAL ROUTING SIMULATION"); console.log("=========================================="); // 1. Load Hutter Shard Data const reportPath = join(process.cwd(), "docs", "HUTTER_FULL_SHARD_REPORT.json"); const report = JSON.parse(readFileSync(reportPath, "utf8")); // We'll treat the top patches as "Route Candidates" const candidates = report.top_patches.map((p, i) => ({ id: `patch_${p.patch.join("_")}`, raw_score: (p.count / report.patch_total) * 100, // Normalized frequency // Assign a hypothetical vector (Substrate-heavy vs Hardware-heavy) vector: i % 2 === 0 ? [1.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] : [0, 0, 0, 0, 0, 0, 0, 0, 1.0, 0, 0, 0, 0, 0] })); // 2. Define a "Hardware" Query // Searching for things related to FPGA/Hardware (Axis 8) const queryVector = new Array(14).fill(0).map((_, i) => i === 8 ? 1.0 : 0); const testBands = [SIGNAL_BANDS.QUIET, SIGNAL_BANDS.STRESSED, SIGNAL_BANDS.EXTREME]; testBands.forEach(band => { console.log(`\n[Regime: ${band.label}] (Weight: ${band.weight})`); const results = candidates.map(c => { const semanticSim = getSim(queryVector, c.vector); // Applying the Dynamic Transition Law: final_score = semantic + (signal_bias * importance) const biasedScore = semanticSim + (band.weight * (c.raw_score / 10)); return { ...c, biasedScore }; }).sort((a, b) => b.biasedScore - a.biasedScore); console.log(` Top Surfaced Route: ${results[0].id} (Score: ${results[0].biasedScore.toFixed(4)})`); console.log(` Confidence Delta : ${(results[0].biasedScore - results[0].raw_score).toFixed(4)}`); }); // 3. Conclusion console.log("\n--- Simulation Conclusion ---"); console.log("Signal data successfully biases the route without changing the underlying semantic vectors."); console.log("In 'EXTREME' regimes, high-frequency patches (Truth) are promoted over semantic matches (Preference)."); } runSimulation();