8.4 KiB
8.4 KiB
Changelog
All notable changes to @gamecult/cultcache-ts are recorded here, following
Keep a Changelog.
[Unreleased]
Breaking
- A single-file store marked
cultcache.store.v3(it holds an element id, written by the C# runtime) is read, and a rewrite keeps the mark and the ids; this runtime does not decide when a document carries ids. A runtime from before this change refuses a v3 store by name, so rolling back to an older release after a store has been written as v3 is one-way: there is no carry-back, so restore from a copy taken before upgrading. indexesare unique, as C#[CultIndex]: a write or a load that leaves two records of a type holding one non-blank value under one alias is refused naming both keys and the alias, and writes nothing. Index text is the C# canonical text (booleansTrue/False, integers as digits, doubles as the exact expansion, blank values never indexed), so an empty string is no longer a value.registerIndexover held duplicates installs nothing. A newrolesmap names the many-row selection aliases (never indexed for lookup, same catalogindexAlias). The per-key migration rule is in the README; classify every key before the CultLib your tools load is updated. The refusal verdict is the contract, its text is informational.- The single-file reader (v1 and the legacy envelope array) refuses a store that holds two records under one key as
StoreUnreadableError; a store that opened before may now be refused. Repair it by removing the extra record with the runtime that wrote it. - A
put,pushorpushAllthat would land a second type under a held key (against the file, or within one batch) is refused withSchemaConflictError, and nothing is written. The written type may replace the record when its catalog entry carries the stored schema id as its own or lists it compatible (a type renamed under a stable id restamps the record, as C# does); otherwise retyping a key is a delete, then a put. The C# allowance for an undeclared older id of the same schema name that reads whole is not ported: a same-named type keeps passing, including one that drops persisted slots, which C# refuses. - Same-type writes replace by key; in one
pushAllbatch the last entry for a key wins. - A store whose canonical-schema catalog slot is not a string is refused as
StoreUnreadableError. - The cache holds one record per key (variants:ruling:cache-refuses-retype). A
putorputEnvelopethat lands a second type under a key the cache holds, or under a key a store carries foreign, is refused withSchemaConflictErrornaming the key, even with no store (a memory-only cache used to hold both types at the key). A type that owns the held record's schema id (as for the store) replaces it, unless the held record is in a store other than the written type's home: that rename is refused withSchemaConflictError(remove the record first). Two stores holding one key, registered or foreign, refuse the load and admit nothing. A store'sdeleteremoves the record whose stored schema id the removal's type owns, whatever the arrived record'stypestring. - A store holding a record no registered type claims now loads (it used to throw "No schema is registered..."): the cache does not serve the record, lists it in
foreignRecords(), keeps its bytes through every write, and refuses aputor adeleteat its key withSchemaConflictError(variants:ruling:unheld-removal-refused-at-commit). Registering a type that claims its schema id serves it at the nextpullAllBackingStores.
Added
CultCache.foreignRecords(): the{key, schemaId, schemaName, storedAt}of every record the last pull carried and no registered type claims, sorted by key ordinal.
Changed
- Opening a legacy (pre-v1) store is a pure read: payloads that were not bytes are normalized in memory and the file is left as it was, so a codec that refuses the content cannot lose the old bytes. The next push, delete or flush rewrites the file as v1, merging what the open read.
SingleFileStoreReadno longer carriesrepairedLegacyPayload; no consumer used it.
[0.15.0]
0.14.1 and 0.14.2 were never tagged or published; this entry carries them with the Unreleased work, and cultcache-ts-v0.14.0 is the previous release.
Breaking
- A single-file store written as
cultcache.store.v3is read and written: a store the C# runtime marked v3 (it holds a record with an element id: an owned list element with a[CultElementId]member) keeps its header here, and is carried through every rewrite with its ids; this runtime never drops the mark. A runtime from before this change refuses a v3 store by name. - A single-file store refuses a zero-byte file as
StoreUnreadableError; only a path with nothing at it is an empty store. A header this runtime does not read is refused, and the refusal echoes the header only ascultcache.store.v<digits>. - A write over a file the reader refuses (
StoreUnreadableError, frompush,pushAllanddelete) refuses and leaves the file as it is. A flush used to replace such a file. A write set cannot merge with a disk it cannot read, so the file is repaired or removed by its owner before the store writes again. A fullpushAllover a file with no readable stamp does not replace it: the reader refuses it. The stamp rule has one owner,refuseUnreadFormat, asked only by the one reader that every write consults under the lock. The reader judges the stamp from the header before it decodes the body, so a newer store is refused by name whether or not its body is whole. - A dangling symbolic link at the store path is an I/O error with code
ENOENT, not an empty store.
Added
@gamecult/cultcache-ts/browser, also what a bundler resolves for the package root under thebrowserexport condition: the root surface withoutSingleFileMessagePackBackingStoreandreadSingleFileStore, so it imports nonode:*built-in and nokoffiand bundles with esbuildplatform: "browser". The Node entry exports exactly what it did.readSingleFileStore(path), the one synchronous reader of a single-file store, for consumers that must read a store file rather than decode it themselves.pullAll,push,deleteandpushAllask the same reader.StoreUnreadableErrorfor a store file this runtime cannot read,SchemaConflictErrorfor a write the catalog cannot describe, andschemaIdentityOfwith its result typeCultCacheSchemaIdentity(schemaId,schemaName,schemaVersion,compatibleSchemaIds), the one derivation of a definition's identity.- The document payload codec, exported from
@gamecult/cultcache-ts/document:decodeDocumentPayload,encodeDocumentPayload, and the two named byte escapesdocumentPayloadFromBytesanddocumentPayloadBytes. SingleFileStoreRead, exported: the result type ofreadSingleFileStore(absent,format,envelopes,repairedLegacyPayload).CultCacheInspection.formatisStoreFormat | "legacy.envelope-array": it reportscultcache.store.v3for a v3 store.- A soft
pushAllwrites only where nothing is at the path, leaves a store it can read byte for byte, and refuses what the reader refuses. SingleFileMessagePackBackingStoretakes a cross-process write lock on<file>.lock, interoperable with the C# and Rust runtimes (flockon Unix,LockFileExon Windows).pushanddeleteread the current file, merge and replace it under the lock, so concurrent TypeScript and Rust writers no longer lose each other's records across those calls. A fullpushAllstill replaces the whole store, so records a concurrent writer added are lost to it. C# writes are not all alike: a conditional commit on a clean store lands onto the file as it is, but C# writers can still overwrite records a concurrent TypeScript writer added.- The staged file is fsynced before the replace, and on Unix the directory after it. A directory sync failure after the replace is reported as replaced but not durable.
checkPayloadDepthis re-exported from@gamecult/cultcache-ts/document, so dependents (cultnet-ts/content) bound payload nesting with the same check the cache applies on decode.
Changed
- The Windows replace is a POSIX-semantics rename first (it lands while C# and Rust readers
hold the store open), falling back to a write-through
MoveFileExW, with 25 attempts 20 ms apart on errors 5, 32 and 33. Writers wait up to 30 s for the lock.
Dependencies
koffi3.3.0, loaded only on the first write.