Repository navigation
♻️ refactor(graph): extract prepareGraph and packBuffers from boot - #121
Merged
Merged
Conversation
Validation, degree, displayed states, the layout seed and the solver's graph now come from a pure prepareGraph. boot keeps writing idToIndexRef, the dropped-edge warning, visualRandom and createPhysics/setParams. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
packNodes then packEdges, so every node seed is drawn before any edge seed. boot still calls it after the Scene and Camera, whose uuids draw from Math.random when the graph is unseeded. The iP2 slot constants and EDGE_END_TRIM move with the code that writes them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Covers the orphan state, the three seed modes, dropped edges, the fray encoding, the alternating bow sign and the order of random draws, plus the patch changeset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A second `* as THREE` namespace made the bundler rename GraphCanvas's to THREE2, so dist/index.js changed far beyond the relocated code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tests Split the shape/tier/colour and gain tests so each asserts one behaviour. Add unit tests that fail if a node's category is looked up by position, if the edge end trim drifts from 1.15, or if the iP2 slot constants move. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JadRizk
added a commit
that referenced
this pull request
Oct 11, 2026
main's tree is identical to #121's head, which this branch already contains, so this branch's tree is kept unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JadRizk
added a commit
that referenced
this pull request
Oct 11, 2026
#121 and #122 moved code out of GraphCanvas.tsx into prepare.ts, buffers.ts, scene.ts, scene-meshes.ts and label-layer.ts, carrying 36 assertions the compiler doesn't need. Drop them, and keep the 2d-context one in label-layer.ts with the reason it had in GraphCanvas.tsx. Restore the reason on the contrast test's kept assertion, lost when main's side of that hunk won. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JadRizk
added a commit
that referenced
this pull request
Oct 11, 2026
…ed (#118) * 🏷️ types(graph): drop the non-null assertions the compiler doesn't need Graph builds under plain strict without noUncheckedIndexedAccess, so 371 of the 454 assertions inherited from qrntn's stricter config assert nothing: their operand's type already excludes null and undefined, or (one case) tsc accepts the nullable value as is. Each was removed as a single-character deletion; no other token changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * 🏷️ types(graph): justify the non-null assertions the compiler needs 83 assertions remain because their operand's type admits null or undefined and tsc rejects the code without them. Each holds by construction (a guard, a loop invariant, or a test's own setup), so each keeps its `!` with an eslint-disable-next-line that says why, as docs/code-style.md asks. The rest of the diff is prettier re-wrapping lines the first commit shortened. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * 📝 docs(changeset): empty changeset for the graph non-null clean-up The built JS and .d.ts are byte-identical to main, so there is nothing to release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * 🏷️ types(graph): redo the non-null cleanup over the moved modules #121 and #122 moved code out of GraphCanvas.tsx into prepare.ts, buffers.ts, scene.ts, scene-meshes.ts and label-layer.ts, carrying 36 assertions the compiler doesn't need. Drop them, and keep the 2d-context one in label-layer.ts with the reason it had in GraphCanvas.tsx. Restore the reason on the contrast test's kept assertion, lost when main's side of that hunk won. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
⏸ Held until 2.0 ships (see #107)
Closes #111
Part of #107
Summary
Moves boot's data prep and buffer packing out of
GraphCanvas.tsxinto two unexported modules. The code was copied as-is, then split and typed. Nothing else changed.prepare.ts:prepareGraphcovers validation, degree, displayed states, the layout seed and the solver's graph.buildPhysicsGraphbuilds the solver's node and edge lists, where a node's own values override its category's. It draws no random numbers.buffers.ts:packBufferscallspackNodesand thenpackEdges, so every node seed is drawn before any edge seed. TheiP2slot constantsA_TIER/A_HIDE/A_JIT/A_FRAYandEDGE_END_TRIMmove with the code that writes them.GraphCanvasimportsA_TIER/A_HIDE.boot(), as the scope asks: writingidToIndexRef, the dropped-edge warning, buildingvisualRandom(passed in), andcreatePhysics+setParams.packBuffersis still called after the Scene and Camera are built.prepareGraphinto boot's catch, which callsonFatal.buffers.tsimports{ Color }only. A second* as THREEmade the bundler rename GraphCanvas's namespace toTHREE2, which turned the dist diff into noise.!s moved over unchanged, so 🏷️ types(graph): drop the non-null assertions the compiler doesn't need #118's removals still apply here if this PR merges second..changeset/graph-prepare-pack.md.Evidence
Harness (Differential harness for GraphCanvas at the three.js boundary #110): the full graph suite passes (322 tests) without
-u, andgit diff --exit-code packages/graph/src/__recordings__is clean after every commit. As a mutation check, settingnodeSeeds[i]to a constant fails 21 of the 22 recordings.Harness gap: flipping the arc's alternating sign does not change any recording, because the fixture's arcs never land on an odd edge index.
buffers.test.tscovers that behaviour directly.browser/graph.spec.ts: 14 passed in the pinned container. The three baselines are unchanged and the tree was clean afterwards.dist:
index.d.tsandindex.d.ctsare byte-identical tomain, built from agit archivecopy. Thenpm pack --dry-runfile list is the same.dist/index.js(prettier-formatted diff vs main): it only relocates code. The removed and added lines match except for:validateGraphmoving up next toprepareGraph;const A_TIER = 0, …becomingvar A_TIER = 0;and so on;edgeCountthat now readsedgeCategoryIds.length, which is the same value.Lint: the graph package has 511 warnings, the same as
main. The new functions raise no size, complexity or params warnings: each is ≤ 60 lines with complexity ≤ 12.Unit tests:
prepare.test.tsandbuffers.test.tstest the pure functions directly. They cover the orphan, declared and default states, all three seed modes, dropped edges, the fray encoding (0/1/2), the alternating bow sign and default bow, radius growth and its cap, trims, gain and direction, defaults, and draw order: one draw per node, then one per edge.CI test-job steps run locally, all passing: format:check, lint, typecheck, test, test:coverage, build, attw ×3, showcase build, the preview, tokens and styles drift checks, check-docs, peer-floor, check-consumer, check-changeset, and
node scripts/test-react.mjs 18.🤖 Generated with Claude Code