Repository navigation
feat(dar): Policy Agent governance workflow node for Data Access Requests - #28269
Conversation
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
There was a problem hiding this comment.
Pull request overview
Adds scaffolding for a new PolicyAgent automated task node in the Data Access Request (DAR) governance workflow, plus a new workflow node factory extension point so downstream distributions (e.g., Collate) can plug in node implementations without modifying OSS NodeFactory.
Changes:
- Introduces
NodeFactoryRegistryand routesPOLICY_AGENT_TASKcreation through it (Collate-provided implementation). - Extends schemas/specs for
policyAgentTask(node subtype + node definition) and updates DAR-related policy config schema (accessType/requestedAccess + columns + duration). - Updates UI workflow builder mappings/icons for the new node subtype and adjusts task due-date handling based on ISO-8601
durationfor granted tasks (with tests).
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| openmetadata-ui/src/main/resources/ui/src/utils/NodeIconUtils.tsx | Adds icon selection for PolicyAgentTask nodes. |
| openmetadata-ui/src/main/resources/ui/src/generated/governance/workflows/elements/nodeSubType.ts | Adds PolicyAgentTask to generated NodeSubType enum. |
| openmetadata-ui/src/main/resources/ui/src/constants/WorkflowBuilder.constants.ts | Adds workflow-builder type/label mapping for PolicyAgentTask. |
| openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedPanel/TaskPanelHeader.tsx | Adds “granted” styling state for task status badge. |
| openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedPanel/feed-panel-header.less | Adds CSS styling for the “granted” status badge. |
| openmetadata-spec/src/main/resources/json/schema/metadataIngestion/policyagentconfig/databasePolicyConfig.json | Replaces privilege with accessType/requestedAccess, adds columns + duration, updates required fields. |
| openmetadata-spec/src/main/resources/json/schema/governance/workflows/elements/nodeSubType.json | Adds policyAgentTask to the workflow NodeSubType enum schema. |
| openmetadata-spec/src/main/resources/json/schema/governance/workflows/elements/nodes/automatedTask/policyAgentTaskDefinition.json | Introduces schema for the policyAgentTask automated node definition. |
| openmetadata-spec/src/main/resources/json/schema/api/governance/createWorkflowDefinition.json | Allows workflow definitions to reference the new policyAgentTask node schema. |
| openmetadata-spec/src/main/java/org/openmetadata/schema/governance/workflows/elements/WorkflowNodeDefinitionInterface.java | Registers PolicyAgentTaskDefinition as a Jackson subtype (policyAgentTask). |
| openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/CreateTaskTest.java | Adds unit tests for duration-based due date resolution/parsing. |
| openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/elements/NodeFactoryTest.java | Adds tests asserting POLICY_AGENT_TASK delegates to the registry. |
| openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/elements/NodeFactoryRegistryTest.java | Adds tests for registry singleton and registration behavior. |
| openmetadata-service/src/main/resources/json/data/governance/workflows/DataAccessRequestTaskWorkflow.json | Removes the DAR workflow seed JSON (entire file deleted). |
| openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/CreateTask.java | Computes “effective due date” from ISO-8601 duration when status becomes Granted. |
| openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/NodeFactoryRegistry.java | Adds singleton registry for external node factory extensions. |
| openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/NodeFactory.java | Routes POLICY_AGENT_TASK creation through NodeFactoryRegistry with a Collate-only fallback error. |
| LOG.warn("No workflow node factory registered for subtype: {}", subType); | ||
| return Optional.empty(); | ||
| } | ||
| return Optional.of(ext.create(nodeDefinition, config, workflowDefinitionName)); |
| try { | ||
| return LocalDate.now(ZoneOffset.UTC) | ||
| .plus(Period.parse(duration)) | ||
| .atStartOfDay(ZoneOffset.UTC) | ||
| .toInstant() | ||
| .toEpochMilli(); |
| @Test | ||
| @Order(3) | ||
| void testCreateReturnsEmptyForUnregisteredSubtype() { | ||
| // POLICY_AGENT_TASK is not registered in OSS — the handler lives in Collate. | ||
| Optional<NodeInterface> result = | ||
| NodeFactoryRegistry.getInstance() | ||
| .create(NodeSubType.POLICY_AGENT_TASK, null, null, "TestWorkflow"); | ||
|
|
||
| assertTrue(result.isEmpty()); | ||
| } |
| // ---- resolveEffectiveDueDate ---- | ||
|
|
||
| @Test | ||
| void testResolveEffectiveDueDatePreservesRequestedDueDateForNonGrantedStatus() { | ||
| Long requested = 999L; |
| void testPolicyAgentTaskThrowsWhenRegistryReturnsEmpty() { | ||
| // Simulate no Collate handler registered: replace with a registry that produces empty. | ||
| // We can't clear the singleton, so we verify the orElseThrow contract by replacing | ||
| // the registered extension with one that mimics an absent registration. | ||
| NodeFactoryRegistry registry = NodeFactoryRegistry.getInstance(); | ||
|
|
||
| // Temporarily point POLICY_AGENT_TASK to a handler that throws to exercise | ||
| // the IllegalStateException contract of NodeFactory.createNode(). | ||
| registry.register( | ||
| NodeSubType.POLICY_AGENT_TASK, | ||
| (def, cfg, name) -> { | ||
| throw new IllegalStateException( | ||
| "policyAgentTask is a Collate-only feature — handler not registered"); | ||
| }); |
✅ TypeScript Types Auto-UpdatedThe generated TypeScript types have been automatically updated based on JSON schema changes in this PR. |
…and CreateTask - Use Optional.ofNullable instead of Optional.of in NodeFactoryRegistry so a null return from an extension produces the meaningful orElseThrow error instead of a cryptic NPE - Fix Period-based duration in parseMillisFromIso8601Duration to use ZonedDateTime instead of LocalDate so month/year durations (e.g. P1M) preserve the time-of-day rather than snapping to midnight Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 24 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
openmetadata-service/src/main/resources/json/data/governance/workflows/DataAccessRequestTaskWorkflow.json:1
- This workflow definition JSON appears to be removed. OSS bootstrapping/tests reference
DataAccessRequestTaskWorkflow(e.g., DataAccessRequest form schema + integration tests) and expect it to be seeded on startup; deleting this file will break DAR lifecycle in OSS unless it is replaced by another workflow definition with the same name.
| try { | ||
| return ZonedDateTime.now(ZoneOffset.UTC) | ||
| .plus(Period.parse(duration)) | ||
| .toInstant() | ||
| .toEpochMilli(); |
| @Test | ||
| @Order(3) | ||
| void testCreateReturnsEmptyForUnregisteredSubtype() { | ||
| // POLICY_AGENT_TASK is not registered in OSS — the handler lives in Collate. | ||
| Optional<NodeInterface> result = | ||
| NodeFactoryRegistry.getInstance() | ||
| .create(NodeSubType.POLICY_AGENT_TASK, null, null, "TestWorkflow"); | ||
|
|
||
| assertTrue(result.isEmpty()); | ||
| } |
| @BeforeEach | ||
| void registerPolicyAgentStub() { | ||
| // Register a no-op stub so POLICY_AGENT_TASK tests are independent of whether | ||
| // NodeFactoryRegistryTest has already run in this JVM. | ||
| NodeFactoryRegistry.getInstance() | ||
| .register(NodeSubType.POLICY_AGENT_TASK, (def, cfg, name) -> STUB); | ||
| } |
| @Test | ||
| void testPolicyAgentTaskThrowsWhenRegistryReturnsEmpty() { | ||
| // Simulate no Collate handler registered: replace with a registry that produces empty. | ||
| // We can't clear the singleton, so we verify the orElseThrow contract by replacing | ||
| // the registered extension with one that mimics an absent registration. | ||
| NodeFactoryRegistry registry = NodeFactoryRegistry.getInstance(); | ||
|
|
||
| // Temporarily point POLICY_AGENT_TASK to a handler that throws to exercise | ||
| // the IllegalStateException contract of NodeFactory.createNode(). | ||
| registry.register( | ||
| NodeSubType.POLICY_AGENT_TASK, | ||
| (def, cfg, name) -> { | ||
| throw new IllegalStateException( | ||
| "policyAgentTask is a Collate-only feature — handler not registered"); | ||
| }); | ||
|
|
| LOG.info("Registering workflow node factory for subtype: {}", subType); | ||
| extensions.put(subType, extension); | ||
| } | ||
|
|
| "columns": { | ||
| "description": "List of column names requested when accessType is ColumnLevel.", | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| } | ||
| }, |
🟡 Playwright Results — all passed (17 flaky)✅ 4184 passed · ❌ 0 failed · 🟡 17 flaky · ⏭️ 90 skipped
🟡 17 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
…ackfill DataConsumerPolicy Create rule - SetApprovalAssigneesImpl: add else branch to log when workflow-managed task creator is removed and task left unassigned (addresses Gitar review) - v200 migration: add addCreateTaskRuleToDataConsumerPolicy to backfill the DataConsumerPolicy-CreateTask-Rule that was added to the seed JSON in #28044 but missing from the migration step for existing installations Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
| label: 'Policy Enforcement', | ||
| displayLabel: 'Policy Enforcement', |
| &.granted { | ||
| background-color: #e6fffb; | ||
| color: #13c2c2; | ||
| } |
…xercise orElseThrow path Use deregister() so NodeFactoryRegistry.create() returns Optional.empty() and the orElseThrow supplier in NodeFactory.createNode fires — the actual contract under test. The previous approach threw from inside the factory extension, bypassing orElseThrow entirely. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Code Review ✅ Approved 3 resolved / 3 findingsImplements the PolicyAgent governance workflow node and registry-based factory extensibility, while resolving singleton test pollution and adding critical self-approval prevention logs. Migration support for existing DataConsumerPolicy rules is also included with no outstanding issues. ✅ 3 resolved✅ Bug: Singleton registry makes test classes order-dependent
✅ Edge Case: parseMillisFromIso8601Duration: "P14D" gives time-of-day precision but "P1M" snaps to start-of-day
✅ Quality: Missing debug log for workflow-managed empty assignees case
OptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
|
|



Summary
Implements the PolicyAgent automated task node in the Data Access Request (DAR) governance workflow. This PR contains the OpenMetadata-side scaffolding — the Collate-specific implementation lives in the openmetadata-collate repo.
What's in this PR
Node factory extensibility (
NodeFactory+NodeFactoryRegistry)NodeFactoryRegistry— new extension point that allows Collate (or any downstream) to register additional node types without modifyingNodeFactorydirectlyNodeFactorydelegates to registered factories before falling back to its own switch — zero changes needed in OpenMetadata when Collate adds new node typesPolicyAgent node scaffolding
policyAgentTaskDefinition.json— JSON schema for thepolicyAgentTasknode subtype:waitForCompletion,timeoutSeconds,inputNamespaceMapnodeSubType.json—policyAgentTaskadded to theNodeSubTypeenumNodeFactory—POLICY_AGENT_TASKcase wired (stub; concrete impl registered by Collate viaNodeFactoryRegistry)Workflow definition update
DataAccessRequestTaskWorkflow.json— base workflow updated; Collate overrides this with the full PolicyAgent node wiringSchema
databasePolicyConfig.json—columns: string[]field added for ColumnLevel access requests;accessTypeandrequestedAccessenums aligned withdataAccessRequestPayload.jsonSelf-approval prevention for workflow-managed tasks
SetApprovalAssigneesImpl— when a task is workflow-managed (taskWorkflowManaged=true) and the only reviewer is the task creator, the creator is now correctly excluded from assignees and the task is left unassigned (assignees=[]).hasAssigneesremainstruefor managed tasks regardless of assignee count, so no task is lost. Previously the creator was always re-added when the list emptied, defeating the self-approval guard for managed tasks.Tests
NodeFactoryTest— coversPOLICY_AGENT_TASKdispatch; adds@AfterEachcleanup to prevent singleton pollution across test classesNodeFactoryRegistryTest— covers custom factory registration and fallback behaviourCreateTaskTest— coversavailableTransitionspopulation fromtransitionMetadataSetApprovalAssigneesImplTest— addedtestSelfApprovalPrevention_workflowManagedTaskRemovesCreatorAndLeavesTaskUnassignedcovering the workflow-managed self-approval caseDepends on / related
Test plan
NodeFactoryRegistryTest— custom factory registered, dispatched, fallback to built-inNodeFactoryTest—POLICY_AGENT_TASKdispatches correctly; singleton cleanup prevents cross-test pollutionCreateTaskTest—availableTransitionsbuilt fromtransitionMetadataon node configSetApprovalAssigneesImplTest— workflow-managed self-approval prevention leaves assignees empty and hasAssignees=truemvn -pl openmetadata-spec clean install -DskipTestsmvn -pl openmetadata-service clean package -DskipTests🤖 Generated with Claude Code
Summary by Gitar
addCreateTaskRuleToDataConsumerPolicytoMigrationUtilto backfill theCreateoperation rule for thetaskresource inDataConsumerPolicy.mysqlandpostgresv200 migration paths to ensure existing installations support task creation.SetApprovalAssigneesImplto add debug logging for workflow-managed tasks when the creator is removed to prevent self-approval.This will update automatically on new commits.