From 05c35c93d9476419b582839e65141315686d3900 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Mon, 13 Jul 2026 09:55:44 -0400 Subject: [PATCH] test(host): pin sequential clear-then-recompile contract of RoslynVirtualTagEvaluator (02/S12 baseline) --- ...2-03-vt-failure-quality-plan.md.tasks.json | 2 +- .../RoslynVirtualTagEvaluatorTests.cs | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/archreview/plans/R2-03-vt-failure-quality-plan.md.tasks.json b/archreview/plans/R2-03-vt-failure-quality-plan.md.tasks.json index ec8ebe41..bbaea7c8 100644 --- a/archreview/plans/R2-03-vt-failure-quality-plan.md.tasks.json +++ b/archreview/plans/R2-03-vt-failure-quality-plan.md.tasks.json @@ -42,7 +42,7 @@ { "id": "R2-03-T6", "subject": "S12 sequential pin: Evaluate_after_ClearCompiledScripts_recompiles_and_succeeds (green baseline the T8 retry-loop restructure must not regress)", - "status": "pending", + "status": "completed", "blockedBy": [] }, { diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests/RoslynVirtualTagEvaluatorTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests/RoslynVirtualTagEvaluatorTests.cs index 03587563..eb191c0f 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests/RoslynVirtualTagEvaluatorTests.cs +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests/RoslynVirtualTagEvaluatorTests.cs @@ -357,6 +357,29 @@ public sealed class RoslynVirtualTagEvaluatorTests CompiledCacheCount(sut).ShouldBe(0); } + /// 02/S12 sequential pin: evaluating a compiled expression, clearing the cache, then + /// evaluating the SAME source again succeeds both times and leaves the cache with exactly one entry + /// (the recompile). This pins the clear-then-recompile contract the T8 retry-loop restructure must + /// not regress. + [Fact] + public void Evaluate_after_ClearCompiledScripts_recompiles_and_succeeds() + { + using var sut = new RoslynVirtualTagEvaluator(NullLogger.Instance, NoOpScriptRoot()); + const string expr = "return (int)ctx.GetTag(\"a\").Value + 1;"; + + var first = sut.Evaluate("vt-clear", expr, new Dictionary { ["a"] = 1 }); + first.Success.ShouldBeTrue(first.Reason); + CompiledCacheCount(sut).ShouldBe(1); + + sut.ClearCompiledScripts(); + CompiledCacheCount(sut).ShouldBe(0); + + var second = sut.Evaluate("vt-clear", expr, new Dictionary { ["a"] = 41 }); + second.Success.ShouldBeTrue(second.Reason); + second.Value.ShouldBe(42); + CompiledCacheCount(sut).ShouldBe(1); + } + /// Reads the count of the private compiled-script cache via reflection. The cache is a /// CompiledScriptCache<,> which exposes a Count property (not ICollection). private static int CompiledCacheCount(RoslynVirtualTagEvaluator sut)