<!-- SOLIDABILITY-WORLD · part 23 -->
  function getHistory() { return [...investigationHistory]; }
  function getFindings() { return findings; }

  // Show diagnostics panel
  function showPanel() {
    let panel = document.getElementById('diagnostics-panel');
    if (!panel) {
      panel = document.createElement('div');
      panel.id = 'diagnostics-panel';
      document.getElementById('app').appendChild(panel);
    }

    const f = findings;
    panel.innerHTML = `
      <div class="diag-card">
        <div class="diag-header">
          <h3>🔍 Diagnostics</h3>
          <span class="code-close" onclick="document.getElementById('diagnostics-panel').classList.remove('visible')">✕</span>
        </div>
        <div class="diag-actions">
          <button class="diag-btn" onclick="SWDiagnose.runAndShow()">Run Integrity Check</button>
          <button class="diag-btn" onclick="SWDiagnose.showLocator()">Find Problem</button>
          <button class="diag-btn" onclick="SWDiagnose.showHistory()">History</button>
          <button class="diag-btn" onclick="SWTrust.showAudit()">📋 Audit</button>
        </div>
        <div class="diag-results" id="diag-results">
          ${f ? renderFindings(f) : '<p class="note">No checks run yet.</p>'}
        </div>
      </div>
    `;
    panel.classList.add('visible');
  }

  function renderFindings(f) {
    const layers = [
      ['Source Integrity', f.sourceIntegrity],
      ['Spatial Integrity', f.spatialIntegrity],
      ['Interaction Integrity', f.interactionIntegrity],
    ];
    return layers.map(([name, check]) => `
      <div class="diag-layer">
        <h4>${name}: <span class="status-${check.status}">${check.status}</span></h4>
        <p>${check.note || ''}</p>
        ${(check.issues || []).map(i =>
          `<p class="issue">⚠️ ${i.type}: ${JSON.stringify(i.rooms || i.room)}</p>`
        ).join('')}
      </div>
    `).join('');
  }

  async function runAndShow() {
    document.getElementById('diag-results').innerHTML = '<p>Running checks...</p>';
    const results = await runIntegrityCheck();
    document.getElementById('diag-results').innerHTML = renderFindings(results);
  }

  // Show audit trail button handler
  function showAuditPanel() {
    if (typeof SWTrust !== 'undefined') SWTrust.showAudit();
  }

  function showLocator() {
    const symptom = prompt('Describe the symptom (e.g. "login is slow", "GET /api/version fails"):');
    if (!symptom) return;
    const result = locateProblem(symptom);
    const html = `
      <h4>Problem: "${symptom}"</h4>
      ${result.candidates.length
        ? result.candidates.map(c => `
          <div class="candidate" onclick="SWDiagnose.navigateToCandidate('${c.key}')">
            <div class="cand-room">${c.room} ${evidenceBadge(c.evidenceState)}</div>
            <div class="cand-evidence">${c.evidence}</div>
            ${c.evidenceNote ? `<div class="cand-note">${c.evidenceNote}</div>` : ''}
          </div>
        `).join('')
        : '<p>No candidates found. Try different keywords.</p>'}
    `;
    document.getElementById('diag-results').innerHTML = html;
  }

  function navigateToCandidate(roomKey) {
    document.getElementById('diagnostics-panel').classList.remove('visible');
    const layout = SWWorld.getLayout();
    const room = layout.rooms.find(r => r.key === roomKey);
    if (room) SWHyper.aiDriveTo(room, `Navigating to diagnostic candidate.`);
  }

  function showHistory() {
    const html = investigationHistory.reverse().map(i => `
      <div class="history-item">
        <div class="hist-room">${i.type}</div>
        <div class="hist-meta">${i.summary}</div>
        <div class="hist-time">${new Date(i.timestamp).toLocaleString()}</div>
      </div>
    `).join('') || '<p>No investigations yet.</p>';
    document.getElementById('diag-results').innerHTML = html;
  }

  return {
    runIntegrityCheck, locateProblem, analyzeImpact,
    getHistory, getFindings, showPanel,
    runAndShow, showLocator, showHistory, navigateToCandidate,
    showAuditPanel,
  };
})();


===== FILE: public/solidability-world/js/sw-engine.js =====
// Solidability World — 3D Engine
// Three.js scene setup. Patterns adapted from /newworld/engine.js (copied, not modified).
// Simplified for inspection: slower pace, deliberate movement, no game physics.

const SWEngine = (() => {
  let scene, camera, renderer, player;
  let keys = {};
  let joystick = { active: false, dx: 0, dy: 0 };

  function init(containerId) {
    const container = document.getElementById(containerId);

    scene = new THREE.Scene();
    scene.background = new THREE.Color(0x1a1a24);
    // scene.fog = new THREE.Fog(0x1a1a24, 40, 160); // DISABLED FOR TEST

    camera = new THREE.PerspectiveCamera(70, container.clientWidth / container.clientHeight, 0.1, 500);

    renderer = new THREE.WebGLRenderer({ antialias: true });
    renderer.setSize(container.clientWidth, container.clientHeight);
    // renderer.shadowMap.enabled = true; // DISABLED FOR TEST
  