Event log library with Lamport clocks and systematic error tracking
Project description
spec-kitty-events
Event log library with Lamport clocks, CRDT merge, and canonical event contracts for distributed systems.
Version: 2.3.0 | SCHEMA_VERSION: 2.0.0 | Python: >= 3.10
Features
- Lamport Clocks: Establish causal ordering in distributed systems
- Event Immutability: Events are immutable (frozen Pydantic models)
- Conflict Detection: Detect concurrent events with
is_concurrent() - CRDT Merge Rules: Merge grow-only sets and counters with CRDT semantics
- State-Machine Merge: Resolve state conflicts with priority-based selection
- Status State Model: 7-lane canonical lifecycle (
Lane) with transition validation and reducer - Lane Mapping Contract:
SyncLaneV1maps 7 canonical lanes to 4 consumer-facing sync lanes - Gate Observability: Typed payloads for GitHub
check_rungate events - Lifecycle Events: Mission lifecycle contracts with typed payloads and reducer
- Collaboration Events: N-participant mission collaboration with advisory coordination (soft locks, not hard locks), 14 event types, dual-mode reducer
- Mission-Next Runtime Events: Run-scoped execution contracts (7 event types, 6 payloads,
deterministic reducer) with
RuntimeActorIdentityand decision lifecycle tracking - Conformance Suite: Dual-layer validation (Pydantic + JSON Schema), manifest-driven fixtures, pytest-runnable conformance tests
- JSON Schemas: 44 committed schema artifacts generated from Pydantic models
- Error Logging: Systematic error tracking with retention policies
- Storage Adapters: Abstract storage interfaces (bring your own database)
- Type Safety: Full
mypy --strictcompliance withpy.typedmarker
Installation
From PyPI
pip install "spec-kitty-events>=2.1.0,<3.0.0"
With conformance testing support (adds jsonschema):
pip install "spec-kitty-events[conformance]>=2.0.0rc1,<3.0.0"
From Git
pip install "git+https://github.com/Priivacy-ai/spec-kitty-events.git@v2.1.0"
Development Installation
git clone https://github.com/Priivacy-ai/spec-kitty-events.git
cd spec-kitty-events
pip install -e ".[dev,conformance]"
Quick Start
Lane Mapping (New in 2.0.0)
from spec_kitty_events import Lane, SyncLaneV1, canonical_to_sync_v1
# Convert canonical 7-lane model to consumer-facing 4-lane model
sync_lane = canonical_to_sync_v1(Lane.IN_PROGRESS)
assert sync_lane == SyncLaneV1.DOING
sync_lane = canonical_to_sync_v1(Lane.BLOCKED)
assert sync_lane == SyncLaneV1.DOING # blocked collapses to doing
Event Emission
import uuid
from datetime import datetime
from spec_kitty_events import (
Event,
LamportClock,
InMemoryClockStorage,
InMemoryEventStore,
)
clock_storage = InMemoryClockStorage()
event_store = InMemoryEventStore()
clock = LamportClock(node_id="alice", storage=clock_storage)
clock.tick()
event = Event(
event_id="01ARZ3NDEKTSV4RRFFQ69G5FAV",
event_type="WPStatusChanged",
aggregate_id="WP001",
timestamp=datetime.now(),
node_id="alice",
lamport_clock=clock.current(),
project_uuid=uuid.uuid4(),
correlation_id="01ARZ3NDEKTSV4RRFFQ69G5FAV",
payload={"state": "doing"},
)
event_store.save_event(event)
Conformance Validation
from spec_kitty_events.conformance import validate_event
payload = {
"feature_slug": "005-my-feature",
"wp_id": "WP01",
"to_lane": "in_progress",
"actor": "ci-bot",
"execution_mode": "worktree",
}
result = validate_event(payload, "WPStatusChanged")
assert result.valid
Collaboration Events (New in 2.1.0)
N-participant mission collaboration with advisory coordination. Soft locks, not hard locks -- warnings are informational and participants decide how to respond.
14 event types grouped by category:
| Category | Event Types |
|---|---|
| Participant Lifecycle | ParticipantInvited, ParticipantJoined, ParticipantLeft, PresenceHeartbeat |
| Drive Intent & Focus | DriveIntentSet, FocusChanged |
| Step Execution | PromptStepExecutionStarted, PromptStepExecutionCompleted |
| Advisory Warnings | ConcurrentDriverWarning, PotentialStepCollisionDetected, WarningAcknowledged |
| Communication | CommentPosted, DecisionCaptured |
| Session | SessionLinked |
Key exports: ParticipantIdentity, FocusTarget, reduce_collaboration_events,
ReducedCollaborationState, UnknownParticipantError, CollaborationAnomaly
from spec_kitty_events import (
Event,
ParticipantIdentity,
ParticipantJoinedPayload,
PARTICIPANT_JOINED,
reduce_collaboration_events,
FocusTarget,
)
# Construct a participant identity
identity = ParticipantIdentity(
participant_id="p-abc123",
participant_type="human",
display_name="Alice",
)
# Construct a typed payload
payload = ParticipantJoinedPayload(
participant_id="p-abc123",
participant_identity=identity,
mission_id="mission/M042",
)
# Reduce collaboration events into materialized state
state = reduce_collaboration_events([])
assert state.event_count == 0
See COMPATIBILITY.md for the full collaboration event contracts, reducer pipeline details, and SaaS-authoritative participation model.
Mission-Next Runtime Events (New in 2.3.0)
Run-scoped execution contracts for the spec-kitty-runtime engine. 7 event types with typed payloads and a deterministic reducer for state materialization.
from spec_kitty_events import (
RuntimeActorIdentity,
MissionRunStartedPayload,
reduce_mission_next_events,
MissionRunStatus,
)
# Construct an actor identity
actor = RuntimeActorIdentity(
actor_id="agent-claude",
actor_type="llm",
provider="anthropic",
model="claude-opus-4-6",
)
# Build a run-started payload
payload = MissionRunStartedPayload(
run_id="run-001",
mission_key="feature-login",
actor=actor,
)
# Reduce events into materialized run state
state = reduce_mission_next_events([])
assert state.run_status is None # no events yet
See COMPATIBILITY.md for event type reference, the MissionCompleted vs
MissionRunCompleted distinction table, and migration notes.
Conflict Detection and Resolution
from spec_kitty_events import is_concurrent, state_machine_merge
# Detect concurrent events
if is_concurrent(event1, event2):
priority_map = {"done": 4, "for_review": 3, "doing": 2, "planned": 1}
resolution = state_machine_merge([event1, event2], priority_map)
winner = resolution.merged_event
Documentation
- CHANGELOG.md: Version history and migration notes
- COMPATIBILITY.md: Lane mapping table, field reference, versioning policy, CI integration guide
- Type hints: Full mypy --strict compliance (source is the documentation)
- Conformance suite:
pytest --pyargs spec_kitty_events.conformance -v
Public API (126 Exports)
The spec_kitty_events package exports 126 symbols covering:
| Category | Count | Key Exports |
|---|---|---|
| Core models | 4 | Event, ErrorEntry, ConflictResolution |
| Exceptions | 4 | SpecKittyEventsError, StorageError, ValidationError, CyclicDependencyError |
| Storage | 6 | EventStore, ClockStorage, ErrorStorage, InMemory* |
| Clocks | 1 | LamportClock |
| Conflict detection | 3 | is_concurrent, total_order_key, topological_sort |
| Merge functions | 3 | merge_gset, merge_counter, state_machine_merge |
| Error logging | 1 | ErrorLog |
| Gate observability | 5 | GatePayloadBase, GatePassedPayload, GateFailedPayload, map_check_run_conclusion, UnknownConclusionError |
| Lifecycle events | 15 | SCHEMA_VERSION, MissionStatus, payload models, reducer, constants |
| Status model | 25 | Lane, SyncLaneV1, canonical_to_sync_v1, StatusTransitionPayload, reducer, validators |
| Collaboration events | 36 | ParticipantIdentity, FocusTarget, payload models, reducer, constants, warnings |
| Version | 1 | __version__ |
Testing
Run the full test suite (790 tests, 98% coverage):
pytest --cov --cov-report=html
Run conformance tests only:
pytest --pyargs spec_kitty_events.conformance -v
Type checking:
mypy src/spec_kitty_events --strict
Schema drift check:
python -m spec_kitty_events.schemas.generate --check
Requirements
- Python >= 3.10
- Pydantic >= 2.0.0, < 3.0.0
- python-ulid >= 1.1.0
- jsonschema >= 4.21.0, < 5.0.0 (optional, for
[conformance]extra)
Release and Publishing
This repository uses GitHub Actions trusted publishing:
publish-testpypi.yml: Manual TestPyPI dry run.publish-pypi.yml: Publish onv*tags (or manual dispatch) to PyPI.
Release flow:
- Update
project.versioninpyproject.toml. - Commit to
main. - Create and push matching tag (e.g.,
v2.1.0forversion = "2.1.0"). - Approve the
pypiGitHub environment (if required). - Verify package on PyPI and install in a clean environment.
License
All rights reserved. This is a private repository owned by Priivacy AI.
Generated with Spec Kitty
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spec_kitty_events-2.3.0.tar.gz.
File metadata
- Download URL: spec_kitty_events-2.3.0.tar.gz
- Upload date:
- Size: 82.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc505379b839d89e9837794dd61c873cdff73079196ff298b74454014cbd3b12
|
|
| MD5 |
03638aecb197d07815600ab6dff8b2ba
|
|
| BLAKE2b-256 |
67c1fe34f6b5c503418befd5f919a60f05c1a46db067e1a9d070898c6c829a71
|
Provenance
The following attestation bundles were made for spec_kitty_events-2.3.0.tar.gz:
Publisher:
publish-pypi.yml on Priivacy-ai/spec-kitty-events
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spec_kitty_events-2.3.0.tar.gz -
Subject digest:
fc505379b839d89e9837794dd61c873cdff73079196ff298b74454014cbd3b12 - Sigstore transparency entry: 957661036
- Sigstore integration time:
-
Permalink:
Priivacy-ai/spec-kitty-events@dff7d07c9a5bd0f73a0e2ff0bcc4a2ddcee22d75 -
Branch / Tag:
refs/tags/v2.3.0 - Owner: https://github.com/Priivacy-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@dff7d07c9a5bd0f73a0e2ff0bcc4a2ddcee22d75 -
Trigger Event:
push
-
Statement type:
File details
Details for the file spec_kitty_events-2.3.0-py3-none-any.whl.
File metadata
- Download URL: spec_kitty_events-2.3.0-py3-none-any.whl
- Upload date:
- Size: 115.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
616341dd727e7137864615c50f03fcd7ca67c703c7e0c581d983eeb8d9106100
|
|
| MD5 |
5186164596f3d240e9cdb3a08988fbb9
|
|
| BLAKE2b-256 |
290c518b0d63c6ca98ff9204b20d86b5ccf3dd630ef7a7f21b04ce68d95880fa
|
Provenance
The following attestation bundles were made for spec_kitty_events-2.3.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on Priivacy-ai/spec-kitty-events
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spec_kitty_events-2.3.0-py3-none-any.whl -
Subject digest:
616341dd727e7137864615c50f03fcd7ca67c703c7e0c581d983eeb8d9106100 - Sigstore transparency entry: 957661103
- Sigstore integration time:
-
Permalink:
Priivacy-ai/spec-kitty-events@dff7d07c9a5bd0f73a0e2ff0bcc4a2ddcee22d75 -
Branch / Tag:
refs/tags/v2.3.0 - Owner: https://github.com/Priivacy-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@dff7d07c9a5bd0f73a0e2ff0bcc4a2ddcee22d75 -
Trigger Event:
push
-
Statement type: