Commit 7485c5b
feat: add ContextMemory entity (Context Center memories) (open-metadata#28224)
* feat(spec): add ContextMemory + CreateContextMemory JSON schemas
* feat(jdbi3): add ContextMemoryDAO
* feat: register contextMemory entity type constant
* feat(service): add ContextMemory repository, resource, mapper
* feat(bootstrap): add context_memory table DDL
* test(service): ContextMemory resource CRUD test
* fix(context-memory): address review (relationship types, stable FQN, status msg, test name)
- storeRelationships: rootMemory -> Relationship.CONTAINS, parentMemory -> Relationship.HAS
so the root-ancestor and direct-parent hierarchies are distinguishable.
- setFullyQualifiedName: derive from the immutable name only (drop mutable
primaryEntity/owner derivation that destabilized nameHash on update).
- validateStatusTransition: separate "no transitions defined" from "disallowed transition".
- Rename ContextMemoryResourceTest -> ContextMemoryStatusTransitionTest (pure unit test).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* test(context-memory): add ContextMemoryIT + SDK ContextMemoryService
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(spec): register contextMemory in EntityLink.g4 ENTITY_TYPE grammar
EntityLinkGrammarTest.testAllEntityTypesHaveGrammarOrExclusion enumerates every
Entity.java constant and requires each to be in the EntityLink grammar or the
test's exclusion list. ContextMemory is a normal EntityRepository-backed
top-level entity (like learningResource / contextFile), so it belongs in the
ENTITY_TYPE rule.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* test(context-memory): override owner ITs for creator-as-owner default
ContextMemoryMapper.defaultOwners() intentionally assigns the creating
user as owner when the create request omits owners. BaseEntityIT's
patch_entityUpdateOwner_200 and patch_entityUpdateOwnerFromNull_200
assert "no owner initially" for any supportsOwners entity, so both
failed for ContextMemory.
Override both in ContextMemoryIT: keep the PATCH-replace-owner contract,
change only the precondition to expect the creator as the sole initial
owner (asserted by count, not a hardcoded principal). Mapper unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Update generated TypeScript types
Add the generated ContextMemory TS types (entity/context/contextMemory.ts,
api/context/createContextMemory.ts). The schemas were on the branch but their
generated types were missing, failing the TypeScript Type Generation check on
this fork PR.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(context-memory): address review (relationship cleanup, owner scope, validations)
Copilot review on the ContextMemory entity:
- #1 record primaryEntity/relatedEntities/root/parent/source*/machineRepresentation
in version history; usageCount/lastUsedAt documented as untracked telemetry
- #2 clear stale HAS/RELATED_TO/CONTAINS edges before re-adding in storeRelationships
- #4 default creator as owner only on create; PUT without owners no longer
silently replaces previously set owners
- #5 schema documents that any status is allowed at creation; transitions
enforced only on update
- #6 setFullyQualifiedName via FullyQualifiedName.build with skip-if-set guard
- #7 validate shared principal type is user/team/domain
- #8 reject self-reference for parentMemory/rootMemory
- #10 inline Entity.CONTEXT_MEMORY, drop redundant constant
Regenerate ContextMemory TS types for the schema doc change; add IT coverage
for the self-reference and invalid-shared-principal validations.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(context-memory): don't blanket-delete relationships (domain data loss)
The #2 cleanup via deleteTo(memory, CONTEXT_MEMORY, HAS, null) also matched the
framework's domain --HAS--> memory edge (storeDomains runs before
storeRelationships in storeRelationshipsInternal, on every create and update),
silently dropping domain assignments.
storeRelationships is now add-only (addRelationship upserts, so re-running on
update is idempotent). Stale-edge cleanup moved to ContextMemoryUpdater using
the framework's updateFromRelationship(s) helpers, which delete only the
specific changed refs and record the version change. parentMemory now uses
Relationship.PARENT_OF (distinct from primaryEntity's HAS and the framework's
domain HAS) so the parent edge can be maintained without collision.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore(bootstrap): move context_memory DDL from 2.0.1 to 2.0.0
The context_memory table belongs in the 2.0.0 migration. Relocated the
MySQL and Postgres DDL verbatim; the 2.0.1 schemaChanges.sql files are
restored to their original task_migration_mapping-only content.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore(bootstrap): add ENGINE=InnoDB to context_memory MySQL DDL
Explicit engine clause, consistent with the task/search-index tables in the
same migration and robust to any server default change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(context-memory): preserve sanitized/validated fields; validate relatedEntities
Review follow-ups:
- ContextMemoryMapper no longer re-sets description/owners/domains/tags/displayName
after copy(). copy() sanitizes description (stored-XSS) and validates owners and
domains; re-setting the raw request values bypassed both. Only ContextMemory-
specific fields are set now.
- prepare() now assigns the result of EntityUtil.populateEntityReferences back onto
relatedEntities so orphaned/invalid refs are filtered instead of persisted.
- ContextMemoryIT Javadoc now references ContextMemoryRepository#setCreatorAsDefaultOwner
(the defaultOwners mapper method no longer exists).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent d6cec7e commit 7485c5b
15 files changed
Lines changed: 2939 additions & 0 deletions
File tree
- bootstrap/sql/migrations/native/2.0.0
- mysql
- postgres
- openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests
- openmetadata-sdk/src/main/java/org/openmetadata/sdk/services/context
- openmetadata-service/src
- main/java/org/openmetadata/service
- jdbi3
- resources/context
- test/java/org/openmetadata/service/resources/context
- openmetadata-spec/src/main
- antlr4/org/openmetadata/schema
- resources/json/schema
- api/context
- entity/context
- openmetadata-ui/src/main/resources/ui/src/generated
- api/context
- entity/context
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
0 commit comments