Skip to content

fix(zones): keep a row's zones side by side, and build a shaped node's end from its edges (#584) - #587

Merged
anandpant merged 2 commits into
mainfrom
fix/issue-584
Oct 31, 2026
Merged

anandpant merged 2 commits into
mainfrom
fix/issue-584

Conversation

@anandpant

@anandpant anandpant commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #584.

What changes

Left-to-right hybrid diagrams keep the cloud beside the data center. hybrid-cloud-zones-v2 asks for left to right. On prod, 2 of 3 Sol samples and 1 of 3 Sonnet samples hung the AWS zone under the data center, and the ERP → VPN line ran down and back left. The judge failed those samples on relationships.

  • Spec or renderer: renderer. Every saved v2 spec sets layout.direction: "LR" and declares the data center's zones before the cloud's. The zone wrap planner chose the stacked layout itself. That choice was a knife-edge:
    • The top-level 2-band plan (data center over cloud) predicted 1.91–1.99:1 on the four stacked specs.
    • The same plan predicted 2.06–2.28:1 on the specs that stayed side by side.
    • The region's 3-band wrap inside the cloud predicted 1.56–1.66:1, and was ranked behind on band count alone.
    • On Sonnet, an archive description was enough to flip a sample from one layout to the other.
  • Fix (planZoneWraps). In a row (LR/RL), when the best plan cuts the top level between two zones, a plan within the target aspect that keeps them side by side goes first. The stacked plan becomes its first alternative, so where the side-by-side plan routes worse, the existing selection still falls back to stacking (the 30-node stress case does). Columns (TB/BT) are unchanged: there the cut stands the zones side by side across a wide export, and keeping them in one column draws a taller image with lines climbing back up (checked on the described/stacked/corridor fixtures).
  • Fixture change. hybrid-cloud LR/RL now wraps its region beside the data center (1.67:1 → 1.45:1 PNG). No other zone fixture changes plan in any direction.

Sonnet's tool error was ours: a shaped node's end now comes from its edges. All 3 Sonnet v2 hybrid samples first built the Oracle database as kind: "process", shape: "database" with nothing leaving it, and got missing_outgoing_edge. 2 of 3 Kubernetes v2 samples marked RabbitMQ end although the workers read it, and got end_has_outgoing. Each retry cost a full turn (25.4k vs 17.9k tokens per hybrid sample).

  • resolveFlowchartNodeKinds already repairs recoverable kinds before validation. It now also turns a connected shaped process that nothing leaves into an end.
  • A shaped end that passes data on becomes a process, where another end remains.
  • Plain steps still need their next edge, and a shaped node that is the only end stays an end.
  • All five saved first builds now build first try.

Lines in zones keep clear of the nodes they run alongside. With the cloud beside it, the ERP → VPN line squeezed 13 units under the Oracle cylinder's foot, between it and the data center's outline. That reads as touching Oracle (about 12 px at a 2,000 px fit). Prod already drew this skim in every side-by-side hybrid sample.

  • Moving the line (clearOutlines, last pass). In zones, a run that lies alongside a node it neither leaves nor enters now moves out to the reader's corridor gap: 24 px at a 2,000 px fit, routingCorridorGap, the threshold the reader-scale checks already use for two lines.
    • "Alongside" means past a corner's length, the new routingCorridorRun.
    • This runs in the last clearing pass, after the router's usual 12-unit clearance pass, which is untouched.
    • A move is kept only where it brings the line within the clearance of no node and draws no more defects, crossings, findings, heads, inward ends or label touches.
  • Making room (zonesWithoutAlongsideRoom). Where the zone's outline leaves no lane at the gap, the zone grows once every other choice is made (Arrangement.zoneSlack, the existing GROUP_SLACK). The growth is kept only where it routes no worse and leaves fewer roomless zones.
  • Result on the samples. The data center grows, and the ERP line runs 27 units below Oracle, 37 above the frame. The Order API → queue line also clears Sync function's top (it was 14 units).
  • Regression test. In zones.test.ts, no line of any zone fixture or generated sample (15 diagrams, all four directions) runs alongside a node it passes, nearer than the corridor gap, along more than a corner. It fails on 9 hybrid fixtures without the fix.
    • Left out: the thirty-services stress case (past the 24-node limit), and depth-four LR, whose 3:1 row the grown zone would only lengthen, so the guard refuses it.

No API or UI surface changes beyond the drawn layout. docs/flowchart-zones.md documents both rules.

Proof

  • pnpm ci:local: passed and signed off on the head, 13 affected projects (lint and format, typecheck and build, tests, project graph, diagram-ui Storybook build).
  • diagram-excalidraw:routing-fuzz (full): passed on the final head, 135/135 tests (ROUTING_FUZZ=full, 531 s); the zoned pins, crossings, findings and lines through heads included. No other fuzz target renders a zoned flowchart: frames and state-machine composites are not zoned, so the new rule never applies to them.
  • Same-spec renders (local harness, main vs this branch, 12 saved hybrid specs):
    • The 4 stacked v2 specs now draw side by side at 1.65–1.74:1 (was 1.68–1.74:1), and wider: 4426–4458 px vs 3452–3482 px.
    • The side-by-side specs widen by the data center's growth, 144 px.
  • Tests:
    • New regression fixture leftToRightHybridFlowchart (Sol v2 sample 2, as sent), tested LR and RL: cloud beside the data center, ERP → VPN forward, aspect < 2.45.
    • Updated hybrid assertions in zones.test.ts.
    • Node-kind tests on the exact Sonnet hybrid and Kubernetes specs.
  • Storybook: new Diagram Types/Flowchart/ZonesHybridCloudLeftToRight. ZonesHybridCloud also shows the change.
  • Cost:
    • Hybrid renders 16 → 27 ms (hybrid-cloud LR), the real Sol sample 69 ms; a zone that needs room takes one more layout.
    • The thirty-services stress fixture (past the 24-node flowchart limit) now also tries the side-by-side plan before falling back, 633 → 1165 ms LR, so the zone stress work bound in routing-work.test.ts rises 18M → 24M (measured 23.8M); the zone fixtures measure 2.22M, under their unchanged 2.3M bound.
    • The kind repair removes a whole retry turn wherever it applies.
  • Preview replay (pr-587-sketchi-studio, playground): the first buildFlowchart call of every saved sample was sent to the preview MCP and to prod, then graded with the scenario CLI (--scenario … --input).
    • Re-run on the final head, 686bbcd.
    • Hybrid Sol s1–s3: prod 3452–3482 px, stacked; preview 4426 px, side by side, the ERP line clear of Oracle. All checks pass on both.
    • Hybrid Sonnet s1–s3 first builds: prod invalid_flowchart (missing_outgoing_edge); preview accepted, all checks pass.
    • Kubernetes Sonnet s1/s3 first builds: prod invalid_flowchart (end_has_outgoing); preview accepted, all checks pass.

Before / after PNGs

Local (this machine):

  • After (first round, still skimming Oracle): /home/anandpant/Development/shpitdev/sketchi/.memory/renderer-584-585/584-pngs/after-r1/
  • Before: /home/anandpant/Development/shpitdev/sketchi/.memory/renderer-584-585/584-pngs/before/. Prod-judged and prod-replayed Sol/Sonnet v2 hybrid samples, plus the hybrid-cloud fixture on main.
  • After: /home/anandpant/Development/shpitdev/sketchi/.memory/renderer-584-585/584-pngs/after/. Preview-replayed hybrid (Sol and Sonnet) and Kubernetes first builds, plus local renders of the same specs and fixture.

…s end from its edges (#584)

Asked for left to right, two of three Sol hybrid samples hung the AWS cloud
under the data center: a top-level wrap came within the target aspect in two
bands, the region's wrap inside the cloud in three, and fewer bands won. In a
row, a plan within the target that keeps the top-level zones side by side now
goes first, the stacked plan its first alternative.

Sonnet's first build failed in all three samples on the Oracle database it
marked process with no outgoing edge, and in two Kubernetes samples on a
RabbitMQ queue marked end that the workers read. A shaped node now takes its
end from its edges before validation.

Copy link
Copy Markdown
Collaborator Author

@github-actions github-actions Bot added the preview Deploy PR previews for the affected apps label Oct 31, 2026
@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Sketchi Playground / Studio Preview

Status: deleted

@anandpant
anandpant marked this pull request as ready for review October 31, 2026 04:55
…e, growing its zone for the lane

The ERP's line to the VPN gateway ran 13 units under the Oracle database's foot,
between it and the data center's outline, which reads as touching it. In zones,
the last clearing pass now moves a run alongside a node it neither leaves nor
enters out to the reader's corridor gap, where that brings the line within the
router's clearance of no node and draws nothing worse; a zone whose outline
leaves no lane there grows once every other choice is made, where that routes no
worse.
@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Sketchi Eval Harness Preview

Status: deleted

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Sketchi Excalidraw Workspace Preview

Status: deleted

@anandpant
anandpant merged commit d99eb3c into main Oct 31, 2026
11 checks passed
@anandpant
anandpant deleted the fix/issue-584 branch October 31, 2026 05:27
@github-actions

Copy link
Copy Markdown
Contributor

Sketchi Icons Preview

Status: deleted

@github-actions

Copy link
Copy Markdown
Contributor

Sketchi Web Preview

Status: deleted

This branch was successfully deployed

1 active deployment
staging — 686bbcd5 Deployed Oct 31, 2026 by anandpant via cleanup-preview (playground) #1100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Deploy PR previews for the affected apps

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hybrid cloud zones: AWS zone lands below the data center in a left-to-right layout

1 participant