fix: user metadata named 'level' is a real field everywhere — the engine-internal node layer no longer shadows it in sort/filter/aggregation, and the indexing views stop stamping a phantom 0 into its column; index epoch 2 rebuilds existing brains at first open
Some checks failed
CI / Node 22 (push) Successful in 12m17s
CI / Node 24 (push) Has been cancelled
CI / Bun (latest) (push) Has been cancelled

Also completes the v8.10.2 write-granularity law for the transact() plan
path: a metadata-only batch update never rewrites the vector-bearing noun
record (planUpdate staged the unconditional save the update() fix removed).
Seven pins in tests/integration/level-field-shadow.test.ts including the
reporting consumer's exact repro rows; orderBy JSDoc documents the ordering
contract and the announced field-addressing law.
This commit is contained in:
David Snelling 2026-08-03 11:57:32 -07:00
parent cb717be275
commit 1a09be0628
8 changed files with 259 additions and 17 deletions

View file

@ -551,7 +551,23 @@ export interface FindParams<T = any> {
cursor?: string // Cursor-based pagination
// Sorting
orderBy?: string // Field to sort by (e.g., 'createdAt', 'title', 'metadata.priority')
/**
* Field to sort by. User metadata fields sort by their stored values
* including natural names like `level`, `rank`, or `score` (an engine-internal
* field can never shadow your metadata; fixed 2026-08 after a production
* report). System timestamps (`createdAt`, `updatedAt`) sort by entity age.
*
* Ordering contract (identical on the pure-JS engine and the native
* accelerator): entities missing the field sort LAST in both directions
* they are never dropped from the result; ties break deterministically.
*
* NOTE the field-addressing law is changing (announced 2026-08): bare
* names will mean user metadata ALWAYS, and system fields will be reached
* explicitly as `system.<field>` (e.g. `system.createdAt`), with typed
* refusals for unresolvable names. Until that release, bare `createdAt`
* and friends keep resolving to the system fields as documented above.
*/
orderBy?: string
order?: 'asc' | 'desc' // Sort direction: 'asc' (default) or 'desc'
// Advanced options