1
0

feat: tone-mapped render rig, studio devices, LA fidelity pass, UI overhaul

The build the studios needed, across eight workstreams and one strict file
partition.

**The render rig was the quality ceiling.** The renderer ran three's
NoToneMapping default while atmosphere drove the sun to 2.35 and assets set
emissives to 3.2, so every value above 1.0 hard-clipped to flat white — which is
why walls blew out and every fitting looked like a white rectangle. ACES filmic
tone mapping and an explicit output colour space land in `stage.ts`, and the
atmosphere intensity table and palette headroom are re-tuned against the new
curve rather than left tuned for the clipping we removed.

`engine/environmentRig.ts` builds a PMREM environment at runtime, procedurally,
so nothing binary is committed. There was no environment map anywhere before, so
every `metalness > 0` role had nothing to reflect and rendered dull grey — a
defect the code already documented against itself in `office/optimus.ts`, where a
whole material role was abandoned over it, and worked around in `modelX.ts` with
a fake emissive that this change deletes. Atmosphere remains the sole light
owner; the rig derives from the `LightingState` it already produced.

**Studio hardware exists.** There was no device concept anywhere in the product:
no type, no route, no state. `devices/types.ts` fixes a declaration/state/
capability/command contract that a smart light, a thermostat, a door sensor and a
charger all fit without a schema change, and both studios now carry a desk mic
and a computer speaker with deterministic simulated behaviour behind an adapter
seam a real API can occupy later. Reads are the demo and are open; commands are a
signed-in action and are kept off the read body entirely, because a shared cache
replaying a GET that turned a microphone on is exactly what the fail-closed
cache default exists to prevent.

**The ADS-B licence hole is closed.** `TERA_ADSB_ENDPOINT` accepted any URL, the
response was served publicly cacheable, and the attribution hardcoded adsb.lol
regardless of where the endpoint pointed — one env var away from republishing
non-redistributable data under an open-terms credit. The host is now allowlisted,
the credit is derived from the host actually configured, public cacheability is
conditional on redistributability, and a refused endpoint demotes to simulated
flights and says so in `degraded[]`. The gate is on the source, not the feature:
live aircraft and their detail cards stay open to anonymous visitors.

**The LA studio was never the smaller pack** — 16 rooms and 248 props against
SF's 4 and 28. Its deficit was fidelity per square metre: 98 of those props were
ceiling troffers, it bound no props to seats, placed none of the habitat kit, and
12 of its 16 rooms had no viewpoint. Density comes from new asset kinds rather
than more instances, because `furnish.ts` draws once per kind and folds colour
into the batch key, so repeat instances add nothing the eye can read.

**The interface stops being forty imperative mutations.** Every visibility
decision moves into a pure, tested `ui/chromeState.ts` and one applier, so the
chrome has coverage for the first time. Deleted: ~100 lines of CSS and two
bindings targeting elements that no longer exist, and a `body:has()` rule that
shifted the desktop layout by 160px for touch controls hidden there. Fixed: the
office picker tabs that drew their label and their badge on top of each other.
Added: a first-run flow, because the product is two verbs and neither was ever
stated on screen. Mobile is designed on its own terms instead of being the
desktop with things hidden — the plan view comes back, and the keyboard-only
shortcuts button is replaced by touch controls.

`arena/studioOps.ts` frames the whole thing as the multi-variable environment it
is, wrapping the same simulators the renderer drives rather than a headless copy.

Also removed `input/vehicle.ts`, which nothing but its own test imported.

Tests 385 -> 961, all passing. Typecheck, build, performance budgets across six
matrix cells, no-binaries, provenance, dependency licences, zero-config boot and
arena source hashes all green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-21 19:44:24 -07:00
parent 8738367258
commit db074e9cf7
150 changed files with 36237 additions and 2586 deletions
+32 -2
View File
@@ -12,9 +12,10 @@
* one and binds it.
*/
import Fastify, { type FastifyInstance } from "fastify";
import Fastify, { type FastifyError, type FastifyInstance } from "fastify";
import { registerCachePolicy } from "./cache.ts";
import { loadConfig, type Config } from "./config.ts";
import { registerDevices } from "./routes/devices.ts";
import { registerFlights } from "./routes/flights.ts";
import { registerHealth } from "./routes/health.ts";
import { registerMarkers } from "./routes/markers.ts";
@@ -54,6 +55,7 @@ export function buildApp(config: Config = loadConfig()): FastifyInstance {
registerMedia(app, services);
registerOffices(app, services);
registerPresence(app, services);
registerDevices(app, services);
registerRealtime(app, services);
registerSession(app, services);
@@ -62,7 +64,35 @@ export function buildApp(config: Config = loadConfig()): FastifyInstance {
return reply.code(404).send(body);
});
app.setErrorHandler(async (err, _req, reply) => {
/**
* The one error handler, and the one place a client's mistake is told apart
* from ours.
*
* It used to answer 500 to everything, which was right for the only thing
* that reached it at the time — a route that threw. It stopped being right
* the moment a route accepted a body: Fastify raises its own errors for a
* payload that is not JSON, a content type it was not offered and a body over
* a route's `bodyLimit`, and every one of those is the caller's mistake,
* carries a 4xx `statusCode`, and was being reported as "something went wrong
* on the server". An operator watching error rates cannot tell a broken box
* from somebody POSTing nonsense at it, and the caller is told to retry
* something that will never work.
*
* So a 4xx from the framework is passed through with its own status and the
* `ErrorBody` shape every other refusal here uses; anything else is still a
* 500 with nothing in it, because the inside of an exception is not a thing
* to hand to the internet.
*/
app.setErrorHandler(async (err: FastifyError, req, reply) => {
const status = typeof err.statusCode === "number" ? err.statusCode : 500;
if (status >= 400 && status < 500) {
req.log.info({ err: err.message, status }, "refused a malformed request");
const body: ErrorBody =
status === 404
? { error: "not_found", message: "No such route." }
: { error: "bad_request", message: "That request could not be read." };
return reply.code(status).send(body);
}
app.log.error({ err }, "unhandled error");
const body: ErrorBody = { error: "internal", message: "Something went wrong." };
return reply.code(500).send(body);