Feedback Signals

Feedback signals (a red main, an error in a deployed app, a failing monitor) enter Cloche through one HTTP endpoint on the web console listener. Cloche accepts signals; it never fetches them. Whoever owns a source writes a small adapter that turns its events into the format below and posts them with curl. There is no CLI command for sending.

Sending a signal

POST /api/projects/{name}/signals
Authorization: Bearer <token>
Content-Type: application/json
Field Required Meaning
source yes Who is reporting: ci-main, sentry. Letters, digits, ., _, -; up to 128 chars.
key yes Your uniqueness key. Two signals with the same source and key are the same problem. Up to 512 bytes.
severity yes low, high, or urgent.
title yes One line, up to 300 bytes.
evidence no Text: log lines, failing tests, metric values. Up to 64 KiB.
domain no A domain name (same charset as source, up to 64 chars). Becomes a task label, and wakes the DRA of that name if there is one.
curl -X POST "http://localhost:8080/api/projects/my-project/signals" \
  -H "Authorization: Bearer $(cloche signals token)" \
  -H "Content-Type: application/json" \
  -d '{"source": "ci-main", "key": "main-red", "severity": "urgent",
       "title": "main is red: 3 tests fail in internal/host",
       "evidence": "--- FAIL: TestRunner ..."}'
Response Meaning
202 {"id": <n>, "coalesced": <bool>} Stored.
400 Unknown field, unknown severity, or a missing required field; the message names the problem.
401 Missing or wrong token, or an unknown project (indistinguishable on purpose).
413 Request body over 128 KiB.
429 Handler limits reached (see below); the signal is stored but not handled.

The token

Each project has its own bearer token, generated on first use and stored under ~/.config/cloche/signal-tokens/ (mode 0600). cloche signals token prints it; cloche signals token --rotate replaces it, and the old one stops working at once (no daemon restart). A project with no token yet rejects every request. Treat it like a password — see the Safety Guide.

What happens to a signal

The daemon stores the signal, answers the request, then runs the host workflow handle-notification with the signal as input.

  • Coalescing. If the same source and key arrive while a handler for them is still running, the signal joins that run ("coalesced": true) instead of starting another, so a burst of 500 identical errors is one handler run. A signal arriving after the handler finishes starts a new run.
  • Limits. At most 8 handler runs at once, and 30 started per hour for one project and source. Signals that join a running handler don’t count.
  • Retention. Stored signals are kept for 30 days; the daemon deletes older ones when it starts.
  • Visibility. Each handler run is recorded, so a failed one shows in cloche list as a failed handle-notification run.

The workflow reads the signal from KV keys:

Key Value
signal_source, signal_key, signal_title, signal_evidence, signal_domain The posted fields
signal_severity low, high, or urgent
signal_priority Severity as a tracker priority: urgent → 0, high → 1, low → 3
signal_json The whole object
signal_count 1, rising as identical signals join the run

The default handle-notification

A built-in workflow that does the least useful thing — no thresholds, no muting, no model step:

  1. lookup — ask update-task for an open task carrying this source and key.
  2. Found — comment adds the occurrence to that task.
  3. Not found — create calls create-task with the title and evidence unchanged, priority from the severity, the domain (if any) as a label, and the source and key recorded so the next occurrence finds the task.

Both go through whichever tracker module project.cloche binds. To change the behaviour, define your own host workflow named handle-notification in .cloche/; it overrides the built-in. For example, add a prompt step to filter noise or rewrite the task.

Work that needs code changes always ends as a tracker task, so it goes through the normal loop: budget, tests, and review. A signal never stops or pauses a run.

Signal sources that ship with Cloche

Repeated failure. When a task’s failed attempt reaches the repeat-failure threshold ([attention] repeat_failure_threshold, default 3 — the point “Needs you” flags it), the daemon posts a signal to itself: source cloche, severity high, key <task id>:<failed step>, title “Find out why task T keeps failing at step S”. Only the attempt that reaches the threshold signals, so further failures don’t repeat it.

check-main. The Cloche repository’s own .cloche/host.cloche has a check-main host workflow you can copy: it runs the full test suite against main’s HEAD in a container on a timer and, on red, posts an urgent signal (source ci-main, key main-red) with the failing tests and the commit range since the last green check. Start it once with cloche run check-main; it loops. CLOCHE_CHECK_MAIN_INTERVAL (seconds, default 21600) sets the period.