Repository navigation
feat(context): extract knowledge pills from Context Center pages - #29119
Conversation
Mirror the file knowledge-pill pipeline for Context Center pages (Knowledge Center articles) through a new shared ContextProcessingEngine with File and Page implementations. Page bodies autosave constantly, so page extraction is gated three ways: - an in-memory, bounded, trailing throttle (one run after the body settles) so editing churn never triggers the LLM mid-edit; - a content hash-gate (new ExtractionStats.sourceHash) so unchanged content is never reprocessed; - reconciliation against the page's existing pills (match by question: keep/update/retire/add) instead of wholesale delete-and-recreate, so pill identity and usage telemetry survive edits. Both the hash-gate and reconciliation live in the shared engine, so the file pipeline inherits them too (no more hard-delete-and-recreate on re-upload, and identical content is skipped). Pills link back to their source via a generic sourceEntity reference resolved from the MENTIONED_IN edge; sourceFile is kept as a deprecated derived alias, so no data migration is needed. A user PATCH flips a pill's sourceType to Manual (keyed on the operation, not updatedBy, since the engine writes as admin), and reconciliation never touches human-edited pills. KnowledgePageRepository schedules extraction on article create/body-change, cascades pill deletion on page delete, and exposes memoryCount. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
✅ TypeScript Types Auto-UpdatedThe generated TypeScript types have been automatically updated based on JSON schema changes in this PR. |
…actor Page knowledge-pill extraction never persisted its ExtractionStats: KnowledgePageUpdater did not recordChange the field, so entityChanged stayed false and EntityRepository.storeUpdate dropped the write. The sourceHash hash-gate therefore never engaged and every throttled run re-invoked the LLM. Record extractionStats (with updateVersion=false, matching lifeCycle) so the stamp persists without churning the article version history, and preserve the stored value when an update omits it so a PUT body edit cannot wipe it (CreatePage has no extractionStats). ContextMemoryExtractor is now a pure derivation: drop the dead persist() method and its ContextMemoryRepository dependency (the reconciler owns all writes); its constructor takes only the LLM client. Give ContextMemoryReconciler.reconcileExisting a single exit. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- KnowledgePageRepository.postDelete now calls super.postDelete so hard deletes still purge RDF and every delete invalidates the list-count cache (regression: the override dropped both). - ContextProcessingEngine reconciles an emptied source against an empty derived set instead of skipping, so clearing an article body / file text archives its now-stale pills rather than leaving them ACTIVE forever; a never-extracted empty source stays a no-op. - extractionStats.pillsCreated stores reconciled.created() (new pills this run) instead of the active total, which had inflated it to the whole knowledge base on every re-extraction. - PageContextProcessingEngine.runScheduled removes the map entry only when it is still the future that fired, so a concurrently rescheduled run stays tracked and cancellable; clarified the best-effort eviction bound. - ContextMemory Manual-flip on PATCH now requires a change to a reconciler-managed field (title/question/answer/summary/memoryType), so tagging or starring an automated pill no longer freezes re-extraction. Also removed the now-unused ReconcileResult.activeCount(). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
🟡 Playwright Results — all passed (13 flaky)✅ 4298 passed · ❌ 0 failed · 🟡 13 flaky · ⏭️ 88 skipped
🟡 13 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 |
A knowledge pill the source no longer yields is now hard-deleted by the reconciler rather than flipped to ARCHIVED. Archived pills were invisible in the UI yet still lived in the search/vector index (nothing filters status) and kept their MENTIONED_IN edge, so they polluted retrieval, inflated memoryCount, and accumulated monotonically (reloaded one-by-one every run). These pills are regenerable from the source, so deletion is the correct lifecycle and removes them from the index and counts in one step. Survivors still keep their id/telemetry; human-edited (Manual) pills are still skipped. ReconcileResult.archived renamed to deleted. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
listExtractedMemories now batch-loads pills in one query (find(ids, NON_DELETED)) instead of a get() per ref, removing the N+1 the reconciler hit each run. The set is now just the live pill count since retired pills are hard-deleted (no archived accumulation). updateSourceEntityRelationship switched from the singular updateFromRelationship (one fromType for both delete and add) to the plural updateFromRelationships with single-element lists, which removes and adds each edge under its own entity type. The singular form orphaned the stale edge when a memory's sourceEntity changed type (ContextFile <-> Page). Mirrors the primaryEntity reconciliation. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
ExtractedMemoriesCard (lifted out of DocumentPreviewPanel) now fetches via getListContextMemories({sourceEntityId, fields:'owners,sourceEntity'}); the panel test still asserted the old sourceFileId/sourceFile shape, failing the ui-coverage-tests job. Update the assertion to the current call.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
|
Code Review ✅ Approved 6 resolved / 6 findingsImplements a generic ContextProcessingEngine to extract knowledge pills from Knowledge Center articles, addressing all previous lifecycle, reconciliation, and deletion findings. The new pipeline successfully coalesces autosaves and preserves manually edited pills. ✅ 6 resolved✅ Bug: Page postDelete drops base RDF/cache cleanup (no super call)
✅ Bug: Throttle runScheduled unconditionally removes possibly-rescheduled future
✅ Edge Case: Emptying a page/file body never retires its existing pills
✅ Quality: memoryCount counts archived pills, inflating over time
✅ Quality: Throttle uses a bare ConcurrentHashMap with arbitrary eviction
...and 1 more resolved from earlier reviews OptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
…s/Memory Agent (#30041) * revert(ai): remove AISettings + Memory/Ontology Agent (#29201) Removes the AISettings config plane and the Memory/Ontology Agent that derived glossary terms and metrics from ContextMemory. Keeps the ContextMemory entity (schemas frozen), CreateContextMemoryTool, and the Persona AI Context feature that reads ContextMemory. Restores the base McpApplication files #29201 had refactored away. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * revert(context): remove page knowledge-pill extraction (#29119) Reverts the Context Center *page* extraction pipeline (generic ContextProcessingEngine + File/Page engines, ContextMemoryReconciler, sourceEntity generalization, ExtractedMemoriesCard UI). Keeps the frozen ContextMemory/ContextFile/Page schemas, file-side sourceFile handling (removed later with #28973), and all follow-on work (pinning, pagination, attachment widget, ui-core-components migration). This reverts commit 506c8c9. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * chore(ai): keep metric.json/createMetric.json schema frozen Extends the D1 schema-freeze decision to the Metric schema: the AI revert (#29201) removed the Memory/Ontology Agent *code* that populated Metric's 'derivedFrom'/'provider', but the JSON schema fields are left intact (inert) so re-introducing the feature later needs no schema change. Verified the service compiles with the fields present and unused. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * revert(context-center): remove file knowledge-pill extraction (#28973) Removes the file extraction pipeline (ContextFileProcessingService, ContextMemoryExtractor, the LLM completion-client layer, KnowledgePill, DocumentStatusBadge UI) and restores the pre-#28973 ContextFileExtractionService stub. Keeps the 3 MCP context tools (Get/Search/CreateContextMemory), the object-storage upload + /system/validate stack (D3), and the frozen ContextMemory/ContextFile schemas (D1). This reverts commit 03530b2. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * revert(mcp): remove MCP Chat client, conversation tracking, chat UI (#26343, #29169) Removes the MCP Chat feature: chat client service (mcpclient/*), the chat LLM-client layer (clients/llm/* except LlmConfigHolder), McpConversation/ McpMessage entities+repos+resource+schemas, McpChatApplication, the chat UI (McpChatPage, /mcp-chat routes) and its playwright spec (#29169), and the mcp_conversation/mcp_message tables. KEPT (now load-bearing for semantic-search embeddings, not chat): llmConfiguration.json + LlmConfigHolder + OpenMetadataApplicationConfig. llmConfiguration — the vector-embedding stack (SystemRepository, the *EmbeddingClient family, OpenSearchBulkSink, #29678 AI Context Platform) depends on it, so a wholesale revert would break semantic search. Follow-up UI reconciliation (package.json deps, locale keys, ApplicationsProvider, generated TS) lands in the codegen/i18n commit. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * revert(ui): reconcile MCP-chat/AI UI removal + checkstyle Finalizes the UI side of the reverts: removes the residual MCP-chat route, plugin, and provider state; reverse-applies #26343's UI wiring (sidebar, constants, ApplicationsClassBase); restores getContextMemoryById (still used by the surviving memories page); fixes the DocumentPreviewPanel status-row JSX left by the badge removal; and runs the organize-imports + eslint + prettier sequence. Locale files and orphaned i18n keys are intentionally left in place (harmless, re-introduction-friendly, in-sync). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Update generated TypeScript types * fix(revert): keep full objectStorage config for file upload The extraction revert (#28973) over-reverted objectStorage down to a NOOP stub, but file upload (ContextFile) survives and needs the full s3/azure/env-overridable config (D3). Restore it to main's version. Net conf diff is now only the llmConfiguration comment, updated to reference its surviving consumer (semantic-search embeddings) instead of the removed extraction/MCP-chat. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * minor fix * lint fix * fixed playwright test --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Rohit0301 <[email protected]>



Fixes #29132
Summary
Extends the file knowledge-pill pipeline (
docs/company-context-knowledge-pills.md) to Context Center pages (Knowledge Center articles). When a page body settles, an LLM extracts knowledge pills (ContextMemoryrows) linked back to the page, embedded and searchable like file-extracted pills — no new entity.The work is structured as a generic, shared
ContextProcessingEnginewithFileandPageimplementations. The page-specific hard part is lifecycle: pages autosave every few seconds, so naive reuse would storm the LLM and churn pills.How page extraction is gated
PageContextProcessingEngine— each body-changed save reschedules a run for the quiet period (default 5 min) after the last edit, so an entire editing session yields one extraction. No sweep job, no separate process. Configurable viapage.context.quiet.period.millis/page.context.max.pending.pages.ExtractionStats.sourceHashlets a run skip the LLM entirely when the body is unchanged (pages hash the markdown; files use the content checksum).ContextMemoryReconciler) — instead of wholesale delete-and-recreate, derived pills are matched against the page's existing pills by normalized question: keep (preserve identity +usageCount/lastUsedAt, skip re-embed) / update / retire (archive) / add.The hash-gate and reconciliation live in the shared engine, so the file pipeline inherits both fixes (it no longer hard-deletes and recreates pills on re-upload, and skips re-extraction of identical content).
Linkage, manual edits, lifecycle
sourceEntityreference resolved from the existingMENTIONED_INedge.sourceFileis retained as a deprecated derived alias, so shipped MCP/ES/contributor consumers keep working and no data migration is needed.sourceTypegainsPageExtraction.sourceTypetoManual— keyed on the operation (PATCH), notupdatedBy, since the extraction engine also writes asadmin. Reconciliation never updates or retires a human-edited pill.KnowledgePageRepositoryschedules extraction on article create / body-change, cascades pill deletion on page delete (mirrorsContextFileRepository.postDelete), and exposesmemoryCount.Schema changes
contextMemory.json/createContextMemory.json:sourceType += PageExtraction, new genericsourceEntity.ExtractionStats(shared type): newsourceHash.page.json:extractionStats+memoryCount.Testing
ContextMemoryExtractorTest,ContextMemoryReconcilerTest,PageContextProcessingEngineTest(hash-gate skip, throttle coalesce/evict),ContextFileProcessingServiceTest(status orchestration around the injected engine).mvn spotless:checkclean.CompanyContextPipelineITalready exercises the shared engine end-to-end via the file source.Follow-ups (intentionally out of scope)
ContextMemoryBodyTextContributorstill readssourceFile, so page pills embed on their Q/A only (avoids re-embedding all file pills); switchable tosourceEntityif page source context in embeddings is wanted.typescript-type-generationworkflow.🤖 Generated with Claude Code
Greptile Summary
This PR extends the knowledge-pill pipeline to Knowledge Center pages (articles) by introducing a generic
ContextProcessingEnginehierarchy withFileandPageimplementations, aContextMemoryReconcilerthat preserves pill identity across re-extractions, and a trailing-throttle debouncer that coalesces page autosaves into a single LLM call.contextMemorygains a genericsourceEntityreference (sourceFilekept as a deprecated alias) and a newPageExtractionsource type;pagegainsextractionStatsandmemoryCount;ExtractionStatsgainssourceHashfor the hash gate.KnowledgePageRepositoryschedules extraction on article create/body-change and cascades pill soft/hard-delete and restore via the new*AdditionalChildrenhooks (mirrorsContextFileRepository);ContextMemoryRepositoryaddssourceEntityrelationship handling and aflipToManualOnUserEditguard.ExtractedMemoriesCardcomponent surfaces extracted pills in the Knowledge Page right panel, wired to the newsourceEntityIdlist filter.Confidence Score: 4/5
Safe to merge; the two open items from earlier rounds are already tracked and neither breaks correctness on the happy path.
The core extraction, reconciliation, hash-gate, and lifecycle cascade logic are all sound and well-tested. Items flagged in earlier review rounds remain open (broad exception catch in FileContextProcessingEngine, previously noted edge-deletion concern) but neither causes incorrect behavior in normal operation. New findings this round are narrow: independent getPage reads in loadSource/loadStats produce a spurious skip on a rare concurrent-autosave race (self-healing via the next schedule), and the ListFilter subquery lacks a toType guard (semantically impure but practically safe).
FileContextProcessingEngine.java and PageContextProcessingEngine.java.
Important Files Changed
Comments Outside Diff (1)
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ContextMemoryRepository.java, line 1162-1178 (link)fromTypeis taken from the updated source, not the original oneupdateFromRelationshipusesfromTypeto locate and delete the old MENTIONED_IN relationship in the DB. The stored relationship was written withoriginalSource.getType()as the from-type. When a PATCH changessourceEntityfrom apage-typed reference to acontextFile-typed reference (or vice versa), this code derivesfromTypefromupdatedSource.getType(), so the lookup for the old edge uses the new type. The old relationship is never deleted and the pill ends up with two MENTIONED_IN edges — andgetSourceEntity(which returnsrefs.getFirst()) could return the stale source on subsequent reads.The fix is to use
originalSource.getType()as the from-type for the delete leg.Reviews (10): Last reviewed commit: "test(context): fix DocumentPreviewPanel ..." | Re-trigger Greptile