MGCWardenWorkItemService
custom service: API approve/reject/delegate/resubmit of workflow work items honoring the same checks as the UI. Operations never throw across the service boundary; they return result strings. Every dispatch attempt and outcome is event-logged. Every operation first resolves THE FAMILY'S OWN action menu item from the work item and refuses with MGCWardenApiDispatch::denied() unless the caller could run that exact menu item in the client; the rule MGCWardenApiDispatch states for the whole surface and that MGCWardenBatchService::gate and MGCWardenGuardOperationsService::runOn already follow. The platform does not close this either: WorkflowWorkItemActionManager::dispatchWorkItemAction uses _menuItemName only to resolve the outcome name, never to check access. WHY THE MENU ITEM IS RESOLVED FROM THE WORKFLOW ELEMENT AND NOT FROM THE WORK ITEM'S OWN FIELDS. The gate is only worth as much as the menu item it names, and there were three candidates: 1. WorkflowWorkItemTable.MenuItemName; REJECTED, AND IT WOULD HAVE FAILED OPEN. That field is typed MenuItemNameDisplay, it is the element's DocumentMenuItem (the link that OPENS the document), and the platform hard-codes its type: WorkflowWorkItemTable::getMenuFunction() returns new MenuFunction(this.MenuItemName, MenuItemType::Display). Both platform writers of the field; SysWorkflowWorkItem and SysWorkflowEventDispatcher; assign documentMenuItem(), and both pass the ACTION menu item somewhere else entirely (parmActionMenuItem). In Warden the document links are granted at Read to the inquiry privileges as well as to the deciding ones (MGCWardenGuardInquiryPriv grants Read on MGCWardenTAGatedJournals, the trade agreement DocumentMenuItem), so gating a decision on the document link would admit every user who may merely LOOK at the family. A gate that admits readers to an approve is worse than no gate, because it reads as one. 2. RefTableId, mapped to a family; REJECTED, BECAUSE REFTABLEID IS NOT ONE-TO-ONE WITH FAMILY. MGCWardenDeltaApproval and MGCWardenExcludedClassApproval are two separate families, two separate workflow elements, two separate privileges and two separate pairs of menu items; and BOTH root on MGCWardenDiffSet (see their queries; and see this class's own diff-set branch and MGCWardenWorkItemActionManager_Extension, which both guard on that one RefTableId for "delta / excluded-class"). A RefTableId map would have to answer one menu item for a diff-set work item and would therefore be wrong for one of the two families every time, in the direction that admits the holder of the other family's grant. Same defect as (1), reached differently. 3. The workflow element the work item actually belongs to; CHOSEN. WorkflowWorkItemTable.ElementId relates to WorkflowElementTable; workflowElementTable() follows it; SysWorkflowElement reads that element's own AxWorkflowApproval metadata. actionMenuItem(outcome) answers the Approve or Reject ActionMenuItem the client button runs, delegateMenuItem() the DelegateMenuItem and resubmitMenuItem() the ResubmitMenuItem. This is sound for three reasons that the other two candidates cannot claim: (a) It is per-family by construction. The element IS the family; nothing is mapped, guessed or shared, so the diff-set collision that defeats (2) cannot arise. (b) It cannot be influenced by the caller. The only caller input is the work item id; the element comes from the work item's own ElementId and the menu item from shipped metadata. (c) THE STRING GATED IS THE STRING DISPATCHED. familyActionMenuItem() resolves one value, canRun() is asked about that value and dispatchWorkItemAction() is handed that same variable. The permission checked and the action taken cannot drift apart, because they are one variable; which is the property findActionTypeForMenuItem() relies on when it reverses the same mapping for the in-client path. The gate runs BEFORE the business gates below, not after. A caller without the grant must not be able to make Warden write governance evidence: the SoD, signing-limit and stamp gates all write event-log rows as they refuse, and a refusal row attributed to somebody who could never have taken the action at all is noise in an audit pack. It is the same ordering MGCWardenBatchService::gate states for its own parameters ("a caller without the grant learns nothing about its parameters"). WHAT THE GATE CANNOT DO, SAID PLAINLY. The work item must be FOUND before its family; and so its menu item; can be known, so a call naming a work item that does not exist is answered NotFound without any authorization check having run. That is unavoidable here and it is exactly why Tests/Api/Scenarios/SurfaceSmoke.ps1 no longer counts a NotFound on a keyed operation as a passing authorization check. THE RETURN SHAPE IS THE LEGACY str, DELIBERATELY. See the report on that work item: the harness manifest marks legacyStringResult per SERVICE, not per operation, so a mixed-shape service is not expressible, and moving all four operations to MGCWardenApiResult is a contract change that must land together with Tests/Api/surface.json and both clients. The denial text is therefore not invented here: it is MGCWardenApiDispatch::denied()'s own message, so there is still exactly one source for the wording the harness maps onto Denied. The signing-limit gate, the stamp gate and the signature gate are all shared rule classes consulted by the in-client Approve chain of command as well, in the same order. Dispatch goes through the same framework entry point the UI menu items use: WorkflowWorkItemActionManager::dispatchWorkItemAction (Complete = approve, Return = reject, Delegate = delegate, Resubmit = resubmit). EVERY CALL IS COUNTED. Each operation is bound to a wrapper (approveCounted and so on) that counts it for Magicite's usage report under the status takeAction settled on, in MGCWardenApiResult's vocabulary: the same status Tests/Api maps the returned text onto.
Methods
approve
Approves (Complete) the caller's pending work item, behind the family's own Approve menu item. Returns a result message; never throws across the service boundary.
- Visibility:
public - Returns:
str
| Name | Type | Optional | Description |
|---|---|---|---|
_workItemId | str | No | |
_comment | str | No |
approveCounted
The approve operation as its service endpoint runs it: runs approve and counts the call for Magicite's usage report under the status it settled on (MGCWardenApiDispatch::countedText).
- Visibility:
public - Returns:
str
| Name | Type | Optional | Description |
|---|---|---|---|
_workItemId | str | No | |
_comment | str | No |
reject
Rejects (Return) the caller's pending work item, behind the family's own Reject menu item. Returns a result message; never throws across the service boundary.
- Visibility:
public - Returns:
str
| Name | Type | Optional | Description |
|---|---|---|---|
_workItemId | str | No | |
_comment | str | No |
rejectCounted
The reject operation as its service endpoint runs it: runs reject and counts the call for Magicite's usage report under the status it settled on (MGCWardenApiDispatch::countedText).
- Visibility:
public - Returns:
str
| Name | Type | Optional | Description |
|---|---|---|---|
_workItemId | str | No | |
_comment | str | No |
delegate
The target user is MANDATORY and is checked here rather than left to the framework: dispatchWorkItemAction throws @ApplicationFoundation:WorkflowUserNotFoundForWorkitem on an empty _toUser, and the catch below would turn that into the generic dispatch-failure string, which tells the caller nothing about what it got wrong. The framework still does the real validation (WorkflowWorkItem::delegateWorkItem checks the user exists and, for a queued work item, that the target is a member of the queue). Returns a result message; never throws across the service boundary.
- Visibility:
public - Returns:
str
| Name | Type | Optional | Description |
|---|---|---|---|
_workItemId | str | No | |
_toUserId | str | No | |
_comment | str | No |
delegateCounted
The delegate operation as its service endpoint runs it: runs delegate and counts the call for Magicite's usage report under the status it settled on (MGCWardenApiDispatch::countedText).
- Visibility:
public - Returns:
str
| Name | Type | Optional | Description |
|---|---|---|---|
_workItemId | str | No | |
_toUserId | str | No | |
_comment | str | No |
resubmit
THIS IS THE RECOVERY PATH THE Return-TYPED REJECT OUTCOME WAS DESIGNED AROUND. Every Warden Reject is Type=Return, which hands the document back to its originator as a new work item rather than killing the workflow; resubmit is how the originator sends the corrected document back up. Without it the harness could drive reject, and then nothing; reject was a terminal state it could reach but not leave. WHY THE WORK-ITEM TYPE IS GATED, AND WHY IT IS A SECURITY CHECK AND NOT A TIDINESS ONE. dispatchWorkItemAction's Resubmit branch does NOT re-read the menu item: for anything that is not a line-item recall it calls WorkflowWorkItem::takeAction(id, dictElement.getCompletingOutcome()), and for an Approval element the completing outcome IS the Approve outcome. Resubmit aimed at an ordinary approval work item would therefore COMPLETE IT AS AN APPROVAL while bypassing every approve-time gate, because MGCWardenWorkItemActionManager_Extension and validateSameChecksAsUi both key on WorkflowWorkItemActionType::Complete. Restricting the operation to work items the framework itself treats as resubmittable closes that door and is exact UI parity besides: SysWorkflowWorkItem offers resubmitMenuItem() as the action menu item on the Return and RequestChange branches, and actionMenuItem(completingOutcome) on the ordinary one. Returns a result message; never throws across the service boundary.
- Visibility:
public - Returns:
str
| Name | Type | Optional | Description |
|---|---|---|---|
_workItemId | str | No | |
_comment | str | No |
resubmitCounted
The resubmit operation as its service endpoint runs it: runs resubmit and counts the call for Magicite's usage report under the status it settled on (MGCWardenApiDispatch::countedText).
- Visibility:
public - Returns:
str
| Name | Type | Optional | Description |
|---|---|---|---|
_workItemId | str | No | |
_comment | str | No |