Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/34839-approvals-viewer-block-descriptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@objectstack/skills': patch
'@objectstack/platform-objects': patch
---

docs(skills): the automation skill says who an `admin_rescue` request opens on

Clause-②: no
Metadata-protocol: none

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.

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`.
32 changes: 20 additions & 12 deletions docs/qa/platform-checklist/areas/approvals.json

Large diffs are not rendered by default.

19 changes: 11 additions & 8 deletions packages/platform-objects/src/apps/account.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,17 @@ export const ACCOUNT_APP: App = {
{
// #7234 — the DESTINATION is the Approvals Inbox component, not the
// raw `sys_approval_request` grid. The engine-owned table has no
// decision actions for an end user: all eight are gated on
// `record.viewer.can_act || record.viewer.can_override`, and the
// `viewer` block is attached ONLY on the approvals REST path
// (`approval-service.ts`, `attachViewers()`), never on the generic
// data API. So the object route could only ever render a read-only
// list of rows an approver cannot act on. The inbox component calls
// the approvals REST path and therefore carries the decision
// actions, business vocabulary, node progress and drawer.
// decision actions for an end user: every one is gated on a leaf
// of the served `record.viewer` block (`can_act`, `is_submitter`,
// `can_override`, `can_override_approve`; the override arm reads
// `can_override_approve` on Approve and `can_override` on Reject,
// Reassign and Recall), and the `viewer` block is attached ONLY on
// the approvals REST path (`approval-service.ts`,
// `attachViewers()`), never on the generic data API. So the object
// route could only ever render a read-only list of rows an approver
// cannot act on. The inbox component calls the approvals REST path
// and therefore carries the decision actions, business vocabulary,
// node progress and drawer.
//
// The ref is the component-registry KEY, never a console path — that
// indirection is the whole contract (objectui#2763; the key is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,22 +322,29 @@ describe('the override never approves its actor\'s own request', () => {
// A store whose collation folds letter case (MySQL's default) resolves a
// differently-cased email to the submitter's account, and the decision door
// admits a named email in any case: the comparison must not be narrower.
const find = engine.find.bind(engine);
// The double is rebuilt before every case; the original `find` is put back
// here as well, so the case does not lean on that to stay contained.
const original = engine.find;
const find = original.bind(engine);
engine.find = async (object: string, options?: any) => {
const email = options?.where?.email;
if (object === 'sys_user' && typeof email === 'string') {
return engine._tables['sys_user'].filter((u) => String(u.email ?? '').toLowerCase() === email.toLowerCase());
}
return find(object, options);
};
const own = await open(ADMIN);
await expect(svc.reassign(own.id, { actorId: 'root', to: 'ROOT@Example.COM' }, ADMIN))
.rejects.toThrow(/^VALIDATION_FAILED: cannot reassign to 'ROOT@Example.COM' — it names the request's submitter/);
const members = await open(SUBMITTER);
await expect(svc.reassign(members.id, { actorId: 'root2', to: 'U1@EXAMPLE.com' }, OTHER_ADMIN))
.rejects.toThrow(/^VALIDATION_FAILED: cannot reassign to 'U1@EXAMPLE.com' — it names the request's submitter/);
expect((await svc.getRequest(own.id, SYS))!.pending_approvers).toEqual(['u9']);
expect((await svc.getRequest(members.id, SYS))!.pending_approvers).toEqual(['u9']);
try {
const own = await open(ADMIN);
await expect(svc.reassign(own.id, { actorId: 'root', to: 'ROOT@Example.COM' }, ADMIN))
.rejects.toThrow(/^VALIDATION_FAILED: cannot reassign to 'ROOT@Example.COM' — it names the request's submitter/);
const members = await open(SUBMITTER);
await expect(svc.reassign(members.id, { actorId: 'root2', to: 'U1@EXAMPLE.com' }, OTHER_ADMIN))
.rejects.toThrow(/^VALIDATION_FAILED: cannot reassign to 'U1@EXAMPLE.com' — it names the request's submitter/);
expect((await svc.getRequest(own.id, SYS))!.pending_approvers).toEqual(['u9']);
expect((await svc.getRequest(members.id, SYS))!.pending_approvers).toEqual(['u9']);
} finally {
engine.find = original;
}
});

it('CONTROL: an administrator who did not submit the request still approves it through the override, audited', async () => {
Expand Down
13 changes: 8 additions & 5 deletions packages/spec/src/data/object.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2880,11 +2880,14 @@ const ATTACHED_ON_READ_NAME = /^[a-z_][a-z0-9_]*$/;
* attaches to the rows it serves, computed per caller on read and never stored.
*
* The worked case is plugin-approvals: `ApprovalService.attachViewers` sets
* `viewer: { can_act, is_submitter, can_override }` on every `sys_approval_request`
* row it reads, from the CALLER's identity, and the object's own action
* predicates gate on `record.viewer.can_act`. Before this key nothing could
* declare such a block in a shape the build validator reads, so those
* predicates were refused as naming an undeclared field.
* `viewer: { can_act, is_submitter, can_override, can_override_approve }` on
* every `sys_approval_request` row it reads, from the CALLER's identity, and
* the object's own action predicates gate on those leaves: `can_act` for an
* approver's actions, `is_submitter` for the submitter's, and an override arm
* that reads `can_override_approve` on Approve and `can_override` on Reject,
* Reassign and Recall. Before this key nothing could declare such a block in
* a shape the build validator reads, so those predicates were refused as
* naming an undeclared field.
*
* ## Shape — a strict record of strict records
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ Object-hook `ctx` is a different vocabulary — see **objectstack-data**
| `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 |
| `lockRecord` | Lock the triggering record from edits while pending. Default `true` |
| `approvalStatusField` | Business-object field to mirror `pending`/`approved`/`rejected`/`returned`/`recalled` onto (should be readonly) |
| `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) |
| `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) |
| `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` |
| `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* |
| `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) |
Expand Down
20 changes: 15 additions & 5 deletions ui/packages/app-shell/src/utils/approvalOverride.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@
*
* So {@link actionAdmittedByOverride} reads the action's OWN declared `visible`
* gate — the very predicate that admitted the button — and asks whether it ORs
* in `can_override`. The three core levers do
* (`… record.viewer.can_act == true || … record.viewer.can_override == true`);
* in an override leaf. The served viewer block carries two: `can_override`,
* which Reject, Reassign and Recall read
* (`… record.viewer.can_act == true || … record.viewer.can_override == true`),
* and `can_override_approve`, which Approve reads in the same position. That
* second leaf is `can_override` minus an approval of the viewer's own request,
* so the server never serves it `true` beside a `false` `can_override`. The
* test is a substring match on `can_override`, which both leaf names carry;
* `approval_remind` / `approval_resubmit` gate on `is_submitter` alone and
* never match.
*
Expand All @@ -56,7 +61,11 @@
* `=== false` / `=== true` rather than truthiness.
*/

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

/**
* Does this declared action's own `visible` gate OR in `can_override`?
* Does this declared action's own `visible` gate OR in an override leaf —
* `can_override`, or Approve's `can_override_approve`?
*
* True for exactly the actions the override flag can admit. Combined with
* True for exactly the actions the override can admit. Combined with
* {@link isOverrideOnlyViewer} — where `can_act` is `false` — the flag is then
* the ONLY term that can have made the button visible, so the button the viewer
* is looking at is an override.
Expand Down
Loading