Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7640432
Say what settings_error_detail returns at the ai-policy, cluster-vip …
wshallwshall Dec 1, 2026
39d5aa6
docs/AI.md: say what the ai-policy error line carries
wshallwshall Dec 1, 2026
a60db09
docs: say which SQL Server preset values are braced and that server i…
wshallwshall Dec 1, 2026
3e90531
Repair round one: point at the renderer's docstring rather than resta…
wshallwshall Dec 1, 2026
89ea694
docs/AI.md: repair round one on the ai-policy disclosure paragraph
wshallwshall Dec 1, 2026
84a291c
settings: the URL check's docstring names an ASCII scheme, judged aft…
wshallwshall Dec 1, 2026
4c62e43
docs: CONFIGURATION.md's backup and DR path rows state the URL check'…
wshallwshall Dec 1, 2026
9011f2f
docs: at-rest cipher row states the keyless gate the code has (BACKLO…
wshallwshall Dec 1, 2026
3f7408f
tests: pin the at-rest cipher row's keyless rule to the code (BACKLOG…
wshallwshall Dec 1, 2026
7578fe5
tests: pin the anchor check's refusal of a PEM block with no data, in…
wshallwshall Dec 1, 2026
f59362b
docs: make four operator-doc security statements say what the code do…
wshallwshall Dec 1, 2026
4c8ce9a
docs: repair the operator-doc fixes after review round one (BACKLOG #…
wshallwshall Dec 1, 2026
2cfbe66
docs: hand-over record for the operator-doc corrections (BACKLOG #2734)
wshallwshall Dec 1, 2026
275bbdc
docs: repair round three of the operator-doc corrections (BACKLOG #2734)
wshallwshall Dec 1, 2026
ccd972c
merge b20053-2734s
wshallwshall Dec 1, 2026
3b17641
merge b20053-5113
wshallwshall Dec 1, 2026
b74f1a0
merge b20053-5270
wshallwshall Dec 1, 2026
c3537ec
merge b20053-5230
wshallwshall Dec 1, 2026
d376dee
docs: relay hop, bind-guard effect, AOAG DR start steps, TOTP keyless…
wshallwshall Dec 1, 2026
3708d19
docstrings and tests: cluster-vip print bound, cadata message source,…
wshallwshall Dec 1, 2026
e83b1b9
docs: review round 1 on the relay, bind-guard and AOAG repair
wshallwshall Dec 1, 2026
55e4ab9
docstrings: review round 1 on the cluster-vip and cadata wording
wshallwshall Dec 1, 2026
45bad2e
docs: review round 2 on the relay, bind-guard and AOAG repair
wshallwshall Dec 1, 2026
fe4f3b0
docs: point the cloud docs at the bind-guard and attestation sources …
wshallwshall Dec 1, 2026
c48a53a
docs: AOAG failback steps name their preconditions and undo the activ…
wshallwshall Dec 1, 2026
a86daa2
docs: review round 1; the cloud docs' bind-guard sentences go back to…
wshallwshall Dec 1, 2026
ff92449
docs: review round 2; CONNECTIONS attestation pair back to its closed…
wshallwshall Dec 1, 2026
e6fc6fb
docs: cloud docs back to main, with only the encrypted-link deletions
wshallwshall Dec 2, 2026
611a67e
docs: AOAG DR start step points at the service environment recipe
wshallwshall Dec 2, 2026
4870a53
docs: review round 1 on the final head; deletions and one pointer only
wshallwshall Dec 2, 2026
de2ba2a
Merge origin/main into batch/20053-docs
wshallwshall Dec 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions docs/AI.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,17 @@ effective policy, and prints the **same JSON** to stdout — except `assist_perm
`null`** (RBAC is not evaluable offline). `--json` prints only the JSON object (the IDE parses
stdout); on error it prints `{"error": "..."}`.

It prints **no message data and no configured value**. That is narrower than the "config only, never
message data" this line used to say, and the difference is the point: no HL7 ever reaches this
subcommand, so the only thing its output could disclose was config, which that sentence said nothing
about. It did disclose config — `str(ValidationError)` carries `input_value=` for every failing
field, so a `[store]` missing `server` put `MEFOR_STORE_PASSWORD` on the stdout the IDE reads. The
error line is now rendered by `settings_error_detail` (field path and message, never the value);
that function's docstring carries the argument, and `tests/test_cli_ai_policy.py` pins it.
On stdout it prints **no message data**, and of config only the policy JSON above or the error
line. No HL7 reaches this subcommand, so config is what its output can disclose, and it once did:
`str(ValidationError)` carried `input_value=` for every failing field, so a `[store]` missing
`server` put `MEFOR_STORE_PASSWORD` on the stdout the IDE reads. Two layers now keep pydantic's
input out of the error line: the settings models hide it themselves, and the line is rendered by
`settings_error_detail`. Neither hides a value an error's own message quotes, and some refusals
quote the value they refused. That function's docstring in
[config/settings.py](../messagefoundry/config/settings.py) names at least some that do.
`tests/test_cli_ai_policy.py` pins the absence of an env-supplied secret, and
`tests/test_cli_settings_error_render.py` pins the renderer on this subcommand. Stderr is not
covered: the settings load's warnings go there, and some quote a configured value.

---

Expand Down
77 changes: 69 additions & 8 deletions docs/AOAG-DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,30 @@ two hospital engines and the DR engine. Give each an **identical config dir** an
identical-config check** below (a divergent DR config dead-letters rows on promotion). This cold
posture is the deliberate counterpart to the cross-WAN-leadership hazard above; the two hospital
engines, both warm and active-eligible, are what actually cover in-hospital engine failover.
**Stopped is not enough: set the DR engine's service to manual start.** `install-service.ps1`
sets the service to start automatically (`SERVICE_AUTO_START`) on every run, a re-run over an
existing service included, so a stopped DR engine starts by itself at its next reboot, against the
cold posture. A manual start type lasts only until the installer's next run, so set it again after
every run of the installer: run this on the DR engine VM, in an elevated PowerShell, because
changing a service's start type needs one. It matches
the service by its exact name, as the installer does, because `-Name` also matches a display name;
put your `-ServiceName` in `$n` if you changed it from the default `MessageFoundry`. If the change
fails, for example in a shell that is not elevated, `-ErrorAction Stop` ends the line at the error,
so it never prints the readback as if the change had been made:

```powershell
if ([Environment]::MachineName -ne '<DR-ENGINE-HOST>') { Write-Host "STOP this must run on <DR-ENGINE-HOST>, but this is $([Environment]::MachineName); nothing ran" } else { $n = 'MessageFoundry'; $svc = Get-Service | Where-Object { $_.Name -eq $n }; if (-not $svc) { Write-Host "STOP no service is named $n here; nothing changed" } else { Set-Service -InputObject $svc -StartupType Manual -ErrorAction Stop; Get-Service | Where-Object { $_.Name -eq $n } | Select-Object Name, Status, StartType } }
```

A manual start type stops only the start at boot. A manual service still starts on demand, so the
§6 runbook's start step starts it, and so do at least these: the `Restart-Service` and
`Start-Service` lines in [SERVICE.md](SERVICE.md), the `Start-Service` line the installer prints
as its next step, and the restart after a re-run of the installer in
[REMOTE-CONSOLE.md](REMOTE-CONSOLE.md). While a §6 activation has the DR engine carrying the
traffic, a manual start type means a reboot of its VM leaves no engine running: run the same line
with `-StartupType Automatic` once it is up (§6 runbook step 5), and with `Manual` again at
failback. Setting `Manual` does not stop the service; the line in failback's engine-side step 2
sets it and stops the service.
- Timing defaults (`[…]` = `[cluster]`, with the invariant `heartbeat < fence < ttl` enforced at
config load): `heartbeat_seconds = 10`, `leader_fence_timeout_seconds = 20`,
`leader_lease_ttl_seconds = 30`, `node_timeout_seconds = 30`. `[store].pool_size ≥ 2` is
Expand Down Expand Up @@ -673,7 +697,7 @@ Document which pattern you chose; the §6 runbook's sender-repoint step executes
| Failure | Automatic behavior | Operator action |
|---|---|---|
| **Hypervisor host holding the SQL primary dies** | AG fails over automatically to the local sync secondary. Detection is bounded by the 20–30 s default timeouts plus redo drain, and runs longer if you raised the WSFC thresholds (§7.3), so substitute your own numbers. The engine rides the outage per §5.2, likely a self-fence and listener bounce that self-heals. Anti-affinity guarantees the engine and the other replica were elsewhere. | Verify `/cluster/nodes` and AG dashboard; check for stuck in-flight (§5.3) and restart the active engine service if any; restore host → replica rejoins and catches up. |
| **Hypervisor host holding the active engine dies** | A non-leader acquires the lease after ≤ `leader_lease_ttl_seconds` (30 s) — the **surviving hospital engine or the DR engine, whichever renews first**, unless you have made the DR engine non-promotable (`[cluster].promotable = false`, §5.1); on-promotion recovery re-pends the dead node's in-flight rows (~7 s measured functional failover). VIP/route follows via the TCP health check. Hypervisor HA also restarts the dead VM (minutes, crash-consistent) — it comes back as a non-leader. DB untouched. | **Verify which engine won** (`/cluster/nodes`). With a second hospital engine present, promotion should stay in-hospital — confirm it did. **If the DR engine took the lease while the AG primary is still hospital-local, you now have a cross-WAN active engine** (§5.1/§3.3): execute **engine failback** — clean-restart the DR engine service so a hospital engine re-acquires (§6 *Failback*), then stop the DR engine cold again (§5.1). Confirm the VIP/route followed and dispositions are flowing. |
| **Hypervisor host holding the active engine dies** | A non-leader acquires the lease after ≤ `leader_lease_ttl_seconds` (30 s) — the **surviving hospital engine or the DR engine, whichever renews first**, unless you have made the DR engine non-promotable (`[cluster].promotable = false`, §5.1); on-promotion recovery re-pends the dead node's in-flight rows (~7 s measured functional failover). VIP/route follows via the TCP health check. Hypervisor HA also restarts the dead VM (minutes, crash-consistent) — it comes back as a non-leader. DB untouched. | **Verify which engine won** (`/cluster/nodes`). With a second hospital engine present, promotion should stay in-hospital — confirm it did. **If the DR engine took the lease while the AG primary is still hospital-local, you now have a cross-WAN active engine** (§5.1/§3.3): execute **engine failback** — stop the DR engine cold, with §6 *Failback* engine-side step 2, its `/cluster/nodes` check first, so its clean stop releases the lease and a hospital engine re-acquires it (§6 *Failback*, routine case). Confirm the VIP/route followed and dispositions are flowing. |
| **Planned local AG failover (patching)** | Planned manual failover between R1↔R2, no data loss. Engine sees a short DB outage — §5.2's 10 s case if quick. | Schedule in a quiet window; afterwards check stuck in-flight; drill this quarterly (it doubles as the §5.3 reconnect drill). |
| **Local sync secondary lost** (host/storage) | After the ~10 s session timeout the primary marks it `NOT SYNCHRONIZING` and keeps committing (`REQUIRED_SYNCHRONIZED_SECONDARIES_TO_COMMIT = 0`). **Running exposed:** no local automatic failover until it's back and resynchronized. | Alert + restore redundancy promptly. If it's *slow* rather than dead, commits are waiting on it (`HADR_SYNC_COMMIT`) — consider flipping it async while remediating. |
| **Both local DB replicas lost, engines alive** (partial site loss — storage/rack; R1 *and* R2 gone, the hospital engines still up) | No automatic failover: with both sync replicas gone the AG has no synchronized local target, and R3 is async (no auto-failover). Ingress commits fail, so the engines stop ACKing and run their store-error retry loops (§5.2); nothing is accepted-and-dropped. | Do **not** let the engines thrash a half-dead AG. In order: **(1) stop the engine services** (both hospital engines) to quiesce commit retries; **(2) force the AG** to R3 (`FORCE_FAILOVER_ALLOW_DATA_LOSS`, forcing quorum first per §4.3/§6 if quorum was lost); **(3) verify via `/cluster/nodes`** that exactly one engine holds the lease, then start it against the now-DR primary — accepting this is cross-WAN operation (§9). RPO per the §6 forced-failover loss statement. |
Expand Down Expand Up @@ -707,8 +731,28 @@ Document which pattern you chose; the §6 runbook's sender-repoint step executes
5. **Start the DR engine service.** In steady state the DR engine runs **cold** (§5.1), so it is
*not* already competing for the lease — **start its NSSM service now**, after (a) confirming the
listener resolves to the DR subnet (step 4) and (b) running the **identical-config check** (§5.1)
so promotion does not dead-letter rows. On start it acquires the lease within ≈ one heartbeat and
on-promotion `reset_stale_inflight` re-pends in-flight rows. Repoint senders per the §5.4 pattern:
so promotion does not dead-letter rows. On start it acquires the lease within ≈ one heartbeat
and on-promotion `reset_stale_inflight` re-pends in-flight rows. Any
`[cluster].acquire_delay_seconds` set on it (§5.1) counts from when the dead leader's lease
expired, on the database's clock, not from this start: if the lease expired less than that delay
ago, the claim waits out the remainder. If that is too long, lower it in its service config before the start, since a node reads it once,
at start; a
`MEFOR_CLUSTER_ACQUIRE_DELAY_SECONDS` in the service's environment wins over the file, so change
or remove it there if one is set.
Edit the service's environment with the read, edit and write-back steps in
[SERVICE.md](SERVICE.md#start--stop--status), because `nssm set AppEnvironmentExtra` replaces the whole list.
A service reads its environment only when it starts, so if it is running, restart it after you change it.
The claim holds only for a promotable
node: a DR engine set `[cluster].promotable = false` (§5.1) never acquires or renews the lease,
so this start leaves it a non-leader and, with the hospital engines down, the cluster with no
leader. So if you set it non-promotable, make it promotable before you start it: set
`[cluster].promotable = true` in the service config its service reads (the installer's
`-ServiceConfig`, [SERVICE.md](SERVICE.md)). A `MEFOR_CLUSTER_PROMOTABLE` variable in the
service's environment wins over the file, so change or remove it there if one is set, and after
the start confirm the node shows `promotable: true` on `/cluster/nodes`. A node reads that setting
once, when it starts, so if its service is already running, restart it rather than start it. Once the service is up,
set its start type to automatic with the §5.1 line, written with `-StartupType Automatic`, so a
reboot of its VM while it carries the traffic starts it again. Repoint senders per the §5.4 pattern:
a global LB / GSLB follows automatically via the health check *once the service is up*; per-DC
VIPs execute the sender cutover list; with RHI, **advertise the DR /32** now.
6. **Verify the hospital-side /32 was withdrawn.** If the hospital site advertised the MLLP VIP as a
Expand All @@ -729,8 +773,10 @@ engine** (the #2 hospital engine, or worse the DR engine) win the lease while th
left the hospital. Nothing on the SQL side moved, so there is nothing to resync — **just move
leadership back**: confirm the configs are identical (§5.1), then **cleanly restart the misplaced
engine service**. Its clean stop releases the lease immediately and the intended engine promotes in
≈ one heartbeat (§5.3). If the misplaced engine was the **DR** engine, **stop it cold again**
afterward (§5.1). Use this whenever §6's active-engine-death row flags a cross-WAN leader; the full
≈ one heartbeat (§5.3). If the misplaced engine was the **DR** engine, **stop it cold instead of
restarting it**, with engine-side step 2 below, its `/cluster/nodes` check first; its line sets manual start and stops it. Its
clean stop releases the lease the same way, and a stopped engine cannot race for it again; the §5.1
line alone sets manual start and leaves it running. Use this whenever §6's active-engine-death row flags a cross-WAN leader; the full
SQL + engine sequence below applies only after an actual DR *database* activation.

**SQL side.** Microsoft's forced-failover doc covers the sequence. In outline: rejoin and resume
Expand All @@ -755,9 +801,24 @@ So **before you RESUME** the old primary:

1. Confirm the two engine configs are **identical** before promoting (§5.1; a divergent config can
dead-letter rows on promotion).
2. **Cleanly restart the DR engine service.** The clean stop releases the lease immediately, and
the primary-DC standby promotes in ≈ one heartbeat. This is §5.3's recovery mechanism, used
deliberately as the failback lever.
2. **Stop the DR engine cold (§5.1).** First confirm on `/cluster/nodes` that a primary-DC engine
is running and promotable: with none, stopping the DR engine leaves the cluster with no leader.
If you made the DR engine promotable at activation (runbook step 5), set `[cluster].promotable =
false` in its service config again, so a later stray start cannot take the lease. Also undo
any activation change to `acquire_delay_seconds` in the file, and to `MEFOR_CLUSTER_PROMOTABLE`
or `MEFOR_CLUSTER_ACQUIRE_DELAY_SECONDS` in the service's environment
([SERVICE.md](SERVICE.md#start--stop--status)). Then run this
on the DR engine VM, in an elevated PowerShell, with the same `$n` as the §5.1 line. It sets the
start type back to manual and stops the service. The clean stop releases the lease immediately,
and the primary-DC standby promotes in ≈ one heartbeat: this is §5.3's recovery mechanism, used
deliberately as the failback lever. A stopped engine cannot race for the lease again, as a
restarted one can. If either change fails, `-ErrorAction Stop` ends the line at that error, so
the readback prints only once both are made:

```powershell
if ([Environment]::MachineName -ne '<DR-ENGINE-HOST>') { Write-Host "STOP this must run on <DR-ENGINE-HOST>, but this is $([Environment]::MachineName); nothing ran" } else { $n = 'MessageFoundry'; $svc = Get-Service | Where-Object { $_.Name -eq $n }; if (-not $svc) { Write-Host "STOP no service is named $n here; nothing changed" } else { Set-Service -InputObject $svc -StartupType Manual -ErrorAction Stop; Stop-Service -InputObject $svc -ErrorAction Stop; Get-Service | Where-Object { $_.Name -eq $n } | Select-Object Name, Status, StartType } }
```

3. Verify the primary-DC node reports `role == "primary"` on `/cluster/nodes`, and that the
listener DNS has flipped back to the primary subnet (the step-4 `Resolve-DnsName` check, run
from the primary-DC engine VM).
Expand Down
Loading
Loading