Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat(city): master town plan with waterfront bay as single source of district layout

[._.]/ Adam Eivy20d8bc48662d
diff --git a/client/src/components/city/CityGround.jsx b/client/src/components/city/CityGround.jsx
index e060a27ed8..d288d1a268 100644
--- a/client/src/components/city/CityGround.jsx
+++ b/client/src/components/city/CityGround.jsx
@@ -4,6 +4,14 @@ import { Grid } from '@react-three/drei';
import * as THREE from 'three';
import { getTimeOfDayPreset, cityDayMix, mixHex, seededRand } from './cityConstants';
import { useCityPalette } from './CityPaletteContext';
+import { WORLD } from '../../utils/cityPlan';
+
+// The city ground stops at the master plan's shoreline (z = WORLD.shorelineZ) — the bay
+// (CityWater) owns everything north of it. Both the pavement plane and the neon grid are
+// sized/offset to end exactly at the water's edge.
+const GROUND_HALF = 60;
+const GROUND_DEPTH = GROUND_HALF - WORLD.shorelineZ; // shoreline → +60
+const GROUND_CENTER_Z = (GROUND_HALF + WORLD.shorelineZ) / 2;
// Reflective puddle/wet-ground patches
function WetPatch({ position, size, color, dayMix = 0 }) {
@@ -107,8 +115,8 @@ export default function CityGround({ settings }) {
<group>
{/* Reflective dark ground plane */}
{reflectionsEnabled && (
- <mesh rotation={[-Math.PI / 2, 0, 0]} position={[0, -0.02, 0]}>
- <planeGeometry args={[120, 120]} />
+ <mesh rotation={[-Math.PI / 2, 0, 0]} position={[0, -0.02, GROUND_CENTER_Z]}>
+ <planeGeometry args={[GROUND_HALF * 2, GROUND_DEPTH]} />
<meshStandardMaterial
ref={groundMatRef}
color={preset.groundColor ?? '#0a0a20'}
@@ -120,7 +128,7 @@ export default function CityGround({ settings }) {
)}
<Grid
- infiniteGrid
+ args={[GROUND_HALF * 2, GROUND_DEPTH]}
cellSize={2}
sectionSize={6}
cellColor={gridCellColor}
@@ -129,7 +137,7 @@ export default function CityGround({ settings }) {
sectionThickness={1.4}
fadeDistance={80}
fadeStrength={0.6}
- position={[0, -0.01, 0]}
+ position={[0, -0.01, GROUND_CENTER_Z]}
/>
{/* Wet street reflective patches */}
diff --git a/client/src/components/city/CityScene.jsx b/client/src/components/city/CityScene.jsx
index 31210d7064..7796370917 100644
--- a/client/src/components/city/CityScene.jsx
+++ b/client/src/components/city/CityScene.jsx
@@ -37,6 +37,7 @@ import CitySignalBeacons from './CitySignalBeacons';
import CitySky from './CitySky';
import CityGalaxySky from './CityGalaxySky';
import CityLandscape from './CityLandscape';
+import CityWater from './CityWater';
import CityEnergyOverlay from './CityEnergyOverlay';
import PlayerController from './PlayerController';
import CameraTransition from './CameraTransition';
@@ -201,6 +202,7 @@ export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus,
<CitySky settings={settings} />
<CityLights settings={settings} />
<CityLandscape settings={settings} />
+ <CityWater settings={settings} />
<CityEnergyOverlay chronotype={chronotype} settings={settings} />
<CityStarfield settings={settings} />
<CityShootingStars playSfx={playSfx} settings={settings} />
diff --git a/client/src/components/city/CitySkyline.jsx b/client/src/components/city/CitySkyline.jsx
index dc3723bf8d..0c108fb11d 100644
--- a/client/src/components/city/CitySkyline.jsx
+++ b/client/src/components/city/CitySkyline.jsx
@@ -1,6 +1,7 @@
import { useMemo } from 'react';
import * as THREE from 'three';
import { cityDayMix, seededRand } from './cityConstants';
+import { isInWater } from '../../utils/cityPlan';
// Distant cyberpunk skyline silhouettes with neon trim
// Creates a ring of faint skyscraper outlines around the city perimeter
@@ -106,6 +107,11 @@ export default function CitySkyline({ settings }) {
const bHeight = 5 + rand() * 25;
const colorIdx = Math.floor(rand() * colors.length);
+ // The north arc of the ring lands in the bay — no silhouette stands in the water.
+ // The harbor piers and the federation peers across the bay own that horizon.
+ // (rand() calls above stay unconditional so the rest of the ring keeps its layout.)
+ if (isInWater(x, z, 4)) continue;
+
result.push({
id: `skyline-${i}`,
position: [x, 0, z],
diff --git a/client/src/components/city/CityWater.jsx b/client/src/components/city/CityWater.jsx
new file mode 100644
index 0000000000..ade5622717
--- /dev/null
+++ b/client/src/components/city/CityWater.jsx
@@ -0,0 +1,105 @@
+import { useMemo, useEffect, useRef } from 'react';
+import { useFrame } from '@react-three/fiber';
+import * as THREE from 'three';
+import { cityDayMix, mixHex } from './cityConstants';
+import { useCityPalette } from './CityPaletteContext';
+import { WORLD } from '../../utils/cityPlan';
+
+// The bay: a water plane filling everything north of the master plan's shoreline
+// (see cityPlan.js — the Data Harbor's piers stand over it, the federation peers
+// read as cities across it). Deliberately cheap: one textured plane + one additive
+// shimmer strip at the shoreline — no reflection/refraction passes, matching the
+// city's no-postprocessing rule. Day/night follows cityDayMix like every surface.
+
+const NIGHT_WATER = '#050d1c'; // near-black ink so neon reflections read
+const DAY_WATER = '#2e4f6e'; // steel-blue daytime bay
+
+// Procedural wave streaks: sparse horizontal sine ridges on a transparent canvas,
+// tiled + scrolled as the emissive map so the water reads as slowly moving swell.
+const makeWaveTexture = () => {
+ const canvas = document.createElement('canvas');
+ canvas.width = 256;
+ canvas.height = 256;
+ const ctx = canvas.getContext('2d');
+ ctx.clearRect(0, 0, 256, 256);
+ ctx.lineWidth = 1.2;
+ for (let row = 0; row < 10; row++) {
+ const y = (row + 0.5) * 25.6;
+ const amp = 2 + (row % 3) * 1.5;
+ const phase = row * 1.7;
+ ctx.strokeStyle = `rgba(255, 255, 255, ${0.16 + (row % 4) * 0.05})`;
+ ctx.beginPath();
+ for (let x = 0; x <= 256; x += 4) {
+ const wy = y + Math.sin(x / 28 + phase) * amp;
+ if (x === 0) ctx.moveTo(x, wy);
+ else ctx.lineTo(x, wy);
+ }
+ ctx.stroke();
+ }
+ const tex = new THREE.CanvasTexture(canvas);
+ tex.wrapS = THREE.RepeatWrapping;
+ tex.wrapT = THREE.RepeatWrapping;
+ tex.repeat.set(26, 14);
+ return tex;
+};
+
+export default function CityWater({ settings }) {
+ const { accent } = useCityPalette();
+ const dayMix = cityDayMix(settings);
+ const waveTex = useMemo(() => makeWaveTexture(), []);
+ useEffect(() => () => waveTex.dispose(), [waveTex]);
+
+ const matRef = useRef();
+ const shimmerRef = useRef();
+
+ const waterColor = mixHex(NIGHT_WATER, DAY_WATER, dayMix);
+ // Night: the swell glows faint accent neon. Day: barely-there white glints.
+ const emissiveColor = mixHex(accent, '#dfeaf2', dayMix);
+ const emissiveIntensity = 0.4 * (1 - dayMix) + 0.1 * dayMix;
+
+ useFrame(({ clock }, delta) => {
+ // Slow drift toward shore with a gentle cross-current wobble.
+ waveTex.offset.y -= delta * 0.012;
+ waveTex.offset.x = Math.sin(clock.getElapsedTime() * 0.05) * 0.03;
+ if (shimmerRef.current) {
+ const t = clock.getElapsedTime();
+ shimmerRef.current.material.opacity =
+ (0.14 + Math.sin(t * 0.9) * 0.05) * (1 - dayMix) + 0.05 * dayMix;
+ }
+ });
+
+ const span = WORLD.waterSpan;
+ const centerZ = WORLD.shorelineZ - span / 2;
+
+ return (
+ <group>
+ <mesh rotation={[-Math.PI / 2, 0, 0]} position={[0, WORLD.waterY, centerZ]}>
+ <planeGeometry args={[span * 2, span]} />
+ <meshStandardMaterial
+ ref={matRef}
+ color={waterColor}
+ roughness={0.18}
+ metalness={0.55}
+ emissive={emissiveColor}
+ emissiveIntensity={emissiveIntensity}
+ emissiveMap={waveTex}
+ />
+ </mesh>
+ {/* Shoreline shimmer — a thin additive surf line where land meets the bay. */}
+ <mesh
+ ref={shimmerRef}
+ rotation={[-Math.PI / 2, 0, 0]}
+ position={[0, WORLD.waterY + 0.015, WORLD.shorelineZ - 0.9]}
+ >
+ <planeGeometry args={[320, 1.8]} />
+ <meshBasicMaterial
+ color={accent}
+ transparent
+ opacity={0.14}
+ blending={THREE.AdditiveBlending}
+ depthWrite={false}
+ />
+ </mesh>
+ </group>
+ );
+}
diff --git a/client/src/utils/README.md b/client/src/utils/README.md
index 3037decca7..4fab265da9 100644
--- a/client/src/utils/README.md
+++ b/client/src/utils/README.md
@@ -82,6 +82,7 @@ its tunable constants and placement helpers.
| `cityMemoryDistrict` | Brain-graph memory district: category clustering, bridges, placement (`computeMemoryDistrict`). |
| `cityMiniMap` | Mini-map projection of building positions into 2D bounds (`computeMiniMap`, `projectPoint`). |
| `cityPhotoMode` | Photo-mode camera presets, the demand-loop fly stepper, postcard stats, and screenshot filename (`getPreset`, `cyclePreset`, `stepFly`). |
+| `cityPlan` | Master town plan: district parcels, shoreline/bay, plaza, transit loop, street network (`PARCELS`, `WORLD`, `computeStreets`, `computeStreetProps`, `isInWater`). |
| `cityProductivity` | Productivity monument from streak/velocity tiers (`computeProductivityMonument`). |
| `citySeasonalDecor` | Season/holiday resolution → seasonal decoration placements (`computeSeasonalDecor`). |
| `citySoundscape` | Ambient soundscape: mood/energy classification and chord selection (`computeSoundscape`). |
diff --git a/client/src/utils/cityAiCore.js b/client/src/utils/cityAiCore.js
index 5c1e525bbb..52ce3b5d66 100644
--- a/client/src/utils/cityAiCore.js
+++ b/client/src/utils/cityAiCore.js
@@ -12,8 +12,10 @@
// keep the generic radial fan-out. Model tier is a best-effort heuristic from the model
// name (the event has no explicit tier).
+import { PARCELS } from './cityPlan';
+
export const AI_CORE = {
- position: [0, 0, 0], // city center — the spire rises above the building grid
+ position: PARCELS.aiCore.anchor, // city center — the spire rises above the building grid
height: 34, // tall enough to clear downtown and read as the central landmark
apexY: 34, // beams/glow originate from the apex
maxBeams: 6, // visible activity beams cap
diff --git a/client/src/utils/cityArtifacts.js b/client/src/utils/cityArtifacts.js
index e9e7e3f4b6..3dca10a7e5 100644
--- a/client/src/utils/cityArtifacts.js
+++ b/client/src/utils/cityArtifacts.js
@@ -9,12 +9,13 @@
import { levelFromXP } from './characterXp';
import { gridIndexToPosition } from './cityDistrictLayout';
+import { PARCELS } from './cityPlan';
-// Hall of Achievements — a clear cluster in the +X / -Z quadrant, between the task-queue
-// (x≈+34, z≈-10), health tower (x≈+48, z≈+28), goal-monument row (z≈-40) and voice marker
-// ([0,0,-40]). Artifacts lay out in a tight grid centered on this base.
+// Hall of Achievements — a clear cluster in the +X / -Z quadrant, between the task-queue,
+// health tower, goal-monument row, and voice beacon. Artifacts lay out in a tight grid
+// centered on this base, anchored by the master plan (cityPlan.js).
export const ARTIFACTS = {
- base: [44, 0, -28], // center of the cluster
+ base: PARCELS.artifacts.anchor, // center of the cluster
spacing: 6, // distance between adjacent pedestals (both x and z)
columns: 3, // grid width before wrapping to the next row (toward -Z)
pedestalWidth: 2,
diff --git a/client/src/utils/cityBackupVault.js b/client/src/utils/cityBackupVault.js
index 2f39483992..c6b93d3cd5 100644
--- a/client/src/utils/cityBackupVault.js
+++ b/client/src/utils/cityBackupVault.js
@@ -4,8 +4,10 @@
// backup that hasn't run in too long glows red and reads as needing attention. No
// three.js / React imports so the topology is unit-testable (mirrors cityFederation.js).
+import { PARCELS } from './cityPlan';
+
export const VAULT = {
- position: [-34, 0, -10], // west of the building grid, clear of downtown and the +Z archive district
+ position: PARCELS.backupVault.anchor, // west of the building grid, anchored by the master plan (cityPlan.js)
width: 5,
height: 8,
// Staleness thresholds, in ms since the last snapshot. A fresh backup is healthy;
diff --git a/client/src/utils/cityEasterEggs.js b/client/src/utils/cityEasterEggs.js
index e034994af2..430e50d115 100644
--- a/client/src/utils/cityEasterEggs.js
+++ b/client/src/utils/cityEasterEggs.js
@@ -12,11 +12,12 @@
import { hashString } from './hashString';
import { effectiveLevel, completedGoalCount, bestStreakDays } from './cityArtifacts';
+import { PARCELS } from './cityPlan';
// Placement: a tight cluster at the far -X / +Z corner, deliberately off in a quiet quadrant
// away from the achievement hall (+X/-Z) so an egg reads as "hidden" rather than featured.
export const EGGS = {
- base: [-46, 0, 40],
+ base: PARCELS.easterEggs.anchor,
spacing: 5,
columns: 2,
size: 1.1,
diff --git a/client/src/utils/cityGoalMonuments.js b/client/src/utils/cityGoalMonuments.js
index e98eb77e70..6279dfdacc 100644
--- a/client/src/utils/cityGoalMonuments.js
+++ b/client/src/utils/cityGoalMonuments.js
@@ -7,13 +7,14 @@
// three.js / React imports so the topology is unit-testable (mirrors cityFederation.js
// / cityHealthTower.js).
+import { PARCELS } from './cityPlan';
+
export const MONUMENTS = {
- // Northeast monument district — a row centered around [30, 0, -40], clear of the
- // vault (x≈-34), task-queue (x≈+34), voice ([0,0,-40]), health ([48,0,28]),
- // AI core ([0,0,0]), and productivity district (SW).
- base: [30, 0, -40], // center of the row
+ // Northeast monument district — a row anchored by the master plan (cityPlan.js), clear
+ // of the vault, task-queue, voice beacon, health tower, AI core, and productivity district.
+ base: PARCELS.goals.anchor, // center of the row
spacing: 9, // x-distance between adjacent monuments
- z: -40, // shared depth of the row
+ z: PARCELS.goals.anchor[2], // shared depth of the row
maxMonuments: 8, // cap; goals beyond this fold into an overflow marker
minHeight: 2, // floor height so even a 0%-progress site reads as a small structure
fullHeight: 12, // height of a completed (100%) monument
diff --git a/client/src/utils/cityHealthTower.js b/client/src/utils/cityHealthTower.js
index 3cc3d16088..a5671f1b3b 100644
--- a/client/src/utils/cityHealthTower.js
+++ b/client/src/utils/cityHealthTower.js
@@ -6,8 +6,10 @@
// 0-step day). No three.js / React imports so the topology is unit-testable (mirrors
// cityBackupVault.js / cityTaskQueue.js).
+import { PARCELS } from './cityPlan';
+
export const TOWER = {
- position: [48, 0, 28], // far southeast — a wellness district clear of the vault, warehouse, grid, and archive
+ position: PARCELS.health.anchor, // far southeast — a wellness district anchored by the master plan (cityPlan.js)
baseRadius: 3.2,
segmentHeight: 3, // height of a fully-lit (level === 1) segment
segmentGap: 0.25, // vertical gap between stacked segments
diff --git a/client/src/utils/cityJiraDistrict.js b/client/src/utils/cityJiraDistrict.js
index edc0612176..f4e1e9506b 100644
--- a/client/src/utils/cityJiraDistrict.js
+++ b/client/src/utils/cityJiraDistrict.js
@@ -6,11 +6,13 @@
// No three.js / React imports so the topology is unit-testable (mirrors cityTaskQueue.js etc.).
import { gridIndexToPosition, tallyByKey, scaleMetricToHeight } from './cityDistrictLayout';
+import { PARCELS } from './cityPlan';
export const JIRA_DISTRICT = {
- // North-east-of-north: a yard between the goal monuments (NE, +30,-40) and downtown, on the
- // -X side so it doesn't collide with the artifact hall (+44,-28) or memory district (-44,-30).
- base: [-20, 0, -44],
+ // North-of-downtown yard between the goal monuments and downtown, on the -X side so it
+ // doesn't collide with the artifact hall or memory quarter. Anchored by cityPlan.js;
+ // sits near the shoreline on purpose — a dockside construction yard.
+ base: PARCELS.jira.anchor,
columns: 6, // structures per row before wrapping toward -Z
spacing: 3.2, // distance between adjacent structures
maxStructures: 24, // cap; overflow folds into a "+N MORE" marker
diff --git a/client/src/utils/cityMemoryDistrict.js b/client/src/utils/cityMemoryDistrict.js
index 6b53399262..521d28f36e 100644
--- a/client/src/utils/cityMemoryDistrict.js
+++ b/client/src/utils/cityMemoryDistrict.js
@@ -8,11 +8,12 @@
import { hashString } from './hashString';
import { groupByFieldValue, scaleMetricToHeight } from './cityDistrictLayout';
+import { PARCELS } from './cityPlan';
export const MEMORY_DISTRICT = {
- // Northwest quadrant — mirrors the artifact cluster at NE (+44,-28), clear of the
- // productivity district (SW, -48,+28), the backup vault (W, -34,-10), and downtown.
- base: [-44, 0, -30],
+ // Northwest quadrant — mirrors the artifact cluster at NE, clear of the productivity
+ // district, the backup vault, and downtown. Anchored by the master plan (cityPlan.js).
+ base: PARCELS.memory.anchor,
radius: 9, // clusters arrange on a ring of this radius around the district center
maxCrystalsPerCluster: 7, // visual cap; overflow is summarized in the cluster label
crystalSpacing: 1.4, // horizontal spread of crystals within a cluster
diff --git a/client/src/utils/cityPlan.js b/client/src/utils/cityPlan.js
new file mode 100644
index 0000000000..3f0c89206b
--- /dev/null
+++ b/client/src/utils/cityPlan.js
@@ -0,0 +1,203 @@
+// CyberCity's master town plan — THE single source of truth for the city's geography.
+// Every district helper anchors its parcel here (instead of each module hardcoding its own
+// compass position), so streets, the transit loop, the waterfront, and the overlap/shoreline
+// invariant tests all read the same map. No three.js / React imports — the whole plan is
+// plain data + pure math, unit-testable in node (mirrors cityDistrictLayout.js).
+//
+// Geography at a glance (top-down, default camera looks from +Z toward -Z):
+//
+// ~ ~ ~ BAY (water, z < shoreline) ~ ~ ~
+// [federation peers on the far horizon, radius 76+]
+// ════ DATA HARBOR (piers) ════
+// ── shoreline z = -56 ──────────────────────────────────
+// jira yard voice beacon goal monuments
+// memory quarter │ avenue │ artifacts hall
+// backup vault ╭── plaza ──╮ task queue
+// │ AI CORE │
+// productivity ╰─ downtown ╯ health tower
+// + heatmap easter eggs
+// warehouse (archived, grows +Z)
+//
+// The bay sits NORTH (-Z) on purpose: the default camera at [0,25,45] faces it, the archive
+// warehouse grows the opposite way (+Z) so it can never reach the water, and the federation
+// horizon's distant peers read as sister cities across the bay.
+
+export const WORLD = {
+ bound: 180, // hard XZ world bound (matches PlayerController)
+ shorelineZ: -56, // land for z > shorelineZ; water (the bay) beyond
+ waterY: -0.04, // water plane height — above the terrain (-0.08), below the city ground (-0.02)
+ waterSpan: 520, // how far the water plane extends past the shoreline / to each side
+};
+
+// Land parcels. `anchor` is the district's center on the ground; `w`/`d` are the static
+// footprint (x-width / z-depth) used by the invariant tests and the tinted ground pads.
+// `dynamic: true` marks data-driven grids (downtown/warehouse) whose extent grows with the
+// install — they're excluded from static-footprint checks. Anchors mirror the hand-tuned
+// pre-plan positions except: the voice beacon steps aside for the harbor avenue, and the
+// Data Harbor is new — piers over the bay, straight ahead of the default camera.
+export const PARCELS = {
+ aiCore: { anchor: [0, 0, 0], w: 24, d: 24, label: 'AI CORE PLAZA' },
+ downtown: { anchor: [0, 0, 0], w: 60, d: 60, dynamic: true, label: 'DOWNTOWN' },
+ warehouse: { anchor: [0, 0, 30], w: 60, d: 60, dynamic: true, label: 'ARCHIVE DISTRICT' },
+ backupVault: { anchor: [-34, 0, -10], w: 7, d: 7, label: 'BACKUP VAULT' },
+ taskQueue: { anchor: [34, 0, -10], w: 8, d: 8, label: 'TASK QUEUE' },
+ memory: { anchor: [-44, 0, -30], w: 22, d: 22, label: 'MEMORY QUARTER' },
+ jira: { anchor: [-20, 0, -44], w: 18, d: 12, label: 'SPRINT YARD' },
+ // Goal monuments + the artifact hall grow toward each other with enough earned
+ // milestones (a pre-plan, visually-tolerated rarity) — footprints reflect typical installs.
+ goals: { anchor: [30, 0, -40], w: 66, d: 5, label: 'GOAL MONUMENTS' },
+ artifacts: { anchor: [44, 0, -28], w: 16, d: 14, label: 'HALL OF ACHIEVEMENTS' },
+ // Stepped off the avenue centerline (was [0,0,-40]) so the plaza→harbor avenue runs clear.
+ voice: { anchor: [9, 0, -38], w: 5, d: 5, label: 'VOICE BEACON' },
+ productivity: { anchor: [-48, 0, 28], w: 10, d: 10, label: 'PRODUCTIVITY' },
+ health: { anchor: [48, 0, 28], w: 8, d: 8, label: 'WELLNESS TOWER' },
+ easterEggs: { anchor: [-46, 0, 40], w: 8, d: 10, label: 'QUIET CORNER' },
+ // Over the water: a pier district between the shoreline and the federation horizon.
+ dataHarbor: { anchor: [0, 0, -64], w: 40, d: 16, water: true, label: 'DATA HARBOR' },
+};
+
+export const PLAZA = { center: [0, 0, 0], radius: 12, sidewalkOuter: 14.5 };
+
+// Elevated transit loop — a closed ride through every quarter, rendered as a glowing tube
+// with trams orbiting it. Stops are pulled toward the loop's centerline (offset from each
+// parcel anchor) so the track skims districts instead of impaling their monuments.
+export const TRANSIT = {
+ y: 9, // track height — above street props, below most rooftops
+ stops: [
+ { id: 'productivity', point: [-44, 9, 24] },
+ { id: 'backupVault', point: [-32, 9, -8] },
+ { id: 'memory', point: [-40, 9, -27] },
+ { id: 'jira', point: [-20, 9, -40] },
+ { id: 'harborGate', point: [0, 9, -47] },
+ { id: 'goals', point: [26, 9, -36] },
+ { id: 'artifacts', point: [40, 9, -25] },
+ { id: 'taskQueue', point: [32, 9, -8] },
+ { id: 'health', point: [44, 9, 24] },
+ { id: 'warehouse', point: [0, 9, 38] },
+ ],
+ tramCount: 3,
+ tramSpeed: 0.012, // loop fraction per second — a leisurely orbit (~80s per lap)
+};
+
+// True when a ground position sits in the bay (used by the skyline ring to skip silhouettes
+// that would otherwise stand in the water, and by the player controller to keep walking
+// players on land). `margin` extends the water zone toward land (positive = stricter).
+export const isInWater = (x, z, margin = 0) => z < WORLD.shorelineZ + margin;
+
+// ---------------------------------------------------------------------------
+// Streets: ring road + spokes + the harbor avenue, as flat rotated rectangles.
+// ---------------------------------------------------------------------------
+
+const RING_RADIUS = 30; // octagonal ring road just outside the downtown grid
+const ROAD_WIDTH = 3.2;
+const AVENUE_WIDTH = 4.6;
+const SPOKE_CLEARANCE = 6; // stop a spoke this short of the district anchor
+
+// Static parcels that get a street spoke from the ring road. The harbor is served by the
+// avenue; downtown/warehouse sit inside/astride the ring; aiCore is the plaza itself.
+const SPOKE_PARCELS = [
+ 'backupVault', 'taskQueue', 'memory', 'jira', 'goals',
+ 'artifacts', 'productivity', 'health', 'easterEggs',
+];
+
+// A street segment is a centered rectangle: rotate a [length × width] quad by `angle`
+// (radians, around Y) at ground position [x, z].
+const segment = (x1, z1, x2, z2, width) => {
+ const dx = x2 - x1;
+ const dz = z2 - z1;
+ return {
+ x: (x1 + x2) / 2,
+ z: (z1 + z2) / 2,
+ length: Math.hypot(dx, dz),
+ angle: Math.atan2(dz, dx),
+ width,
+ };
+};
+
+// The full street network, derived from the plan. Pure + deterministic; the component
+// merges every rectangle into one geometry, so count here is free.
+export function computeStreets() {
+ const segments = [];
+
+ // Octagonal ring road around downtown.
+ const ringPoints = [];
+ for (let k = 0; k < 8; k++) {
+ const a = (k / 8) * Math.PI * 2 + Math.PI / 8; // flat edges face the compass directions
+ ringPoints.push([Math.cos(a) * RING_RADIUS, Math.sin(a) * RING_RADIUS]);
+ }
+ for (let k = 0; k < 8; k++) {
+ const [x1, z1] = ringPoints[k];
+ const [x2, z2] = ringPoints[(k + 1) % 8];
+ segments.push({ ...segment(x1, z1, x2, z2, ROAD_WIDTH), kind: 'ring' });
+ }
+
+ // Spokes: ring → each served district, stopping short of the anchor.
+ const crosswalks = [];
+ for (const id of SPOKE_PARCELS) {
+ const [ax, , az] = PARCELS[id].anchor;
+ const dist = Math.hypot(ax, az);
+ if (dist <= RING_RADIUS + SPOKE_CLEARANCE) continue; // hugs the ring already
+ const ux = ax / dist;
+ const uz = az / dist;
+ const inner = RING_RADIUS - ROAD_WIDTH / 2; // tuck under the ring edge — no gap at the joint
+ const outer = dist - SPOKE_CLEARANCE;
+ segments.push({ ...segment(ux * inner, uz * inner, ux * outer, uz * outer, ROAD_WIDTH), kind: 'spoke', to: id });
+ // Crosswalk band where the spoke meets the ring.
+ crosswalks.push({ x: ux * RING_RADIUS, z: uz * RING_RADIUS, angle: Math.atan2(uz, ux), length: ROAD_WIDTH * 1.4, width: 2.0 });
+ }
+
+ // The grand avenue: plaza edge → shoreline, straight up the city's axis to the harbor.
+ segments.push({
+ ...segment(0, -(PLAZA.radius - 1), 0, WORLD.shorelineZ + 1, AVENUE_WIDTH),
+ kind: 'avenue',
+ });
+
+ return { segments, crosswalks, plazaRing: { inner: PLAZA.radius, outer: PLAZA.sidewalkOuter } };
+}
+
+// ---------------------------------------------------------------------------
+// Street props: lamp posts along every street, holo-trees ringing the plaza.
+// ---------------------------------------------------------------------------
+
+const LAMP_SPACING = 11; // world units between lamp pairs along a street
+const LAMP_SIDE_OFFSET = 2.6; // lateral distance from the street centerline
+
+// Lamp + tree positions for a given street layout. `density` scales counts (quality
+// presets): 0 → no props, 1 → full. Deterministic — same input, same town furniture.
+export function computeStreetProps(streets, density = 1) {
+ const lamps = [];
+ const trees = [];
+ if (!streets || density <= 0) return { lamps, trees };
+
+ const spacing = LAMP_SPACING / Math.min(1.5, Math.max(0.25, density));
+ for (const seg of streets.segments) {
+ const count = Math.floor(seg.length / spacing);
+ const cos = Math.cos(seg.angle);
+ const sin = Math.sin(seg.angle);
+ for (let i = 0; i < count; i++) {
+ // March along the segment; alternate which side of the street the lamp stands on.
+ const t = (i + 0.5) / count - 0.5;
+ const side = i % 2 === 0 ? 1 : -1;
+ const along = t * seg.length;
+ const off = side * (seg.width / 2 + LAMP_SIDE_OFFSET - 1);
+ lamps.push({
+ x: seg.x + cos * along - sin * off,
+ z: seg.z + sin * along + cos * off,
+ });
+ }
+ }
+
+ // Holo-trees around the plaza sidewalk, skipping the avenue mouth (north) so the
+ // walkway to the harbor stays open.
+ const treeCount = Math.round(10 * Math.min(1.5, density));
+ const treeRadius = (streets.plazaRing.inner + streets.plazaRing.outer) / 2 + 0.6;
+ for (let i = 0; i < treeCount; i++) {
+ const a = (i / treeCount) * Math.PI * 2 + Math.PI / 2; // start at the south point
+ const x = Math.cos(a) * treeRadius;
+ const z = Math.sin(a) * treeRadius;
+ if (z < -treeRadius * 0.86) continue; // the avenue mouth
+ trees.push({ x, z, seed: i });
+ }
+
+ return { lamps, trees };
+}
diff --git a/client/src/utils/cityPlan.test.js b/client/src/utils/cityPlan.test.js
new file mode 100644
index 0000000000..5ddc934f88
--- /dev/null
+++ b/client/src/utils/cityPlan.test.js
@@ -0,0 +1,179 @@
+import { describe, it, expect } from 'vitest';
+import {
+ WORLD, PARCELS, PLAZA, TRANSIT, isInWater, computeStreets, computeStreetProps,
+} from './cityPlan';
+
+const staticParcels = Object.entries(PARCELS).filter(([, p]) => !p.dynamic);
+
+describe('cityPlan PARCELS', () => {
+ it('keeps every parcel inside the world bound', () => {
+ for (const [id, p] of Object.entries(PARCELS)) {
+ expect(Math.abs(p.anchor[0]) + p.w / 2, id).toBeLessThanOrEqual(WORLD.bound);
+ expect(Math.abs(p.anchor[2]) + p.d / 2, id).toBeLessThanOrEqual(WORLD.bound);
+ }
+ });
+
+ it('keeps land parcels on land and water parcels in the bay', () => {
+ for (const [id, p] of staticParcels) {
+ const nearEdge = p.anchor[2] - p.d / 2; // most-northern (bay-ward) edge
+ if (p.water) {
+ expect(isInWater(p.anchor[0], p.anchor[2]), id).toBe(true);
+ } else {
+ expect(nearEdge, id).toBeGreaterThan(WORLD.shorelineZ);
+ }
+ }
+ });
+
+ it('keeps static parcels (except the plaza itself) clear of the AI Core plaza', () => {
+ for (const [id, p] of staticParcels) {
+ if (id === 'aiCore') continue;
+ const dist = Math.hypot(p.anchor[0], p.anchor[2]);
+ expect(dist - Math.max(p.w, p.d) / 2, id).toBeGreaterThanOrEqual(PLAZA.radius - 0.01);
+ }
+ });
+
+ it('keeps the new harbor parcel clear of every land parcel', () => {
+ const harbor = PARCELS.dataHarbor;
+ for (const [id, p] of staticParcels) {
+ if (id === 'dataHarbor') continue;
+ const xOverlap = Math.abs(harbor.anchor[0] - p.anchor[0]) < (harbor.w + p.w) / 2;
+ const zOverlap = Math.abs(harbor.anchor[2] - p.anchor[2]) < (harbor.d + p.d) / 2;
+ expect(xOverlap && zOverlap, `dataHarbor vs ${id}`).toBe(false);
+ }
+ });
+
+ it('every parcel carries an anchor, footprint, and label', () => {
+ for (const [id, p] of Object.entries(PARCELS)) {
+ expect(p.anchor, id).toHaveLength(3);
+ expect(p.w, id).toBeGreaterThan(0);
+ expect(p.d, id).toBeGreaterThan(0);
+ expect(typeof p.label, id).toBe('string');
+ }
+ });
+});
+
+describe('isInWater', () => {
+ it('classifies the bay vs land around the shoreline', () => {
+ expect(isInWater(0, WORLD.shorelineZ - 1)).toBe(true);
+ expect(isInWater(0, WORLD.shorelineZ + 1)).toBe(false);
+ expect(isInWater(0, 0)).toBe(false);
+ });
+
+ it('margin extends the water zone toward land', () => {
+ expect(isInWater(0, WORLD.shorelineZ + 2, 4)).toBe(true);
+ expect(isInWater(0, WORLD.shorelineZ + 6, 4)).toBe(false);
+ });
+});
+
+describe('TRANSIT', () => {
+ it('keeps the loop track on land, above the streets, below rooftop scale', () => {
+ expect(TRANSIT.y).toBeGreaterThan(6);
+ expect(TRANSIT.y).toBeLessThan(14);
+ for (const stop of TRANSIT.stops) {
+ expect(stop.point[1], stop.id).toBe(TRANSIT.y);
+ expect(isInWater(stop.point[0], stop.point[2]), stop.id).toBe(false);
+ expect(Math.abs(stop.point[0]), stop.id).toBeLessThanOrEqual(WORLD.bound);
+ expect(Math.abs(stop.point[2]), stop.id).toBeLessThanOrEqual(WORLD.bound);
+ }
+ });
+
+ it('has unique stop ids', () => {
+ const ids = TRANSIT.stops.map((s) => s.id);
+ expect(new Set(ids).size).toBe(ids.length);
+ });
+});
+
+describe('computeStreets', () => {
+ const streets = computeStreets();
+
+ it('is deterministic', () => {
+ expect(computeStreets()).toEqual(streets);
+ });
+
+ it('builds a closed 8-segment ring road', () => {
+ const ring = streets.segments.filter((s) => s.kind === 'ring');
+ expect(ring).toHaveLength(8);
+ for (const seg of ring) {
+ // Every ring segment's center sits on the ring radius (chord midpoint, slightly inside).
+ expect(Math.hypot(seg.x, seg.z)).toBeGreaterThan(20);
+ expect(Math.hypot(seg.x, seg.z)).toBeLessThan(31);
+ }
+ });
+
+ it('runs a spoke toward every outlying served district', () => {
+ const spokeTargets = streets.segments.filter((s) => s.kind === 'spoke').map((s) => s.to);
+ for (const id of ['memory', 'jira', 'goals', 'artifacts', 'productivity', 'health', 'easterEggs']) {
+ expect(spokeTargets, id).toContain(id);
+ }
+ // Each spoke ends short of its district anchor (clearance) and starts at the ring.
+ for (const seg of streets.segments.filter((s) => s.kind === 'spoke')) {
+ const [ax, , az] = PARCELS[seg.to].anchor;
+ const anchorDist = Math.hypot(ax, az);
+ const segFar = Math.hypot(seg.x, seg.z) + seg.length / 2;
+ expect(segFar, seg.to).toBeLessThan(anchorDist);
+ }
+ });
+
+ it('runs the avenue from the plaza to the shoreline without entering the water', () => {
+ const avenue = streets.segments.find((s) => s.kind === 'avenue');
+ expect(avenue).toBeTruthy();
+ expect(avenue.x).toBe(0);
+ const farEdge = avenue.z - avenue.length / 2;
+ expect(farEdge).toBeGreaterThanOrEqual(WORLD.shorelineZ);
+ });
+
+ it('keeps every street on land', () => {
+ for (const seg of streets.segments) {
+ const cos = Math.cos(seg.angle);
+ const sin = Math.sin(seg.angle);
+ for (const t of [-0.5, 0, 0.5]) {
+ const z = seg.z + sin * t * seg.length;
+ expect(isInWater(seg.x + cos * t * seg.length, z), seg.kind).toBe(false);
+ }
+ }
+ });
+
+ it('places a crosswalk where each spoke meets the ring', () => {
+ const spokes = streets.segments.filter((s) => s.kind === 'spoke');
+ expect(streets.crosswalks).toHaveLength(spokes.length);
+ });
+});
+
+describe('computeStreetProps', () => {
+ const streets = computeStreets();
+
+ it('is deterministic and density-scaled', () => {
+ const full = computeStreetProps(streets, 1);
+ expect(computeStreetProps(streets, 1)).toEqual(full);
+ const half = computeStreetProps(streets, 0.5);
+ expect(half.lamps.length).toBeLessThan(full.lamps.length);
+ expect(half.lamps.length).toBeGreaterThan(0);
+ });
+
+ it('returns no props at zero density or missing streets', () => {
+ expect(computeStreetProps(streets, 0)).toEqual({ lamps: [], trees: [] });
+ expect(computeStreetProps(null, 1)).toEqual({ lamps: [], trees: [] });
+ });
+
+ it('keeps lamps on land and inside the world bound', () => {
+ const { lamps } = computeStreetProps(streets, 1.5);
+ expect(lamps.length).toBeGreaterThan(10);
+ for (const lamp of lamps) {
+ expect(isInWater(lamp.x, lamp.z)).toBe(false);
+ expect(Math.abs(lamp.x)).toBeLessThanOrEqual(WORLD.bound);
+ expect(Math.abs(lamp.z)).toBeLessThanOrEqual(WORLD.bound);
+ }
+ });
+
+ it('rings the plaza with trees but leaves the avenue mouth open', () => {
+ const { trees } = computeStreetProps(streets, 1);
+ expect(trees.length).toBeGreaterThan(5);
+ for (const tree of trees) {
+ const r = Math.hypot(tree.x, tree.z);
+ expect(r).toBeGreaterThan(PLAZA.radius);
+ // No tree blocks the avenue (north sector around x=0, z negative).
+ const onAvenue = Math.abs(tree.x) < 3 && tree.z < -PLAZA.radius * 0.8;
+ expect(onAvenue).toBe(false);
+ }
+ });
+});
diff --git a/client/src/utils/cityProductivity.js b/client/src/utils/cityProductivity.js
index f7705a23f4..d142111ac0 100644
--- a/client/src/utils/cityProductivity.js
+++ b/client/src/utils/cityProductivity.js
@@ -5,8 +5,10 @@
// zero-day streak (present but unlit beyond the base). No three.js / React imports so the
// topology is unit-testable (mirrors cityBackupVault.js / cityHealthTower.js).
+import { PARCELS } from './cityPlan';
+
export const MONUMENT = {
- position: [-48, 0, 28], // southwest district — clear of the vault (-34), grid, archive, and the SE wellness tower
+ position: PARCELS.productivity.anchor, // southwest district — anchored by the master plan (cityPlan.js)
baseWidth: 5, // footprint of the obelisk base
minHeight: 3, // floor height so a 0-streak monument still reads as a stub, not nothing
maxHeight: 26, // height at/above STREAK_CAP days
diff --git a/client/src/utils/cityTaskQueue.js b/client/src/utils/cityTaskQueue.js
index 6e1165d906..18dedfd15c 100644
--- a/client/src/utils/cityTaskQueue.js
+++ b/client/src/utils/cityTaskQueue.js
@@ -5,9 +5,10 @@
// React imports so the topology is unit-testable (mirrors cityBackupVault.js).
import { tallyByKey } from './cityDistrictLayout';
+import { PARCELS } from './cityPlan';
export const TASK_QUEUE = {
- position: [34, 0, -10], // east of the building grid, mirroring the backup vault to the west
+ position: PARCELS.taskQueue.anchor, // east of the building grid, mirroring the backup vault to the west
maxCrates: 8, // visible-crate cap; beyond this the warehouse reads as "overflow"
crateSize: 1.5,
crateGap: 0.18,
diff --git a/client/src/utils/cityVoiceMarker.js b/client/src/utils/cityVoiceMarker.js
index d2f70b6ca3..a1cf577463 100644
--- a/client/src/utils/cityVoiceMarker.js
+++ b/client/src/utils/cityVoiceMarker.js
@@ -6,10 +6,11 @@
// persisted /voice/status payload. No three.js / React imports so the topology is
// unit-testable (mirrors cityBackupVault.js).
+import { PARCELS } from './cityPlan';
+
export const MARKER = {
- position: [0, 0, -40], // front-north: between the building grid (~±25) and the far skyline,
- // clear of the backup vault (x≈-34), CoS warehouse (x≈+34), +Z archive district, and
- // the federation horizon (radius 76).
+ position: PARCELS.voice.anchor, // north of downtown, stepped just off the harbor avenue's
+ // centerline so the plaza→harbor walkway runs clear past the beacon (see cityPlan.js).
baseRadius: 2.2,
poleHeight: 6,
beaconRadius: 0.9,
diff --git a/client/src/utils/index.js b/client/src/utils/index.js
index c2262c513c..829db7159a 100644
--- a/client/src/utils/index.js
+++ b/client/src/utils/index.js
@@ -51,6 +51,7 @@ export * from './cityJiraDistrict.js';
export * from './cityMemoryDistrict.js';
export * from './cityMiniMap.js';
export * from './cityPhotoMode.js';
+export * from './cityPlan.js';
export * from './cityProductivity.js';
export * from './citySeasonalDecor.js';
export * from './citySoundscape.js';
diff --git a/docs/plans/2026-06-09-cybercity-redesign-master-plan.md b/docs/plans/2026-06-09-cybercity-redesign-master-plan.md
new file mode 100644
index 0000000000..2c5e8e4a62
--- /dev/null
+++ b/docs/plans/2026-06-09-cybercity-redesign-master-plan.md
@@ -0,0 +1,113 @@
+# CyberCity Redesign: Master Town Plan, Data Harbor, Street Fabric, Third-Person Character
+
+## Context
+
+The `/city` page renders PortOS state as a 3D R3F city, but it reads as scattered monuments on an empty plane: districts sit at arbitrary compass anchors with no connecting fabric, buildings are plain boxes, and exploration mode is an invisible first-person camera (`PlayerAvatar.jsx` is dead code — never imported). The user granted **full liberty to redesign the city UX** with two hard requirements: **day/night themes that match PortOS themes** (already the backbone: `cityDayMix(settings)` + `CityPaletteContext` theme-derived palette — preserved and extended, never bypassed) and **3D navigation around the city**.
+
+Chosen direction (user-confirmed): **refined cyberpunk metropolis** — keep the neon identity, make it a real town — via a **new master plan that evolves the existing ~60 data-driven components** (repositioned/reskinned, all live data bindings kept) rather than a ground-up rewrite.
+
+House rules that shape everything below: pure helpers in `client/src/utils/city*.js` (node-env vitest, no three/React/window imports) + thin components; no live-mode postprocessing (emissive + additive only); drei `<Line>` is broken in this stack (native three geometry only); headless WebGL renders the city blank, so correctness leans on pure-helper tests + dev-server GPU verification.
+
+---
+
+## Workstream 1 — Master town plan (`cityPlan.js`)
+
+**The structural redesign.** Today every district helper exports its own ad-hoc position constant. Replace that with a single source of truth:
+
+- **New `client/src/utils/cityPlan.js` + test** — exports the whole town topology as data:
+ - `CITY_PLAN.plaza` — central AI Core plaza (clearance radius 12, as today) with sidewalk ring tiles.
+ - `CITY_PLAN.parcels` — named parcels for every district (`memory`, `goals`, `health`, `productivity`, `taskQueue`, `backupVault`, `jira`, `artifacts`, `voice`, `easterEggs`, `dataHarbor`, `warehouse`, `downtown`), each `{ anchor: [x,y,z], width, depth, facing }`, arranged as coherent *neighborhoods* along the street network instead of lone compass monuments: civic core (AI plaza + health + task queue) center-north, memory/knowledge quarter NW, productivity/goals quarter E, industrial warehouse N+Z as today, and a **waterfront on the south edge** where the Data Harbor docks sit.
+ - `CITY_PLAN.shoreline` — the south world edge becomes water: shoreline z-coordinate, water plane bounds, dock positions.
+ - `CITY_PLAN.streets` — ring road around downtown + spokes to every parcel, plaza ring, crosswalks (consumed by Workstream 3).
+ - `CITY_PLAN.transit` — an elevated transit loop path (evolves the existing `CityTubeLine.jsx`) linking the quarters — the "alive game city" motion layer.
+ - Invariant tests: no two parcels overlap, every parcel inside world bound ±180, every parcel reachable by a street spoke, plaza clearance respected, shoreline south of all non-harbor parcels.
+- **Evolve, mechanically**: each district helper (`cityMemoryDistrict.js`, `cityGoalMonuments.js`, `cityHealthTower.js`, …) swaps its hardcoded position constant for `CITY_PLAN.parcels.<name>.anchor`. `cityLayout.js` `computeCityLayout` keeps its grid algorithm but reads downtown/warehouse origin + bounds from the plan. Existing per-district tests keep passing (they assert shape, not absolute coordinates; update the few that pin positions).
+- **New `CityWater.jsx`** — animated water plane along the south shoreline: large plane, dark semi-reflective `meshStandardMaterial`, slow-scrolling procedural canvas wave texture (same canvas-texture technique as `CityGround`), additive shimmer strip at the shoreline, color lerped by `cityDayMix` (night: ink with neon reflections tint; day: steel blue). No reflections/refraction passes.
+- **Evolve `CityGround.jsx` / `CityLandscape.jsx`** — ground texture gains district-tinted zones (subtle color wash per parcel from the palette) and stops at the shoreline.
+
+This workstream is the enabler: streets, harbor, and props all consume `CITY_PLAN` instead of inventing geometry.
+
+---
+
+## Workstream 2 — "Data Harbor" district (DB + filesystem visualization)
+
+A waterfront dock district on parcel `dataHarbor` (south shore):
+
+- **Database Quay**: one glowing disk-stack silo per Postgres table on dock piers (stack height = log-scaled row count, radius = log-scaled relation size); pgvector tables get a rotating emissive torus ring; a migration obelisk shows applied-migration count.
+- **Archive Racks**: shipping-container-style rack wall, one per `data/` domain directory, emissive slat fill = log-scaled disk usage.
+- Click a silo/rack → drei `Html` holo-card (name, rows, bytes, files, embedding badge) styled like `HolographicPanel.jsx`. DB down → dimmed red silos + "DB OFFLINE" label (`db: null` ≠ empty arrays, per the sentinel rule).
+
+### Server
+
+- **New `server/services/cityIntrospection.js`** — `getCityIntrospection()` → `{ ts, db, fs }`; 45s TTL cache + in-flight dedupe + **stale-while-revalidate** (`data/images` is ~3.1GB / thousands of files — never block the route on a re-walk).
+ - `db`: `pg_stat_user_tables` (relname, `n_live_tup`, `pg_total_relation_size`), `information_schema.columns` where `udt_name='vector'` → `hasEmbedding`, `pg_database_size`, `schema_migrations` count + max(applied_at). Each piece `.catch(() => null)`.
+ - `fs`: depth-1 domains under `PATHS.data`, async recursive walk (concurrency ~4, skip symlinks, per-entry error tolerance), loose root files → `(root)` pseudo-domain.
+- **Modify `server/routes/cityRoutes.js`** — `GET /api/city/introspection` (no params → no new Zod schema). Document in `docs/API.md`.
+
+### Client
+
+- `apiCity.js`: `getCityIntrospection(options)`. `CyberCity.jsx`: `useAutoRefetch(... , 120_000)` with `{ silent: true }` (same pattern as `memoryGraph`), pass to `CityScene`.
+- **New `client/src/utils/cityDataHarbor.js` + test** — `computeDataHarbor(introspection)` → `{ empty, dbDown, silos[], racks[], obelisk, totals, overflow }`; anchors from `CITY_PLAN.parcels.dataHarbor`; reuse `scaleMetricToHeight`/`gridIndexToPosition` from `cityDistrictLayout.js`; top-N + overflow count.
+- **New `client/src/components/city/CityDataHarbor.jsx`** — mirrors `CityMemoryDistrict.jsx`; `useCityPalette()` colors, `cityDayMix` legibility, one shared `useFrame` for ring rotation, `CityLabel` titles.
+
+---
+
+## Workstream 3 — Street fabric, props, rooftops
+
+1. **Streets** — **New `CityStreets.jsx`** renders `CITY_PLAN.streets` as 2–3 merged `BufferGeometry` draw calls (`BufferGeometryUtils.mergeGeometries`): asphalt quads at y=0.02 (color lerped by `cityDayMix`), emissive accent edge strips (`toneMapped={false}`), crosswalks.
+2. **Street props** — **New `CityStreetProps.jsx`** + helper `computeStreetProps` (in `cityPlan.js` or sibling): `InstancedMesh` ×4 — lamp poles, emissive lamp heads, additive ground glow discs (no real point lights), holo-trees on the plaza ring. Deterministic via `seededRand`. Quality-gated: `low` → none, `medium` 0.5×, `high` 1×, `ultra` 1.5× density.
+3. **Rooftops** — **New `client/src/utils/cityRooftops.js` + test**: `computeRooftopKit(name, width, height)` → 0–3 fixtures (antenna/tank/AC/dish) seeded by app-name hash (same determinism as window textures). Rendered in `Building.jsx` with module-scope shared materials; off on `low`. If profiling shows pain on huge installs → instanced fallback as a PLAN.md deferred item.
+
+---
+
+## Workstream 4 — Third-person game character
+
+### Player rig (`PlayerController.jsx` refactor)
+
+- Extract per-frame state into a mutable **`rigRef`**: `{ position, yaw, pitch, speedSq, moving, sprinting, airborne, lastYaw }`. All existing behavior preserved (WASD/arrows, shift sprint, E/Q vertical, F interact, pointer-lock mouselook, building collision r=3.5, flyover above y=12, bounds ±180, spawn persistence). Add water as non-walkable below flyover height (clamp z at shoreline) using `CITY_PLAN.shoreline`.
+- New `settings.cameraView` (`'third'` **default** | `'first'`), toggled with **V**; settings row in `CitySettingsPanel.jsx`; default in `useCitySettings.js`.
+- First-person branch = existing camera math unchanged; third-person = new helper math.
+- **Explicitly skip camera writes while `transitioning`** (prop from `CityScene`) so `CameraTransition` is the sole camera writer during toggle flights — today that works only by mount-order luck.
+
+### New `client/src/utils/cityPlayerRig.js` + test (pure math, plain `{x,y,z}`)
+
+- `thirdPersonCamera({ pos, yaw, pitch, boom 6.5, shoulder 0.6, height 2.4 })` → `{ camera, lookAt }`; asymmetric pitch clamp [-0.45, 1.15].
+- `resolveBoom(...)` — shorten boom when the camera lands inside a building cylinder; floor `camY ≥ 0.6`.
+- `dampFactor(rate, delta) = 1 - exp(-rate·delta)` (frame-rate independent; camera ≈8, lookAt ≈12), `dampAngle` (shortest-arc), `moveFacing(yaw, localMove)` (character faces movement direction; camera yaw stays mouse-driven), `avatarState()` → `idle|walk|run|hover`, `bankAngle` (±0.25 rad, damped).
+
+### Rewrite `PlayerAvatar.jsx` (currently dead code — upgrade in place, mounted by `PlayerController` in third-person only)
+
+- Reads `rigRef` each frame — no React state on the hot path.
+- **Design**: ~1.7-unit stylized cyber-runner — angular flat-shaded helmet + wraparound emissive visor, chevron chest with emissive core, shoulder pauldrons, **two-segment arms/legs** (shoulder→elbow, hip→knee), boots with emissive sole strips, back jet vents, additive ground glow disc. Palette: body = theme-tinted dark, trim/visor = accent (`toneMapped={false}`), eyes semantic red. ~22 meshes, shared module-scope geometries.
+- **Animations** via `avatarState()`: idle (bob, visor breathing, head scan), walk (opposing hip/shoulder swing, joint follow-through), run (faster phase, larger amplitude, torso pitched forward), **hover** (flyover: legs tuck, jet vents pulse — a flying runner instead of mid-air walking). Facing damped + banking into turns.
+- Mode interactions verified: OrbitControls only mounts when `!explorationMode`; photo/playback force exploration off (`CyberCity.jsx:122–135`) so the avatar can't leak into postcards.
+
+---
+
+## Delivery: two PRs
+
+**PR 1 — "city redesign: master town plan, waterfront Data Harbor, street fabric"** (commits kept individually green):
+1. `feat(city): master town plan as single source of district layout` (cityPlan.js + tests, district helpers re-anchored, water + shoreline, ground zones)
+2. `feat(server): city introspection service + GET /api/city/introspection` (+ tests, API.md)
+3. `feat(city): waterfront Data Harbor district`
+4. `feat(city): street network, instanced props, rooftop kits`
+
+**PR 2 — "third-person cyber-runner exploration"**:
+5. `refactor(city): player rig + third-person follow camera` (behavior-neutral on `cameraView='first'`)
+6. `feat(city): cyber-runner avatar`
+
+Each PR: `/simplify`, changelog entry in `.changelog/NEXT.md`, `/do:pr`, merge with `gh pr merge --merge --delete-branch`.
+
+## Test plan
+
+- **Pure helpers (vitest, node env)**: `cityPlan.test.js` (parcel non-overlap, world bounds, street reachability, plaza clearance, shoreline invariants), `cityDataHarbor.test.js` (null introspection → empty, dbDown shape, top-N+overflow, log-height monotonicity, pgvector flags), `cityRooftops.test.js` (deterministic, 0–3, in-bounds), `cityPlayerRig.test.js` (camera behind yaw, pitch clamp, boom shortening vs blocking cylinder, dampFactor monotonicity, shortest-arc ±π, moveFacing strafe/backpedal, avatarState transitions). Update any district tests that pinned old absolute positions.
+- **Server (vitest)**: `cityIntrospection.test.js` — mock `lib/db.js` per SQL shape; rejection → `db: null`; `mkdtempSync` fixture tree for the fs walk; TTL cache hit; stale-while-revalidate. Route test mocks the service.
+- **Visual (dev server, real GPU — headless renders blank)**: full-city day + night across both PortOS themes (the hard requirement); waterfront + harbor + holo-cards + DB-stopped state; streets/props/rooftops at all 4 quality presets with FPS sanity; transit loop; third-person walk/run/strafe/bank/collision/boom/hover; V toggle; exploration transition; F interact; photo mode (avatar absent); minimap + playback still coherent with the new layout.
+
+## Risks
+
+- **Re-anchoring ~15 district helpers** is wide but mechanical; the plan-invariant tests + per-district shape tests catch drift. Snapshot playback stores no coordinates (only statuses/counts) → unaffected by the new layout.
+- **CameraTransition vs follow camera** → explicit `transitioning` gate.
+- **`data/` walk cost** → stale-while-revalidate + concurrency-limited walk.
+- **drei `<Line>` broken** → merged native geometry only; water has no reflection passes.
+- **Client lib tests run in node env in CI** → all new utils three-free and window-free by construction.