A position is a place, not just a number (#1421) #1422
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!1422
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/layout-position-world"
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?
Closes #1421.
Two doors set a device's position —
POST /layoutandfromJSON()— and both asked for two finite numbers, with the endpoint keeping its own copy of that sentence inline while the engine askedisPosition(). Both accepted1e308, which is finite and is not a place:The rule, in one place
engine/topology.js:WORLD_LIMIT = 1e6pixels from the origin (a person drags across a canvas; the largest lab the catalogue builds spans tens of thousands),isPosition(p)for the verdict,positionProblem(p)for the words — so a refusal and the rule cannot disagree.POST /layout,1e308200, stored400 E_BAD_POSITION, reason names the limit, nothing storedPOST /layout,positions: [..]/"abc"/{}200 {"ok":true}, nothing happened400, says what a map of positions isPOST /layout, unknown device id200 { ignored: ["ghost"] }/load,1e308E_LAYOUT_BAD_ENTRYnames the limit, board still opensfitView(), out-of-world positiontranslate(-1e+308), blankThe canvas guard is deliberately expressed as "framing the board has to show the board" — the centre of what was measured must land in the viewport — rather than as a copy of
WORLD_LIMIT, because a second copy of the number is the thing this PR is about.Evidence
test/layout-positions.test.js, 18 checks:±1e308, strings, nulls, half a position, arrays, scalars) driven through both doors and required to answer identically, with a refusal that names which of the two things is wrong and changes nothing;positionsshapes and theignoredlist;web/canvas.jsin a stub DOM: a board spanning the whole world frames at a real scale with its centre near the viewport; a board holding1e308opens at the default view instead of blank; an empty board and an ordinary board are unchanged.Reverts: engine bound → 4/18 fail; endpoint's own copy restored → 1/18; canvas guard removed → 1/18, quoting
{"panX":-1e+308,"panY":-1e+308,"zoom":1}.Suite: 211 suites, 8,064 assertions, 0 failed; syntax 279 files OK. Docs:
docs/ARCHITECTURE.md, "A position is a place, not just a number".Two doors set a device position: POST /layout (the drag, and the tidy-up button) and fromJSON(). Both asked for two finite numbers, and the endpoint kept its own copy of that sentence inline while the engine asked isPosition() - the same one-rule-two-implementations shape that has drifted six times here. Both accepted 1e308. That is a finite number and not a place: fitView() takes the board width as the largest x minus the smallest, which is Infinity for two such positions, zoom clamps to its 0.25 floor, translate() is handed -1e308, and the canvas draws nothing. 'Fit to view' computes the same arithmetic, so the board cannot be recovered from the UI. The lab is not lost; it cannot be seen, which for a person is the same thing. Fixed by making the rule one thing in one place: WORLD_LIMIT (1e6 pixels from the origin - generous, a person drags across a canvas and the largest lab the catalogue builds spans tens of thousands), isPosition() for the verdict, positionProblem() for the words. Both doors ask it. A bad entry is refused with E_BAD_POSITION and the reason and nothing is stored; on load the entry is dropped and reported as E_LAYOUT_BAD_ENTRY naming the limit, so the board still opens. A 'positions' that is not a map is 400 instead of 200 {ok:true} that changed nothing, and an id that is not on the board comes back in 'ignored' rather than in silence. web/canvas.js fitView() checks its own result: if the centre of what it measured does not land in the viewport, the framing failed and the default view is the honest answer - which covers documents written before the limit existed. Evidence: test/layout-positions.test.js, 18 checks. One table of 15 shapes through both doors, required to answer identically; then the real web/canvas.js in a stub DOM, asserting the property the limit exists for - every position the doors accept is one fitView() can frame. Reverting the engine bound fails 4/18; the endpoint's own copy fails 1/18; the canvas guard fails 1/18 with panX=-1e+308 quoted. Suite: 211 suites, 8,064 assertions, 0 failed; syntax 279 files OK.