feat: add Execution / Worker / Agent / Message Pydantic models (additive)#31
Open
mikemolinet wants to merge 1 commit intomainfrom
Open
feat: add Execution / Worker / Agent / Message Pydantic models (additive)#31mikemolinet wants to merge 1 commit intomainfrom
mikemolinet wants to merge 1 commit intomainfrom
Conversation
…ive) Closes the remaining `model_drift` items in cueapi-python #24's parity manifest. Adds 4 new model files + 7 new exported classes covering the response shapes that resource methods currently return as raw dicts. **Additive only** — resource methods still return raw `dict` (no breaking change to return types). Callers opt into typed accessors via `Model.model_validate(dict)`. Promoting resource methods to return typed objects is a separate breaking-change PR and would warrant a major version bump. New files: - `cueapi/models/execution.py` — `Execution` + `ExecutionList` + `OutcomeDetail` (typed outcome inline). Covers all 13 fields the manifest flagged as missing on Execution: `payload` (PR #589), `outcome`, `outcome_state`, `triggered_by`, evidence_*, claimed_by_*, chain_*, last_heartbeat_at. - `cueapi/models/worker.py` — `Worker` + `WorkerList`. Captures `heartbeat_status` (online / stale / dead), `seconds_since_heartbeat`, `handlers` list. - `cueapi/models/agent.py` — `Agent` + `AgentList` (Phase 12.1.5 messaging primitive identity surface). Mirrors server's `AgentResponse`. `webhook_secret` field captures the one-time-on-create / one-time-on-regenerate contract. - `cueapi/models/message.py` — `Message` + `MessageList` + `FromAgentRef` (inline sender reference) + `StateTransitionResponse` (read / ack response shape). Notable design choices: - All new models use `extra="allow"` so server can grow response shapes without breaking SDK callers. Same pattern already in use on `AlertConfig` + `VerificationConfig` from #29. - `Message.from_agent` aliases the server's `from` field via `Field(alias="from")` — `from` is a reserved keyword in Python so the SDK exposes it as `from_agent` while still parsing server's `from` on the wire. `populate_by_name=True` lets callers use either name on construction. - All 11 new classes exported from `cueapi.__init__` for ergonomic access (`from cueapi import Agent, Message, ...`). Tests: 17 new (93 → 110 total). Coverage: - Minimal vs full responses parse cleanly - Forward-compat: unknown fields land in `model_extra` instead of raising - `from` → `from_agent` alias roundtrip - `webhook_secret` one-time-view shape on Agent - All new classes are exported from top-level + are BaseModel subclasses 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the remaining
model_driftitems in cueapi-python #24's parity manifest. Adds 4 new model files + 11 new exported classes covering response shapes that resource methods currently return as raw dicts.Additive only — resource methods still return raw
dict. No breaking change. Callers opt into typed accessors viaModel.model_validate(dict). Promoting resource methods to return typed objects directly is a separate breaking-change PR (would warrant a major version bump).New models
cueapi/models/execution.pyExecution,ExecutionList,OutcomeDetailpayload(PR #589),outcome,outcome_state,triggered_by,evidence_*,claimed_by_*,chain_*,last_heartbeat_atcueapi/models/worker.pyWorker,WorkerListheartbeat_status(online / stale / dead),seconds_since_heartbeat,handlerscueapi/models/agent.pyAgent,AgentListwebhook_secretfield captures one-time-on-create / one-time-on-regenerate contractcueapi/models/message.pyMessage,MessageList,FromAgentRef,StateTransitionResponseMessage.from_agentaliases server'sfromfieldDesign notes
extra="allow"on every new model so the server can grow response shapes without breaking SDK callers. Same pattern asAlertConfig/VerificationConfigfrom feat: expand Cue model with 8 missing fields (drift fix-up) #29.Message.from_agentaliases server'sfromfield viaField(alias="from").fromis a reserved keyword in Python so the SDK exposes it asfrom_agentwhile still parsing the server'sfromon the wire.populate_by_name=Truelets callers use either name on construction.All 11 new classes exported from
cueapi.__init__for ergonomic access:Tests
17 new (93 → 110 total unit tests). Coverage:
model_extrainstead of raising (pinned bytest_forward_compat_extra_field)from→from_agentalias roundtripwebhook_secretone-time-view shape on AgentNo hosted-PR dependency
All response shapes already shipped on prod. Pure SDK catch-up.
Companion PRs from this session
mark_verifiedbug fix +replay()WorkersResource+UsageResourceAgentsResourceMessagesResourcefire(send_at=...)(#618 port)After this lands, the entire
model_driftsection of cueapi-python #24's manifest is closed.🤖 Generated with Claude Code