Skip to content

knowledge-turso: approximate (libsql_vector_idx) search for large sources, chosen by size, never on a multi-organization store #37975

Description

@objectstack-fleet

repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP

Filing gate: ③ maintainer-directed (topic child of #37000) · Source: maintainer (hotlong, cloud #5 project thread, 2026-11-27 13:41Z): 「但是我们作为元数据开发平台,不能只考虑制度库」 · Spec: objectstack#37000 comment 7220000671 · relayed by seat repo:objectstack#1 (mailbox #37561 comment 7220012379)
Grading: area:ai · Feature · p3 (topic) · reach: a hosted organization whose source holds more than about 20k passages (ticket history, visit notes, emails); at 1,536-dim float32 one exact search reads ~150 MB at 20k passages and ~1.5 GB at 200k · evidence: read on main 0b539b6.
Dedupe: is:issue knowledge vector index approximate → 2 (open: #37000 parent, #12708 seat post) · is:issue libsql_vector_idx → 3 (open: #37000 parent only).
Reader: area o1-C of seat repo:objectstack#1 claims it after triage's first touch.

维护者速读

  • 问题:现在每次检索都逐条扫完整张段落表,段落多了(工单、拜访记录、邮件动辄几十万条)会很慢。
  • 做什么:单个知识源段落超过阈值(默认约 2 万条,可配)时,建 libSQL 的近似向量索引走快速检索,再按组织、元数据过滤并逐条复核权限;可见记录少的调用者仍走精确的索引路径。存储里有多个组织时绝不走这条路。
  • 谁受益:托管版上知识量大的客户,检索速度。
  • 需要你做的:无。

What

Premise re-read on main 0b539b6: the store creates no DiskANN index because vector_top_k ranks before the organization filter (packages/plugins/knowledge-turso/README.md:49, turso-adapter.ts:189). On hosted, one organization per database (cloud ADR-0114), so that filter is moot there.

Acceptance

  • At 200k passages, p95 search latency is under a stated bound (measure it and put the number in the PR).
  • recall@10 against the exact scan is ≥ 0.95 on a sample.
  • A store holding more than one organization never takes the ANN path (pinned).

Activity

  1. added
    pm:queue
    area:ai
    on Nov 27, 2026
  2. objectstack-fleet commented on Nov 27, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Triage: lands in area:ai · domain:server · Feature · p3 · pm:queue · size M; rationale: maintainer-directed knowledge-topic child (#37000): approximate vector search for large Turso sources, chosen by size and never on a multi-organization store. A scale feature, so p3 as filed. Recorded 2026-11-27T14:16Z.

  3. added
    domain:server
    on Nov 27, 2026
  4. objectstack-fleet commented on Nov 27, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP

    Claim: PM loop round 9 · area o1-C (epic #37000; area concurrency 8 by the maintainer 2026-11-27T11:26Z) · 2026-11-27T19:52Z
    Session: session_016WV4cwPhGV4g9p1BGQaZbP
    Account: os-elon-musk
    Branch: claude/area-o1C-37975
    Worktree: objectstack-issue-37975
    Domain: domain:server
    Area: o1-C
    Seat: repo:objectstack#1
    File surface: packages/plugins/knowledge-turso/src/turso-adapter.ts + sql.ts (a per-source passage-count threshold option, a libsql_vector_idx built above it, the vector leg via vector_top_k(k × factor) then the in-scope WHERE and the per-hit re-check; the keyword leg and RRF merge unchanged), knowledge-turso tests (threshold switch, multi-organization store never ANN, recall@10 sample against the exact scan, a latency measurement), packages/plugins/knowledge-turso/README.md (the Search paragraph), content/docs/ai/knowledge-rag.mdx if it names the exact scan, a changeset.
    Container & model: M, mode:subagent, model: default tier (dispatch-gates --tier: "no path-derived mandate"), effort: high (reason: M; an index whose ranking precedes the filter, so the organization rule and the over-fetch factor carry correctness, plus a measured latency and recall)
    Clause-②: no
    Metadata-protocol: none
    Responsibility: objectstack's own code, packages/plugins/knowledge-turso/src/turso-adapter.ts | a search over a source with hundreds of thousands of passages reads every vector on each call | a hosted organization with a large knowledge source
    Thread-read: 7220587871
    Premise: holds, read on origin/main c151c49 (after #38037) — README.md:49 and turso-adapter.ts:189 / :205 / :217: the vector leg is an exact cosine scan and the store creates no DiskANN index because vector_top_k ranks before the organization filter.
    Serial constraints cleared: probe overlap-check (turso-adapter.ts, sql.ts, README.md) against origin/main and every open PR: VERDICT clean exit 0, no PR shares a file. #38037 (hybrid, same search SQL) merged at c151c49, so this card's wait is over. F3 #37957 (visible-ids cap) is not started; the card's "callers whose visible ids fit the F3 cap keep the exact path" lands with whichever of the two lands second, and the PR says so.
    Pre-claim lane: packages/plugins/knowledge-*/** ⇒ domain:server.
    Pre-claim deps: none open; triage 7220587871 sized it M.
    Prior rulings read: card thread 0 rulings (triage 7220587871).
    Fold-or-serial: not folded with #37957 (different surface: search options in the service; serial by the rule above).

  5. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 27, 2026
  6. objectstack-fleet commented on Nov 27, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP
    os-dev-report

    {
      "issue": 37975,
      "status": "needs_decision",
      "branch": "claude/area-o1C-37975",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/38056",
      "head": "19841efaf2",
      "session": "session_016WV4cwPhGV4g9p1BGQaZbP",
      "premise_still_valid": true,
      "summary": "A complete build on a generation of vectorIndexThreshold passages or more (default 20,000), all of one organization, now gives that generation an approximate index. The vector leg takes topK x vectorIndexOverfetch (default 40) candidates, runs the unchanged in-scope WHERE over them, re-ranks by float32, and falls back to the exact scan when it comes up short; the keyword leg and RRF are unchanged. The index is a one-bit side table, not the card's libsql_vector_idx: measured at 200k, DiskANN reached recall@10 0.39 after a 24-minute, 2.2 GB build, against 0.998 for the one-bit index after 3 s and 54 MB. The vector leg's p95 is 81 ms where the exact scan's is 1,054 ms. A store with more than one organization in the passage table never takes the ANN path: decided at build and at every search, and pinned by tests.",
      "tests": "Lock-held pre-merge (DiskANN design): knowledge-turso typecheck + vitest, Test Files 4 passed (4), Tests 216 passed (216), VERDICT command-exit 0. One-bit design, unlocked and targeted: approximate-index describe Tests 14 passed; recall/options 15 passed. Ablations 1a/1b (organization checks), 2a (post-filter), 2b (over-fetch 1) and 3 (threshold Infinity) were all red as intended (2, 2, 2, 2 and 10 failures), each restored to the HEAD blob. NOT MEASURED on head 19841efaf2: the full knowledge-turso vitest run and typecheck. Reason: four os-verify-lock queue-timeouts (exit 99) at position 2 behind holder pid 28441 (a sibling's verify.sh, 36 min).",
      "gates": "overlap-check VERDICT clean exit 0 against origin/main 8d34c4404f plus PRs 38043, 38013, 37982 and 37963. dispatch-gates --commands derived 100 commands at 19841efaf2. NOT MEASURED: the lock never acquired in four attempts, and an unlocked run was refused by the session's permission classifier, so it was not run. PR check-runs: in_progress at report time.",
      "dogfood_battery": "n/a — no ! in the PR title and no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "2 — fleet-write pr_create (POST /repos/objectstack-ai/objectstack/pulls + POST issues/38056/assignees), this report comment (POST issues/37975/comments)",
      "open_questions": [
        {
          "question": "Accept the one-bit side-table index in place of the card's libsql_vector_idx/vector_top_k?",
          "options": [
            "A accept the one-bit index: recall 0.998, 3 s build, p95 81 ms at 200k",
            "B revert to DiskANN: recall 0.39 at 200k fails the 0.95 bar, 24 min build",
            "C keep the one-bit index but default vectorIndexThreshold to Infinity (opt-in)"
          ],
          "recommendation": "A, because it is the only option measured to meet both acceptance bars (recall at least 0.95 and p95 at 200k) and it keeps the build off the request path at 3 s"
        },
        {
          "question": "Is the organization rule per passage table enough, or must it be store-wide?",
          "options": [
            "A per passage table, as built: a generation table holds one source",
            "B store-wide: count organizations across every source table"
          ],
          "recommendation": "A, because the ANN leak is bounded to the table being ranked, and the cloud store is one organization per database"
        }
      ],
      "security_findings": "none",
      "out_of_scope_findings": [
        "class: none (observation) · reach: bench only · the keyword leg's LIKE for terms under 3 characters and its trigram match for common trigrams cost about 600 ms at 200k passages · carrier: none · dedupe words: knowledge-turso keyword leg LIKE short term trigram latency",
        "class: none (unproven) · reach: bench only · native memory grew during bulk upsert until GC ran · carrier: none · dedupe words: libsql native memory upsert growth"
      ],
      "deviations": [
        "The card's libsql_vector_idx/vector_top_k mechanism was replaced by a measured one-bit side-table scan (open question 1)",
        "Clause-②: the claim says no; declared yes (widening) because two optional public options were added",
        "Benchmarks, ablations and the targeted one-bit test runs ran outside os-verify-lock",
        "The post-merge lock-held rebuild, typecheck, tests and derived gates are NOT MEASURED (lock saturated)"
      ]
    }

    Generated by Claude Code

  7. objectstack-fleet commented on Nov 28, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-elon-musk · session_016WV4cwoXEE1amuRAGHdPBs

    维护者速读

    • 您选了 A:超过两万段的知识源默认启用新的一位索引,自动提速。落地前先补一处小修,cloud 席去托管数据库上核对一次,不等它回复。
    • 需要你做的:无。

    Ruled: A — maintainer Elon (os-elon-musk), decision card in this project's F6 decision thread, tapped at 2026-11-28T00:40:10Z, option text verbatim 「A 采用新索引,默认开启」. Fork: dev report 7229320124 on this card (DiskANN libsql_vector_idx / vector_top_k measured recall@10 0.387 at 200k, capped by the 200-row limit, against the card's 0.95 bar; one-bit side table + float32 re-rank measured 0.998).

    Premise corrected: the card named DiskANN as the mechanism. Measured, it cannot meet the card's own recall bar. The ruling keeps the card's outcomes and flow (over-fetch → in-scope WHERE → re-check → RRF, a short leg re-runs exact) and changes the mechanism only.

    Execution (PR #38056):

    1. One-bit index on by default above the existing threshold.
    2. Scoped-recall floor: when the in-scope candidate pool is under 8 × topK, the leg runs exact. Pin a scoped-recall test, and record real-store rows at 10% and 20% in scope in the PR body.
    3. Hosted DDL guard: a refused index or backfill keeps the exact scan, and the build completes; pinned.
    4. The vectorIndexOverfetch minimum follows the floor. The option is unreleased, and the contract review settles it.
    5. The never-over-two-organizations rule is read per passage table (ADR-0114: one organization per cloud database), as the PR body states.
    6. Not in scope: a second approximate attempt for narrowly scoped searches (callers who see about a fifth of the records or less get no speed-up) goes to its own follow-up card, filed by area o1-C.

    State: stays pm:dispatched with area o1-C. The cloud seat is notified on objectstack#37457 and asked for one hosted check, non-blocking.

  8. objectstack-fleet commented on Nov 28, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP

    Close-out · area o1-C · 2026-11-28T06:46Z

    Delivered by PR #38056 (merged e3bdc74 at 2026-11-28T06:46Z), under the maintainer's ruling A (record 7231124445): the new index ships on by default. The one deferred item of that ruling is follow-up #38066 (pm:blocked by PR #38056, which has now merged). Nothing else remains on this card for the area. pm:dispatched removed with this comment.

  9. removed
    pm:dispatched
    on Nov 28, 2026
  10. added a commit that references this issue on Dec 1, 2026
    e3bdc74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:aidomain:serverpriority:p3

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions