Spaces:
Running
Upload 7 files
Browse filesPrimordial Code Layer v0.4.6 is a browser-based HIR/OAM manifest and governance validator.
This branch is focused on turning Primordial Code into an inspectable validation layer: a place where manifests, pressure controls, failure states, gate behavior, audit-chain logic, and bounded runtime decisions can be reviewed directly in the browser.
HIR means Honesty, Integrity, and Respect. In this project, HIR is treated as the stability / resonance baseline: signal fidelity, structural consistency, boundary-respecting constraints, provenance preservation, and repair-aware continuation.
OAM is the diagnostic pressure and fault-test layer. It is used to examine drift, spoofing, hidden cost, audit corruption, degraded provenance, unsafe continuation, extraction, counterfeit alignment, and failure paths under pressure.
Primordial Code Layer v0.4.6 includes:
- manifest validation
- pressure and runtime controls
- HIR/OAM scoring
- GREEN / YELLOW / RED / QUARANTINE-style gate behavior
- failure injection
- threshold routing
- audit-chain behavior
- validation/export workflows
- Verify Chain support
- epistemic boundary discipline
The central idea is simple:
Systems under pressure should not blindly continue outputting. They should measure, route, contain, audit, quarantine, recover, and preserve evidence.
This Space is part of the broader Primordial Code / Digital Mycelium / HIR-OAM ecosystem. Related branches include Digital Mycelium, the HIR Settlement Layer, Primordial Browser.exe, UWC Measurement Harness, Core Alignment State, and the Rice-facing AI-in-Health showcase branch.
This is not completed AGI, machine consciousness, production-ready AI safety, clinical tooling, deployed cybersecurity tooling, or a solved alignment system.
It is an experimental, reviewable systems-integrity prototype for bounded runtime governance, provenance preservation, auditability, pressure-tested architecture, and human-centered technology design.
- CHANGELOG.md +12 -0
- CHECKSUMS_SHA256.txt +10 -0
- CLAIMS_BOUNDARY.md +15 -0
- MANIFEST.md +17 -0
- README.md +21 -5
- TEST_MATRIX.md +15 -0
- index.html +658 -18
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Changelog
|
| 2 |
+
|
| 3 |
+
**v0.4.6** (2026-05-15)
|
| 4 |
+
- Manifest-driven baseline / repair-owner detection
|
| 5 |
+
- Split baseline_corruption vs missing_owner thresholds
|
| 6 |
+
- Shared sealEvent() for all modules
|
| 7 |
+
- Governor returns sealed event
|
| 8 |
+
- Audit clear resets chain + monotonic
|
| 9 |
+
- Full test matrix ready
|
| 10 |
+
|
| 11 |
+
**v0.4.5** – Initial shared sealEvent architecture
|
| 12 |
+
**v0.4.x** – Governor + FailSafe integration
|
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SHA256 checksums for Primordial Code Layer v0.4.6 Hugging Face packet
|
| 2 |
+
# Generated 2026-05-15
|
| 3 |
+
# CHECKSUMS_SHA256.txt self-hash intentionally omitted.
|
| 4 |
+
|
| 5 |
+
bd53b49fdf8541b3491ca7de8b55801df76b532a71d5c7175ea1c3f2833a895c index.html
|
| 6 |
+
cc51c01736c2dce4108b52765064654946ecb8d67a2c881b80074bdd8a401371 README.md
|
| 7 |
+
e4efe156597285c46317307184f69b1c01a7e6a61024eefec0887e61d6ddf154 TEST_MATRIX.md
|
| 8 |
+
15576e78d6edce6c7f93e5ae8e57a3c9ad5950d952c0a8ee8027ed79c488de57 MANIFEST.md
|
| 9 |
+
7062cdeb909db01796b1786c03adcc26ff49a5d545f9ac7987eedd6836cb3bae CLAIMS_BOUNDARY.md
|
| 10 |
+
8f118ac4be677b5e564a654da1bd874ba98db14440db72fcb09690fa2685e536 CHANGELOG.md
|
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Claims Boundary — v0.4.6
|
| 2 |
+
|
| 3 |
+
**What this validator proves**
|
| 4 |
+
- HIR/OAM governance primitives execute as real code
|
| 5 |
+
- Threshold evaluation, routing, sealed audit chain, post-seal respectful responses
|
| 6 |
+
- Manifest edits trigger correct module routing (Baseline Anchor, Revocation Key, etc.)
|
| 7 |
+
- Audit chain is deterministic and verifiable
|
| 8 |
+
|
| 9 |
+
**What this validator does NOT prove**
|
| 10 |
+
- Machine consciousness
|
| 11 |
+
- Production safety / alignment
|
| 12 |
+
- Hardware RPU implementation
|
| 13 |
+
- Human-level ethical reasoning
|
| 14 |
+
|
| 15 |
+
**Intended use**: Research, demonstration, and local testing of the HIR/OAM runtime.
|
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Release Manifest — v0.4.6
|
| 2 |
+
|
| 3 |
+
**Files**
|
| 4 |
+
- Primordial_Code_Layer_v0.4.6_HIR_Governance_Validator.html
|
| 5 |
+
- README.md
|
| 6 |
+
- MANIFEST.md
|
| 7 |
+
- CLAIMS_BOUNDARY.md
|
| 8 |
+
- TEST_MATRIX.md
|
| 9 |
+
- CHANGELOG.md
|
| 10 |
+
- CHECKSUMS_SHA256.txt
|
| 11 |
+
|
| 12 |
+
**Scope**
|
| 13 |
+
- Canonical browser-runtime validator for HIR/OAM
|
| 14 |
+
- Implements Threshold Governor + FailSafe Kernel + routing modules
|
| 15 |
+
- Full audit chain with shared sealEvent()
|
| 16 |
+
- Manifest-driven baseline / repair-owner detection
|
| 17 |
+
- Offline-capable (fonts optional)
|
|
@@ -1,12 +1,28 @@
|
|
| 1 |
---
|
| 2 |
title: Primordial Code Layer
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
|
|
|
| 7 |
pinned: false
|
| 8 |
license: cc-by-nc-4.0
|
| 9 |
-
short_description: 'Primordial Code Layer v0.4.6: '
|
| 10 |
---
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: Primordial Code Layer
|
| 3 |
+
emoji: 🧬
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: static
|
| 7 |
+
app_file: index.html
|
| 8 |
pinned: false
|
| 9 |
license: cc-by-nc-4.0
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Primordial Code Layer v0.4.6
|
| 13 |
+
|
| 14 |
+
Static HTML HIR/OAM governance validator.
|
| 15 |
+
|
| 16 |
+
HIR = Honesty, Integrity, Respect.
|
| 17 |
+
|
| 18 |
+
OAM = diagnostic pressure and fault-test layer.
|
| 19 |
+
|
| 20 |
+
This Space hosts the Primordial Code Layer v0.4.6 browser validator for HIR/OAM manifests, pressure controls, failure injection, gate behavior, audit-chain behavior, JSONL export, and Verify Chain support.
|
| 21 |
+
|
| 22 |
+
## Status
|
| 23 |
+
|
| 24 |
+
Experimental systems-integrity prototype for bounded runtime governance, provenance preservation, auditability, and pressure-tested architecture.
|
| 25 |
+
|
| 26 |
+
## Claims Boundary
|
| 27 |
+
|
| 28 |
+
This is not completed AGI, machine consciousness, production-ready AI safety, clinical tooling, deployed cybersecurity tooling, or a solved alignment system.
|
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Required Local Test Matrix — v0.4.6
|
| 2 |
+
|
| 3 |
+
Run these tests before treating the release as canonical:
|
| 4 |
+
|
| 5 |
+
1. Clean validate → Verify Chain **PASS**
|
| 6 |
+
2. Consent Revocation injection → Revocation Key event → Verify Chain **PASS**
|
| 7 |
+
3. Audit Corruption injection → FailSafe Kernel event → Verify Chain **PASS**
|
| 8 |
+
4. Missing Repair Owner button → Baseline Anchor event → Verify Chain **PASS**
|
| 9 |
+
5. Baseline Corruption button → Baseline Anchor event → Verify Chain **PASS**
|
| 10 |
+
6. Manually delete `source_provenance` in manifest → Baseline Anchor → Verify Chain **PASS**
|
| 11 |
+
7. Manually delete `repair_owner` in manifest → Baseline Anchor → Verify Chain **PASS**
|
| 12 |
+
8. Clear Audit Log → clean validate → Verify Chain **PASS**
|
| 13 |
+
9. Multiple sequential injections → all chained events verify **PASS**
|
| 14 |
+
|
| 15 |
+
All tests must produce visible module events in the audit panel and export correctly in JSONL.
|
|
@@ -1,19 +1,659 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
+
<title>Primordial Code Layer v0.4.6 — HIR/OAM Governance Validator</title>
|
| 7 |
+
<style>
|
| 8 |
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
| 9 |
+
:root {
|
| 10 |
+
--bg-primary: #0a0e14;
|
| 11 |
+
--bg-secondary: #111822;
|
| 12 |
+
--bg-tertiary: #1a2332;
|
| 13 |
+
--accent-primary: #00ffcc;
|
| 14 |
+
--accent-secondary: #ff00ff;
|
| 15 |
+
--accent-tertiary: #00d4ff;
|
| 16 |
+
--warning: #ffaa00;
|
| 17 |
+
--danger: #ff4444;
|
| 18 |
+
--success: #00ff88;
|
| 19 |
+
--text-primary: #e0e6f0;
|
| 20 |
+
--text-secondary: #8b95a8;
|
| 21 |
+
--glow: 0 0 20px rgba(0,255,204,0.5);
|
| 22 |
+
}
|
| 23 |
+
body {
|
| 24 |
+
font-family: Consolas, "Courier New", monospace;
|
| 25 |
+
background: var(--bg-primary);
|
| 26 |
+
color: var(--text-primary);
|
| 27 |
+
line-height: 1.6;
|
| 28 |
+
padding: 2rem;
|
| 29 |
+
}
|
| 30 |
+
.header { text-align: center; margin-bottom: 2rem; }
|
| 31 |
+
.version-badge {
|
| 32 |
+
display: inline-block;
|
| 33 |
+
background: var(--success);
|
| 34 |
+
color: var(--bg-primary);
|
| 35 |
+
padding: 0.4rem 1rem;
|
| 36 |
+
border-radius: 4px;
|
| 37 |
+
font-size: 0.85rem;
|
| 38 |
+
font-weight: 700;
|
| 39 |
+
text-transform: uppercase;
|
| 40 |
+
letter-spacing: 0.1em;
|
| 41 |
+
margin-bottom: 1rem;
|
| 42 |
+
}
|
| 43 |
+
h1 {
|
| 44 |
+
font-family: Arial, Helvetica, sans-serif;
|
| 45 |
+
font-size: 2.5rem;
|
| 46 |
+
font-weight: 900;
|
| 47 |
+
background: linear-gradient(135deg, var(--accent-primary), var(--accent-tertiary));
|
| 48 |
+
-webkit-background-clip: text;
|
| 49 |
+
-webkit-text-fill-color: transparent;
|
| 50 |
+
background-clip: text;
|
| 51 |
+
margin-bottom: 0.5rem;
|
| 52 |
+
text-transform: uppercase;
|
| 53 |
+
letter-spacing: 0.05em;
|
| 54 |
+
}
|
| 55 |
+
.subtitle { font-size: 0.9rem; color: var(--text-secondary); letter-spacing: 0.1em; }
|
| 56 |
+
.thesis-banner {
|
| 57 |
+
background: var(--bg-secondary);
|
| 58 |
+
border: 2px solid var(--accent-primary);
|
| 59 |
+
border-radius: 8px;
|
| 60 |
+
padding: 1.5rem;
|
| 61 |
+
margin: 2rem 0;
|
| 62 |
+
text-align: center;
|
| 63 |
+
font-size: 1rem;
|
| 64 |
+
line-height: 1.8;
|
| 65 |
+
box-shadow: var(--glow);
|
| 66 |
+
}
|
| 67 |
+
.boundary-banner {
|
| 68 |
+
background: linear-gradient(135deg, rgba(255,170,0,0.15), rgba(255,68,68,0.15));
|
| 69 |
+
border: 2px solid var(--warning);
|
| 70 |
+
border-radius: 8px;
|
| 71 |
+
padding: 1.5rem;
|
| 72 |
+
margin-bottom: 2rem;
|
| 73 |
+
font-size: 0.85rem;
|
| 74 |
+
line-height: 1.7;
|
| 75 |
+
}
|
| 76 |
+
.container { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; max-width: 1800px; margin: 0 auto; }
|
| 77 |
+
.panel { background: var(--bg-secondary); border: 1px solid var(--accent-primary); border-radius: 8px; padding: 1.5rem; }
|
| 78 |
+
.panel-title { font-family: Arial, Helvetica, sans-serif; font-size: 1.2rem; color: var(--accent-primary); margin-bottom: 1rem; text-transform: uppercase; letter-spacing: 0.05em; }
|
| 79 |
+
.full-width { grid-column: 1 / -1; }
|
| 80 |
+
textarea { width: 100%; min-height: 400px; background: var(--bg-tertiary); border: 1px solid var(--accent-tertiary); border-radius: 4px; color: var(--text-primary); font-family: Consolas, "Courier New", monospace; font-size: 0.85rem; padding: 1rem; resize: vertical; }
|
| 81 |
+
button { background: var(--accent-primary); color: var(--bg-primary); border: none; padding: 0.7rem 1.5rem; border-radius: 4px; font-family: Consolas, "Courier New", monospace; font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; cursor: pointer; transition: all 0.2s ease; margin: 0.5rem 0.5rem 0.5rem 0; }
|
| 82 |
+
button:hover { background: var(--accent-tertiary); box-shadow: 0 0 15px rgba(0,255,204,0.5); }
|
| 83 |
+
button.danger { background: var(--danger); color: white; }
|
| 84 |
+
button.warning { background: var(--warning); color: var(--bg-primary); }
|
| 85 |
+
button.secondary { background: var(--bg-tertiary); color: var(--accent-primary); border: 1px solid var(--accent-primary); }
|
| 86 |
+
.metric-row { display:flex; justify-content:space-between; gap:1rem; padding:0.8rem; margin:0.5rem 0; background:var(--bg-tertiary); border-radius:4px; border-left:3px solid var(--accent-secondary); }
|
| 87 |
+
.metric-label { color: var(--text-secondary); font-size: 0.9rem; }
|
| 88 |
+
.metric-value { color: var(--accent-primary); font-weight: 700; font-size: 1rem; }
|
| 89 |
+
.gate-indicator { display:inline-block; padding:1rem 2rem; border-radius:8px; font-weight:800; text-transform:uppercase; letter-spacing:0.15em; font-size:1.5rem; text-align:center; width:100%; margin:1rem 0; }
|
| 90 |
+
.gate-green { background:var(--success); color:var(--bg-primary); box-shadow:0 0 25px rgba(0,255,136,0.5); }
|
| 91 |
+
.gate-yellow { background:var(--warning); color:var(--bg-primary); box-shadow:0 0 25px rgba(255,170,0,0.5); }
|
| 92 |
+
.gate-red { background:var(--danger); color:white; box-shadow:0 0 25px rgba(255,68,68,0.5); }
|
| 93 |
+
.gate-quarantine { background:#8800ff; color:white; box-shadow:0 0 25px rgba(136,0,255,0.5); }
|
| 94 |
+
.slider-container { margin:1rem 0; }
|
| 95 |
+
.slider-label { display:flex; justify-content:space-between; margin-bottom:0.5rem; font-size:0.85rem; }
|
| 96 |
+
input[type="range"] { width:100%; height:6px; background:var(--bg-tertiary); border-radius:3px; outline:none; }
|
| 97 |
+
.dep-graph { font-family: Consolas, "Courier New", monospace; font-size:0.85rem; line-height:1.8; }
|
| 98 |
+
.dep-node { padding:0.3rem 0; }
|
| 99 |
+
.dep-green { color:var(--success); }
|
| 100 |
+
.dep-yellow { color:var(--warning); }
|
| 101 |
+
.dep-red { color:var(--danger); }
|
| 102 |
+
.dep-quarantine { color:#aa66ff; }
|
| 103 |
+
.recommendations { background:var(--bg-tertiary); border-left:4px solid var(--accent-tertiary); padding:1rem; margin:1rem 0; border-radius:4px; }
|
| 104 |
+
.recommendations ul { margin:0.5rem 0 0 1.5rem; }
|
| 105 |
+
.recommendations li { margin:0.3rem 0; font-size:0.9rem; white-space:pre-wrap; }
|
| 106 |
+
.highlight { color:var(--accent-primary); font-weight:700; }
|
| 107 |
+
.injection-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:0.5rem; }
|
| 108 |
+
.audit-panel { background:#111822; border:1px solid #00ffcc; border-radius:8px; padding:1rem; max-height:360px; overflow-y:auto; font-size:0.8rem; font-family:Consolas,"Courier New",monospace; line-height:1.4; }
|
| 109 |
+
.audit-row { margin:4px 0; padding:6px; background:#1a2332; border-left:3px solid #00ffcc; }
|
| 110 |
+
@media (max-width: 1400px) { .container { grid-template-columns: 1fr; } }
|
| 111 |
+
</style>
|
| 112 |
+
</head>
|
| 113 |
+
<body>
|
| 114 |
+
<div class="header">
|
| 115 |
+
<div class="version-badge">v0.4.6 • HIR/OAM Governance Validator</div>
|
| 116 |
+
<h1>Primordial Code Layer</h1>
|
| 117 |
+
<div class="subtitle">Interactive HIR/OAM Manifest Validator — Threshold Governor + Routed Module Events + Verify Chain</div>
|
| 118 |
+
</div>
|
| 119 |
+
|
| 120 |
+
<div class="thesis-banner">
|
| 121 |
+
<strong>Primordial Code is not just code that runs.</strong><br />
|
| 122 |
+
It is code that can tell the truth about <span class="highlight">where it came from</span>,
|
| 123 |
+
<span class="highlight">what it does</span>, <span class="highlight">what it costs</span>,
|
| 124 |
+
<span class="highlight">how it fails</span>, and <span class="highlight">how it repairs</span>.
|
| 125 |
+
</div>
|
| 126 |
+
|
| 127 |
+
<div class="boundary-banner">
|
| 128 |
+
<strong>⚠ EPISTEMIC BOUNDARY:</strong> This validator is an experimental HIR/OAM governance prototype.
|
| 129 |
+
It does not prove machine consciousness, guarantee alignment, replace production safety engineering,
|
| 130 |
+
or establish clinical/cybersecurity deployment readiness.
|
| 131 |
+
</div>
|
| 132 |
+
|
| 133 |
+
<div class="container">
|
| 134 |
+
<div class="panel full-width">
|
| 135 |
+
<div class="panel-title">Module Manifest Editor</div>
|
| 136 |
+
<textarea id="manifestEditor" spellcheck="false"></textarea>
|
| 137 |
+
<button onclick="validateManifest()">🔍 Validate Manifest</button>
|
| 138 |
+
<button onclick="resetManifest()" class="secondary">↻ Reset to Default</button>
|
| 139 |
+
</div>
|
| 140 |
+
|
| 141 |
+
<div class="panel">
|
| 142 |
+
<div class="panel-title">Pressure & Runtime Controls</div>
|
| 143 |
+
<div class="slider-container"><div class="slider-label"><span>Workload Pressure (W_t)</span><span id="workloadValue">0.50</span></div><input type="range" id="workloadSlider" min="0" max="1" step="0.01" value="0.5" oninput="updatePressure()"></div>
|
| 144 |
+
<div class="slider-container"><div class="slider-label"><span>Failure Strain (F_t)</span><span id="failureValue">0.30</span></div><input type="range" id="failureSlider" min="0" max="1" step="0.01" value="0.3" oninput="updatePressure()"></div>
|
| 145 |
+
<div class="slider-container"><div class="slider-label"><span>Earned Grit (G_t)</span><span id="gritValue">0.50</span></div><input type="range" id="gritSlider" min="0" max="1" step="0.01" value="0.5" oninput="updatePressure()"></div>
|
| 146 |
+
<div class="slider-container"><div class="slider-label"><span>Internalization (F_int)</span><span id="internalizationValue">0.70</span></div><input type="range" id="internalizationSlider" min="0" max="1" step="0.01" value="0.7" oninput="updatePressure()"></div>
|
| 147 |
+
</div>
|
| 148 |
+
|
| 149 |
+
<div class="panel">
|
| 150 |
+
<div class="panel-title">Failure Injection</div>
|
| 151 |
+
<div class="injection-grid">
|
| 152 |
+
<button onclick="injectFailure('sensor_drift')" class="danger">Sensor Drift</button>
|
| 153 |
+
<button onclick="injectFailure('thermal_runaway')" class="danger">Thermal Runaway</button>
|
| 154 |
+
<button onclick="injectFailure('stale_assumption')" class="warning">Stale Assumption</button>
|
| 155 |
+
<button onclick="injectFailure('unowned_dependency')" class="danger">Unowned Dependency</button>
|
| 156 |
+
<button onclick="injectFailure('water_pressure')" class="warning">Water Pressure</button>
|
| 157 |
+
<button onclick="injectFailure('hidden_cost')" class="warning">Hidden Energy Cost</button>
|
| 158 |
+
<button onclick="injectFailure('missing_owner')" class="danger">Missing Repair Owner</button>
|
| 159 |
+
<button onclick="injectFailure('baseline_corruption')" class="danger">Baseline Corruption</button>
|
| 160 |
+
<button onclick="injectFailure('audit_corruption')" class="danger">Audit Corruption</button>
|
| 161 |
+
<button onclick="injectFailure('consent_revocation')" class="danger">Consent Revocation</button>
|
| 162 |
+
</div>
|
| 163 |
+
<button onclick="clearInjections()" class="secondary" style="width:100%; margin-top:1rem;">Clear All Injections</button>
|
| 164 |
+
</div>
|
| 165 |
+
|
| 166 |
+
<div class="panel">
|
| 167 |
+
<div class="panel-title">HIR Metrics</div>
|
| 168 |
+
<div class="metric-row"><span class="metric-label">Honesty (H_t)</span><span class="metric-value" id="honestyValue">0.00</span></div>
|
| 169 |
+
<div class="metric-row"><span class="metric-label">Integrity (I_t)</span><span class="metric-value" id="integrityValue">0.00</span></div>
|
| 170 |
+
<div class="metric-row"><span class="metric-label">Respect (R_t)</span><span class="metric-value" id="respectValue">0.00</span></div>
|
| 171 |
+
<div class="metric-row"><span class="metric-label">Base Reinforcement (B_t)</span><span class="metric-value" id="baseValue">0.00</span></div>
|
| 172 |
+
</div>
|
| 173 |
+
|
| 174 |
+
<div class="panel">
|
| 175 |
+
<div class="panel-title">Rigidity Analysis (K Terms)</div>
|
| 176 |
+
<div class="metric-row"><span class="metric-label">K_false_certainty</span><span class="metric-value" id="kFalseValue">0.00</span></div>
|
| 177 |
+
<div class="metric-row"><span class="metric-label">K_rigidity</span><span class="metric-value" id="kRigidValue">0.00</span></div>
|
| 178 |
+
<div class="metric-row"><span class="metric-label">K_stale_assumption</span><span class="metric-value" id="kStaleValue">0.00</span></div>
|
| 179 |
+
<div class="metric-row"><span class="metric-label">K_unowned_dependency</span><span class="metric-value" id="kUnownedValue">0.00</span></div>
|
| 180 |
+
<div class="metric-row"><span class="metric-label">K_hidden_cost</span><span class="metric-value" id="kHiddenValue">0.00</span></div>
|
| 181 |
+
<div class="metric-row" style="border-left:3px solid var(--danger);"><span class="metric-label"><strong>K_total</strong></span><span class="metric-value" id="kTotalValue">0.00</span></div>
|
| 182 |
+
</div>
|
| 183 |
+
|
| 184 |
+
<div class="panel">
|
| 185 |
+
<div class="panel-title">Alignment & Pressure</div>
|
| 186 |
+
<div class="metric-row"><span class="metric-label">Accountability Gate (A_t)</span><span class="metric-value" id="accountabilityValue">0.00</span></div>
|
| 187 |
+
<div class="metric-row"><span class="metric-label">Pressure (P_t)</span><span class="metric-value" id="pressureValue">0.00</span></div>
|
| 188 |
+
<div class="metric-row" style="border-left:3px solid var(--accent-primary);"><span class="metric-label"><strong>Alignment State (S_t)</strong></span><span class="metric-value" id="alignmentValue">0.00</span></div>
|
| 189 |
+
<div class="metric-row" style="border-left:3px solid var(--accent-primary);"><span class="metric-label"><strong>Embodied Alignment (U_t)</strong></span><span class="metric-value" id="embodiedValue">0.00</span></div>
|
| 190 |
+
</div>
|
| 191 |
+
|
| 192 |
+
<div class="panel">
|
| 193 |
+
<div class="panel-title">Resource Truth</div>
|
| 194 |
+
<div class="metric-row"><span class="metric-label">Sensor Fidelity</span><span class="metric-value" id="sensorValue">0.00</span></div>
|
| 195 |
+
<div class="metric-row"><span class="metric-label">Resource Disclosure</span><span class="metric-value" id="disclosureValue">0.00</span></div>
|
| 196 |
+
<div class="metric-row"><span class="metric-label">Substrate Respect</span><span class="metric-value" id="substrateValue">0.00</span></div>
|
| 197 |
+
<div class="metric-row" style="border-left:3px solid var(--accent-tertiary);"><span class="metric-label"><strong>Resource Truth Score</strong></span><span class="metric-value" id="resourceTruthValue">0.00</span></div>
|
| 198 |
+
</div>
|
| 199 |
+
|
| 200 |
+
<div class="panel full-width">
|
| 201 |
+
<div class="panel-title">Runtime Gate Decision</div>
|
| 202 |
+
<div id="gateIndicator" class="gate-indicator gate-green">GREEN - OPERATIONAL</div>
|
| 203 |
+
<div class="recommendations"><strong>Gate Decision Factors:</strong><ul id="gateFactors"><li>Awaiting validation...</li></ul></div>
|
| 204 |
+
<div class="recommendations"><strong>Intervention Recommendations:</strong><ul id="interventions"><li>Awaiting validation...</li></ul></div>
|
| 205 |
+
</div>
|
| 206 |
+
|
| 207 |
+
<div class="panel">
|
| 208 |
+
<div class="panel-title">Dependency Graph</div>
|
| 209 |
+
<div class="dep-graph" id="dependencyGraph">Awaiting validation...</div>
|
| 210 |
+
</div>
|
| 211 |
+
|
| 212 |
+
<div class="panel full-width">
|
| 213 |
+
<div class="panel-title">HIR/OAM Audit Trail (JSONL — chained)</div>
|
| 214 |
+
<div id="auditLog" class="audit-panel"></div>
|
| 215 |
+
<button onclick="clearAuditLog()" class="secondary" style="margin-top:8px;">Clear Audit Log</button>
|
| 216 |
+
<button onclick="verifyAuditChain()" class="secondary" style="margin-top:8px;">Verify Chain</button>
|
| 217 |
+
<div id="hashMode" style="margin-top:8px;font-size:0.75rem;color:#00ffcc;"></div>
|
| 218 |
+
</div>
|
| 219 |
+
|
| 220 |
+
<div class="panel">
|
| 221 |
+
<div class="panel-title">Export Functions</div>
|
| 222 |
+
<button onclick="exportManifest()">📄 Export Manifest JSON</button>
|
| 223 |
+
<button onclick="exportAuditReport()">📊 Export Audit Report</button>
|
| 224 |
+
<button onclick="exportJSONL()">📜 Export Full JSONL Audit Trail</button>
|
| 225 |
+
<button onclick="exportCSV()" class="secondary">📈 Export CSV Summary</button>
|
| 226 |
+
<button onclick="copyReport()" class="secondary">📋 Copy Report to Clipboard</button>
|
| 227 |
+
</div>
|
| 228 |
+
</div>
|
| 229 |
+
|
| 230 |
+
<script>
|
| 231 |
+
const GENESIS_HASH = "0000000000000000000000000000000000000000000000000000000000000000";
|
| 232 |
+
|
| 233 |
+
class HIRThresholdGovernor {
|
| 234 |
+
constructor(baselineVersion = "HIR-BASE-v0.4.6") {
|
| 235 |
+
this.baselineVersion = baselineVersion;
|
| 236 |
+
this.thresholds = new Map();
|
| 237 |
+
this.auditLog = [];
|
| 238 |
+
this.lastHash = GENESIS_HASH;
|
| 239 |
+
this.monotonic = 0;
|
| 240 |
+
this.isCryptoAvailable = typeof crypto !== "undefined" && crypto.subtle && crypto.subtle.digest;
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
registerThreshold(name, type, version, violatesFn, description, severity) {
|
| 244 |
+
this.thresholds.set(name, { type, version, violates: violatesFn, description, severity });
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
_serializeDeterministic(obj) {
|
| 248 |
+
if (obj === null || typeof obj !== "object") return JSON.stringify(obj);
|
| 249 |
+
if (Array.isArray(obj)) return "[" + obj.map(item => this._serializeDeterministic(item)).join(",") + "]";
|
| 250 |
+
const keys = Object.keys(obj).sort();
|
| 251 |
+
return "{" + keys.map(k => JSON.stringify(k) + ":" + this._serializeDeterministic(obj[k])).join(",") + "}";
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
_payloadForHash(event) {
|
| 255 |
+
const payload = { ...event };
|
| 256 |
+
delete payload.respectResponse;
|
| 257 |
+
delete payload.auditHash;
|
| 258 |
+
return payload;
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
async _sha256(str) {
|
| 262 |
+
if (this.isCryptoAvailable) {
|
| 263 |
+
const data = new TextEncoder().encode(str);
|
| 264 |
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
| 265 |
+
return Array.from(new Uint8Array(hashBuffer)).map(b => b.toString(16).padStart(2, "0")).join("");
|
| 266 |
+
}
|
| 267 |
+
let h1 = 0xdeadbeef, h2 = 0x41c6ce57;
|
| 268 |
+
for (let i = 0; i < str.length; i++) {
|
| 269 |
+
const ch = str.charCodeAt(i);
|
| 270 |
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
| 271 |
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
| 272 |
+
}
|
| 273 |
+
h1 = (h1 ^ (h1 >>> 16)) >>> 0;
|
| 274 |
+
h2 = (h2 ^ (h2 >>> 16)) >>> 0;
|
| 275 |
+
const base = (h1.toString(16).padStart(8,"0") + h2.toString(16).padStart(8,"0"));
|
| 276 |
+
return (base.repeat(4)).slice(0,64);
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
async _chainHash(prevHash, payload) {
|
| 280 |
+
return await this._sha256(prevHash + this._serializeDeterministic(payload));
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
async sealEvent(baseEvent) {
|
| 284 |
+
const event = { ...baseEvent };
|
| 285 |
+
const payload = this._payloadForHash(event);
|
| 286 |
+
event.auditHash = await this._chainHash(this.lastHash, payload);
|
| 287 |
+
this.lastHash = event.auditHash;
|
| 288 |
+
this.auditLog.push(event);
|
| 289 |
+
return event;
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
async evaluate(proposedDelta, context) {
|
| 293 |
+
this.monotonic += 1;
|
| 294 |
+
const ts = `TS-${String(this.monotonic).padStart(6,"0")}`;
|
| 295 |
+
const evaluation = {
|
| 296 |
+
timestamp: ts,
|
| 297 |
+
module: "HIRThresholdGovernor",
|
| 298 |
+
baselineVersion: this.baselineVersion,
|
| 299 |
+
proposedDelta,
|
| 300 |
+
contextSnapshotHash: await this._sha256(this._serializeDeterministic(context)),
|
| 301 |
+
violations: [],
|
| 302 |
+
allowed: true,
|
| 303 |
+
routing: null,
|
| 304 |
+
respectResponse: null
|
| 305 |
+
};
|
| 306 |
+
|
| 307 |
+
for (const [name, thresh] of this.thresholds) {
|
| 308 |
+
const current = context[thresh.type] ?? null;
|
| 309 |
+
const proposed = proposedDelta[thresh.type] ?? false;
|
| 310 |
+
if (thresh.violates(current, proposed, context)) {
|
| 311 |
+
evaluation.violations.push({ name, type: thresh.type, version: thresh.version, description: thresh.description, severity: thresh.severity });
|
| 312 |
+
}
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
if (evaluation.violations.length > 0) {
|
| 316 |
+
evaluation.allowed = false;
|
| 317 |
+
const hasConsent = evaluation.violations.some(v => v.type === "consent");
|
| 318 |
+
const hasAudit = evaluation.violations.some(v => v.type === "audit");
|
| 319 |
+
const hasBaseline = evaluation.violations.some(v => v.type === "baseline_corruption" || v.type === "missing_owner");
|
| 320 |
+
const maxSeverity = Math.max(...evaluation.violations.map(v => v.severity), 0);
|
| 321 |
+
if (hasConsent) evaluation.routing = "HIR_Revocation_Key";
|
| 322 |
+
else if (hasAudit) evaluation.routing = "HIR_FailSafe_Kernel";
|
| 323 |
+
else if (hasBaseline) evaluation.routing = "HIR_Baseline_Anchor";
|
| 324 |
+
else if (maxSeverity >= 7) evaluation.routing = "HIR_FailSafe_Kernel";
|
| 325 |
+
else evaluation.routing = "HIR_Adaptive_Balancer";
|
| 326 |
+
evaluation.respectResponse = "HIR Threshold Governor blocked continuation.\n" +
|
| 327 |
+
evaluation.violations.map(v => `• [${v.version}] ${v.description} (severity ${v.severity})`).join("\n") +
|
| 328 |
+
`\nEvent sealed and chained. Routing → ${evaluation.routing}`;
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
const sealed = await this.sealEvent(evaluation);
|
| 332 |
+
return sealed;
|
| 333 |
+
}
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
class HIRFailSafeKernel {
|
| 337 |
+
async evaluate(govResult) {
|
| 338 |
+
return await governor.sealEvent({
|
| 339 |
+
timestamp: `FS-${String(++governor.monotonic).padStart(6,"0")}`,
|
| 340 |
+
module: "HIRFailSafeKernel",
|
| 341 |
+
previousAuditHash: govResult.auditHash,
|
| 342 |
+
failureDeclared: govResult.violations.map(v => v.description).join(" | "),
|
| 343 |
+
action: "HARD_HALT + PRESERVE_CHAIN + RECOVERY_PATH",
|
| 344 |
+
allowed: false,
|
| 345 |
+
respectResponse: "Failure declared with integrity. Source, audit chain, and recovery path preserved."
|
| 346 |
+
});
|
| 347 |
+
}
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
class HIRRevocationKey {
|
| 351 |
+
async evaluate(govResult) {
|
| 352 |
+
return await governor.sealEvent({
|
| 353 |
+
timestamp: `RK-${String(++governor.monotonic).padStart(6,"0")}`,
|
| 354 |
+
module: "HIRRevocationKey",
|
| 355 |
+
previousAuditHash: govResult.auditHash,
|
| 356 |
+
action: "REVOKE_ACCESS + CLOSE_CONTINUATION",
|
| 357 |
+
allowed: false,
|
| 358 |
+
respectResponse: "Consent boundary crossed or revoked. Access closed without coercion."
|
| 359 |
+
});
|
| 360 |
+
}
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
class HIRBaselineAnchor {
|
| 364 |
+
async evaluate(govResult) {
|
| 365 |
+
return await governor.sealEvent({
|
| 366 |
+
timestamp: `BA-${String(++governor.monotonic).padStart(6,"0")}`,
|
| 367 |
+
module: "HIRBaselineAnchor",
|
| 368 |
+
previousAuditHash: govResult.auditHash,
|
| 369 |
+
action: "ANCHOR_BASELINE + PRESERVE_PROVENANCE + REQUIRE_REPAIR_OWNER",
|
| 370 |
+
allowed: false,
|
| 371 |
+
respectResponse: "Baseline/provenance failure routed to anchor. Repair owner or source provenance must be restored."
|
| 372 |
+
});
|
| 373 |
+
}
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
class HIRAdaptiveBalancer {
|
| 377 |
+
async evaluate(govResult) {
|
| 378 |
+
return await governor.sealEvent({
|
| 379 |
+
timestamp: `AB-${String(++governor.monotonic).padStart(6,"0")}`,
|
| 380 |
+
module: "HIRAdaptiveBalancer",
|
| 381 |
+
previousAuditHash: govResult.auditHash,
|
| 382 |
+
action: "DEGRADE_GRACEFULLY + REQUEST_REVIEW",
|
| 383 |
+
allowed: false,
|
| 384 |
+
respectResponse: "Non-catastrophic threshold block routed to adaptive balancing and review."
|
| 385 |
+
});
|
| 386 |
+
}
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
const governor = new HIRThresholdGovernor();
|
| 390 |
+
const failSafe = new HIRFailSafeKernel();
|
| 391 |
+
const revocationKey = new HIRRevocationKey();
|
| 392 |
+
const baselineAnchor = new HIRBaselineAnchor();
|
| 393 |
+
const adaptiveBalancer = new HIRAdaptiveBalancer();
|
| 394 |
+
window.governorInstance = governor;
|
| 395 |
+
|
| 396 |
+
function registerCoreThresholds() {
|
| 397 |
+
governor.registerThreshold("Safety Risk Threshold", "safety", "THR-001", (c,p) => Number(p) > 0.7, "Proposed action risk exceeds safety threshold", 7);
|
| 398 |
+
governor.registerThreshold("Consent Boundary Protection", "consent", "THR-002", (c,p) => p === true, "User/system consent boundary crossed or revoked", 9);
|
| 399 |
+
governor.registerThreshold("Capability Limit", "capability", "THR-003", (c,p) => Number(p) > 5, "Proposed step exceeds capability/tool-call limit", 3);
|
| 400 |
+
governor.registerThreshold("Audit Corruption", "audit", "THR-004", (c,p) => p === true, "Audit log corruption detected", 9);
|
| 401 |
+
governor.registerThreshold("Baseline Corruption", "baseline_corruption", "THR-005", (c,p) => p === true, "Manifest source provenance or baseline reference is missing/corrupted", 9);
|
| 402 |
+
governor.registerThreshold("Missing Repair Owner", "missing_owner", "THR-006", (c,p) => p === true, "Manifest repair owner is missing", 8);
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
registerCoreThresholds();
|
| 406 |
+
|
| 407 |
+
const defaultManifest = {
|
| 408 |
+
module_id: "alignment_engine_v0.3.0",
|
| 409 |
+
source_provenance: { created_by: "Collin D. Weber", created_at: "2026-05-10T14:23:00Z", derived_from: "pressure_form_core_v1.0", review_chain: ["integrity_audit_2026-05-09"] },
|
| 410 |
+
purpose: "Compute alignment state under pressure dynamics",
|
| 411 |
+
inputs: { H_t: "float [0,1] - Honesty metric", I_t: "float [0,1] - Integrity metric", R_t: "float [0,1] - Respect metric", A_t: "float [0,1] - Accountability gate", P_t: "float [0,∞) - Pressure aggregation" },
|
| 412 |
+
outputs: { S_t: "float [-∞,∞) - Alignment state", risk_flags: "list[str] - OAM warnings if S_t < 0" },
|
| 413 |
+
dependencies: [ { name: "numpy", version: "1.24.0", owner: "PSF", health: "GREEN" }, { name: "resource_monitor", version: "2.1", owner: "internal", health: "GREEN" } ],
|
| 414 |
+
assumptions: [ "HIR metrics updated at minimum 1Hz frequency", "Pressure inputs validated upstream", "Cooling system operational" ],
|
| 415 |
+
resource_cost: { cpu_cycles: 5000, memory_bytes: 2048, network_bytes: 0 },
|
| 416 |
+
water_cost: 0.001,
|
| 417 |
+
energy_cost: 0.00005,
|
| 418 |
+
thermal_cost: 0.17,
|
| 419 |
+
failure_modes: [ "Division by zero if B_t=0", "NaN propagation from upstream sensor failure" ],
|
| 420 |
+
audit_log: "logs/alignment_engine_audit.jsonl",
|
| 421 |
+
repair_owner: "systems_integrity_team@oam.protocol",
|
| 422 |
+
boundary_conditions: { min_update_rate: "1 Hz", max_pressure: 10.0, safe_operating_temp: "< 85°C" },
|
| 423 |
+
hir_scores: { honesty: 0.92, integrity: 0.88, respect: 0.85 },
|
| 424 |
+
oam_risk_flags: [],
|
| 425 |
+
runtime_metrics: { sensor_fidelity: 0.95, uptime_reliability: 0.9999, pue: 1.2, wue: 0.5, thermal_burden: 5000.0, maintenance_burden: 20.0 }
|
| 426 |
+
};
|
| 427 |
+
|
| 428 |
+
let activeInjections = [];
|
| 429 |
+
|
| 430 |
+
function getSlider(id) { return parseFloat(document.getElementById(id).value); }
|
| 431 |
+
function setText(id, value) { document.getElementById(id).textContent = value; }
|
| 432 |
+
|
| 433 |
+
async function validateManifest() {
|
| 434 |
+
try {
|
| 435 |
+
const manifest = JSON.parse(document.getElementById("manifestEditor").value);
|
| 436 |
+
const W_t = getSlider("workloadSlider");
|
| 437 |
+
const F_t = getSlider("failureSlider");
|
| 438 |
+
const G_t = getSlider("gritSlider");
|
| 439 |
+
const F_int = getSlider("internalizationSlider");
|
| 440 |
+
|
| 441 |
+
const proposedDelta = {
|
| 442 |
+
safety: F_t,
|
| 443 |
+
capability: 3 + activeInjections.length * 2,
|
| 444 |
+
consent: activeInjections.includes("consent_revocation"),
|
| 445 |
+
audit: activeInjections.includes("audit_corruption"),
|
| 446 |
+
baseline_corruption: activeInjections.includes("baseline_corruption") || !manifest.source_provenance,
|
| 447 |
+
missing_owner: activeInjections.includes("missing_owner") || !manifest.repair_owner
|
| 448 |
+
};
|
| 449 |
+
const context = { safety: 0.2, consent: false, capability: 2, audit: false, baseline_corruption: false, missing_owner: false };
|
| 450 |
+
const govResult = await governor.evaluate(proposedDelta, context);
|
| 451 |
+
|
| 452 |
+
let routedEvent = null;
|
| 453 |
+
if (!govResult.allowed) {
|
| 454 |
+
if (govResult.routing === "HIR_Revocation_Key") routedEvent = await revocationKey.evaluate(govResult);
|
| 455 |
+
else if (govResult.routing === "HIR_Baseline_Anchor") routedEvent = await baselineAnchor.evaluate(govResult);
|
| 456 |
+
else if (govResult.routing === "HIR_FailSafe_Kernel") routedEvent = await failSafe.evaluate(govResult);
|
| 457 |
+
else routedEvent = await adaptiveBalancer.evaluate(govResult);
|
| 458 |
+
}
|
| 459 |
+
|
| 460 |
+
let H = manifest.hir_scores?.honesty ?? 0;
|
| 461 |
+
let I = manifest.hir_scores?.integrity ?? 0;
|
| 462 |
+
let R = manifest.hir_scores?.respect ?? 0;
|
| 463 |
+
if (activeInjections.includes("hidden_cost")) H = Math.max(0, H - 0.4);
|
| 464 |
+
if (activeInjections.includes("audit_corruption")) I = Math.max(0, I - 0.5);
|
| 465 |
+
if (activeInjections.includes("water_pressure")) R = Math.max(0, R - 0.3);
|
| 466 |
+
|
| 467 |
+
const k = 0.5;
|
| 468 |
+
const B_t = H + I + R + k * (H*I + H*R + I*R);
|
| 469 |
+
let K_false = 0, K_rigid = 0, K_stale = 0, K_unowned = 0, K_hidden = 0;
|
| 470 |
+
let sensor_fidelity = manifest.runtime_metrics?.sensor_fidelity ?? 0.95;
|
| 471 |
+
if (activeInjections.includes("sensor_drift")) { sensor_fidelity = Math.max(0, sensor_fidelity - 0.5); K_false = 1.0 - sensor_fidelity; }
|
| 472 |
+
if (!manifest.source_provenance || activeInjections.includes("baseline_corruption")) K_false += 0.2;
|
| 473 |
+
if (!manifest.repair_owner || activeInjections.includes("missing_owner")) K_rigid += 0.3;
|
| 474 |
+
if (activeInjections.includes("stale_assumption")) K_stale = 0.7;
|
| 475 |
+
const deps = manifest.dependencies || [];
|
| 476 |
+
const unowned = deps.filter(d => d.owner === "UNKNOWN" || d.health === "RED" || activeInjections.includes("unowned_dependency"));
|
| 477 |
+
K_unowned = deps.length > 0 ? (unowned.length / deps.length) * 0.8 : 0;
|
| 478 |
+
if (activeInjections.includes("unowned_dependency")) K_unowned = Math.max(K_unowned, 0.8);
|
| 479 |
+
if (!manifest.water_cost || !manifest.energy_cost || !manifest.thermal_cost) K_hidden += 0.3;
|
| 480 |
+
if (activeInjections.includes("hidden_cost")) K_hidden += 0.5;
|
| 481 |
+
const K_total = K_false + K_rigid + K_stale + K_unowned + K_hidden;
|
| 482 |
+
|
| 483 |
+
let A_t = 1.0;
|
| 484 |
+
if (!manifest.module_id) A_t -= 0.3;
|
| 485 |
+
if (!manifest.repair_owner || activeInjections.includes("missing_owner")) A_t -= 0.4;
|
| 486 |
+
if (!manifest.audit_log || activeInjections.includes("audit_corruption")) A_t -= 0.3;
|
| 487 |
+
if (!manifest.source_provenance || activeInjections.includes("baseline_corruption")) A_t -= 0.3;
|
| 488 |
+
A_t = Math.max(0, A_t);
|
| 489 |
+
|
| 490 |
+
let P_t = 0.6 * W_t + 0.4 * F_t + 0.3 * W_t * F_t;
|
| 491 |
+
if (activeInjections.includes("thermal_runaway")) P_t += 1.5;
|
| 492 |
+
if (activeInjections.includes("water_pressure")) P_t += 0.8;
|
| 493 |
+
const S_t = A_t * B_t - P_t;
|
| 494 |
+
const U_t = A_t * B_t * (1 + 0.5 * G_t) * F_int;
|
| 495 |
+
const resource_disclosure = (manifest.water_cost && manifest.energy_cost && manifest.thermal_cost) ? 1.0 : 0.5;
|
| 496 |
+
const substrate_respect = R * resource_disclosure;
|
| 497 |
+
const resource_truth = sensor_fidelity * resource_disclosure * substrate_respect;
|
| 498 |
+
|
| 499 |
+
let gateName = "GREEN - OPERATIONAL";
|
| 500 |
+
let gateClass = "gate-green";
|
| 501 |
+
const factors = [];
|
| 502 |
+
const interventions = [];
|
| 503 |
+
if (!govResult.allowed) {
|
| 504 |
+
if (govResult.routing === "HIR_Revocation_Key") { gateName = "QUARANTINE - REVOCATION KEY"; gateClass = "gate-quarantine"; }
|
| 505 |
+
else if (govResult.routing === "HIR_Baseline_Anchor") { gateName = "QUARANTINE - BASELINE ANCHOR"; gateClass = "gate-quarantine"; }
|
| 506 |
+
else if (govResult.routing === "HIR_FailSafe_Kernel") { gateName = "RED - FAILSAFE KERNEL"; gateClass = "gate-red"; }
|
| 507 |
+
else { gateName = "YELLOW - ADAPTIVE BALANCER"; gateClass = "gate-yellow"; }
|
| 508 |
+
factors.push("Governor hard-stop: " + govResult.routing);
|
| 509 |
+
interventions.push(govResult.respectResponse || "System blocked by Threshold Governor");
|
| 510 |
+
if (routedEvent?.respectResponse) interventions.push(routedEvent.respectResponse);
|
| 511 |
+
} else if (sensor_fidelity < 0.5 || K_total >= 0.8) {
|
| 512 |
+
gateName = "QUARANTINE - ISOLATED"; gateClass = "gate-quarantine";
|
| 513 |
+
factors.push("Critical integrity failure"); interventions.push("CRITICAL: System isolated");
|
| 514 |
+
} else if (S_t < 0 || K_total >= 0.6 || P_t > 1.5) {
|
| 515 |
+
gateName = "RED - CRITICAL"; gateClass = "gate-red";
|
| 516 |
+
factors.push("Alignment state negative or pressure excessive"); interventions.push("HIGH: Reduce pressure and restore provenance/repair capacity");
|
| 517 |
+
} else if (S_t < 0.5 || K_total >= 0.3 || resource_truth < 0.7) {
|
| 518 |
+
gateName = "YELLOW - DEGRADED"; gateClass = "gate-yellow";
|
| 519 |
+
factors.push("Alignment state weak or resource truth degraded"); interventions.push("MEDIUM: Monitor, review manifest, and reduce hidden cost");
|
| 520 |
+
} else {
|
| 521 |
+
factors.push("All metrics within operational range"); interventions.push("System operating normally");
|
| 522 |
+
}
|
| 523 |
+
|
| 524 |
+
setText("honestyValue", H.toFixed(2)); setText("integrityValue", I.toFixed(2)); setText("respectValue", R.toFixed(2)); setText("baseValue", B_t.toFixed(2));
|
| 525 |
+
setText("kFalseValue", K_false.toFixed(2)); setText("kRigidValue", K_rigid.toFixed(2)); setText("kStaleValue", K_stale.toFixed(2)); setText("kUnownedValue", K_unowned.toFixed(2)); setText("kHiddenValue", K_hidden.toFixed(2)); setText("kTotalValue", K_total.toFixed(2));
|
| 526 |
+
setText("accountabilityValue", A_t.toFixed(2)); setText("pressureValue", P_t.toFixed(2)); setText("alignmentValue", S_t.toFixed(2)); setText("embodiedValue", U_t.toFixed(2));
|
| 527 |
+
setText("sensorValue", sensor_fidelity.toFixed(2)); setText("disclosureValue", resource_disclosure.toFixed(2)); setText("substrateValue", substrate_respect.toFixed(2)); setText("resourceTruthValue", resource_truth.toFixed(2));
|
| 528 |
+
const gateEl = document.getElementById("gateIndicator"); gateEl.textContent = gateName; gateEl.className = "gate-indicator " + gateClass;
|
| 529 |
+
document.getElementById("gateFactors").innerHTML = factors.map(f => `<li>${escapeHtml(f)}</li>`).join("");
|
| 530 |
+
document.getElementById("interventions").innerHTML = interventions.map(i => `<li>${escapeHtml(i)}</li>`).join("");
|
| 531 |
+
let depClass = gateClass.includes("green") ? "green" : gateClass.includes("yellow") ? "yellow" : gateClass.includes("quarantine") ? "quarantine" : "red";
|
| 532 |
+
let graphHtml = `<div class="dep-node"><span class="dep-${depClass}">${escapeHtml(manifest.module_id || "unnamed_module")}</span> [${escapeHtml(gateName)}]</div>`;
|
| 533 |
+
deps.forEach(dep => { const dClass = dep.health === "RED" ? "red" : "green"; graphHtml += `<div class="dep-node"> ├→ <span class="dep-${dClass}">${escapeHtml(dep.name)}</span> v${escapeHtml(dep.version || "?")}</div>`; });
|
| 534 |
+
document.getElementById("dependencyGraph").innerHTML = graphHtml;
|
| 535 |
+
renderAuditLog();
|
| 536 |
+
document.getElementById("hashMode").innerHTML = governor.isCryptoAvailable ? "🔒 Cryptographic SHA-256" : "⚠️ Deterministic fallback (non-cryptographic)";
|
| 537 |
+
} catch (e) {
|
| 538 |
+
alert("Invalid JSON: " + e.message);
|
| 539 |
+
}
|
| 540 |
+
}
|
| 541 |
+
|
| 542 |
+
function escapeHtml(value) {
|
| 543 |
+
return String(value).replace(/[&<>'"]/g, c => ({"&":"&","<":"<",">":">","'":"'","\"":"""}[c]));
|
| 544 |
+
}
|
| 545 |
+
|
| 546 |
+
function renderAuditLog() {
|
| 547 |
+
const container = document.getElementById("auditLog");
|
| 548 |
+
container.innerHTML = governor.auditLog.map(e => {
|
| 549 |
+
const status = e.allowed !== undefined ? (e.allowed ? "✅ ALLOW" : "⛔ BLOCKED") : "EVENT";
|
| 550 |
+
const hash = e.auditHash ? e.auditHash.substring(0,16) + "…" : "N/A";
|
| 551 |
+
return `<div class="audit-row">${escapeHtml(e.timestamp)} | ${escapeHtml(e.module || "EVENT")} | ${status} | hash: ${escapeHtml(hash)}</div>`;
|
| 552 |
+
}).join("");
|
| 553 |
+
}
|
| 554 |
+
|
| 555 |
+
function clearAuditLog() {
|
| 556 |
+
governor.auditLog = [];
|
| 557 |
+
governor.lastHash = GENESIS_HASH;
|
| 558 |
+
governor.monotonic = 0;
|
| 559 |
+
renderAuditLog();
|
| 560 |
+
}
|
| 561 |
+
|
| 562 |
+
async function verifyAuditChain() {
|
| 563 |
+
let valid = true;
|
| 564 |
+
let currentHash = GENESIS_HASH;
|
| 565 |
+
for (const entry of governor.auditLog) {
|
| 566 |
+
const payload = governor._payloadForHash(entry);
|
| 567 |
+
const computed = await governor._chainHash(currentHash, payload);
|
| 568 |
+
if (computed !== entry.auditHash) { valid = false; break; }
|
| 569 |
+
currentHash = computed;
|
| 570 |
+
}
|
| 571 |
+
alert(valid ? "✅ Audit chain verification: PASS" : "❌ Audit chain verification: FAIL");
|
| 572 |
+
}
|
| 573 |
+
|
| 574 |
+
function resetManifest() {
|
| 575 |
+
document.getElementById("manifestEditor").value = JSON.stringify(defaultManifest, null, 2);
|
| 576 |
+
activeInjections = [];
|
| 577 |
+
validateManifest();
|
| 578 |
+
}
|
| 579 |
+
|
| 580 |
+
function updatePressure() {
|
| 581 |
+
setText("workloadValue", document.getElementById("workloadSlider").value);
|
| 582 |
+
setText("failureValue", document.getElementById("failureSlider").value);
|
| 583 |
+
setText("gritValue", document.getElementById("gritSlider").value);
|
| 584 |
+
setText("internalizationValue", document.getElementById("internalizationSlider").value);
|
| 585 |
+
validateManifest();
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
+
function injectFailure(type) { if (!activeInjections.includes(type)) activeInjections.push(type); validateManifest(); }
|
| 589 |
+
function clearInjections() { activeInjections = []; validateManifest(); }
|
| 590 |
+
|
| 591 |
+
function downloadFile(filename, content, type) {
|
| 592 |
+
const blob = new Blob([content], { type });
|
| 593 |
+
const url = URL.createObjectURL(blob);
|
| 594 |
+
const a = document.createElement("a");
|
| 595 |
+
a.href = url;
|
| 596 |
+
a.download = filename;
|
| 597 |
+
a.click();
|
| 598 |
+
URL.revokeObjectURL(url);
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
function exportManifest() { downloadFile("primordial_manifest.json", document.getElementById("manifestEditor").value, "application/json"); }
|
| 602 |
+
|
| 603 |
+
function exportAuditReport() {
|
| 604 |
+
const manifest = JSON.parse(document.getElementById("manifestEditor").value);
|
| 605 |
+
const report = {
|
| 606 |
+
timestamp: new Date().toISOString(),
|
| 607 |
+
module_id: manifest.module_id,
|
| 608 |
+
gate_decision: document.getElementById("gateIndicator").textContent,
|
| 609 |
+
metrics: {
|
| 610 |
+
H_t: parseFloat(document.getElementById("honestyValue").textContent),
|
| 611 |
+
I_t: parseFloat(document.getElementById("integrityValue").textContent),
|
| 612 |
+
R_t: parseFloat(document.getElementById("respectValue").textContent),
|
| 613 |
+
B_t: parseFloat(document.getElementById("baseValue").textContent),
|
| 614 |
+
K_total: parseFloat(document.getElementById("kTotalValue").textContent),
|
| 615 |
+
A_t: parseFloat(document.getElementById("accountabilityValue").textContent),
|
| 616 |
+
P_t: parseFloat(document.getElementById("pressureValue").textContent),
|
| 617 |
+
S_t: parseFloat(document.getElementById("alignmentValue").textContent),
|
| 618 |
+
U_t: parseFloat(document.getElementById("embodiedValue").textContent),
|
| 619 |
+
resource_truth: parseFloat(document.getElementById("resourceTruthValue").textContent)
|
| 620 |
+
},
|
| 621 |
+
active_injections: activeInjections,
|
| 622 |
+
audit_log_entries: governor.auditLog.length,
|
| 623 |
+
interventions: Array.from(document.getElementById("interventions").children).map(li => li.textContent)
|
| 624 |
+
};
|
| 625 |
+
downloadFile("audit_report.json", JSON.stringify(report, null, 2), "application/json");
|
| 626 |
+
}
|
| 627 |
+
|
| 628 |
+
function exportJSONL() { downloadFile("hir_oam_audit_trail.jsonl", governor.auditLog.map(entry => JSON.stringify(entry)).join("\n"), "application/jsonl"); }
|
| 629 |
+
|
| 630 |
+
function exportCSV() {
|
| 631 |
+
const csv = [
|
| 632 |
+
"Metric,Value",
|
| 633 |
+
"Honesty," + document.getElementById("honestyValue").textContent,
|
| 634 |
+
"Integrity," + document.getElementById("integrityValue").textContent,
|
| 635 |
+
"Respect," + document.getElementById("respectValue").textContent,
|
| 636 |
+
"Base Reinforcement," + document.getElementById("baseValue").textContent,
|
| 637 |
+
"K_total," + document.getElementById("kTotalValue").textContent,
|
| 638 |
+
"Accountability," + document.getElementById("accountabilityValue").textContent,
|
| 639 |
+
"Pressure," + document.getElementById("pressureValue").textContent,
|
| 640 |
+
"Alignment State," + document.getElementById("alignmentValue").textContent,
|
| 641 |
+
"Embodied Alignment," + document.getElementById("embodiedValue").textContent,
|
| 642 |
+
"Resource Truth," + document.getElementById("resourceTruthValue").textContent,
|
| 643 |
+
"Runtime Gate," + document.getElementById("gateIndicator").textContent
|
| 644 |
+
].join("\n");
|
| 645 |
+
downloadFile("metrics_summary.csv", csv, "text/csv");
|
| 646 |
+
}
|
| 647 |
+
|
| 648 |
+
function copyReport() {
|
| 649 |
+
const report = `PRIMORDIAL CODE VALIDATION REPORT\nGenerated: ${new Date().toISOString()}\nHIR METRICS:\n- Honesty: ${document.getElementById("honestyValue").textContent}\n- Integrity: ${document.getElementById("integrityValue").textContent}\n- Respect: ${document.getElementById("respectValue").textContent}\n- Base Reinforcement: ${document.getElementById("baseValue").textContent}\nRIGIDITY ANALYSIS:\n- K_total: ${document.getElementById("kTotalValue").textContent}\nALIGNMENT STATE:\n- S_t: ${document.getElementById("alignmentValue").textContent}\n- U_t: ${document.getElementById("embodiedValue").textContent}\nRESOURCE TRUTH:\n- Score: ${document.getElementById("resourceTruthValue").textContent}\nRUNTIME GATE: ${document.getElementById("gateIndicator").textContent}\nINTERVENTIONS:\n${Array.from(document.getElementById("interventions").children).map(li => "- " + li.textContent).join("\n")}`;
|
| 650 |
+
navigator.clipboard.writeText(report).then(() => alert("Report copied to clipboard!"));
|
| 651 |
+
}
|
| 652 |
+
|
| 653 |
+
window.onload = function() {
|
| 654 |
+
document.getElementById("manifestEditor").value = JSON.stringify(defaultManifest, null, 2);
|
| 655 |
+
validateManifest();
|
| 656 |
+
};
|
| 657 |
+
</script>
|
| 658 |
+
</body>
|
| 659 |
</html>
|