From 3c9169fb2890105ef01b65d06cf34eabdbbd2f3d Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 00:58:47 +0000 Subject: [PATCH 1/5] fix(approvals)!: approval_reject requires a reason at every action door approval_reject declares its comment param required, so the declared param contract (ADR-0104 D2) refuses a reject whose comment is missing or blank at the REST action door, MCP run_action and the console's param dialog. A reject with a reason runs as before. Claude-Session: https://claude.ai/code/session_016WV4czKnDE6hsyXQzB9wB2 Co-authored-by: Claude --- .../35659-approval-reject-requires-reason.md | 16 +++++++++ content/docs/automation/approvals.mdx | 5 ++- .../src/sys-approval-request.object.test.ts | 33 +++++++++++++++++++ .../src/sys-approval-request.object.ts | 10 ++++-- 4 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 .changeset/35659-approval-reject-requires-reason.md diff --git a/.changeset/35659-approval-reject-requires-reason.md b/.changeset/35659-approval-reject-requires-reason.md new file mode 100644 index 00000000000..018f5b566fa --- /dev/null +++ b/.changeset/35659-approval-reject-requires-reason.md @@ -0,0 +1,16 @@ +--- +'@objectstack/plugin-approvals': patch +--- + +fix(approvals): rejecting through the `approval_reject` action requires a reason + +Clause-②: no (narrowing) +Metadata-protocol: none + + + +**BREAKING** for a caller of the `approval_reject` action on `sys_approval_request` that sends no `comment`: the call used to reject the request and is now refused before the approvals route runs. It ships `patch` because it is a non-protocol breaking change (AGENTS.md Post-Task Checklist step 3): the declaration belongs to this plugin, and nothing a metadata author writes changes, so `Metadata-protocol` is `none`. + +`approval_reject` declares its `comment` param `required: true`, so a rejection always carries its reason. The declared param contract judges the call before the target route runs, and it counts an empty or whitespace-only string as missing: the REST action door (`POST /api/v1/actions/sys_approval_request/approval_reject`) and MCP `run_action` answer `400` with the param contract's refusal naming `comment`, and the console's param dialog holds Confirm until a reason is typed. A reject with a reason runs as before. The action's AI tool description now says the reason is required. The `POST /api/v1/approvals/requests/:id/reject` route itself is unchanged. + +Fix for a caller: send the reason as `params.comment` when you run `approval_reject`. diff --git a/content/docs/automation/approvals.mdx b/content/docs/automation/approvals.mdx index a1aea485675..e48a82fcd85 100644 --- a/content/docs/automation/approvals.mdx +++ b/content/docs/automation/approvals.mdx @@ -934,7 +934,10 @@ 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. +hand-written buttons. A rejection 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). 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/packages/plugins/plugin-approvals/src/sys-approval-request.object.test.ts b/packages/plugins/plugin-approvals/src/sys-approval-request.object.test.ts index 4330fc2e3a3..e1a245de7e6 100644 --- a/packages/plugins/plugin-approvals/src/sys-approval-request.object.test.ts +++ b/packages/plugins/plugin-approvals/src/sys-approval-request.object.test.ts @@ -24,6 +24,7 @@ import { describe, it, expect } from 'vitest'; import { templateSlotSource } from '@objectstack/spec/automation'; import { isAiReadExposed } from '@objectstack/spec/data'; +import { validateActionParams, type ResolvedActionParam } from '@objectstack/spec/ui'; import { SysApprovalRequest } from './sys-approval-request.object.js'; import { SysApprovalAction } from './sys-approval-action.object.js'; @@ -321,3 +322,35 @@ describe('[#32442, ruling A] the AI read declaration', () => { expect(isAiReadExposed(SysApprovalAction)).toBe(false); }); }); + +/** + * A rejection always carries its reason. `approval_reject` declares its + * `comment` required, and the declared param contract (ADR-0104 D2) is what + * every action door judges a call by before the target route runs: the REST + * action door, MCP `run_action` and the console's param dialog. This runs the + * spec's own validator over the declaration, resolved the way the runtime + * resolves an inline param, so a missing, empty or whitespace-only reason is + * the `required` refusal and a reason passes. + */ +describe('approval_reject requires a reason', () => { + const resolved = (name: string): ResolvedActionParam[] => + byName(name).params.map((p: any) => ({ + name: p.name, type: p.type, multiple: p.multiple, required: Boolean(p.required ?? false), options: p.options, + })); + + it('refuses a reject with no comment, an empty one or a whitespace-only one', () => { + for (const bag of [{}, { comment: '' }, { comment: ' \n\t ' }, { comment: null }]) { + const issues = validateActionParams(resolved('approval_reject'), bag); + expect(issues.map((i) => [i.param, i.code]), JSON.stringify(bag)).toEqual([['comment', 'required']]); + } + }); + + it('CONTROL: a reject with a reason passes, with or without attachments', () => { + expect(validateActionParams(resolved('approval_reject'), { comment: 'Over budget.' })).toEqual([]); + expect(validateActionParams(resolved('approval_reject'), { comment: 'Over budget.', attachments: ['file_a'] })).toEqual([]); + }); + + it('CONTROL: approve keeps its comment optional', () => { + expect(validateActionParams(resolved('approval_approve'), {})).toEqual([]); + }); +}); 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 0aaebee890f..2693614c6a3 100644 --- a/packages/plugins/plugin-approvals/src/sys-approval-request.object.ts +++ b/packages/plugins/plugin-approvals/src/sys-approval-request.object.ts @@ -698,8 +698,14 @@ export const SysApprovalRequest = ObjectSchema.create({ type: 'api', method: 'POST', target: '/api/v1/approvals/requests/{id}/reject', + // A rejection always carries its reason (maintainer requirement on the + // record page's Reject). `required: true` is enforced by the declared + // param contract (ADR-0104 D2, `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. params: [ - { name: 'comment', label: 'Comment', type: 'textarea', required: false }, + { name: 'comment', label: 'Comment', type: 'textarea', required: true }, { name: 'attachments', label: 'Attachments', type: 'file', multiple: true, required: false }, ], visible: @@ -711,7 +717,7 @@ export const SysApprovalRequest = ObjectSchema.create({ ai: { exposed: true, description: - 'Reject a pending approval request (the record: a sys_approval_request id) on behalf of the user, with an optional comment. A rejection is final for every approver. Only a current approver of the request, or an administrator who may override a stuck request, may decide it; anyone else is refused. Ask the human to confirm before calling.', + 'Reject a pending approval request (the record: a sys_approval_request id) on behalf of the user. The param comment, the reason for the rejection, is required: a call without one, or with a blank one, is refused. A rejection is final for every approver. Only a current approver of the request, or an administrator who may override a stuck request, may decide it; anyone else is refused. Ask the human to confirm before calling.', requiresConfirmation: true, }, }, From 4966c992a29ead38e13f2fbd5632015e116b575e Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 01:25:04 +0000 Subject: [PATCH 2/5] test(dogfood): approval_reject without a reason is refused at the REST action door and over MCP The approver's reject with no comment, an empty one or a whitespace-only one answers 400 VALIDATION_ERROR naming comment at the REST action door and at MCP run_action, and the request stays pending; CONTROL: a REST reject with a reason rejects it and records the comment. Claude-Session: https://claude.ai/code/session_016WV4czKnDE6hsyXQzB9wB2 Co-authored-by: Claude --- .../approval-decide-over-mcp.dogfood.test.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/packages/qa/dogfood/test/approval-decide-over-mcp.dogfood.test.ts b/packages/qa/dogfood/test/approval-decide-over-mcp.dogfood.test.ts index cf6d570c8f8..d72a5d11b48 100644 --- a/packages/qa/dogfood/test/approval-decide-over-mcp.dogfood.test.ts +++ b/packages/qa/dogfood/test/approval-decide-over-mcp.dogfood.test.ts @@ -317,4 +317,34 @@ describe('an approver\'s agent decides a pending approval request over MCP (#324 } await expectUndecided(requestId, 'recall, send-back and resubmit over MCP'); }); + + /** + * A rejection always carries its reason: `approval_reject` declares its + * `comment` required, so the declared param contract (ADR-0104 D2) refuses a + * missing or blank one at the REST action door and at MCP `run_action`, + * before the confirmation gate and before the approvals route. CONTROL: the + * approver's REST reject with a reason rejects the request as before. + */ + it('⭐ a reject with no reason, or a blank one, is refused at the REST action door and over MCP; with a reason it rejects', async () => { + const requestId = await openRequest('reject-reason'); + const restReject = (params: Record) => + stack.apiAs(approver, 'POST', `/actions/${REQUEST}/approval_reject`, { recordId: requestId, params }); + for (const params of [{}, { comment: '' }, { comment: ' \n\t ' }]) { + const res = await restReject(params); + const body: any = await res.json(); + const label = `REST ${JSON.stringify(params)} → ${JSON.stringify(body)}`; + expect([res.status, body?.error?.code ?? body?.code], label).toEqual([400, 'VALIDATION_ERROR']); + expect(JSON.stringify(body), label).toContain('"comment" is required'); + const viaMcp = await act({ bearer: approver }, 'approval_reject', requestId, false, String(params.comment ?? '')); + expect(viaMcp.isError, viaMcp.text).toBe(true); + expect([viaMcp.payload?.error?.status, viaMcp.payload?.error?.code], viaMcp.text).toEqual([400, 'VALIDATION_ERROR']); + expect(viaMcp.text).toContain('"comment" is required'); + } + await expectUndecided(requestId, 'a reject without a reason'); + + const res = await restReject({ comment: 'Over budget.' }); + expect(res.status, await res.clone().text()).toBe(200); + expect((await requestRow(requestId)).status).toBe('rejected'); + expect((await decisionsOn(requestId)).map((r) => [r.action, r.comment])).toEqual([['reject', 'Over budget.']]); + }); }); From 400c82eed3cb60b5ff500f4fcda48d24d49bd702 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 01:31:40 +0000 Subject: [PATCH 3/5] test(dogfood): name the comment param in the reject refusal, not its sentence Claude-Session: https://claude.ai/code/session_016WV4czKnDE6hsyXQzB9wB2 Co-authored-by: Claude --- .../qa/dogfood/test/approval-decide-over-mcp.dogfood.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/qa/dogfood/test/approval-decide-over-mcp.dogfood.test.ts b/packages/qa/dogfood/test/approval-decide-over-mcp.dogfood.test.ts index d72a5d11b48..6ce53f6df65 100644 --- a/packages/qa/dogfood/test/approval-decide-over-mcp.dogfood.test.ts +++ b/packages/qa/dogfood/test/approval-decide-over-mcp.dogfood.test.ts @@ -334,11 +334,11 @@ describe('an approver\'s agent decides a pending approval request over MCP (#324 const body: any = await res.json(); const label = `REST ${JSON.stringify(params)} → ${JSON.stringify(body)}`; expect([res.status, body?.error?.code ?? body?.code], label).toEqual([400, 'VALIDATION_ERROR']); - expect(JSON.stringify(body), label).toContain('"comment" is required'); + expect(String(body?.error?.message), label).toMatch(/\bcomment\b/); const viaMcp = await act({ bearer: approver }, 'approval_reject', requestId, false, String(params.comment ?? '')); expect(viaMcp.isError, viaMcp.text).toBe(true); expect([viaMcp.payload?.error?.status, viaMcp.payload?.error?.code], viaMcp.text).toEqual([400, 'VALIDATION_ERROR']); - expect(viaMcp.text).toContain('"comment" is required'); + expect(String(viaMcp.payload?.error?.message), viaMcp.text).toMatch(/\bcomment\b/); } await expectUndecided(requestId, 'a reject without a reason'); From 5023ae8dbaa58bcdc9b05f26d6df3a561e82e845 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 02:24:03 +0000 Subject: [PATCH 4/5] docs(qa): the approvals checklist says the reject reason is required The record-page Reject dialog item and the declared-actions source line now say approval_reject's comment is required, refused when missing or blank at REST, MCP and the console; approve's comment stays optional. Claude-Session: https://claude.ai/code/session_016WV4czKnDE6hsyXQzB9wB2 Co-authored-by: Claude --- docs/qa/platform-checklist/areas/approvals.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/qa/platform-checklist/areas/approvals.json b/docs/qa/platform-checklist/areas/approvals.json index b85709aa85d..047a09dff4b 100644 --- a/docs/qa/platform-checklist/areas/approvals.json +++ b/docs/qa/platform-checklist/areas/approvals.json @@ -1018,7 +1018,7 @@ "PATCH a showcase_project budget to e.g. 200000 over /api/v1/data — showcase_budget_approval opens and parks at manager_review (routed to manager = admin), lockRecord:false; the admin is the request's submitter as well as its approver", "open that project's record page — /_console/apps/showcase_app/showcase_project/record/:id, the served record route (the shorthand /apps/showcase_app/showcase_project/:id still lands there: the console's ShorthandRecordRedirect rewrites it); once it settles, screenshot the decision bar ABOVE the page body, not the record header: DeclaredActionsBar renders sys_approval_request's declared record_section actions against the pending request row. For the admin (pending approver and submitter) that is Approve (approval_approve, declared variant 'primary' → filled), Reject (approval_reject, 'danger' → destructive), Reassign, Send back, Request info, Recall and Reply, in declaration order, each a button whose data-testid is declared-action- plus the action name; Send reminder is left to the approvals panel (approval_remind is excluded) and Resubmit stays hidden (the request is not 'returned'). Read the viewer block the bar ran on: on first load the record's approvals arrive inside the record page's one read, POST /api/v1/data/showcase_project/:id/page (useRecordApprovals.ts seedRecordApprovals, objectstack#27627), and GET /api/v1/approvals/requests?object=showcase_project&recordId=:id fires only as the post-decision refresh, so read the pending row from that /page body or send the GET yourself: it answers the pending row with viewer.can_act true and viewer.is_submitter true", "because manager_review is lockRecord:false (the request row reads lock_record: false), confirm the edit affordances remain live on this record (the editable contrast): the header's Edit button is enabled, the inline-edit pencils are present, and the approval band reads 'In approval · editable' (sky, a clock icon; ui/packages/plugin-detail/src/DetailView.tsx, detail.approvalPendingEditable)", - "click Reject (declared-action-approval_reject): assert exactly ONE dialog opens — the param dialog titled by the declared label, Reject, with the declared confirm question as its description ('Reject this request? A rejection is final for every approver.'), carrying the optional Comment textarea and Attachments file input inline; there is NO confirm dialog in front of it and no second comment dialog after it (approval_reject declares its question as description and no confirmText, so the runtime chains nothing, #7278; objectui#3126)", + "click Reject (declared-action-approval_reject): assert exactly ONE dialog opens — the param dialog titled by the declared label, Reject, with the declared confirm question as its description ('Reject this request? A rejection is final for every approver.'), carrying the required Comment textarea (the reject reason: a missing or blank one is refused at REST, MCP and in this dialog, which holds Confirm until a reason is typed) and the optional Attachments file input inline; there is NO confirm dialog in front of it and no second comment dialog after it (approval_reject declares its question as description and no confirmText, so the runtime chains nothing, #7278; objectui#3126)", "fill the comment and Confirm; capture the decision POST, the action door POST /api/v1/actions/sys_approval_request/approval_reject, with recordId = the REQUEST's id (never the project's) and the comment under params.comment; the door forwards it in-process to the declared target /api/v1/approvals/requests/:id/reject under the caller's identity (ui/packages/app-shell/src/utils/apiActionDoor.ts; targets in packages/plugins/plugin-approvals/src/sys-approval-request.object.ts); re-read GET /api/v1/approvals/requests/:id (status=rejected) and GET /api/v1/approvals/requests/:id/actions (the reject row carries the comment). The bar re-reads the approvals after the decision (refreshAfter) and draws nothing once no request is pending", "approve path: PATCH another project's budget to e.g. 200000; on its record page click Approve → one dialog (titled Approve, described 'Approve this request? Your approval is recorded, and the request moves on once this step has the approvals it requires.', optional Comment and Attachments) → Confirm → POST /api/v1/actions/sys_approval_request/approval_approve (forwarded to /api/v1/approvals/requests/:id/approve, as step 6) → re-read (status=approved; at or under 500000, needs_exec ends the run at approved)", "lock contrast: PATCH a third project's budget above 500000 (e.g. 600000) and approve its manager_review from the record page as in step 7 — needs_exec routes the run to exec_review (position 'showcase_exec', the admin again; lockRecord:true), a NEW pending request whose row reads lock_record: true; once the page re-reads (the decision's refresh, or a reload), screenshot — the header's Edit button stays RENDERED but DISABLED (disabled, not hidden, so the user sees the affordance is off: RecordDetailView.tsx, framework#3794), the inline-edit pencils are gone (approvalLocked, from resolveApprovalLock over recordLockedByApproval of the pending request → InlineEditProvider canEdit false), and the approval band reads 'Locked for approval' (amber, a lock icon; detail.lockedByApproval)", @@ -1068,7 +1068,7 @@ "objectui packages/app-shell/src/views/DeclaredActionsBar.tsx (blob f27b4ab0efff): each declared action's visible predicate evaluated fail-closed against the row's viewer block, the declared variant mapped (primary → filled, danger → destructive), the override framing (isOverrideDecision in utils/approvalOverride.ts: 'Override' plus the label, amber outline, data-override-decision) and the data-testid declared-action- plus the action name; + hooks/useRecordApprovals.ts (blob b65a91f4a9a4): the record's read, GET /api/v1/approvals/requests?object=…&recordId=… then GET …/requests/:id, with no client-side canDecide; + hooks/useConsoleActionRuntime.tsx: the param dialog takes its title from the action's label and its description from the declared description", "objectui packages/app-shell/src/views/RecordDetailView.approvalDeclaredActions.test.tsx (objectui#3055, blob 9519ae70f743 at the console pin cf153eb2e535: the record page runs sys_approval_request's declared decision actions, and 'folds a declared decision output into the nested `outputs` body' asserts that a decision's comment and declared outputs reach the POST to the request) + packages/plugins/plugin-approvals/src/sys-approval-request.object.test.ts ('the confirm question rides `description`, not `confirmText`, so one decision opens one dialog (#7278)'). Between them they hold what the deleted RecordDetailView.approvalDecisionActions.test.tsx pinned, the decision params and one dialog per decision; objectui 99782f961 deleted that file before both console pins", "examples/app-showcase/src/automation/flows/index.ts#BudgetApprovalFlow (BudgetApprovalFlow — manager_review lockRecord:false / exec_review lockRecord:true on showcase_project)", - "packages/plugins/plugin-approvals/src/sys-approval-request.object.ts#approval_reject (the declared actions: approval_approve 'primary' and approval_reject 'danger', each with optional comment and attachments params and its confirm question as description, never confirmText, #7278; approval_reassign, approval_send_back, approval_request_info, approval_remind, approval_recall, approval_resubmit and approval_comment; all at record_section, every visible predicate over record.viewer, the attachedOnRead block) + packages/plugins/plugin-approvals/src/approval-service.ts#attachViewers (can_act: pending and the caller takes a slot; is_submitter; can_override: pending and isOverrideActor; can_override_approve: can_override and the viewer did not submit the request)", + "packages/plugins/plugin-approvals/src/sys-approval-request.object.ts#approval_reject (the declared actions: approval_approve 'primary' with optional comment and attachments params, and approval_reject 'danger' with a required comment (refused when missing or blank at REST, MCP and the console) and optional attachments, each with its confirm question as description, never confirmText, #7278; approval_reassign, approval_send_back, approval_request_info, approval_remind, approval_recall, approval_resubmit and approval_comment; all at record_section, every visible predicate over record.viewer, the attachedOnRead block) + packages/plugins/plugin-approvals/src/approval-service.ts#attachViewers (can_act: pending and the caller takes a slot; is_submitter; can_override: pending and isOverrideActor; can_override_approve: can_override and the viewer did not submit the request)", "packages/plugins/plugin-approvals/src/request-read-gate.ts (header: the approvals door serves a request to its participants and the override actor, and to a record reader only where the object declares enable.approvalsVisibleToReaders, which no showcase object does) + packages/plugins/plugin-approvals/src/approval-service.ts#refuseUnreadableRequest (every door that acts on a request, decide included, answers a caller who may not READ it REQUEST_NOT_FOUND, exactly as a missing id, answered 404 by packages/rest/src/approvals-routes.ts) + packages/plugins/plugin-approvals/src/approval-service.ts#decide (a reader who takes no slot and holds no override: FORBIDDEN, answered 403)" ], "history": [ From d1f69fb9d72d32005ef855493eab2ea0516abfbd Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 03:00:03 +0000 Subject: [PATCH 5/5] docs(approvals): scope the reason guarantee to approval_reject The source comment, the approvals guide, the unit and dogfood test docblocks, the changeset and the two checklist lines now say a reject through approval_reject always carries its reason, and name the REST action door rather than REST: the approvals route itself still accepts a reject with no reason. Claude-Session: https://claude.ai/code/session_016WV4czKnDE6hsyXQzB9wB2 Co-authored-by: Claude --- .changeset/35659-approval-reject-requires-reason.md | 2 +- content/docs/automation/approvals.mdx | 4 ++-- docs/qa/platform-checklist/areas/approvals.json | 4 ++-- .../src/sys-approval-request.object.test.ts | 2 +- .../src/sys-approval-request.object.ts | 13 +++++++------ .../test/approval-decide-over-mcp.dogfood.test.ts | 2 +- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.changeset/35659-approval-reject-requires-reason.md b/.changeset/35659-approval-reject-requires-reason.md index 018f5b566fa..6181d2d7a3b 100644 --- a/.changeset/35659-approval-reject-requires-reason.md +++ b/.changeset/35659-approval-reject-requires-reason.md @@ -11,6 +11,6 @@ Metadata-protocol: none **BREAKING** for a caller of the `approval_reject` action on `sys_approval_request` that sends no `comment`: the call used to reject the request and is now refused before the approvals route runs. It ships `patch` because it is a non-protocol breaking change (AGENTS.md Post-Task Checklist step 3): the declaration belongs to this plugin, and nothing a metadata author writes changes, so `Metadata-protocol` is `none`. -`approval_reject` declares its `comment` param `required: true`, so a rejection always carries its reason. The declared param contract judges the call before the target route runs, and it counts an empty or whitespace-only string as missing: the REST action door (`POST /api/v1/actions/sys_approval_request/approval_reject`) and MCP `run_action` answer `400` with the param contract's refusal naming `comment`, and the console's param dialog holds Confirm until a reason is typed. A reject with a reason runs as before. The action's AI tool description now says the reason is required. The `POST /api/v1/approvals/requests/:id/reject` route itself is unchanged. +`approval_reject` declares its `comment` param `required: true`, so a reject through `approval_reject` always carries its reason. The declared param contract judges the call before the target route runs, and it counts an empty or whitespace-only string as missing: the REST action door (`POST /api/v1/actions/sys_approval_request/approval_reject`) and MCP `run_action` answer `400` with the param contract's refusal naming `comment`, and the console's param dialog holds Confirm until a reason is typed. A reject with a reason runs as before. The action's AI tool description now says the reason is required. The `POST /api/v1/approvals/requests/:id/reject` route itself is unchanged. Fix for a caller: send the reason as `params.comment` when you run `approval_reject`. diff --git a/content/docs/automation/approvals.mdx b/content/docs/automation/approvals.mdx index e48a82fcd85..a3567115849 100644 --- a/content/docs/automation/approvals.mdx +++ b/content/docs/automation/approvals.mdx @@ -934,8 +934,8 @@ 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 rejection carries its reason: `approval_reject` declares -its `comment` param required, so the action door, MCP `run_action` and the +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 dialog refuse a reject whose `comment` is missing or blank (`400`, the declared param contract's `required` refusal). diff --git a/docs/qa/platform-checklist/areas/approvals.json b/docs/qa/platform-checklist/areas/approvals.json index 047a09dff4b..ab160b826c5 100644 --- a/docs/qa/platform-checklist/areas/approvals.json +++ b/docs/qa/platform-checklist/areas/approvals.json @@ -1018,7 +1018,7 @@ "PATCH a showcase_project budget to e.g. 200000 over /api/v1/data — showcase_budget_approval opens and parks at manager_review (routed to manager = admin), lockRecord:false; the admin is the request's submitter as well as its approver", "open that project's record page — /_console/apps/showcase_app/showcase_project/record/:id, the served record route (the shorthand /apps/showcase_app/showcase_project/:id still lands there: the console's ShorthandRecordRedirect rewrites it); once it settles, screenshot the decision bar ABOVE the page body, not the record header: DeclaredActionsBar renders sys_approval_request's declared record_section actions against the pending request row. For the admin (pending approver and submitter) that is Approve (approval_approve, declared variant 'primary' → filled), Reject (approval_reject, 'danger' → destructive), Reassign, Send back, Request info, Recall and Reply, in declaration order, each a button whose data-testid is declared-action- plus the action name; Send reminder is left to the approvals panel (approval_remind is excluded) and Resubmit stays hidden (the request is not 'returned'). Read the viewer block the bar ran on: on first load the record's approvals arrive inside the record page's one read, POST /api/v1/data/showcase_project/:id/page (useRecordApprovals.ts seedRecordApprovals, objectstack#27627), and GET /api/v1/approvals/requests?object=showcase_project&recordId=:id fires only as the post-decision refresh, so read the pending row from that /page body or send the GET yourself: it answers the pending row with viewer.can_act true and viewer.is_submitter true", "because manager_review is lockRecord:false (the request row reads lock_record: false), confirm the edit affordances remain live on this record (the editable contrast): the header's Edit button is enabled, the inline-edit pencils are present, and the approval band reads 'In approval · editable' (sky, a clock icon; ui/packages/plugin-detail/src/DetailView.tsx, detail.approvalPendingEditable)", - "click Reject (declared-action-approval_reject): assert exactly ONE dialog opens — the param dialog titled by the declared label, Reject, with the declared confirm question as its description ('Reject this request? A rejection is final for every approver.'), carrying the required Comment textarea (the reject reason: a missing or blank one is refused at REST, MCP and in this dialog, which holds Confirm until a reason is typed) and the optional Attachments file input inline; there is NO confirm dialog in front of it and no second comment dialog after it (approval_reject declares its question as description and no confirmText, so the runtime chains nothing, #7278; objectui#3126)", + "click Reject (declared-action-approval_reject): assert exactly ONE dialog opens — the param dialog titled by the declared label, Reject, with the declared confirm question as its description ('Reject this request? A rejection is final for every approver.'), carrying the required Comment textarea (the reject reason: a missing or blank one is refused at the REST action door, MCP and in this dialog, which holds Confirm until a reason is typed) and the optional Attachments file input inline; there is NO confirm dialog in front of it and no second comment dialog after it (approval_reject declares its question as description and no confirmText, so the runtime chains nothing, #7278; objectui#3126)", "fill the comment and Confirm; capture the decision POST, the action door POST /api/v1/actions/sys_approval_request/approval_reject, with recordId = the REQUEST's id (never the project's) and the comment under params.comment; the door forwards it in-process to the declared target /api/v1/approvals/requests/:id/reject under the caller's identity (ui/packages/app-shell/src/utils/apiActionDoor.ts; targets in packages/plugins/plugin-approvals/src/sys-approval-request.object.ts); re-read GET /api/v1/approvals/requests/:id (status=rejected) and GET /api/v1/approvals/requests/:id/actions (the reject row carries the comment). The bar re-reads the approvals after the decision (refreshAfter) and draws nothing once no request is pending", "approve path: PATCH another project's budget to e.g. 200000; on its record page click Approve → one dialog (titled Approve, described 'Approve this request? Your approval is recorded, and the request moves on once this step has the approvals it requires.', optional Comment and Attachments) → Confirm → POST /api/v1/actions/sys_approval_request/approval_approve (forwarded to /api/v1/approvals/requests/:id/approve, as step 6) → re-read (status=approved; at or under 500000, needs_exec ends the run at approved)", "lock contrast: PATCH a third project's budget above 500000 (e.g. 600000) and approve its manager_review from the record page as in step 7 — needs_exec routes the run to exec_review (position 'showcase_exec', the admin again; lockRecord:true), a NEW pending request whose row reads lock_record: true; once the page re-reads (the decision's refresh, or a reload), screenshot — the header's Edit button stays RENDERED but DISABLED (disabled, not hidden, so the user sees the affordance is off: RecordDetailView.tsx, framework#3794), the inline-edit pencils are gone (approvalLocked, from resolveApprovalLock over recordLockedByApproval of the pending request → InlineEditProvider canEdit false), and the approval band reads 'Locked for approval' (amber, a lock icon; detail.lockedByApproval)", @@ -1068,7 +1068,7 @@ "objectui packages/app-shell/src/views/DeclaredActionsBar.tsx (blob f27b4ab0efff): each declared action's visible predicate evaluated fail-closed against the row's viewer block, the declared variant mapped (primary → filled, danger → destructive), the override framing (isOverrideDecision in utils/approvalOverride.ts: 'Override' plus the label, amber outline, data-override-decision) and the data-testid declared-action- plus the action name; + hooks/useRecordApprovals.ts (blob b65a91f4a9a4): the record's read, GET /api/v1/approvals/requests?object=…&recordId=… then GET …/requests/:id, with no client-side canDecide; + hooks/useConsoleActionRuntime.tsx: the param dialog takes its title from the action's label and its description from the declared description", "objectui packages/app-shell/src/views/RecordDetailView.approvalDeclaredActions.test.tsx (objectui#3055, blob 9519ae70f743 at the console pin cf153eb2e535: the record page runs sys_approval_request's declared decision actions, and 'folds a declared decision output into the nested `outputs` body' asserts that a decision's comment and declared outputs reach the POST to the request) + packages/plugins/plugin-approvals/src/sys-approval-request.object.test.ts ('the confirm question rides `description`, not `confirmText`, so one decision opens one dialog (#7278)'). Between them they hold what the deleted RecordDetailView.approvalDecisionActions.test.tsx pinned, the decision params and one dialog per decision; objectui 99782f961 deleted that file before both console pins", "examples/app-showcase/src/automation/flows/index.ts#BudgetApprovalFlow (BudgetApprovalFlow — manager_review lockRecord:false / exec_review lockRecord:true on showcase_project)", - "packages/plugins/plugin-approvals/src/sys-approval-request.object.ts#approval_reject (the declared actions: approval_approve 'primary' with optional comment and attachments params, and approval_reject 'danger' with a required comment (refused when missing or blank at REST, MCP and the console) and optional attachments, each with its confirm question as description, never confirmText, #7278; approval_reassign, approval_send_back, approval_request_info, approval_remind, approval_recall, approval_resubmit and approval_comment; all at record_section, every visible predicate over record.viewer, the attachedOnRead block) + packages/plugins/plugin-approvals/src/approval-service.ts#attachViewers (can_act: pending and the caller takes a slot; is_submitter; can_override: pending and isOverrideActor; can_override_approve: can_override and the viewer did not submit the request)", + "packages/plugins/plugin-approvals/src/sys-approval-request.object.ts#approval_reject (the declared actions: approval_approve 'primary' with optional comment and attachments params, and approval_reject 'danger' with a required comment (refused when missing or blank at the REST action door, MCP and the console) and optional attachments, each with its confirm question as description, never confirmText, #7278; approval_reassign, approval_send_back, approval_request_info, approval_remind, approval_recall, approval_resubmit and approval_comment; all at record_section, every visible predicate over record.viewer, the attachedOnRead block) + packages/plugins/plugin-approvals/src/approval-service.ts#attachViewers (can_act: pending and the caller takes a slot; is_submitter; can_override: pending and isOverrideActor; can_override_approve: can_override and the viewer did not submit the request)", "packages/plugins/plugin-approvals/src/request-read-gate.ts (header: the approvals door serves a request to its participants and the override actor, and to a record reader only where the object declares enable.approvalsVisibleToReaders, which no showcase object does) + packages/plugins/plugin-approvals/src/approval-service.ts#refuseUnreadableRequest (every door that acts on a request, decide included, answers a caller who may not READ it REQUEST_NOT_FOUND, exactly as a missing id, answered 404 by packages/rest/src/approvals-routes.ts) + packages/plugins/plugin-approvals/src/approval-service.ts#decide (a reader who takes no slot and holds no override: FORBIDDEN, answered 403)" ], "history": [ diff --git a/packages/plugins/plugin-approvals/src/sys-approval-request.object.test.ts b/packages/plugins/plugin-approvals/src/sys-approval-request.object.test.ts index e1a245de7e6..65f9515e09e 100644 --- a/packages/plugins/plugin-approvals/src/sys-approval-request.object.test.ts +++ b/packages/plugins/plugin-approvals/src/sys-approval-request.object.test.ts @@ -324,7 +324,7 @@ describe('[#32442, ruling A] the AI read declaration', () => { }); /** - * A rejection always carries its reason. `approval_reject` declares its + * A reject through `approval_reject` always carries its reason. It declares its * `comment` required, and the declared param contract (ADR-0104 D2) is what * every action door judges a call by before the target route runs: the REST * action door, MCP `run_action` and the console's param dialog. This runs the 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 2693614c6a3..8019a9aee5b 100644 --- a/packages/plugins/plugin-approvals/src/sys-approval-request.object.ts +++ b/packages/plugins/plugin-approvals/src/sys-approval-request.object.ts @@ -698,12 +698,13 @@ export const SysApprovalRequest = ObjectSchema.create({ type: 'api', method: 'POST', target: '/api/v1/approvals/requests/{id}/reject', - // A rejection always carries its reason (maintainer requirement on the - // record page's Reject). `required: true` is enforced by the declared - // param contract (ADR-0104 D2, `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. + // A reject through `approval_reject` always carries its reason + // (maintainer requirement on the record page's Reject). `required: true` + // is enforced by the declared param contract (ADR-0104 D2, + // `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. params: [ { name: 'comment', label: 'Comment', type: 'textarea', required: true }, { name: 'attachments', label: 'Attachments', type: 'file', multiple: true, required: false }, diff --git a/packages/qa/dogfood/test/approval-decide-over-mcp.dogfood.test.ts b/packages/qa/dogfood/test/approval-decide-over-mcp.dogfood.test.ts index 6ce53f6df65..bd3c7340fe4 100644 --- a/packages/qa/dogfood/test/approval-decide-over-mcp.dogfood.test.ts +++ b/packages/qa/dogfood/test/approval-decide-over-mcp.dogfood.test.ts @@ -319,7 +319,7 @@ describe('an approver\'s agent decides a pending approval request over MCP (#324 }); /** - * A rejection always carries its reason: `approval_reject` declares its + * A reject through `approval_reject` always carries its reason: it declares its * `comment` required, so the declared param contract (ADR-0104 D2) refuses a * missing or blank one at the REST action door and at MCP `run_action`, * before the confirmation gate and before the approvals route. CONTROL: the