feat: real fire on the boards, the LA office as a twin, and a night sky worth reading
The world stops being a simulation of California and starts being California. **THE PROMOTION GATE WAS THE FIRST COMMIT, BEFORE ANY ORANGE PIXEL EXISTED.** On today's live store the SoCal board contains 22 incidents. Every one has NULL acreage and fifteen are nameless LA County dispatch numbers. Drawn naively that is 22 orange marks over Los Angeles on a day nothing is burning — in a frame that contains no other warm colour, so one glyph would be the most salient object on the board and twenty-two would spend its credibility permanently. `acres >= 10 AND contained < 80 AND type != 'RX' AND last_seen = max(last_seen)` returns 0 on SoCal, exactly 5 on California, 0 on the Bay — same body, same day, three correct answers. The empty board is a deliverable, not a fallback: it says "No active fire on this board — CAL FIRE and WFIGS, just now", states that 21 records were gated and why, lists the largest fires burning OUTSIDE the frame with distances, and counts the hot pixels it is deliberately not drawing. **The privacy leak is structurally impossible rather than carefully avoided.** cloud-1 serves a projection; the four home-relative columns never leave that box. `observations.threat` was the one that nearly got through — it is `(16/distance)^2 x log10(acres) x momentum x containment x wind-alignment`, so with acreage and containment public it inverts to a distance circle around a house and three fires give an intersection. A grep of the built bundle for distance_km, bearing_deg, threat, 7762 and the street name returns nothing. **Deliberately not used, and both would have produced a confident wrong answer:** the store's `air` table retains only the last parameter of each poll, so all 78 rows read "Good" while the live feed reports ozone 101 "Unhealthy for Sensitive Groups" — haze driven off it would clear the sky during a smoke event. And `weather` is written only inside the NWS alerts loop, so a quiet day stores no wind at all. Tera's own per-region NWS wind is already correct and already what the clouds drift on. Satellite detections are drawn as evidence and never as incidents. The permanent industrial heat source 4.7 km from the owner's house is flagged persistent and dropped, asserted by a test that first proves it is present in the fixture. MODIS integer confidence and VIIRS string confidence are branched on `sat`. **The LA office is a twin.** Its entire authored second storey — Model Loft, Model Bay, The Materials Room, 430 lines nobody had ever stood in — is reachable on foot: a walker crosses level-1 to level-2 in 73 fixed steps, floorY 0 to 5, verified against the real pack rather than a synthetic plan. Its two studio devices read real hardware through a field-allowlisted bridge: mute, volume and reachability only. Never level, because there is no passive level upstream and obtaining one would record a room with people in it. Never dB, because upstream is gainPct across four different native scales. The bridge refuses all writes. Fixed at its root: an anonymous visitor was getting permanently at-rest instruments backing off against a 401. The tier moves into `createDeviceSource`, so anon gets the living simulator three file headers already promised. **Item 8 is closed, not fixed, and the correction is the point.** The Bay Area "stutter" was GPU power management — the card sat at 500 MHz of 2725 through every run that reproduced it, 4096/2048/1024/256 shadow maps all render in 1.21-1.31 ms, and two consecutive runs over a byte-identical dist gave 33.4 then 16.7. The allowance is removed and the cell is back to 16.7. Geometry is the gate; frame time is advisory. Item 7 was re-scoped after measuring: 1,069,006 of the Bay Area's 2,265,056 triangles were the second submission of the same buildings into the shadow pass. Mobile now has its own triangle caps and bay-area mobile draws 1,266,096. Also: bridges and the freeway corridor light up at night as emission, not lights — 1,614 deck lamps and 18 tower heads on the Bay in two draw calls. The single change that made US-101 legible was moving its edge lines from the lit material to the unlit one: retroreflective paint, the argument the SFO night frame already makes. California went 21,991 lamps to 4,051, clustered at the 17 town districts, because a rural interurban corridor genuinely is unlit. Tests 1137 -> 1340, server 280. All ten budget cells pass on first attempt with no cap raised. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+154
-20
@@ -42,6 +42,7 @@
|
||||
import {
|
||||
CAPABILITY_READING,
|
||||
DEVICE_RANGES,
|
||||
deviceRange,
|
||||
initialDeviceState,
|
||||
normalizeDeviceCommand,
|
||||
} from "../devices/types.ts";
|
||||
@@ -49,6 +50,7 @@ import type {
|
||||
DeviceCapability,
|
||||
DeviceCommand,
|
||||
DeviceDeclaration,
|
||||
DeviceRange,
|
||||
DeviceState,
|
||||
} from "../devices/types.ts";
|
||||
import { TOUCH_TARGET_PX } from "./tokens.ts";
|
||||
@@ -152,6 +154,14 @@ export const DEVICE_PANEL_CSS = `
|
||||
background: linear-gradient(90deg, #6fd58f 0%, #f2b134 78%, #ff8f6b 100%);
|
||||
transition: width 120ms linear;
|
||||
}
|
||||
.tera-device__status {
|
||||
margin: 0;
|
||||
font-size: 9px;
|
||||
letter-spacing: .06em;
|
||||
text-transform: uppercase;
|
||||
color: var(--ink-3, rgba(255,255,255,.4));
|
||||
}
|
||||
.tera-device__status[data-reachable="false"] { color: var(--ink-2, rgba(255,255,255,.56)); }
|
||||
.tera-device__disclosure {
|
||||
margin: 0;
|
||||
font-size: 9px;
|
||||
@@ -188,11 +198,24 @@ const ROW_LABEL: Readonly<Record<DeviceCapability, string>> = {
|
||||
level: "Level",
|
||||
};
|
||||
|
||||
/** The step a slider moves in, in the reading's own unit. */
|
||||
const SLIDER_STEP: Readonly<Record<"gain" | "volume", number>> = { gain: 1, volume: 0.01 };
|
||||
/**
|
||||
* The step a slider moves in, derived from the range rather than tabled against
|
||||
* the capability.
|
||||
*
|
||||
* It used to be a constant per capability — 1 for gain, 0.01 for volume — which
|
||||
* was right only while every gain in the world was the default −12…+36 dB. A
|
||||
* Yeti Nano declares 0–100 "%" and a step of 1 is still right there; a
|
||||
* hypothetical 0–1 gain would need 0.01. So the rule is about the span: a wide
|
||||
* range moves in whole units, a narrow one in hundredths.
|
||||
*/
|
||||
function sliderStep(range: DeviceRange): number {
|
||||
return range.max - range.min > 5 ? 1 : (range.max - range.min) / 100;
|
||||
}
|
||||
|
||||
interface Row {
|
||||
capability: DeviceCapability;
|
||||
/** This device's own bounds and unit, or `null` for a switch. */
|
||||
range: DeviceRange | null;
|
||||
/**
|
||||
* How this row presents itself, carried rather than re-derived.
|
||||
*
|
||||
@@ -213,9 +236,31 @@ interface Row {
|
||||
interface Instrument {
|
||||
declaration: DeviceDeclaration;
|
||||
rows: readonly Row[];
|
||||
/**
|
||||
* The one line per instrument that says which of the two sentences the viewer
|
||||
* is reading, and whether anybody answered the door.
|
||||
*/
|
||||
status: HTMLElement;
|
||||
disclosure: HTMLElement;
|
||||
}
|
||||
|
||||
function formatReading(capability: DeviceCapability, reading: unknown): string {
|
||||
/**
|
||||
* One reading, in the unit the *declaration* says it is in.
|
||||
*
|
||||
* The unit comes from the range and never from the capability, and that is the
|
||||
* whole reason `DeviceDeclaration.ranges` exists. A Blue Yeti Nano's capture
|
||||
* level is an ALSA position on a 0–50 scale; there is no arithmetic that turns
|
||||
* 68% of it into decibels, and printing "+20.6 dB" beside it would present a
|
||||
* guess in the typography of a measurement. The field on `DeviceState` is still
|
||||
* called `gainDb` — renaming it would break four consumers to fix a label — so
|
||||
* this is the one place that decides what the number is called on screen, and it
|
||||
* asks the declaration.
|
||||
*/
|
||||
function formatReading(
|
||||
capability: DeviceCapability,
|
||||
reading: unknown,
|
||||
range: DeviceRange | null,
|
||||
): string {
|
||||
if (reading === undefined || reading === null) return "—";
|
||||
if (typeof reading === "boolean") {
|
||||
if (capability === "power") return reading ? "On" : "Off";
|
||||
@@ -223,19 +268,50 @@ function formatReading(capability: DeviceCapability, reading: unknown): string {
|
||||
return reading ? "Playing" : "Stopped";
|
||||
}
|
||||
if (typeof reading !== "number" || !Number.isFinite(reading)) return "—";
|
||||
if (capability === "gain") return `${reading >= 0 ? "+" : ""}${reading.toFixed(0)} dB`;
|
||||
if (capability === "level") return `${reading.toFixed(0)} dBFS`;
|
||||
if (capability === "volume") return `${Math.round(reading * 100)}%`;
|
||||
return String(reading);
|
||||
const unit = range?.unit ?? "";
|
||||
// A fraction is the one unit nobody wants to read as a fraction.
|
||||
if (unit === "fraction") return `${Math.round(reading * 100)}%`;
|
||||
if (unit === "%") return `${Math.round(reading)}%`;
|
||||
if (unit === "dB") return `${reading >= 0 ? "+" : ""}${reading.toFixed(0)} dB`;
|
||||
if (unit === "dBFS") return `${reading.toFixed(0)} dBFS`;
|
||||
if (unit === "") return String(reading);
|
||||
return `${reading.toFixed(reading % 1 === 0 ? 0 : 2)} ${unit}`;
|
||||
}
|
||||
|
||||
/** A level in dBFS as a fraction of the meter's travel. `-60` is empty, `0` is full. */
|
||||
export function meterFraction(levelDb: number | undefined): number {
|
||||
/**
|
||||
* A level as a fraction of the meter's travel. On the default range, `-60` dBFS
|
||||
* is empty and `0` is full.
|
||||
*
|
||||
* `range` is optional and defaults to the global one so that every existing
|
||||
* caller — and every test that already asserts on this — is unchanged. A device
|
||||
* that declared its own level range gets its own travel.
|
||||
*/
|
||||
export function meterFraction(levelDb: number | undefined, range?: DeviceRange): number {
|
||||
if (levelDb === undefined || !Number.isFinite(levelDb)) return 0;
|
||||
const { min, max } = DEVICE_RANGES.level;
|
||||
const { min, max } = range ?? DEVICE_RANGES.level;
|
||||
if (!(max > min)) return 0;
|
||||
return Math.min(1, Math.max(0, (levelDb - min) / (max - min)));
|
||||
}
|
||||
|
||||
/**
|
||||
* How old a reading is, in the coarsest unit that is still true.
|
||||
*
|
||||
* Deliberately vague past an hour. A panel that said "not reached — last reading
|
||||
* 3h 41m ago" would be inviting a precision the underlying clock does not have:
|
||||
* `observedAt` is the bridge's own `checkedAt`, restamped through two caches.
|
||||
*/
|
||||
function sinceLabel(observedAt: number | undefined, nowMs: number = Date.now()): string {
|
||||
if (typeof observedAt !== "number" || !Number.isFinite(observedAt) || observedAt <= 0) {
|
||||
return "at an unknown time";
|
||||
}
|
||||
const seconds = Math.max(0, Math.round((nowMs - observedAt) / 1000));
|
||||
if (seconds < 90) return `${seconds}s ago`;
|
||||
const minutes = Math.round(seconds / 60);
|
||||
if (minutes < 90) return `${minutes} min ago`;
|
||||
const hours = Math.round(minutes / 60);
|
||||
return hours < 36 ? `${hours}h ago` : "over a day ago";
|
||||
}
|
||||
|
||||
// ---- Mount ----------------------------------------------------------------
|
||||
|
||||
export function mountDevicePanel(
|
||||
@@ -313,6 +389,7 @@ export function mountDevicePanel(
|
||||
let control: HTMLElement;
|
||||
let input: HTMLInputElement | null = null;
|
||||
let meterFill: HTMLElement | null = null;
|
||||
let range: DeviceRange | null = null;
|
||||
|
||||
if (shape === "switch") {
|
||||
const button = doc.createElement("button");
|
||||
@@ -335,8 +412,9 @@ export function mountDevicePanel(
|
||||
});
|
||||
control = button;
|
||||
} else if (shape === "slider") {
|
||||
const range = capability === "gain" ? DEVICE_RANGES.gain : DEVICE_RANGES.volume;
|
||||
const step = capability === "gain" ? SLIDER_STEP.gain : SLIDER_STEP.volume;
|
||||
// The device's own bounds, not the global defaults. See `deviceRange`.
|
||||
range = deviceRange(declaration, capability === "gain" ? "gain" : "volume");
|
||||
const step = sliderStep(range);
|
||||
const slider = doc.createElement("input");
|
||||
slider.type = "range";
|
||||
slider.className = "tera-device__slider";
|
||||
@@ -357,11 +435,12 @@ export function mountDevicePanel(
|
||||
control = slider;
|
||||
input = slider;
|
||||
} else {
|
||||
range = deviceRange(declaration, "level");
|
||||
const meter = doc.createElement("div");
|
||||
meter.className = "tera-device__meter";
|
||||
meter.setAttribute("role", "meter");
|
||||
meter.setAttribute("aria-valuemin", String(DEVICE_RANGES.level.min));
|
||||
meter.setAttribute("aria-valuemax", String(DEVICE_RANGES.level.max));
|
||||
meter.setAttribute("aria-valuemin", String(range.min));
|
||||
meter.setAttribute("aria-valuemax", String(range.max));
|
||||
const fill = doc.createElement("i");
|
||||
fill.style.width = "0%";
|
||||
meter.append(fill);
|
||||
@@ -371,19 +450,22 @@ export function mountDevicePanel(
|
||||
|
||||
row.append(label, control, value);
|
||||
card.append(row);
|
||||
rows.push({ capability, shape, root: row, control, input, value, meterFill });
|
||||
rows.push({ capability, range, shape, root: row, control, input, value, meterFill });
|
||||
}
|
||||
|
||||
// Per instrument, not once per panel. A disclosure at the top of a scrolling
|
||||
// list is a disclosure you have already scrolled past by the time you are
|
||||
// looking at the meter that needed it.
|
||||
const status = doc.createElement("p");
|
||||
status.className = "tera-device__status";
|
||||
status.textContent = "";
|
||||
const disclosure = doc.createElement("p");
|
||||
disclosure.className = "tera-device__disclosure";
|
||||
disclosure.textContent = declaration.disclosure;
|
||||
card.append(disclosure);
|
||||
card.append(status, disclosure);
|
||||
|
||||
root.append(card);
|
||||
instruments.push({ declaration, rows });
|
||||
instruments.push({ declaration, rows, status, disclosure });
|
||||
}
|
||||
|
||||
host.append(root);
|
||||
@@ -402,7 +484,7 @@ export function mountDevicePanel(
|
||||
// statement from zero and gets a different treatment: the row goes away
|
||||
// rather than sitting there reporting a confident 0 dB.
|
||||
row.root.setAttribute("data-unavailable", String(reading === undefined));
|
||||
row.value.textContent = formatReading(row.capability, reading);
|
||||
row.value.textContent = formatReading(row.capability, reading, row.range);
|
||||
|
||||
if (row.shape === "switch") {
|
||||
row.control.setAttribute("aria-pressed", String(reading === true));
|
||||
@@ -411,17 +493,69 @@ export function mountDevicePanel(
|
||||
row.input.value = String(reading);
|
||||
}
|
||||
} else if (row.meterFill !== null) {
|
||||
const fraction = meterFraction(typeof reading === "number" ? reading : undefined);
|
||||
const range = row.range ?? DEVICE_RANGES.level;
|
||||
const fraction = meterFraction(
|
||||
typeof reading === "number" ? reading : undefined,
|
||||
range,
|
||||
);
|
||||
row.meterFill.style.width = `${(fraction * 100).toFixed(1)}%`;
|
||||
row.control.setAttribute(
|
||||
"aria-valuenow",
|
||||
typeof reading === "number" ? reading.toFixed(1) : String(DEVICE_RANGES.level.min),
|
||||
typeof reading === "number" ? reading.toFixed(1) : String(range.min),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
applyProvenance(instrument, state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The two sentences under one instrument, and which of them is true right now.
|
||||
*
|
||||
* There are three facts a viewer needs and only one of them is a reading:
|
||||
*
|
||||
* - **Which disclosure applies.** A `first-party-sensor` declaration's own
|
||||
* `disclosure` says the hardware is live. An anonymous visitor is handed the
|
||||
* *local simulator* running that same declaration — see
|
||||
* `devices/adapter.ts` — and printing "live, LA Studio, north wall" over a
|
||||
* number invented a millisecond ago in their own browser is the exact
|
||||
* provenance confusion `DeviceProvenance` exists to prevent, arriving
|
||||
* through the honest path. So when a state says `synthetic` and the
|
||||
* declaration does not, `simulatedDisclosure` is what is shown.
|
||||
* - **Whether anybody answered.** `reachable: false` means the readings below
|
||||
* still stand and nobody has been able to confirm them since. It is
|
||||
* emphatically not `powered: false`: a microphone on a machine that is
|
||||
* asleep is not a switched-off microphone. There is deliberately no fifth
|
||||
* indicator colour in the 3D scene for it — a new colour would have to be
|
||||
* learned, and would be learned wrong. The sentence lives here, where there
|
||||
* is room for a sentence.
|
||||
* - **How old the reading is**, once it has stopped being confirmed.
|
||||
*/
|
||||
function applyProvenance(instrument: Instrument, state: DeviceState | null): void {
|
||||
const { declaration } = instrument;
|
||||
const invented = state === null ? true : state.synthetic;
|
||||
const simulatedSentence = declaration.simulatedDisclosure;
|
||||
instrument.disclosure.textContent =
|
||||
invented && declaration.provenance !== "simulated" && typeof simulatedSentence === "string"
|
||||
? simulatedSentence
|
||||
: declaration.disclosure;
|
||||
|
||||
// Absent means the concept does not apply to this source, which is every
|
||||
// simulated device — a state machine in this tab is never unreachable, and a
|
||||
// line claiming it is reachable would be a fact about nothing.
|
||||
const reachable = state?.reachable;
|
||||
if (reachable === undefined) {
|
||||
instrument.status.removeAttribute("data-reachable");
|
||||
instrument.status.textContent = "";
|
||||
return;
|
||||
}
|
||||
instrument.status.setAttribute("data-reachable", String(reachable));
|
||||
instrument.status.textContent = reachable
|
||||
? "Reached"
|
||||
: `Not reached — last reading ${sinceLabel(state?.observedAt)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Everything starts at rest rather than blank.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user