Skip to content

docs(status): note the window the age cannot cover, and read better inside it - #8

Merged
impuls42 merged 1 commit into
mainfrom
feat/status-staleness-followup
Aug 2, 2026
Merged

docs(status): note the window the age cannot cover, and read better inside it#8
impuls42 merged 1 commit into
mainfrom
feat/status-staleness-followup

Conversation

@impuls42

@impuls42 impuls42 commented Aug 2, 2026

Copy link
Copy Markdown
Member

Follow-up to #7, which merged before these review points were addressed. Same three changes, rebased onto the merged main.

The window the age cannot cover

Review raised a case this module cannot defend against, and it is worth writing down rather than leaving to be rediscovered.

The agent's MQTT will is fixed when its connection opens and the broker holds it, so a fault learned during that session never reaches it. Agent connects while the tape is fine → a print an hour later finds the tape gone and correctly publishes media_ok: false → agent is killed → the broker publishes the older, healthier reading over the newer one, and this page renders DISCONNECTED with a stale-healthy detail line.

Nothing here can detect it: retained MQTT v3.1.1 messages carry no publish timestamp. So the README note says where the recovery actually comes from rather than pretending to a fix — the agent restarts (Restart=always, RestartSec=5), seeds from its spool, which does hold the fault, and republishes. Seconds wide, not indefinite.

Worth being precise about what does not close it, since both were suggested: on_disconnect fires with no connection to publish on, and a SIGKILL runs no callback at all. Re-arming the will on reconnect (done in sengine-cloud/labelfab#13) bounds it by the reconnect interval rather than the process lifetime, but cannot touch a live session. The recovery path is now pinned by a test upstream rather than left as an argument.

Two nits

_ago's seen is annotated object, deliberately not str | None — it comes out of json.loads on a payload this process did not produce and can be any JSON type, so a narrow annotation would move the lie into the signature rather than remove it.

Under 10 seconds renders seen just now instead of seen 0s ago. That is the common case, since the page is usually looked at right after printing something.

Verified

49 tests on 3.12, 37 on a real 3.9.25 in Docker, ruff clean.

…nside it

Review raised a case the age rendering cannot defend against, and it is worth writing
down in both repos rather than leaving it to be rediscovered.

The agent's MQTT will is fixed when its connection opens and the broker holds it, so a
fault learned during that session never reaches it. If the agent is then killed, the
broker publishes the older, healthier reading over the newer one and this page renders
DISCONNECTED with a stale-healthy detail line. Nothing here can detect it -- retained
MQTT v3.1.1 messages carry no publish timestamp -- so the note says where the recovery
actually comes from: the agent restarts on a 5s systemd timer, seeds from its spool,
which does have the fault, and republishes.

Two review nits while here. `seen` is annotated `object` rather than `str | None`,
because it comes out of json.loads on a payload this process did not produce and can be
any JSON type; annotating it narrowly would move the lie into the signature. And under
10 seconds now reads "seen just now" instead of "seen 0s ago" -- that is the common
case, since the page is usually looked at right after printing something.
@impuls42
impuls42 merged commit c0e76f9 into main Aug 2, 2026
1 check passed
@impuls42
impuls42 deleted the feat/status-staleness-followup branch August 2, 2026 14:45
impuls42 added a commit that referenced this pull request Aug 2, 2026
The Machines page now says how old the printer's report is, not just what it said
(#7, #8). Pairs with labelfab 0.3.0, which publishes device_seen_at; against an older
agent that omits the field the page renders exactly as it did before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant