Feature: ETag-based CDN model cache invalidation

When admin replaces a model/art file via the CDN browser, the S3 ETag is
now captured and stored on CardAsset.ContentETag. The ETag is included in
the content sync DTO (CardAssetDto) so clients receive it on every sync.

Client-side ModelCache now keys its disk cache on sha256(url + "#" + etag)
instead of sha256(url), so updating a file at the same CDN path busts the
disk cache automatically. A _CACHE_VER="v2" sentinel purges old-scheme
.bin files on first launch after the client update.

Changes:
- CdnUploadResult: add string? ETag field
- S3CdnClient: capture ETag from PutObjectAsync response
- CardAsset: add string? ContentETag property
- Migration 20260318000001_AddAssetContentETag: add content_etag text column
- ContentMessages: add string? ContentETag to CardAssetDto
- ContentDtoMapper: map ContentETag in CardAsset → CardAssetDto
- CdnBrowser.razor: UploadFileToKeyAsync returns Task<string?> (ETag);
  ReplaceAsync calls PropagateAssetETagAsync which updates CardAsset rows
  and touches CardDefinition.UpdatedAt to trigger a version bump
- ModelCache.gd: versioned disk key + cache migration + etag parameter on
  load_model() and evict()
- game_screen.gd: pass model_asset.contentETag to load_model / retry chain

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-03-18 09:38:17 -04:00
co-authored by Claude Happy
parent 4f0f0e9c0f
commit 73c3a71194
11 changed files with 677 additions and 45 deletions
+3 -1
View File
@@ -119,7 +119,9 @@ public sealed record CardAssetDto(
bool IsAiGenerated,
// Model3D config (asset/file-level)
string? ModelFacingDirection,
string? ModelTintMaskUrl);
string? ModelTintMaskUrl,
// Cache-busting ETag updated whenever the file is replaced via CDN browser
string? ContentETag = null);
public sealed record CardAnimationBindingDto(
Guid Id,
@@ -60,7 +60,8 @@ internal static class ContentDtoMapper
a.MimeType,
a.IsAiGenerated,
a.ModelFacingDirection,
a.ModelTintMaskUrl)),
a.ModelTintMaskUrl,
a.ContentETag)),
AnimationBindings: c.AnimationBindings.Select(b => new CardAnimationBindingDto(
b.Id,
b.ActionName,