feat: add retained underlay runtime controls

This commit is contained in:
tei
2026-09-22 16:18:58 +09:00
parent 9ad2fe5d58
commit 8384c8bd24
31 changed files with 1181 additions and 59 deletions

View File

@@ -87,3 +87,29 @@ TEST(RetainedUnderlayCache, UnsupportedAndResourceFailureFallBackSafely) {
EXPECT_FALSE(cache.isValid());
EXPECT_EQ(cache.getFallbackCount(), 2u);
}
TEST(RetainedUnderlayCache, RuntimeControlDisablesAndReenablesMapScopedCache) {
auto state = std::make_shared<RetainedUnderlayRuntimeState>();
RetainedUnderlayCache cache;
cache.synchronizeRuntimeState(state);
EXPECT_EQ(cache.evaluate(key(), true), RetainedUnderlayDecision::Build);
cache.markBuildSucceeded();
EXPECT_TRUE(cache.isValid());
EXPECT_TRUE(state->setEnabled(false));
cache.synchronizeRuntimeState(state);
EXPECT_FALSE(cache.isValid());
EXPECT_EQ(cache.evaluate(key(), true), RetainedUnderlayDecision::Fallback);
auto disabled = state->snapshot();
EXPECT_FALSE(disabled.enabled);
EXPECT_EQ(disabled.build, 1u);
EXPECT_EQ(disabled.fallback, 1u);
EXPECT_EQ(disabled.invalidation, 2u); // first-frame plus the runtime disable.
EXPECT_EQ(disabled.lastReason, "runtime-disabled");
EXPECT_TRUE(state->setEnabled(true));
cache.synchronizeRuntimeState(state);
EXPECT_EQ(cache.evaluate(key(), true), RetainedUnderlayDecision::Build);
EXPECT_TRUE(state->snapshot().enabled);
}