Repository navigation
feat(service-messaging): serve the notification topics and channels a preference or template can name - #31004
Conversation
…c and channel Claude-Session: https://claude.ai/code/session_01L9qibwBQRERS1JhPWT48RW Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibwBQRERS1JhPWT48RW Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibwBQRERS1JhPWT48RW Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibwBQRERS1JhPWT48RW Co-Authored-By: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 43 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 13 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 6 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 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
|
…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
|
domain:server#2 · os-tesla · session_01L9qibyvxbrLP4jm4PargoH 维护者速读
席位意见:可以落地。 席位核对ACCEPT · seat
|
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(十一种语言)。*照存、不新增任何拒绝,已存数据不动;新接口只读、仅限已登录成员,且每个组织只看得到自己组织的已存主题。回滚即撤销本 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
registerPreferenceOptionsRoutes(src/preference-options-routes.ts) mountsGET /api/v1/messaging/preference-optionsonhttp-serveratkernel:ready, as service-settings / service-print / service-storage mount theirs. The sibling/api/v1/notificationsroutes live inpackages/runtimebehindINotificationService(a spec contract), so a runtime face would have needed a spec card; this PR touches neitherpackages/runtimenorpackages/spec. A kernel with no HTTP server logs onewarnnaming what is not mounted./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 is403with the policy's code; anonymous is401 UNAUTHENTICATED; the closed query set is empty, so any query parameter is400 VALIDATION_ERRORnaming it. All of these answer before any source is read.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); everynotifystep's own stringtopicin this environment's flows (protocol.getMetaItems({ type: 'flow' })), andnotifyfor a step that names none (the node's own default); the distinctsys_notification.topicvalues of the caller's organization (oneaggregategrouped bytopic,where: { organization_id }, under a named system contextPREFERENCE_OPTIONS_SYSTEM_CONTEXT; a caller with no organization gets no stored topic).channels: Array<{ value: string; wildcard: boolean; configured: boolean }>:*first, thenMessagingService.getKnownChannels()(new): directly registered channels, then each lazy provider,configured: falsewhen its transport is absent ("not configured").500 INTERNAL_ERRORwith the door's sentence and the error in the fault log, never a partial list.sys_notification_preference.topicdeclareswidget: 'notification-topic',.channeldeclareswidget: 'notification-channel',sys_notification_template.topicdeclareswidget: 'notification-topic'.FieldSchema.widgetis an existing freez.string(), so no spec value is added; an unregistered widget degrades to the text box. The template'schannelkeepschannel_renders_templateand declares nothing.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;enregenerated bycheck-i18n-bundles --write.src/messaging-route-ledger.ts(oneserver-onlyrow) with its package-local conformance test, and the three wiring lines the claim names: the live-mount parity dogfood test imports the ledger, andscripts/cross-package-test-inputs.mjs/turbo.jsondeclare it as that test's input.scripts/check-route-envelope.mjsdeclares the new door inMODULESat{ responses: 0, ok: 0, err: 0 }beside the print door (every body goes through the sharedsendOk/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, realObjectQLoverSqlDriver(better-sqlite3) holdingorg_aandorg_bon theisolatedposture: the full list and its sources; cross-organization isolation (a topic stored inorg_bnever listed fororg_a, and the reverse); no protocol means no flow topic; anonymous401, held sign-in403 PASSWORD_EXPIRED, query parameter400naming it, each asserting by envelope (ApiError parse + code + status) and that no source was read; a failing source500, 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.tsre-pinned: the built channel ids are['inbox', 'email', 'sms', 'push'](push factory added to the enumeration) and the help names exactly those;pushleft the "named but not implemented" list; a new case pins the three widget hints, the template topic'stexttype, and no widget on the template channel.Acceptance notes
PLATFORM_NOTIFICATION_TOPICSis a measured constant, since nothing registers topics (ADR-0030'sdefineTopic()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_inviteare template topics (the SMS goes out withoutemit()), listed because the template form reads the same list; on a preference they match nothing.aggregate, no limit inEngineAggregateOptions); the event table's 90-day lifecycle window bounds it in practice.shouldDenyAnonymousremoved,!contextkept), 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.node scripts/pm/dispatch-gates.mjs --commandsdid not derivepnpm check:route-envelopefor this diff's paths, so the 86 local gates were green while CI'sLint · docs & code guardswent red onResponse-envelope guard(run 42254020926,NOT DECLARED) atd4930694. Fixed in581fce5c; a new*-routes.tsmodule outside the derivation's reach needs that command run by hand.skills/**,content/docs/**or ADR edit: no published sentence states these fields have no list. The ui half (registeringfield:notification-topic/field:notification-channel) is the next card.Verification
All readings on head
d4930694unless a line says otherwise (d4930694=00bd47c0+ merge oforigin/main, 8 commits, onlyturbo.jsonoverlapping; head581fce5cadds 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 typecheckunder 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)
where: { organization_id: organizationId },, anchor 1 -> 0):a topic stored in one organization never appears for anotherfailed,AssertionError: expected [ '*', 'approval.comment', …(18) ] to not include 'org_b.secret_topic'.if (false as boolean) {:refuses an anonymous caller 401 UNAUTHENTICATEDfailed,expected [ 'INTERNAL_ERROR', 500 ] to deeply equal [ 'UNAUTHENTICATED', 401 ]. (First mutation,if (!context) {, stayed green: see Acceptance notes.)refuses a held sign-in 403 ...failed.refuses a query parameter 400 VALIDATION_ERROR naming it, never ignoring itfailed.not.a.notify.topic.Derived gates
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackon00bd47c0(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.d4930694:pnpm check:turbo-task-graph,pnpm check:cross-package-test-inputs,pnpm check:ci-filter-parity,pnpm check:i18n: exit 0 each.581fce5c:pnpm check:route-envelopeexit 0 (--self-testthen the audit; wasNOT DECLAREDforpreference-options-routes.tsbefore),npx eslint --no-inline-config scripts/check-route-envelope.mjsexit 0..changeset/30208-messaging-preference-options.md,@objectstack/service-messaging: patch, carrying both declaration lines at line start.!in the title, no(narrowing)arm).🤖 Generated with Claude Code
https://claude.ai/code/session_01L9qibwBQRERS1JhPWT48RW
Generated by Claude Code