Skip to content

Conversation

@prosdev
Copy link
Contributor

@prosdev prosdev commented Jan 10, 2026

Overview

Implements composable validators and Segment-compatible schema adapter for type-safe event processing.

Features

Validators (Task 5)

  • ✅ Protocol - structural typing for composable validators
  • ✅ - ensure required fields are present
  • ✅ - validate field types (supports union types)
  • ✅ - parse ISO 8601 and Unix timestamps
  • ✅ - composable fail-fast validation chain

Segment Schema Adapter (Task 6)

  • ✅ - Segment-compatible event transformation
  • ✅ Type routing (identify/track/page)
  • ✅ ValidationPipeline integration
  • ✅ Railway-oriented error handling (AdapterResult.success/failure)
  • ✅ 16 comprehensive tests covering all event types

Architecture

Two-Tier Design (Future-Proof):

  1. Format Adapters (future) - Parse raw formats → RawEvent
  2. Schema Adapters (now) - Apply schema rules → TypedEvent

This enables seamless integration with future eventkit-schema package for dynamic per-account schemas.

Testing

  • 66 tests passing (41 new tests)
  • 87% overall coverage
  • 88% coverage on SegmentSchemaAdapter
  • TDD approach throughout

Commits

  1. feat(validators): add Validator protocol
  2. feat(validators): add RequiredFieldsValidator
  3. feat(validators): add TypeCheckValidator
  4. feat(validators): add TimestampValidator with ISO8601 and Unix support
  5. feat(validators): add ValidationPipeline for composable validation
  6. feat(adapter): add SegmentSchemaAdapter with ValidationPipeline
  7. test(adapter): add comprehensive SegmentSchemaAdapter tests
  8. feat(adapter): export SegmentSchemaAdapter from package
  9. docs: update README with validator and adapter details

Closes #3

- Add 16 tests covering validation, identify, track, and page events
- Add stream field to TypedEvent for event routing
- Fix field names to use snake_case (user_id, anonymous_id)
- 88% coverage on SegmentSchemaAdapter
- Add Validation & Adaptation section with code examples
- Document ValidationPipeline and composable validators
- Document SegmentSchemaAdapter usage
- Update roadmap to show completed features
- Mark Tasks 5 & 6 complete in tasks.md
- Rename test_base.py → test_validator_protocol.py (fix pytest collision)
- 66 tests passing, 87% overall coverage
- Fix duplicate stream field in TypedEvent
- Add dict[str, Any] type annotations to all validators
- Add types-python-dateutil stub package
- Fix Pydantic alias usage ($set/$set_once via **kwargs)
- Fix timestamp None handling with explicit fallback
- Add return type annotation to __init__
- Add assertion for validator error message invariant
- All tests pass (86), mypy clean, 95% coverage
@prosdev prosdev force-pushed the feat/validation-and-adaptation branch from 6150bc6 to 9d39e13 Compare January 10, 2026 20:37
@prosdev prosdev merged commit 054f2e4 into main Jan 10, 2026
1 check passed
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.

Validation & Adaptation

2 participants