-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender_map.py
More file actions
184 lines (157 loc) · 5.96 KB
/
Copy pathrender_map.py
File metadata and controls
184 lines (157 loc) · 5.96 KB
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
#!/usr/bin/env python3
"""Deterministic SVG renderer for the roadmap path map.
The map is data, not a drawing: edit SECTIONS / EDGES below and re-run to
regenerate assets/roadmap.svg. No external dependencies, no randomness, no
timestamps — the same input always produces byte-identical output, so the
committed SVG and this script never drift.
python scripts/render_map.py # writes assets/roadmap.svg
python scripts/render_map.py --check # exit 1 if the SVG is stale
"""
from __future__ import annotations
import argparse
import sys
from pathlib import Path
# --- data -------------------------------------------------------------------
# Each section is (id, title, track). `track` picks the accent color.
SECTIONS = [
("§0", "Orientation", "spine"),
("§1", "Foundations", "spine"),
("§2", "Evals ⭐", "core"),
("§3", "Red teaming", "offense"),
("§4", "Guardrails", "defense"),
("§5", "Agent security", "defense"),
("§6", "Monitoring & Control ⭐", "core"),
("§7", "Interpretability", "spine"),
("§8", "ML/AI security", "offense"),
("§9", "Career", "career"),
("§10", "Governance", "spine"),
]
# Directed edges by section id (drawn as connectors down the spine).
EDGES = [
("§0", "§1"), ("§1", "§2"), ("§2", "§3"), ("§3", "§4"),
("§4", "§5"), ("§5", "§6"), ("§2", "§6"), ("§6", "§7"),
("§7", "§8"),
]
TRACK_FILL = {
"spine": "#e8eef7",
"core": "#fde8c8",
"offense": "#f7dfe0",
"defense": "#dcefe4",
"career": "#e9e3f5",
}
TRACK_STROKE = {
"spine": "#5b7aa8",
"core": "#d08a2e",
"offense": "#c15862",
"defense": "#4f9b74",
"career": "#7a5fb0",
}
TEXT = "#1b2430"
MUTED = "#5a6472"
# --- layout -----------------------------------------------------------------
BOX_W, BOX_H = 260, 56
V_GAP = 34
LEFT = 60
TOP = 96
WIDTH = 720
FONT = "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif"
def esc(s: str) -> str:
return s.replace("&", "&").replace("<", "<").replace(">", ">")
def build() -> str:
n = len(SECTIONS)
height = TOP + n * (BOX_H + V_GAP) + 60
ypos = {sid: TOP + i * (BOX_H + V_GAP) for i, (sid, _, _) in enumerate(SECTIONS)}
box_x = LEFT
cx = box_x + BOX_W // 2
parts: list[str] = []
parts.append(
f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {WIDTH} {height}" '
f'width="{WIDTH}" height="{height}" font-family="{FONT}" '
f'role="img" aria-label="AI Safety Engineer roadmap path map">'
)
parts.append(f'<rect width="{WIDTH}" height="{height}" fill="none"/>')
# title
parts.append(
f'<text x="{LEFT}" y="44" font-size="22" font-weight="700" '
f'fill="{TEXT}">Working engineer → AI safety engineer</text>'
)
parts.append(
f'<text x="{LEFT}" y="70" font-size="13" fill="{MUTED}">'
f'Every node is a milestone with an artifact. ⭐ = flagship (public, cited).</text>'
)
# edges first (behind boxes)
for a, b in EDGES:
ya = ypos[a] + BOX_H
yb = ypos[b]
if b == "§6" and a == "§2":
# the shortcut edge: curve out to the right
xr = box_x + BOX_W + 40
parts.append(
f'<path d="M {cx} {ypos[a] + BOX_H} '
f'C {xr} {ypos[a] + BOX_H + 20}, {xr} {yb - 20}, {cx} {yb}" '
f'fill="none" stroke="{MUTED}" stroke-width="1.6" '
f'stroke-dasharray="5 4" marker-end="url(#arrow)"/>'
)
else:
parts.append(
f'<line x1="{cx}" y1="{ya}" x2="{cx}" y2="{yb}" '
f'stroke="{MUTED}" stroke-width="1.8" marker-end="url(#arrow)"/>'
)
# arrow marker
parts.append(
f'<defs><marker id="arrow" viewBox="0 0 10 10" refX="8" refY="5" '
f'markerWidth="7" markerHeight="7" orient="auto-start-reverse">'
f'<path d="M 0 0 L 10 5 L 0 10 z" fill="{MUTED}"/></marker></defs>'
)
# fork annotation at §7
y7 = ypos["§7"]
parts.append(
f'<text x="{box_x + BOX_W + 24}" y="{y7 + BOX_H // 2 - 4}" font-size="12" '
f'fill="{TRACK_STROKE["career"]}" font-weight="600">→ research fork:</text>'
)
parts.append(
f'<text x="{box_x + BOX_W + 24}" y="{y7 + BOX_H // 2 + 12}" font-size="12" '
f'fill="{MUTED}">ARENA ch.1/4 → MATS</text>'
)
# career sidebar note
y9 = ypos["§9"]
parts.append(
f'<text x="{box_x + BOX_W + 24}" y="{y9 + BOX_H // 2 + 4}" font-size="12" '
f'fill="{MUTED}">runs in parallel from §2</text>'
)
# boxes
for sid, title, track in SECTIONS:
y = ypos[sid]
parts.append(
f'<rect x="{box_x}" y="{y}" width="{BOX_W}" height="{BOX_H}" rx="10" '
f'fill="{TRACK_FILL[track]}" stroke="{TRACK_STROKE[track]}" stroke-width="2"/>'
)
parts.append(
f'<text x="{box_x + 16}" y="{y + 34}" font-size="15" font-weight="700" '
f'fill="{TRACK_STROKE[track]}">{esc(sid)}</text>'
)
parts.append(
f'<text x="{box_x + 58}" y="{y + 34}" font-size="15" font-weight="600" '
f'fill="{TEXT}">{esc(title)}</text>'
)
parts.append("</svg>")
return "\n".join(parts) + "\n"
def main() -> int:
ap = argparse.ArgumentParser()
ap.add_argument("--check", action="store_true",
help="exit 1 if committed SVG differs from freshly rendered")
args = ap.parse_args()
out = Path(__file__).resolve().parent.parent / "assets" / "roadmap.svg"
svg = build()
if args.check:
if not out.exists() or out.read_text(encoding="utf-8") != svg:
print("roadmap.svg is stale — run: python scripts/render_map.py", file=sys.stderr)
return 1
print("roadmap.svg up to date.")
return 0
out.parent.mkdir(parents=True, exist_ok=True)
out.write_text(svg, encoding="utf-8")
print(f"wrote {out}")
return 0
if __name__ == "__main__":
raise SystemExit(main())