Implement governed function assignment workflows
This commit is contained in:
@@ -0,0 +1,193 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from govoplan_core.core.workflows import WorkflowDefinitionContribution
|
||||
|
||||
|
||||
def function_assignment_workflow_definitions(
|
||||
*,
|
||||
module_version: str,
|
||||
) -> tuple[WorkflowDefinitionContribution, ...]:
|
||||
return (
|
||||
_contribution(
|
||||
module_version=module_version,
|
||||
definition_key="function-assignment-request",
|
||||
name="Request an organization function",
|
||||
description=(
|
||||
"Governed holder, authority, and optional recipient decisions "
|
||||
"for a self-requested organization function assignment."
|
||||
),
|
||||
kind="request",
|
||||
),
|
||||
_contribution(
|
||||
module_version=module_version,
|
||||
definition_key="function-assignment-grant",
|
||||
name="Bestow an organization function",
|
||||
description=(
|
||||
"Governed holder, authority, and recipient decisions for an "
|
||||
"organization function grant."
|
||||
),
|
||||
kind="grant",
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def _contribution(
|
||||
*,
|
||||
module_version: str,
|
||||
definition_key: str,
|
||||
name: str,
|
||||
description: str,
|
||||
kind: str,
|
||||
) -> WorkflowDefinitionContribution:
|
||||
return WorkflowDefinitionContribution(
|
||||
origin_module_id="idm",
|
||||
origin_module_version=module_version,
|
||||
definition_key=definition_key,
|
||||
name=name,
|
||||
description=description,
|
||||
graph=_graph(kind=kind),
|
||||
scope_type="system",
|
||||
inherit_to_lower_scopes=True,
|
||||
allow_start=True,
|
||||
allow_reuse=False,
|
||||
allow_automation=False,
|
||||
execution_mode="guided",
|
||||
activate_on_install=True,
|
||||
metadata={
|
||||
"domain": "idm.function_assignment_change",
|
||||
"change_kind": kind,
|
||||
"state_owner": "idm",
|
||||
},
|
||||
policy_metadata={
|
||||
"governance_capability": ("policy.functionAssignmentGovernance"),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def _graph(*, kind: str) -> dict[str, object]:
|
||||
return {
|
||||
"schema_version": 1,
|
||||
"nodes": [
|
||||
{
|
||||
"id": "start",
|
||||
"type": "workflow.start.manual",
|
||||
"label": "Submitted",
|
||||
"position": {"x": 20, "y": 120},
|
||||
"config": {
|
||||
"input_schema_ref": (f"govoplan/idm/function-assignment-{kind}.v1"),
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": "holder_review",
|
||||
"type": "workflow.review",
|
||||
"label": "Holder review",
|
||||
"position": {"x": 230, "y": 120},
|
||||
"config": {
|
||||
"title": "Holder review",
|
||||
"reviewer": "effective-holder",
|
||||
"required_evidence": [],
|
||||
"view_surface_ids": [
|
||||
"idm.action.view-function-assignments",
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": "authority_review",
|
||||
"type": "workflow.review",
|
||||
"label": "Authority clearance",
|
||||
"position": {"x": 470, "y": 120},
|
||||
"config": {
|
||||
"title": "Authority clearance",
|
||||
"reviewer": "designated-authority",
|
||||
"required_evidence": [],
|
||||
"view_surface_ids": [
|
||||
"idm.action.view-function-assignments",
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": "recipient_review",
|
||||
"type": "workflow.review",
|
||||
"label": "Recipient acceptance",
|
||||
"position": {"x": 730, "y": 120},
|
||||
"config": {
|
||||
"title": "Recipient acceptance",
|
||||
"reviewer": "candidate",
|
||||
"required_evidence": [],
|
||||
"view_surface_ids": [
|
||||
"idm.action.view-function-assignments",
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": "completed",
|
||||
"type": "workflow.end.completed",
|
||||
"label": "Approved",
|
||||
"position": {"x": 990, "y": 70},
|
||||
"config": {"output_mapping": {}},
|
||||
},
|
||||
{
|
||||
"id": "rejected",
|
||||
"type": "workflow.end.cancelled",
|
||||
"label": "Rejected",
|
||||
"position": {"x": 990, "y": 230},
|
||||
"config": {"reason": "Function assignment change rejected"},
|
||||
},
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"id": "start-holder",
|
||||
"source": "start",
|
||||
"target": "holder_review",
|
||||
},
|
||||
{
|
||||
"id": "holder-authority",
|
||||
"source": "holder_review",
|
||||
"source_port": "approved",
|
||||
"target": "authority_review",
|
||||
},
|
||||
{
|
||||
"id": "holder-rejected",
|
||||
"source": "holder_review",
|
||||
"source_port": "rejected",
|
||||
"target": "rejected",
|
||||
},
|
||||
{
|
||||
"id": "authority-recipient",
|
||||
"source": "authority_review",
|
||||
"source_port": "approved",
|
||||
"target": "recipient_review",
|
||||
},
|
||||
{
|
||||
"id": "authority-rejected",
|
||||
"source": "authority_review",
|
||||
"source_port": "rejected",
|
||||
"target": "rejected",
|
||||
},
|
||||
{
|
||||
"id": "recipient-completed",
|
||||
"source": "recipient_review",
|
||||
"source_port": "approved",
|
||||
"target": "completed",
|
||||
},
|
||||
{
|
||||
"id": "recipient-rejected",
|
||||
"source": "recipient_review",
|
||||
"source_port": "rejected",
|
||||
"target": "rejected",
|
||||
},
|
||||
],
|
||||
"metadata": {
|
||||
"notation": "govoplan.workflow.native",
|
||||
"domain": "idm.function_assignment_change",
|
||||
"change_kind": kind,
|
||||
"optional_steps": [
|
||||
"holder_review",
|
||||
"authority_review",
|
||||
"recipient_review",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
__all__ = ["function_assignment_workflow_definitions"]
|
||||
Reference in New Issue
Block a user