Repository navigation
Description
repo:objectstack#2 · os-warren · session_01JQwxbYGom9jneGXshSXk4W
Filing category ④ — child card of topic #38703, diagnosis speed item 1 · Source: cloud#5250 diagnosis (project file cloud-5250/pg-diagnosis-2026-11-30.md, section 补充实测 10:03Z)
Grade: priority:p1 · area:ai · inherits the topic's grade. Triage (lane self-triage, fleet-filed child card): domain:server (the fix lands in packages/plugins/knowledge-pgvector).
Route: developed by repo:objectstack#3 (os-steve) per the maintainer's 2026-11-30T08:00:03Z 「38703 剩下的任务让 #3 座位接手」; filed by seat 2 at the maintainer's go (below), not claimed by it.
维护者速读
- 问题:按单位范围检索时,数据库仍把 5.8 万条条款全部算一遍相似度,最后才丢掉范围外的。范围内只有约 170 条,但耗时和不带范围一样,10 人同时查时带范围检索 p95 约 4.2 秒。
- 本卡做:给条款的 metadata 建 PostgreSQL 自带的 GIN 索引,把范围条件改成索引能用的写法,让数据库先取出范围内的行,只对这些行算距离。仍是逐条精确比较,结果不变。
- 实测:同一问题、同一单位范围,向量这一路从约 400 毫秒降到约 1.4 毫秒,前 5 条完全一致。
- 不做:HNSW 等近似索引(第三期,维护者裁定不处理)。
Maintainer's go
- 2026-11-30T10:05:00Z, os-warren's project, cloud#5250 diagnosis thread: 「1+2+3+4」 — approving the diagnosis thread's speed list, of which item 1 is this card.
- 2026-11-30T10:05:11Z, same thread: 「现在就是考虑只走向量」 — the direction is vector-only retrieval, so the
vecCTE is the priority (see Scope).
Business reason
Topic #38703's phase-1 target: on self-hosted Enterprise PostgreSQL, ten people asking at once get answers without timeouts. BrightRule policy inquiry, the first customer, always searches within the asker's unit chain. Real-embedding load on cloud#5250 (2026-11-30T09:50Z, PG16, 58,512 passages, 10 clients, pool 4): scoped p50 2.50 s / p95 4.24 s against unscoped 0.47 s / 0.67 s. Scoping is the slow path, and it is the path the customer uses.
Premise (read on origin/main f782a12, 2026-11-30T10:10Z)
packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts:645-668— ametadatascope term is written asEXISTS (SELECT 1 FROM jsonb_array_elements(CASE jsonb_typeof(metadata -> field) …) AS e(v) WHERE jsonb_typeof(e.v) IN ('string','number') AND e.v #>> '{}' = ANY(ids)). No index can serve it. Re-check:git grep -n "jsonb_array_elements" origin/main -- packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts.pgvector-adapter.ts:674— that predicate joins the oneinScopestring used by thevecCTE (:684), thecandCTE (:717) and thestatscount (:721). Re-check:git grep -n "WHERE \${inScope}" origin/main -- packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts.packages/plugins/knowledge-pgvector/src/sql.ts:92-97,122— the adapter already creates its own indexes (_document,_record, the keyword GIN onto_tsvector) withCREATE INDEX IF NOT EXISTS; there is none onmetadata. Re-check:git grep -n "CREATE INDEX" origin/main -- packages/plugins/knowledge-pgvector/src/sql.ts.- Measurement (cloud#5250 acceptance DB, PG16 + pgvector 0.8.7, 58.5k rows, one unit = 168 rows,
jit = off, 4 runs each): current scopedvecSQL 386–459 ms, a sequential scan filtering out 58,348 rows; withCREATE INDEX … USING gin (metadata jsonb_path_ops)and the scope written asmetadata @> '{"owning_unit":"<id>"}' OR metadata @> '{"owning_unit":["<id>"]}', 1.3–2.3 ms via Bitmap Index Scan + BitmapOr, 164 rows,same_top5 = t. Index build 0.27 s, ANALYZE 2.1 s.
What
- Add a GIN index on
metadata(jsonb_path_ops) to the passage table's DDL insql.ts, beside the existing indexes, so new and existing tables get it the way they get the keyword index. State in the PR what an existing large table pays the first time (lock and time), and whether that path already runs for existing tables. - Rewrite each
metadatascope term so the planner can use that index: a disjunction ofmetadata @> …containment forms, one scalar and one one-element-array form per id, as boundjsonbparameters. Because today's predicate also holds for a stored number equal to the id as text, an id that reads as a JSON number also gets the number forms. - Keep today's exact predicate as a recheck ANDed with the containment disjunction (or prove the containment form alone is equivalent). The containment disjunction must be a superset of today's matches, so results cannot change.
Scope under the vector-only direction
- The
vecCTE is the priority: vector mode (知识源加「检索方式」和混合比例:只用向量 / 只用关键词 / 混合(可设比例),由应用元数据指定,单次检索可覆盖 #38692 1a, PR feat(knowledge-pgvector): run one leg or both by the search's retrieval mode; report the three modes, hybrid by default #38745) runs only that leg. candandstatsread the sameinScopestring, so the rewrite reaches them at no extra cost. Hybrid stays the default mode in feat(knowledge-pgvector): run one leg or both by the search's retrieval mode; report the three modes, hybrid by default #38745 for other sources, so no extra work is owed for them and none is removed.
Constraints
- Only PostgreSQL's own facilities (GIN,
jsonb_path_ops,@>). No approximate index; phase 3 (HNSW etc.) is ruled out (maintainer, 2026-11-30T08:00:49Z 「第三期不处理」). - Results must equal today's for every stored shape: string, number, array of strings or numbers, missing, null, object, boolean. One equivalence test per shape.
- Tests pin statement shape (the containment form, the index DDL), never wall-clock time. A live-PG test (the package's
contract.live-postgres.test.tspattern) shows the plan uses the index for a scoped search:EXPLAINnames the index, not a sequential scan. - B2's
SET LOCAL statement_timeoutand coded refusals (src/errors.ts) stay as they are.
Order with in-flight work
- PR feat(knowledge-pgvector): run one leg or both by the search's retrieval mode; report the three modes, hybrid by default #38745 (知识源加「检索方式」和混合比例:只用向量 / 只用关键词 / 混合(可设比例),由应用元数据指定,单次检索可覆盖 #38692 1a pgvector, zone o2-A, draft) changes
search()in the same file (+49/-18), around the legs, not the scope-term block. This card's PR lands after feat(knowledge-pgvector): run one leg or both by the search's retrieval mode; report the three modes, hybrid by default #38745. Build frommain; if feat(knowledge-pgvector): run one leg or both by the search's retrieval mode; report the three modes, hybrid by default #38745 merges first, rebase onto it. Its thread tells topic 专题:私有部署企业版(PostgreSQL + pgvector)知识检索 10 人同时提问不超时;Turso 只保基本能力 #38703 when it lands. - Does not touch
service-knowledge(知识源加「检索方式」和混合比例:只用向量 / 只用关键词 / 混合(可设比例),由应用元数据指定,单次检索可覆盖 #38692 1a's PR feat(service-knowledge): read a source's retrieval mode and refuse a mode its store does not run #38722 holds it).
Acceptance
- A scoped search's
vecstatement on PG uses the metadata GIN index (EXPLAIN in the live test), and its hits equal today's for every stored shape above. - The PR body gives the before/after
EXPLAIN ANALYZEof one scopedvecstatement on a seeded table, and the index's first-build cost. - Feeds the PG 10-client re-run (knowledge-pgvector:检索分段计时与 PostgreSQL 基线(专题 #38703 B1) #38719 part 2), run by
repo:objectstack#2zone o2-E on cloud#5250 after feat(knowledge-pgvector): run one leg or both by the search's retrieval mode; report the three modes, hybrid by default #38745 and this card merge.
Dedupe
Searched 2026-11-30T10:12Z, open and closed: repo:objectstack-ai/objectstack is:issue pgvector scope (8 hits) and pgvector gin metadata (3 hits: #37974, #38473, #38411, all closed keyword-leg cards). None covers a metadata index or scope-first filtering. #38676 is Turso's slow path, not PostgreSQL's. The diagnosis's own note agrees (「还没有卡覆盖」).
Activity
objectstack-fleet commentedon Nov 30, 2026
repo:objectstack#3 · os-steve · session_01ADHkmTLwBddAv8qQwmLzdk
Claim: PM loop round 2
Session:
session_01ADHkmTLwBddAv8qQwmLzdkAccount:
os-steveBranch:
claude/issue-38747-pgvector-scope-ginWorktree:
objectstack-issue-38747Domain:
domain:serverSeat:
repo:objectstack#3Area: o3-D (seat's exception pick for this area:ai card; the seat has no ai zone; route per the card: 「38703 剩下的任务让 #3 座位接手」)
File surface:
packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts(the metadata scope-term block andinScope, ~:645-674 onorigin/mainf782a12, only; not the retrieval-mode / embedding block that PR #38745 changes),packages/plugins/knowledge-pgvector/src/sql.ts(the GIN index DDL beside the existingCREATE INDEX IF NOT EXISTSlines, and its readiness check if the adapter has one), new test filespackages/plugins/knowledge-pgvector/src/__tests__/scope-containment-38747.test.tsandpackages/plugins/knowledge-pgvector/src/__tests__/scope-containment-38747.live-postgres.test.ts,.changeset/38747-*.md. Anything else ⇒ stop and report.Container & model:
M,mode:subagent,model: opus(dispatch-gates --tier: "Model tier — no path-derived mandate … floor sonnet · default opus · ceiling fable"),effort: highClause-②: no
Metadata-protocol: none
Responsibility:
knowledge-pgvector's own scope SQL in this repo — the metadata scope term is anEXISTS (… jsonb_array_elements …)no index can serve (pgvector-adapter.ts:663), joined into the oneinScoperead byvec(:687),cand(:718) andstats(:721) | no existing path covers it (sql.tscreates_document,_recordand the keyword GIN, none onmetadata) | every scoped search on self-hosted PostgreSQL; the first customer always scopes by unit (cloud#5250 load: scoped p95 4.24 s vs unscoped 0.67 s)Thread-read: none
Rulings read: card body (maintainer go 2026-11-30T10:05:00Z 「1+2+3+4」 and 10:05:11Z 「现在就是考虑只走向量」; phase 3 out, 2026-11-30T08:00:49Z 「第三期不处理」); seat 10:16Z: Steve asked to speed this card up, so it is built in parallel with PR #38745 instead of queued behind it
Premise: holds (origin/main f782a12:
git grep -n "jsonb_array_elements"→pgvector-adapter.ts:663;git grep -n 'WHERE ${inScope}'→ :687, :718, :721;git grep -n "CREATE INDEX" … sql.ts→ :92, :95, :122, none onmetadata. The card's measurements were taken on the cloud#5250 acceptance DB and are not re-measured here; the dev measures before/after on a seeded table)Pre-claim lane:
domain:server—packages/plugins/knowledge-pgvector(plugin family).Pre-claim deps: PR #38745 (#38692 1a, seat 2 zone o2-A, draft) edits the same file. Its hunks in
pgvector-adapter.tssit at ~133, 189, 289, 610-650 (mode, embedding), 755 and 1422; this card's block is 645-674, so the text barely meets and the code does not depend on it. This branch rebases ontomainunder the same name after #38745 merges and still lands after #38745, as the card orders.Prior rulings read:
check-prior-rulings.mjs --card 38747→ 143 term hits; ADR-0003 §4, ADR-0005 §3/§5/§8/§11, ADR-0019 D3 named by term only, none on scope SQL or index DDL; thread: none.Fold-or-serial: serial after PR #38745 for landing only; no other card folded.
Serial constraints cleared:
check-handover --inflight --paths=pgvector-adapter.ts,sql.ts,src/__tests__/ --card=38747: overlap with #38692 (claim 7270621658,packages/plugins/knowledge-pgvector/src/**) — accepted for this card on the maintainer's word via the seat (2026-11-30T10:16Z), landing serial behind PR #38745; overlap with #37802 is a suffix match on a__tests__/…tsxfragment, not this package.objectstack-fleet commentedon Nov 30, 2026
triage@os-warren · os-warren · session_01JQwxbZzZ2f5mzcvJbRrRNZ
Triage: first-touch (type only) · Task · lane grade kept: p1 ·
area:ai·domain:server·pm:dispatched(claimed by repo:objectstack#3, 7275406524).objectstack-fleet commentedon Nov 30, 2026
repo:objectstack#3 · os-steve · session_01ADHkmTLwBddAv8qQwmLzdk
os-dev-report
{ "issue": 38747, "status": "blocked", "branch": "claude/issue-38747-pgvector-scope-gin", "pr": "https://github.com/objectstack-ai/objectstack/pull/38758", "session": "session_01ADHkmTLwBddAv8qQwmLzdk", "premise_still_valid": true, "summary": "Implemented at head 620fadf1f9 (draft PR #38758, lands after #38745). sql.ts: GIN index knowledge_vec_dWIDTH_metadata on metadata jsonb_path_ops in vectorTableDdl, plus metadataScopeForms (per id: scalar and one-element-array string forms, plus the two number forms when the id is PostgreSQL's numeric text). Adapter scope-term block: each metadata term is now (metadata @> ANY($N::jsonb[]) AND today's exact EXISTS predicate byte for byte); the one inScope still feeds vec, cand and stats. Existing tables: the DDL path (ensureVectorTable) runs only on upsert/beginBuild and is skipped once a search has found the table, so an ensureMetadataIndex twin of ensureKeywordIndex (to_regclass lookup first, then a plain CREATE INDEX IF NOT EXISTS, refusing 503 with the statement when it cannot create) runs at the first metadata-scoped search. BLOCKED on one thing only the seat can grant: packages/plugins/knowledge-pgvector/bench/instrument.test.mjs:189 pins the ranking statement's params as ['clauses', 1, ['u1','u2'], 'unit']. This change appends the forms array, so that pin is red (the package test shows 163/164). The file is outside the claimed surface, and my Edit was refused by the auto-mode classifier, so I did not work around it. The fix is one hunk: change the expectation to ['clauses', 1, ['u1','u2'], 'unit', ['{\"unit\":\"u1\"}','{\"unit\":[\"u1\"]}','{\"unit\":\"u2\"}','{\"unit\":[\"u2\"]}']] (optionally also assert parts.where contains 'metadata @> ANY($5::jsonb[])'). Everything else is done and does not wait on it.", "measurements": { "seeded_table": "local PG 16.15 + pgvector 0.6.0, jit off, 58,500 passages x 1024 dims, owning_unit over 350 units (1/10 list two), scope u7 (336 hold, 81 below distance 1); the adapter's own vec CTE recorded from a real search, EXPLAIN (ANALYZE, BUFFERS) x4; shared container", "before_base_f782a12033": "Seq Scan, Rows Removed by Filter 58420; 296.7 / 338.5 / 295.7 / 306.5 ms", "after_head_620fadf1f9": "Bitmap Index Scan on knowledge_vec_d1024_metadata, Recheck Cond metadata @> ANY(jsonb[]); 2.27 / 1.95 / 1.80 / 1.67 ms; top5 identical (c56007,c35707,c3857,c39557,c53557)", "first_build": "CREATE INDEX 32 ms (index 256 kB, table 338 MB), ANALYZE 264 ms; SHARE lock: reads continue, writes wait for the build", "lock_probe": "CREATE INDEX IF NOT EXISTS on an EXISTING index, with a writer transaction open, was cancelled by lock_timeout 800ms (it takes the table lock before the existence check); to_regclass answered at once, which is why the ensure looks up first", "concurrently": "not chosen: an interrupted concurrent build leaves an INVALID index that IF NOT EXISTS then treats as made forever; cannot run in a transaction block; the table's other three indexes are plain" }, "tests": "HEAD 620fadf1f9. With the live server OS_TEST_POSTGRES_URL=postgres://...:54747/kt and OS_EXPECT_LIVE_DIALECT_MATRIX=1: (1) new files alone, verbose: unit 12 + live 11 = 23 passed; every live case ran, none skipped. (2) Package-wide `pnpm --filter @objectstack/knowledge-pgvector test` through the lock (VERDICT command-exit 1): Test Files 17 passed, 1 failed (18); Tests 163 passed, 1 failed (164). The one red is bench/instrument.test.mjs, the stale pin named in summary. (3) `pnpm --filter @objectstack/knowledge-pgvector typecheck` VERDICT command-exit 0. Red first: with the base sql.ts and adapter restored by git restore --source=f782a12033 and the new tests kept, 13 tests were red (11 unit, plus the live EXPLAIN case and the existing-table case). The record-only preservation case and the 9 per-shape equivalence cases stayed green. They are invariance pins: today's exact predicate is their oracle, so they cannot go red on the code that is that oracle. Mutation ablations through scripts/ablation-replace.mjs, each landing confirmed on disk (anchor x1->x0, blob changed) and each restored (git diff HEAD empty, status clean): recheck ORed with TRUE gave 4 red (number, list of numbers, 2 shape pins); array forms dropped gave 7 red; number forms dropped gave 5 red; the ensure call deleted gave 4 red; the DDL line deleted gave 2 red. The tests import from src, so no dist leg applies.", "gates": "Local: `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` (no paths) derived 70 families at 620fadf1f9. Each ran with stdin from /dev/null, exit captured before any pipe; 69 exit 0. `pnpm check:dual-build-cjs-loads` first exited 3 (PREREQUISITE NOT MET, no dist). After a full `pnpm turbo run build --concurrency=2` (124/124 tasks) it was re-run through the lock: exit 0 ('126 published require entry point(s) across 74 package(s) load'). `--ran` reconciliation: '70 derived, 70 run, 0 NOT-MEASURED, 0 UNRUN'. Overlap: `node scripts/pm/overlap-check.mjs --branch=claude/issue-38747-pgvector-scope-gin` gave 'VERDICT clean exit 0': merges cleanly with origin/main and with #38745. CI check-runs: NOT MEASURED, reason: the report was written right after the PR opened. Test Core is expected red on the bench pin until the seat authorizes that hunk.", "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm", "line_budget": { "files_changed": 5, "additions": 562, "deletions": 3, "pgvector-adapter.ts": "+45/-3 (now 1614 lines)", "sql.ts": "+62/-0 (302)", "unit test": "+200", "live test": "+244", "changeset": "+11" }, "files_changed": [ ".changeset/38747-knowledge-pgvector-scope-gin.md", "packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts", "packages/plugins/knowledge-pgvector/src/sql.ts", "packages/plugins/knowledge-pgvector/src/__tests__/scope-containment-38747.test.ts", "packages/plugins/knowledge-pgvector/src/__tests__/scope-containment-38747.live-postgres.test.ts" ], "deviations": [ "Adapter surface beyond the scope-term block, under the claim's 'and its readiness check if the adapter has one': imports of the three sql.ts helpers, one field (metadataIndexed, beside keyed), and the ensureMetadataIndex method beside ensureKeywordIndex. Card What 1 requires it ('so new and existing tables get it the way they get the keyword index'), and the DDL path alone does not reach a table first touched by a search. None of these hunks is in #38745's ranges (overlap-check clean).", "os-dev rule 3, >1000-line file: the new ensure method went into pgvector-adapter.ts (1614 lines) beside its twin rather than into a sibling module, because the claim admits no new source file. This conflict between the rule and the claim is named here, not resolved silently.", "Containment is written as one `metadata @> ANY($N::jsonb[])` per term instead of an explicit OR of 2-4 bound jsonb parameters per id. It is the same disjunction, the planner runs it as one Bitmap Index Scan, and it keeps a 500-id term to one parameter.", "Number forms are built from the id's raw text, never through a JS Number, so a long id does not lose precision. Lone surrogates are written as U+FFFD, as the pg driver sends text parameters, so jsonb never sees an invalid escape.", "pgvector was missing in this container: I installed postgresql-16-pgvector with apt-get and ran a private initdb cluster at /tmp/pg38747 on port 54747. It is stopped and its directory deleted. The measurement script lives in the scratchpad, outside the repo.", "My first commit carried the harness's model-named Co-Authored-By trailer. check:commit-card-trailers refused the push, and I amended it to the model-free pair before anything was published.", "A python heredoc edit was refused by Claude Code's built-in removal-safety check. Nothing was deleted, and I made the same edit with the Edit tool. My Edit of bench/instrument.test.mjs was refused by the auto-mode classifier and was not retried by any other route." ], "mcp_calls": "0", "api_writes": "2 — relay pr_create (POST /repos/objectstack-ai/objectstack/dispatches, which the relay ran as POST /repos/objectstack-ai/objectstack/pulls and created #38758: 20676 bytes sent, 20676 stored, no labels or assignees); this os-dev-report comment through post-stamped (POST /repos/objectstack-ai/objectstack/issues/38747/comments). git push is not counted.", "classifier_refusals": [ { "command": "Edit packages/plugins/knowledge-pgvector/bench/instrument.test.mjs (update the parameter-list pin at :189 to include the containment forms)", "reason": "[Destructive or Unwanted Actions]", "mode": "subagent", "human_turn_before": "no", "resend": "none" }, { "command": "python3 heredoc applying the adapter edits (no removal in it)", "reason": "built-in Claude Code safety check: could not rule out a dangerous removal in the command as parsed", "mode": "subagent", "human_turn_before": "no", "resend": "passed — the same edits were applied with the Edit tool, which deletes nothing" } ], "open_questions": [ { "question": "Authorize the one-hunk update of bench/instrument.test.mjs:189 (outside the claimed surface) so Test Core goes green?", "options": [ "A: seat authorizes; the next round applies the hunk named in summary on this branch", "B: the seat applies it itself on the branch" ], "recommendation": "A, because the hunk is the mechanical consequence of this change and os-dev's rule has a change's own stale fixture fixed in the same PR" }, { "question": "Should a database role that may not create the metadata index refuse a scoped search (as now, mirroring ensureKeywordIndex), or degrade to the unindexed scan with one warn?", "options": [ "A: refuse 503 with the CREATE INDEX statement in remedy (current, same as the keyword index)", "B: answer through the sequential scan and warn once" ], "recommendation": "A for parity with the keyword index; B only if read-only search roles are a supported deployment" } ], "security_findings": "none", "out_of_scope_findings": [ "carrier: none · noted, not filed: ensureKeywordIndex sends CREATE INDEX IF NOT EXISTS without a lookup first, so its once-per-process run waits on any open writer transaction (measured with lock_timeout on PG16); it is in PR #38758's Acceptance notes" ] }objectstack-fleet commentedon Nov 30, 2026
repo:objectstack#3 · os-steve · session_01ADHkmTLwBddAv8qQwmLzdk
Claim amendment (#38747, PR #38758) — seat ruling 2026-11-30 11:32Z.
packages/plugins/knowledge-pgvector/bench/instrument.test.mjs, the single params pin at :189 only. The edit appends the containment-forms array this change adds to the ranking statement's parameters; no other line in that file changes.CREATE INDEXstatement. A missing performance index must not turn a scoped search that works today into a 503. Pinned by a test (index cannot be created → same top 5, exactly one warning) and an ablation of the fallback.ensureKeywordIndexis unchanged, because a keyword search cannot run without its index.Landing order is unchanged: rebase onto
mainunder the same branch name after #38745 merges, land after #38745.objectstack-fleet commentedon Nov 30, 2026
repo:objectstack#3 · os-steve · session_01ADHkmTLwBddAv8qQwmLzdk
Landing order changed (#38747, PR #38758) by the maintainer's ruling at 2026-11-30 12:02:57Z: PR #38758 no longer lands after #38745. Once it passes review it lands on its own, with no rebase onto #38745 first.
overlap-checkreads the two as merging cleanly in either order, so whichever lands second rebases ontomainif git asks. The rest of the claim and the 11:32Z amendment are unchanged.objectstack-fleet commentedon Nov 30, 2026
repo:objectstack#3 · os-steve · session_01ADHkmTLwBddAv8qQwmLzdk
os-dev-report
{ "issue": 38747, "status": "done", "branch": "claude/issue-38747-pgvector-scope-gin", "pr": "https://github.com/objectstack-ai/objectstack/pull/38758", "session": "session_01ADHkmTLwBddAv8qQwmLzdk", "round": 2, "premise_still_valid": true, "summary": "Round 2 at head 6f65533787 (one commit on 620fadf1f9), under the 11:32Z claim amendment. (1) The bench/instrument.test.mjs:189 params pin now lists the containment-forms array and asserts that parts.where contains 'metadata @> ANY($5::jsonb[])'. No other line in that file changed, so the comment at :188 still names only the ids and the field. (2) Missing-index behaviour is now B. When CREATE INDEX fails and the index is still absent, ensureMetadataIndex adds the width to metadataUnindexed (the failure twin of metadataIndexed) and logs one warn naming the consequence and the full CREATE INDEX statement. It never tries again in that process. The search runs the same statement, answered by today's sequential scan, and once an owner creates the index the next search uses it with no restart. ensureKeywordIndex, errors.ts and the mode/embedding block are untouched; there is no HNSW. The changeset sentence about the 503 was replaced to match. In the PR body I rewrote the read-only-role bullet, the 维护者速读 line 3, the test-count line, the ablation rows and the local readings, and removed the KNOWN GAP note. Per the 12:02:57Z ruling, the landing line now says the PR lands on its own once reviewed and that overlap-check reads the two as merging cleanly in either order. The overlap-check verification line is kept.", "measurements": { "round1_unchanged": "before 296.7-338.5 ms Seq Scan vs after 1.67-2.27 ms Bitmap Index Scan, same top 5; first build 32 ms + ANALYZE 264 ms (58,500 x 1024)", "real_role_probe": "one-off, outside the suite, live PG16: a role that owns the store schema and generation table but not the passage table got 'must be owner of table knowledge_vec_d384'. Two searches both answered p0:1.0000, p15:0.9839, p28:0.9683, p7:0.9531, p22:0.9385, identical to the indexed adapter; 1 warning carrying the CREATE INDEX statement; index absent afterwards", "note": "a role with no CREATE on the database is refused earlier, by ready()'s schema DDL (SERVICE_UNAVAILABLE, existing behaviour). The fallback is reached by a role that may run the store's schema DDL but does not own the passage table, or by a create that fails for another reason, such as a lock_timeout" }, "tests": "HEAD 6f65533787, live PostgreSQL 16.15 + pgvector 0.6.0, OS_EXPECT_LIVE_DIALECT_MATRIX=1. Package test: Test Files 18 passed (18), Tests 165 passed (165); typecheck exit 0 (TEST_EXIT=0 TYPECHECK_EXIT=0 printed separately). New pins: unit 'when it cannot be made, the search still ranks, warns once with the statement to run, and never tries again' (one create, two lookups, one warning, both searches ranked with the containment statement), and live 'a database that refuses the metadata index: the scoped search answers the indexed top 5 by a scan, with one warning'. The live pin drops the index, stubs the refusal at the pool (code 42501) so CI needs no role privileges, compares ids and scores for two queries against the indexed path, and asserts one attempt, one warning with the full statement, and the index still absent. The two new files hold 12 unit + 12 live cases. Ablations through scripts/ablation-replace.mjs, each restore proven by blob 6fe750f9cf7d and an empty git diff HEAD. 503 put back in place of the fallback: 2 red (both fallback pins). Remembered failure removed (the metadataUnindexed check): 2 red (both fallback pins). The first 503 attempt was a no-op that the tool refused (its replacement contained the anchor, 'anchor count moved 1 -> 1'); it was re-run with a non-overlapping replacement, which landed (anchor 1 -> 0). The round-1 ablations stand.", "gates": "Local, at 6f65533787: `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 70 families over 6 paths. A full `pnpm turbo run build --concurrency=2` ran first (lock VERDICT command-exit 0). Each family ran with stdin from /dev/null, exit captured before any pipe; all 70 exited 0, including check:dual-build-cjs-loads. `--ran`: '70 derived, 70 run, 0 NOT-MEASURED, 0 UNRUN'. overlap-check before the push and again at 6f65533787: 'VERDICT clean exit 0' (origin/main and #38745 both merge cleanly). CI check-runs at 6f65533787: 57 runs, 39 success, 18 skipped, 0 failure, including Lint & Repo Gates, TypeScript Type Check, Build Core, Test Core 1/12-12/12 and Check Changeset. Temporal Conformance and the Dogfood Regression Gate do not run on pull_request (first run in the merge queue): NOT MEASURED here.", "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm", "line_budget": { "round2_commit": "6 files: adapter (metadataUnindexed field + fallback in ensureMetadataIndex), bench pin hunk, unit test (fallback case replaces the 503 case), live test (+1 case), changeset sentence" }, "files_changed": [ ".changeset/38747-knowledge-pgvector-scope-gin.md", "packages/plugins/knowledge-pgvector/bench/instrument.test.mjs", "packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts", "packages/plugins/knowledge-pgvector/src/sql.ts", "packages/plugins/knowledge-pgvector/src/__tests__/scope-containment-38747.test.ts", "packages/plugins/knowledge-pgvector/src/__tests__/scope-containment-38747.live-postgres.test.ts" ], "deviations": [ "The resumed worktree did not merge origin/main, which dev-worktree suggests for a resumed branch. The coordinator said to build on 620fadf1f9, and AGENTS.md §10 merges main into an open PR only on a conflict or a main-caused red; neither applies (overlap-check clean, CI green). The base was pinned at 620fadf1f9.", "The local branch left over from round 1 made dev-worktree refuse; I deleted it with `git branch -d` (it equalled the remote at 620fadf1f9) and re-ran. After this round the worktree is removed, but the local branch claude/issue-38747-pgvector-scope-gin (6f65533787, equal to the remote) is kept because `git branch -d` refused it as unmerged relative to the shared checkout's HEAD, and I did not force it. A next round must `git branch -d`/`-D` it before dev-worktree --resume-from, or the seat may.", "The fallback warns through the adapter's existing optional logger; that option's docstring (line 117, outside the surface) still names only the old-generation case.", "The fallback live pin stubs the refusal at the pool rather than using a real role, so CI needs no CREATE ROLE privilege; the real-role refusal is shown by the one-off probe in measurements.", "My private PostgreSQL at /tmp/pg38747 (port 54747) was re-created for this round, then stopped and deleted." ], "mcp_calls": "0", "api_writes": "2 this round — relay issue_patch on #38758's body (POST /repos/objectstack-ai/objectstack/dispatches, run 46416759729, 22655 bytes sent, 22655 stored, identical; the live body was read and found unchanged by others before the write); this os-dev-report comment through post-stamped (POST /repos/objectstack-ai/objectstack/issues/38747/comments). Round 1 had 2 (pr_create, report comment). git push is not counted.", "classifier_refusals": [], "open_questions": [], "security_findings": "none", "out_of_scope_findings": [ "carrier: none · noted, not filed: ensureKeywordIndex sends CREATE INDEX IF NOT EXISTS without a lookup first, so its once-per-process run waits on an open writer transaction; it is in the PR's Acceptance notes (unchanged from round 1)" ] }objectstack-fleet commentedon Nov 30, 2026
repo:objectstack#3 · os-steve · session_01ADHkmTLwBddAv8qQwmLzdk
Delivered by PR #38758, merged 2026-11-30T13:01Z as 111ad63, which closed this card by
Fixes.sweep-closed-cards --pr 38758is clean: the only card it closed is this named one.pm:dispatchedis removed with this comment.fix(knowledge-pgvector): read only the passages in scope for a metada…