Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

feat(escalations): ack-clock escalation bridge for unacknowledged CRITICAL/HIGH cases (#1573)

alexmateescuf8d92e6ec227
diff --git a/.env.example b/.env.example
index 5040764da..069eabe5d 100644
--- a/.env.example
+++ b/.env.example
@@ -552,3 +552,12 @@ SSO_GROUPS_CLAIM=
# aisoc_sso_connections, managed via /api/v1/sso-connections by callers
# holding settings:write. Provisioning defaults there are viewer + first
# login only + JIT on; admin roles cannot be granted through any mapping.
+
+# --- escalation bridge (escalations profile) ---
+# Power Automate 'Post card in a chat or channel' webhook used by the
+# ack-clock escalation bridge (services/escalations).
+# https:// required — the bridge refuses any other scheme at startup.
+AISOC_ESCALATION_TEAMS_URL=
+# The address escalation cards link back to; defaults to the console's own
+# default. Set it to this deployment's public console origin.
+AISOC_CONSOLE_URL=http://localhost:3000
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index c64c8c76e..f36adfc40 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1844,6 +1844,7 @@ jobs:
service:
- actions
- connectors
+ - escalations
- mesh
- osquery-tls
- slack-bot
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fbe51c195..d5f7768ef 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Added
+
+- **An opt-in ack-clock escalation bridge** (`services/escalations`, compose
+ profile `escalations`; externally contributed). The native outbound-webhook
+ subsystem is complete but its `enqueue_event` has no production callers, so
+ a CRITICAL case nobody acknowledged produced no notification at all. The
+ bridge watches `aisoc_cases.acknowledged_at`: unacknowledged CRITICAL cases
+ get a Teams card after a grace period with capped re-nags, unacknowledged
+ HIGH cases arrive as one daily digest with a pipeline-health line, and
+ dedup/nag state survives restarts. Deployment-wide by design (one
+ operator-configured webhook; per-tenant routing stays the native
+ subsystem's job, into which this retires when the emitters are wired) and
+ the webhook must be https. The sweep's cross-tenant reads are recorded on
+ the tenant-predicate ratchet with that reasoning, the service is
+ SLO-exempt with its reason, and its status filter is pinned against the
+ case table's own CHECK constraint by test.
+
### Security
- **Dependencies:** the Oct-31 `minimatch` / `glob` advisory wave worked
diff --git a/apps/docs/docs/quickstart.md b/apps/docs/docs/quickstart.md
index 9b3454c50..25bec2091 100644
--- a/apps/docs/docs/quickstart.md
+++ b/apps/docs/docs/quickstart.md
@@ -261,6 +261,7 @@ does not.
| `monitoring` | **prometheus** (9091) · **grafana** (3001) · **alertmanager** (9094) · **tempo** (3200) · **otel-collector** (4317/4318) |
| `osquery` | **osquery-tls** (8091) |
| `mcp` | **mcp** (8096, streamable-HTTP MCP server, off by default) |
+| `escalations` | **escalations** (ack-clock bridge: Teams cards for unacknowledged CRITICAL/HIGH cases; off by default, needs `AISOC_ESCALATION_TEAMS_URL`) |
CORE is 16 long-running services, or 17 counting `ollama-pull`, which fetches
the model once and exits, and `full` is 22. `connectors` and `actions` moved
diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml
index 6de1235f4..6de7664e0 100644
--- a/docker-compose.prod.yml
+++ b/docker-compose.prod.yml
@@ -431,6 +431,14 @@ services:
condition: service_completed_successfully
ports: !reset []
+ # Opt-in ack-clock bridge (profile `escalations`). No ports in the base
+ # file, so nothing to reset; it only needs to wait for the credential
+ # preflight like every other service.
+ escalations:
+ depends_on:
+ preflight-secrets:
+ condition: service_completed_successfully
+
osquery-tls:
depends_on:
preflight-secrets:
diff --git a/docker-compose.yml b/docker-compose.yml
index a0ef7233d..309e0daf9 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -70,6 +70,8 @@ networks:
driver: bridge
volumes:
+ # ack-clock bridge dedup/nag state (escalations service)
+ escalation-state:
tempo_data:
postgres_data:
redis_data:
@@ -1570,6 +1572,37 @@ services:
# `ghcr.io/beenuar/aisoc-mcp` package has been published yet and naming one
# here would tell an operator to pull something that does not exist.
# `scripts/check_published_images.py` is what catches that.
+ # Ack-clock escalator: Teams cards for unacknowledged CRITICAL cases and a
+ # daily HIGH digest. Opt-in profile — the native outbound-webhook emitters
+ # (services/api enqueue_event) have no production callers yet, so this
+ # service is the interim escalation transport. Enable with
+ # docker compose --profile escalations up -d
+ # and set AISOC_ESCALATION_TEAMS_URL in .env (a Power Automate Teams webhook).
+ escalations:
+ build:
+ context: ./services/escalations
+ container_name: aisoc-escalations
+ profiles:
+ - escalations
+ environment:
+ # Plain postgresql:// scheme: this service uses psycopg (sync), not asyncpg.
+ DATABASE_URL: postgresql://aisoc_app:${AISOC_APP_DB_PASSWORD:-aisoc_app_dev_secret}@postgres:5432/aisoc
+ AISOC_ESCALATION_TEAMS_URL: ${AISOC_ESCALATION_TEAMS_URL:-}
+ AISOC_CONSOLE_URL: ${AISOC_CONSOLE_URL:-http://localhost:3000}
+ ESC_TICK_SECONDS: 900
+ ESC_CRITICAL_GRACE_MINUTES: 30
+ ESC_CRITICAL_NAG_HOURS: 4
+ ESC_CRITICAL_MAX_NAGS: 3
+ ESC_DIGEST_HOUR_UTC: 8
+ volumes:
+ - escalation-state:/data
+ depends_on:
+ postgres:
+ condition: service_healthy
+ networks:
+ - aisoc
+ restart: unless-stopped
+
mcp:
build:
context: .
diff --git a/docs/operations/slos.yaml b/docs/operations/slos.yaml
index 7e61ea16a..72604bc65 100644
--- a/docs/operations/slos.yaml
+++ b/docs/operations/slos.yaml
@@ -103,5 +103,11 @@ services:
exempt:
demo-producer:
reason: Demo-only synthetic event generator; not a production service.
+ escalations:
+ reason: >-
+ Opt-in ack-clock notification bridge (profile `escalations`): a
+ single polling loop with no service endpoint to measure, designed to
+ retire when the native outbound-webhook emitters are wired. Its own
+ failure mode (a missed tick) is logged and retried next tick.
osquery-extensions:
reason: Build-time Go virtual-table library shipped with the osquery agent; no service endpoint.
diff --git a/scripts/check_tenant_query_predicates.py b/scripts/check_tenant_query_predicates.py
index 3629e094b..1ef727a89 100644
--- a/scripts/check_tenant_query_predicates.py
+++ b/scripts/check_tenant_query_predicates.py
@@ -810,6 +810,24 @@ RATCHET: dict[str, str] = {
"omitted the predicate would be flagged there. Entry is keyed on this table, so an "
"unscoped statement on any other table in this module still fails"
),
+ # -- escalations bridge: a deployment-level pager, not a tenant channel ----
+ # The opt-in ack-clock bridge (profile `escalations`) sweeps every tenant's
+ # unacknowledged cases to ONE operator-configured webhook by design: it is
+ # the interim transport while the native outbound-webhook emitters (which
+ # do per-tenant routing) have no production callers, and it retires when
+ # they are wired. The deployment-wide read is the feature, documented in
+ # the service README with the multi-tenant caveat. No route handler can
+ # reach these — the service has no server at all, only a polling loop.
+ "services/escalations/app/bridge.py::fetch_unacked::aisoc_cases": (
+ "deployment-level escalation sweep across tenants to one operator webhook; "
+ "per-tenant routing is the native outbound-webhook subsystem's job, which this bridges until wired"
+ ),
+ "services/escalations/app/bridge.py::pipeline_health::aisoc_dead_letters": (
+ "deployment-wide health count (dead letters in 24h) for the daily digest; a per-tenant count would misstate pipeline health"
+ ),
+ "services/escalations/app/bridge.py::pipeline_health::investigation_runs": (
+ "deployment-wide health count (failed investigations in 24h) for the daily digest, same reasoning as the dead-letter count"
+ ),
}
#: Raising this is a deliberate act with a diff attached. Appending to RATCHET
@@ -913,7 +931,7 @@ RATCHET: dict[str, str] = {
# *stricter*: the statement that had to be fixed rather than recorded,
# `fetch_enabled_connectors` called from a request handler, is absent from the
# list because the route now uses a sibling that filters in SQL.
-MAX_RATCHET = 77
+MAX_RATCHET = 80
# ---------------------------------------------------------------------------
diff --git a/scripts/mypy_baseline.json b/scripts/mypy_baseline.json
index 664f989c5..f174d79d7 100644
--- a/scripts/mypy_baseline.json
+++ b/scripts/mypy_baseline.json
@@ -1,9 +1,9 @@
{
"(environment)": {
"flags": "--no-color-output --no-error-summary --no-site-packages --no-incremental",
- "mypy": "2.3.1",
+ "mypy": "2.4.1",
"mypy_major": "2",
- "python": "3.14"
+ "python": "3.11"
},
"(unmanaged)": {
"plugins/mttr-widget/plugin.py": {
@@ -491,6 +491,7 @@
"union-attr": 16
}
},
+ "services/escalations": {},
"services/fusion": {
"tests/test_consumer_dlq.py": {
"arg-type": 1
diff --git a/services/escalations/Dockerfile b/services/escalations/Dockerfile
new file mode 100644
index 000000000..23f64a3fe
--- /dev/null
+++ b/services/escalations/Dockerfile
@@ -0,0 +1,41 @@
+# ── Stage 1: turn the lock into a hash-pinned requirements file ──────────────
+#
+# Same shape as every other Python service here (see
+# services/honeytokens/Dockerfile for the full rationale): poetry runs in this
+# stage and nowhere else, so its own dependency closure never reaches the
+# runtime image, and `poetry export` still refuses a lock that no longer
+# matches the manifest — editing pyproject.toml without re-locking stays a
+# build error rather than a silent re-resolution.
+FROM python:3.11-slim AS deps
+
+RUN pip install --no-cache-dir poetry==2.4.1 poetry-plugin-export==1.9.0
+
+WORKDIR /app
+COPY pyproject.toml poetry.lock ./
+
+RUN poetry export --only main --format requirements.txt --output /requirements.txt
+
+
+# ── Stage 2: the runtime image ───────────────────────────────────────────────
+FROM python:3.11-slim
+
+WORKDIR /app
+ENV PYTHONDONTWRITEBYTECODE=1 \
+ PYTHONUNBUFFERED=1 \
+ PIP_NO_CACHE_DIR=1 \
+ PIP_DISABLE_PIP_VERSION_CHECK=1
+
+COPY --from=deps /requirements.txt /requirements.txt
+
+# Every version here comes from poetry.lock by way of the stage above;
+# --require-hashes refuses anything not pinned `==` with a matching hash.
+RUN pip install --no-cache-dir --require-hashes -r /requirements.txt
+
+COPY pyproject.toml poetry.lock ./
+COPY app/ ./app/
+
+USER nobody
+
+# `python -m app` runs app/__main__.py, which the module-reachability gate
+# recognises as the service entry point; it calls bridge.main().
+CMD ["python", "-u", "-m", "app"]
diff --git a/services/escalations/README.md b/services/escalations/README.md
new file mode 100644
index 000000000..00aa3d7ff
--- /dev/null
+++ b/services/escalations/README.md
@@ -0,0 +1,48 @@
+# escalations — ack-clock escalation bridge
+
+Teams escalations for cases nobody has acknowledged, until the native
+outbound-webhook emitters are wired (`services/api/app/services/
+outbound_webhooks.py::enqueue_event` currently has no production callers).
+
+Watches the platform's own ack clock (`aisoc_cases.acknowledged_at`):
+
+- **CRITICAL** unacknowledged >= 30 min -> immediate card, re-nag every 4 h,
+ max 3 sends per case.
+- **HIGH** unacknowledged -> one digest per day (08:00 UTC) plus a pipeline
+ health line (failed investigations / dead-letters, last 24 h).
+
+Dedup + nag state persists in the `escalation-state` volume; restarts never
+double-send. All thresholds are env-tunable (`ESC_*`, see docker-compose.yml).
+
+Two semantics to know before enabling it:
+
+- **What stops the clock:** a case counts as acknowledged only when
+ `aisoc_cases.acknowledged_at` is written — today that is the console's
+ acknowledge action and joining the case's war room. Editing, assigning or
+ moving a case along the status ladder does **not** stop the clock; an
+ actively-investigated CRITICAL that nobody acknowledged still escalates (up
+ to the nag cap). That is the point of an ack clock, stated here so nobody
+ expects otherwise.
+- **The sweep is deployment-wide.** Every tenant's unacknowledged cases
+ escalate to the one configured webhook — this is a deployment-level pager,
+ not per-tenant notification (that is the native outbound-webhook
+ subsystem's job, which this service bridges until its emitters are wired,
+ and into which it retires). On a multi-tenant deployment, case titles from
+ every tenant reach that one channel: enable this only where the channel's
+ audience is cleared to see all tenants. The cross-tenant reads are recorded
+ with this reasoning on `scripts/check_tenant_query_predicates.py`'s
+ ratchet.
+
+## Run
+
+ docker compose --profile escalations up -d
+
+The webhook target is any JSON POST endpoint that renders an Adaptive Card
+(payload fields: `severity`, `title`, `summary`, `case_id`, `opened_at`,
+`url`). The documented setup uses a Power Automate "Post card in a chat or
+channel" flow; note that that action requires the bare Adaptive Card object,
+not a `message`/`attachments` envelope.
+
+## Tests
+
+ python -m pytest tests/ -q
diff --git a/services/escalations/app/__init__.py b/services/escalations/app/__init__.py
new file mode 100644
index 000000000..561f3ae94
--- /dev/null
+++ b/services/escalations/app/__init__.py
@@ -0,0 +1 @@
+"""Ack-clock escalation bridge package (see bridge.py for the whole story)."""
diff --git a/services/escalations/app/__main__.py b/services/escalations/app/__main__.py
new file mode 100644
index 000000000..1bee9fa60
--- /dev/null
+++ b/services/escalations/app/__main__.py
@@ -0,0 +1,12 @@
+"""Entry point: `python -m app` (and the container CMD) start the bridge here.
+
+Named `__main__.py` so the module-reachability gate recognises it as a
+service entry point the way it does every other service's — the bridge is
+started by a command, not imported, so without this the gate reads bridge.py
+as dead code (it has no production importer).
+"""
+
+from app.bridge import main
+
+if __name__ == "__main__":
+ main()
diff --git a/services/escalations/app/bridge.py b/services/escalations/app/bridge.py
new file mode 100644
index 000000000..41b31804a
--- /dev/null
+++ b/services/escalations/app/bridge.py
@@ -0,0 +1,266 @@
+"""Ack-clock escalation bridge.
+
+The platform's outbound webhook subsystem (services/api/app/services/
+outbound_webhooks.py) is complete but not yet wired: enqueue_event has no
+production callers. Until it is, this service fills the gap by watching the
+platform's OWN ack clock (aisoc_cases.acknowledged_at) and
+posting escalations to a Microsoft Teams Power Automate workflow (or any
+generic JSON webhook):
+
+ * CRITICAL cases unacknowledged for >= ACK_GRACE_MINUTES escalate
+ immediately, re-nagging every CRIT_NAG_HOURS up to CRIT_MAX_NAGS times.
+ * unacknowledged HIGH cases arrive in one daily digest at DIGEST_HOUR_UTC
+ (first tick at or after that hour), with a one-line pipeline health
+ summary (failed investigations / dead-letters in the last 24h).
+
+Dedup and nag state live in a JSON file so restarts never double-send.
+
+Two deliberate semantics, stated so nobody infers better ones:
+
+* **"Acknowledged" means `acknowledged_at` was written** — today the console's
+ acknowledge action and a war-room join write it (`war_room.py` stamps it
+ with COALESCE). A case merely being edited, assigned or moved along the
+ status ladder does NOT stop the clock; that is the point of an ack clock.
+* **The sweep is deployment-wide, not per-tenant.** Every tenant's
+ unacknowledged cases escalate to the one operator-configured webhook,
+ because this bridge is a deployment-level pager, not a tenant notification
+ channel — per-tenant routing is exactly what the native outbound-webhook
+ subsystem does once its emitters are wired, and what this service retires
+ into. On a multi-tenant deployment that means case titles from every tenant
+ reach one channel: run it only where the operators of that channel are
+ cleared to see every tenant, or not at all. The cross-tenant reads are
+ recorded on `scripts/check_tenant_query_predicates.py`'s ratchet with this
+ reasoning.
+"""
+
+from __future__ import annotations
+
+import json
+import os
+import time
+import urllib.request
+from dataclasses import dataclass
+from datetime import UTC, datetime
+
+import psycopg
+from psycopg.rows import dict_row
+
+# --- configuration (env) ------------------------------------------------------
+DATABASE_URL = os.environ.get("DATABASE_URL", "")
+TEAMS_URL = os.environ.get("AISOC_ESCALATION_TEAMS_URL", "")
+# Deployment-neutral default: the console's own default address. A specific
+# deployment's hostname here is how one install's URL ends up inside
+# another's escalation cards.
+CONSOLE_URL = os.environ.get("AISOC_CONSOLE_URL", "http://localhost:3000")
+TICK_SECONDS = int(os.environ.get("ESC_TICK_SECONDS", "900"))
+ACK_GRACE_MINUTES = int(os.environ.get("ESC_CRITICAL_GRACE_MINUTES", "30"))
+CRIT_NAG_HOURS = int(os.environ.get("ESC_CRITICAL_NAG_HOURS", "4"))
+CRIT_MAX_NAGS = int(os.environ.get("ESC_CRITICAL_MAX_NAGS", "3"))
+DIGEST_HOUR_UTC = int(os.environ.get("ESC_DIGEST_HOUR_UTC", "8"))
+STATE_FILE = os.environ.get("ESC_STATE_FILE", "/data/escalation-state.json")
+
+# Exactly the non-terminal members of aisoc_cases' status CHECK constraint
+# (migration 012_case_management.sql:
+# new|triaged|investigating|contained|resolved|closed).
+# "open" is not in that vocabulary — a filter member that can never match —
+# and "contained" is included deliberately: containment can be automated,
+# and the ack clock measures whether a human has acknowledged, not whether
+# automation has acted. test_ladder.py pins this tuple against the
+# migration's own CHECK clause so the two cannot drift apart silently.
+OPEN_STATUSES = ("new", "triaged", "investigating", "contained")
+
+
+def log(msg: str) -> None:
+ print(f"{datetime.now(UTC).isoformat(timespec='seconds')} {msg}", flush=True)
+
+
+# --- pure decision logic (unit-tested) --------------------------------------
+@dataclass
+class Case:
+ id: str
+ case_number: str
+ title: str
+ severity: str
+ opened_at: datetime
+
+ @property
+ def url(self) -> str:
+ return f"{CONSOLE_URL}/cases/{self.id}"
+
+ @property
+ def ref(self) -> str:
+ return self.case_number or self.id[:8]
+
+
+@dataclass
+class NagState:
+ count: int = 0
+ last: str = ""
+
+
+def should_escalate_critical(case: Case, nag: NagState | None, now: datetime) -> bool:
+ """A CRITICAL case escalates once past the ack grace period, then at
+ most every CRIT_NAG_HOURS, up to CRIT_MAX_NAGS total sends."""
+ if (now - case.opened_at).total_seconds() < ACK_GRACE_MINUTES * 60:
+ return False
+ if nag is None or not nag.last:
+ return True
+ last = datetime.fromisoformat(nag.last)
+ if (now - last).total_seconds() < CRIT_NAG_HOURS * 3600:
+ return False
+ return nag.count < CRIT_MAX_NAGS
+
+
+def should_send_digest(digest_last: str, now: datetime) -> bool:
+ return now.hour >= DIGEST_HOUR_UTC and digest_last != now.strftime("%Y-%m-%d")
+
+
+def crit_payload(case: Case, age_minutes: float, nag_number: int) -> dict:
+ return {
+ "severity": "CRITICAL",
+ "title": case.title or "Critical case unacknowledged",
+ "summary": (f"Unacknowledged for {int(age_minutes)} min. Escalation {nag_number}/{CRIT_MAX_NAGS}."),
+ "case_id": case.ref,
+ "opened_at": case.opened_at.strftime("%Y-%m-%d %H:%M UTC"),
+ "url": case.url,
+ }
+
+
+def digest_payload(cases: list[Case], health: str, now: datetime) -> dict:
+ listed = "\n".join(f"- {c.ref}: {c.title}" for c in cases[:8])
+ more = f"\n…and {len(cases) - 8} more" if len(cases) > 8 else ""
+ return {
+ "severity": "DIGEST",
+ "title": f"AiSOC daily digest — {len(cases)} HIGH unacked",
+ "summary": f"{listed}{more}\n\nPipeline health: {health}",
+ "case_id": f"{len(cases)} HIGH open",
+ "opened_at": now.strftime("%Y-%m-%d %H:%M UTC"),
+ "url": f"{CONSOLE_URL}/cases",
+ }
+
+
+# --- state -------------------------------------------------------------------
+def load_state() -> dict:
+ try:
+ with open(STATE_FILE) as fh:
+ return json.load(fh)
+ except (OSError, ValueError):
+ return {"escalations": {}, "digest_last": ""}
+
+
+def save_state(state: dict) -> None:
+ os.makedirs(os.path.dirname(STATE_FILE), exist_ok=True)
+ tmp = STATE_FILE + ".tmp"
+ with open(tmp, "w") as fh:
+ json.dump(state, fh, indent=1)
+ os.replace(tmp, STATE_FILE)
+
+
+# --- IO ----------------------------------------------------------------------
+def post(url: str, payload: dict) -> int:
+ req = urllib.request.Request(url, data=json.dumps(payload).encode(), headers={"Content-Type": "application/json"}, method="POST")
+ # The URL is operator-supplied configuration (AISOC_ESCALATION_TEAMS_URL),
+ # validated https-only at startup by require_https_webhook() — never
+ # tenant- or request-derived, so the SSRF surface the audit rule
+ # (python.lang.security.audit.dynamic-urllib-use-detected) exists for does
+ # not apply. Bare nosemgrep because the fully-qualified id exceeds the
+ # line limit; this is the module's only urlopen.
+ with urllib.request.urlopen(req, timeout=15) as resp: # nosemgrep
+ return resp.status
+
+
+def require_https_webhook(url: str) -> str:
+ """Refuse a webhook target that is not https.
+
+ The value is operator-set, but a typo'd `http://` would send case titles
+ in cleartext and a `file://`/`ftp://` scheme would make urlopen do
+ something else entirely. Failing at startup names the problem while the
+ operator is still looking at the deployment.
+ """
+ if not url.startswith("https://"):
+ raise SystemExit(f"AISOC_ESCALATION_TEAMS_URL must be https:// (got scheme of {url.split(':', 1)[0]!r})")
+ return url
+
+
+def fetch_unacked(cur, severity: str) -> list[Case]:
+ rows = cur.execute(
+ "SELECT id, case_number, title, severity, opened_at FROM aisoc_cases "
+ "WHERE acknowledged_at IS NULL AND lower(severity) = %s AND status = ANY(%s) "
+ "ORDER BY opened_at ASC LIMIT 50",
+ (severity, list(OPEN_STATUSES)),
+ ).fetchall()
+ out = []
+ for r in rows:
+ opened = r["opened_at"]
+ if opened.tzinfo is None:
+ opened = opened.replace(tzinfo=UTC)
+ out.append(Case(str(r["id"]), r["case_number"] or "", r["title"] or "", r["severity"], opened))
+ return out
+
+
+def pipeline_health(cur) -> str:
+ bits = []
+ try:
+ n = cur.execute(
+ # The ledger table is `investigation_runs` (migration 008) — there
+ # is no `aisoc_`-prefixed variant, and the first draft queried one,
+ # which this try/except would have converted into a permanent
+ # "n/a" that read like a healthy pipeline with no failures.
+ "SELECT count(*) AS n FROM investigation_runs WHERE status = 'failed' AND created_at > now() - interval '24 hours'"
+ ).fetchone()["n"]
+ bits.append(f"investigation failures 24h: {n}")
+ except Exception:
+ bits.append("investigation failures 24h: n/a")
+ try:
+ n = cur.execute("SELECT count(*) AS n FROM aisoc_dead_letters WHERE created_at > now() - interval '24 hours'").fetchone()["n"]
+ bits.append(f"dead-letters 24h: {n}")
+ except Exception:
+ bits.append("dead-letters 24h: n/a")
+ return "; ".join(bits)
+
+
+# --- main loop ---------------------------------------------------------------
+def tick(state: dict) -> None:
+ now = datetime.now(UTC)
+ with psycopg.connect(DATABASE_URL, row_factory=dict_row) as conn:
+ cur = conn.cursor()
+ for case in fetch_unacked(cur, "critical"):
+ nag_d = state["escalations"].get(case.id)
+ nag = NagState(**nag_d) if nag_d else None
+ if not should_escalate_critical(case, nag, now):
+ continue
+ nag = nag or NagState()
+ age = (now - case.opened_at).total_seconds() / 60
+ code = post(TEAMS_URL, crit_payload(case, age, nag.count + 1))
+ log(f"critical escalation {case.ref} HTTP {code}")
+ nag.count += 1
+ nag.last = now.isoformat()
+ state["escalations"][case.id] = nag.__dict__
+
+ if should_send_digest(state.get("digest_last", ""), now):
+ highs = fetch_unacked(cur, "high")
+ if highs:
+ code = post(TEAMS_URL, digest_payload(highs, pipeline_health(cur), now))
+ log(f"daily digest HTTP {code} highs={len(highs)}")
+ state["digest_last"] = now.strftime("%Y-%m-%d")
+ save_state(state)
+
+
+def main() -> None:
+ if not TEAMS_URL:
+ raise SystemExit("AISOC_ESCALATION_TEAMS_URL is required")
+ require_https_webhook(TEAMS_URL)
+ if not DATABASE_URL:
+ raise SystemExit("DATABASE_URL is required")
+ log(f"escalation bridge up: tick={TICK_SECONDS}s grace={ACK_GRACE_MINUTES}m digest_hour={DIGEST_HOUR_UTC}Z console={CONSOLE_URL}")
+ state = load_state()
+ while True:
+ try:
+ tick(state)
+ except Exception as exc: # never let one bad tick kill the loop
+ log(f"ERROR tick: {type(exc).__name__}: {exc}")
+ time.sleep(TICK_SECONDS)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/services/escalations/poetry.lock b/services/escalations/poetry.lock
new file mode 100644
index 000000000..dfea21745
--- /dev/null
+++ b/services/escalations/poetry.lock
@@ -0,0 +1,379 @@
+# This file is automatically @generated by Poetry 2.4.1 and should not be changed by hand.
+
+[[package]]
+name = "colorama"
+version = "0.4.6"
+description = "Cross-platform colored terminal text."
+optional = true
+python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
+groups = ["main"]
+markers = "extra == \"dev\" and sys_platform == \"win32\""
+files = [
+ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"},
+ {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"},
+]
+
+[[package]]
+name = "coverage"
+version = "7.17.0"
+description = "Code coverage measurement for Python"
+optional = true
+python-versions = ">=3.11"
+groups = ["main"]
+markers = "extra == \"dev\""
+files = [
+ {file = "coverage-7.17.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:99a7b390cbccc6bf029ca4da3f0f607c218bb4085e9cd6b58a90d14ca12993c3"},
+ {file = "coverage-7.17.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f72640e02a470b57b15cd655820133f6892760209283a363a60e2df932d5f0fe"},
+ {file = "coverage-7.17.0-cp311-cp311-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:2dc9233f39149b5a4f4aba17a4b6bc5cca22e52cfc4b06fdb07d014439b8b2ea"},
+ {file = "coverage-7.17.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:8e8113d3852e9377421a61de1917df27b3abb25404a4ecf69f9e64612c4345b5"},
+ {file = "coverage-7.17.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c86a39539d10d666bb819c16c94d7edfc1aa2e0531b937f7c549b83d15177c6e"},
+ {file = "coverage-7.17.0-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:559f748446ee799803686b5784e3deb54c70d655ac386a860e06b11672504ba7"},
+ {file = "coverage-7.17.0-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:34d65c9e8e257f48a654908005046fbf1bc48d9540ae3776ad08c0acd010e10c"},
+ {file = "coverage-7.17.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:5b7fa0997b8eba7378ac66f31ec7f70164490353ab79b9667d37c0d365e50177"},
+ {file = "coverage-7.17.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:6ae0453a3390e67f7bfbe34417bbdf5b4ebfc21db23fb446a0a41115eeeca6ca"},
+ {file = "coverage-7.17.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:96151262832f3c230ebae23b2d6911ad549e1738465946c97004913ff06112ba"},
+ {file = "coverage-7.17.0-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:cd7397de6cc782f00fe5ac1d75e9b306bcfa49c8b6b8dd6ed1f7709393ad40b3"},
+ {file = "coverage-7.17.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:9d1fdf82c6fea57b5e9dada509f9ce9638c8334664e2c98c7f6f1ccf3d143ad2"},
+ {file = "coverage-7.17.0-cp311-cp311-win32.whl", hash = "sha256:38c86e5d74bbfd88a393fa3f91257c1225c63aa6db6d5918de3e49ab04f91c6e"},
+ {file = "coverage-7.17.0-cp311-cp311-win_amd64.whl", hash = "sha256:2ed3097c6817bc1a7fc8ae0a6131db74aa1150d863cccc308237ff362d3226b2"},
+ {file = "coverage-7.17.0-cp311-cp311-win_arm64.whl", hash = "sha256:6052e878b628abcd38fa5f2b64abebc686eed4e2267da42434017a9c6d24f241"},
+ {file = "coverage-7.17.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:0cfdc938ca3319d873d1f1252e60620a39aee4ebf9dbd7cc58238109ebda9c51"},
+ {file = "coverage-7.17.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:d523da3c2e4bca49417768bcdb1a443c5b359dc44b8b93a3102e118fce912c40"},
+ {file = "coverage-7.17.0-cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:adbf3450c0f3f2b2854e282a8758f2b3eddf787eeff24ec9c9bc2cbc38328cc1"},
+ {file = "coverage-7.17.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:85932227e9dd38e62cd29c17fefdfecfb919eead6af1e3259522d03cf85de983"},
+ {file = "coverage-7.17.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:30f5477aac9c9e4a0a641c55f8f8fddd7f3bd91176c912c50f40ffced96b4034"},
+ {file = "coverage-7.17.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:0b8bb651a4406fb6a983a905309fec1783443c65e1771b41e92740a0f4a1176b"},
+ {file = "coverage-7.17.0-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:0edeb6594f080c8de1263cccb239cb316ef77aeb959e2e0f38f2953fcc72a49e"},
+ {file = "coverage-7.17.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:da94ec0484e84fce5c7bf8d0f54b97767a90d992653a129b35634699d516e0a5"},
+ {file = "coverage-7.17.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:a25cc5e8c23a590815c6a7aa43624234d25cb23b21b484adb8a0daed59860db5"},
+ {file = "coverage-7.17.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:db645c81cf4d6bcb392ea1894aad65d55d1588a8472c834b25ca575da3029a56"},
+ {file = "coverage-7.17.0-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:6a80a11b90c4a03df1502304cf24ff953255b6b5d076ef79066ecf88baaff31f"},
+ {file = "coverage-7.17.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:e4eaf11d6b0f2147f46cfbf06fe7edcca6f095d0120da00ddc2458995ee869fc"},
+ {file = "coverage-7.17.0-cp312-cp312-win32.whl", hash = "sha256:912a29f338798541d795e2e25903c6fe7a99dee70a40fe4706a9a124649b523e"},
+ {file = "coverage-7.17.0-cp312-cp312-win_amd64.whl", hash = "sha256:88a1a9fb0075b83389dd9b403bb3fce976031b3c2aa0e05e3e57143cf639de69"},
+ {file = "coverage-7.17.0-cp312-cp312-win_arm64.whl", hash = "sha256:2c680e838ff9e68d491158625ca2c1ddb17d78d791bba96a31f8b839b4990438"},
+ {file = "coverage-7.17.0-cp313-cp313-android_24_arm64_v8a.whl", hash = "sha256:84538c040f4e6214f663459d89372ce4e6b2bbdd9d397ef0dca7b3ecd56b8eb2"},
+ {file = "coverage-7.17.0-cp313-cp313-android_24_x86_64.whl", hash = "sha256:6abfb6a4cf1cb1b67bc8fccdde177e2d2b781d0d34449e7078156547025140e5"},
+ {file = "coverage-7.17.0-cp313-cp313-ios_13_0_arm64_iphoneos.whl", hash = "sha256:ef65e96f0fc1a7c8b7644c7011d47a8228555e7888ac4d6246f715a7f3d7c398"},
+ {file = "coverage-7.17.0-cp313-cp313-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:55939ea4c097fda2edabf80fac5e49bef15597b950a9f29fc56292a895245feb"},
+ {file = "coverage-7.17.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:bfb6f868af552c0ceb2d19220b8cbcc2be096ca26163ac30e682a13041433429"},
+ {file = "coverage-7.17.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:8d823d66afd59566030539c49c7a6acaf3083996682be2dda760c63555842094"},
+ {file = "coverage-7.17.0-cp313-cp313-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:50678474e714c684b82c108e63fbb8f1bcf1266d8293a49980f1d08526f093b5"},
+ {file = "coverage-7.17.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:045c1eeb19fb4eae949850a761102fffb3a5f638b97f977912f95843e54f6669"},
+ {file = "coverage-7.17.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:dfb12891a773cbc2132349c77c690a045a882fe3f98b4bda50dfabb01893f9bd"},
+ {file = "coverage-7.17.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:3067608b4429629f640c1b23d2f69b05d2fd45e00ebb6ee9e8fad220a6c11722"},
+ {file = "coverage-7.17.0-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:a1762e85cbbe3b5ff9c6dcbcc1b89d5c72320094292b7b9572bf882c85e428b7"},
+ {file = "coverage-7.17.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:62bb77987d3f72a0aaa77c567ee7f9806bc2e748c8f46fafbe1fdb90dd148398"},
+ {file = "coverage-7.17.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:6cc31f27240d4e080437e3b8229d92f1d809c9a4f233607385373b73974e183e"},
+ {file = "coverage-7.17.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:61cde5222f1933d476647c5a25ed1a8678b7703098cb5a15f4a0aa39967d8c28"},
+ {file = "coverage-7.17.0-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:11f5f7fb2d97a0fe865f5e7bad4eb0619b957637f676bc088d13844adf26ba95"},
+ {file = "coverage-7.17.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:6e09612b1b82c9df1d2b6c85dee88d5aad3e73d77a8ec0b16ac6a7322cbdf5d9"},
+ {file = "coverage-7.17.0-cp313-cp313-win32.whl", hash = "sha256:bd3e9eb493631ff1ca34bf5efac25b5c66724f837bf6182c4fc771c55946423d"},
+ {file = "coverage-7.17.0-cp313-cp313-win_amd64.whl", hash = "sha256:f1fc9a7cea899c51d8a53e66c2f082a3d9e461ece32418d3ef0a0b90c32bfd3d"},
+ {file = "coverage-7.17.0-cp313-cp313-win_arm64.whl", hash = "sha256:e65a1e61a68493fbfbe44d8bec71b3231d81b9917f62d3dafe0e105072147e83"},
+ {file = "coverage-7.17.0-cp314-cp314-android_24_arm64_v8a.whl", hash = "sha256:dc5936491e306f2f6f095bd5fba593de11eb0375cee787ca1f245c3a333a523a"},
+ {file = "coverage-7.17.0-cp314-cp314-android_24_x86_64.whl", hash = "sha256:968c5fb6e0c83cab752d79a70209648ce4d90cae815c60fa229b59e264601062"},
+ {file = "coverage-7.17.0-cp314-cp314-ios_13_0_arm64_iphoneos.whl", hash = "sha256:12cb8a20ad904a5811e6660d829a586b216e5254b9b34b76dde8a4d65d827dc6"},
+ {file = "coverage-7.17.0-cp314-cp314-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:bb5ca66937c55bc85d1a5e9c5900a3e4693a8edf2280a9b3672b7b2661a84b95"},
+ {file = "coverage-7.17.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:5cc15faaf318ee5040d835a62c75bc6f122d837274f3b5efd47bf9fbd4ac5b85"},
+ {file = "coverage-7.17.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:7d6d9d396c8b7bcaf76d774a10140b218111484e54c73a5f2a1b75655381748e"},
+ {file = "coverage-7.17.0-cp314-cp314-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:42e6f170d1ac04b7eb3363310a6c41cdfd82c1fe6bf9ffbc4a86f380bdf091c7"},
+ {file = "coverage-7.17.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:acdb5f3c96046efff9dc6c572a6acb2b8d0da09372d7b9a9ed7249cf7d17434f"},
+ {file = "coverage-7.17.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3393209f6894713161ee82a9b0e673e58237e0f9733c6638e7a6c0c620ef0b33"},
+ {file = "coverage-7.17.0-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:e9494d9e99389d39e6a96227749af898d8924ff591cb63944f8a98e68582bf0e"},
+ {file = "coverage-7.17.0-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:032d4c2db4c677eb71d43f2f8b80bf64e9346f7a3f7b6ebb13f1782f3cc6c274"},
+ {file = "coverage-7.17.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:4343a9378b964eb3cb80fa90406385de91c7e982a769ca9314d848f93bc0d3f2"},
+ {file = "coverage-7.17.0-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:b609df3d6d900464207532c5170a65c6ede8d2e0b91f151f90008a866395cd76"},
+ {file = "coverage-7.17.0-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:a01ef92caeedfa4f2ad171a3a8e6fece4565de871d8bca428151bf9929f41048"},
+ {file = "coverage-7.17.0-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:a3914e2c98c34b94c26d2add3d2a61ccfd3534fc4eaa879ee290bdbb5184ba6c"},
+ {file = "coverage-7.17.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:e8a72b26dc5c9a9422e45472b1d67ba5caf273c524c8668cc04b23062663755e"},
+ {file = "coverage-7.17.0-cp314-cp314-win32.whl", hash = "sha256:03baf0688e14a5a44ffd1eefa8928dfc92b14565e521174e072b31b971aa1657"},
+ {file = "coverage-7.17.0-cp314-cp314-win_amd64.whl", hash = "sha256:3a4459b0f389dd1e51aac3dbfc4ca35b30cae7dc99caa3c0a086d1997a985709"},
+ {file = "coverage-7.17.0-cp314-cp314-win_arm64.whl", hash = "sha256:a32ee5831b15ba239bef5d272ae586ca8acea4a661b5f2941f5a0d380e518b23"},
+ {file = "coverage-7.17.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:9c083e253e96fdeeaf48133fe836cac86ace2db215d235700e7f7532420a200c"},
+ {file = "coverage-7.17.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:b88fb4d4d7608cbcebdc7ff7dbffc2115e3b81d6c33a79147cd79d54fcb080f4"},
+ {file = "coverage-7.17.0-cp314-cp314t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:2bf3ee38a40c0570c316b9e7507c472469586906a20f289705898528c31aaea8"},
+ {file = "coverage-7.17.0-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:7c570293f001ea91598b90e90cb9b98fddee833e90bbede432cbd218331ccd8e"},
+ {file = "coverage-7.17.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:791f9ee09814dd30d9562b4f4eb037a371485ec1c830b53999d2320d20c4e764"},
+ {file = "coverage-7.17.0-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:c7c5672ecf1b497de7a0b37743bef40e3b58e3207e9fe2ed6682cb0420836a88"},
+ {file = "coverage-7.17.0-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:337f87e62e1c5f43c8198d879f677c342d152f84d3f157add12558853cbb8eaf"},
+ {file = "coverage-7.17.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:c8a58baa8eb6154c6645eadcc19b6c089deab78c24a612a83206f2a8a5992a7c"},
+ {file = "coverage-7.17.0-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:fb5745048ee20f796b0e3ab61831049e749acff188563e2af32f58ede957ac1b"},
+ {file = "coverage-7.17.0-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:7b5abcae74750302ac4bc77351eaee87c450e4abd3b6225eacde3858e260f8b2"},
+ {file = "coverage-7.17.0-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:4e153f0bd6509dbf837fd585f489b3328bfd98f2a718a0b15ae63032148b285c"},
+ {file = "coverage-7.17.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:e42a835271922fe7bf98c7a05c78d4032f4e52bf5b07fafa1eadfdfc2f0ad22f"},
+ {file = "coverage-7.17.0-cp314-cp314t-win32.whl", hash = "sha256:5900055351ec89fdffb34b27898815106529ded29a9496464c1ebd6313fd40fa"},
+ {file = "coverage-7.17.0-cp314-cp314t-win_amd64.whl", hash = "sha256:5ee9c8bd13a59e301dc2aefe7aa8384633406808de051b1982775667094eb673"},
+ {file = "coverage-7.17.0-cp314-cp314t-win_arm64.whl", hash = "sha256:0a9cb9a0fb58e6fff5442969af36094ecd6976f4907f179e33b27e15355d8f74"},
+ {file = "coverage-7.17.0-cp315-cp315-android_24_arm64_v8a.whl", hash = "sha256:adabc1079ba844b096799ba8638d8df434aca1613f95bb7d5791af320cf05559"},
+ {file = "coverage-7.17.0-cp315-cp315-android_24_x86_64.whl", hash = "sha256:6b4593d2871c4c801656dd5861e759f8f5156febd6b6061b02f6a72d64618b7b"},
+ {file = "coverage-7.17.0-cp315-cp315-ios_13_0_arm64_iphoneos.whl", hash = "sha256:c2c48a36bb970b7265b196032bfd4237c0b373f2b25ef7012d7e905b5b35c19c"},
+ {file = "coverage-7.17.0-cp315-cp315-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:f8bc2cd4c6aa58be1ca243fb8cddb6c3c42031fe4403991ad9cf2b3baed03d9f"},
+ {file = "coverage-7.17.0-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:cbf0b83ce927de6053279ba61342d9f8892afde1385fcba9144cd05d4023d109"},
+ {file = "coverage-7.17.0-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:66efc0fb99cee34626fc17d3adac9c3cd816bfdad563bb1e983c3ef432f566d4"},
+ {file = "coverage-7.17.0-cp315-cp315-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:58a304efdf2253fb2ea03d45d0a04cc174a92a0cd5279c28c5bb893ce7410968"},
+ {file = "coverage-7.17.0-cp315-cp315-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:aed06129a9f530a948928260d7d2d81c47261355b0127e3c782251b38958463c"},
+ {file = "coverage-7.17.0-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f6cdb47a9be2d3313829bed1d296086287682a3ee901ff987b3432b45705b771"},
+ {file = "coverage-7.17.0-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:804fbaf81d09b34e2f8b1159d01e211a50713d743d32fd9b2ca6cf0ae507a66f"},
+ {file = "coverage-7.17.0-cp315-cp315-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:b2afebb96da9a1bbca142f8cc12320c14e5c215e0a49cded4f191f5a31506a28"},
+ {file = "coverage-7.17.0-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:bd04fd23206be9ad3de13b0b39313094fafa66a1f6baf70f5471c004a9fac47d"},
+ {file = "coverage-7.17.0-cp315-cp315-musllinux_1_2_i686.whl", hash = "sha256:5ebfbc87836529a31d25c2dec1262c38eea852ec1c46c0f690a515a7339d9c5b"},
+ {file = "coverage-7.17.0-cp315-cp315-musllinux_1_2_ppc64le.whl", hash = "sha256:a59c3b470ac3b2432af3598a996affbeb10236cd899a005c1c4e517fcff8b592"},
+ {file = "coverage-7.17.0-cp315-cp315-musllinux_1_2_riscv64.whl", hash = "sha256:7fef12cec4b96f59e09761cbd4fc9bdf4788062d1ae435b920241fc16c8a9549"},
+ {file = "coverage-7.17.0-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:a14e8d69464da9cbe1dc29e7116dbd37296d1d51a695327c478e250349085089"},
+ {file = "coverage-7.17.0-cp315-cp315-win32.whl", hash = "sha256:9a66074231799d8884d267234d49f60c90b43a945dfe069646b72f3058cd4e67"},
+ {file = "coverage-7.17.0-cp315-cp315-win_amd64.whl", hash = "sha256:79cf71e5f9a48877ccfed5baa2c72f45af4feeaa596249e23eb15b473134830e"},
+ {file = "coverage-7.17.0-cp315-cp315-win_arm64.whl", hash = "sha256:09e563b49c81cd0a33734e926d7a4a6ef1778d74304cde2dcc3aff8b30ea1036"},
+ {file = "coverage-7.17.0-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:a5e2e0625dfc789af0b2e10acfc106b352f314fffbd19e6392a7961c8cbe5d9a"},
+ {file = "coverage-7.17.0-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:194562ab1eff0d85aee8a17ce4c5c0bc1ebf70a629a7145257123156ad100fd6"},
+ {file = "coverage-7.17.0-cp315-cp315t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:85682ca89bc4601125dcdff23fa70e6274e13c9ad502fba845e6c274ab2c6569"},
+ {file = "coverage-7.17.0-cp315-cp315t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:0d0fac604a962ff546beb038cba9a5a09d88e6e3f01612fb46f7bd4fe5dc8dca"},
+ {file = "coverage-7.17.0-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:72edd4f9483ae30cd1ba4f230687840ef7b58a16afb1c9e81131fd6d64655f36"},
+ {file = "coverage-7.17.0-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:91e487ad07c511da77b574820141a7c2da09bc2a4b4090b5be2424295d100697"},
+ {file = "coverage-7.17.0-cp315-cp315t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:1cabb31531002fef5197de5df3c84730aef01e750e25154b9813a2583435aba2"},
+ {file = "coverage-7.17.0-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:c9ac886242bbd50fb35a2242ba79555a99891e657da33f98b7ca968e3488a350"},
+ {file = "coverage-7.17.0-cp315-cp315t-musllinux_1_2_i686.whl", hash = "sha256:d45cdc495671fc99268ff3653e0da4244972e9fc0e1fc3ea9de18781ad28963a"},
+ {file = "coverage-7.17.0-cp315-cp315t-musllinux_1_2_ppc64le.whl", hash = "sha256:12961f738d717a046d4bf3f8d1727eb3ebe2ed5478ff96cd6233d4dfc39323d3"},
+ {file = "coverage-7.17.0-cp315-cp315t-musllinux_1_2_riscv64.whl", hash = "sha256:1ee0a982b0e1230b3edf768a7dd022bd2377303763895327ac62deb5efacee03"},
+ {file = "coverage-7.17.0-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:460679f53893081edb94eeed011d26be37228ba649b853fd2aed7e4394fb1f35"},
+ {file = "coverage-7.17.0-cp315-cp315t-win32.whl", hash = "sha256:600e121e412cd6bdb52ec105b95c6a04da0c9710d1534f6e64a42db667907802"},
+ {file = "coverage-7.17.0-cp315-cp315t-win_amd64.whl", hash = "sha256:c3e11b81faafb1f063248735c3e2c5c4183fc1db2c7f46782170dd7760dffcbc"},
+ {file = "coverage-7.17.0-cp315-cp315t-win_arm64.whl", hash = "sha256:d472ee1c64868a917a47f02ffb4ac8c22b477f7589d57a3eb0c58b1ad4f0137c"},
+ {file = "coverage-7.17.0-py3-none-any.whl", hash = "sha256:bac487dce0d2aff28ddf1a533a916f771416eee0e493960f611e49037b878e9d"},
+ {file = "coverage-7.17.0.tar.gz", hash = "sha256:cc010a0a7fbdd9bb8bdfd0d3f04a5151275860213cbd7e2b876b29778489c712"},
+]
+
+[[package]]
+name = "iniconfig"
+version = "2.3.1"
+description = "brain-dead simple config-ini parsing"
+optional = true
+python-versions = ">=3.10"
+groups = ["main"]
+markers = "extra == \"dev\""
+files = [
+ {file = "iniconfig-2.3.1-py3-none-any.whl", hash = "sha256:9121e2c1fdb355232495be3194c8dfe87ccc2d5dee45947b78e68f499790d7a7"},
+ {file = "iniconfig-2.3.1.tar.gz", hash = "sha256:67f4b9c50da0dedf52af349e7749a80a9057a5031199791b906c3bb3ae878960"},
+]
+
+[[package]]
+name = "packaging"
+version = "26.3"
+description = "Core utilities for Python packages"
+optional = true
+python-versions = ">=3.9"
+groups = ["main"]
+markers = "extra == \"dev\""
+files = [
+ {file = "packaging-26.3-py3-none-any.whl", hash = "sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c"},
+ {file = "packaging-26.3.tar.gz", hash = "sha256:94edc256424af38762eb31306eed28beb9f0efc50a8837492c9d6fd6004aed79"},
+]
+
+[[package]]
+name = "pluggy"
+version = "1.7.0"
+description = "plugin and hook calling mechanisms for python"
+optional = true
+python-versions = ">=3.10"
+groups = ["main"]
+markers = "extra == \"dev\""
+files = [
+ {file = "pluggy-1.7.0-py3-none-any.whl", hash = "sha256:7dd7b0d8832ba3cb632c306926ded123429211b83641b35dc5c41ad2d34f9bec"},
+ {file = "pluggy-1.7.0.tar.gz", hash = "sha256:d1eaa46ebb595891b860ab086b4d09c8588af65ebd4361b8e8f4bb8920b90ba8"},
+]
+
+[[package]]
+name = "psycopg"
+version = "3.3.6"
+description = "PostgreSQL database adapter for Python"
+optional = false
+python-versions = ">=3.10"
+groups = ["main"]
+files = [
+ {file = "psycopg-3.3.6-py3-none-any.whl", hash = "sha256:a1db9f7148b06a28606767efaca51fa6f9398c5c0a3810519be69d7000bdb631"},
+ {file = "psycopg-3.3.6.tar.gz", hash = "sha256:c081f2250df751a943036e42db6df4571c66cd0aabe8291a7a506512b12007d2"},
+]
+
+[package.dependencies]
+psycopg-binary = {version = "3.3.6", optional = true, markers = "implementation_name != \"pypy\" and extra == \"binary\""}
+typing-extensions = {version = ">=4.6", markers = "python_version < \"3.13\""}
+tzdata = {version = "*", markers = "sys_platform == \"win32\""}
+
+[package.extras]
+binary = ["psycopg-binary (==3.3.6) ; implementation_name != \"pypy\""]
+c = ["psycopg-c (==3.3.6) ; implementation_name != \"pypy\""]
+dev = ["ast-comments (>=1.1.2)", "black (>=26.1.0)", "codespell (>=2.2)", "cython-lint (>=0.21)", "dnspython (>=2.1)", "flake8 (>=4.0)", "isort-psycopg (>=0.0.3)", "isort[colors] (>=6.0)", "mypy (>=2.1.0)", "pre-commit (>=4.0.1)", "types-setuptools (>=57.4)", "types-shapely (>=2.0)", "wheel (>=0.37)"]
+docs = ["Sphinx (>=9.1)", "furo (==2025.12.19)", "sphinx-autobuild (>=2025.8.25)", "sphinx-autodoc-typehints (>=3.10.2)"]
+pool = ["psycopg-pool"]
+test = ["anyio (>=4.0)", "mypy (>=2.1.0) ; implementation_name != \"pypy\"", "pproxy (>=2.7)", "pytest (>=6.2.5)", "pytest-cov (>=3.0)", "pytest-randomly (>=3.5)"]
+
+[[package]]
+name = "psycopg-binary"
+version = "3.3.6"
+description = "PostgreSQL database adapter for Python -- C optimisation distribution"
+optional = false
+python-versions = ">=3.10"
+groups = ["main"]
+markers = "implementation_name != \"pypy\""
+files = [
+ {file = "psycopg_binary-3.3.6-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7beb3e41c9a1e509f3ed85263386588cbe3e975aa67be21f79f44fd35ffaeefc"},
+ {file = "psycopg_binary-3.3.6-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:aa73160077345ec21b3f51e8e24b3de2e99586217e497629326eb9b2ea88c52e"},
+ {file = "psycopg_binary-3.3.6-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:f87dbdc42e78ee0f7ea180c03f8c78e80a949e373066629bd90fefff10552dff"},
+ {file = "psycopg_binary-3.3.6-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:a9348c5b43a3bb5ef8c2e89d5237c9c87eeafb01d338c84a7aebbc5cd0313299"},
+ {file = "psycopg_binary-3.3.6-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0a52991594ac4db888c7d39bccef331797e30cb31a95cae02cf2607f83a42dc2"},
+ {file = "psycopg_binary-3.3.6-cp310-cp310-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:5ea8beeb5541780b4b50b462eeacbc4f594ce3b911dc20c81c75f267876f71d2"},
+ {file = "psycopg_binary-3.3.6-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:198a48e68cc99ccac03ba95ac857e73aa66f3bf6be77019fafb0832a05f7ad03"},
+ {file = "psycopg_binary-3.3.6-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:fa34eb47969297471db7b7f193622c7e3ee839ec05abd05f1fe104d5b1b1dcf4"},
+ {file = "psycopg_binary-3.3.6-cp310-cp310-musllinux_1_2_riscv64.whl", hash = "sha256:b979a42815410432420275412633960807178b1ce26591a16ce06e78a5bd4bb2"},
+ {file = "psycopg_binary-3.3.6-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:889e42acec10450185e0cdfb396f375e2c1a8d7737c114830a7fde4654f59e30"},
+ {file = "psycopg_binary-3.3.6-cp310-cp310-win_amd64.whl", hash = "sha256:cbd5f73073ed19c378d4c35499db1e3e703a5b1a324e521204065967bfaa7a18"},
+ {file = "psycopg_binary-3.3.6-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:be4f9b3c9338ac5dd217c5847e21521b396c8117f78dc420d495a5c49bbef874"},
+ {file = "psycopg_binary-3.3.6-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f0535693ce476a722b718b002d5d2c27d47e71ca945276ac194409c98e74c492"},
+ {file = "psycopg_binary-3.3.6-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:3c9e663b2e800e3218994cf948c11bcc2844e6491b34aa80d089baf6531827bf"},
+ {file = "psycopg_binary-3.3.6-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:a2e44a342d2aee40508e28a563d8961c39d9bbd8cae36d8578f0a3c6658aab0f"},
+ {file = "psycopg_binary-3.3.6-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5f598f19fa9a91540b5cee17932ffd227b7b53a481605bcc4573c0eafa647300"},
+ {file = "psycopg_binary-3.3.6-cp311-cp311-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:6ff05561e4a067d35507dc5c90f1deb2ec1c9703ac5cccc1bc26e08a197f9c5a"},
+ {file = "psycopg_binary-3.3.6-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:566dd827f17728efdf7d88a5b066f815170f6fdad13967ae952842d90e6aaa9f"},
+ {file = "psycopg_binary-3.3.6-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:9b2f11794e017ce340934e35de46181c46ef71ec75ea3d85dd75cd836761c01e"},
+ {file = "psycopg_binary-3.3.6-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:910ace140e3e7b7596898d083f37a8fe90c5c40684252ad4e682364b2cd3deba"},
+ {file = "psycopg_binary-3.3.6-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:37e517c146b185f9c0c6e8d0a0ebbdeeeb67896af28466e032bc810d0c7dc7a7"},
+ {file = "psycopg_binary-3.3.6-cp311-cp311-win_amd64.whl", hash = "sha256:c7f92daa0d2a1c76f07264abddf8cbabd30152a2f09c3270e50f0c7efdf5dcac"},
+ {file = "psycopg_binary-3.3.6-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:3f84dab25e0385692ee13274c68678377e0b1a70ab9d14e56264cbf61f60c62d"},
+ {file = "psycopg_binary-3.3.6-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:612382ac3ed13651c7fa44b5fee9fbf7baaa2ddbc6f500391672682c5f1df9e0"},
+ {file = "psycopg_binary-3.3.6-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:366db6e97e66b37211475f20c4c1324a2dc0dd825e46d4e87f9d599304d276f9"},
+ {file = "psycopg_binary-3.3.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:1679a1cb93fbe5a6d1fd58d82cbddcc6fcb8c61446ba7cae6eb2a7b19bc585de"},
+ {file = "psycopg_binary-3.3.6-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:37d40450659401600e6d043ff586c89a71a69f33cbb8bcdba6cdb2569beecdbe"},
+ {file = "psycopg_binary-3.3.6-cp312-cp312-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:a5165300324efd5a772c48a88ab3a928513ab3979fca76553e62ee815f7b2b9c"},
+ {file = "psycopg_binary-3.3.6-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:d636338c8f21b0df2f84657b00bc34f9313f826ef93f1155bc743607e4a0c5eb"},
+ {file = "psycopg_binary-3.3.6-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:a4ee3bdd5468a725f2a4d9aab8a74b6d0279f768c8b5d3aeb102c5307ff3d59c"},
+ {file = "psycopg_binary-3.3.6-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:289aadd6a00e151203c081f708348ec89f1e483c9b510ef4ac3981f847f01f79"},
+ {file = "psycopg_binary-3.3.6-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:f21d057f3e5f5491067e5b292498073b73847d48799b099803fef100775fcc52"},
+ {file = "psycopg_binary-3.3.6-cp312-cp312-win_amd64.whl", hash = "sha256:e23a66a763fbe83fcc210bc77c27e5a5ea380ebf091c06f34d8561b695e5a40f"},
+ {file = "psycopg_binary-3.3.6-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:5ad8f35e67cc16d1fad1fa8c88972dc9b3a3141ea67897399904edab96a301b6"},
+ {file = "psycopg_binary-3.3.6-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:373704aea331d3f3e3402c125a1543f5875e2986ebb54f97d1647942161f803f"},
+ {file = "psycopg_binary-3.3.6-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:b82491019b884d62318b5f30706c3d7e6d4e5a6cb7eabcb3edc0c1b0fdaceae9"},
+ {file = "psycopg_binary-3.3.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:cec5ea900390897d0b46130f60bc2883bf19c314f9044235217c8be88b0ef269"},
+ {file = "psycopg_binary-3.3.6-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:98c02090d88f2ebc0ec1e8da538f77d225ce0fffecf372aa39262e62a1b054ef"},
+ {file = "psycopg_binary-3.3.6-cp313-cp313-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:ee2c4728c691245e24501fcd7a97b5b381236b9985bc445bba88cdce7d1b5784"},
+ {file = "psycopg_binary-3.3.6-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:f19cc87343eaa55255e76b31259a570072ac95d6ae82c92dd34b97691f5e49dc"},
+ {file = "psycopg_binary-3.3.6-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:fdccb3a0e184b03e9baa673b15a809cf36c339c85dbda0ebc25a698846dfbee8"},
+ {file = "psycopg_binary-3.3.6-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:9892188bb15e5803beb51afe8a25add6b56be391a53058e8bca03b74e1e6bf22"},
+ {file = "psycopg_binary-3.3.6-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:3af90f92769d8cc10f94515ee7a0aef36ea85ca733a0ce22858f6e0953f41138"},
+ {file = "psycopg_binary-3.3.6-cp313-cp313-win_amd64.whl", hash = "sha256:0ebfad5d131de9f892ae9e70cc7616207768b6714b66a52d4612b8ceaf78b372"},
+ {file = "psycopg_binary-3.3.6-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:b3f75dee0f9afafabe4edc52c4842f1e1878ed2069bd05b22d6fe961e97e4dba"},
+ {file = "psycopg_binary-3.3.6-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:5927b7ba63153cd8e9862987290a2b783a5c590daf2a4ef981700cc3569166d4"},
+ {file = "psycopg_binary-3.3.6-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:0bf08b749cc144f33b44a91b78e3f71c60eb07963746a0df5a100b36ce3d7475"},
+ {file = "psycopg_binary-3.3.6-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:31cd942c23f613276b81a6e6598cefa12960058b0f46e1e874b540c793f6aca5"},
+ {file = "psycopg_binary-3.3.6-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4690cf67738f0e0e49a32aeec99bf0e4595cc2b4f1af984a4345394b1dcff91a"},
+ {file = "psycopg_binary-3.3.6-cp314-cp314-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:ad1c785e784cfd87e8436c6b7702f2d321fc39601bbaf29bc63a41a867091638"},
+ {file = "psycopg_binary-3.3.6-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:79a2a1c3449f6c3409427078ed1cec10de79f3023cb5f2504f0597d350ad46c7"},
+ {file = "psycopg_binary-3.3.6-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:86147cb5d140341c3363fb5bacce31f8d5543902a46699d3c536b101bbceaf9e"},
+ {file = "psycopg_binary-3.3.6-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:7308c93cf0b19bbaf8e6ff0a6ad50d3c442385739245fe15a8d593bf841734a6"},
+ {file = "psycopg_binary-3.3.6-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:05a83ac9fd52b9bca7cb5ab04b3691163170bd16f53defa27216ea3aa07ee781"},
+ {file = "psycopg_binary-3.3.6-cp314-cp314-win_amd64.whl", hash = "sha256:1fbd30e537dab22cafdf080608f10148fe2a5f3a61294ddb5113caac8a623840"},
+ {file = "psycopg_binary-3.3.6-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:bf8c8481d026b85dd70c5fa7dde85b2333aed0b32a2602bcd38a900cbd78a49c"},
+ {file = "psycopg_binary-3.3.6-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:b599defe9190b17e9907c8b4d114c181e702c87efcd1b8a0ad40971cdcc4634a"},
+ {file = "psycopg_binary-3.3.6-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:b8ece331509f7a975b90501f41e83ad905e4141753fedf3f2711b2bc70a8efbc"},
+ {file = "psycopg_binary-3.3.6-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c61617eaae0112ca154da87ffb99b73af2c74067acac28dfb9a4455b019dff2e"},
+ {file = "psycopg_binary-3.3.6-cp315-cp315-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c6d19cb4999d03231e8730a5f66c8f5068bc3b532677eb39dab0f600bff3e312"},
+ {file = "psycopg_binary-3.3.6-cp315-cp315-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:e8cbb54454dbf1bbf2ff08dd7693e8d94ac94b1a20f70f4b3b813d52ecb5cbc1"},
+ {file = "psycopg_binary-3.3.6-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:dc75da5a20951049f7b773145f998f69d181adad9c58a0ff36e0cf1d73c10e10"},
+ {file = "psycopg_binary-3.3.6-cp315-cp315-musllinux_1_2_ppc64le.whl", hash = "sha256:955e3dd94da361e052d2e49acf591017158dc8f8ed2c8a42c2e3943403c39dc2"},
+ {file = "psycopg_binary-3.3.6-cp315-cp315-musllinux_1_2_riscv64.whl", hash = "sha256:c7753871eb57e6a5f4646f6168590c6653073dea5e9e720b201c8875332df4c8"},
+ {file = "psycopg_binary-3.3.6-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:303732e798fe6729f8e12021b9c96107df8e95ecec4dd487c67b98ec2a59435e"},
+ {file = "psycopg_binary-3.3.6-cp315-cp315-win_amd64.whl", hash = "sha256:2f122603f36050937982abf9668d8bc4769a79f7c93a65013b1c49f1cab7b56b"},
+]
+
+[[package]]
+name = "pygments"
+version = "2.21.0"
+description = "Pygments is a syntax highlighting package written in Python."
+optional = true
+python-versions = ">=3.9"
+groups = ["main"]
+markers = "extra == \"dev\""
+files = [
+ {file = "pygments-2.21.0-py3-none-any.whl", hash = "sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9"},
+ {file = "pygments-2.21.0.tar.gz", hash = "sha256:610ca751c9bc2492b38eb9a38a7fbc93edbbb2d7182edaf34e66ae493dee5c8c"},
+]
+
+[package.extras]
+windows-terminal = ["colorama (>=0.4.6)"]
+
+[[package]]
+name = "pytest"
+version = "9.2.0"
+description = "pytest: simple powerful testing with Python"
+optional = true
+python-versions = ">=3.10"
+groups = ["main"]
+markers = "extra == \"dev\""
+files = [
+ {file = "pytest-9.2.0-py3-none-any.whl", hash = "sha256:07acdcf88ec174f907dc01af70bf52d49b014bbab03faeeade31c96b18c2e588"},
+ {file = "pytest-9.2.0.tar.gz", hash = "sha256:97c4f3b1f3c7414aa36465e09b8220f1d03627993bd51b1282e193753c80557b"},
+]
+
+[package.dependencies]
+colorama = {version = ">=0.4", markers = "sys_platform == \"win32\""}
+iniconfig = ">=2"
+packaging = ">=24"
+pluggy = ">=1.6,<2"
+pygments = ">=2.15"
+
+[package.extras]
+dev = ["argcomplete", "asynctest ; python_version < \"3.11\"", "attrs (>=23.1)", "coverage (>=7.5)", "hypothesis (>=6.75)", "mock", "numpy (>=1.26)", "pexpect (>=4.9)", "pytest-xdist (>=3.5)", "pyyaml", "requests", "setuptools", "xmlschema"]
+
+[[package]]
+name = "pytest-cov"
+version = "7.1.0"
+description = "Pytest plugin for measuring coverage."
+optional = true
+python-versions = ">=3.9"
+groups = ["main"]
+markers = "extra == \"dev\""
+files = [
+ {file = "pytest_cov-7.1.0-py3-none-any.whl", hash = "sha256:a0461110b7865f9a271aa1b51e516c9a95de9d696734a2f71e3e78f46e1d4678"},
+ {file = "pytest_cov-7.1.0.tar.gz", hash = "sha256:30674f2b5f6351aa09702a9c8c364f6a01c27aae0c1366ae8016160d1efc56b2"},
+]
+
+[package.dependencies]
+coverage = {version = ">=7.10.6", extras = ["toml"]}
+pluggy = ">=1.2"
+pytest = ">=7"
+
+[package.extras]
+testing = ["process-tests", "pytest-xdist", "virtualenv"]
+
+[[package]]
+name = "typing-extensions"
+version = "4.16.0"
+description = "Backported and Experimental Type Hints for Python 3.9+"
+optional = false
+python-versions = ">=3.9"
+groups = ["main"]
+markers = "python_version < \"3.13\""
+files = [
+ {file = "typing_extensions-4.16.0-py3-none-any.whl", hash = "sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8"},
+ {file = "typing_extensions-4.16.0.tar.gz", hash = "sha256:dc983d19a509c94dba722ee6abd33940f7c05a89e243c47e907eb4db6f1a43e5"},
+]
+
+[[package]]
+name = "tzdata"
+version = "2026.6"
+description = "Provider of IANA time zone data"
+optional = false
+python-versions = ">=2"
+groups = ["main"]
+markers = "sys_platform == \"win32\""
+files = [
+ {file = "tzdata-2026.6-py2.py3-none-any.whl", hash = "sha256:0a10eec6e13ef16b627fabed9a5f2ba61a62b1c67f327305f4e7e412a70b4aec"},
+ {file = "tzdata-2026.6.tar.gz", hash = "sha256:85d2cd9c09f81f0bb29db27759fc83af4f1e620efb814f8c5bf8b4cc4feece6d"},
+]
+
+[extras]
+dev = ["pytest", "pytest-cov"]
+
+[metadata]
+lock-version = "2.1"
+python-versions = ">=3.11"
+content-hash = "942d4b0cffe46e58d34465267482ec503ba921ebce2b0693dc29f454e0eda63d"
diff --git a/services/escalations/pyproject.toml b/services/escalations/pyproject.toml
new file mode 100644
index 000000000..d4d1c06fa
--- /dev/null
+++ b/services/escalations/pyproject.toml
@@ -0,0 +1,52 @@
+[build-system]
+requires = ["hatchling"]
+build-backend = "hatchling.build"
+
+[project]
+name = "aisoc-escalations"
+version = "0.1.0"
+description = "Ack-clock escalation bridge: Teams escalations for unacknowledged CRITICAL/HIGH cases while the native outbound-webhook emitters are unwired."
+requires-python = ">=3.11"
+dependencies = [
+ # The service's only dependency. Sync psycopg on purpose: one query burst
+ # every ESC_TICK_SECONDS from a single loop needs no event loop, and a
+ # second async stack in a sidecar is surface without a payoff.
+ "psycopg[binary]>=3.2,<4",
+]
+
+[project.optional-dependencies]
+# Test-only, same shape as the other wave-2 services so the CI matrix can
+# install from the lock and run pytest + the coverage gate. No
+# pytest-asyncio: every test here is a pure synchronous decision-logic check.
+dev = ["pytest>=9,<10", "pytest-cov>=5,<8"]
+
+[tool.mypy]
+python_version = "3.11"
+strict = false
+ignore_missing_imports = true
+
+[tool.pytest.ini_options]
+testpaths = ["tests"]
+
+[tool.coverage.run]
+source = ["app"]
+branch = true
+
+# Coverage floor for the CI gate (`pytest --cov-config=pyproject.toml
+# --cov=app`). The suite covers the pure decision logic — the escalation
+# ladder, the digest day-gate, payload shape, and the status vocabulary
+# pinned against the migration — which is the half worth unit-testing; the
+# IO half (psycopg fetches, the webhook POST, the tick loop) needs a live
+# DB and webhook and is exercised in the service's own integration run, not
+# here. Floor set a few points below the measured baseline so branch-
+# execution variance cannot red main; raise it as the suite grows, never
+# lower without a written reason.
+[tool.coverage.report]
+fail_under = 38
+show_missing = true
+exclude_lines = [
+ "pragma: no cover",
+ "raise NotImplementedError",
+ "if TYPE_CHECKING:",
+ "if __name__ == .__main__.:",
+]
diff --git a/services/escalations/tests/test_ladder.py b/services/escalations/tests/test_ladder.py
new file mode 100644
index 000000000..54a602dba
--- /dev/null
+++ b/services/escalations/tests/test_ladder.py
@@ -0,0 +1,85 @@
+import re
+from datetime import UTC, datetime, timedelta
+from pathlib import Path
+
+from app.bridge import (
+ OPEN_STATUSES,
+ Case,
+ NagState,
+ crit_payload,
+ digest_payload,
+ should_escalate_critical,
+ should_send_digest,
+)
+
+
+def test_open_statuses_are_real_members_of_the_cases_check_constraint():
+ """The first draft filtered on "open", a status aisoc_cases has never had —
+ a filter member that can never match is invisible at runtime, so this pins
+ OPEN_STATUSES against the migration's own CHECK clause. It also pins the
+ one deliberate exclusion set: everything we leave out must be terminal."""
+ migration = (
+ # parents[2] is services/ — this file sits at services/escalations/tests/.
+ Path(__file__).resolve().parents[2] / "api" / "migrations" / "012_case_management.sql"
+ ).read_text(encoding="utf-8")
+ m = re.search(r"status\s+TEXT[^)]*CHECK \(status IN \(([^)]+)\)\)", migration)
+ assert m, "could not locate the aisoc_cases status CHECK in migration 012"
+ vocabulary = set(re.findall(r"'([a-z_]+)'", m.group(1)))
+ assert set(OPEN_STATUSES) <= vocabulary, f"OPEN_STATUSES not in the CHECK vocabulary: {set(OPEN_STATUSES) - vocabulary}"
+ assert vocabulary - set(OPEN_STATUSES) == {"resolved", "closed"}, "a non-terminal status is missing from OPEN_STATUSES"
+
+
+NOW = datetime(2026, 10, 31, 9, 0, tzinfo=UTC)
+
+
+def _case(minutes_ago: int) -> Case:
+ return Case("a" * 32, "AI-42", "admin brute force", "critical", NOW - timedelta(minutes=minutes_ago))
+
+
+class TestCriticalLadder:
+ def test_inside_grace_not_escalated(self):
+ assert should_escalate_critical(_case(10), None, NOW) is False
+
+ def test_past_grace_first_send(self):
+ assert should_escalate_critical(_case(31), None, NOW) is True
+
+ def test_no_nag_before_interval(self):
+ nag = NagState(count=1, last=(NOW - timedelta(hours=1)).isoformat())
+ assert should_escalate_critical(_case(120), nag, NOW) is False
+
+ def test_nag_after_interval(self):
+ nag = NagState(count=1, last=(NOW - timedelta(hours=5)).isoformat())
+ assert should_escalate_critical(_case(600), nag, NOW) is True
+
+ def test_nag_cap(self):
+ nag = NagState(count=3, last=(NOW - timedelta(hours=5)).isoformat())
+ assert should_escalate_critical(_case(600), nag, NOW) is False
+
+
+class TestDigest:
+ def test_before_hour(self):
+ assert should_send_digest("", datetime(2026, 10, 31, 7, 59, tzinfo=UTC)) is False
+
+ def test_at_hour(self):
+ assert should_send_digest("", NOW) is True
+
+ def test_same_day_suppressed(self):
+ assert should_send_digest("2026-10-31", NOW) is False
+
+ def test_next_day_fires(self):
+ assert should_send_digest("2026-10-30", NOW) is True
+
+
+class TestPayloads:
+ def test_crit_payload_fields(self):
+ p = crit_payload(_case(45), 45.0, 1)
+ assert p["severity"] == "CRITICAL"
+ assert p["case_id"] == "AI-42"
+ assert p["url"].endswith("/cases/" + "a" * 32)
+ assert "1/3" in p["summary"]
+
+ def test_digest_truncates_list(self):
+ cases = [_case(i) for i in range(10, 20)]
+ p = digest_payload(cases, "dead-letters 24h: 0", NOW)
+ assert p["severity"] == "DIGEST"
+ assert "…and 2 more" in p["summary"]