-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Overview
Implement the foundational version tracking infrastructure for component schema migrations.
Parent Issue
- Component Schema Evolution (Phase 16.2) #352 (Component Schema Evolution)
- ADR: docs/adr/015-component-schema-migrations.md
Requirements
Attribute Support
- Add
Versionproperty to[Component]attribute (default: 1) - Validate version is positive integer at compile time
Source Generator
- Generate
ComponentMigrationMetadataclass -
GetVersion<T>()method for compile-time known types -
GetVersion(Type)method for runtime lookup - Generate version lookup table (AOT-compatible)
Serialization Format Changes
- Binary format: Add version field (int16) after component type ID
- JSON format: Add
$versionproperty to component objects - Backward compatibility: Treat missing version as v1
Version Mismatch Detection
- Detect version mismatch during deserialization
- Throw
ComponentVersionExceptionwith clear message - Include component name, serialized version, current version
Example
[Component(Version = 2)]
public partial struct Health
{
public int Current;
public int Max;
public int Shield;
}
// Generated:
public static partial class ComponentMigrationMetadata
{
public static int GetVersion<T>() where T : struct, IComponent
{
if (typeof(T) == typeof(Health)) return 2;
// ... other components
return 1; // default
}
}Acceptance Criteria
- Components can declare version via attribute
- Version metadata accessible at runtime (AOT-compatible)
- Serialized data includes version information
- Version mismatch throws descriptive exception
- Unit tests for version metadata generation
- Unit tests for serialization format changes
Technical Notes
- No reflection allowed (Native AOT compatibility)
- Version stored as int16 in binary format (max 32,767 versions)
- Source generator in
KeenEyes.Generators
Metadata
Metadata
Assignees
Labels
No labels