Skip to content

Commit b85dff0

Browse files
docs(approvals): descriptions name the four-leaf viewer block; the automation skill says who admin_rescue opens on (#35066)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_ Fixes #34839 Clause-②: no Metadata-protocol: none Served-tier: CONTRACT_REVIEW_TIER ## 维护者速读 - 改了什么:只改文字和一处测试整理,不改运行时行为。① 三处代码注释、三条 QA 清单条目改成和服务端一致:审批请求的 `viewer` 块有四个字段(`can_act`、`is_submitter`、`can_override`、`can_override_approve`),「批准」读 `can_override_approve`,「驳回 / 改派 / 撤回」仍读 `can_override`。② 对外发布的自动化技能里 `onEmptyApprovers` 一行,原来说 `admin_rescue` 下「只有特权管理员能通过改派处理」,现在改成运行时的真实行为:请求直接落到本组织管理员的待办里。③ 一条测试用例把替换掉的 `find` 在 finally 里放回去。 - 为什么改:#34755 合并后服务端多了 `can_override_approve`,这些描述还停在三个字段;技能那一句会让照着技能搭审批的 AI 向用户讲错 `admin_rescue` 的行为。 - 风险与回滚:没有行为变化;技能文件比原来短 9 字节,token 棘轮上限没动。回滚就是还原这一个 PR。 - 先看:`skills/objectstack-automation/references/state-machines-and-approvals.md` 的 `onEmptyApprovers` 行(对外发布,唯一受治理的文件);`docs/qa/platform-checklist/areas/approvals.json` 里 `approvals.record-page-decisions` 的 steps[9] 和 acceptance[4](期望从「菜单里有 Override Approve」改成「没有 Approve」,依据是源码,没有在浏览器里重跑);`ui/packages/app-shell/src/utils/approvalOverride.ts` 的文件头注释。 - 两分钟验证:`node scripts/check-skills-token-ratchet.mjs`,预期看到 `state-machines-and-approvals.md is 5913 tokens (ceiling 5916; headroom 3)` 且整体通过。 - 需要你做的:审阅后合并本 PR,或给出批准评审后由席位落地。落地档位是 Tier H(人合):`check-governed-merges --branch` 的实测输出是 `landing tier: H(人合) — the maintainer's hand, or an authorized APPROVED review (GOVERNED_APPROVERS) and then the owning seat lands it`。低风险技能通道用不上,原因见 Acceptance notes 第 1 条。 ## What changes No behaviour change. Seven files. **The served block, as read from the runtime.** `ApprovalService.attachViewers` (`packages/plugins/plugin-approvals/src/approval-service.ts`) sets four leaves on every request it serves: `can_act`, `is_submitter`, `can_override` and `can_override_approve`. The object declares the same four under `attachedOnRead` (`sys-approval-request.object.ts`). `can_override_approve` is `can_override` minus an approval of the viewer's own request. Of the nine declared actions, `approval_approve` reads `can_override_approve` in its override arm; `approval_reject`, `approval_reassign` and `approval_recall` read `can_override`. **Descriptions brought to that reading (items 1 to 4):** - `packages/spec/src/data/object.zod.ts`: the docblock over the `attachedOnRead` schema names the four leaves and which action reads which override leaf. Comment only; the docblock sits on a non-exported const. - `packages/platform-objects/src/apps/account.app.ts`: the comment over the Approvals nav entry said all eight actions gate on `can_act || can_override`. It now says every action gates on a leaf of the served block, and names the four. - `ui/packages/app-shell/src/utils/approvalOverride.ts`: the module docblock, the `ViewerBlockLike` docblock and the `actionAdmittedByOverride` docblock say that the override test is a substring match on `can_override`, which both leaf names carry. No code line changes. - `docs/qa/platform-checklist/areas/approvals.json`: three items, each with its revision bumped and a history entry dated 2026-11-18, ref #34839. - `approvals.inbox-metadata-actions` (9 to 10): steps[3], steps[4] and acceptance[2].verify name the four leaves. - `approvals.viewer-gating-submitter-side` (7 to 8): acceptance[0].verify no longer says Approve is visible on `can_override`. - `approvals.record-page-decisions` (8 to 9): steps[9], acceptance[4].verify and source[4]. The admin of this item submitted the request, so off the slate the row reads `can_override` true and `can_override_approve` false, and the folded override menu lists Override Reject, Override Reassign and the plain Recall, and no Approve. The text listed Override Approve. **The skill row (item 5).** `skills/objectstack-automation/references/state-machines-and-approvals.md`, the `onEmptyApprovers` row: "request opens, only a privileged admin can act via Reassign" becomes "request opens on the organization's administrators". The rest of the row is unchanged. This matches `content/docs/automation/approvals.mdx` (the manager callout, the `onEmptyApprovers` paragraph and the section "When a slate names no one") and the runtime: the `admin_rescue` branch of `openNodeRequest` resolves `organizationAdministrators` and opens the request on them as ordinary approvers. **Test hygiene (item 6).** `approval-override-audit.test.ts`: the letter-case case keeps the double's original `find` and puts it back in a `finally` block. **Changeset.** `.changeset/34839-approvals-viewer-block-descriptions.md`, patch for `@objectstack/skills` and `@objectstack/platform-objects`. ## Tests Head `77dbe40f6e`. - `pnpm --filter @objectstack/plugin-approvals exec vitest run --maxWorkers=2 src/approval-override-audit.test.ts`: 20 of 20 passed on the base copy of the file (`367e324eeb`), and 20 of 20 on the edited copy. - `pnpm --filter @objectstack/plugin-approvals exec vitest run --maxWorkers=2`: Test Files 122 passed (122), Tests 1741 passed (1741). - `pnpm --filter @objectstack/plugin-approvals typecheck`: exit 0. - `pnpm --filter @objectstack/spec check:generated`: all 14 generated artifacts up to date, against a `dist` built from this branch. - No ablation: no tested behaviour changed. ## Acceptance notes 1. **Low-risk skills arm.** `check-governed-merges --branch` prints `low-risk skills arm: NOT MEASURED — no reading of the pull request was handed in` and answers Tier H, fail closed. Read against the arm's own allowlist in the same script (`LOW_RISK_RIDER_PATTERNS`, `LOW_RISK_ARM_FILE_PATTERNS`), the arm cannot apply to this PR: every changed path has to lie under a hit catalog row or be a changeset or docs Markdown, and five of the seven paths are neither (`packages/spec`, `packages/platform-objects`, `packages/plugins/plugin-approvals`, `ui/packages/app-shell`, and the checklist JSON under `docs/`). The changeset also releases `@objectstack/platform-objects`, and the arm admits nothing but a skills patch. 2. **Item 6, premise.** The double in that describe block is already rebuilt before every case (`beforeEach` calls `makeFakeEngine()`), so the replaced `find` could not reach another case. The `finally` makes the case self-contained; it fixes no observed leak. 3. **Item 7, no pin added.** A live MySQL lane exists, `Temporal Conformance (live PG + MySQL)` in `ci.yml`, and it runs the `driver-sql` suite only. No lane runs `ApprovalService` on a store whose collation folds letter case: plugin-approvals' integration tests use `driver-sql` on SQLite, which compares text case-exactly. A pin for the email-target rule would need a new lane, so none was added. 4. **Checklist item `approvals.record-page-decisions`.** The new expectation (no Approve in the override menu for the admin who submitted the request) is read from source: `attachViewers`, the `approval_approve` predicate, and `DeclaredActionsBar` drawing each action by its own declared `visible`. It was not re-run in a browser. 5. **What ships.** Built and searched: the `packages/spec` docblock does not reach `packages/spec/dist` (0 files carry the new sentence; control `attachedOnRead`, 12 files). The `platform-objects` comment does reach `packages/platform-objects/dist` (4 files), so the changeset names that package. `@object-ui/app-shell` is private. 6. **Token ratchet.** The reference file is priced: `scripts/check-skills-token-ratchet.mjs` holds a row for it at 5916, and it sat at 5916 with headroom 0. The edit shortens the file from 23661 to 23652 bytes (5913 tokens), so the row is not touched. The whole published bundle moves by the same 9 bytes; no `SKILL.md` changes. 7. **Open PR #35002** edits another section of the same skill file. `overlap-check` merges it cleanly with this branch. 8. **Body shape.** This body opens with the attribution comment and ends with the signed trailer, as the dispatch order and the relay's PR-body rule ask. The developer agent file says a body carries no HTML comment of the agent's own writing; the two rules disagree and this PR follows the dispatch order. ## Verification <details><summary>Derived gates (dispatch-gates --commands, then --ran)</summary> `dispatch-gates --commands` derived 113 families from the tree at `77dbe40f6e`. Each was run with its exit code captured before any pipe. - 110 exited 0. - `pnpm check:dual-build-cjs-loads`: exit 3, PREREQUISITE NOT MET (needs a full workspace build). NOT MEASURED locally. - `pnpm check:i18n`: exit 3, PREREQUISITE NOT MET (the workspace CLI is not built). NOT MEASURED locally. - `pnpm --dir ui exec vitest run scripts/`: exit 1. Test Files 1 failed, 170 passed, 2 skipped. The one failure, `unit-registry-absence-collision.test.ts`, could not resolve `@objectstack/client`, which was not built in this worktree. After building that package's closure the file was re-run alone: 15 of 15 passed, exit 0. The full family was not re-run. - `dispatch-gates --ran`: `113 derived famil(ies) accounted for — 111 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3)`, exit 0. Outside the derived list: - `node scripts/check-platform-checklist.mjs --changed-from origin/main`: `OK — 2 anchored file(s) in the change set, 20 anchor(s) judged, 0 lost`, exit 0. - `pnpm gen:checklist-status`: exit 0, working tree clean after it. - `node scripts/check-skills-token-ratchet.mjs`: `state-machines-and-approvals.md is 5913 tokens (ceiling 5916; headroom 3)`, 58 authored bundle files within their ceilings. - `node scripts/pm/overlap-check.mjs`: clean against `origin/main` and #35002. </details> <details><summary>Not run locally, left to CI</summary> - The full test suites of `@objectstack/spec`, `@objectstack/platform-objects` and `@object-ui/app-shell`: their diffs are comments only. - `test:repo`, the repo-wide lint run and the full dogfood battery (the title carries no `!` and the declaration carries no narrowing arm). </details> ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (a comment changed, no schema) - [x] 2. Every name I added uses the casing for its kind. (no name added) - [x] 3. No formatter ran; `pnpm lint` passes. (the repo-wide lint run is CI's) - [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. (`check:generated` reports all 14 up to date) - [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 by [Claude Code](https://claude.ai/code/session_01WGufziunkXbDT7wUWqfmWz)_ <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufziunkXbDT7wUWqfmWz --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3b4ffb2 commit b85dff0

7 files changed

Lines changed: 84 additions & 40 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@objectstack/skills': patch
3+
'@objectstack/platform-objects': patch
4+
---
5+
6+
docs(skills): the automation skill says who an `admin_rescue` request opens on
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
objectstack-automation's `references/state-machines-and-approvals.md` no longer says that under `onEmptyApprovers: 'admin_rescue'` "only a privileged admin can act via Reassign". The row now says what the runtime does: the request opens on the organization's administrators. Nothing else in the row changes.
12+
13+
No runtime change. In-code descriptions (one of them a comment that ships in `@objectstack/platform-objects`' build output) of the approval request's served `viewer` block now name its four leaves (`can_act`, `is_submitter`, `can_override`, `can_override_approve`) and say that Approve reads `can_override_approve` while Reject, Reassign and Recall read `can_override`.

‎docs/qa/platform-checklist/areas/approvals.json‎

Lines changed: 20 additions & 12 deletions
Large diffs are not rendered by default.

‎packages/platform-objects/src/apps/account.app.ts‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,17 @@ export const ACCOUNT_APP: App = {
110110
{
111111
// #7234 — the DESTINATION is the Approvals Inbox component, not the
112112
// raw `sys_approval_request` grid. The engine-owned table has no
113-
// decision actions for an end user: all eight are gated on
114-
// `record.viewer.can_act || record.viewer.can_override`, and the
115-
// `viewer` block is attached ONLY on the approvals REST path
116-
// (`approval-service.ts`, `attachViewers()`), never on the generic
117-
// data API. So the object route could only ever render a read-only
118-
// list of rows an approver cannot act on. The inbox component calls
119-
// the approvals REST path and therefore carries the decision
120-
// actions, business vocabulary, node progress and drawer.
113+
// decision actions for an end user: every one is gated on a leaf
114+
// of the served `record.viewer` block (`can_act`, `is_submitter`,
115+
// `can_override`, `can_override_approve`; the override arm reads
116+
// `can_override_approve` on Approve and `can_override` on Reject,
117+
// Reassign and Recall), and the `viewer` block is attached ONLY on
118+
// the approvals REST path (`approval-service.ts`,
119+
// `attachViewers()`), never on the generic data API. So the object
120+
// route could only ever render a read-only list of rows an approver
121+
// cannot act on. The inbox component calls the approvals REST path
122+
// and therefore carries the decision actions, business vocabulary,
123+
// node progress and drawer.
121124
//
122125
// The ref is the component-registry KEY, never a console path — that
123126
// indirection is the whole contract (objectui#2763; the key is

‎packages/plugins/plugin-approvals/src/approval-override-audit.test.ts‎

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -322,22 +322,29 @@ describe('the override never approves its actor\'s own request', () => {
322322
// A store whose collation folds letter case (MySQL's default) resolves a
323323
// differently-cased email to the submitter's account, and the decision door
324324
// admits a named email in any case: the comparison must not be narrower.
325-
const find = engine.find.bind(engine);
325+
// The double is rebuilt before every case; the original `find` is put back
326+
// here as well, so the case does not lean on that to stay contained.
327+
const original = engine.find;
328+
const find = original.bind(engine);
326329
engine.find = async (object: string, options?: any) => {
327330
const email = options?.where?.email;
328331
if (object === 'sys_user' && typeof email === 'string') {
329332
return engine._tables['sys_user'].filter((u) => String(u.email ?? '').toLowerCase() === email.toLowerCase());
330333
}
331334
return find(object, options);
332335
};
333-
const own = await open(ADMIN);
334-
await expect(svc.reassign(own.id, { actorId: 'root', to: 'ROOT@Example.COM' }, ADMIN))
335-
.rejects.toThrow(/^VALIDATION_FAILED: cannot reassign to 'ROOT@Example.COM' — it names the request's submitter/);
336-
const members = await open(SUBMITTER);
337-
await expect(svc.reassign(members.id, { actorId: 'root2', to: 'U1@EXAMPLE.com' }, OTHER_ADMIN))
338-
.rejects.toThrow(/^VALIDATION_FAILED: cannot reassign to 'U1@EXAMPLE.com' — it names the request's submitter/);
339-
expect((await svc.getRequest(own.id, SYS))!.pending_approvers).toEqual(['u9']);
340-
expect((await svc.getRequest(members.id, SYS))!.pending_approvers).toEqual(['u9']);
336+
try {
337+
const own = await open(ADMIN);
338+
await expect(svc.reassign(own.id, { actorId: 'root', to: 'ROOT@Example.COM' }, ADMIN))
339+
.rejects.toThrow(/^VALIDATION_FAILED: cannot reassign to 'ROOT@Example.COM' — it names the request's submitter/);
340+
const members = await open(SUBMITTER);
341+
await expect(svc.reassign(members.id, { actorId: 'root2', to: 'U1@EXAMPLE.com' }, OTHER_ADMIN))
342+
.rejects.toThrow(/^VALIDATION_FAILED: cannot reassign to 'U1@EXAMPLE.com' — it names the request's submitter/);
343+
expect((await svc.getRequest(own.id, SYS))!.pending_approvers).toEqual(['u9']);
344+
expect((await svc.getRequest(members.id, SYS))!.pending_approvers).toEqual(['u9']);
345+
} finally {
346+
engine.find = original;
347+
}
341348
});
342349

343350
it('CONTROL: an administrator who did not submit the request still approves it through the override, audited', async () => {

‎packages/spec/src/data/object.zod.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,11 +2880,14 @@ const ATTACHED_ON_READ_NAME = /^[a-z_][a-z0-9_]*$/;
28802880
* attaches to the rows it serves, computed per caller on read and never stored.
28812881
*
28822882
* The worked case is plugin-approvals: `ApprovalService.attachViewers` sets
2883-
* `viewer: { can_act, is_submitter, can_override }` on every `sys_approval_request`
2884-
* row it reads, from the CALLER's identity, and the object's own action
2885-
* predicates gate on `record.viewer.can_act`. Before this key nothing could
2886-
* declare such a block in a shape the build validator reads, so those
2887-
* predicates were refused as naming an undeclared field.
2883+
* `viewer: { can_act, is_submitter, can_override, can_override_approve }` on
2884+
* every `sys_approval_request` row it reads, from the CALLER's identity, and
2885+
* the object's own action predicates gate on those leaves: `can_act` for an
2886+
* approver's actions, `is_submitter` for the submitter's, and an override arm
2887+
* that reads `can_override_approve` on Approve and `can_override` on Reject,
2888+
* Reassign and Recall. Before this key nothing could declare such a block in
2889+
* a shape the build validator reads, so those predicates were refused as
2890+
* naming an undeclared field.
28882891
*
28892892
* ## Shape — a strict record of strict records
28902893
*

‎skills/objectstack-automation/references/state-machines-and-approvals.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ Object-hook `ctx` is a different vocabulary — see **objectstack-data**
372372
| `minApprovals` | Approvals required — total for `quorum`, per group for `per_group`. Omitted ⇒ ALL resolvable approvers under `quorum`, `1` per group; clamped at runtime so a misconfiguration can never deadlock |
373373
| `lockRecord` | Lock the triggering record from edits while pending. Default `true` |
374374
| `approvalStatusField` | Business-object field to mirror `pending`/`approved`/`rejected`/`returned`/`recalled` onto (should be readonly) |
375-
| `onEmptyApprovers` | What an EMPTY resolved slate does: `admin_rescue` (default — request opens, only a privileged admin can act via Reassign; never waves through, never kills the run), `fail` (node fails — treat an empty slate as a config bug), `auto_approve` (skip the request, continue down `approve` with `output.autoApproved = true` — opt-in because it silently waves the record through), `fallback` (request opens on the sibling `fallbackApprovers` instead — same shape as `approvers`, required by this policy and refused under any other; a fallback that itself resolves to nobody degrades to `admin_rescue`). Declare it explicitly on any node with an `expression` approver (linted) |
375+
| `onEmptyApprovers` | What an EMPTY resolved slate does: `admin_rescue` (default — request opens on the organization's administrators; never waves through, never kills the run), `fail` (node fails — treat an empty slate as a config bug), `auto_approve` (skip the request, continue down `approve` with `output.autoApproved = true` — opt-in because it silently waves the record through), `fallback` (request opens on the sibling `fallbackApprovers` instead — same shape as `approvers`, required by this policy and refused under any other; a fallback that itself resolves to nobody degrades to `admin_rescue`). Declare it explicitly on any node with an `expression` approver (linted) |
376376
| `excludeSubmitter` | `true` drops the run's submitter (`submitter_id`) from the resolved slate, whatever approver type produced them — segregation of duties; a slate it empties takes the `onEmptyApprovers` route, never a silent pass. `onEmptyApprovers: 'auto_approve'` is **refused** beside it (it would approve exactly the request this exists to stop): use `admin_rescue`, `fail` or `fallback`. Default `false` |
377377
| `decisionOutputs` | Decision outputs a decision may carry: bare keys (free text) **or typed declarations** `{ key, label?, type: 'text'\|'user'\|'department'\|'position'\|'team', multiple?, required? }`, enforced at the decision — see *Recording a decision* |
378378
| `escalation` | Optional per-node SLA — `{ enabled, timeoutHours, action: reassign\|auto_approve\|auto_reject\|notify, escalateTo?, notifySubmitter }`. `timeoutHours` is **calendar (wall-clock) hours** — nights, weekends and holidays count; the platform ships no business-hours calendar. `escalateTo` is a **position machine name** (expanded to its holders via `sys_user_position`, ADR-0090 D3) or a specific user id — never a membership tier. `reassign` without `escalateTo` degrades to notify (linted) |

‎ui/packages/app-shell/src/utils/approvalOverride.ts‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@
3434
*
3535
* So {@link actionAdmittedByOverride} reads the action's OWN declared `visible`
3636
* gate — the very predicate that admitted the button — and asks whether it ORs
37-
* in `can_override`. The three core levers do
38-
* (`… record.viewer.can_act == true || … record.viewer.can_override == true`);
37+
* in an override leaf. The served viewer block carries two: `can_override`,
38+
* which Reject, Reassign and Recall read
39+
* (`… record.viewer.can_act == true || … record.viewer.can_override == true`),
40+
* and `can_override_approve`, which Approve reads in the same position. That
41+
* second leaf is `can_override` minus an approval of the viewer's own request,
42+
* so the server never serves it `true` beside a `false` `can_override`. The
43+
* test is a substring match on `can_override`, which both leaf names carry;
3944
* `approval_remind` / `approval_resubmit` gate on `is_submitter` alone and
4045
* never match.
4146
*
@@ -56,7 +61,11 @@
5661
* `=== false` / `=== true` rather than truthiness.
5762
*/
5863

59-
/** The viewer capability block `getRequest` / `listRequests` attach (framework#3310). */
64+
/**
65+
* The viewer capability block `getRequest` / `listRequests` attach
66+
* (framework#3310). The served block has a fourth leaf, `can_override_approve`;
67+
* this module reads it only through the Approve action's declared predicate.
68+
*/
6069
interface ViewerBlockLike {
6170
can_act?: unknown;
6271
is_submitter?: unknown;
@@ -102,9 +111,10 @@ function predicateSource(predicate: unknown): string {
102111
}
103112

104113
/**
105-
* Does this declared action's own `visible` gate OR in `can_override`?
114+
* Does this declared action's own `visible` gate OR in an override leaf —
115+
* `can_override`, or Approve's `can_override_approve`?
106116
*
107-
* True for exactly the actions the override flag can admit. Combined with
117+
* True for exactly the actions the override can admit. Combined with
108118
* {@link isOverrideOnlyViewer} — where `can_act` is `false` — the flag is then
109119
* the ONLY term that can have made the button visible, so the button the viewer
110120
* is looking at is an override.

0 commit comments

Comments
 (0)