feat(sites): record the artifact revision last deployed to a site

Site.ArtifactRevisionHash / ArtifactsDeployedAt (nullable, migration
AddSiteArtifactRevision) so the Sites page can tell whether a site's
system-wide artifacts are current. Not transported. Adds the
GetDeployedRevisionHashesAsync projection for the fleet-wide staleness batch.

Claude-Session: https://claude.ai/code/session_01Y5ef34iUUMjmwnMpL9xgmB
This commit is contained in:
Joseph Doherty
2026-09-14 13:33:59 -04:00
parent 0762d69132
commit dd202e5dde
9 changed files with 2333 additions and 4 deletions
@@ -45,8 +45,10 @@ namespace ZB.MOM.WW.ScadaBridge.Transport.IntegrationTests;
/// Tasks 3–5. Excluded properties are limited to: surrogate <c>Id</c>s, FK id
/// columns that are legitimately remapped to the target's own surrogate keys,
/// inheritance-placeholder flags that are re-derived at import (never carried), and
/// the one documented design reset (imported <see cref="Instance.State"/> →
/// <see cref="InstanceState.NotDeployed"/>). Each exclusion is annotated inline.
/// the documented design resets — imported <see cref="Instance.State"/> →
/// <see cref="InstanceState.NotDeployed"/>, and <see cref="Site.ArtifactRevisionHash"/> /
/// <see cref="Site.ArtifactsDeployedAt"/> → null ("artifacts never deployed" in the importing
/// environment). Each exclusion is annotated inline.
/// </para>
/// <para>
/// Both the "source" and "imported" entities are re-read from the DB (AsNoTracking)
@@ -783,6 +785,10 @@ public sealed class RoundTripEquivalenceTests : IDisposable
NodeBAddress = "akka://site@10.0.0.2:2552",
GrpcNodeAAddress = "10.0.0.1:8083",
GrpcNodeBAddress = "10.0.0.2:8083",
// Non-default deploy state, so the imported site is provably reset rather than
// accidentally equal to an unset source.
ArtifactRevisionHash = "artifact-hash-1",
ArtifactsDeployedAt = new DateTimeOffset(2026, 9, 14, 10, 0, 0, TimeSpan.Zero),
};
ctx.Sites.Add(site);
await ctx.SaveChangesAsync();
@@ -883,8 +889,14 @@ public sealed class RoundTripEquivalenceTests : IDisposable
var impConn = await ctx.DataConnections.AsNoTracking().SingleAsync(c => c.Name == "OpcUaPrimary");
var impInstance = await LoadInstanceAsync(ctx, "Pump-01");
// Site.
AssertRoundTripEqual(srcSite, impSite, nameof(Site.Id));
// Site. ArtifactRevisionHash/ArtifactsDeployedAt are environment-specific deploy state
// (like Instance.State) — a site reads "artifacts never deployed" in the importing
// environment until artifacts are deployed there, so they are deliberately not
// transported.
AssertRoundTripEqual(srcSite, impSite,
nameof(Site.Id), nameof(Site.ArtifactRevisionHash), nameof(Site.ArtifactsDeployedAt));
Assert.Null(impSite.ArtifactRevisionHash);
Assert.Null(impSite.ArtifactsDeployedAt);
// DataConnection. SiteId remapped; Primary/Backup config ride the SecretsBlock.
AssertRoundTripEqual(srcConn, impConn, nameof(DataConnection.Id), nameof(DataConnection.SiteId));