Skip to content

Add timestamps to GateEvaluation and ActionSkip value objects (Fixes #22) - #40

Merged
benrowe merged 3 commits into
masterfrom
feature/issue-22-add-timestamps
Dec 12, 2025
Merged

benrowe merged 3 commits into
masterfrom
feature/issue-22-add-timestamps

Conversation

@benrowe

@benrowe benrowe commented Dec 12, 2025

Copy link
Copy Markdown
Collaborator

Summary

Adds timestamp tracking to GateEvaluation and ActionSkip value objects to improve observability and enable time-based analysis of workflow execution.

  • ✅ Added float $timestamp property to GateEvaluation (readonly value object)
  • ✅ Added float $timestamp property to ActionSkip (readonly value object)
  • ✅ Auto-generates timestamp using microtime(true) (follows existing Event.php pattern)
  • ✅ Supports explicit timestamp for deserialization (backward compatible)
  • ✅ Updated TransitionContext serialization to persist timestamps
  • ✅ Full backward compatibility - old serialized data loads without timestamps

Implementation Details

Pattern Used (following existing Event.php):

readonly class GateEvaluation
{
    public readonly float $timestamp;

    public function __construct(
        public Gate $gate,
        public GateResult $result,
        public bool $isActionGate,
        float $timestamp = 0.0,
    ) {
        $this->timestamp = $timestamp === 0.0 ? microtime(true) : $timestamp;
    }
}

Key Design Decisions:

  • Uses float timestamps (not DateTime objects) to match existing project patterns
  • Default parameter allows existing code to work unchanged
  • Explicit timestamp parameter enables deserialization with preserved values
  • Backward compatibility: missing timestamps in old data default to 0.0 → auto-generates current time

Test Coverage

New Tests:

  • GateEvaluationTest.php - 7 tests covering timestamp behavior
  • ActionSkipTest.php - 7 tests covering timestamp behavior
  • TransitionContextSerializationTest.php - 5 new tests for timestamp serialization

Total Test Count: 347 tests (up from 328)
Code Coverage: 100% maintained

Test Plan

  • All 347 tests pass
  • 100% code coverage maintained
  • make check passes (lint + quality + tests)
  • PHPStan baseline updated for removed redundant type assertions
  • Backward compatibility verified (old serialized data loads)

Benefits

✅ Observability - Know when gates evaluated and actions skipped
✅ Debugging - Correlate workflow timing with logs
✅ Analysis - Measure gate evaluation duration
✅ Consistency - Matches existing Event timestamp pattern
✅ Backward Compatible - Existing code continues to work

Closes #22

🤖 Generated with Claude Code

benrowe and others added 3 commits December 12, 2025 21:27
- Update TransitionContext to restore timestamps for ActionSkip objects
- Remove redundant assertIsFloat() calls (PHPStan knows type from readonly property)
- Regenerate PHPStan baseline to account for new test assertions

All tests passing (347 tests, 1174 assertions)
100% code coverage maintained

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@benrowe
benrowe merged commit ebd4bd5 into master Dec 12, 2025
8 checks passed
@benrowe
benrowe deleted the feature/issue-22-add-timestamps branch December 12, 2025 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce value objects for history items (GateEvaluation, ActionSkip)

1 participant