Repository navigation
Commit 199e362
feat(service-automation): the connector connection store, the connect door and the OAuth callback read and write one instance by its package and name (#33218)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6Jao3aDjoEUznHeGMZJaoMEKa5)_
Part of #31699
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
- 改了什么:连接存储、连接门(读 / 开始 / 回调 / 撤销)、OAuth 回调和派发都按「包 +
名字」读写连接。开始连接时把实例的包记进待完成授权,回调只完成那个包的实例,不再按名字重新解析。没有包的旧连接行,只在名字的持久解析指向该包时才算它的,该包重新连接时就地认领。
- 为什么改:ADR-0150 D4,#31699 PR 3a 的第二半(第一半 #33199 加宽了键)。
- 不变:每个名字只有一个持有者、每个组织一条连接的库上,所有答复照旧;一持有者兜底仍在。
- 新的拒绝(逐条列在 changeset 的 "What answers differently"):名字有两个持有者时连接门
409;同一组织有两条行回答同一实例时门 409、派发 503(不再挑一条);回调记录的包不再声明该实例时 404。
- 声明的偏离:M5(本 PR 不加 `?package=`,地址化的门随收窄兜底的 PR
一起落,不晚于它)、M6(无持有者时用条目自己的包)、S3(两个持有者时包自己的行优先)。三条都经红线审读接受。
-
先看:`packages/services/service-automation/src/connector-connections.ts`(`answering`)、`src/plugin.ts`(`connectorInstancePackage`、`connectionDoorInstance`)、`src/oauth2-grant/grant-handle.ts`。
## What changes
- **Store** (`ConnectorConnectionStore`): `connect`, `read`,
`readOrRefuse`, `revoke`, `listFor` take the instance's package. One
rule (`answering`) decides which rows answer: the package's own rows,
plus a package-less row only where the name's durable resolution (the
boot backfill's question) binds it to that package or no registry can
judge; a connect adopts that row in place (M2). Two answering rows are
refused, never picked. A package-less row of a name two packages hold is
no package's: the read and the revoke are refused 409 naming `os migrate
stored-references bind`. `listFor` still counts a conflicted
organization, carrying the refusal. The post-insert take-back from
#33199 now counts by package.
- **Instance package** (`connectorInstancePackage`): a real stamp; none
for the environment's stored entry; for an unstamped or
compatibility-default entry, the durable holder's package. Door,
dispatch handle, materializer and reconnect mark all use it.
- **Door** (`connectionDoorInstance`): resolves the name; two holders
409; no registry or no holder serves the one declared entry (two
declared entries 409).
- **Pending authorization**: carries `packageId` (explicit `null` for no
package). The callback completes exactly that package's entry; a record
from before this change (no key, TTL ten minutes) resolves the name.
- **Dispatch** (`createOAuth2GrantHandle`): reads by package; a conflict
is 503 on both the selection and the refresh read; an org-less dispatch
never takes a conflicted organization's row.
- **Docs**: one sentence in `content/docs/automation/connectors.mdx`.
## Declared deviations from the design review
- **M5**: no `?package=` on the HTTP door and no spec change here. The
addressed door lands with the PR that narrows the one-holder backstop,
and no later. Until then a name with two holders (a package installed
after boot) is refused at every leg of the door, revoke included.
- **M6**: with no registry answer or no holder, the one declared entry
is served with its own package, not `null`.
- **S3**: under two holders a package's own row wins over a package-less
row of the name; the stray row keeps its token until bound and revoked
(remedy in the changeset).
## Verification
- `connector-connection-package.test.ts` (new, real ObjectQL over
SQLite): 10 pins on the store rule, adoption, two holders, two rows,
revoke, `listFor`.
- `connector-connection-door.test.ts`: 13 new pins through the booted
plugin and a real `SchemaRegistry`: stamping, the 409s, the callback
completing the recorded package (including `null`) after the
declarations change, refusal before the code is used, M2 adoption, two
rows refused with and without the run's organization, a conflicted
organization still counted (422), revoke 409 under a disabled second
holder, unstamped and `__runtime__` entries keeping their row across the
backfill bind.
- Ablations (each reds its pins): connect stamps no package; begin
records no package; callback re-resolves; refused resolution not
refused; two declared entries picked; adoption not stamping; org-less
takes a conflicted entry; `listFor` skips a conflicted organization;
revoke answers not-connected under conflict; door fallback removed; the
resolver arm of the instance package removed.
- `@objectstack/service-automation` full suite, rebased on `main` after
#33199: 281 files, 3871 tests passed. `tsc --noEmit`, ESLint on touched
files, `tenant-audit-census`, `check-engine-double-contract` green.
## Red-line read
Run in this thread by a separate review pass (maintainer's instruction:
「你自己有fable,自己审就可以了吧?」). Round 1: PASS-WITH-CHANGES, one must-fix (an
org-less dispatch could take the first of two answering rows) and five
should-fix (a conflicted organization skipped turning a 422 into a
dispatch; the door's holder-to-entry match; revoke 404 vs read 409;
revoke under two holders; the changeset's "as before"), all taken; M5,
M6 and S3 accepted. Round 2: PASS-WITH-CHANGES, one should-fix (an
unstamped entry must be its durable holder's instance, or the backfill
bind loses its row), taken. Round 3: PASS. Carried to 3b: re-key the
grant handles by `(package, name)` and evaluate the handle's package per
read, before any PR lets two instances of one name live.
These red-line reads ran before the 2026-11-14 04:37Z pause of seat-run
contract reviews. This PR is opened as a draft and owes a contract
review at **TIER_DEFAULT (widening)** from the new review agent before
it is marked ready.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L9qibzKCovWpJoMZD6U3NT
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent d4fbb4d commit 199e362
11 files changed
Lines changed: 947 additions & 72 deletions
File tree
- .changeset
- content/docs/automation
- packages/services/service-automation/src
- oauth2-grant
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
757 | 757 | | |
758 | 758 | | |
759 | 759 | | |
760 | | - | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
761 | 764 | | |
762 | 765 | | |
763 | 766 | | |
| |||
0 commit comments