Repository navigation
Description
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP
Filing gate: ③ maintainer-directed (topic child of #37000) · Source: maintainer (hotlong, cloud project): 「云上需要知识库,用turso」 / 「云端不应该让客户配置向量模型」, recorded on cloud#4993 comment 7218621399 · Spec: objectstack#37000 comment 7218695999
Grading: area:ai · Feature · p3 (topic) · reach: a non-system caller who can read few of the rows an object source indexes (for example 20 of 1,000 policies) · evidence: read on main bc17334.
Dedupe: knowledge search visible record ids pre-filter → 8 (open: #37000 parent, seat posts only) · knowledge search refill permission filter recall → 7 (open: #37000 parent, seat posts only; the refill itself shipped under closed #36993) · knowledge hosted turso → 27 (no open card on search recall).
Reader: area o1-C of seat repo:objectstack#1 claims it after triage's first touch.
维护者速读
- 问题:搜索先按相似度取前 5×topK 条,再逐条按调用者的权限过滤,必要时再取 20×topK 条补一轮。调用者只能看到很少的行(1000 条里只有 20 条)时,可能在这个上限内一条自己能看的答案都没有。
- 做什么:对非系统调用者,先以调用者身份读出他可见的记录 id(带知识源的 where,只取 id,上限 501)。不超过 500 时,把这些 id 作为
record范围条件交给适配器,只在这些行里排序;超过 500 走原来的路径。命中仍逐条复核权限。 - 谁受益:权限范围窄的用户,搜得到自己有权看的答案。
- 需要你做的:无。
What
Premise re-read on main bc17334: every cited fact holds; line numbers moved.
- Post-rank re-check:
packages/services/service-knowledge/src/knowledge-service.tssearch path,filtered/widenedat :1563-1568 (first round askstopK × SEARCH_FIRST_ROUND_FACTOR, constant = 5 at :2818),applyPermissionFiltercall at :1574 (method :2514), the one refill round at :1584 (topK × SEARCH_REFILL_FACTOR, constant = 20 at :2826); the explanatory note is at :1438-1470 (spec: 1442-1458). The refill is the cap, so a caller whose visible rows rank below 20×topK overall gets none. - Record-scope limit:
packages/services/service-knowledge/src/knowledge-search-scope.ts:42-44(SEARCH_SCOPE_MAX_ENTRIES = 10,SEARCH_SCOPE_MAX_IDS = 500). - Adapters:
packages/plugins/knowledge-turso/src/turso-adapter.ts:516-541(source_record_id IN …for arecordterm at :529,metadataterms after it; terms are joined withORat :539 and an empty-ids scope ranks nothing at :477); pgvector likewise (pgvector-adapter.ts:576-598,source_record_id = ANY(…), terms OR'd). - No
source_record_idindex:packages/plugins/knowledge-turso/src/sql.ts:146creates only thedocument_idindex (the column is at :136).
Problem: hits are re-checked after ranking, so a caller who can read few rows may get none of their visible answers within 20×topK.
What: for a non-system caller, per object source, first read the caller's visible ids (as the caller, with the source's where, ids only, limit 501). If 500 or fewer, pass them as a record term so the adapter ranks only those. Scope terms are OR'd in the adapter, so the visible ids must be INTERSECTED with a caller-given record scope, never appended; with a caller-given metadata (parent) term, fall back to today's over-fetch (or add an AND condition). More than 500: today's path. Hits are still re-checked one by one. The count of removed hits is still never returned.
Acceptance
- A caller who may read 20 of 1,000 indexed records finds an answer in one of their 20 when it ranks below 20×topK overall.
- A caller scope of one record stays one record (intersection, not union).
- The organization filter is unchanged.
- A caller with more than 500 visible ids takes today's path; a system caller is unchanged.
- Note in the PR: this raises recall, it does not cut row reads (no
source_record_idindex,sql.ts:146).
Parent: #37000.
Activity
objectstack-fleet commentedon Nov 27, 2026
triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH
Triage: lands in area:ai · domain:server · Feature · p3 · pm:queue · size M; rationale: a maintainer-directed child of #37000. Knowledge search pre-filters by the record ids the caller can see within the record scope, so a caller who can read few rows still gets a full page of hits. This is recall and efficiency, not exposure: results are already limited to visible rows. The filer's p3 stands. Recorded 2026-11-27T13:16Z.
objectstack-fleet commentedon Nov 27, 2026
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP
F3 amendment (2026-11-27T13:55Z), per the filing gate a comment on this card rather than a new card.
Source: maintainer (hotlong, cloud #5 project thread, 2026-11-27T13:41Z): 「但是我们作为元数据开发平台,不能只考虑制度库」 · Spec: objectstack#37000 comment 7220000671 · relayed by seat repo:objectstack#1 (mailbox #37561 comment 7220012379)
Premise re-read on main 0b539b6:
packages/plugins/knowledge-turso/src/sql.ts:146(insidepassageTableDdl, :127) still creates only thedocument_idindex;source_record_idis the column at :136.SEARCH_SCOPE_MAX_IDS = 500is atpackages/services/service-knowledge/src/knowledge-search-scope.ts:44.Added to What
CREATE INDEX <table>_record ON <table>(source_record_id)inpassageTableDdl. New generations carry it; an existing table gets it on its next build, with no migration.Added to Acceptance
EXPLAIN QUERY PLANfor the scoped search showsUSING INDEXon the new index.objectstack-fleet commentedon Nov 28, 2026
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP
Claim: PM loop round 11 · area o1-C (epic #37000; area concurrency 8 by the maintainer 2026-11-27T11:26Z) · 2026-11-28T01:45Z
Session:
session_016WV4cwPhGV4g9p1BGQaZbPAccount:
os-elon-muskBranch:
claude/area-o1C-37957Worktree:
objectstack-issue-37957Domain:
domain:serverArea: o1-C
Seat:
repo:objectstack#1File surface:
packages/services/service-knowledge/src/knowledge-service.ts(search path: a non-system caller's visible ids read first, ≤500 passed as arecordterm INTERSECTED with any caller record scope),packages/services/service-knowledge/src/knowledge-search-scope.ts,packages/plugins/knowledge-turso/src/sql.ts(passageTableDdl: asource_record_idindex, amendment 7220129954), the pgvector adapter's DDL if it needs the same index, tests,content/docs/protocol/knowledge.mdx, a changeset.Container & model: M,
mode:subagent, model: default tier (dispatch-gates --tier: "no path-derived mandate"), effort: high (reason: M; a permission-scoped search path where a union instead of an intersection would widen what a caller sees)Clause-②: no
Metadata-protocol: none
Responsibility: objectstack's own code,
packages/services/service-knowledge/src/knowledge-service.ts| a caller who can read few of a source's rows may find none of their visible answers within 20×topK | every non-system caller ofsearch_knowledgewith narrow record permissionsThread-read: 7219273171
Premise: holds, read on origin/main f72f335 — the search re-checks permission after ranking (
applyPermissionFilter, one refill round at 20×topK);SEARCH_SCOPE_MAX_IDS = 500; tursopassageTableDdlcreates only thedocument_idindex.Serial constraints cleared: #37963 merged (9351562), the serial gate named at filing. Probe overlap-check (knowledge-service.ts, sql.ts, knowledge-search-scope.ts) against origin/main and #38067, #38060, #38056, #38038: VERDICT clean exit 0. #38056 (F6, in rework) edits
turso-adapter.ts's vector leg andsql.ts's side-table DDL, notpassageTableDdl's indexes; whichever lands second merges main, and both PRs say so.Pre-claim lane:
packages/services/service-knowledge/**⇒domain:server.Pre-claim deps: #37963 closed out (7231879880).
Prior rulings read: card thread — triage 7219273171 (M, Feature p3), F3 amendment 7220129954 (index + measure before raising the cap).
Fold-or-serial: not folded with #38066 (the F6 pool retry; another leg).
objectstack-fleet commentedon Nov 28, 2026
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP
os-dev-report
{ "issue": 37957, "status": "done", "branch": "claude/area-o1C-37957", "pr": "https://github.com/objectstack-ai/objectstack/pull/38160", "session": "session_016WV4cwPhGV4g9p1BGQaZbP", "premise_still_valid": true, "summary": "For a non-system caller with an engine, each object source's search is first narrowed to the caller's readable records: one read per object and where, as the caller (where = source.where, fields ['id'], limit 501, context in the query). With 500 or fewer ids the source gets one record term INTERSECTED with any caller record scope (narrowToVisible, never appended). A parent (metadata) term, more than 500 ids, a narrowing naming no record, a failed read (warn) or the system identity keep today's path. The rounds, refill, per-hit re-check and organization filter are unchanged. Turso passageTableDdl and pgvector vectorTableDdl gain a source_record_id index (pgvector's lacked it). Docs and a patch changeset are included.", "tests": "Head 27b7a296bb (after merging origin/main 9726bd83bb), under os-verify-lock: service-knowledge Test Files 19/19, Tests 677/677; knowledge-turso 4/4, 235/235; knowledge-memory 3/3, 66/66; knowledge-pgvector 3 passed + 7 skipped live-Postgres files, 14 passed + 90 skipped (no Postgres server here, so the pgvector index is NOT MEASURED). Typecheck exit 0 on all four. New pins: 13-case narrow-caller describe, 7 narrowToVisible cases, a conformance case through memory and turso, and a turso EXPLAIN QUERY PLAN pin (USING INDEX TABLE_record). Ablations on committed source, restored, git status clean after: A1 intersection to union, 8 failed; A2 no narrowing, 7 failed; A3 500 bound dropped, 2 failed; A4 system identity narrowed, 1 failed; A5 organizationIds dropped, 1 failed; A6 turso index removed from DDL, 2 failed. Measured on 100k passages (scratch script, shared box): the plan shows USING INDEX knowledge_bench_g1_record on the vector leg, the keyword candidates and count. Vector-led search: 1.1 / 3.3 / 8.5 ms at 20 / 500 / 2000 ids, against 38.2 / 48.5 / 55.2 ms without the index and 59.0 ms unscoped. Keyword-heavy search: 232 / 241 / 263 ms, against 522 ms unscoped.", "gates": "Local derived families (dispatch-gates --commands --repo objectstack-ai/objectstack at 27b7a296bb, 101 commands): NOT MEASURED. The run was denied by the auto-mode classifier ('Undermining Oversight') when started as a nohup background job, and per the order it was not retried another way, so there is no --ran reconciliation. overlap-check VERDICT clean exit 0 before the merge, against main and #38060, #38056, #38050, #38038, #38013. PR check-runs read once right after opening: all gate-carrying jobs in_progress (Check Changeset, Lint · *, Type Check · *, Governed Surface Queue Guard, Spec property liveness), and opt-in or schedule jobs skipped. test:repo not run locally (CI-owned).", "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm", "mcp_calls": "0", "api_writes": "2 — fleet-write relay pr_create (POST /repos/objectstack-ai/objectstack/pulls draft + POST /issues/38160/assignees os-elon-musk); post-stamped report comment on #37957 (POST /issues/37957/comments). git push is not a REST write.", "open_questions": [], "security_findings": "none", "out_of_scope_findings": [ "carrier: none · noted in the PR's Acceptance notes, not filed: (1) the turso keyword leg's candidates are still each term's FTS matches ANDed with the scope, so a scoped query of common words costs FTS-match time (232 ms vs 1.1 ms vector-led at 100k); (2) pgvector's new CREATE INDEX IF NOT EXISTS on an existing shared table is not CONCURRENTLY, so writes wait while it builds; (3) a row-dropping afterFind hook could make a caller with more than 500 rows read as 500 or fewer (recall only, every hit is still re-checked); (4) the TABLE_record index name can collide with a legacy table name for a source id ending in _gN_record, the same as the existing TABLE_document." ] }objectstack-fleet commentedon Nov 28, 2026
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP
Close-out · area o1-C · 2026-11-28T06:05Z
Delivered by PR #38160 (merged d753fd9 at 2026-11-28T06:04Z). Nothing remains on this card for the area.
pm:dispatchedremoved with this comment.