Skip to content

Temporal Versioning

Overview

Temporal Versioning treats every state change as immutable, creating a timeline of system states rather than mutations. It enables time travel, auditing, and historical analysis by maintaining a complete version history.

Key Concepts

  • Version ID: Unique identifier for each version
  • Delta Changes: Only store what changed between versions
  • State Timeline: Linear or branching history of states
  • Commit: The act of creating a new version
  • Rollback: Reverting to a previous version

Benefits

  • Time Travel: Inspect and revert to any previous system state
  • Auditing: Every change is documented with its cause
  • Analysis: Track how state evolves over time
  • Concurrency: Simplifies concurrent operations with immutable states
  • Debugging: Examine system state at any historical point

Implementation Considerations

  • Storage Efficiency: Consider delta storage vs. full state copies
  • Branching Strategy: Support for linear history vs. branched history
  • Performance Impact: Balance history tracking with runtime performance
  • Garbage Collection: Policy for pruning old versions
  • Referential Integrity: Handling references between versioned objects

Core Interfaces

Versioned[S]
├── get_current_version_id() -> VersionId
├── get_version(version_id) -> S
├── commit(state, description) -> VersionId
└── get_history() -> List[VersionInfo]

Pattern Variations

Linear History

Simple version chain where each version has one parent and one child. Best for straightforward history tracking.

Branched History

Tree-like structure where versions can have multiple children. Useful for exploring alternative paths or concurrent editing.

Git-like Model

Sophisticated versioning with merge capability, allowing concurrent branches to be combined.

Integration with Other Patterns

  • Reactive Event Mesh: Events can trigger version creation
  • Perspective Shifting: Different views of version history
  • State Projection: Projections built from version history
  • Effect System: Version changes can be modeled as effects

Usage Examples

See the implementation file: nerv/temporal_store.md

Python Implementation

See the implementation code: nerv/python/temporal_store.py

  • Memento Pattern
  • Command Pattern with History
  • Event Sourcing
  • Copy-on-Write

Released under the MIT License.