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
Check · Review · Land · Live done — Landed and live in production.
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 aa26afa
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
startedAttodetectedAt. - Time to clear: minutes from
detectedAttoclearedAt. - Stranded dollars: a "Stranded at peak" line, shown only when
strandedUsdis 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
reasonsis 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
durationhelper 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. 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.
This adds
clogNoteinsrc/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.tspass, andbun x tsc --noEmitis clean. I didn't run the rest of the suite.What the note says
;. With no reasons it reads "not recorded".startedAttodetectedAt.detectedAttoclearedAt.strandedUsdis above zero.Durations
Choices I made
reasonsis a list of strings and the three times are epoch milliseconds.durationhelper 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