Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Agents' glossary-term proposals are decided through the approval workflow

- **Status:** Accepted
- **Revisions:** v1 2026-10-22 (initial) · v2 2026-10-23 (a proposal branch after the start; lifecycles ask for an approval)
- **Revisions:** v1 2026-10-22 (initial) · v2 2026-10-23 (a proposal branch after the start; lifecycles ask for an approval) · v3 2026-11-25 (a sole editor no longer keeps their own approval)
- **Deciders:** Pere Miquel Brull
- **Guard:** `GlossaryTermAutomationDraftIT`, `JSONLogicSearchClassBase.test.ts`, Collate `LifecycleWorkflow.behavior.test.ts`, `WorkflowEventConsumerTest`, `GlossaryApprovalWorkflowReviewTest`, `GlossaryAutomationReviewMigrationTest`, `GlossaryTermRepositoryStageDecisionTest`, `AutomationProposalsTest`, `ContextMemoryDerivationIT`, `useGlossaryProposals.test.tsx`, `ProposalCard.test.tsx`, `GlossaryAiGeneratedTerm.spec.ts`
- **Related:** ADR:2026-10-19-memories-become-draft-glossary-terms-through-the-ai-provider
Expand Down Expand Up @@ -91,3 +91,11 @@ A reviewer's own edit still approves a proposal, as it approves any term: the br
term nobody can be assigned is approved as before (v1's admin fallback on them, and its
consequence for reviewers that are teams without members, is withdrawn), and the migration no
longer touches them.

## Amendment (v3, 2026-11-25)

- **A sole reviewer or owner who made the edit no longer keeps it.** v1's "a sole one keeps it" is
withdrawn: the editor is left off the assignees even when nobody else remains, and the step's
empty-assignee strategy decides, as it does when no approver resolves at all. A task kept by its
editor was filed by them and could not be resolved by them. See
ADR:2026-11-25-an-approval-never-goes-to-its-requester.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# An approval never goes to its requester

- **Status:** Accepted
- **Revisions:** v1 2026-11-25 (initial)
- **Deciders:** Ram Narayan Balaji
- **Guard:** `WorkflowDefinitionResourceIT.test_editorWhoIsTheOnlyApproverIsNeverAskedToApprove`,
`WorkflowDefinitionResourceIT.test_editorIsLeftOffTheApprovalWhenSomeoneElseCanApprove`,
`SetApprovalAssigneesImplTest.testSelfApprovalPrevention_eventDrivenSoleRequester_*`
- **Related:** ADR:2026-11-12-approval-threshold-never-exceeds-eligible-voters;
amends ADR:2026-10-22-agent-glossary-proposals-are-decided-through-the-approval-workflow
(withdraws its "a sole one keeps it" consequence)

## Context

An approval node resolves its assignees from the entity's owners, reviewers and named candidates,
then removes the requester, the user whose edit started the run. For workflows not managed by a
task workflow, an emptied list was given back to the requester when the node's empty-assignee
strategy was `none`, to keep the task "actionable". It was not actionable: the task is filed by the
requester, and `TaskAuthorPolicy` denies a task's filer `ResolveTask`. The requester was the only
assignee and could not approve, so the run waited until an admin, who bypasses the policy, found
and resolved a task assigned to someone else. This hit any workflow whose approval node kept the
default strategy, for example a reviewers-only approval of a data contract edited by its only
reviewer.

## Decision

The requester is never an assignee of an approval their own edit started, in any workflow and
under any empty-assignee strategy. When removing the requester leaves no one, the node's strategy
decides:

- `none` approves automatically, as it does when no approver resolves at all;
- `assignAdmins` assigns the platform admins other than the requester;
- `wait` opens the task with no assignee.

## Consequences

A workflow that must never approve an edit on its own when the editor is the only approver
configures `assignAdmins` or `wait`; lifecycle playbooks and the data access request workflow
already do. Under `none`, an edit by an entity's only approver is approved without review, which is
the documented meaning of `none`. Revisit only if `none` itself should stop approving automatically.

On upgrade, an existing workflow under `none` stops opening these tasks: an edit by the entity's
only approver, which used to wait for an admin to step in, is approved automatically. A workflow
that relied on that wait switches the node to `wait` or `assignAdmins`.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
import org.junit.jupiter.api.parallel.Isolated;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.junitpioneer.jupiter.RetryingTest;
import org.openmetadata.it.bootstrap.SharedEntities;
import org.openmetadata.it.factories.DatabaseSchemaTestFactory;
Expand All @@ -104,6 +107,7 @@
import org.openmetadata.schema.api.data.CreateChart;
import org.openmetadata.schema.api.data.CreateDashboard;
import org.openmetadata.schema.api.data.CreateDashboardDataModel;
import org.openmetadata.schema.api.data.CreateDataContract;
import org.openmetadata.schema.api.data.CreateDatabase;
import org.openmetadata.schema.api.data.CreateDatabaseSchema;
import org.openmetadata.schema.api.data.CreateGlossary;
Expand Down Expand Up @@ -134,6 +138,7 @@
import org.openmetadata.schema.entity.data.APIEndpoint;
import org.openmetadata.schema.entity.data.Chart;
import org.openmetadata.schema.entity.data.Dashboard;
import org.openmetadata.schema.entity.data.DataContract;
import org.openmetadata.schema.entity.data.Database;
import org.openmetadata.schema.entity.data.DatabaseSchema;
import org.openmetadata.schema.entity.data.Glossary;
Expand All @@ -159,6 +164,7 @@
import org.openmetadata.schema.governance.workflows.AutomaticApprovalReason;
import org.openmetadata.schema.governance.workflows.WorkflowDefinition;
import org.openmetadata.schema.governance.workflows.WorkflowInstance;
import org.openmetadata.schema.governance.workflows.elements.nodes.userTask.Assignees__1.EmptyAssigneeStrategy;
import org.openmetadata.schema.services.connections.api.OpenAPISchemaURL;
import org.openmetadata.schema.services.connections.api.RestConnection;
import org.openmetadata.schema.services.connections.database.MysqlConnection;
Expand Down Expand Up @@ -18436,4 +18442,197 @@ void test_onlyTheAssigneesDecideAWorkflowApproval(TestNamespace ns) throws Excep
.resolve(task.getId().toString(), approve);
awaitApprovedApprovalTask(client, tag.getFullyQualifiedName());
}

/** Who an approval node asks: the contract's owners, its reviewers, or both. */
private enum ApproverSource {
OWNERS(true, false),
REVIEWERS(false, true),
OWNERS_AND_REVIEWERS(true, true);

private final boolean addOwners;
private final boolean addReviewers;

ApproverSource(boolean addOwners, boolean addReviewers) {
this.addOwners = addOwners;
this.addReviewers = addReviewers;
}
}

private static Stream<Arguments> approverSourcesAndEmptyAssigneeStrategies() {
return Stream.of(ApproverSource.values())
.flatMap(
source ->
Stream.of(EmptyAssigneeStrategy.values())
.map(strategy -> Arguments.of(source, strategy)));
}

@ParameterizedTest(name = "{0} / {1}")
@MethodSource("approverSourcesAndEmptyAssigneeStrategies")
void test_editorWhoIsTheOnlyApproverIsNeverAskedToApprove(
ApproverSource source, EmptyAssigneeStrategy strategy, TestNamespace ns) throws Exception {
OpenMetadataClient admin = SdkClients.adminClient();
User steward = createPlainUser(admin, "steward");
// The steward owns and reviews the contract, so every source resolves to the steward alone.
DataContract contract =
createContract(
ns, List.of(steward.getEntityReference()), List.of(steward.getEntityReference()));
String workflowName = createContractApprovalWorkflow(contract, source, strategy);

editDescriptionAs(steward, contract);

switch (strategy) {
case NONE -> {
// Nobody else can approve, so the node approves instead of asking the steward.
JsonNode instance = awaitOnlyInstanceEnded(admin, workflowName);
assertEquals(
WorkflowInstance.WorkflowStatus.FINISHED.value(),
instance.path("status").asText(),
instance.toString());
assertTrue(
listOpenApprovalTasks(admin, contract.getFullyQualifiedName()).getData().isEmpty(),
"no approval task may be opened for the steward's own edit");
}
case ASSIGN_ADMINS -> {
UUID adminId = admin.users().getByName("admin").getId();
Task task =
awaitOpenApprovalTaskAssignedTo(admin, contract.getFullyQualifiedName(), adminId);
assertFalse(assigneeNames(task).contains(steward.getName()), assigneeNames(task)::toString);
}
case WAIT -> {
Task task = awaitOpenApprovalTask(admin, contract.getFullyQualifiedName());
assertTrue(assigneeNames(task).isEmpty(), assigneeNames(task)::toString);
}
}
}

@ParameterizedTest(name = "{0} / {1}")
@MethodSource("approverSourcesAndEmptyAssigneeStrategies")
void test_editorIsLeftOffTheApprovalWhenSomeoneElseCanApprove(
ApproverSource source, EmptyAssigneeStrategy strategy, TestNamespace ns) throws Exception {
OpenMetadataClient admin = SdkClients.adminClient();
User steward = createPlainUser(admin, "steward");
User colleague = createPlainUser(admin, "colleague");
EntityReference stewardRef = steward.getEntityReference();
EntityReference colleagueRef = colleague.getEntityReference();
// The steward stays an owner so they may edit; the colleague is reachable through each source.
List<EntityReference> owners =
source == ApproverSource.REVIEWERS
? List.of(stewardRef)
: List.of(stewardRef, colleagueRef);
List<EntityReference> reviewers =
source == ApproverSource.OWNERS ? List.of() : List.of(stewardRef, colleagueRef);
DataContract contract = createContract(ns, owners, reviewers);
createContractApprovalWorkflow(contract, source, strategy);

editDescriptionAs(steward, contract);

Task task =
awaitOpenApprovalTaskAssignedTo(admin, contract.getFullyQualifiedName(), colleague.getId());
assertEquals(Set.of(colleague.getName()), assigneeNames(task));
}

private static User createPlainUser(OpenMetadataClient admin, String role) {
String name = "%s_%s".formatted(role, UUID.randomUUID().toString().substring(0, 8));
return admin
.users()
.create(
new CreateUser()
.withName(name)
.withEmail(name + "@example.com")
.withPassword("password123"));
}

private static DataContract createContract(
TestNamespace ns, List<EntityReference> owners, List<EntityReference> reviewers) {
DatabaseSchema schema = DatabaseSchemaTestFactory.createSimple(ns);
Table table = TableTestFactory.createSimple(ns, schema.getFullyQualifiedName());
return SdkClients.adminClient()
.dataContracts()
.create(
new CreateDataContract()
.withName("contract_" + UUID.randomUUID().toString().substring(0, 8))
.withDescription("initial")
.withEntity(table.getEntityReference())
.withOwners(owners)
.withReviewers(reviewers));
}

private String createContractApprovalWorkflow(
DataContract contract, ApproverSource source, EmptyAssigneeStrategy strategy)
throws Exception {
ensureWorkflowEventConsumerIsActive(SdkClients.adminClient());
String workflowName = "editorApproval" + UUID.randomUUID().toString().substring(0, 8);
String onlyThisContract =
"{\"!=\":[{\"var\":\"fullyQualifiedName\"},\"%s\"]}"
.formatted(contract.getFullyQualifiedName());
String json =
"""
{
"name": "%s",
"description": "Approval of data contract edits",
"trigger": {
"type": "eventBasedEntity",
"config": {
"entityTypes": ["dataContract"],
"events": ["Updated"],
"exclude": ["reviewers"],
"filter": %s
},
"output": ["relatedEntity", "updatedBy"]
},
"nodes": [
{"type": "startEvent", "subType": "startEvent", "name": "StartNode"},
{"type": "endEvent", "subType": "endEvent", "name": "EndNode"},
{
"type": "userTask",
"subType": "userApprovalTask",
"name": "EditApproval",
"config": {
"assignees": {
"addOwners": %s,
"addReviewers": %s,
"candidates": [],
"emptyAssigneeStrategy": "%s"
},
"approvalThreshold": 1,
"rejectionThreshold": 1
},
"input": ["relatedEntity"],
"inputNamespaceMap": {"relatedEntity": "global"},
"output": ["updatedBy"],
"branches": ["true", "false"]
}
],
"edges": [
{"from": "StartNode", "to": "EditApproval"},
{"from": "EditApproval", "to": "EndNode", "condition": "approve"},
{"from": "EditApproval", "to": "EndNode", "condition": "reject"}
]
}
"""
.formatted(
workflowName,
JsonUtils.pojoToJson(Map.of("dataContract", onlyThisContract)),
source.addOwners,
source.addReviewers,
strategy.value());
createWorkflow((ObjectNode) MAPPER.readTree(json), workflowName);
return workflowName;
}

private static void editDescriptionAs(User editor, DataContract contract) throws Exception {
SdkClients.createClient(editor.getName(), editor.getEmail(), new String[] {})
.dataContracts()
.patch(
contract.getId().toString(),
MAPPER.readTree(
"[{\"op\":\"replace\",\"path\":\"/description\",\"value\":\"edited by %s\"}]"
.formatted(editor.getName())));
}

private static Set<String> assigneeNames(Task task) {
return listOrEmpty(task.getAssignees()).stream()
.map(EntityReference::getName)
.collect(Collectors.toSet());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.openmetadata.schema.utils.ResultList;
import org.openmetadata.service.Entity;
import org.openmetadata.service.exception.EntityNotFoundException;
import org.openmetadata.service.governance.approval.ChangeRequestRun;
import org.openmetadata.service.governance.workflows.WorkflowVariableHandler;
import org.openmetadata.service.governance.workflows.WorkflowVariableHandler.InputNamespaces;
import org.openmetadata.service.jdbi3.EntityRepository;
Expand Down Expand Up @@ -209,28 +208,19 @@ && cascadesOwners(assigneesConfig)) {
// (DAR, GlossaryApproval, RequestApproval) publish the requester as `taskUpdatedBy`; entity
// workflows (glossary term / tag approval, certification changes, …) publish it as the
// global `updatedBy`. Both are checked because each variable is authoritative for its own
// workflow family — reading only one silently leaves the other's requester on the list. A
// non-workflow-managed task under the "none" strategy keeps the requester when no one else is
// available, so the task stays actionable; "assignAdmins" and "wait" have a fallback of their
// own below, and workflow-managed tasks rely on it too. A change request is never given back
// to its requester.
// workflow family — reading only one silently leaves the other's requester on the list. The
// requester is never given back their own approval, even when no one else is left: the task
// would be filed by them, and TaskAuthorPolicy denies a filer ResolveTask, so only an admin
// could act on it. An emptied list goes to the empty-assignee strategy below instead.
// ADR:2026-11-25-an-approval-never-goes-to-its-requester
// A stored definition may carry the key with a null value; it means the default, none.
final EmptyAssigneeStrategy emptyAssigneeStrategy =
Optional.ofNullable(assigneesConfig.get("emptyAssigneeStrategy"))
.map(String::valueOf)
.map(EmptyAssigneeStrategy::fromValue)
.orElse(NONE);
final boolean assignAdmins = emptyAssigneeStrategy == ASSIGN_ADMINS;
List<String> preRemovalAssignees = new ArrayList<>(assigneeList);
boolean removedRequester = assigneeList.removeAll(requesterEntityLinks);
boolean reviewsChangeRequest = ChangeRequestRun.from(varHandler).isPresent();
if (removedRequester
&& assigneeList.isEmpty()
&& !workflowManagedTask
&& !reviewsChangeRequest
&& emptyAssigneeStrategy == NONE) {
assigneeList.addAll(preRemovalAssignees);
}
assigneeList.removeAll(requesterEntityLinks);

// Empty-assignee strategy: when nothing resolved (no reviewers/owners, or the only
// assignee was the requester and was stripped above), apply the node's configured
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,9 @@ void testSelfApprovalPrevention_workflowManagedTaskRemovesCreatorAndLeavesTaskUn
}

@Test
void testSelfApprovalPrevention_eventDrivenSoleRequester_keptWhenNoOneElse() {
// Event-driven approval (not workflow-managed, not a change request): the only reviewer is the
// requester, who is kept so the task stays actionable.
void testSelfApprovalPrevention_eventDrivenSoleRequester_neverAssignedAndAutoApproved() {
// Event-driven approval whose only reviewer is the requester: the requester is never their own
// approver (as filer they could not resolve it), so under "none" the node approves.
EntityReference creatorRef =
new EntityReference().withType("user").withFullyQualifiedName("alice");

Expand All @@ -456,9 +456,27 @@ void testSelfApprovalPrevention_eventDrivenSoleRequester_keptWhenNoOneElse() {

delegate.execute(execution);

assertEquals("[]", capturedVars.get("ApprovalTask_assignees"));
assertFalse((Boolean) capturedVars.get("hasAssignees"));
}

@Test
void testSelfApprovalPrevention_eventDrivenSoleRequester_routedToOtherAdmins() {
EntityReference creatorRef =
new EntityReference().withType("user").withFullyQualifiedName("alice");
when(mockEntity.getReviewers()).thenReturn(List.of(creatorRef));
when(execution.getVariable("global_updatedBy")).thenReturn("alice");
givenAdmins("alice", "platform_admin");
when(assigneesExpr.getValue(execution))
.thenReturn(
"{\"addReviewers\":true,\"addOwners\":false,\"users\":[],\"teams\":[],\"emptyAssigneeStrategy\":\"assignAdmins\"}");

delegate.execute(execution);

String assigneesJson = (String) capturedVars.get("ApprovalTask_assignees");
assertNotNull(assigneesJson);
assertTrue(assigneesJson.contains("alice"), "sole requester is kept outside change requests");
assertTrue(assigneesJson.contains("platform_admin"), assigneesJson);
assertFalse(assigneesJson.contains("<#E::user::alice>"), assigneesJson);
assertTrue((Boolean) capturedVars.get("hasAssignees"));
}

@Test
Expand Down
Loading