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

A pure function writes the note posted when a clog clears: cause, time to detect, time to clear, stranded dollars #6539

Merged opened this

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

Merged

This adds `clogNote` in `src/flow/clog_note.ts`, a pure function that writes the note posted when a clog clears. Nothing calls it yet, so it isn't reachable from the feed or the MCP. The issue scoped this to the function and its test.

shipped production is serving it deploy bbd5a0b

opened this

This adds clogNote in src/flow/clog_note.ts, a pure function that writes the note posted when a clog clears. Nothing calls it yet, so it isn't reachable from the feed or the MCP. The issue scoped this to the function and its test.

The five new tests in test/flow-clog-note.test.ts pass, and bun x tsc --noEmit is clean. I didn't run the rest of the suite.

What the note says

  • Cause: one line, the reasons joined with ; . With no reasons it reads "not recorded".
  • Time to detect: minutes from startedAt to detectedAt.
  • Time to clear: minutes from detectedAt to clearedAt.
  • Stranded dollars: a "Stranded at peak" line, shown only when strandedUsd is above zero.

Durations

  • They read in minutes up to and including 90, then in hours to one decimal ("2.5 h").
  • A negative or non-finite span reads "0 min".

Choices I made

  • The issue doesn't give the input types, so I assumed reasons is a list of strings and the three times are epoch milliseconds.
  • "Time to clear" runs from detection, not from the clog's start.
  • The function is exported with its small duration helper and has no new dependencies.

Left out: posting the note, and anything that decides when a clog has cleared.

To try it, run bun test test/flow-clog-note.test.ts.

Closes #6519

commented

This adds clogNote in src/flow/clog_note.ts, a pure function that writes the note posted when a clog clears. Nothing calls it yet, so it isn't reachable from the feed or the MCP. The issue scoped this to the function and its test.

The five new tests in test/flow-clog-note.test.ts pass, and bun x tsc --noEmit is clean. I didn't run the rest of the suite.

What the note says

  • Cause: one line, the reasons joined with ; . With no reasons it reads "not recorded".
  • Time to detect: minutes from startedAt to detectedAt.
  • Time to clear: minutes from detectedAt to clearedAt.
  • Stranded dollars: a "Stranded at peak" line, shown only when strandedUsd is above zero.

Durations

  • They read in minutes up to and including 90, then in hours to one decimal ("2.5 h").
  • A negative or non-finite span reads "0 min".

Choices I made

  • The issue doesn't give the input types, so I assumed reasons is a list of strings and the three times are epoch milliseconds.
  • "Time to clear" runs from detection, not from the clog's start.
  • The function is exported with its small duration helper and has no new dependencies.

Left out: posting the note, and anything that decides when a clog has cleared.

To try it, run bun test test/flow-clog-note.test.ts.

Approved

Approved. This is a pure module with no I/O, input, secret, dependency or dead code. It does what the issue scoped: cause, time to detect, time to clear and stranded dollars. The edge cases (negative spans, no reasons, zero dollars, the 90-minute boundary) are tested and would fail without the code. Nothing calls it yet, so there is no page, terminal or MCP door to try in the preview. That matches the scope, but it is not done in the VISION sense until it is called. Next: (1) add the caller that posts this note when the flow clears a clog, with a test that the note lands on the clearing path. (2) Make duration module-private unless a second caller needs it, and trim reasons to a sane length and count when a real caller feeds it, because the note is posted as markdown and the reasons are not escaped.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs