Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Nodra is a concurrency-safe reactive state store for Go desktop applications. Th
- `bridge/`: the optional bridge to the web pages of a MyGo app, with its dependency-free JavaScript client in `bridge/client` (tested with `node --test bridge/client/nodra.test.mjs`); the core never imports it.
- `nativeui/`: the optional Edit menu integration for MyGo native UI, which imports MyGo's `ui` package; the core never imports it, so apps without native UI do not link `ui`.
- `examples/`, `example_test.go`, `public_api_test.go`: runnable examples and the external-package tests that define the v1 contract.
- `docs/`: `public-api.md`, `architecture.md`, `compatibility.md`, `support.md` and the release evidence. They are release inputs: changing them needs a compatibility review and a changelog entry.
- `docs/`: `public-api.md`, `architecture.md`, `compatibility.md`, `support.md` and the release evidence. They are release inputs: changing them needs a compatibility review. A contract change reaches the changelog only through a pull request title of a listed type (`feat`, `fix`, `perf` or `deps`, with `!` when breaking); `docs` is hidden, so a docs-only clarification is not listed (see Releases and `docs/compatibility.md`).
- `site/`: the website (TanStack Start, TanStack Router, Tailwind CSS v4, React 19 on Cloudflare Workers).

## Go module
Expand All @@ -19,7 +19,7 @@ Follow [CONTRIBUTING.md](CONTRIBUTING.md). Before a pull request run `go test ./

## Releases

release-please publishes the module from Conventional Commits on `main`, and pull requests are squash-merged, so the pull request title becomes the commit that release-please reads.
release-please publishes the module from Conventional Commits on `main`, and pull requests are squash-merged, so the pull request title becomes the commit that release-please reads. `CHANGELOG.md` is generated by release-please from those titles and is not edited by hand: describe a change in the pull request title, not in a hand-written changelog section. Only `feat`, `fix`, `perf`, `deps` and `revert` titles are listed; `docs`, `chore`, `ci`, `test`, `build`, `refactor` and `style` are hidden (`changelog-sections` in `release-please-config.json`).

- `site/` is excluded from releases, but only for commits whose files are all inside `site/`. A squashed commit that also touches anything outside `site/` counts as a library change, and a `feat` or `fix` title then publishes a new Nodra version. v1.1.0 was released this way by a website pull request that also edited CI and release configuration.
- A dependency change that consumers inherit, such as raising the required MyGo version, uses the `deps` type: it publishes a patch release and is listed under Dependencies in the release notes (`changelog-sections` in `release-please-config.json`).
Expand Down
71 changes: 0 additions & 71 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,76 +1,5 @@
# Changelog

## Unreleased

### Features

* **history:** add `History.Clear`, which drops every undo and redo step and makes the store's current value the new baseline, so after File > Open, New or Revert replaces the document Undo can no longer restore the previous one; Status publishes the empty stacks, so `nativeui.InvalidateHistory` and other Status subscribers follow without closing and re-tracking. It returns `ErrHistoryGroup` while a group is open, `ErrHistoryBatch` inside an open `Batch` and `ErrClosed` after `Close`; the texts of those two errors now name clearing as well as undo and redo, and their identities are unchanged
* **bridge:** add `Options.FrameInterval`, the least time between two frames of one watch: changes within it coalesce into the latest, which is sent when the interval ends, and a change after a quiet spell is sent at once. Zero keeps the previous behaviour, in which a page receives every change until about 1 MiB of frames is queued; docs/bridge.md suggests a display frame for fast-changing state
* **core:** add `Derived.Done`, closed by `Close`, so a bridge watch of a derived value ends with `ErrClosed` when the derived value closes
* **persistence:** add `AsyncOptions.MaxWait` to bound how long continuous updates can postpone an `AutoSaveAsync` debounced write; every update restarts the trailing debounce, so a store updated more often than `Debounce` was not written until Flush or Close. Zero keeps today's unbounded behaviour, and the postponement is now documented on `AsyncOptions` and in docs/architecture.md
* add the `nodra_nomygo` build tag for programs that use only the core and DevTools: it leaves out `Invalidate`, `InvalidateSelector`, `InvalidateSelectorWith`, `InvalidateProjection` and `InvalidateProjectionWith` so MyGo is not linked, which avoids MyGo's main-thread lock and makes a `CGO_ENABLED=0` Linux build statically linked; the default build and API are unchanged, and CI checks the tagged `examples/basic` build has no `PT_INTERP` header. docs/support.md now says the default Linux pure-Go build is dynamically linked, docs/architecture.md describes the tag, and docs/compatibility.md records it as part of the v1 contract with the v2 plan to drop MyGo from the root package
* **bridge:** let the web pages of a MyGo app follow a Store and change it through registered actions: `bridge.Expose` and `bridge.ExposeProjection` serve a source, or the part of it pages may see, through a bound service whose watch sends a frame only when the encoded value changes and coalesces to the latest while a page is slow; `bridge.Handle` registers the actions pages dispatch; `Options.AllowRead` and `Options.AllowDispatch` decide per page. A dependency-free JavaScript client (`bridge/client`, also served from Go as `bridge.Client`) fits React's `useSyncExternalStore`. See docs/bridge.md and examples/web
* **nativeui:** make a native UI window's Undo and Redo act on a History: `nativeui.UndoShortcuts` registers Cmd+Z and Shift+Cmd+Z (and Ctrl+Y on Windows) while history can act, so with MyGo 0.7.4 on macOS the Edit menu enables its items only then, and a focused text input keeps its own undo; `nativeui.InvalidateHistory` redraws the window when that changes. A separate subpackage, so apps without native UI do not link MyGo's ui package
* **async:** `ActionMetrics` gains `Superseded`, and superseded LatestWins runs are counted there instead of in `Failed`, matching the `TaskSuperseded` phase; docs/architecture.md describes the classification

### Bug Fixes

* **persistence:** an `AutoSaveAsync` writer with a `Debounce` no longer writes updates made during a save as soon as that save returns: they wait for the debounce and `MaxWait`, counted from when the save returns, so storage slower than the update rate no longer turns the writer into back-to-back writes. A zero `Debounce`, or a Flush or Close waiting on the save, still writes them at once; docs/architecture.md and the `AsyncOptions` doc say so
* **persistence:** `LoadWithRecovery` on a closed Store returns `ErrClosed` before reading anything, and a Store that closes while the primary is read returns `ErrClosed` without reading the backup, as documented; with a damaged primary it used to read and decode the backup as well and return a `RecoveryError`. An invalid configuration and cancellation still take precedence over `ErrClosed`
* **core:** a `Store.Watch` or `ReadOnly.Watch` stream that closes because the store closed first receives the store's final snapshot when it has not delivered that version; a write that committed before `Close` but was still notifying its subscribers used to be dropped, and so was the value of a batch closed before it published. `Store.Watch` now has a doc comment stating its buffering, that it does not send the current snapshot, and this close behaviour, and docs/architecture.md says the same
* **bridge:** a watch whose source closes sends the source's final value before ending with `ErrClosed`; with `Options.FrameInterval` set, a change held back by the interval used to be dropped, so a page following a task's status never saw it finish, and without an interval a change racing the close was lost about half the time. The final frame still keeps the interval. Stopping the exposure or closing the bridge ends a watch without starting another frame, also for a change made while a send blocked, which used to go out after the stop about half the time; `Options.FrameInterval`, `Bridge.Watch` and docs/bridge.md now state this
* **core:** `Derived.Close` no longer deadlocks against a store update whose callback reads that derived value: it used to unsubscribe from the store while holding its own lock, and the update held the store lock while waiting for it, which left the store locked for good. Close now unsubscribes after releasing its lock, and a notification that arrives in between is still dropped
* **core:** an `AtomicGroup` commit into a `NewWithClone` store no longer shares slices or maps with the candidate its `AtomicUpdate` callback received, so changing a retained candidate after the group returns no longer changes the store's value without a new version or notification; `Atomic2` and `Update` already committed a separate clone
* **persistence:** `FileStorage.Save` on Windows no longer fails with "Access is denied." when another handle briefly holds the file it replaces, such as an antivirus or indexer scan, a sync client or another process's Load; it retries access-denied, sharing-violation and lock-violation failures with a jittered backoff for up to about 2 s and stops early when the save's context ends. Other systems are unchanged
* **persistence:** `FileStorage.Save` on Windows no longer fails with "Access is denied." when another handle briefly holds the file it replaces, such as an antivirus or indexer scan, a sync client or another process's Load; it retries access-denied, sharing-violation and lock-violation failures with a jittered backoff for up to about 2 s per replaced file and stops early when the save's context ends. Each file a Save replaces gets its own limit (the primary, the .bak with `Backup`, the journal and commit marker with `Journal`, and the primary again when Load recovers a journal), so one Save can wait several times as long; the context bounds the total, and a synchronous `AutoSave` or `AutoSaveWithErrors` blocks the updating goroutine for that time, as their docs now say. Other systems are unchanged
* **persistence:** a `FileStorage.Perm` without the owner-write bit, such as 0400, no longer makes every Save after the first fail on Windows: Windows maps that Perm to the read-only attribute, which MoveFileEx refuses to replace, so Save now clears it on the file it replaces, as rename on other systems ignores the old file's mode, and restores it if the replacement fails. `Perm` is now documented, including that on Windows only the owner-write bit has an effect

### Bug Fixes

* **async:** retry backoff saturates instead of overflowing, so `MaxBackoff` still bounds every delay when `MaxAttempts` is large; canceling, superseding or closing during a backoff delay no longer starts one more work attempt with a canceled context
* **scope:** a late `Scope.Observe` contains a panicking stop function and returns `ErrClosed` joined with a `PanicError`, like a late `Defer`

### Bug Fixes

* **core:** an update callback that reads another store no longer deadlocks every store when an `Atomic2` or `AtomicGroup` starts meanwhile; store reads no longer take the global transaction gate, and the docs state that update callbacks may read other stores but must not write to any store
* **core:** transactions settle derived values by height, so a `Combine` whose inputs are Stores, read-only views or derived values at different depths, and anything derived from it, no longer sees a half-applied transaction, and a derived value settles on the newest snapshot of a transaction. An application `Observable` counts as height zero, so one that forwards a derived value is still not settled after it
* **core:** a `Derive` or `Combine` constructed while a transaction is being dispatched no longer loses its catch-up and stays stale
* **core:** an `Atomic2` or `AtomicGroup` commit into a store with an open batch becomes the batch's publication boundary: the batch no longer republishes the transaction's value, and each mutation's `Previous` is the value subscribers last received
* **bridge:** `Expose` and `ExposeProjection` return `ErrInvalid` for a zero `ReadOnly` (or a `Store` or `ReadOnly` without a store) instead of serving its zero value through a watch that never ends
* **core:** closing a store inside an open batch gives its last committed value a new version instead of one already published with an older value

### Bug Fixes

* **persistence:** a journaled FileStorage no longer fails every Load, WithConflictDetection and CheckedFileStorage call after a crash or failed removal during journal cleanup: cleanup now removes the commit marker before the journal, and recovery discards a commit marker that has no matching journal instead of returning "read committed journal" or "committed journal checksum mismatch"
* **persistence:** `FileStorage{Durable: true}` no longer fails every Save on Windows with an access-denied directory sync after the primary was already replaced, which also skipped the backup; Windows has no directory fsync, so the sync is skipped there, as the journal path already did
* **persistence:** `LoadWithRecovery` now falls back to the backup when the primary fails to decode with an error that wraps `ErrInvalidPersistence`, such as a damaged `VersionedJSONCodec` envelope; it used to return that load error as if the configuration were invalid and never tried the backup. Configuration errors still stop before the backup and are not reported as `RecoveryError`: the bare sentinel from a storage or codec (an empty `FileStorage` path, an `AESGCMCodec` without `Inner` or `Keys`, a `VersionedJSONCodec` with `Version` below 1) and any read-stage rejection, such as a `CheckedFileStorage` primary that became a symlink
* **persistence:** the `AutoSaveAsync` worker now turns a panic from `PersistenceOptions.Validate`, `Codec.Encode` or `Storage.Save` into a `PanicError` write failure, reported through Errors, Flush and Close with the state left pending, instead of crashing the process; synchronous Save and AutoSave still propagate panics to their caller

### Bug Fixes

* **core:** a `Combine` no longer projects or publishes a pair of input values that no committed state contained when concurrent `Atomic2` or `AtomicGroup` transactions write the same stores: settling one transaction published whatever pair the Combine held at that moment, which could hold half of another transaction, so a projector that relied on an invariant every transaction keeps, such as an index into a slice written in the same transaction, could panic. Combine now checks that both inputs still hold a pair, down to the Stores below derived inputs, before projecting it, and otherwise reads a pair both hold, recomputing derived inputs that have not caught up, so concurrent writers may see fewer intermediate values. The same check covers a write outside a transaction that reaches a Combine through one input before the other
* **core:** a `Combine` constructed while a transaction was being dispatched could start from, and keep until the dispatch ended, a pair that mixed values from before and after the transaction, because it read its two inputs one after the other and its catch-up could publish one input's new value with the other's old one; it now reads its first pair the same consistent way, including through derived inputs that have not settled the transaction yet

### Performance Improvements

* **core:** `Invalidate`, `InvalidateTarget`, `Persistence.AutoSave`, `AutoSaveWithErrors` and `AutoSaveAsync` no longer make a `NewWithClone` store clone its whole state for them on every update; they use a publication only as a change signal, so a Store or ReadOnly source now notifies them with the borrowed snapshot, and each update saves one clone per helper (from 3 to 2 clones per update with `InvalidateTarget` or `AutoSaveAsync`, from 4 to 3 with `AutoSave`). Out-of-order notifications are still dropped, and derived values and application `Observable` types, including ones that embed a Store, are still observed through their own `SubscribeSnapshot`
* **bridge:** a page's `Watch` of an exposed Store or ReadOnly no longer makes a `NewWithClone` store clone its whole state for the watch's change signal on every update; the watch borrows the publication and reads the state itself, as before, so each open watch costs one clone per update instead of two (with four watches, from 10 to 6 clones per update). Frames are unchanged, and derived values and application `Observable` types are still observed through their own `SubscribeSnapshot`
* **core:** the default selector equality, used by `SubscribeSelector`, `SubscribeProjection`, `InvalidateSelector` and the other selector helpers when no `Equals` is given, decides once per subscription whether the selected type can hold an interface value; scalars, pointers and structs or arrays of them now compare with `==` without reflection, which removes about 16 allocations per notification for a three-field struct. Results are unchanged, including pointer identity and NaN, and types that can hold an interface, slices and maps still use the reflective comparison

### Dependencies

* support MyGo 0.9.0; go.mod now requires it instead of 0.7.4, so a module that requires Nodra builds with MyGo 0.9.0 or newer. Nodra's API, the invalidation helpers and `nativeui` keep the same signatures and behaviour; apps should check MyGo's own breaking changes since 0.7.4: keys in `HandleInput` (0.8.0) and the removal of `sqlite.LibraryPath` (0.9.0)
* support MyGo 0.7.4; go.mod now requires it instead of 0.6.3 (by way of 0.7.2 and 0.7.3), and the invalidation helpers keep the same signatures and behaviour

### Documentation

* **bridge:** docs/bridge.md declares the `PageState` its Go example exposes, with the `json:"count"` tag its React example reads as `state?.count`; an untagged field is sent as `Count`, so a page written from the document showed its placeholder forever. A test checks that the page reads keys the documented type is sent with
* the copy-on-write `UpdateErr` example in docs/architecture.md copies the map with `make` and `maps.Copy` instead of `maps.Clone`, which returns nil for a nil map, so the example no longer panics on its first update of a zero-value state; a test now runs the example and keeps the document identical to it
* **core:** state that a derived value with a nil equals function notifies on every accepted source version, and that an equality function is what filters unchanged values
* document every root-package function in Go doc; index `Define`, `DefineWithClone`, `Definition`, `BindField`, `Field`, `Derived`, `NewMemoryKeyProvider`, `NewScope` and the MyGo invalidation helpers in docs/public-api.md; list the methods of every re-exported type under that type in docs/public-api.md and in the package comment, including ReadOnly, the MemoryKeyProvider key-rotation methods, FileStorage, CheckedFileStorage and the codecs, because Go doc shows no methods for the root aliases; remove a duplicated paragraph from docs/architecture.md. No API or behaviour changes
* record v1.0.0 publication checks, checksums, API evidence, and package documentation; activate the published v1 compatibility policy
* state in docs/architecture.md and the Go docs that `SubscribeMetrics` callbacks are not covered by `Task.Wait` or `AsyncAction.Close` and can run after unsubscribing, and that `Metrics` read after `Close` is the final aggregate

## [1.5.0](https://github.com/yldm-tech/nodra/compare/v1.4.0...v1.5.0) (2026-11-14)


Expand Down
Loading
Loading