Lesson 06 · Lab
Practice Lab: Design a Compositional Interface
Apply a compositionality checklist to a real system sketch and diagnose non-compositional designs.
From theory to a desk check
This lab is a constrained design studio. You will wire a small open system, pick a semantics, and attack your own design with the failure modes from Lesson 1. The interactive compose lab below tracks arity and nesting so the operad discipline stays visible.
Compose lab
Live composition lab
Root operation α has 2 slots. Each child contributes its arity. Composite lives in P(3).
arity P(2)
arity P(1)
Unit check: set any child arity to represent a pass-through only when that child is the unit in P(1) and you intend identity substitution — changing structure without the unit law breaks compositionality.
Compositionality checklist
Ports complete?
Every external dependency appears as a port.
Diagnose before you ship
| Mode | Symptom | Repair |
|---|---|---|
| Doc-only hierarchy | Nesting exists in slides, not in interfaces | Make subassemblies real ported boxes |
| Algebra drift | Teams interpret the same wire differently | Publish α and a golden composition test |
| Port inflation | Everything is public; no encapsulation | Hide internal wires; minimize outer boundary |
| Fake compositionality | Marketing claims without preservation law | Demand the equation or demote the claim |
When to stop refining an interface
Can a peer predict swap behavior from ports + algebra alone?
Lab protocol (20 minutes)
- 01Pick a target: checkout flow, ETL job, multi-agent research crew, or sensor fusion box.
- 02Draw outer ports (no more than 6) and three inner boxes.
- 03Wire every port; ban hidden side channels (globals, shared mutable caches) unless they appear as ports.
- 04Choose algebra X (behavior functions, relations, or cost).
- 05Run the checklist; repair any failure mode you can name.
- 06Write one sentence: “This design is compositional because …” citing the algebra equation in plain language.
Check yourself
Retrieval practice — feedback explains why.
Explain it back
Paste or summarize your lab sketch: outer ports, three inner boxes, wires, chosen algebra, and one failing counterexample you fixed.
Sources · claim ledger
David Spivak showed that hierarchical wiring diagrams form morphisms of an operad T, providing a graphical language for databases, recursion, and plug-and-play circuits.
Spivak, The operad of wiring diagrams (arXiv:1305.0297) · verified 2026-07-28
Compositionality requires that the meaning of a composite system is determined by the meanings of its parts and the way they are composed — formalized when semantics is an algebra over a composition operad.
Spivak wiring diagrams + standard categorical usage · verified 2026-07-28
An open system exposes a typed boundary (ports/interfaces); composition glues boundaries rather than treating systems as closed black boxes.
Spivak, operad of wiring diagrams — plug-and-play devices · verified 2026-07-28