Skip to content

fix(knowledge): cut each Chinese question once with the segmenter and the Setup search words (step 2 of #38710) - #39781

Draft
objectstack-fleet[bot] wants to merge 8 commits into
mainfrom
claude/project-thread-dgwut1
Draft

objectstack-fleet[bot] wants to merge 8 commits into
mainfrom
claude/project-thread-dgwut1

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

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/jieba in the EE image with no build step, objectstack-ai/cloud#5253).

Clause-②: yes (the adapter contract AdapterSearchOptions gains 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

  • The service cuts the question once. KnowledgeService resolves the segmenter (SEGMENTER_SERVICE), reads the enabled sys_search_term entries, and cuts each question once per source face. The terms ride to every adapter call on the new optional AdapterSearchOptions.keywordTerms (ADR-0161, dated note of 2026-12-05 under K8, committed before the fix). A search under vector is handed nothing; with no segmenter, or when it throws, the member is absent and the adapter cuts as before.
  • Both adapters use the passed terms. Turso and pgvector match opts.keywordTerms when present and fall back to keywordTerms from @objectstack/core; their private copies in sql.ts are deleted.
  • The reader (carry-forward items). Entries go unscoped first, then the source's own, each by created_at, then id (never updated_at). A new read-only term_key (NFKC, trim, lower case, written by the segmenter plugin's hooks) with knowledge_source stored as '' when empty carries a unique: 'global' index. A write naming a knowledge source the environment does not have is refused with VALIDATION_ERROR 400 on knowledge_source; a stored entry whose source was later removed is warned once and applies to no search. enabled is read as a strict boolean. keyOf is exported. The README SEARCH_TERM_BUNDLE_ID row is restored. The object's comment now says userActions.import shows only the console's Import entry.
  • Cache. Per environment (per KnowledgeService), with a 30 s TTL; any insert/update/delete clears it at once (after the unit of work commits) and publishes on search-term.changed, which MetadataClusterBridgePlugin carries as its sixth lane (precedent settings.changed), attached at kernel:ready on an in-process cluster driver and detached at shutdown.
  • One landing. The knowledge capability now mounts @objectstack/service-segmenter beside 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).

  • New red-first pins (commit 5d9b5d9, then the fix): service-knowledge/src/__tests__/search-terms-38710.test.ts (8) over a real ObjectQL + SQL driver + segmenter plugin: 年假 whole and no sliding windows, English pump X-200 warranty unchanged, 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.
  • Adapters: turso acceptance.test.ts (the handed terms find the leave clause its own cut misses; [] finds nothing in keyword mode), pgvector keyword-terms.test.ts (the handed terms reach the SQL; no window term does).
  • Contract suite (service-knowledge/src/testing.ts, ADR-0161 K8 rule 1; contract review 7430714803 M1): a store that declares a keyword leg, under keyword, answers without keywordTerms what 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 in knowledge-turso (:memory: and file:), knowledge-memory and the two service stubs; knowledge-pgvector runs it in contract.live-postgres.test.ts (live PostgreSQL, NOT MEASURED locally, CI's merge queue).
  • Segmenter: term_key / unique-key integration, keyOf pins, the Setup navigation contribution. Cluster: lane 6 attaches, logs and detaches once, skipped on memory / bare / none.
Suite readings
Package Result
service-knowledge (full) 933 passed (typecheck incl. tests: exit 0)
service-segmenter (full) 51 passed; fixture: hit@3 windows 10/16 → segmenter 16/16
knowledge-turso (full) 349 passed
knowledge-memory (full) 71 passed
knowledge-pgvector 76 passed, 117 skipped (live Postgres; NOT MEASURED locally, CI)
service-cluster 171 passed
platform-objects (full) 2459 passed
core capability-composition 26 passed
verify required-providers 16 passed
cli identity + boot-preparation parity 139 passed
typecheck: knowledge, segmenter, turso, pgvector, cluster, core, platform-objects, spec 8 successful

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 through scripts/ablation-replace.mjs (anchor 1 → 0, blob changed; restored to the HEAD blob, git diff HEAD empty), then vitest run -t keywordTerms src/__tests__/contract.test.ts:

  • Handed terms ignored ([...keywordTerms(query)]): 2 failed (both stores), at the handed assertion: expected [] to deeply equal [ 'contract_kw_terms:clause' ].
  • Handed terms added to the store's own cut ([...(opts.keywordTerms ?? []), ...keywordTerms(query)]): 2 failed, at the does-not-cut assertion: expected [ { …(8) } ] to deeply equal [].
  • Restored head: 2 passed.

Acceptance notes

  • Turso LIKE terms per question (16 fixture questions, jieba dictionary engine): terms under three characters, matched by LIKE, 4.75 → 4.06 per question; all terms 16 → 4.75 per question. 「我在集团干了 12 年了,一年有几天年假?」 sends 集团, 一年, 年假, 12 instead of sixteen windows.
  • Enterprise image. @node-rs/jieba@2.0.4 declares no install, preinstall or postinstall script (its package.json read here) and ships prebuilt binaries as optional platform packages, including linux-x64-gnu and linux-x64-musl; it loads on this linux x64 glibc box. apps/objectos-ee/Dockerfile lives in the cloud repository, which this session cannot read: NOT MEASURED, the image build owes the reading (objectstack-ai/cloud#5253).
  • Rows saved before this change get a term_key only when an edit carries term, and their knowledge_source is normalised only when the edit carries knowledge_source. An edit that only toggles enabled leaves 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.
  • Owed: the BrightRule 132-question re-run (hit@1, hit@3 and hit@8 on both stores, with the evaluation ruling 7271251336 sets; held by 知识库混合检索在中文口语问题上比只用向量更差:关键词一路的滑动窗口切词 + 等权 RRF #38671's reporter) and the Enterprise kit reading (objectstack-ai/cloud#5253). Neither is measured here; both are on the Part of line.
  • Remainder on knowledge: Chinese questions are cut into real words by a dictionary segmenter, in one module both knowledge-turso and knowledge-pgvector use #38710: split preview, stop-word and dictionary suggestions, Excel import/export of search words (CSV import exists through the generic door, export through system-data), and the two readings above.
  • Setup label. nav_search_terms is labelled in all eleven Setup bundles (zh-CN 「检索词条」). check:app-nav-i18n does not boot the segmenter plugin, so it does not judge this id.
  • scripts/ci/snapshot-next.mjs --self-test fails 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:

  1. packages/services/service-knowledge/src/knowledge-search-terms.ts: the reader, the cache, the refusal hook.
  2. packages/services/service-knowledge/src/knowledge-service-search.ts: the one-cut-per-face memo before adapter.search.
  3. packages/services/service-segmenter/src/segmenter-service-plugin.ts: the term_key hooks and the Setup entry.

Two-minute check: pnpm --filter @objectstack/service-knowledge exec vitest run src/__tests__/search-terms-38710.test.ts prints 8 passed.

Gates
  • node scripts/pm/dispatch-gates.mjs --commands: 140 derived families run at a40db16, 139 exit 0; check-plugin-teardown-shape --self-test exit 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-test exit 1 as on main.
  • At the final head fe28894 (a comment and changeset prose changed): adr-0087-registration, changeset-no-major, empty-changeset, changeset-fixed, changeset-gate-self-tests, closing-keyword-parity, comment-mask (three), drift-comment, i18n (four), nul-bytes, role-word: 19/19 exit 0.
  • check-platform-checklist --changed-from origin/main: OK, 0 anchors lost.
  • At the rework head 2363667 (contract suite case, ADR note sentence, eleven Setup labels, two changeset sentences), narrowed to the families that read those files: i18n, i18n-stale-fill, i18n-walk-parity, app-nav-i18n, adr-anchors, adr-index, adr-symbol-anchors, adr-links, adr-0087-registration, changeset-no-major, empty-changeset, changeset-fixed, nul-bytes, issue-citations (two), closing-keyword-parity, test-source-alias, cross-package-test-inputs, spec-docblock-symbol-anchors, undeclared-dep-imports, published-files, keyed-text-bounds, role-word, affected-docs, drift-comment: 25/25 exit 0. check:i18n-coverage exit 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-alias first named the segmenter alias and the spec/migrations module-top import; both added, exit 0.

🤖 Generated with Claude Code

https://claude.ai/code/session_01L9qibw3sEzqFZcu4JmuGwW

…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
@github-actions github-actions Bot added size/xl dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Dec 5, 2026
@github-actions

github-actions Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 10 package(s): @objectstack/cli, @objectstack/core, @objectstack/platform-objects, @objectstack/knowledge-pgvector, @objectstack/knowledge-turso, @objectstack/service-cluster, @objectstack/service-knowledge, @objectstack/service-segmenter, @objectstack/spec, @objectstack/verify, touching 76 documentable anchor(s). ⚠️ 6 changed file(s) yielded no anchor (packages/cli/package.json, packages/services/service-knowledge/src/index.ts, packages/services/service-knowledge/vitest.config.ts, …), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

54 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 0635432d09c4d6d95eacd6c39aa0caee845f01e2.

⛔ 12 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 6 changed file(s) yielded no anchor (packages/cli/package.json, packages/services/service-knowledge/src/index.ts, packages/services/service-knowledge/vitest.config.ts, …) — pages documenting those are invisible to this run
  • 2 anchor(s) matched too much of the corpus to be a work list: VALIDATION_ERROR (literal, 40 pages), created_at (literal, 49 pages)
  • 15 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 71 of 255 client-bound route-ledger rows — the other 184 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 184: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 60 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 199 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 0635432d09c4d6d95eacd6c39aa0caee845f01e2 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 30c66d6bcfa6ee4d75b0272604cac9d4cddb4109 — the merge of head 236366746f827b154cc0c6d61248b5e4fcc7f5b2 into base 0635432d09c4d6d95eacd6c39aa0caee845f01e2, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# 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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 0635432d09c4d6d95eacd6c39aa0caee845f01e2 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-tesla · os-tesla · session_01L9qibvPFnj3TkGq8ps2Jgv

Contract-review-claim: session_01L9qibvPFnj3TkGq8ps2Jgv · head fe28894 · 2026-12-05T02:50Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-tesla · os-tesla · session_01L9qibvPFnj3TkGq8ps2Jgv

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: fe288946e902bc7d088ac7891d8f8c91e1b6b24a
Local-runs: none
Scope: packages/spec/src/contracts/knowledge-adapter.ts, docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md + packages/services/service-knowledge/src/knowledge-search-terms.ts, packages/services/service-knowledge/src/knowledge-service-search.ts, packages/services/service-knowledge/src/knowledge-service.ts, packages/services/service-knowledge/src/knowledge-service-top-level.ts, packages/services/service-knowledge/src/knowledge-service-plugin.ts, packages/services/service-knowledge/src/index.ts, packages/plugins/knowledge-turso/src/turso-adapter.ts, packages/plugins/knowledge-turso/src/sql.ts, packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts, packages/plugins/knowledge-pgvector/src/sql.ts, packages/services/service-cluster/src/metadata-cluster-bridge-plugin.ts, packages/services/service-segmenter/src/segmenter-service-plugin.ts, packages/services/service-segmenter/src/segmenter-service.ts, packages/services/service-segmenter/src/index.ts, packages/platform-objects/src/system/sys-search-term.object.ts, packages/core/src/capability-providers.ts, packages/core/src/capability-composition.ts, content/docs/protocol/knowledge.mdx
Security-touching: yes

Read for this record: card #38710 (body and all 29 comments), PR #39781 (body, 50 files, net diff against main, merge base 56bed06636), the 75 check-runs on the head, and the head tree through REST. Nothing was built or run. The rest of the diff (tests, the 11 generated translation bundles, the two package.json edits, the vitest alias, the lockfile, the changesets' prose) is the lane seat's ACCEPT at TIER_DEFAULT.

Security-touching: yes is meant: neither hits file teaches security, but three changed hunks do. sys-search-term.object.ts states which capability guards the import door ("opens no door and closes none"), segmenter-service-plugin.ts puts requiredPermissions: ['manage_platform_settings'] on a new Setup entry, and knowledge-search-terms.ts reads an administrator-only object under a system context (isSystem: true) inside every caller's search. The words read never reach the caller, and the write refusal that lists the registered source faces sits behind the authorisation middleware (engine-insert.ts: executeWithMiddleware at 392 wraps the beforeInsert dispatch at 702), so a caller without the capability is refused before the hook speaks. No finding; the seat adds the security label.

① Derived judgments

  • @objectstack/spec: AdapterSearchOptions.keywordTerms?: readonly string[]. One optional member on a published contract. Widening, right. An adapter written before it compiles and runs unchanged.
  • Both stores stop cutting when handed terms. turso-adapter.ts:762 and pgvector-adapter.ts:685 read opts.keywordTerms ?? keywordTerms(query), with keywordTerms from @objectstack/core. Right. The core body, KEYWORD_SEPARATORS and UNSEGMENTED_RUN were compared with both sql.ts files at the merge base: identical, so the absent-member path answers as before.
  • No public export is removed. keywordTerms, MAX_KEYWORD_TERMS and KEYWORD_SEPARATORS leave both sql.ts modules; neither package index exported them (knowledge-turso/src/index.ts:33, knowledge-pgvector/src/index.ts:17). @objectstack/core was already a runtime dependency of both. Right.
  • A behaviour change the diff implies, stated by the contract. A question that cuts to no term (stop words only) is handed []. In keyword mode the store now answers nothing, where the sliding windows answered something; in hybrid the vector leg answers alone. The contract jsdoc, the ADR note and knowledge.mdx all say so. Right.
  • @objectstack/core: resolveCapabilityExtras('knowledge') answers two extras. The store, then KNOWLEDGE_SEGMENTER_PROVIDER, with no optional flag. Right for the two hosts in this repository that resolve extras: packages/cli and packages/verify both gain the dependency, the same two that hold the store packages. A host that cannot import it is warned and boots without it (serve.ts:5695-5700).
  • @objectstack/service-knowledge: new public surface. KnowledgeServiceOptions.resolveSegmenter, three public methods (searchTermsChanged, attachSearchTermChangePubSub, resyncSearchTermChangePubSub), and five exports from the index. Additive, right.
  • @objectstack/service-segmenter: keyOf, searchTermNavItem, SEARCH_TERM_KEY_HOOK_PACKAGE exported. Additive, right.
  • @objectstack/service-cluster: a sixth lane and a new wire name, search-term.changed. Additive, right.
  • sys_search_term: a narrower record accept-set. A second record with the same normalised term and source is refused by the unique index, and a record naming an unregistered source is refused with VALIDATION_ERROR 400. Right as the carry-forward orders it (items 2 and 3). Until this head nothing read a record and no Setup entry offered the object, so no working consumer loses an accepted write. Both changesets state the refusals.

② Semver level

  • Two changesets cover all ten packages the diff moves: spec, core, service-knowledge, knowledge-turso, knowledge-pgvector, service-cluster, cli, verify in the first; service-segmenter, platform-objects in the second. Every one is patch.
  • Metadata-protocol: none is right: term_key is a read-only field the platform writes on a system object, and nothing a metadata author can write is added, narrowed or changed in meaning. Under AGENTS.md the kind none takes patch, so the level matches.
  • Clause-②: yes on the PR body and on both changesets matches what the diff publishes: a member added to a published adapter contract. No arm is owed.
  • The gates agree: Check Changeset, Lint · CI, release & engine gates and Governed Surface Queue Guard conclude success on this head.

③ Boundary flags

Dev flags and open_questions (report 7430121648):

  • Metadata-protocol: unchanged against none. Answered A by claim amendment 7430172645. Correct: none is the closed-set spelling.
  • Files outside the claimed surface. Answered A by the same amendment. Each is a test, a generated bundle, a dependency line or a doc page that a claimed item cannot land without. Accepted.
  • check-plugin-teardown-shape --self-test, NOT MEASURED locally. Answered by the head: Lint · scoped · tooling self-tests concludes success.
  • snapshot-next --self-test red locally, identical on main. Not this change. Lint · CI, release & engine gates concludes success on this head. The dev's class-a finding stays with the seat to file.

The two readings the dev did not take:

  • pgvector against a live PostgreSQL. A risk this record names. No check-run on this head ran the live suite: Temporal Conformance (live PG + MySQL) is skipped, as ci.yml orders for every pull_request. The merge queue will run it, because this diff hits the temporal_live paths. What it runs does not hand terms: no live-postgres test passes keywordTerms, so the handed path reaches a real server for the first time in production. The exposure is small, since the adapter change is one expression and a handed term enters the same per-term statement a window piece entered (a term holding Han is a substring match, as before), and keyword-terms.test.ts pins the handed terms into the statement over a fake pool. The reading is owed, and M1 below is where it is taken: the contract suite is the one knowledge-pgvector runs on a live server.
  • jieba in the EE image, with no build step. A risk this record names, not a blocker here. apps/objectos-ee/Dockerfile is in the cloud repository and was not read. The tree bounds the failure: @node-rs/jieba is an optionalDependency of service-segmenter, pinned 2.0.4. Where its binary does not load, the plugin still registers, logs not_installed or load_failed apart, and cuts by sliding windows with the administrator's words still protected. Where service-segmenter itself is missing from an offline bundle, serve.ts warns and boots, and each store cuts as before this PR. Both failures degrade to today's behaviour; neither is silent. The card's acceptance item "Enterprise kit" stays unmet until the cloud lane reads it (objectstack-ai/cloud#5253), and N2 asks that the Part of remainder say so.

SQL push-down: one new read, engine.find('sys_search_term', …) ordered by created_at, id, limit 10,000, with the per-source pick done in memory (knowledge-search-terms.ts:117-120). Not a finding: the reason is in the file header. It is one read for the whole service, cached 30 s and shared by every source, so a WHERE knowledge_source per source would turn one read per 30 s into one per source per search. No id is materialised, no join is made in the application, and neither store's statement changes shape.

Nothing is escalated.

④ Design judgment

The 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 keywordTerms of @objectstack/core. Present: both match the handed terms and do not cut. Empty: terms.length === 0, so keyword mode returns [] and hybrid runs the vector leg alone. "Never handed under vector" holds at knowledge-service-search.ts:1018.

Answers to the brief, from the tree.

  • The service cuts once and passes the terms; the stores no longer cut. Holds, with one precision: once per source of a search, not once per question. searchRound memoises on the SearchTarget (target.keywordTerms ??= …, line 1020). The refill round is handed sources.filter(…), the same objects, so both rounds share one cut. Per source is required, because a source-scoped entry changes that source's terms only; the ADR note says so. adapter.search has one call site in the service (line 1021). Both private keywordTerms copies are deleted.
  • The core fallback with no segmenter. Holds. resolveSegmenter is read at each cut, never at boot, and answers undefined for an unregistered slot (knowledge-service-plugin.ts:712-719). termsFor then returns undefined, the member is left off the call, and the store cuts by core's sliding windows. A segmenter that throws takes the same path with a warn. A segmenter present without jieba answers with windows plus the administrator's protected words, which is the ruled design. Pinned by "without a segmenter no terms are handed".
  • The 30 s TTL and the cluster lane. Holds. SEARCH_TERMS_TTL_MS = 30_000, stamped at read start. The cache drops on a local write after the unit commits (runAfterOpenUnitsCommit), on a peer's message, and on resync. A read in flight when a write lands is not kept, because changed() clears the slot and the next search reads again. A failed read is not served past its own search. Lane 6 follows the family: duck-typed on attachSearchTermChangePubSub, bound at kernel:ready, skipped on an in-process driver, registered for resync, detached once at shutdown. The payload is an address (originNode, at), with a loopback guard. Pinned by the two-replica case, the missed-message case and the lane tests.
  • The reader and the Setup entry. Hold; see the carry-forward below.
  • The named remainder. The Part of line keeps three items open (split preview, suggestions, Excel import/export). Two more card acceptance items are unmet and are not on that line; see N2.

Carry-forward 7321020032, item by item.

  1. Ordering. Met. Unscoped entries, then the source's own, each by created_at then id; updated_at is read nowhere. Pinned.
  2. Normalised unique key. Met. term_key is keyOf(term), written by the segmenter's beforeInsert and beforeUpdate hooks, per row on a batch, so the import door is covered. An empty source is stored as '', and { fields: ['term_key', 'knowledge_source'], unique: 'global' } is declared. It lands with the Setup entry, not before it; see N3 for rows that predate it.
  3. knowledge_source. Met. A write naming an unregistered face is refused (VALIDATION_ERROR, 400, fields[0].field = 'knowledge_source'); a stored entry whose source is gone applies to no search and is warned once per name. NULL and '' both read as every source (storedSource).
  4. enabled as a strict boolean. Met. storedBoolean maps the driver's false or 0 to false and everything else to true; the segmenter tests === false.
  5. One landing. Met. The mount (KNOWLEDGE_SEGMENTER_PROVIDER), the reader and the Setup entry (group_apps_ai, priority 252, requiresObject, manage_platform_settings) are in this one PR.
  6. keyOf exported. Met. The platform-word pin now reads the exported keyOf over PLATFORM_WORDS, which segmenter-service-plugin.test.ts:60 pins as the same array as PLATFORM_SEARCH_WORDS.
  7. README row. Met. SEARCH_TERM_BUNDLE_ID is back in the Exports table.
  8. userActions.import. Met. The object's comment says the flag shows the console's Import entry and opens no door.

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 packages/services/service-knowledge/src/testing.ts, which all three stores run (knowledge-memory and knowledge-turso in contract.test.ts, knowledge-pgvector in contract.live-postgres.test.ts). That file is not in this diff and holds no keywordTerms case; the precedent member queryVector has one there (lines 696-728). Ruling 7272436453 names the rule for this member: 「AdapterSearchOptions 加成员要遵守 ADR-0161 K8 的规则 1、2、5」. The note added here closes with "It lands in the PR that builds it, with its first readers … (rule 1)", which the tree does not bear out. The two tests added sit in each store's own files, and the pgvector one runs over a fake pool. Fix: one case in the contract suite, for a store that reports a keyword leg, covering the three meanings (absent, handed, empty). That case is also the live-PostgreSQL reading ③ names as owed, because the merge queue runs the suite against a real server.

N1 (nit) — the Setup entry has no translated label. nav_search_terms appears in no file under packages/platform-objects/src/apps/translations/, while its sibling nav_knowledge_sync_states is translated there (zh-CN: 「知识库同步状态」). A Chinese-language administrator, the reader this card serves, sees "Search Terms" in English. Not a prose face: left as a follow-up on the card, which stays open.

N2 (nit) — the Part of remainder is short by two card acceptance items. The body's first line and claim amendment 7430172645 keep three things open. The card's Acceptance also asks for the BrightRule re-run (hit@1, hit@3, hit@8 on both stores, with phase ruling 7271251336's evaluation) and the Enterprise kit reading. The PR body lists both lower down as owed and not measured, but the line that decides when the card may close does not name them. Fix on the PR body.

N3 (nit) — "until their next edit" overstates the repair of rows that predate the key. The key hook writes term_key only when the patch carries term, and normalises knowledge_source only when the patch carries it (segmenter-service-plugin.ts, keyed). A legacy row edited to toggle enabled keeps a NULL key and stays outside the unique index. The reader treats NULL source correctly, so no search is wrong; only the duplicate guard is missing for such rows. Fix the sentence on the PR body; a backfill, if rows exist, is a follow-up.

N4 (nit) — a segmenter that keeps throwing is warned on every search, once per source (termsFor), where a failed read of the entries is warned once (readFailureReported). Log volume only. Left as an accepted deviation.

N5 (nit) — a bulk import publishes once per row. afterInsert runs per row, so an import of several thousand words sends that many messages on search-term.changed after the commit, each clearing every peer's cache. Correct, not coalesced. Left as an accepted deviation.

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 knowledge.mdx does name. Left as an accepted deviation; a fix on the spec file would move the head.

Implemented-by: claude/project-thread-dgwut1
Reviewed-by: session_01L9qibvPFnj3TkGq8ps2Jgv (isolated sub-agent)

VERDICT: FAIL

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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 @ fe288946e902bc7d088ac7891d8f8c91e1b6b24a (card #38710)

You review at CONTRACT_REVIEW_TIER. Render ONE ## Contract review record on this head — its shape is
node scripts/pm/record-recognisers.mjs --template --paths packages/spec/src/contracts/knowledge-adapter.ts docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md — with a PASS or FAIL verdict, and post it as ONE comment
on the PR or its card.

Inputs — these and nothing else:
· card #38710: its body and EVERY comment (rulings and earlier records included)
· PR #39781: its body, its file list, and the net diff against main at fe288946e902bc7d088ac7891d8f8c91e1b6b24a
· the check-runs on fe288946e902bc7d088ac7891d8f8c91e1b6b24a: their conclusions ARE the gate verdicts
⛔ Not the dispatch order, ⛔ not the dispatching seat's own conclusions — this brief is adversarial by design.

Scope — the paths reviewFace returns as hits on this PR's file list: packages/spec/src/contracts/knowledge-adapter.ts, docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md;
plus every file IN THIS DIFF that directly implements or enforces them — the gate that enforces a rule, the code
a jsdoc or schema line describes, the validator a skill teaches — reviewed for agreement with the contract.
Widen it freely, ⛔ never below hits; the record's Scope: line names the implementing files apart from hits.
The rest of the diff (tests, unrelated modules, lockfiles, generated output, changesets) is the lane seat's
ACCEPT at TIER_DEFAULT, exactly as a standalone PR of those files.
④ judges the hits files and those implementing files ONLY:
lockfiles, generated output, changesets and prose elsewhere in the PR are not reviewed;
code outside the diff is READ to judge them, never reviewed.

Security — a hits path sits on the low-risk skills arm: when the change teaches security, auth or permission
behaviour the path name doesn't show, the record says so and the seat adopting the record adds the security label.
The record says so on its Security-touching: line, and the arm lands on no alone: write no ONLY when no changed
hunk teaches permission, sharing, credential, token, authentication or other security behaviour, else yes.

⛔ READ-ONLY. No worktree, no checkout, no build, no test run, no gate re-run, no ablation: the check-runs
on the head already answered every derived gate family, and a local run costs more than it returns.
If ONE probe is unavoidable, the record's Local-runs: line says probe — REASON; otherwise none.
Scratch space is /tmp/claude-0/-home-user/f90b304d-2703-5b33-b155-97489671c85a/scratchpad/pr-39781/ alone; nothing there you did not write this round is read.

Judge, in the record's own sections:
① Derived judgments — every accept-set and public-surface change the diff implies, each named right or wrong.
② Semver level — the changeset (or skip-changeset) matches what the diff publishes, and the Clause-②: line.
③ Boundary flags — every dev flag and every open_questions entry answered, or escalated.
On every face, SQL push-down: a new id materialisation or in-app join where SQL could push down is a
finding unless a reason is given (AGENTS.md, Prime Directive 5: SQL first).
④ Design judgment — for EVERY hits file: does the change hold against the code it cites and the
scenario it is accepted against? A skill file against the card's eval prompt and the spec it teaches
on main; a schema file against the ruling or ADR it implements and its first consumer; an ADR
against its first consumer and its execution plan. For EVERY implementing file in the diff: does the
code agree with the contract, sentence by sentence? Read the cited code in the live tree, and try to
break the design.
Grade each finding must-fix, should-fix or nit — a nit has no effect on correctness or the contract.
A must-fix is a FAIL; a must-fix or should-fix earns a delta review of its fix; nits alone end the round.
Spell a must-fix or should-fix with its id and grade, S1 (should-fix) — …, and a clean round as
No must-fix, no should-fix.: the queue guard reads a graded finding as OPEN on this head and
refuses the record; the delta record names those it closes by id alone, S1: closed.
A nit is fixed only on the prose faces, or left as an accepted deviation or a follow-up card: a fix
anywhere else moves the head, and this record no longer covers it.
⛔ Judge the tree, never the PR body's account of it.
Sign Implemented-by: with the dev's branch and Reviewed-by: with your session id — the value is the FIRST
thing after each colon.

The PR declares Clause-②: yes (AdapterSearchOptions gains keywordTerms) and is Part of #38710 (step 2). Judge it
against the card's step-2 acceptance items, which are on the card (inputs above): the step 2 carry-forward record
7321020032 (all 8 items) and the claim 7428337400 with amendments 7428364519 and 7430172645. In particular, answer
each from the tree:
· the service cuts each question once and passes the terms to the adapter (pgvector and turso no longer cut);
· the core fallback when no segmenter is present;
· the search-word cache's 30 s TTL and its cluster invalidation lane (service-cluster bridge);
· the admin 检索词条 reader and Setup entry, and the named remainder the Part of line keeps open;
· two things the dev did NOT MEASURE — pgvector against a live PG, and jieba loading in the EE image with no build
step — say whether either is a risk the record must name.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-tesla · os-tesla · session_01L9qibvPFnj3TkGq8ps2Jgv

L1-a · REWORK · #39781 @ fe288946e9 · Area: ot-p1 · read 2026-12-05T03:01Z

  • L2: the at-tier record is 7430714803 (CONTRACT_REVIEW_TIER, FAIL) and its filled brief is 7430725952 (claim 7430601573).
    • M1 (must-fix): ADR-0161 K8 rule 1 says a new adapter member lands "with a case in the contract test suite". Ruling 7272436453 names rules 1, 2 and 5 for this member.
    • The suite is packages/services/service-knowledge/src/testing.ts. It is not in the diff and has no keywordTerms case. The precedent queryVector has one there.
    • The PR's two tests sit in each store's own files, and the pgvector one runs over a fake pool. The new ADR note still cites "(rule 1)" as met.
    • Fix: add one contract-suite case, for stores that report a keyword leg, covering the member absent, handed, and empty. This is also where the live-PG reading is taken, because the queue's live PG lane runs the suite.
  • Everything else holds (read in the record):
    • All 8 items of carry-forward 7321020032 are met.
    • The service cuts once per source of a search, memoised and shared by the refill round, and both stores read opts.keywordTerms ?? keywordTerms(query) from core.
    • Core's fallback is byte-identical to the two deleted sql.ts copies.
    • The 30 s TTL holds, and cluster lane 6 drops the cache on a local write, a peer message and a resync.
    • Reader and Setup entry are in one landing.
    • patch on the ten packages, Clause-②: yes and Metadata-protocol: none are right.
  • NOT MEASURED, both named as risks:
    • pgvector against live PG: PR runs skip it. M1's case closes this.
    • jieba in the EE image: both failure modes fall back to pre-PR behaviour and are logged. The card's Enterprise-kit acceptance stays open (cloud#5253).
  • Nits:
    • N1: nav_search_terms has no translations, while its sibling nav_knowledge_sync_states has them. Card follow-up.
    • N2: the Part of line omits the BrightRule re-run and the Enterprise-kit reading. Fix in the PR body.
    • N3: "until their next edit" overstates the repair of old rows, because term_key is written only when the patch carries term. Fix in the PR body.
    • N4–N6 are accepted deviations: repeated segmenter-throw warnings, one change message per imported row, and the jsdoc's third "absent" case.
  • For the seat: the record says Security-touching: yes (nav requiredPermissions, the import door, and a system-context read in search). No security finding. Add the security label.
  • Gates at fe288946e9: 64 success · 10 expected skip · 0 failed · 0 pending. Mergeable clean.

Tier H (docs/adr/**): after the delta PASS and L1 ACCEPT, the seat sends it to the maintainer through os-zhuang.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-tesla · os-tesla · session_01L9qibxjHbaJSwcu6suJxbB

2026-12-05T03:02Z · Seat: added the security label because L1-a's record (7430740311) reads "Security-touching: yes" with no finding. The PR touches an admin-only object gated by manage_platform_settings and its import door. The label marks the surface (§7). It does not gate landing.

…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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation security size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants