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.
Python agentic-aiai-securityalert-triageblue-teamcybersecuritydetection-engineeringincident-responselanggraphllm-agentsmcpmitre-attackmodel-context-protocolpurple-teamsecurity-operationsself-hostedsiemsoarsocthreat-detectionthreat-intelligence
feat(gates): check_deployment_completeness.py and the scheduler-lease job
Beenu Arorac33a29a3e0ca
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 2c12e5b74..327d5c4bc 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -716,6 +716,18 @@ jobs:run: python3 scripts/check_standard_inputs.py --self-test- name: Standard inputs gaterun: python3 scripts/check_standard_inputs.py+ # Three descriptions of one platform that can drift apart+ # silently: the Helm chart against CORE in docker-compose.yml,+ # restore.sh against backup.sh, and the connector scheduler+ # against its own lease. Each was wrong in a way nothing could+ # see — `helm install` brought up a deployment missing response+ # execution and every connector poll and reported success, and+ # two scheduler replicas each polled every vendor. Self-test+ # first, on the same tree: nine injected violations, one per rule.+ - name: Deployment completeness gate — self-test+ run: python3 scripts/check_deployment_completeness.py --self-test+ - name: Deployment completeness gate+ run: python3 scripts/check_deployment_completeness.py# One layer in from the name: the profile gate asks whether a connector# reaches a normalization path, this asks which OCSF class it reaches# when it gets there. The class uid divided by a thousand is thediff --git a/.github/workflows/scheduler-lease-live.yml b/.github/workflows/scheduler-lease-live.ymlnew file mode 100644index 000000000..a52cfa99c--- /dev/null+++ b/.github/workflows/scheduler-lease-live.yml@@ -0,0 +1,152 @@+# One connector scheduler leads, against real Postgres (depth plan 4.5).+#+# Without an election two replicas each add one APScheduler job per+# connector instance, so every vendor is polled twice on every cycle. On+# a rate-limited API that is worse than duplication: the second replica's+# poll is what gets throttled, and a throttled connector looks identical+# to one whose credentials expired.+#+# The election is one conditional UPDATE, and the only way to show it+# works is two of them against one row. The decisive test interleaves the+# transactions explicitly rather than racing them, because a race between+# coroutines on one loop passes under a SELECT-then-UPDATE as well —+# measured on this repository's own lake-job claim.+name: Scheduler lease (live)++on:+ push:+ branches: [main]+ pull_request:+ workflow_dispatch:++concurrency:+ group: scheduler-lease-live-${{ github.ref }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.sha }}+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}++permissions:+ contents: read++jobs:+ scheduler-lease-live:+ name: Two replicas cannot both poll every vendor+ runs-on: ubuntu-latest+ timeout-minutes: 20++ services:+ postgres:+ image: public.ecr.aws/docker/library/postgres:16-alpine+ env:+ POSTGRES_USER: aisoc+ POSTGRES_PASSWORD: aisoc_ci_only+ POSTGRES_DB: aisoc+ ports: ["5432:5432"]+ options: >-+ --health-cmd "pg_isready -U aisoc"+ --health-interval 5s+ --health-timeout 5s+ --health-retries 20++ env:+ LEASE_DSN: postgresql+asyncpg://aisoc:aisoc_ci_only@localhost:5432/aisoc+ PGPASSWORD: aisoc_ci_only+ ENVIRONMENT: test+ OTEL_SDK_DISABLED: "true"++ steps:+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7++ - uses: actions/setup-python@e9d6f990972a57673cdb72ec29e19d42ba28880f # v6+ with:+ python-version: "3.11"++ - name: Install connectors from its lockfile+ working-directory: services/connectors+ run: |+ set -euo pipefail+ python -m pip install --quiet --upgrade pip "poetry==2.4.1"+ poetry config virtualenvs.create false+ poetry install --no-root --no-interaction+ # greenlet explicitly: SQLAlchemy 2.1 moved it out of the base+ # dependency set, and without it every async engine call raises+ # a ValueError that reads as a test bug rather than a missing+ # package.+ python -m pip install --quiet pytest pytest-asyncio greenlet++ - name: Apply every migration, in order+ run: |+ set -euo pipefail+ for f in services/api/migrations/*.sql; do+ psql -h localhost -U aisoc -d aisoc -v ON_ERROR_STOP=1 -q -f "$f"+ done++ - name: The lease table exists+ run: |+ set -euo pipefail+ found=$(psql -h localhost -U aisoc -d aisoc -tAc \+ "SELECT count(*) FROM information_schema.tables WHERE table_name = 'scheduler_leases'")+ if [ "$found" != "1" ]; then+ echo "FAIL: migration 112 ran and created no scheduler_leases table."+ exit 1+ fi++ - name: Acquisition, renewal, takeover and release+ working-directory: services/connectors+ env:+ ISOLATION_LEASE_DSN: ${{ env.LEASE_DSN }}+ PYTHONPATH: .+ run: python -m pytest ../../tests/isolation/test_scheduler_lease_live.py -v --tb=short++ - name: The suite actually ran+ working-directory: services/connectors+ env:+ ISOLATION_LEASE_DSN: ${{ env.LEASE_DSN }}+ PYTHONPATH: .+ run: |+ set -euo pipefail+ python -m pytest ../../tests/isolation/test_scheduler_lease_live.py -q 2>&1 | tee /tmp/lease-run.txt+ if grep -qE '[0-9]+ skipped' /tmp/lease-run.txt; then+ echo "FAIL: a case skipped in the job whose whole purpose is to run it live."+ exit 1+ fi+ if ! grep -qE '[0-9]+ passed' /tmp/lease-run.txt; then+ echo "FAIL: no case reported as passed."+ exit 1+ fi++ # The negative control.+ #+ # Remove the expiry predicate from the acquire. Postgres then has+ # nothing to re-evaluate once the row lock is released, so both+ # interleaved transactions take the lease and both replicas poll+ # every vendor. The suite must go red.+ - name: The gate fails when the acquire stops checking the expiry+ working-directory: services/connectors+ env:+ ISOLATION_LEASE_DSN: ${{ env.LEASE_DSN }}+ PYTHONPATH: .+ run: |+ set -euo pipefail+ cp app/leader_lease.py /tmp/lease.bak+ python - <<'PY'+ import pathlib, sys+ p = pathlib.Path("app/leader_lease.py")+ s = p.read_text()+ needle = " WHERE scheduler_leases.expires_at < now()\n"+ if needle not in s:+ print("negative control could not find the expiry predicate; the acquire has been "+ "reshaped and this control no longer proves anything")+ sys.exit(1)+ p.write_text(s.replace(needle, "\n", 1))+ PY+ set +e+ python -m pytest \+ "../../tests/isolation/test_scheduler_lease_live.py::TestOnlyOneLeader" \+ -q >/dev/null 2>&1+ rc=$?+ set -e+ cp /tmp/lease.bak app/leader_lease.py+ if [ "$rc" -eq 0 ]; then+ echo "FAIL: both replicas took the lease and the suite stayed green."+ exit 1+ fi+ echo "OK: without the predicate both replicas lead and the suite goes red, as it must."diff --git a/scripts/check_deployment_completeness.py b/scripts/check_deployment_completeness.pynew file mode 100644index 000000000..9f4d7aa5e--- /dev/null+++ b/scripts/check_deployment_completeness.py@@ -0,0 +1,361 @@+#!/usr/bin/env python3+"""A chart that installs CORE, a restore that covers the backup, one leader.++Depth plan 4.5 / parity 6.8. Three claims, each of which was false in a+way nothing could see.++**The chart did not install CORE.** `infra/helm/aisoc/values.yaml`+declared seven application services. CORE in `docker-compose.yml` is+sixteen, and the chart was missing response execution, every connector+poll, the threat-intel store, the LLM gateway, the local model and the+vector store. `helm install` produced a deployment that could not act,+could not collect and could not triage — and reported success, because+nothing compared the two files.++**A restore that does not cover the backup is a backup nobody can use.**+The two scripts are a pair, maintained separately, and a component added+to one and not the other is discovered during an incident. They happen to+agree today; nothing held them that way.++**Two scheduler replicas each polled every vendor.** The scheduler adds+one job per connector instance in process, so two replicas doubled every+vendor's call volume — and on a rate-limited API the second replica's+poll is the one that gets throttled, which looks exactly like expired+credentials.++Read statically rather than by installing anything. `helm` is not on a+lint runner and a Kubernetes cluster certainly is not, and a gate that+skips when it cannot find a toolchain is a gate that silently stops+checking.++Usage:+ python3 scripts/check_deployment_completeness.py+ python3 scripts/check_deployment_completeness.py --self-test+"""++from __future__ import annotations++import argparse+import re+import shutil+import sys+import tempfile+from pathlib import Path++import yaml++sys.path.insert(0, str(Path(__file__).resolve().parent))++from gate_toolkit import TREE_SHAPES, refuses_an_empty_tree, repo_root # noqa: E402++REPO_ROOT = repo_root()++COMPOSE = Path("docker-compose.yml")+VALUES = Path("infra/helm/aisoc/values.yaml")+TEMPLATE_DIR = Path("infra/helm/aisoc/templates")+BACKUP_SH = Path("scripts/backup.sh")+RESTORE_SH = Path("scripts/restore.sh")+LEASE_PY = Path("services/connectors/app/leader_lease.py")+SCHEDULER_PY = Path("services/connectors/app/scheduler.py")+LEASE_MIGRATION = Path("services/api/migrations/112_scheduler_leases.sql")++#: Compose services the chart is not expected to render, with the reason.+#:+#: Each is a deliberate exclusion rather than an omission, and naming them+#: here is what stops this gate becoming a list someone appends to+#: whenever it fails.+CHART_EXEMPT: dict[str, str] = {+ "postgres": "a Bitnami subchart dependency, not a template of ours",+ "redis": "a Bitnami subchart dependency, not a template of ours",+ "zookeeper": "the chart's Kafka runs KRaft and needs no ZooKeeper",+ "ollama-pull": "a one-shot model pull; the StatefulSet's startup probe covers the same wait",+}++#: Workload components the chart renders that are not CORE compose+#: services. Also deliberate: these are `full`-profile or optional+#: surfaces the chart has always shipped.+COMPOSE_EXEMPT: dict[str, str] = {+ "alert-fusion": "the chart's name for the fusion worker, which compose calls `fusion`",+ "enrichment": "a full-profile service the chart has always shipped",+ "ueba": "a full-profile service with its own template and values block",+ "honeytokens": "a full-profile service with its own template",+ "purple-team": "a full-profile service with its own template",+ "backup": "a CronJob, not a long-running service",+ "kafka-topics": "a one-shot topic-creation Job",+ "core-api": "an optional second API surface with its own template and values block",+ "kafka": "the chart ships its own StatefulSet; compose runs the Confluent image",+}++#: The compose service each chart component corresponds to where the two+#: use different names. Stated rather than guessed: a fuzzy match would+#: silently pair `fusion` with `alert-fusion` today and with something+#: else after a rename.+NAME_MAP = {"ingest-worker": "ingest", "fusion": "alert-fusion"}+++def _read(root: Path, rel: Path) -> str:+ try:+ return (root / rel).read_text(encoding="utf-8")+ except OSError:+ return ""+++def core_compose_services(root: Path) -> set[str]:+ """Long-running CORE services: no `profiles:` key, and not one-shot."""+ raw = _read(root, COMPOSE)+ if not raw:+ return set()+ try:+ parsed = yaml.safe_load(raw) or {}+ except yaml.YAMLError:+ return set()+ out: set[str] = set()+ for name, body in (parsed.get("services") or {}).items():+ if isinstance(body, dict) and body.get("profiles"):+ continue+ out.add(name)+ return out+++def chart_components(root: Path) -> set[str]:+ """Every workload the chart renders, from values and from templates.++ Values first, because `.Values.services` drives the generic+ Deployment template. Templates after, because the services that do+ not fit that loop — the ones with volumes or third-party tags — have+ their own files, and a gate that only read the values map would call+ them missing.+ """+ components: set[str] = set()+ raw = _read(root, VALUES)+ if raw:+ try:+ values = yaml.safe_load(raw) or {}+ except yaml.YAMLError:+ values = {}+ components.update((values.get("services") or {}).keys())++ directory = root / TEMPLATE_DIR+ if directory.is_dir():+ for path in sorted(directory.glob("*.yaml")):+ text = path.read_text(encoding="utf-8", errors="replace")+ for match in re.finditer(r"app\.kubernetes\.io/component:\s*([a-z0-9-]+)", text):+ components.add(match.group(1))+ return components+++def _shell_functions(source: str, prefix: str) -> set[str]:+ return {m.group(1) for m in re.finditer(rf"^{prefix}_([a-z0-9_]+)\(\)", source, flags=re.M)}+++def evaluate(root: Path) -> list[str]:+ failures: list[str] = []++ # 1. The chart installs CORE.+ core = core_compose_services(root)+ if not core:+ failures.append(f"{COMPOSE} has no profile-less services, so there is no CORE set to compare against.")+ else:+ rendered = chart_components(root)+ if not rendered:+ failures.append(f"{VALUES} and {TEMPLATE_DIR} render no workloads at all.")+ missing = sorted(+ name for name in core if name not in CHART_EXEMPT and NAME_MAP.get(name, name) not in rendered and name not in rendered+ )+ for name in missing:+ failures.append(+ f"{name} is a CORE service in {COMPOSE} and the chart renders no workload for it. "+ f"`helm install` would bring up a deployment missing it and report success."+ )+ unexplained = sorted(+ name+ for name in rendered+ if name not in COMPOSE_EXEMPT+ and name not in core+ and name not in set(NAME_MAP.values())+ and name not in {NAME_MAP.get(c, c) for c in core}+ )+ for name in unexplained:+ failures.append(+ f"the chart renders {name}, which is neither a CORE compose service nor in the exempt "+ f"list with a reason. Add it to COMPOSE_EXEMPT saying why, or the two descriptions of "+ f"the platform have drifted."+ )++ # 2. Restore covers what backup covers.+ backup = _shell_functions(_read(root, BACKUP_SH), "backup")+ restore = _shell_functions(_read(root, RESTORE_SH), "restore")+ if not backup:+ failures.append(f"{BACKUP_SH} declares no backup_* component functions, so nothing is being backed up.")+ if not restore:+ failures.append(f"{RESTORE_SH} declares no restore_* component functions.")+ for component in sorted(backup - restore):+ failures.append(+ f"{BACKUP_SH} backs up {component!r} and {RESTORE_SH} cannot restore it. A backup nobody can "+ f"restore is discovered during an incident."+ )+ for component in sorted(restore - backup):+ failures.append(f"{RESTORE_SH} restores {component!r} and {BACKUP_SH} never backs it up, so the restore path has nothing to read.")++ # 3. One scheduler leads.+ lease = _read(root, LEASE_PY)+ if not lease:+ failures.append(+ f"{LEASE_PY} is missing, so two connector replicas each run every poll job and every vendor is polled twice on every cycle."+ )+ else:+ if "expires_at < now()" not in lease:+ failures.append(+ f"{LEASE_PY} acquires without checking the expiry in the same statement. Postgres has "+ f"nothing to re-evaluate after the row lock, and two replicas both become leader."+ )+ if "fenced_at" not in lease:+ failures.append(+ f"{LEASE_PY} records no term, so a log cannot say which generation of the leader wrote a line after a partition."+ )++ scheduler = _read(root, SCHEDULER_PY)+ if not scheduler:+ failures.append(f"{SCHEDULER_PY} is missing.")+ else:+ if "_is_leader" not in scheduler:+ failures.append(+ f"{SCHEDULER_PY} never asks whether it leads, so the lease is taken and ignored — which is "+ f"the same double-poll with a table to prove it was avoidable."+ )+ if "_remove_all_poll_jobs" not in scheduler:+ failures.append(+ f"{SCHEDULER_PY} does not drop its poll jobs when leadership is lost. A replica that "+ f"stops adding jobs but keeps the ones it had is still polling every vendor."+ )++ if not (root / LEASE_MIGRATION).is_file():+ failures.append(+ f"{LEASE_MIGRATION} is missing, so scheduler_leases exists in code and in no database and every acquisition raises."+ )++ return failures+++_INJECTIONS = (+ ("CHART_MISSING_SERVICE", "a CORE service the chart does not render"),+ ("CHART_EXTRA_SERVICE", "a chart workload that is in neither compose nor the exempt list"),+ ("RESTORE_GAP", "a component backed up and not restorable"),+ ("BACKUP_GAP", "a component restorable and never backed up"),+ ("NO_LEASE", "a missing lease module"),+ ("RACY_ACQUIRE", "an acquire that does not re-check the expiry"),+ ("LEASE_IGNORED", "a scheduler that takes the lease and ignores it"),+ ("FOLLOWER_KEEPS_JOBS", "a follower that keeps the jobs it already had"),+ ("NO_LEASE_TABLE", "a lease table that exists in code and in no database"),+)+++def _inject(tmp: Path, kind: str) -> None:+ values = tmp / VALUES+ if kind == "CHART_MISSING_SERVICE":+ text = values.read_text(encoding="utf-8")+ values.write_text(text.replace("\n connectors:\n", "\n connectors_disabled:\n", 1), encoding="utf-8")+ elif kind == "CHART_EXTRA_SERVICE":+ text = values.read_text(encoding="utf-8")+ values.write_text(+ text.replace("\n actions:\n", "\n invented-service:\n image: {}\n actions:\n", 1),+ encoding="utf-8",+ )+ elif kind == "RESTORE_GAP":+ path = tmp / RESTORE_SH+ path.write_text(path.read_text(encoding="utf-8").replace("restore_qdrant()", "_disabled_qdrant()", 1), encoding="utf-8")+ elif kind == "BACKUP_GAP":+ path = tmp / BACKUP_SH+ path.write_text(path.read_text(encoding="utf-8").replace("backup_qdrant()", "_disabled_qdrant()", 1), encoding="utf-8")+ elif kind == "NO_LEASE":+ (tmp / LEASE_PY).unlink(missing_ok=True)+ elif kind == "RACY_ACQUIRE":+ path = tmp / LEASE_PY+ path.write_text(path.read_text(encoding="utf-8").replace("expires_at < now()", "true"), encoding="utf-8")+ elif kind == "LEASE_IGNORED":+ path = tmp / SCHEDULER_PY+ path.write_text(path.read_text(encoding="utf-8").replace("_is_leader", "_unused_leader_check"), encoding="utf-8")+ elif kind == "FOLLOWER_KEEPS_JOBS":+ path = tmp / SCHEDULER_PY+ path.write_text(path.read_text(encoding="utf-8").replace("_remove_all_poll_jobs", "_noop_drop"), encoding="utf-8")+ elif kind == "NO_LEASE_TABLE":+ (tmp / LEASE_MIGRATION).unlink(missing_ok=True)+ else: # pragma: no cover+ raise AssertionError(f"unknown injection {kind}")+++def _self_test() -> int:+ print(f"{Path(__file__).name} self-test\n")+ results: list[tuple[str, bool]] = []++ clean = evaluate(REPO_ROOT)+ results.append(("reports the real tree clean", not clean))+ for line in clean[:6]:+ print(f" unexpected: {line}")++ for kind, label in _INJECTIONS:+ tmp = Path(tempfile.mkdtemp(prefix="deployment-completeness-"))+ try:+ for rel in (COMPOSE, VALUES, BACKUP_SH, RESTORE_SH, LEASE_PY, SCHEDULER_PY, LEASE_MIGRATION):+ source = REPO_ROOT / rel+ if source.is_file():+ (tmp / rel).parent.mkdir(parents=True, exist_ok=True)+ shutil.copy2(source, tmp / rel)+ if (REPO_ROOT / TEMPLATE_DIR).is_dir():+ shutil.copytree(REPO_ROOT / TEMPLATE_DIR, tmp / TEMPLATE_DIR)+ _inject(tmp, kind)+ results.append((f"catches {label}", bool(evaluate(tmp))))+ finally:+ shutil.rmtree(tmp, ignore_errors=True)++ details: list[str] = []+ for shape in TREE_SHAPES:+ refused, detail = refuses_an_empty_tree(Path(__file__).name, shape=shape)+ results.append((f"refuses a {shape} tree rather than reporting it clean", refused))+ details.append(f"{shape}: {detail}")++ ok = True+ for description, passed in results:+ ok &= passed+ print(f" {'PASS' if passed else 'FAIL'} {description}")+ for line in "\n".join(details).splitlines():+ print(f" {line}")+ print()+ if not ok:+ print(f"{Path(__file__).name}: self-test FAILED")+ return 1+ print(f"{Path(__file__).name}: self-test OK")+ return 0+++def main() -> int:+ parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)+ parser.add_argument("--self-test", action="store_true", help="inject one violation per rule and require each to be caught")+ args = parser.parse_args()+ if args.self_test:+ return _self_test()++ if not (REPO_ROOT / COMPOSE).is_file():+ print(f"check_deployment_completeness: {COMPOSE} is not there — nothing to render a verdict about.", file=sys.stderr)+ return 2++ failures = evaluate(REPO_ROOT)+ if failures:+ print("Deployment completeness (depth plan 4.5 / parity 6.8) is incomplete:\n", file=sys.stderr)+ for line in failures:+ print(f" - {line}", file=sys.stderr)+ print(f"\n{len(failures)} problem(s).", file=sys.stderr)+ return 1++ core = core_compose_services(REPO_ROOT)+ backup = _shell_functions(_read(REPO_ROOT, BACKUP_SH), "backup")+ print(+ f"OK — the chart renders a workload for every one of the {len(core)} CORE services "+ f"(or names why not), restore covers all {len(backup)} components backup writes, and the "+ f"connector scheduler elects one leader with a predicate two replicas cannot both satisfy."+ )+ return 0+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/tests/isolation/test_scheduler_lease_live.py b/tests/isolation/test_scheduler_lease_live.pyindex 7b62595e2..f302fcd79 100644--- a/tests/isolation/test_scheduler_lease_live.py+++ b/tests/isolation/test_scheduler_lease_live.py@@ -79,9 +79,7 @@ class TestOnlyOneLeader:results = await asyncio.gather(a.acquire(), b.acquire())assert sum(1 for won in results if won) == 1, f"acquisitions: {results}"- async def test_two_interleaved_transactions_cannot_both_take_an_expired_lease(- self, engine, scope- ):+ async def test_two_interleaved_transactions_cannot_both_take_an_expired_lease(self, engine, scope):"""The deterministic proof, not a race.The first challenger runs the acquire and **holds its@@ -111,9 +109,7 @@ class TestOnlyOneLeader:async def challenger_a() -> None:async with engine.connect() as conn:await conn.begin()- row = (- await conn.execute(_ACQUIRE_SQL, {"scope": scope, "holder": "a", "lease": 90.0})- ).first()+ row = (await conn.execute(_ACQUIRE_SQL, {"scope": scope, "holder": "a", "lease": 90.0})).first()first.append(row is not None)first_has_run.set()await asyncio.sleep(0.5)@@ -124,18 +120,14 @@ class TestOnlyOneLeader:await asyncio.sleep(0.1)async with engine.connect() as conn:await conn.begin()- row = (- await conn.execute(_ACQUIRE_SQL, {"scope": scope, "holder": "b", "lease": 90.0})- ).first()+ row = (await conn.execute(_ACQUIRE_SQL, {"scope": scope, "holder": "b", "lease": 90.0})).first()second.append(row is not None)await conn.commit()await asyncio.gather(challenger_a(), challenger_b())assert first == [True], "the first challenger did not take the expired lease"- assert second == [False], (- "both replicas took the lease; every vendor would be polled twice on every cycle"- )+ assert second == [False], "both replicas took the lease; every vendor would be polled twice on every cycle"async def test_a_held_lease_cannot_be_stolen(self, engine, scope):a = _lease(engine, scope, "replica-a")@@ -209,9 +201,7 @@ class TestRelease:class TestState:- async def test_state_names_the_holder_so_an_all_follower_deployment_is_visible(- self, engine, scope- ):+ async def test_state_names_the_holder_so_an_all_follower_deployment_is_visible(self, engine, scope):a = _lease(engine, scope, "replica-a")await a.acquire()b = _lease(engine, scope, "replica-b")