Commit Graph
57 Commits
Author SHA1 Message Date
que01 c4bcbe8ff9 feat(junction): enable complex carriageway width editing 2026-09-08 12:09:44 +08:00
que01 0a5a229ce3 feat(junction): establish stable complex junction structure 2026-09-08 11:25:57 +08:00
que01 2b49a78b99 style(junction): fold facilities and clarify diagnostics 2026-09-07 18:02:34 +08:00
que01 92ab2edd96 feat(junction): add reference geometry comparison layer 2026-09-07 16:45:37 +08:00
que01 de6ef8e64b feat(junction): add stage2 object selection scope controls 2026-09-07 15:23:03 +08:00
que01 fc7fe81eff feat(junction): expose stage1 structure and standards panel 2026-09-07 14:52:06 +08:00
que01 a359f88edc feat(junction): classify complex junction shapes 2026-09-07 10:52:12 +08:00
que01 38ea779d9b feat: add complex junction selection markers 2026-09-04 17:09:32 +08:00
que01 1f439d98de fix(workbench): show junction traffic signals 2026-09-04 14:23:27 +08:00
que01 f10a5da325 feat(workbench): stabilize junction tools workspace 2026-09-04 09:46:19 +08:00
que01 e6b822416d fix(workbench): keep map visible in junction tools 2026-09-03 14:04:13 +08:00
que01 c9d9e45f48 fix(workbench): clarify junction browse mode 2026-09-03 13:54:26 +08:00
que01 3811790dc8 fix(workbench): persist junction workspace edits 2026-09-03 12:39:01 +08:00
que01 b7d9a1973e test(workbench): cover junction workspace deep links 2026-09-03 12:35:45 +08:00
que01 ecfa391eea feat(workbench): summarize junction facilities and diagnostics 2026-09-03 12:07:50 +08:00
que01 60e28f6b7a feat(workbench): expose junction geometry parameters 2026-09-03 12:02:16 +08:00
que01 4b38ce3c31 fix(workbench): require explicit junction draft exit 2026-09-03 11:28:49 +08:00
que01 2504e8342f feat(workbench): add junction tools workspace shell 2026-09-03 11:20:37 +08:00
que01 7d9b0f46d4 feat(workbench): add junction hotspot entry points 2026-09-03 11:12:22 +08:00
que01 fcb07b8396 test(workbench): add browser regression coverage 2026-09-02 17:39:25 +08:00
que01 2fb9db65e5 test(workbench): lock cross-domain edit history 2026-09-02 16:57:36 +08:00
que01 bb6c51c489 fix(workbench): preserve cross-domain undo order 2026-09-02 16:41:12 +08:00
que01 31552a5b6f feat(workbench): drag control markings as elements 2026-09-02 16:04:38 +08:00
que01 834470cfa1 refactor(workbench): split editor state and components 2026-09-02 15:04:58 +08:00
que01 caa3cb843f feat(workbench): add traffic signal rotation handle 2026-09-02 11:38:30 +08:00
que01 9b7c3d59bd feat(workbench): stage traffic signal edits 2026-09-02 09:30:03 +08:00
que01 9c83392b97 feat(workbench): drag traffic signal assemblies 2026-09-02 09:05:56 +08:00
que01 cf5bc0602b feat(workbench): improve traffic signal editing 2026-09-02 09:04:56 +08:00
que01 00d5f7650f refactor(workbench): use persistent mode switch 2026-09-01 17:20:16 +08:00
que01 c804a373ca feat(workbench): unify lane maneuver edits in v2 2026-09-01 16:46:22 +08:00
que01 118dc8e9aa fix(workbench): preview lane arrow drag 2026-09-01 15:04:11 +08:00
que01 fe73d993a9 fix(workbench): preview staged lane arrow overrides 2026-09-01 14:46:22 +08:00
que01 bb108267e3 feat(workbench): organize map editing panels 2026-09-01 13:47:30 +08:00
que01 6d80597642 feat(workbench): preview and drag lane turn arrows 2026-09-01 11:47:35 +08:00
que01 9cb715a592 feat: drag lane turn arrows along their lanes 2026-09-01 10:24:59 +08:00
que01 3d135761e7 fix: outline selected turn arrows 2026-09-01 09:21:24 +08:00
que01 e48eb15827 feat: edit lane turn arrows in workbench 2026-09-01 09:17:24 +08:00
que01andClaude Opus 5 f3924caa5c feat: make crosswalk size a constraint the geometry stage reads
Every zebra was six stripes at 3m by 0.45m on a 0.9m pitch, all literals. Depth
and stripe count are now a constraint, junction-crosswalk-size, and the loop
reads them.

The span across the road stays derived rather than stored: it is count times
pitch, and pitch is fixed because stripe and gap widths are standardised while
the road they cross is not. Widening a crossing means adding stripes, which is
what a real one does, and it is why the span quantises in 0.9m steps.

That also fixes a span pinned at 4.95m regardless of the street. Measured, every
crossing sat on a 6.50m carriageway and covered under four fifths of it. The
default now follows the segment width — both directions, since a crossing spans
the carriageway — giving eight stripes and 6.74m, reaching the kerb rather than
stopping short. Fixture baselines move for exactly two entries on the one area
with crossings; the area without them is untouched.

No handle is published yet. design.md requires proving compileGeometry() consumes
a parameter before any grip is drawn — the rule left over from profile.interval
shipping a handle that did nothing — so the grips come next, on a value already
known to work.

Adding the kind made the client's exhaustive scalar switch fail to compile, which
is the check working: size is a pair and has no dragged-scalar form, so that case
now says so and throws rather than writing half a value.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 17:10:45 +08:00
que01andClaude Opus 5 84c82f3f09 feat: select and drag stop lines the same way as crosswalks
Element identity moves behind a provenance-keyed registry, and stop lines join
as its second entry. Selection, the dashed box and the drag all work unchanged —
the registry supplies the group key, the layer the members live in, and the
constraint that moves them.

Stop lines are the useful second case rather than an easy one. They are a group
of one where a crosswalk is six, so adding them proves the grouping does not
quietly depend on there being parts; and they share crossing_node_id with the
zebra they protect on all eight measured groups, so provenance has to pick the
type before the key is ever read. A test holds both.

The registry promises only what the measurements support: provenance picks the
type, then a key picks the group. Arrows are deliberately absent — their group
keys are two-field and derived, group sizes run to 230, and neither has a
constraint kind the geometry stage reads.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 15:36:33 +08:00
que01andClaude Opus 5 8a039f47ab fix: keep the selection box on the crosswalk it is drawn around
The box measured state.layers, which is the last compiled output and does not
change while editing. The zebra is drawn from the preview, so it slid out from
under its own box on every drag and only caught up after a recompile.

Reading the preview when one exists puts them back on the same geometry. A null
preview layer already means "back to baseline", which is what the fallback says.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 14:22:28 +08:00
que01andClaude Opus 5 7b5bb753a7 feat: drag the crosswalk itself, not a dot beside it
A dashed box now hugs the selected group and is the thing you grab. It is
oriented along the crossing rather than along latitude and longitude: measured
groups run at azimuths from 14 to 105 degrees, so an axis-aligned box would sit
visibly askew and read as a bug. Extents come out at 3.00m by 4.94m on every
group, matching the compiler's literals.

The box carries the handleId of the control that moves it rather than an id of
its own, so grabbing it runs the existing value gesture — no second drag branch,
no second constraint, and the dot still works where the two overlap.

Resolving that control needs more than the segment: 15 of 23 segments carry two
crosswalk-inset handles, one per junction, and one segment carries two groups.
The junction is the road's last source node, which is the rule
crossingJunctionInset() already applies rather than a guess, and it resolves 8/8
groups uniquely — the two-group segment included, told apart by direction.

Also stops a gesture that never moved from becoming an edit. handleUpEvent
always reports a final value, so a tap committed a constraint equal to the one
already there. The box is a large target, which turns that from a curiosity into
something a user would hit routinely.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 14:06:51 +08:00
que01andClaude Opus 5 2694cad619 feat: select a crosswalk group by clicking any of its stripes
A crosswalk renders as six stripe features but is edited as one thing. Clicking
one now resolves the whole group, and clicking anything else drops the selection
so a box cannot outlive what it was drawn around.

The group id needed no compiler change: crosswalk:node/<crossingId> is already
stable, because compileControlMarkings() emits exactly one group per crossing
from a single candidate road. Verified against real output — 48 stripes, 8
groups of 6, nothing ungrouped, and none of the 8 stop lines mistaken for one,
since both share controlFeature() and are told apart by provenance. Grouping
therefore reads a published identifier rather than clustering on proximity,
which prd.md forbids.

Two supporting fixes in MapCanvas: the select callbacks join the existing
callback ref, and an empty click now reports background instead of returning
early. The listener is registered once, so it had been holding the first
render's closures — harmless while they only called stable setters, and not
survivable now that one of them reads current layers.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 13:35:59 +08:00
que01andClaude Opus 5 1c27501534 feat: edit road parameters by number as well as by drag
The map had one input device. A drag projects a pointer onto the manifest's
axis; there was no way to state a value, read one, or withdraw one.

Both channels now meet at the same three exits in App.tsx — draftValue()
previews, settleValue() commits one undoable command, abandonGesture() puts the
settled state back — so nothing about the constraint, the debounce or the
previewSeq arbitration is implemented twice. EditSession is untouched: focus and
blur land on the gesture boundary that pointerdown and pointerup already used,
which is why typing 1.53 is one undo step rather than four.

Three rules the two devices do not share:

- Live drag values bypass React and write the input's value directly, per
  direct-edit-client.md §7. A layout effect re-applies them after a mid-drag
  preview replaces the manifest, and drops the override once the manifest
  reports the value the drag asked for.
- Typed values out of range are refused, not clamped. A pointer cannot state an
  intent it never reached, so a drag clamps; typed text is an intent, and a
  clamped typo reads as a plausible value that can go unnoticed. The offered
  extremes round inward — a real max of 2.925 renders as 2.93 under
  nearest-rounding, which the range it came from would then reject.
- Reset disables the constraint rather than deleting it: validateEditDocument()
  rejects an operation naming a constraint that is not in the document. This is
  the one edit a drag cannot express, since a drag can set a value but never
  withdraw one.

Interval editing stays behind intervalEditingSupported, which is still false —
compileGeometry() does not read profile.interval, and a control that changes
nothing is worse than no control. The conversions are implemented and tested so
the row appears when the flag flips.

Probing a live manifest turned up a defect that is not from this change and is
not fixed here: an edge offset advertises ±2.925 while the solver rejects past
about ±1. Evidence is in the task's research/, and the requirement moved to
08-31-constraint-range-validation.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 11:58:00 +08:00
que01 11f4d748a7 fix: expose and apply control marking handles 2026-08-28 17:45:03 +08:00
que01andClaude Opus 5 7c45c21f8c feat: drag crosswalk and stop-line offsets on the map
Handles for the two control-marking kinds, completing what step 1 made solvable.
They drag along the approach tangent and reuse the whole existing chain — hit
test, projection, clamp, ghost, debounce, arbitration, preview, save, undo —
without changes to any of it. That reuse is the point of having modelled edits as
kind + anchor + axis + value.

Ownership: design.md gives junction reserve interiors to JunctionTools, but that
rule is about junction *shape* — width, cutback, corner. Placement of the zebra
and the stop line is offered nowhere else, so the main map takes it. A segment
selection therefore returns its cross-section handles plus the control markings
at its ends, and shape kinds stay out so the two editors never offer the same
edit. The test that asserted "road kinds only" now states this rule instead.

The default placements move to the solver, which owns the editable bounds and is
the module a test keeps free of fs/path; native-road.js imports them rather than
the reverse, so the IO-free property survives.

Deliberately not done: the handle-target generalisation this task's PRD listed as
step 2. These kinds persist exactly like the existing junction constraints, so
there is no second write target to abstract over yet. Building the discriminator
now would be designing for one hypothetical case; the signal pose work will
provide the real second case.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-28 16:58:31 +08:00
que01andClaude Opus 5 5292c00926 feat: scope the handle manifest and re-aim the ghost
Two consequences of the preview dropping from ~1535 ms to ~142 ms.

The manifest is now scoped to the object being edited. It was 844 KB on a
41-road workspace — 239 handles, 89% of the bytes being `affects` id lists at 46
ids per junction handle — shipped on every preview while the map rendered six.
A segment selection returns 12.2 KB, a 69x reduction, and the cost no longer
multiplies with each handle kind we are about to add. Omitting the selection
keeps the full manifest for the compiler and existing callers, and the tests
assert that scoping is a filter of the full manifest rather than a second
derivation.

The ghost is re-aimed from "estimated geometry" to "what you asked for". Its
guide line existed to mark the origin through a long wait that no longer happens,
so it is gone; what remains is what the preview cannot say — the numeric delta
and whether the drag has hit its clamp. The translucent outline
research/joint-solver.md asked for is deliberately not built: drawing it
accurately means recomputing the road surface in the browser, which the design
forbids, and drawing it crudely would be wrong exactly at transitions, junction
boundaries and clamps. A preview that lies is worse than none.

`degraded` finally has a consumer. EditSession has tracked it since the session
work but nothing read it; a slow solve now dims the ghost in place with a pending
label instead of clearing it and letting the geometry flicker, as design.md
requires.

Selection also fixed a latent hazard: the manifest effect reloads on every
selection change, and it used to call session.load() each time, which would have
discarded unsaved edits the moment the user clicked another road. It now adopts a
document only when the compiled document actually changed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-28 12:26:15 +08:00
que01andClaude Opus 5 d94c546450 fix: recompile after saving direct edits
Saving wrote the v2 document but nothing else, and `/api/state` serves the
outputs of the last compile — so a refresh showed the pre-edit geometry and a
successful save was indistinguishable from a failed one. Reported as "saved,
refreshed, edit gone"; the document on disk was in fact correct, resolving as
`exact` with the constraint reaching the profile.

Save now recompiles and clears the preview overlay, since the baseline carries
the edit afterwards and would otherwise draw it twice. The recompile is reported
separately from the save: if it fails the message says the edit was saved and
names the compile error, rather than claiming the save failed.

The existing identity test could not have caught this. An ignored `editsFile`
and an empty document produce the same output, so it proved nothing about a
non-empty one. The API test now compiles with and without a saved constraint and
asserts the outputs differ.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-28 09:25:09 +08:00
que01andClaude Opus 5 38593f6f67 feat: save, undo and redo direct edits
Step 5 of the map editor. EditSession becomes the single owner of the constraint
set, replacing the pair of refs step 4 kept alongside it: it now holds the saved
operations too, and `fragment()` assembles the constraints plus every operation
they reference — the shape both preview and save send. That removes the class of
bug that produced the earlier 400, because callers can no longer ship a
constraint whose provenance points at nothing.

Save goes through `expectedDocumentVersion`. A 409 adopts the server's version so
the next attempt is checked against reality, and says which version won instead
of failing silently. Undo of a saved gesture appends an inverse operation rather
than rewriting persisted history; undo of an unsaved one just moves the cursor.
Discard drops unsaved commands, cancels anything in flight, and returns the map
to the baseline.

One gesture mints one operation id, released on pointerup. Reusing an id across
gestures put two operations with the same id in the document, which
validateEditDocument() rejects.

The API test now covers the payload the client actually sends — `constraints` +
`operations` merged into the active document, rather than a whole document — and
asserts that a save survives a reload as `exact`. Sending constraints without
their operations is asserted to be rejected rather than written.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-27 18:11:52 +08:00
que01andClaude Opus 5 92297270f1 feat: drag road handles with ghost and server preview
Three things, kept in one commit because they touch overlapping hunks of the
same two files and this environment has no interactive hunk staging. Splitting
them by file would have drawn boundaries that misrepresent what changed.

1. Step 4 of the map editor. A native OpenLayers PointerInteraction turns a
   drag into a clamped constraint value, the ghost source shows it immediately,
   and the solver's answer replaces a parallel set of preview layers while the
   baseline layers are hidden rather than overwritten. Preview requests debounce
   at 80 ms, pointerup flushes without waiting, and a newer request aborts the
   one in flight; EditSession decides which answers count. Handle positions come
   from the clamped value, so a handle stops at its limit instead of following
   the cursor. Three of the four drag capabilities are live: edge offset,
   sidewalk width, lane divider.

2. Road edge handles were drawn on the wrong side. offsetLine() offsets
   counter-clockwise from the direction of travel and sidewalks use
   `heading + (side === 'left' ? -90 : 90)`, so left is `tangent - 90`;
   makeRoadHandles() placed the left handle at `tangent + 90`, over the right
   kerb. Dragging the visually-left handle moved the right edge. Fixed on both
   sides of the wire, with regression tests that name the sides geographically
   rather than by axis sign.

3. Roads the junctions geometrically fill are now read-only. The 0.45 cap per
   reserve made the existing `unavailable` branch unreachable, so a 14.5 m stub
   between two junctions was offered a 1.5 m editable band with no room for the
   transitions a road-interval constraint needs. Greying only affects the
   manifest: constraints already saved against such a road keep being solved, so
   the geometry output is unchanged and the fixture baselines do not move.

Range handles are built and unit-tested but hidden behind
`intervalEditingSupported`: compileGeometry() reads neither profile.interval nor
profile.transitions, so every edit applies to the whole road and the control
would have had no effect. Recorded in research/interval-not-applied.md, which
also blocks one PRD acceptance criterion.

The ol-ext probe stays in the tree as a manual harness; ol-ext is still not a
dependency.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-27 17:38:34 +08:00
que01andClaude Opus 5 bc4b9a9717 feat: add direct edit handles behind directEdit flag
Steps 1-3 of the main map road interval editor.

EditSession keeps the command stack, undo/redo and previewSeq arbitration as
pure logic with no OpenLayers reference, so all of it is unit-tested in node.
Pointer displacement converts to meters through EPSG:4326 and spherical
distance: treating a 3857 delta as meters desyncs the geometry from the cursor
by 1/cos(latitude). Handle drags project onto the axis the manifest declares
and clamp to its range, so the client never writes a coordinate into a road
polygon.

All of it sits behind a directEdit flag that defaults to off. With the flag off
the workbench requests no manifest, creates no extra source and registers no
interaction, so behaviour matches main.

The ol-ext probe passed its three gates but is not adopted for road handles.
Transform translates by the raw pointer delta, so a handle detaches from its
clamped constraint value: a drag reading -24.1 m produced a draft of -5.4 m.
Production needs the handle position derived from the constraint instead, which
means owning the position update, so native OL PointerInteraction will carry
the drag. ol-ext stays out of package.json; the probe is kept as a manual
harness. Reserve handles are unreachable with the current solver, recorded in
research/ rather than worked around.

Also names the dead backend when an API response is empty, instead of
surfacing "Unexpected end of JSON input" from response.json().

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-27 14:59:11 +08:00