Skip to content

Conversation

@LZL0
Copy link
Member

@LZL0 LZL0 commented Dec 10, 2025

Summary by cubic

Adds Pydantic models for all L0 types and exports them under l0.pydantic to enable runtime validation, JSON serialization, and JSON schema generation. Also updates the README with examples and adds tests.

  • New Features

    • New l0.pydantic module with BaseModel equivalents for core, guardrails, consensus, drift, metrics, pipeline, parallel, pool, window, state machine, event sourcing, errors, and observability events.
    • Strict validation (extra="forbid") and enums; supports model_dump_json and model_json_schema.
    • Centralized exports via l0.pydantic for simple imports.
    • README examples and tests covering defaults, validation, and serialization.
  • Migration

    • No breaking changes; this is additive.
    • Import models from l0.pydantic (e.g., from l0.pydantic import StateModel, RetryModel).

Written for commit a12cd56. Summary will update automatically on new commits.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 16 files

Prompt for AI agents (all 1 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/l0/pydantic/events.py">

<violation number="1" location="src/l0/pydantic/events.py:133">
P2: Inconsistent field aliasing: `ObservabilityEventModel.ts` uses `Field(alias=&quot;timestamp&quot;)` but all specific event models define `ts: float` without the alias. This means events serialized from `ObservabilityEventModel` (with `by_alias=True`) will have `&quot;timestamp&quot;` key, but specific models expect `&quot;ts&quot;` key for deserialization. Consider adding the same alias to specific models for consistency.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

model_config = ConfigDict(extra="forbid")

type: ObservabilityEventTypeModel = ObservabilityEventTypeModel.SESSION_START
ts: float
Copy link

@cubic-dev-ai cubic-dev-ai bot Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Inconsistent field aliasing: ObservabilityEventModel.ts uses Field(alias="timestamp") but all specific event models define ts: float without the alias. This means events serialized from ObservabilityEventModel (with by_alias=True) will have "timestamp" key, but specific models expect "ts" key for deserialization. Consider adding the same alias to specific models for consistency.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/l0/pydantic/events.py, line 133:

<comment>Inconsistent field aliasing: `ObservabilityEventModel.ts` uses `Field(alias=&quot;timestamp&quot;)` but all specific event models define `ts: float` without the alias. This means events serialized from `ObservabilityEventModel` (with `by_alias=True`) will have `&quot;timestamp&quot;` key, but specific models expect `&quot;ts&quot;` key for deserialization. Consider adding the same alias to specific models for consistency.</comment>

<file context>
@@ -0,0 +1,202 @@
+    model_config = ConfigDict(extra=&quot;forbid&quot;)
+
+    type: ObservabilityEventTypeModel = ObservabilityEventTypeModel.SESSION_START
+    ts: float
+    stream_id: str
+    context: dict[str, Any] = Field(default_factory=dict)
</file context>

✅ Addressed in 4596014

@LZL0 LZL0 merged commit b5b77f1 into master Dec 10, 2025
4 checks 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.

2 participants