HirModel's picture
Upload 2 files
db893e5 verified
Raw
History Blame Contribute Delete
39.4 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Runtime Trail v0.1.1 — Cell Stage Mutation Patch</title>
<style>
:root{
--bg:#05070a;--panel:#10161d;--panel2:#0a0f14;--line:#263846;--text:#d8f5ea;--muted:#8ca79d;
--green:#69f0a3;--gold:#ffd36b;--blue:#8fd7ff;--red:#ff5f6d;--amber:#ffbf5c;--purple:#bd8cff;--gray:#61737d;
}
*{box-sizing:border-box}html,body{margin:0;min-height:100%;background:radial-gradient(circle at 50% 0%,#111a19 0,#07090b 44%,#020304 100%);color:var(--text);font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace;overflow-x:hidden}
body:before{content:"";position:fixed;inset:0;pointer-events:none;background:repeating-linear-gradient(to bottom,rgba(255,255,255,.035),rgba(255,255,255,.035) 1px,transparent 1px,transparent 4px);mix-blend-mode:overlay;z-index:1000;opacity:.22}
button{background:#111b18;color:var(--text);border:1px solid #355b44;padding:9px 12px;font-family:inherit;cursor:pointer;text-transform:uppercase;letter-spacing:.045em;box-shadow:inset 0 0 0 1px rgba(255,255,255,.03)}
button:hover{border-color:var(--green);box-shadow:0 0 12px rgba(105,240,163,.18)}button.primary{background:#183923;border-color:var(--green)}button.warn{background:#261d0d;border-color:#7a5d27;color:#ffe0a5}button.danger{background:#2b1117;border-color:#80404a;color:#ffd3da}
.intro{position:fixed;inset:0;z-index:999;background:radial-gradient(circle at 50% 48%,#13251b 0,#050806 62%,#010201 100%);display:grid;place-items:center;padding:22px;transition:opacity .55s ease,visibility .55s ease}.intro.hide{opacity:0;visibility:hidden}
.introBox{max-width:980px;width:100%;border:2px solid #416a50;box-shadow:0 0 36px rgba(105,240,163,.18),inset 0 0 36px rgba(105,240,163,.08);background:rgba(4,10,7,.9);padding:28px}.pixelTitle{font-size:clamp(38px,7.5vw,90px);letter-spacing:.08em;text-align:center;color:#afffd0;text-shadow:0 0 12px rgba(105,240,163,.85),0 0 2px #fff;margin:0 0 8px;font-weight:900;line-height:.98}.pixelSub{text-align:center;color:#ffd36b;text-transform:uppercase;letter-spacing:.22em;font-size:clamp(13px,2vw,18px);margin-bottom:24px}.boot{border:1px solid #2e5140;background:#06110c;padding:18px;color:#bdfcd5;line-height:1.6;min-height:208px;white-space:pre-wrap}.introActions{display:flex;gap:12px;justify-content:center;flex-wrap:wrap;margin-top:18px}
.wrap{max-width:1660px;margin:0 auto;padding:16px}header{display:flex;align-items:flex-start;justify-content:space-between;gap:18px;padding:14px 0 12px;border-bottom:1px solid #21303a;margin-bottom:14px}h1{margin:0;color:#dfffe9;font-size:28px;text-transform:uppercase;letter-spacing:.08em;text-shadow:0 0 10px rgba(105,240,163,.32)}.subtitle{color:var(--muted);line-height:1.45;margin-top:6px;max-width:1040px}.pillbar{display:flex;flex-wrap:wrap;gap:7px;margin-top:10px}.pill{border:1px solid #2b3a44;background:#0d1419;color:#b8d9ce;padding:5px 8px;font-size:12px;white-space:nowrap}.green{color:#9effc7}.gold{color:#ffdf8c}.blue{color:#9ee0ff}.red{color:#ffadb6}.pill.green{border-color:#2d7048}.pill.gold{border-color:#7b6732}.pill.red{border-color:#83434b}.pill.blue{border-color:#3c6e8a}.pill.purple{border-color:#65478d;color:#d4b8ff}
.topHud{display:grid;grid-template-columns:repeat(7,minmax(88px,1fr));gap:8px;margin-bottom:12px}.hudItem{background:linear-gradient(180deg,#101820,#0a0f14);border:1px solid #263544;padding:10px;min-height:58px}.hudLabel{font-size:11px;color:#7f9a91;text-transform:uppercase;letter-spacing:.08em}.hudVal{font-size:17px;color:#f0fff7;margin-top:5px}.routeHeld{color:#8dffb3}.routeStrained{color:#ffd27b}.routeStop{color:#ff8d99}.routeCollapsed{color:#ff4c60;text-shadow:0 0 10px rgba(255,95,109,.5)}
.mainGrid{display:grid;grid-template-columns:1fr 1fr 370px;gap:12px;align-items:stretch}.panel{background:linear-gradient(180deg,rgba(16,21,27,.97),rgba(8,12,16,.97));border:1px solid #263544;box-shadow:0 0 18px rgba(0,0,0,.25);position:relative;overflow:hidden}.panel h2{font-size:14px;margin:0;padding:10px 12px;border-bottom:1px solid #24323e;color:#d9fff0;text-transform:uppercase;letter-spacing:.08em;background:rgba(255,255,255,.02)}.cap{font-size:12px;color:#89a69b;padding:8px 12px 0;line-height:1.35}.canvasBox{position:relative;padding:8px;min-height:270px}canvas{width:100%;height:260px;display:block;background:#05080b;border:1px solid #1c2a33}.worldPanel{grid-column:1 / span 2}.worldPanel canvas{height:360px}.worldPanel .canvasBox{min-height:370px}.side{grid-column:3;grid-row:1 / span 2;display:flex;flex-direction:column;gap:12px}.stats{padding:12px;display:grid;gap:9px}.statRow{display:grid;grid-template-columns:112px 1fr 44px;gap:8px;align-items:center;font-size:12px;color:#a7c7bd}.bar{height:8px;background:#0a0e12;border:1px solid #22323d}.bar>i{display:block;height:100%;width:50%;background:linear-gradient(90deg,#69f0a3,#8fd7ff)}.eventDeck{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;padding:12px}.eventDeck button{text-align:left;min-height:58px;text-transform:none;letter-spacing:0;background:#0b1217;border-color:#2b3a44}.eventDeck .emoji{font-size:18px;margin-right:6px}.eventDeck small{display:block;color:#7f9a91;margin-top:4px;font-size:10px;line-height:1.25}.controls{padding:12px;display:flex;gap:8px;flex-wrap:wrap;border-top:1px solid #22313b}.controls button{font-size:12px}.readout{padding:12px;border-top:1px solid #22313b}.readout p{margin:0 0 10px;color:#b8d9ce;line-height:1.45}.readout code{color:#ffe2a0}.bigRoute{font-size:24px;font-weight:800;letter-spacing:.08em;margin:8px 0;text-transform:uppercase}.stateBadge{padding:6px 8px;border:1px solid #293844;display:inline-block;font-weight:800}.stateBadge.held{background:#102417;border-color:#3f9b61;color:#90ffb8}.stateBadge.strained{background:#2a2111;border-color:#a87b2f;color:#ffd27b}.stateBadge.stop{background:#2a1117;border-color:#ae4b58;color:#ff9ba7}.stateBadge.collapsed{background:#18050a;border-color:#ff5f6d;color:#ff6677}.fieldBox{margin:0 12px 12px;padding:10px;border:1px solid #273946;background:#080e12;color:#a9c8be;font-size:12px;line-height:1.45}.miniAndLedger{display:grid;grid-template-columns:440px 1fr;gap:12px;margin-top:12px}.miniPanel canvas{height:190px}.ledger{max-height:270px;overflow:auto;padding:10px 12px;font-size:12px;line-height:1.45;color:#bdd8cf}.ledgerEntry{border-left:3px solid #355061;padding:8px 9px;margin:0 0 8px;background:#0a1116}.ledgerEntry.HELD{border-color:#69f0a3}.ledgerEntry.STRAINED{border-color:#ffd36b}.ledgerEntry.MUSTSTOP{border-color:#ff5f6d}.ledgerEntry.COLLAPSED{border-color:#ff1e42;background:#15070a}.boundary{margin-top:12px;padding:12px;background:#080e12;border:1px solid #273946;color:#a9c8be;font-size:12px;line-height:1.45}.modal{position:fixed;inset:0;background:rgba(0,0,0,.72);z-index:990;display:none;place-items:center;padding:20px}.modal.show{display:grid}.modalBox{max-width:920px;background:#0b1116;border:1px solid #3d5d6f;box-shadow:0 0 36px rgba(143,215,255,.2);padding:22px;line-height:1.55}.modalBox h2{margin-top:0;color:#dfffe9}.modalBox pre{white-space:pre-wrap;color:#bfe8db;background:#06090c;padding:12px;border:1px solid #20313a;max-height:60vh;overflow:auto}
@media (max-width:1220px){.mainGrid{grid-template-columns:1fr}.side,.worldPanel{grid-column:auto;grid-row:auto}.miniAndLedger{grid-template-columns:1fr}.topHud{grid-template-columns:repeat(3,1fr)}}@media (max-width:680px){.topHud{grid-template-columns:repeat(2,1fr)}header{display:block}.eventDeck{grid-template-columns:1fr}.pixelTitle{font-size:38px}.introBox{padding:18px}.wrap{padding:10px}}
</style>
</head>
<body>
<div class="intro" id="intro"><div class="introBox"><h1 class="pixelTitle">RUNTIME TRAIL</h1><div class="pixelSub">Cell Stage Mutation Patch</div><div class="boot" id="bootText">BOOTING RUNTIME TRAIL...</div><div class="introActions"><button class="primary" onclick="startTrail()">Start Trail</button><button onclick="showRoadmap()">View Roadmap</button><button onclick="showBoundary()">Boundary Notes</button></div></div></div>
<div class="modal" id="modal"><div class="modalBox"><h2 id="modalTitle">Runtime Trail</h2><pre id="modalBody"></pre><div style="text-align:right;margin-top:12px"><button onclick="closeModal()">Close</button></div></div></div>
<div class="wrap">
<header><div><h1>Runtime Trail v0.1.1</h1><div class="subtitle">First Mutation Path Patch. A symbolic HIR/OAM pressure-evolution instrument where persistent cold, toxin, damage, repair, trace coupling, and return visibly shape the cell across mind, physical body, local world, and trail memory.</div><div class="pillbar"><span class="pill green">Before the trail, there is a boundary</span><span class="pill gold">Persistent pressure fields</span><span class="pill blue">Mind • body • world • memory</span><span class="pill purple">Resonant Access mutation gate</span><span class="pill red">Symbolic only — no consciousness / life proof</span></div></div><div style="min-width:300px;text-align:right;color:#88a59a;font-size:12px;line-height:1.45"><strong style="color:#dfffe9">Patch lock</strong><br>Pressure persists. Correction costs. Staying too long matters. Trace becomes mutation only after boundary holds.</div></header>
<div class="topHud"><div class="hudItem"><div class="hudLabel">Cycle</div><div class="hudVal" id="dayVal">0</div></div><div class="hudItem"><div class="hudLabel">Stage</div><div class="hudVal" id="stageVal">Cell</div></div><div class="hudItem"><div class="hudLabel">Condition</div><div class="hudVal" id="conditionVal">Dormant</div></div><div class="hudItem"><div class="hudLabel">Route</div><div class="hudVal" id="routeVal">HELD</div></div><div class="hudItem"><div class="hudLabel">Shape</div><div class="hudVal" id="shapeVal">Seed</div></div><div class="hudItem"><div class="hudLabel">Bloom Meter</div><div class="hudVal" id="bloomVal">0</div></div><div class="hudItem"><div class="hudLabel">Seed ID</div><div class="hudVal" id="seedVal"></div></div></div>
<section class="mainGrid">
<div class="panel"><h2>Mind / Cognition Panel</h2><div class="cap">Shows internal correction: signal fidelity, memory nodes, knots, repair bridges, quarantine paths, return loops, and proto-cognitive routing.</div><div class="canvasBox"><canvas id="mindCanvas"></canvas></div></div>
<div class="panel"><h2>Physical Attributes Panel</h2><div class="cap">Shows external adaptation: membrane thickness, scars, tendrils, shell, spines, frost strain, toxin pockets, repair seams, and budding/division markers.</div><div class="canvasBox"><canvas id="bodyCanvas"></canvas></div></div>
<div class="side"><div class="panel"><h2>HIR/OAM State</h2><div class="stats" id="stats"></div><div class="fieldBox" id="fieldBox">Persistent fields: none.</div><div class="readout"><div id="routeBadge" class="stateBadge held">HELD</div><div class="bigRoute" id="routeExplain">Dormant seed</div><p id="interpretation">A tiny boundary is present. Pressure field has not begun.</p><p><code>S_cell = Energy × Membrane × Signal × Repair − P_oam</code><br><code>C_bloom = Boundary × Signal × Memory × Valence × Repair × Action − P_oam</code></p></div></div><div class="panel"><h2>Event Deck</h2><div class="eventDeck" id="eventDeck"></div><div class="controls"><button class="primary" onclick="runDemo()">Run Demo</button><button onclick="advanceTick('manual')">Advance Tick</button><button onclick="replayTrail()">Replay</button><button onclick="exportTrace()">Export Trace</button><button class="warn" onclick="resetTrail()">Reset</button></div></div></div>
<div class="panel worldPanel"><h2>Local World Panel</h2><div class="cap">Shows immediate pressure: nutrient fields, cold gradients, toxin patches, membrane breaches, warmth pockets, trace signals, crowding, waste, and return basins.</div><div class="canvasBox"><canvas id="worldCanvas"></canvas></div></div>
</section>
<section class="miniAndLedger"><div class="panel miniPanel"><h2>Trail Minimap / Memory Map</h2><div class="cap">Shows accumulated route memory: where pressure formed nourishment, strain, repair, pruning, quarantine, trace-mutation, or return loops.</div><div class="canvasBox"><canvas id="miniCanvas"></canvas></div></div><div class="panel"><h2>Journey Ledger</h2><div class="ledger" id="ledger"><div class="ledgerEntry HELD">Cycle 0 — Dormant seed. Awaiting first world-pressure event.</div></div></div></section>
<div class="boundary"><strong>Boundary:</strong> Runtime Trail v0.1.1 is a bounded symbolic HIR/OAM pressure-evolution instrument. It is not a biological evolution simulator, not survival advice, not a medical/psychological tool, not proof of consciousness, and not proof of biological or digital life. The Conscious-State Bloom meter at this stage only tracks boundary response and proto-cognitive routing conditions; it does not certify consciousness.</div>
</div>
<script>
const bootLines=['BOOTING RUNTIME TRAIL...','','Seed boundary detected.','Pressure field initializing.','HIR grammar online.','OAM pressure map online.','Persistent pressure engine online.','Resonant Access mutation gate online.','Conscious-State Bloom meter bounded to cell-stage thresholds.','Memory ledger empty.','Correction path unknown.','','Before the trail, there is a boundary.','','PRESS START.'];let bootIndex=0;const bootEl=document.getElementById('bootText');function bootType(){if(bootIndex<=bootLines.length){bootEl.textContent=bootLines.slice(0,bootIndex).join('\n');bootIndex++;setTimeout(bootType,bootIndex<3?220:135)}}bootType();
function startTrail(){document.getElementById('intro').classList.add('hide');resizeAll();drawAll()}function showModal(t,b){document.getElementById('modalTitle').textContent=t;document.getElementById('modalBody').textContent=b;document.getElementById('modal').classList.add('show')}function closeModal(){document.getElementById('modal').classList.remove('show')}
function showRoadmap(){showModal('Runtime Trail Roadmap',`v0.1.1 keeps the first build at cell stage and adds a real mutation/demo engine. Later layers scale from cell → organism → pair/group → camp → settlement → multi-settlement society → long-horizon stress test.\n\nThis patch proves that persistent pressure changes the organism across mind, physical body, local world, and trail memory.`)}
function showBoundary(){showModal('Boundary Notes',`Runtime Trail is symbolic only. It is not a biological evolution simulator, not proof of consciousness or life, not medical/psychological advice, and not survival guidance.\n\nAt cell stage, the Bloom meter only maps boundary response and proto-cognitive routing conditions: boundary, signal, memory-like persistence, repair, action routing, and OAM pressure.`)}
const canvases={mind:document.getElementById('mindCanvas'),body:document.getElementById('bodyCanvas'),world:document.getElementById('worldCanvas'),mini:document.getElementById('miniCanvas')};const ctx={};for(const k in canvases)ctx[k]=canvases[k].getContext('2d');let DPR=Math.max(1,window.devicePixelRatio||1);function fitCanvas(canvas,nominalH){const rect=canvas.getBoundingClientRect();const w=Math.max(260,rect.width),h=nominalH||rect.height||260;canvas.width=Math.round(w*DPR);canvas.height=Math.round(h*DPR);const c=canvas.getContext('2d');c.setTransform(DPR,0,0,DPR,0,0);canvas._w=w;canvas._h=h}function resizeAll(){DPR=Math.max(1,window.devicePixelRatio||1);fitCanvas(canvases.mind,260);fitCanvas(canvases.body,260);fitCanvas(canvases.world,360);fitCanvas(canvases.mini,190);drawAll()}window.addEventListener('resize',resizeAll);
function mulberry32(a){return function(){let t=a+=0x6D2B79F5;t=Math.imul(t^t>>>15,t|1);t^=t+Math.imul(t^t>>>7,t|61);return((t^t>>>14)>>>0)/4294967296}}const seedNum=Math.floor(Math.random()*900000)+100000;let rand=mulberry32(seedNum);document.getElementById('seedVal').textContent=String(seedNum).slice(-4);
const initialMetrics={energy:54,membrane:58,signal:56,continuity:54,repair:52,waste:8,memory:6,boundary:58,nourishment:32,oam:12,hir:56,thermal:62,toxinLoad:0,viability:60,bloom:0};
const initialMorph={tendrils:2,membraneThickness:2,spines:0,scars:0,blooms:0,shell:0,asymmetry:0,warmthNode:0,hydration:0,toxinPockets:0,socialBridge:0,frost:0,bud:0,traceFilaments:0};
const state={seed:seedNum,cycle:0,tick:0,stage:'Cell',condition:'Dormant',route:'HELD',shape:'Seed',correction:'Awaiting pressure',metrics:{...initialMetrics},morphology:{...initialMorph},fields:{cold:0,toxin:0,waste:0},mindNodes:[],bodyMarks:[],worldMarks:[],miniPath:[],ledger:[],mutationPackets:[],currentEvent:null,replaying:false,timers:[]};
const events=[
{id:'nutrient',emoji:'🟢',name:'Nutrient Gradient',desc:'usable energy appears nearby',d:{energy:18,nourishment:24,waste:3,signal:4,oam:-4,thermal:2},shape:'TENDRIL / BLOOM',world:'nutrient'},
{id:'cold',emoji:'❄️',name:'Temperature Drop',desc:'persistent cold lowers thermal gradient',d:{energy:-7,membrane:3,boundary:4,repair:-1,oam:7,thermal:-14},field:{cold:4},shape:'CONTRACTION',world:'cold'},
{id:'toxin',emoji:'☣️',name:'Toxin Contact',desc:'persistent toxin raises toxin load',d:{membrane:-8,signal:-7,waste:10,boundary:4,oam:15,toxinLoad:18},field:{toxin:4},shape:'QUARANTINE',world:'toxin'},
{id:'damage',emoji:'⚡',name:'Membrane Damage',desc:'boundary rupture requires repair',d:{membrane:-18,repair:-8,boundary:-5,oam:17,continuity:-5},shape:'REPAIR BRIDGE',world:'damage'},
{id:'repair',emoji:'✚',name:'Repair Event',desc:'repair bridge stabilizes a strain point',d:{repair:20,membrane:13,continuity:10,oam:-12,boundary:7,energy:-4,toxinLoad:-10},field:{cold:-1,toxin:-1},shape:'REPAIR BRIDGE',world:'repair'},
{id:'trace',emoji:'◇',name:'Trace Signal',desc:'Resonant Access mutation gate tests a signal',d:{signal:10,memory:12,boundary:5,oam:-2,continuity:4},shape:'TRACE MUTATION',world:'trace'},
{id:'warmth',emoji:'🔥',name:'Warmth Pocket',desc:'thermal recovery path appears',d:{thermal:24,energy:8,repair:4,oam:-8,memory:5},field:{cold:-2},shape:'WARMTH MEMORY',world:'warmth'},
{id:'divide',emoji:'◎',name:'Replication Chance',desc:'branching wants to divide',d:{energy:-8,continuity:11,repair:-2,nourishment:-3,oam:4,boundary:-2},shape:'DIVISION CHECK',world:'divide'},
{id:'waste',emoji:'▣',name:'Waste Buildup',desc:'internal residue persists if not expelled',d:{waste:20,energy:-7,signal:-4,oam:12},field:{waste:3},shape:'PRUNE / RELEASE',world:'waste'},
{id:'return',emoji:'↺',name:'Return / Stabilization',desc:'repair returns value to substrate',d:{repair:16,continuity:14,waste:-20,oam:-15,boundary:6,memory:8,toxinLoad:-8,thermal:5},field:{cold:-1,toxin:-1,waste:-2},shape:'RETURN LOOP',world:'return'}
];
function clamp(x,min=0,max=100){return Math.max(min,Math.min(max,x))}function applyDelta(d){for(const k in d){state.metrics[k]=clamp((state.metrics[k]||0)+d[k])}}function applyFieldDelta(f){if(!f)return;for(const k in f){state.fields[k]=Math.max(0,(state.fields[k]||0)+f[k])}}
function compute(){const m=state.metrics; m.hir=clamp(m.signal*.20+m.continuity*.22+m.boundary*.20+m.repair*.18+m.membrane*.12+(100-m.toxinLoad)*.08); const oamLoad=clamp(m.oam+m.waste*.22+m.toxinLoad*.30+Math.max(0,50-m.thermal)*.24+Math.max(0,40-m.energy)*.16+Math.max(0,42-m.membrane)*.18); m.oamLoad=oamLoad; m.viability=clamp((m.energy*.22+m.membrane*.23+m.signal*.18+m.repair*.17+m.thermal*.10+(100-m.toxinLoad)*.10)-oamLoad*.26); const bloomRaw=(m.boundary/100)*(m.signal/100)*(Math.max(5,m.memory)/100)*(m.repair/100)*(m.continuity/100)-(oamLoad/100)*.25; m.bloom=clamp(bloomRaw*160,0,32); let route='HELD'; if(m.viability<12||m.membrane<10||m.thermal<8||m.toxinLoad>88) route='COLLAPSED'; else if(m.viability<26||oamLoad>80||m.toxinLoad>66||m.thermal<22) route='MUST STOP'; else if(m.viability<44||oamLoad>52||m.energy<26||m.thermal<38||m.toxinLoad>34) route='STRAINED'; state.route=route; return {route,oamLoad,viability:m.viability,bloom:m.bloom} }
function classifyShape(event){const m=state.metrics,r=state.route;if(r==='COLLAPSED')return m.thermal<10?'FROZEN COLLAPSE':m.toxinLoad>88?'POISONED COLLAPSE':'BOUNDARY COLLAPSE'; if(event.id==='cold'||m.thermal<38)return r==='HELD'?'CONTRACTION / MEMBRANE THICKENING':'CONTRACTION / FREEZING RISK'; if(event.id==='toxin'||m.toxinLoad>34)return r==='HELD'?'QUARANTINE POCKET':'QUARANTINE / CONTAMINATION'; if(event.id==='repair')return 'REPAIR BRIDGE'; if(event.id==='trace')return r==='HELD'?'STABLE TRACE MUTATION':'PROVISIONAL TRACE MUTATION'; if(event.id==='divide')return (r==='HELD'&&m.energy>45)?'BUD / FORK':'DIVISION WITHHELD'; if(event.id==='return')return 'RETURN LOOP / STABILIZATION'; if(event.id==='waste')return 'PRUNE / RELEASE'; if(event.id==='nutrient')return m.nourishment>56?'BLOOM / ENERGY TENDRIL':'FORAGING TENDRIL'; if(event.id==='warmth')return 'WARMTH MEMORY NODE'; return event.shape||'PRESSURE RESPONSE'}
function updateMorph(event,shape){const mo=state.morphology;if(shape.includes('TENDRIL'))mo.tendrils++; if(shape.includes('BLOOM'))mo.blooms++; if(shape.includes('CONTRACTION')){mo.membraneThickness+=.45;mo.frost+=.5;mo.tendrils=Math.max(1,mo.tendrils-1)} if(shape.includes('QUARANTINE')){mo.spines++;mo.toxinPockets++;mo.membraneThickness+=.35} if(shape.includes('REPAIR')){mo.scars++;mo.membraneThickness+=.2} if(shape.includes('PRUNE'))mo.tendrils=Math.max(1,mo.tendrils-1); if(shape.includes('BUD'))mo.bud++; if(shape.includes('TRACE'))mo.traceFilaments++; if(shape.includes('WARMTH'))mo.warmthNode++; if(shape.includes('RETURN')){mo.hydration++;mo.blooms++;} if(state.route==='COLLAPSED')mo.tendrils=0; mo.membraneThickness=clamp(mo.membraneThickness,1,10);}
function addVisualNodes(event,shape){const color=routeColor(state.route);const a=rand()*Math.PI*2,d=38+rand()*70;state.mindNodes.push({x:Math.cos(a)*d,y:Math.sin(a)*d,color,shape,route:state.route,age:rand()*6,type:event.world});state.mindNodes=state.mindNodes.slice(-20);state.worldMarks.push({x:rand(),y:rand(),type:event.world||event.id,route:state.route,age:0});state.worldMarks=state.worldMarks.slice(-32);state.miniPath.push({cycle:state.cycle,route:state.route,shape,event:event.name,type:event.world});state.miniPath=state.miniPath.slice(-24)}
function mutationPacket(event,shape){if(event.id!=='trace')return null;const route=state.route;return {packetType:'RUNTIME_TRAIL_RESONANT_ACCESS_MUTATION',event:event.name,trace:'cell-stage environmental signal',witnessed:['signal gradient','boundary response'],inferred:['possible adaptive route'],unsupported:['proof of consciousness','proof of life','permanent safety'],uncertainty:route==='HELD'?['future repeatability not proven']:['trace requires confirmation before stable integration'],boundary:'Trace becomes mutation only after boundary holds.',route,mutation:shape,returnPath:route==='HELD'?'stored as bounded memory node':'held as provisional / quarantined trace'} }
function runEvent(id){const event=events.find(e=>e.id===id);if(!event)return;state.cycle++;state.currentEvent=event;applyDelta(event.d);applyFieldDelta(event.field);const c=compute();const shape=classifyShape(event);state.shape=shape;state.condition=event.name;state.correction=correctionFor(event,shape);updateMorph(event,shape);addVisualNodes(event,shape);const mp=mutationPacket(event,shape);if(mp)state.mutationPackets.push(mp);state.ledger.unshift({cycle:state.cycle,tick:state.tick,event:event.name,route:state.route,shape,correction:state.correction,metrics:{...state.metrics},fields:{...state.fields},mutation:mp});renderUI();drawAll()}
function advanceTick(source='tick'){state.tick++; let note=[]; if(state.fields.cold>0){applyDelta({thermal:-7,energy:-3,repair:-1,oam:3,membrane:-1});note.push('cold lowered thermal gradient')} if(state.fields.toxin>0){applyDelta({toxinLoad:7,signal:-3,membrane:-2,oam:4,waste:2});note.push('toxin load increased')} if(state.fields.waste>0){applyDelta({waste:5,energy:-2,oam:3,signal:-1});note.push('waste pressure accumulated')} Object.keys(state.fields).forEach(k=>{state.fields[k]=Math.max(0,state.fields[k]-.35)}); const c=compute(); let fake={id:source,name:'Pressure Tick',world:source==='manual'?'tick':source}; const shape=state.route==='COLLAPSED'?(state.metrics.thermal<8?'FROZEN COLLAPSE':'PRESSURE COLLAPSE'):(note.length? (state.route==='HELD'?'GRADIENT HELD':'PERSISTENT STRAIN'):'IDLE TICK');state.shape=shape;state.condition=note.length?note.join(' + '):'Pressure tick';state.correction=note.length?`Persistent field update: ${note.join('; ')}.`:'No persistent pressure field active.';addVisualNodes(fake,shape);state.ledger.unshift({cycle:state.cycle,tick:state.tick,event:'Pressure Tick',route:state.route,shape,correction:state.correction,metrics:{...state.metrics},fields:{...state.fields}});renderUI();drawAll()}
function correctionFor(event,shape){if(state.route==='COLLAPSED')return 'Boundary/continuity failed. Trail record marks collapse; reset or replay required.'; if(event.id==='cold')return 'Cold persists: thermal gradient will continue falling until warmth, conservation, repair, or collapse.'; if(event.id==='toxin')return 'Toxin persists: toxin load rises unless quarantined, repaired, expelled, or escaped.'; if(event.id==='repair')return 'Repair bridge spends energy to restore membrane, continuity, and boundary.'; if(event.id==='trace')return 'Resonant Access gate separated witnessed/inferred/unsupported before allowing mutation.'; if(event.id==='return')return 'Return loop completed; stable growth may thicken only after repair and boundary hold.'; if(state.route==='MUST STOP')return 'Boundary gate says stop: do not integrate; quarantine, prune, or seek repair.'; if(state.route==='STRAINED')return 'Pressure is survivable but unresolved; correction must continue.'; return 'Pressure routed through HIR; mutation/adaptation can be retained as bounded memory.'}
function routeColor(r){return r==='HELD'?'#69f0a3':r==='STRAINED'?'#ffd36b':r==='MUST STOP'?'#ff5f6d':'#ff1e42'}
function routeClass(r){return r==='HELD'?'held':r==='STRAINED'?'strained':r==='MUST STOP'?'stop':'collapsed'}
function bloomLabel(){const b=state.metrics.bloom;if(b<8)return '0 Dormant'; if(b<18)return '1 Boundary Response'; return '2 Proto-Cognitive Routing'}
function renderUI(){document.getElementById('dayVal').textContent=state.cycle+'.'+state.tick;document.getElementById('stageVal').textContent=state.stage;document.getElementById('conditionVal').textContent=state.condition;const rv=document.getElementById('routeVal');rv.textContent=state.route;rv.className='hudVal '+(state.route==='HELD'?'routeHeld':state.route==='STRAINED'?'routeStrained':state.route==='MUST STOP'?'routeStop':'routeCollapsed');document.getElementById('shapeVal').textContent=state.shape;document.getElementById('bloomVal').textContent=bloomLabel();const badge=document.getElementById('routeBadge');badge.textContent=state.route;badge.className='stateBadge '+routeClass(state.route);document.getElementById('routeExplain').textContent=state.shape;document.getElementById('interpretation').textContent=interpretation();document.getElementById('fieldBox').innerHTML=fieldText();const keys=['energy','membrane','thermal','toxinLoad','signal','continuity','repair','waste','memory','boundary','nourishment','hir','oamLoad','viability','bloom'];document.getElementById('stats').innerHTML=keys.map(k=>{const label={energy:'Energy',membrane:'Membrane',thermal:'Thermal',toxinLoad:'Toxin Load',signal:'Signal',continuity:'Continuity',repair:'Repair',waste:'Waste',memory:'Memory',boundary:'Boundary',nourishment:'Nourish',hir:'HIR',oamLoad:'OAM Load',viability:'Viability',bloom:'Bloom'}[k];const v=Math.round(state.metrics[k]||0),danger=['oamLoad','waste','toxinLoad'].includes(k);const grad=danger?'linear-gradient(90deg,#ffd36b,#ff5f6d)':'linear-gradient(90deg,#69f0a3,#8fd7ff)';return `<div class="statRow"><span>${label}</span><span class="bar"><i style="width:${v}%;background:${grad}"></i></span><b>${v}</b></div>`}).join('');document.getElementById('ledger').innerHTML=state.ledger.length?state.ledger.map(e=>`<div class="ledgerEntry ${e.route.replace(' ','')}"><b>Cycle ${e.cycle}.${e.tick}${e.event}</b><br>Route: ${e.route} · Shape: ${e.shape}<br><span style="color:#8ba89e">${e.correction}</span></div>`).join(''):'<div class="ledgerEntry HELD">Cycle 0 — Dormant seed.</div>'}
function fieldText(){const f=state.fields;const active=Object.entries(f).filter(([k,v])=>v>0.2).map(([k,v])=>`${k}: ${v.toFixed(1)}`).join(' · ');return `<strong>Persistent fields:</strong> ${active||'none'}<br><span class="blue">Cold and toxin lower gradients over time.</span> <span class="gold">Correction costs energy.</span> <span class="red">Staying too long can collapse the cell.</span>`}
function interpretation(){if(state.route==='COLLAPSED')return 'The boundary failed under accumulated pressure. This is collapse, not MUST STOP; the organism did not preserve continuity.'; if(state.route==='MUST STOP')return 'The current pressure must be stopped, quarantined, pruned, or repaired before it can become stable memory.'; if(state.route==='STRAINED')return 'The cell is still viable, but pressure is unresolved. Correction must continue or persistent gradients may overwhelm the boundary.'; if(state.currentEvent&&state.currentEvent.id==='trace')return 'Trace signal passed through Resonant Access: witnessed, inferred, unsupported, boundary, return, then mutation.'; return 'HIR is currently routing pressure into bounded correction. Stable growth requires loop completion and return.'}
function buildDeck(){document.getElementById('eventDeck').innerHTML=events.map(e=>`<button onclick="runEvent('${e.id}')"><span class="emoji">${e.emoji}</span>${e.name}<small>${e.desc}</small></button>`).join('')}function clearTimers(){state.timers.forEach(t=>clearTimeout(t));state.timers=[]}
function runDemo(){clearTimers();const seq=[['nutrient'],['cold'],['tick'],['tick'],['warmth'],['toxin'],['tick'],['damage'],['repair'],['trace'],['divide'],['return']];seq.forEach((item,i)=>state.timers.push(setTimeout(()=>{item[0]==='tick'?advanceTick('demo'):runEvent(item[0])},i*900)))}
function replayTrail(){if(!state.ledger.length)return;const old=[...state.ledger].reverse().filter(e=>e.event!=='Pressure Tick').map(e=>events.find(ev=>ev.name===e.event)?.id).filter(Boolean);resetTrail(false);clearTimers();old.forEach((id,i)=>state.timers.push(setTimeout(()=>runEvent(id),i*750)));setTimeout(()=>renderUI(),old.length*750+50)}
function resetTrail(redraw=true){clearTimers();Object.assign(state,{cycle:0,tick:0,stage:'Cell',condition:'Dormant',route:'HELD',shape:'Seed',correction:'Awaiting pressure',currentEvent:null});state.metrics={...initialMetrics};state.morphology={...initialMorph};state.fields={cold:0,toxin:0,waste:0};state.mindNodes=[];state.bodyMarks=[];state.worldMarks=[];state.miniPath=[];state.ledger=[];state.mutationPackets=[];compute();if(redraw){renderUI();drawAll()}}
function exportTrace(){const payload={artifact:'Runtime Trail',version:'0.1.1-cell-stage-mutation-patch',seed:state.seed,createdAt:new Date().toISOString(),boundary:'Symbolic HIR/OAM pressure-evolution instrument. Not biological evolution simulation, not proof of consciousness or digital life, not survival advice.',coreLock:'Pressure persists. Correction costs. Staying too long matters. Trace becomes mutation only after boundary holds.',state:{cycle:state.cycle,tick:state.tick,route:state.route,shape:state.shape,condition:state.condition,metrics:state.metrics,morphology:state.morphology,persistentFields:state.fields,bloomLabel:bloomLabel()},ledger:[...state.ledger].reverse(),mutationPackets:state.mutationPackets};const blob=new Blob([JSON.stringify(payload,null,2)],{type:'application/json'});const a=document.createElement('a');a.href=URL.createObjectURL(blob);a.download='RUNTIME_TRAIL_SEED_TRACE_v0_1_1.json';a.click();URL.revokeObjectURL(a.href)}
function bg(c){const w=c.canvas._w,h=c.canvas._h;c.clearRect(0,0,w,h);c.fillStyle='#05080b';c.fillRect(0,0,w,h);c.strokeStyle='rgba(143,215,255,.06)';c.lineWidth=1;for(let x=0;x<w;x+=24){c.beginPath();c.moveTo(x,0);c.lineTo(x,h);c.stroke()}for(let y=0;y<h;y+=24){c.beginPath();c.moveTo(0,y);c.lineTo(w,y);c.stroke()}}
function caption(c,text){const w=c.canvas._w,h=c.canvas._h;c.fillStyle='rgba(0,0,0,.58)';c.fillRect(8,h-30,Math.min(w-16,690),22);c.fillStyle='rgba(215,243,232,.75)';c.font='11px monospace';c.fillText(text,14,h-15)}
function drawMind(){const c=ctx.mind,w=canvases.mind._w,h=canvases.mind._h;bg(c);const cx=w/2,cy=h/2;const pulse=1+Math.sin(Date.now()/420)*.08;c.save();c.translate(cx,cy);c.strokeStyle=state.route==='COLLAPSED'?'rgba(255,30,66,.75)':'rgba(105,240,163,.72)';c.lineWidth=2;c.beginPath();c.arc(0,0,(30+state.metrics.bloom*.55)*pulse,0,Math.PI*2);c.stroke();c.fillStyle=state.route==='COLLAPSED'?'rgba(255,30,66,.22)':'rgba(105,240,163,.16)';c.beginPath();c.arc(0,0,22+state.metrics.bloom*.35,0,Math.PI*2);c.fill();if(state.metrics.thermal<38){c.strokeStyle='rgba(143,215,255,.75)';c.beginPath();c.arc(0,0,46,0,Math.PI*2);c.stroke()}if(state.metrics.toxinLoad>25){c.strokeStyle='rgba(255,95,109,.75)';c.beginPath();c.arc(0,0,56,Math.PI*.18,Math.PI*1.62);c.stroke()}for(const n of state.mindNodes){const x=n.x,y=n.y;c.strokeStyle=n.color;c.globalAlpha=.57;c.beginPath();c.moveTo(0,0);c.quadraticCurveTo(x*.35+Math.sin(Date.now()/700+n.age)*18,y*.35,x,y);c.stroke();c.globalAlpha=1;c.fillStyle=n.color;c.beginPath();c.arc(x,y,n.shape.includes('KNOT')?7:n.shape.includes('BLOOM')?9:n.shape.includes('TRACE')?8:5,0,Math.PI*2);c.fill();if(n.shape.includes('REPAIR')){c.strokeStyle='#8fd7ff';c.lineWidth=3;c.beginPath();c.arc(x,y,13,0,Math.PI*1.4);c.stroke()}if(n.route==='MUST STOP'||n.route==='COLLAPSED'){c.strokeStyle='#ff5f6d';c.beginPath();c.arc(x,y,15,0,Math.PI*2);c.stroke()}}c.restore();caption(c,'Mind: correction path — knots, repair bridges, trace gates, return loops, proto-cognitive routing.');}
function drawBody(){const c=ctx.body,w=canvases.body._w,h=canvases.body._h;bg(c);const cx=w/2,cy=h/2,mo=state.morphology;let base=32+state.metrics.energy*.12+state.metrics.viability*.08;if(state.route==='COLLAPSED')base*=.72;const n=54,pts=[];for(let i=0;i<n;i++){let a=i/n*Math.PI*2;let noise=Math.sin(i*1.7+state.seed)*4+Math.cos(i*3.1+state.cycle)*3;let r=base+noise+mo.asymmetry*16*Math.cos(a)+mo.shell*2;pts.push([cx+Math.cos(a)*r,cy+Math.sin(a)*r])}c.fillStyle=state.route==='COLLAPSED'?'rgba(255,95,109,.13)':'rgba(105,240,163,.12)';c.strokeStyle=state.metrics.thermal<35?'#8fd7ff':state.metrics.toxinLoad>35?'#ff5f6d':'#69f0a3';c.lineWidth=1.5+mo.membraneThickness;c.beginPath();pts.forEach((p,i)=>i?c.lineTo(...p):c.moveTo(...p));c.closePath();c.fill();c.stroke();for(let i=0;i<mo.tendrils;i++){let a=(i/Math.max(1,mo.tendrils))*Math.PI*2+state.seed*.0001;let len=24+state.metrics.nourishment*.42+(i%3)*8;if(state.metrics.thermal<30)len*=.55;c.strokeStyle='rgba(105,240,163,.55)';c.lineWidth=1.3;c.beginPath();c.moveTo(cx+Math.cos(a)*base,cy+Math.sin(a)*base);c.quadraticCurveTo(cx+Math.cos(a+.4)*base*1.5,cy+Math.sin(a-.2)*base*1.5,cx+Math.cos(a)*(base+len),cy+Math.sin(a)*(base+len));c.stroke()}for(let i=0;i<mo.spines;i++){let a=(i/Math.max(1,mo.spines))*Math.PI*2;c.strokeStyle='#ff5f6d';c.lineWidth=2;c.beginPath();c.moveTo(cx+Math.cos(a)*base,cy+Math.sin(a)*base);c.lineTo(cx+Math.cos(a)*(base+18),cy+Math.sin(a)*(base+18));c.stroke()}for(let i=0;i<mo.scars;i++){let a=(i+.3)*1.7;c.strokeStyle='#8fd7ff';c.lineWidth=3;c.beginPath();c.arc(cx+Math.cos(a)*base*.35,cy+Math.sin(a)*base*.35,12+i*2,0,Math.PI*1.25);c.stroke()}for(let i=0;i<mo.toxinPockets;i++){let a=i*2.2+.4;c.fillStyle='rgba(255,95,109,.75)';c.beginPath();c.arc(cx+Math.cos(a)*(base+28),cy+Math.sin(a)*(base+28),7,0,Math.PI*2);c.fill()}if(mo.warmthNode){c.fillStyle='rgba(255,211,107,.85)';c.beginPath();c.arc(cx+base*.35,cy-base*.15,9+mo.warmthNode,0,Math.PI*2);c.fill()}if(mo.bud){c.strokeStyle='#69f0a3';c.lineWidth=2;c.beginPath();c.arc(cx+base*.8,cy,13+mo.bud*2,0,Math.PI*2);c.stroke()}if(mo.traceFilaments){c.strokeStyle='#bd8cff';c.lineWidth=2;c.beginPath();c.arc(cx,cy,base+18,Math.PI*.2,Math.PI*.78);c.stroke()}caption(c,'Physical: adaptation — membrane, scars, spines, tendrils, frost, toxin pockets, budding.');}
function drawWorld(){const c=ctx.world,w=canvases.world._w,h=canvases.world._h;bg(c);const tile=28;for(let y=18;y<h-20;y+=tile){for(let x=18;x<w-20;x+=tile){let r=Math.sin(x*.04+y*.05+state.seed);c.fillStyle=r>.55?'rgba(105,240,163,.06)':r<-.55?'rgba(143,215,255,.06)':'rgba(255,211,107,.025)';c.fillRect(x,y,tile-4,tile-4)}}const temp=(100-state.metrics.thermal)/100;if(temp>.05){const g=c.createRadialGradient(w*.25,h*.28,10,w*.25,h*.28,w*.62);g.addColorStop(0,`rgba(143,215,255,${.30*temp})`);g.addColorStop(1,'rgba(143,215,255,0)');c.fillStyle=g;c.fillRect(0,0,w,h)}if(state.metrics.toxinLoad>0){const t=state.metrics.toxinLoad/100;const g=c.createRadialGradient(w*.76,h*.46,10,w*.76,h*.46,w*.5);g.addColorStop(0,`rgba(255,95,109,${.36*t})`);g.addColorStop(1,'rgba(255,95,109,0)');c.fillStyle=g;c.fillRect(0,0,w,h)}const colors={nutrient:'#69f0a3',cold:'#8fd7ff',toxin:'#ff5f6d',light:'#ffd36b',damage:'#bd8cff',predator:'#ff5f6d',crowd:'#ffd36b',divide:'#69f0a3',waste:'#ff9f6b',shock:'#ff5f6d',return:'#8fd7ff',repair:'#8fd7ff',trace:'#bd8cff',warmth:'#ffd36b',tick:'#9bb8af',demo:'#9bb8af',manual:'#9bb8af'};for(const m of state.worldMarks){const x=30+m.x*(w-60),y=36+m.y*(h-72);c.fillStyle=colors[m.type]||routeColor(m.route);c.globalAlpha=.85;c.beginPath();c.arc(x,y,8,0,Math.PI*2);c.fill();c.globalAlpha=1;if(m.route==='MUST STOP'||m.route==='COLLAPSED'){c.strokeStyle='#ff5f6d';c.beginPath();c.arc(x,y,17,0,Math.PI*2);c.stroke()}}drawWorldBars(c,w,h);caption(c,'World: pressure field — cold and toxin persist, gradients decay, return basins stabilize.');}
function drawWorldBars(c,w,h){const bars=[['Thermal',state.metrics.thermal,'#8fd7ff'],['Toxin',state.metrics.toxinLoad,'#ff5f6d'],['Waste',state.metrics.waste,'#ffbf5c'],['Nutrient',state.metrics.nourishment,'#69f0a3']];c.font='11px monospace';bars.forEach((b,i)=>{const x=18,y=18+i*20;c.fillStyle='rgba(0,0,0,.45)';c.fillRect(x,y,150,14);c.fillStyle=b[2];c.fillRect(x,y,150*(b[1]/100),14);c.fillStyle='#d8f5ea';c.fillText(`${b[0]} ${Math.round(b[1])}`,x+6,y+11)})}
function drawMini(){const c=ctx.mini,w=canvases.mini._w,h=canvases.mini._h;bg(c);c.strokeStyle='rgba(255,255,255,.16)';c.beginPath();c.moveTo(28,h/2);c.lineTo(w-28,h/2);c.stroke();const path=state.miniPath;path.forEach((p,i)=>{const step=Math.max(24,(w-68)/Math.max(1,Math.min(12,path.length)));const x=34+i*step;const y=h/2+Math.sin(i*.9+state.seed)*26;if(i>0){const px=34+(i-1)*step;const py=h/2+Math.sin((i-1)*.9+state.seed)*26;c.strokeStyle=routeColor(p.route);c.beginPath();c.moveTo(px,py);if(p.shape&&p.shape.includes('RETURN'))c.quadraticCurveTo((px+x)/2,py-35,x,y);else c.lineTo(x,y);c.stroke()}c.fillStyle=routeColor(p.route);c.beginPath();c.arc(x,y,p.shape&&p.shape.includes('RETURN')?8:6,0,Math.PI*2);c.fill();if(p.shape&&p.shape.includes('PRUNE')){c.strokeStyle='#ffbf5c';c.beginPath();c.moveTo(x-6,y-6);c.lineTo(x+6,y+6);c.stroke()}c.fillStyle='#9bb8af';c.font='10px monospace';c.fillText(String(p.cycle),x-3,y-10)});caption(c,'Minimap: memory — route, strain, trace mutation, repair, return, collapse markers.');}
function drawAll(){drawMind();drawBody();drawWorld();drawMini()}function tickAnim(){drawAll();requestAnimationFrame(tickAnim)}
buildDeck();compute();renderUI();resizeAll();tickAnim();
</script>
</body>
</html>