Repository navigation
feat(context): restore memory extraction from files and articles behind an AiProvider seam - #32524
Conversation
…nd an AiProvider seam Re-lands the Context Center knowledge-pill extraction pipeline (engines, reconciler, repository hooks, list filters, search-index fields) that #30041 reverted, without the Memory Agent, AISettings, or MCP Chat. Extraction now runs behind a pluggable AiProvider seam resolved from llmConfiguration.aiProviderClass: OSS ships LlmAiProvider (one structured completion via the shared LLMCompletionClient, all providers supported); Collate can substitute an agent-platform implementation without any caller changing. The candidate shape (KnowledgePill) is the compatibility boundary between the two engines. Adaptations over the reverted code: - File pipeline rebuilt on the hardened conditional-update service (#31118): retry/backoff, contention requeue, RequestEntityCache hygiene now cover the pill stage too. - Extraction gate is llmConfiguration.enabled alone; the AISettings toggles are gone. - AiProviderHolder resolves the configured class via asSubclass and falls back to the built-in provider on ClassCastException instead of crashing (review finding on #29360), pinned by a regression test. - FileContextProcessingEngine only treats EntityNotFoundException as file-gone; infrastructure failures now propagate to a Failed status instead of silently marking the file Processed. Co-Authored-By: Claude Fable 5 <[email protected]>
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
✅ Generated Sources Auto-UpdatedThe generated TypeScript types ( |
|
Collate-side implementation of this seam: open-metadata/openmetadata-collate#6374 (draft until this merges and the submodule pin advances). |
…xt becomes context/entity The service-layer package now matches the domain language: everything Context Center (file/article extraction engines, the AiProvider seam, KnowledgePill) lives under context/center, and the AI entity-prompt classes move from the context/ root into context/entity. 'drive' was the legacy storage name; the REST surface already says contextCenter. Mechanical move — no behavior change; all moved-package suites green (48 tests). Co-Authored-By: Claude Fable 5 <[email protected]>
…nd skips cross-source duplicates Extraction previously matched derived pills to stored ones by exact normalized question, so a model that reworded a question between runs retired the old pill and created a new one — losing its usageCount/lastUsedAt and its embedding for an unchanged fact. And nothing looked beyond the source being extracted, so one policy stated in two documents produced two pills. Reconciliation now runs three passes: exact question match, then word-overlap similarity for rephrasings (same gate as the server's duplicate probe — 0.6*question + 0.4*answer Jaccard at 0.85), then creation, where a best-effort search probe checks whether another source's automated pill already states the fact. A rephrase updates in place; a cross-source restatement is skipped and counted. Deliberately deterministic and lexical: the precision gate is word overlap, so vector recall could not change an outcome, only cost more. Semantic paraphrase and contradiction detection belong to the scheduled reconciliation pass, not to extraction time. Manual and chat-authored memories never suppress extraction — a user's private note must not silence a document's knowledge — and a probe failure degrades to creating the pill. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Pushed two follow-ups on this branch: 1. 2. Reconciliation keeps pill identity across rephrasing, and skips cross-source duplicates. Matching was exact normalized question, so a reworded question retired the old pill and created a new one — losing Deliberately deterministic and lexical: the precision gate is word overlap, so vector recall could not change an outcome, only cost more. Manual and chat-authored memories never suppress extraction (a user's private note must not silence a document's knowledge), and a probe failure degrades to creating the pill. Semantic paraphrase/contradiction detection stays out of extraction time — it belongs to the scheduled reconciliation pass (ai-platform#1130), whose judge agent is now seeded in openmetadata-collate#6374. Suites green: 46 tests across |
…n, redundant index put - memoryCount was populated per-entity in setFields but never in either repository's setFieldsInBulk, so a list asking for it got 0/null while GET-by-id returned the real count. Both ContextFile and Page now fill it from one batched MENTIONED_IN query (MemoryCountFetcher), and Page clears it when unrequested like ContextFile already did. - The page extraction throttle evicted a pending page even when the incoming id was already tracked, so one actively-autosaved page could repeatedly cost unrelated pages their run. Evict only when the page is new. - Dropped a duplicate sourceType put in ContextMemoryIndex; the field is already stamped, null-safely, earlier in the same doc build. Co-Authored-By: Claude Fable 5 <[email protected]>
…js/no-nested-conditional Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
🚦 Removed from the merge queue —
|
Code Review 👍 Approved with suggestions 4 resolved / 5 findingsRestores the Context Center knowledge-pill extraction pipeline behind a pluggable 💡 Quality: Docs say memoryExtractionEnabled is "Independent" but code requires enabled too📄 conf/openmetadata.yaml:615-618 📄 openmetadata-spec/src/main/resources/json/schema/configuration/llmConfiguration.json:34-38
✅ 4 resolved✅ Bug: memoryCount populated on GET but omitted in list queries
✅ Edge Case: Throttle reschedule can evict an unrelated pending page
✅ Quality: Redundant sourceType put in ContextMemoryIndex
✅ Performance: Duplicate probe issues one search per new candidate
🤖 Prompt for agentsOptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
| Count | Rule |
|---|---|
| 1 | openmetadata-imports/no-circular-imports |
| 1 | openmetadata-imports/no-rest-ui-imports |
| 1 | openmetadata-imports/no-internal-barrel-imports |
All findings
| Location | Rule | Message | |
|---|---|---|---|
| 🟡 | src/interface/knowledge-center.interface.ts:14:1 |
openmetadata-imports/no-circular-imports |
This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency. |
| 🟡 | src/rest/contextMemoryAPI.ts:15:1 |
openmetadata-imports/no-rest-ui-imports |
REST clients must not import UI or state-layer modules. Move shared request/response types to the interface layer. |
| 🟡 | src/rest/contextMemoryAPI.ts:19:1 |
openmetadata-imports/no-internal-barrel-imports |
Import the internal module directly instead of its index barrel so unrelated siblings do not enter the bundle graph. |
Fix locally (fast - only checks files changed in this branch):
make ui-checkstyle-changed
|
|
🚦 Removed from the merge queue —
|



Describe your changes:
Fixes #32523
Re-lands the Context Center knowledge-pill extraction pipeline that #30041 reverted — uploaded files and Knowledge Center articles are turned into
ContextMemorypills again — without the Memory Agent, AISettings, or MCP Chat, and this time behind the pluggable engine seam that was the point of the closed #29360.AiProvider→DocumentMemoryExtractor, resolved once byAiProviderHolderfromllmConfiguration.aiProviderClass. Unset → the built-inLlmAiProvider(one structured completion per chunk via the sharedLLMCompletionClient, so every supported provider — OpenAI/Azure, Bedrock, Google, Anthropic — works out of the box). Collate sets the class name to substitute an agent-platform engine with zero OSS changes: its implementation invokes a seeded dynamic agent on the AI platform (default graph, no skills, bot identity — the same pattern as the landing-page recommended actions), and this seam'sKnowledgePilldeserialization is the structural gate on whatever comes back. Resolution hardening reviewers asked for on feat(ai): pluggable AiProvider seam for memory & ontology derivation #29360 is in: a configured class that exists but does not implementAiProviderfalls back cleanly (asSubclass+ClassCastExceptioncatch) instead of crashing the service, pinned by a regression test.ContextProcessingEngine(hash gate — unchanged content never calls the LLM; a failed run never stamps the success hash),FileContextProcessingEngine,PageContextProcessingEngine(5-min trailing-throttle debounce for autosaves),ContextMemoryExtractor(paragraph-aligned chunking, 60K chars × 8 chunks cap), andContextMemoryReconciler(match by normalized question; keep/update/retire — preserves pill identity, usage telemetry and embeddings; human-edited pills flip toManualand are never touched).RequestEntityCachehygiene), renamed back toContextFileProcessingService, with the LLM stage riding the same conditional updates.FileContextProcessingEnginenow only treatsEntityNotFoundExceptionas file-gone; infrastructure failures propagate to aFailedstatus instead of silently marking the fileProcessed.drive/memory/*(Memory Agent), AISettings (the gate isllmConfiguration.enabledalone),DERIVED_FROMprojections, MCP Chat. Ontology derivation returns later through Ontology Studio change sets, per the memory & ontology plan (open-metadata/ai-platform#1107 / Fields for creating service used by Redash #523).llmConfiguration.aiProviderClass+LLM_AI_PROVIDER_CLASSinconf/openmetadata.yaml; ES mappings re-addsourceFile(additive; the index-time visibility-enforcement fields are untouched). No DB migration — the entity fields were frozen by the revert and are re-activated code-only. Generated TS forllmConfigurationrides the type-generation workflow.Type of change:
High-level design:
Checklist:
ContextFileProcessingServiceTest(status machine incl. LLM stage, contention, recovery),PageContextProcessingEngineTest(throttle, hash gate, blank-body retire),ContextMemoryExtractorTest(chunking, dedup, validation),ContextMemoryReconcilerTest(keep/update/retire, Manual pills),AiProviderHolderTest(fallbacks incl. the ClassCastException regression) — all green locally, plusmvn -pl openmetadata-service,openmetadata-spec spotless:apply.