Part 2 of the fifth-protocol series. The other posts each go deep on one thing. This one is the day in order, because the order is most of the lesson: the protocol bug was found in the afternoon, and nearly everything before it was clearing the way to it.
The day before: a Check button
The office's terminal had been added a day earlier and read nothing. The first thing built was not a fix for it but a way to see what was wrong from a desk.
Check sits next to the address and port when HR adds a terminal. It asks the office PC that would read the terminal to try that address now:
- Every terminal port, not only the one typed. If the terminal answers on another port, the answer says so and offers "use port N".
- What answered. A family is named only when its own hello answers, so an open port that is something else is not mistaken for a terminal.
- The network ID (MAC) of whatever answered, so the terminal can be found again when the router gives it a new address.
- A password. A terminal that answers and says no is reported as "has a password", not as "not a terminal".
- Why it could not check, in words HR can act on: the PC is off, the PC is on a version too old to check, or no PC serves that place yet.
Support has the same check on its own screen. Two details mattered later. The PC's answer carries a flag saying it tried this terminal family, because a PC on an older version would otherwise report "not this kind of terminal" when it had never looked. And an answer belongs to the address and port it was for: change either, and the answer clears.
Morning: no self-update, and two windows
The connector can update itself, but that is switched off. A security review decided it stays off until an update installs exactly the bytes it verified, refuses a downgrade and checks its rollback. So a new version reaches an office PC only when someone runs the installer. Every fix that day needed a person at a PC, or a release they could download.
The first release of the day carried the Check feature and a fix for the white window. Opening the setup window while it was already open gave a blank window and then a crash: the second copy could not start the embedded browser on the first copy's data folder, and the window library failed on a nil pointer there. The fix looks for the connector's own open window by its window class and title, and brings it forward instead. The PC on site had the version from just before that fix, which is why it crashed the day before.
That fix had a catch for the install itself. The old setup window was still running on the PC, hidden: not on the taskbar, not in the start menu. A new copy opened while it ran would only have brought the old one forward, and not updated anything. The connector runs as two programs with different file names: a service that reads the terminals, and the setup window. So the window can be ended by name while the service keeps reading:
taskkill /IM <ConnectorWindow>* /F
A restart of the PC does the same, since only the service starts with Windows.
Late morning: on site
The terminal turned out to be from a family the connector had never read: the FK family, answering on TCP 5005. Two setup mistakes sat in front of the protocol: it was saved as another brand, and with a link address on a private range it never joined. The overview has the network picture. With the address fixed by hand, the PC reached the terminal, and every download came back refused with code 3.
Midday: the first fix, which was wrong
The PC's own report showed one read that had worked: a hello and a count, on one connection. Every later read had opened with the count and been refused. So: the terminal wants a hello first. The fix was small, the test machine was taught to refuse until greeted, and thirteen tests failed without the fix and passed with it. It was built for release.
Then, from a laptop on the same network, the same code was run against the real terminal, and it was refused exactly as before. The build was cancelled. When your simulator agrees with your bugs is about why the tests could not have caught it.
Early afternoon: probes and a year
With the laptop on the LAN, a probe that can only send three read requests varied one argument at a time. Small sizes: yes, zero bytes. Large: code 3. The fields two bytes to the right: the whole log, about 16,000 records, in twenty seconds. Then the records: 20 bytes each, not 12, and a year that read 505. Three long runs in the log, one of which went backwards, put the year in bits 2–11. A test punch matched the terminal's screen to the second. Two bytes to the right has every byte.
Afternoon: typed, then five minutes of nothing
The official release takes about twenty-five minutes. The people on site were waiting, so the same commit was built on the laptop with the same server address and release key, and served on the office network for a few minutes. Pasting into the PC was not possible, so the install was four short lines, typed:
taskkill /IM <ConnectorWindow>* /F
cd \
curl.exe -o c.exe http://<laptop-lan-ip>:8765/c.exe
.\c.exe setup
The update went in, the pairing stayed, and the terminal still showed "not reading". For five minutes. After 33 failures in a row the connector tries a terminal every five minutes, and the last failure had been a minute before the install. The next slot read it. That rule now resets on an update; the audit has the detail.
Afternoon: punches, people, history
The first read brought three punches, the test punches among them. From then on, one read every minute.
The people list came next, asked from the terminal's page: 42 staff numbers. This terminal keeps no names, so each number is linked to a person once in the platform. Punches from numbers not linked yet are kept and attach when linked.
History: older punches from ten days back, asked for one day at a time.
| Day | Punches |
|---|---|
| 1 | 52 |
| 2 | 57 |
| 3 | 65 |
| 4 | 62 |
| 5 | 64 |
| 6 (weekend) | 0 |
| 7 | 62 |
| 8 | 64 |
| 9 | 69 |
| 10 (today, so far) | 37 |
About 530 punches in all, every one an attendance event, none stored twice. A weekend day with none is what it should look like.
Late afternoon: the release
Fix to the staging branch, staging to main, a one-job runner on a Mac, signed and notarised, every file checked, uploaded, deployed, and every public download compared byte for byte with the build. Shipping a signed connector release is the whole path.
Evening: three audits, two promotions, one red job
Three audits ran after the terminal was reading, each looking for the same kind of gap somewhere else:
- The connector, for assumptions only this terminal had shown it: device numbers, refusal wording, retries, finding terminals without a serial, large logs, two terminals on one PC. Its own post.
- The setup screens: a phantom link address, a serial nobody could read off the network, nowhere to change an address, status lines that were wrong. Its own post.
- What was still left: support's own add screen, the wording for adding a terminal twice, the office PC's search, "Test the connection", and a clock warning.
Their fixes went to staging and then to main in two promotions, one per repository, after each one's checks.
One of those checks went red with every test green: 11,700 test runs, no failures, then "artifact storage quota has been hit" while saving a small timing file. Sixty-one old connector test builds held 1.3 of the 1.5 GB. They were deleted; the quota is recounted hours later, so the next runs stayed red for the same reason. A job's colour is not its result.
Evening: the clock
Nobody could stand in front of the terminal again that day, and its set-clock command is not public. So the clock was read from the outside: punch time against arrival time, for punches read live. About a minute behind. Reading a clock you cannot touch has the method.
What the order says
The protocol fix was about forty lines. Getting to it took a check button, a crash fix, a hidden window, a wrong address, a wrong first theory and a laptop on the right network. Getting it to every office took a release path that checks its own output. If there is one lesson, it is that the time goes into everything around the bug, and that is where most of the fixes from the audits ended up.