ServiceMap: update tests and backend/app (+7 areas)

Public changes compared with the previous published export:
89 files changed.

Affected areas:
- backend/app: 21 files
- dependencies: 5 files
- deployment and CI: 6 files
- documentation: 2 files
- frontend: 3 files
- frontend/src: 20 files
- project files: 1 file
- tests: 30 files
- unraid: 1 file

Changed files:
- Updated: ".env.example"
- Updated: "Dockerfile.unraid"
- Updated: "README.md"
- Updated: "backend/Dockerfile"
- Added: "backend/app/alerts.py"
- Updated: "backend/app/auth.py"
- Added: "backend/app/backups.py"
- Updated: "backend/app/config_io.py"
- Updated: "backend/app/demo.py"
- Updated: "backend/app/discovery.py"
- Updated: "backend/app/discovery_store.py"
- Updated: "backend/app/docker_discovery.py"
- Updated: "backend/app/events.py"
- Updated: "backend/app/evidence.py"
- Updated: "backend/app/health.py"
- Updated: "backend/app/incidents.py"
- Added: "backend/app/loops.py"
- Updated: "backend/app/main.py"
- Updated: "backend/app/models.py"
- Updated: "backend/app/observation.py"
- Updated: "backend/app/probes.py"
- Added: "backend/app/response_cache.py"
- Updated: "backend/app/scheduler.py"
- Updated: "backend/app/semantic.py"
- Updated: "backend/app/store.py"
- Updated: "backend/pyproject.toml"
- Updated: "backend/tests/test_api.py"
- Updated: "backend/tests/test_config_io.py"
- Updated: "backend/tests/test_demo.py"
- Updated: "backend/tests/test_discovery_v120.py"
- Updated: "backend/tests/test_health.py"
- Updated: "backend/tests/test_probes.py"
- Updated: "backend/tests/test_scheduler.py"
- Updated: "backend/tests/test_v130_probe_reachability.py"
- Updated: "backend/tests/test_v160_evidence_changes.py"
- Added: "backend/tests/test_v163_alerts.py"
- Added: "backend/tests/test_v163_backups.py"
- Added: "backend/tests/test_v163_data_integrity.py"
- Added: "backend/tests/test_v163_efficiency.py"
- Added: "backend/tests/test_v163_health_performance.py"
- Added: "backend/tests/test_v163_loops.py"
- Added: "backend/tests/test_v163_management.py"
- Added: "backend/tests/test_v163_realtime.py"
- Added: "backend/tests/test_v163_security.py"
- Added: "backend/tests/test_v163_semantic_etag.py"
- Added: "compose.demo.yaml"
- Updated: "compose.yaml"
- Added: "docker-compose.broker.yml"
- Updated: "docker-compose.yml"
- Updated: "docs/ARCHITECTURE.md"
- Added: "frontend/e2e/a11y.spec.ts"
- Updated: "frontend/e2e/demo.spec.ts"
- Updated: "frontend/index.html"
- Updated: "frontend/nginx.conf"
- Updated: "frontend/package-lock.json"
- Updated: "frontend/package.json"
- Updated: "frontend/playwright.config.ts"
- Updated: "frontend/src/App.tsx"
- Updated: "frontend/src/LivingEdge.tsx"
- Added: "frontend/src/activityView.test.ts"
- Added: "frontend/src/activityView.ts"
- Updated: "frontend/src/api.ts"
- Added: "frontend/src/apiAuth.test.ts"
- Added: "frontend/src/components/ActionsMenu.tsx"
- Added: "frontend/src/components/ConfirmDialog.test.tsx"
- Added: "frontend/src/components/ConfirmDialog.tsx"
- Added: "frontend/src/components/StatusIcon.tsx"
- Updated: "frontend/src/demo/DemoWalkthrough.test.ts"
- Updated: "frontend/src/demo/DemoWalkthrough.tsx"
- Added: "frontend/src/elk-worker-url.d.ts"
- Added: "frontend/src/labels.ts"
- Updated: "frontend/src/main.tsx"
- Added: "frontend/src/realtime/refreshPlan.test.ts"
- Added: "frontend/src/realtime/refreshPlan.ts"
- Updated: "frontend/src/realtime/useRealtimeEvents.ts"
- Added: "frontend/src/routing/urlState.test.ts"
- Added: "frontend/src/routing/urlState.ts"
- Updated: "frontend/src/styles.css"
- Added: "frontend/src/topology/GraphListView.test.tsx"
- Added: "frontend/src/topology/GraphListView.tsx"
- Updated: "frontend/src/topology/ServiceNode.tsx"
- Updated: "frontend/src/topology/TopologyCommandBar.tsx"
- Added: "frontend/src/topology/semanticGraph.test.ts"
- Updated: "frontend/src/topology/semanticGraph.ts"
- Added: "frontend/src/topologyLayout.test.ts"
- Updated: "frontend/src/topologyLayout.ts"
- Updated: "package-lock.json"
- Updated: "package.json"
- Updated: "unraid/my-servicemap.xml"

Export provenance/manifests refreshed; excluded from the change summary.

Publish curated ServiceMap source from af46f684e468dffd3a5190e28d3b572d4c26bfd7
This commit is contained in:
NuklearRabbit committed 2026-11-20 13:51:46 +01:00
1 parent d7319250e8
commit adc2c70c21
91 files changed
+9205 -1691

No files matched your search

+93 -4
View File
@@ -2,7 +2,7 @@ from __future__ import annotations
import json
import sqlite3
from datetime import UTC, datetime
from datetime import UTC, datetime, timedelta
from hashlib import sha256
from typing import Any
from uuid import uuid4
@@ -354,7 +354,7 @@ class DiscoveryStore:
(
DiscoveryRunStatus.FAILED.value,
run.started_at.isoformat(),
"Superseded by a newer discovery run",
"Vervangen door een nieuwere detectierun",
DiscoveryRunStatus.DISCOVERING.value,
DiscoveryRunStatus.RECONCILING.value,
),
@@ -502,7 +502,7 @@ class DiscoveryStore:
"INSERT INTO topology_snapshot_relations VALUES (?, ?, ?, ?, ?, ?, ?)",
[(snapshot.id, relation_id, source_id, target_id, relation_type, fingerprint, _json(payload)) for relation_id, source_id, target_id, relation_type, fingerprint, payload in relation_rows],
)
self.record_change("topology_snapshot", f"Topology snapshot captured ({snapshot.service_count} services)")
self.record_change("topology_snapshot", f"Topologiesnapshot gemaakt ({snapshot.service_count} services)")
return snapshot
def list_snapshots(self, *, limit: int = 50) -> list[TopologySnapshot]:
@@ -514,7 +514,7 @@ class DiscoveryStore:
with self._connect() as db:
after = db.execute("SELECT * FROM topology_snapshots WHERE id=?", (after_snapshot_id,)).fetchone()
if after is None:
raise ValueError("Topology snapshot not found")
raise ValueError("Topologiesnapshot niet gevonden")
before = (
db.execute("SELECT * FROM topology_snapshots WHERE id=?", (before_snapshot_id,)).fetchone()
if before_snapshot_id
@@ -758,6 +758,7 @@ class DiscoveryStore:
if existing:
previous = self._evidence(existing)
evidence = evidence.model_copy(update={
"id": previous.id,
"confidence": _higher_confidence(previous.confidence, evidence.confidence),
"explanation": "; ".join(dict.fromkeys(part for part in (previous.explanation, evidence.explanation) if part)),
"source_ref": evidence.source_ref or previous.source_ref,
@@ -765,6 +766,19 @@ class DiscoveryStore:
"active": evidence.active,
"first_seen_at": min(previous.first_seen_at, evidence.first_seen_at),
})
# Update the found row by id. The UNIQUE constraint includes
# nullable columns (target_ref is NULL for manual edges), so
# ON CONFLICT never matched and each save inserted a duplicate.
db.execute(
"""
UPDATE relation_evidence SET target_service_id=?, confidence=?, explanation=?,
source_ref=?, locked=MAX(locked, ?), active=?, last_seen_at=?
WHERE id=?
""",
(evidence.target_service_id, evidence.confidence.value, evidence.explanation, evidence.source_ref, int(evidence.locked), int(evidence.active), evidence.last_seen_at.isoformat(), evidence.id),
)
row = db.execute("SELECT * FROM relation_evidence WHERE id=?", (evidence.id,)).fetchone()
return self._evidence(row)
db.execute(
"""
INSERT INTO relation_evidence
@@ -884,6 +898,53 @@ class DiscoveryStore:
def evidence_for_service(self, service_id: str) -> list[RelationEvidence]:
return self.list_evidence(service_id, active_only=True)
def evidence_for_services(self, service_ids: list[str]) -> dict[str, list[RelationEvidence]]:
"""Active relation evidence for many services in one read (no N+1)."""
ids = sorted(set(service_ids))
result: dict[str, list[RelationEvidence]] = {service_id: [] for service_id in ids}
if not ids:
return result
placeholders = ", ".join("?" for _ in ids)
with self._connect() as db:
rows = db.execute(
f"""
SELECT * FROM relation_evidence
WHERE active=1
AND (source_service_id IN ({placeholders}) OR target_service_id IN ({placeholders}))
ORDER BY last_seen_at DESC
""",
[*ids, *ids],
).fetchall()
for row in rows:
evidence = self._evidence(row)
for service_id in {row["source_service_id"], row["target_service_id"]}:
if service_id in result:
result[service_id].append(evidence)
return result
def sources_for_services(self, service_ids: list[str]) -> dict[str, list[ServiceSource]]:
"""Discovery sources for many services in one read (no N+1)."""
ids = sorted(set(service_ids))
result: dict[str, list[ServiceSource]] = {service_id: [] for service_id in ids}
if not ids:
return result
placeholders = ", ".join("?" for _ in ids)
with self._connect() as db:
rows = db.execute(
f"""
SELECT s.*, ss.service_id AS linked_service_id
FROM discovery_sources s JOIN service_sources ss ON ss.source_id=s.id
WHERE ss.service_id IN ({placeholders})
ORDER BY s.source_type, s.source_name
""",
ids,
).fetchall()
for row in rows:
result[row["linked_service_id"]].append(self._source(row))
return result
def sources_for_service(self, service_id: str) -> list[ServiceSource]:
with self._connect() as db:
rows = db.execute(
@@ -925,6 +986,34 @@ class DiscoveryStore:
with self._connect() as db:
db.execute("UPDATE discovery_runs SET status=? WHERE id=?", (status.value, run_id))
def prune_observations(self, keep_runs: int = 10) -> int:
"""Keep per-container observations only for the most recent runs.
Each run stores a full candidate dump per container. Runs themselves
are kept because review decisions (suggestions) reference them.
"""
if keep_runs < 1:
return 0
with self._connect() as db:
cursor = db.execute(
"""
DELETE FROM discovery_observations WHERE run_id NOT IN (
SELECT id FROM discovery_runs ORDER BY started_at DESC LIMIT ?
)
""",
(keep_runs,),
)
return cursor.rowcount
def prune_change_events(self, retention_days: int) -> int:
if retention_days <= 0:
return 0
cutoff = (_now() - timedelta(days=retention_days)).isoformat()
with self._connect() as db:
cursor = db.execute("DELETE FROM topology_change_events WHERE created_at < ?", (cutoff,))
return cursor.rowcount
def record_change(
self,
event_type: str,