feat(protocol_dto): add canonical serialization for protocol DTOs#281
Conversation
…s and enhance collector logging
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (21)
📝 WalkthroughWalkthroughThis PR implements comprehensive protocol DTO serialization for tracker result, incremental state, and activity record types. A new ChangesProtocol DTO Serialization & Tracker App Consolidation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
Adds canonical serialization for tracker protocol DTOs (
TrackerResult,IncrementalState,ActivityRecord) so collectors and observability tooling share one JSON shape instead of ad-hoc dict assembly.core/protocol_dto.pywith shared frozen base dataclasses:TrackerResultDataclass,IncrementalStateDataclass,ActivityRecordDataclassasdict(),to_json()(deterministic, ISO-8601 datetimes),from_dict(), and log-friendly truncated__repr__GenericTrackerResult,GenericIncrementalState, and newGenericActivityRecordinherit the bases; all 11 trackerprotocol_impl.pymodules refactored to subclass them (repr=Falseon subclasses so truncation is preserved)format_occurred_at_z()promoted to public incore/activity_types.pyfor shared datetime serializationBaseCollectorCommandlogsresult_reprandresult_jsonin structuredextrawhen the run result is aTrackerResultDataclassto_legacy_dict()kept unchanged for Tier-C workspace bridge JSONApps touched
Test plan
uv run pytest core/tests/test_protocol_serialization.py core/tests/test_collector_protocol_conformance.py core/tests/test_protocols.py core/tests/test_collectors_base.py core/tests/test_activity_types.pyuv run pytest */tests/test_protocol_impl.py(app protocol_impl smoke tests)uv run pyrightlint-imports(no new cross-app imports; worth running in CI)Docs / coupling
python scripts/generate_service_docs.pyrun (ifservices.pyorcore/protocols.pychanged) — N/A (core/protocols.pyunchanged)docs/updated (if behavior or ops changed) —docs/Core_public_API.md,CHANGELOG.mdCloses #277
Summary by CodeRabbit
Release Notes
New Features
asdict(),to_json(), andfrom_dict()methods with bounded, log-friendly__repr__output.GenericActivityRecordas a default implementation for activity tracking.Changed
result_reprandresult_jsonfields for improved observability.Documentation
Tests