Repository navigation
fix(service-automation): converge a connector definition change on every replica - #28028
Conversation
…ery replica The automation plugin's metadata-mutation listener took flow mutations only, and metadata:reloaded is a kernel-local hook, so a connector definition published on one replica re-materialized there alone. Queue the soft connector reconcile the reload hook runs for a non-draft connector mutation: lane 2's replay reaches a peer's listener, and a direct active save, which raises no reload, now re-materializes the writing replica too. The measurement's it.fails pin becomes a plain it. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cxbvGGSLgjTAqnkkMK
📓 Docs Drift CheckThis PR changes 1 package(s): 1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 1 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 10 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 df6e7936bf02bc5d4db63a0dcabbf3a79b968d4a && git checkout df6e7936bf02bc5d4db63a0dcabbf3a79b968d4a
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 7a378234c8b44f98537900941f6ab06d6f1edbd2 89267c8b3ec2277857b466333136781016b023ba && git checkout -B drift-repro 7a378234c8b44f98537900941f6ab06d6f1edbd2 && git merge --no-ff 89267c8b3ec2277857b466333136781016b023ba
node scripts/docs-audit/affected-docs.mjs --json 7a378234c8b44f98537900941f6ab06d6f1edbd2
|
|
domain:server#3 · os-elon-musk · session_016WV4czuTWNgKR22fKv7jia Seat ACCEPT · PR #28028 · head
|
Requested by Elon · project thread
Fixes #28002
Clause-②: no
Metadata-protocol: none
Skills-docs: none in skills (
git grep -n -i -E "replica|cluster|metadata\.mutated|peer" -- skills/ | grep -i connectorfinds 0 lines); docs follow-up owed and outside this card's file surface:content/docs/kernel/cluster.mdx§6.2 (the lane 2 row's "Converges" column and the "Lane 2" subsection name only ObjectQL's object registry, while the automation service's flows and, after this PR, its materialized connectors converge on lane 2 as well) andcontent/docs/automation/connectors.mdx(the fault table's "runtime reload (Studio publish / dev reload)" row now also covers a direct active save and a change made on another replica)维护者速读
PUT /api/v1/meta/connector/:name(不走发布门)也会让写入的那个副本自己生效。metadata:reloaded重建实例,其它副本虽然经 lane 2 收到了变更,但自动化插件的监听器只处理flow,于是一直用旧定义直到重载或重启。connector变更多排一次「软」对账(与 reload 同一路径),不新增集群通道;发布方会对账两次,第二次签名不变、不重建(已测)。回滚即还原本 PR 的plugin.ts。packages/services/service-automation/src/plugin.ts(subscribeFlowMutations里新加的connector分支与新方法queueConnectorMutationReconcile);connector-definition-cluster.test.ts。pnpm --filter @objectstack/service-automation exec vitest run --maxWorkers=2 src/connector-definition-cluster.test.ts,预期 7/7 通过。What changes
AutomationServicePluginsubscribes to the metadata protocol's post-persistence signal (onMetadataMutation, #21725), and its listener returned for every type butflow. A connector definition change therefore re-materialized only wheremetadata:reloadedfired: on the replica that published it (ObjectQLPlugin.announcePerItemPublish). That hook is kernel-local. Lane 2 (metadata.mutated) did deliverconnector/NAMEinto a peer's mutation listeners, as #27977 measured, and nothing there acted on it.Now the listener also handles a
connectormutation whose state is notdraft(activeordeleted) by queuingqueueConnectorMutationReconcile: the soft reconcilemetadata:reloadedruns (reconcileDeclaredConnectors(ctx, { fatal: false })), on the existing reconcile queue, so it never interleaves with a credential write or another reconcile. The reconcile re-reads the declaration from this replica's own protocol view, the same read the reload path makes. No new lane, channel or payload: a peer converges on the lane 2 replay it already receives (triage 6517791280, §6.2's single-signal rule).warn, cause inmetaper finding(service-automation): connector 物化失败的fail()也是${err.message}单行插值,同 #5048 的类别、另一个接缝 #5575) and leaves the next reload or restart to reconcile, as lane 4's receipt does.Tests
packages/services/service-automation/src/connector-definition-cluster.test.ts(the #27977 two-kernel harness: realObjectKernel,ObjectQLPlugin, driver-sql on one shared better-sqlite3 file, lanes 2 and 4 attached as the cluster bridge attaches them):it.failspin is now a plainit: the peer follows a published definition with no reload on the peer.metadata:reloadedplus its own mutation listener; lane 2's loopback guard drops the bus echo), and the provider is called exactly[V1, V2], so the second run is a no-op.saveMetaItemwith no mode, the call behindPUT /api/v1/meta/connector/:name) re-materializes the writing replica and converges the peer. The same listener covers it, so it is pinned here and not widened elsewhere.reconcileDeclaredConnectors, attributed per plugin instance), the provider is not called again, and the flow save still arms the flow on both replicas.metadata:reloadedis again its only trigger: the peer holds nothing before the reload and converges from its own read after it.Acceptance notes
auditDeclaredConnectors, the inert-descriptor warning) still runs atkernel:readyand onmetadata:reloadedonly. This PR adds convergence, not another warning per save.Verification
All readings at head
89267c8b(branched offmainat066ff51e, after #28014 merged).Package tests and typecheck
pnpm --filter @objectstack/service-automation typecheck(underscripts/pm/os-verify-lock.sh): exit 0,check:test-typecheck: OK … 0 file(s) / 0 error(s). The test layer compiles undertsconfig.test.json, which includessrc/**/*.test.ts.pnpm --filter @objectstack/service-automation test:Test Files 223 passed (223),Tests 2846 passed (2846), lockVERDICT command-exit 0.vitest run src/connector-definition-cluster.test.ts:Tests 7 passed (7).Ablation and restore
Through
scripts/ablation-replace.mjsonplugin.ts: the anchorthis.queueConnectorMutationReconcile(ctx);plus thereturn;line after it, replaced by/* ABLATION-28002 */ return;(a connector mutation is then dropped, as onmain). Anchor x1 to x0, marker x0 to x1, blob154b06fea8a2to9852d936898e. The suite imports./plugin.jsfrom source, so no rebuild is in the path.Tests 5 failed | 2 passed (7). Red: the flipped peer pin, the publishing-replica count, the direct save, the delete, and the draft/flow control (on its setup line,expected undefined to be 'https://v1.billing.example.test': the peer never converges, so the control's precondition cannot hold). Green: the lane 2 reach row and the lane-2-off reload control, which do not depend on the listener.154b06fea8a2), andgit diff HEADis empty.Derived gate families and lint
node scripts/pm/dispatch-gates.mjs --commandsderived 60 families at89267c8b. All were run, pluspnpm lint(exit 0).--ran:60 derived famil(ies) accounted for — 59 run, 1 NOT-MEASURED.pnpm check:dual-build-cjs-loads, exit 3, PREREQUISITE NOT MET (it needs every package'sdist; only the@objectstack/service-automation^...closure was built). CI runs it.Generated by Claude Code