diff --git a/.changeset/35772-reject-reason-required-texts.md b/.changeset/35772-reject-reason-required-texts.md new file mode 100644 index 00000000000..df80a90f0b6 --- /dev/null +++ b/.changeset/35772-reject-reason-required-texts.md @@ -0,0 +1,11 @@ +--- +'@objectstack/spec': patch +'@objectstack/plugin-approvals': patch +--- + +docs(approvals): a reject reason is required at every human door — the contract docblock, the docs and the platform checklist say so + +Clause-②: no +Metadata-protocol: none + +Text only; no behaviour changes. `ApprovalService.decide()` already refuses a reject whose `comment` is missing, blank or not a string with `400 VALIDATION_ERROR` before any write, and an approve keeps its comment optional. The texts that still called the reason optional now state that rule: the `ApprovalDecisionInput.comment` and `IApprovalService.decide` docblocks in `@objectstack/spec` (the type is unchanged: `comment` stays optional in the interface, because an approve may omit it), and the `approval_reject` action's source comment in `@objectstack/plugin-approvals`, which said the target route does not judge the reason. diff --git a/content/docs/automation/approvals.mdx b/content/docs/automation/approvals.mdx index a3567115849..43b998a3e0f 100644 --- a/content/docs/automation/approvals.mdx +++ b/content/docs/automation/approvals.mdx @@ -771,7 +771,8 @@ curl -b cookies.txt -X POST \ https://your-app.example.com/api/v1/approvals/requests/req_456/approve \ -H "Content-Type: application/json" \ -d '{ "comment": "Within budget." }' -# POST .../reject for the other direction; body: { actorId?, comment? } +# POST .../reject for the other direction; body: { actorId?, comment } +# a reject's comment is its reason: required, a non-blank string ``` `actorId` defaults to the caller, who takes the first slot in @@ -868,7 +869,7 @@ continuity levers on the same request. All are `POST | Verb | Route | Who | Effect | |:---|:---|:---|:---| -| `approve` / `reject` | `/approve` `/reject` | pending approver | Records the decision (finalizes per `behavior`). Accepts `comment`, `attachments`, and — when the node declares `decisionOutputs` — structured `outputs` handed to the flow as `.` variables. | +| `approve` / `reject` | `/approve` `/reject` | pending approver | Records the decision (finalizes per `behavior`). Accepts `comment` (a reject's reason — required at every human door, see below), `attachments`, and — when the node declares `decisionOutputs` — structured `outputs` handed to the flow as `.` variables. | | `reassign` | `/reassign` | pending approver | Hands one slot to another user (`to`); the request stays pending. | | `revise` (send back) | `/revise` | pending approver | Ends this round as **`returned`**, unlocks the record for rework (ADR-0044). | | `request-info` | `/request-info` | pending approver | Asks the submitter for more info; the request **stays pending**. `comment` required. | @@ -934,10 +935,14 @@ renders and executes them wherever the object is surfaced — the **Approvals inbox** included — so a decision (comment, a file-upload for `attachments`, the reassign user-picker) is collected by the generic action dialog with **no per-action UI code**. New decision capabilities ship as backend metadata, not -hand-written buttons. A reject through `approval_reject` carries its reason: the -action declares its `comment` param required, so the action door, MCP `run_action` and the +hand-written buttons. Every human reject carries its reason: `approval_reject` +declares its `comment` param required, so the action door, MCP `run_action` and the dialog refuse a reject whose `comment` is missing or blank (`400`, the declared -param contract's `required` refusal). +param contract's `required` refusal), and `ApprovalService.decide()`, behind the +`/reject` route and the SDK's `client.approvals.reject`, refuses one the same +way (`400 VALIDATION_ERROR`); the inbox keeps Reject disabled until a reason is typed. The one +exception is the email action link, which still records the fixed text "Via +action link" instead of the approver's reason (tracked in #35722). On the record itself, a record with approval requests grows an **Approvals** tab beside Details and Related, with a request-count badge: the current step, decision diff --git a/docs/qa/platform-checklist/areas/approvals.json b/docs/qa/platform-checklist/areas/approvals.json index 2495133c2bf..d70eeb9e49e 100644 --- a/docs/qa/platform-checklist/areas/approvals.json +++ b/docs/qa/platform-checklist/areas/approvals.json @@ -191,7 +191,7 @@ "title": "M-of-N quorum approves at the threshold; one rejection vetoes", "since": "v16", "status": "active", - "revision": 12, + "revision": 13, "priority": "P1", "surface": "browser", "personas": ["three DISTINCT users each holding one of the approver positions"], @@ -214,7 +214,7 @@ "repeat-actor probe: as the NON-PRIVILEGED approver who already decided (e.g. Ada), approve the same request again — refused 403 FORBIDDEN ('is not a pending approver': her own decision keeps her a reader of the request, and her slot has left the slate) and the tally unchanged. A user holding none of the routed positions, who never acted on the request, is refused too, but with 404 REQUEST_NOT_FOUND, the answer an id naming no request gets: they cannot read the request (no showcase object declares enable.approvalsVisibleToReaders), and packages/plugins/plugin-approvals/src/approval-service.ts#refuseUnreadableRequest answers such a caller before the slate check, so the request's existence never leaks; the tally is unchanged either way. A 403 for that user means they could read the request: record which tier admitted them. ⛔ Never use the platform/tenant admin for this probe — an admin decision is the documented override (#3424) and finalizes by design", "as approver 2, approve — re-read: status=approved, remaining pending task for approver 3 closed", "GET /:id/actions — exactly two approve rows from two distinct actors", - "on a SECOND quorum request: as any single approver, POST /reject — re-read immediately", + "on a SECOND quorum request: as any single approver, POST /reject with a reason in the body ({\"comment\": \"Out of budget\"}; a reject without a non-blank comment is refused 400 VALIDATION_ERROR and decides nothing) — re-read immediately", "screenshot the request page's tally line at each stage alongside the API reads — the inbox's Request cell (or ?request=) opens the served sys_approval_request record page, /apps/APP/sys_approval_request/record/ID (objectui#12484 retired the drawer), whose approvals panel reads 'Approvals — x of 2 · N eligible approvers'; a '(2 of 3)' in the flow's step text is static, not the tally" ], "acceptance": [ @@ -317,6 +317,12 @@ "date": "2026-11-14", "change": "fixtures.knownGaps[1]: the runtime fixture is by design and the 'one seed line retires it' wording is dropped (maintainer ruling 2026-11-14 on #33351, row 135, option B). Seeding Ada into finance or legal would also make her a required approver of the unanimous invoice dual sign-off. Read at base ba35dfd78: flows/index.ts (showcase_invoice_signoff approvers finance + legal, behavior unanimous), approval-service.ts (isApprovalSatisfied, unanimous = every resolved approver approved). No clause changed", "ref": "#33351" + }, + { + "revision": 13, + "date": "2026-11-20", + "change": "steps[7] sends a reason with the veto's POST /reject. A reject now carries its reason at every human door: ApprovalService.decide refuses a reject whose comment is missing, blank or not a string with 400 VALIDATION_ERROR before any write (packages/plugins/plugin-approvals/src/approval-service.ts), so a body-less /reject decides nothing. Read from source at base d9be915f40, not re-run. No clause changed", + "ref": "#35772" } ] }, @@ -1768,7 +1774,7 @@ "title": "Inbox keyboard flow: j/k and arrows move focus, Enter opens the request's page, x selects — and a/r quick-decide through the SAME server transition as the buttons, gated by quick-decidability", "since": "v16", "status": "active", - "revision": 3, + "revision": 4, "priority": "P2", "surface": "browser", "personas": ["dev admin (pending approver on the seeded demo requests — several quick-decidable rows plus the dynamic-approval stage-1 row as the NOT-quick-decidable contrast)"], @@ -1782,7 +1788,7 @@ "steps": [ "boot the showcase on its own port and DB (dogfood §0); sign in as the dev admin; open the inbox via the account app's Approvals entry; confirm the hint bar renders ('Keyboard: j/k move · Enter open · x select · a approve · r reject')", "press j/j/k and ArrowDown/ArrowUp — the focus ring walks the FILTERED list order; press Enter — the focused row's request page opens (/apps/APP/sys_approval_request/record/ID; verify the page's request identity against GET /api/v1/approvals/requests/:id, not the highlight); go Back to the queue", - "focus a quick-decidable row and press r — the shared confirm dialog opens (nothing posted yet); confirm — capture POST /api/v1/approvals/requests/:id/reject and re-read the request + /:id/actions", + "focus a quick-decidable row and press r — the shared confirm dialog opens (nothing posted yet) with Reject disabled until a reason is typed; type a reason, then confirm — capture POST /api/v1/approvals/requests/:id/reject carrying that comment and re-read the request + /:id/actions", "press a on another quick-decidable row — approve dialog → confirm → POST /:id/approve; re-read", "ownership guards: click into the search input and type j/k/a — the list focus does not move and nothing decides; with a confirm dialog open press j/Enter — inert (the list handler yields while a decide dialog or any alertdialog is up)", "gating: focus the dynamic-approval stage-1 row (declared decisionOutputs) and press a and r — NOTHING happens: no dialog, no POST (those decisions need the typed-output dialog on the request's page)", @@ -1834,7 +1840,8 @@ "history": [ { "revision": 1, "date": "2026-08-30", "change": "initial — the inbox's keyboard surface (documented in the page's own header and advertised by its hint bar) had no checklist coverage; the load-bearing halves are that r/a land the same server transition as the buttons and that quick-decidability gates hotkeys off rows whose decisions require typed outputs", "ref": "#sweep-2026-08-30" }, { "revision": 2, "date": "2026-10-20", "change": "steps[0] respelled: 'boot showcase isolated' → 'boot the showcase on its own port and DB'. Round 12's out-of-scope finding (landing record 6287983829 on wave anchor #24579): the phrase 'showcase isolated' named the dogfood §0 own-port boot, and a runner read it as the `isolated` tenancy posture (OS_TENANCY_POSTURE=isolated). The new spelling names that boot by what it is, in RUNNER.md's own words for it (the trap table's counter: own port/DB, skill §0), and names no posture. Read at base e4d604efd3. No clause changed", "ref": "#25003" }, - { "revision": 3, "date": "2026-10-28", "change": "the retired request drawer took two of this item's behaviours with it: the ←/→ drawer-to-drawer walk and the list handler's yield to an open drawer sheet. objectui#12484 deleted the inbox's side sheet (ruling C on objectui#12438); it came into this tree with the ui/ import, PR #25825; Enter, a row click and ?request= now navigate to the request's served record page, /apps/APP/sys_approval_request/record/ID, and the keyboard effect in ui/apps/console/src/pages/system/ApprovalsInboxPage.tsx has no ArrowLeft/ArrowRight branch and yields only to a decide dialog, a focused input and an alertdialog. Dropped: revision 2's steps[2] (the drawer walk), the drawer-sheet guard in steps[5] and acceptance[2], and acceptance[4]'s ←/→ half (its x/space half stays). Rewritten to the request page: title, steps[1], steps[6], acceptance[0], acceptance[3], negative[3] and source[0]. acceptance[0] and [4] changed meaning, so a prior verdict on them does not carry. Read from source at base f2fdac5d, not driven live. Wave anchor #25807, slice C; lead from slice B's report 6457925443", "ref": "#25807" } + { "revision": 3, "date": "2026-10-28", "change": "the retired request drawer took two of this item's behaviours with it: the ←/→ drawer-to-drawer walk and the list handler's yield to an open drawer sheet. objectui#12484 deleted the inbox's side sheet (ruling C on objectui#12438); it came into this tree with the ui/ import, PR #25825; Enter, a row click and ?request= now navigate to the request's served record page, /apps/APP/sys_approval_request/record/ID, and the keyboard effect in ui/apps/console/src/pages/system/ApprovalsInboxPage.tsx has no ArrowLeft/ArrowRight branch and yields only to a decide dialog, a focused input and an alertdialog. Dropped: revision 2's steps[2] (the drawer walk), the drawer-sheet guard in steps[5] and acceptance[2], and acceptance[4]'s ←/→ half (its x/space half stays). Rewritten to the request page: title, steps[1], steps[6], acceptance[0], acceptance[3], negative[3] and source[0]. acceptance[0] and [4] changed meaning, so a prior verdict on them does not carry. Read from source at base f2fdac5d, not driven live. Wave anchor #25807, slice C; lead from slice B's report 6457925443", "ref": "#25807" }, + { "revision": 4, "date": "2026-11-20", "change": "steps[2] types a reason before confirming the r-key reject. The inbox's row Reject confirmation, which the r key opens, keeps Reject disabled until the reason is non-blank, and ApprovalService.decide refuses a reject without one (ui/apps/console/src/pages/system/ApprovalsInboxPage.tsx; packages/plugins/plugin-approvals/src/approval-service.ts). Read from source at base d9be915f40, not re-run. No clause changed", "ref": "#35772" } ] }, { diff --git a/packages/plugins/plugin-approvals/src/sys-approval-request.object.ts b/packages/plugins/plugin-approvals/src/sys-approval-request.object.ts index 8019a9aee5b..2abdb335b86 100644 --- a/packages/plugins/plugin-approvals/src/sys-approval-request.object.ts +++ b/packages/plugins/plugin-approvals/src/sys-approval-request.object.ts @@ -704,7 +704,9 @@ export const SysApprovalRequest = ObjectSchema.create({ // `validateActionParams`), which counts a blank or whitespace-only // string as missing: the action door, MCP `run_action` and the console's // param dialog all refuse a reject without one, before the target route - // is called. The target route itself does not judge the reason. + // is called. The target route judges it again: `ApprovalService.decide()` + // refuses a reject without a non-blank string reason, so a caller that + // skips this action is held to the same rule. params: [ { name: 'comment', label: 'Comment', type: 'textarea', required: true }, { name: 'attachments', label: 'Attachments', type: 'file', multiple: true, required: false }, diff --git a/packages/spec/src/contracts/approval-service.ts b/packages/spec/src/contracts/approval-service.ts index 9b705f01f8b..7600f992270 100644 --- a/packages/spec/src/contracts/approval-service.ts +++ b/packages/spec/src/contracts/approval-service.ts @@ -644,6 +644,12 @@ export interface ApprovalActionRow { export interface ApprovalDecisionInput { decision: 'approve' | 'reject'; actorId: string; + /** + * The decision's comment, recorded on the `sys_approval_action` audit row. + * A REJECT must carry it as a non-blank string — its reason; `decide()` + * refuses a reject whose comment is missing, blank or not a string with + * `400 VALIDATION_ERROR` before any write. An approve keeps it optional. + */ comment?: string; /** * File references (already stored via the storage service) to attach to this @@ -1090,6 +1096,11 @@ export interface IApprovalService { * Record a decision on a node-driven request. Honours the node's * `unanimous` behaviour, finalises the request when satisfied, and resumes * the owning flow run down the matching `approve` / `reject` edge. + * + * A reject carries its reason: one whose `comment` is missing, blank or not + * a string is refused with `400 VALIDATION_ERROR` before anything is read + * or written ({@link ApprovalDecisionInput.comment}). An approve keeps its + * comment optional. */ decide(requestId: string, input: ApprovalDecisionInput, context: ExecutionContext): Promise;