fix(site-runtime): batch native-alarm deletes into the coalesced flush transaction; docs for scripts/cache/scheduler (review 2026-10-21 01/SR-P2)

This commit is contained in:
Joseph Doherty
2026-10-22 08:33:30 -04:00
parent 010d2ea438
commit 37c25db2f1
5 changed files with 148 additions and 18 deletions
@@ -95,6 +95,23 @@ public class NativeAlarmStateStoreTests : IAsyncLifetime, IDisposable
Assert.Equal("Tank01.Lo", rows[0].SourceReference);
}
/// <summary>Upserts and deletes apply together in one batch (review 2026-10-21 01/SR-P2).</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task ApplyChanges_UpsertsAndDeletesInOneBatch()
{
await _storage.UpsertNativeAlarmAsync("inst", "Src", "A", "{}", DateTimeOffset.UnixEpoch);
await _storage.UpsertNativeAlarmAsync("inst", "Src", "B", "{}", DateTimeOffset.UnixEpoch);
await _storage.UpsertNativeAlarmAsync("inst", "Src", "C", "{}", DateTimeOffset.UnixEpoch);
await _storage.ApplyNativeAlarmChangesAsync("inst", "Src",
[("D", "{\"n\":1}", null, DateTimeOffset.UnixEpoch)],
["A", "B"]);
var refs = (await _storage.GetNativeAlarmsAsync("inst", "Src")).Select(r => r.SourceReference).OrderBy(x => x).ToArray();
Assert.Equal(new[] { "C", "D" }, refs);
}
/// <summary>Verifies that clearing an instance removes all of its sources and leaves other instances untouched.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]