Skip to content

feat(service-messaging): serve the notification topics and channels a preference or template can name - #31004

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/project-thread-py5oh8
Nov 6, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/project-thread-py5oh8

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Tesla · project thread

Clause-②: yes (widening)
Metadata-protocol: none

Refs #30208 (row 6, server half). Ruling E on #30527 (record 6670386759), execution step 1 of comment 6670396132. The card stays open: the ui dropdowns (step 2) follow after this merges, quiet hours (step 3) is its own ui card, and row 5 is not in this PR.

维护者速读

  • 改了什么:新增只读接口 GET /api/v1/messaging/preference-options,返回通知偏好与通知模板可选的「主题」和「渠道」清单(* 排第一;主题来自平台固定主题、本环境流程通知步骤里写明的主题、本组织已发过的通知主题;渠道列出所有已知渠道,未配置服务的标「未配置」);三个字段声明下拉控件提示;渠道帮助文字补上 push(十一种语言)。
  • 为什么改:管理员在 通知偏好 里只能凭记忆手打主题和渠道的机器名,打错一个字母就静默失效;按 [Decision] 通知偏好 topic/channel: pickers, refuse unmatched values, or free text as ruled on #25346? #30527 裁决 E,服务端先给出清单,控制台下一张卡据此画「可选可填」的下拉。
  • 风险与回滚:字段仍是文本、* 照存、不新增任何拒绝,已存数据不动;新接口只读、仅限已登录成员,且每个组织只看得到自己组织的已存主题。回滚即撤销本 PR,控件提示在控制台注册前本来就退化为文本框。
  • 先看:packages/services/service-messaging/src/preference-options.ts(三个主题来源与组织边界的 organization_id 条件)、src/preference-options-routes.ts(拒绝顺序:身份→受限登录→匿名→查询参数)、src/messaging-service-plugin.ts 的挂载段。
  • 两分钟验证:pnpm --filter @objectstack/service-messaging exec vitest run src/preference-options-routes.integration.test.ts,预期 8 个用例全过(含「B 组织的主题不会出现在 A 组织」)。
  • 需要你做的:无,席位落地。

What changes

  • A read-only list route, mounted by service-messaging itself (route B in the seat's claim 6688765720): registerPreferenceOptionsRoutes (src/preference-options-routes.ts) mounts GET /api/v1/messaging/preference-options on http-server at kernel:ready, as service-settings / service-print / service-storage mount theirs. The sibling /api/v1/notifications routes live in packages/runtime behind INotificationService (a spec contract), so a runtime face would have needed a spec card; this PR touches neither packages/runtime nor packages/spec. A kernel with no HTTP server logs one warn naming what is not mounted.
  • Who may ask (the posture of /api/v1/notifications): any signed-in member. The caller is resolved by the one composition (resolveRequestExecutionContext, session or API key); an authorization-store outage and an API key lifecycle refusal are relayed as declared; a held sign-in is 403 with the policy's code; anonymous is 401 UNAUTHENTICATED; the closed query set is empty, so any query parameter is 400 VALIDATION_ERROR naming it. All of these answer before any source is read.
  • What it serves (src/preference-options.ts), response { success: true, data: { topics, channels } }:
    • topics: Array<{ value: string; wildcard: boolean; sources: Array<'platform' | 'flow' | 'stored'> }>: { value: '*', wildcard: true, sources: [] } first, then sorted and de-duplicated, each with every source naming it: PLATFORM_NOTIFICATION_TOPICS (15 fixed topics measured from their send/template sites in plugin-approvals, plugin-audit, plugin-security, plugin-auth); every notify step's own string topic in this environment's flows (protocol.getMetaItems({ type: 'flow' })), and notify for a step that names none (the node's own default); the distinct sys_notification.topic values of the caller's organization (one aggregate grouped by topic, where: { organization_id }, under a named system context PREFERENCE_OPTIONS_SYSTEM_CONTEXT; a caller with no organization gets no stored topic).
    • channels: Array<{ value: string; wildcard: boolean; configured: boolean }>: * first, then MessagingService.getKnownChannels() (new): directly registered channels, then each lazy provider, configured: false when its transport is absent ("not configured").
    • A source that cannot be read answers 500 INTERNAL_ERROR with the door's sentence and the error in the fault log, never a partial list.
  • The fields: sys_notification_preference.topic declares widget: 'notification-topic', .channel declares widget: 'notification-channel', sys_notification_template.topic declares widget: 'notification-topic'. FieldSchema.widget is an existing free z.string(), so no spec value is added; an unregistered widget degrades to the text box. The template's channel keeps channel_renders_template and declares nothing.
  • The help: the preference channel help names push (registered as a lazy provider since Push channel: build the device registry routes (/notifications/devices) and the APNs + FCM transport that ADR-0012 marks "MUST ship M1" #29041), in the English source and all ten translated bundles; en regenerated by check-i18n-bundles --write.
  • Ledger: src/messaging-route-ledger.ts (one server-only row) with its package-local conformance test, and the three wiring lines the claim names: the live-mount parity dogfood test imports the ledger, and scripts/cross-package-test-inputs.mjs / turbo.json declare it as that test's input.
  • Envelope guard: scripts/check-route-envelope.mjs declares the new door in MODULES at { responses: 0, ok: 0, err: 0 } beside the print door (every body goes through the shared sendOk / sendError / sendServerFault). The claim was widened to this path for it.

Tests

  • src/preference-options-routes.integration.test.ts (new, 8 cases), real resolver over a fake auth service, real ObjectQL over SqlDriver (better-sqlite3) holding org_a and org_b on the isolated posture: the full list and its sources; cross-organization isolation (a topic stored in org_b never listed for org_a, and the reverse); no protocol means no flow topic; anonymous 401, held sign-in 403 PASSWORD_EXPIRED, query parameter 400 naming it, each asserting by envelope (ApiError parse + code + status) and that no source was read; a failing source 500, no data.
  • src/messaging-route-ledger.conformance.test.ts (new): registrar enumeration against the ledger, both directions.
  • src/objects/notification-preference-topic-channel-help.test.ts re-pinned: the built channel ids are ['inbox', 'email', 'sms', 'push'] (push factory added to the enumeration) and the help names exactly those; push left the "named but not implemented" list; a new case pins the three widget hints, the template topic's text type, and no widget on the template channel.

Acceptance notes

  • Flows are the environment's, not an organization's (ADR-0131 D6: the list serves the environment's rows and no organization's), so every organization of one environment is offered the same flow topics; the organization boundary applies to the stored topics, which is what the isolation pin holds.
  • PLATFORM_NOTIFICATION_TOPICS is a measured constant, since nothing registers topics (ADR-0030's defineTopic() was never built). A feature that starts sending a new fixed topic must add it there; no gate catches a miss. auth.phone_otp / auth.phone_invite are template topics (the SMS goes out without emit()), listed because the template form reads the same list; on a preference they match nothing.
  • The stored-topic read is unbounded in the number of distinct topics (one grouped aggregate, no limit in EngineAggregateOptions); the event table's 90-day lifecycle window bounds it in practice.
  • The anonymous floor test first stayed green under a narrower mutation (shouldDenyAnonymous removed, !context kept), because the fail-closed composition already answers no context for an unauthenticated request; the second mutation removed the whole branch and went red (below). Both runs are recorded.
  • A derived-gate blind spot: node scripts/pm/dispatch-gates.mjs --commands did not derive pnpm check:route-envelope for this diff's paths, so the 86 local gates were green while CI's Lint · docs & code guards went red on Response-envelope guard (run 42254020926, NOT DECLARED) at d4930694. Fixed in 581fce5c; a new *-routes.ts module outside the derivation's reach needs that command run by hand.
  • No skills/**, content/docs/** or ADR edit: no published sentence states these fields have no list. The ui half (registering field:notification-topic / field:notification-channel) is the next card.

Verification

All readings on head d4930694 unless a line says otherwise (d4930694 = 00bd47c0 + merge of origin/main, 8 commits, only turbo.json overlapping; head 581fce5c adds only the envelope-guard declaration).

Package suite, typecheck, lint (on 00bd47c, before the main merge)
  • pnpm --filter @objectstack/service-messaging test && pnpm --filter @objectstack/service-messaging typecheck under the verify lock: Test Files 69 passed (69), Tests 874 passed (874); VERDICT command-exit 0.
  • npx eslint --no-inline-config packages/services/service-messaging/src packages/qa/dogfood/test/route-ledger-live-mount-parity.dogfood.test.ts scripts/cross-package-test-inputs.mjs: exit 0.
  • pnpm --filter @objectstack/dogfood exec vitest run test/route-ledger-live-mount-parity.dogfood.test.ts: 8/8 passed on the showcase boot, which logged [messaging] preference options list mounted at GET /api/v1/messaging/preference-options; VERDICT command-exit 0.
Negative-pin ablations (each through scripts/ablation-replace.mjs, restored blob == HEAD, git diff HEAD empty)
  • Organization term deleted (where: { organization_id: organizationId },, anchor 1 -> 0): a topic stored in one organization never appears for another failed, AssertionError: expected [ '*', 'approval.comment', …(18) ] to not include 'org_b.secret_topic'.
  • Anonymous branch replaced by if (false as boolean) {: refuses an anonymous caller 401 UNAUTHENTICATED failed, expected [ 'INTERNAL_ERROR', 500 ] to deeply equal [ 'UNAUTHENTICATED', 401 ]. (First mutation, if (!context) {, stayed green: see Acceptance notes.)
  • Held sign-in gate disabled: refuses a held sign-in 403 ... failed.
  • Query refusal disabled: refuses a query parameter 400 VALIDATION_ERROR naming it, never ignoring it failed.
  • Notify-type filter disabled (every node read as a notify step): the list case failed on not.a.notify.topic.
Derived gates
  • node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack on 00bd47c0 (25 paths): 86 commands, every one run with stdin from /dev/null, all :: exit 0.
  • --ran: 86 derived, 86 run, 0 NOT-MEASURED, 0 UNRUN.
  • After the main merge, on d4930694: pnpm check:turbo-task-graph, pnpm check:cross-package-test-inputs, pnpm check:ci-filter-parity, pnpm check:i18n: exit 0 each.
  • On 581fce5c: pnpm check:route-envelope exit 0 (--self-test then the audit; was NOT DECLARED for preference-options-routes.ts before), npx eslint --no-inline-config scripts/check-route-envelope.mjs exit 0.
  • Changeset: .changeset/30208-messaging-preference-options.md, @objectstack/service-messaging: patch, carrying both declaration lines at line start.
  • Dogfood battery: n/a (no ! in the title, no (narrowing) arm).

🤖 Generated with Claude Code

https://claude.ai/code/session_01L9qibwBQRERS1JhPWT48RW


Generated by Claude Code

@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/service-messaging, touching 59 documentable anchor(s).

43 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 8ae0ab9b0d77d56473e89dae9fe437778172dda8.

⛔ 13 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 12 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 63 of 222 client-bound route-ledger rows — the other 159 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 159: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 104 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 6 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 8ae0ab9b0d77d56473e89dae9fe437778172dda8 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from b12957ca1328e6736d966f7a9cc5e13a94149881 — the merge of head 581fce5cadca90b9f7aa204e8fa849ff7e5a3f80 into base 8ae0ab9b0d77d56473e89dae9fe437778172dda8, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin b12957ca1328e6736d966f7a9cc5e13a94149881 && git checkout b12957ca1328e6736d966f7a9cc5e13a94149881
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 8ae0ab9b0d77d56473e89dae9fe437778172dda8 581fce5cadca90b9f7aa204e8fa849ff7e5a3f80 && git checkout -B drift-repro 8ae0ab9b0d77d56473e89dae9fe437778172dda8 && git merge --no-ff 581fce5cadca90b9f7aa204e8fa849ff7e5a3f80

node scripts/docs-audit/affected-docs.mjs --json 8ae0ab9b0d77d56473e89dae9fe437778172dda8

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 8ae0ab9b0d77d56473e89dae9fe437778172dda8 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

…route-envelope guard

The door writes every body through the shared sendOk / sendError /
sendServerFault pair, so it is declared at 0 / 0 / 0 beside the print door.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibwBQRERS1JhPWT48RW
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#2 · os-tesla · session_01L9qibyvxbrLP4jm4PargoH

维护者速读

  • 改了什么:新增只读接口 GET /api/v1/messaging/preference-options,返回通知偏好与通知模板可选的「主题」和「渠道」清单(* 排第一;主题来自平台固定主题、本环境流程通知步骤写明的主题、本组织已发过的通知主题;渠道列出所有已知渠道,未配置服务的标「未配置」);三个字段声明下拉控件提示;渠道帮助文字补上 push(各语言)。
  • 为什么改:管理员在 通知偏好 里只能凭记忆手打主题和渠道的机器名,打错一个字母就静默失效;按 [Decision] 通知偏好 topic/channel: pickers, refuse unmatched values, or free text as ruled on #25346? #30527 裁决 E,服务端先给清单,控制台的下拉卡随后据此实现。
  • 风险与回滚:字段仍是文本、* 照存、不新增拒绝、已存数据不动;接口只读,仅限已登录成员,每个组织只看得到自己组织的已存主题名(不含内容与条数)。回滚即撤销本 PR;控件提示在控制台注册前退化为文本框。
  • 先看:packages/services/service-messaging/src/preference-options.ts(三个来源与 organization_id 组织边界)、src/preference-options-routes.ts(拒绝顺序)。
  • 两分钟验证:pnpm --filter @objectstack/service-messaging exec vitest run src/preference-options-routes.integration.test.ts,8 个用例全过(含「B 组织的主题不出现在 A 组织」)。
  • 需要你做的:无。席位按常设授权落地;Setup: replace developer wording and hand-written JSON with fields a business administrator can use #30208 留着等 ui 下拉卡和第 5 行。

席位意见:可以落地。

席位核对

ACCEPT · seat domain:server#2 · head 581fce5c · 2026-11-06T17:34Z

  1. Shape: Refs #30208 (row 6, server half) (no Fixes: the card stays open for the ui half and row 5), draft, base main, 26 files, +927/−35 (under 3,000; no governed path). @objectstack/service-messaging patch changeset with Clause-②: yes (widening) and Metadata-protocol: none, matching claim 6688765720 and its route-B surface (service-messaging + the three wiring lines; packages/runtime and packages/spec untouched).
  2. Premise: ruling E ([Decision] 通知偏好 topic/channel: pickers, refuse unmatched values, or free text as ruled on #25346? #30527 record 6670386759, step 1 of 6670396132); on main service-messaging mounted no route and getRegisteredChannels reached only a boot log line.
  3. Review: Clause-②: yes (widening) alone ⇒ the seat's TIER_DEFAULT review of record; no *.zod.ts, no narrowing arm, so no CONTRACT_REVIEW_TIER review owed. Seat read the whole non-generated diff: the refusal order (caller → held sign-in → anonymous → query) answers before any source is read; the stored-topic read runs under the named system context with the organization_id term as the boundary and returns topic names only, which is exactly what ruling E lists ("stored sys_notification.topic values" of this organization); flow notify topics are static strings (notify-node.ts reads cfg.topic as a metadata cross-reference), so listing them verbatim is correct; widget is the existing free FieldSchema.widget string, so no spec value is added; a failing source answers 500, never a partial list. Cross-organization isolation is pinned and ablated (PR body).
  4. Gates / check-runs: dev report 6690068310. Delta d4930694 → 581fce5c read by the seat: one MODULES entry in scripts/check-route-envelope.mjs (+6) declaring the new route module (responses: 0, ok: 0, err: 0, every body via the shared sendOk / sendError / sendServerFault), per claim amendment on the card; dispatch-gates did not derive that gate for service-messaging paths (recorded in the PR's Acceptance notes). On head 581fce5c: 58 success, 10 skipped, 0 failed; mergeable_state: clean.
  5. Accepted deviations: the route lives in service-messaging (route B), not beside /api/v1/notifications in runtime, because a runtime face needs a new INotificationService member (a spec card); the seat accepted this before the build.
  6. Landing: not governed, 962 changed lines: the seat readies the PR and arms auto-merge on the maintainer's word in the seat thread 「你应该使用 pm-dispatch 技能审核和落地pr」(2026-11-06T16:49Z). On merge: release Setup: replace developer wording and hand-written JSON with fields a business administrator can use #30208 for the ui half (step 2) and row 5; the seat files the ui card.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant