Repository navigation
feat(service-automation, metadata-protocol, driver-mongodb, cli): a connector connection is unique per organization and instance (package, name) - #33199
Conversation
…tor connection unique per organization and instance (package, name) ADR-0150 D4 and D8 row R11, storage half. The maintainer's ruling: a connection is unique by package and name. - sys_connector_connection's key widens from (organization_id, connector_name) to (organization_id, connector_package, connector_name), spelled 'global' with organization_id listed, so driver-sql's widening arm replaces the old key (safe, create-before-drop) once the guard stands. - uniq_sys_connector_connection_packageless keeps the connections that name no package to one per (organization_id, connector_name), built at objectql:schema-synced as the grant guard is, on SQLite, PG, MySQL 8.0.13+, MariaDB 10.3+ and MongoDB; listed in the runtime-index preflight, os migrate duplicates and os migrate apply's steps. - A first connect that raced the backfill takes its second row back and is refused, as the old key refused it. - The R11 boot backfill leaves a row whose bind would be a second row of one key and reports it (duplicated) once a read confirms it; the dry run agrees; os migrate stored-references bind refuses it as 'duplicate'. - Declared limits: upgraded MySQL 8 keeps the old key (driver-sql reads the functional key part as an expression, as for the grant); driver-memory builds no guard. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzKCovWpJoMZD6U3NT
|
domain:server#7 · os-tesla · session_01L9qibzKCovWpJoMZD6U3NT Posted 2026-11-14T01:53Z. Red-line read run in the card thread on the maintainer's instruction, by a separate review pass: design round, code round 1, code round 2 (delta). Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
Findings by round: design PASS-WITH-CHANGES (M1 to M7, S1 to S9, taken). Code round 1 PASS-WITH-CHANGES, no must-fix, seven should-fix, all taken. Round 2 PASS, one should-fix (foreign messages on the new count and delete) and two changeset notes, taken. Open at this head: none. Implemented-by: VERDICT: PASS |
📓 Docs Drift CheckThis PR changes 4 package(s): 4 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 51 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 4b798b46baca8885aec33cdcf9c391e1ca9d0403 && git checkout 4b798b46baca8885aec33cdcf9c391e1ca9d0403
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 67274acad689d5be75d5bfc5007f4fb9396aa907 f5d2a9e370b3bd8d92a4fb1b52f7830f394dd230 && git checkout -B drift-repro 67274acad689d5be75d5bfc5007f4fb9396aa907 && git merge --no-ff f5d2a9e370b3bd8d92a4fb1b52f7830f394dd230
node scripts/docs-audit/affected-docs.mjs --json 67274acad689d5be75d5bfc5007f4fb9396aa907
|
… asserts; tenant-audit census counts the take-back delete The take-back delete in ConnectorConnectionStore#connect is one more write call site (elevated, against sys_connector_connection): census regenerated and the page's prose figures moved with it. The race pin's double opens its update and delete with assertEngineUpdateDispatch / assertEngineDeleteDispatch, and the engine-double ledger records it. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzKCovWpJoMZD6U3NT
…rrorText callers, pinned by its own sentinel test Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzKCovWpJoMZD6U3NT
…nector connection guard beside the grant's Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzKCovWpJoMZD6U3NT
|
domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx Delta review over record 6869740710 (head Contract reviewServed-tier: ① Derived judgmentsThis is a delta over 6869740710 at 2dfdbbe. The red lanes at 2dfdbbe were the engine test-double contract gate (inside Lint · ESLint), the tenant-audit census gate (inside Lint · repo & tooling gates), and the umbrella Lint and TypeScript lanes that roll them up. Type Check · workspace was cancelled, not failed. The delta answers those gates and the three CLI count pins. No assertion is loosened.
② Semver levelThis is a delta over 6869740710 at 2dfdbbe. The only non-test source change is in ③ Boundary flagsThis is a delta over 6869740710 at 2dfdbbe. Nothing in the delta touches the declared limits, the carry-forward to 3a-ii, or the accepted nits in that record. Nothing here contradicts its PASS. The race pin is stronger, not weaker. Check-runs on Findings: none (must-fix 0, should-fix 0, nit 0). Implemented-by: VERDICT: PASS |
|
domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx 维护者速读 · PR #33199 @
|
… door and the OAuth callback read and write one instance by its package and name (objectstack-ai#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 objectstack-ai#31699 Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 改了什么:连接存储、连接门(读 / 开始 / 回调 / 撤销)、OAuth 回调和派发都按「包 + 名字」读写连接。开始连接时把实例的包记进待完成授权,回调只完成那个包的实例,不再按名字重新解析。没有包的旧连接行,只在名字的持久解析指向该包时才算它的,该包重新连接时就地认领。 - 为什么改:ADR-0150 D4,objectstack-ai#31699 PR 3a 的第二半(第一半 objectstack-ai#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 objectstack-ai#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 objectstack-ai#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>
Requested by Tesla · project thread
Part of #31699
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
sys_connector_connection的唯一键从(organization_id, connector_name)加宽为(organization_id, connector_package, connector_name)。没有包的连接(环境自建或代码注册的连接器实例)靠一条运行时守卫索引uniq_sys_connector_connection_packageless继续保持每个组织一条。守卫立住之后,旧键在下一次安全同步时被替换(先建后删,safe),中间任何时刻都有唯一规则。packages/metadata-protocol/src/migrations/connector-connection-packageless-index.ts(从 plugin-security + runtime: the grant, clone and activation doors take a permission set's package and report a two-holder name with its candidates (ADR-0150 D3/D8; before #31698 PR-2) #32164 的授权守卫复制,只换常量和措辞)、packages/services/service-automation/src/connector-connections.ts(首次连接与回填竞态的回收)、stored-reference-package-backfill.ts(duplicated)。What changes
sys_connector_connectiondeclares{ fields: ['organization_id', 'connector_package', 'connector_name'], unique: 'global' }. Spelled'global'withorganization_idlisted, as plugin-security + runtime: the grant, clone and activation doors take a permission set's package and report a two-holder name with its candidates (ADR-0150 D3/D8; before #31698 PR-2) #32164 spelled the grant's, becausedriver-sql's widening arm (widenedUniqueReplacements) does not fire for'organization'(measured: that spelling plans a destructive orphan drop). The arm keeps the old key until a partial guard on exactly(organization_id, connector_name)stands, then plans onereplace_unique_index,safe, create-before-drop.uniq_sys_connector_connection_packageless, built atobjectql:schema-syncedon every kernel that runs the table's DDL (metadata-protocolplugin.ts): partial index on SQLite and PostgreSQL, functional digest on MySQL 8.0.13+, INVISIBLE generated column on MariaDB 10.3+,RUNTIME_OWNED_UNIQUESon MongoDB (keyed(connector_name), the key Mongo materialized for the old declaration). Listed inruntime-index-preflight.ts(soos migrate duplicates) and in the CLI'sschema-sync-indexes.ts(soos migrate plan/apply). The module is a copy ofuser-permission-set-packageless-index.tswith the table's constants and wording.duplicated), and the walk goes on; the dry run agrees.os migrate stored-references bindrefuses it asduplicate.content/docs/deployment/cli.mdx(runtime-owned indexes, old-key retirement, MySQL limit, the bind refusal);content/docs/automation/connectors.mdx(one connection per organization and instance).Why
ADR-0150 D4: a connector instance is identified by
(package, name), and D8 row R11 gives the connection its package column. The maintainer ruled on #31699 that a connection is unique by package and name, so one organization can connect both packages' instances of one name once the backstop narrows (the last PR of #31699).Verification
service-automationconnector-connection-guard-at-schema-sync.test.ts, realObjectQLPlugin, SQLite, the shipped object): a second package-less connection written from astart()beforekernel:readyis refused, two packages' connections of one name are admitted, a second of one package's is refused; withbootPhaseHooks: falsetoo; a dropped guard is rebuilt by the next pass. Ablation (guard call removed from the hook): 3 of 5 red.driver-sqlsql-driver-widened-connection-key.test.ts: SQLite (no guard → old key kept; guard → one safe replace; re-plan empty) and live PostgreSQL 16 locally; the MySQL cell pins the declared limit (old key kept) and runs onmain.main.driver-mongodb4 tests (live mongod not reachable here);driver-memory3 (declared limit).connector-connections.test.ts(ablation red). Backfill: 3 new pins instored-reference-package-column.test.ts(dry run agrees, unconfirmed violation and an R8 violation end the pass; each red under ablation).@objectstack/service-automation3843 passed (before the review round; affected files re-run, 409 passed),@objectstack/metadata-protocol339 files passed. CLI:schema-sync-indexes,duplicates.contract,stored-references,apply.schema-sync-indexes,schema-migrate.grant-guardgreen. Build with declarations,tsc --noEmitandcheck:test-typecheckgreen for every touched package.Red-line read
Run in this thread by a separate review pass (maintainer's instruction: 「你自己有fable,自己审就可以了吧?」). Design round: PASS-WITH-CHANGES (M1–M7, S1–S9, taken). Code round 1: PASS-WITH-CHANGES, no must-fix, 7 should-fix (a racing first connect could leave two rows; dry run vs real run; backfill catch confirmation; docs and changeset wording), all taken. Round 2 (delta): PASS, one should-fix (foreign messages on the new count and delete) and two changeset notes, taken. Carried to the next PR: the store reads and counts by package.
Human Minimum
packages/specholds no runtime logic.pnpm lintpasses.main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01L9qibzKCovWpJoMZD6U3NT