feat(reconcile): site-reconcile messages + expected-set/stage-if-absent repo

- Commons: ReconcileSiteRequest / ReconcileSiteResponse / ReconcileGapItem
  message contracts (site→central ClusterClient on startup; central reply with
  gap fetch tokens + orphan list + base URL).
- Commons: ExpectedDeployment projection record (Commons/Types/Deployment/),
  lightweight join of DeployedConfigSnapshot + Instance (no ConfigJson).
- IDeploymentManagerRepository: GetExpectedDeploymentsForSiteAsync (inner-join
  query returning deployed set for a site, excluding snapshot-less instances) +
  StagePendingIfAbsentAsync (insert-if-absent, self-contained save, returns bool;
  does NOT supersede — an existing pending row signals in-flight delivery).
- DeploymentManagerRepository: implement both methods; StagePendingIfAbsent
  commits internally (matches PurgeExpiredPendingDeployments convention).
- ReconcileRepositoryTests: 4 tests covering expected-set filter/IsEnabled/
  cross-site isolation, empty-site, stage-absent (true + row retrievable),
  stage-present (false + existing row unchanged); all pass.
This commit is contained in:
Joseph Doherty
2026-06-26 16:04:12 -04:00
parent e5503857df
commit ec2aa2bbac
6 changed files with 333 additions and 0 deletions
@@ -0,0 +1,19 @@
namespace ZB.MOM.WW.ScadaBridge.Commons.Types.Deployment;
/// <summary>
/// Lightweight projection of an instance's last-deployed state, used by the startup-reconciliation
/// path to compute the gap between central's expected deployed set and a site node's local inventory.
/// No <c>ConfigurationJson</c> is included — the full config is only fetched for gap instances via
/// the HTTP endpoint using the freshly-minted <see cref="ReconcileGapItem.FetchToken"/>.
/// </summary>
/// <param name="InstanceId">The instance primary key.</param>
/// <param name="InstanceUniqueName">The system-wide unique name for the instance.</param>
/// <param name="RevisionHash">Revision hash of the flattened configuration at last successful deploy.</param>
/// <param name="DeploymentId">Deployment ID of the last successful deploy (the fetch key).</param>
/// <param name="IsEnabled">True when the instance's current <c>State</c> is <c>Enabled</c>.</param>
public record ExpectedDeployment(
int InstanceId,
string InstanceUniqueName,
string RevisionHash,
string DeploymentId,
bool IsEnabled);