Repository navigation
Commit 1a2361c
feat(service-automation): declared connector instances resolve by (package, name) through the shared resolver (#31725)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9B9qYj7GTyDGfaMgXwXx7rZ)_
Part of #31677
Clause-②: no
Metadata-protocol: none
Narrowing: D3 (a) declared by the card, measured 0 here: no reader in
this PR has a caller package (first-party package-caller reads wired:
0), so the closure-outside sub-case of #31527 comment 6728487836
measures 0, sibling-in-the-same-artifact included.
Part of epic #31527 (ADR-0150 child E5), connectors only, per seat 3's
split on the card (6728849524, epic seat 6728850663). Two remainders of
#31677 stay open:
- **Webhooks**: waits on the maintainer's ruling on names two packages
held before phase 1 (the card's needs-user-decision, Q1). Its code is at
`da3bc28e` on this branch's history and lands as its own draft PR after
`Ruled:`.
- **Email templates**: waits on R2 #31716, which stops the resolver from
counting a dependent's added locale (#28802) as a second holder of the
base's template name.
Card thread `domain:server#3` · `os-steve` ·
`session_01ADHkmR4astMzES5UkW47jW`; claim 6728454873, file-surface
amendment 6728498905.
## 维护者速读
- 改了什么:声明式连接器实例在物化时,按名字取哪一条声明,改为问 R 的共享解析器
`resolvePackageScopedName`(无包调用方):先环境自建项,再全环境唯一的包持有者,否则拒绝并列出全部候选。
- 为什么改:ADR-0150 把连接器改为按(软件包, 名称)寻址;以前两个包同名时只报「名字重复」,不点名是哪两个包。
- 风险与回滚:阶段一的单持有者拒绝对 connector
仍然生效,今天不可能有两个包同名,所以每个名字的答案不变(service-automation 全量 3458
条全绿)。`@objectstack/objectql` 从开发依赖改为运行时依赖,无循环。回滚即还原本 PR。
-
先看:`packages/services/service-automation/src/connector-package-scope.ts`,以及
`plugin.ts` 里 `reconcileDeclaredConnectors` 开头的拒绝循环。
- 两分钟验证:`pnpm --filter @objectstack/service-automation exec vitest run
src/connector-materialization.test.ts -t "resolves by"`,预期 2
条通过、其余跳过,其中两个包同名的用例断言启动失败、错误信息点名两个包、工厂从未被调用。
- 需要你做的:无,席位落地。
## What changes
`reconcileDeclaredConnectors` (service-automation, the declared-instance
index the engine's `connectors` map is filled from) now asks the ONE
package-scoped resolver (`resolvePackageScopedName`,
`@objectstack/objectql`, R #31637) which declared connector instance a
name means, before it materializes anything. The reconcile reads the
whole environment's declaration and has no caller package, so it asks as
a caller with no package (ADR-0150 D3): the environment's own item, else
the unique package holder, else a refusal naming every candidate.
| Reader on `main`, by symbol | Pick today | Caller package | After this
PR |
|:--|:--|:--|:--|
| `reconcileDeclaredConnectors` desired map | a second entry refused as
"duplicate", no candidates named | none | a name the resolver refuses is
not materialized; `fail()` names every candidate (fatal at boot for a
host-declared entry, soft for a stored one, as the duplicate check
already was) |
Not touched, and why:
- `connector_action`'s `connectorConfig.connectorId` is the one
reference here written inside a package (the flow's).
`AutomationContext` (spec) names no flow package, so the node cannot ask
as that package yet; per seat 3's ruling (Q3 A) it stays context-free
here and is wired after E1 #31672. It keeps reading the engine's
one-instance-per-name map, which this PR now fills through the resolver.
- `findInertDeclaredConnectors` (an audit warning) picks no item.
- Plugin-registered connectors (`engine.registerConnector`) are no
registry items; the resolver answers not-found and they keep ADR-0097
§4's one-origin rule.
- Stored references (`sys_connector_connection.connector_name`) are S3
#31684's.
`@objectstack/objectql` moves from `devDependencies` to `dependencies`
in service-automation (claim amendment 6728498905). No cycle: objectql's
workspace closure (deps, devDeps and peers, 14 packages) does not
contain service-automation. E1 #31672 makes the same move on the same
lines; a trial merge of its branch onto this head is clean, and per the
seat E1 lands first and this branch merges `origin/main` after it.
## ADR-0150's four readings
- **(a) phase-1 one-holder tests stay green.** objectql's four
`registry-bare-name-one-holder*` suites plus
`package-scoped-resolver.test.ts`: 187 passed; the four
`bare-name-one-holder*` dogfood files are in the targeted run below.
This PR does not touch objectql.
- **(b) bare-name behaviour unchanged for every name with one holder.**
The new suite pins the one-holder case on a real `SchemaRegistry` (the
connector materializes with the holder's definition), and
service-automation's full suite stays green. No URL, MCP or SDK surface
moves.
- **(c) no migration.** Nothing stored is read or written differently.
- **(d)** `Clause-②: no`, `Metadata-protocol: none`; no ADR-0087 entry.
## Tests
`service-automation/src/connector-materialization.test.ts`, new describe
"a declared connector name resolves by (package, name)": one holder
materializes; two holders fail the boot naming both, and the provider
factory is never called. The harness's `boot()` gains an optional
`schemaRegistry` (a real registry in place of the double). No existing
test changed.
Ablation (`scripts/ablation-replace.mjs`, mutation proved on disk,
restored to the HEAD blob, `git diff HEAD` empty after; the suite
imports `src`, so no `dist` leg; measured at `da3bc28e`, whose
service-automation tree is byte-identical to this head):
`refusedConnectorNames` records no refusal → 1 failed: the boot still
fails on the older duplicate-name check, but `expected '[Automation]
duplicate declarative co…' to contain 'connector instance \'billing\' is
not…'`. The candidates are what the pin adds.
## Verification (head 47f5d0c)
- `@objectstack/service-automation` test exit 0 (266 files, 3458 tests);
typecheck exit 0; root `eslint --no-inline-config
packages/services/service-automation` exit 0 (the package has no `lint`
script). Run under `os-verify-lock`.
- Targeted dogfood after `turbo run build
--filter='@objectstack/dogfood^...'` (70/70): 19 files (the four phase-1
bare-name families, email template boot/materialization/locale files,
connector install/restart/package-ref files, declarative MCP, webhook
materialization), 96 tests passed.
- Derived gates: `dispatch-gates --commands` derived 85 families at
47f5d0c; all 85 run with `exit 0`; `--ran`: "85 derived, 85 run, 0
NOT-MEASURED, 0 UNRUN" (a derived zero, every row carrying its exit
code).
- `test:repo` not run locally (CI's `Test Core`); this diff touches no
repo-project test.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmR4astMzES5UkW47jW
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 470339e commit 1a2361c
6 files changed
Lines changed: 158 additions & 5 deletions
File tree
- .changeset
- packages/services/service-automation
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | | - | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
112 | 118 | | |
113 | 119 | | |
114 | 120 | | |
| |||
136 | 142 | | |
137 | 143 | | |
138 | 144 | | |
139 | | - | |
| 145 | + | |
140 | 146 | | |
141 | 147 | | |
142 | 148 | | |
| |||
418 | 424 | | |
419 | 425 | | |
420 | 426 | | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
421 | 461 | | |
422 | 462 | | |
423 | 463 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
| |||
2586 | 2588 | | |
2587 | 2589 | | |
2588 | 2590 | | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
2589 | 2616 | | |
2590 | 2617 | | |
2591 | 2618 | | |
| |||
2893 | 2920 | | |
2894 | 2921 | | |
2895 | 2922 | | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
| 2930 | + | |
| 2931 | + | |
| 2932 | + | |
2896 | 2933 | | |
2897 | 2934 | | |
2898 | 2935 | | |
| |||
2903 | 2940 | | |
2904 | 2941 | | |
2905 | 2942 | | |
| 2943 | + | |
2906 | 2944 | | |
2907 | 2945 | | |
2908 | 2946 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments