Author SHA1 Message Date
Jens fd4aaf40a3 Merge pull request 'Publish the ServiceMap 1.6.4 source edition' (#2) from codex/publish-servicemap-1-6-4 into main 2026-11-20 15:02:59 +00:00
NuklearRabbit 41a8eee259 ServiceMap: update dependencies and backend/app (+5 areas)
Public changes compared with the previous published export:
16 files changed.

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

Changed files:
- Updated: ".env.example"
- Updated: "Dockerfile.unraid"
- Updated: "README.md"
- Updated: "backend/app/incidents.py"
- Updated: "backend/app/main.py"
- Updated: "backend/app/store.py"
- Updated: "backend/pyproject.toml"
- Updated: "backend/tests/test_docker_provider.py"
- Updated: "backend/tests/test_v163_health_performance.py"
- Updated: "docker-compose.broker.yml"
- Updated: "docs/ARCHITECTURE.md"
- Updated: "frontend/package-lock.json"
- Updated: "frontend/package.json"
- Updated: "frontend/src/App.tsx"
- Updated: "package-lock.json"
- Updated: "package.json"

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

Publish curated ServiceMap source from 8c297f756ff84aaa917ae9c48535e835f8c09ec7
2026-11-20 16:01:36 +01:00
Jens d4c351ce73 Merge pull request 'Publish the ServiceMap 1.6.3 source edition' (#1) from codex/publish-servicemap-1-6-3 into main 2026-11-20 14:50:56 +00:00
18 changed files with 167 additions and 92 deletions

No files matched your search

+3 -3
View File
@@ -18,9 +18,9 @@ SERVICEMAP_DOCKER_HOST=unix:///var/run/docker.sock
SERVICEMAP_DOCKER_PROVIDER=socket SERVICEMAP_DOCKER_PROVIDER=socket
SERVICEMAP_DOCKER_BROKER_URL= SERVICEMAP_DOCKER_BROKER_URL=
SERVICEMAP_DOCKER_BROKER_TOKEN_FILE= SERVICEMAP_DOCKER_BROKER_TOKEN_FILE=
# Used only by docker-compose.broker.yml. The host token file must already # Used only by docker-compose.broker.yml. The dedicated directory must already
# exist with restrictive permissions; Compose will not create it. # contain only the scoped servicemap-docker-broker.token with restrictive permissions.
SERVICEMAP_DOCKER_BROKER_TOKEN_HOST_FILE= SERVICEMAP_DOCKER_BROKER_TOKEN_HOST_DIRECTORY=
# Existing external Docker network shared with the registered read broker. # Existing external Docker network shared with the registered read broker.
SERVICEMAP_DOCKER_BROKER_NETWORK= SERVICEMAP_DOCKER_BROKER_NETWORK=
SERVICEMAP_APPOPS_URL= SERVICEMAP_APPOPS_URL=
+1 -1
View File
@@ -11,7 +11,7 @@ FROM python:3.12-slim
LABEL org.opencontainers.image.title="ServiceMap" \ LABEL org.opencontainers.image.title="ServiceMap" \
org.opencontainers.image.description="Production infrastructure intelligence" \ org.opencontainers.image.description="Production infrastructure intelligence" \
org.opencontainers.image.version="1.6.3" org.opencontainers.image.version="1.6.4"
WORKDIR /app WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1 \ ENV PYTHONDONTWRITEBYTECODE=1 \
+1 -1
View File
@@ -1,3 +1,3 @@
# Public source export # Public source export
This source snapshot was generated from the private canonical repository at revision `af46f684e468dffd3a5190e28d3b572d4c26bfd7`. It contains no private Git history or operational evidence. Changes are published from the canonical repository. This source snapshot was generated from the private canonical repository at revision `8c297f756ff84aaa917ae9c48535e835f8c09ec7`. It contains no private Git history or operational evidence. Changes are published from the canonical repository.
+26 -26
View File
@@ -1,6 +1,6 @@
{ {
"schemaVersion": 1, "schemaVersion": 1,
"sourceRevision": "af46f684e468dffd3a5190e28d3b572d4c26bfd7", "sourceRevision": "8c297f756ff84aaa917ae9c48535e835f8c09ec7",
"files": [ "files": [
{ {
"path": ".dockerignore", "path": ".dockerignore",
@@ -9,8 +9,8 @@
}, },
{ {
"path": ".env.example", "path": ".env.example",
"sha256": "3671bd15b95a235ba96ef607a94bd1c6054b8086640bdab78a0761b9d0dd2891", "sha256": "c0ca098f748ed6b6c57d0a8e133c51abee64d861ede05d75b877e6853d3495d9",
"bytes": 2034 "bytes": 2064
}, },
{ {
"path": ".gitignore", "path": ".gitignore",
@@ -19,13 +19,13 @@
}, },
{ {
"path": "Dockerfile.unraid", "path": "Dockerfile.unraid",
"sha256": "17f22770bafe4ca9ed6389e9040fd25ff9691a4d25ba134a509b25357c076204", "sha256": "c9844a496d8c419ba034f13e5ac87e2b859abed8a7fb46ddaa06b1c2c1a02fd2",
"bytes": 881 "bytes": 881
}, },
{ {
"path": "README.md", "path": "README.md",
"sha256": "e5b878912e376d3301e7e83d532551a07af03d954deb1f917dd4911bd51f2004", "sha256": "51d933eb32792dbd22e69f3927eb36b7246ff3d50be888be62696a4ef601b149",
"bytes": 5508 "bytes": 5547
}, },
{ {
"path": "backend/Dockerfile", "path": "backend/Dockerfile",
@@ -99,8 +99,8 @@
}, },
{ {
"path": "backend/app/incidents.py", "path": "backend/app/incidents.py",
"sha256": "dd4f4cf37813426e4aaaa7707cb1fa564d3510ca41ac742c43c7eedfcee10d60", "sha256": "fed645042f73ac02af62b4be7314e1d029a676c8f8d02c0c7bdc512bc5723eca",
"bytes": 7726 "bytes": 8047
}, },
{ {
"path": "backend/app/loops.py", "path": "backend/app/loops.py",
@@ -109,8 +109,8 @@
}, },
{ {
"path": "backend/app/main.py", "path": "backend/app/main.py",
"sha256": "91f8f01aa81a364e9c2968c3cd28339d3884d696191ea547851fbee433175fc9", "sha256": "ab6c150bd1a258ab3a9ed1454a5867e470a23af79a8e9f706d4b8fe3784aa9f3",
"bytes": 43917 "bytes": 44235
}, },
{ {
"path": "backend/app/models.py", "path": "backend/app/models.py",
@@ -144,12 +144,12 @@
}, },
{ {
"path": "backend/app/store.py", "path": "backend/app/store.py",
"sha256": "619ceeebe8236ff6135204721fc41061465c2fc7f147a03d06be5f8743a2f326", "sha256": "28c4c443a733b08ed78bfc9086842e81fc5c9cb453c745da5f3d5f075d977380",
"bytes": 113419 "bytes": 113556
}, },
{ {
"path": "backend/pyproject.toml", "path": "backend/pyproject.toml",
"sha256": "090bcedfa40fb692ede31ba38656a54eeb091110726cf5d82c57314573e64b54", "sha256": "a77ef16ae54a2bc93466cddc508bc79c33e9e5a0bf887284d373bf1d865cc220",
"bytes": 498 "bytes": 498
}, },
{ {
@@ -194,8 +194,8 @@
}, },
{ {
"path": "backend/tests/test_docker_provider.py", "path": "backend/tests/test_docker_provider.py",
"sha256": "57ffc4d4ffcf3198a9261b284c3fd8166bd1670220d917c54a9ea6cb0d309e1e", "sha256": "e642e7223bc26959f8527f0e746c4ed53f752358fc28d14280d997c11f81bf70",
"bytes": 8393 "bytes": 9714
}, },
{ {
"path": "backend/tests/test_health.py", "path": "backend/tests/test_health.py",
@@ -264,8 +264,8 @@
}, },
{ {
"path": "backend/tests/test_v163_health_performance.py", "path": "backend/tests/test_v163_health_performance.py",
"sha256": "0ec2188dbb5bb407649b3cfe801a16bfb6ded7cb416cce5182aaeffeaf65cb7f", "sha256": "f029475b392bddca9eb4455dce6167c048365980cec1d2c6a68f753e13d8b9ea",
"bytes": 14241 "bytes": 15040
}, },
{ {
"path": "backend/tests/test_v163_loops.py", "path": "backend/tests/test_v163_loops.py",
@@ -304,8 +304,8 @@
}, },
{ {
"path": "docker-compose.broker.yml", "path": "docker-compose.broker.yml",
"sha256": "3213899c1a8b929388a10ed9ac52eefc6f5c4a73972ddafa08ffd26ebffdf485", "sha256": "42a9d5297abcf3625bbefb4c3d9941c609b54792fad5044d8ead3469e3543f2e",
"bytes": 3548 "bytes": 3621
}, },
{ {
"path": "docker-compose.yml", "path": "docker-compose.yml",
@@ -314,8 +314,8 @@
}, },
{ {
"path": "docs/ARCHITECTURE.md", "path": "docs/ARCHITECTURE.md",
"sha256": "aa5ed3cbbdcc1966b6e83db41527e68d84831d1d01df4cfbbab27d218d4800f2", "sha256": "8963e449b098c2aa8506cb193e4d0b7413cd4944f1b0ef9d88d2e8e80be9848d",
"bytes": 18510 "bytes": 18707
}, },
{ {
"path": "docs/screenshots/demo-health.png", "path": "docs/screenshots/demo-health.png",
@@ -359,12 +359,12 @@
}, },
{ {
"path": "frontend/package-lock.json", "path": "frontend/package-lock.json",
"sha256": "343126dd503ed9e08f23b613232e314026dd87c60c8513e8fe456c81e920e836", "sha256": "a01bf36cf1704a4c437cbae64b9ab0bb341488c24ba97a7e650435720ad4c7d1",
"bytes": 160062 "bytes": 160062
}, },
{ {
"path": "frontend/package.json", "path": "frontend/package.json",
"sha256": "cc22ff7ed7138703d88b257b17dbd7beaf23e3e419d49363ee0c1c6303ba0d4d", "sha256": "f2d64abb21e260cf030442ceb737c32ecf01938bc6b74a984b327ca4aeaa6e15",
"bytes": 1146 "bytes": 1146
}, },
{ {
@@ -434,7 +434,7 @@
}, },
{ {
"path": "frontend/src/App.tsx", "path": "frontend/src/App.tsx",
"sha256": "00093ee16eab74a86026760f449475466dcb420398685637dcebc6de8e96c7f9", "sha256": "5401ec7974be3fb3238157d9d97513e267bdbcc7cfece076856833e316ff399d",
"bytes": 189981 "bytes": 189981
}, },
{ {
@@ -624,12 +624,12 @@
}, },
{ {
"path": "package-lock.json", "path": "package-lock.json",
"sha256": "c2df0fa270d2e687acf6277c99cc270d976cf87649d92f35ed0560ee3b78eea2", "sha256": "ab28e6be7931828f2f9adc85f8c85ae660db327bc92458f960f4cba2baa04cf9",
"bytes": 203 "bytes": 203
}, },
{ {
"path": "package.json", "path": "package.json",
"sha256": "bc4ce50c81c106ce390ce73d0c2ec259467f6dec6a3a0281fc078a74e3b64a37", "sha256": "3ce2e957d5d9ce819e32e37af0712487c0342081852566843d904af1079822c3",
"bytes": 478 "bytes": 478
}, },
{ {
+2 -2
View File
@@ -52,7 +52,7 @@ docker compose up --build
Open `http://localhost:1253`. Standard Compose runs the Python API and React frontend separately and persists SQLite under `./data`. Preserve this directory during upgrades. Set `SERVICEMAP_PROBE_INTERVAL=0` to disable scheduled probes. Define targets and dependencies in the UI or import a configuration before expecting live coverage. Open `http://localhost:1253`. Standard Compose runs the Python API and React frontend separately and persists SQLite under `./data`. Preserve this directory during upgrades. Set `SERVICEMAP_PROBE_INTERVAL=0` to disable scheduled probes. Define targets and dependencies in the UI or import a configuration before expecting live coverage.
The single-container Unraid build is provided by `Dockerfile.unraid` and `docker-compose.yml`. Review the socket/network mounts before enabling discovery. A read-only Docker socket mount still exposes a powerful Docker API boundary. Broker mode requires a dedicated registered identity and token file and deliberately has no socket fallback. AppOps enrichment is optional; configure your own endpoint. The single-container Unraid build is provided by `Dockerfile.unraid` and `docker-compose.yml`. Review the socket/network mounts before enabling discovery. A read-only Docker socket mount still exposes a powerful Docker API boundary. Broker mode requires a dedicated registered identity and a read-only directory containing the scoped token and deliberately has no socket fallback. AppOps enrichment is optional; configure your own endpoint.
## Move from demo to live coverage ## Move from demo to live coverage
@@ -86,6 +86,6 @@ Vite proxies the API to port 8000. Validate changes with `python -m pytest`, `np
## Source distribution and licensing ## Source distribution and licensing
This is the curated public source edition of ServiceMap 1.6.3. Reviewed updates flow from the private canonical repository after merges to `main`; private history, production evidence and internal CI/deployment workflows are excluded. Deployment examples use generic addresses and must be configured for your environment. This is the curated public source edition of ServiceMap 1.6.4. Reviewed updates flow from the private canonical repository after merges to `main`; private history, production evidence and internal CI/deployment workflows are excluded. Deployment examples use generic addresses and must be configured for your environment.
No project-wide license is included. Public source visibility does not grant reuse or redistribution rights; obtain the owner's terms and review third-party dependencies before redistribution. No project-wide license is included. Public source visibility does not grant reuse or redistribution rights; obtain the owner's terms and review third-party dependencies before redistribution.
+14 -5
View File
@@ -97,14 +97,23 @@ def _severity(service: Service) -> Criticality:
# concurrent passes could both see "no active incident" for a root and each # concurrent passes could both see "no active incident" for a root and each
# open one (the later duplicate cleanup then left two journal entries). # open one (the later duplicate cleanup then left two journal entries).
_SYNC_LOCK = threading.RLock() _SYNC_LOCK = threading.RLock()
_DEFAULT_RESOLUTION_REASON = "Hoofdoorzaak hersteld; incident opgelost"
def sync_incidents(store: Store, *, resolution_reason: str = "Hoofdoorzaak hersteld; incident opgelost") -> list[IncidentRecord]: def sync_incidents(store: Store, *, resolution_reason: str = _DEFAULT_RESOLUTION_REASON) -> list[IncidentRecord]:
with _SYNC_LOCK: with _SYNC_LOCK:
return _sync_incidents_locked(store, resolution_reason=resolution_reason) _sync_incidents_locked(store, resolution_reason=resolution_reason)
return store.list_incidents(active_only=False)
def _sync_incidents_locked(store: Store, *, resolution_reason: str) -> list[IncidentRecord]: def reconcile_incidents(store: Store) -> tuple[TopologyHealth, IncidentOverview]:
with _SYNC_LOCK:
return _sync_incidents_locked(store, resolution_reason=_DEFAULT_RESOLUTION_REASON)
def _sync_incidents_locked(
store: Store, *, resolution_reason: str
) -> tuple[TopologyHealth, IncidentOverview]:
"""Reconcile the current graph with the durable incident journal. """Reconcile the current graph with the durable incident journal.
A root service has at most one active incident. Repeated probe cycles only A root service has at most one active incident. Repeated probe cycles only
@@ -117,7 +126,7 @@ def _sync_incidents_locked(store: Store, *, resolution_reason: str) -> list[Inci
now = datetime.now(UTC) now = datetime.now(UTC)
active: dict[str, IncidentRecord] = {} active: dict[str, IncidentRecord] = {}
for incident in sorted( for incident in sorted(
store.list_incidents(active_only=True), store.list_incidents(active_only=True, services=services),
key=lambda item: (item.detected_at, item.id), key=lambda item: (item.detected_at, item.id),
): ):
if incident.root_service_id in active: if incident.root_service_id in active:
@@ -191,4 +200,4 @@ def _sync_incidents_locked(store: Store, *, resolution_reason: str) -> list[Inci
) )
store.upsert_incident(resolved) store.upsert_incident(resolved)
store.append_incident_event(incident.id, "incident.resolved", resolution_reason, root_id) store.append_incident_event(incident.id, "incident.resolved", resolution_reason, root_id)
return store.list_incidents(active_only=False) return health, overview
+42 -40
View File
@@ -22,8 +22,8 @@ from .discovery_store import DiscoveryStore
from .docker_discovery import discover_containers from .docker_discovery import discover_containers
from .docker_provider import docker_provider_mode from .docker_provider import docker_provider_mode
from .events import SSE_RETRY_MS, event_bus, next_event, sse_payload from .events import SSE_RETRY_MS, event_bus, next_event, sse_payload
from .health import status_maps, topology_health, validate_dependencies from .health import TopologyHealth, status_maps, topology_health, validate_dependencies
from .incidents import incident_overview, sync_incidents from .incidents import incident_overview, reconcile_incidents, sync_incidents
from .loops import loop_registry, run_periodic from .loops import loop_registry, run_periodic
from .models import ( from .models import (
AvailabilitySummary, AvailabilitySummary,
@@ -288,7 +288,7 @@ async def lifespan(_: FastAPI):
await background_task await background_task
app = FastAPI(title="ServiceMap API", version="1.6.3", lifespan=lifespan) app = FastAPI(title="ServiceMap API", version="1.6.4", lifespan=lifespan)
# Bounded request bodies: the largest legitimate payload is a config import. # Bounded request bodies: the largest legitimate payload is a config import.
@@ -404,7 +404,7 @@ def meta() -> dict[str, str | int | float | bool]:
auth_mode = "misconfigured" auth_mode = "misconfigured"
return { return {
"name": "ServiceMap", "name": "ServiceMap",
"version": "1.6.3", "version": "1.6.4",
"stage": "v1", "stage": "v1",
"scheduled_probing": PROBE_INTERVAL > 0, "scheduled_probing": PROBE_INTERVAL > 0,
"probe_interval_seconds": PROBE_INTERVAL, "probe_interval_seconds": PROBE_INTERVAL,
@@ -488,21 +488,21 @@ def verify_write_access() -> dict[str, bool]:
return {"ok": True} return {"ok": True}
def _service_snapshots( def _visible_services(services: list[Service]) -> list[Service]:
*, include_hidden: bool = False, include_context: bool = True return [
) -> list[ServiceSnapshot]: service for service in services
all_services = store.list_services()
services = (
all_services
if include_hidden
else [
service
for service in all_services
if service.visibility.value == "visible" and service.lifecycle.value not in {"retired", "ignored"} if service.visibility.value == "visible" and service.lifecycle.value not in {"retired", "ignored"}
] ]
)
latest = store.latest_probes([service.id for service in services])
availability = store.availability_summaries([service.id for service in services], 24) def _service_snapshots(
*, include_hidden: bool = False, include_details: bool = True
) -> tuple[list[ServiceSnapshot], TopologyHealth]:
all_services = store.list_services()
services = all_services if include_hidden else _visible_services(all_services)
visible_ids = [service.id for service in services]
latest = store.latest_probes(visible_ids)
availability = store.availability_summaries(visible_ids, 24) if include_details else {}
evidence_by_service = store.health_evidence_for_services([service.id for service in all_services]) evidence_by_service = store.health_evidence_for_services([service.id for service in all_services])
# Calculate propagation over the complete canonical graph first. Hidden # Calculate propagation over the complete canonical graph first. Hidden
# infrastructure nodes may still sit between a visible service and its # infrastructure nodes may still sit between a visible service and its
@@ -512,15 +512,15 @@ def _service_snapshots(
[service.id for service in all_services], evidence_by_service=evidence_by_service [service.id for service in all_services], evidence_by_service=evidence_by_service
) )
effective_all, dependency_all = status_maps(all_services, direct_statuses=direct_all) effective_all, dependency_all = status_maps(all_services, direct_statuses=direct_all)
dependent_names = { dependent_names: dict[str, list[str]] = {}
service.id: [item.name for item in services if service.id in item.depends_on] if include_details:
for service in services for service in services:
} for dependency_id in set(service.depends_on):
visible_ids = [service.id for service in services] dependent_names.setdefault(dependency_id, []).append(service.name)
windows = store.maintenance_windows() windows = store.maintenance_windows() if include_details else {}
sources_by_service = discovery_store.sources_for_services(visible_ids) if include_context else {} sources_by_service = discovery_store.sources_for_services(visible_ids) if include_details else {}
relations_by_service = discovery_store.evidence_for_services(visible_ids) if include_context else {} relations_by_service = discovery_store.evidence_for_services(visible_ids) if include_details else {}
return [ snapshots = [
ServiceSnapshot( ServiceSnapshot(
service=service, service=service,
latest_probe=latest.get(service.id), latest_probe=latest.get(service.id),
@@ -539,16 +539,18 @@ def _service_snapshots(
sources=sources_by_service.get(service.id, []), sources=sources_by_service.get(service.id, []),
evidence=relations_by_service.get(service.id, []), evidence=relations_by_service.get(service.id, []),
health_evidence=evidence_by_service.get(service.id, []), health_evidence=evidence_by_service.get(service.id, []),
health_resolution=resolutions.get(service.id, HealthResolution()), health_resolution=resolutions.get(service.id) or HealthResolution(),
maintenance_until=windows.get(service.id), maintenance_until=windows.get(service.id),
) )
for service in services for service in services
] ]
return snapshots, TopologyHealth(all_services, direct_all, effective_all, dependency_all)
@app.get("/api/v1/services", response_model=list[ServiceSnapshot]) @app.get("/api/v1/services", response_model=list[ServiceSnapshot])
def list_services(include_hidden: bool = Query(default=False)) -> list[ServiceSnapshot]: def list_services(include_hidden: bool = Query(default=False)) -> list[ServiceSnapshot]:
return _service_snapshots(include_hidden=include_hidden) snapshots, _ = _service_snapshots(include_hidden=include_hidden)
return snapshots
@app.post("/api/v1/services", response_model=Service, status_code=status.HTTP_201_CREATED) @app.post("/api/v1/services", response_model=Service, status_code=status.HTTP_201_CREATED)
@@ -768,23 +770,23 @@ async def event_stream() -> StreamingResponse:
@app.get("/api/v1/overview", response_model=OverviewSummary) @app.get("/api/v1/overview", response_model=OverviewSummary)
def overview() -> OverviewSummary: def overview() -> OverviewSummary:
sync_incidents(store) health, overview_state = reconcile_incidents(store)
# Only status and coverage are counted; discovery context is not needed. services = _visible_services(health.services)
snapshots = _service_snapshots(include_hidden=False, include_context=False)
overview_state = incident_overview(store)
counts: dict[str, int] = {} counts: dict[str, int] = {}
coverage: dict[str, int] = {} coverage: dict[str, int] = {}
for snapshot in snapshots: for service in services:
counts[snapshot.effective_status.value] = counts.get(snapshot.effective_status.value, 0) + 1 status = health.effective[service.id].value
state = snapshot.service.monitoring_state.value counts[status] = counts.get(status, 0) + 1
state = service.monitoring_state.value
coverage[state] = coverage.get(state, 0) + 1 coverage[state] = coverage.get(state, 0) + 1
services_by_id = {service.id: service for service in health.services}
return OverviewSummary( return OverviewSummary(
generated_at=overview_state.generated_at, generated_at=overview_state.generated_at,
total_services=len(snapshots), total_services=len(services),
health_counts=counts, health_counts=counts,
active_incidents=len(store.list_incidents(active_only=True)), active_incidents=len(store.list_incidents(active_only=True, services=services_by_id)),
likely_root_causes=[candidate.service_name for candidate in overview_state.candidates], likely_root_causes=[candidate.service_name for candidate in overview_state.candidates],
flapping_services=[snapshot.service.name for snapshot in snapshots if snapshot.flapping], flapping_services=[service.name for service in services if service.flapping],
recent_events=store.list_events(limit=10), recent_events=store.list_events(limit=10),
monitoring_coverage=coverage, monitoring_coverage=coverage,
) )
@@ -982,8 +984,8 @@ def _semantic_representation(include_hidden: bool) -> CachedRepresentation:
cached = semantic_cache.get(cache_key, revision) cached = semantic_cache.get(cache_key, revision)
if cached is not None: if cached is not None:
return cached return cached
snapshots = _service_snapshots(include_hidden=include_hidden, include_context=False) snapshots, health = _service_snapshots(include_hidden=include_hidden, include_details=False)
incident_state = incident_overview(store) incident_state = incident_overview(store, health=health)
root_ids = {candidate.service_id for candidate in incident_state.candidates} root_ids = {candidate.service_id for candidate in incident_state.candidates}
affected_ids = { affected_ids = {
service_id service_id
+7 -2
View File
@@ -2134,8 +2134,9 @@ class Store:
event_bus.publish({"event_type": "topology.changed", "message": "Synthetische demo afgesloten"}) event_bus.publish({"event_type": "topology.changed", "message": "Synthetische demo afgesloten"})
return True return True
def list_incidents(self, active_only: bool = False, limit: int = 100) -> list[IncidentRecord]: def list_incidents(
services = {service.id: service for service in self.list_services()} self, active_only: bool = False, limit: int = 100, *, services: dict[str, Service] | None = None
) -> list[IncidentRecord]:
with self._connect() as db: with self._connect() as db:
query = "SELECT * FROM incidents" query = "SELECT * FROM incidents"
params: tuple[Any, ...] = () params: tuple[Any, ...] = ()
@@ -2144,6 +2145,10 @@ class Store:
query += " ORDER BY detected_at DESC LIMIT ?" query += " ORDER BY detected_at DESC LIMIT ?"
params += (limit,) params += (limit,)
rows = db.execute(query, params).fetchall() rows = db.execute(query, params).fetchall()
if not rows:
return []
if services is None:
services = {service.id: service for service in self.list_services()}
return [self._row_to_incident(row, services) for row in rows] return [self._row_to_incident(row, services) for row in rows]
def get_incident(self, incident_id: str) -> IncidentRecord | None: def get_incident(self, incident_id: str) -> IncidentRecord | None:
+1 -1
View File
@@ -1,6 +1,6 @@
[project] [project]
name = "servicemap-backend" name = "servicemap-backend"
version = "1.6.3" version = "1.6.4"
description = "ServiceMap API, topology intelligence and probe engine" description = "ServiceMap API, topology intelligence and probe engine"
requires-python = ">=3.12" requires-python = ">=3.12"
dependencies = [ dependencies = [
+35
View File
@@ -53,6 +53,41 @@ def _mocked_broker_client(
return client, options return client, options
def test_reopened_inventory_client_reads_atomically_rotated_broker_token(tmp_path, monkeypatch) -> None:
token_file = tmp_path / "servicemap-docker-broker.token"
token_file.write_text("initial-token", encoding="utf-8")
monkeypatch.setenv("SERVICEMAP_DOCKER_PROVIDER", "broker")
monkeypatch.setenv("SERVICEMAP_DOCKER_BROKER_URL", "https://broker.internal")
monkeypatch.setenv("SERVICEMAP_DOCKER_BROKER_TOKEN_FILE", str(token_file))
seen = []
def inventory(request):
seen.append(request.headers["authorization"])
return httpx.Response(200, json={"items": []})
original_client = httpx.Client
monkeypatch.setattr(
docker_provider.httpx, "Client",
lambda **kwargs: original_client(transport=httpx.MockTransport(inventory), **kwargs),
)
client = docker_provider.docker_client_for_inventory("")
try:
assert client.containers.list() == []
finally:
client.close()
replacement = tmp_path / "next-token"
replacement.write_text("rotated-token", encoding="utf-8")
replacement.replace(token_file)
client = docker_provider.docker_client_for_inventory("")
try:
assert client.containers.list() == []
finally:
client.close()
assert seen == ["Bearer initial-token", "Bearer rotated-token"]
def test_inventory_uses_authenticated_fixed_get_and_health_check_has_no_token(monkeypatch) -> None: def test_inventory_uses_authenticated_fixed_get_and_health_check_has_no_token(monkeypatch) -> None:
requests = [] requests = []
@@ -353,12 +353,35 @@ def test_topology_request_budget_at_300_services(tmp_path: Path, monkeypatch) ->
return original() return original()
monkeypatch.setattr(store, "_connect", counting_connect) monkeypatch.setattr(store, "_connect", counting_connect)
evidence_reads = 0
read_evidence = store.health_evidence_for_services
def counting_evidence(service_ids, **kwargs):
nonlocal evidence_reads
evidence_reads += 1
return read_evidence(service_ids, **kwargs)
monkeypatch.setattr(store, "health_evidence_for_services", counting_evidence)
topology_reads = 0
list_services = store.list_services
def counting_services():
nonlocal topology_reads
topology_reads += 1
return list_services()
monkeypatch.setattr(store, "list_services", counting_services)
client = TestClient(main_module.app) client = TestClient(main_module.app)
budget_ms = os.environ.get("SERVICEMAP_API_P95_BUDGET_MS") budget_ms = os.environ.get("SERVICEMAP_API_P95_BUDGET_MS")
for endpoint in ("/api/v1/topology/semantic", "/api/v1/overview"): for endpoint in ("/api/v1/topology/semantic", "/api/v1/overview"):
connections = 0 connections = 0
evidence_reads = 0
topology_reads = 0
main_module.semantic_cache.clear()
assert client.get(endpoint).status_code == 200 assert client.get(endpoint).status_code == 200
assert evidence_reads == 1, (endpoint, evidence_reads)
assert topology_reads == 1, (endpoint, topology_reads)
assert connections <= 30, (endpoint, connections) assert connections <= 30, (endpoint, connections)
elapsed_ms = [] elapsed_ms = []
for _ in range(20): for _ in range(20):
+4 -3
View File
@@ -24,7 +24,7 @@ services:
# environment or volume fallback in this deployment contract. # environment or volume fallback in this deployment contract.
SERVICEMAP_DOCKER_PROVIDER: broker SERVICEMAP_DOCKER_PROVIDER: broker
SERVICEMAP_DOCKER_BROKER_URL: ${SERVICEMAP_DOCKER_BROKER_URL:?set SERVICEMAP_DOCKER_BROKER_URL} SERVICEMAP_DOCKER_BROKER_URL: ${SERVICEMAP_DOCKER_BROKER_URL:?set SERVICEMAP_DOCKER_BROKER_URL}
SERVICEMAP_DOCKER_BROKER_TOKEN_FILE: /run/secrets/servicemap-docker-broker.token SERVICEMAP_DOCKER_BROKER_TOKEN_FILE: /run/servicemap-broker/servicemap-docker-broker.token
SERVICEMAP_APPOPS_URL: ${SERVICEMAP_APPOPS_URL:-} SERVICEMAP_APPOPS_URL: ${SERVICEMAP_APPOPS_URL:-}
SERVICEMAP_PROBE_HOST: ${SERVICEMAP_PROBE_HOST:-} SERVICEMAP_PROBE_HOST: ${SERVICEMAP_PROBE_HOST:-}
SERVICEMAP_AUTH_MODE: ${SERVICEMAP_AUTH_MODE:-token} SERVICEMAP_AUTH_MODE: ${SERVICEMAP_AUTH_MODE:-token}
@@ -41,8 +41,9 @@ services:
volumes: volumes:
- servicemap_data:/data - servicemap_data:/data
- type: bind - type: bind
source: ${SERVICEMAP_DOCKER_BROKER_TOKEN_HOST_FILE:?set SERVICEMAP_DOCKER_BROKER_TOKEN_HOST_FILE} # A directory bind sees token replacements made by atomic rename.
target: /run/secrets/servicemap-docker-broker.token source: ${SERVICEMAP_DOCKER_BROKER_TOKEN_HOST_DIRECTORY:?set SERVICEMAP_DOCKER_BROKER_TOKEN_HOST_DIRECTORY}
target: /run/servicemap-broker
read_only: true read_only: true
bind: bind:
create_host_path: false create_host_path: false
+1 -1
View File
@@ -35,7 +35,7 @@ v1.6.1 adds no schema migration. Its health-only observation loop is distinct fr
v1.6.2 keeps the same schema and evidence scopes. An AppOps `warning` observation is degraded application evidence; it cannot resolve a component. Evidence freshness is recomputed when persisted claims are read, so an expired claim cannot appear fresh in the raw inspector/API payload. The current MCP Hub Docker read broker cannot replace the production socket provider yet: its registration covers two unrelated projects, its ServiceMap-scoped inventory is empty, and its short-lived HMAC service-token contract rejects a raw bearer secret. Cutover requires a dedicated ServiceMap read identity, full bounded inventory parity and an explicit network path; broker mode remains fail-closed with no socket fallback. v1.6.2 keeps the same schema and evidence scopes. An AppOps `warning` observation is degraded application evidence; it cannot resolve a component. Evidence freshness is recomputed when persisted claims are read, so an expired claim cannot appear fresh in the raw inspector/API payload. The current MCP Hub Docker read broker cannot replace the production socket provider yet: its registration covers two unrelated projects, its ServiceMap-scoped inventory is empty, and its short-lived HMAC service-token contract rejects a raw bearer secret. Cutover requires a dedicated ServiceMap read identity, full bounded inventory parity and an explicit network path; broker mode remains fail-closed with no socket fallback.
The HTTP discovery routes accept only the Docker host and AppOps URL selected in deployment configuration. A request body cannot turn the container into a general-purpose client for another Docker daemon or internal HTTP endpoint. The private-LAN deployment keeps OIDC disabled because it has no dedicated browser client or tested owner login path. Since v1.6.3 it runs in `token` mode, so mutation APIs need the admin token instead of depending on the LAN perimeter. Broker mode must be deployed without the legacy Docker socket bind even though the current socket-mode Compose file retains it. The HTTP discovery routes accept only the Docker host and AppOps URL selected in deployment configuration. A request body cannot turn the container into a general-purpose client for another Docker daemon or internal HTTP endpoint. The private-LAN deployment keeps OIDC disabled because it has no dedicated browser client or tested owner login path. Since v1.6.3 it runs in `token` mode, so mutation APIs need the admin token instead of depending on the LAN perimeter. The broker Compose uses a dedicated read-only token directory and never mounts the Docker socket. A scoped issuer can atomically replace the token in that directory. Each new inventory client reads the current file. Activation still requires a dedicated Hub identity, matching inventory coverage and a healthy rollback path.
The v1.4 semantic projection is deliberately not a parallel datastore. `semantic.py` derives Domain → Application → Component from canonical services, relations, runtime/monitoring state and incident analysis. Logical relations are grouped at query time so one graph edge retains all independent evidence records and their first/last-seen provenance. v1.6.1 resolves application health separately: fresh aggregate AppOps evidence can answer an application but never a component; direct component failures override weak aggregate health and conflicting claims remain visible. Semantic application identity uses locked operator grouping, Compose provenance and stable source references before a display name, preventing generic provider labels from collapsing unrelated services. Bulk evidence lookup serves the complete semantic projection in one bounded SQL query rather than an application-by-application scan. v1.6.3 matches direct and linked claims through two separately indexed lookups (a `UNION`) and applies the per-service limit with a window function, because an `OR` across the link join forced a full `health_evidence` scan. Direct, dependency and effective health for incidents, the overview and service detail all come from one bulk read and one in-memory traversal (`health.topology_health`), never a per-node recursive SQLite walk. Snapshot discovery context (sources and relation evidence) is also read in bulk. The v1.4 semantic projection is deliberately not a parallel datastore. `semantic.py` derives Domain → Application → Component from canonical services, relations, runtime/monitoring state and incident analysis. Logical relations are grouped at query time so one graph edge retains all independent evidence records and their first/last-seen provenance. v1.6.1 resolves application health separately: fresh aggregate AppOps evidence can answer an application but never a component; direct component failures override weak aggregate health and conflicting claims remain visible. Semantic application identity uses locked operator grouping, Compose provenance and stable source references before a display name, preventing generic provider labels from collapsing unrelated services. Bulk evidence lookup serves the complete semantic projection in one bounded SQL query rather than an application-by-application scan. v1.6.3 matches direct and linked claims through two separately indexed lookups (a `UNION`) and applies the per-service limit with a window function, because an `OR` across the link join forced a full `health_evidence` scan. Direct, dependency and effective health for incidents, the overview and service detail all come from one bulk read and one in-memory traversal (`health.topology_health`), never a per-node recursive SQLite walk. Snapshot discovery context (sources and relation evidence) is also read in bulk.
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "servicemap-frontend", "name": "servicemap-frontend",
"version": "1.6.3", "version": "1.6.4",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "servicemap-frontend", "name": "servicemap-frontend",
"version": "1.6.3", "version": "1.6.4",
"dependencies": { "dependencies": {
"@fontsource-variable/inter": "^5.3.0", "@fontsource-variable/inter": "^5.3.0",
"@xyflow/react": "^12.8.5", "@xyflow/react": "^12.8.5",
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "servicemap-frontend", "name": "servicemap-frontend",
"private": true, "private": true,
"version": "1.6.3", "version": "1.6.4",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
+1 -1
View File
@@ -4414,7 +4414,7 @@ ${dependents.length} service(s) zijn ervan afhankelijk en verliezen die afhankel
: "Alles controleren"} : "Alles controleren"}
</span> </span>
</button> </button>
<ActionsMenu label="Meer acties" footer={<small>ServiceMap v1.6.3</small>}> <ActionsMenu label="Meer acties" footer={<small>ServiceMap v1.6.4</small>}>
{(close) => ( {(close) => (
<> <>
{writeAuth === "admin_token" && {writeAuth === "admin_token" &&
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "servicemap-workspace", "name": "servicemap-workspace",
"version": "1.6.3", "version": "1.6.4",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "servicemap-workspace", "name": "servicemap-workspace",
"version": "1.6.3" "version": "1.6.4"
} }
} }
} }
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "servicemap-workspace", "name": "servicemap-workspace",
"private": true, "private": true,
"version": "1.6.3", "version": "1.6.4",
"scripts": { "scripts": {
"install:frontend": "npm --prefix frontend ci --no-audit --no-fund", "install:frontend": "npm --prefix frontend ci --no-audit --no-fund",
"lint": "npm run install:frontend && npm --prefix frontend run lint", "lint": "npm run install:frontend && npm --prefix frontend run lint",