<!-- SAGA-SOLID · part 94 -->
:"NO")+"\nAIRBORNE  "+(P.airborne?"YES":"NO")+"\nFALLING   "+(P.falling?"YES":"NO")+"\nSURFACE   "+P.surface+"\nGROUND Y  "+(P.groundY===null?"NONE":P.groundY.toFixed(2))+"\nDELTA     "+(P.delta===null?"NONE":P.delta.toFixed(2))+"\nSLOPE     "+(P.slope===null?"NONE":P.slope.toFixed(1))+"\nSAFE      "+(P.safeStand?"YES":"NO")+"\n\nMOVEMENT AUTHORITY  "+String(R.authority).toUpperCase();}};
    CODES.actortest = {cat:"Special",desc:"Run AI Actor controller self-test",fn:function(){ if(window.ACTOR_RUNTIME) window.ACTOR_RUNTIME.runControllerTest(); }};
    CODES.actordebug = {cat:"Special",desc:"Toggle Actor Runtime debugger",fn:function(){ if(window.ACTOR_RUNTIME) window.ACTOR_RUNTIME.toggleDebug(); }};
      CODES.worlddebug = {
      cat:'Special',
      desc:'Toggle Foundation 1 debugger',
      fn:function(){
        WF.toggleDebug();
      }
    };
  }

  /*
   * Base plane exists by this point in the current script.
   * Mountain list can continue changing, so syncMountains() is
   * idempotently called by debug observation.
   */
  /*
   * v184 FOUNDATION STARTUP TRACE
   * UI diagnostics only. Never touches world state.
   */
  function foundationTrace(message){
    var el = document.getElementById('foundation-startup-trace');

    if(!el){
      el = document.createElement('div');
      el.id = 'foundation-startup-trace';
      el.style.cssText = [
        'position:fixed',
        'top:55px',
        'left:12px',
        'z-index:2147483647',
        'background:rgba(0,0,0,.92)',
        'color:#7CFF7C',
        'border:1px solid #7CFF7C',
        'border-radius:6px',
        'padding:5px 8px',
        'font:11px monospace',
        'pointer-events:none'
      ].join(';');
      el.style.display = 'none'; /* gameplay HUD cleanup */
      document.body.appendChild(el);
    }

    el.textContent = message;
  }

  foundationTrace('F1 A · ENTERED');

  try{
    foundationTrace('F1 B · BASE START');
    WF.registerBasePlane();
    foundationTrace('F1 C · BASE OK · ' + WF.colliders.length);
  }catch(err){
    foundationTrace(
      'F1 ERROR BASE · ' +
      (err && err.message ? err.message : String(err))
    );
    throw err;
  }

  try{
    foundationTrace('F1 D · MOUNTAINS START');
    WF.syncMountains();
    foundationTrace('F1 E · MOUNTAINS OK · ' + WF.colliders.length);
  }catch(err){
    foundationTrace(
      'F1 ERROR MOUNTAINS · ' +
      (err && err.message ? err.message : String(err))
    );
    throw err;
  }

  foundationTrace('F1 F · STARTUP COMPLETE · ' + WF.colliders.length);

  /*
   * BOOT PROOF.
   * This appears ONLY if execution actually reaches Foundation 1.
   * Diagnostic UI only. It does not touch the world.
   */
  (function(){
    var boot = document.getElementById('foundation-boot-proof');

    if(!boot){
      boot = document.createElement('div');
      boot.id = 'foundation-boot-proof';
      boot.style.cssText = [
        'position:fixed',
        'top:55px',
        'left:12px',
        'z-index:2147483647',
        'background:rgba(0,0,0,.85)',
        'color:#7CFF7C',
        'border:1px solid #7CFF7C',
        'border-radius:6px',
        'padding:5px 8px',
        'font:11px monospace',
        'pointer-events:none'
      ].join(';');

      boot.style.display = 'none'; /* gameplay HUD cleanup */
      boot.textContent =
        'F1 READY · ' + WF.colliders.length + ' SURFACES';

      document.body.appendChild(boot);
    }
  })();

  /*
   * One observation timer.
   * It NEVER writes kingPos.
   */
  WF.debugTimer = setInterval(function(){
    try{
      WF.syncMountains();
      var boot = document.getElementById("foundation-boot-proof");
      if(boot) boot.textContent = "F1 READY · " + WF.colliders.length + " SURFACES";
      WF.updateDebug();
    }catch(err){
      if(window.console && console.error){
        console.error('[WORLD_FOUNDATION]', err);
      }
    }
  }, 200);

})();

/* ============================================================
   V219 COMMISSIONING TEST INSTRUMENT (temporary)
   Authorized 2026-10-07 by the King. NOT Drive Stage 2.
   Minimal in-game control for 1-second AI drive test.
   Fail-closed on Safety Supervisor. Human override always.
   ============================================================ */
(function(){
  if (window._v219testInstalled) return;
  window._v219testInstalled = true;

  // V219 panel hidden — controlled via Cockpit
  var panel = document.createElement('div');
  panel.id = 'v219-test-panel';
  panel.style.display = 'none';
  panel.innerHTML =
    '<button id="v219-run"></button>' +
    '<button id="v219-abort"></button>' +
    '<div id="v219-out"></div>';
  document.body.appendChild(panel);
  // Expose for Cockpit
  window._v219panel = panel;

  function log(s){
    var o = document.getElementById('v219-out');
    if(o) o.textContent += s + '\n';
  }
  function clearLog(){
    var o = document.getElementById('v219-out');
    if(o) o.textContent = '';
  }

  // Emergency abort — al