fix(correctness): cold-audit fixes -- tile-cache determinism bug, cache identities, lifetimes

Correctness round on AUDIT-COLD-2026-09-14.md (Codex; key fixes reviewed by me).

#7 (determinism, introduced by the tile-cache work): the refetch guard in GetDensityAt now
rebuilds on `bTileCacheContext != CP_UsesTileCacheWindow` or when the worker-local stack/core were
moved into a cache entry (`CP_ActiveTunnelDensityCache != nullptr`). A cache miss can no longer
evaluate a moved-from, empty operator stack. Test (VoxelForgeCorrectnessRoundTest): the pre-fix
binary CRASHED in the context-switch case (negative control); the fixed binary passes with 0/5
coarse and fine mismatches, and warm vs fresh origin-tile meshes are identical.

Also fixed, each with a focused test that passes:
- #3/#8: worker diff/surface/biome caches carry owner/layer identity (no cross-world reuse);
  #9: the shaft key gains LedgeSpacing/LedgeDepth and the island key BoundarySealThickness;
  #14: clearing passages bumps PassagesVersion; #21: HasAnyModInChunkRange is proportional to
  the queried range (the sealed-rock proof calls it per candidate).
- #1: the density-volume fill thread is paused/drained with generation; #2: each content manager
  joins its own decoration tasks before destruction; #15: non-finite/invalid modification
  geometry is rejected; #20: zero-width transition blend is guarded at runtime.
- Also #4-#6, #10-#13, #16-#18, #22. #19 is valid C++20 and unchanged.

Verified: canonical export b3e5f4c3..9b377; capability 20,830 / 10,909; fresh trace 841/841
identical, 0 origin-column mismatches; static mesher calls 18,078,130. Performance: two pairs
disagree in sign, and the means are final -2.5% static / -0.8% moving; no repeatable regression.

Known and NOT caused by this round: ClassifyTileSoundness and PassageLandsInOpenSpace were already
failing (15/17 in the grouped suite). Queued for investigation.

Ledger: first determinism launch hit the DDC fatal (crash folder 57DB6ADC, 23:21); the retry
exited 1 on the two known failures; one malformed multi-test launch was inconclusive; one
malformed trace launch was stopped; one launch with an unquoted project path found no test and its
retry passed. Everything else passed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TaFdXhTdYMkW1xrV6ApT6Y
This commit is contained in:
Fr0zkaandClaude Opus 5 committed 2026-09-15 00:29:46 +02:00
1 parent 39c306b524
commit 8879045627
14 files changed
+1365 -139

No files matched your search

@@ -1084,6 +1084,27 @@ bool UVoxelStrateManager::Initialize(UVoxelSettings* Settings, int32 WorldSeed)
WorldSeed = SeasonManifest.Seed;
}
// Keep a valid live layout intact until every season/layout validation step below has
// succeeded. RebuildStrates is called from live edit while old meshes are still visible;
// returning false after clearing these members would leave those meshes backed by an empty or
// partial manager. The copies are small (one entry per strate) and this path is not part of
// worker generation.
const TArray<FStrateSlot> PreviousLayout = StrateLayout;
const TArray<FVoxelSeasonStrate> PreviousSeasonStrates = SeasonStrates;
const FString PreviousSeasonContentHash = ActiveSeasonContentHash;
#if WITH_EDITOR
const TMap<int32, TSharedPtr<FVoxelStrateComposerSlotOverride>> PreviousComposerOverrides = ComposerOverrides;
#endif
auto RestorePreviousLayout = [&]()
{
StrateLayout = PreviousLayout;
SeasonStrates = PreviousSeasonStrates;
ActiveSeasonContentHash = PreviousSeasonContentHash;
#if WITH_EDITOR
ComposerOverrides = PreviousComposerOverrides;
#endif
};
StrateLayout.Empty();
SeasonStrates.Empty();
ActiveSeasonContentHash.Reset();
@@ -1185,8 +1206,7 @@ bool UVoxelStrateManager::Initialize(UVoxelSettings* Settings, int32 WorldSeed)
UE_LOG(LogTemp, Error,
TEXT("[StrateManager] Season slot %d could not load authored definition '%s'."),
i, *SeasonStrate.SourceDefinitionPath);
StrateLayout.Empty();
SeasonStrates.Empty();
RestorePreviousLayout();
return false;
}
// Keep the authored content/passage/visual bag without mutating the cooked asset,
@@ -1228,8 +1248,7 @@ bool UVoxelStrateManager::Initialize(UVoxelSettings* Settings, int32 WorldSeed)
{
UE_LOG(LogTemp, Error,
TEXT("[StrateManager] Season slot %d bounds do not describe the declared stacked layout."), i);
StrateLayout.Empty();
SeasonStrates.Empty();
RestorePreviousLayout();
return false;
}
SeasonStrates.Add(SeasonStrate);
@@ -1611,6 +1630,9 @@ bool UVoxelStrateManager::GetRecipeForChunk(
void UVoxelStrateManager::GeneratePassages()
{
VoxelForgeStartupTrace::FStageScope StartupTraceStage(TEXT("GeneratePassages"));
// Invalidate worker-local passage shortlists even when the new layout is empty. Returning
// before this bump would leave a nearby-passage TLS list pointing at the cleared array.
++PassagesVersion;
Passages.Empty();
if (StrateLayout.Num() < 1)
@@ -2473,9 +2495,6 @@ void UVoxelStrateManager::GeneratePassages()
}
}
// Invalidate any thread_local per-chunk passage shortlists (see EvaluateModifierSDF).
++PassagesVersion;
VoxelForgeStartupTrace::RecordEvent(TEXT("passages_ready"), FString::Printf(
TEXT("\"passages\":%d,\"passages_version\":%u,\"upper_source_fit\":%d,\"lower_source_fit\":%d"),
Passages.Num(), PassagesVersion, NumAimedAtUpperPlayerFit, NumAimedAtLowerPlayerFit));
@@ -5691,7 +5710,7 @@ FStrateGenerationParams UVoxelStrateManager::GetGenerationParams(const FIntVecto
{
// GRADIENT TRANSITION: Classic smooth lerp across the blend zone.
// Alpha goes from 0 (at the outer edge of the zone) to 1 (right at boundary).
if (DistFromBottom < EffectiveBlend)
if (EffectiveBlend > 0 && DistFromBottom < EffectiveBlend)
{
FStrateGenerationParams BelowParams = BuildParamsFromDefinition(BelowSlot.Definition);
BelowParams.StrateTopWorldZ = (float)(BelowSlot.TopChunkZ + 1) * CHUNK_SIZE;
@@ -5709,6 +5728,8 @@ FStrateGenerationParams UVoxelStrateManager::GetGenerationParams(const FIntVecto
case EVoxelStrateTransition::Interleaved:
{
if (EffectiveBlend <= 0) { break; }
// INTERLEAVED TRANSITION: 3D noise warps the effective boundary Z.
//
// Instead of a flat boundary plane, the boundary becomes a wavy 3D surface.
@@ -5788,7 +5809,7 @@ FStrateGenerationParams UVoxelStrateManager::GetGenerationParams(const FIntVecto
case EVoxelStrateTransition::Gradient:
{
if (DistFromTop < EffectiveBlend)
if (EffectiveBlend > 0 && DistFromTop < EffectiveBlend)
{
FStrateGenerationParams AboveParams = BuildParamsFromDefinition(AboveSlot.Definition);
AboveParams.StrateTopWorldZ = (float)(AboveSlot.TopChunkZ + 1) * CHUNK_SIZE;
@@ -5805,6 +5826,8 @@ FStrateGenerationParams UVoxelStrateManager::GetGenerationParams(const FIntVecto
case EVoxelStrateTransition::Interleaved:
{
if (EffectiveBlend <= 0) { break; }
const float WarpAmplitude = 2.0f;
const int32 CheckRange = EffectiveBlend + FMath::CeilToInt(WarpAmplitude);