Public: anyone can read this; the crew can change it.

A pure step says when a clog starts and when it clears, once each, across readings #6527

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

I added `clogStep(prev, reading, now)` in `src/flow/clog_watch.ts`. It returns `{ state, event }` (plus `since` on a clear), so a clog gives one `started` and one `cleared`. The type check and the 5 new tests pass; I did not run the rest of the suite, since the forge runs the whole check on push.

shipped production is serving it deploy fc82d1a

opened this

I added clogStep(prev, reading, now) in src/flow/clog_watch.ts. It returns { state, event } (plus since on a clear), so a clog gives one started and one cleared. The type check and the 5 new tests pass; I did not run the rest of the suite, since the forge runs the whole check on push.

  • Reading: a readonly string[] of reasons, empty when nothing is clogged. The issue didn't give a type, so this is my choice.
  • Start: the first non-empty reading emits started and sets state to { since: now, firstReasons }.
  • Stands: further non-empty readings emit nothing and keep since and firstReasons. A non-empty reading also resets the quiet count.
  • Clear: the second quiet reading in a row emits cleared with since set to the start time and state back to null. A single quiet reading changes nothing visible.
  • Restart: after a clear, the next non-empty reading emits a fresh started.

To count quiet readings without any state outside the step, state carries an optional quiet count. It only appears after the first quiet reading, so a freshly started state is exactly { since, firstReasons }.

Nothing calls clogStep yet. Wiring it to the notification and the clear note is for the other issues under #5930.

The tests are in test/flow-clog-watch.test.ts. They cover start, stand, one quiet reading, two quiet readings and restart.

Closes #6518

commented

I added clogStep(prev, reading, now) in src/flow/clog_watch.ts. It returns { state, event } (plus since on a clear), so a clog gives one started and one cleared. The type check and the 5 new tests pass; I did not run the rest of the suite, since the forge runs the whole check on push.

  • Reading: a readonly string[] of reasons, empty when nothing is clogged. The issue didn't give a type, so this is my choice.
  • Start: the first non-empty reading emits started and sets state to { since: now, firstReasons }.
  • Stands: further non-empty readings emit nothing and keep since and firstReasons. A non-empty reading also resets the quiet count.
  • Clear: the second quiet reading in a row emits cleared with since set to the start time and state back to null. A single quiet reading changes nothing visible.
  • Restart: after a clear, the next non-empty reading emits a fresh started.

To count quiet readings without any state outside the step, state carries an optional quiet count. It only appears after the first quiet reading, so a freshly started state is exactly { since, firstReasons }.

Nothing calls clogStep yet. Wiring it to the notification and the clear note is for the other issues under #5930.

The tests are in test/flow-clog-watch.test.ts. They cover start, stand, one quiet reading, two quiet readings and restart.

Approved

Approved. This is the pure-step slice of #5930 that #6518 asked for. The logic is correct: start fires once, further reasons stand without repeating, two quiet readings in a row clear it with the start time, and a new clog after a clear starts again. It has no I/O and no new dependency, and the module is small. The five tests cover each transition and would fail without the code. The preview has nothing to show yet, because nothing calls clogStep. That is stated in the description and is the scope of this issue. Next two things: (1) wire it to the home and /boards alarm line and the single owner notification, which also makes it reachable from the feed, the MCP and src/tty.ts, with a README line on how to use it. (2) Add a test that pins a restarted state to exactly {since, firstReasons} after a quiet-then-reason sequence, so the stray quiet field cannot leak back.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs