The layout is copied, belongs to its device, and is two finite numbers (#1325) #1326
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge!1326
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/layout-honesty"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The layout is copied, belongs to its device, and is two finite numbers.
Fixes #1325.
The third thing a board holds, after devices (#1321) and cables (#1323). Where each box sits was the least guarded of
the three.
Measured before
Why each is a defect and not a taste
layoutwas still handing out itsown object.
removeDevice()left the position. The server remembereddelete topo.layout[devId]; the engine did not. Aremoval from anywhere else left a box in the file that is not on the board.
web/canvas.jsreadspos.xstraight from the layout, so{"x": "left"}gives NaNcoordinates and the box is drawn nowhere with nothing to explain it.
layout: []is worse — accepted, kept, thenlost at the next save.
0is a coordinate.{ x: body.x || 160 }treats zero as missing, so a device placed at the origin is quietlymoved to 160,160.
/layoutstored whatever it was handed, unvalidated.Fixes
serialize()copies the layout;removeDevice()takes the position with the device;fromJSONvalidates every entry(
E_LAYOUT_BAD_ENTRY,E_LAYOUT_MALFORMED,E_LAYOUT_UNKNOWN_DEVICE— throughloadIssues, which every payloadalready carries); the API checks every position before storing any, so a bad entry cannot half-apply a layout, and
answers
400naming the rule; and0places a device at0.Evidence
test/layout-roundtrip.test.js— 20 checks: a fractional negative position and the origin both survive a reload;the handed-out document can be changed without moving the board; removing a device removes its position from memory,
from the saved document and from the reload; six impossible layouts are each reported with the right code and none
becomes a position the canvas will draw, while a good position beside a bad one survives; over HTTP a device placed at
0,0is at0,0, a string coordinate is a400with the board unmoved, a real position applies, and deleting thedevice takes its position out of the state.
With
engine/topology.jsandserver/index.jsreverted, 12 of the 20 fail.docs/ARCHITECTURE.md: "Where the boxes are".Suite: 178 suites, 7,043 assertions, 0 failed.