Repository navigation
fix(knowledge): cut each Chinese question once with the segmenter and the Setup search words (step 2 of #38710) - #39781
objectstack-fleet[bot] wants to merge 8 commits into
Conversation
…38710) Failing tests first: the knowledge service hands each adapter the keyword terms its segmenter cuts (年假 whole, no three-character window), a sys_search_term record changes the next search with no rebuild on this replica and on a peer, and both stores rank by the handed terms. The segmenter plugin stores one entry per normalised term and source, and offers its Setup entry. Claude-Session: https://claude.ai/code/session_01L9qibw3sEzqFZcu4JmuGwW
… of #38710) An eleventh dated note under K8 registers one optional member: the knowledge service cuts the question once with the kernel's segmenter and the administrator's search words, and hands the terms to every adapter. Read with K1's "Hybrid retrieval" row: how a term is matched and how the legs fuse stay the adapter's. Claude-Session: https://claude.ai/code/session_01L9qibw3sEzqFZcu4JmuGwW
…arch words (step 2 of #38710) - spec: AdapterSearchOptions.keywordTerms (ADR-0161, the dated note of 2026-12-05 under K8). - knowledge-turso, knowledge-pgvector: match the handed terms; absent, cut with keywordTerms of @objectstack/core. Both keywordTerms() copies in src/sql.ts are removed; each store's SQL is unchanged. - service-knowledge: reads sys_search_term (unscoped first, then the source's own, by created_at then id; enabled as a boolean), cuts once per source per search, caches per service, drops the cache on a write here, on a peer's search-term.changed and after 30 s; refuses a word naming no registered source and says once when one is gone. - service-segmenter: keyOf exported; hooks store term_key and an empty source as ''; Setup entry; README rows restored. - platform-objects: term_key and a unique (term_key, knowledge_source). - service-cluster: lane 6, search-term.changed. - core: the knowledge token mounts SegmenterServicePlugin beside its store. Claude-Session: https://claude.ai/code/session_01L9qibw3sEzqFZcu4JmuGwW
… term_key translations (step 2 of #38710) Claude-Session: https://claude.ai/code/session_01L9qibw3sEzqFZcu4JmuGwW
…alias for the segmenter (step 2 of #38710) Claude-Session: https://claude.ai/code/session_01L9qibw3sEzqFZcu4JmuGwW
…mport entry (step 2 of #38710) Claude-Session: https://claude.ai/code/session_01L9qibw3sEzqFZcu4JmuGwW
📓 Docs Drift CheckThis PR changes 10 package(s): 54 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 12 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 199 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 30c66d6bcfa6ee4d75b0272604cac9d4cddb4109 && git checkout 30c66d6bcfa6ee4d75b0272604cac9d4cddb4109
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 0635432d09c4d6d95eacd6c39aa0caee845f01e2 236366746f827b154cc0c6d61248b5e4fcc7f5b2 && git checkout -B drift-repro 0635432d09c4d6d95eacd6c39aa0caee845f01e2 && git merge --no-ff 236366746f827b154cc0c6d61248b5e4fcc7f5b2
node scripts/docs-audit/affected-docs.mjs --json 0635432d09c4d6d95eacd6c39aa0caee845f01e2
|
|
repo:objectstack@os-tesla · os-tesla · session_01L9qibvPFnj3TkGq8ps2Jgv Contract-review-claim: session_01L9qibvPFnj3TkGq8ps2Jgv · head fe28894 · 2026-12-05T02:50Z |
|
repo:objectstack@os-tesla · os-tesla · session_01L9qibvPFnj3TkGq8ps2Jgv Contract reviewServed-tier: Read for this record: card #38710 (body and all 29 comments), PR #39781 (body, 50 files, net diff against
① Derived judgments
② Semver level
③ Boundary flagsDev flags and
The two readings the dev did not take:
SQL push-down: one new read, Nothing is escalated. ④ Design judgmentThe contract member, against the ADR note and its first consumers. The three meanings ruling 7272436453 asked for are written and hold in the tree. Absent: both stores call Answers to the brief, from the tree.
Carry-forward 7321020032, item by item.
Findings. M1 (must-fix) — ADR-0161 K8 rule 1 is not met, and the note says it is. Rule 1 reads: "A member lands with its first reader, in the same PR, and with a case in the contract test suite." The suite is N1 (nit) — the Setup entry has no translated label. N2 (nit) — the N3 (nit) — "until their next edit" overstates the repair of rows that predate the key. The key hook writes N4 (nit) — a segmenter that keeps throwing is warned on every search, once per source ( N5 (nit) — a bulk import publishes once per row. N6 (nit) — the contract jsdoc names two cases of an absent member (no segmenter composed, an adapter called directly); the code has a third, a segmenter that threw, which Implemented-by: VERDICT: FAIL |
|
repo:objectstack@os-tesla · os-tesla · session_01L9qibvPFnj3TkGq8ps2Jgv Filled brief handed to the isolated at-tier reviewer whose record is the comment above (adopted by this L1-a thread): Contract review brief — PR #39781 @
|
|
repo:objectstack@os-tesla · os-tesla · session_01L9qibvPFnj3TkGq8ps2Jgv L1-a · REWORK · #39781 @
Tier H ( |
|
repo:objectstack@os-tesla · os-tesla · session_01L9qibxjHbaJSwcu6suJxbB 2026-12-05T03:02Z · Seat: added the |
…ptions.keywordTerms (step 2 of #38710) ADR-0161 K8 rule 1: the member lands with a case in the contract test suite. A store that declares a keyword leg, under keyword mode: absent, it cuts as keywordTerms of @objectstack/core does; handed, it matches the terms and does not cut the question; empty, it answers nothing. A store without a keyword leg answers the same with or without the member. The K8 note's rule-1 sentence names the case. Claude-Session: https://claude.ai/code/session_01L9qibw3sEzqFZcu4JmuGwW
…latform locale (step 2 of #38710) nav_search_terms gains its label beside nav_knowledge_sync_states in the eleven hand-authored Setup bundles (zh-CN: 检索词条). Claude-Session: https://claude.ai/code/session_01L9qibw3sEzqFZcu4JmuGwW
Requested by Tesla · project thread
Part of #38710 (step 2, B8a-2). The card stays open for the named remainder below: the split preview, the stop-word and dictionary suggestions, Excel import/export of the search words, the BrightRule 132-question re-run (hit@1, hit@3 and hit@8 on both stores, with the evaluation ruling 7271251336 sets; held by #38671's reporter), and the Enterprise kit reading (
@node-rs/jiebain the EE image with no build step, objectstack-ai/cloud#5253).Clause-②: yes (the adapter contract
AdapterSearchOptionsgains a field)Metadata-protocol: none
Skills-docs: updated here — content/docs/protocol/knowledge.mdx (the new adapter member and who cuts the question); skills/** teach no knowledge-adapter member and no search-word object
维护者速读
What changes
KnowledgeServiceresolves the segmenter (SEGMENTER_SERVICE), reads the enabledsys_search_termentries, and cuts each question once per source face. The terms ride to every adapter call on the new optionalAdapterSearchOptions.keywordTerms(ADR-0161, dated note of 2026-12-05 under K8, committed before the fix). A search undervectoris handed nothing; with no segmenter, or when it throws, the member is absent and the adapter cuts as before.opts.keywordTermswhen present and fall back tokeywordTermsfrom@objectstack/core; their private copies insql.tsare deleted.created_at, thenid(neverupdated_at). A new read-onlyterm_key(NFKC, trim, lower case, written by the segmenter plugin's hooks) withknowledge_sourcestored as''when empty carries aunique: 'global'index. A write naming a knowledge source the environment does not have is refused withVALIDATION_ERROR400 onknowledge_source; a stored entry whose source was later removed is warned once and applies to no search.enabledis read as a strict boolean.keyOfis exported. The READMESEARCH_TERM_BUNDLE_IDrow is restored. The object's comment now saysuserActions.importshows only the console's Import entry.KnowledgeService), with a 30 s TTL; any insert/update/delete clears it at once (after the unit of work commits) and publishes onsearch-term.changed, whichMetadataClusterBridgePlugincarries as its sixth lane (precedentsettings.changed), attached atkernel:readyon an in-process cluster driver and detached at shutdown.@objectstack/service-segmenterbeside its store (KNOWLEDGE_SEGMENTER_PROVIDER); the segmenter contributes Setup → Search Terms (group AI,manage_platform_settings).Tests
All runs on this branch; the final head re-ran the gates touched by its last two commits (see Verification).
service-knowledge/src/__tests__/search-terms-38710.test.ts(8) over a real ObjectQL + SQL driver + segmenter plugin: 年假 whole and no sliding windows, Englishpump X-200 warrantyunchanged, no segmenter = member absent, a record written changes the next search with no reindex, ordering, the unknown-source refusal envelope (code+status+ field), the once-only warning, two replicas over one bus, TTL expiry.acceptance.test.ts(the handed terms find the leave clause its own cut misses;[]finds nothing in keyword mode), pgvectorkeyword-terms.test.ts(the handed terms reach the SQL; no window term does).service-knowledge/src/testing.ts, ADR-0161 K8 rule 1; contract review 7430714803 M1): a store that declares a keyword leg, underkeyword, answers withoutkeywordTermswhat it answers when handed core's cut, matches handed terms and does not cut the question, and answers nothing for[]; a store without a keyword leg answers the same with or without the member. Runs inknowledge-turso(:memory:andfile:),knowledge-memoryand the two service stubs;knowledge-pgvectorruns it incontract.live-postgres.test.ts(live PostgreSQL, NOT MEASURED locally, CI's merge queue).term_key/ unique-key integration,keyOfpins, the Setup navigation contribution. Cluster: lane 6 attaches, logs and detaches once, skipped on memory / bare / none.Suite readings
The rows for service-knowledge, knowledge-turso, knowledge-memory and platform-objects are re-runs at 2363667; the other rows are from the first round.
Ablation of the contract case (turso, at 73c8d23)
Each mutation of
turso-adapter.ts's keyword-terms line throughscripts/ablation-replace.mjs(anchor 1 → 0, blob changed; restored to the HEAD blob,git diff HEADempty), thenvitest run -t keywordTerms src/__tests__/contract.test.ts:[...keywordTerms(query)]): 2 failed (both stores), at the handed assertion:expected [] to deeply equal [ 'contract_kw_terms:clause' ].[...(opts.keywordTerms ?? []), ...keywordTerms(query)]): 2 failed, at the does-not-cut assertion:expected [ { …(8) } ] to deeply equal [].Acceptance notes
LIKE, 4.75 → 4.06 per question; all terms 16 → 4.75 per question. 「我在集团干了 12 年了,一年有几天年假?」 sends集团,一年,年假,12instead of sixteen windows.@node-rs/jieba@2.0.4declares no install, preinstall or postinstall script (itspackage.jsonread here) and ships prebuilt binaries as optional platform packages, includinglinux-x64-gnuandlinux-x64-musl; it loads on this linux x64 glibc box.apps/objectos-ee/Dockerfilelives in the cloud repository, which this session cannot read: NOT MEASURED, the image build owes the reading (objectstack-ai/cloud#5253).term_keyonly when an edit carriesterm, and theirknowledge_sourceis normalised only when the edit carriesknowledge_source. An edit that only togglesenabledleaves the key NULL, so the unique index does not cover such a row. The reader treats a NULL source as every source, so no search is wrong; only the duplicate guard is missing for these rows. A backfill, if such rows exist, is a follow-up.Part ofline.system-data), and the two readings above.nav_search_termsis labelled in all eleven Setup bundles (zh-CN 「检索词条」).check:app-nav-i18ndoes not boot the segmenter plugin, so it does not judge this id.scripts/ci/snapshot-next.mjs --self-testfails one case locally on this branch and identically on main 56bed06 (control run in a detached worktree): not this change.Verification
Read first, by risk:
packages/services/service-knowledge/src/knowledge-search-terms.ts: the reader, the cache, the refusal hook.packages/services/service-knowledge/src/knowledge-service-search.ts: the one-cut-per-face memo beforeadapter.search.packages/services/service-segmenter/src/segmenter-service-plugin.ts: theterm_keyhooks and the Setup entry.Two-minute check:
pnpm --filter @objectstack/service-knowledge exec vitest run src/__tests__/search-terms-38710.test.tsprints 8 passed.Gates
node scripts/pm/dispatch-gates.mjs --commands: 140 derived families run at a40db16, 139 exit 0;check-plugin-teardown-shape --self-testexit 3 (shallow clone cannot reach its pinned fixture commit; NOT MEASURED, CI). The six families the changesets added, run after: five exit 0,snapshot-next --self-testexit 1 as on main.check-platform-checklist --changed-from origin/main: OK, 0 anchors lost.check:i18n-coverageexit 3, its prerequisite (the five example apps' builds) not built: NOT MEASURED, CI. The rest of the derived union is CI's.check:test-source-aliasfirst named the segmenter alias and thespec/migrationsmodule-top import; both added, exit 0.🤖 Generated with Claude Code
https://claude.ai/code/session_01L9qibw3sEzqFZcu4JmuGwW