All seven criteria pass against a live area. Notes what a UI would need first:
turn arrows group by lane plus maneuver, a two-field key, where crosswalks and
stop lines group by a single property — so the element registry's groupProperty
has to become composable before arrows can join it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The arrow on a lane came from the OSM turn:lanes tag with no way to change it,
and a lane the tag skipped got no arrow at all. lane-maneuver is a v1 override
that sets it.
v1 rather than a v2 constraint, because "which arrow" is a discrete attribute of
a lane with no station to anchor to, while every v2 anchor is positional. The
existing road override already covers OSM-derived values this way — laneCount,
width, sidewalks — and this is the same kind of thing. Arrow *placement* is the
positional half and stays out; it also still has an open question about whether
a group is a lane or a single arrow.
Three behaviours, each measured against compiled output: an override replaces
the tag's maneuver, it adds arrows to a lane the tag never marked, and '' removes
one the tag asked for. The empty string is therefore distinguished from "no
override" rather than falling through to the tag. An empty override set leaves
the arrows byte-identical and the fixtures untouched.
Validation lists the accepted maneuvers and rejects anything else, including
correctly-spelled components in the wrong order. It cannot be left to
normalizeManeuver(), which returns unrecognised input unchanged — a typo would
otherwise reach the template lookup and silently produce no arrow.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Steps 1, 2 and 4 are done and step 3 is parked with a reason: the client never
reads affects and no highlighting exists, so fixing it alone changes nothing a
user can see. It belongs with the highlight, as one piece of work.
Step 5 has a design question that should be settled before code. The size value
is a pair while the drag path is scalar end to end, so a corner grip moving one
component has to preserve the other or every drag resets the half it did not
touch. Three options noted, with the reason the tempting one — letting element
controls build their own value — is the wrong shape.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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>
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>
Measured the grouping of every marking layer. Stop lines are nearly free — same
feature builder, same key shape, an existing constraint kind, and a sweep shows
the offset tracks one-to-one across its whole range with no dead zone. Arrows
are not: neither kind exists and neither is read by the geometry stage.
The trap is that crosswalks and stop lines share crossing_node_id on all eight
groups, so grouping has to branch on provenance before touching the key or the
two merge into one element. That is already how element.ts works and a test
holds it.
What the data earns is a provenance-keyed registry and nothing more: group keys
are single-field, two-field and derived; group sizes run 1 to 230; two element
types have no constraint at all. A universal element protocol would be inventing
past the evidence, which the PRD rules out.
Also records delivery state — steps 1 and 2 done, 3 through 5 not started — so
the task is not mistaken for complete.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The directional-road trap cost two rounds in one session — once on the client,
once in the solver — and both times produced a plausible number attached to the
wrong object, which nothing but a segment with two of the thing will catch.
Also tabulates what measuring three handle ranges turned up: one rejects past a
third of its declared span, one goes silently inert over most of it, and one
would happily place a stop line 126m from the junction it protects. Each was
derived independently, and each was wrong in its own direction.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The silently-inert case is fixed for crosswalk inset, so this task is down to
the edge-offset case and the missing server-side check. Records the reusable
shape — ceilings derived from geometry rather than declared as constants — and
the trap that cost a round: two directional roads of one segment can meet at a
junction serving different objects, so taking the first match publishes one
road's bound on the other's handle.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Every junction-crosswalk-inset handle advertised max 8. Sweeping the real
response across eight groups, the ceiling ran 1.0 to 4.5 and varied per
approach, so 44-88% of the declared range moved nothing and returned no
diagnostic. Two approaches had a ceiling at or below the 1.5 default, meaning
dragging outward there did nothing at all — which is what made direct editing
look broken rather than limited.
crossingJunctionInset() stops responding once the inset reaches the cutback, and
sooner still when the crossing sits beyond the 4m cap, giving
cutback - max(0, junctionDistance - 4). Predicted ceilings matched all eight
measurements within the 0.5m sweep step, and the published max now matches them
8/8 where it used to be a flat 8.
The distance needs to know which crossing an approach serves, which lived only
inside compileControlMarkings(). crossing-approach.js now holds that rule at road
level, which is model-only and so usable from the solver. Behaviour is
unchanged: every lane of a road shares its junction distance, so the compiler's
(road, lane) ordering already grouped by road — fixtures confirm the geometry is
byte-identical.
Both directional roads of a segment can meet at one junction serving different
crossings; taking the first match published one road's ceiling on the other's
handle. The road that ends at this node wins, which is the same rule the client
uses to find the handle and the same one crossingJunctionInset() applies.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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>
Sweeping the declared [0, 8] range and measuring where the group actually lands:
0 to 3.2 tracks one-to-one, and 3.2 to 8 does not move at all. No diagnostic, no
feedback — roughly 60% of the advertised range is inert.
crossingJunctionInset() drives it. targetDistance bottoms out once inset reaches
the approach's cutback, and a 4m cap sits above that, so the real ceiling varies
per approach while the manifest publishes a flat 8 for all of them.
This is worse than the edge-offset case already on file. That one refuses and
says so; this one silently does nothing, which is indistinguishable from a broken
control — the exact failure the interval flag exists to prevent, occurring in the
upper half of a range rather than across a whole handle. A user whose first drag
lands in the dead zone concludes direct editing does not work.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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>
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>
Measured rather than assumed: grouping the 48 stripes by crossing_node_id yields
exactly 8 groups of 6, and no crossing maps to more than one road. The uniqueness
is structural — compileControlMarkings() iterates model.crossings and each pass
emits one group from one candidate — so crosswalk:node/<crossingId> is already a
stable group id and needs no compiler change.
The earlier claim that no group id existed conflated the crossing node
(node/-26452, the pedestrian crossing) with the junction node (node/1140799725).
Different ids. Grouping client-side therefore reads a published identifier rather
than clustering by proximity, which is what the PRD forbids.
The missing affects entries are real and unchanged, but they only degrade
drag highlighting; they do not block selection. The two are now separate steps,
and selection moves first because it costs nothing on the server.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Three symptoms turned out to be one hole. junctionAffects() builds
junctionSurface + roadAffects + connectors and never adds crosswalks, so on an
area with 48 of them the crosswalk-inset handle reports 59 affected features and
zero crosswalks. The cause is that stripe ids key off the crossing node while the
solver has no approach-to-group mapping — which is also why there is no stable
elementId and why clicking a stripe cannot select the group. Publishing that
mapping resolves all three, so it is now the first gate rather than three
separate steps.
Corner resize moves into the first phase by decision; rotation is deferred, since
it needs a new constraint kind and the compiler has to consume it before any grip
may be drawn.
Sizing semantics are settled: stripe depth is a stored number, but span is
count x pitch, so the corner drag varies the count at a fixed 0.9m pitch and
therefore quantises. That is honest rather than janky and the UI has to read as
deliberate snapping. It also fixes span being pinned at 5.4m regardless of road
width, which will move fixture baselines.
Records the data prerequisite: crossing nodes are required, and the current
import had none, which is what made the handle look broken.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Four things the parameter panel settled that the next input channel should not
have to rediscover: where the channels meet, why a drag clamps while a field
refuses, why a focused field owns its own text, and why reset disables rather
than deletes.
The clamp/refuse split is the one most likely to be reported as an
inconsistency. It is one invariant with two honest expressions — a pointer
cannot state an intent it never reached, so it stops; typed text is an intent,
so rewriting it hides a typo behind a plausible number.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A four-arm junction already carries 20 handles across 4 segments, and the main
map shows only the selected segment's — so seeing one junction whole takes four
selections. That is why element-level selection is a prerequisite for complex
junction work rather than a refinement of it.
The experiment stays crosswalk-only by decision, to keep the risk small. What
that costs is now written down: a crosswalk moves but does not reshape the
junction, so passing this proves the select-and-position path and nothing about
approach width, cutback or corner radius, which change the junction polygon
itself and have to be validated separately.
Also records that the parameter form half already exists, so the element
controls join the existing exits instead of growing a second preview or undo
path.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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>
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>
Step 1 of the control-marking task, and deliberately server-only: no handle is
drawn yet. This project already shipped a range handle for `profile.interval`,
which compileGeometry ignores, so the control dragged and changed nothing. The
consumer comes first now.
Two kinds join the taxonomy — `junction-crosswalk-inset` and
`junction-stop-line-offset`, both on the existing `junction-approach` anchor. The
solver writes them onto the approach entry, `applyDirectJunctionPlans` carries
them onto the compiled approach, and `compileControlMarkings` reads them in place
of the module constants it used for every junction. They move markings without
reshaping the junction, so unlike width and cutback they deliberately do not
trigger a boundary recompute.
`applyJunctionConstraint` becomes an explicit switch. Its trailing `else` had
meant every kind that was not approach-width fell through to the cutback
validator, so a new kind would have been silently validated and written as a
cutback. The same non-exhaustive shape in the test fixture's `valueFor` is fixed
the same way, and now throws for an unnamed kind rather than answering with a
corner radius.
design.md's taxonomy is updated with it — a test asserts the two cannot drift,
which is what caught the omission.
Measured on a 41-road workspace with 8 crossings: both constraints change their
marking geometry, neither drags the other, and out-of-range blocks instead of
clamping. That measurement is not in the suite: the synthetic junction resolves
`junction_inset_m` to 0 because its crossing never binds to a plan, and the
committed OSM fixture has no crossings at all. The tests assert the wiring the
handles will depend on — values reaching the approach entry, distinct branches,
blocking diagnostics — and the gap is recorded in the test itself.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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>
compileGeometry took 1575 ms on a 41-road area and grew superlinearly — 6x the
time for 2x the roads — while feature count grew linearly. Profiling put 84% of
it in three adjacent lines: `bounds` alone was 821 ms, `ringsOverlap` 258 ms, and
the intermediate arrays cost another 163 ms of GC.
The callers walk every lane in 0.25 m steps and test each step's rectangle
against every control feature, which is millions of calls on a small area. Each
one recomputed the control's bounding box from scratch through four
`Math.min(...ring.map(...))` spreads, allocating four arrays per call for a box
that never changes.
Control rings are the same array objects for the whole compile, so their bounds
are now computed once into a WeakMap, candidate bounds are taken in a single
allocation-free pass, and the cheap rejection moved up into `ringsOverlapControl`
so the exact test only runs for boxes that actually touch.
1575 ms -> 104 ms, and the per-road cost is flat instead of rising, so this now
extends to city-scale areas rather than degrading quadratically. Output is
unchanged, which the fixture baselines prove.
Found because a preview felt slow to drag. The measurement mattered more than the
reading did: the nested `model.roads.find()` calls that looked like the culprit
were not, and building the scoped-compile architecture first would have left this
untouched.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Three of this task's defects were cross-layer wiring rather than logic, so they
belong in the spec where the next session will read them, not only in the task's
research notes.
Frontend: a new client spec covering layer ownership (baseline is never written,
preview hides rather than overwrites), why a handle carries only its id, why a
handle's position must derive from the clamped value, the ban on computing inside
a setState updater, and why per-pointermove React state is the wrong owner of
per-frame feedback.
Backend: the left/right convention now states the three places that must agree
and why a sign convention can be wrong on both sides of the wire at once; a table
of the four profile fields the geometry stage actually reads, so nobody builds UI
for interval-scoped editing again before the compiler honours it; and the
save-is-not-applying contract, including that compileFresh must be installed by
every path that sets session.area.
Also records that an identity test cannot catch an ignored editsFile, and that a
regression test is only trustworthy once it has been seen to fail.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`/api/import` set `session.area` but never `session.context.compileFresh`, which
is only wired when the server starts with an area on the command line. Every
session imported through the browser therefore answered "请先导入 OSM 文件" to
`/api/compile`, even though the import had just succeeded.
This predates direct editing — it broke "保存并重新生成" for UI-imported
workspaces — but it surfaced now, because saving a direct edit recompiles and so
reported a failed regeneration after a save that had in fact succeeded.
Covered by a new HTTP-level test: import the fixture, then recompile twice. The
bug lived in the wiring between two handlers rather than in either one, so
nothing below the HTTP boundary could catch it. Verified by reverting the fix and
watching the test fail.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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>