Repository navigation
Commit e952cff
fix(service-knowledge): drop the record.* branch from the realtime event bridge and name data.record.* in its docs (#21140)
Fixes #20573
Clause-②: no
The knowledge plugin's realtime bridge still carried a `record.created`
/ `record.updated` / `record.deleted` branch (with a `payload.record ??
payload` fallback), and its docs named `record.*` as the ObjectQL events
it syncs. No producer emits those names, in this repository or in cloud.
The branch is removed and the docs now name
`data.record.created|updated|deleted`.
## What changed
- `knowledge-service-plugin.ts`: removed the `record.*` branch and the
`payload.record ?? payload` fallback. The `[#4626]` comment no longer
contrasts with a shape that does not exist; it states the three names
ObjectQL publishes. The `enableEventSync` option TSDoc names
`data.record.created|updated|deleted` and says the `data.records.*`
aggregate events only warn.
- `knowledge-service.ts`: `handleRecordUpsert` / `handleRecordDelete`
docs name `data.record.*` (record body from `after`, id from
`recordId`).
- `event-sync-data-events.test.ts`: one new describe, four cases
(below).
- `.changeset/20573-knowledge-record-branch.md`: `patch` for
`@objectstack/service-knowledge` (published package, no `private` flag).
The `data.record.*` sync and the `data.records.*` stale-index warning
are byte-for-byte unchanged.
## Premise check (measured at origin/main 7a606a9, the branch point)
In-repo producers, three steps because the first instrument cannot
answer the question:
- `git grep -nE "publish\(" -- 'packages/**/*.ts' ':!**/*.test.ts'`
returns 38 lines, and none of them carries an event name (the type is
built in a variable or template). Filtering them for `record.` event
names gives 0, but the same-subject control (a `data.record.` name on a
`publish(` line) also gives 0, so that count is void. It is not used as
evidence.
- Widened instrument, realtime-publishing call sites: 3
(`metadata-manager.ts:723`, `engine.ts:7445`, `engine.ts:7542`).
Control, same file: `engine.ts` builds `type: data.record.ACTION`
(`:7428`) and `type: data.records.ACTION` (`:7527`), 16
`data.record(s).` lines in the file. `metadata-manager.ts` publishes
`metadata.TYPE.ACTION`.
- Bare `record.(created|updated|deleted)` as an event name in non-test
source (`git grep -nP` with a not-preceded-by-`data.` lookbehind over
`packages` and `examples`): 0 producers. The only hits naming it as an
event are the branch removed here, its two doc comments changed here,
and the spec's own retirement records (`realtime.zod.ts`, the
realtime-event-type migration entry), which state that no producer ever
emitted these names. Field-path uses such as `record.created_at` are not
events.
- Cross-repo: the `repo:cloud` seat read cloud `main` `72b8415a`
(comment 5925992601 on the card): 1 hit for the bare names, a doc
comment about the field `record.created_by`; control 35 hits. So cloud
has no producer either.
- Tests: no existing `service-knowledge` test fed a bare `record.*`
event to the handler, so none pinned the removed branch and none was
converted or deleted. Docs (`content/docs`) and `skills/` do not name
the bare events.
## Tests
`pnpm --filter @objectstack/service-knowledge test`: 4 files, 44 tests
pass. The package typecheck passes, and `tsc --listFiles` shows the
edited test file is compiled by both the package and the test tsconfig.
New pin, four cases in `event-sync-data-events.test.ts`. Each delivers
the bare shape on the subscription and asserts no `handleRecordUpsert` /
`handleRecordDelete` call, then delivers the same row or id as
`data.record.*` on the SAME subscription and asserts it IS synced (the
control, so a dead harness cannot pass for a removed branch):
- `record.created` with the row under `payload.record`;
- `record.updated` with the row as the payload itself (the old `??
payload` fallback);
- `record.deleted` with the id from `payload.id`;
- `record.deleted` with the id from `payload.record.id`.
Ablation, run from the committed fix (HEAD blob 495cad1): the original
branch put back verbatim with `scripts/ablation-replace.mjs` in wrap
mode.
- Mutation proof from the tool: anchor 1 to 0, blob `495cad164104` to
`6345444c7301`.
- Result, red: `Tests 4 failed | 5 passed (9)`, failing with `expected
"handleRecordUpsert" to not be called at all, but actually been called 1
times` (and the same for `handleRecordDelete`). The five pre-existing
tests stayed green.
- Restore proven by the tool: blob after restore equals the HEAD blob,
`git diff HEAD` empty.
- The first ablation leg was a no-op and is void: my replacement text
re-contained the anchor, so the tool refused (anchor count 1 to 1)
before the tests ran. It restored cleanly; the second leg above used an
anchor the replacement does not reproduce.
- The subject is the package's own source file imported by relative
path, so vitest reads `src`, not a dependency's `dist`; the red above is
the proof it read the mutated file.
## Gates
Derived with `node scripts/pm/dispatch-gates.mjs --repo
objectstack-ai/objectstack --commands` (no path arguments; the script
takes the change set from the merge base, as the standing rule
requires). 61 commands, each run in the foreground with its exit code
recorded beside the verbatim command; `--ran` reconciles `61 derived, 60
run, 1 NOT-MEASURED, 0 UNRUN`.
- 60 exit 0.
- NOT MEASURED: `pnpm check:dual-build-cjs-loads` exits 3, `PREREQUISITE
NOT MET`: it reads built `dist/` for 65 packages across the repo and
this worktree builds only the dependency closure of one package. This
diff touches no `exports`, build config or manifest. CI owns that scan.
- `pnpm check:type-check-debt` first exited 124 (my own 280 second
timeout under shared-box contention, not a verdict); rerun under the
lock with a larger budget: `OK — 1 ledger entr(ies) re-measured in
103.7s, none above its recorded number`. `service-knowledge` has no
ledger entry.
- The derivation printed a stale-tree warning (origin/main had moved 8
commits, 3 files it reads changed: a `fleet-write.yml` action bump, one
`engine-double-contract.pinned.json` row for another test file, the root
`package.json`). I derived again in a throwaway detached worktree at
origin/main `39ab2940` with this diff applied: the 61-command list is
identical. That worktree is removed.
- Lint, narrowed: `eslint --no-inline-config --format json` on the 3
changed TypeScript files, 3 files linted (the count is read from
eslint's own JSON), 0 errors, 0 warnings. `eslint.config.mjs` never
enables type-aware linting (no `parserOptions.project`, noted at
`:328`), so this diff cannot move the verdict of any untouched file. The
repo-wide `pnpm lint` is CI's.
- Commits at final head `3e588a22`: the gates above ran at it. The
whole-package test ran at `8cd6a922` (44 tests) and the pin file again
at `3e588a22` (9 tests); the only change between those two commits is
the changeset file.
## Acceptance notes
Not filed, not fixed here:
- Bare `record.created|updated|deleted` still appears as arbitrary
event-name test data in
`packages/services/service-realtime/src/in-memory-realtime-adapter.test.ts`,
`packages/spec/src/contracts/realtime-service.test.ts`, and a few spec
schema tests (`websocket.test.ts`, `protocol.test.ts`,
`connector-author-shape.test.ts`). The adapter's event `type` is a plain
string and nothing at runtime reads those names. No non-test source or
doc advertises them. Carrier: none.
- The subscription takes no `eventTypes` filter, so the handler sees
every event, including `metadata.*`, and falls through on any name it
does not know. That was already the behaviour for `metadata.*` and is
unchanged.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01DiCSbmJrkzNhuEAier4VoJ)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent b3917d9 commit e952cff
4 files changed
Lines changed: 99 additions & 29 deletions
File tree
- .changeset
- packages/services/service-knowledge/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
28 | 32 | | |
29 | 33 | | |
30 | 34 | | |
| |||
159 | 163 | | |
160 | 164 | | |
161 | 165 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
168 | 178 | | |
169 | 179 | | |
170 | 180 | | |
| |||
214 | 224 | | |
215 | 225 | | |
216 | 226 | | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | 227 | | |
233 | 228 | | |
234 | 229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
232 | | - | |
233 | | - | |
234 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
235 | 236 | | |
236 | 237 | | |
237 | 238 | | |
| |||
249 | 250 | | |
250 | 251 | | |
251 | 252 | | |
252 | | - | |
| 253 | + | |
253 | 254 | | |
254 | 255 | | |
255 | 256 | | |
| |||
0 commit comments