fix(service-messaging,plugin-audit): the service that writes sys_notification declares it (#4154) - #4182
Merged
Merged
Conversation
…fication declares it (#4154) `MessagingService.emit()` writes `sys_notification` on every call — it is the pipeline's single ingress (ADR-0030 L2). But the object was contributed to the manifest by AuditPlugin, parked there with a comment saying it would stay "until that [ADR-0030] migration lands". The migration landed; the parking did not move. That left a real deployment hole, because AuditPlugin is an OPTIONAL pair in the CLI's plugin table. Install messaging without audit and nothing registers the object, so the engine has no schema to issue DDL from and every notify() fails with `no such table: sys_notification`. AuditPlugin never wrote the row itself — it deliberately routes through this service's emit() ingress (`getMessaging()` in audit-writers.ts), and its own exclusion list already annotates the object as "messaging-owned (ADR-0030)". The contribution now lives with the writer, matching how every other service-owned platform object is handled here: service-job imports SysJob/SysJobRun, service-queue imports SysJobQueue, rest imports SysImportJob. Ownership of the DEFINITION is unchanged — the object stays in @objectstack/platform-objects and in PLATFORM_OBJECTS_BY_PACKAGE, because owning a definition and contributing it to a running kernel are different things. It is also added to provisionSystemTables so the table is created with the rest of the pipeline it heads rather than lazily on first write. Found while migrating notifications.hono.integration.test.ts to in-memory SQLite in #4065: that suite had to register the object itself to boot, which was the deployment bug in miniature. The workaround is deleted here — the suite now boots messaging alone and passes, which is the proof. A direct regression test pins the invariant at the plugin rather than three layers downstream, where it surfaced as a 404 or a `Find operation failed`. Verified it fails against the un-declared manifest before landing the fix. Verified: full forced suite including dogfood green (132/132), lint clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L5q3BZMpdiAueHf2emhDY9
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 2 package(s): 9 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
… answer now (#4154) `objects/index.ts` listed `sys_notification` under "Intentionally NOT moved here" with the reason "reworked by ADR-0030 messaging" — a pending state. The rework landed and the contribution moved to service-messaging, so the note now says where it went and why the definition still lives in platform-objects. Found by the docs-drift check on #4182 flagging plugin-audit. The nine docs it listed were all verified accurate and need no change — `audit-service.mdx` only references sys_audit_log/sys_activity, which this plugin still registers. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L5q3BZMpdiAueHf2emhDY9
os-zhuang
marked this pull request as ready for review
July 30, 2026 14:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4154。
比 issue 里写的更糟一点
我立 #4154 时说的是「
MessagingServicePlugin写sys_notification但不声明它,真实 boot 能跑只因 platform-objects 恰好也加载」。查下去发现两处需要更正,而且实际情况更严重:AuditPlugin——audit-plugin.ts把它放进了自己的 manifestobjects。AuditPlugin在 CLI 里是 optional 的(serve.ts:1778"Pair: AuditPlugin — optional")。所以这不是「层次不好看」,是装了 messaging 不装 audit,每次
notify()都会炸no such table: sys_notification—— 而emit()是整条 ADR-0030 pipeline 的唯一入口。修法是代码自己预约好的
audit-plugin.ts原注释:ADR-0030 早已落地(
MessagingServicePlugin带完整 L2/L4/L5 pipeline、对象 docstring 写着 "Re-modeled (ADR-0030)"、migrate-sys-notification-to-event.ts也在)。这条寄放到期了,把它挪到位即可 —— 不是新发明的方案。佐证 AuditPlugin 本就不该持有它:
emit()入口(audit-writers.ts:41的getMessaging())'sys_notification', // messaging-owned (ADR-0030); its own lifecycle(audit-writers.ts:112)改了什么
MessagingServicePlugin的 manifestobjects加上SysNotification,并加进provisionSystemTables(表随它统领的 pipeline 一起建,而不是等第一次写时懒建)AuditPlugin的 manifest 去掉它,陈旧的寄放注释换成说明去向service-messaging增加@objectstack/platform-objects依赖(无环:→ metadata-core/spec,没有回边)定义归属没变:对象仍在
@objectstack/platform-objects、仍在PLATFORM_OBJECTS_BY_PACKAGE里。拥有定义 ≠ 把它贡献进运行中的 kernel,这两件事本来就分开。这也正是仓库既有模式:service-jobimportSysJob/SysJobRun、service-queueimportSysJobQueue、restimportSysImportJob—— 拥有行为的 service 负责贡献。验证
最有说服力的一条:删掉 #4100 里为这个缺陷加的 fixture 绕行。
notifications.hono.integration.test.ts当时必须自己AppPlugin({ objects: [SysNotification] })才能启动——那正是这个部署缺陷的缩影。现在它只引导 messaging 就能跑通,绕行代码已删除。另加一条直接的回归断言(
plugin-declares-event-object.test.ts),把不变量钉在插件本身,而不是等它在三层之外表现为 404 或Find operation failed。已验证它在未声明的 manifest 上会红,不是空洞断言。pnpm run lint干净关联
sys_notification但不声明它——靠 platform-objects 恰好也加载才能工作 #4154(本 issue)pnpm test只能跑绿一次:InMemoryDriver 默认把数据落盘,datasource-autoconnect 测试在第二次运行必然失败 #4065 / fix(driver-memory): persistence opt-in again + move the remaining suites to in-memory SQLite (#4065) #4100(发现路径)Generated by Claude Code