fix(8.0): real bugs surfaced by integration hardening — where-intersect, related() offset, relate() updatedAt
Three of the five bugs the rot pass surfaced (correct inputs → wrong output), fixed:
1. where-filter dropped all but the last operator on a field. getIdsForFilter()'s
per-operator loop overwrote fieldResults each iteration, so
{ year: { greaterThan: 2009, lessThan: 2020 } } kept only lessThan. Now each
operator's match set is AND-intersected (multi-operator-per-field works).
(metadataIndex.ts)
2. related({ offset }) ignored the offset — getVerbs() zeroed it and smuggled it via
an unimplemented cursor, so every page returned items [0, limit). Now the real
offset is passed through to getVerbsWithPagination (which slices [offset,+limit)).
(baseStorage.ts) — verified: get-relations-fix pagination test passes.
3. relate() never persisted updatedAt, so reads fabricated a fresh Date.now() each
call (non-idempotent). Now createdAt and updatedAt share one timestamp at create.
(brainy.ts) — verified: get-relations-fix equivalence test passes.
Follow-ups (precisely diagnosed, not papered over): exclusive range bounds —
ColumnStore.rangeQuery(field,min,max) is inclusive-only, so getIdsForRange() drops
includeMin/includeMax (metadataIndex.ts:996) and lessThan/greaterThan behave as
lte/gte when the column store is active (the dual-bound test's popularity:95 boundary
stays red); counts not rehydrating after restart; unscoped VFS path-cache.
This commit is contained in:
parent
e5997a1516
commit
5eaf579937
3 changed files with 26 additions and 13 deletions
|
|
@ -2583,6 +2583,9 @@ export class Brainy<T = any> implements BrainyInterface<T> {
|
|||
|
||||
// Prepare verb metadata
|
||||
// User metadata spread FIRST, then system fields ALWAYS win (prevents collision)
|
||||
// One timestamp for both createdAt and updatedAt so a never-updated edge reports a
|
||||
// stable updatedAt (=== createdAt) instead of a fresh Date.now() fabricated per read.
|
||||
const relateTs = Date.now()
|
||||
const verbMetadata = {
|
||||
...(params.metadata || {}),
|
||||
verb: params.type,
|
||||
|
|
@ -2593,7 +2596,8 @@ export class Brainy<T = any> implements BrainyInterface<T> {
|
|||
weight: params.weight ?? 1.0,
|
||||
...(params.confidence !== undefined && { confidence: params.confidence }),
|
||||
...(params.service !== undefined && { service: params.service }),
|
||||
createdAt: Date.now(),
|
||||
createdAt: relateTs,
|
||||
updatedAt: relateTs,
|
||||
...(params.data !== undefined && { data: params.data })
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue