Skip to content

Fixes #36958: Set OSS approval defaults and hide pending memories from other readers - #36989

Merged
pmbrull merged 16 commits into
mainfrom
pmbrull/memory-visibility
Nov 6, 2026
Merged

pmbrull merged 16 commits into
mainfrom
pmbrull/memory-visibility

Conversation

@pmbrull

@pmbrull pmbrull commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #36958

  • Pending memories: Unprocessed and Draft memories now list only to their owners and to admins, in the REST list, the search listing and a document's memory card. A pending memory extracted from a document also lists to that document's owners, team owners included. A direct read by id keeps the share rules, so review-task assignees can still open the memory.
  • List totals: paging.total counts only the memories the caller can see.
  • Defaults and approval: OSS defaults new memories to Approved because it has no reconciliation application. It preserves an explicit stage and lets an authorized owner approve or restore their own memory. A distribution that requires review selects the protected repository constructor: ordinary creates then start Unprocessed, owner PATCH approval returns 403, and PUT preserves the pending stage. Collate selects this policy in its counterpart PR. Admins, bots and conflict-review decisions retain their approval rights. Disputes and evidence holds remain server-controlled.
  • Personal data: the extractor's prompt forbids personal data, as chat capture already does. It also retains Fixes #36957: Let extracted memories await review and keep every value a document gives #36988's conflicting-value instructions; both branches now carry the same prompt.

Type of change:

  • Bug fix

High-level design:

  • Listing:
    • ContextMemoryVisibility.isListedToOwnersOnly covers the REST list and document cards.
    • The 3-argument ContextMemorySearchVisibility.buildVisibilityFilter covers the search listing, by splitting the pending statuses into the owner clause.
    • ContextMemoryResource recounts the total, capped at 10,000 rows, whenever the database counted more rows than the page shows. Admins skip the recount.
  • Stage rules: in ContextMemoryRepository:
    • The protected constructor selects whether review is required. For review-required distributions, the create rule runs in prepare, before the memory is stamped as reviewed. An evidence hold on a retired query still starts in Draft.
    • The update rule sits in checkStageDecision.
    • A conflict-review decision is written as the resolving user impersonated by governance-bot, which no client can claim without the bot's token.
  • Distribution behavior: authorized OSS owners can restore their memory to Approved. Collate owners send it back to review; privileged actors retain approval rights. Existing stored states are not rewritten.
  • Records:
    • New: 2026-11-03-context-center-listings-show-and-count-only-what-the-caller-may-read, 2026-11-03-document-extraction-keeps-no-personal-data, and 2026-11-05-oss-memories-are-approved-without-reconciliation.
    • Amended: 2026-10-15-search-admits-a-subjects-own-pending-memories-on-request (v2), 2026-10-15-a-memory-cites-its-supporting-queries-and-their-retirement-holds-it-for-review (v2: the held-Draft queue is now the owners' and admins'), and 2026-10-09-data-consumers-create-context-memories (v4: OSS defaults and distribution review policy).
  • Counterpart: Collate #8241 selects the review-required repository and adds the privacy rule to its extraction agent. Merge this PR first.

Tests:

Use cases covered

  • Another user's Unprocessed or Draft memory no longer shows in a reader's Memories list or search, but still shows to its owner and to admins.
  • A document's owner sees the document's pending memories on its card.
  • paging.total with hidden rows counts only visible ones, including with limit=0.
  • OSS creates default to Approved; explicit Draft/Unprocessed states and authorized owner transitions are preserved. Collate creates/PUT stay pending and direct owner approval is refused.

Unit tests

  • Earlier baseline at 4badfea9115: the planner-selected unit run passed 303 tests (286 service, 17 MCP), no failures or skips.
  • Covers memory visibility, lifecycle, write access, repository/resource listing, search visibility, extraction/re-extraction, derivations, and the company-context tool.
  • Command: mvn -B package -pl openmetadata-mcp,openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=CompanyContextToolTest,ContextFileProcessingServiceTest,ContextMemoryExtractorTest,ContextMemoryLifecycleTest,ContextMemoryReconcilerTest,ContextMemoryRepositoryTest,ContextMemoryResourceTest,ContextMemorySearchVisibilityTest,ContextMemoryStatusTransitionTest,ContextMemoryVisibilityTest,ContextMemoryWriteAccessTest,EntityRepositoryEntityStatusTest,MemoryDerivationsTest,PageContextProcessingEngineTest,SearchRequestBuilderMemoryVisibilityTest,SemanticMemoryDuplicateFinderTest -Dsurefire.failIfNoSpecifiedTests=false.
  • mvn spotless:apply and the Java impact map check passed.

Backend integration tests

Focused Java verification at 6cf57120efccca2d61134d482154c2f9d648006a: PASSED.

  • Unit: MemoryEvidenceHoldsTest (21), ContextMemoryWriteAccessTest (24), ContextMemoryStatusTransitionTest (14), ContextMemoryRepositoryTest (40): 99 passed.
  • MySQL/Elasticsearch REST: ContextMemoryIT (35), ContextMemoryLifecycleIT (4), ContextMemoryCreateGrantIT (4): 43 passed. This exercises default creation, explicit stages, owner transitions, visibility and create grants over HTTP.
  • All counts have zero failures, errors or skips. Built with the locally installed companion snapshot. The full planner-selected integration suite was not rerun for this follow-up.

UI screen recording:

Not applicable: backend-only 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 added tests (unit / integration / Playwright as applicable) and listed them above.
  • Self-review against REVIEW.md: fresh review of 4badfea9115 found no remaining Important findings or test-map gaps. The extraction prompt preserves both privacy and conflicting-value rules.
  • By design: a review reconciliation opens between two memories of the same owner is assigned to that owner.
  • Non-admin list totals have live REST coverage in the November 4 follow-up. The complete planner-selected integration suite has not been rerun at the latest head.
  • Decision check: the records above.

Regression follow-up (2026-11-04)

  • New REST coverage checks the creation clamp through POST and PUT (including repeated PUT), rejects owner self-approval, checks pending rows and exact totals for owner/admin/other readers through database and search lists at limit=10 and limit=0, and allows an article owner to list its pending pills even when another user owns those memories.
  • 3 new/strengthened REST cases passed on isolated MySQL/Elasticsearch. Combined memory/governance unit run: 240 passed. The complete planner-selected IT suite was not run in this follow-up.
  • Self-review: 7ab64030a0a20d53a9556d8fcc58ca75827a422f, fresh REVIEW.md pass, no unanswered Important findings. Coverage findings were fixed before this pass.
  • Runtime evidence: all 12 pinned PR heads are present in the combined stack; source heads: OpenMetadata 7d7ac24b6e4e274b935954a067dbae7fa61007a3, AI eacb39819e854615b6eebf27b6fa486b4b9beba3, Collate f10b2d235cd4ec4f461a2db409f43a9289d4e3ae. Targeted combined runs are reported here; this does not claim that every planner-selected integration or browser suite ran.

Distribution approval policy (2026-11-05)

  • OSS defaults new memories to Approved; Collate selects review-required behavior independently of the reconciliation application's runtime state. Existing stored states are preserved.
  • Focused Maven reports verified from the implementation run: 99 OSS unit tests, 73 Collate unit tests, 43 OSS REST cases, and 3 Collate REST cases with AI disabled passed without failures or skips. The 73 Collate cases passed in both configured executions.
  • The Collate repository test was moved into the existing repository/context/*Test.java selection so normal unit CI executes it. No POM/build-file changes were made.
  • Fresh REVIEW.md review found no remaining Important findings at 6cf57120efccca2d61134d482154c2f9d648006a; the CI selection gap was fixed at 304afdc4549f946801ecc99411deb0b78a5c155d.
  • Fresh combined-stack check: the normal Collate surefire:test@unit-tests selection passed 2,690 tests, including all 3 relocated ContextMemoryRepositoryExtTest cases; no failures or skips.
  • OpenMetadata, AI and Collate Maven builds and both Docker image builds passed. The running Collate and AI services are healthy; all 12 remote PR heads are ancestors of the running sources. The 9 pre-restart memories retained their IDs, versions and stages.
  • Live non-admin Data Consumer REST smoke: omitted status creates Unprocessed; PUT requesting Approved stays Unprocessed; PATCH approval returns 403 and leaves the memory unchanged. The restricted-Query browser check also passed. Temporary fixtures were removed.
  • The review instance was missing the seeded memory-create rule (its Collate 2.0 snapshot does not apply the upstream 2.1 migration). Only that missing rule was added; other policy rules and review data were preserved.
  • This refresh used the focused REST results above; it did not rerun the complete impact-planner integration or Playwright selections.

Merge readiness (2026-11-06)

Merge order (12 memory PRs). OpenMetadata #36988 first, then #36990 and #36992 in any order, then #36989 (it needs #36988). Right after #36989: Collate #8241, then #8239. Until #8241 lands, Collate main starts a memory created without a stage Approved. Collate #8240 and #8242 can merge any time. OpenMetadata #36991 goes last of the OpenMetadata PRs, after one update once #36989 and #36992 land; its conflicts are already resolved. ai-platform #2035 and #2036 can merge any time. #2034 goes after Collate #8239 and #8241, with one update after #2035, also already resolved.

🤖 Generated with Claude Code

pmbrull and others added 5 commits November 3, 2026 12:27
…read

Release testing found the Memories page showing a reader another user's Shared
memory awaiting review, and an admin another user's Draft; the plain list also
kept a paging.total that counted memories the caller cannot see. Document
extraction kept a person's contact details, which chat capture never saves.

- A listing asking for Unprocessed or Draft gets them for the caller's own
  memories only, admins included, as a search asking for them already did.
- A list page that hides rows reports the total of memories the caller may
  read, counted over at most 10,000 rows.
- The extraction prompt forbids personal data and credentials, like capture.

ADR:2026-11-03-context-center-listings-show-and-count-only-what-the-caller-may-read
ADR:2026-11-03-document-extraction-keeps-no-personal-data

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ft keeps the share rules

The listing rule from the previous commit made Draft owner-only too, which hid
evidence holds (Draft with no review task) from the reviewers and readers that
Draft as the review queue relies on. Only a person's Unprocessed memory is now
listed to its owners alone, admins included; a document's pills and every
other stage keep the share rules. The plain list applies the same rule
(ContextMemoryVisibility.isListedToOwnersOnly) as the search-backed listing.

paging.total is now recounted whenever the database counted more rows than the
page shows, not only when this page hid a row, so a count-only call and a page
without hidden rows no longer count memories the caller cannot list.

ADR:2026-11-03-context-center-listings-show-and-count-only-what-the-caller-may-read
amends ADR:2026-10-15-search-admits-a-subjects-own-pending-memories-on-request

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…admin creates start Unprocessed

Item 15: an Unprocessed or Draft memory is listed only to its owners and to
admins, on the search-backed listing, the plain list and the per-document
cards. This replaces the previous commit's Unprocessed-only rule and its
extraction exemption. The plain list also shows a document's pending pills to
the document's owners, since the extractor, not the uploader, owns them. A
read by id keeps the share rules.

Item 18: a memory created by anyone but an admin or a bot starts Unprocessed,
whatever entityStatus it requests. ContextMemoryRepository.prepare applies it
on every create (POST, a PUT that creates, MCP create_entity), before the
stage stamps a review, and keeps a hold for retired evidence.

ADR:2026-11-03-context-center-listings-show-and-count-only-what-the-caller-may-read
amends ADR:2026-10-15-search-admits-a-subjects-own-pending-memories-on-request,
ADR:2026-10-15-a-memory-cites-its-supporting-queries-and-their-retirement-holds-it-for-review
and ADR:2026-10-09-data-consumers-create-context-memories

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…es a memory

Review finding: a Data Steward's create started Unprocessed, then a PATCH of
/entityStatus approved it, grounding everyone's answers without review.
ContextMemoryRepository.checkStageDecision now refuses (403) any move into
Approved unless an admin or a bot writes it, or a conflict review decision does
(the resolver writes as themselves through governance-bot). A PUT re-sends its
create request, stage included, so it keeps the stored stage instead.
Evidence holds, reconciliation, extraction, capture and upsertMemory are
unaffected. An owner can no longer restore their own retired memory to
Approved; the lifecycle ITs now assert that and restore as admin.

Also: an admin's list skips the visible-total recount, since nothing is hidden
from an admin, and a document's pending pills list to the members of a team
that owns it (SubjectContext.isOwner).

amends ADR:2026-10-09-data-consumers-create-context-memories

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o requested hold

Review finding: a non-admin could still approve their own memory through a
conflict review. Anyone who may edit a memory could add disputes, the review
is assigned to the owners of both sides, and its decision writes through
governance-bot. New disputes are now accepted only from an admin, a bot, or a
bot writing for a user (Collate's reconciliation writes them either way), on
create and on update; anyone else gets a 403.

The create rule no longer trusts a Draft that carries the evidence-hold text.
It runs before the server's own hold, which still starts a memory citing a
retired Query in Draft, and a PUT that creates now runs the POST create so it
is prepared once.

amends ADR:2026-10-09-data-consumers-create-context-memories

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 3, 2026 19:49
@pmbrull
pmbrull requested a review from a team as a code owner November 3, 2026 19:49
@pmbrull
pmbrull requested a review from sonika-shah November 3, 2026 19:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Nov 3, 2026
Copilot AI balanced review requested due to automatic review settings November 3, 2026 22:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 4, 2026 16:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

OSS has no reconciliation app or general approval UI. Keep review
required as a repository policy that Collate selects explicitly,
including its creation and owner approval restrictions.

Preserve explicit OSS stages and existing memories. Keep ownership,
provenance, visibility, and evidence checks in both distributions.
@pmbrull
pmbrull requested a review from a team as a code owner November 5, 2026 10:27
@pmbrull
pmbrull requested review from Rohit0301 and a balanced review from Copilot November 5, 2026 10:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@pmbrull pmbrull changed the title Fixes #36958: List pending memories only to owners and admins, let only admins, bots and reviews approve, and keep personal data out of extraction Fixes #36958: Set OSS approval defaults and hide pending memories from other readers Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 81%
81.6% (141370/173230) 69.02% (51720/74933) 71.98% (28972/40245)

@sonarqubecloud

sonarqubecloud Bot commented Nov 5, 2026

Copy link
Copy Markdown

pmbrull and others added 2 commits November 5, 2026 17:12
…r tests

Both PRs added tests at the same spot, so whichever merged second conflicted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 5, 2026 16:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 6, 2026 07:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 6, 2026 08:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@gitar-bot

gitar-bot Bot commented Nov 6, 2026

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

🔴 High risk · Restricting who can list pending memories and defaulting OSS creations to Approved could hide review items or expose unreviewed facts for grounding.

Adds personal-data and conflicting-value rules to the document memory extractor prompt, plus owner/admin-only listing of pending memories and admin/bot-only approval. Changes requested: the conflicting-values extraction rule has no decision record and no test asserting its prompt text, and the companion Collate agent carries only the personal-data rule.

✅ 1 closed
Closed: Quality: New conflicting-values extraction rule has no record or test

📄 openmetadata-service/src/main/java/org/openmetadata/service/context/center/ContextMemoryExtractor.java:40-43
This commit's title is "retain both extraction rules", but the first rule (lines 40-43, which says to return one element per differing value, name the section only in the summary, and never merge or pick the newer one) was not in the tree before. git log -S"one element per value" finds only 4badfea. The PR description doesn't mention it, and no file in docs/decisions/ records it. 2026-11-03-document-extraction-keeps-no-personal-data covers only the personal-data rule. The repo squash-merges, so the reason for this rule will be lost. It is also a contract: that ADR already says a provider that replaces the prompt (Collate's extraction agent) must carry the same rules, and the companion PR open-metadata/openmetadata-collate#8241 adds only the personal-data rule. ContextMemoryExtractorTest checks only the "Never extract personal data" text, so if a later edit drops this rule, no test fails.

The record would say: "When a document gives different values for the same fact, automatic extraction returns one memory per value, each answer stating only its own value with its source section named in the summary, and never merges them or picks one, even when a section claims to be newer. Any provider that replaces the prompt must carry the same rule." Add that sentence to the extraction ADR (or a new record), add a test assertion for the prompt text, and mirror the rule in the Collate agent.

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

sonarqubecloud Bot commented Nov 6, 2026

Copy link
Copy Markdown

@pmbrull
pmbrull merged commit f7ee984 into main Nov 6, 2026
72 of 75 checks passed
@pmbrull
pmbrull deleted the pmbrull/memory-visibility branch November 6, 2026 10:11
Rohit0301 added a commit that referenced this pull request Nov 9, 2026
…ken by memory-status, page-size and leave-team changes (#37338)

* test(playwright): fix Context Center, Table and ProfileTeam specs after memory-status, page-size and leave-team changes

- createMemoryViaApi and the Permission owner fixture pin entityStatus Approved:
  #36989 made Collate (reviewRequired) start memories Unprocessed and hid pending
  memories from non-owners, so readers never saw the fixtures.
- Table tag-search test uses dim_customer.average_order_size: with 15-row column
  pages sorted by name (#35288), shop_id moved to page 2.
- ProfileTeam leave waits for PATCH /users/<me>: leaving now updates the user's
  teams instead of DELETE /teams/<id>/users/<id>.

* test(playwright): assert 200 on ProfileTeam join/leave responses after awaiting them

* test(playwright): address review on Context Center, Table and ProfileTeam spec fixes

- createMemoryViaApi keeps the Approved default when entityStatus is passed as undefined
- Dashboard drops the Approved asserts that only echoed the helper (OSS default is
  guarded by ContextMemoryCreateGrantIT)
- Permission owner fixture goes through createMemoryViaApi so a failed POST fails fast
- Table tag test searches the column before tagging, so pagination and sort no longer
  matter; afterAll hard-deletes the glossary and classification
- ProfileTeam join/leave waits are scoped to the admin's own PATCH via
  waitForResponseWithStatus

* chore(playwright): auto-refresh impact-map.generated.json

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.1 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.

Memories: pending memories list to other readers, totals count hidden rows, extraction keeps personal data, any user can create Approved

4 participants