You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit adab62a
Browse filesBrowse the repository at this point in the historyBrowse files
fix(service-datasource)!: the datasource admin door asks the walled-catalog verdict on every row-writing verb, as the /meta door does (#31005)
security#1 · os-tesla · session_01L9qibvynRbCtMndW8EHNGc
Clause-②: no (narrowing) — under the `isolated` and `group` tenancy
postures, creating, changing or removing a datasource at the datasource
admin routes (`POST /api/v1/datasources`, `PATCH` and `DELETE
/api/v1/datasources/:name`, `POST
/api/v1/datasources/:name/migrate-credential`) is a write to the
environment's metadata catalog, and it is the platform operator's, as
every other write to that catalog is.
Metadata-protocol: none
Skills-docs: none — no `skills/**` text teaches the datasource admin
routes or who may call them (0 hits for `api/v1/datasources` and
`migrate-credential` under `skills/`; `datasource` itself is named
there, the positive control); the rule is stated in the docs this diff
updates (`content/docs/deployment/tenancy-modes.mdx`,
`content/docs/data-modeling/external-datasources.mdx`).
## 维护者速读
- 改了什么:数据源管理路由中写数据源记录的四个动作(创建、修改、删除、迁移凭据),在 `isolated` / `group` 租户姿态下,与
`/meta` 写入门问同一个“围墙目录写入”裁决(`walledCatalogWriteVerdict`,类型 `datasource`)。
- 为什么改:数据源是环境元数据目录里的一个 `datasource` 条目,与 `PUT /meta/datasource/:name`
写的是同一条记录;围墙姿态下这个目录只归平台运营方(与引擎自身)写,所以这道门与 `/meta` 门读同一条裁决、给同一个状态码与同一句话。
- 风险与回滚:围墙姿态下,平台运营方以下、持有 `manage_platform_settings` 的调用方(包括组织内的
`admin_full_access` 持有人)写数据源改为 `403
PERMISSION_DENIED`,什么都不存、不封存凭据、不重建连接池;`single`
与未注册租户服务的部署不变;列表、读取、驱动目录、两种连接测试、远程表列表与对象草稿不变;回滚即还原本 PR,已存的数据源不受影响。
-
先看:`packages/services/service-datasource/src/admin-routes.ts`(`requireDatasourceAdmin`
的 `catalogWrite` 段与
`walledVerdictTenancyPosture`,以及四条写路由的调用)、`packages/services/service-datasource/src/__tests__/admin-routes-tenancy-posture-admission.test.ts`(§1
改用运营方作写入对照,§8 / §8b
新矩阵)、`packages/services/service-datasource/src/__tests__/datasource-update-kept-pool-stores-nothing.test.ts`(被拒的
PATCH 不动存储与连接池)。
- 两分钟验证:`pnpm --filter @objectstack/service-datasource exec vitest run
src/__tests__/admin-routes-tenancy-posture-admission.test.ts
src/__tests__/datasource-update-kept-pool-stores-nothing.test.ts`,预期 2
个文件 73 个用例全部通过。
- 需要你做的:无,席位落地。
## What changes
- **The rule.** Under `isolated` and `group` every organization shares
the environment's metadata catalog, and a write to it is admitted only
for the platform operator and for the engine's own writes (ADR-0131 D3,
D12 items 7–8, D11). A datasource is a `datasource` item of that
catalog, the record `PUT /api/v1/meta/datasource/:name` writes. The
datasource admin door now asks the walled-catalog verdict on every
row-writing verb, as the `/meta` door does: create, update, remove and
migrate-credential each ask `walledCatalogWriteVerdict`
(`@objectstack/metadata-core`) for the type `datasource`, after the
`manage_platform_settings` capability gate and before the datasource
service is looked up. The verdict is reused, not restated.
- **The answer.** A refused call answers `403 PERMISSION_DENIED` with
the verdict's sentence for a `datasource` item, the sentence the `/meta`
write doors answer for the same record, naming the posture. Nothing is
stored, no secret is sealed or removed, and no pool is rebuilt or
evicted.
- **The posture judged.** On a host whose kernel has the async service
accessor, the verdict judges the same effective posture the door's
admission already resolved, so one read of the `tenancy` service decides
both. On a host without that accessor, where the admission does not read
the posture, the verdict reads a registered `tenancy` service
synchronously; a service that is not registered reads as the
no-`tenancy` composition, inert as `single` is.
- **Unchanged.** The platform operator writes datasources under a wall
as before. Under `single`, and with no `tenancy` service, every caller
holding `manage_platform_settings` writes datasources as before.
Listing, reading, the driver catalog, the draft probe (`POST
/datasources/test`), the saved-datasource probe (`POST
/datasources/:name/test`), the remote-table listing and the object draft
write no datasource record and do not ask the verdict; the object draft
hands back a definition the caller saves through the `/meta` doors,
which ask it themselves. The capability gate still answers first.
- **Docs and doc comments.** The admin routes' docblock states the rule
in place of the old "no posture arm" note. `deployment/tenancy-modes`
and `data-modeling/external-datasources` state who writes a datasource
under a wall. The `walledCatalogWriteVerdict` doc comment and its ADR
anchor name the datasource admin routes among the doors that ask it, and
a new ADR-0131 anchor holds the rule on `admin-routes.ts`.
## Tests
- `admin-routes-tenancy-posture-admission.test.ts` (real `ObjectKernel`,
real `resolveAuthzContext`, API keys over the shipped permission-store
shapes):
- §1's write controls under `isolated` are now the platform operator's
key (declared in `OS_PLATFORM_OWNER_EMAIL` over a verified row); they
previously pinned a member's create and delete landing under `isolated`.
- §8, for `isolated` and for `group`, each of the four verbs: refused
for a current member holding `manage_platform_settings` (`403`,
`PERMISSION_DENIED`, the message equal to the verdict's message for
`datasource` on that posture, the service method never called, the store
unchanged); refused for an organization's `admin_full_access` holder;
allowed for the platform operator, and the write lands. The capability
refusal still answers first for a caller without the capability. The
seven routes that write no record still answer `200` for the member.
- §8b, under `single` and with no `tenancy` service: each of the four
verbs is served for the member and the write lands.
- `datasource-update-kept-pool-stores-nothing.test.ts` (the real
`DatasourceAdminServicePlugin` and `ExternalDatasourceServicePlugin`
behind the real routes, the real secret binder, a driver factory that
records every pool it builds): under `isolated` and `group` a PATCH
carrying a new secret and a new host by the entitled caller is refused
with the verdict's status, code and sentence; the stored record and the
`sys_secret` ids are byte-equal to before, no pool is built, and the
serving pool still answers its test. Control: the same PATCH under
`single` stores the new host and builds one new pool. This rig has no
`getKernel`, so it also covers the synchronous posture read.
## Acceptance notes
- **Where the rule sits.** At the door, beside the capability gate,
before `resolve()`: the service below receives the record, not the
caller's rung, and the door is where this family's admission already
lives. One option on the shared floor (`catalogWrite`) is passed by
exactly the four row-writing routes.
- **Which verbs write.** Decided from the code: the service's write
seams (`putDatasourceRecord`, `deleteDatasourceRecord`, the secret
writes and the pool seams) are reached only from `createDatasource`,
`updateDatasource`, `removeDatasource` and `migrateCredential`.
`testConnection` (draft and saved), `listRemoteTables`,
`generateObjectDraft`, `listDatasources` and `getDatasource` reach none
of them.
- **The code.** `PERMISSION_DENIED`, the standard-catalog member this
family already answers for a 403, and the code the dispatcher `/meta`
door answers; the REST `/meta` door answers its grandfathered synonym
(`STANDARD_SYNONYM_WAIVERS`, ADR-0112 D3), which is not endorsed for new
code.
- **`isSystem`.** Not passed to the verdict: this family's resolution
never carries it from inbound HTTP, so the verdict's engine admission is
unreachable here, as before.
- **Breaking, patch.** An accept-set narrowing under a walled posture
only; no key of any schema moves and nothing stored changes, so the
package takes a patch with a BREAKING banner (ADR-0087 marker
`not-required (no-migration-prescription)`).
- **The metadata-core edit is comments only** (the verdict's door list),
so it publishes no behaviour and carries no changeset of its own.
## Verification
All readings below are at head
`b99ce15091cc324f14293a091741c641936cd413`, after `origin/main` was
merged in at `e304cae63f` (no conflicts; `main` had moved
`core/security`, `metadata-core`, `tenancy-modes` and a
`service-datasource` test), the closure rebuilt and every build and test
run under the shared verify lock. `main` has moved since by 14 commits,
none touching `service-datasource`, `metadata-core`, the authorization
resolver or the two docs pages (one `core/security` pin test).
<details><summary>Package tests and typecheck</summary>
- `pnpm --filter @objectstack/service-datasource exec vitest run`: Test
Files 72 passed (72), Tests 1279 passed (1279).
- `pnpm --filter @objectstack/metadata-core exec vitest run`: Test Files
23 passed (23), Tests 911 passed (911).
- The two edited pin files hold 73 of those tests (65 in the admission
matrix, 8 in the PATCH rig).
- `typecheck` for `service-datasource`, `metadata-core` and the direct
consumers of `service-datasource` (`rest`, `runtime`, `cli`, `verify`,
`dogfood`, `example-showcase`): `VERDICT command-exit 0`, every package
`Done`, 0 `error TS` lines. The package's typecheck compiles both edited
test files (`tsc --listFiles`).
- `pnpm --filter @objectstack/spec check:generated` after the merge: all
14 generated artifacts up to date.
</details>
<details><summary>Ablations</summary>
Each through `scripts/ablation-replace.mjs` (anchor hit once, blob
changed, restored blob-equal to HEAD with `git diff HEAD` empty), on the
committed tree. The pins import `../admin-routes.js` from source, so no
rebuild sits between the mutation and the run. The four route ablations
were read at `56a424acf3` (blob `c44ff35c97f1`); `admin-routes.ts` has
since changed only in a doc comment (blob `bf51f83b0cbc`). The
posture-read ablation was read at the head.
| subject | ablation | reading (73 pins) |
| --- | --- | --- |
| create | the route stops naming the type it writes | 4 failed: the
member and `admin_full_access` refusals, under `isolated` and `group` |
| update | the same, on `PATCH /:name` | 6 failed: the same four, and
the PATCH rig's refusal under `isolated` and `group` |
| remove | the same, on `DELETE /:name` | 4 failed: the member and
`admin_full_access` refusals, both postures |
| migrate-credential | the same, on `POST /:name/migrate-credential` | 4
failed: the member and `admin_full_access` refusals, both postures |
| the synchronous posture read | the verdict judges the admission
posture on every host | 2 failed: the PATCH rig's refusal under
`isolated` and `group` |
After each restore the blob equals `HEAD`'s and `git diff HEAD` is
empty; `git status --porcelain` empty after the last.
</details>
<details><summary>Derived gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` (no paths) at `b99ce15091`: 102 commands,
each run as printed with stdin from `/dev/null` and its exit code
recorded. `--ran`: 102 derived, 102 run, 0 NOT-MEASURED, 0 UNRUN; every
recorded exit is 0. Before the merge, at `f2dc54d5ea`, two first
answered exit 3 (`check:skill-examples`, `check:dual-build-cjs-loads`:
prerequisite packages outside this diff unbuilt) and answered 0 once
those were built; they were built before the run at the head.
`pnpm check:adr-anchors`: exit 0 with the new anchor.
</details>
<details><summary>Full dogfood battery at the head</summary>
`b99ce15091cc324f14293a091741c641936cd413`, the closure built at that
head, then under the lock `pnpm --filter @objectstack/dogfood test` with
no shard and no path:
- `os-verify-lock: VERDICT command-exit 0`
- Test Files 427 passed | 3 skipped (430)
- Tests 3556 passed | 41 skipped (3597)
- no failures
</details>
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(service-datasource)!: the datasource admin door asks the walled-catalog verdict on every row-writing verb, as the /meta door does
6
+
7
+
Clause-②: no (narrowing) — under the `isolated` and `group` tenancy postures, creating, changing or removing a datasource at the datasource admin routes (`POST /api/v1/datasources`, `PATCH` and `DELETE /api/v1/datasources/:name`, `POST /api/v1/datasources/:name/migrate-credential`) is a write to the environment's metadata catalog, and it is the platform operator's, as every other write to that catalog is.
8
+
Metadata-protocol: none
9
+
10
+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped and nothing at rest changes: which caller the datasource admin routes admit to a datasource write under a walled tenancy posture is all that moves, and every stored datasource stays as it is. -->
11
+
12
+
**BREAKING** accept-set narrowing at the datasource admin routes (`@objectstack/service-datasource`) under a walled tenancy posture.
13
+
14
+
-**The rule.** Under `isolated` and `group` every organization shares the environment's metadata catalog, and a write to it is admitted only for the platform operator and for the engine's own writes (ADR-0131 D3, D12 items 7–8, D11). A datasource is a `datasource` item of that catalog, the same record `PUT /api/v1/meta/datasource/:name` writes. So each datasource admin route that writes a datasource record (create, update, remove, migrate-credential) asks the walled-catalog verdict the `/meta` write doors ask (`walledCatalogWriteVerdict`, `@objectstack/metadata-core`) for the type `datasource`, after the `manage_platform_settings` capability gate and before the datasource service is looked up.
15
+
-**The answer.** A refused call answers `403 PERMISSION_DENIED` with the verdict's sentence for a `datasource` item, the one the `/meta` write doors answer, naming the posture. Nothing is stored, no secret is sealed or removed, and no pool is rebuilt or evicted.
16
+
-**Unchanged.** The platform operator writes datasources under a wall as before. Under `single`, and on a deployment with no `tenancy` service, every caller holding `manage_platform_settings` writes datasources as before. Listing, reading, the driver catalog, both connection tests, the remote-table listing and the object draft are unchanged, and the capability gate answers first, as before.
17
+
-**Who moves.** On a walled deployment, a datasource create, update, removal or credential migration by a caller below the platform operator, an organization's `admin_full_access` holder included, is refused; the platform operator performs it.
0 commit comments