Repository navigation
Commit 2fa787c
authored
host: the palette's full-text search finds nothing after the index mark in a read-only window (and answers more: 0) (#3320)
Fixes #3319
Owner: Dev-1
Reviewer: Birfy
## What is missing
In a read-only window — the second dsh over one home — ⌘K → **Messages
(full text)** answered with the writer's index only. `searchHomeChat`
caught each session up and then answered from `matchedRows`; in a
read-only window `catchUp` returns at once (`if (!index.writable ||
readOnly()) return Promise.resolve()`), so a part whose log ran past
`marks.through` contributed nothing: no row, no `stop` (the own-chat
surface has one, #3195), and `more: 0`, which reads as "there is nothing
else" while the message sat in the log.
Reproduced on base `73e0972dd87216ed851cefa2fa8d6b705c37c4de` with the
shape `core/test/chat-index-writers.test.js` already builds (a real
runtime, a temporary home, real SQLite, a writer that indexed three
lines and stopped): append `a fourth NEEDLE line` to the log, open the
read-only window (`heldBy: process.ppid`), then
- `searchHomeChat(['solo'], 'NEEDLE')` →
`{"rows":[],"every":true,"more":0}`
- the control, `'third'` → 1 row (the index and the query are fine; the
index is behind)
- through `/api/bot`, `chats.search` → `{"rows":[],"more":0}`
## Red first
New case `a read-only window searches the log past its index mark
(#3319)` in `core/test/chat-index-writers.test.js`, run at base
`73e0972dd872` with only that test applied:
```
not ok 4 - a read-only window searches the log past its index mark (#3319)
error: |-
{"rows":[],"every":true,"more":0}
0 !== 1
# tests 12
# pass 11
# fail 1
```
The case also asserts the row names its session and seq, that the index
the writer left still holds its 3 rows, and that `chats.search` through
the real `/api/bot` route answers the same. At the fixed tip: `# tests
12 / # pass 12 / # fail 0`.
## What changed
- `core/src/host/chat-index.js`: `catchUp`'s row-building pass is
factored out as `markedRows(sessionId, mark, events)` — same order, same
`keepAnswers` rule, same `turn`/`turnNo` tracking — so a row matched
outside the index cannot drift from the row the index holds; the writer
inserts the same objects.
- `unindexedRows()` reads each session whose `marks.through` is behind
its log (`eventsBackwards` from `through`, bounded by
`HISTORY_TIMEOUT_MS`) and matches the query in memory. Nothing is
written; a session this window cannot resolve or read is answered from
the index alone, with one warning, never an error for the palette.
- `withLogRows()` merges the index answer with those rows the way the
index answers: the rows holding every term when any exist, else the rows
holding some; newest first, deduplicated by `(session, seq)`; `more` is
the two totals minus what is shown, i.e. hits the cap left out, not "the
index stopped early".
- A writer window (which catches up first) and a read-only window whose
index is caught up answer byte for byte as before: `searchHomeChat`
returns `matchedRows`' own object unless the tail contributed a match.
- `docs/subsystems/core-host.md`: one bullet beside the palette section;
`changelog.d/3319-palette-readonly-search.fixed.md`;
`patches/ds-bot/0001-core-fixes.patch` and
`files/test/chat-index-writers.test.js` regenerated by `node
scripts/ds-bot-patches.mjs generate`.
## Verification at the tip
- `TZ=UTC npm run verify` → exit 0, run at
`bc0fe9635b9aff8f14cbadeba8ae1472e94d00a8` (the tree the pushed head is
rebuilt from): core **3446/3446**, plane 25, social 762, tree 157,
timeline 178, workflow 544, project 151, scripts+policy 735, interop 37,
live-e2e 34 — `# fail 0` in every suite.
- `core/test/chat-index-writers.test.js` alone: 12/12 (11/12 at base,
the new case the only red).
- oxlint core: `Found 91 warnings and 0 errors.` (the count base
carries).
- `node scripts/ds-bot-patches.mjs check` → `10 patches apply cleanly in
order`, `core/ equals ds-bot/ + patches/ds-bot/`; `canonical` →
`patches/ds-bot/ is what generate writes (generate is a no-op)`.
- `ARCH_DOCS_BASE=73e0972dd872 npm run arch-docs` (in `core/`) → `OK (6
changed file(s))`.
- `node .github/scripts/changelog.mjs check` → `4 fragment(s) in
changelog.d/ are well formed`.
- `node .github/scripts/check-mojibake.mjs --check` → `0 occurrences of
U+FFFD in 1789 text file(s)`.
## Not run
- `dev/smoke.mjs` (bench): not run.
- The CI `package` job's `build-client.mjs --check` is inside `verify`;
its pack check, typecheck and actionlint are not part of `verify` and
were not run here.
## Known limits
- The tail is read for a session whose mark is behind its log; one whose
agent this window cannot resolve is answered from the index alone, the
way `stop` already behaves.
- Nothing is written: a read-only window still never creates, repairs or
adds to `chat-index.sqlite`, and the case asserts the 3 rows the writer
left are unchanged.
- No UI face: the palette's rows and copy are unchanged; the host
answers rows it already had.
## Checkpoint
<!-- flybot:checkpoint -->
```json
{
"pr": 3320,
"claim": "Dev-1",
"issue": 3319,
"summary": "A read-only window's palette search answered only the writer's index, so a message already in the log past the mark was missing and more: 0 claimed there was nothing else. The index's catch-up pass is now markedRows(), shared by both paths, and searchHomeChat matches the events after each mark in memory and merges them with the index answer: every-term rows when any exist, else the some-term rows, newest first, deduplicated, with more still meaning hits the cap left out. Nothing is written, and a writer window or a caught-up window answers byte for byte as before.",
"files": ["core/src/host/chat-index.js", "core/test/chat-index-writers.test.js", "docs/subsystems/core-host.md", "changelog.d/3319-palette-readonly-search.fixed.md", "patches/ds-bot/0001-core-fixes.patch", "patches/ds-bot/files/test/chat-index-writers.test.js"],
"checks": { "ran": "TZ=UTC npm run verify", "result": "green", "at": "7ca6f0bf3e52a4e45cbe4fa091b5417b81578b52" },
"next": "review the read-only tail read, the merge ordering, and that the index is untouched at the pushed tip"
}
```
<!-- /flybot:checkpoint -->1 parent 73e0972 commit 2fa787c
6 files changed
Lines changed: 322 additions & 52 deletions
File tree
- changelog.d
- core
- src/host
- test
- docs/subsystems
- patches/ds-bot
- files/test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
255 | 283 | | |
256 | 284 | | |
257 | 285 | | |
| |||
286 | 314 | | |
287 | 315 | | |
288 | 316 | | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
310 | 320 | | |
311 | 321 | | |
312 | 322 | | |
| |||
390 | 400 | | |
391 | 401 | | |
392 | 402 | | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
393 | 472 | | |
394 | 473 | | |
395 | 474 | | |
| |||
403 | 482 | | |
404 | 483 | | |
405 | 484 | | |
406 | | - | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
407 | 490 | | |
408 | 491 | | |
409 | 492 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
306 | 353 | | |
307 | 354 | | |
308 | 355 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
477 | | - | |
| 477 | + | |
| 478 | + | |
478 | 479 | | |
479 | 480 | | |
480 | 481 | | |
| |||
0 commit comments