Repository navigation
Fixes #34540: Support a shared lifecycle stage on entities and let active workflows own it - #34541
Conversation
…tive workflows own it Every entity type whose schema declares entityStatus now gets its lifecycle stage rules from EntityRepository instead of a schema default, so they live in one place: - A new entity starts in its type's stage: Draft for domains, data products, glossaries, articles, ontology axioms, data contracts and AI assets; Approved for assets that come from the data infrastructure. Metrics and glossary terms start Draft only when they have reviewers. - A PUT, bulk upsert or CSV import whose request carries no stage keeps the stage the entity is in instead of resetting it. - While a deployed, unsuspended governance workflow sets an entity type's stage, only that workflow (acting as the governance bot) may change it. A direct change is rejected with 403, and a create that asks for a stage the workflow owns starts in the type's own stage. The workflow's trigger filter decides which entities it owns; suspending it releases them. - GET /v1/metadata/types/lifecycleStages lists the stages and, per entity type, the workflows that own its stage. - Context memories move from their own Draft/Active/Archived status onto entityStatus. The 2.1.0 migration converts stored memories and their version history (Active becomes Approved). - The approval-task closing, in-review delete and reviewer rules that seven repositories each duplicated are shared now, with per-type flags keeping each rule on the entity types that had it. - A consolidated update no longer re-validates a stage change that an earlier version made, such as a workflow approving on the user's behalf. - createOntologyAxiom no longer requires entityStatus, and DataProduct lifecycleStage is deprecated in favor of entityStatus. BaseEntityIT checks the stage rules for every entity type; types without a lifecycle (users, teams, test suites, ...) opt out.
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
✅ Generated Sources Auto-UpdatedThe generated TypeScript types ( |
- Keep main's starting stages: entities start Unprocessed unless their type derives one (glossary terms and metrics from reviewers, ontology axioms Draft, system relationship types and memories Approved); keep DataProduct lifecycleStage instead of deprecating it. - Record governance-bot impersonation on page, ontologyAxiom, relationshipType, contextMemory and AI asset schemas, so a workflow's own Set Action is not rejected by the stage lock it holds. - Apply the stage rules to batched CSV import updates (workflow lock, lifecycle moves, keep stored stage when the row has none) and keep a blank glossary status instead of resetting it to Draft. - Skip workflow definitions this server cannot read when resolving stage ownership instead of failing every stage change. - Restore the in-review delete flag on Tag and TestCase. - Seed glossary status-filter Playwright specs with their glossary excluded from the approval workflow, and update ITs for main's starting stages.
🔄 Playwright impact map auto-refreshedThis PR touched specs or UI source that changed the source→spec routing map. I regenerated What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit: python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit # or a separate commit |
✅ Generated Sources Auto-UpdatedThe generated TypeScript types ( |
- A workflow's approval task already decides who may approve (reviewers, owners or named candidates), so its write no longer fails the reviewer rule when an owner or candidate approves; direct edits and imports keep the rule. - Load reviewers, inherited ones included, before checking an import row that moves an entity out of review, since import rows are matched from stored JSON that holds no relationship fields.
- ClassificationResourceIT expects a new classification to start Unprocessed again, as on main. - The metric CSV-update Playwright test leaves the status cell blank: the fixture metric is In Review under MetricApprovalWorkflow, so a CSV row cannot move its stage, and a blank status keeps it.
An import row is matched from stored JSON, which holds no reviewers, so the reviewer rule only works on import because applyEntityStatusRulesForImport reloads them. The test imports a classification CSV as admin that approves two tags in review: the one another user reviews fails with "is not a reviewer" and stays In Review, and the one admin reviews becomes Approved. Without the reload, the non-reviewer's row goes through.
Exclude marked glossary fixtures from automatic approval during test bootstrap. Status and search tests can update stages through the API without waiting for the shared workflow event queue.
| System.setProperty("IT_BASE_URL", "http://localhost:" + APP.getLocalPort() + "/api"); | ||
|
|
||
| SharedEntities.initialize(SdkClients.adminClient()); | ||
| excludeGlossaryStatusFixturesFromApproval(); |
There was a problem hiding this comment.
💡 Edge Case: Status-fixture exclusion is skipped in external (JPW) mode
The four GlossaryTermResourceIT status tests now set term stages with a direct PATCH. They only pass because excludeGlossaryStatusFixturesFromApproval() adds an exclusion filter to GlossaryTermApprovalWorkflow. That call runs inside launcherSessionOpened, after the early return taken when JPW_MODE=external or skip.embedded.bootstrap=true. Against an external server the workflow still owns these terms, so each PATCH gets the new 403 ("stage owned by workflow") and the tests fail. To fix this, apply the exclusion whenever the suite starts, including the external path (for example, run it lazily and idempotently from GlossaryTestFactory.createForStatusTests). Alternatively, skip these tests when the exclusion isn't in place.
Was this helpful? React with 👍 / 👎
Keep status assignment before persistence while avoiding overlapping creation hooks with #34025 in the merge queue.
🚦 Removed from the merge queue —
|
Code Review 👍 Approved with suggestions 2 closed / 3 findings🔴 High risk · Workflow-owned lifecycle stages alter authorization, with a memory status migration. Adds shared lifecycle stage ownership to entities, with active workflows controlling stage transitions and per-type lifecycle declarations. Per-type flags preserve approval-task closing and reviewer rules on the types that had them, and memories migrate from 💡 Edge Case: Status-fixture exclusion is skipped in external (JPW) mode📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/bootstrap/TestSuiteBootstrap.java:180-185 📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/bootstrap/TestSuiteBootstrap.java:245 📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/bootstrap/TestSuiteBootstrap.java:256-270 📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/GlossaryTermResourceIT.java:1594-1606 📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/GlossaryTermResourceIT.java:1614-1624 📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/GlossaryTermResourceIT.java:2971-2985 📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/GlossaryTermResourceIT.java:3058-3072 The four GlossaryTermResourceIT status tests now set term stages with a direct PATCH. They only pass because ✅ 2 closed✅ Bug: Tag and TestCase lose the reviewer-only delete rule while in review
✅ Bug: CSV import reviewer check never runs: original has no reviewers
🤖 Prompt for agentsOptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
|



Describe your changes:
Fixes #34540
Lifecycle workflow playbooks move assets between lifecycle stages, so OpenMetadata needs to know which stage each entity is in and keep that stage under an active governance workflow's control. This makes the stage an entity-level concept in
EntityRepositoryinstead of a per-repository one:type/status.json), but a type can declare its own lifecycle: the stages it uses, including stages only it has, and the moves between them. Types that declare none keep the general lifecycle (any move between today's stages), so nothing changes for them, Metric included.GET /v1/metadata/types/lifecycleStageslists the stages and, per entity type, the stages it uses, the moves between them, and the workflows that own its stage.status(Draft/Active/Archived) ontoentityStatus, with a 2.1.0 migration for stored memories and their version history (Active becomes Approved). They are the first type to declare their own lifecycle: Draft, Approved and Archived.createOntologyAxiom.entityStatusis no longer required. DataProductlifecycleStagestays as it is.Type of change:
High-level design:
Approach. Every entity type whose schema declares
entityStatusshares the existingEntityStatusenum; there are no per-type stage lists, so playbooks work the same way on every type.EntityRepositoryowns the rules:defaultEntityStatus, plus aninitialEntityStatus(entity)override for the reviewer-dependent types, gives the starting stage. The schemadefaultwas removed fromtype/status.jsonand its siblings so the server decides the stage, not each generated client model.EntityUpdater.updateEntityStatuskeeps the stored stage when a request omits it, validates a change (workflow lock, then the reviewer rule, then the per-typevalidateEntityStatusTransitionhook) and records it. The reviewer rule guards direct edits and imports only: a workflow's own write skips it, because its approval task already decided who may approve (reviewers, owners or named candidates). A consolidated update re-diffs from the start of the user's session and doesn't re-validate a stage change an earlier version made, such as a workflow approving on the user's behalf.EntityStatusWorkflowsanswers which active workflows own a type's stage, or a given entity's. A workflow owns the stage when it is deployed, not suspended, triggered by the type, and has a node that setsstatus/entityStatus. The answer sits in a bounded Caffeine cache (1 entry, 30 s) that workflow create, update, delete, suspend and resume invalidate. The trigger filter is evaluated per entity throughTriggerEntityFilter, extracted fromFilterEntityImplso both share it.Workflow writes are recognized by
updatedByorimpersonatedBybeing the governance bot.RollbackEntityImplandSetGlossaryTermStatusImplnow patch impersonating the governance bot, likeSetEntityAttributeImpl. The page, ontology axiom, relationship type, context memory and AI asset schemas gainimpersonatedBy, so a workflow's own Set Action on them is not rejected by the stage it owns.Batched CSV import updates apply the same stage rules as a PATCH: a row without a stage keeps the stored one, and a stage change must be a lifecycle move no active workflow owns and, out of review, be made by a reviewer (reviewers are loaded first, inherited ones included); otherwise the row fails with the reason. A blank glossary term status keeps the term's stage instead of resetting it to Draft.
A stored workflow definition this server cannot read (for example a node type from another version) is skipped when resolving stage ownership, instead of failing every stage change.
Per-type lifecycles.
EntityLifecyclemaps each stage a type uses to the stages it can move to; a repository declares it withentityLifecycle = new EntityLifecycle(Map.of(...)). The default,EntityLifecycle.GENERAL, allows any move between the seven stages that exist today. A stage added to the vocabulary later is outside it, so only types that declare that stage can use it. A declaration that moves to a stage it doesn't list fails when the repository is built.EntityRepositoryrejects, with 400, a create in a stage outside the type's lifecycle and any stage change the lifecycle has no move for, before the workflow lock. The check applies to direct edits, imports and workflows alike.Per-type flags:
defaultEntityStatusinitialEntityStatus)workflowsOwnEntityStatus = falseonlyReviewersDeleteInReviewapprovalTaskReviewsEntityStatusentityLifecycle(own lifecycle)Alternatives considered.
Migration and compatibility.
The 2.1.0
postDataMigrationSQLScript.sqlfor MySQL and Postgres movescontext_memory.statustoentityStatus(Draft and Archived kept, everything else Approved). It does the same for memory version history inentity_extension. The statements are idempotent, andContextMemoryStatusMigrationITruns them twice on both databases.Other entities keep their stored stages, so nothing else needs migrating.
Breaking:
statusfield is removed from the entity and the create request; useentityStatus.GlossaryTermApprovalWorkflowandMetricApprovalWorkflowactive, a direct PATCH of a glossary term's or metric's stage now returns 403. Use the approval task, or suspend the workflow.entityStatus; the server assigns the starting stage.Overlap with Fixes #34394: Add memory lifecycle and status filtering #34395, which builds a memory lifecycle (Superseded/Invalidated) on the memory
statusfield this removes. It can move ontoentityStatuswithout a second field:SupersededandInvalidatedtotype/status.json.ContextMemoryRepository.LIFECYCLEwith those stages and their moves; Active maps to Approved.statusReason,supersededByanddisputeson the memory schema, and check them inContextMemoryRepository.prepare, e.g. Superseded requiressupersededBy.Other types won't see the new stages, and
/lifecycleStagesandBaseEntityITpick up the declared lifecycle automatically.Tests:
Use cases covered
entityStatus, and the 2.1.0 migration converts stored memories on MySQL and Postgres.Unit tests
I added unit tests for the new/changed logic.
Files added/updated:
EntityRepositoryEntityStatusTest,EntityLifecycleTest,GlossaryTermRepositoryInitialStageTest,EntityStatusWorkflowsTest,TriggerEntityFilterTest.FilterEntityImplTest,MetricRepositoryTest,ContextMemoryStatusTransitionTest(now on the declared memory lifecycle),RollbackEntityImplTest,KnowledgePageMapperTest, and the memory mapper, index and extractor tests.MemoryDerivedOntology.utils.test.ts,CreateMemoryModal.test.tsx.Coverage (JaCoCo, unit tests only, 258 tests):
EntityRepository,EntityUpdater,GlossaryTermRepository,MetricRepository) plusEntityLifecycleEntityLifecycleTriggerEntityFilterEntityStatusWorkflowsEntityRepositorytakes aStageOwnership(the active workflows by default), so unit tests can put an entity under an owning workflow. The remaining lines are approval-task closing throughTaskRepository(the ITs check the task outcome both ways) and branches for types with no lifecycle stage.Backend integration tests
I added integration tests in
openmetadata-integration-tests/for new/changed API endpoints.Files added/updated:
EntityStatusWorkflowOwnershipIT,ContextMemoryStatusMigrationIT, and the helpersApiAssertions,GovernanceWorkflowActions,WorkflowInstances.BaseEntityIT: seven stage tests run for every entity IT, including one that a move outside the type's lifecycle is rejected; 20 types without a lifecycle opt out.ContextMemoryIT,DataProductResourceIT,GlossaryTermResourceIT,GlossaryResourceIT,DatabaseSchemaResourceIT,MetricResourceIT,KnowledgeCenterIT,AIApplicationResourceIT,McpServerResourceIT,OntologyAxiomResourceIT,ClassificationResourceIT.Results on the latest commit:
WorkflowDefinitionResourceITContextMemoryStatusMigrationIT,ContextMemoryIT,EntityStatusWorkflowOwnershipIT,OntologyAxiomResourceITThe new lifecycle test runs for
ContextMemoryIT, the only type with its own lifecycle so far, and is skipped where every move between the general stages is allowed.Ingestion integration tests
tests/integration/amundsen/test_metadata.pynow expects the server-assignedUnprocessedstage on created services.Playwright (UI) tests
status→entityStatusrename inMemoryDerivedOntology.utils.ts.GlossaryStatusFilterLargeDatasetandGlossaryStatusFilterNestedTermsexclude their glossary fromGlossaryTermApprovalWorkflowwhile seeding term stages (new helpers inplaywright/utils/glossary.ts), since a direct stage change on a workflow-owned term is now rejected;setTermStatusasserts the response.Manual testing performed
No manual UI testing. The behavior was verified with the integration suites above against MySQL + Elasticsearch and Postgres + OpenSearch. The UI type check (
tsc --noEmit) reports no new errors compared with the same check on main.UI screen recording / screenshots:
Not applicable. There is no visible UI change.
Checklist:
I have read the CONTRIBUTING document.
My PR title is
Fixes <issue-number>: <short explanation>My PR is linked to a GitHub issue via
Fixes #<issue-number>above.I have commented on my code, particularly in hard-to-understand areas.
For JSON Schema changes: I updated the migration scripts or explained why it is not needed. Memories are migrated; other entities keep their stored stages.
For UI changes: I attached a screen recording and/or screenshots above. Not applicable: no visible UI change.
I have added tests (unit / integration / Playwright as applicable) and listed them above.
I have added the tag
Backward-Incompatible-Change.