Skip to main content
NewEpisode 3a is out: Carry the conversation onWatch →

This part is for members

Membership opens soon. Leave your email and we'll tell you the day it does. Founding members get the launch price.

Keep watching the free parts
Data & comms · 29b

Product contract 2: what the gate catches, and what it misses

The product contract, part two: the two gates contract_tool.py all keeps. It opens with the whole episode on one framework page: all runs load + validate (29a), then five checks in order and stops at the first failure; gate one, check, renders the eleven texts again and compares them with contract/generated/, catching a forgotten generate; gate two, sources, evidence, golden and mavlink, searches the firmware's own files for the names the JSON gives: it proves the names exist, not what the code computes. The page: the five checks and the file each reads on the left; a table of real runs, and where each stopped, on the right. Running example: in a copy of the pinned tree, 0x60FF's wire type changed from int32 to int16 (labelled PATCHED). Five stops: the command all (L26, five calls; fail() raises ValueError → FAIL, return 1); gate one (check on the int16 copy: 6 of 11 stale; the printed paths cut at different depths, cosmetic; generate fixes it); sources (data_param.h searched as text for the field as a whole word, found at line 112; SlaveOD.eds split into sections keyed by (index, subindex), comparing name, data type, PDO mapping and access; the JSON expects 0x0003, the section says 0x0004 → FAIL); evidence (10 items need it; the conversion file and data_param.c are read and each name must appear in the text; the multiply on line 938 is never looked at); golden and mavlink (Python checked against Python; the MAVLink headers pinned by hash, their source XML missing). The pinned tree passes all five. Then five more edits, each guess first: renaming the EDS entry or the field is caught (whole-word search: an underscore is part of a word, so set_app_Target_velocity doesn't count); multiplying the conversion by 2 or making the field int32_t both PASS (on the bench, int32_t stores 1000 as 0 rpm); the board's own motor: the Y01 build's default wb40st has no load encoder, so the firmware falls back to the motor encoder, 60/131,072 (1000 → 0.457763671875 rpm), but Load_control_resolution is 0, the contract's 60/Load_control_resolution becomes 60/0, and giving the tool that 0 stops it with an uncaught ZeroDivisionError, neither PASS nor FAIL; feedback.velocity uses the same formula. The fix: the course fork's branch fix/contract-velocity-no-load-encoder (45ab3cb, labelled PATCHED): the motor resolution when the load's is 0, the golden context now the board's own motor, the vector 1000 → 0.457763671875 rpm, the firmware's own number; PASS. When the gate runs: the GitHub workflow runs only when a listed path changes, and data_param.c isn't listed (read from the workflow file, not run). Not covered: the CANopen write → episode 30; MAVLink → episode 32; EtherCAT, about which the contract makes no claim. Your turn: rename get_Target_velocity → all still PASSES (its USER CODE comments keep the old name), but the firmware won't link (OD_0x60FF_Target_velocity_Read_Callback can't find it).

Up next30a · CAN 1: one write, two front doors→