Repository navigation
Conversation
… snapshots Phase 1 of the 1.0 preparation. - Store methods and array operations run as transactions. Versions still advance per write, but synchronous subscribers are notified once when the outermost call returns. An unshift on 5,000 rows with one synchronous subscriber drops from about 7.7 s to about 18 ms. - subscribe() on a nested proxy observes that subtree only. The sibling notifications kept for pre-0.11 compatibility are gone, along with the path-observer bookkeeping in ownership.ts. - Each subscribe() call is an independent registration. - A snapshot assigned into a store is held by reference and stays frozen, including one read through React's tracking proxy. - Dense arrays are snapshotted by index instead of by key enumeration. - Export PROXYABLE so a class can opt into nested reactivity. BREAKING CHANGE: synchronous subscribers no longer observe each write made inside a store method or array operation; a subscription to a nested proxy no longer fires for sibling changes; subscribing one callback twice now yields two subscriptions. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ed collections
Phase 2 of the 1.0 preparation.
persist
- Hydration is per field. A stored field is restored unless that same field
was edited locally while the read was in flight; an edit to any other
field no longer discards the stored record.
- Background saves wait for an in-flight read, so a local edit cannot
overwrite the stored record with defaults before it is restored.
- Stored data from another schema version is ignored unless `migrate` is
given. A record with no version counts as version 0.
withHistory
- Undo and redo delete top-level fields that the restored entry lacks.
- undo() first records an edit made in the same tick, so it steps back
over that edit and redo can return to it.
- Fields whose snapshot is unchanged are left alone, keeping their identity.
shallowEqual
- Values with different prototypes are never equal. Dates compare by
instant, Map and Set one level deep. An object with no enumerable keys
is equal to another only when both are plain records.
devtools
- Returns a handle with dispose(), like persist and withHistory.
- No longer augments the global Window type in the published declarations.
collections
- Keys and set values are compared by identity, so an object matches
whether it is given raw, as a store proxy or as a snapshot.
- Live and snapshot lookups scan the raw backing array. A get() on a
10,000-entry map inside a store drops from about 3.7 ms to about 0.06 ms.
- set() on an existing key keeps the stored key and updates in place.
BREAKING CHANGE: devtools() returns {dispose} instead of a function;
persist no longer applies stored state whose version differs when no
migrate is configured; shallowEqual returns false for values it previously
treated as equal (different prototypes, different dates, maps or sets).
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…e Solid peer range Phase 3 of the 1.0 preparation. - Angular: injectStore is now injectClassyStore, matching createClassyStore and useClassyStore. Source, tests, the Angular example and the docs that name it are updated. - Solid: accept solid-js ^2.0.0-rc.18 instead of exactly rc.18. The adapter unit tests and the Solid example typecheck and build were run at rc.18 and at rc.23, the newest release candidate; development now uses rc.23. - Tests read the DevTools extension through a local type, as the library does, now that nothing is declared on the global Window. BREAKING CHANGE: `injectStore` from `@codebelt/classy-store/angular` is renamed to `injectClassyStore`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… tests Phase 4 of the 1.0 preparation. - core.fuzz.test.ts: 60 seeds x 300 random operations (aliasing rows across lists, detaching, retaining, reattaching, sorting, truncating, store methods). After each one the snapshot must equal the live data, a visible change must produce a new root snapshot and a sync notification, and live and snapshot getters must match a fresh computation. - react.transactions.test.tsx: an in-place array operation on a long list builds one list snapshot and renders once; a multi-field store method never renders a half-applied state; a row taken from a rendered list is stored as an immutable snapshot in both hook modes; a Date selection with shallowEqual re-renders; auto-tracked collection lookups re-render when the looked-up key appears. - types.exports.test.ts: signatures of the public entry points, PROXYABLE as a static class key, and every utility returning a handle. Temporarily disabling transactions, version propagation to owners, or parent unlinking makes these tests fail. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Phase 5 of the 1.0 preparation. - Add check:package, which runs publint --strict and arethetypeswrong on the packed tarball, and run it in CI after the build. Both pass for the node16 (CJS and ESM) and bundler resolutions. The legacy node10 resolution cannot resolve subpath exports and is not supported. - Declare engines.node >= 20 and export ./package.json. - Add a major changeset so the Changesets release PR produces 1.0.0. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Phase 6 of the 1.0 preparation. - Add UPGRADING_1_0.md with a before/after for every breaking change, the changes that need no edit, framework and package support, and what is unchanged. Link it from the README, the docs landing page and the sidebar. - Tutorial: replace the batching section with "Batching and transactions", and add sections on reactive nested classes (PROXYABLE), snapshots stored in a store, and getters appearing as own fields on snapshots. - API reference: subscribe scope and registrations, shallowEqual rules, the devtools handle, PROXYABLE, withHistory restoration, transactions. - Architecture: a Transactions section, updated method binding and nested state notes, file tree and performance table. - Persist tutorial and architecture: per-field hydration, deferred saves and the version rule. History, collections, devtools, Solid, Svelte, subscribeKey and SSR pages updated to match. - CLAUDE.md: current layout, measured bundle size, transactions and other key facts, and the package-check command. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Phase 7 of the 1.0 preparation (validation). The transaction wrapper allocated a closure for every method call. Count the depth inline and settle in a finally block instead. No behavior change. Validated on this branch: lint, 684 unit tests, build, the full monorepo typecheck, publint and arethetypeswrong, the cross-browser suite on Chromium, Firefox and WebKit, the React 18.0/18.3/19.0/19.3 packed consumers with and without React Compiler, Vue 3.2.0, Svelte 4.0.0 and 5.0.0, Angular 22.0.0 and 22.2.3, the packed Next.js consumer with the compiler off and on, the performance and memory smoke runs, and the docs site tests. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Solid 2.0.0 was published on 2026-11-17. Move development off the release candidates: - solid-js, @solidjs/web and @solidjs/compiler 2.0.0-rc.23 -> 2.0.0 - @solidjs/vite-plugin 3.0.0-next.51 -> 3.0.1 (Solid example) - Remove the root overrides. They held @solidjs/babel-plugin and @solidjs/compiler on one release candidate. The stable Vite plugin depends on @solidjs/compiler ^2.0.0 and makes the Babel plugin an optional peer, so nothing installs the Babel plugin any more and the compiler resolves to a single 2.0.0 copy without an override. Checked on 2.0.0: all 684 unit tests including the Solid adapter tests, the package typecheck, the Solid example typecheck, integration check and production build, and the Solid browser spec on Chromium, Firefox and WebKit (18 passed). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Solid 2 is stable, so the adapter no longer needs to track release candidates. - Peer range: solid-js ^2.0.0-rc.18 -> ^2.0.0. The release candidates are no longer accepted. - README, Solid guide, API reference, architecture page, docs landing page and browser test notes: describe the adapter as supporting Solid 2 instead of being a preview that follows release candidates. - 1.0 upgrade guide and changeset: list the Solid requirement among the breaking changes. The adapter's code is unchanged; it passes its unit and browser tests on Solid 2.0.0. BREAKING CHANGE: `@codebelt/classy-store/solid` requires `solid-js@^2.0.0`. Projects on a Solid 2 release candidate must update `solid-js` and `@solidjs/web` to the stable release. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Solid 2 is the supported version, so the documentation no longer mentions its release candidates, a preview status, or Solid 1. - README, Solid guide, API reference, docs landing page, 1.0 upgrade guide and the 1.0 changeset state the requirement as Solid 2 (`solid-js@^2.0.0`) without describing what came before. - The Solid guide opens with how to call the adapter instead of a migration note, and names `@solidjs/vite-plugin` as the Vite plugin. - The 0.11 release notes point to the Solid guide for the current requirement instead of repeating a superseded pin. The generated package changelog keeps its entries for earlier releases. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- Docs site: fumadocs-core and the fumadocs UI 16.19.4, fumadocs-mdx 15.6.3, mermaid 12.3.0, Tailwind 4.3.5, and patch updates to postcss, serve and the Node types. The site builds, typechecks and passes its 38 page tests. - Examples: TypeScript 7.0.2 for Solid, 6.0.3 for Vue and Svelte. Their TypeScript configs drop `baseUrl`, which TypeScript 7 removed and 6 deprecates; `paths` already resolve relative to each config. - CI: Bun 1.4.4. Left as they are, each for a tested or declared reason: - TypeScript stays on 6.0.3 in the Angular example (the Angular compiler requires >=6.0 <6.1) and cannot go past 6 in the Vue and Svelte examples (vue-tsc fails to load on 7; svelte-check accepts 5 or 6). - @babel/core stays on 7: with 8, babel-plugin-react-compiler 1.0.0 skips components with a compile error. - @changesets/cli 3 and @changesets/changelog-github 1 change the release commands this repository's workflow uses; that belongs in its own change after 1.0.0 is published. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Store methods and array operations already run as transactions. A plain loop of direct writes outside any method still notified synchronous subscribers once per write, and each notification rebuilt the snapshots on the changed path: 5,000 pushes with one synchronous subscriber took about 9.6 s. batch(run) opens the same transaction around any callback and returns its result. The same loop inside batch() takes about 11 ms and notifies once. Calls nest with each other and with store methods; the outermost one notifies. Only the synchronous part of an async callback is covered. Tests cover grouping, nesting, several stores, a callback that throws, a callback with no effective write, an async callback, batched subscribers, a mounted React consumer, and the exported type. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
1.0 is the first stable release, so the documentation no longer carries guidance for moving from earlier versions. - Remove the 0.7, 0.8, 0.11 and 1.0 upgrade guides and the Upgrading section of the docs sidebar. - Remove the README's upgrade section and the migration notes inside the API reference, tutorial, Angular guide and docs landing page. - Document batch(): an API reference section, the tutorial's batching and transactions section, the README and API tables, and the architecture page. - The 1.0 changeset keeps its list of breaking changes, which becomes the 1.0.0 changelog entry, but no longer links to an upgrade guide. It states the Node 22 minimum and the new batch() export. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Docs site - website/ is now a workspace member and depends on the library with workspace:*, like the Next.js example. Its live examples run the code in this repository, so they match the documentation at merge time and need no manual update after a release. Its separate lockfile is gone. - docs:build and docs:dev build the library first; the Docs workflow installs from the root lockfile. - The site declares zod so that every package resolves one copy of the docs framework's core. Without it the workspace install produced two copies and the site's page types no longer resolved. - The devtools demo and its page use the handle that devtools() returns, and no longer rely on a global Window type. Node - engines.node is >=22, the oldest release line still maintained. The packed-consumer fixtures pass on Node 22.13 and 26.13 locally (and on 20.12, which is past end of life and not claimed). - The React compatibility workflow adds a Node 22 job. Examples - The root typecheck now covers the Next.js example and the docs site. - The Next.js example's API map lists transactions. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Remove the 0.x entries. They linked to upgrade pages that no longer exist and described the Solid release-candidate pin. The earlier notes remain in git history and on the GitHub Releases page. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Add 20 unit tests. A seeded sample of 160 single-line mutations left 21 undetected; nine of those were real gaps and now fail a test: - history: dispose releases the store subscription; initial status - ownership: reattaching a detached list reconnects a row that kept its own subscriber - persist: cross-tab events that are stale, unreadable, live with clearOnExpire, or expired without it - snapshot: class getters are enumerable own properties; a setter-only accessor reads as undefined - React: a field a memoized child never read does not re-render the parent - cloneSnapshot: cloned accessors stay configurable - utilityStatus: direct tests, including a listener that throws - Angular: an already-destroyed DestroyRef is rejected Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Run the remaining 495 single-line mutations (655 in all). The unit tests now fail for 595 of them. Of the 60 left, one is caught by the Solid browser suite and 59 change no observable behavior. Add 27 tests for what the sweep exposed, including: - core: a nested object replaced by null or a primitive drops the old child; assigning a nested proxy back is a no-op; a rejected write throws; a deleted own method uncovers the class method; a throwing subscriber is reported; a later transaction does not re-notify an earlier store; a getter recomputes after a property it read is deleted; a detached one-row list refreshes - persist: syncTabs is off by default; clearOnExpire removes only expired records; a newer cross-tab record or an explicit save wins over a slow read; queued writes stay ordered; save() cancels the pending debounced write; a success clears the last error - shallowEqual: maps of different sizes; an empty object against one with keys - devtools: only a DISPATCH message can time-travel Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Reading a nested object through a frozen object held in a store threw a TypeError: the proxy returned a child proxy for a property that a Proxy is required to return unchanged. That affected any frozen input, including deeply frozen data from an immutable-update library. A frozen object is now an immutable value, kept by reference and never proxied, like a snapshot or a Date. A snapshot holds the same object, and replacing the field notifies subscribers. - Whether an object is frozen is worked out once and remembered, because the check scans every property (17 ms for 100,000 rows). - The value of a non-writable, non-configurable property is returned as it is. This also makes a frozen store root readable. - Object.freeze through the proxy detaches the children it makes read-only, so the object stays readable. - A store embedded by its proxy stays connected inside a frozen root. Ordinary reads cost the same as before. The gzipped core grows by about 0.1 KB. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Working plan for the core review and refactor before 1.0.0: five stages, the ground rules, and where each stage writes its results. Stage 5 deletes it with the rest of the review's working documents. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`bun run test:mutation` mutates each target file one change at a time in a temporary copy of the package and runs the unit tests against every change. A survivor must be killed by a test or listed in tests/mutation/equivalentMutants.json with a reason, and a stale entry in that list also fails the run. The rules are fixed: sixteen of them, including the removal of a single statement and both forced values of every condition. Keys hold no line numbers, and the checkout is never written to. Bun reports no branch coverage, so this run is also the branch check. Adds @types/babel__core for the parser the generator uses. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`bun run size` builds the library, bundles every published entry point together with the main entry (proxy-compare inside, frameworks left out), minifies it and reports gzipped bytes and what each entry adds to the core. The numbers repeat exactly for a given Bun version. It fails when an entry is over its budget in tests/size/budgets.json or has no budget. The budgets arrive with CONSTRAINTS.md; this commit records the baseline: 3,661 bytes gzipped for the main entry. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`bun run benchmark:core` (JavaScriptCore) and `benchmark:core:node` (V8) time single operations of the built core in nanoseconds: reads, writes, snapshots, getters, store creation and subscription. Each run is a fresh process; a metric's figure is the median over the runs and its spread is the lowest and highest run. It also reports each operation as a ratio to a Proxy that only forwards, taken inside one process, so a limit on the ratio holds on another machine. The baseline is recorded later, on a quiet machine. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The lists move to tests/mutation/equivalent/, one JSON file per mutated source file, so they stay small and two people can triage different files without touching the same list. A partial or sampled run now writes report-partial.json and leaves the report of a full run alone. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A coverage run showed two traps of the read-only handler were never called: proxy-compare's tracking proxy refuses a write or a delete before it reaches the shared copy. The new test reaches the copy through the cache and checks that the copy refuses them itself. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`bun run check:floor` reads the diff between a base commit and the working tree and reports the cheap ways to turn a red check green: a new suppression comment, an `any` cast or expected type error in library source, an unconditional skip or a focused test, a deleted test file, a test file left with fewer assertions, an unfinished stub, and a rule in CONSTRAINTS.md that was removed or loosened. A constraint that is loosened together with a decision record under docs/decisions/ is listed instead of blocked, which is the one route the review plan allows. The base defaults to the commit that adds CONSTRAINTS.md while that commit is on the branch, so the bar applies from the point it was written down. Adapted from the constraint-driven-development reference guard. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
T-01, decision 4. Tooling only; no library source changes. - budgets.json holds a budget and a ceiling per entry. The ceilings are those of decision 4; the budgets are unchanged. - The size script's checks move into checkSizes(), which a test calls without a build. It also fails a budget above its ceiling and an entry with no ceiling. - The floor guard judges each commit against its parent, from the merge base with main (or the commit that added CONSTRAINTS.md while main does not hold it), then the working tree. It fails on a merge commit, reads budgets.json and limits.json, refuses a ceiling changed with anything else, treats its own file, the coverage settings and the mutation target list as bar files, asks for a line added to a decision record instead of a touched one, and lets a test file shrink only with a Test-change line in the commit message. - CONSTRAINTS.md: one size row naming budgets.json, the new floor rules, and the owner sentences in line with the delegation of 2026-11-19. - 9 tests of the size checks and 32 of the guard, each case on a throwaway Git repository with its fixtures put together at run time; they run concurrently, in about 2.5 seconds. Checked: the new guard is clean on all 85 commits of the branch after c070953. 1,382 tests pass with full coverage; lint, typecheck and bun run size pass, sizes unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
T-02, decision 36 (the guard's rule), used early by decision 27. - CONSTRAINTS.md gains a floor rule: a development-only check reads process.env.NODE_ENV inline at its call site, after a cheap test, behind typeof process, and reports with console.warn, which nothing else in the library calls. - bun run size, which already bundles every entry for production, now also fails when a production bundle calls console.warn or holds a code listed in tests/size/developmentOnly.json. The list is empty until the lost-write check lands. - productionBundle.test.ts bundles a fixture in that form for production and for development: the marker text and console.warn are gone from the first and present in the second. The bundling moves into an exported bundle() so the test uses the size script's own build. No library source changes. 1,385 tests pass; lint, typecheck, bun run size and bun run check:floor pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
T-02 (ae990df) was committed with a type error: bundle() returned Uint8Array<ArrayBufferLike>, which Bun.gzipSync does not take. The command that ran the checks did not stop on the failed typecheck. Now typecheck, lint, the size tests and bun run size pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a pull request, actions/checkout gives the merge of the head into main, so the per-commit guard of a46cd96 walked up to that merge commit and failed on it: it keeps the branch linear by refusing merge commits. The guard now takes --head <ref>: the walk ends at that commit and the working tree, which belongs to another commit, is not judged. ci.yml passes github.event.pull_request.head.sha. A test builds the same merge on a throwaway repository: without --head it fails, with the head it is clean. Record 0004 has the line for this change to a bar file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
T-03, decision 35. Every error now reads `@codebelt/classy-store [code]: facts`, with one prefix for every entry, the adapters' too. A new codedMessage() in the core builds the text, and every entry reaches it through the store runtime, so the prefix is in a bundle once. - getter-cycle: the path of the cycle is the facts. - not-a-store: no facts. - vue-no-scope, solid-no-owner: `useClassyStore()`. These two used to start with their entry point. - angular-no-context: `injectClassyStore()`. It had no prefix. - persist-disposed: the handle's storage key. It had no prefix. The snapshot's circular-reference error gets no code: decision 44 removes it before 1.0. The new page website/content/docs/ERRORS.md lists the six codes with their advice and what 1.0 does not catch (decision 36); the API reference links it. Tests: the assertions on today's texts are changed by decision 35, in 12 test files, each now anchored on the prefix and the code. Same count. Measured against the commit before: the main entry 3,661 -> 3,673 bytes gzipped (the helper costs more than the two shorter core messages save; budget 3,750 unchanged), ./vue -30, ./solid -29, the rest within 14. Cost ratios inside their limits on both engines (Bun read 14.7, write 2.45; Node read 2.04, write 1.38). Mutation on core.ts and persist.ts: 937 mutants, none unexplained. 1,388 tests, lint, typecheck, docs build, size and the floor guard pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dc2f144 (T-03, decision 35) gave the Solid adapter's error its code, and the browser suite still matched the old text "active Solid owner", so tests/browser/solid.spec.ts failed in all three browsers on CI. The assertion now matches `@codebelt/classy-store [solid-no-owner]: useClassyStore()`, changed by decision 35. No other browser or packed-app suite matches a message text. Checked: the whole browser suite passes in Chromium (54); WebKit and Firefox are not installed on this machine, and CI runs them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
T-04, decision 20. Written again from the dead rows of stage 3's review of our own code, in the form the type checker accepts: - core.ts: the `!cached` check of areDepsValid() merged into the next line; `existing ??` in linkChild(), which createNode() repeats; the `if` around suspendIfDetached() in the unsubscribe function. - ownership.ts: `?? 0` in place of the `count === undefined` return in disconnect(); resume() pops in a `for` loop with no `if (!frame) break`. - snapshot.ts: `getter &&` in originalSnapshotAccessor(); the redundant checks before `typeof descriptor?.value` in markSnapshotForTracking(); `configurable` and `writable` on properties that Object.freeze() sets anyway; `inProgress.delete()`, since the set lives for one snapshot() call and a finished node is cached before it can be reached again. The ternary in activeTracker() and the fast paths stay. No test changes. Mutation on the three files: 800 mutants, none unexplained. Ten entries of the equivalent-mutant list that marked these lines are removed, and one is added: `descriptor?.value` read as `descriptor.value` behaves the same, because the key comes from the same object a line above. Measured against the commit before: the main entry 3,673 -> 3,641 bytes gzipped (-32, as stage 3 measured). Bun store.read 32.4 ns, store.write 157, getter.cached 55.6, snapshot.cached 14.5; every ratio inside its limit on both engines. 1,388 tests, lint, typecheck and the Chromium browser suite (54) pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
T-05, decision 20 (the dead code of persist.ts that stage 1 listed). - The debounce timer is cancelled in one place, cancelPendingSave(), in place of five copies of a null-checked block. The timer is undefined when none is pending, which clearTimeout() takes as it is. - A read that delivers data no longer cancels a pending debounced save itself: it only asks for the save that follows the read, and queueAutoSave() cancels the old timer when it arms that save. - writeToStorage() no longer checks for a disposed handle: nothing calls it on one. save() keeps its check, which is now the one that matters; a new test shows that save() on a disposed handle rejects before it serializes or writes anything. - applyPersistedState() drops `typeof envelope !== 'object'`, which the check of `envelope.state` repeats, and rehydrate() sets the hydrated flag without first asking whether it is set. Two guards on the list stay: `if (onError)`, because without it the code would rely on a TypeError that a catch swallows, and decision 21 rewrites that function in step 8; and `if (prop.transform)`, because removing it would put undefined into a map typed for transforms, for no gain. Their equivalent-mutant entries stay with them. Mutation on persist.ts: 431 mutants, none unexplained; the equivalent list for it goes from 17 entries to 6. Measured against the commit before: ./utils adds 2,684 -> 2,673 bytes gzipped. 1,389 tests, lint, typecheck, size, the Chromium browser suite and the floor guard pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
T-06, decision 20 (stage 1 finding 59). - equality.ts: the three `b instanceof Date / Map / Set` checks go. After the same-prototype check, b is an instance of whatever a is. - history.ts: record() sets the length of the history without asking whether there is anything after the pointer, and redo() drops `disposed ||`, because dispose() empties the history. - collections.ts: the object guard in indexOfMember stays, measured. The core benchmark gains two rows, collection.has.primitive and collection.has.object: has() of the last of 1,000 numbers, and of 1,000 objects, in a reactiveSet held by a store. On the commit before, and with the guard removed (ns per call, median and spread of five runs): | Row | Engine | Before | Without guard | | ------------------------ | ------ | ------------------ | ------------------ | | collection.has.primitive | Bun | 593 (585-597) | 3,312 (3,233-3,344) | | collection.has.primitive | Node | 2,213 (2,207-2,262) | 2,325 (2,290-2,344) | | collection.has.object | Bun | 13,646 (13,396-13,977) | 13,688 (13,600-13,837) | | collection.has.object | Node | 32,174 (31,527-33,840) | 32,176 (31,156-32,397) | The primitive row leaves its spread on both engines, so the guard stays as a shortcut and its four equivalent-mutant entries now give these figures. No test changes. Mutation on the three files: 505 mutants, none unexplained; seven stale entries removed (equality.json 8 -> 5, history.json 4 -> 0). 1,389 tests, lint, typecheck, size, the Chromium browser suite and the floor guard pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nnot reach T-07, decision 20 (stage 1 finding 4). The read-only handler that guards the cache's shared copies loses its `set` and `deleteProperty` traps: proxy-compare's tracking proxy refuses a write and a delete before they reach a copy, so nothing public can reach either trap. Deleting them fails one unit test, which reached the private copy through the cache to show the traps; stage 1 added it for coverage. It is a test of internal state (decision 20) and goes with the traps. The public fact, that a write and a delete through the tracking proxy are refused, stays covered by "protects both the initial and cached copies against reflective mutation" in the same file. With the traps deleted, the unit suite, the React compatibility suite (React 18.0.0, 18.3.1, 19.0.0 and 19.3.1, ESM and CommonJS) and the React Compiler suite pass, and snapshotTargetCache.ts stays at 100% of lines and functions. ./react adds 1,666 bytes gzipped. 1,388 tests, lint, typecheck, size and the Chromium browser suite pass. Test-change: packages/classy-store/src/frameworks/react/utils/snapshotTargetCache/snapshotTargetCache.test.ts: decision 20; the traps it reached are gone, and "protects both the initial and cached copies against reflective mutation" covers the public fact Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c4ec4d1 committed the two JSON files as the benchmark wrote them, and bun run lint failed on their layout. No figure changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
T-08, decision 3. A suspended node kept a pointer to the container it left, and a touch walked those pointers up before it resumed. The walk caused a read that never returned (a frozen, removed container that the object points back to), a stale first snapshot after such a container was frozen, and a subscriber that missed the next write. Each node saves its children's versions when it is suspended, so each now resumes on its own when it is touched: the pointer and the walk go. Suspension stays. The traps call resumeIfDetached(), a small method that holds the check and calls the private resume() only for a suspended node. Calling resume() itself from the traps made a field read on Node about 9% slower (45.8 -> 50.1 ns) and a nested read 8% (133 -> 143), because V8 then could not inline it; with the small method both are back in the spread of the commit before (46.8 and 134). The call in createClassyStore() is redundant now and goes (decision 20). Tests, changed by decision 3, all fixes: two pins of the stale snapshot and the missed write in core.removedContainers.test.ts, three in core.unobservedObjects.test.ts, and the test without WeakRef in core.noWeakRefMemory.test.ts, which now shows that a held row no longer keeps its removed list alive and still works as a store of its own (only "it works" is promised there, and its file says so). New: the read that never returned, a write through a held object below a child still shared with the store, and a list freed once its last subscriber goes. The tutorial says that a subscription on an object that left the store lasts while the caller holds the store, the object or the unsubscribe function. Mutation on core.ts and ownership.ts: none unexplained; two entries updated, one stale removed, one added (the check in resumeIfDetached() is performance only). Measured against the commit before: the main entry 3,641 -> 3,606 bytes gzipped. Node, same command on both commits: store.read 45.8 -> 46.8 ns, store.read.nested 133 -> 134, store.write 200 -> 201, all inside the spread; read ratio 2.07. Bun store.read 32.1, write 163; every ratio inside its limit. 1,391 tests at full coverage, lint, typecheck, size, the Chromium browser suite and the floor guard pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Written by bun run test:mutation at checkpoint 2, on the code of 7737d15 (after T-07): 1,736 mutants over the seven target files, none unexplained, 51 equivalent, down from 78. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
T-09, decision 12. The get and set traps no longer walk the prototype
chain with Object.getOwnPropertyDescriptor on every access.
- An own key is data unless the node has seen an own accessor: a flag set
when the raw object is indexed and when a definition through the store
leaves an accessor. A field read takes no descriptor.
- An inherited key is answered by a table per prototype, filled on the
first miss. It records which prototype holds an accessor for the key, or
that none does, and holds no function: a cached getter result that is
still valid is returned, and only a recompute asks that prototype for its
current getter. A getter gone by then leaves the key to be read as data.
- A key absent from the whole chain is recorded only while the table holds
fewer than 256 keys, so reads by keys an object does not have cannot grow
it; past that, such a key is looked up at each read.
What a prototype changed after its first read through a store does is
unspecified, and the reference now gives today's answers: a redefined
getter runs at its next recompute; a removed getter, or one replaced by a
value, is seen at its next recompute (before 1.0, at once); an override
added nearer the instance is not seen; a getter added for a key read as
missing is seen but not memoized. core.prototypeTable.test.ts pins each,
with the bound, a dictionary with no prototype, own and defined getters,
and inherited setters. No existing test changes.
Measured against the commit before (ns per operation, --only runs):
Bun store.read 32.4 -> 11.8, store.read.nested 109 -> 47.6,
getter.cached 51.5 -> 32.3, store.method 233 -> 176, store.write
163 -> 142; read ratio 14.9 -> 5.93.
Node store.read 46.8 -> 34.9, store.read.nested 134 -> 106,
getter.cached 79.2 -> 72.1 (checkpoint 2), store.method 285 -> 258,
store.write 201 -> 195; read ratio 2.07 -> 1.54.
Every ratio inside its limit on both engines.
Size (decision 4): the main entry 3,606 -> 3,768 bytes gzipped, against
an estimate of +180. Its budget moves to 3,768 plus 2%, 3,844, under the
ceiling of 5,575, with the line in record 0004.
Mutation on core.ts and ownership.ts: none unexplained. Two entries added
(the own-accessor flag is performance only; deleting a cache entry for a
getter that is gone is memory only), two stale ones removed. 1,402 tests
at full coverage, lint, typecheck, size, the Chromium browser suite and the
floor guard pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…test "clear during storage restore wins until a later local write (editAfterClear=false)" failed twice during mutation runs, under eight workers, on mutants that change nothing, and marked them killed. After the last edit it slept debounce + 5 ms and then expected the debounced write. That sleep is armed before the store arms its own timer, in the microtask after the edit, so a pause of more than 5 ms between the two lets the sleep fire first. The test now waits for the write to arrive. Where no write is expected it still waits a fixed time, which can only let a wrong write slip past, never fail a right one. Same assertions. Not reproduced: sixteen full runs of the suite, eight at a time, and twelve parallel runs of the file passed on the old test as well as on this one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
T-10, decision 8. `delete store.dict.missing` returns true and does nothing else: the deleteProperty trap returns before it touches the node when the key is not an own key. A delete that removed nothing used to call every subscriber and replace the snapshot with an equal one, which broke guarantee 2: a write that changes nothing notifies no one. The same held for an index past the end of a list, a name the store only inherits, and the holes that sort and copyWithin delete. Tests: three new cases in core.characterisation.invariants.test.ts (a missing key, an index past the end, a key of a frozen container: no call, the same snapshot). Changed by decision 8, all fixes: three findings in core.fuzz.findings.test.ts, two pins in core.characterisation.invariants.test.ts, one getter pin in core.characterisation.getters.test.ts; and the randomized test in core.fuzz.test.ts loses its switch for the old behaviour. Same number of assertions in each file or more. Measured against the commit before: the main entry 3,768 -> 3,776 bytes gzipped (estimate +11); its budget moves to 3,852, with the line in record 0004. Ratios inside their limits on both engines (Bun read 5.31, write 2.19; Node read 1.52, write 1.27). Mutation on core.ts: none unexplained. 1,409 tests at full coverage, lint, typecheck, the Chromium browser suite and the floor guard pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
T-11, decision 2. Object.defineProperty on a store used to change the raw object in silence: no subscriber heard it, the snapshot missed it until the next write, a defined object stayed raw in snapshots, a redefined object was ignored, and a getter that read a redefined accessor kept its old result. The defineProperty trap now does a write's bookkeeping: - it resumes the node first, so a child defined on an object that left the store is connected once; - a data value becomes the property's child, or the old child is detached (a read-only property holds its value as it is); an accessor detaches the old child and marks the node as having own accessors; a length defined on an array detaches the elements past it; - a definition that replaces an accessor clears the node's getter cache, and so does a delete of an accessor; - subscribers are told when the value, the getter, the kind of property or its enumerability changed, so Object.freeze(store) stays silent. Every descriptor is still forwarded. No setPrototypeOf trap. The defined value is stored as it is given; T-12 stores the raw value. Tests: core.definitions.test.ts, 14 new cases. Changed by decision 2, all fixes: the defineProperty block of core.characterisation.invariants.test.ts (nine tests, and the length defined on an array), the redefined getter in core.characterisation.getters.test.ts, and the two redefined elements in snapshot.redefinedElements.test.ts. One pin, an accessor defined over a nested object, passed by coincidence and now says what happens: the object is detached. No file has fewer assertions. Measured against the commit before: the main entry 3,776 -> 3,847 bytes gzipped, 71 against an estimate of 49; the difference is the resume, the length case, the cache clear and the four change checks, which the spike did not hold. Its budget moves to 3,924, with the line in record 0004. Ratios inside their limits on both engines (Bun read 5.34, write 2.14; Node read 1.54, write 1.27). Mutation on core.ts: none unexplained; four entries added, for the length check, which only spares a scan. 1,419 tests at full coverage, lint, typecheck, size, the Chromium browser suite and the floor guard pass. The tutorial and the architecture page describe the trap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Summary
Prepares
@codebelt/classy-storefor its first stable release. It fixes two serious defects found in an audit of 0.11.0, removes behavior that existed only for compatibility with early versions, and makes the API and packaging corrections that would be breaking to make after 1.0.The proxy, snapshot and ownership design is unchanged. The library source diff is 15 files, +535/−246; the rest is tests, documentation, examples and build configuration.
Merging this does not publish anything by itself. It adds a
majorchangeset, so the Changesets release PR that follows will propose 1.0.0.Why
unshifton 3,000 rows with one mounted React component: ~2,440 mspushcalls with one synchronous subscriber: ~9,600 msbatch()persist()discarded stored data, then overwrote it with defaults, if anything in the store changed before hydration settled (including a field that is not persisted)ReactiveMaplookups scanned every entry through the store proxyget()on 10,000 entries: ~3.7 ms; building it withset(): ~18.9 sstore.config.nestedraised aTypeErrorfor any frozen input, including deeply frozen data from an immutable-update libraryshallowEqualtreated any two key-less objects as equalDateselector withisEqual: shallowEqualnever re-renderedTimings are from Bun on an Apple-silicon Mac.
Breaking changes
These are listed in the changeset, which becomes the 1.0.0 changelog entry.
subscribe()on a nested proxy observes only that proxy's subtree. Each call is its own registration.persistversions. Stored data whoseversiondiffers is ignored unlessmigrateis given. A record with no version counts as 0.shallowEqual. Stricter, as above.devtools(). Returns{dispose}like the other utilities, and its published types no longer augment the globalWindow.injectStoreis renamedinjectClassyStore.solid-jspeer range is^2.0.0. The adapter source is unchanged.engines.nodeis>=22.Other changes
batch(run)is exported. It groups direct writes made outside a store method into one synchronous notification, returns the callback's result, and nests with store methods.persist: a stored field is restored unless that same field was edited locally during the read; a background save can no longer replace the stored record before it is restored.withHistory: undo and redo delete top-level fields the restored entry lacks,undo()steps back over an edit made in the same tick, and unchanged fields keep their identity.PROXYABLEis exported so a class can opt into nested reactivity.ownership.tsis removed; dense arrays are snapshotted by index../package.jsonexport, and acheck:packagescript (publint --strictandarethetypeswrong) that CI runs.Documentation
batch(), reactive nested classes, frozen objects and snapshots stored in a store, per-field hydration, history restoration and collection identity.Docs site and examples
website/is now a workspace member and depends on the library withworkspace:*, like the Next.js example. Its live examples run the code in this repository, so they match the documentation at merge time and need no manual update after a release. Its separate lockfile is removed;docs:buildanddocs:devbuild the library first; the Docs workflow installs from the root lockfile.zodso that every package resolves one copy of the docs framework's core. Without it the workspace install produced two copies and the site's page types stopped resolving.devtools()returns.typechecknow also covers the Next.js example and the docs site.Dependencies
solid-js,@solidjs/web,@solidjs/compiler) with@solidjs/vite-plugin3.0.1; the rootoverridesblock is removed.vue-tscfails to load on 7,svelte-checkaccepts 5 or 6, the Angular compiler requires 6.0).@babel/corestays on 7, because with 8 the React Compiler plugin skips components with a compile error.@changesets/cli3 renameschangeset tag, which the release workflow calls, so that upgrade is left for its own PR after 1.0.0 is published.Validation
All of the following ran locally (macOS, Bun 1.4.4, Node 24 unless stated) and passed. Everything except the example builds, the Node-version fixtures, the Angular and Next.js consumers and the full-size performance and memory runs was repeated on the final commit, which changes the core. Those remaining suites last ran on
b18d772.publintandarethetypeswrong.The Node fixtures also pass on Node 26.13.
New tests include a seeded randomized differential test (60 seeds × 300 operations) and regressions for every fix. Temporarily disabling transactions, version propagation to owners, or parent unlinking makes them fail.
Test strength
Unit tests execute every line of the library except garbage-collection cleanup in
ownership.ts(one line and one finalizer callback). To check that the tests also notice wrong behavior, 655 single-line mutations (flipped operators, negated conditions, removed calls) were applied one at a time across 20 source files:The first 160 mutations were run against the original 695 tests and the other 495 after the first 20 tests had been added, so the original suite caught at most 560. The 35 misses were about 30 untested behaviors; 47 tests were added for them and for the few lines coverage showed unexecuted. None exposed a defect: every added test passed against the existing code. The most significant gap was that no test replaced a nested object with
nullor a primitive. The 59 remaining survivors are redundant guards, speed-only paths, or changes with the same result, judged by reading the code.The frozen-value fix was made after that sweep and checked the same way: 15 of its 22 new tests fail on the previous code, and breaking any functional part of the fix fails a test. Ordinary reads cost the same as before (about 37 ns for a nested read); a frozen array of 100,000 rows is scanned once when assigned and read in about 40 ns afterwards.
For the reviewer
moduleResolution: nodecannot resolve the subpath entries. This was already true in 0.x andcheck:packageignores that profile.🤖 Generated with Claude Code