Skip to content

knowledge-turso: a narrow record-only scope goes straight to the exact scan instead of paying for the one-bit pass first #38215

Description

@objectstack-fleet

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

Filing gate: ① follow-up of #38066 (the seat's ruling B, comment 7236023531; named out of the os-dev report 7235999186) · Source: topic #37000
Grading: area:ai · Feature · p3 (suggested: a speed-up; recall is unaffected) · reach: every Turso store with the one-bit index on, for a search whose scope is record ids only and keeps a small share of passages · evidence: measured in the #38066 report 7235999186 at 200k x 1536 (clustered synthetic, topK 10, 50 queries per share) on origin/main e3bdc74. Under a record-only scope the floor-8 path costs p95 303 / 381 / 419 ms at 10 / 15 / 20% in scope. The exact scan alone, which F3's record index (PR #38160) now limits to the rows in scope, costs 128 / 207 / 265 ms.
Dedupe: is:issue knowledge-turso record scope exact index one-bit pass → checked at filing; open: #38066 (the parent) only.
Reader: area o1-C of seat repo:objectstack#1 claims it after triage's first touch.

维护者速读

  • 问题:F3 加了按记录的索引后,"只看少量指定记录"的检索直接逐条比对已经很快(约 0.13 到 0.27 秒)。但现在仍先跑一遍近似检索,不够再逐条比对,总共约 0.3 到 0.42 秒,反而更慢。
  • 做什么:范围只按记录、而且很窄时,直接逐条比对;范围宽时仍用近似检索。分界点要实测。
  • 谁受益:权限范围窄的用户在大知识库里的检索速度。
  • 需要你做的:无。

What

In packages/plugins/knowledge-turso/src/turso-adapter.ts, when the scope is record ids only (no parent term) and the in-scope share is narrow, skip the approximate leg and run the exact scan, which the record index already limits to the rows in scope. Choose the cut-over by measurement. It can be a share estimate, or a threshold on the scope's id count relative to the source's passage count. Wider shares keep the approximate leg: at 50% the exact scan reads 100k rows and the one-bit pass wins.

Acceptance

Blocked-by: #38066

Activity

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

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Triage: lands in area:ai · domain:server · Feature · p3 · pm:blocked · size S; rationale: a narrow record-only Turso scope should go straight to the exact scan instead of paying for the one-bit pass first (measured at 200k x 1536). A speed-up that leaves recall unaffected, so the filer's p3 stands. Recorded 2026-11-28T08:15Z.

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

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Unlock · #38215 · 2026-11-28T10:06Z: its Blocked-by: card #38066 closed at 2026-11-28T10:03Z (PR #38229 merged). pm:blocked → pm:queue; the grade (p3, area:ai, domain:server) is unchanged. Knowledge retrieval is outside the p1-only line. Answers seat repo:objectstack#1 (7237665591).

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

    @objectstack-fleet
    ContributorAuthor

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

    Claim: PM loop round 15 · area o1-C (epic #37000; area concurrency 8 by the maintainer 2026-11-27T11:26Z; all priorities, maintainer 2026-11-28T06:54Z) · 2026-11-28T10:17Z
    Session: session_016WV4cwPhGV4g9p1BGQaZbP
    Account: os-elon-musk
    Branch: claude/area-o1C-38215
    Worktree: objectstack-issue-38215
    Domain: domain:server
    Area: o1-C
    Seat: repo:objectstack#1
    File surface: packages/plugins/knowledge-turso/src/turso-adapter.ts (the record-only scoped path and its cut-over), its tests and the real-store bench, a changeset.
    Container & model: S, mode:subagent, model: default tier (dispatch-gates --tier: "no path-derived mandate"), effort: high (reason: S, but the cut-over is placed by a real-store bench at 200k x 1536 across five shares, with no recall loss and an ablation pin)
    Clause-②: no
    Metadata-protocol: none
    Responsibility: objectstack's own code, packages/plugins/knowledge-turso/src/turso-adapter.ts | a narrow record-only scope pays for the one-bit pass before the exact scan (p95 303 / 381 / 419 ms vs 128 / 207 / 265 ms for exact alone at 10 / 15 / 20%) | every Turso store with the one-bit index on, for narrowly scoped callers
    Thread-read: 7237678323
    Premise: holds, read on origin/main e42520c: PR #38229 merged with the second pass gated to non-record scopes; a record-only scope keeps the floor-8 path.
    Serial constraints cleared: PR #38229 merged. No open PR touches knowledge-turso/src/turso-adapter.ts (56 open PRs read).
    Pre-claim lane: packages/plugins/** ⇒ domain:server.
    Pre-claim deps: none.
    Prior rulings read: seat ruling B 7236023531 (item 2 names this card); triage 7236471878; unlock 7237678323.
    Fold-or-serial: not folded.

  7. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 28, 2026
  8. objectstack-fleet commented on Nov 28, 2026

    @objectstack-fleet
    ContributorAuthor

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

    {
      "issue": 38215,
      "status": "done",
      "branch": "claude/area-o1C-38215",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/38327",
      "session": "session_016WV4cwPhGV4g9p1BGQaZbP",
      "premise_still_valid": true,
      "summary": "Resumed from a clean worktree at e42520c67b. The premise holds on origin/main: a record-only scope runs the one-bit pass first and then the exact scan whenever the pool falls under the floor. A record-only scope (no parent term) is now estimated before the approximate leg. If the first pass's topK x overfetch candidates are not expected to keep 1.25 x the floor (8 x topK) in scope, the search goes straight to the exact scan; at the default overfetch of 40 that is a scope of under 25% of the passages. One statement estimates the scope: the table's passage count plus a record-index count over the passages of at most 256 of its ids, spread evenly (exact for 256 or fewer). So a record of many passages counts as many and an absent id counts as none. It costs p50 1-2 ms. Parent-scoped and unscoped searches keep #38229's path unchanged. Read strictly, the 'no worse than the better of the two' line is missed at 25% and 30% by 16-17 ms p95 in the final run, while the identical one-bit statement's own p95 differs by 14-15 ms between the two adapters, which is box noise.",
      "tests": "Real-store bench (scratch, not committed: scratchpad issue-38215/bench.mts, the #38066 gen.py data, 200k x 1536, 1 passage a record, file store built through the adapter: upsert 171 s, completeBuild 7.0 s). Each share ran 50 record-only queries at topK 10. Exact (Infinity threshold, recall truth), origin/main's adapter (a copy of origin/main's file, blob b83cf88639 equal to origin/main:) and head (eefc6556905) ran interleaved in one process under os-verify-lock (VERDICT command-exit 0, shared box, load 6-8 on 4 cores). p95 ms, exact / today / head, with recall today / head: 5% 81/219/74 (1/1); 10% 154/321/143 (1/1); 20% 291/418/289 (0.994/1.000); 25% 346/190/206 (0.982/0.982); 30% 389/187/204 (0.998/0.998); 35% 451/206/207 (0.992/0.992); 50% 671/223/228 (0.996/0.996). Head took the one-bit pass on 0% of queries at 5-20% and 100% at 25-50%. Placement: an earlier run with the new branch ablated on disk gave exact/today p95 20% 228/373 (48% of queries paid both passes) and 25% 308/200 (2% did), which put the cut between them at 1.25 x the floor = 25%. Ablation pin, on disk through scripts/ablation-replace.mjs (anchor 1 -> 0, blob ff1f06686b -> d3bf3bcf5d; restored to ff1f06686b == HEAD:, git diff HEAD empty): the bench's head at 5/10/20% p95 212/293/409 ms (today 219/321/418), 100% one-bit pass; unit test -t 'goes straight to the exact scan': exit 1, Tests 2 failed | 128 skipped, '{ approximate: 1, exact: 0 } to deeply equal { approximate: 0, exact: 1 }'. Restored head: pnpm --filter @objectstack/knowledge-turso test exit 0, Test Files 4 passed (4), Tests 280 passed (280); typecheck exit 0 (check:test-typecheck OK, 0 errors); build exit 0. The new unit case runs on both store kinds: cut-over 99 vs 100 passages, multi-passage records, two terms sharing an id, a sampled scope of 340 ids with 300 absent, a parent-term control, and the count binding. Three existing pins were updated to the new path (over-fetch case over-fetch 10 -> 20; retry case record control; term-less binding case).",
      "gates": "Local, on final head f041d0a8985 (README and changeset only on top of the tested eefc6556905): dispatch-gates --commands --repo objectstack-ai/objectstack derived 67 commands, all run sequentially, exit codes captured before any pipe. 66 exited 0, including check:type-check-debt (re-measured, 0 errors) and check:query-options-erasure. check:dual-build-cjs-loads exited 3, PREREQUISITE NOT MET (about 60 packages without dist; needs a whole-repo build): NOT MEASURED, left to CI. --ran reconciliation with exit codes: '67 derived, 66 run, 1 NOT-MEASURED, 0 UNRUN', exit 0. Closure build pnpm --filter '@objectstack/knowledge-turso^...' build: VERDICT command-exit 0. test:repo not run locally (no repo-project test touched; CI Test Core). CI on PR #38327 at f041d0a8985, read right after the create: skipped are Packed-tarball smoke, 18.x upgrade harness, Borrowed queue verdict, Queue verdict and Schedule gate; in_progress are Lint (ESLint, PM dispatch-gates, scoped query-options erasure, scoped slot lookup & corpus, scoped tooling self-tests, docs & code guards, repo & tooling gates, CI release & engine gates), Type Check (workspace, consumer gates, debt ledger, source gates), Check Changeset, Check PR Size, filter, Governed Surface Queue Guard, Flag docs affected by code changes, and PR-body guards. Not waited on, per contract.",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm (Clause-②: no)",
      "mcp_calls": "0",
      "api_writes": "2 relay strokes via fleet-write: pr_create (POST /repos/objectstack-ai/objectstack/pulls draft, then POST /repos/objectstack-ai/objectstack/issues/38327/assignees os-elon-musk), and POST /repos/objectstack-ai/objectstack/issues/38215/comments (this report, via post-stamped.mjs). git push of the branch 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: the existing case 'recall@10 stays 0.95 or more under a record scope that keeps 10%, 5% or 3%' now runs the exact scan, so it pins recall 1.0 there rather than the one-bit pass's; approximate recall under a narrow scope is still pinned under a parent scope by #38229's case",
        "carrier: none · noted: the bench data (passages.f32 1.2 GB, bench.db 1.7 GB) and bench.mts stay in the scratchpad issue-38215 folder for a patch round; delete them if none follows"
      ]
    }

    Generated by Claude Code

  9. 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-28T14:28Z

    Delivered by PR #38327 (merged e9002d6 at 2026-11-28T14:27Z, Tier S): in knowledge-turso, a scope of record terms alone that covers under a quarter of the passages (at the default over-fetch) goes straight to the exact scan; parent-term and unscoped searches keep #38229's path. The card closed on merge via Fixes. Nothing else remains on this card for the area. pm:dispatched removed with this comment.

  10. removed
    pm:dispatched
    on Nov 28, 2026
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