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"""
7Typed read models for the orchestration registry.
8
9Purpose
10-------
11Provide stable dataclasses for registry reader APIs and native CLI output.
12
13Responsibilities
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
19Diagnostics
20-----------
21Domain: OC_CHAT.MAIN
22Levels:
23 L2 - lifecycle events
24 L3 - semantic details
25 L4 - deep tracing
26
27Contracts
28---------
29- Dataclasses are frozen and safe to return from reader functions.
30- Payload mappings are already decoded from canonical JSON by readers.
31
32Dependencies
33------------
34- dataclasses (immutable record types)
35- typing (read-model payload annotations)
36- oc_diagnostics (structured debug logging via _dbg)
37"""
38from __future__ import annotations
39
40from dataclasses import dataclass
41from typing import Mapping
42
43from oc_diagnostics import _dbg
44
45
46_dbg("OC_CHAT.MAIN", "module", "loaded", 4)
47
48
49@dataclass(frozen=True)
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)
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)
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)
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)
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)
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)
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