homek8s/apps/base/osint/README.md
Lance Walters 2f613e4f11 fix(osint): run the PR #72 summarizer (fail-loudly + concurrent map phase)
The resilience fix sirius/osint-dashboard@fb5285d (PR #72) was merged but
never deployed: ns osint still ran the 11/19 image amd64-fe2b5df369d0, which
has neither the concurrent map phase nor NousAPIError, so a non-retryable
Nous rejection was swallowed as an empty completion and the analyst idled
for nine days without a single signal.

* pin deploy/osint-news-summarizer to the CI-built amd64-fb5285df7f38
  (build run 1497 / job 2165, manifest sha256:e2387f90...4de52)
* pin osint-analyst-exporter to the same tag — it borrows the summarizer
  image for python3 + psycopg2, and two tags for one image read as drift
* SUMMARY_MAP_CONCURRENCY=16 next to BATCH_SIZE: ~20 s per map call, the
  746-batch recap measured 951 s at 16 (8 projects to ~98 min)
* README: image inventory + a section on the new behaviour and log line
2026-12-05 00:29:11 -05:00

11 KiB

OSINT Dashboard stack (namespace osint)

Ported from the Pi docker-compose stack in sirius/osint-dashboard so the dashboard is served from the cluster at https://osint.siriusdevops.com instead of a host Docker container on the Pi.

Workloads

Deployment Image Purpose
osint-db forgejo…/sirius/osint-dashboard-pg:amd64-c48788d4b614-r3 TimescaleDB 2.32.1 + PostGIS 3 on Postgres 16.16, local-path-linode PVC osint-pgdata-linode 15 Gi
osint-nats forgejo…/sirius/nats:2.10 JetStream event bus (-js -m 8222)
osint-app forgejo…/sirius/osint-dashboard:amd64-915f6cbe25be FastAPI + static HUD; runs alembic upgrade heads on start; single-admin auth (app/auth.py) — public read-only site, admin-only keys/settings/mutations
osint-ingester same app image RSS/GDELT/USGS/FIRMS/vessel ingest → NATS → Postgres
osint-camera-service same app image public-camera discovery + snapshots (PVC osint-camera-snapshots 3 Gi, shared with the app)
osint-titiler forgejo…/sirius/titiler:0.26.0 SAR COG tile proxy, exposed same-origin at /titiler
osint-news-scraper forgejo…/sirius/osint-news-scraper:amd64-58f71f5b4520 Scrapy news scraper loop
osint-news-summarizer forgejo…/sirius/osint-news-summarizer:amd64-fb5285df7f38 "analyst" — Nous Portal briefs every 15 min + 23:00 recap

Every workload is pinned to kubernetes.io/hostname: siriussec (Gateway/Envoy co-location + local-path PVs).

Images

CI builds the cluster images. Since PR #63 in sirius/osint-dashboard, .forgejo/workflows/build.yml runs on the amd64 runner (runs-on: amd64), tags amd64-<sha12>, and pushes straight into the in-cluster registry (forgejo.forgejo.svc.cluster.local:3000, plain HTTP, whitelisted by --insecure-registry on the runner's dind). Deploying is then just a pin change here in apps/base/osint/ — check the run's ## Pin in homek8s summary for the exact tags. Builds are path-filtered, so one image can be several commits older than another: the app tag is normally master tip, the summarizer tag is whichever commit last touched news/summerizer/.

Do not build these by hand and push over a :amd64-<sha> tag: that replaces CI's manifest, and Forgejo's registry garbage-collects the displaced digest, so the CI artifact cannot be pulled back. If you need a tag rebuilt, dispatch CI instead: POST /api/v1/repos/sirius/osint-dashboard/actions/workflows/build.yml/dispatches with {"ref":"master","inputs":{"rebuild_all":"true"}}.

Manual builds exist only as a historical fallback (pre-#63 images, or a CI outage) — and then build from a detached worktree at the merge sha, never from the main checkout: Legion's ~/osint-dashboard sits on a feature branch, and a docker build there once produced a :amd64-<sha> image that carried the right tag and none of the commit's code.

# fallback only — the normal path is: let CI build, then pin the tag here
git -C ~/osint-dashboard fetch origin
git -C ~/osint-dashboard worktree add --detach /tmp/osint-build origin/master
cd /tmp/osint-build && SHA=$(git rev-parse --short=12 HEAD) && TAG="amd64-$SHA"
docker build -f Dockerfile                    -t 127.0.0.1:3000/sirius/osint-dashboard:$TAG .
docker build -f news/scraper/Dockerfile       -t 127.0.0.1:3000/sirius/osint-news-scraper:$TAG news/scraper
docker build -f news/summerizer/Dockerfile    -t 127.0.0.1:3000/sirius/osint-news-summarizer:$TAG news/summerizer
docker build -f pg-image/Dockerfile           -t 127.0.0.1:3000/sirius/osint-dashboard-pg:$TAG-r2 .

pg-image/Dockerfile is the cluster copy of Dockerfile.pg. It pins postgres:16.16-bookworm: the upstream file's bare postgres:16 now resolves to Debian trixie, whose postgresql-16-postgis-3 (3.7.0+pgdg13) fails to load against PG 16.15 with undefined symbol: heap_datum_check — CREATE EXTENSION postgis crashes the server. On bookworm (+pgdg12) PostGIS 3.7 loads and create_hypertable() works. Port the one-line base-image pin upstream when the Pi stack is next rebuilt.

It also pins the TimescaleDB packages to 2.32.1~debian12-1616 (the -1616 suffix = built against PG 16.16) and the base image to the 16.16 minor. PG 16.16 added the PortalDrop() "cannot drop portal while it is being set up" check that TimescaleDB <=2.32.0 trips in its background-worker path, so every policy job failed with SQLSTATE 24000 while CALL run_job() worked (timescale/timescaledb#11038, fixed in 2.31.2/2.32.1). Never unpin either half: a pg minor bump without a matching TimescaleDB build reintroduces the failure. -r3 is that build. After a pod recreate the extension itself still has to be moved: ALTER EXTENSION timescaledb UPDATE TO '2.32.1'.

Secrets (never in git)

kubectl -n osint create secret generic osint-db --from-literal=password='<strong>'

osint-db/password is used for POSTGRES_PASSWORD and every workload's DB_PASSWORD. Regenerating it requires the Postgres role password to be changed too (ALTER ROLE osint PASSWORD …), not just the Secret.

API keys (Nous Portal NOUS_API_KEY, FIRMS, AISStream, VesselAPI) are not Kubernetes Secrets: they live in the dashboard's api_keys table and are set from the Keys page in the UI (GET/PUT /api/keys). The summarizer reads NOUS_API_KEY from the env first, then from that table. Since the auth change the Keys page is admin-only, so set them while signed in (/login).

Admin login (osint-admin)

# password -> pbkdf2 hash (from a checkout of sirius/osint-dashboard)
python app/auth.py hash '<password>'
python -c 'import secrets; print(secrets.token_urlsafe(48))'   # session secret

kubectl -n osint create secret generic osint-admin \
  --from-literal=ADMIN_USER=lance \
  --from-literal=ADMIN_PASSWORD_HASH='pbkdf2_sha256$…' \
  --from-literal=ADMIN_SESSION_SECRET='…'
kubectl -n osint rollout restart deploy/osint-app    # env is fixed at container start

ADMIN_USER=lance; the current password lives in ~/.hermes/secrets/osint_admin_password (0600, Legion) — never in git. The three refs in app-deployment.yaml are optional: true on purpose: a missing Secret must not block startup, and the app then fails closed (admin routes 403 {"detail":"admin auth not configured"}) while the public HUD keeps serving.

The session cookie is HttpOnly + SameSite=Lax + Secure. Secure comes from ADMIN_COOKIE_SECURE=1 (ConfigMap), not from header inference: the tunnel origins at plain HTTP and Cilium Envoy rewrites X-Forwarded-Proto to http, so app/auth.py::_is_https() never sees https (an explicit request header is discarded too — verified). Leave the flag unset only if you ever serve this over plain http locally; browsers will not send a Secure cookie there.

News list hygiene

/api/news orders by articles.timestamp DESC, so anything dated in the future pins the top of the feed indefinitely. Two guards (PR #52):

  • the Scrapy pipeline drops items dated more than 2 h ahead (FUTURE_TOLERANCE in newsScraper/pipelines.py), counting them under the future_dated_dropped stat and logging one INFO line per crawl;
  • GET /api/news additionally excludes timestamp > now() (keeping timestamp IS NULL rows), so rows already in the table can never resurface early.

Items with an unparseable date are still kept — the guard only fires on a date it can actually parse.

Analyst model

SUMMARY_MODEL=deepseek/deepseek-v4.1-flash-1017 (Nous Portal, 1M context, verified to honour response_format: json_object; the previous free meituan/longcat-2.5:free id was retired and 404'd every call). When picking a replacement, confirm it is in GET /v1/models — a stale id fails silently because chat() swallows non-200s and returns an empty string. It is set in configmap.yaml; changing it in the UI (PUT /api/settings) only takes effect when the env var is empty, because resolve_model() prefers the env.

Analyst resilience + map concurrency (PR #72)

SUMMARY_MAP_CONCURRENCY (16, in configmap.yaml) sets how many map calls are in flight. Each call is a ~20 s wall clock, so the phase is latency-bound: the 746-batch recap measured 951 s end-to-end at 16, where 8 is projected at ~98 min. The code default is also 16; the env var is pinned so a default change upstream cannot silently stretch the 15-min interval past its window.

A non-retryable Nous rejection (400/404/422 — e.g. a retired model id) now raises NousAPIError and aborts the run with rc=1 instead of being swallowed as an empty completion, so the failure shows up in the pod log on the first tick rather than as nine days of "idle" ticks. The per-run summary line is summarize done kind=<interval|recap> summary_id=… model=… batches=… articles=… ticker=… map=… elapsed=…s.

Analyst grading (PR #53 + #54)

The map call scores every article 0-100 against a rubric in the same request (no extra round-trip): 90+ breaking geopolitical/military/disaster, 70-89 significant national/international, 40-69 notable regional, 10-39 routine/crime, 0-9 noise (sport, celebrity, market tape, event-calendar listings). Only blocks scoring >= SUMMARY_MIN_SCORE (60) reach the reduce prompt, capped at SUMMARY_TOP_N (12). If nothing clears the bar the fallback may only pick blocks >= SUMMARY_FALLBACK_MIN_SCORE (40), and if none clear that the brief is the honest No significant developments in this window. — SUMMARY_FALLBACK_TOP=0 disables the fallback entirely.

get_recent_news() uses a closed window (now - window, now]: future-dated rows must never be re-graded every 15 minutes (they are dropped at ingest and hidden in /api/news — see above).

Every graded article is persisted to article_scores (score, category, selected, model, summary_id) for threshold tuning, e.g.

select width_bucket(score, 0, 100, 10) * 10 as bucket, count(*), avg(selected::int)
from article_scores group by 1 order by 1;

Before the threshold/cap, dedupe_blocks() collapses syndicated wire copies (six Hearst stations carrying one AP story) onto the best-scoring representative, comparing normalised titles — lowercase, source suffix ( - KCCI, | CNN) stripped when the tail is short and digit-free — with word-set Jaccard / sequence similarity >= SUMMARY_DEDUPE_SIMILARITY (0.85). Duplicates are still graded and persisted, with selected=false and duplicate_of pointing at the survivor. SUMMARY_DEDUPE=0 disables the collapse.

Ingress

Cloudflare tunnel sirius home already carries osint.siriusdevops.com → http://10.10.0.2:8080. DNS is a proxied CNAME to 6d0702eb-99cc-4062-b57d-e70e2f1a7895.cfargotunnel.com. HTTPRoute rule order: /titiler (prefix stripped) → osint-titiler:8000, then / → osint-app:8000 (WebSocket /ws/live included).