Skip to content

feat(memory): open a review task for conflicting memories; approving it supersedes the disputed memory - #35329

Merged
pmbrull merged 29 commits into
mainfrom
pmbrull/conflicting-memories-review
Oct 14, 2026
Merged

pmbrull merged 29 commits into
mainfrom
pmbrull/conflicting-memories-review

Conversation

@pmbrull

@pmbrull pmbrull commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #35372 (the OpenMetadata half of the human conflict review in open-metadata/ai-platform#1462). Collate follow-up: open-metadata/openmetadata-collate#7351 (writes the disputes link from reconciliation; merge after this PR).

Collate's Memory Reconciliation moves a memory that contradicts Approved knowledge to Draft with a free-text reason, and then nothing happens: nobody is told, the Draft does not say which memory it contradicts, and approving it leaves the contradicted memory Approved, so both claims keep grounding answers. This PR makes a conflict actionable in OpenMetadata:

  • disputes now link a conflict. They are the unresolved conflicts holding a Draft memory in review: Draft-only, one per contradicting memory, detectedAt defaulting to the write time, released (history keeps them) when the memory leaves Draft. Nothing wrote the field before; its old "both remain Approved" meaning is dropped.
  • A Draft memory with disputes opens one review task. New task type MemoryConflictReview (category Review), opened by governance-bot after the write commits, assigned to the owners of both sides, who are notified. Server-owned: the task API refuses to create the type, to PATCH or bulk-edit a review, to turn another task into one, and to close one without a decision while its memory is in review. Standalone (no Flowable workflow), with fixed Approve / Reject transitions.
  • Approving supersedes the old claim. Approve: the reviewed memory becomes Approved, then every disputed memory that is still Approved becomes Superseded by it — approving first means an interrupted approval leaves both claims Approved, never a retired claim with nothing in its place. Reject: the reviewed memory becomes Rejected, with the comment as statusReason; the disputed memories are untouched. Every memory write records a change event.
  • Refusals leave the task open and nothing written (412/403): the memory left review for another outcome, a disputed memory's content changed after the conflict was detected (lastContentUpdatedAt > detectedAt, which is never later than the write that recorded it), a memory changed while the decision was being made, what the reviewer compared changed since (the compare dialog sends it as the resolution payload, type/memoryConflictReviewResolution.json), or the resolver may not read or supersede the disputed memory directly — so the author of a correction cannot retire someone else's knowledge by approving their own memory. The memory writes of a decision commit in one transaction, so a write refused part-way leaves both memories as they were. A decision whose writes committed but whose task did not resolve can be retried: it converges instead of being refused.
  • Leaving review outside the task closes it (approve/reject in Context Center, a governance workflow's transition, explicit requeue to Unprocessed, soft delete) — every open review of the memory, also when one writer's session consolidated the edits; only the task's own decision is exempt. Restoring a memory still held for conflicts opens a fresh one.
  • Context Center → Memories gets a "Needs review" tab. A count card and tab list the open conflict reviews — every one for an admin, the ones assigned to the user or their teams otherwise — the way the task inbox lists tasks (same row component, with a "Memory conflict" type chip the inbox now uses too); each row reads its memory's title through the memory API. The count is one limit=1 request; the list loads only on the tab, 20 at a time with Load more, with an error state and retry. The count cards stay up while reviews are open even when no memory is listed, and the memory search hides on the tab, since reviews name memories by reference only.
  • Opening a review shows one split diff. A single dialog reads like a pull request's split diff: the Approved (current) memory on the left, the memory in review on the right, each column headed by its title, owner, date, Draft/Approved status and whether it is newer, under the question they answer and why they conflict. One row per field the memory's detail view shows (title, memory, question, type, linked assets, visibility, tags, source, owners); changed rows are tinted and the words or values the memory in review drops and adds are marked (del/ins). Under each column, Keep this one says what it does to the other side: keeping the memory in review approves it and supersedes the contradicted ones; keeping the Approved one rejects the memory in review. When it contradicts several, a select switches the left column between them. A side that is gone, that the reviewer may not read, or that failed to load says so and marks nothing; Keep waits until both sides are read.
  • The task holds no memory content. Every user may read tasks (OrganizationPolicy-ViewAll), while a memory may be Private, Shared or anchored to an asset only some may view. So the task's title ("Review conflicting memory") and description are fixed text, and its payload names the disputed memories by reference with when each conflict was detected — no title, question, answer, reason or source. The list and the diff read both memories through the memory API, which applies their visibility.
  • Scoped task lists take type. GET /tasks/assigned, /visible, /owned and /created accept the type filter GET /tasks already had, so the tab fetches conflict reviews only.

Decision record: docs/decisions/2026-10-13-a-memory-conflict-opens-a-review-task-and-approving-it-supersedes-the-disputed-memory.md.

Type of change:

  • New feature

High-level design:

  • Stage stays Draft; no "Conflict" stage. A conflict is a relation between two memories (the disputed one stays Approved while the candidate is reviewed; in revalidation the older one is the one in review), and every review hold behaves the same for grounding and queues. The structured disputes link plus the task carry what is specific to a conflict. A new stage would ripple through the spec enum, lifecycle map, three repos' generated models, a data migration and an accepted ADR.
  • Opening — ContextMemoryRepository.postCreate/postUpdate → MemoryConflictReviewTasks.afterWrite. Post-commit like closeApprovalTaskOnEntityStatusChange; find-then-create via TaskRepository.findOpenTaskByEntityAndType, serialized per memory on a server (striped lock); a failure is logged and the next write retries. Opening records a change event and pushes the task to its assignees, as a workflow-created task does. The task is built by a pure reviewTask(...) (assignees = owners of both sides, payload = disputes by reference).
  • Keeping the task current — a write that changes a held memory's disputes or owners patches the open task's assignees and payload as governance-bot, recording a change event; nothing else on the task can go stale.
  • Standalone, not workflow-managed — TaskWorkflowLifecycleResolver.defaultWorkflowDefinitionRef(MemoryConflictReview) is null, so prepare binds no workflow (a new type otherwise falls back to CustomTaskWorkflow). Its transitions are set at creation.
  • Deciding — TaskWorkflowHandler.applyTaskResolution delegates this type to MemoryConflictResolution.decide, which (unlike applyEntityChanges) also acts on rejection, touches two entities, and throws instead of logging. MemoryConflictDecision (pure) plans the writes and refusals; supersessions need the read visibility and the policy check a direct PATCH would face; every write is guarded on version and updatedAt (a lost race is a 412), made as the resolver impersonated by governance-bot, and records a change event. The resolving thread marks the memory it is deciding, so the close hook skips only the task's own writes; a governance workflow's write, also made as governance-bot, still closes the task. A retry converges: an outcome already written is neither refused nor rewritten, an already superseded memory is skipped, and the disputes Draft released are read from the task payload, which only the server writes.
  • Why "Keep this one" instead of Approve/Reject — reconciliation holds a memory for review in two ways. A new memory that contradicts an Approved one goes to Draft, so approving it replaces the old claim. But revalidation sends an old Approved memory back to Draft when a newer one contradicts it, and approving that keeps the old claim and supersedes the newer one. "Approve" meant opposite things to a reviewer; choosing which claim to keep, with the newer one marked, reads the same in both. The transitions underneath are unchanged (keep the memory in review = approve, keep the Approved ones = reject).
  • No content in the task; the UI reads the memories — the payload is {disputes: [{memory, detectedAt}]}, defined once in type/memoryConflictReviewPayload.json like the other task payloads; the server and the UI use the generated MemoryConflictReviewPayload / DisputedMemory types. The Needs review rows and the diff read the memories with the memory API (useQueries on the memory-detail key, so opening a review reuses the row's read). "Newer" compares lastContentUpdatedAt (revalidation moves an old memory to Draft without touching its content). Approval is refused once a disputed memory's content changes after the conflict was detected, so what the reviewer compared is what the decision acts on.
  • UI — useMemoryConflictReviews reads the count (limit=1) always and the list (useInfiniteQuery on the after cursor) only on the tab: GET /tasks for an admin, GET /tasks/assigned otherwise. MemoryConflictReviews renders them with the inbox's InboxTaskListItem; MemoryConflictCompare loads the reviewed memory and every disputed one and draws the split diff: text fields diff word by word with the diff package already in the UI's dependencies (each side keeps its own words), lists value by value by identity (MemoryConflictCompare.utils, pure and unit-tested); it resolves through POST /tasks/{id}/resolve, then refreshes the review list, the memory counts and the inbox count. Under components/discovery/context-center/, built from ui-core-components (Dialog, Grid, Select, Badge, Button, Typography, Skeleton, EmptyPlaceholder, core icons); new strings translated in all 20 locales.
  • Rejected alternative — a governance workflow with a userApprovalTask on contextMemory: it would take ownership of the memory's stage (checkEntityStatusNotOwnedByWorkflow) and block direct approve/reject/requeue in Context Center, and its generic entity actions only touch the about entity and swallow failures.
  • Compatibility — no migration: disputes was never written, the new enum value is additive, and the type filter is optional. Existing supersededBy references keep the form they were stored in until the memory is superseded again. The hand-written Python TaskEntityType and the UI's exhaustive TASK_ENTITY_TYPES gain the value.

Tests:

Use cases covered

  • A memory moved to Draft with a dispute opens exactly one review task, assigned to both owners, with Approve/Reject; the task holds no memory content (fixed title and description, disputes by reference); an edit during review opens no second task, and changing the memory's owners reassigns the open task.
  • Approving approves the reviewed memory and supersedes the disputed one with it (the stored successor reference reads as its title), without the decision ever closing its own task; rejecting rejects only the reviewed memory and records why.
  • Leaving review outside the task (requeue) cancels the task and releases the disputes; a soft delete cancels it and a restore opens a fresh one.
  • A governance workflow's write (as governance-bot) that takes the memory out of review closes the task; the task's own decision does not. A decision retried after its writes landed converges instead of being refused.
  • A dispute whose memory changed after detection refuses approval (412) and leaves the task open.
  • The reviewed memory's owner cannot approve when they may not supersede the disputed memory (403), can still reject; the disputed memory's owner can approve.
  • An assignee lists their conflict reviews with GET /tasks/assigned?type=MemoryConflictReview, and only those.
  • The task API refuses to file this type, to patch it or another task into it, or to close it or resolve it without a decision while its memory is in review. Disputes outside Draft are refused; PUT keeps a Draft's disputes; history keeps released ones; a dispute cannot be detected after the write that records it.
  • In Context Center, the Needs review card counts the open reviews and lists them as tasks named by their memory's title; opening one shows the split diff with what changed marked, and "Keep this one" under either column resolves it with the stated outcome, closes the dialog, and refreshes the list and counts. A refused decision keeps the dialog open, says why and refreshes the list; a side that is gone, unreadable or failed to load says so, and a failed one holds the decision.
  • A decision refused part-way (a write the resolver may not make, after the approval was written) leaves both memories as they were and the review open; a decision made against an outdated comparison is refused with nothing written.
  • A non-admin owner finds their review (an unrelated user does not), is refused (403) when approving would retire a claim they do not own, with nothing changed, and can reject.
  • With no memory listed but reviews open, the count cards and the Needs review tab stay reachable; past 20 open reviews, Load more lists the next page; the memory search hides on the tab.

Unit tests

  • Java: MemoryConflictDecisionTest (26), MemoryConflictReviewTasksTest (20), MemoryConflictResolutionTest (13); extended ContextMemoryLifecycleTest (38 total, 11 new). 114/114 pass locally, with TaskWorkflowHandlerTest (17).
  • Jest: MemoryConflictCompare.test.tsx (13), MemoryConflictCompare.utils.test.ts (15), MemoryConflictReviews.test.tsx (8), MemoryConflictReviews.utils.test.ts (10), useMemoryConflictReviews.test.ts (4), ContextCenterMemoriesPage.test.tsx (13, 4 for Needs review: the tab, reviews reachable with no memory listed, the empty state with neither, search hidden), taskDetail.utils.test.ts (54, incl. the "Memory conflict" chip). 126/126 pass locally (with the other context-center suites).
  • Coverage: the orchestration in MemoryConflictReviewTasks/MemoryConflictResolution that needs a live server is covered by ContextMemoryConflictReviewIT; their pure seams and MemoryConflictDecision by the unit tests above.

Backend integration tests

  • Added ContextMemoryConflictReviewIT (16 cases, incl. a deterministic part-way failure and an outdated comparison); updated ContextMemoryLifecycleIT for Draft-only disputes (4 new cases); ContextMemoryIT.list_contextMemoryRelationshipFields_populated now pages through the list (memories other tests create concurrently could push its memory off page 1).

Local Java test run: FAILED

  • Commit: 6b830ac24e34 (base origin/main)
  • Finished: 2026-10-13 20:29 UTC · 75.3 min
  • Details: the classes each step ran, why these tests, the commands
Step Scope Classes Tests Failed Skipped Min Result
unit openmetadata-mcp (4 classes), openmetadata-service (56 classes) 56 1242 1 0 1.8 FAILED
integration mysql-elasticsearch · parallel 336 16783 5 1578 29.1 FAILED
integration mysql-elasticsearch · isolated 15 575 0 15 19.1 passed
integration mysql-elasticsearch · rdf 26 249 0 1 15.0 passed
integration cache-tests · parallel 8 39 0 1 2.8 passed
integration cache-tests · isolated 2 11 0 0 2.8 passed
integration postgres-opensearch · parallel 1 1 0 0 2.4 passed
integration postgres-opensearch · isolated 1 1 0 1 2.3 no tests ran

Failed: TaskWorkflowLifecycleResolverTest#workflowStartVariablesTolerateNullOptionalFields, ContextMemoryConflictReviewIT#anotherTaskCannotBePatchedIntoAConflictReview(TestNamespace), GlossaryTermMoveApprovalIT#test_approveApprovalTaskAfterMovingParentTerm_drivesMovedTermToApproved(TestNamespace), MetricResourceIT#post_metricWithReviewersCreatesApprovalTaskAndReviewerCanApprove(TestNamespace), GlossaryTermInheritedReviewerApprovalIT#test_reviewerAddedToGlossaryAfterFirstTerm_stillGatesLaterTerms(TestNamespace), LineageDeletedPipelineIT#patchKeepsSoftDeletedPipelineAlreadyOnEdge(TestNamespace)

Selected but produced no report: CompanyContextToolTest (openmetadata-mcp (4 classes), openmetadata-service (56 classes)), CreateEntityToolTest (openmetadata-mcp (4 classes), openmetadata-service (56 classes)), GetEntityToolTest (openmetadata-mcp (4 classes), openmetadata-service (56 classes)), PatchEntityToolTest (openmetadata-mcp (4 classes), openmetadata-service (56 classes)), McpServiceResourceIT (mysql-elasticsearch · parallel)

Every test skipped, so these exercised nothing (check their assumptions — usually the engine): DataRetentionAppIT (mysql-elasticsearch · parallel), SearchIndexPromotionIT (mysql-elasticsearch · parallel), SearchIndexingFieldsParityIT (mysql-elasticsearch · parallel), WritePathBenchmarkIT (mysql-elasticsearch · parallel), RdfIndexAppScaleIT (mysql-elasticsearch · rdf), PatchTableEmbeddingIT (postgres-opensearch · isolated)

  • Impacted, not run locally: 2 classes (listed in the details)

Full suite re-run on 9935215f566 (MySQL + Elasticsearch): unit 1242/0; the parallel lane ran 16,787 tests with 4 errors, and the run was stopped during the isolated lane. ContextMemoryConflictReviewIT#anotherTaskCannotBePatchedIntoAConflictReview failed again despite the resource lock. No CustomTask form schema is seeded, so TaskResourceIT creates one and hard-deletes it on restore, and TaskFormSchemaRepository clears its schema cache only when a schema is stored, never on delete. The deleted schema then keeps validating every CustomTask payload; this was reproduced against a running server. 1b5526ef5cf patches a DescriptionUpdate task instead, which no test's schema override touches. The other three, GlossaryTermInheritedReviewerApprovalIT (2) and GlossaryTermMoveApprovalIT, are a local build artifact: each IT step rebuilds openmetadata-spec incrementally and regenerates Task.priority without its default, which CI's clean build never does. After mvn clean -pl openmetadata-spec they pass (578 tests across them, MetricResourceIT, LineageDeletedPipelineIT, TaskResourceIT and ContextMemoryConflictReviewIT, 0 failed). On 1b5526ef5cf, ContextMemoryConflictReviewIT + TaskResourceIT ran 305 tests with 0 failed on both MySQL + Elasticsearch and PostgreSQL + OpenSearch. McpServiceResourceIT is the empty stub on main that never reports.

Merge-queue run on 1b5526ef5cf: the PostgreSQL + Elasticsearch + Redis lane failed ContextMemoryConflictReviewIT#aDecisionThatFailsPartWayLeavesBothMemoriesAsTheyWere. A refused decision left Redis serving the reviewed memory as Approved while the database still held it in Draft. Superseding reads the reviewed memory back inside the transaction, CachedEntityDao caches that uncommitted row, and the rollback drops the evictions executeInTransaction deferred. 46bef17cea5 evicts every memory a refused decision wrote, once the rollback is done; the ADR records it. Reproduced locally on 1b5526ef5cf with -Pcache-tests (16 tests, 1 failed). On 46bef17cea5, ContextMemoryConflictReviewIT + ContextMemoryLifecycleIT ran 54 tests with 0 failed on each of Redis (-Pcache-tests), MySQL + Elasticsearch and PostgreSQL + OpenSearch; the memory conflict unit tests and TaskWorkflowLifecycleResolverTest ran 90 with 0 failed. The required lanes that ejected the queue runs were not from this change. On MySQL + Elasticsearch, MetricResourceIT#rejectMetricUpdateRollsBackPreviousApprovedVersion timed out waiting for an approval task; it failed the same way in a queue group without this PR. Later, the lane hit its 65-minute limit with 418 classes passed. PostgreSQL + OpenSearch once hit its limit on a stalled runner and passed on the next group.

Ingestion integration tests

  • Not applicable — only the hand-written TaskEntityType enum gains a value.

Playwright (UI) tests

  • Added playwright/e2e/Features/ContextCenterMemoryReview.spec.ts (the review waits in Needs review as a task; opening it shows both memories as a diff with the memory field changed; keeping the memory in review supersedes the contradicted one; keeping the Approved one rejects it), mapped in .github/playwright/impact-map.json.
  • Ran locally against the Docker stack below (working tree of 6b830ac24e3, --project=chromium, after the setup project): ContextCenterMemoryReview.spec.ts 3/3, repeated 3× (9/9) — incl. the new non-admin owner scenario — plus ContextCenterMemories.spec.ts, ContextCenterMemoryLifecycle.spec.ts and Pages/Tasks.spec.ts 68/68.
  • Not run locally: the rest of the 75 specs plan_local_playwright.py selects. rest/tasksAPI.ts and service/tasks/** map to the whole Tasks area, so the plan pulls in every Features/Tasks/** spec plus smoke and canaries; the merge queue runs them.

Manual testing performed

A review of the whole diff by three reviewers (backend logic, authorization and security, UI) found, and this PR fixes: memory content copied into a task every user can read (now references only); supersessions written before the approval (now approve first); review tasks editable or dismissable through PATCH, bulk edits and /close; no change events or assignee notification; a stale review left open after consolidated edits; a future detectedAt disabling the stale-claim refusal; the supersede check skipping visibility; and on the UI, a failed read shown as a deleted memory, a diff drawn before both sides loaded, raw enum values, colour-only change marks, a failed list shown as empty, and an unrefreshed inbox count.

Validated the PR build in Docker with sample data (details under the recording). Reviewing it led to the side-by-side redesign above, and found and fixed three bugs:

  • Review rows and the task description named memories by their generated names (dim_customer-<uuid>) — now titles.
  • Retitling a memory in review left the task's old title (the task patch was written as governance-bot, whose display-name edits the updater discards) — now written as the editor, impersonated by governance-bot; covered by retitlingAMemoryInReviewRetitlesItsTask.
  • A superseded memory linked to its successor by generated name — the stored reference now carries the title.

UI screen recording:

Recorded on 2241a6dce99 (the head commit) with Playwright (1440×900, every step asserted through the UI and the API).

pr-35329-review-2241a6d.webm

Build and health. mvn -DskipTests clean package -pl openmetadata-dist -am on 2241a6dce99, server image built from docker/development/Dockerfile. Run as an isolated Compose project (own container names, ports, network and volumes) beside other checkouts' stacks: MySQL 8.3 (healthy), Elasticsearch 9.3.0 (healthy), execute-migrate-all exited 0, server healthy. GET /api/v1/system/version → {"version":"2.0.0-SNAPSHOT","revision":"2241a6dce998869b7ede7adbce68d2c6c3c56831"}; /healthcheck reports the server and database healthy.

Sample data. The repository sample_data workflow, ingested with metadata ingest against the stack: 1,531 records, 99.9% success (the 3 failures are sample test-case resolution Ack statuses, unrelated to this flow). Fixture, created through the API the way reconciliation records a conflict: two Approved memories anchored on sample_data.ecommerce_db.shopify.dim_customer and …fact_order, and for each a newer, contradicting memory moved to Draft with a dispute pointing at it.

Shown, and asserted:

  1. Memories shows Needs review 2, listed as tasks titled "Review conflicting memory", each naming its memory ("Active customer: three completed orders", the churn one) read through the memory API — the task itself holds no memory content.
  2. Opening the first shows one split diff under its question ("Who counts as an active customer?") and why they conflict: Current (Approved · Older) against In review (Draft · Newer), with the Title and Memory rows changed — "five" struck through on the left, "three" highlighted on the right — and the other fields unchanged.
  3. Keep this one under In review ("Approves this memory and supersedes 'Active customer: five completed orders'") → POST /tasks/{id}/resolve 200, the dialog closes, success toast, the review leaves, the count drops to 1; the API shows the original Superseded by the incoming memory, which is Approved.
  4. The original memory reads Superseded, reason "Superseded in conflict review by 'Active customer: three completed orders'", with a Superseded by link titled after it.
  5. Opening the other conflict, then Keep this one under Current ("Keeps this memory and rejects 'Churned customer: 30 days without an order'") → 200, empty state Nothing to review, count 0; the API shows the incoming memory Rejected and the original still Approved.
  6. The rejected memory reads Rejected, reason "Rejected in conflict review".

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 a UI feature or feature task: as part of PR creation, I ran the PR build in Docker with sample data and embedded a verified GitHub-hosted recording plus build/health evidence above (or explained why this requirement is not applicable).
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Decision check: adds docs/decisions/2026-10-13-a-memory-conflict-opens-a-review-task-and-approving-it-supersedes-the-disputed-memory.md.

🤖 Generated with Claude Code

A Draft memory with disputes now has one open MemoryConflictReview task,
opened by governance-bot and assigned to the owners of both sides.
Approving it supersedes every disputed memory that is still Approved with
the reviewed one, then approves it; rejecting it rejects the reviewed
memory. A resolution is refused, leaving the task open, when the memory
left review, a disputed memory changed after the conflict was detected,
or the resolver may not supersede the disputed memory directly. Leaving
review outside the task closes it.

`disputes` now means the unresolved conflicts holding a Draft memory in
review: Draft-only, one per memory, released on leaving Draft, with
detectedAt defaulting to the write time. The task type is server-owned
and standalone (no workflow).

Part of open-metadata/ai-platform#1462.
…er-owned

A soft-deleted memory in review cannot be decided, so its open review
task now closes; restoring a memory still held for conflicts opens a
fresh one. PATCH can no longer turn a task into, or out of, a
MemoryConflictReview, closing the same hole the create guard closes.
@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Oct 13, 2026
Context Center Memories gains a Needs review tab next to the memory counts.
An admin sees every open conflict review; anyone else sees the reviews
assigned to them or their teams. Each row names the memory under review and
the memories it contradicts, with the reason, and approves or rejects it in
place. Approving supersedes the contradicted memories, as resolving the task
anywhere else does.

The scoped task lists (/tasks/assigned, /visible, /owned and /created) accept
the `type` filter the main list already had, so the tab fetches conflict
reviews only.

ContextMemoryIT now pages through the memory list: memories that concurrent
tests create could sort ahead of the one it looks for and push it off page 1.
Memory names are generated: an extracted memory is named after its source
plus a UUID. A review task that showed names gave a reviewer nothing to
recognise. The task payload now records the reviewed memory's title and each
disputed memory with its title as the display name, the description lists
the disputed memories by title, and the Needs review tab shows the titles.

A write that changes a held memory's title, disputes or owners rewrites the
open task's title, description, assignees and payload, so the task keeps
showing what its decision acts on.
The refresh wrote as governance-bot, and an update by a bot that may not
edit display names keeps an entity's old title and description, so a
retitled memory left its task named after the old title. The refresh now
writes as whoever changed the memory, impersonated by governance-bot, and
builds the task from the memory as the write left it.

The Needs review row shows the memory under review in the weight and color
the memory list uses for titles.
A stored supersededBy or dispute reference took the referenced memory's
generated name as its display name, so a superseded memory linked to its
successor as `orders.pdf-<uuid>`. The lifecycle now stores the referenced
memory's title as the display name, unless that memory has one of its own.
The empty state composed "No" with the tab name, which read as
"No Needs review".
The conflict review package, the memory lifecycle, the Context Center review
hook and query keys, the task workflow handlers and the task constants had no
impact-map entry, so CI would escalate a change to any of them to the full
Playwright suite. They now select the Context Center and Tasks specs, and the
memory lifecycle spec joins the Context Center area.
A conflict review showed the memory in review and the titles of the memories
it contradicts, with Approve and Reject: a reviewer had to open each memory to
see what it said, nothing told which claim was newer, and "Approve" meant the
opposite thing when revalidation sends an old memory back to review.

The task now records each side's claim when it opens: title, question,
answer, status, when its content last changed, anchor, source and author. The
Needs review tab shows the two claims side by side under the question they
answer, marks the newer one, and offers "Keep this one" on each side with
what it does to the other: keeping the memory in review approves it and
supersedes the ones it contradicts, keeping the approved ones rejects it. The
task description states both claims too, and an edit to the reviewed
memory's question, answer or anchor rewrites the open task.

The empty state takes its icon from the core icon set.
Each claim in a conflict review carries its status badge, Draft for the
memory in review and Approved for the ones it contradicts, next to the
newer/older mark.
A conflict review is now decided in a comparison dialog that shows both
memories exactly as their own detail modal does: the memory in review on the
left, the Approved memory it contradicts on the right, each with its Draft or
Approved status and which is newer, under the question they answer and why
they conflict. Each side has "Keep this one" at the bottom, saying what it
does to the other side. When the memory in review contradicts several, tabs
switch between them.

The memory modal gains an embedded mode for this: the same content as a
panel inside another dialog, with the host's actions in place of its own and
no edit banner. The Needs review list becomes a summary of each conflict with
a Compare button.
The comparison is one dialog that reads like a pull request's split diff: the
Approved memory on the left, the memory in review on the right, each column
headed by its title, owner, date, status and whether it is newer, then one
row per field the detail view shows (title, memory, question, type, linked
assets, visibility, tags, source, owners). Changed rows are tinted and the
words or values the memory in review drops and adds are highlighted. Under
each column, "Keep this one" says what it does to the other side.

The Needs review list shows each review the way the task inbox shows tasks,
with a "Memory conflict" type chip that the inbox uses too; opening one
starts the comparison. The memory modal's embedded mode, which only the
previous side-by-side panels used, is gone.
The memories empty state replaced the count cards whenever no Approved or
Unprocessed memory was listed, hiding the Needs review tab from a reviewer
whose only memory is the one held in review. It now waits until there are
no open reviews either.

The Needs review list read one page of 50 while its card counted them all.
It now pages by cursor, with a Load more control under the list.
The close hook skipped every write made as, or impersonating,
governance-bot, so a governance workflow moving a memory out of review
left its task open forever. The task's own decision now marks the memory
it is deciding for the resolving thread, and only those writes are exempt.

A decision whose writes landed but whose task failed to resolve could
never be retried: the reviewed memory had left Draft, so the retry was
refused, and the task stayed open. Approve and reject now converge: an
outcome already written is not refused or written again, an already
superseded memory is skipped, and the disputes Draft released are read
from the task payload.
@pmbrull
pmbrull marked this pull request as ready for review October 13, 2026 15:14
@pmbrull
pmbrull requested review from Khairajani and a balanced review from Copilot October 13, 2026 15:14
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

Resolving one decides its memory with no edit check on it, so a client that could file or retype one would choose which memory gets decided and by whom.
- An approval supersedes a memory saved before stages existed, so the
  read check before superseding now uses the same rule and covers it.
- Looking for a memory's open review and opening one run one write at a
  time per memory on a server, so concurrent writes there open one review.
- The comparison holds the decision while a memory is loading or failed to
  load; a memory that is gone or not for this reviewer still lets them
  decide.
- An IT pins that a resolution naming no decision is refused while the
  memory is in review.
The task payload was described twice by hand, as Java records and a
TypeScript interface. type/memoryConflictReviewPayload.json now defines
it once, as other task payloads are, and the server and the UI use the
types generated from it.

@harshach harshach left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: NEEDS_WORK
HEAD: a70e927 — re-checked against GitHub before posting.

SENSE: The change addresses #35372 and the task-based conflict review fits the requested flow.
QUALITY: The remaining blockers are partial approval on a concurrent edit, decisions made against an outdated comparison, and approval while another disputed claim has not loaded. The existing server-owned-task thread also needs a follow-up for DELETE.
TEST: present+meaningful, with gaps — pure Java decision tests, real API integration assertions and two real browser happy paths exist; orchestration failure recovery, stale comparisons and non-admin browser behavior need regressions.
read: MemoryConflictDecisionTest.java; MemoryConflictResolutionTest.java; MemoryConflictReviewTasksTest.java; ContextMemoryLifecycleTest.java; ContextMemoryConflictReviewIT.java; changed ContextMemoryLifecycleIT/ContextMemoryIT cases; the new Jest suites and ContextCenterMemoryReview.spec.ts.
CI: pending — latest check snapshot: 34 successful, 9 in progress, 29 skipped, no failures returned.
read: current gh pr checks for this head; no failing job log was available to diagnose.
ISSUE: fixes the requested scope, subject to the findings.
read: #35372
BLOCKERS: the inline correctness findings and DELETE follow-up; tests requested inline distinguish unit, integration and Playwright gaps.
SIZE: +5780/-56, 70 files.

Verification performed in this review: 10 MemoryConflictReviews utility tests passed in an isolated Jest/Node configuration using existing dependencies. The normal jsdom suites could not start with the available dependency tree (ERR_REQUIRE_ESM in http-proxy-agent/@tootallnate/once); the broader pure-utility attempt also hit an import.meta setup dependency. git diff --check passed. Changed schema JSON parses; all 20 locale files contain the same 14 new keys. No source files changed.

Not rerun here: Java unit tests, backend integration tests, Playwright, full UI suites, or coverage measurement. The review does not treat the PR description's earlier test results as fresh execution evidence.

- The decision's memory writes commit in one transaction, so a write
  refused part-way, by a concurrent edit or a check only the write path
  makes, leaves every memory as it was and the review open instead of an
  approved memory beside the claim it should have retired.
- A client that shows the comparison sends what the reviewer compared
  (type/memoryConflictReviewResolution.json): the reviewed memory and every
  disputed memory with the claim time the reviewer read. The decision is
  refused when the disputes or any claim changed since.
- DELETE, soft or hard, is refused while the memory is in review, like
  /close and bulk Cancel.
- Keeping a memory sends what the dialog compared, and a refused decision
  reloads both memories so the reviewer compares again.
- Keeping the memory in review supersedes every memory it contradicts, so
  it waits until all of them are read, and a contradicted memory that
  failed to load is named above the comparison.
- Playwright covers a non-admin owner: the review is listed for them and
  not for a user with no stake, approving a claim they may not retire is
  refused with nothing changed, and rejecting resolves it.
@pmbrull
pmbrull enabled auto-merge October 13, 2026 19:51
…emories-review

# Conflicts:
#	openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterMemoriesPage/ContextCenterMemoriesPage.tsx
A review a delete cancelled, or one resolved earlier, can no longer end
its memory's review, so it closes or deletes freely even while a later
review holds the same memory.

The IT that creates a custom task now takes the form-schema lock
TaskResourceIT holds while it overrides that schema, so the two no longer
race in the parallel lane.
@pmbrull
pmbrull added this pull request to the merge queue Oct 14, 2026
…custom task

No CustomTask form schema is seeded, so TaskResourceIT's schema override
creates one and its restore hard-deletes it. TaskFormSchemaRepository only
clears its schema cache when a schema is stored, never when one is deleted,
so the deleted schema keeps validating CustomTask payloads until the next
schema write. A custom task created after that restore failed with
"required property 'reviewNotes' not found", which a resource lock cannot
prevent because the stale cache outlives the lock.

Use a DescriptionUpdate task, whose seeded schema no test rewrites, and
assert the refusal is the server-opened-review one.
@pmbrull
pmbrull removed this pull request from the merge queue due to a manual request Oct 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — manual (2026-10-14T05:44:30Z)

The entry left the queue before it was built, so no checks ran against it.

@pmbrull
pmbrull enabled auto-merge October 14, 2026 05:44
@pmbrull
pmbrull added this pull request to the merge queue Oct 14, 2026
Approving writes the reviewed memory first, then supersedes each disputed
memory, and that second write reads the reviewed memory back. With the
Redis entity cache, CachedEntityDao keeps the row such a read loads, the
uncommitted one included. When a later write is refused, the transaction
rolls back and executeInTransaction drops the cache evictions it deferred,
so Redis kept serving the reviewed memory as Approved while the database
still held it in Draft. ContextMemoryConflictReviewIT's part-way failure
case failed on the PostgreSQL + Elasticsearch + Redis lane only.

A decision whose transaction does not commit now evicts every memory it
wrote once the rollback is done.
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-10-14T14:29:44Z)

Blocked the queue: integration-tests-mysql-elasticsearch

@gitar-bot

gitar-bot Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 5 closed / 5 findings

🔴 High risk · Approving conflict reviews approves one memory and supersedes disputed claims, so a mistaken decision could retire knowledge used to ground answers.

Adds a memory conflict review task: a Draft memory with disputes opens one review assigned to both owners, and approving it supersedes the disputed memories. Resolved this session: governance-bot writes that end review now close the task, the Needs review tab is reachable without default-status memories, reviews are paginated past 50, the visibility check covers stage-less memories, and closed review tasks no longer block deletion. No open issues found.

✅ 5 closed
✅ Bug: Any governance-bot write that ends review leaves the task stuck open

📄 openmetadata-service/src/main/java/org/openmetadata/service/context/review/MemoryConflictReviewTasks.java:83-97 📄 openmetadata-service/src/main/java/org/openmetadata/service/context/review/MemoryConflictResolution.java:134-148 📄 openmetadata-service/src/main/java/org/openmetadata/service/tasks/TaskWorkflowHandler.java:415-429
afterWrite decides whether to skip closing the task with EntityStatusWorkflows.isWorkflowChange(current). That check is true for every write made as, or impersonating, governance-bot, not only for this task's own decision. So when anything else running as governance-bot moves a disputed Draft memory out of Draft, the open MemoryConflictReview task is never closed. One example is a governance workflow that owns the stage of contextMemory, which the description says is a supported setup. Another is a task resolution whose memory writes commit (decide at TaskWorkflowHandler:416) but whose later taskRepository.resolveTask call at line 438 fails.

After that, every attempt to resolve the task fails with 412 from requireInReview ("no longer in review"). The task stays in the owners' inbox until an admin cancels it by hand. The skip should apply only while this task's own resolution is running. For example, set a scoped marker (a ThreadLocal or a request attribute) in MemoryConflictResolution.decide and check it in afterWrite, instead of reusing the generic workflow predicate.

✅ Edge Case: Needs review tab unreachable when no default-status memories are visible

📄 openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterMemoriesPage/ContextCenterMemoriesPage.tsx:333-338 📄 openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterMemoriesPage/ContextCenterMemoriesPage.tsx:579-587
showMemoriesEmptyState only looks at the memory list, which is filtered to Approved/Unprocessed by default. If a user has no visible memories in those statuses, the page shows the full-page onboarding placeholder and never renders the count cards or tabs. Take an assignee whose only memory is their own Draft one, while the disputed memory is not visible to them: they have open conflict reviews and no way to reach them. Fix: skip the empty state when reviewTotal > 0 or when isReviewing is true.

✅ Edge Case: Reviews beyond the first 50 cannot be reached; no pagination

📄 openmetadata-ui/src/main/resources/ui/src/hooks/discovery/context-center/useMemoryConflictReviews.ts:19-33 📄 openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterMemoriesPage/ContextCenterMemoriesPage.tsx:1213-1226
useMemoryConflictReviews fetches one page of limit: 50, but the Needs review card shows paging.total. If more than 50 reviews are open (likely for an admin, who lists every review), the card counts them all while the list shows only 50, with no pager or after cursor. The rest only appear as earlier ones get resolved. Fix: page with the after cursor (for example useInfiniteQuery plus a load-more control), or tell the user the list is capped.

✅ Security: Visibility check skips the stage-less memories approval still supersedes

📄 openmetadata-service/src/main/java/org/openmetadata/service/context/review/MemoryConflictResolution.java:163-177 📄 openmetadata-service/src/main/java/org/openmetadata/service/context/review/MemoryConflictDecision.java:96-101
MemoryConflictDecision.isApproved counts a memory with no entityStatus (one saved before stages existed) as Approved, so approving the review supersedes it. readableDisputed only runs the visibility check when getEntityStatus() == APPROVED, so it skips those memories. The comment above it says a direct PATCH checks visibility before policy, which means requireMaySupersede's policy check does not cover visibility either. As a result, an assignee who cannot read a stage-less Private or Shared disputed memory can still retire it by approving the review. The fix is to use one predicate in both places, so every memory the approval supersedes also goes through the visibility check.

✅ Edge Case: Delete guard blocks removing closed review tasks while memory is held

📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/tasks/TaskResource.java:1591 📄 openmetadata-service/src/main/java/org/openmetadata/service/context/review/MemoryConflictResolution.java:157-167
delete now calls requireClosable(task), which goes to MemoryConflictResolution.requireReviewEnded. That method only checks whether the memory is still held for conflicts; it never looks at the task's own status. Here is how it goes wrong: a memory in review is soft-deleted, which cancels review A. The memory is then restored, which opens review B (the flow in deletingAMemoryInReviewClosesItsTaskAndRestoringItReopensOne). From then on, deleting or hard-deleting the already-cancelled task A returns 400 "Approve or reject this memory conflict review". The same happens to any review that was resolved earlier, for as long as the memory is held again. Only an open task can still end the review, so apply the guard to open tasks only.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@pmbrull
pmbrull merged commit 6f71f35 into main Oct 14, 2026
80 of 82 checks passed
@pmbrull
pmbrull deleted the pmbrull/conflicting-memories-review branch October 14, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review conflicting context memories with a task

5 participants