File size: 7,067 Bytes
2955ecc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#!/usr/bin/env python3
"""Figure 2: registry-derived observable-family and access-context matrix."""

from __future__ import annotations

from collections import OrderedDict

import matplotlib.pyplot as plt
import yaml
from matplotlib.patches import Rectangle

from style import (
    BLUE,
    INK,
    LIGHT_GREY,
    MID_GREY,
    HERE,
    REPO_ROOT,
    assert_text_inside_figure,
    assert_text_not_overlapping,
    save_figure,
)


INPUT = REPO_ROOT / "observables" / "observables.yaml"
OUTPUT = HERE / "fig_taxonomy_matrix.pdf"
FIGURE_WIDTH_IN = 6.25
TABLE_TEXT_PT = 9.0
ACCESS_TEXT_PT = 8.5

DISPLAY_NAMES = OrderedDict(
    [
        ("O01", "inventory and device state"),
        ("O02", "topology and capability"),
        ("O03", "scheduler and allocation"),
        ("O04", "cloud control plane"),
        ("O05", "accelerator telemetry"),
        # Follow the released registry rather than the manuscript's proposed
        # but unimplemented O06 profiling expansion.
        ("O06", "achieved-operation counters"),
        ("O07", "local accelerator interconnect"),
        ("O08", "scale-out fabric"),
        ("O09", "general network"),
        ("O10", "storage and data movement"),
        ("O11", "power and energy"),
        ("O12", "cooling and environment"),
        ("O13", "host and container resources"),
        ("O14", "maintenance and physical access"),
        ("O15", "site and electrical timing"),
    ]
)

ACCESS = OrderedDict(
    [
        ("public_or_out_of_band", "public /\nOOB"),
        ("facility_operator", "facility"),
        ("cluster_operator", "cluster"),
        ("cloud_provider_control_plane", "cloud /\ncontrol"),
        ("host_or_orchestrator_resource", "host /\norch."),
        ("storage_network_operator", "storage /\nnetwork"),
    ]
)


def load_registry() -> list[dict]:
    data = yaml.safe_load(INPUT.read_text(encoding="utf-8"))
    if data.get("taxonomy_id") != "operator_visible_datacenter_observables":
        raise ValueError("unexpected taxonomy identifier")
    if data.get("version") != "2026-05-15":
        raise ValueError("taxonomy version changed; review Figure 2 before regeneration")
    if list(data.get("access_contexts", {})) != list(ACCESS):
        raise ValueError("access-context schema changed")
    families = data.get("observables", [])
    if [family.get("id") for family in families] != list(DISPLAY_NAMES):
        raise ValueError("expected exactly O01--O15 in registry order")
    if len(families) != 15:
        raise ValueError("expected 15 indirect families")
    features = [feature for family in families for feature in family.get("features", [])]
    if len(features) != 83:
        raise ValueError("expected 83 value-level features for taxonomy version 2026-05-15")
    feature_ids = [feature.get("id") for feature in features]
    if len(set(feature_ids)) != len(feature_ids):
        raise ValueError("feature identifiers are not globally unique")
    for family in families:
        unknown = set(family.get("access_contexts", [])) - set(ACCESS)
        if unknown:
            raise ValueError(f"{family['id']} contains unknown access contexts: {unknown}")
    return families


def main() -> None:
    families = load_registry()

    fig, ax = plt.subplots(figsize=(FIGURE_WIDTH_IN, 4.15))
    fig.subplots_adjust(left=0.018, right=0.985, bottom=0.035, top=0.965)
    ax.set_xlim(0.0, 1.0)
    ax.set_ylim(0.0, 1.0)
    ax.axis("off")

    # Coordinates are normalized so the access columns retain a fixed,
    # inspectable width when the physical output size changes.
    x_name = 0.004
    x_count = 0.460
    x_divider = 0.510
    x_access = [0.555, 0.634, 0.713, 0.792, 0.871, 0.958]
    group_header_y = 0.947
    header_y = 0.845
    group_rule_y = 0.905
    rule_y = 0.785
    row_top = 0.752
    row_step = 0.0476

    header_text = [
        ax.text(
            x_name,
            header_y,
            "observable family",
            ha="left",
            va="center",
            fontsize=TABLE_TEXT_PT,
        ),
        ax.text(
            x_count,
            header_y,
            "features\n$n$",
            ha="center",
            va="center",
            fontsize=TABLE_TEXT_PT,
            linespacing=0.95,
        ),
        ax.text(
            sum(x_access) / len(x_access),
            group_header_y,
            "declared access context",
            ha="center",
            va="center",
            fontsize=TABLE_TEXT_PT,
            color=MID_GREY,
        ),
    ]
    for x, label in zip(x_access, ACCESS.values()):
        header_text.append(
            ax.text(
                x,
                header_y,
                label,
                ha="center",
                va="center",
                fontsize=ACCESS_TEXT_PT,
                linespacing=0.93,
            )
        )

    ax.plot(
        [x_access[0] - 0.035, x_access[-1] + 0.035],
        [group_rule_y, group_rule_y],
        color=LIGHT_GREY,
        lw=0.55,
    )
    ax.plot([0.0, 0.995], [rule_y, rule_y], color=INK, lw=0.75)
    ax.plot(
        [x_divider, x_divider],
        [0.045, group_rule_y],
        color=LIGHT_GREY,
        lw=0.7,
    )

    for row, family in enumerate(families):
        y = row_top - row * row_step
        ax.plot(
            [0.0, 0.995],
            [y - row_step / 2, y - row_step / 2],
            color=LIGHT_GREY,
            lw=0.45,
        )
        ax.text(
            x_name,
            y,
            rf"$\bf{{{family['id']}}}$  {DISPLAY_NAMES[family['id']]}",
            ha="left",
            va="center",
            fontsize=TABLE_TEXT_PT,
        )
        ax.text(
            x_count,
            y,
            str(len(family["features"])),
            ha="center",
            va="center",
            fontsize=TABLE_TEXT_PT,
        )
        declared = set(family["access_contexts"])
        for x, key in zip(x_access, ACCESS):
            if key in declared:
                # Use one simple vector cell. PDFKit/Quick Look misplaces
                # repeated transformed circles and compound pseudo-circles,
                # while a single rectangle per declaration remains stable.
                ax.add_patch(
                    Rectangle(
                        (x - 0.0055, y - 0.0085),
                        width=0.0110,
                        height=0.0170,
                        facecolor=BLUE,
                        edgecolor=INK,
                        lw=0.35,
                        zorder=3,
                    )
                )

    # This table uses a deliberately conservative inset beyond the global
    # one-point guard because multi-line column headers are easy to misread as
    # clipped even when their glyph boxes technically fit.
    assert_text_not_overlapping(fig, header_text, padding_points=1.5)
    assert_text_inside_figure(fig, padding_points=6.0)
    save_figure(
        fig,
        OUTPUT,
        subject="Access contexts for the fifteen indirect TRACE observable families",
    )


if __name__ == "__main__":
    main()