Archetypes And Schema Extension
Post-4.x: Later (5.0TODO: 5.0?) it may be possible for an archetype to define its own schema extension.
Similar functionality should be possible even in 4.x. But the deployer need to define all possible extension items in the schema extension in midPoint home. Then per-archetype object templates can be used to limit the number of extension items applicable for each archetype. But this "add all, remove excess" approach is quite troublesome to maintain - especially for large schema extensions.
In midPoint 5.0 this should be reversed: midPoint should start with empty schema extension, then archetypes will add only those extension elements that are needed. Archetype definition will contain schema definition snippet. This means that all archetype definitions will need to be pre-processed and the schema definition snippets injected into Prism schema registry. But this should work well. We are doing similar thing for relation definitions already.
However, even in 5.0 we may still need to define all those "flexible" extension elements on schema top-level (global) - similarly to LDAP schema. This may be needed to properly process search queries. Or alternatively we may need to extend search queries to be archetype-aware. This needs to be further analyzed.
TODO: "Default archetype" in system config? E.g. to specify default assignmentRelation for all non-archetyped objects.