Repository navigation
Fixes #34394: Add memory lifecycle and status filtering - #34647
Conversation
Entity memories about restricted assets were visible through direct REST reads. Check ViewBasic on the anchor for non-owners. Search still relies on domain inheritance and search RBAC; asset policies are not evaluated per result.
The by-name Company Context lookup omitted primaryEntity, so an anchored memory appeared unanchored to the visibility check. Fetch the decision fields before projecting the pill. Query search remains governed by search RBAC and inherited domains.
History endpoints exposed earlier versions without checking the current memory's visibility. Check the current memory before serving either history endpoint. Keep paging cursors when hidden memories are filtered from a list page so callers can reach later visible rows.
Map supersession and dispute fields in every search locale and request the relationship fields needed by memory docs during reindex. Default an omitted status to Active on create. The generated model leaves the schema default null, which broke lifecycle reads after regeneration.
Stamp lifecycle status on chunk docs and accept it in both vector query builders. Non-Active transitions change the fingerprint to refresh the filter fields; existing Active memories keep their fingerprint.
Preserve server-managed lifecycle fields on PUT so re-extraction cannot reactivate a superseded memory or erase disputes. Reject newly referenced memories the editor cannot read, and cache anchor access decisions within each list page.
Search cannot evaluate an anchor's asset policy for each indexed hit. Limit anchored Entity memories to owners and admins in lexical and vector search; direct reads still allow asset readers. Require an explicit unanchored marker so older documents fail closed until reindexed. Stamp the marker on entity and chunk documents.
Keep retired memories available through direct lifecycle and version reads while excluding them from lexical, vector, and Company Context retrieval.
Allow status selection alongside search, asset, author, and sort filters while keeping ordinary search Active-only. Preserve lifecycle fields on omitted-status PUT and prevent non-Active memories from proposing glossary terms. Extend API and UI coverage for these behaviors.
Reconcile Public memory visibility and index fields after the parent PR landed. Cover retired memory behavior in Playwright and align the deleted-source glossary expectation. Refs open-metadata#34394
…es and let active 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.
The repositories' stage rules reached the active workflows through a static EntityStatusWorkflows lookup, so no unit test could put an entity under an owning workflow. EntityRepository now takes a StageOwnership, with the active workflows as its default, and the create-time stage assignment and the updater's stage check are package-private instead of being reached through reflection. New tests cover a create that asks for a workflow-owned stage, the workflow creating and moving an entity in that stage, types whose stage no workflow owns, approval and rejection by reviewers and reviewing teams, sending an entity in review back to Draft, session consolidation, memory transitions through the updater, and glossary terms inheriting reviewers. Line and branch coverage of the repositories' stage code goes from 66% and 58% to 91% each.
Every type with entityStatus draws its stages from one vocabulary, but a type can now declare its own lifecycle in its repository: 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 seven stages, so nothing changes for them, Metric included. A stage added to the vocabulary later is outside the general lifecycle, so only the types that declare it can use it. EntityRepository rejects with 400 a create in a stage outside the type's lifecycle and a stage change the lifecycle has no move for, for direct edits, imports and workflows alike. Context memories are the first type to declare one (Draft, Approved, Archived), replacing their own transition table and validators. GET /v1/metadata/types/lifecycleStages now reports each type's stages and transitions, and BaseEntityIT checks that every type rejects a move outside its lifecycle.
… made dead main's 2.1.0 postDataMigration sets entityStatus to Approved on every context memory and version row that lacks one, and every create path assigns the initial stage, so a memory without a stage can no longer exist. Remove effectiveStatus and the updater's legacy branches, compare statuses directly as main did, let the shared entityStatus index field carry the stage, and delete the tests that built such rows by hand.
Deduplicating a fact, or reusing the memories of a byte-identical file, links the existing memory to the new source but leaves it anchored to its own file. Since anchors now gate reads, a memory from a private or shared file would stay hidden from readers of the new file. Reuse only memories whose anchor file everyone can read; the new file extracts its own otherwise.
The status filter had its own method on the resource, repository, search repository, search client interface, both clients and both managers. Carry the selected statuses on SearchListFilter instead: the resource uses the generic listInternalFromSearch, SearchRepository hands them to a listWithOffset overload, and the existing overload defaults to the searchable statuses.
The live, chunk-only and staged-backfill paths each repeated the check for when a memory's chunks must be rewritten, and no test caught the status or anchor restamp being dropped. They now share chunkRefresh, which is tested directly. Live updates also rewrite an in-flight staged generation, as deletes already do, so a recreate that copied a memory before its status or anchor changed cannot promote the stale chunks.
get_entity_details searched a knowledge item's chunks without a subject, so restricted, anchored or retired memories the caller may read returned no passages at all. Search as the caller, and return the full body when search still withholds every chunk.
Retired memories stay attached to their asset, and the builder capped the attached pills before filtering by status and visibility, so they could push Approved pills out of the context. Load a bounded batch, filter it, then cap; visibility is decided once for the batch. Only Approved pills are active now that every memory carries a stage.
…rams - The sidebar badge counted memories through the database list, which includes every status and other users' private memories. It now asks for Approved memories through search, like the page's default view. - The successor link replaced the whole query string. It now keeps the Context Center's other parameters.
Re-extraction still re-approved Archived and Draft pills. Extraction creates every pill Approved, and no engine path archives one (a pill the source drops is deleted), so any other stage is a reviewer's decision. Only Approved pills are engine-managed now, which also makes the re-approval branch in applyDerived unreachable, so it is removed.
The duplicate finder searched as the user named admin, which deployments with other admin principals do not have, so the lookup threw and aborted reconciliation. Search as a synthetic admin instead, as EntityUpdater does for system writes. It carries an id, since search treats a subject without one as anonymous and would hide every anchored memory again.
Code Review ✅ Approved 2 closed / 2 findings🔴 High risk · Memory anchor access rules now govern direct reads and search visibility Adds memory lifecycle and status filtering using the shared ✅ 2 closed✅ Bug: Duplicate finder fails when no user is literally named "admin"
✅ Bug: Re-extraction still re-approves Archived (and Draft) pills
OptionsDisplay: 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 #34394
Adds a lifecycle to Context Center memories. A memory that was replaced or found wrong leaves search, agent context and glossary proposals, while its own page and history stay readable. This replaces #34395, which GitHub closed when its base branch was deleted after #34541 merged; this PR targets
mainand builds on the shared lifecycle from #34541.Lifecycle
EntityStatusstages: Draft, Approved (in use), Deprecated (replaced), Rejected (invalidated) and Archived. A memory created without a stage starts Approved. Allowed moves: Draft → Approved or Archived; Approved → Archived, Deprecated or Rejected; Deprecated or Rejected → Approved or Archived; Archived → Approved.supersededBy: another memory the editor can read that is not deleted and not itself.statusReasonrecords why a memory reached its stage. A status change without a reason of its own clears the old one, and leaving Deprecated clears the successor. PUT keeps these fields, and a PATCH that removes the stage is rejected. Direct reads and version history keep retired states.disputesrecords memories by other owners whose claims contradict this one. ALearningmemory type and aConversationExtractionsource type support conversation capture for ai-platform#523.Access
Search and listing
entityStatusandanchorId.GET /v1/contextCenter/memories?statuses=Approved,Deprecatedlists the chosen stages and combines withq,assets,author, sort and offset. The statuses ride onSearchListFilterthrough the generic search listing.Extraction
admin. A memory is shared with another file, through deduplication or byte-identical reuse, only when its own file is readable by everyone.Glossary proposals and agents
company_contextreturns Approved shared file memories only.get_entity_detailssearches passages as the caller and falls back to the full body when search returns none.UI
memoryURL parameter, and a slow lookup cannot reopen a closed modal.Type of change:
High-level design:
ContextMemoryRepositorydeclares the memory stages through the sharedEntityLifecycle, soEntityRepositoryvalidates every move.ContextMemoryLifecycleadds the memory-only rules: successor and dispute references, and clearing a stale reason or successor. Status changes are never folded into an in-session version, so history keeps each one.ContextMemoryVisibilitydecides REST reads in memory and delegates the anchor check toContextMemoryAnchorAccess, a policy check on the anchor with a bounded per-request cache.ContextMemorySearchVisibilityandVectorSearchQueryBuilderrender the same rule as search filters and add the status constraint and the conservative anchor rule.SearchListFilterto alistWithOffsetoverload on the search clients; the existing overload defaults to Approved. There is no memory-specific listing method in the repository or search layers.OpenSearchVectorService.chunkRefreshchooses between no change, restamping stored vectors and re-embedding, for the live, chunk-only and staged-backfill paths. Status and anchor sit outside the content fingerprint, so changing them costs no embedding calls.entityStatusandanchorIdstay out of search until restamped, out of vector search even for admins. Chunk schema version 7 upgrades older chunk mappings.maven-collate-cifails while Collate still importsContextMemoryStatus, which Fixes #34540: Support a shared lifecycle stage on entities and let active workflows own it #34541 removed; that build fails onmaintoo.main. Extraction creates memories asadminwith no owner, so saving one fails on deployments without a user namedadmin.Tests:
Use cases covered
Unit tests
ContextMemoryLifecycleTest,ContextMemoryVisibilityTest,ContextMemoryAnchorAccessTest,ContextMemoryStatusTransitionTest,ContextMemorySchemaTest,ContextMemoryIndexTest,ContextMemoryIndexMappingTest,ContextMemorySearchVisibilityTest,VectorSearchQueryBuilderTest,VectorDocBuilderChunkTest,OpenSearchVectorServiceTest,ContextMemoryReconcilerTest,SemanticMemoryDuplicateFinderTest,FileContextProcessingEngineTest,ContextFileVisibilityTest,OntologyChangePreflightTest,OntologyMemoryDerivationServiceTest,OntologyMemoryDerivationQueueTest,AIContextBuilderTest,SearchRepositoryBehaviorTest.CompanyContextToolTest,GetEntityToolTest.ContextCenterMemoriesPage,CreateMemoryModaland its utils,MemoriesView,MemoryDerivedOntology.utils,useContextCenterBadges.Backend integration tests
openmetadata-integration-tests/for new/changed API endpoints.ContextMemoryLifecycleIT,ContextMemoryAnchorIT. Extended:ContextMemoryIT(version access),OntologyChangeSetIT(retired, co-sourced and deleted source memories),McpContextMemoryVisibilityIT(anchored memories).Ingestion integration tests
Playwright (UI) tests
openmetadata-ui/.../ui/playwright/for UI changes.playwright/e2e/Features/ContextCenterMemoryLifecycle.spec.ts.Results
Run locally on 2026-10-05, integration tests against PostgreSQL and Elasticsearch containers:
c8a71173b1c8a71173b1ContextMemoryIT,ContextMemoryLifecycleIT,ContextMemoryAnchorIT,OntologyChangeSetIT,McpContextMemoryVisibilityIT,AIContextRestIT,AIContextMcpIT,PersonaAIContextITc8a71173b1c8a71173b10335a6a86fContextCenterMemoryLifecycle.spec.ts8466c48d5ctscadds no errors0335a6a86fIntegration tests were not re-run on the two review-fix commits, and the Playwright spec was not re-run after the later UI changes.
Manual testing performed
8466c48d5c).Live semantic search was not revalidated: the local embedding model produced 384 dimensions against a 512-dimension chunk index. Vector behaviour is covered by the Java tests.
UI screen recording / screenshots:
TODO: attach a short recording of the status filter, a Deprecated memory's details and the successor link.
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.
For UI changes: I attached a screen recording and/or screenshots above.
I have added tests (unit / integration / Playwright as applicable) and listed them above.
The issue properly describes why the new feature is needed, what's the goal, and how we are building it. Any discussion or decision-making process is reflected in the issue.
I have updated the documentation.
I have added tests around the new logic.