UI and API: Needs attention, incident pages, known conditions, /covering for Gandalf and hwmonDaemon
CI / Lint (flake8, house style) (pull_request) Successful in 56s
CI / Test (pytest) (pull_request) Successful in 53s
CI / Security (bandit, pip-audit) (pull_request) Successful in 1m8s
CI / Integration (MariaDB) (pull_request) Successful in 1m49s
CI / UI (screenshots) (pull_request) Failing after 1m7s
CI / Scan (secrets, workflows, shell, patterns) (pull_request) Successful in 1m58s
CI / Deploy (pull_request) Skipped

- thor/web/api.py: /api/incidents/covering (thor#1 pre-check), /api/incidents, /api/incident/<key>,
  machine keys by SHA-256 with optional source CIDRs, like Gandalf's (gandalf#68); 503 when the
  database is away so callers fail open. covered=true only when there is a ticket to comment on;
  shadow incidents are listed but never cover.
- thor/web/ui.py + templates: Needs attention (incidents, Thor itself, timeline-only, known
  conditions seen again, unexplained symptoms), incident page (what happened, also seen, what
  Thor sent or would have sent, ticket text), known conditions. Read-only; CSP with nonces;
  Authelia identity shown only when it comes from NPM. Mobile nav drawer.
- web_template v1.2 (8286bb2) vendored and checked against upstream in CI.
- docs/contract.md: the /covering contract for the Gandalf and hwmonDaemon sessions.
- scripts/ui_demo.py + scripts/screenshots.py, and a CI job that renders every page with replay
  data (desktop, mobile, dark, light) and uploads the screenshots.
- Fix: systemd-escaped cpusets (system-ceph\x2dosd.slice) were not recognised as Ceph; four of
  the 11-23 kills came from the OSD slice. Found while reviewing the screenshots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-25 23:23:43 -05:00
1 parent 6c2328c2b1
commit ab4b20d15f
23 files changed
+9946 -9

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
#!/bin/bash
# Fails if thor/web/static/web_template/{base.css,base.js} differ from LotusGuild/web_template at
# the commit recorded in thor/web/static/web_template/VERSION. Change the design system upstream,
# then vendor it with a new download (see thor/web/static/web_template/VERSION); never edit the copies here.
set -euo pipefail
ROOT=$(cd "$(dirname "$0")/../.." && pwd)
DEST="$ROOT/thor/web/static/web_template"
UPSTREAM=${WEB_TEMPLATE_RAW_URL:-https://code.lotusguild.org/LotusGuild/web_template/raw/commit}
sha=$(awk '{print $2}' "$DEST/VERSION")
[[ "$sha" =~ ^[0-9a-f]{7,40}$ ]] || { echo "::error::thor/web/static/web_template/VERSION has no commit sha"; exit 1; }
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
status=0
for f in base.css base.js; do
curl -fsS --retry 2 --max-time 30 -o "$tmp/$f" "$UPSTREAM/$sha/$f"
if cmp -s "$tmp/$f" "$DEST/$f"; then
echo "$f matches web_template@$sha"
else
echo "::error::thor/web/static/web_template/$f differs from web_template@$sha. Change it upstream and resync with a new download (see thor/web/static/web_template/VERSION)."
diff -u "$tmp/$f" "$DEST/$f" | head -40 || true
status=1
fi
done
exit $status
+48
View File
@@ -0,0 +1,48 @@
#!/usr/bin/env python3
"""Screenshot Thor's pages (desktop and mobile) for UI review in pull requests.
Usage: python scripts/screenshots.py <base-url> <out-dir>
Needs Playwright with Chromium (pip install playwright; playwright install chromium).
Pair it with scripts/ui_demo.py to show the pages with replay data.
"""
import sys
from pathlib import Path
from playwright.sync_api import sync_playwright
PAGES = {
'needs-attention': '/',
'incident-oom-t1': '/incident/host:compute-storage-01:oom',
'incident-partition-t4': '/incident/cluster:corosync:partition',
'incident-maintenance-t2': '/incident/maintenance:gandalf:2',
'known-conditions': '/known',
}
VIEWPORTS = {'desktop': {'width': 1440, 'height': 900}, 'mobile': {'width': 390, 'height': 844}}
# The design system follows the browser's preference; the terminal look is the dark one.
SCHEMES = ('dark', 'light')
def main(base: str, out: str) -> None:
out_dir = Path(out)
out_dir.mkdir(parents=True, exist_ok=True)
with sync_playwright() as p:
browser = p.chromium.launch()
count = 0
for scheme in SCHEMES:
for vp_name, vp in VIEWPORTS.items():
if scheme == 'light' and vp_name == 'mobile':
continue
page = browser.new_page(viewport=vp, color_scheme=scheme)
for name, path in PAGES.items():
resp = page.goto(base.rstrip('/') + path, wait_until='networkidle')
if resp is None or resp.status >= 400:
raise SystemExit(f'{path} answered {resp.status if resp else "nothing"}')
page.screenshot(path=str(out_dir / f'{name}-{vp_name}-{scheme}.png'), full_page=True)
count += 1
page.close()
browser.close()
print(f'wrote {count} screenshots to {out_dir}')
if __name__ == '__main__':
main(sys.argv[1], sys.argv[2])
+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env python3
"""Serve Thor's UI with data from the replays, for screenshots and design review.
Usage: .venv/bin/python scripts/ui_demo.py [port] (default 8811, binds 127.0.0.1)
The store holds T1 stopped mid-incident (05:40, an open P1), the T2 maintenance timeline,
the DIMM known-condition note, and the T4 partition, all from tests/fixtures. The clock is
frozen at T1 05:40 so "ago" texts read as they would have that night.
"""
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(ROOT))
from tests.fakes import FakeStore # noqa: E402
from tests.replay import Replay # noqa: E402
from thor.config import Settings # noqa: E402
from thor.web.app import create_app # noqa: E402
T1_0540 = 1795412400.0
def demo_store() -> FakeStore:
merged = FakeStore()
runs = [Replay('t4').run(), Replay('dimm').run(), Replay('t2').run(), Replay('t1').run(until=T1_0540)]
for r in runs:
merged.incidents.update(r.store.incidents)
offset = len(merged.actions)
for a in r.store.actions:
merged.actions.append(dict(a, id=a['id'] + offset))
merged.observations.update(r.store.observations)
t1 = runs[-1].store
merged.state.update(t1.state)
merged.sources = t1.sources
merged.blind = t1.blind
# Show T2's maintenance as still active, as it was mid-window.
m = merged.incidents['maintenance:gandalf:2']
m.update(state='open', cleared_at=None, last_seen=T1_0540 - 600)
return merged
def build():
settings = Settings()
settings.public_url = ''
return create_app(settings, demo_store(), 'demo0000', clock=lambda: T1_0540)
if __name__ == '__main__':
port = int(sys.argv[1]) if len(sys.argv) > 1 else 8811
build().run(host='127.0.0.1', port=port)