Skip to content
quarry View Ticket
Login

View Ticket

Server errors: capture in a ring, surface on /fleet, notify on first sighting

Fixed2276e92f75d0c2a472fb1c087422132f80a5c88fCreated 103.2 days agoUpdated 67.9 days ago
Description2026-08-19 18:24:29
Today's state: every 500 writes its real error to stderr and shows the reader "internal error". Correct hygiene, but stderr is where errors go to be unread — on the dev box it is a file in /tmp interleaved with ingest chatter. Every 500 found today (the fleet template error, the fts corruption) was found by a HUMAN hitting the page and reporting a screenshot. The fleet page says "ok" while the web layer burns.

## Design, in quarry's own idioms

**1. Capture: one seam.** Both funnels already exist — web's fail() default case and the API router's 500 branch — plus a new recovery middleware for panics (today a handler panic is Go's default: stack to stderr, connection dropped, no record). All three report into an in-process error journal: a bounded ring (say 500 entries) of {first/last seen, count, surface, path, message}, DEDUPED BY MESSAGE so a hot loop is one row with a count, not a flood. Alongside it, fossil's exact mechanism for durability: an --errorlog file, appended plainly, rotated by size. No new storage tier; the ring is process state and honest about it.

**2. See: the fleet page.** An Errors panel beside ingest health — same badge idiom (red count when nonzero), rows newest-first with count and last-seen, admin-gated like the rest of /fleet. The health JSON gains errors{total, distinct, lastAt} so the API sees what the page sees.

**3. React: the notify plane.** fireNotify already reaches the companion; emit quarry-error on FIRST SIGHTING of a new error signature (dedup makes this cheap), never per occurrence — an alert channel that repeats itself gets muted. Webhook subscribers get the same event.

**4. Ticket: a hand on the trigger, not an automaton.** Auto-filing tickets from errors is how a tracker fills with 40 duplicates of one bad deploy. Instead: each row on the Errors panel carries "file ticket", prefilled (title = the message, body = path/surface/count/ first-last seen, subsystem guessed from the surface). One click, human judgment, no noise.

**Non-goals:** external observability vendors (the forge should not need one to see itself); stack traces in the ring (the message and path locate the code; traces stay in the errorlog).

## Order

1. Recovery middleware + ring + the two funnel hookups (small, the value core). 2. Fleet panel + health JSON. 3. notify event. 4. File-ticket button.

2026-08-19 18:53:02

Built (1412e9e4), order items 1–3:

  • internal/errlog: bounded ring (500 signatures), DEDUPED BY MESSAGE — a hot loop is one row with a count. Eviction removes the signature least recently SEEN, so an error still happening is never displaced by one that stopped. OnFirst hook fires exactly once per signature.
  • All three funnels report: web fail()'s default case, the API router's 500 branch, and a new recovery middleware wrapping the whole handler tree — a panic is now a recorded entry and a clean 500 instead of a dropped connection and an unread stack (the stack still goes to the log).
  • /fleet: "N server errors" badge in the summary line and a Server errors table (last seen, count, surface, path, message). fleet.status carries errors[] and errorTotal, so the API sees what the page sees.
  • Notify: quarry-error fires on a signature's FIRST sighting only, wired at the composition root where the notify plane is configured.

End-to-end test drives a real panic through a real server and asserts the clean 500, the journal entry, and the row on /fleet.

Remaining (order item 4 + durability): the per-row "file ticket" button (needs the new-ticket form to accept prefill), and the --errorlog append file for post-restart forensics.

2026-08-19 19:33:52

Remainders landed in e374d161; the whole design is now built.

  • --errorlog FILE: one plain line per OCCURRENCE (the ring dedupes for the UI; the file is forensics and wants every event), appended best-effort so a full disk cannot turn error recording into error throwing. Survives restarts, which the ring by design does not.
  • --tracker REPO designates the forge's own tracker; each journal row on /fleet gains "file ticket" — a deep link into the new-ticket form prefilled with title, subsystem, and a body carrying surface, path, count and last-seen. No tracker designated, no buttons drawn: there is nowhere honest to send them.
  • The new-ticket form accepts its fields as query parameters generally, so any surface that knows about a problem can hand a human a half-written ticket. The values pass through template escaping like all text.

Live wiring: serve now runs with --tracker quarry and --errorlog under the data dir. Human judgment stays on the trigger, per the design — nothing auto-files.