Skip to content

feat: phase 1 core completeness (hashers, prefetch, cancel, focus triggers) - #1

Merged
matheuseabra merged 10 commits into
mainfrom
feat/p1-core-completeness
Sep 5, 2026
Merged

matheuseabra merged 10 commits into
mainfrom
feat/p1-core-completeness

Conversation

@matheuseabra

Copy link
Copy Markdown
Owner

Implements all Phase 1 tasks from docs/roadmap.md.

Behavior changed

  • Custom key hashers: Query.make({ hash }) overrides hashing for fetch; default stays JSON.stringify. Raw-key ops (getData, setData, invalidate, cancel) keep structural identity. Unhashable keys fail typed with new KeyHashError, never throw.
  • Query.notifyFocus() / Query.notifyReconnect() revalidate entries whose queries opt in via refetchOnFocus / refetchOnReconnect, in background daemons.
  • Query.prefetch(query, ...args) warms the cache without awaiting data (fire-and-forget daemon).
  • Query.cancel(key) interrupts the in-flight winner fiber for a key and clears the slot; idle/missing keys are no-ops.
  • Single-flight reworked: winner forks the request into a supervised child; child taps cache on success; winner funnels every outcome through the shared Deferred in an onExit finalizer, so joiners are always released.

API / cache-semantics notes (breaking within 0.x)

  • invalidate, setData, getData, cancel now carry KeyHashError in the error channel (was never); fetch is E | KeyHashError.
  • MutationDefinition gains an E2 = never parameter so onSuccess hooks may fail typed (e.g. fallible invalidation).
  • Trigger revalidation only has QueryService in scope: queries needing more fail silently in the daemon without touching cached data.

Tests

  • 9 new behavior tests (30 total): custom hasher sharing, typed hash failures on fetch and manual reads, focus/reconnect revalidation and no-ops, prefetch warming without awaiting, cancel-interrupt with slot reuse, cancel no-ops.
  • pnpm check green: typecheck, lint, 30/30 tests, 100% line/function and 97.7% branch coverage (thresholds hold), build clean.

Spec links

  • docs/roadmap.md Phase 1 boxes checked; docs/spec.md and docs/architecture.md updated (including interruption semantics per operation).

No version bump: release as 0.2.0-beta.0 happens separately via tag.

@matheuseabra
matheuseabra merged commit 6c199da into main Sep 5, 2026
1 check passed
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