oc_chat
Loading...
Searching...
No Matches
dataclasses.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
# oc_chat/registry/dataclasses.py
4
5
# OCT-LINT: disable=tests_exist reason="Covered by oc_chat/tests/registry/test_readers.py"
6
"""
7
Typed read models for the orchestration registry.
8
9
Purpose
10
-------
11
Provide stable dataclasses for registry reader APIs and native CLI output.
12
13
Responsibilities
14
----------------
15
- Represent queue history and plan lifecycle events without exposing raw JSON.
16
- Represent compact plan, actor, and orchestration status projections.
17
- Keep read-model types dependency-light and immutable.
18
19
Diagnostics
20
-----------
21
Domain: OC_CHAT.MAIN
22
Levels:
23
L2 - lifecycle events
24
L3 - semantic details
25
L4 - deep tracing
26
27
Contracts
28
---------
29
- Dataclasses are frozen and safe to return from reader functions.
30
- Payload mappings are already decoded from canonical JSON by readers.
31
32
Dependencies
33
------------
34
- dataclasses (immutable record types)
35
- typing (read-model payload annotations)
36
- oc_diagnostics (structured debug logging via _dbg)
37
"""
38
from
__future__
import
annotations
39
40
from
dataclasses
import
dataclass
41
from
typing
import
Mapping
42
43
from
oc_diagnostics
import
_dbg
44
45
46
_dbg(
"OC_CHAT.MAIN"
,
"module"
,
"loaded"
, 4)
47
48
49
@dataclass(frozen=True)
50
class
QueueEvent
:
51
"""One queue-related audit event for a plan."""
52
53
ts: str
54
operation_type: str
55
payload: Mapping[str, object]
56
state_version: int
57
actor_slot: str
58
actor_type: str
59
related_plan_id: str |
None
60
related_round: int |
None
61
is_migration_synthetic: bool =
False
62
63
64
@dataclass(frozen=True)
65
class
PlanStatusEvent
:
66
"""One status event from the projected status table or operation log."""
67
68
ts: str
69
plan_id: str
70
from_status: str |
None
71
to_status: str
72
actor_slot: str |
None
73
source: str |
None
74
note: str |
None
75
state_version: int |
None
=
None
76
77
78
@dataclass(frozen=True)
79
class
PlanAssignmentEvent
:
80
"""One assignment-related audit event for a plan."""
81
82
ts: str
83
plan_id: str
84
from_slot: str |
None
85
to_slot: str |
None
86
queue_position: int |
None
87
state_version: int
88
89
90
@dataclass(frozen=True)
91
class
PlanTimeline
:
92
"""Combined lifecycle timeline for a plan."""
93
94
plan_id: str
95
status_events: tuple[PlanStatusEvent, ...]
96
assignment_events: tuple[PlanAssignmentEvent, ...]
97
98
99
@dataclass(frozen=True)
100
class
PlanView
:
101
"""Current projected plan row."""
102
103
plan_id: str
104
plan_number: int
105
title: str
106
status: str
107
assigned_slot: str |
None
108
queue_position: int |
None
109
branch: str |
None
110
worktree: str |
None
111
body_path: str
112
body_sha256: str |
None
113
114
115
@dataclass(frozen=True)
116
class
ActorView
:
117
"""Current projected actor/agent row."""
118
119
slot: str
120
slot_kind: str
121
identity_kind: str
122
model_class: str
123
orchestrator_eligible: bool
124
active: bool
125
provider: str |
None
126
profile: str |
None
127
128
129
@dataclass(frozen=True)
130
class
CurrentStatus
:
131
"""Compact registry status projection."""
132
133
plan_counts: Mapping[str, int]
134
open_rounds: tuple[Mapping[str, object], ...]
135
active_leases: tuple[Mapping[str, object], ...]
136
orchestration_state: Mapping[str, object] |
None
oc_chat.registry.dataclasses.ActorView
Definition
dataclasses.py:116
oc_chat.registry.dataclasses.CurrentStatus
Definition
dataclasses.py:130
oc_chat.registry.dataclasses.PlanAssignmentEvent
Definition
dataclasses.py:79
oc_chat.registry.dataclasses.PlanStatusEvent
Definition
dataclasses.py:65
oc_chat.registry.dataclasses.PlanTimeline
Definition
dataclasses.py:91
oc_chat.registry.dataclasses.PlanView
Definition
dataclasses.py:100
oc_chat.registry.dataclasses.QueueEvent
Definition
dataclasses.py:50
oc_chat
registry
dataclasses.py
Generated by
1.15.0