Skip to content

refactor(query): delete the dead valuesEqual seam#157

Merged
zzal merged 1 commit into
mainfrom
refactor/remove-dead-valuesequal
Jul 6, 2026
Merged

refactor(query): delete the dead valuesEqual seam#157
zzal merged 1 commit into
mainfrom
refactor/remove-dead-valuesequal

Conversation

@zzal

@zzal zzal commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Part II Wave 1 · #4 — a threaded-but-unused witness

A type-erased Value-equality witness was allocated per query per render and threaded through the whole stack — built in observe(), carried on QueryObservation, stored on QueryEntry — and never called. The comment at commitFetch said it was "reserved" for select change-detection.

Why delete, not wire

Tracing the notify path shows the witness is unusable in its threaded shape, not merely unused. The audit's caveat ("must not suppress the isFetching → false transition") isn't an edge case — it's every commit:

  • commitFetch always flips inFlight non-nil → nil
  • QueryState exposes that as isFetching
  • the client can't know which subscribers render it

→ under the whole-snapshot model there is no settle notify that can be safely value-gated — gating would freeze SWR spinners. Real gating needs select-style subscriptions (components declare the projection they read; notify gates on projection inequality, with isFetching observed separately) — and that witness compares selected projections, not raw Values. Today's witness was mis-shaped for its own intended future.

Change

  • Deleted end-to-end: observe()'s closure, QueryObservation.valuesEqual, QueryEntry.valuesEqual + its init (now implicit), and 27 ceremonial test-fixture sites.
  • The analysis is recorded at commitFetch's notify — notify-per-settle is documented as deliberate, with the select design inheriting the reasoning.
  • Kept Query.Value: Equatable — the zero-cost reserved door for future select (re-adding the constraint later would be source-breaking; the dead runtime plumbing was the waste, not the one-word declaration).
  • Bonus: drops a closure allocation per query per render.

Verification

Pure dead-code deletion — no behavior change possible (nothing read it); the existing suites are the pin:

  • SwiflowQuery suite (incl. the state-machine fuzz): 126/126
  • Full host suite: 1379 tests, 277 suites green
  • QueryDemo wasm build clean

🤖 Generated with Claude Code

A type-erased Value-equality witness was allocated per query per render and
threaded through the whole stack — built in observe(), carried on
QueryObservation, stored on QueryEntry — and never called; the comment at
commitFetch said it was "reserved" for select change-detection.

Tracing the notify path shows the witness is UNUSABLE in its threaded shape,
not merely unused: every commitFetch flips inFlight non-nil → nil, QueryState
exposes that as isFetching, and the client can't know which subscribers render
it — so no settle notify can be gated on value equality without freezing SWR
spinners. Real gating needs select-style subscriptions (components declare the
projection they read), and THAT witness compares selected projections, not raw
Values — today's witness is mis-shaped for its own intended future.

So: delete it end-to-end (observe / QueryObservation / QueryEntry + 27
ceremonial test-fixture sites), record the analysis at commitFetch's notify so
the select feature inherits it, and KEEP Query.Value's Equatable constraint —
the zero-cost reserved door for select (re-adding it later would be
source-breaking).

Pure dead-code deletion; no behavior change possible (nothing read it). Also
drops a closure allocation per query per render.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

📦 Bundle size

Artifact Baseline This PR Δ
App.wasm 5.06 MB 5.15 MB +1.90%
App.wasm (gzip) 1.80 MB 1.84 MB +2.19%
JS runtime 54.5 KB 54.5 KB +0.00%
JS runtime (gzip) 11.3 KB 11.3 KB +0.00%
Total (gzip) 1.81 MB 1.85 MB +2.17%

✅ Within budget (≤5% growth allowed).

Baseline: Swift 6.3, WASM SDK 6.3-RELEASE, measured 2026-06-18.

@zzal zzal merged commit c87eb1a into main Jul 6, 2026
6 checks passed
@zzal zzal deleted the refactor/remove-dead-valuesequal branch July 6, 2026 23:45
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