Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,10 @@ right, ownship teal left, only Debrief detects ownship turns, `splitter_ownship_
chart's quantity as a drop-down; the Preset drop-down shows the matching preset or "custom"; a
waypoint drag keeps the adjacent legs' speeds (`moveWaypoint(..., "speed")`; the square keeps
duration); ctrl-click deletes a waypoint. Schema 0.39.0.
Owner 2026-11-22: bearings are lost in ownship's turns and for 120 s after each; the demonstrator
drops them by default (`DemoScenario.turn_loss_s`, null keeps all; `TmaProblem.bearing_valid`,
rows kept so grids stay regular; schema 0.40.0). Spec 035's golden problems and spec 036's
readings pin `turn_loss_s: null`.

## Stack (owner decisions, 2026-10-31)

Expand Down
62 changes: 61 additions & 1 deletion conformance/onnx/demo_node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,64 @@ test("LinkML validation accepts every preset and rejects a bad file with its mes
assert.ok(errs.some((e) => e.includes('"extra"')), errs.join("; "));
});

// ---------- bearings lost in ownship's turns (owner, 2026-11-22) ----------
test("bearings are lost during each ownship turn and 120 s after; the kept ones do not change", () => {
const sc = preset("good-geometry");
assert.equal(sc.turn_loss_s, 120);
const b = bearings(sc), keep = bearings({ ...sc, turn_loss_s: null });
assert.deepEqual(Array.from(b.z), Array.from(keep.z));
assert.ok(keep.valid.every((v) => v === 1));
const turns = T.manoeuvres(b.paths.own).filter((m) => m.course);
assert.equal(turns.length, 3);
for (let i = 0; i < b.n; i++) {
const lost = turns.some((m) => b.t[i] >= m.t0 - 1e-9 && b.t[i] <= m.t1 + 120 + 1e-9);
assert.equal(b.valid[i], lost ? 0 : 1, `row ${i} t ${b.t[i]}`);
}
// a 60-degree turn at 1 deg/s lasts about a minute, then two minutes: about 36 rows of 5 s each
const nLost = b.n - b.valid.reduce((a, v) => a + v, 0);
assert.ok(nLost > 90 && nLost < 130, `${nLost} lost`);
// a scenario saved without the field takes the default
const legacy = clone(sc);
delete legacy.turn_loss_s;
assert.equal(normaliseScenario(legacy).turn_loss_s, 120);
assert.deepEqual(Array.from(bearings(legacy).valid), Array.from(b.valid));
// the schema accepts null and rejects a negative tail
assert.deepEqual(checkScenario(schema, { ...sc, turn_loss_s: null }), []);
assert.ok(checkScenario(schema, { ...sc, turn_loss_s: -1 }).length > 0);
});

test("least squares with lost bearings flagged equals least squares on the received rows only", async () => {
const sc = preset("good-geometry");
const b = bearings(sc);
const { problem } = problemOf(sc, b, windowRows(sc, b));
assert.ok(problem.bearing_valid.includes(0));
const keep = problem.t_s.map((_, k) => k).filter((k) => problem.bearing_valid[k]);
const pick = (a) => keep.map((k) => a[k]);
const sub = { ...problem, t_s: pick(problem.t_s), bearing_rad: pick(problem.bearing_rad), own_x_m: pick(problem.own_x_m), own_y_m: pick(problem.own_y_m), own_course_rad: pick(problem.own_course_rad), own_speed_mps: pick(problem.own_speed_mps), bearing_valid: undefined };
const a = await solver("ls-js").solve(problem, { run }), c = await solver("ls-js").solve(sub, { run });
for (const k of [0, keep.length - 1]) {
assert.ok(Math.abs(a.x_m[keep[k]] - c.x_m[k]) < 1e-6 && Math.abs(a.vx_mps[keep[k]] - c.vx_mps[k]) < 1e-9);
}
for (let q = 0; q < 16; q++) assert.ok(Math.abs(a.cov_end[q] - c.cov_end[q]) <= 1e-8 * (Math.abs(c.cov_end[q]) + 1));
// the scored residuals skip lost bearings
const r = await solveScenario(sc, "ls-js");
assert.equal(r.ev.residual.length, keep.length);
});

test("the learned model's inputs zero a lost bearing's features and keep ownship's", () => {
const sc = preset("good-geometry");
const b = bearings(sc);
const { problem: p } = problemOf(sc, b, windowRows(sc, b));
const full = TLM.periodFeatures(p.t_s, p.own_x_m, p.own_y_m, p.bearing_rad, p.sigma_rad);
const lost = TLM.periodFeatures(p.t_s, p.own_x_m, p.own_y_m, p.bearing_rad, p.sigma_rad, p.bearing_valid);
const k = p.bearing_valid.indexOf(0), N = TLM.N_FEATURES;
assert.deepEqual([0, 1, 4].map((j) => lost.f[k * N + j]), [0, 0, 0]);
for (const j of [2, 3, 5, 6, 7, 8]) assert.equal(lost.f[k * N + j], full.f[k * N + j]);
// the smoothed bearing interpolates over the gap
const zs = TLM.smoothedBearing(p.bearing_rad, p.bearing_valid);
assert.ok(zs.every(Number.isFinite));
});

// ---------- ONNX ----------
test("the ONNX physics layer with one leg equals the JavaScript solve on noise-free bearings", async () => {
const sc = { ...preset("good-geometry"), sigma_deg: 0 };
Expand Down Expand Up @@ -322,7 +380,9 @@ test("spec 036 follow-up: Debrief's splitter states the ownship turns it found,
});

test("two target turns inside ownship legs: joined legs find both, Debrief one, independent slices land between", async () => {
const sc = preset("two-target-turns");
// spec 036's reading, every bearing kept (with the owner's turn loss, seed 1's first turn is
// placed at 50 min, outside the 120 s match; seeds 2, 3 and 5 still find both)
const sc = { ...preset("two-target-turns"), turn_loss_s: null };
const j = await split(sc, "arctan-joined");
assert.equal(j.legs.matched, 2);
assert.equal(j.legs.false_, 0);
Expand Down
14 changes: 14 additions & 0 deletions conformance/onnx/demo_page.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,20 @@ try {

await settled();

// owner 2026-11-22: bearings lost in ownship's turns; the control turns the loss off and on
const lostText = async () => page.locator("[data-testid=window-slider]").innerText();
const withLoss = await lostText();
await page.locator("[data-testid=turn-loss]").uncheck();
await page.waitForTimeout(50);
await settled();
const without = await lostText();
const sNo = await state();
await page.locator("[data-testid=turn-loss]").check();
await page.waitForTimeout(50);
await settled();
const sYes = await state();
check("bearings lost in ownship turns: stated under the window, and the control turns the loss off", /lost in ownship's turns/.test(withLoss) && !/lost in ownship's turns/.test(without) && sNo.sc.turn_loss_s === null && sYes.sc.turn_loss_s === 120, { withLoss: withLoss.split(";")[1] });

// acceptance 5: the URL restores the exact scenario and solution
await page.locator("[data-testid=reseed]").click();
await page.waitForTimeout(50);
Expand Down
8 changes: 5 additions & 3 deletions conformance/onnx/demo_problems.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Spec 035: the demonstrator's solver problems for the golden least-squares vectors. Every
// preset at sigma 1 and 0, the target-turn preset narrowed to its first leg, written as JSON
// for demo_golden.py (Python's tma2.references.lsq.solve_batch on the same arrays).
// for demo_golden.py (Python's tma2.references.lsq.solve_batch on the same arrays). Spec 035's
// problems keep every bearing (turn_loss_s null), so the golden files' digests stand; the
// lost-bearing path is checked in demo_node.mjs.
// node demo_problems.mjs > demo/problems.json
import { PRESETS } from "../../site/static/demo-data/js/presets.js";
import { bearings, windowRows, problemOf } from "../../site/static/demo-data/js/scenario.js";
Expand All @@ -10,10 +12,10 @@ export function goldenCases() {
// spec 035's presets only: a later preset (golden: false) would change the problems' digest
// that the golden files bind
for (const p of PRESETS.filter((q) => q.golden !== false)) {
for (const sigma of [1, 0]) out.push({ id: `${p.id}-s${sigma}`, sc: { ...p.scenario, sigma_deg: sigma } });
for (const sigma of [1, 0]) out.push({ id: `${p.id}-s${sigma}`, sc: { ...p.scenario, sigma_deg: sigma, turn_loss_s: null } });
}
const tt = PRESETS.find((p) => p.id === "target-turn").scenario;
out.push({ id: "target-turn-first-leg", sc: { ...tt, window: { start_s: 0, end_s: 3500 } } });
out.push({ id: "target-turn-first-leg", sc: { ...tt, window: { start_s: 0, end_s: 3500 }, turn_loss_s: null } });
return out.map(({ id, sc }) => {
const b = bearings(sc);
const { problem } = problemOf(sc, b, windowRows(sc, b));
Expand Down
4 changes: 3 additions & 1 deletion schema/tma.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: >-
principle I). Frame: local flat-earth Cartesian, x east, y north, metres, origin at ownship's
window-start position. Bearings and courses are true, clockwise from north, radians in [0, 2π).
Speeds in m/s. Times in seconds since window start. All stored floats are float32-rounded.
version: 0.39.0
version: 0.40.0
license: Apache-2.0
prefixes:
linkml: https://w3id.org/linkml/
Expand Down Expand Up @@ -2205,6 +2205,7 @@ classes:
target: { range: DemoTrack, required: true, inlined: true }
sigma_deg: { range: float, required: true, minimum_value: 0, maximum_value: 5, description: "Standard deviation of the zero-mean Gaussian bearing noise (FR-011)." }
interval_s: { range: float, required: true, minimum_value: 1, maximum_value: 120, description: "Bearing sample interval (FR-010)." }
turn_loss_s: { range: float, minimum_value: 0, maximum_value: 1800, description: "Owner 2026-11-22: bearings are lost while ownship turns and for this many seconds after each turn ends (default 120); null keeps every bearing." }
seed: { range: integer, required: true, minimum_value: 0, maximum_value: 4294967295, description: "Seed of the noise generator; the same seed and scenario give identical bearings." }
window: { range: DemoWindow, required: true, inlined: true }
solver: { range: string, required: true, description: "Name of the selected solver plug-in (FR-024)." }
Expand All @@ -2228,6 +2229,7 @@ classes:
own_course_rad: { range: float, multivalued: true, description: "Ownship course at each bearing (the learned model reads ownship legs from it)." }
own_speed_mps: { range: float, multivalued: true }
sigma_rad: { range: float, required: true }
bearing_valid: { range: integer, multivalued: true, description: "1 where the bearing was received, 0 where it was lost (an ownship turn and its tail); absent: every bearing received. Lost rows keep their place so the time grid stays regular." }
knots: { range: DemoSpan, multivalued: true, inlined_as_list: true, description: "Manoeuvre spans a solver may use when it accepts knots (the oracle is told the truth's)." }

TmaSolution:
Expand Down
3 changes: 2 additions & 1 deletion scripts/research/demo_charts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ async function run(name, feeds) {
return o;
}
const commit = execSync("git rev-parse HEAD", { cwd: root }).toString().trim();
const preset = (id) => clone(PRESETS.find((p) => p.id === id).scenario);
// spec 035's figures kept every bearing (before the owner's 2026-11-22 turn loss): pinned here
const preset = (id) => ({ ...clone(PRESETS.find((p) => p.id === id).scenario), turn_loss_s: null });
async function solve(sc, name) {
const b = bearings(sc), rows = windowRows(sc, b);
const { problem, origin, t0 } = problemOf(sc, b, rows);
Expand Down
3 changes: 2 additions & 1 deletion scripts/research/demo_splitters.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ async function run(name, feeds) {
return o;
}
const commit = execSync("git rev-parse HEAD", { cwd: root }).toString().trim();
const preset = (id) => clone(PRESETS.find((p) => p.id === id).scenario);
// spec 036's readings kept every bearing (before the owner's 2026-11-22 turn loss): pinned here
const preset = (id) => ({ ...clone(PRESETS.find((p) => p.id === id).scenario), turn_loss_s: null });

async function trial(sc, name) {
const b = bearings(sc), rows = windowRows(sc, b);
Expand Down
17 changes: 17 additions & 0 deletions site/blog/2026-11-21-leg-splitters-kickoff.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,20 @@ This is spec 036.
hover tooltips on squares and circles say the same.
- Schema 0.39.0: `TmaSolution.splitter_ownship_spans`, and the `DemoSplitterInfo` flags
`detects_target` and `detects_ownship`.

## 2026-11-22: bearings lost in ownship's turns

The owner noted that bearings are lost while ownship turns and for two minutes after each turn
ends. The demonstrator now drops them by default. A scenario's `turn_loss_s` sets the tail
(120 s); null keeps every bearing, and a checkbox under the noise controls turns the loss off.
Lost bearings keep their rows, flagged in the problem's `bearing_valid` (schema 0.40.0), so every
solver and splitter keeps its regular time grid and skips them, as Python's `valid` column does.
Least squares, the physics layer, C, the arctan splitters and the learned model's inputs all
ignore them, and the plot, bearings chart and residuals hide them. The noise is still drawn for
every row, so the bearings that are kept do not change. On the good-geometry preset, 120 of
1,429 bearings are lost (three turns of 1 to 1.5 minutes, each plus two minutes).

Spec 035's golden problems and spec 036's readings and figures kept every bearing, so their
scripts and tests pin `turn_loss_s: null`. With the loss on, joined legs on the two-turn preset
places the first turn at 50 min instead of 46.5 on seed 1, outside the 120 s match. Seeds 2, 3
and 5 still find both turns. This is one draw, not a result.
24 changes: 17 additions & 7 deletions site/src/pages/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import useBaseUrl from "@docusaurus/useBaseUrl";
import BrowserOnly from "@docusaurus/BrowserOnly";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import * as T from "../../static/demo-data/js/track.js";
import { bearings, windowRows, problemOf, targetManoeuvresIn, ownTurnsIn, SCHEMA_VERSION } from "../../static/demo-data/js/scenario.js";
import { bearings, windowRows, problemOf, targetManoeuvresIn, ownTurnsIn, validCount, TURN_LOSS_S, SCHEMA_VERSION } from "../../static/demo-data/js/scenario.js";
import { evaluate, observability, compareLegs, OBS_GREEN, OBS_AMBER, OBS_SIGMA_DEG } from "../../static/demo-data/js/metrics.js";
import { PRESETS, DEFAULT_SCENARIO, clone, normaliseScenario } from "../../static/demo-data/js/presets.js";
import { SOLVER_LIST, SPLITTER_LIST } from "../../static/demo-data/js/solver-info.js";
Expand Down Expand Up @@ -284,11 +284,12 @@ function Demo() {
const derived = useMemo(() => {
const b = bearings(sc);
const rows = windowRows(sc, b);
if (rows.length < 4) return { b, rows, problem: null };
const received = validCount(b, rows);
if (received < 4) return { b, rows, received, problem: null };
const { problem, origin, t0 } = problemOf(sc, b, rows);
const kn = targetManoeuvresIn(sc, b);
const obs = observability(sc, b, rows, kn);
return { b, rows, problem, origin, t0, kn, obs, ownTurns: ownTurnsIn(sc, b) };
return { b, rows, received, problem, origin, t0, kn, obs, ownTurns: ownTurnsIn(sc, b) };
}, [sc]);
const info = SOLVER_LIST.find((s) => s.name === sc.solver) || SOLVER_LIST[0];
const splitterName = sc.splitter || "none";
Expand Down Expand Up @@ -616,6 +617,7 @@ function Demo() {
const step = Math.max(1, Math.ceil(b.n / 48));
const bearingLines = [];
for (let i = 0; i < b.n; i += step) {
if (!b.valid[i]) continue; // lost in ownship's turn
const r = Math.hypot(b.tx[i] - b.ox[i], b.ty[i] - b.oy[i]) * 1.15;
const x1 = b.ox[i] + r * Math.sin(b.z[i]), y1 = b.oy[i] + r * Math.cos(b.z[i]);
bearingLines.push(<line key={i} x1={sx(b.ox[i] / NM)} y1={sy(b.oy[i] / NM)} x2={sx(x1 / NM)} y2={sy(y1 / NM)} stroke={inWin(b.t[i]) ? BRG : "#999"} strokeOpacity={inWin(b.t[i]) ? 0.55 : 0.25} strokeWidth={0.8} />);
Expand Down Expand Up @@ -795,14 +797,16 @@ function Demo() {
if (ev || derived.problem) {
// bearings drawn around their circular mean, so a track across north does not jump 360°
let cs = 0, cc = 0;
for (let i = 0; i < b.n; i++) { cs += Math.sin(b.z[i]); cc += Math.cos(b.z[i]); }
for (let i = 0; i < b.n; i++) if (b.valid[i]) { cs += Math.sin(b.z[i]); cc += Math.cos(b.z[i]); }
const mean = Math.atan2(cs, cc);
const unwrap = (z) => (mean + Math.atan2(Math.sin(z - mean), Math.cos(z - mean))) / DEG;
const meas = Array.from(b.t, (t, i) => [t, unwrap(b.z[i])]);
const meas = [];
for (let i = 0; i < b.n; i++) if (b.valid[i]) meas.push([b.t[i], unwrap(b.z[i])]);
const lostMarks = b.lost.map(([a, e]) => [a, Math.min(e, period), "#d0d0d0"]);
const pred = ev ? ev.predicted.map(([t, z]) => [t, unwrap(z)]) : [];
const res = ev ? ev.residual : [];
brgChart = {
bearings: (w, h) => <Chart width={w} height={h} testid="chart-bearings" title="Bearings" xDomain={[0, period]} yLabel="° (dots measured, line solution)" series={[{ points: meas, dots: true, colour: BRG, colourAt: (p) => (inWin(p[0]) ? "#8c8c00" : "#bbb") }, { points: pred, colour: EST, width: 1.5 }]} marks={[[win.start_s, win.end_s, "#2ca02c"], ...trueMarks, ...foundMarks]} />,
bearings: (w, h) => <Chart width={w} height={h} testid="chart-bearings" title="Bearings" xDomain={[0, period]} yLabel="° (dots measured, line solution)" series={[{ points: meas, dots: true, colour: BRG, colourAt: (p) => (inWin(p[0]) ? "#8c8c00" : "#bbb") }, { points: pred, colour: EST, width: 1.5 }]} marks={[[win.start_s, win.end_s, "#2ca02c"], ...lostMarks, ...trueMarks, ...foundMarks]} />,
residuals: (w, h) => <Chart width={w} height={h} testid="chart-residuals" title="Residuals" xDomain={[0, period]} yLabel="÷ σ (±2 dashed)" series={[{ points: res, dots: true, colour: EST }, { points: [[0, 2], [period, 2]], colour: "#888", dash: "3 3", width: 1 }, { points: [[0, -2], [period, -2]], colour: "#888", dash: "3 3", width: 1 }]} marks={[[win.start_s, win.end_s, "#2ca02c"], ...trueMarks, ...foundMarks]} yClip={[-8, 8]} />,
};
}
Expand Down Expand Up @@ -990,7 +994,7 @@ function Demo() {
</div>
<div className="margin-top--sm" data-testid="window-slider">
<div className={styles.small}>
Analysis window {fmtMin(win.start_s)} – {fmtMin(Math.min(win.end_s, period))} of {fmtMin(period)} (min:s); {derived.rows.length} bearings go to the solver. Drag either end; the solve runs on release.
Analysis window {fmtMin(win.start_s)} – {fmtMin(Math.min(win.end_s, period))} of {fmtMin(period)} (min:s); {derived.received} bearings go to the solver{derived.received < derived.rows.length ? ` (${derived.rows.length - derived.received} lost in ownship's turns)` : ""}. Drag either end; the solve runs on release.
</div>
<div className={styles.dual}>
<div className={styles.track}>
Expand All @@ -1009,6 +1013,12 @@ function Demo() {
<label>Interval (s){" "}
<input type="number" min={1} max={120} step={1} defaultValue={sc.interval_s} key={`iv-${sc.interval_s}`} style={{ width: "4.5rem" }} onBlur={(e) => { const v = Number(e.target.value); if (v >= 1 && v <= 120) commit({ ...sc, interval_s: v }); }} onKeyDown={(e) => e.key === "Enter" && e.target.blur()} />
</label>
<label title="Bearings are lost while ownship turns and for this long after each turn">
<input type="checkbox" data-testid="turn-loss" checked={sc.turn_loss_s !== null} onChange={(e) => commit({ ...sc, turn_loss_s: e.target.checked ? TURN_LOSS_S : null })} /> Lose bearings in ownship turns{" "}
{sc.turn_loss_s !== null && (
<>+ <input type="number" min={0} max={1800} step={10} defaultValue={sc.turn_loss_s} key={`tl-${sc.turn_loss_s}`} style={{ width: "4.5rem" }} data-testid="turn-loss-s" onBlur={(e) => { const v = Number(e.target.value); if (v >= 0 && v <= 1800) commit({ ...sc, turn_loss_s: v }); }} onKeyDown={(e) => e.key === "Enter" && e.target.blur()} /> s after</>
)}
</label>
</div>
</div>
<div className={styles.chartsCol}>
Expand Down
11 changes: 10 additions & 1 deletion site/static/demo-data/demo-scenario.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@
"target": {
"$ref": "#/$defs/DemoTrack"
},
"turn_loss_s": {
"description": "Owner 2026-11-22: bearings are lost while ownship turns and for this many seconds after each turn ends (default 120); null keeps every bearing.",
"maximum": 1800,
"minimum": 0,
"type": [
"number",
"null"
]
},
"window": {
"$ref": "#/$defs/DemoWindow"
}
Expand All @@ -162,5 +171,5 @@
],
"title": "DemoScenario",
"type": "object",
"version": "0.39.0"
"version": "0.40.0"
}
Loading
Loading