Repository navigation
Conversation
…faces Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
❌ PR checklist incompleteThis 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 |
| } catch (ClassNotFoundException notOnClasspath) { | ||
| resolved = new LlmAiProvider(); | ||
| } catch (ReflectiveOperationException badProvider) { |
There was a problem hiding this comment.
ClassCastException escapes the fallback handler
If a class named by the system property exists on the classpath but does not implement AiProvider, the (AiProvider) cast on line 55 throws a ClassCastException. That is a RuntimeException, not a ReflectiveOperationException, so neither catch block intercepts it — the exception propagates unchecked through build() → get() → every AiProviderHolder.get() call site, crashing the service at startup instead of logging the error and falling back to LlmAiProvider. The second catch block's intent ("on the classpath but could not be instantiated") clearly covers this case, so adding ClassCastException (or widening the second catch to Exception) makes the behaviour consistent with the stated contract.
| } catch (ClassNotFoundException notOnClasspath) { | |
| resolved = new LlmAiProvider(); | |
| } catch (ReflectiveOperationException badProvider) { | |
| } catch (ClassNotFoundException notOnClasspath) { | |
| resolved = new LlmAiProvider(); | |
| } catch (ClassCastException | ReflectiveOperationException badProvider) { |
Replace the hardcoded DEFAULT_PROVIDER_CLASS constant and the openmetadata.ai.provider.class system property with a config-driven seam: AiProviderHolder reads llmConfiguration.aiProviderClass (openmetadata.yaml) via LlmConfigHolder. Unset/blank/absent class falls back to the built-in LlmAiProvider. Mirrors pipelineServiceClientConfiguration.className. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
| private static AiProvider resolveConfigured(final String className) { | ||
| AiProvider resolved; | ||
| try { | ||
| final Class<?> clazz = Class.forName(className); | ||
| resolved = (AiProvider) clazz.getDeclaredConstructor().newInstance(); | ||
| LOG.info("Using AI provider: {}", className); | ||
| } catch (ClassNotFoundException notOnClasspath) { | ||
| LOG.warn( | ||
| "Configured aiProviderClass '{}' is not on the classpath; using the built-in LLM provider", | ||
| className); | ||
| resolved = new LlmAiProvider(); | ||
| } catch (ReflectiveOperationException badProvider) { | ||
| LOG.error( | ||
| "Configured aiProviderClass '{}' could not be instantiated; using the built-in LLM provider", | ||
| className, |
There was a problem hiding this comment.
⚠️ Bug: Misconfigured non-AiProvider class crashes startup instead of falling back
In resolveConfigured, the cast (AiProvider) clazz.getDeclaredConstructor().newInstance() (line 71) throws ClassCastException when the configured aiProviderClass names a class that exists on the classpath but does not implement AiProvider. ClassCastException is an unchecked RuntimeException, so it is caught by neither catch (ClassNotFoundException ...) nor catch (ReflectiveOperationException ...). The exception propagates out of build() (which is called lazily from get()), defeating the graceful-fallback contract now stated in the Javadoc and warn/error messages ("using the built-in LLM provider"). A distribution that wires in a wrong class name in llmConfiguration.aiProviderClass would crash the service rather than degrade to the OSS LlmAiProvider. The error-handling block around this cast is modified in this commit, so the fallback guarantee should cover this case too.
Use asSubclass for an early, descriptive failure and also catch ClassCastException so a wrong-type class falls back gracefully. Add a regression test covering a classpath class that does not implement AiProvider.:
private static AiProvider resolveConfigured(final String className) {
AiProvider resolved;
try {
final Class<? extends AiProvider> clazz =
Class.forName(className).asSubclass(AiProvider.class);
resolved = clazz.getDeclaredConstructor().newInstance();
LOG.info("Using AI provider: {}", className);
} catch (ClassNotFoundException notOnClasspath) {
LOG.warn(
"Configured aiProviderClass '{}' is not on the classpath; using the built-in LLM provider",
className);
resolved = new LlmAiProvider();
} catch (ReflectiveOperationException | ClassCastException badProvider) {
LOG.error(
"Configured aiProviderClass '{}' could not be instantiated; using the built-in LLM provider",
className,
badProvider);
resolved = new LlmAiProvider();
}
return resolved;
}
Was this helpful? React with 👍 / 👎
✅ TypeScript Types Auto-UpdatedThe generated TypeScript types have been automatically updated based on JSON schema changes in this PR. |
🟡 Playwright Results — all passed (19 flaky)✅ 4093 passed · ❌ 0 failed · 🟡 19 flaky · ⏭️ 22 skipped
🟡 19 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
Code Review
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
| final Class<?> clazz = Class.forName(className); | ||
| resolved = (AiProvider) clazz.getDeclaredConstructor().newInstance(); | ||
| LOG.info("Using AI provider: {}", className); |
There was a problem hiding this comment.
Wrong type still escapes
When aiProviderClass names an existing class with a no-arg constructor that does not implement AiProvider, construction succeeds and this cast throws ClassCastException. That exception is not handled by the fallback block, so AiProviderHolder.get() can still fail instead of returning LlmAiProvider. A configuration mistake such as LLM_AI_PROVIDER_CLASS=java.lang.String can break the lazy file, page, or memory deriver setup.
| final Class<?> clazz = Class.forName(className); | |
| resolved = (AiProvider) clazz.getDeclaredConstructor().newInstance(); | |
| LOG.info("Using AI provider: {}", className); | |
| final Class<?> clazz = Class.forName(className); | |
| resolved = AiProvider.class.cast(clazz.getDeclaredConstructor().newInstance()); | |
| LOG.info("Using AI provider: {}", className); |
| try { | ||
| final Class<?> clazz = Class.forName(className); | ||
| resolved = (AiProvider) clazz.getDeclaredConstructor().newInstance(); | ||
| LOG.info("Using AI provider: {}", className); | ||
| } catch (ClassNotFoundException notOnClasspath) { | ||
| LOG.warn( | ||
| "Configured aiProviderClass '{}' is not on the classpath; using the built-in LLM provider", | ||
| className); | ||
| resolved = new LlmAiProvider(); | ||
| } catch (ReflectiveOperationException badProvider) { | ||
| LOG.error( | ||
| "Configured aiProviderClass '{}' could not be instantiated; using the built-in LLM provider", | ||
| className, | ||
| badProvider); | ||
| resolved = new LlmAiProvider(); | ||
| } |
|
|
…nd an AiProvider seam (open-metadata#32524) * feat(context): restore memory extraction from files and articles behind an AiProvider seam Re-lands the Context Center knowledge-pill extraction pipeline (engines, reconciler, repository hooks, list filters, search-index fields) that open-metadata#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 (open-metadata#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 open-metadata#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]> * Update generated TypeScript types and dereferenced schemas * refactor(context): drive/ becomes context/center, entity-prompt context 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]> * feat(context): reconciliation keeps pill identity across rephrasing and 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]> * fix(context): review findings — batched memoryCount, throttle eviction, 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]> * feat(context): memory extraction gets its own switch, independent of llmConfiguration.enabled llmConfiguration.enabled turns on embeddings, Ontology Studio AI and every other completion feature, so a deployment that enabled LLM features for semantic search was also, silently, asking every upload and article edit to spend model calls deriving knowledge pills. Extraction now needs llmConfiguration.memoryExtractionEnabled as well (LLMClientHolder.isMemoryExtractionEnabled = enabled AND extraction flag). Off by default in OpenMetadata: extraction here is unmetered, so it is opt-in and a large upload cannot become unbounded model spend on a self-hosted deployment without someone asking for it. Ontology Studio AI and the RDF endpoints keep reading isEnabled — this switch is extraction's alone. Co-Authored-By: Claude Fable 5 <[email protected]> * Update generated TypeScript types and dereferenced schemas * feat(context): restore the extracted-memories panel and status badges The revert in open-metadata#30041 removed the UI half of knowledge-pill extraction while this branch restored the backend. The memory -> source link survived (the view modal renders sourceEntity), but the source -> memories direction did not, so an article or file had no way to show what was derived from it. Restores the deleted components as they were and re-wires their call sites: - ExtractedMemoriesCard: lists a source's pills via GET /contextCenter/memories?sourceEntityId=..., opens each in the view modal - ArticleStatusBadge / DocumentStatusBadge: extraction status, with the processing error (or partial chunk coverage) as a tooltip - KnowledgePageDetailRightPanel: status row + collapsible memories card - DocumentPreviewPanel: status row, processing-error row, memories card - DocumentsView: "N memories" in the file row, status badge in the actions - ContextMemoryListParams regains sourceFileId/sourceEntityId; KnowledgePage regains processingStatus/processingError DocumentPreviewPanel also regains tw:min-h-0: the memories card is shrink-0, so without it the flex child cannot shrink to the scroll container and the panel body stops scrolling. MemoryStatusBadge and DerivedOntologyCard are deliberately not restored. Both render MemoryProcessingStatus, which tracks the Memory/Ontology Agent derivation rather than pill extraction, and nothing in the service stamps it on this branch — they would render nothing. The schema enum stays frozen, so reviving them needs no schema change. Tests: ExtractedMemoriesCard and KnowledgePageDetailRightPanel had no coverage before and now do (fetch params, empty/error states, view modal, owner-based delete permission, status row gating); DocumentPreviewPanel gains the status, memories and error-row cases; the playwright spec regains its Status assertion. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * feat(context): stamp Processing when an article extraction run starts PageProcessingStatus has always declared Processing, but nothing wrote it: the pipeline went Queued -> Processed/Failed. Because the throttle coalesces autosaves over a five-minute quiet period, the UI badge sat on Queued for minutes and then jumped straight to Processed, with no way to tell a run in flight from one still waiting. Adds ContextProcessingEngine.markProcessing(UUID) -- a no-op by default, called from runExtraction after the shouldProcess hash gate rather than at the top, so an unchanged-content skip stays a single write instead of two. PageContextProcessingEngine overrides it to stamp Processing. FileContextProcessingEngine deliberately does not override it: ContextFileProcessingService already owns the file status flow (Uploaded -> Analyzing -> ExtractingContext -> Processed/Failed/Unsupported). Cost is one extra version-free page write plus a reindex per real run, and none per skip. Known gap, matching the in-memory throttle's existing behaviour for Queued: a JVM death between the Processing stamp and the terminal stamp leaves the article on Processing until its next body edit re-arms the run. The test helper that captured the single page write now captures all of them and asserts on the last, since a real run writes twice. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(context): a deleted source leaves no knowledge pills behind Hard-deleting a Context Center file left its pills in the database forever as soft-deleted rows. A hard delete runs the soft-delete pass first, which soft-deleted the pills; the hard pass then looked them up through deleteExtractedMemories, whose findTo used the default Include.NON_DELETED and so could not see the rows its own soft pass had just hidden. The result was invisible tombstones that still held their FQNs and their search and vector index entries -- exactly what the reconciler's deleteRetired comment argues against. deleteExtractedMemories now looks up with Include.ALL and always hard-deletes, so both delete paths converge on the same outcome: no memories. A pill is derived data, regenerable from its source, so it should not outlive the source in any form. This also makes the behaviour consistent for pages, which cannot soft-delete at all (page.json has no `deleted` property, so supportsSoftDelete is false) and therefore only ever reached the hard hook. restoreExtractedMemories and both restoreAdditionalChildren overrides are removed: with the pills hard-deleted there is nothing left to un-delete. A restored source is expected to re-derive its pills rather than resurrect tombstones. Covered by three ITs in ContextFileIT. They create pills through POST /contextCenter/memories with sourceEntity set, which writes the same MENTIONED_IN edge extraction does, so the cascade is exercised without a model call. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(context): article extraction no longer deletes relatedEntities Every extraction stamp silently wiped an article's related data assets and bumped its version. PageContextProcessingEngine.getPage loaded the page with getFields(""), which leaves the relationship-backed fields null; relatedEntities is in KNOWLEDGE_UPDATE_FIELDS, so the updater read that null as a removal and deleted the HAS rows. The article's own version history recorded it as `fieldsDeleted: relatedEntities` on the first stamp of every run. Loading getPutFields() instead makes the stamp a real read-modify-write, so relatedEntities, parent and children round-trip untouched. This also removes the version churn the surrounding comments say machine extraction avoids: the churn was never processingStatus (already recorded with updateVersion=false), it was the relationship deletion riding along with it. FileContextProcessingEngine keeps getFields(""), which is correct there: ContextFileRepository declares no patch/put fields, so a file has no updater-managed relationship to lose. Confirmed against a running instance -- a file's folder survives extraction. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(context): the duplicate probe can actually return a hit Cross-source dedup never fired. The probe passed the candidate's title, question and answer joined as one query string, and the search layer applies AND semantics to a bare query -- so every word had to occur in a single stored memory. Any one non-matching token returned zero hits, which made duplicateElsewhere unreachable and the "two documents stating one policy yield one pill" guarantee false. Measured on a running instance with two identical uploads: all seven pill pairs score 1.000 against the 0.85 gate, and the run still logged `0 duplicates skipped`. q="Tier B Vendor Requirements" -> 5 hits q="Tier B Vendor Requirements zzzqqqxyz" -> 0 hits q=<the probe's own query> -> 0 hits The query is now an OR of the candidate's distinct words, restoring should-style recall. Precision is unaffected: the reconciler re-scores every hit through the same deterministic Jaccard gate. Recall draws on title and question only. The answer's generic prose dilutes ranking -- including it, an exact duplicate placed 7th of the 10 hits fetched and on a larger corpus would fall out of the window; title plus question ranks that duplicate 2nd, which also matches the gate's own weighting of question over answer. Tokenizing on non-word characters replaces the old operator blacklist and is strictly safer: every clause is now a \w+ run, so candidate text can neither break the query nor smuggle in a lucene operator. The outage was invisible because the probe logs its failures at debug and ContextMemoryReconcilerTest supplies a fake probe, so nothing exercised the real query. New tests pin its shape, which is the whole of the defect. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(context): a rephrased question keeps its pill instead of churning it Reconciliation matched a derived pill to a stored one using DUPLICATE_THRESHOLD, the same 0.85 bar used to suppress a duplicate from another source. That conflates two different questions. Suppressing a duplicate means "another source already states this" and should demand near-verbatim agreement; keeping identity means "the model rephrased my fact", where 0.85 is far too strict -- so a single reworded question orphaned the pill, and re-extraction deleted and recreated most of a document's pills, losing their usageCount/lastUsedAt along the way. Measured on a running instance: editing one number in a seven-pill article produced 6 created, 1 updated, 1 kept, 5 deleted. Scoring each stored pill against its best new match gives 0.85 -> 2 of 7 keep identity 0.70 -> 4 of 7 0.50 -> 6 of 7 The seventh scores 0.175 because the model genuinely dropped that fact, so retiring it is correct and 6 is the ceiling. Splitting out IDENTITY_THRESHOLD at 0.5 reaches it with a wide margin over the true non-match (0.539 vs 0.175). DUPLICATE_THRESHOLD stays at 0.85 for cross-source suppression. The loose bar is safe because removeMostSimilar already claims the best match above the bar rather than the first, so a weaker candidate cannot take a pill a closer one should own -- now stated in its contract, since the bar no longer makes a wrong match implausible on its own. Both measured pairs are covered by tests. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(ui): extract nested ternary in ExtractedMemoriesCard to fix sonarjs/no-nested-conditional Co-Authored-By: Claude Sonnet 4.6 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Rohit0301 <[email protected]> Co-authored-by: Rohit Jain <[email protected]>



Describe your changes:
Follow-up to #29201 (feature issue #29285) — refactor only, no separate tracking issue, no user-visible change.
I put the two LLM-backed AI steps added in #29201 — document → memory pills and memory → ontology verdict — behind a single pluggable
AiProviderseam, so OSS keeps calling the LLM while a downstream distribution can drop in a different backend (e.g. an agent platform) with zero changes to OSS code. Selection is config-driven (same shape aspipelineServiceClientConfiguration.className):AiProviderHolderreadsllmConfiguration.aiProviderClassfromopenmetadata.yamland reflectively loads it, falling back to the built-inLlmAiProviderwhen unset/blank/absent; all three production call sites now build their deriver through it. Behavior is unchanged in OSS and guarded by existing tests.Type of change:
High-level design:
MemoryDeriver(ContextMemory + MemoryContext → MemoryDerivation) andDocumentMemoryExtractor(text → DeriveResult) interfaces from the existing concreteMemoryExtractor/ContextMemoryExtractor; theDeriveResultrecord moved onto the interface so no consumer is pinned to the LLM impl. The seam sits at the agent altitude (verdict in / out), not the LLM-token altitude — an agent backend is not a chat-completion client.AiProvidervends both derivers;LlmAiProvideris the OSS default (builds the LLM-backed impls viaLLMClientHolder);AiProviderHoldercaches a single instance resolved fromllmConfiguration.aiProviderClass(missing class → warn + OSS fallback, instantiation failure → error + OSS fallback), withsetForTesting/resettest seams. Config-driven-FQCN pattern likepipelineServiceClientConfiguration.className; double-checked-locking idiom from the siblingPageContextProcessingEngineHolder. New schema fieldllmConfiguration.aiProviderClass(additive, optional) surfaced inconf/openmetadata.yamlas${LLM_AI_PROVIDER_CLASS:-""}.MemoryProcessingEngine,ContextFileProcessingService, andPageContextProcessingEngineHoldernow obtain their deriver fromAiProviderHolder.get(). Post-condition: onlyLlmAiProviderconstructs the OSS extractors.LLMCompletionClient(token) level — wrong altitude; subclassing the concrete extractors — fragile base class and forces the OSS constructor's dependencies on the alternate impl.Tests:
Use cases covered
llmConfiguration.aiProviderClassunset:AiProviderHolder.get()returnsLlmAiProvider; both AI steps call the LLM exactly as before.aiProviderClassset to an on-classpath impl: thatAiProviderdrives both steps with no OSS edit. A configured-but-missing class warns and falls back to the LLM provider.setForTesting.Unit tests
AiProviderHolderTest(4): OSS fallback when unconfigured,setForTestinginjection,aiProviderClassresolution, configured-but-missing-class fallback.AiProviderHolderTest,MemoryExtractorTest,MemoryProcessingEngineTest,ContextMemoryExtractorTest,PageContextProcessingEngineTest,ContextFileProcessingServiceTest).Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
Consolidated
mvn -pl openmetadata-service testover the six touched test classes on the final commit: 37 run / 0 failed.UI screen recording / screenshots:
Not applicable.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.aiProviderClassonllmConfiguration; no migration needed (generic config schema). GeneratedllmConfiguration.tsupdated (CI's TypeScript Type Generation will normalize if needed).🤖 Generated with Claude Code
Greptile Summary
This PR adds a configurable AI provider seam for Context Center derivation. The main changes are:
AiProviderinterface with LLM-backed default implementation.llmConfiguration.aiProviderClass.Confidence Score: 4/5
This is close, but the provider fallback should be fixed before merging.
AiProvidercan still throw during lazy setup.openmetadata-service/src/main/java/org/openmetadata/service/drive/AiProviderHolder.java
Important Files Changed
Reviews (4): Last reviewed commit: "Merge branch 'main' into pmbrull/ai-sett..." | Re-trigger Greptile
Context used (3)