refactor: decompose the well-traveled code paths (exploration 0276) - #401
Merged
crs48 merged 19 commits intoJul 7, 2026
Merged
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
One comparator for per-property LWW and change-application order (lamport, wallTime, author by UTF-16 code units — protocol §L1.7), plus the SQL ON CONFLICT guard builder, so store/adapter/hub stop re-implementing the convergence invariant. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…t core LWW (0276) sqlite-adapter.ts sheds its three heaviest aggregations behind delegate seams: query-compiler.ts (descriptor→SQL + fused CTE, flags as explicit inputs), hydration.ts (joined + aggregated modes sharing one node scaffold), sql-batching.ts (arity buckets/chunking). store.ts shouldReplace and applyRemoteChanges ordering now delegate to @xnetjs/core lww; both node_properties ON CONFLICT guards use the shared SQL builder. Adds compiler unit tests and the cross- implementation LWW conformance suite (0200 golden ordering). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…s (0276) server.ts drops from 1,750 to 888 lines: the 600-line if/else pump becomes an ordered handler registry (packages/hub/src/ws/) with one room-auth resolution path (authorize.ts), one WS error shape (errors.ts), and per-message-type metrics in dispatch. Wire behavior unchanged; adds the previously-missing pump-level tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… order (0276) getNodeChangesSince sorted lamport ties with localeCompare, diverging from the SQLite storage's BINARY collation and the client's code-unit tiebreak on case-mixed author DIDs (locale collation is also non-deterministic across ICU versions). Adopts compareChangeApplicationOrder from @xnetjs/core and pins the ordering with a conformance test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…aracterization tests first (0276) Adds 25 characterization tests pinning tool names/scopes/schemas, the page-mutation plan→apply→rollback round-trip, audit-log recording, and every resource URI family — the mutation/rollback path previously had zero coverage. Then extracts tool definitions+handlers into self-contained entries (tools/) and readResource string parsing into a declarative router (resources/). Barrel and public API unchanged; adding a tool now edits one file instead of three. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…from NodeStore (0276) Both transaction paths (per-operation slow path, preflight+applyNodeBatch fast path) and the deterministic-import planner/applier move to transaction-executor.ts / batch-write-orchestrator.ts, running on one narrow WriteExecutionHost capability seam. Conflict tracking and event dispatch are shared by construction. store.ts drops to 2,491 lines (from 2,763 pre-0276). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
context.ts drops from 1,213 to ~700 lines: initialization (storage → NodeStore → runtime bridge incl. StrictMode teardown), runtime-bridge resolution + fallback policy, hub UCAN auth, sync/backup lifecycle, bridge wiring, hub status, and search indexing each move to packages/react/src/provider/ hooks with explicit inputs. Behavior unchanged (existing worker-fallback/fail-closed tests pass); adds auth-unit failure-path tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…her from CanvasV3 (0276) viewport-math.ts (240 lines of pure coordinate/rect transforms, now directly tested) and scene-mutations.ts (the shared doc.transact → iterate → onSceneMutation pattern behind applyPosition/Lock/Properties updates) move out of the 7.7k-line CanvasV3.tsx. All 938 canvas tests green. Adds the branch changeset (core minor for the new lww exports; data/plugins/react internal-only patches). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…dapter (0276) The three index families move to store/indexing/ behind a shared IndexingStrategy interface (sync/rebuild/plan per family), with table-existence memos owned by each family instance. Adapter drops 3,712 -> 3,087 lines; emitted SQL verified byte-identical; public API unchanged. 250 store tests green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… from App.tsx (0276) Web App.tsx (1,009 -> 401 lines): the boot state machine, the ~280-line storage-init effect, the three durability watchers, and the PWA install prompt move to apps/web/src/boot/ hooks. Electron App.tsx (1,193 -> 353): ShellState becomes a pure dispatch-table reducer with the overlay transition-timer semantics preserved, and document/palette handlers move to apps/electron/src/renderer/shell/ hooks. 777 app tests green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…across web/electron (0276) usePageComments (packages/editor) absorbs the ~800-line verbatim comment state machine both PageViews carried with zero shared commits: popover state/grace timers, mark restoration, orphaned-thread assembly, and all action handlers. Electron's caret-exit dismiss survives behind an option; its unconditional docId-reset (latent mount bug) converges on web's guarded variant. DataWorkspaceCore (packages/views) hosts the 92%- identical workspace logic with platform deltas as options (canvas-frame insert on electron, feed enrichment + moderation gate on web). PageView: 1,101->701 (web) / 993->481 (electron). DataWorkspaceView: 1,060->65 / 1,189->96. 3,580 tests green across editor/electron/dom. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
check-view-drift.mjs warns when a diff touches one side of a known duplicated view pair without its twin (9 pairs); --strict exits 1. Wired as pnpm check:view-drift. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…eled-code-paths-churn-weighted-refactor
…(0276) The security regression greps App.tsx source; the hub-session URL handling it pins moved to apps/web/src/boot/use-boot-sequence.ts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Preview removed for PR #401. |
Contributor
🖼️ UI changes in this PRInteractionsAuto-captured by CI · run. Informational — not a blocking check. |
There was a problem hiding this comment.
fallow found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
…eled-code-paths-churn-weighted-refactor
crs48
deleted the
claude/0276-well-traveled-code-paths-churn-weighted-refactor
branch
July 7, 2026 00:16
crs48
added a commit
that referenced
this pull request
Jul 7, 2026
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @xnetjs/core@0.3.0 ### Minor Changes - [#401](#401) [`92708ab`](92708ab) Thanks [@crs48](https://github.com/crs48)! - Add the shared Last-Write-Wins ordering module to `@xnetjs/core` (`compareChangeApplicationOrder`, `compareLwwStamps`, `lwwWins`, `lwwUpdateGuardSql`, `LwwStamp`) — the single canonical LWW comparison used across the stack (protocol §L1.7). `@xnetjs/data`, `@xnetjs/plugins`, and `@xnetjs/react` adopt it and receive internal decompositions of their most-churned modules (NodeStore query compiler/hydration/transaction execution, ai-surface tool registry and resource URI router, XNetProvider provider units). No public API changes in those packages. ## @xnetjs/abuse@0.3.0 ### Patch Changes - Updated dependencies []: - @xnetjs/crypto@0.3.0 - @xnetjs/identity@0.3.0 ## @xnetjs/cli@0.0.8 ### Patch Changes - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/core@0.3.0 - @xnetjs/data@0.3.0 - @xnetjs/plugins@0.3.0 - @xnetjs/crypto@0.3.0 - @xnetjs/identity@0.3.0 - @xnetjs/runtime@0.1.4 - @xnetjs/sync@0.3.0 - @xnetjs/sqlite@0.3.0 ## @xnetjs/crypto@0.3.0 ### Patch Changes - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/core@0.3.0 ## @xnetjs/data@0.3.0 ### Patch Changes - [#401](#401) [`92708ab`](92708ab) Thanks [@crs48](https://github.com/crs48)! - Add the shared Last-Write-Wins ordering module to `@xnetjs/core` (`compareChangeApplicationOrder`, `compareLwwStamps`, `lwwWins`, `lwwUpdateGuardSql`, `LwwStamp`) — the single canonical LWW comparison used across the stack (protocol §L1.7). `@xnetjs/data`, `@xnetjs/plugins`, and `@xnetjs/react` adopt it and receive internal decompositions of their most-churned modules (NodeStore query compiler/hydration/transaction execution, ai-surface tool registry and resource URI router, XNetProvider provider units). No public API changes in those packages. - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/core@0.3.0 - @xnetjs/crypto@0.3.0 - @xnetjs/identity@0.3.0 - @xnetjs/storage@0.3.0 - @xnetjs/sync@0.3.0 - @xnetjs/sqlite@0.3.0 ## @xnetjs/data-bridge@0.3.0 ### Patch Changes - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/core@0.3.0 - @xnetjs/data@0.3.0 - @xnetjs/sync@0.3.0 - @xnetjs/sqlite@0.3.0 ## @xnetjs/history@0.3.0 ### Patch Changes - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/core@0.3.0 - @xnetjs/data@0.3.0 - @xnetjs/sync@0.3.0 ## @xnetjs/identity@0.3.0 ### Patch Changes - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/core@0.3.0 - @xnetjs/crypto@0.3.0 ## @xnetjs/plugins@0.3.0 ### Patch Changes - [#401](#401) [`92708ab`](92708ab) Thanks [@crs48](https://github.com/crs48)! - Add the shared Last-Write-Wins ordering module to `@xnetjs/core` (`compareChangeApplicationOrder`, `compareLwwStamps`, `lwwWins`, `lwwUpdateGuardSql`, `LwwStamp`) — the single canonical LWW comparison used across the stack (protocol §L1.7). `@xnetjs/data`, `@xnetjs/plugins`, and `@xnetjs/react` adopt it and receive internal decompositions of their most-churned modules (NodeStore query compiler/hydration/transaction execution, ai-surface tool registry and resource URI router, XNetProvider provider units). No public API changes in those packages. - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/core@0.3.0 - @xnetjs/data@0.3.0 - @xnetjs/abuse@0.3.0 ## @xnetjs/react@0.3.0 ### Patch Changes - [#401](#401) [`92708ab`](92708ab) Thanks [@crs48](https://github.com/crs48)! - Add the shared Last-Write-Wins ordering module to `@xnetjs/core` (`compareChangeApplicationOrder`, `compareLwwStamps`, `lwwWins`, `lwwUpdateGuardSql`, `LwwStamp`) — the single canonical LWW comparison used across the stack (protocol §L1.7). `@xnetjs/data`, `@xnetjs/plugins`, and `@xnetjs/react` adopt it and receive internal decompositions of their most-churned modules (NodeStore query compiler/hydration/transaction execution, ai-surface tool registry and resource URI router, XNetProvider provider units). No public API changes in those packages. - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/core@0.3.0 - @xnetjs/data@0.3.0 - @xnetjs/plugins@0.3.0 - @xnetjs/crypto@0.3.0 - @xnetjs/data-bridge@0.3.0 - @xnetjs/history@0.3.0 - @xnetjs/identity@0.3.0 - @xnetjs/runtime@0.1.4 - @xnetjs/sync@0.3.0 ## @xnetjs/runtime@0.1.4 ### Patch Changes - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/core@0.3.0 - @xnetjs/data@0.3.0 - @xnetjs/plugins@0.3.0 - @xnetjs/crypto@0.3.0 - @xnetjs/data-bridge@0.3.0 - @xnetjs/history@0.3.0 - @xnetjs/identity@0.3.0 - @xnetjs/storage@0.3.0 - @xnetjs/sync@0.3.0 ## @xnetjs/storage@0.3.0 ### Patch Changes - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/core@0.3.0 - @xnetjs/crypto@0.3.0 - @xnetjs/sqlite@0.3.0 ## @xnetjs/sync@0.3.0 ### Patch Changes - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/core@0.3.0 - @xnetjs/crypto@0.3.0 - @xnetjs/identity@0.3.0 ## @xnetjs/sqlite@0.3.0 ## xnet-cloud@0.0.6 ### Patch Changes - Updated dependencies []: - @xnetjs/cloud@0.0.1 - @xnetjs/crypto@0.3.0 ## @xnetjs/brain@0.0.7 ### Patch Changes - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/data@0.3.0 - @xnetjs/vectors@0.0.1 ## @xnetjs/comms@0.0.7 ### Patch Changes - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/data@0.3.0 - @xnetjs/crypto@0.3.0 ## @xnetjs/dashboard@0.0.7 ### Patch Changes - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/data@0.3.0 - @xnetjs/plugins@0.3.0 - @xnetjs/react@0.3.0 - @xnetjs/social@0.0.7 ## @xnetjs/labs@0.0.7 ### Patch Changes - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/data@0.3.0 - @xnetjs/plugins@0.3.0 ## @xnetjs/licenses@0.0.7 ### Patch Changes - Updated dependencies []: - @xnetjs/crypto@0.3.0 ## @xnetjs/maps@0.0.7 ### Patch Changes - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/data@0.3.0 ## @xnetjs/server@0.0.6 ### Patch Changes - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/data@0.3.0 - @xnetjs/crypto@0.3.0 - @xnetjs/data-bridge@0.3.0 - @xnetjs/identity@0.3.0 ## @xnetjs/social@0.0.7 ### Patch Changes - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/data@0.3.0 - @xnetjs/crypto@0.3.0 ## @xnetjs/unreal@0.0.7 ### Patch Changes - Updated dependencies [[`92708ab`](92708ab)]: - @xnetjs/data@0.3.0 ## xnet-desktop@0.3.0 Desktop shell release riding the @xnetjs/core 0.3.0 train. Desktop-specific changes are not tracked here; see the core packages' changelogs for what shipped.
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.


Implements exploration 0276 — a churn-weighted refactor of the hottest files in the repo. Behavior-preserving decompositions with test protection at every seam.
Theme 1 — data layer (rank 1/3/7 hotspots)
sqlite-adapter.ts4,407 → 3,087 lines: query compiler (query-compiler.ts), dual-mode hydration (hydration.ts), SQL batching helpers, and the three index families (indexing/behindIndexingStrategy) extracted; emitted SQL verified byte-identical.store.ts2,763 → ~2,100: transaction executors + deterministic-import orchestration moved behind one narrowWriteExecutionHostseam.@xnetjs/corelww.ts, protocol §L1.7) now backsshouldReplace, both SQLON CONFLICTguards, and change application order — previously implemented 3×. Fixes hub memory storage ordering lamport ties withlocaleCompare(diverged from SQLite storage + clients). Cross-implementation golden-vector conformance suite added.Theme 2 — hub server (highest-churn non-barrel file)
server.ts1,750 → 888 lines: the 600-line WebSocket if/else pump becomes an ordered handler registry (src/ws/+ 7 handler modules) with one room-auth path, one error shape, per-message-type metrics — wire behavior unchanged, plus the previously-missing pump-level tests.Theme 3 — stop web/electron drift
usePageCommentsextracts the ~800-line verbatim comment subsystem bothPageViews carried with zero shared commits (web 1,101→701, electron 993→481). Electron-only caret-exit dismiss preserved behind an option; its latent unconditional docId-reset converges on web's guarded variant.DataWorkspaceCoreshares the 92%-identical workspace logic (1,060→65 / 1,189→96) with platform deltas as options.scripts/check-view-drift.mjstripwire warns when one side of a known duplicated pair changes without its twin.Theme 4 — provider + shell ergonomics
XNetProvider(context.ts1,213 → ~700) split intoprovider/units: init, runtime resolution, hub auth, sync/backup lifecycle, search indexing — with failure-path tests.App.tsx1,009 → 401 (boot orchestrator hooks); electronApp.tsx1,193 → 353 (pure shell reducer + document/palette hooks).Opportunistic
Validation
Build 52/52 · typecheck 91/91 · tests 10,305 passed (947 files) · reliability lane 20/20 · changeset: core
minor(new lww exports), data/plugins/reactpatch(internal only).🤖 Generated with Claude Code