clsa-code / figures /f1_stack.py
fahadhafeezofficial's picture
Upload folder using huggingface_hub
fd5366a verified
Raw History Blame Contribute Delete
2.39 kB
# Copyright (c) 2026 CLSA contributors
# SPDX-License-Identifier: MIT
"""Figure 1: the World-First Agent Stack, drawn programmatically."""
from __future__ import annotations
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
from common import save, style
LAYERS = [
("Perception\n(text, image, tool state)", "#d6e4f0"),
("Trajectory Transcoder\nTopK features + Tiwari admission", "#b7d3ec"),
("Causal World Core\np(s' | do(a), s), CWL-trained", "#8fb8dd"),
("Latent MPC\nfive modes, calibrated budget", "#6396c9"),
("Certificate Renderer\nG, Fork, E, Bound", "#3f6f9f"),
]
SIDE = [
("Belief state b\n(Bayes, 2nd order)", "#e8f4ea"),
("Evidence ledger e\n(provenance, staleness)", "#fdf2e9"),
("Cost ledger\n(monitor, sim, verify, alloc)", "#f4ecf7"),
]
def main() -> None:
style()
fig, ax = plt.subplots(figsize=(7.2, 4.2))
ax.set_xlim(0, 10)
ax.set_ylim(0, 6.4)
ax.axis("off")
for i, (label, colour) in enumerate(LAYERS):
y = 5.2 - i * 0.95
box = mpatches.FancyBboxPatch(
(0.7, y), 5.6, 0.78, boxstyle="round,pad=0.03,rounding_size=0.08",
linewidth=0.8, edgecolor="#2c3e50", facecolor=colour,
)
ax.add_patch(box)
ax.text(3.5, y + 0.39, label, ha="center", va="center", fontsize=8.4, color="#12232e")
if i > 0:
ax.annotate(
"", xy=(3.5, y + 0.80), xytext=(3.5, y + 0.96),
arrowprops=dict(arrowstyle="-|>", lw=1.0, color="#2c3e50"),
)
for j, (label, colour) in enumerate(SIDE):
box = mpatches.FancyBboxPatch(
(6.9, 4.25 - j * 1.15), 2.6, 0.95,
boxstyle="round,pad=0.03,rounding_size=0.08",
linewidth=0.8, edgecolor="#566573", facecolor=colour,
)
ax.add_patch(box)
ax.text(8.2, 4.72 - j * 1.15, label, ha="center", va="center", fontsize=7.6, color="#1b2631")
ax.annotate(
"", xy=(6.9, 4.72 - j * 1.15), xytext=(6.35, 4.72 - j * 1.15),
arrowprops=dict(arrowstyle="-|>", lw=0.8, color="#566573", linestyle="--"),
)
ax.text(0.7, 0.35, "Language proposes candidates and renders the certified decision; it is never the planning substrate.",
fontsize=7.4, style="italic", color="#34495e")
save(fig, "fig1_stack")
if __name__ == "__main__":
main()