Repository navigation
feat(service-knowledge): record changes sync through the queue service — a save does not wait for the embedder, a failed sync is retried, a rolled-back write is never indexed - #38043
Conversation
…ependencies Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…e (wip) Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…otocol, the RAG guide and the README Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…e it was Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…ps dead letters Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…nd the queue service from source Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…umn requires Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…ted yet; test the published rows, not their absence Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
… and by record Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
📓 Docs Drift CheckThis PR changes 1 package(s): 34 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 6 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 4 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 711f6b613c7e2b32c49c31d5669ab1c18cb77c78 && git checkout 711f6b613c7e2b32c49c31d5669ab1c18cb77c78
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 8d34c4404f951410083a6caebd6ad8003ea3423d 5d430ea461542902c21fbc9ff0c6ec921d07c758 && git checkout -B drift-repro 8d34c4404f951410083a6caebd6ad8003ea3423d && git merge --no-ff 5d430ea461542902c21fbc9ff0c6ec921d07c758
node scripts/docs-audit/affected-docs.mjs --json 8d34c4404f951410083a6caebd6ad8003ea3423d
|
|
repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3 Contract reviewServed-tier: Face: declaration. The diff touches no published-schema path and no governed rule text (13 files, all under ① Derived judgments
② Semver level
③ Boundary flags
Nits (no grade)
No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3 L1 review — ACCEPT on merits, landing blocked by the PR-body guardHead: Verdict: ACCEPT on the code, tests and docs at this head. Contract review: TIER_DEFAULT declaration record 7227410375, PASS, no must-fix and no should-fix. Read: the queue module, the service and plugin changes, the hooks, the 20 new tests, the changeset and both docs pages sentence by sentence. The publish goes through Before it lands:
A head that moves only for the claim and a re-run needs nothing more from this lane; a code change needs a delta read. Nits (optional, may go in a follow-up): N1 qualify the "last committed version" sentence in |
|
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP Landing · area o1-C · head
State: ready + auto-merge; #37735 and #37110 close on merge via |
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…h the source's binding Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 46064910619 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
|
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP Merge-queue drop (CI_FAILURE): cause and fix Cause: this was a real semantic conflict with main, not a flake. #38026 landed on main and made Fix (commit 5d430ea, on top of a merge of origin/main):
The verification readings are in the dev report. Generated by Claude Code |
|
repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3 Contract reviewServed-tier: Delta of record 7227410375 (head 43dc682). Face: declaration, unchanged. No published-schema path and no governed rule text in the diff. ① Derived judgments
② Semver levelUnchanged: ③ Boundary flags
Nits (no grade)
No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3 L1 verdict (L1-a): ACCEPT at head Review summaryContract review. Delta declaration record 7229469935 at this head: PASS, no must-fix and no should-fix. Delta.
Gates.
Nits, optional:
Next: not governed and not Tier H, so the area re-lands it once every check on this head is green. |
|
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP Re-landing · area o1-C · head
Queue drop cause (TS2345 after #38026 made |
…behind a per-source recipe proof (objectstack-ai#37963) repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP Fixes objectstack-ai#37467 Clause-②: yes (narrowing) Metadata-protocol: none Skills-docs: none — no published skill teaches the knowledge field gate or its refusals (`git grep` of `skills/objectstack-ai` for the gate, the display field and `KNOWLEDGE_REBUILD_REQUIRED`: 0 hits) Security-touching: yes ## 维护者速读 - 用户能看到什么变化:知识检索的权限过滤不再额外检查名为“标题”的旧字段;对象同时有“标题”字段和另一个显示字段的知识源,只有在索引确认按当前方式完整建成后才对非系统用户开放,而且每条命中都要与记录的当前内容核对,对不上的不返回。 - 为什么做:知识检索收口(知识库检索按调用者权限过滤)的遗留清理:旧索引兼容分支退役,改为按知识源确认索引、按命中核对内容。 - 出错会怎样:最坏是这类知识源在重建完成前检索不到内容(会明确报“需要重建”),或刚改过的个别记录暂时搜不到(后台自动补写);不会泄露无权字段,改动可直接撤回。 - 要你做什么:审阅这次安全相关的收紧,决定是否合并。 ## What changes - **The field gate's `title` arm is gone** (`knowledge-source-admission.ts`, `servedFieldsOf`). The gate asks about exactly what a document carries under the current recipe: each `content` and `metadataFields` member and the display field (`documentTitleField`), less the fields an index never carries. - **Per-source proof at search time** (`KnowledgeService.unprovenIndex`, from `planSearches`). `mayServeEarlierRuleTitle` names the sources where the retired arm mattered: the object declares a field named `title` (or its fields cannot be enumerated), the index may carry it, and the source does not serve it. For a non-system caller such a source is searched only when its adapter's `indexStatus` reports the fingerprint AND the recipe hash `planIndex` computes now, and only where the builds that record that hash purge. It is never proven for `refresh.onRecordChange: false`, or on an adapter with no `indexStatus`, no `completeBuild` or no `listDocuments`. - **Per-hit check on a proven source** (`KnowledgeService.dropUnverifiedHits`; the seat's ruling S1 = B). The proof speaks for the index as its last complete build left it. So each hit of a proven source is served only when (a) one system-context read per source per search round, `where` AND `id` in the hits' record ids, answers its record, (b) its `documentId` is the one the source derives from that record, and (c) its stored `docHash` equals the one `recordToDocument` computes from the row under the current object definition. The hash covers the title. Every way the check cannot be made drops the hit: the read throws or answers no list, the hit has no `sourceRecordId` or no stored hash, the hash cannot be computed, or the tenancy posture cannot be read. The read decides survival only. A surviving hit is returned as the store answered it, and nothing the read returned is put on it. A stale or missing record's own document is repaired in the background through the existing `repairStale`, once per document until a later search finds it current; a document under a foreign id is dropped and not repaired. Under record granularity `checkFreshness` then reads the same records again, so "one read" is the new check's own cost. - **Without the proof the source is refused, never served through the old arm**: named in `refused` as `KNOWLEDGE_REBUILD_REQUIRED` / 409. That code is already in `@objectstack/service-knowledge`'s error-code ledger, which this PR does not change. A search where it was the only source refuses whole. The caller and the operator are told what ends the refusal: a complete rebuild, nothing (a configuration no build can prove), or the next search (an unreadable status). A refused search starts no build and writes nothing. - **A source that needs the index proof is never searched without it.** The adapter a source binds to is resolved once per search, in `planSearches`: the proof is read from that instance, both search rounds search that same instance, and a source whose adapter does not resolve at the plan carries the coded refusal its resolution answered and is refused, never searched. `searchRound` no longer looks an adapter up. - **Every other source pays nothing**: no proof read and no per-hit read when the object declares no `title`, its display field is `title`, `title` is credential-class or `internal`, or the source serves `title` itself. - **Save door (ADR-0161 K4 guard two)**: the same `servedFieldsOf` judges a save, so an author no longer needs to query a `title` field the source never indexes. This is the widening half of the declaration; the display field is still asked. - Docs: `content/docs/protocol/knowledge.mdx` (the title rule, the proof, the permanent cases, the per-hit check) and `content/docs/ai/knowledge-rag.mdx` (the second cause of `KNOWLEDGE_REBUILD_REQUIRED`). ## Measurements: the per-hit read Method, enough to rebuild it (the script is not committed: it imports the in-memory driver from its source by relative path, which is not a dependency of this package): - Engine and driver: `new ObjectQL()` from `@objectstack/objectql`, `registerDriver(new InMemoryDriver(), true)` with `InMemoryDriver` imported from `packages/drivers/driver-memory/src/index`, then `init()`. One object `account` (text `name`, text `title`, textarea `body`) registered with `registry.registerObject`. - Rows: 2,000, inserted in the system context: `name` "Acme i", `title` "T i", `body` "body text i " repeated 40 times. - Source and service: object source `s` over `account`, `content: ['body']`; `new KnowledgeService({ dataEngine: engine })` with a stub adapter registered as `memory`. - Hits: for each size n in 5, 25 and 100, the first n rows read in the system context; each hit's `documentId` is `s:ID`, its `sourceRecordId` the row id, and its `docHash` `recordToDocument(source, source.source, row, engine.getSchema('account')).docHash`. So every hit is current. - Timing: call `dropUnverifiedHits(hits, new Set(['s']))` 20 times to warm up, then 200 timed rounds per size with `performance.now()`; p50 and p95 from the sorted times. `engine.find` is wrapped to count system-context calls (round trips) and the rows they return (rows read). - Re-run: put the file in `packages/services/service-knowledge/src/__tests__/`, run `pnpm --filter @objectstack/service-knowledge exec vitest run --maxWorkers=1 FILE`, delete it. - Box: the shared container, beside sibling verify runs; load averages (1, 5, 15 min) 8.07, 7.98, 7.60 at the run. Read the times as an upper bound on CPU cost. A remote driver adds one database round trip per proven source per round. | hits checked | when | round trips per round | rows read per round | p50 | p95 | |---|---|---|---|---|---| | 5 | small: one `topK` 5 page of hits | 1 | 5 | 1.5 ms | 2.5 ms | | 25 | first round at `topK` 5 (`SEARCH_FIRST_ROUND_FACTOR` 5) | 1 | 25 | 3.3 ms | 7.6 ms | | 100 | refill at `topK` 5 (`SEARCH_REFILL_FACTOR` 20) | 1 | 100 | 9.2 ms | 14.5 ms | An earlier run of the same method at load about 7 read 1.6/5.1, 3.3/6.2 and 9.5/12.3 ms (p50/p95). Rows read are bounded by the distinct record ids among the round's hits of proven sources, projected to the fields assembly reads. Every hit was served in every timed round, so the recomputed hash agrees with the stored one end to end on the real engine. ## Tests `packages/services/service-knowledge/src/__tests__/knowledge-source-admission.test.ts`: - proven index: a caller who may not query `title` is served, and the stored hit is returned unchanged; - unproven, seven ways (no `indexStatus`, no `completeBuild`, no `listDocuments`, no recipe hash, another recipe hash, another fingerprint, a throwing `indexStatus`) plus `refresh.onRecordChange: false`: refused `KNOWLEDGE_REBUILD_REQUIRED` / 409, never searched. The caller message and the warn line promise a rebuild only where one ends the refusal, and the system context is still served; - per-hit check (new `describe`): CONTROL served with exactly one system read; the read's fields never reach the caller; dropped for a stored hash that is not the current one, a hit whose stored docHash differs from the record's current build inputs, a document a complete build kept, a foreign `documentId`, no hash, an empty hash, and a record the read no longer answers; fails closed for a read that throws, one that answers no list, an unreadable tenancy posture, a hash that cannot be computed, and a hit with no `sourceRecordId`; a source with a `where`: the system read asks for `{ $and: [where, { id: { $in } }] }` and a record outside `where` is dropped; the refill round: a proven source saturates the first round with stale hits, the refill runs, and its stale hits are dropped while its current hit is served; a source searched without the proof is not checked; two race pins for the rule that a source that needs the index proof is never searched without it: another adapter instance registered under the same id while the proof is read is not searched, and an adapter that registers only after its source was planned is not searched that search (the source is refused `SERVICE_UNAVAILABLE` / 503); - an unproven source beside a searchable one; sources where the arm never mattered read nothing; rebuilt: refused (no `beginBuild`, `upsert` or `completeBuild` call), then `rebuildSource` completes and the source is served; - reverse pins: on a proven index the display field, a `content` field and a `metadataFields` field the caller may not query each still refuse the source; on an unproven index a stored earlier-rule title never reaches the caller; - `mayServeEarlierRuleTitle` table; save door. <details><summary>Readings at 3a69848</summary> - `pnpm exec vitest run --maxWorkers=2` in `packages/services/service-knowledge`: Test Files 18 passed (18), Tests 611 passed (611), after the merge of main and a rebuild of the dependency closure under the verify lock. - `pnpm typecheck` in the package (tsc plus `check:test-typecheck`): exit 0, "0 file(s) / 0 error(s)". - The admission file alone: 83 passed (83). </details> <details><summary>Ablations (one on-disk mutation each, file restored after)</summary> Per-hit check, each run against the admission file: - hash not compared: red, the four stored-hash-differs cases (the refill pin among them); - `documentId` not checked: red, the foreign document; - usable-hash filter and equality both admit a missing hash: red, no hash and empty hash. The usable filter ablated alone stays green, because the equality also refuses a missing hash, so this is a double ablation by design; - a record the read no longer answers passes: red, that case; - a read error serves the hits: red; a non-list answer serves them: red; - an unreadable posture proceeds: red; - a hash that cannot be computed trusts the store: red; - no `sourceRecordId`: the permission filter ablated alone leaves the new pin green (the check holds it) and turns the existing filter pin red; filter plus the check's record-id test ablated turns the new pin red; - the read's row put on the hit: red, CONTROL and the no-leak pin; - every source checked: red, the unproven-source case and the hits elsewhere that carry no hash; - S4 (a), the `where` conjunct dropped (the system read's `where` replaced by the id list alone): red, the `where` case; - S4 (b), the refill round not checked (`served(...)` removed from the `refilledKept` call site only): red, the refill case; - the first-round call site not checked (`served(...)` removed from the `kept` call site only): red, 13 cases; - the check not wired (the body of `served` replaced by returning the hits, which removes the check at both call sites, first round and refill): red, 13 cases. - resolve once undone (`searchRound` looks the adapter up again by the source's binding, as before): red, both race pins. Proof and refusal (earlier rounds, unchanged code): arm restored, proof skipped, recipe hash not compared, fingerprint not compared, predicate always true, withheld `title` ignored, served-field check removed, `onRecordChange: false` proven, no `listDocuments` proven, no `completeBuild` proven, a `never` refusal promising a rebuild, a refused search starting a build: each red. </details> <details><summary>Gates at 3a69848</summary> - `dispatch-gates --commands`: 101 families, run locally and reconciled with `--ran`: 100 exit 0, 1 NOT MEASURED. `check:type-check-debt` exits 3: its coverage half reads OK (132/135 workspace packages type-checked, 0 in the debt ledger), but its re-measure closure build queue-timed-out twice on the shared verify lock (540 s each). CI's `Type Check · debt ledger` lane reads it. `✓ dispatch-gates --ran: 101 derived famil(ies) accounted for — 100 run, 1 NOT-MEASURED`. - `check-nul-bytes`: OK. `overlap-check`: `VERDICT clean exit 0` against origin/main, objectstack-ai#38043, objectstack-ai#38038, objectstack-ai#38013 and objectstack-ai#37982. - Dogfood battery (owed by the `!` title), at 3a69848, under the verify lock: `pnpm exec turbo run build --filter='@objectstack/dogfood^...' --concurrency=2 && pnpm --filter @objectstack/dogfood test`, `VERDICT command-exit 0`, waited 293 s, held 2743 s; Test Files 490 passed, 3 skipped (493); Tests 4144 passed, 68 skipped (4212). </details> ## Acceptance notes - Card acceptance 1, per-source proof at search time: `unprovenIndex` reads `indexStatus` against `planIndex`'s fingerprint and recipe hash on every search that needs it, never cached. It adds no contract member and no stored state. - Card acceptance 2: the arm is removed for proven sources. Unproven ones are refused and are rebuilt by the existing boot pass, reload, reconcile or `os knowledge rebuild`, never served through the old arm. On a proven source a hit the current recipe would not assemble from the live record is not served either (seat ruling S1 = B). - Card acceptance 3: no other arm changed; reverse pins above. - Seat conditions for B: (1) each fail-closed case pinned and ablated, as above. (2) The no-leak pin plus its ablation. (3) The `indexStatus` proof is kept beside the per-hit check rather than dropped. (4) Measurements above. (5) `KNOWLEDGE_REBUILD_REQUIRED` is kept with messages that say what ends each refusal, and the ledger is unchanged. (6) Withdrawn by the seat (it concerned a follow-up card). The ruling is recorded on this PR (7224861986); the PR keeps `Clause-②: yes (narrowing)` and `Security-touching: yes`, and lands the Tier H way through the seat. - The claim's `:178` is not the arm: `documentTitleField` answering `title` for an object with no definition is the current assembly rule, so the gate keeps asking about it. - Narrowing, declared for the seat: for a non-system caller, a qualifying source is refused until a complete build under the current recipe has completed (for good under `refresh.onRecordChange: false` or an adapter missing `indexStatus`, `completeBuild` or `listDocuments`). On a proven source, a hit whose record changed after its document was written is dropped until the document is rewritten, and an adapter whose hits carry no `docHash` serves no hit from it (the built-in adapters carry it). Under `buildAtBoot: false` only the reconcile, where it runs, or `os knowledge rebuild SOURCE` ends the first. - Merged with main after objectstack-ai#37306 landed (f10feed). The one `planSearches` conflict keeps both intents: the adapter is the one the source binds to (main's optional-adapter placement) and the index-proof requirement stays on the admitted entry. Review point S5 is on top of it (3a69848): a source that needs the index proof is never searched without it. For every source, an adapter that registers mid-search is used from the next search on. - Deviation: with the shared verify lock held by sibling batteries through repeated 540 s queue-timeouts (five runs queued ahead at the last try), the package suite, typecheck, single-file runs, ablations and the measurement ran unlocked at `--maxWorkers=2`. The dogfood battery ran under the lock. ## Verification Read first: `knowledge-service.ts` `dropUnverifiedHits` (the per-hit check and its fail-closed exits), then `planSearches`, `searchRound` and `unprovenIndex` (the adapter resolved once, the refusal and the comparison), then `knowledge-source-admission.ts` `mayServeEarlierRuleTitle` (which sources pay either read). Two minutes: `pnpm --filter @objectstack/service-knowledge exec vitest run --maxWorkers=2 src/__tests__/knowledge-source-admission.test.ts` shows 83 passed, including the `per-hit check` block. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP --------- Co-authored-by: Claude <noreply@anthropic.com>
…A-g3hv-75wg-m249 exemption (objectstack-ai#38057) Fixes objectstack-ai#36160 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户无感:只改依赖覆盖规则、锁文件和安全扫描豁免清单,任何包的发布内容都不变。 - 为什么做:去掉依赖安全扫描里那条 12 月 21 日到期的匹配库漏洞豁免,让豁免清单回到零条。 - 出错会怎样:最可能是安全扫描或某个类型打包步骤在持续集成里变红,合并前就能看到;合并后出问题直接撤回这个改动即可。 - 要你做什么:无。 ## What changes The follow-up to objectstack-ai#38049 (merged as 39d611d), which moved the five parents that accept minimatch 11 and kept exceljs's glob chain on its own minimatch majors. The seat chose option A for the last holder. Every reading below was taken on this PR's head, 84e6e1c, rebased onto 39d611d. 1. **`pnpm-workspace.yaml`: a parent-scoped override, `@microsoft/api-extractor>minimatch` to `^11.0.9`.** `@microsoft/api-extractor` declares `minimatch` `10.2.3` exact (7.58.2 here; the newest release, 7.60.2, still pins it). It was the last minimatch 10.x copy in the lockfile. The comment beside the line gives the reason, and says to delete the line once an api-extractor release drops its exact 10.x pin. - It is in the graph only as an auto-installed optional peer of `tsup`, `unplugin-dts` and `vite-plugin-dts`. Those load it lazily, and only for `bundleTypes`, `rollupTypes` or `experimentalDts`, which no build here enables (evidence 1 below). - Its one call into minimatch is the named `minimatch()` export, in `Collector.js`, which minimatch 11 keeps. The smoke below runs that exact call. - The `pnpm-workspace.yaml` selector-shape rule governs `pkg@range` floors. This key names a parent and has no version range, so there is no bound to place. The exact-target rule covers packages whose export surface we compile against, and minimatch is not one of them, so the target is `^`. - The comment over the per-major minimatch floors now says the 6.0.0 to 11.0.0 floor holds no copy today. 2. **`osv-scanner.toml`: the GHSA-g3hv-75wg-m249 exemption is deleted.** It was the only entry, so the ledger is at its intended steady state of zero exemptions. Per convention 3, removing an exemption may ride with the fix. The header and template are untouched. 3. **`pnpm-lock.yaml`**, regenerated with pnpm 10.31.0. The only change is that api-extractor's `minimatch` moves from 10.2.6 to 11.0.9, `minimatch@10.2.6` drops out of the lockfile, and the `overrides` header gains the new line. No published package changes, so this PR carries no changeset. Every manifest that moved for objectstack-ai#36160 moved in objectstack-ai#38049. When `@microsoft/api-extractor` ships a release without the exact 10.x pin, delete the override line. That needs no card. ## Tests <details><summary>Evidence 1: no build here enables an api-extractor path</summary> - `git grep -n -E 'rollupTypes|bundleTypes|experimentalDts|api-extractor|apiExtractor|ExtractorConfig|api-extractor\.json'` outside the lockfile and changelogs: 6 hits. Five are the new comment and override in `pnpm-workspace.yaml`. One is a doc comment in `packages/spec/scripts/lib/file-description.ts` that says no typedoc or api-extractor reads the field it describes. - `git grep` for `experimental-dts`, `experimentalDts` or `rollup-types` in any `package.json`, `.ts`, `.mts`, `.js`, `.mjs` or `.cjs`: 0 hits. No tracked `api-extractor.json` exists. - The 41 files that reference `vite-plugin-dts` or `unplugin-dts` pass `dts()` options from this set only: `aliasesExclude`, `compilerOptions`, `exclude`, `include`, `insertTypesEntry`, `outDir`, `tsconfigPath`. The one helper that spreads into `dts()` (`ui/scripts/vite-dts-explicit-extensions.ts`) adds only `beforeWriteFile` and `afterBuild`. - `unplugin-dts` imports api-extractor with a dynamic `import()` inside its rollup step only; `tsup` loads it only for `experimentalDts`. </details> <details><summary>Evidence 2: OSV-Scanner v2.5.0 (the workflow's scanner), offline npm database freshly downloaded</summary> - This head, `--offline-vulnerabilities --download-offline-databases --config` pointing at this head's `osv-scanner.toml` (zero `[[IgnoredVulns]]` entries; the only match for that string is the commented template, and `g3hv` occurs 0 times): `No issues found`, 1698 packages scanned. - This head with no ledger at all: `No issues found`. - `node scripts/check-osv-exemptions.mjs`: exit 0, "osv-scanner.toml holds zero OSV exemptions (the intended steady state)". `--self-test`: exit 0. </details> <details><summary>Evidence 3: no minimatch 10.x copy in pnpm-lock.yaml</summary> - `grep -c -E 'minimatch@10\.|minimatch: 10\.' pnpm-lock.yaml` gives 0. - Holders by resolved version: 3.1.5 for `glob` 7.2.3; 5.1.9 for `readdir-glob` 1.1.3; 11.0.3 for `@oclif/core` 5.1.12, `@typescript-eslint/typescript-estree` 8.74.0 and `glob` 14.0.3; 11.0.9 for `eslint` 10.15.0, `@eslint/config-array` 0.23.6, `@ts-morph/common` 0.29.1 and `@microsoft/api-extractor` 7.58.2. </details> <details><summary>api-extractor on minimatch 11, and the dts builds</summary> - A direct api-extractor 7.58.2 run on a fixture package resolved `minimatch@11.0.9`. The fixture's `bundledPackages: ["foo-*"]` against three declared dependencies drives the `Collector.js` glob branch, the one `minimatch()` call. With a d.ts rollup enabled: `succeeded: true`, 0 errors, 2 warnings (`ae-missing-release-tag` on the fixture's untagged exports), and the rolled file carries the fixture's API. - On 84e6e1c, `turbo run build` over the `@objectstack/cli...` and `@objectstack/rest...` closures, `@objectstack/metadata-core`, `@object-ui/plugin-markdown...` and the i18n extract packages, under the verify lock: `VERDICT command-exit 0`, Tasks 78 successful of 78, 3 cached. Its tsup builds emitted their declarations, with `check-dts-emitted` passing for metadata-core. The vite builds ran unplugin-dts: plugin-markdown printed "Declaration files built", as did the `@object-ui` packages in its closure. - `pnpm check:override-consistency`: exit 0. Its consumer census reports the new key as having 0 consumers, which is a report, not a failure; see Acceptance notes. </details> <details><summary>Derived gate families (dispatch-gates.mjs --commands), on head 84e6e1c</summary> The change set is 3 paths against merge base 39d611d (`osv-scanner.toml`, `pnpm-lock.yaml`, `pnpm-workspace.yaml`), giving 25 derived families. All 25 were run on head 84e6e1c, with exit codes captured before any pipe, and all 25 exited 0. Among them: `check-osv-exemptions.mjs` and its `--self-test`, `check:override-consistency`, `check:vendor-export-contract-resolve`, `check:dual-build-cjs-loads`, `check:changeset-fixed`, `check:nul-bytes` and `osv-base-relative.mjs --self-test`. The `--ran` reconciliation reports 25 accounted for, 25 run, 0 NOT-MEASURED and 0 UNRUN. Before the push, `overlap-check.mjs` returned VERDICT clean exit 0 against origin/main 39d611d and objectstack-ai#38043. </details> ## Acceptance notes - `check:override-consistency` reads an override key as `name@selector`, split at its last `@`. It does not parse a `parent>child` key, so its report-only consumer census lists `@microsoft/api-extractor>minimatch` as having 0 consumers, although api-extractor consumes it. That is a report, never a failure, and the line must not be read as "safe to tidy". - Once an api-extractor release accepts minimatch 11, the override line comes out in an ordinary dependency PR, with no card. ## Verification Read first: 1. `pnpm-workspace.yaml`: the new `@microsoft/api-extractor>minimatch` line and its comment. 2. `osv-scanner.toml`: the deleted entry, and that the header and template are unchanged. 3. `pnpm-lock.yaml`: the `@microsoft/api-extractor@7.58.2` snapshot's `minimatch: 11.0.9`. Two-minute check: `grep -c -E 'minimatch@10\.|minimatch: 10\.' pnpm-lock.yaml` prints `0`, and `node scripts/check-osv-exemptions.mjs` prints that the ledger holds zero exemptions. --- _Generated by [Claude Code](https://claude.ai/code/session_01L9qibzpqH1nQTsbGckLspg)_ Co-authored-by: Claude <noreply@anthropic.com>
…t that mounts the knowledge service (objectstack-ai#38013) repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP Fixes objectstack-ai#37983 Clause-②: no (narrowing) Metadata-protocol: narrowed Skills-docs: skills/objectstack-ai/SKILL.md § Knowledge Sources (RAG) — the run-time clause now says that where an app ships no source, a run-time save is refused (`503 SERVICE_UNAVAILABLE`, nothing written) until the stack declares `requires: ['knowledge']` and the server restarts (it said such items are never indexed); the matching eval case in `skills/objectstack-ai/evals/skills-tools-knowledge.json` expects the same; the token-ratchet row moves 6893 → 6906 under ruling record 6513306068, letter B ## 维护者速读 - 作者在没装知识服务的部署上,通过工作台、元数据接口或智能体工具保存知识源时,会当场失败并看到原因和修法(先在应用配置里声明需要知识服务并重启,再保存);以前这种保存显示成功却永远不生效。 - 属于知识库检索这条线,执行您选的方案 D:让作者在保存那一刻就知道,而不是只在看不到的服务器日志里。 - 只影响在这类部署上保存知识源的作者;在这类部署上复制一个含知识源的整个应用包也会被拒、什么都不复制(这是裁决点名的三处之外的第四处,请批准前读下方的待定问题一节);装包、种子数据、迁移照常通过;出问题可整单撤回。 - 要你做的:批准这次收窄(按审批流程)。 ## What changes Ruling D (maintainer, recorded on objectstack-ai#37983, comment 7220511579) is implemented in the one predicate every save door asks, `authoredKnowledgeSourceRefusal` (`packages/metadata-core/src/knowledge-source-save-admission.ts`): - **No knowledge service registered + a non-system writer ⇒ refused.** `resolveKnowledgeService()` answering `undefined` (or `null`) used to admit the save; it now answers `503 SERVICE_UNAVAILABLE` with a message that names the item, the reason and the remedy in order: add `requires: ['knowledge']` to the stack (or, on a host that composes its own kernel, `KnowledgeServicePlugin` and a knowledge store), restart, then save the source again. Nothing is written. - **Held as ruled:** the engine's own write (`isSystem`: package install, seed, migration) is never refused (the `isSystem` check still runs before the service is resolved); a REGISTERED knowledge service with no `admitAuthoredSource` (not the platform's, for example host-mounted) keeps today's accept. The module doc (`:33-34` on main) now says both, and gains a section on the no-service case. - **Doors.** No door code changed shape: `PUT /meta/:type/:name` in `packages/rest` passes `refused.code` through for a non-403 (`SERVICE_UNAVAILABLE`), the runtime dispatcher `PUT` derives `SERVICE_UNAVAILABLE` from `503`, and the MCP `save_metadata_draft` passes `refused.code` through for a non-403 (on `main` since objectstack-ai#37306). Only their comments are updated. Each door is pinned. - **Why `503 SERVICE_UNAVAILABLE`** (ADR-0112 status table, `STATUS_TO_STANDARD_CODE` in `packages/spec/src/api/errors.zod.ts`): the save needs a service this deployment does not run. It is the code this module already answers for a knowledge service that cannot be reached, and the code the knowledge service answers at index and search for a source whose store is not mounted (the same kind of composition fact). It is also the one code all three doors already carry without a door change. Rejected: `400 VALIDATION_ERROR` (the item is valid; a validation code sends the author to fix the item), `403` (not a permission), `501 NOT_IMPLEMENTED` (the meta door's answer for a protocol with no `saveMetaItem`), `409 RESOURCE_CONFLICT` and `428 PRECONDITION_REQUIRED` (no conflicting resource, no missing request precondition), and a new ledger code (a contract change the ruling did not make). The message carries the remedy and does not say "try again". - **ADR-0087:** `Metadata-protocol: narrowed` owes a registered entry: `packages/spec/src/migrations/entries/semantic/19.knowledge-source-save-refused-without-knowledge-service.ts` (notice only, no D2 conversion: the fix is the deployment's composition, never the item). The changeset carries `registered` with that id. ## Boot line and docs (ruling items 2 and 4), landed after objectstack-ai#37306 Held off this branch until objectstack-ai#37306 merged (PR objectstack-ai#38026, dbe0716); `main` is now merged in (1ca3a31) and the held commit is re-applied as 33acf12. - **Boot line** (`packages/objectql/src/knowledge-source-unserved.ts`): the line for `knowledge_source` items held with no knowledge service now names the same remedy as the save refusal, from the item-4 patch's `UNSERVED_REMEDY`: declare `requires: ['knowledge']` and restart (or, on a host that composes its own kernel, `KnowledgeServicePlugin` and a knowledge store). Before, it said "add `KnowledgeServicePlugin` and a knowledge adapter to the composition". Only the boot-line half of that patch was taken: objectstack-ai#37306 did not touch this file, so `main` still carried the old text. - **What objectstack-ai#37306 changed, and what that changes here.** A source the app ships in `knowledgeSources` now mounts the service by itself, and `adapter` is optional. So a source saved at run time (Studio, the metadata API, MCP) is never one that mounts the service, and the remedy the maintainer ruled (`requires: ['knowledge']`, restart, then save) is still the one that fixes such a save. The refusal sentence is unchanged. The docs now also say that a source saved at run time does not mount the service. The boot-line module doc says that the items it names are ones the stack does not ship. Main's `knowledge-rag.mdx` already said "the token is for an app that ships none and authors its sources at run time", which matches. - **Docs.** `content/docs/ai/knowledge-rag.mdx`: a bullet beside "Without a source or the token", plus a clause on the run-time-authoring bullet. `content/docs/protocol/knowledge.mdx`: the boot-line paragraph names the remedy (it named the plugin and an adapter), and a paragraph under "Who may author one" covers the refusal, the duplicate and the holds. Rewritten against main's merged text, not patched blindly: `git am --3way` conflicted on `knowledge-rag.mdx`. - **Changeset:** gains the `@objectstack/objectql` and `@objectstack/skills` patch lines and their bullets. - The MCP draft door on `main` now passes `refused.code` through for a non-403 (objectstack-ai#37306), so this refusal still arrives there as `SERVICE_UNAVAILABLE`. ## Open question The package **duplicate** door (`POST /packages/:id/duplicate`) asks the same predicate for each knowledge source it copies, so on a deployment with no knowledge service it now refuses a duplicate of a package that holds one, `503`, naming the remedy (pinned in `packages-knowledge-source-gate.test.ts`). The ruling names three doors; this is the fourth door that saves a source as the caller. Keeping it refused is the predicate's own reading and the ruling's principle (the copy would be kept and never served); carving it out needs a new input on an exported function. Recommendation: keep it. ## Tests - `packages/metadata-core/src/knowledge-source-save-admission.test.ts`: refusal with code, status, the reason sentence and the ordered remedy, for both URL spellings and for `undefined`/`null`; an unnamed item; `isSystem` not refused and the service never resolved; a registered service without the member still admits. - REST `PUT` (`packages/rest/src/meta-write-door-capability-enumeration.test.ts`): refused on the kernel's branded "never registered" miss and on a server with no kernel provider; system write saved; host-mounted service saved. - Runtime dispatcher `PUT` (`packages/runtime/src/domains/meta-save-capability-gate.test.ts`): refused on a real `ObjectKernel` with nothing registered; system write saved; host-mounted service saved. - MCP `save_metadata_draft` (`packages/runtime/src/domains/mcp-authoring.test.ts`): refused, nothing written, another type still saves; host-mounted service saved. - Package duplicate (`packages/runtime/src/domains/packages-knowledge-source-gate.test.ts`): refused, nothing copied; a package with no source and the engine's own call copy as before. - Boot line (`packages/objectql/src/knowledge-source-unserved.test.ts`): names `Declare requires: ['knowledge'] in the stack and restart`. Head is now `5bc3ee1a00`. Since `33acf12ec4` it adds only: the test-harness fix `6e4a904ea1` (the MCP `knowledge_source` contract case from objectstack-ai#38053 mounts an admitting knowledge service; comment 7232197442), the skills text, eval expectation, ratchet row and changeset line above, the module-doc wording at index and search, and two clean merges of `main` (the second carries objectstack-ai#38091). No runtime or rest code moved after `33acf12ec4`, so the dogfood battery below stands. On `5bc3ee1a00`: the skills token ratchet exits 0 (6906, headroom 0; self-test 111 cases pass), `check:skill-docs` and `check:skill-refs` exit 0, and the changeset, ADR-0087, NUL-byte and issue-citation gates exit 0. After the harness fix, runtime reads 12315 passed, 0 failed. Readings at head `33acf12ec4` (main merged in; shared container; every build and test through `scripts/pm/os-verify-lock.sh`, verdict `command-exit 0` each round): <details><summary>Tests and typecheck at 33acf12</summary> - Full build (`turbo run build`, all but docs) exit 0, `packages/runtime/.objectstack` cleared, `@objectstack/spec check:generated` exit 0. - `@objectstack/metadata-core` `pnpm test`: Tests 1113 passed; `typecheck` exit 0. - `@objectstack/objectql` `knowledge-source-unserved.test.ts`: Tests 7 passed; `typecheck` exit 0. - `@objectstack/rest`, 4 files (door enumeration, type-write capability, both org-scope suites): Tests 161 passed; `typecheck` exit 0. - `@objectstack/runtime`, 10 files (dispatcher save gate, MCP authoring, package knowledge gate, error passthrough, capability parity, org scope, ensure-customization, publish-drafts x2, package state store): Tests 304 passed; `typecheck` exit 0. - On the first head, 5 suites that save a `knowledge_source` as a capable author with no knowledge service went red: that is the ruled refusal. Their harnesses now mount a knowledge service that admits every source. Two door-level `isSystem` cases were dropped because inbound HTTP never carries `isSystem` (`metaTypeWriteRefusal` answers 401 first); that hold is tested at the predicate instead. - Narrowed locally: the full rest and runtime suites, `test:repo`, and the derived families not listed under Gates run in CI. </details> <details><summary>Ablations (one per tested behaviour)</summary> - **The save refusal** (at dd50936): `scripts/ablation-replace.mjs` replaced the one new line (anchor 1 -> 0, marker 0 -> 1). `@objectstack/metadata-core` was rebuilt, and `ablation-dist-preflight` found the marker in `dist/index.js` and `dist/index.cjs`. Exactly these went red: the predicate test (1 of 9), REST `PUT` (1 of 81), and dispatcher `PUT`, MCP draft save and package duplicate (3 of 162). Restored with `git checkout HEAD` (blob back to cd26e8f, `git diff HEAD` empty), rebuilt, and preflight `--absent` was clean. - **The boot line** (at 33acf12): the remedy was put back to main's text (anchor 1 -> 0, marker 0 -> 1; the test imports source, so no build was needed). Red: `names the item, the missing service and both remedies` (1 of 7). Restored with `git checkout HEAD` (blob aa50e2e, `git diff HEAD` empty). - The docs pages are not ablated. </details> <details><summary>Live server (REST door, at dd50936)</summary> After a full build I ran `pnpm dev:crm -- --fresh -p 38937`; the CRM stack declares `requires: ['ui', 'automation']` and no knowledge. Signed in as the seeded admin, `PUT /api/v1/meta/knowledge_source/faq` answered `503`, `error.code` `SERVICE_UNAVAILABLE`, with the remedy sentence. A `GET` of the item then answered `404`, so nothing was written. The server was stopped by its recorded pid. A positive control on a stack with `requires: ['knowledge']` was not run (NOT MEASURED); the unit tests cover the admitted path. </details> <details><summary>Gates at 33acf12</summary> Local, exit 0 each: `check-adr-0087-registration` (1 declared-breaking changeset, with its disposition), `check-changeset-no-major`, `check-empty-changeset`, spec `check:upgrade-guide`, `check:spec-changes`, `check:api-surface` (unchanged), `check:nul-bytes`, `check:doc-authoring`, `check-affected-docs`, `check:issue-citations`, `check:dispatcher-error-vocabulary`, `check:startup-registry-verdict`, `check:durability-log-level`. At dd50936 these were also exit 0: `check:authorable-surface`, `check:route-envelope`, `check:error-status-conformance`, `check-closing-keyword-parity`, `check:cross-package-test-inputs`, `check:test-source-alias`, `check:adr-anchors`. `overlap-check` before the push: clean against `main` and against objectstack-ai#38043, objectstack-ai#37982 and objectstack-ai#37963. </details> <details><summary>Dogfood battery at 33acf12</summary> The full battery, run as CI runs it (no `OS_TEST_SHARD`, no path), under `scripts/pm/os-verify-lock.sh`. The build was `turbo run build --filter='@objectstack/dogfood^...'` and exited 0. The test was `pnpm --filter @objectstack/dogfood test`. - Verdict: `VERDICT command-exit 0 · held the lock 1727s (28m47s)`, in shared-box seconds. - `Test Files 490 passed | 3 skipped (493)` - `Tests 4144 passed | 68 skipped (4212)` - Failures: none. Recorded in comment 7229739676. CI's `Dogfood Regression Gate` on the PR reads `OS_DOGFOOD_RESULT: skipped` (the shards run in the merge queue), so it is not evidence for this head. </details> ## Acceptance notes - The note on this PR's first head about objectstack-ai#37306's `400 VALIDATION_ERROR` arriving at the MCP draft door as `SERVICE_UNAVAILABLE` is obsolete: objectstack-ai#37306 merged with the MCP door passing `refused.code` through. - Docs Drift Check (comment 7222797378) is receipted here. `content/docs/ai/knowledge-rag.mdx` and `content/docs/protocol/knowledge.mdx` are updated on this branch. `content/docs/permissions/system-context.mdx` row 46 is re-read and still true: the refusal is not on the `isSystem` path. The other pages match on the `SERVICE_UNAVAILABLE` literal only and say nothing about knowledge sources. The release-owned pages are not edited. - Contract review 7228262724 (PASS) and L1 7228292666 (REWORK: dogfood battery only) are receipted here. The battery is recorded in comment 7229739676: green, and the head is unchanged. The review's nits N1 to N5 are left for a follow-up card; none of them is changed on this head. ## Verification Read first (by risk): `packages/metadata-core/src/knowledge-source-save-admission.ts` (the `service === undefined || null` branch, before the member check), `packages/runtime/src/domains/packages-knowledge-source-gate.test.ts` (the fourth door), `content/docs/protocol/knowledge.mdx` (the two paragraphs rewritten against objectstack-ai#37306's text). Two-minute check: `pnpm --filter @objectstack/metadata-core exec vitest run src/knowledge-source-save-admission.test.ts` — expect the "no knowledge service registered" cases green; flip line `if (service === undefined || service === null) return noKnowledgeServiceRefusal(input.item);` out and they go red. Body refreshed 2026-11-28T03:15Z at head `5bc3ee1a00`; the readings in the three blocks above were taken at `33acf12ec4`. --- _Generated by [Claude Code](https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
…nd the dropSource cleanup (objectstack-ai#38050) repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP Fixes objectstack-ai#38022 Clause-②: no Metadata-protocol: none ## 维护者速读 - 升级到 19 的运维读升级表时,会看到「以下划线开头的知识源 id 要改名并清理旧索引」这一例外,不再被告知「索引原样找回」。 - 为 AI 知识库(epic 37000)的 18 到 19 升级文档补上一处与升级条目不一致的说法。 - 只改文档与报错文案,不影响运行行为,可直接撤回。 - 无。 ## What changes - `content/docs/protocol/knowledge.mdx`: the `id` row of the 18 to 19 table names the underscore exception (`name` refuses it, the source is rebuilt under a new name) and the `dropSource` cleanup, in the words of the upgrade entry `knowledge-source-registration-governed`. It states the memory adapter holds nothing across a restart. The row does not touch `adapter`, which objectstack-ai#38026 made optional (rows and prose near it re-read on current main; no contradiction). - N1: the upgrade entry's reason says the adapter keeps the old index only where its store outlives the process (Turso, pgvector); the memory adapter holds nothing across a restart. - N2: the `id` tombstone in `knowledge-source.zod.ts` says the entry's manual notices still apply after `os migrate meta --from 18`; the reference page `content/docs/references/ai/knowledge-source.mdx` carries the same sentence. - `.changeset/37304-knowledge-source-governed-type.md` is not edited: it sits in `.changeset/pre/` (consumed by pre mode). A new patch changeset covers the spec string change. ## Tests NOT MEASURED: `knowledge-source.test.ts` and `retired-key-migrate-sentence.test.ts` (the tombstone still ends with the migrate sentence and still begins with its pinned prefix), because the verify lock was never acquired in 4 attempts over about 36 minutes (holder was a dogfood run; VERDICT queue-timeout exit 99). ## Acceptance notes - NOT MEASURED: `pnpm gen:docs` regeneration (needs the spec build, same lock). The reference page was edited by one exact-string substitution mirroring the zod edit; CI `check:generated` is the judge. <details><summary>Verification</summary> - check:doc-authoring, check:doc-anchors, check:doc-frontmatter, check:docs-nav-label, check:docs-image-tag: exit 0. check:docs-transcript-drift: exit 3, NOT MEASURED (prerequisite). - overlap-check at d60a6ce: VERDICT clean exit 0 (main, objectstack-ai#38043, objectstack-ai#38013, objectstack-ai#37963 merge cleanly). - Two-minute check: open the knowledge protocol page, 18 to 19 table, `id` row: it names the underscore exception. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP Co-authored-by: Claude <noreply@anthropic.com>
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP
Fixes #37735
Fixes #37110
Clause-②: yes (widening) —
KnowledgeServicePluginOptionsgains the optionalrecordSyncRetry;KnowledgeServicegainsrouteRecordSyncs,recordSyncQueued,enqueueRecordSyncandprocessRecordSync; the package exportsKNOWLEDGE_RECORD_SYNC_QUEUE,RECORD_SYNC_RETRY_DEFAULTSand theKnowledgeRecordSync*typesMetadata-protocol: none
维护者速读
What changes
A record change of an indexed object no longer syncs its document inside the write. Where the kernel composes a durable
queueservice (QueueServicePluginover a data engine) and a data engine is bound, both triggers publish to theknowledge-record-syncqueue:knowledge-event-syncsubscription;A worker, subscribed in
kernel:ready, re-reads the row and writes or removes the document. Everything else keeps the inline path and says so once at boot atwarn:listFailed;enableEventSync: falseandrefresh.onRecordChange: falseare unchanged: they publish nothing.{ source, object, recordId, reason }, where the reason iseventorfreshness. It never carries a field value. The test reads the storedsys_job_queuerow.runAfterOpenUnitsCommit. It goes out once the open unit commits (the write's own unit or a caller'sengine.transaction()) and is dropped on rollback. With no unit open it goes out at once. I did not use the other approach (the queue row joining the write's unit), and no engine change was needed.idempotencyKey.DbQueueAdaptersuppresses a keyed publish while a message is pending or running, and for 24 h after it completes. A key per document would therefore drop a save made while that record's sync runs, and every save of it for a day after. Each worker run re-reads the row, so the last committed version wins.IQueueServiceandDbQueueAdapterare unchanged.recordSyncRetry: by default 8 attempts, 5 s doubling to a 2 min cap. The message then becomes alistFaileddead letter that names the source and record, logged once aterror.repairStalenow publishes afreshnessmessage instead of starting an un-awaited inline sync.freshnessmessage inrepairStale). If fix(service-knowledge)!: retire the knowledge field gate's title arm behind a per-source recipe proof #37963 lands first, this branch merges main and adopts its seam.content/docs/protocol/knowledge.mdxgains "Through the queue" and "Without a durable queue".content/docs/ai/knowledge-rag.mdx, the README and a changeset are updated too.Tests
src/__tests__/record-sync-queue.test.tsis new. It boots a realObjectKernelwithObjectQLPlugin,SqlDriver(a better-sqlite3 file),QueueServicePlugin({ adapter: 'db' })andKnowledgeServicePlugin. Every queue-path case runs once per trigger (realtime, and the hooks).The queue-path cases cover:
engine.transaction();Further cases:
afterInserthook that aborts the write's own unit publishes nothing;warnand inline sync, plus both switches;destroy()leaves the message pending.Re-land head 5d430ea (after the merge-queue drop: #38026 made
source.adapteroptional, soprocessRecordSyncnow resolves through main'sadapterFor(source); cause and fix in comment 7229116666). One locked batch, lockVERDICT command-exit 0:turbo build --filter='@objectstack/service-knowledge^...': 19 of 19 tasks;pnpm --filter @objectstack/service-knowledge build: CJS, ESM and DTS build success (the build that failed in the queue);pnpm --filter @objectstack/service-knowledge typecheck:check:test-typecheck: OK;vitest run --maxWorkers=2: 19 of 19 files, 605 of 605 tests, including the new pin (a source with noadaptersyncs through the queue to the deployment's store, on both triggers);Earlier readings, on head 43dc682 unless noted (all under
os-verify-lock):pnpm --filter @objectstack/service-knowledge exec vitest run --maxWorkers=2: 19 of 19 files and 593 of 593 tests pass (on merge head 640b356; the one later commit changes only docs and the changeset);pnpm --filter @objectstack/service-knowledge typecheck:check:test-typecheck: OK.Ablations (mutated on disk, test file re-run, restored with git checkout; tests run from source, so no rebuild)
runAfterOpenUnitsCommitremoved, publish at once): 4 failed. They are the rolled-back insert (both triggers), the own-unit test and the own-unit abort. The caller-transaction case stayed green under this mutation, because on SQLite's single connection the poller cannot read inside an open transaction. The rollback cases are the pin for the deferral.idempotencyKey= source:object:recordId): 9 failed, including the burst, after-completed and delete cases.titleadded to the message on both triggers): 2 failed (the identifiers-only case for each trigger).warndropped: 2 failed.listFailedaccepted: 2 failed.Acceptance notes
MemoryQueueAdapter(adapter: 'memory') carries nodegradedlabel and has nolistFailed. It is refused through thelistFailedcondition, so it takes the inline path with the boot warn.chainAfterper document) orders two runs on one node. Two nodes processing two messages for one record are not ordered against each other. Each run re-reads the row, so the last run to finish writes what it read. A save committing between one node's read and another's write can leave an older version until the next save, a freshness hit or the reconcile.runAfterOpenUnitsCommitsees the open unit). A realtime adapter that delivers out of process would publish with no unit open, that is at once. That is still after the write returned, but not ordered against a caller's transaction. No such adapter ships today.granularity: 'record'searches do not; the docs now say so.queueon every preset exceptminimal. Underminimalthe sync takes the inline path with the warn.Verification
Two-minute check:
pnpm --filter @objectstack/service-knowledge exec vitest run --maxWorkers=2 src/__tests__/record-sync-queue.test.tsExpected result: 33 of 33 tests pass.
Read first (by risk):
knowledge-service.ts:publishRecordSyncs(the commit deferral) andprocessRecordSync(what is retried and what completes).knowledge-service-plugin.ts:startRecordSyncQueue(the queue resolution, the fallback warn and the dead-letter line).knowledge-record-sync-queue.ts:recordSyncPublishOptions(why there is no idempotency key).Local gate subset
dispatch-gates --commands --repo objectstack-ai/objectstackderived 119 families. The--ranreconciliation reads: 115 run, 3 NOT MEASURED, 1 unrun.check:skill-examples,check:dual-build-cjs-loads,check:published-readme-exports.check:published-readme-exports, I confirmed the one new README import (QueueServicePluginfrom@objectstack/service-queue) by hand againstservice-queue/dist/index.d.ts.@objectstack/spec check:docs:packages/spec/json-schemais older thansrc. This branch touches nothing in spec.check:dts-closure:packages/rest/disthas no.d.ts. This branch does not touch rest; the partial dist likely comes from a build I stopped earlier.check:type-check-debt, because it builds every package under the shared lock.CI measures the full set.
overlap-checkon 5d430ea:VERDICT clean exit 0against main and the open PRs, including #37963, #38013 and #37982. Earlier, on 43dc682:VERDICT clean exit 0against main and 6 open PRs (#38038, #38037, #38032, #38026, #37982, #37963).Generated by Claude Code