Stage 3 of 6 · Theory · how pieces meet
Joining the pieces
The skeleton said what to build first; integration discipline says how pieces meet from now on. The rule fits in a sentence: join one interface at a time, verify it, then the next. The hour's job is to show why the obvious alternative quietly costs a week, and to hand you the two command-line stubs that make the rule practical for a pair.
Big bang versus one join at a time
Big-bang integration builds every component separately, then connects them all at once near the deadline. Incremental integration connects two pieces, verifies the join, and only then adds the third. Software engineering has preferred the second for fifty years, and the reason is fault localization, not neatness. When a big-bang system fails its first combined run, the fault could be at any of the k freshly exercised interfaces, or in several at once, masking each other; with six contracts you start the worst week of the project with six suspects and no alibis. When an incremental join fails, one interface changed since the last green check, so the suspect list has length one.
Your course already made the first move for you: the skeleton is the first full incremental pass, so from today integration means something gentler, re-verifying the chain each time a rung thickens one piece. The habit is mechanical: before changing a component, run the end-to-end check; after changing it, run it again. Two minutes, and any new fault has a one-line suspect list, your diff.
The bench's natural order
When a join does need building or rebuilding, order matters, and the bench has a natural one: follow the data, and never join to an unverified neighbour. Each step below assumes the previous one is green, which is exactly what makes a failure at step k a statement about join k alone.
- Node ↔ broker. The node publishes; the Week 9 firehose listens:
mosquitto_sub -t "#" -v. Green means Wi-Fi, topic and payload all hold. - Broker ↔ rule. Your monitor or controller subscribes and logs what it parses. Green means the subscription and the payload reading hold, bytes decoded, numbers converted.
- Rule ↔ actuator path. The rule publishes its command; the node's
check_msgloop obeys. Green means the command grammar holds in both directions. - Bridge ↔ broker, then page ↔ bridge.
curlthe API route before any browser touches it; only then load the page and letfetchtake over.
The verifier at each step is a tool, not a teammate
Notice that every green check above uses a neutral instrument, the firehose, a log line, curl, never "my partner's program seemed happy". Instruments do not share your assumptions; that is their whole value, and it is why the same four instruments return on the next page as probes.
Stubs: never wait for your partner
Pair work has a scheduling trap: if the dashboard can only be tested against the live node, then the dashboard's author idles whenever the node's author is mid-surgery, and both work converges on the one shared bench. The escape is the stub, a stand-in that honours the contract while the real piece is away, and the bench's protocols make stubs nearly free. MQTT does not care who publishes, and HTTP does not care who asks:
# A fake node: publish by hand what the real node would say
you@lastname-pi:~ $ mosquitto_pub -t "bench/s07/light" -m "42"
# A fake browser: ask the bridge what the page would ask
you@lastname-pi:~ $ curl http://localhost:5000/api/light
docs/topics.md are what keep the halves honest; when the real pieces meet, only reality is new.A stub is also a demo insurance policy
Keep your stub commands in the repo, in a docs/stubs.md or a small script. If a sensor dies ten minutes before a milestone demo, publishing honest fake data while saying so is a professional recovery; markers grade method, and a pair that can degrade gracefully is demonstrating it.
Checklist for this stage
Check yourself
A pair split the work by layer, and the node author is reflashing all afternoon. What can the dashboard author verify meanwhile, concretely?
mosquitto_pub -t "bench/s07/light" -m "42" (their project's topic) as the fake node, they can verify the rule parses and reacts, the bridge's latest updates, curl of the API returns the right JSON keys, the page renders and polls, and the setpoint POST publishes on the command topic, watched with mosquitto_sub. That is five of six contracts, and when the real node returns, only contract 1 is news.The first combined run after a big bang fails with a frozen dashboard. Why is "the bug is probably in the newest code" unreliable here, in terms of suspects?
Why must the stub read docs/topics.md rather than the stub author's memory, when both authors sit at the same bench?
bench/s07/Light, their whole stack verifies green against a topic the real node never uses, and the error survives until the pieces meet, disguised as a mysterious integration bug. A stub built from the written contract turns the file into the single source both halves are tested against, so a wrong file fails loudly on both sides instead of silently on one.