Skip to content

Commit 27c0b20

Browse files
feat(approvals): platform_admin approver type for a deployment's own packaged flows (#34300)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbCpddLFmKzR39wJWZpkRMCi)_ Fixes #34218 Clause-②: yes (widening) Metadata-protocol: added The widening: `ApproverType` accepts a new member, `platform_admin`, which takes no `value`. Nothing accepted before is refused. The narrowing that comes with it applies only to the new member: it is refused outside the running body of a `source: 'code'` package's flow. ## 维护者速读 - 改了什么:审批节点新增审批人类型 `platform_admin`,把一步交给平台管理员处理;"只有该类型能打开平台管理员槽位"这条规则在决策、越权、收件箱各入口实际读取的待审名单上成立;本轮起,请求在开启时记下"由 `platform_admin` 步骤打开了该槽位",各入口只在带此记录的请求上认这个槽位。 - 为什么改:平台自带的流程(cloud#4632 在等)需要平台管理员审批;合同审核 6912724496 与复审 6916583417 要求该规则在各入口读取的名单上、对每一个请求都成立。 - 风险与回滚:只有部署在代码里注册的包的流程能用它,别处一律拒绝开启;含该槽位的请求,组织管理员不能越权代审;不带开启记录的请求上,各入口不认该槽位,存量数据不改写、无需迁移;回滚即撤这个 PR。 - 先看:`approval-service.ts` 的 `pendingSlateOf` 与 `syncApproverIndex`(开启记录与各入口的读法),`approver-address.ts` 的 `pendingSlateAsDoorsRead` 与 `readsAsPlatformAdminAddress`,再看 `stepRunsInArmedBody`。 - 两分钟验证:`pnpm --filter @objectstack/plugin-approvals exec vitest run src/platform-admin-approver-34218.test.ts`,预期 52 条全过。 - 需要你做的:无,席位落地。 ## What changes - **spec** (`packages/spec/src/automation/approval.zod.ts`): `ApproverType` gains `platform_admin`. Its value binding is `auto` (no `value`), it is not org-scoped, and it is in `NON_AUTHORABLE_APPROVER_TYPES`, so no designer offers it. The `.describe()` text says who may use it. The generated reference (`content/docs/references/automation/approval.mdx`) is regenerated. - **expansion** (`approval-service.ts`, `approver-address.ts`): the type expands to ONE address slot, `platform_admin:*`. No administrator is enumerated, no one is notified, and the slot grants no record read. `slateNamesAPerson` counts it, so `onEmptyApprovers` does not treat the slate as empty. - **admission**: `actingAddresses` adds the slot for a caller whose `platformAdmin` flag is set, and `resolveActor` admits a caller naming the slot. Both read `hasPlatformAdminStanding(engine, callerId)` from `@objectstack/core` at that moment, memoized per request context. The predicate is not re-derived, it has no org scope, and it never reads the session's posture. A decision records the person (`actor_id`) and the slot (`acted_as`), in the #21411 shape. - **only the typed approver opens the slot, on the slate the doors read** (`approver-address.ts`, `approval-service.ts`): `readStoredSlate` is the one reading of a stored slate. `readsAsPlatformAdminAddress` and `withoutPlatformAdminAddress` judge the slot on what that reading answers, for any entry, text or not: an entry that is not text is judged as the text the stored slate holds for it. The rule is applied wherever a slate is resolved or rewritten: each approver entry in `expandApprovers` (the approvers, the fallback slate, the administrators' slate, and the tally's legacy re-resolution), an out-of-office hop in `applyOooDelegation` (the slot stays with its approver), the SLA hand-over's holders, and `reassignTargetRefusal` (reassign, and the SLA's literal target), which now judges the slot first. An entry that resolves to the slot adds nothing and logs one warning naming the entry. A vote's rewrite of the slate is a subset of the open-time snapshot, which these rules built. - **the doors honour the slot only on a request a `platform_admin` step opened** (`approval-service.ts`, `approver-address.ts`): when a request opens, its config snapshot records `__platformAdminSlotOpened: true` exactly when the step names the `platform_admin` type (admitted at node entry) and the slate holds the slot. Only the open path writes it, and a key of that name handed in with a step's config is dropped (`ApprovalNodeConfigSchema` declares none). Every door reads the pending slate through one reader, `pendingSlateOf` (`pendingSlateAsDoorsRead`), which keeps the slot only on a request that carries the record: the served request and its per-viewer flags, the decision, send-back, comment, hand-off, reminder and override admissions, the action-link minting, the SLA hand-over, and the approver index behind the inbox (`syncApproverIndex` on every write that sets the slate, and the rebuild at plugin start). The stored text is not rewritten. - **who may name it**: at node entry, `platformAdminApproverRefusal` reads the armed body's package through `flowPackageOf` (`armedFlowPackage`), never `packagedFlowOwner`. A registry row with `source: 'code'` is admitted. A row with any other source is refused. With no row, the residual-owner reading applies: `residualOwnerSource` `'code'` admits, and anything else refuses. The fallback slate is checked the same way. The origin is answered for the body whose step is being opened: the approval executor hands the node it runs (`approval-node.ts`), and `stepRunsInArmedBody` opens the step only when the body armed under the flow's key (the run's slot through `getFlowSlot`, else the bare name through `getFlow`) holds that node object. A refusal throws `FORBIDDEN: …` before anything is written. - **override**: on a request whose pending slate holds `platform_admin:*`, the #3424 tenant-admin (organization administrator) override arm is withheld at every override admission: decide, reassign, recall, and the `viewer.can_override` flag they agree with. `isOverrideActor` takes the slate from those admissions only (the read grants pass none), and the slot test is `slateHoldsPlatformAdminAddress`. The platform-admin override arm and the system context are unchanged. Override is whole-request, so on a mixed slate the guard holds for the whole request, and the ordinary slot holder still decides as a slot holder. - **moving the slot**: reassigning the platform slot itself needs platform standing now, the platform override, or the system. - **save door** (`packages/lint`): `validateApprovalApprovers` takes `{ atSaveDoor }`. The runtime publish gate passes it (`ctx.runtimeWriteType !== undefined`), and there a `platform_admin` approver, or fallback approver, is an error, `approval-approver-platform-admin-authored`. `os lint` and the other CLI commands know the type and refuse nothing. The rule id is exported from the barrel. - **docs**: `content/docs/automation/approvals.mdx` gains a "Routing to the platform administrators" section. ## Tests `packages/plugins/plugin-approvals/src/platform-admin-approver-34218.test.ts`, 52 tests: real ObjectQL over SQLite, the real `hasPlatformAdminStanding`, a real package registry with code, marketplace and authored packages and recorded residual owners, and (for the origin pins) the real `AutomationEngine`. - The slot opens and tells no one. A grant admin and the verified configured owner (no grant row) each find it in the inbox and decide it as an ordinary approver (`actor_id` the person, `acted_as` the slot, not an override). - A member of the request's organization takes no slot. An organization administrator takes no slot and no override (decide, reassign, recall refused; `viewer` `{ can_act: false, can_override: false }`); another organization's administrator cannot decide. Mixed slate: the organization administrator is withheld whole, the ordinary holder decides. CONTROLS: the tenant arm is unchanged on a slate without the slot; the platform override arm is unchanged on it. - A revoked administrator cannot decide a request opened before the revocation. - Refused at node entry, writing nothing: a flow authored in the environment, an environment override of a host flow, a marketplace package's flow, an authored package's, an unrecorded package's, a marketplace residual's, and a fallback slate naming the type. A residual owner a code door recorded is admitted. - **Cases 1 to 23: no route but the typed approver opens the slot on the slate the doors read.** Each case resolves or rewrites a slate on one route (approver entries of each kind, record values, directory values, an out-of-office delegation, a fallback slate, the administrators' slate, a vote, the SLA hand-over, a hand-off target, a queue's members, an expression yielding a list of people) and asserts, for cases 7 to 23, every door: the request as served, the inbox after the approver index is rebuilt from the stored slate, the decision admission for a caller in platform standing naming the slot, and the override admission (the tenant arm stands). - The slot test is total: each entry that is not text is judged as the text the stored slate holds for it. - **The doors honour the slot only on a request that records a `platform_admin` step opened it.** CONTROL: a request a `platform_admin` step opened records it, and every door reads the slot (served, listed for a platform administrator, the tenant arm withheld, decided under the slot). A request whose snapshot carries no record, its stored slate unchanged: no door reads the slot (served without it, not listed, decision under it refused, the tenant arm stands), and its people decide as before. On such a request, a vote that rewrites the slate indexes no slot for the inbox. A step's config cannot carry the record: the spec schema refuses the key, and the open path drops it. - The platform's place on a mixed slate moves only for a platform administrator or the system. - **The origin is answered for the body whose step is being opened, on the real flow engine:** a real run of a code package's flow opens on the slot, the origin read through the run's slot (`getFlowSlot`); on that read and on the bare read (`getFlow`), the armed body's own step opens and a step the armed body does not hold is refused, writing nothing. The stand-in pins for the same rule stay. - The save door refuses the type; `os lint` refuses nothing. CONTROL: a `user` approver opens as before and the platform administrator takes no slot on it. Ablations (each through `scripts/ablation-replace.mjs` on the pin file, source-imported so no dist leg; every leg restored to the HEAD blob with `git diff HEAD` empty, and no marker left): - On head 5c86710, in one lock hold after the typecheck: - (S3 doors) `pendingSlateAsDoorsRead` keeping the slot without the record: `Tests 2 failed | 50 passed (52)`, the two requests without the record, e.g. `AssertionError: expected { Object (served, listed, ...) } to deeply equal { served: [ 'u_alice' ], …(2) }`. The CONTROL stays green. - (S3 index) `syncApproverIndex` indexing the slot without the record: `Tests 1 failed | 51 passed (52)`, the vote on a request without the record, `AssertionError: expected [ …(6) ] to not include 'areq_…'`. - (S3 record) the open path keeping a record handed in with the config: `Tests 1 failed | 51 passed (52)`, `AssertionError: expected { approvers: [ { …(2) } ], …(2) } to not have property "__platformAdminSlotOpened"`. - (N7) the slot test without the text coercion: `Tests 1 failed | 51 passed (52)`, the totality pin. - (S2) `stepRunsInArmedBody` answering yes without asking the armed body: `Tests 4 failed | 48 passed (52)`, the real-engine slot read and bare read and the two stand-in pins, e.g. `AssertionError: promise resolved "{ …(25) }" instead of rejecting`. - On head 275b45c: (M1) `readsAsPlatformAdminAddress` reverted to the earlier judgement of the slot: `Tests 15 failed | 30 passed (45)`, exactly cases 7 to 21, e.g. case 21 `AssertionError: promise resolved "{ request: { …(31) } }" instead of rejecting`. Earlier rounds' ablations (standing check, decision-only standing check, source gate, tenant-arm guard, save door both ways) are recorded in the dev report on the card at 21dd241 and in the hand-off; their anchors are unchanged on this head. ## Fix rounds - Round 1 (`8cb89ac5` to `084419d6`): the type, its one slot, admission by live platform standing, the origin gate at node entry, the save door, pins and docs. - Round 2 (`5282972a`, `cffa4a47`, seat ruling Q1 = B): the tenant-admin override is withheld from a request whose slate holds the platform slot, a mixed slate whole. - Round 3 (`0a0baffc` to `ba113a3f`, ruling 6904694980 point 2 as amended by 6904772436, hand-off 6912407414): only the typed approver opens the slot on the resolved slate, and the origin is answered for the body whose step is being opened. - Round 4 (`275b45c8`, contract review 6912724496): the rule holds on the slate the decision, override and inbox doors read, for every way a slate is resolved or rewritten; the origin rule is pinned on the real flow engine, on both reads. - Round 5 (`f1a021ef`, `5c867107`, contract review delta 6916583417): the doors honour the slot only on a request that records a `platform_admin` step opened it; the slot test is total for entries that are not text; pins for a queue and an expression yielding a list of people. ## Acceptance notes - **The slot stands in for the card's "pending approvers" wording.** The request stores one address, `platform_admin:*`, as its pending approver, the way `position:NAME` is stored. The administrators are never listed onto it. - **Spelling `platform_admin:*`, not bare `platform_admin`.** The readers tell an address from a person by the colon, so a bare word would read as a user id. The `*` says it names no one. - **Organization administrators (seat ruling Q1 = B).** They take no slot, and the #3424 tenant-admin override is withheld from any request whose slate holds `platform_admin:*`, a mixed slate whole. The platform-admin override arm is unchanged. The type is new, so no served answer moves. - **Requests without the record.** The doors honour the platform slot only on a request that records a `platform_admin` step opened it. A pending request without that record keeps its stored text as it is, so nothing is migrated: no door reads the slot on it, and its other approvers, and the override arms as on `main`, decide it. - **Inputs accepted on `main` whose behaviour moves (rule-level):** an approver entry, out-of-office delegate, SLA target or hand-off target that resolves to the platform slot now adds nothing to the slate (a hand-off or SLA target is refused, and the slate stays). On `main` such an entry left a literal on the slate that no acting path admitted, so no request could be decided through it. - **Inbox reads**: one extra `resolveUserAuthzGrants` read per caller per request context, memoized. The server inbox listing still applies the caller's active-organization wall (nit N3, for the cloud lane to confirm before cloud#4632 relies on it). - A `value` on `platform_admin` is ignored, not refused. - **Follow-ups, not built here:** nit N3 (above) is #34409; nit N6 (a deployment where nobody has platform standing opens the step on a slot nobody can take, and nothing warns) and the slot's raw display label (nit N4) are #34410. - **Files beyond the claim's literal list, ratified within the surface:** `approver-address.ts`, `packages/lint/src/authoring-rules.ts`, `packages/lint/src/index.ts` (seat ruling Q2 = A), and `approval-node.ts` (hand-off 6912407414). - **cloud#4632 consumes this.** The cloud lane was asked to confirm that its packaging registers as `source: 'code'`. A marketplace or authored registration is refused at node entry by design. ## Verification <details><summary>Commands and verdicts for head 5c86710</summary> - `pnpm --filter @objectstack/plugin-approvals typecheck` (includes `check:test-typecheck`): exit 0. - `pnpm --filter @objectstack/plugin-approvals test`: Test Files 121 passed (121), Tests 1704 passed (1704). The pin file alone: Tests 52 passed (52). - Both ran in one verify-lock hold on 5c86710, the suite after every ablation leg was restored (`git diff HEAD` empty, no marker in either file). - `dispatch-gates --commands`: 118 derived (the same list as on 275b45c); all 118 run, each exit 0. `--ran` reconciliation: 118 derived, 118 run, 0 NOT-MEASURED, 0 UNRUN. - `dispatch-gates --tier`: exit 0, no path-derived mandate; clause-② suspect surface `approval.zod.ts`, as declared. Changed lines 1570, under the 3000 threshold. - CI on 5c86710: 68 check-runs, 56 success, 10 skipped, 2 failure: `Test Core (3/8)` and its aggregate `Test Core`. The one failing test is `@objectstack/mcp` `src/mcp-file-tools.test.ts` "out of CPU budget on the worker: the pages read so far, truncated, with the budget note, as in-process", a 30 ms CPU-budget read on a worker pool that read no page (`content: 'none'`). It is not this PR's: `@objectstack/mcp`'s workspace dependency closure (16 packages) does not include `@objectstack/plugin-approvals`, the only package this round changed; the same shard passed on 275b45c; and the file passes on 5c86710 locally (Tests 47 passed (47)). A rerun of that job is the seat's call. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FEkQ5kgF3mo9f7LXuv5hac <!-- signed: repo:objectstack#1 · os-project-manager · session_01FEkQ5kgF3mo9f7LXuv5hac --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 18194fb commit 27c0b20

11 files changed

Lines changed: 1518 additions & 52 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/plugin-approvals': minor
4+
'@objectstack/lint': minor
5+
---
6+
7+
feat(approvals): a `platform_admin` approver type routes a step to the platform administrators, from the deployment's own packaged flows only
8+
9+
Clause-②: yes (widening)
10+
Metadata-protocol: added
11+
12+
The widening: `ApproverType` accepts a new member, `platform_admin`, which takes no `value`. Nothing accepted before is refused. The narrowing that comes with it applies only to the new member: it is refused outside the running body of a `source: 'code'` package's flow.
13+
14+
`{ type: 'platform_admin' }` on an approval node addresses the deployment's platform administrators: the people `hasPlatformAdminStanding` answers yes for, which covers a holder of the cross-tenant `admin_full_access` grant and a verified account whose email `OS_PLATFORM_OWNER_EMAIL` declares.
15+
16+
- The step opens on ONE address slot, `platform_admin:*`, that names no person. Nobody is enumerated, nobody is notified, and the slot grants no record read. `onEmptyApprovers` does not treat the slate as empty.
17+
- At the inbox and at every decision, the server asks whether the caller has platform-administrator standing at that moment, from the stored rows and never from the session's posture. A caller who has it decides as an ordinary approver, and the decision records the person (`actor_id`) and the slot (`acted_as`). A revoked administrator cannot decide, also on a request opened before the revocation. An organization administrator takes no slot. The #3424 tenant-admin override is withheld from a request whose slate holds `platform_admin:*`, including a mixed slate: an override decides the whole request, so the guard covers the whole request. Its ordinary approvers still decide as usual. The platform-admin override is unchanged.
18+
- Only the `platform_admin` approver type opens the slot, on the slate as the decision, override and inbox doors read it: no other way a slate is resolved or later rewritten opens it. A request records, when it opens, that a `platform_admin` step opened its slot, and the doors honour the slot only on a request that carries that record. Moving the slot to someone else needs the platform's own standing, the platform-admin override, or the system.
19+
- The new member is accepted only in the running body of a flow shipped by a package the deployment registers in code (registry `source: 'code'`, or a residual owner a code door recorded). The origin is answered for the body whose step is being opened, in every run state. Anywhere else the node refuses to open, fails closed and writes nothing: a flow authored in the environment, an environment override of a packaged flow, and a marketplace or authored package's flow. The runtime save door refuses an active flow naming it with `approval-approver-platform-admin-authored`. `os lint` knows the type and refuses nothing, because it cannot know which door will register a package. No designer offers the type.
20+
21+
Nothing to migrate.

‎content/docs/automation/approvals.mdx‎

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,10 @@ Only `approvers` is required on the node; everything else has a default
433433
(`behavior: 'first_response'`, `lockRecord: true`, `maxRevisions: 3`).
434434

435435
Approver entries resolve by kind — `position`, `user`, `field`, `manager`,
436-
`team`, `department`, `org_membership_level`, `queue`, and `expression`
437-
(described in the [callout above](#3-the-approval-node) and in
438-
[Dynamic approvers](#dynamic-approvers-3447)); `org_membership_level` is the
436+
`team`, `department`, `org_membership_level`, `queue`, `expression` and
437+
`platform_admin` (described in the [callout above](#3-the-approval-node) and in
438+
[Dynamic approvers](#dynamic-approvers-3447), and `platform_admin` in
439+
[Routing to the platform administrators](#platform-admin-approvers)); `org_membership_level` is the
439440
one that silently resolves to nobody when it's mistaken for a business
440441
hierarchy. A `queue` entry names an ownership queue by its machine name — one
441442
an installed app declares, or one of the organization's own — and resolves to
@@ -454,6 +455,51 @@ A `position` or `queue` name is not checked when the flow is saved: positions an
454455
queues are runtime data an administrator adds and removes, so a name nobody holds
455456
yet saves, and it is resolved when the run reaches the node.
456457

458+
#### Routing to the platform administrators [#platform-admin-approvers]
459+
460+
`{ type: 'platform_admin' }` routes the step to the deployment's **platform
461+
administrators**: the people with platform-administrator standing, which is a
462+
cross-tenant `admin_full_access` grant or a verified account whose email the
463+
deployment declares in `OS_PLATFORM_OWNER_EMAIL`. It takes no `value` and no
464+
`organization`.
465+
466+
- **One slot, nobody listed.** The request opens on one slot,
467+
`platform_admin:*`, that names no person. At every inbox read and every
468+
decision, the server asks whether the caller has platform-administrator
469+
standing at that moment. A caller who has it sees the request under
470+
"My Pending" and decides it as an ordinary approver, and the decision records
471+
that person. A caller whose standing was revoked cannot decide it, even if
472+
the request opened before the revocation. An organization administrator
473+
neither takes the slot nor overrides the request: the tenant admin override
474+
below is withheld from any request whose slate holds `platform_admin:*`,
475+
including a mixed slate that also names ordinary approvers. An override
476+
decides the whole request, so a mixed slate is withheld whole, and its
477+
ordinary approvers still decide it as usual. The platform admin override is
478+
unchanged.
479+
- **Only this type opens the slot.** The rule holds on the slate as the
480+
decision, override and inbox doors read it: however else a slate is resolved
481+
or later rewritten, the slot is not opened through it. A request records,
482+
when it opens, that a `platform_admin` step opened its slot, and the doors
483+
honour the slot only on a request that carries that record. Moving the slot
484+
to someone else takes a platform administrator, the platform admin override,
485+
or the system.
486+
- **Nobody is told.** The slot names no person, so opening the request sends
487+
no notification, and the slot grants no read of the record. The request does
488+
not count as an empty slate, so `onEmptyApprovers` never replaces it with
489+
the organization's administrators.
490+
- **Only the deployment's own packaged flows may use it.** The approval node
491+
opens on this type only when the flow body it runs ships in a package the
492+
deployment registers in code (registry `source: 'code'`). The origin is
493+
answered for the body whose step is being opened, in every run state. Anywhere else, the
494+
node fails with a `FORBIDDEN:` error that says why, and writes no request.
495+
That covers a flow authored in the deployment, an environment override of a
496+
packaged flow, and a flow from a package installed from the marketplace or
497+
created in the deployment. Saving an active flow that names the type, in
498+
Studio or through `/meta`, is refused with
499+
`approval-approver-platform-admin-authored`. `os lint` accepts the type. It
500+
cannot know which door will register the package it reads. No designer
501+
offers the type.
502+
457503
What an entry that resolves to nobody leaves on the slate depends on its kind:
458504

459505
- **A person entry** (`manager`, `field`) adds no slot. Nor does a `queue`
@@ -913,7 +959,9 @@ then — and for a `team` or `department` literal, always — no concrete user c
913959
act, and (with `lockRecord`) the record stays locked. A **platform admin**
914960
(`admin_full_access`) or **tenant admin** (`organization_admin`, org-scoped) may
915961
act on any `pending` request — **approve, reject, reassign** it to a real
916-
approver, or **recall** it — releasing the lock. An admin decision is
962+
approver, or **recall** it — releasing the lock. The one exception is a
963+
request whose slate holds the platform administrators' slot: a tenant admin
964+
cannot override it ([Routing to the platform administrators](#platform-admin-approvers)). An admin decision is
917965
authoritative: it finalizes the node even under `unanimous`/`quorum`/`per_group`,
918966
and is audited under the admin's own id. Prefer a guaranteed-staffed fallback
919967
approver so the set is never empty in the first place.

‎content/docs/references/automation/approval.mdx‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const result = ApprovalDecision.parse(data);
5353

5454
| Property | Type | Required | Description |
5555
| :--- | :--- | :--- | :--- |
56-
| **type** | `Enum<'manager' \| 'position' \| 'department' \| 'team' \| 'queue' \| 'field' \| 'expression' \| 'org_membership_level' \| 'role' \| 'user'>` | ✅ | How this step finds its approvers. Prefer a role in the organization (manager, position, department, team) over one named person, who may leave or not exist in another environment. A manager step only finds someone once an administrator has recorded each user's manager in the user directory; until then it finds nobody and the request follows the node's `onEmptyApprovers` policy. `os lint` reports that at authoring time as `approval-approvers-may-resolve-empty`, and `os explain approval-approvers-may-resolve-empty` carries the ways to fill the directory in and the full remedy; the Approvals guide states the same remedy in prose. |
56+
| **type** | `Enum<'manager' \| 'position' \| 'department' \| 'team' \| 'queue' \| 'field' \| 'expression' \| 'org_membership_level' \| 'role' \| 'user' \| 'platform_admin'>` | ✅ | How this step finds its approvers. Prefer a role in the organization (manager, position, department, team) over one named person, who may leave or not exist in another environment. A manager step only finds someone once an administrator has recorded each user's manager in the user directory; until then it finds nobody and the request follows the node's `onEmptyApprovers` policy. `os lint` reports that at authoring time as `approval-approvers-may-resolve-empty`, and `os explain approval-approvers-may-resolve-empty` carries the ways to fill the directory in and the full remedy; the Approvals guide states the same remedy in prose. The platform administrators type is for a deployment's own packaged flows only: a flow saved here cannot use it, and an approval step that names it anywhere else does not open. |
5757
| **value** | `string` | optional | Who exactly, for the chosen type: the user, membership tier, position, team, department or queue, or the record field that holds the approver. Leave it empty for a manager step. For an expression step, write the CEL expression that returns the approvers; it may read `current.*`, `trigger.*` and `vars.*`. |
5858
| **resolveAs** | `Enum<'user' \| 'department' \| 'position' \| 'team'>` | optional | Expression steps only: what the expression's results name. By default each result is a person; choose departments, positions or teams to make all their members approvers. |
5959
| **group** | `string` | optional | Group name for one-from-each-group sign-off: approvers with the same name form one group, and the step needs approval from every group (e.g. "legal", "finance"). Read only when approvers combine per group. |
@@ -84,7 +84,7 @@ const result = ApprovalDecision.parse(data);
8484

8585
| Property | Type | Required | Description |
8686
| :--- | :--- | :--- | :--- |
87-
| **type** | `Enum<'manager' \| 'position' \| 'department' \| 'team' \| 'queue' \| 'field' \| …>` | ✅ | How this step finds its approvers. Prefer a role in the organization (manager, position, department, team) over one named person, who may leave or not exist in another environment. A manager step only finds someone once an administrator has recorded each user's manager in the user directory; until then it finds nobody and the request follows the node's `onEmptyApprovers` policy. `os lint` reports that at authoring time as `approval-approvers-may-resolve-empty`, and `os explain approval-approvers-may-resolve-empty` carries the ways to fill the directory in and the full remedy; the Approvals guide states the same remedy in prose. |
87+
| **type** | `Enum<'manager' \| 'position' \| 'department' \| 'team' \| 'queue' \| 'field' \| …>` | ✅ | How this step finds its approvers. Prefer a role in the organization (manager, position, department, team) over one named person, who may leave or not exist in another environment. A manager step only finds someone once an administrator has recorded each user's manager in the user directory; until then it finds nobody and the request follows the node's `onEmptyApprovers` policy. `os lint` reports that at authoring time as `approval-approvers-may-resolve-empty`, and `os explain approval-approvers-may-resolve-empty` carries the ways to fill the directory in and the full remedy; the Approvals guide states the same remedy in prose. The platform administrators type is for a deployment's own packaged flows only: a flow saved here cannot use it, and an approval step that names it anywhere else does not open. |
8888
| **value** | `string` | optional | Who exactly, for the chosen type: the user, membership tier, position, team, department or queue, or the record field that holds the approver. Leave it empty for a manager step. For an expression step, write the CEL expression that returns the approvers; it may read `current.*`, `trigger.*` and `vars.*`. |
8989
| **resolveAs** | `Enum<'user' \| 'department' \| 'position' \| 'team'>` | optional | Expression steps only: what the expression's results name. By default each result is a person; choose departments, positions or teams to make all their members approvers. |
9090
| **group** | `string` | optional | Group name for one-from-each-group sign-off: approvers with the same name form one group, and the step needs approval from every group (e.g. "legal", "finance"). Read only when approvers combine per group. |
@@ -94,7 +94,7 @@ const result = ApprovalDecision.parse(data);
9494

9595
| Property | Type | Required | Description |
9696
| :--- | :--- | :--- | :--- |
97-
| **type** | `Enum<'manager' \| 'position' \| 'department' \| 'team' \| 'queue' \| 'field' \| …>` | ✅ | How this step finds its approvers. Prefer a role in the organization (manager, position, department, team) over one named person, who may leave or not exist in another environment. A manager step only finds someone once an administrator has recorded each user's manager in the user directory; until then it finds nobody and the request follows the node's `onEmptyApprovers` policy. `os lint` reports that at authoring time as `approval-approvers-may-resolve-empty`, and `os explain approval-approvers-may-resolve-empty` carries the ways to fill the directory in and the full remedy; the Approvals guide states the same remedy in prose. |
97+
| **type** | `Enum<'manager' \| 'position' \| 'department' \| 'team' \| 'queue' \| 'field' \| …>` | ✅ | How this step finds its approvers. Prefer a role in the organization (manager, position, department, team) over one named person, who may leave or not exist in another environment. A manager step only finds someone once an administrator has recorded each user's manager in the user directory; until then it finds nobody and the request follows the node's `onEmptyApprovers` policy. `os lint` reports that at authoring time as `approval-approvers-may-resolve-empty`, and `os explain approval-approvers-may-resolve-empty` carries the ways to fill the directory in and the full remedy; the Approvals guide states the same remedy in prose. The platform administrators type is for a deployment's own packaged flows only: a flow saved here cannot use it, and an approval step that names it anywhere else does not open. |
9898
| **value** | `string` | optional | Who exactly, for the chosen type: the user, membership tier, position, team, department or queue, or the record field that holds the approver. Leave it empty for a manager step. For an expression step, write the CEL expression that returns the approvers; it may read `current.*`, `trigger.*` and `vars.*`. |
9999
| **resolveAs** | `Enum<'user' \| 'department' \| 'position' \| 'team'>` | optional | Expression steps only: what the expression's results name. By default each result is a person; choose departments, positions or teams to make all their members approvers. |
100100
| **group** | `string` | optional | Group name for one-from-each-group sign-off: approvers with the same name form one group, and the step needs approval from every group (e.g. "legal", "finance"). Read only when approvers combine per group. |
@@ -125,7 +125,7 @@ const result = ApprovalDecision.parse(data);
125125

126126
## ApproverType
127127

128-
How this step finds its approvers. Prefer a role in the organization (manager, position, department, team) over one named person, who may leave or not exist in another environment. A manager step only finds someone once an administrator has recorded each user's manager in the user directory; until then it finds nobody and the request follows the node's `onEmptyApprovers` policy. `os lint` reports that at authoring time as `approval-approvers-may-resolve-empty`, and `os explain approval-approvers-may-resolve-empty` carries the ways to fill the directory in and the full remedy; the Approvals guide states the same remedy in prose.
128+
How this step finds its approvers. Prefer a role in the organization (manager, position, department, team) over one named person, who may leave or not exist in another environment. A manager step only finds someone once an administrator has recorded each user's manager in the user directory; until then it finds nobody and the request follows the node's `onEmptyApprovers` policy. `os lint` reports that at authoring time as `approval-approvers-may-resolve-empty`, and `os explain approval-approvers-may-resolve-empty` carries the ways to fill the directory in and the full remedy; the Approvals guide states the same remedy in prose. The platform administrators type is for a deployment's own packaged flows only: a flow saved here cannot use it, and an approval step that names it anywhere else does not open.
129129

130130
### Allowed Values
131131

@@ -139,6 +139,7 @@ How this step finds its approvers. Prefer a role in the organization (manager, p
139139
* `org_membership_level`
140140
* `role`
141141
* `user`
142+
* `platform_admin`
142143

143144

144145
---

‎packages/lint/src/authoring-rules.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,12 @@ export interface AuthoringRuleContext {
364364
* authored shape the build judges (`stripInjectedSystemColumns`); and it
365365
* leaves out a label group every member of which already shared the label on
366366
* the target without the written entry, a clash the entry did not create.
367+
*
368+
* `validateApprovalApprovers` reads its presence only, as
369+
* `validateEmailTemplateHoleGrammar` does: a flow written at the publish door is authored in the
370+
* deployment, never a package's own code, so a `platform_admin` approver in
371+
* it is refused there; the CLI commands read a package's source and cannot
372+
* know which door will register it, so they refuse nothing.
367373
*/
368374
runtimeWriteType?: string;
369375
/**
@@ -1638,7 +1644,10 @@ export const AUTHORING_RULES: readonly AuthoringRule[] = [
16381644
// `approver.value` is just a string to Zod. It is not just a string here.
16391645
surfaces: CLI_AND_RUNTIME,
16401646
runtimeTypes: ['flow'],
1641-
run: (stack) => validateApprovalApprovers(stack),
1647+
// At the runtime door a flow is authored in the deployment, so a
1648+
// `platform_admin` approver in it is refused there (`atSaveDoor`, read off
1649+
// `runtimeWriteType`'s presence; see that field).
1650+
run: (stack, ctx) => validateApprovalApprovers(stack, { atSaveDoor: ctx.runtimeWriteType !== undefined }),
16421651
},
16431652
// ADR-0079 — `titleFormat` is retired in favour of `nameField`, and the
16441653
// ruling of record on #29007 (6574393684, letter B) refuses it: an object

‎packages/lint/src/index.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,9 @@ export {
338338
APPROVAL_EXPRESSION_NO_EMPTY_POLICY,
339339
APPROVAL_DECISION_OUTPUTS_RESERVED,
340340
APPROVAL_APPROVER_CROSS_ORG_UNSUPPORTED,
341+
APPROVAL_APPROVER_PLATFORM_ADMIN_AUTHORED,
341342
} from './validate-approval-approvers.js';
342-
export type { ApprovalApproverFinding, ApprovalApproverSeverity } from './validate-approval-approvers.js';
343+
export type { ApprovalApproverFinding, ApprovalApproverSeverity, ValidateApprovalApproversOptions } from './validate-approval-approvers.js';
343344

344345
export {
345346
validateAssignmentRules,

0 commit comments

Comments
 (0)