Repository navigation
Commit 73d0240
fix(service-knowledge): a source naming an unmounted adapter is logged once at boot (#37951)
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP
Fixes #37479
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 运维人员看启动日志时,一个指向未挂载存储的知识源从两行告警变为一行错误,错误里写明知识源、存储名和可选的已挂载存储;用户无感。
- 属于知识检索平台(AI 检索)史诗,替看启动日志的运维人员去掉重复噪音。
- 出错只会让这条错误多一行或少一行,检索与建索引的行为不变,可直接撤回。
- 无。
## What changes
- `packages/services/service-knowledge/src/knowledge-service.ts`
`buildIfDue`: at boot, a source whose adapter is not mounted is skipped
by the first-build pass without a line. Before, the pass read its index
state, `getAdapter` threw the unmounted-adapter refusal, and the pass
logged it at `warn` as "is not built at boot: what the adapter holds
could not be read (...)", beside the `error` that
`reportUnmountedAdapters` already prints at `kernel:bootstrapped`. Now
the boot says it once, at `error`, naming the source, the adapter and
the mounted adapters.
- On reload (a `knowledge_source` item added while the process runs)
nothing changes: no boot reading runs then, so the reload build's `warn`
is still the one line that names the source.
- Indexing and searching such a source still answer the coded
`SERVICE_UNAVAILABLE` 503 (PR #37442); not touched.
This is item 1 of the re-scope (card comment 7187970703). Item 2, a
publish or `os validate` refusal of an adapter name no deployment can
serve, is NOT in this PR: it would narrow what is accepted, and the area
decides. Options are in the dev report on the card. That is why this PR
says `Part of` and leaves the card open.
## Tests
- New pin in `src/__tests__/knowledge-build.test.ts`: with a data engine
bound, one mounted source and one naming `pgvector` (not mounted), the
boot pass plus the boot reading produce exactly one log line naming
`'docs'` across debug/info/warn/error. That line is at `error` and names
the adapter as not mounted. The mounted source is still built (`status:
'done'`).
- Ablation: with the new guard line replaced by a comment, the pin goes
red: `expected [ [ 'warn', …(1) ], [ 'error', …(1) ] ] to have a length
of 1 but got 2` (1 failed, 22 passed). With the line restored, the file
is green (23 passed).
<details><summary>Package test and typecheck (head 13f32fc)</summary>
`pnpm --filter @objectstack/service-knowledge test && pnpm --filter
@objectstack/service-knowledge typecheck` under the verify lock:
`VERDICT command-exit 0`, Test Files 17 passed (17), Tests 529 passed
(529). `typecheck` is `tsc --noEmit && pnpm check:test-typecheck`, so
the test files are type-checked too.
</details>
## Acceptance notes
- Item 2 of re-scope 7187970703 (a publish or `os validate` refusal) is
closed by area decision D, with no publish-time refusal added. The
refusal point is boot: `reportUnmountedAdapters` prints a coded error
naming the source and the adapter. `searchWithRefusals` lists such a
source as refused (`knowledge-service.ts` near :1882), and index and
search answer the coded 503 (PR #37442 and this PR). Options A
(save-time admission) and B (a `ragflow` tombstone) stay in the dev
report on the card, for a future card.
- The claim's file surface pointed at `:372` as "the boot build pass's
kept(...) line". On origin/main 73d5e34, `:372` is
`dropMetadataSource`'s `kept(...)`, which runs when a source is removed,
not at boot. The second boot line comes from `buildIfDue` (the `warn` of
an `unreadable` index reading). The fix sits there, and
`dropMetadataSource` is not touched.
- Public surface: no exported type, export or wire shape changes. No
dependent package owes a test.
## Verification
Read first: `knowledge-service.ts` `buildIfDue` (the one added guard
line), then the new pin.
Two-minute check: `pnpm --filter @objectstack/service-knowledge exec
vitest run --maxWorkers=2 src/__tests__/knowledge-build.test.ts` should
show 23 passed. Delete the guard line `if (trigger === 'boot' &&
!this.adapters.has(entry.handed.adapter)) return;` and the pin fails
with 2 lines (warn, error) where it expects 1.
<details><summary>Derived gates (local, head 13f32fc): 68 exit 0, 2
NOT MEASURED</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 70 families from the 3 changed
paths. All 70 ran; `--ran` with recorded exit codes: "70 derived
famil(ies) accounted for — 68 run, 2 NOT-MEASURED (2 DERIVED from a
recorded exit 3)".
- NOT MEASURED: `check:dual-build-cjs-loads`, reason: PREREQUISITE NOT
MET, it needs every package's `dist/` (a whole-tree build). CI runs it.
- NOT MEASURED: `check:type-check-debt`, reason: its re-measure build
did not get a turn on the shared verify lock (queue-timeout 99). CI runs
it.
The package-wide scans (`pnpm lint` and the rest of the farm) are CI's.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
Co-authored-by: Claude <noreply@anthropic.com>1 parent 0b539b6 commit 73d0240
3 files changed
Lines changed: 42 additions & 1 deletion
File tree
- .changeset
- packages/services/service-knowledge/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
376 | 376 | | |
377 | 377 | | |
378 | 378 | | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
379 | 403 | | |
380 | 404 | | |
381 | 405 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1345 | 1345 | | |
1346 | 1346 | | |
1347 | 1347 | | |
1348 | | - | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
1349 | 1351 | | |
1350 | 1352 | | |
1351 | 1353 | | |
| |||
1383 | 1385 | | |
1384 | 1386 | | |
1385 | 1387 | | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
1386 | 1393 | | |
1387 | 1394 | | |
1388 | 1395 | | |
| |||
0 commit comments