Skip to content

Separate layout coordination from connector routing - #29

Open
mepcotterell wants to merge 9 commits into
mainfrom
mepcotterell/layout-coordinator
Open

mepcotterell wants to merge 9 commits into
mainfrom
mepcotterell/layout-coordinator

Conversation

@mepcotterell

@mepcotterell mepcotterell commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Layout repair previously changed DOM geometry inside route orchestration. This gives a per-visualizer coordinator ownership of sizing, movement, bounded repair, canvas allocation, rollback, and final paint, while path selection consumes measured data.

supplied trace sequence + settings
  → independent stack/global and heap models
  → coordinator prepares and measures geometry
  → router returns complete plan or typed constraint
  → coordinator repairs/re-measures within bounds, then paints

The initial models retain the legacy placement policies. Independent strategy seams accommodate future frame-order and trace-based heap planning; this PR does not enable global rearrangement. The extracted orientation-aware search preserves production weights/caps and gains an independent, bounded Dijkstra comparison oracle on the same graph and cost. Its exactness excludes endpoint stub turns, terminal stubs, heads, and rounding.

Prerequisite for issue #27 and PR #28. PR #28 targets this branch and includes its head as an ancestor. The algorithm inventory, two-cycle research report, interface comparison, glossary, and ADR explain algorithms, guarantees, DP/cache conditions, and future contracts.

Evidence

  • Before: routing owned resizing/movement and retry sequencing; entering frames could reuse DOM IDs; final Java intrinsic content could change after route measurement.

  • After: measured-scene routing, coordinator-owned effects/cleanup, independent production region models, unique frame IDs, intrinsic content before measurement, passive navigation regression checks, and one initial configured-state materialization. Ordinary filter setters remain synchronous, including the initial height callback; its regression was demonstrated RED and fixed.

  • Current pushed head: 9b9eebe4b61ac9df5b8b276b3a5f53b635d370d4. Runtime evidence binds clean 7271983ec755166d51c8b95f1e591c5373517098; only two research-note wording corrections follow. No runtime, input, test, or bundle bytes changed. Markdown/link checks passed after the corrections.

  • make check: 686 Python tests / 100% coverage / 2,091 statements, 300 frontend tests / 21 files, lint/types/docs. JDK 25 examples: 34 examples / 415 images. Focused native/navigation/cropping/frame-parent suite: 9 passed. Independent static reviews have no remaining actionable findings in their frozen scopes.

  • 12 native PNG/SVG pairs plus 12 reopened SVG rasters pass dimensions, four-sided ≥4 px padding, and first/restored PNG and SVG-route checks. All 12 descriptions match the supplied baseline; none of the PNG pixels or SVG route records is identical. Eleven dimensions match; self-loop is 1 px narrower. The frame fixture uses supplied synthetic helper frames. Native differences remain review evidence, without inferred approval or tracer semantics.

  • The 11-case main comparison retains six fresh layouts, five warmups, and 40 repaints/redraws. Dense-48 fresh maximum is 226.5 → 222.8 ms, full-redraw p95 14.0 → 15.8 ms; representative final redraw p95 ≤1.3 ms. This is not the independent/shared acceptance protocol or a general speedup claim.

  • Runtime-head CI passed JDK 21/25, builds, wheel checks, examples and native capture. Its review artifact records the CI merge ref separately. Final-head CI also passed JDK 21/25, builds, wheel checks, examples and capture. Its current review artifact has all seven checks true and all 74 input hashes matching current files.

  • Combined PR Add controlled shared-reference routing #28 runtime head c688db7 passes 367 frontend tests and CI's 693 Python tests / 100% coverage, plus examples and both native packages. All 28 controlled baselines pass, but both stress cases still fail 300 ms under both policies. Criteria 19, 20, and 22 remain open; historical routing stays default. See the detailed step-5 record for all 14 cases, six fresh samples for every gated case, provenance, and remaining limits.

  • Step 1 — algorithm audit

  • Step 2 — literature research

  • Step 3 — interface comparison and design

  • Step 4 — implementation

  • Step 5 — native/navigation/performance and dependent integration verification

Merge Danger

Door: two-way

Legacy placement and routing policies remain in force, with measured output differences from correctness fixes and materialization ordering. Global rearrangement, default sharing enablement, main merge, release, and issue closure are outside this delivery.

Blast Radius: rendering

Stack/heap placement, geometry measurement, bounded repairs, routing lifecycle, navigation, and native exports are affected. The exact oracle verifies the supplied graph objective; it does not prove optimal painted drawings or optimal execution sequences.

@mepcotterell

Copy link
Copy Markdown
Contributor Author

This work now depends on PR #29 — Separate layout coordination from connector routing: #29.

PR #29 starts from main and owns the approved five-step algorithm audit, literature research, interface comparison, bounded coordinator implementation, and verification. PR #28 is stacked on its branch, mepcotterell/layout-coordinator. Issue #27 remains blocked by both prerequisite coordination and the shared-routing acceptance work.

Existing source-to-object semantics, the 300 ms stress limits, native visual review, and historical production default remain in force. Coordinator extraction alone does not establish a performance improvement or close acceptance criteria 19, 20, or 22.

GitHub's native issue-dependency API rejected a pull request as a dependency target (422: Target issue may only be an issue); PR #28 also cannot be a source issue for that API. The relationship is recorded through the PR base, explicit body links, and these reciprocal conversation references. No native issue-dependency record is claimed.

After each of the five plan steps, PR #29 will receive a completion comment with results, decisions, verification limits, and records carried forward.

@mepcotterell

Copy link
Copy Markdown
Contributor Author

Step 1 completed — current algorithm audit

The source inventory distinguishes immutable main baseline b6b2e2b9 from shared-routing comparison 971e893; controlled sharing is not treated as functionality already on main. The committed inventory records source locations, complexity inferences, assumptions, caches, repair ownership, and proposed regressions.

Important results carried into research and design:

  • Stack/global placement uses browser table/block layout and keyed frame ordering; Java reverses supplied stack order. There is no independent stack placement strategy yet.
  • Heap row membership is precomputed forward across the supplied trace using a reachability/order heuristic. Rendering, rightward nudges, content sizing, and saved drag offsets determine pixel geometry. Row continuity does not imply fixed coordinates.
  • Search already uses an orthogonal Cartesian grid and A* with initial/horizontal/vertical states, a turn penalty, a weighted heuristic for combined ports, deterministic tie rules, and work caps. These are not a proof of shortest accepted geometric routing.
  • Routing currently owns DOM repair and retries. Accepted routes are checked, but the current failure path does not guarantee complete rollback. The coordinator must make that ownership and transaction boundary explicit.
  • Some adapted frame keys contain method/line/depth information, so future temporal strategies cannot assume stable invocation lifetimes from every render key. Direct seeking, backwards navigation, cache validity, and canonical planning require explicit contracts.

This step was a static audit, not runtime or performance acceptance. Independently captured before-change evidence includes the unmodified main benchmark and 12 native SVG/PNG pairs, with verified dimensions and frame restoration. Those measurements do not substitute for PR #28's original controlled-policy stress protocol.

Next: finish literature synthesis, then compare independent coordinator interfaces under the approved bounded-repair scope and separate stack/heap model requirement. Existing <=300 ms stress limits, native review, and historical default remain unchanged.

Record: committed algorithm inventory. Source-link definitions and line ranges were checked; make lint-docs passed.

@mepcotterell

Copy link
Copy Markdown
Contributor Author

Step 2 completed — spatial and temporal research

The narrative research report and supporting notes are committed. The notes retain two complete research cycles per theme: orthogonal routing, spatial placement/mental-map stability, and temporal planning/DP. They include primary papers, APA references, search/evidence logs, assumptions, counterexamples, confidence, and access limits. The report distinguishes source observations, published guarantees, empirical workload results, and application deductions.

Important results and decisions carried into interface design:

  • Cartesian ruler intersections can be quadratic in input geometry despite constant-degree adjacency. The published 1-bend alternative reduces vertices but retains quadratic worst-case edges and trades construction cost against route-search cost; no speedup is assumed here.
  • Current orientation-aware weighted/capped A* does not establish shortest accepted geometric routing. An exact Dijkstra/admissible-A* comparison must use the same graph and explicit cost/endpoint model. Routing work bounds are not a wall-clock acceptance deadline.
  • Stack and heap models should be independent but coordinated through one measured geometry revision. Appending frames can preserve old frame coordinates under fixed sizing/origin assumptions; width, viewport, and occupancy changes can still affect either region.
  • Count, summed width, summed height, and area can peak at different heap states. Peak-set intersections are candidate anchors, not proof of continuous lifetime, stable sizes, valid old routes, or optimal placement.
  • A finite-candidate temporal DP can be exact only for its represented states/transitions and sufficient retained history. Locally optimal layouts need not form an optimal sequence. Memoization, canonical direct seeking/backward navigation, and temporal optimization are distinct contracts.
  • Future temporal matching cannot assume stable invocation identity from every current frame render key. Geometry, occupancy, policy, font/options, identity, and source/target exceptions belong in cache validity decisions.

The 2014 paper's accessible manuscript and publisher abstract use different canonicality wording; the report preserves that discrepancy and does not promote it into an application guarantee. Broader global rearrangement and new sparse/incremental algorithms remain separately measured proposals. The first coordinator implementation preserves current placement behavior and bounded repair policy.

This is research evidence, not runtime, pedagogy, or performance acceptance. All existing 300 ms stress gates, native review requirements, and historical default remain unchanged. make lint-docs passes for the committed report/notes and all repository Markdown/local links.

Next: compare the three independently designed interfaces and select the smallest interface that gives separate stack/heap ownership, typed routing outcomes, bounded repair/rollback, and deterministic trace-context handling.

Records: narrative research report, routing evidence and method, temporal/placement evidence and method.

@mepcotterell

Copy link
Copy Markdown
Contributor Author

Step 3 completed — independent interfaces and selected ownership

Three independent designs were compared: one-shot transaction, long-lived coordinator with independent region models, and compiled trace plans with measurement binding. The committed comparison presents signatures, caller examples, hidden responsibilities, trade-offs, and the chosen synthesis.

Decision: one per-visualizer, synchronous coordinator with independent stack/global and heap strategies; borrow transactional repair ownership and keep semantic trace context separate from measured geometry. The first adapters preserve existing placement and path policies and must be used by real rendering paths, not merely declared for future use.

The coordinator owns resizing/movement/canvas allocation, bounded retry accounting, remeasurement, reverse-order repair restoration, and final paint publication. Routing consumes a DOM-free measured scene and returns a full plan or typed constraint failure. Reservation-only retries remain distinct from layout repair. Immediate rollback restores the current state's intrinsic, sized, model-placed baseline and clears stale route paint; it does not rewind semantic navigation or promise a full previous-view transaction.

We rejected a mandatory asynchronous trace compiler/full semantic-DOM transaction for the initial extraction because it would change the public synchronous contract and expand scope. The supplied sequence, model versions, dimensions, and canonical context remain separate inputs so later append-frame, heap-peak, anchor, and finite-candidate DP experiments can be introduced deliberately. No navigation-seeded temporal cache or global optimum is implemented by this decision.

Domain terms are recorded in GLOSSARY.md; ADR 0001 records the ownership choice. The detailed comparison and research qualifications carry into implementation. The same-graph search/oracle seam is independent of the coordinator's interface and preserves graph construction, neighbor order, costs, heuristic weights, work caps, and production candidate policy.

make lint-docs passed. This is a design record; runtime/native/performance verification remains pending. Existing stress/redraw gates, historical default, and maintainer visual-review requirement remain in force.

Next: implement the selected boundaries and actual independent region-model call sites, then verify geometry/navigation, failure rollback, native exports, and the original performance protocol.

Records: interface comparison, ADR 0001, glossary.

@mepcotterell

Copy link
Copy Markdown
Contributor Author

Step 4 completed — production layout coordinator and region models

Implemented in e4843791a9321a99ea37f0d6e448bfa2328579ae. The per-visualizer coordinator now owns preparation, bounded movement/widening, leading/trailing canvas allocation, remeasurement, retry accounting, repair rollback, and final paint. Routing takes a DOM-free measured scene and returns a complete plan or typed constraint. DOM bindings stay in the measurement/paint adapter.

The independently replaceable stack/global and heap models are used by real rendering paths. Both receive supplied-sequence context and their own canonical predecessor; measured placement can see dimensions of both regions. The legacy adapters preserve Java ordering, heap row traversal/grouping, the executable 96px nudge, label/value sizing, and explicit drag restoration. This introduces no global rearrangement or new public factory policy.

Repairs are restored in reverse order, with original inline values and priorities. Failure clears stale paint and accepted-route reuse; rollback returns to the current step's sized, model-placed baseline, rather than rewinding semantic navigation. Accepted routes can be reused only when their complete routing dependencies and placement revision match; canvas allocation is independently revalidated. Reset and disposal release effects and retained plans.

The extracted orthogonal search preserves orientation states, neighbor/tie order, Manhattan plus 18-unit axis-change cost, weights, caps, and stale-pop accounting. An independent small Dijkstra oracle compares the same graph objective; terminal stubs/turns, signed directions, arrowheads and rounding remain outside that objective. Its exhaustive fixtures include 256 blocked-edge configurations. Weighted/bounded production routing gains no global optimality claim.

Runtime navigation exposed two issues now fixed: new frames could duplicate a surviving frame's DOM ID, and Java's final content-normalization hook ran after routing, leaving routes measured against String labels that were subsequently hidden. Frame IDs are unique while keyed nodes survive, and intrinsic-content hooks now finish inside the materialization batch before final measurement/paint. The native navigation test observes ordinary navigation passively, without an export-triggered redraw masking stale output.

Validation on the implemented sources: 296 frontend tests passed in 21 files; production build passed; 9 focused public native/navigation/cropping/frame-parent tests passed; Ruff, Python type checking and documentation checks passed. Independent static search and production reviews reported no actionable findings. Two evidence-review findings (active redraw during navigation observation and skipped failure artifacts) were corrected and re-reviewed. The final intrinsic-hook ordering change is also receiving a focused independent re-review.

The native review generator produces 12 PNG/SVG pairs, separately reopened SVG rasters, an offline gallery, and a provenance manifest. CI uploads it even when capture checks fail, and PR checks now cover stacked PRs as well as main-targeting PRs. The fixture is synthetic renderer evidence, not proof of tracer-generated calls. Source/bundle hashes do not by themselves prove a rebuild; the parent rebuilt the frozen implementation before these native tests.

Carry forward into step 5: run the complete coverage/check/example suite; capture clean-commit native before/after evidence; compare the unchanged main benchmark; integrate the coordinator into dependent PR #28 and retain its controlled-policy gates. The historical default, criterion 19 maintainer approval, original maximum-of-six ≤300ms stress limits, redraw limits, and default-enablement hold remain unchanged. No release, merge, issue closure, or maintainer approval is inferred.

Records: coordinator, region models, native review tool, implementation boundaries.

@mepcotterell

mepcotterell commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Step 5 — rendered/native, navigation, performance, and integration verification

The coordinator implementation and dependent integration are complete. Current pushed heads are 9b9eebe for this PR and 01eb6cf for PR #28. PR #28 targets mepcotterell/layout-coordinator and contains the coordinator head as an actual ancestor. Issue #27 and PR #28 retain their dependency links/comments. GitHub's native issue-dependency endpoint rejected PR targets (422: Target issue may only be an issue); the actual PR base/ancestry and explicit links represent the stack.

Implementation and review results

  • The coordinator owns sizing preparation, bounded movement/widening, canvas allocation, retries, repair rollback, invalidation, and final paint. Routing consumes a measured scene and returns a plan or constraint. Independent stack/global and heap models feed production rendering while retaining the legacy placement policies. Future frame-order, peak/intersection, and temporal-DP strategies remain separate proposals.
  • Runtime regressions found during verification were fixed: entering-frame DOM IDs stay unique; intrinsic Java content completes before route measurement; ordinary navigation is observed through a passive barrier; constructor option filters defer only their initial materialization while live setters remain synchronous, including the initial height callback.
  • Canvas-only allocation may reuse a complete candidate within the same synchronous transaction after fresh geometry measurement. Tests distinguish this from allocation that moves an endpoint and requires a fresh solve. No provisional candidate is published before bounds checks.
  • Independent static review rounds found no remaining actionable findings in their frozen scopes. The initial filter compatibility finding was reproduced RED and resolved; native test observation/artifact-retention findings were resolved. Static reviews are not runtime approval or a whole-repository guarantee.
  • The final two-file documentation correction makes the crossing exemption strictly beyond 30°, modulo reversal, and describes the complete supplied sequence, which can omit execution history. No production, test, input, or bundle bytes changed after the runtime heads below; make lint-docs passed in both worktrees.

Correctness and native evidence

On clean runtime head 7271983ec755166d51c8b95f1e591c5373517098, make check passed: 686 Python tests, 100% coverage / 2,091 statements, 300 frontend tests / 21 files, Ruff, Basedpyright, Markdown and local links. JDK 25 make test-examples passed: 34 examples / 415 images, 60.12 s. The focused native/navigation/cropping/frame-parent suite passed 9 tests. The final current head differs only in the two research-note wording corrections.

The public-export coordinator package contains 12 native PNG/SVG pairs plus 12 separately reopened SVG rasters: four frame-transition states in each theme, plus aliases, cycle, arrays, and self-loop. All seven manifest checks pass, including dimensions, at least 4 px on every side, and first/restored PNG and SVG-route equality. Passive direct/forward/backward/indexed navigation checks do not invoke export preparation or another repaint. The frame fixture uses supplied synthetic helper frames; it establishes rendering transitions, not Java tracer call semantics.

The before/after gallery was presented in the implementation thread. Preserved policy does not mean identical output: all 12 SVG descriptions match the supplied baseline, but 0/12 PNG pixel comparisons and 0/12 SVG route-record comparisons are identical. Eleven dimensions match; self-loop changes from 498×150 to 497×150. Reopened SVGs pass their own bounds checks but are not pixel-identical to native PNGs. These differences remain visible review evidence, without inferred maintainer approval. The historical baseline is supplied evidence, not a retroactive clean-commit capture. The clean after manifest binds 74 inputs and 36 export/raster files; build execution and the source-map checks provide separate build provenance.

On combined runtime head c688db7adc28e74139d6bed98ff3113578d7d755, the production rebuild and 367 frontend tests / 27 files passed locally. Its completed CI run passed both JDK 21/25 jobs: 693 Python tests / 100% coverage / 2,094 statements, the frontend suite/build, and JDK 25's 34 examples / 415 images, plus both native review packages. A separate local combined package has 31 native PNG/SVG pairs plus one standalone-SVG viewport screenshot / 63 files; all baselines are valid, native PNG/SVG dimensions agree and native PNG padding checks pass, restoration passes, all 35 recorded source/bundle/input hashes match disk and Git, and all export hashes match. Compared with the retained preceding-feature benchmark, 26/28 logical-route signatures match exactly; both cycle-default signatures have subpixel differences. This is not a claim of unchanged geometry in all 28 combinations.

The coordinator CI run for runtime head 7271983 also passed both JDK jobs, builds, wheel checks, examples and native capture. Its downloadable layout review artifact is available. The artifact captures the CI merge ref 34200291c47d77d318c5e3c66b1487076c08735c; its recorded source/bundle hashes match the reviewed root files. Both final-head CI runs have now completed successfully.

Final-head CI is complete and successful: PR #29 / 9b9eebe and PR #28 / 01eb6cf passed Markdown, lint/types, JDK 21/25 frontend builds/tests, Python tests/100% coverage, wheel checks, and JDK 25 examples. Final counts are 686 Python / 300 frontend for the coordinator and 693 Python / 367 frontend for the combined branch. Each JDK 25 job produced 415 images across 34 examples. Linux CI reports 2,094 covered statements; the coordinator's local macOS result above reports 2,091. Release jobs were skipped.

Downloaded final-head review artifacts are available: coordinator, combined coordinator, and combined shared references. The manifests record clean CI merge refs 588fb5b20bbae6f09f75318da914d4d4758db517 and baec40b0630363268bfcae29eb7783a0810192bb. All 74 coordinator, 76 combined-coordinator, and 35 shared-package input hashes match the current respective working-tree files; both coordinator manifests pass all seven checks and the shared package records 31 valid-baseline pairs. CI artifacts are separate captures and are not claimed pixel-identical to local macOS output.

Performance results and retained failures

The 11-case main-refactor comparison used the original main harness with frozen baseline b6b2e2b9a0593662ac336016706809151cfa1c04: six fresh layouts, five warmups, 40 repaints and 40 redraws. Dense-48 maximum fresh layout is 226.5 → 222.8 ms; full-redraw p95 is 14.0 → 15.8 ms. Representative final full-redraw p95 is at most 1.3 ms. This supports the extraction's measured main comparison; it does not establish shared-policy acceptance, a general speedup, or a sequence optimum.

The separate original policy-switch acceptance run covers all 14 cases under both controlled policies, with public historical initialization, policy selection, font readiness and final redraw included. Both reports contain six fresh samples, five warmups, 40 repaints, 40 full redraws, state/style transitions, and valid controlled baselines. Hardware/browser: Apple M2 Pro / 32 GiB / macOS 26.7.1; Electron 44.9.3 / Chromium 152.0.7977.167; 1536×960. No agent tests/builds/native captures overlapped timing. Browser-fetched SHA-256 values matched the combined bundles. There was no elapsed-time cutoff; initial-policy results were not substituted.

Case Independent fresh max (ms) Shared fresh max (ms) Independent full-redraw p95 (ms) Shared full-redraw p95 (ms)
later-node-compact 28.0 12.2 0.7 0.8
arrays-default 17.4 16.2 1.0 1.2
later-node-default 14.6 14.7 0.8 0.8
later-node-inline 14.4 7.6 0.6 0.6
aliases-default 15.0 14.4 0.8 0.9
cycle-default 13.1 11.5 1.1 1.0
self-loop-default 8.7 12.0 0.5 0.5
fields-default 13.7 9.7 0.8 0.9
arrays-compact 10.6 9.9 0.9 0.8
dense-24 115.3 104.6 4.8 5.1
dense-48 263.9 237.3 9.6 11.3
fan-in-12 19.8 19.2 0.9 1.0
fan-in-48 422.1 411.3 3.4 3.4
many-groups-12x4 1596.2 1559.2 3.6 3.6

The unchanged raw-sample checker exits 1 for the four stress failures. Dense-48 passes 300 ms under both policies; fan-in-48 and many-groups-12x4 fail 300 ms under both. Representative redraws pass 16 ms and dense-48 passes 50 ms. Restored-state logical paths match under both policies. State/style latencies are separately recorded and are not ordinary redraw measurements.

Six fresh samples for each acceptance-gated case
  • independent / dense-48: 263.9, 206.0, 209.8, 236.8, 214.7, 215.6 ms.
  • independent / fan-in-48: 422.1, 359.0, 353.5, 357.1, 395.1, 360.1 ms.
  • independent / many-groups-12x4: 1596.2, 1474.9, 1564.1, 1524.4, 1540.1, 1513.7 ms.
  • shared / dense-48: 222.3, 229.7, 222.8, 213.8, 237.3, 213.3 ms.
  • shared / fan-in-48: 386.5, 365.4, 361.2, 411.3, 347.6, 348.9 ms.
  • shared / many-groups-12x4: 1548.1, 1559.2, 1508.2, 1480.8, 1516.4, 1511.8 ms.

Raw reports, logs, manifests, and offline galleries are retained under the ignored local .scratch/layout-coordinator/ evidence directory. Remote reproducibility comes from the committed benchmark protocol, public native coordinator generator, and shared review generator. Local paths are not remotely accessible attachments. The combined CI run also provides layout and shared review packages.

Carry forward: criterion 19 still requires documented maintainer review; criterion 20 remains failed, with the original ≤300 ms maximum required for both stress cases and policies; criterion 22/default enablement remains held. Historical routing stays the default. Exact Dijkstra claims remain limited to the supplied graph/cost, excluding terminal stub/turn/head/rounding effects. Research does not establish global layout optimality or a universal DP/cache speedup. No main merge, release, issue closure, or maintainer approval is implied.

@mepcotterell
mepcotterell marked this pull request as ready for review October 22, 2026 10:45
@mepcotterell
mepcotterell added this pull request to stack #31 November 12, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant