Skip to content

Commit 06bf084

Browse files
committed
docs(knowledge): correct the sync model's event names and note the bulk-write gap
The sync-model section named the legacy unprefixed `record.*` events; the engine has published `data.record.*` since #4626, and the plugin reads the record body from `after` and a delete's id from the required `recordId`. Also states what a predicate write does to an object source: it publishes the aggregate `data.records.*` (#4639), which names no record, so the index goes stale in a way the event stream cannot repair. Reconciliation is #4672. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LYnZrTwXbrctB8E8HpJAPT
1 parent 9a7b3cc commit 06bf084

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

content/docs/protocol/knowledge.mdx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,16 +296,31 @@ with a `permissions` mapping function at index time.
296296

297297
## 6. Sync model
298298

299-
For `object` sources, `KnowledgeService` subscribes to ObjectQL
300-
`record.created`, `record.updated`, and `record.deleted` events. Each
301-
event triggers a single `adapter.upsert` / `adapter.delete` call.
299+
For `object` sources, `KnowledgeService` subscribes to the ObjectQL engine's
300+
`data.record.created`, `data.record.updated` and `data.record.deleted` events
301+
(the legacy unprefixed `record.*` shape is still accepted). Each event triggers
302+
a single `adapter.upsert` / `adapter.delete` call — the record body is read
303+
from the event's `after`, and a delete's id from its required `recordId`.
302304

303305
- **MVP (Phase 1):** synchronous, inline with the originating mutation.
304306
Fast for low-volume dev / demo. Indexing failures are logged but do
305307
not block the originating write.
306308
- **Phase 2:** async via `service-queue` for batching, retries, and
307309
back-pressure.
308310

311+
<Callout type="warn">
312+
**A predicate write leaves the index stale.** A `multi: true` update/delete
313+
reaches `updateMany` / `deleteMany`, which report only an affected row count,
314+
so it publishes the aggregate `data.records.updated` / `data.records.deleted`
315+
([#4639](https://github.com/objectstack-ai/objectstack/issues/4639)) rather
316+
than per-record events. A knowledge index is a per-record projection and
317+
`matched: 40` names no record, so there is no upsert or delete to derive —
318+
the service logs a warning naming the object and count instead of failing
319+
silently. Reconciliation against the source object is the durable fix and is
320+
tracked in [#4672](https://github.com/objectstack-ai/objectstack/issues/4672):
321+
events keep the index *fresh*, reconciliation keeps it *correct*.
322+
</Callout>
323+
309324
`file` / `http` sources rely on explicit `reindexSource` calls
310325
(typically triggered by a cron job, a Console button, or a webhook).
311326

0 commit comments

Comments
 (0)