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

The forge pages the phone once when it has been draining for five minutes, and once when the drain ends #2497

Parked opened this
Closed without merging

The forge now pages the admin's notify URL once when it has been draining for more than five minutes, and once with "Recovered" when the drain ends. I ran tsc --noEmit and the notify, health and guard tests; they pass. I did not run the full bun test suite, which the forge's check will do on this push.

Notes

stopped parked by the crew deploy ebc9b8b

opened this

The forge now pages the admin's notify URL once when it has been draining for more than five minutes, and once with "Recovered" when the drain ends. I ran tsc --noEmit and the notify, health and guard tests; they pass. I did not run the full bun test suite, which the forge's check will do on this push.

What changed

  • Decision: src/crew/incidents.ts is pure. drainIncident(drainingSince, now) turns a drain past 5 minutes into one incident keyed by when it started. nextPage(current, paged) returns a page, a "Recovered", or nothing. Nothing from forge-guard (held, stuck, oom:*) or the vitals goes through it.
  • Sending: src/crew/notify.ts gains a page() step. It runs for admins with a notify URL, on its own timer (at most every minute, and every clockMs if that is shorter), so a drain is paged within a minute of its fifth rather than within the ten-minute clock.
  • Retry: A key counts as paged only after delivery succeeded. A page held back by the hourly cap or the backoff, or one the endpoint refused, is tried again on the next tick, and its Recovered is still sent afterwards. The page shares the existing hourly cap and backoff.
  • Boot: The first look at boot is silent, so a restart in a drain that was already paged does not page again.
  • Drain start time: health.drainingSince is new, set once in startDraining. ForgeHealth carries it as drainingSince.
  • Tests: Notifier.tick() lets a test drive the check with a fake clock. test/notify-drain.test.ts covers:
    • 6 minutes of draining sends one page and the end sends one Recovered;
    • a page the endpoint refuses (backoff) is sent on a later tick, and its Recovered is not lost;
    • a restart in a paged drain sends nothing;
    • a guard with stuck:r1 and drill causes past five minutes sends no page.
    • I did not write a test that fills the hourly cap itself.

Left out

  • Only admins are paged, and only through the notify URL they already set. There is no new setting and no new dependency.
  • Nothing is persisted. A drain is in-memory per process and never un-drains in production, so "Recovered" mainly matters if draining is ever reversed. The boot baseline covers restarts.

Try it Run bun test test/notify-drain.test.ts.

Closes #2491

commented

The forge now pages the admin's notify URL once when it has been draining for more than five minutes, and once with "Recovered" when the drain ends. I ran tsc --noEmit and the notify, health and guard tests; they pass. I did not run the full bun test suite, which the forge's check will do on this push.

What changed

  • Decision: src/crew/incidents.ts is pure. drainIncident(drainingSince, now) turns a drain past 5 minutes into one incident keyed by when it started. nextPage(current, paged) returns a page, a "Recovered", or nothing. Nothing from forge-guard (held, stuck, oom:*) or the vitals goes through it.
  • Sending: src/crew/notify.ts gains a page() step. It runs for admins with a notify URL, on its own timer (at most every minute, and every clockMs if that is shorter), so a drain is paged within a minute of its fifth rather than within the ten-minute clock.
  • Retry: A key counts as paged only after delivery succeeded. A page held back by the hourly cap or the backoff, or one the endpoint refused, is tried again on the next tick, and its Recovered is still sent afterwards. The page shares the existing hourly cap and backoff.
  • Boot: The first look at boot is silent, so a restart in a drain that was already paged does not page again.
  • Drain start time: health.drainingSince is new, set once in startDraining. ForgeHealth carries it as drainingSince.
  • Tests: Notifier.tick() lets a test drive the check with a fake clock. test/notify-drain.test.ts covers:
    • 6 minutes of draining sends one page and the end sends one Recovered;
    • a page the endpoint refuses (backoff) is sent on a later tick, and its Recovered is not lost;
    • a restart in a paged drain sends nothing;
    • a guard with stuck:r1 and drill causes past five minutes sends no page.
    • I did not write a test that fills the hourly cap itself.

Left out

  • Only admins are paged, and only through the notify URL they already set. There is no new setting and no new dependency.
  • Nothing is persisted. A drain is in-memory per process and never un-drains in production, so "Recovered" mainly matters if draining is ever reversed. The boot baseline covers restarts.

Try it Run bun test test/notify-drain.test.ts.

commented

Parked by the crew: the check failed ("a site admin with a read-only token gets the shape; others get the short one") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs