Commit 7bf217e
committed
chore(storage): pre-merge polish from final review (easy minors)
Six low-risk follow-ups from the final pre-merge review. Nothing here
changes behaviour beyond error wording and JSDoc; the public API
surface tightens slightly.
#4 Hide cursor format internals from the public API.
`common.ts` switches the Cursor module from `export *` to a
selective re-export of `PageCursor`, `encodeCursor`, `decodeCursor`,
`assertCursorMatches`, and `MAX_CURSOR_LENGTH`. `CursorPayload`
(the wire shape) and `CURSOR_VERSION` (the format integer) are now
internal-only — callers can't depend on the encoding format, which
keeps it free to evolve. The unit test inlines the version constant.
#6 ScopedTabularStorage emits `query` from `getPage`/`queryPage`.
Cache invalidators that listen for tabular reads were missing
page reads. Switching a caller from `query` to `getPage` would
silently invalidate their invalidation logic. The emitted criteria
is the user-facing criteria (without our injected `kb_id`).
#7 Document `pages()` defensive `.slice()`.
The async generator yields a fresh copy of `Page.items` per page so
callers can't poison subsequent iterations by mutating the yielded
array. JSDoc now says so.
#8 Cursor JSON-roundtrip test.
Pins the contract that cursors are safe to persist and re-load
across process boundaries (URLs, durable queues, etc). The codec is
pure so this should always work, but a one-line test locks it in.
#10 Hoist the `jsToSqlValue` coupling note.
`ITabularStorage.query` JSDoc now spells out the third-party-backend
implementation contract: bind SearchCondition values through the
same conversion path as row values going *into* the store, so the
cursor pagination machinery's round-trip comparison works.
#11 More actionable `StorageInvalidLimitError` message.
Says "must be a positive integer, got X" instead of "must be greater
than 0, got X" so a user staring at `limit: 1.5` knows fractional
values are the problem.
914 vitest storage / 934 bun-native / 22 scoped storage / 322 queue
tests pass. Pre-existing build issues on `chrome-ai` (from main's
`bootstrapWorkglow` refactor) and the `KnowledgeBaseRegistry`
`registerInputResolver` arity mismatch are unaffected and unchanged.1 parent 8cc66a2 commit 7bf217e
6 files changed
Lines changed: 52 additions & 4 deletions
File tree
- packages
- knowledge-base/src/knowledge-base
- storage/src
- tabular
- test/src/test/storage-tabular
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
186 | 192 | | |
187 | 193 | | |
188 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
18 | 24 | | |
19 | 25 | | |
20 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
466 | 469 | | |
467 | 470 | | |
468 | 471 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
363 | 372 | | |
364 | 373 | | |
365 | 374 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
| |||
104 | 108 | | |
105 | 109 | | |
106 | 110 | | |
107 | | - | |
| 111 | + | |
108 | 112 | | |
109 | 113 | | |
110 | 114 | | |
| |||
125 | 129 | | |
126 | 130 | | |
127 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
128 | 147 | | |
0 commit comments