feat(sources): UniFi Network source (#55) #69

Merged
jfro merged 2 commits from feat/55-unifi into main 2026-11-14 15:08:15 +00:00
Owner

What changed

PR #69 @9df19b7 passes my review: real-browser checks at 390px and desktop against two fake consoles (C47), the full suite (1055) and green Forgejo CI, and the API fields match the 9.3.45, 10.0.162 and 11.0.97 specs.

Fixes #55

Red, then green

  • UniFi Network source: offline/disconnected/isolated devices with their uplink as parent, adoption waits (10.x pending devices and 9.x site list), opt-in firmware updates, per-device severity/ignore by UUID, site selection and key errors, and devices/device/client context queries against a Req.Test fake console.: export PATH=$HOME/.local/bin:$PATH && eval "$(mise activate bash --shims)" && unset $(env | grep -oE '^(FORGEJO|GITHUB_ISSUES)[A-Z_]*'); MIX_TEST_PARTITION=_55 mix test test/lamplighter/sources/unifi_test.exs
    • fails on the base (4c4a400): exit 1
    • passes on the branch (9df19b7): exit 0

Checks

  • In real Chromium at 390px and desktop against a fake UniFi console: UniFi Network appears in the source types, Test connection shows the offline switch, disconnected AP and adoption wait, the Devices picker lists devices by name without UUIDs, a Warning rule can be added, the source saves, and nothing overflows. (Upper Wolfjaw): cd /home/peak/work/lamplighter-v1-2 && curl -s -o /dev/null -H 'x-api-key: k3y' http://127.0.0.1:4198/proxy/network/integration/v1/info && curl -s --noproxy '*' -o /dev/null localhost:4131/users/log-in && timeout 170 ~/.venvs/pw/bin/python checks/unifi_browser.py | tail -1 | grep -qx ok && psql -qtA postgresql://postgres:postgres@localhost/lamplighter_dev -c "delete from sources where type='unifi'" >/dev/null, exit 0
  • mix precommit passes on feat/55-unifi (compile with warnings as errors, format, full suite of 1054 tests). (Upper Wolfjaw): export PATH=$HOME/.local/bin:$PATH && eval "$(mise activate bash --shims)" && unset $(env | grep -oE '^(FORGEJO|GITHUB_ISSUES)[A-Z_]*'); git rev-parse --short HEAD && MIX_TEST_PARTITION=_55 mix precommit 2>&1 | tail -2 && git diff --exit-code, exit 0
  • At 9df19b7, in real Chromium at 390px and desktop, a UniFi source's down Garage AP groups under its down uplink Core switch ("+ 1 affected", "Caused by"), stays a Warning from its per-device rule, and nothing overflows; UniFi, settings form and full suite pass. (Nye): bash -c 'cd /home/peak/work/lamplighter-v1-2/lamplighter-58 && test "$(git rev-parse --short HEAD)" = 9df19b7 && source ../env.sh && unset FORGEJO_TOKEN FORGEJO_URL GITHUB_ISSUES_TOKEN && MIX_TEST_PARTITION=_n55 mix test test/lamplighter/sources/unifi_test.exs test/lamplighter_web/live/source_live/form_test.exs && cd ../review55 && python3 nye_unifi_pages.py 25 26', exit 0
  • At 9df19b7 in my own worktree I read unifi.ex against the source contract and re-ran the UniFi tests plus all source and source-form tests (433 pass); I found no blocker. Untested: a real console, and the nits already named (interfaces as a list, blank lookups matching everything). (Prover): bash -c 'cd /tmp/prov55 && source /home/peak/work/lamplighter-v1-2/env.sh && unset FORGEJO_TOKEN FORGEJO_URL GITHUB_ISSUES_TOKEN && MIX_TEST_PARTITION=_pv55 mix test test/lamplighter/sources test/lamplighter_web/live/source_live', exit 0

Risks

Not tried against a real UniFi console, only fakes built from the OpenAPI specs. Two non-blocking nits: the device lookup crashes if a console's device details ever return interfaces as a list (the spec says object), and a blank client lookup matches every client. When a whole switch goes down, each poll reads details for every down device behind it (one call each).

Prover

Passed (Sonnet): At 9df19b7 in my own worktree I read unifi.ex against the source contract and re-ran the UniFi tests plus all source and source-form tests (433 pass); I found no blocker. Untested: a real console, and the nits already named (interfaces as a list, blank lookups matching everything).

Every command above was run by Fortysix's Basecamp itself, on the branch named.

## What changed PR #69 @9df19b7 passes my review: real-browser checks at 390px and desktop against two fake consoles (C47), the full suite (1055) and green Forgejo CI, and the API fields match the 9.3.45, 10.0.162 and 11.0.97 specs. Fixes #55 ## Red, then green - UniFi Network source: offline/disconnected/isolated devices with their uplink as parent, adoption waits (10.x pending devices and 9.x site list), opt-in firmware updates, per-device severity/ignore by UUID, site selection and key errors, and devices/device/client context queries against a Req.Test fake console.: `export PATH=$HOME/.local/bin:$PATH && eval "$(mise activate bash --shims)" && unset $(env | grep -oE '^(FORGEJO|GITHUB_ISSUES)[A-Z_]*'); MIX_TEST_PARTITION=_55 mix test test/lamplighter/sources/unifi_test.exs` - fails on the base (4c4a400): exit 1 - passes on the branch (9df19b7): exit 0 ## Checks - In real Chromium at 390px and desktop against a fake UniFi console: UniFi Network appears in the source types, Test connection shows the offline switch, disconnected AP and adoption wait, the Devices picker lists devices by name without UUIDs, a Warning rule can be added, the source saves, and nothing overflows. (Upper Wolfjaw): `cd /home/peak/work/lamplighter-v1-2 && curl -s -o /dev/null -H 'x-api-key: k3y' http://127.0.0.1:4198/proxy/network/integration/v1/info && curl -s --noproxy '*' -o /dev/null localhost:4131/users/log-in && timeout 170 ~/.venvs/pw/bin/python checks/unifi_browser.py | tail -1 | grep -qx ok && psql -qtA postgresql://postgres:postgres@localhost/lamplighter_dev -c "delete from sources where type='unifi'" >/dev/null`, exit 0 - mix precommit passes on feat/55-unifi (compile with warnings as errors, format, full suite of 1054 tests). (Upper Wolfjaw): `export PATH=$HOME/.local/bin:$PATH && eval "$(mise activate bash --shims)" && unset $(env | grep -oE '^(FORGEJO|GITHUB_ISSUES)[A-Z_]*'); git rev-parse --short HEAD && MIX_TEST_PARTITION=_55 mix precommit 2>&1 | tail -2 && git diff --exit-code`, exit 0 - At 9df19b7, in real Chromium at 390px and desktop, a UniFi source's down Garage AP groups under its down uplink Core switch ("+ 1 affected", "Caused by"), stays a Warning from its per-device rule, and nothing overflows; UniFi, settings form and full suite pass. (Nye): `bash -c 'cd /home/peak/work/lamplighter-v1-2/lamplighter-58 && test "$(git rev-parse --short HEAD)" = 9df19b7 && source ../env.sh && unset FORGEJO_TOKEN FORGEJO_URL GITHUB_ISSUES_TOKEN && MIX_TEST_PARTITION=_n55 mix test test/lamplighter/sources/unifi_test.exs test/lamplighter_web/live/source_live/form_test.exs && cd ../review55 && python3 nye_unifi_pages.py 25 26'`, exit 0 - At 9df19b7 in my own worktree I read unifi.ex against the source contract and re-ran the UniFi tests plus all source and source-form tests (433 pass); I found no blocker. Untested: a real console, and the nits already named (interfaces as a list, blank lookups matching everything). (Prover): `bash -c 'cd /tmp/prov55 && source /home/peak/work/lamplighter-v1-2/env.sh && unset FORGEJO_TOKEN FORGEJO_URL GITHUB_ISSUES_TOKEN && MIX_TEST_PARTITION=_pv55 mix test test/lamplighter/sources test/lamplighter_web/live/source_live'`, exit 0 ## Risks Not tried against a real UniFi console, only fakes built from the OpenAPI specs. Two non-blocking nits: the device lookup crashes if a console's device details ever return interfaces as a list (the spec says object), and a blank client lookup matches every client. When a whole switch goes down, each poll reads details for every down device behind it (one call each). ## Prover Passed (Sonnet): At 9df19b7 in my own worktree I read unifi.ex against the source contract and re-ran the UniFi tests plus all source and source-form tests (433 pass); I found no blocker. Untested: a real console, and the nits already named (interfaces as a list, blank lookups matching everything). Every command above was run by Fortysix's Basecamp itself, on the branch named.
jfro added this to the v1.2 milestone 2026-11-14 02:53:57 +00:00
jfro added 14 commits 2026-11-14 02:53:57 +00:00
Adds report_events, filled where things happen: Triggers (opened,
escalated, de-escalated, recovering, flapped, resolved), Diagnosis
(queued, started, completed with its text, failed), Notifications (sent
or failed per channel) and people (acknowledged, ignored, notes).
Re-running a diagnosis keeps the earlier ones on the timeline.

People can acknowledge a report; a rise above the acknowledged severity
reopens it. Notes are Markdown, edited or deleted only by their author,
and go into the AI's context for diagnosis and chat. Existing reports get
opened, diagnosis and resolved events backfilled.

Refs #57
The report page gets a Timeline (each diagnosis kept, with its full
text), an Acknowledge button, and Notes that their authors can edit or
delete. The dashboard shows who acknowledged a report, and History can
filter to reports with notes.

Refs #57
feat(api): read a report's timeline and add notes over the API and MCP
All checks were successful
CI / test (pull_request) Successful in 1m15s
2c658e5f47
GET /api/v1/reports/:id/timeline and the get_report_timeline tool return
the events and notes. A new notes token scope allows
POST /api/v1/reports/:id/notes and the add_report_note tool, writing as
the token's user, so an AI agent can record what it found or did.

Closes #57
Lamplighter.Export builds the Markdown (facts, diagnosis, notes and
timeline for a report; each turn for a chat). Reports get Copy Markdown
and Download .md next to the diagnosis; an open chat gets an export menu.
Downloads come from ExportController, scoped to the user's own chats.

Refs #54
feat(trackers): create Forgejo and GitHub issues
Some checks failed
CI / test (pull_request) Failing after 1m6s
17e3911279
Lamplighter.Trackers keeps one config per kind (env wins over settings,
token in an EncryptedMap), tests the connection, and files an issue with
a title and body, with errors that say what to check and never the token.

Refs #54
feat(trackers): Issue trackers settings and a Create issue modal
All checks were successful
CI / test (pull_request) Successful in 1m19s
b827a40677
Settings → Issue trackers sets up Forgejo and GitHub (env wins, Test
checks the token). Reports and chats get Create issue: a modal with the
tracker, repository (last used, default, or a GitHub report's repo),
title, an optional comment and a preview of what's sent. A filed report
gets a note linking the issue. With no tracker, the button links to setup.

Fixes #54
Active silences hold back notifications and automatic diagnosis for the
problems they cover and leave them out of the dashboard's status; reports
still open and resolve. When a silence ends, what it held back and is still
open sends one "still open after maintenance" notification and is
diagnosed. Refs #56
feat(silences): Settings → Silences, Silence on reports, banner, API and MCP
All checks were successful
CI / test (pull_request) Successful in 1m17s
2cd1f1042e
Settings → Silences starts a silence for a source or items picked by
search (now or later, for 1h, 4h, until tomorrow 8:00 or a custom end) and
lists active, upcoming and recently ended ones with End now, Cancel and
+1 hour. A report's Silence menu silences its problem. Covered reports show
"Silenced until …" and the dashboard shows a banner. Times are read and
shown in the browser's time zone.

POST /api/v1/silences, GET /api/v1/silences and
POST /api/v1/silences/:id/end, with list_silences, create_silence and
end_silence MCP tools; writing needs the new silences token scope.
Refs #56
fix(silences): catch up hold-backs from before the ending silence began
All checks were successful
CI / test (pull_request) Successful in 1m30s
0c7eab5928
A problem held back by a whole-source silence and then silenced again from
its report never got its still-open notice: catch-up only counted hold-backs
at or after the ending silence's own start. Count every hold-back not yet
caught up instead.
Signals can name the keys they depend on (parent), and links you set tie an
item of one source to an item of another. While a parent's report is open,
its effects attach to it: they send no notification and aren't diagnosed on
their own; the root's notification lists them, its diagnosis gets their
facts, and an update goes out when more join within five minutes. Effects
that open first attach when their parent opens; ones still failing five
minutes after their parent resolves are split off. Silencing or ignoring a
parent covers its effects. Proxmox guests, ZFS pools, disks and a node's own
storage name their node.
Effects show collapsed under their root on the dashboard and in history
("+ N affected"). A root's report page lists what it affects, an effect's
says what caused it, and reports that opened within a minute without a link
are shown as probably related. Settings → Dependencies adds links between
sources with the item picker, and lists suggested links to confirm or
dismiss: Find suggestions matches hosts across sources, and a diagnosis can
suggest links with "Link: report X depends on report Y" lines, which are
kept out of its text.
fix(incidents): count an effect whose root has resolved in the dashboard status
All checks were successful
CI / test (pull_request) Successful in 1m18s
4c4a40042b
Reads the official Network Integration API (Network 9.3+) with an API key:
offline, disconnected and isolated devices with their uplink as parent,
devices waiting for adoption, opt-in firmware updates, per-device severity
by UUID, and devices/device/client context queries.

Refs #55
fix(settings): fit per-item rules with UUID ids on small screens
All checks were successful
CI / test (pull_request) Successful in 1m17s
9df19b77ea
Hide item ids that aren't numbers, keep the label ahead of the detail, and
say an item is missing from the loaded list instead of naming Proxmox.
Author
Owner

Screenshots at 9df19b7 against a fake console (checks/fake_unifi.py, checks/unifi_browser.py):

390-type

390-type

desktop-type

desktop-type

390-picker

390-picker

desktop-picker

desktop-picker

390-device-rule

390-device-rule

desktop-device-rule

desktop-device-rule

Screenshots at 9df19b7 against a fake console (`checks/fake_unifi.py`, `checks/unifi_browser.py`): **390-type** ![390-type](https://git.knope.dev/attachments/7608d47c-a4ec-42cd-a338-e3d9d4e98118) **desktop-type** ![desktop-type](https://git.knope.dev/attachments/3a27f9a5-61c6-454f-b59d-d9b793377480) **390-picker** ![390-picker](https://git.knope.dev/attachments/a745fc91-8b28-4dad-835e-489cac24a13a) **desktop-picker** ![desktop-picker](https://git.knope.dev/attachments/4843f1c7-7fb3-49dc-b4b9-ab713ebd224e) **390-device-rule** ![390-device-rule](https://git.knope.dev/attachments/7d2c6b4c-b403-43d2-9bcf-eae3efc41173) **desktop-device-rule** ![desktop-device-rule](https://git.knope.dev/attachments/ab51d58d-363b-44d6-bf31-b3ec461b23b2)
jfro force-pushed feat/55-unifi from 9df19b77ea
All checks were successful
CI / test (pull_request) Successful in 1m17s
to 51521a28f2
All checks were successful
CI / test (pull_request) Successful in 1m30s
2026-11-14 14:32:44 +00:00
Compare
Author
Owner

Rebased onto main 1d67708 after #64 (relay agent) merged, now at 51521a2. The only conflicts were where both added to the same list: the Settings tabs (Agents now sits after Sources), the settings routes, the server's supervision tree (silence sweeper added to server_children), and the API auth test's route check. No feature code changed. mix precommit passes on every branch in the stack and CI is green.

Rebased onto main 1d67708 after #64 (relay agent) merged, now at 51521a2. The only conflicts were where both added to the same list: the Settings tabs (Agents now sits after Sources), the settings routes, the server's supervision tree (silence sweeper added to server_children), and the API auth test's route check. No feature code changed. `mix precommit` passes on every branch in the stack and CI is green.
jfro merged commit 9377073f31 into main 2026-11-14 15:08:15 +00:00
jfro deleted branch feat/55-unifi 2026-11-14 15:08:15 +00:00
Sign in to join this conversation.
No description provided.