Repository navigation
feat(knowledge): knowledge-turso moves into objectstack — Apache-2.0, platform embedder and splitter, generations, the contract suite - #37388
Conversation
…ions and the contract suite Claude-Session: https://claude.ai/code/session_01JQwxbaMuehXzctoWq7iRsV Co-authored-by: Claude <noreply@anthropic.com>
…edger row Claude-Session: https://claude.ai/code/session_01JQwxbaMuehXzctoWq7iRsV Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbaMuehXzctoWq7iRsV Co-authored-by: Claude <noreply@anthropic.com>
…platform now ships Claude-Session: https://claude.ai/code/session_01JQwxbaMuehXzctoWq7iRsV Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 3 package(s): 26 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 8 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 178 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 7295f1ec7e399880b6b41d91bd65e741c25b6058 && git checkout 7295f1ec7e399880b6b41d91bd65e741c25b6058
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin e8740c55f0eaba7571c16a5588c833fe29e176ac 796b204c685c9299058ff00a1912799d2d811fa8 && git checkout -B drift-repro e8740c55f0eaba7571c16a5588c833fe29e176ac && git merge --no-ff 796b204c685c9299058ff00a1912799d2d811fa8
node scripts/docs-audit/affected-docs.mjs --json e8740c55f0eaba7571c16a5588c833fe29e176ac
|
Brings #37342 (record scope). Conflict in content/docs/protocol/knowledge.mdx's adapter table: both rows kept. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbaMuehXzctoWq7iRsV
…ng (ADR-0161 K8 item 17) Mirrors knowledge-pgvector's scope from #37342: the terms are ORed inside the organization-filtered WHERE, a record term on source_record_id, a metadata term on a stored string or number equal to an id as text or a list with such an element. Ids go as one bound JSON array per term; a field name is a bound value compared with the stored keys, never a JSON path. A scope with no term that has ids answers [] before any query. The contract suite runs with implements.scope: true. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbaMuehXzctoWq7iRsV
|
repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U 维护者速读
席位核对REWORK — M1 is open at this head: the rule that recognises a table of the package's earlier releases is too wide, and a complete reindex can drop a table that is not one, the store's own generation table included. S1 to S3 stand beside it. The merge of Head-sha: Read in two parts. First the PR at 形态
门禁 check-runs (at
对照 knowledge-pgvector 的约定 (#37337)
逐项核对与消融 (21 single-change ablations in a scratch worktree, each restored; worktree removed)
逐句核的散文面
修复清单
接受的偏差
范围外去向
落地条款
Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
M1 (must-fix) — the rule that recognises an earlier-release table is too wide: a table that is not one is refused as one and then dropped by a complete reindex, the store's own generation table among them. After that every source of the store fails until a restart and is then rebuilt from nothing. It is reachable through a source id the spec allows. Reproduced at both heads.
S1 (should-fix) — a call to a remote database has no bound, while boot awaits the health check and one queue serves every source of the client.
S2 (should-fix) — two conventions of the reference are held in code and pinned by no case: the first generation made afresh, and
Implemented-by: VERDICT: FAIL |
…ape, a bound on remote calls, the conventions pinned - A table of the cloud-repo releases is recognised by exactly their columns and an F32_BLOB vector, never by one missing column: the store's own generation table and a table it did not make (a shared database) are never refused as one nor dropped by a reindex. openGeneration makes a table afresh only when it is one of the store's passage tables, and refuses any other table under that name. - requestTimeoutMs bounds one turn of the per-client queue (default 10000 on a remote URL): past it SERVICE_UNAVAILABLE, and the queue moves on. - Pinned: a first generation made afresh; listDocuments without an embedder is 503, not 409; the write-time generation recheck; the scope scalar guard. - The platform-file refusal compares the percent-decoded path, without case, and a bare-path OS_DATABASE_URL; an undecodable file: URL is refused. - A spec-valid source id of any length is accepted; a refused one carries VALIDATION_ERROR 400. The search retry on a switched generation is bounded; the third-attempt write error names no synthetic passage id. - Prose: the unique index keeps one generation under construction, not one builder; os dev does not mount the store yet. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbaMuehXzctoWq7iRsV
|
repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U 维护者速读
席位核对REWORK — M1 and S1 to S3 of round 1 are closed at this head, and every check is green. One new finding, S4, came in with the fix for S1: the bound on a remote call is taken over a whole queue turn, and a write turn is a whole page of documents. A small patch round. Head-sha: Delta review: one commit on 形态
门禁 check-runs (at
上轮各项的复核 (16 single-change ablations at this head, each restored; worktree removed)
逐句核的散文面 (delta sentences)
修复清单
接受的偏差 (unchanged, plus one)
范围外去向
落地条款
Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
M1 (must-fix): closed.
S4 (should-fix) — the bound is taken over a whole queue turn, and a write turn is a page of documents in one transaction, so against a remote database the default is passed by an ordinary page: the write answers 503, the reindex stops there every time, and a rebuild under a new fingerprint does not complete. Simulated in proportion; not measured on a real remote database.
S1 (should-fix): closed.
S2 (should-fix): closed.
Implemented-by: VERDICT: FAIL |
… never per page; a write stopped is rolled back - requestTimeoutMs bounds each request on its own (a statement, a batch, opening a transaction, a commit or rollback) through a bounded view of the client, no longer a whole queue turn; the queue stays keyed by the client as given. A write sends each document's statements as one batch, so a page of 100 documents is ~100 requests. A request that times out inside a write is followed by a rollback, never a commit; only a commit that times out may still land, and its remedy says so. The remedy names requestTimeoutMs. Pinned with a slow client (40 documents, 2 passages each) and a write whose second batch hangs (nothing of it lands). - search's retry count is a private method's, not a third public parameter. - A table the store did not make under a generation name answers SERVICE_UNAVAILABLE with the table in the remedy. - The platform-file refusal compares the file a link resolves to, and reads SQLite's -wal, -shm and -journal side files as their database. - Pinned: the vector-type half of the legacy shape, the VALIDATION_ERROR code (and a long source id accepted), the search retry bound, the remote default bound (requestBoundFor). Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbaMuehXzctoWq7iRsV
|
repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U 维护者速读
席位核对ACCEPT — S4 is closed at this head: the request bound is per request, a write sends one request per document, and a write stopped by the bound is rolled back. Nothing else moved. Every check is green. Nits only, the first of them worth a follow-up with the hosted registration. Head-sha: Delta review: one commit on 形态
门禁 check-runs (at
逐项核对与消融 (12 single-change ablations at this head, each restored; worktree removed)
逐句核的散文面 (delta sentences)
修复清单
接受的偏差 (unchanged)
范围外去向
落地条款
Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
S4 (should-fix): closed.
M1 (must-fix): closed. Implemented-by: VERDICT: PASS |
Requested by Warren · project thread
Fixes #37107
Clause-②: yes
Metadata-protocol: none
维护者速读
What changes
@objectstack/knowledge-tursomoves intopackages/plugins/knowledge-turso(Apache-2.0LICENSEtext, settling cloud ADR-0119 D5's mixed licence). Same package name; the next version publishes from here, in the fixed version group.urloption (file:,:memory:,libsql://), elsefile:+ project root +/.objectstack/data/knowledge.db(defaultStoreUrl, for Open runtime: requires: ['knowledge'] mounts the knowledge service, and pgvector on PostgreSQL #37102 to name). A URL namingobjectstack.db,dev.db,standalone.dbor the fileOS_DATABASE_URLnames (a URL or a bare path) is refused, compared percent-decoded, without case, as the file a link resolves to, and with SQLite's-wal/-shm/-journalside files read as their database (os-bob's Evaluate: canos dev's default database move from SQLite (better-sqlite3) to a local libSQL file (driver-turso)? #37106 measurement, comment 7143523345: two engines on one file lose rows). On a file:PRAGMA journal_mode = WALand a busy timeout (busyTimeoutMs, default 5000). In one process all database work of one client runs through one queue: a write transaction holds its connection across awaits, and a second in-process writer would otherwise wait in SQLite's synchronous busy handler on the very thread the holder needs. On a remote URL each request is bounded on its own (requestTimeoutMs, default 10000): a statement, a document's batch (a write sends each document's statements as one batch, so a 100-document page is ~100 requests), opening a transaction, a commit or rollback. Past it the call answers503 SERVICE_UNAVAILABLEnamingrequestTimeoutMs, and the queue moves on. A request that times out inside a write is followed by a rollback, never a commit; only a commit that itself times out may still land, and its remedy says so (writes are idempotent).embedderservice at each call (orembedder), reportsembedding(model, dimensions, maxInputTokens), and declarescapabilities.chunks.knowledge_generation(source_id, generation, fingerprint, recipe_hash, dim, model, state, created_at) with two partial unique indexes: oneactiveand onebuildingrow per source; the second is the lock row that keeps one builder per source. One passage table per source and generation,knowledge_SOURCE_gN(chunk_id PK, document_id, source_record_id, organization_id, content, title, heading_path, doc_hash, chunk_hash, metadata, embeddingF32_BLOB(dim)). Source ids are held to the spec's^[a-z_][a-z0-9_]*$before any SQL (refused400 VALIDATION_ERROR); every value is a bind parameter. The unique index keeps one generation under construction per source, not one builder: a secondbeginBuildunder the same fingerprint joins the build, one under another fingerprint replaces it, and the first builder's writes are then refused 409.409 KNOWLEDGE_REBUILD_REQUIRED; a search under another fingerprint than the active one's is refused the same way ("is being rebuilt" while a build for it runs).beginBuildunder a new fingerprint createsknowledge_SOURCE_gN+1beside the active table; a build of a third fingerprint drops the unfinished one.completeBuildmakes it active, records the recipe hash, drops the old table.indexStatusanswers fingerprint, recipeHash andbuilding. Unlike knowledge-pgvector (which refuses a second generation, knowledge-pgvector: a changed fingerprint builds a new generation and switches to it #37101), this store runs the suite withgenerations: true.knowledge_SOURCEtable of the cloud releases, recognised by exactly their seven columns and anF32_BLOBvector, is never served. A table of any other shape under a store name (the store's own generation table, another source's generation table, a table the store did not make in a shared database) is neither served nor dropped;openGenerationremakes a table only when it has the passage shape: search answersKNOWLEDGE_REBUILD_REQUIRED, a write outside a build is refused,beginBuildopens generation 1 as building, andcompleteBuilddrops the legacy table.vector_distance_cos) with the organization filter, the record scope and the metadatafilter(JSON equality per top-level key) in the sameWHERE, before ranking; hits carrydocHashandheadingPath. No DiskANN index:vector_top_kranks before it filters, which breaks K8 item 9, and it is what made os-bob's 1,000 × 1,536 file 329 MB with a 21.8 s build. Measured here without it: 1,000 passages 8.3 MB, write 0.7 s, search ~5 ms; 10,000 passages 82 MB, write 7.2 s, search ~52 ms (Linux x64). Docs say so and point larger sources at pgvector.[]before any query; terms are ORed inside the organization-filteredWHERE. Arecordterm matchessource_record_id; ametadataterm matches a stored string or number equal to an id as text, or a list with such an element, by the field's stored key (bound, never a JSON path). Each term's ids go as one bound JSON array. The suite declaresimplements.scope: true.chunk_hashis stored is not re-embedded; a passage removed by a concurrent write is re-planned (3 attempts), as in pgvector.@libsql/clientis imported lazily instart(); a failed load (no native build), an unopenable file or a refused URL registers the adapter unavailable: boot continues,healthCheckok: false, every call503 SERVICE_UNAVAILABLE, one-sentence message, reason inremedy..changeset/config.jsonfixed group;pnpm-lock.yaml(no new external dependency:@libsql/client@0.18.0is already in the lockfile); one ledger row@objectstack/knowledge-turso: [KNOWLEDGE_REBUILD_REQUIRED]inpackages/spec/src/api/error-code-ledger.zod.ts(its docs mirror lists codes only, unchanged);packages/spec/llms.txtpackage count 77 → 78 (check:llms-txtdemanded it).knowledge.manifest.ts: the Turso "Test connection" hint said the package "this platform does not ship", from the ObjectOS Cloud monorepo, and that a store with no URL reuses the tenant's primary libSQL connection; both are now false. It now names the plugin registered beside the knowledge service and its default file; header list updated; the two tests re-pinned as properties. Minimal, as Knowledge settings page: every key has a reader or leaves the page (adapter, chunk_target, chunk_overlap, over_fetch, enforce_rls) #37104 rewrites this manifest.content/docs/protocol/knowledge.mdxnew section 4.2, overview diagram, contract paragraph, example, status table;content/docs/ai/knowledge-rag.mdxnew section "Local vector store: a libSQL file".Why
Card #37107 (ADR-0161 Execution row 7; cloud ADR-0119 D5 「都放开源」): every deployment not on PostgreSQL,
os devincluded, gets an open vector store that follows the platform's embedder, splitter, listing and fingerprint contract.Tests
packages/plugins/knowledge-turso, 143 cases, no service or image (libSQL runs in-process):contract.test.ts—runKnowledgeAdapterContractwith every member declared (listDocuments,chunks,organizationIds,indexStatus,builds,refusesOtherFingerprint,generations,scope) on:memory:and on afile:URL: 92/92.acceptance.test.ts(42, both stores plus two request-bound cases): Chinese text found with a fixed fake embedder; same content re-upserted → no embed call, changed passage → only it embedded; model changed at the same width and at another width → throughKnowledgeServicethe search is refused, a complete reindex builds_g2,_g1is dropped, the generation row records the new width and model; mid-build the old generation answers its own fingerprint and the new one is "being rebuilt", a third fingerprint abandons the unfinished build and a write under the abandoned fingerprint is refused; two organizations never see each other's hits (topK 1, filter before ranking); metadata filter by JSON type (2vs"2"); legacy table →KNOWLEDGE_REBUILD_REQUIRED, write refused,indexStatusempty, then a reindex replaces and drops it; another source's generation table never read as legacy; a source namedgenerationreindexed with the store's generation table intact and other sources still answering; a table the store did not make under a legacy name kept through a reindex, and under a generation name refused and kept; a passage table left without its generation row remade afresh, not adopted; a write whose generation is switched while it embeds refused 409, never written elsewhere; a record scope by stored key (a dotted name is a key), strings and numbers only (a boolean or object matches no id), a quote in a name, an injection-shaped id matching nothing; 12 concurrent upserts and searches on one:memory:client all succeed; an unsafe source id refused before SQL; no client / no embedder →SERVICE_UNAVAILABLEwith the reason only inremedy,listDocumentsincluded (503, not 409); a request that never answers is bounded byrequestTimeoutMsand the queue moves on; on a slow client (15 ms a request, 120 ms bound) a page of 40 documents of 2 passages is written whole, twice; a write whose second batch hangs answers 503 namingrequestTimeoutMsand nothing of it lands, then the next write goes through; a table with the legacy column names but noF32_BLOBvector is not legacy; a search whose generation is switched at every embed stops after three attempts (503); a source id outside the pattern is400 VALIDATION_ERROR, an 80-character one accepted.plugin.test.ts(9): default URL; platform database refused by name (percent-encoded and differently cased too) and byOS_DATABASE_URL(a URL or a bare path); an undecodablefile:URL refused; side files and links (a linked file, a linked directory) refused; the remote default bound (requestBoundFor); the opened file is in WAL with the generation table; a@libsql/clientthat fails to load (mockedwin32-arm64-msvcerror) registers an unavailable adapter and boot continues; a kernel embedder registered afterstartis read.Single-change ablations, each restored: the old legacy rule (4 red),
openGenerationremaking a foreign table (2 red), the fresh-tableDROP(2 red),listDocumentscomparing before the embedder (1 red), the request bound (1 red), the old whole-turn bound (both request-bound cases red), a commit instead of a rollback after a timeout (1 red), the vector-type half (2 red), theVALIDATION_ERRORcode (2 red), the search retry bound (2 red), the remote default (1 red), the side-file reading (1 red), the write-time generation recheck (2 red), the scope scalar guard (2 red), the scopeWHERE(12 red in the suite).Not covered here: two processes writing one file (the busy timeout is set and pinned by
PRAGMA, not by a two-process race). Scope ids are compared with a stored number's SQLite text: exponent forms and numbers past 15 significant digits match no id here (fewer hits, never more; the service's check after the answer stays the guard).Acceptance notes
carrier: cloud—packages/knowledge-tursoin the cloud repo is now a duplicate; its removal is the cloud card the card names (out of scope). Nothing in cloud imports the package outside its own directory (searched cloudorigin/main).carrier: #37102— the runtime mount names the store's path;defaultStoreUrl(projectRoot)andPLATFORM_DATABASE_FILESare exported for it.knowledgesettings namespace (turso_url,turso_auth_token) is still read by no plugin; Knowledge settings page: every key has a reader or leaves the page (adapter, chunk_target, chunk_overlap, over_fetch, enforce_rls) #37104 rewrites the manifest.Verification
Two-minute check:
pnpm --filter @objectstack/knowledge-turso test→Test Files 3 passed (3),Tests 143 passed (143).Read first:
src/turso-adapter.tsbeginBuild/completeBuild/writeTarget(generation switching),hasLegacy/openGenerationwithtableShapeinsrc/sql.ts(the legacy rule), theserialqueue and its bound at its top, andsrc/plugin.tsresolveStoreUrl(the platform-file refusal).Local gates at head 796b204: 133 of 134 derived families exit 0, 1 not measured; CI at 796b204: 62 success, 9 skipped, 0 failed
node scripts/pm/dispatch-gates.mjs --ran(with exit codes): 134 derived famil(ies) accounted for, 133 run, 1 NOT-MEASURED (1 derived from a recorded exit 3).pnpm --filter @objectstack/knowledge-turso test: Test Files 3 passed (3), Tests 143 passed (143) (lock VERDICT command-exit 0).typecheck(incl.check:test-typecheck) andbuildexit 0.service-settings:knowledge.manifest.test.ts25/25;typecheckexit 0.check:llms-txtgreen at 78 packages.check:error-code-provenance,check:docs,check:package-naming,check:changeset-no-major,check:dual-build-cjs-loads,check:published-readme-exports,check:skill-examplesexit 0 at this head.check-plugin-teardown-shape --self-test(needs an unshallow clone; its scan passed)..github/workflowsedit: the libSQL suite runs in the normal test shards, no service image needed. Dogfood battery: n/a (no!in the title, no narrowing arm).56f3dc5e(first hand-back) →68654e1dmergesmainatdb77cc49(brings feat(service-knowledge): search inside chosen records — the record scope, by the records a source indexes or by a parent through a listed lookup #37342) →9c469ddfthe record scope →f073750areview round 1 (seat comment 7179839476) →796b204creview round 2 (seat comment 7180860083).Human Minimum
packages/specholds no runtime logic.pnpm lintpasses (CI).main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed (none change for a ledger row;check:error-code-provenanceandcheck:docsgreen).content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code