<!-- SAGA-SOLID · part 61 -->
xt.slope;T.surface=next.kind||"surface";
 var currentY=(cur&&cur.hit)?cur.height:kingPos.y-R.physics.rootClearance;
 T.step=next.height-currentY;
 if(!next.valid||next.slope>R.physics.maxSlope){T.classification="UNSAFE SLOPE";return T;}
 if(T.step>R.physics.stepHeight){T.classification="STEP TOO HIGH";return T;}
 if(T.step < -R.physics.stepHeight){T.classification="DROP";return T;}
 T.safe=true;
 T.classification=Math.abs(T.step)>0.08?"STEP / SLOPE":"SAFE GROUND";
 return T;
};
setInterval(function(){try{if(ActorRuntime.authority==="legacy"||ActorRuntime.authority==="ai_guarded")ActorRuntime.predictTerrain();}catch(e){ActorRuntime.debug.lastError=String(e);}},50);
/* ===== END TERRAIN PREDICTION — v208 ===== */
/* ===== REAL MOVEMENT CANDIDATE — v215 ===== */
ActorRuntime.realCandidate={version:215,verdict:"WAIT",allowed:false,reason:"startup",x:null,y:null,z:null,groundY:null,step:null,slope:null,surface:"NONE",samples:0};
ActorRuntime.evaluateRealCandidate=function(){
 var R=this,C=R.realCandidate,S=R.shadowMotion,WF=window.WORLD_FOUNDATION;
 C.verdict="WAIT";C.allowed=false;C.reason="not_ready";C.groundY=null;C.step=null;C.slope=null;C.surface="NONE";
 if(!S||!WF||typeof WF.supportBelow!=="function"||typeof kingPos==="undefined"||!kingPos)return C;
 var p=S.predicted.clone();
 C.x=p.x;C.y=p.y;C.z=p.z;C.samples++;
 var cur=WF.supportBelow(kingPos,{startOffset:2,maxDrop:8,maxSlope:R.physics.maxSlope});
 var nxt=WF.supportBelow(p,{startOffset:2,maxDrop:8,maxSlope:R.physics.maxSlope});
 if(!nxt||!nxt.hit){C.verdict="BLOCK";C.reason="no_support";return C;}
 C.groundY=nxt.height;C.slope=nxt.slope;C.surface=nxt.kind||"surface";
 var gy=(cur&&cur.hit)?cur.height:kingPos.y-R.physics.rootClearance;
 C.step=nxt.height-gy;
 if(!nxt.valid||C.slope>R.physics.maxSlope){C.verdict="BLOCK";C.reason="slope";return C;}
 if(C.step>R.physics.stepHeight){C.verdict="BLOCK";C.reason="step_high";return C;}
 if(C.step < -R.physics.stepHeight){C.verdict="BLOCK";C.reason="drop";return C;}
 if(p.y<R.safety.killY){C.verdict="BLOCK";C.reason="kill_y";return C;}
 C.allowed=true;C.verdict="ALLOW";C.reason="safe_ground";return C;
};
setInterval(function(){try{if(ActorRuntime.authority==="legacy"||ActorRuntime.authority==="ai_guarded")ActorRuntime.evaluateRealCandidate();}catch(e){ActorRuntime.debug.lastError=String(e);}},16);
/* ===== END REAL MOVEMENT CANDIDATE — v215 ===== */
/* ===== SAFETY SUPERVISOR — v216 ===== */
ActorRuntime.safetySupervisor={version:216,status:"WAIT",permit:false,reason:"startup",safeSamples:0,blockedSamples:0,lastSafeAt:0};
ActorRuntime.superviseSafety=function(){
 var R=this,V=R.safetySupervisor,C=R.realCandidate,P=R.senseWorld?R.senseWorld():null;
 V.status="BLOCK";V.permit=false;V.reason="not_ready";
 if(typeof kingPos==="undefined"||!kingPos||!C||!P)return V;
 if(kingPos.y<R.safety.killY){V.reason="below_kill_y";V.blockedSamples++;return V;}
 if(!P.support||!P.safeStand){V.reason="unsafe_current_position";V.blockedSamples++;return V;}
 if(!C.allowed||C.verdict!=="ALLOW"){V.reason="candidate_"+String(C.reason||"blocked");V.blockedSamples++;return V;}
 R.safety.lastSafe.copy(kingPos);
 R.safety.hasLastSafe=true;
 V.lastSafeAt=performance.now();
 V.safeSamples++;
 V.status="SAFE";V.permit=true;V.reason="verified";
 return V;
};
setInterval(function(){try{if(ActorRuntime.authority==="legacy"||ActorRuntime.authority==="ai_guarded")ActorRuntime.superviseSafety();}catch(e){ActorRuntime.debug.lastError=String(e);}},16);
/* ===== END SAFETY SUPERVISOR — v216 ===== */
/* ===== AI CONTROL INTERFACE — v209 ===== */
window.WORLD_INTELLIGENCE={
 version:209,
 latest:null,
 snapshot:function(){
  var R=window.ACTOR_RUNTIME,F=window.WORLD_FOUNDATION;
  if(!R)return null;
  var P=R.senseWorld?R.senseWorld():null,T=R.terrainPrediction||null,I=R.input||null;
  var q=function(n){return Number.isFinite(n)?Number(n.toFixed(4)):null;};
  var out={
   version:209,authority:R.authority,control:R.enabled?"LIVE":"SHADOW",
   owner:I?I.owner:"none",mode:R.locomotion.requestedMode,
   player:(typeof kingPos!=="undefined"&&kingPos)?{x:q(kingPos.x),y:q(kingPos.y),z:q(kingPos.z)}:null,
   input:I?{x:q(I.moveX),z:q(I.moveZ),magnitude:q(I.magnitude)}:null,
   perception:P?{support:P.support,grounded:P.grounded,airborne:P.airborne,falling:P.falling,surface:P.surface,groundY:q(P.groundY),delta:q(P.delta),slope:q(P.slope),safe:P.safeStand}:null,
   terrain:T?{classification:T.classification,support:T.support,valid:T.valid,groundY:q(T.groundY),slope:q(T.slope),step:q(T.step),surface:T.surface,safe:T.safe}:null,
   surfaces:F?F.colliders.length:0,timestamp:Date.now()
  };
  this.latest=out;return out;
 },
 requestAI:function(agentId){
  var R=window.ACTOR_RUNTIME;if(!R||!R.ai.allowed)return false;
  R.ai.active=true;R.ai.agentId=String(agentId||"ai");R.ai.control="shadow";return true;
 },
 drive:function(agentId,intent){
  var R=window.ACTOR_RUNTIME;if(!R||!R.ai.active||R.ai.agentId!==String(agentId||"ai"))return 