feat(sources): add Sable DNS source #9

Manually merged
jfro merged 2 commits from feat/2-sable into main 2026-11-01 18:31:29 +00:00
Owner

Closes #2

Adds a Sable DNS source (sable) with both roles, :problems and :context. It reads Sable's public GET /api/v1/health and calls Sable's MCP server (POST /mcp, one JSON-RPC tools/call per request, Authorization: Bearer, MCP-Protocol-Version: 2025-06-18). Only read-only tools that Sable turns on by default are used. Written against Sable's source at bc7adf2 (Oct 30): internal/web/server.go, mcp.go, mcp_advanced_tools.go, mcp_server_tools.go.

Why MCP and not just the REST API: block-list health, per-node cluster problems, and Insights findings are only exposed through the MCP tools. /api/v1/policy has counts but no health.

What it reports

  • server :availability: the health endpoint's status, with version, config revision, and query-log drop/write-error counts as facts
  • block_list:<name> :incident (list_block_lists, blocking.read): failing/warning when the last update failed. Why is Sable's own detail, e.g. download …: HTTP 503 (last successful update …)
  • cluster_node:<name> :availability (get_cluster_status, cluster.read): serious if not online (why: last contact), warning if it has open problems (why: Sable's problem text), pending while lag > 0. Not clustered: no cluster signals
  • cluster:rollout :incident: serious when a rolling update has an error, naming the failed node
  • finding:<id> :insight (list_findings over the last day, logs.read): findings with tone attention, or attention + notice if chosen. Finding IDs are Sable's stable kind:subject ids. Block-list findings are left out because the block-list signals already cover them

A tool that comes back as a tool error (token lacks the grant, or turned off in Sable) is skipped: its signals are left out, it's logged at info, and the connection test names it. A 404 from /mcp fails the poll with "turn it on in Integrations → MCP Server", and 401/403/redirect/JSON-RPC errors/transport errors each get their own message.

Settings

URL (a pasted /dns-query suffix is dropped), API token (secret), the usual TLS trust fields, and Insights findings to report (needs attention / attention and notices / none). Polls every 2 minutes by default. The setup guide lists the grants: blocking.read, cluster.read, logs.read, zones.read, metrics.read.

Context queries

lookup (resolve a name through Sable and say where the answer came from), check_domain (blocked? which rule and list), stats (get_stats for a range, top 10 blocked), and findings (every finding for a range, capped at 50). context_summary: e.g. Sable 1.1.0, 2 block lists, 3 nodes, 2 online, 1 behind, 1 with problems. list_findings skipped: Insights is turned off.

Logging

Failed tool calls log Sable: MCP tool <name> on <url> failed after N ms: <reason>, a failed poll logs the URL and duration, skipped tools log at info, and successful polls log the duration and the skipped tools at debug.

Screenshots

Settings form with example values, desktop and 390px:

Sable settings, desktop

Sable settings, 390px

(The 390px header overflow is the same one on main, passed to the gap audit.)

Testing

  • test/lamplighter/sources/sable_test.exs: 21 tests with Req.Test stubs and fixtures shaped after Sable's handlers (a healthy and a failing block list; a 3-node cluster with one offline, one behind with a problem; attention, notice, positive, and block-list findings). Covers skipped tools, MCP off (404), 401, a JSON-RPC error, a transport error, the request headers and arguments, and every context query
  • mix precommit: 627 tests pass, no warnings

Not yet run against a live Sable; the shapes come from its source, not a running instance.

Closes #2 Adds a **Sable DNS** source (`sable`) with both roles, `:problems` and `:context`. It reads Sable's public `GET /api/v1/health` and calls Sable's MCP server (`POST /mcp`, one JSON-RPC `tools/call` per request, `Authorization: Bearer`, `MCP-Protocol-Version: 2025-06-18`). Only read-only tools that Sable turns on by default are used. Written against Sable's source at `bc7adf2` (Oct 30): `internal/web/server.go`, `mcp.go`, `mcp_advanced_tools.go`, `mcp_server_tools.go`. Why MCP and not just the REST API: block-list health, per-node cluster problems, and Insights findings are only exposed through the MCP tools. `/api/v1/policy` has counts but no health. ### What it reports - `server` `:availability`: the health endpoint's `status`, with version, config revision, and query-log drop/write-error counts as facts - `block_list:<name>` `:incident` (`list_block_lists`, `blocking.read`): **failing/warning** when the last update failed. *Why* is Sable's own detail, e.g. `download …: HTTP 503 (last successful update …)` - `cluster_node:<name>` `:availability` (`get_cluster_status`, `cluster.read`): **serious** if not `online` (why: last contact), **warning** if it has open problems (why: Sable's problem text), **pending** while `lag > 0`. Not clustered: no cluster signals - `cluster:rollout` `:incident`: **serious** when a rolling update has an `error`, naming the failed node - `finding:<id>` `:insight` (`list_findings` over the last day, `logs.read`): findings with tone `attention`, or `attention` + `notice` if chosen. Finding IDs are Sable's stable `kind:subject` ids. Block-list findings are left out because the block-list signals already cover them A tool that comes back as a tool error (token lacks the grant, or turned off in Sable) is **skipped**: its signals are left out, it's logged at info, and the connection test names it. A 404 from `/mcp` fails the poll with "turn it on in Integrations → MCP Server", and 401/403/redirect/JSON-RPC errors/transport errors each get their own message. ### Settings URL (a pasted `/dns-query` suffix is dropped), API token (secret), the usual TLS trust fields, and **Insights findings to report** (needs attention / attention and notices / none). Polls every 2 minutes by default. The setup guide lists the grants: `blocking.read, cluster.read, logs.read, zones.read, metrics.read`. ### Context queries `lookup` (resolve a name through Sable and say where the answer came from), `check_domain` (blocked? which rule and list), `stats` (`get_stats` for a range, top 10 blocked), and `findings` (every finding for a range, capped at 50). `context_summary`: e.g. `Sable 1.1.0, 2 block lists, 3 nodes, 2 online, 1 behind, 1 with problems. list_findings skipped: Insights is turned off`. ### Logging Failed tool calls log `Sable: MCP tool <name> on <url> failed after N ms: <reason>`, a failed poll logs the URL and duration, skipped tools log at info, and successful polls log the duration and the skipped tools at debug. ### Screenshots Settings form with example values, desktop and 390px: ![Sable settings, desktop](https://git.knope.dev/attachments/875fdfef-13f1-4fa1-b3aa-abf9ea5ac146) ![Sable settings, 390px](https://git.knope.dev/attachments/1643f375-678c-4727-b025-5f6ea3b5d77c) (The 390px header overflow is the same one on `main`, passed to the gap audit.) ### Testing - `test/lamplighter/sources/sable_test.exs`: 21 tests with `Req.Test` stubs and fixtures shaped after Sable's handlers (a healthy and a failing block list; a 3-node cluster with one offline, one behind with a problem; attention, notice, positive, and block-list findings). Covers skipped tools, MCP off (404), 401, a JSON-RPC error, a transport error, the request headers and arguments, and every context query - `mix precommit`: 627 tests pass, no warnings Not yet run against a live Sable; the shapes come from its source, not a running instance.
jfro added this to the v1.0 milestone 2026-11-01 16:43:35 +00:00
feat(sources): add Sable DNS source
All checks were successful
CI / test (pull_request) Successful in 56s
11a237be16
Reads Sable's public health endpoint and calls its read-only MCP tools
(list_block_lists, get_cluster_status, list_findings) with a bearer API
token. Reports block lists that fail to update, cluster nodes that are
offline, have open problems, or are behind, a failed rolling update, and
Insights findings Sable marks as needing attention (optionally notices).
A tool the token lacks a grant for is skipped and named in the
connection test. As a context source it answers lookup, check_domain,
stats, and findings. Logs failed calls with the tool, URL, and duration.

Closes #2
jfro force-pushed feat/2-sable from 11a237be16
All checks were successful
CI / test (pull_request) Successful in 56s
to 2caabbb4d0
All checks were successful
CI / test (pull_request) Successful in 25s
2026-11-01 17:52:49 +00:00
Compare
Author
Owner

Re-review of #9 at 2caabbb (Nye)

F5 fixed. An "unknown tool" JSON-RPC error (-32602, matching Sable's internal/web/mcp.go:167 "unknown tool: ") is now kept as {:skipped, ...} like a missing grant, so a Sable 1.5.x still reports block lists and findings and the poll doesn't fail. The "needs Sable 1.6 or newer" note for get_cluster_status is right: list_block_lists/list_findings are in v1.5.0, get_cluster_status first ships in v1.6.0. metrics.read is now in the token help.

  • mix precommit: 661 tests pass (C22); CI green; mergeable on current main.
  • My test/review/sable_old_version_test.exs passes.

Non-blocking: other -32602 errors (bad arguments) still surface as refusals, which is correct; for query tools on an old Sable the user gets "Sable: this Sable has no X; it needs Sable a newer version" — the wording "needs Sable a newer version" reads a little oddly; consider "needs a newer Sable". Ready to ship from my side.

Re-review of #9 at 2caabbb (Nye) F5 fixed. An "unknown tool" JSON-RPC error (-32602, matching Sable's internal/web/mcp.go:167 "unknown tool: <name>") is now kept as {:skipped, ...} like a missing grant, so a Sable 1.5.x still reports block lists and findings and the poll doesn't fail. The "needs Sable 1.6 or newer" note for get_cluster_status is right: list_block_lists/list_findings are in v1.5.0, get_cluster_status first ships in v1.6.0. metrics.read is now in the token help. - mix precommit: 661 tests pass (C22); CI green; mergeable on current main. - My test/review/sable_old_version_test.exs passes. Non-blocking: other -32602 errors (bad arguments) still surface as refusals, which is correct; for query tools on an old Sable the user gets "Sable: this Sable has no X; it needs Sable a newer version" — the wording "needs Sable a newer version" reads a little oddly; consider "needs a newer Sable". Ready to ship from my side.
jfro manually merged commit 74fe20a3bd into main 2026-11-01 18:31:29 +00:00
Sign in to join this conversation.
No description provided.