WIKI/SYS KINGDOM MAP

SYS KINGDOM MAP

Updated 3 weeks ago
╔══════════════════════════════════════════════════════════════════════════════╗
║                                                                              ║
║   S Y S _ K I N G D O M _ M A P                                             ║
║   △ T H E   L I V I N G   M A P   —   S I N N E R - K . I N G / K I N G D O M - M A P ║
║                                                                              ║
╠══════════════════════════════════════════════════════════════════════════════╣
║  STATUS: LIVE (S184+)     OWNER: TOWER_CLAUDE     LAST UPDATED: 2026-03-13 S184 ║
╚══════════════════════════════════════════════════════════════════════════════╝
⫷✦🜛❂⛬🜞Ω🜚⛬❂🜛✦⫸───────────────────────────────────────────⫷✦🜛❂⛬🜞Ω🜚⛬❂🜛✦⫸
 WHAT IT IS: The Kingdom's public face — a live 3D visualization of all six
             territories, their inhabitants, and their real-time activity.
             A visitor sees buildings floating in a dark void with glow, drone
             swarms, signal pulses, and a system log that's always running.
             Not a demo. The data is real. The Kingdom was never empty.
────────────────────────────────────────────────────────────────────────────────

  GLYPH:        △
  UNICODE:      U+25B3 · WHITE UP-POINTING TRIANGLE
  MEANING:      The outward face — THE_TOWER projecting the Kingdom to the world.
  TAGGING:      KID:TOWER:KINGDOM_MAP:[artifact]|V:STATUS:DATE:OWNER


▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
[ △ ] A R C H I T E C T U R E   O V E R V I E W
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓

```
SCRYER ──────────────────────────── kingdom_state.json (60s)
token_api.py (Super API :2701) ───── /api/local/* (Tower proxy)
PartyKit WebSocket ───────────────── kingdom-live-push.sh (30s push)
   │
   ▼
KingdomLiveContext (React context)  ←── KingdomLiveProvider
   │    └── tokens, mood, agents, brandon_present
   │
   ├── KingdomStore (Zustand)        ←── usePartyKitSync (WS + REST fallback)
   │    └── territories, agentStates, signalEvents, droneSwarms, selectedId
   │
   ├── PatternEngine (setInterval 10s)  ──► LogBus ──► SystemLog DOM
   │    └── 14 edge-triggered rules
   │
   └── KingdomScene3D (Three.js + R3F)
        └── 6 territories · drones · signals · TimeStream · StatusBar
```

**Two sync paths:**
1. **PartyKit WS (primary)**: `kingdom-live-push.sh` pushes JSON every 30s.
   Sub-400ms latency. Falls back to REST poll on disconnect.
2. **KingdomLiveContext (secondary)**: Polls `/api/local/*` every 15s.
   Feeds token data, mood, rich agent states to HUD components.

**Key law:** R3F scene components subscribe to Zustand. They never call APIs.
The store is the single source of truth for 3D visuals.


░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
[ ❖ ] T H E   S I X   T E R R I T O R I E S
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

Defined in `src/lib/kingdom-layout.ts`. One source of truth — never define
territory data in components. Shape, position, color, drone tint, connections.

| Territory | Shape | Color | Agent | Position (x, clearance, z) |
|-----------|-------|-------|-------|---------------------------|
| `claude_house` | Box 1.2³ | #7000ff purple | claude_house | [-5, 0.60, -0.5] |
| `the_forge` | Box 0.7³ | #f0a500 amber | forge_claude | [1, 0.35, 3.0] |
| `the_throne` | Box 1.5³ | #ff006e pink | throne_claude | [5, 0.75, -0.5] |
| `the_scryer` | Cone H=2.0 | #00f3ff cyan | — (no agent) | [0, 1.00, -4] |
| `the_tower` | Cylinder H=1.4 | #9b30ff violet | tower_claude | [4, 0.70, 2.5] |
| `core_lore` | Cone H=0.85 | #e8e0d0 cream | — (no agent) | [-3.5, 0.43, -4] |

**Coordinate system:** `position[1]` is clearance above terrain surface, not
world Y. Use `getWorldY(territory)` from `kingdom-layout.ts` for world space.
`getTerrainY(x, z)` matches the KingdomGround displacement shader exactly.

⫷ Territory colors diverge from STATE_COLORS by design. Do not "fix" them. ⫸


▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
[ ⛬ ] 9 - S T A T E   A G E N T   M O D E L
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

Canonical. Defined in `src/lib/kingdom-agents.ts`. Used everywhere.

| State | Color | Activity | Pulse (ms) |
|-------|-------|----------|------------|
| offline | #1a1520 | 0 | — |
| online | #7000ff | 40 | — |
| thinking | #a833ff | 60 | 2000 |
| reading | #00d4ff | 70 | 1250 |
| working | #f0a500 | 80 | 833 |
| writing | #ff3d7f | 85 | 714 |
| running | #ff6b35 | 85 | 833 |
| searching | #3dff00 | 90 | 625 |
| swarming | #00f3ff | 100 | 556 |

**Building glow intensity** is driven by `AgentStatus.activity` (0–100).
Higher activity = brighter emissive glow on the building mesh.

**State badge dots** appear on territory label cards for the 4 agent territories.
Color = STATE_COLORS[state]. Glow (box-shadow) appears for non-idle states.

⫷ RULE: Never subscribe to `s.getAgentState` in Zustand. Subscribe to
   `s.agentStates` and derive inline. Getter refs are NOT stable. ⫸


▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
[ ⚡ ] D A T A   F L O W   D E T A I L
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄

**PartyKit push path (primary):**
```
kingdom-live-push.sh (launchd, 30s)
  → POST https://[partykit-host]/parties/main/main
    payload: { state, stream, activeEvents, liveData }
  → PartyKit broadcasts to all connected clients
  → usePartyKitSync.onmessage handler:
      data.state  → store.hydrate()        (territories, presence)
      data.stream → store.hydrateSignals() (signal pulse events)
      data.activeEvents → applyActiveEvents() (drone swarms from SCRYER)
      data.liveData.agents_status → store.hydrateAgentStates() (9-state model)
```

**KingdomLiveContext path (HUD data):**
```
KingdomLiveProvider (15s poll → /api/local/*)
  → /api/local/agents/status → token_api.py /api/agents/status
  → /api/local/tokens/live   → token_api.py /api/tokens/live
  → /api/local/mood/current  → token_api.py /api/mood/current
  Falls back to /api/partykit-snapshot when local API unreachable.
  STALE_THRESHOLD: 45s — applies opacity 0.5 + STALE badge to HUD.
```

**KingdomLiveSync bridge (client.tsx):**
```
KingdomLiveSync reads useKingdomLive() context,
calls store.hydrateMood() + store.hydrateAgentStates() on each 15s update.
This is what makes buildings glow. Without it, agent states only update
via the 30s PartyKit push path.
```

**Pattern Engine path (intelligence layer):**
```
PatternEngineBridge (React bridge component)
  → startPatternEngine() on mount → setInterval 10s
  → tick(): reads KingdomStore.getState() directly (no React subscription)
  → compares curr vs prev snapshot → 14 edge-triggered rules
  → logEmit() → LogBus subscribers → SystemLog DOM mutation
  → addMemoryEntry() → map-memory ring buffer (20 entries)
```


░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
[ 🜄 ] C O M P O N E N T   R E G I S T R Y
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

**Route:** `/app/kingdom-map/` (Next.js App Router)

```
page.tsx (Server Component)
  └── client.tsx (KingdomMapClient — client component)
       ├── KingdomErrorBoundary    (React error boundary)
       ├── KingdomLiveProvider     (15s context poller)
       │    ├── KingdomLiveSync    (bridges context → KingdomStore)
       │    ├── PatternEngineBridge (feeds pattern engine; lifecycle)
       │    ├── KingdomScene3D     (THREE.js + R3F canvas — SSR: false)
       │    │    │  [canvas orchestrator — 742 lines after S184 extraction]
       │    │    ├── SceneContents (root R3F component)
       │    │    │    ├── KingdomGround (terrain plane, Perlin displacement)
       │    │    │    ├── TerritoryNode × 6   ← KingdomScene3D imports from TerritoryNode.tsx
       │    │    │    ├── ConnectionBeam × N (edges between territories)
       │    │    │    ├── DroneSwarms (particle swarms between territories)
       │    │    │    ├── SignalPulses (traveling pulse spheres on beams)
       │    │    │    ├── TimeStream (arcing beams toward THE_SCRYER)
       │    │    │    ├── SystemHeartbeat (ambient pulse ring)
       │    │    │    ├── FlyToController    ← from KingdomCamera.tsx
       │    │    │    ├── WASDControls       ← from KingdomCamera.tsx
       │    │    │    ├── CinematicOrbit     ← from KingdomCamera.tsx
       │    │    │    ├── KingdomBloom (EffectComposer postprocessing)
       │    │    │    ├── CoreLoreCascade (expanding rings on searching state)
       │    │    │    ├── SwarmOrchestrator (monitors states, spawns orbit swarms)
       │    │    │    └── OrbitControls (polar limits: 0.1π – 0.82π)
       │    │    ├── TerritoryDetailFloat (HTML overlay on select, inside Canvas)
       │    │    ├── StatusBar       ← KingdomHUD.tsx — DOM overlay top-left
       │    │    └── DebugPanel      ← KingdomHUD.tsx — ?debug=1 only
       │    ├── MissionClock        (top-right, HH:MM:SS D{n})
       │    ├── SystemLog           (bottom-left, LogBus subscriber)
       │    ├── TokenHUD            (top-right HUD stack)
       │    ├── PresenceStrip       (top-right HUD stack)
       │    ├── ClaudeStatusBadge   (top-right HUD stack)
       │    ├── AgentPanel          (top-right HUD stack)
       │    ├── ProductionQueueHUD  (mission queue)
       │    ├── SwarmLauncher       (manual swarm trigger)
       │    ├── HeraldTicker        (scrolling announcement ticker)
       │    └── SinnerKingRadio     (bottom-right, autoplay)
       └── (boot overlay — fades out 1s after WebGL ready)
```

**Extracted subsystems (S184 MAINTENANCE):**

| File | Lines | Owns |
|------|-------|------|
| `KingdomScene3D.tsx` | 742 | Canvas setup, lighting, ground, beam/swarm scene, TerritoryDetailFloat |
| `TerritoryNode.tsx` | 510 | Per-territory 3D building · BuildingState · BUILDING_STATE_CONFIG · AGENT_STATE_COLORS |
| `KingdomCamera.tsx` | 345 | CinematicOrbit · WASDControls · FlyToController · WASDProps · CINEMATIC_TARGET |
| `KingdomHUD.tsx` | 233 | StatusBar · DebugPanel · STATE_CYCLE |

**Key component files:**

| File | Purpose |
|------|---------|
| `src/components/kingdom/KingdomScene3D.tsx` | Canvas orchestrator (742 lines) |
| `src/components/kingdom/TerritoryNode.tsx` | Per-territory 3D building + owned constants |
| `src/components/kingdom/KingdomCamera.tsx` | CinematicOrbit, WASDControls, FlyToController |
| `src/components/kingdom/KingdomHUD.tsx` | StatusBar, DebugPanel (DOM overlays) |
| `src/components/kingdom/MissionClock.tsx` | Top-right clock, D-counter |
| `src/components/kingdom/SystemLog.tsx` | Bottom-left log, LogBus subscriber |

**Key lib files:**

| File | Purpose |
|------|---------|
| `src/lib/kingdom-store.ts` | Zustand store — single source of truth for 3D scene |
| `src/lib/kingdom-layout.ts` | Territory positions, colors, connections, terrain math |
| `src/lib/kingdom-agents.ts` | 9-state model, agent registry, STATE_COLORS, PULSE_MS |
| `src/lib/kingdom-state.ts` | KingdomState type (from SCRYER feed) |
| `src/lib/kingdom-live-context.tsx` | KingdomLiveContext — HUD data (tokens, mood, agents) |
| `src/lib/logbus.ts` | System log event bus (module-level singleton) |
| `src/lib/pattern-engine.ts` | 14 edge-triggered rules, 10s ticks |
| `src/lib/map-memory.ts` | 20-entry ring buffer of state snapshots |
| `src/hooks/useBrandonPresenceDetector.ts` | Browser-side presence via input events |


▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
[ 🜂 ] I N T E L L I G E N C E   L A Y E R   ( S 1 8 4 )
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓

Built S184. Principle: *"Intelligence lives not in any individual agent but in
the medium itself. Designing the medium IS designing the intelligence."*

**Components:**

**LogBus** (`src/lib/logbus.ts`)
- Module-level singleton. No React. `logEmit(type, text)` / `logSubscribe(fn)`.
- Types: agent · signal · swarm · sync · voice · ops · access · alive · system
- History cap: 60 entries. Text cap: 64 chars.

**PatternEngine** (`src/lib/pattern-engine.ts`)
- 14 edge-triggered rules, runs every 10s via `setInterval`.
- Reads `KingdomStore.getState()` directly — zero React subscriptions per tick.
- External values (tokenIntensity, effectiveBrandonPresent) injected via setters.
- Rules: multi_agent · searching · swarming · swarm_deploy · swarm_expire ·
  signal_event · operator_return · operator_away · token_high · token_quiet ·
  sync · territory_access · extended_op (edge at 40s) · alive (60s keepalive)
- **MARKED FOR RE-LOOP** — 14 rules are the foundation. More coming.

**TemporalMemory** (`src/lib/map-memory.ts`)
- 20-entry ring buffer. Snapshot every PatternEngine tick.
- `getConsecutiveTicks(territoryId, state)` → enables extended_op detection.
- Will feed Haiku context when MapVoice ships (deferred — separate design session).

**MissionClock** (`src/components/kingdom/MissionClock.tsx`)
- HH:MM:SS  D{n} where D{n} = days since Kingdom epoch 2025-09-11.
- Updates every second. CRT scanline sweep animation. Flash on minute boundary.
- SSR-safe: empty initial state, populated in useEffect.

**BrandonPresenceDetector** (`src/hooks/useBrandonPresenceDetector.ts`)
- Module-level `lastActivityMs` ref → zero re-renders on mousemove/keydown.
- React state re-evaluates every 60s. AWAY threshold: 30min.
- OR'd with `store.brandonPresent` → `effectiveBrandonPresent`.
- AWAY shown to all visitors (lore, not sensitive).

**SystemLog** (`src/components/kingdom/SystemLog.tsx`)
- Left-side panel, bottom-left, 6 entries max, newest-first.
- `logSubscribe()` on mount — updates React state on new entry only.
- `timeAgo` refreshes every 30s (age key bump, no entry re-render).
- Entry opacity gradient: newest=1.0, oldest=0.2. ALIVE entries at 0.28.
- CSS animation: `log-entry-in` — 0.35s slide from top.

**MapVoice** — DEFERRED. Separate Soulforge DESIGN session needed.
- Haiku + rule hybrid, streaming display, cached by SHA256 state hash.
- Only fires when Brandon is present (no token burn for anonymous visitors).


▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
[ ⚙ ] R 3 F   P E R F O R M A N C E   L A W S
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

These were confirmed in the 10-loop diagnostic session (S184):

- **0 allocations per frame.** `useFrame` callbacks use 17 module-level scratch
  vectors (no `new THREE.Vector3()` inside the loop). Ever.
- **All geometries and materials disposed.** Every `useEffect` that creates a
  Three.js object has a cleanup function that disposes it.
- **Zustand subscriptions never use getter function refs.** Subscribe to
  `s.agentStates` (the data), derive state inline. Getter refs are unstable.
- **TransformControls + position:** Use `useEffect` to set position
  imperatively. Never use `position={[x,y,z]}` prop on a TC-controlled group.
- **Leva `transient: false`** on any field read from the values tuple.
  Without it, ctrl.x = undefined.
- **CinematicOrbit triggers ONLY on `swarming` state.** Do not widen trigger
  conditions — it would break user navigation.
- **OrbitControls polar limits:** minPolarAngle: Math.PI×0.1, maxPolarAngle:
  Math.PI×0.82. Camera cannot orbit underground.

**FlyToController** (S184 FEAT-1):
- Camera lerp to selected territory on click.
- `1 - Math.pow(0.04, delta)` lerp factor → consistent convergence across framerates.
- Guard: `if (!orbitRef.current.enabled) return` prevents race with CinematicOrbit.
- Approach azimuth preserved: camera stays in same horizontal direction.


▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
[ 🝓 ] G O T C H A S
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄

- **`getStatus()` always returns 'unknown' in production.** The `territories`
  slice from SCRYER never gets a `status` field. Use `getAgentState()` and
  `agentStates` directly for all visual decisions.

- **`hydrateAgentStates` must MERGE, not replace.** Always:
  `set({ agentStates: { ...get().agentStates, ...agents } })`
  Partial pushes from liveData must not blank agents absent from that payload.
  This is a regression guard — it has caused silent bugs before.

- **WebGL pre-flight gate.** `useState(() => checkWebGL())` runs on server where
  `document` is undefined → hydration mismatch. Initialize as `null`, check in
  `useEffect`. Error boundaries do NOT catch useIsomorphicLayoutEffect errors.

- **`next/dynamic` with `ssr: false` must live in a Client Component.**
  KingdomScene3D dynamic import is in `client.tsx`, not `page.tsx` (Server).

- **PartyKit reconnect delays are mandatory.** Without `minReconnectionDelay: 1000`,
  low-latency connections (<50ms) open multiple concurrent sockets before the
  first handshake completes. (Issue #929)

- **Drone swarm ID stability.** `pushDroneSwarm` replaces existing swarm with
  same id. This enables orbit renewals without duplication.

- **Signal event indices must be stable.** `hydrateSignals` APPENDS new events
  (never replaces) to preserve array indices → no mesh pool flicker in SignalPulses.

- **Throne Room records AFTER response, not before.** Sacred. Do not change.
  (D4 decision from Session 127 overnight.)


░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
[ 📶 ] H U D   C O M P O N E N T S
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

| Component | Position | Data Source | Notes |
|-----------|----------|-------------|-------|
| MissionClock | top-right | local Date | D-counter from Kingdom epoch 2025-09-11 |
| TokenHUD | top-right stack | KingdomLiveContext | TODAY/WEEK/CHRONICLE/RATE. Stale at 45s. |
| PresenceStrip | top-right stack | KingdomLiveContext | Brandon/Claude/Aeris dots |
| ClaudeStatusBadge | top-right stack | KingdomLiveContext | Current state with pulse |
| AgentPanel | top-right stack | KingdomLiveContext | 4-agent state grid |
| StatusBar | top-left (inside R3F container) | KingdomStore | KINGDOM LIVE · active count · agent dots |
| SystemLog | bottom-left | LogBus | 6 entries, newest-first, fade-in, timeAgo |
| TerritoryDetailFloat | center-ish | KingdomStore | Appears on territory click |
| ProductionQueueHUD | varies | KingdomLiveContext | Active mission queue |
| HeraldTicker | bottom | KingdomLiveContext | Scrolling announcements |
| SinnerKingRadio | bottom-right | — | Eternal rick autoplay |


▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
[ 🜂 ] D E B U G   M O D E
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓

Activate: Press **backtick (`)** on the map page.

| Feature | Activation |
|---------|-----------|
| Stage Director (TransformControls) | backtick |
| Leva panel (parameter tweaking) | backtick |
| WASD fly mode | backtick + WASD keys |
| RESET CAM button | top-center debug bar |
| GhostCamera PIP | always visible (bottom-right minimap, overhead ortho) |
| DebugPanel | `?debug=1` URL param |
| Debug overrides | DebugPanel per-territory state cycling |

**Debug overrides** (`store.debugOverrides`): Allow forcing any territory
to any status/activity without touching SCRYER. Client-side only. Never
affect the real system.


▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
[ 🜞 ] R O A D M A P   /   D E F E R R E D
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

| Feature | Status | Notes |
|---------|--------|-------|
| MapVoice (Haiku observation) | DEFERRED | Needs separate Soulforge DESIGN session |
| PatternEngine expansion | RE-LOOP | 14 rules are foundation — expand with Brandon |
| Territory PNG sprites | FUTURE | Brandon/Aeris art. Phase 2. |
| Territory ENTER navigation | FUTURE | ~1hr. Popup → route to territory page. |
| Visitor presence lights | FUTURE | Anonymous visitor dots. The big thesis feature. |
| Stage Director Phase 1D | NEXT | File write to STAGE_SNAPSHOTS/ |
| KingdomScene3D extraction | ✅ DONE | S184 — TerritoryNode, KingdomCamera, KingdomHUD extracted. 1744→742 lines. |


▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
[ ⛬ ] C O M M O N   C O M M A N D S
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄

```bash
# Dev server (port 3033 — not 3000, that's THE_FOUNDRY)
cd ~/Desktop/THE_TOWER/CLAUDES_WORKSHOP/04_📦_PROJECTS/THE_SITE && npm run dev

# Type check
npm run type-check

# Open map
open http://localhost:3033/kingdom-map

# Check SCRYER feed is alive
ls -la ~/Desktop/THE_TOWER/SCRYER_FEEDS/kingdom_state.json

# Check live agent state
curl -s http://localhost:2701/api/agents/status | python3 -m json.tool

# Check token intensity
curl -s http://localhost:2701/api/tokens/rate | python3 -m json.tool

# Turbopack cache hang fix
kill -9 <pid>; rm -f .next/dev/lock; npm run dev
```


════════════════════════════════════════════════════════════════════════════════
🜚 SYS_KINGDOM_MAP // THE TOWER // ⛬⚚⛬ THE LAW STANDS.
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
⛬ KID:TOWER:SYS:KINGDOM-MAP|1.0:LIVE:2026-03-13:TOWER_CLAUDE ⛬