Goal
Keep an isolated CommandSchemaRegistry schema immutable after registration unless the registry API explicitly performs a validated change.
Background
Registration normalizes and copies the supplied field mapping and rejects duplicate registration so a process cannot silently change an established record type. However, CommandSchemaRegistry.schema() returns the stored mutable dictionary itself. Any consumer with read access can add/remove fields and bypass name/type/duplicate validation.
The module-level RECORD_SCHEMAS alias is intentionally mutable for compatibility; the newer isolated registry is the recommended boundary and should not inherit that escape hatch accidentally.
Reproduction and evidence
Framework reference: 263d893 on main.
registry = CommandSchemaRegistry()
registry.register("demo", {"name": STRING})
registry.schema("demo")["enabled"] = BOOLEAN
print(registry.schema("demo"))
# {'name': STRING, 'enabled': BOOLEAN}
No register() validation or duplicate check runs for the mutation.
Scope
- Return an immutable view or defensive copy from the isolated registry lookup.
- Keep codec encode/decode behavior deterministic after registration.
- Preserve the explicitly documented module-level compatibility surface as needed.
- Update public typing/docs and add mutation-regression tests.
Acceptance criteria
CommandSchemaRegistry.schema() cannot mutate stored registry state.
- Caller mutation of the original mapping after
register() remains isolated.
- The only supported schema mutation path enforces validation and duplicate rules.
- Default compatibility helpers continue to behave as documented.
Project fields
- Status: Backlog
- Priority: P2
- Area: Python
- Initiative: v1.0 Readiness
- Size: S
Ownership
Goal
Keep an isolated
CommandSchemaRegistryschema immutable after registration unless the registry API explicitly performs a validated change.Background
Registration normalizes and copies the supplied field mapping and rejects duplicate registration so a process cannot silently change an established record type. However,
CommandSchemaRegistry.schema()returns the stored mutable dictionary itself. Any consumer with read access can add/remove fields and bypass name/type/duplicate validation.The module-level
RECORD_SCHEMASalias is intentionally mutable for compatibility; the newer isolated registry is the recommended boundary and should not inherit that escape hatch accidentally.Reproduction and evidence
Framework reference:
263d893onmain.No
register()validation or duplicate check runs for the mutation.Scope
Acceptance criteria
CommandSchemaRegistry.schema()cannot mutate stored registry state.register()remains isolated.Project fields
Ownership