model-debugger 0.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mdb/__init__.py +43 -0
- mdb/__main__.py +5 -0
- mdb/analysis/__init__.py +34 -0
- mdb/analysis/circuits/__init__.py +6 -0
- mdb/analysis/circuits/build.py +690 -0
- mdb/analysis/circuits/test.py +600 -0
- mdb/analysis/features/__init__.py +5 -0
- mdb/analysis/features/basis.py +685 -0
- mdb/analysis/features/sae.py +374 -0
- mdb/analysis/features/watch.py +268 -0
- mdb/analysis/measure/__init__.py +7 -0
- mdb/analysis/measure/branches.py +806 -0
- mdb/analysis/measure/bridge.py +379 -0
- mdb/analysis/measure/changes.py +201 -0
- mdb/analysis/measure/compare.py +348 -0
- mdb/analysis/measure/donors.py +193 -0
- mdb/analysis/measure/novelty.py +227 -0
- mdb/analysis/measure/paths.py +146 -0
- mdb/analysis/measure/pools.py +454 -0
- mdb/analysis/measure/readout.py +387 -0
- mdb/analysis/measure/reads.py +455 -0
- mdb/analysis/measure/sweep.py +215 -0
- mdb/analysis/numerics/__init__.py +6 -0
- mdb/analysis/numerics/accumulation.py +180 -0
- mdb/analysis/numerics/finite.py +1712 -0
- mdb/analysis/numerics/labels.py +80 -0
- mdb/analysis/numerics/pooling.py +89 -0
- mdb/analysis/numerics/stability.py +183 -0
- mdb/analysis/numerics/summary.py +306 -0
- mdb/analysis/numerics/units.py +86 -0
- mdb/analysis/numerics/verdict.py +244 -0
- mdb/analysis/numerics/why_frames.py +162 -0
- mdb/analysis/predict/__init__.py +7 -0
- mdb/analysis/predict/capture.py +265 -0
- mdb/analysis/predict/consumers.py +52 -0
- mdb/analysis/predict/explain.py +776 -0
- mdb/analysis/predict/forecast.py +635 -0
- mdb/analysis/predict/plan.py +248 -0
- mdb/analysis/predict/propagate.py +596 -0
- mdb/analysis/predict/rounding.py +95 -0
- mdb/analysis/predict/rowmodel.py +817 -0
- mdb/analysis/predict/supplied.py +103 -0
- mdb/analysis/predict/verify.py +433 -0
- mdb/analysis/predict/whatif.py +840 -0
- mdb/analysis/symbols/__init__.py +7 -0
- mdb/analysis/symbols/binding.py +138 -0
- mdb/analysis/symbols/candidates.py +320 -0
- mdb/analysis/symbols/circuit_map.py +592 -0
- mdb/analysis/symbols/components.py +436 -0
- mdb/analysis/symbols/frame.py +451 -0
- mdb/analysis/symbols/hop.py +439 -0
- mdb/analysis/symbols/liveness.py +292 -0
- mdb/analysis/symbols/probe.py +393 -0
- mdb/analysis/symbols/rows.py +400 -0
- mdb/analysis/symbols/sealed.py +149 -0
- mdb/analysis/symbols/subspace.py +380 -0
- mdb/analysis/symbols/symbol_finite.py +417 -0
- mdb/analysis/symbols/symbol_runs.py +683 -0
- mdb/analysis/symbols/table.py +1110 -0
- mdb/cli.py +105 -0
- mdb/core/__init__.py +4 -0
- mdb/core/address.py +1353 -0
- mdb/core/bounded.py +101 -0
- mdb/core/checkpoint_schema.py +202 -0
- mdb/core/checkpoint_store.py +377 -0
- mdb/core/circuit_pages.py +117 -0
- mdb/core/custody.py +629 -0
- mdb/core/errors.py +51 -0
- mdb/core/foreign_names.py +152 -0
- mdb/core/graph_seal.py +426 -0
- mdb/core/index.py +403 -0
- mdb/core/kinds.py +255 -0
- mdb/core/locate.py +161 -0
- mdb/core/migrate.py +280 -0
- mdb/core/neuronpedia.py +116 -0
- mdb/core/plugins.py +78 -0
- mdb/core/pointers.py +621 -0
- mdb/core/project.py +248 -0
- mdb/core/project_read.py +1038 -0
- mdb/core/recipe.py +457 -0
- mdb/core/records.py +1027 -0
- mdb/core/resolve.py +296 -0
- mdb/core/settings.py +718 -0
- mdb/engine/__init__.py +21 -0
- mdb/engine/attention_observer.py +53 -0
- mdb/engine/attention_port.py +903 -0
- mdb/engine/breakpoints.py +1465 -0
- mdb/engine/bundle.py +137 -0
- mdb/engine/checkpoint.py +1265 -0
- mdb/engine/core_file.py +306 -0
- mdb/engine/edits.py +323 -0
- mdb/engine/holds.py +256 -0
- mdb/engine/models.py +172 -0
- mdb/engine/ports.py +1424 -0
- mdb/engine/refs.py +223 -0
- mdb/engine/run.py +2162 -0
- mdb/engine/selfcheck.py +347 -0
- mdb/engine/trace.py +536 -0
- mdb/interop/__init__.py +17 -0
- mdb/interop/circuit_tracer_graph.py +253 -0
- mdb/interop/circuit_tracer_names.py +44 -0
- mdb/interop/clone.py +22 -0
- mdb/interop/names.py +295 -0
- mdb/interop/nn.py +431 -0
- mdb/interop/pyvene_compat.py +40 -0
- mdb/interop/pyvene_names.py +82 -0
- mdb/interop/tl.py +149 -0
- mdb/interop/verify.py +85 -0
- mdb/machines/__init__.py +53 -0
- mdb/machines/x86/__init__.py +13 -0
- mdb/machines/x86/address.py +171 -0
- mdb/machines/x86/binary.py +285 -0
- mdb/machines/x86/grid.py +188 -0
- mdb/machines/x86/index.py +184 -0
- mdb/machines/x86/interchange.py +156 -0
- mdb/machines/x86/lanes.py +281 -0
- mdb/machines/x86/method.py +252 -0
- mdb/machines/x86/method_v2.py +105 -0
- mdb/machines/x86/mlp.py +430 -0
- mdb/machines/x86/records.py +138 -0
- mdb/machines/x86/session.py +631 -0
- mdb/machines/x86/trace.py +351 -0
- mdb/ops/__init__.py +31 -0
- mdb/ops/builtin.py +1977 -0
- mdb/ops/context.py +60 -0
- mdb/ops/debugger.py +926 -0
- mdb/ops/errors.py +8 -0
- mdb/ops/features.py +513 -0
- mdb/ops/graph.py +58 -0
- mdb/ops/inspect.py +906 -0
- mdb/ops/lines.py +496 -0
- mdb/ops/named.py +672 -0
- mdb/ops/predict.py +450 -0
- mdb/ops/registry.py +332 -0
- mdb/ops/sets.py +988 -0
- mdb/ops/sweep.py +574 -0
- mdb/repl/__init__.py +5 -0
- mdb/repl/__main__.py +244 -0
- mdb/repl/config.py +213 -0
- mdb/repl/remote.py +324 -0
- mdb/repl/render.py +1699 -0
- mdb/repl/shell.py +409 -0
- mdb/serve/__init__.py +17 -0
- mdb/serve/__main__.py +180 -0
- mdb/serve/_legacy.py +97 -0
- mdb/serve/app.py +526 -0
- mdb/serve/blobs.py +280 -0
- mdb/serve/caps.py +148 -0
- mdb/serve/export.py +9 -0
- mdb/serve/guard.py +216 -0
- mdb/serve/live.py +412 -0
- mdb/serve/live_reduce.py +90 -0
- mdb/serve/recorded.py +515 -0
- mdb/serve/reduce.py +449 -0
- mdb/serve/schema.py +969 -0
- mdb/serve/states.py +125 -0
- mdb/serve/static/assets/index-BJpByNCO.js +58 -0
- mdb/serve/static/assets/index-H9zlNeqq.css +1 -0
- mdb/serve/static/index.html +14 -0
- mdb/serve/static/manifest.json +5 -0
- mdb/serve/stored.py +34 -0
- mdb/serve/typegen.py +131 -0
- mdb/serve/views/__init__.py +1 -0
- mdb/serve/views/common.py +201 -0
- mdb/serve/views/frame.py +235 -0
- mdb/serve/views/graph.py +224 -0
- mdb/serve/views/live.py +402 -0
- mdb/serve/views/records.py +557 -0
- mdb/serve/views/sessions.py +151 -0
- mdb/serve/views/symbols.py +185 -0
- mdb/serve/views/timeline.py +121 -0
- model_debugger-0.4.0.dist-info/METADATA +1516 -0
- model_debugger-0.4.0.dist-info/RECORD +177 -0
- model_debugger-0.4.0.dist-info/WHEEL +4 -0
- model_debugger-0.4.0.dist-info/entry_points.txt +2 -0
- model_debugger-0.4.0.dist-info/licenses/LICENSE +202 -0
- model_debugger-0.4.0.dist-info/licenses/NOTICE +6 -0
mdb/serve/schema.py
ADDED
|
@@ -0,0 +1,969 @@
|
|
|
1
|
+
"""View records served by ``mdb serve``: the source of truth for the wire format.
|
|
2
|
+
|
|
3
|
+
TypeScript types in ``web/src/api/types.gen.ts`` are generated from these models
|
|
4
|
+
(``python -m mdb.serve.typegen --write``); a test fails when that file is stale.
|
|
5
|
+
|
|
6
|
+
Every number travels as ``Num``: a value with its evidence class. ``unresolved`` and ``refused``
|
|
7
|
+
carry no value and must say why. Field names are the wire names (camelCase where the UI reads
|
|
8
|
+
them), so the generated types need no mapping layer.
|
|
9
|
+
"""
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import math
|
|
13
|
+
from typing import Annotated, Any, Generic, Literal, TypeVar, Union
|
|
14
|
+
|
|
15
|
+
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
|
16
|
+
|
|
17
|
+
SCHEMA_PREFIX = "mdb-view-"
|
|
18
|
+
CAP_BYTES = 64 * 1024
|
|
19
|
+
|
|
20
|
+
Ev = Literal["measured", "derived-exact", "derived-local", "bound", "supplied", "unresolved",
|
|
21
|
+
"refused"]
|
|
22
|
+
VALUED = ("measured", "derived-exact", "derived-local", "bound", "supplied")
|
|
23
|
+
# Keys whose own value is structure, not a measurement: a scalar int, a list of ints, or a flat
|
|
24
|
+
# name -> int map such as a count per kind (ids, indices, shapes, counts, clock positions, byte
|
|
25
|
+
# sizes). A key here exempts only ITS value, never a subtree (a float, a nested object or a list of
|
|
26
|
+
# objects under it is still checked);
|
|
27
|
+
# every other number in a response is a ``Num``/``NumList`` carrying an evidence class. The web
|
|
28
|
+
# client reads the same list (``STRUCTURAL_KEYS`` in the generated types) and the contract test
|
|
29
|
+
# walks every response with it.
|
|
30
|
+
STRUCTURAL_KEYS = (
|
|
31
|
+
"at", "i", "x", "y", "x0", "x1", "y0", "y1", "w", "h", "level", "lane", "count", "bytes", "cap",
|
|
32
|
+
"seq", "page", "pages", "total", "order", "mask", "k", "bins", "axis", "axes", "fixed",
|
|
33
|
+
"shape", "outShape", "full", "index", "selector", "select", "item", "block", "head",
|
|
34
|
+
"kvGroup", "step", "clock", "pos", "token", "layer", "nonfinite", "counts", "cuts",
|
|
35
|
+
"receipts", "symbols", "records", "sessions", "rows", "id", "locationsMore", "readersMore",
|
|
36
|
+
"usesMore", "evidenceMore", "limits", "kinds",
|
|
37
|
+
# snake_case keys of stored record bodies, symbol bindings and state clocks (indices, ids and
|
|
38
|
+
# counts; every one holds only non-negative ints in real data, never a measurement):
|
|
39
|
+
"attention_selector", "contrast", "decision", "edges", "kv_group", "kv_head", "left", "right",
|
|
40
|
+
"local_clock", "logical_step", "native_payload_reads", "native_transition_index", "neuron", "feature",
|
|
41
|
+
"nodes", "own_tokens", "query_head", "receiver_row", "repeated_argument_groups", "row", "size",
|
|
42
|
+
"source_row", "src", "steps", "stride", "token_id", "token_ids", "tokens",
|
|
43
|
+
"torch_num_threads", "transition", "n",
|
|
44
|
+
# engine record bodies (circuit, symbol-table) drawn by the recorded views: a circuit's depth,
|
|
45
|
+
# a table's head count, page offset and limit, and how many readers a binding left out
|
|
46
|
+
"depth", "heads", "offset", "limit", "omitted",
|
|
47
|
+
)
|
|
48
|
+
State = Literal["resolved", "unresolved", "refused"]
|
|
49
|
+
Verdict = Literal["supported", "set_only", "not_supported", "unresolved", "control_missing",
|
|
50
|
+
"untested"]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class Model(BaseModel):
|
|
54
|
+
# Every field is always serialised, so defaults are required in the generated types.
|
|
55
|
+
model_config = ConfigDict(extra="forbid", json_schema_serialization_defaults_required=True)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class Num(Model):
|
|
59
|
+
"""A number with its evidence class. ``ptr`` is the digest of the pointer it was read from."""
|
|
60
|
+
v: float | None
|
|
61
|
+
ev: Ev
|
|
62
|
+
unit: str | None = None
|
|
63
|
+
proof: str | None = None
|
|
64
|
+
ptr: str | None = None
|
|
65
|
+
reason: str | None = None
|
|
66
|
+
note: str | None = None # e.g. "as recorded; this record carries no per-number authority"
|
|
67
|
+
recorded_authority: str | None = None # the record-level authority string, shown as text
|
|
68
|
+
|
|
69
|
+
@model_validator(mode="after")
|
|
70
|
+
def _evidence(self):
|
|
71
|
+
if self.ev in ("unresolved", "refused"):
|
|
72
|
+
if self.v is not None:
|
|
73
|
+
raise ValueError(f"an {self.ev} number carries no value")
|
|
74
|
+
if not self.reason:
|
|
75
|
+
raise ValueError(f"an {self.ev} number says why")
|
|
76
|
+
else:
|
|
77
|
+
if self.v is None or not math.isfinite(self.v):
|
|
78
|
+
raise ValueError("a valued number needs a finite value")
|
|
79
|
+
return self
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class NumList(Model):
|
|
83
|
+
"""A labelled vector: every value shares one evidence class (e.g. histogram bin edges)."""
|
|
84
|
+
vs: list[float]
|
|
85
|
+
ev: Ev
|
|
86
|
+
unit: str | None = None
|
|
87
|
+
proof: str | None = None
|
|
88
|
+
|
|
89
|
+
@model_validator(mode="after")
|
|
90
|
+
def _evidence(self):
|
|
91
|
+
if self.ev in ("unresolved", "refused"):
|
|
92
|
+
raise ValueError("a NumList holds values; use Num for unresolved/refused")
|
|
93
|
+
if not all(math.isfinite(v) for v in self.vs):
|
|
94
|
+
raise ValueError("NumList values are finite")
|
|
95
|
+
return self
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def num(value, ev, **kw) -> Num:
|
|
99
|
+
return Num(v=None if value is None else float(value), ev=ev, **kw)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def unresolved(reason, **kw) -> Num:
|
|
103
|
+
return Num(v=None, ev="unresolved", reason=reason, **kw)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class Omitted(Model):
|
|
107
|
+
"""What a bounded list left out: never silent truncation."""
|
|
108
|
+
field: str
|
|
109
|
+
count: int
|
|
110
|
+
sum: Num | None = None
|
|
111
|
+
reason: str | None = None
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class Refused(Model):
|
|
115
|
+
"""Sent with ``None`` fields dropped, so they are optional on the wire."""
|
|
116
|
+
model_config = ConfigDict(extra="forbid", json_schema_serialization_defaults_required=False)
|
|
117
|
+
|
|
118
|
+
refused: str # the reason
|
|
119
|
+
state: Literal["refused"] = "refused"
|
|
120
|
+
detail: str | None = None
|
|
121
|
+
bytes: int | None = None
|
|
122
|
+
cap: int | None = None
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
T = TypeVar("T")
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class Envelope(Model, Generic[T]):
|
|
129
|
+
schema_: str = Field(alias="schema")
|
|
130
|
+
state: State = "resolved"
|
|
131
|
+
reason: str | None = None # non-empty whenever state is not "resolved"
|
|
132
|
+
data: T
|
|
133
|
+
digest: str
|
|
134
|
+
bytes: int
|
|
135
|
+
omitted: list[Omitted] | None = None
|
|
136
|
+
|
|
137
|
+
model_config = ConfigDict(extra="forbid", populate_by_name=True,
|
|
138
|
+
json_schema_serialization_defaults_required=True)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
# --------------------------------------------------------------------------- clocks / addresses
|
|
142
|
+
|
|
143
|
+
class AxisTick(Model):
|
|
144
|
+
"""One tick of a clock axis. ``addressable`` is False for a boundary that no occurrence
|
|
145
|
+
address names (e.g. before the embedding, where no hidden state exists yet)."""
|
|
146
|
+
i: int
|
|
147
|
+
label: str
|
|
148
|
+
frag: str = ""
|
|
149
|
+
port: str | None = None
|
|
150
|
+
detail: str | None = None
|
|
151
|
+
addressable: bool = True
|
|
152
|
+
inferred: bool = False # True when the tick exists only because of an inferred layer count
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class ClockAxis(Model):
|
|
156
|
+
"""One named clock axis, ordered. The renderer never assumes which axes exist."""
|
|
157
|
+
id: str
|
|
158
|
+
label: str
|
|
159
|
+
kind: Literal["ordinal", "categorical"]
|
|
160
|
+
ticks: list[AxisTick]
|
|
161
|
+
note: str | None = None
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
class OccAddr(Model):
|
|
165
|
+
run: str
|
|
166
|
+
branch: str | None = None
|
|
167
|
+
cut: str | None = None
|
|
168
|
+
clock: dict[str, int | None]
|
|
169
|
+
sel: str | None = None
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
class SlotPointer(Model):
|
|
173
|
+
kind: Literal["slot"] = "slot"
|
|
174
|
+
cut: str
|
|
175
|
+
slot: str
|
|
176
|
+
item: int | None = None
|
|
177
|
+
select: list[int] = []
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
class BlobPointer(Model):
|
|
181
|
+
kind: Literal["blob"] = "blob"
|
|
182
|
+
ref: str
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
class OccurrencePointer(Model):
|
|
186
|
+
"""An occurrence by address text (``t10.L12.h``). The pointer an op result carries (``print``:
|
|
187
|
+
``address`` a clock dict, plus authority/cut/event/program/recipe/value) is accepted too and
|
|
188
|
+
reduced to its address text; the extra fields are not part of the reduction's identity."""
|
|
189
|
+
kind: Literal["occurrence"] = "occurrence"
|
|
190
|
+
address: str
|
|
191
|
+
|
|
192
|
+
@model_validator(mode="before")
|
|
193
|
+
@classmethod
|
|
194
|
+
def _from_op_pointer(cls, value: Any) -> Any:
|
|
195
|
+
if not isinstance(value, dict) or not isinstance(value.get("address"), dict):
|
|
196
|
+
return value
|
|
197
|
+
from ..core import address as addresses
|
|
198
|
+
|
|
199
|
+
try:
|
|
200
|
+
text = addresses.format_address(addresses.from_json(value["address"]))
|
|
201
|
+
except (ValueError, KeyError, TypeError) as error:
|
|
202
|
+
raise ValueError(f"not an occurrence address: {error}") from error
|
|
203
|
+
return {"kind": value.get("kind", "occurrence"), "address": text}
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
PointerSpec = Annotated[Union[SlotPointer, BlobPointer, OccurrencePointer],
|
|
207
|
+
Field(discriminator="kind")]
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
class PointerRef(Model):
|
|
211
|
+
digest: str
|
|
212
|
+
addr: str | None = None
|
|
213
|
+
spec: PointerSpec | None = None
|
|
214
|
+
via: list[str] = []
|
|
215
|
+
status: Literal["resolvable", "frontier"]
|
|
216
|
+
reason: str | None = None
|
|
217
|
+
shape: list[int] | None = None
|
|
218
|
+
dtype: str | None = None
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
class LiveState(Model):
|
|
222
|
+
state: Literal["offline", "paused", "running"]
|
|
223
|
+
frontier: list[str] = []
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
class FrameFocus(Model):
|
|
227
|
+
cut: str | None
|
|
228
|
+
point: dict[str, Any] | None
|
|
229
|
+
receipts: list[str]
|
|
230
|
+
symbols: list[str]
|
|
231
|
+
records: list[str]
|
|
232
|
+
pointers: list[PointerRef]
|
|
233
|
+
note: str | None = None
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
class Frame(Model):
|
|
237
|
+
"""``addr`` is the canonical spelling of the requested address; ``key`` is its value key
|
|
238
|
+
(``mdb.core.address.value_key``: ``tN.emb`` -> ``tN.L0.h``, ``tN.Lk.h_out`` ->
|
|
239
|
+
``tN.L{k+1}.h``), the identity views use to decide two addresses are one cell."""
|
|
240
|
+
addr: str
|
|
241
|
+
key: str | None = None
|
|
242
|
+
occ: OccAddr
|
|
243
|
+
axes: list[ClockAxis]
|
|
244
|
+
pos: dict[str, int | None]
|
|
245
|
+
live: LiveState
|
|
246
|
+
focus: FrameFocus | None = None
|
|
247
|
+
prev: str | None = None
|
|
248
|
+
next: str | None = None
|
|
249
|
+
stateClock: dict[str, Any] | None = None
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
# --------------------------------------------------------------------------- sessions
|
|
253
|
+
|
|
254
|
+
class SessionSummary(Model):
|
|
255
|
+
id: str
|
|
256
|
+
family: str | None
|
|
257
|
+
adapter: str | None
|
|
258
|
+
granularity: str | None
|
|
259
|
+
model: str
|
|
260
|
+
cuts: int
|
|
261
|
+
receipts: int
|
|
262
|
+
symbols: int
|
|
263
|
+
records: int
|
|
264
|
+
selected: str
|
|
265
|
+
home: str | None
|
|
266
|
+
state: State = "resolved" # "refused": the session's stored rows cannot be read
|
|
267
|
+
reason: str | None = None
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
class PortInfo(Model):
|
|
271
|
+
name: str
|
|
272
|
+
role: str | None
|
|
273
|
+
kind: str | None
|
|
274
|
+
writable: bool | None
|
|
275
|
+
recorded: bool
|
|
276
|
+
addr: str | None = None
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
class LensInfo(Model):
|
|
280
|
+
id: str
|
|
281
|
+
label: str
|
|
282
|
+
unit: str
|
|
283
|
+
hasData: bool
|
|
284
|
+
note: str
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
class ViewAvail(Model):
|
|
288
|
+
available: bool
|
|
289
|
+
reason: str | None = None
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
class Capabilities(Model):
|
|
293
|
+
"""``layers`` is the decoder layer count: ``measured`` (the cut surface's layer clock),
|
|
294
|
+
``derived-local`` (a lower bound: the highest recorded layer index) or ``unresolved``."""
|
|
295
|
+
session: str
|
|
296
|
+
axes: list[ClockAxis]
|
|
297
|
+
layers: Num
|
|
298
|
+
ports: list[PortInfo]
|
|
299
|
+
lenses: list[LensInfo]
|
|
300
|
+
views: dict[str, ViewAvail]
|
|
301
|
+
reduce: dict[str, Any]
|
|
302
|
+
ops: ViewAvail
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
class Hello(Model):
|
|
306
|
+
"""``live`` is the session id of the attached debugger (``mdb serve --tiny|--model``), None
|
|
307
|
+
on a read-only server over a recorded project."""
|
|
308
|
+
version: str
|
|
309
|
+
schemas: dict[str, str]
|
|
310
|
+
cap: int
|
|
311
|
+
sessions: int
|
|
312
|
+
readOnly: bool
|
|
313
|
+
capabilities: dict[str, ViewAvail]
|
|
314
|
+
web: ViewAvail
|
|
315
|
+
live: str | None = None
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
# --------------------------------------------------------------------------- timeline / branches
|
|
319
|
+
|
|
320
|
+
class TimelineCell(Model):
|
|
321
|
+
x: int
|
|
322
|
+
y: int
|
|
323
|
+
v: float | None
|
|
324
|
+
ev: Ev
|
|
325
|
+
glyphs: list[str] = []
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
class TokenCell(Model):
|
|
329
|
+
x: int
|
|
330
|
+
id: int | None
|
|
331
|
+
text: str | None = None
|
|
332
|
+
ev: Ev
|
|
333
|
+
reason: str | None = None
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
class Window(Model):
|
|
337
|
+
x0: int
|
|
338
|
+
x1: int
|
|
339
|
+
y0: int
|
|
340
|
+
y1: int
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
class TimelineBlock(Model):
|
|
344
|
+
lens: str
|
|
345
|
+
lenses: list[LensInfo]
|
|
346
|
+
unit: str
|
|
347
|
+
axes: list[ClockAxis]
|
|
348
|
+
win: Window
|
|
349
|
+
cells: list[TimelineCell]
|
|
350
|
+
fill: Num
|
|
351
|
+
tokens: list[TokenCell] | None = None
|
|
352
|
+
branch: str | None = None
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
class BranchNode(Model):
|
|
356
|
+
cut: str
|
|
357
|
+
parent: str | None
|
|
358
|
+
branch: str
|
|
359
|
+
clock: dict[str, int | None]
|
|
360
|
+
kind: str
|
|
361
|
+
retained: bool
|
|
362
|
+
receipt: str | None = None
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
class BranchInfo(Model):
|
|
366
|
+
name: str
|
|
367
|
+
head: str
|
|
368
|
+
base: str | None
|
|
369
|
+
cuts: int
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
class BranchTree(Model):
|
|
373
|
+
run: str
|
|
374
|
+
active: str
|
|
375
|
+
nodes: list[BranchNode]
|
|
376
|
+
branches: list[BranchInfo]
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
# --------------------------------------------------------------------------- symbols
|
|
380
|
+
|
|
381
|
+
class ReadSourceView(Model):
|
|
382
|
+
name: str
|
|
383
|
+
rows: list[int]
|
|
384
|
+
assignment: str
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
class ReaderView(Model):
|
|
388
|
+
block: int
|
|
389
|
+
head: int
|
|
390
|
+
kvGroup: int | None
|
|
391
|
+
step: int | None
|
|
392
|
+
receivers: str | None
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
class ReadEdge(Model):
|
|
396
|
+
id: str
|
|
397
|
+
source: ReadSourceView
|
|
398
|
+
reader: ReaderView
|
|
399
|
+
mass: Num
|
|
400
|
+
massKind: str
|
|
401
|
+
verdict: Verdict
|
|
402
|
+
addr: str | None = None
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
class LifePoint(Model):
|
|
406
|
+
cut: str | None
|
|
407
|
+
clock: dict[str, int | None]
|
|
408
|
+
label: str
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
class Lifetime(Model):
|
|
412
|
+
defs: list[LifePoint]
|
|
413
|
+
reads: list[LifePoint]
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
class UseView(Model):
|
|
417
|
+
id: str
|
|
418
|
+
consumer: str
|
|
419
|
+
support: str
|
|
420
|
+
closure: str | None
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
class SymbolRow(Model):
|
|
424
|
+
id: str
|
|
425
|
+
symbol: str
|
|
426
|
+
context: str
|
|
427
|
+
status: Literal["supplied", "observed", "validated", "abstained"]
|
|
428
|
+
assignment: str | None
|
|
429
|
+
claim: str
|
|
430
|
+
confidence: Num | None
|
|
431
|
+
abstainReason: str | None
|
|
432
|
+
locations: list[str]
|
|
433
|
+
locationsMore: int
|
|
434
|
+
readers: list[ReadEdge]
|
|
435
|
+
readersMore: int
|
|
436
|
+
uses: list[UseView]
|
|
437
|
+
usesMore: int
|
|
438
|
+
verdict: str
|
|
439
|
+
lifetime: Lifetime
|
|
440
|
+
evidence: list[str]
|
|
441
|
+
evidenceMore: int
|
|
442
|
+
fingerprint: str
|
|
443
|
+
lifecycles: list[str]
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
class SymbolPage(Model):
|
|
447
|
+
rows: list[SymbolRow]
|
|
448
|
+
page: int
|
|
449
|
+
pages: int
|
|
450
|
+
total: int
|
|
451
|
+
at: str | None
|
|
452
|
+
q: str | None
|
|
453
|
+
unbound: Num
|
|
454
|
+
coverage: str
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
class SymbolDetail(Model):
|
|
458
|
+
row: SymbolRow
|
|
459
|
+
binding: dict[str, Any]
|
|
460
|
+
slices: list[str]
|
|
461
|
+
statuses: dict[str, str]
|
|
462
|
+
claimBoundary: str | None
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
# --------------------------------------------------------------------------- graph
|
|
466
|
+
|
|
467
|
+
GraphEdgeType = Literal["dataflow", "read", "kv_write", "attribution", "intervention", "declared",
|
|
468
|
+
"unknown"]
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
class GraphNode(Model):
|
|
472
|
+
id: str
|
|
473
|
+
kind: Literal["state", "action", "output", "source", "aggregate"]
|
|
474
|
+
label: str
|
|
475
|
+
role: str
|
|
476
|
+
x: int | None = None
|
|
477
|
+
y: int | None = None
|
|
478
|
+
lane: int = 0
|
|
479
|
+
ev: Ev | None = None
|
|
480
|
+
count: int | None = None
|
|
481
|
+
addr: str | None = None
|
|
482
|
+
meta: dict[str, Any] = {}
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
class GraphEdge(Model):
|
|
486
|
+
id: str
|
|
487
|
+
source: str
|
|
488
|
+
target: str
|
|
489
|
+
type: GraphEdgeType
|
|
490
|
+
relation: str
|
|
491
|
+
evidence: str
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
class PrunedGroup(Model):
|
|
495
|
+
group: str
|
|
496
|
+
count: int
|
|
497
|
+
node: str
|
|
498
|
+
sum: Num | None = None
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
class CircuitOverlay(Model):
|
|
502
|
+
id: str
|
|
503
|
+
kind: str
|
|
504
|
+
label: str # text only: any number goes in ``interaction``
|
|
505
|
+
interaction: Num | None = None
|
|
506
|
+
nodes: list[str]
|
|
507
|
+
verdict: str
|
|
508
|
+
record: str
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
class SliceRef(Model):
|
|
512
|
+
id: str
|
|
513
|
+
component: str
|
|
514
|
+
cut: str
|
|
515
|
+
complete: bool
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
class GraphView(Model):
|
|
519
|
+
zoom: Literal["slice", "session"]
|
|
520
|
+
center: str | None
|
|
521
|
+
slice: SliceRef | None
|
|
522
|
+
nodes: list[GraphNode]
|
|
523
|
+
edges: list[GraphEdge]
|
|
524
|
+
pruned: list[PrunedGroup]
|
|
525
|
+
overlays: list[CircuitOverlay]
|
|
526
|
+
slices: list[SliceRef]
|
|
527
|
+
authority: str
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
# --------------------------------------------------------------------------- records
|
|
531
|
+
|
|
532
|
+
class NamedNum(Model):
|
|
533
|
+
name: str
|
|
534
|
+
n: Num
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
class RecordSummary(Model):
|
|
538
|
+
id: str
|
|
539
|
+
schema_: str = Field(alias="schema")
|
|
540
|
+
kind: str
|
|
541
|
+
title: str
|
|
542
|
+
status: str
|
|
543
|
+
authority: str
|
|
544
|
+
cut: str | None = None
|
|
545
|
+
focus: str | None = None
|
|
546
|
+
addr: str | None = None
|
|
547
|
+
order: int
|
|
548
|
+
nums: list[NamedNum] = []
|
|
549
|
+
|
|
550
|
+
model_config = ConfigDict(extra="forbid", populate_by_name=True,
|
|
551
|
+
json_schema_serialization_defaults_required=True)
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
class RecordPage(Model):
|
|
555
|
+
rows: list[RecordSummary]
|
|
556
|
+
page: int
|
|
557
|
+
pages: int
|
|
558
|
+
total: int
|
|
559
|
+
kinds: dict[str, int]
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
class ArmRow(Model):
|
|
563
|
+
mask: int
|
|
564
|
+
label: str
|
|
565
|
+
status: str
|
|
566
|
+
value: Num
|
|
567
|
+
effect: Num
|
|
568
|
+
prediction: Num | None = None
|
|
569
|
+
residual: Num | None = None
|
|
570
|
+
decision: str | None = None
|
|
571
|
+
record: str
|
|
572
|
+
cut: str | None = None
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
class Link(Model):
|
|
576
|
+
rel: str
|
|
577
|
+
id: str
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
class RecordDetail(Model):
|
|
581
|
+
summary: RecordSummary
|
|
582
|
+
body: dict[str, Any]
|
|
583
|
+
arms: list[ArmRow] | None = None
|
|
584
|
+
pointers: list[PointerRef]
|
|
585
|
+
links: list[Link]
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
class StoredBody(Model):
|
|
589
|
+
"""The whole sealed body of one engine record a recorded view draws (kind ``circuit`` or
|
|
590
|
+
``symbol-table``): the op's own JSON as it was sealed, so the recorded page draws it with the
|
|
591
|
+
Live view's components. Numbers are labelled as the Records drawer labels them: a stored
|
|
592
|
+
``{value, authority}`` keeps its class (and proof, unit); any other number is ``supplied``;
|
|
593
|
+
a stored ``{v, ev}`` look-alike is never passed through. ``consumer`` and ``where`` are the
|
|
594
|
+
body's own (the consumer and the cursor the op ran at). A circuit record is paged: ``body`` is
|
|
595
|
+
its root page, a group that did not fit is a node whose ``paged`` holds a pointer to a child
|
|
596
|
+
page, and ``node`` set asks for that node's page instead (``body`` is then the page,
|
|
597
|
+
``{schema, node: <subtree>}``). ``ledger_id`` is the ``circuit N`` number the REPL printed
|
|
598
|
+
when the record was built (None for a record from before it was stored)."""
|
|
599
|
+
id: str
|
|
600
|
+
kind: str
|
|
601
|
+
record_schema: str
|
|
602
|
+
authority: str
|
|
603
|
+
consumer: str | None
|
|
604
|
+
where: str | None
|
|
605
|
+
body: dict[str, Any]
|
|
606
|
+
ledger_id: int | None = None
|
|
607
|
+
node: str | None = None
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
# --------------------------------------------------------------------------- reduce / ops / events
|
|
611
|
+
|
|
612
|
+
ReduceOp = Literal["stats", "topk", "slice", "histogram", "tile", "project"]
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
class ReduceRequest(Model):
|
|
616
|
+
pointer: PointerSpec
|
|
617
|
+
op: ReduceOp
|
|
618
|
+
params: dict[str, Any] = {}
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
class ReduceBase(Model):
|
|
622
|
+
op: ReduceOp
|
|
623
|
+
pointer: str
|
|
624
|
+
shape: list[int]
|
|
625
|
+
dtype: str
|
|
626
|
+
note: str | None = None
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
class StatsResult(ReduceBase):
|
|
630
|
+
op: Literal["stats"] = "stats"
|
|
631
|
+
count: Num
|
|
632
|
+
finite: Num
|
|
633
|
+
min: Num
|
|
634
|
+
max: Num
|
|
635
|
+
mean: Num
|
|
636
|
+
std: Num
|
|
637
|
+
absmax: Num
|
|
638
|
+
l2: Num
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
class TopkEntry(Model):
|
|
642
|
+
index: list[int]
|
|
643
|
+
v: Num
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
class TopkResult(ReduceBase):
|
|
647
|
+
op: Literal["topk"] = "topk"
|
|
648
|
+
axis: int | None
|
|
649
|
+
by: Literal["abs", "signed"]
|
|
650
|
+
k: int
|
|
651
|
+
entries: list[TopkEntry]
|
|
652
|
+
score: str
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
class SliceResult(ReduceBase):
|
|
656
|
+
op: Literal["slice"] = "slice"
|
|
657
|
+
selector: list[Any]
|
|
658
|
+
outShape: list[int]
|
|
659
|
+
encoding: Literal["f32-le-base64"]
|
|
660
|
+
data: str
|
|
661
|
+
nonfinite: int
|
|
662
|
+
ev: Ev
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
class HistogramResult(ReduceBase):
|
|
666
|
+
op: Literal["histogram"] = "histogram"
|
|
667
|
+
bins: int
|
|
668
|
+
edges: NumList
|
|
669
|
+
counts: list[int]
|
|
670
|
+
nonfinite: int
|
|
671
|
+
ev: Ev
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
class TileResult(ReduceBase):
|
|
675
|
+
op: Literal["tile"] = "tile"
|
|
676
|
+
axes: list[int]
|
|
677
|
+
fixed: list[int]
|
|
678
|
+
x0: int
|
|
679
|
+
y0: int
|
|
680
|
+
level: int
|
|
681
|
+
w: int
|
|
682
|
+
h: int
|
|
683
|
+
full: list[int]
|
|
684
|
+
encoding: Literal["u8-base64"]
|
|
685
|
+
data: str
|
|
686
|
+
domain: NumList
|
|
687
|
+
scale: Literal["linear", "diverging"]
|
|
688
|
+
agg: str
|
|
689
|
+
nonfinite: int
|
|
690
|
+
ev: Ev
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
class ProjectResult(ReduceBase):
|
|
694
|
+
op: Literal["project"] = "project"
|
|
695
|
+
direction: str
|
|
696
|
+
directionNorm: Num
|
|
697
|
+
outShape: list[int]
|
|
698
|
+
encoding: Literal["f32-le-base64"]
|
|
699
|
+
data: str
|
|
700
|
+
ev: Ev
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
ReduceResult = Annotated[Union[StatsResult, TopkResult, SliceResult, HistogramResult, TileResult,
|
|
704
|
+
ProjectResult], Field(discriminator="op")]
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
class OpRequest(Model):
|
|
708
|
+
op: str
|
|
709
|
+
args: dict[str, Any] = {}
|
|
710
|
+
request_id: str
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
class OpResult(Model):
|
|
714
|
+
"""One op of a live session. ``result`` is exactly the JSON ``python -m mdb.repl --json``
|
|
715
|
+
prints for the same command (an op result, ``{error, state, reason}`` or ``{interrupted,
|
|
716
|
+
state, reason}``); its numbers are registry-labelled (``{value, authority}``). ``seq``
|
|
717
|
+
numbers ops and console lines in execution order; ``where`` is the cursor after it."""
|
|
718
|
+
request_id: str
|
|
719
|
+
op: str
|
|
720
|
+
seq: int
|
|
721
|
+
where: str | None
|
|
722
|
+
result: dict[str, Any]
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
class ConsoleRequest(Model):
|
|
726
|
+
line: str = Field(max_length=4096)
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
class ConsoleResult(Model):
|
|
730
|
+
"""One console line: ``text`` is what the REPL prints for it."""
|
|
731
|
+
line: str
|
|
732
|
+
seq: int
|
|
733
|
+
where: str | None
|
|
734
|
+
text: str
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
class Interrupt(Model):
|
|
738
|
+
"""``interrupted``: an op was running and Ctrl-C was delivered to it. ``cancelled``: jobs
|
|
739
|
+
that were queued behind it and will not run (each answers as interrupted)."""
|
|
740
|
+
interrupted: bool
|
|
741
|
+
running: str | None
|
|
742
|
+
cancelled: int
|
|
743
|
+
reason: str | None
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
class LiveUpstream(Model):
|
|
747
|
+
"""One edit upstream of a value: ``selection`` is the selector text that limits it (``h6``
|
|
748
|
+
for ``L22.A[h6]``, ``row=2`` for a state cell), None for the whole port."""
|
|
749
|
+
row: int
|
|
750
|
+
layer: int
|
|
751
|
+
port: str
|
|
752
|
+
op: str
|
|
753
|
+
staged: bool
|
|
754
|
+
selection: str | None = None
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
class LiveEdit(Model):
|
|
758
|
+
"""Provenance of a computed port value (``Run.read_info``): ``authority`` is None and
|
|
759
|
+
``state`` refused when the engine declined to label it."""
|
|
760
|
+
state: State
|
|
761
|
+
authority: Ev | None
|
|
762
|
+
edited: bool
|
|
763
|
+
kind: str
|
|
764
|
+
by: str | None
|
|
765
|
+
reason: str | None
|
|
766
|
+
upstream: list[LiveUpstream]
|
|
767
|
+
upstream_total: int
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
class LivePort(Model):
|
|
771
|
+
"""One port of the listed layer in program order (the ``list`` op). ``edit`` is None for a
|
|
772
|
+
port the run has not computed yet (nothing to say, never "unedited")."""
|
|
773
|
+
port: str
|
|
774
|
+
addr: str
|
|
775
|
+
sublayer: str | None
|
|
776
|
+
operator: str
|
|
777
|
+
proofs: list[str]
|
|
778
|
+
editable: bool
|
|
779
|
+
cursor: bool
|
|
780
|
+
focus: bool
|
|
781
|
+
computed: bool
|
|
782
|
+
edit: LiveEdit | None = None
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
class LiveCheckpoint(Model):
|
|
786
|
+
"""A checkpoint name and where its latest checkpoint stands: ``durable`` (stored in the
|
|
787
|
+
project; ``restart NAME`` replays it after a server restart) or ``memory`` (this process
|
|
788
|
+
only, the ``checkpoints`` op; a server without a project)."""
|
|
789
|
+
name: str
|
|
790
|
+
where: str
|
|
791
|
+
store: Literal["memory", "durable"]
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
class LiveFrame(Model):
|
|
795
|
+
"""The live cursor: ``where`` (None before ``start``), the ``where`` op's ``stop`` and
|
|
796
|
+
tokens, the listed layer's ports, staged and committed edits (the ``info edits`` op), the
|
|
797
|
+
breakpoint/watch table (``info breakpoints``), displays and checkpoints. ``limits``:
|
|
798
|
+
``layers``, ``max_positions``, ``heads``, ``kv_heads``. The frame always fits the response
|
|
799
|
+
cap: each list shows its first items and ``more`` names every list it shortened (``field``:
|
|
800
|
+
the list, or
|
|
801
|
+
``upstream:<addr>`` for a port's upstream edits; ``count``: items left out; ``reason``: the
|
|
802
|
+
``GET .../live/items`` request for the rest)."""
|
|
803
|
+
session: str
|
|
804
|
+
family: str
|
|
805
|
+
live: LiveState
|
|
806
|
+
seq: int
|
|
807
|
+
where: str | None
|
|
808
|
+
stop: dict[str, Any] | None
|
|
809
|
+
row: int | None
|
|
810
|
+
layer: int | None
|
|
811
|
+
limits: dict[str, int]
|
|
812
|
+
ports: list[LivePort]
|
|
813
|
+
checks: dict[str, Any] | None = None
|
|
814
|
+
tokens: list[dict[str, Any]]
|
|
815
|
+
edits: dict[str, Any] | None
|
|
816
|
+
breakpoints: list[dict[str, Any]]
|
|
817
|
+
displays: list[dict[str, Any]]
|
|
818
|
+
checkpoints: list[LiveCheckpoint]
|
|
819
|
+
more: list[Omitted]
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
class LiveItems(Model):
|
|
823
|
+
"""One page of a live frame list (``breakpoints``, ``displays``, ``checkpoints``,
|
|
824
|
+
``staged``, ``committed`` edits, or ``upstream`` edits of the computed address ``addr``):
|
|
825
|
+
the items from ``offset`` that fit one response, ``total`` items in all, ``next`` the offset
|
|
826
|
+
of the following page (None at the end)."""
|
|
827
|
+
list: str
|
|
828
|
+
addr: str | None
|
|
829
|
+
offset: int
|
|
830
|
+
total: int
|
|
831
|
+
items: list[dict[str, Any]]
|
|
832
|
+
next: int | None
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
class LiveRow(Model):
|
|
836
|
+
"""One token row: ``token`` its id; ``count`` stops computed in it (all for a finished row,
|
|
837
|
+
None for a prefilled row whose ports were never stepped); ``edits`` ports edited there,
|
|
838
|
+
each with its selector (``L22.A[h6]``)."""
|
|
839
|
+
row: int
|
|
840
|
+
token: int | None
|
|
841
|
+
count: int | None
|
|
842
|
+
edits: list[str]
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
class LiveStop(Model):
|
|
846
|
+
"""A stop of the run's clock: token ``row`` and ``index`` into ``stops``."""
|
|
847
|
+
row: int
|
|
848
|
+
index: int
|
|
849
|
+
label: str
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
class LiveTimeline(Model):
|
|
853
|
+
"""The run's clock: every row's stops (``stops``, one program per row), the cursor and the
|
|
854
|
+
run root (the first stop the run can step back to), and per-row edit marks. ``limits``:
|
|
855
|
+
``layers``, ``max_positions``, ``heads``, ``kv_heads``."""
|
|
856
|
+
session: str
|
|
857
|
+
where: str | None
|
|
858
|
+
stops: list[str]
|
|
859
|
+
cursor: LiveStop | None
|
|
860
|
+
root: LiveStop | None
|
|
861
|
+
rows: list[LiveRow]
|
|
862
|
+
limits: dict[str, int]
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
class LiveCircuit(Model):
|
|
866
|
+
"""One circuit of the run's ledger (the ``circuit`` op): its id, consumer, ``k`` (top) and
|
|
867
|
+
``depth``, node ``count``, the cursor it was built at, its sealed record id, how many times
|
|
868
|
+
it was tested and ``verdict``: the last ``circuit test`` in one line, its two measured ratios
|
|
869
|
+
against the reference or why they were refused (None: never tested; there is no pass/fail).
|
|
870
|
+
``from_previous_run``: built by an earlier run that ``start``/``restart`` replaced (the ledger
|
|
871
|
+
is kept across runs; its ``where`` and source rows are that run's, not this one's)."""
|
|
872
|
+
id: int
|
|
873
|
+
consumer: str
|
|
874
|
+
k: int
|
|
875
|
+
depth: int
|
|
876
|
+
count: int
|
|
877
|
+
where: str
|
|
878
|
+
record: str
|
|
879
|
+
tests: int
|
|
880
|
+
verdict: str | None
|
|
881
|
+
from_previous_run: bool = False
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
class LiveForecast(Model):
|
|
885
|
+
"""One sealed forecast of the run (the ``forecast`` op), as ``analysis.predict.forecast.view``
|
|
886
|
+
gives it: target, status (``open`` until ``verify`` closes it), where it was sealed, its record
|
|
887
|
+
id, the predicted summary and bound (labelled numbers, premises left out), the number of
|
|
888
|
+
identities in its method chain, and the last ``verify`` verdict (None before one)."""
|
|
889
|
+
id: int
|
|
890
|
+
target: str
|
|
891
|
+
status: str
|
|
892
|
+
sealed_at: str
|
|
893
|
+
record: str
|
|
894
|
+
steps: int
|
|
895
|
+
predicted: dict[str, Any]
|
|
896
|
+
bound: dict[str, Any]
|
|
897
|
+
verdict: dict[str, Any] | None
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
class LiveSymbol(Model):
|
|
901
|
+
"""A user symbol declared on the run (the ``symbol`` op): its name, the addresses it was
|
|
902
|
+
declared over and the token rows they cover."""
|
|
903
|
+
name: str
|
|
904
|
+
definitions: list[str]
|
|
905
|
+
rows: list[int]
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
class LiveLedger(Model):
|
|
909
|
+
"""What this run has built: circuits, sealed forecasts and declared symbols, the latest of
|
|
910
|
+
each (``more`` names what was left out). ``seq`` is the op count it was read at."""
|
|
911
|
+
session: str
|
|
912
|
+
seq: int
|
|
913
|
+
where: str | None
|
|
914
|
+
circuits: list[LiveCircuit]
|
|
915
|
+
forecasts: list[LiveForecast]
|
|
916
|
+
symbols: list[LiveSymbol]
|
|
917
|
+
more: list[Omitted]
|
|
918
|
+
runs: list[str] = []
|
|
919
|
+
"""The debugger's other named runs: the references ``circuit test ID ref=NAME`` can take."""
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
class Event(Model):
|
|
923
|
+
"""``op``: a live op or console line completed (``data``: op, seq, source, where, stopped,
|
|
924
|
+
state, stale views). Events carry no tensors; clients re-fetch the stale views."""
|
|
925
|
+
type: Literal["hello", "heartbeat", "op"]
|
|
926
|
+
seq: int
|
|
927
|
+
at: int # epoch milliseconds (a clock position, not a measurement)
|
|
928
|
+
data: dict[str, Any] = {}
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
# Wire schema ids, one per view record (the Envelope ``schema`` field).
|
|
932
|
+
VIEWS = {
|
|
933
|
+
"hello": Hello,
|
|
934
|
+
"sessions": SessionSummary,
|
|
935
|
+
"capabilities": Capabilities,
|
|
936
|
+
"frame": Frame,
|
|
937
|
+
"timeline": TimelineBlock,
|
|
938
|
+
"branches": BranchTree,
|
|
939
|
+
"symbols": SymbolPage,
|
|
940
|
+
"symbol": SymbolDetail,
|
|
941
|
+
"graph": GraphView,
|
|
942
|
+
"records": RecordPage,
|
|
943
|
+
"record": RecordDetail,
|
|
944
|
+
"stored": StoredBody,
|
|
945
|
+
"reduce": None, # ReduceResult union
|
|
946
|
+
"op": OpResult,
|
|
947
|
+
"console": ConsoleResult,
|
|
948
|
+
"interrupt": Interrupt,
|
|
949
|
+
"live": LiveFrame,
|
|
950
|
+
"live-timeline": LiveTimeline,
|
|
951
|
+
"live-items": LiveItems,
|
|
952
|
+
"live-ledger": LiveLedger,
|
|
953
|
+
"event": Event,
|
|
954
|
+
}
|
|
955
|
+
SCHEMAS = {name: f"{SCHEMA_PREFIX}{name}-v1" for name in VIEWS}
|
|
956
|
+
|
|
957
|
+
# Models exported to TypeScript (typegen walks their JSON Schema).
|
|
958
|
+
EXPORTED = [Num, NumList, Omitted, Refused, AxisTick, ClockAxis, OccAddr, SlotPointer, BlobPointer,
|
|
959
|
+
OccurrencePointer, PointerRef, LiveState, FrameFocus, Frame, SessionSummary, PortInfo,
|
|
960
|
+
LensInfo, ViewAvail, Capabilities, Hello, TimelineCell, TokenCell, Window,
|
|
961
|
+
TimelineBlock, BranchNode, BranchInfo, BranchTree, ReadSourceView, ReaderView,
|
|
962
|
+
ReadEdge, LifePoint, Lifetime, UseView, SymbolRow, SymbolPage, SymbolDetail,
|
|
963
|
+
GraphNode, GraphEdge, PrunedGroup, CircuitOverlay, SliceRef, GraphView, NamedNum,
|
|
964
|
+
RecordSummary, RecordPage, ArmRow, Link, RecordDetail, StoredBody, ReduceRequest,
|
|
965
|
+
StatsResult, TopkEntry, TopkResult, SliceResult, HistogramResult, TileResult,
|
|
966
|
+
ProjectResult,
|
|
967
|
+
OpRequest, OpResult, ConsoleRequest, ConsoleResult, Interrupt, LiveUpstream, LiveEdit,
|
|
968
|
+
LivePort, LiveCheckpoint, LiveFrame, LiveItems, LiveRow, LiveStop, LiveTimeline,
|
|
969
|
+
LiveCircuit, LiveForecast, LiveSymbol, LiveLedger, Event]
|