Skip to content

Commit 468a6ce

Browse files
dmealingclaude
andcommitted
CRITICAL FIX: Service Provider Inheritance System
Fixed inheritance bugs preventing field types from accepting attribute children: 1. TypeDefinitionBuilder.from() - Now copies ALL requirements (including inherited ones) instead of only direct requirements, preserving wildcard inheritance when service providers extend types 2. TypeDefinition.acceptsChild() - Fixed inherited wildcard filtering to check all inherited requirements instead of incorrectly filtering by name="*" 3. Wildcard requirement handling - Proper unique key generation for multiple wildcard requirements (attr.*, validator.*, view.*) prevents overwrites in Map storage RESULTS: ✅ UnifiedRegistrySchemaIntegrationTest now passes (was failing on field inheritance) ✅ All 193 metadata tests pass ✅ All field types properly inherit wildcard attribute acceptance from field.base ✅ Service provider extensions preserve base type capabilities ✅ All modules compile successfully 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8579409 commit 468a6ce

3 files changed

Lines changed: 56 additions & 8 deletions

File tree

metadata/src/main/java/com/draagon/meta/registry/TypeDefinition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ public boolean acceptsChild(String childType, String childSubType, String childN
246246
return inheritedNamedReq.matches(childType, childSubType, childName);
247247
}
248248

249-
// Check inherited wildcard requirements
249+
// Check all inherited requirements (both named and wildcard)
250250
for (ChildRequirement inheritedReq : inheritedChildRequirements.values()) {
251-
if ("*".equals(inheritedReq.getName()) && inheritedReq.matches(childType, childSubType, childName)) {
251+
if (inheritedReq.matches(childType, childSubType, childName)) {
252252
return true;
253253
}
254254
}

metadata/src/main/java/com/draagon/meta/registry/TypeDefinitionBuilder.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,14 @@ public static TypeDefinitionBuilder from(TypeDefinition existing) {
7777
builder.parentType = existing.getParentType();
7878
builder.parentSubType = existing.getParentSubType();
7979

80-
// Copy direct child requirements (not inherited ones)
81-
for (ChildRequirement req : existing.getDirectChildRequirements()) {
82-
builder.childRequirements.put(req.getName(), req);
80+
// Copy ALL child requirements (including inherited ones)
81+
for (ChildRequirement req : existing.getChildRequirements()) {
82+
String keyToUse = req.getName();
83+
if ("*".equals(keyToUse)) {
84+
// For wildcard requirements, create unique keys to avoid overwrites
85+
keyToUse = "*:" + req.getExpectedType() + ":" + req.getExpectedSubType();
86+
}
87+
builder.childRequirements.put(keyToUse, req);
8388
}
8489

8590
return builder;

metadata/src/test/java/com/draagon/meta/registry/UnifiedRegistrySchemaIntegrationTest.java

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,55 @@ public void testMultipleMetadataStructures() throws IOException {
200200
@Test
201201
public void testRegistrySchemaComplianceMapping() {
202202
// Test that registry types map correctly to schema expectations
203-
203+
204+
// Debug registry state
205+
System.out.println("=== REGISTRY DEBUG ===");
206+
System.out.println("Total types: " + registry.getStats().totalTypes());
207+
System.out.println("Registered types: " + registry.getRegisteredTypeNames());
208+
209+
// Check if field.string is registered
210+
boolean stringFieldExists = registry.getRegisteredTypeNames().contains("field.string");
211+
System.out.println("field.string registered: " + stringFieldExists);
212+
213+
// Check if attr.string is registered
214+
boolean stringAttrExists = registry.getRegisteredTypeNames().contains("attr.string");
215+
System.out.println("attr.string registered: " + stringAttrExists);
216+
217+
// Check field.base acceptance of attr.string
218+
boolean baseAccepts = registry.acceptsChild("field", "base", "attr", "string", "testAttr");
219+
System.out.println("field.base accepts attr.string: " + baseAccepts);
220+
221+
// Get description of what field.base supports
222+
String baseDescription = registry.getSupportedChildrenDescription("field", "base");
223+
System.out.println("field.base supported children: " + baseDescription);
224+
225+
// Get description of what field.string supports
226+
String description = registry.getSupportedChildrenDescription("field", "string");
227+
System.out.println("field.string supported children: " + description);
228+
229+
// Check if field.string properly inherits from field.base
230+
try {
231+
java.lang.reflect.Method getTypeDefMethod = registry.getClass().getDeclaredMethod("getTypeDefinition", String.class, String.class);
232+
getTypeDefMethod.setAccessible(true);
233+
Object baseTypeDef = getTypeDefMethod.invoke(registry, "field", "base");
234+
Object stringTypeDef = getTypeDefMethod.invoke(registry, "field", "string");
235+
236+
if (baseTypeDef != null && stringTypeDef != null) {
237+
System.out.println("field.base definition exists: true");
238+
System.out.println("field.string definition exists: true");
239+
System.out.println("field.string parent: " + stringTypeDef.getClass().getMethod("getParentType").invoke(stringTypeDef) + "." +
240+
stringTypeDef.getClass().getMethod("getParentSubType").invoke(stringTypeDef));
241+
}
242+
} catch (Exception e) {
243+
System.out.println("Reflection debug failed: " + e.getMessage());
244+
}
245+
204246
// Field types that should be supported
205247
String[] expectedFieldTypes = {"string", "int", "long", "double", "float", "boolean", "date", "timestamp"};
206248
for (String fieldType : expectedFieldTypes) {
207-
assertTrue("Registry should support field type: " + fieldType,
208-
registry.acceptsChild("field", fieldType, "attr", "string", "testAttr"));
249+
boolean accepts = registry.acceptsChild("field", fieldType, "attr", "string", "testAttr");
250+
System.out.println("field." + fieldType + " accepts attr.string: " + accepts);
251+
assertTrue("Registry should support field type: " + fieldType, accepts);
209252
}
210253

211254
// Object types that should be supported

0 commit comments

Comments
 (0)