Skip to content

fix(resource): follow up on the merged resource and save pull requests - #2485

Open
houko wants to merge 5 commits into
mainfrom
fix/followup-resource-save-2
Open

houko wants to merge 5 commits into
mainfrom
fix/followup-resource-save-2

Conversation

@houko

@houko houko commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Follow-up review of the resource and save pull requests the merge train landed without CI.

Reviewed pull requests

#2279 feat(resource): add adaptive music format

Landed intact, but Music.Validate accepted files the format cannot play: a NaN or infinite bpm, clips with neither a source nor stems, a next, from, to or via naming a clip that does not exist, any at string, and negative fades or crossfade. This PR checks each of them with a *loaderr.Error naming the field (from: "*" stays allowed, as #1400 specifies). #1400 stays open: playback, game check and game mv are follow-ups.

#2280 feat(resource): add sound cue resources

OK. The merge dropped the doc comments on KindAnimGraph, KindSound and KindMusic, and Parse's fix text and the package doc still listed the kinds without animgraph and music; both are fixed here.

#2284 feat(resource): add advanced animation tracks

sounds and clips keys were not validated at all (times outside the clip or out of order, paths outside the project, an empty clip), and event args accepted nested maps and null although the docs say scalar. They are now refused. SoundKey, ClipKey, Animation.Sounds/Clips and Event.Args get doc comments.

#2286 feat(resource): add 3D animation graph format

The from, to / clip, fire tag bug was already fixed on main. Validation only checked the model path, parameter names and layer names. It now also checks parameter types (float, bool, trigger), unique layer names, exactly one of machine and oneShot per layer, unique state names, entry and transitions naming states, a state's clip or blend1d, blends driven by a declared float parameter with finite increasing samples, one-shots fired by a declared trigger, mask weight in [0, 1], layer mode (override/additive), and non-negative fades.

#2302 feat(resource): add theme style boxes and variations

The merge dropped the "Theme style boxes" section from docs/en and docs/zh gameui.md; restored. The format did not match #1422: border was a string where the issue specifies {width, color}, and a variation could not set font, so the issue's own example was refused. Style boxes were not validated (kind, colors, radius, image). This PR adds StyleBorder, ThemeVariation.Font, style box validation, font validation for types and variations, and doc comments on the new fields. The round-trip test now checks that encoding is stable.

#2115 feat(save): add tamper-evident per-install seals

Code landed intact, but there is a security hole: Load verified the seal only when the envelope had one, so deleting the seal field was all an edit needed to load. A copy without a seal is now a mismatch; the new SealOptions.AcceptUnsealed keeps the legacy upgrade path (#1655: "unsealed saves upgrade") as an explicit opt-in. The docs paragraph the merge put between the migrations sentence and its code example moves into the tamper-evident section, which now also says the header is not sealed and what the seal does not protect against. SealRefuse/SealReport and the SealOptions fields get doc comments, and the implementation note is updated.

#2251 fix(save): normalize storage full errors

The docs line was dropped by the merge; restored. ErrStorageFull only wrapped *core.StorageFullError, so FileBackend's ENOSPC (ERROR_DISK_FULL / ERROR_HANDLE_DISK_FULL on Windows) and a file-backed SettingsStore never matched it, although the docs promise it across backends. Both are wrapped now. The PR said Closes #1569, but LoadInfo/FromBackup, the quarantine copy and its tests are not implemented, so #1569's acceptance is not met.

#2353 feat(save): add stable load diagnostics

The docs and changelog were released with 0.4.0 and moved to save.md, which is fine. DiagnosticError reported ErrNotFound and ErrStorageFull as unknown, a missing migration as recoverable, and a tampered save as corrupt. They now get not_found, storage_full, missing_migration (not recoverable) and tampered, and the codes are documented.

#2358 feat: add unsaved progress close policy

The docs line was dropped by the merge; restored, and the CloseDecision constants get doc comments. The PR said Closes #1574, but it only adds the three-value DirtyState.Decide: no game.GuardQuit, no quit or window-close handling, no dialog and no template changes, so #1574's acceptance is not met.

#2407 feat: add save migration registry

The "Migration registries" docs section was dropped by the merge; restored. The code is OK. MigrationRegistry is not used by Store, which keeps its own Migrations map. It is the start of #1541's format registry, so it stays.

Verification

  • go tool nsgo test ./pkg/resource/... ./pkg/save/... (blackmac): all pass
  • go tool nsgo check ./pkg/save/..., go tool nsgo check ./pkg/resource/...; GOOS=windows and GOOS=js GOARCH=wasm go vet ./pkg/save/
  • go tool nsgo test ./internal/repocheck/...: pass
  • bun run verify-notes, go run ./tools/changelog check

No open pull request touches these files.

Screenshots: None

…heme styles

The music, sound and nested clip animation keys, animgraph and theme style formats from #2279, #2284, #2286 and #2302 accepted files they could not use: a NaN tempo, transitions, next clips and states naming clips or states that do not exist, unknown transition points, layer modes and parameter types, a blend driven by a trigger, nested or null event arguments, sound and clip keys outside the clip or outside the project, and style boxes with an unknown kind or color. Each is now refused with a *loaderr.Error naming the field.

Theme style box borders are a {width, color} stroke and variations may set a font, as #1422 specifies; a string border and a variation font were refused before.

The animgraph, sound and music kinds get their doc comments back, and Parse and the package doc list them.

The theme style boxes section of docs/en and docs/zh gameui.md that the merge dropped is restored.
With WithSeal, Load verified the seal only when the envelope had one, so deleting the seal field was all an edit needed to load, which defeated #1655's tamper evidence. A copy without a seal is now a mismatch; SealOptions.AcceptUnsealed loads saves written before sealing was turned on, which the next Save seals.

SealRefuse, SealReport and the SealOptions fields get doc comments, and docs/en and docs/zh save.md describe the seal in one section instead of splitting it across the migrations example.
#2251 wrapped only core.StorageFullError, so FileBackend's ENOSPC (ERROR_DISK_FULL on Windows) and a file-backed SettingsStore never matched ErrStorageFull, though the docs promise it across storage backends.
DiagnosticError reported ErrNotFound and ErrStorageFull as unknown, ErrMissingMigration as recoverable, and ErrTampered as corrupt. The codes are now not_found, storage_full, missing_migration (not recoverable) and tampered, and LoadDiagnostic, DirtyState and the CloseDecision constants get doc comments.
…stry sections

The merges of #2251, #2358 and #2407 each appended a section to docs/en and docs/zh save.md and only #2115's survived. The sections are back, with the diagnostic codes and the changelog fragment for this follow-up.
@github-actions github-actions Bot added size/L documentation Improvements or additions to documentation pkg/save pkg/resource area/agents bug Something isn't working labels Nov 29, 2026
@houko

houko commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Focused source checks are clean on current head 91eb14d against origin/main 072b8df: go tool nsgo check and go tool nsgo test -count=1 pass for both pkg/resource (39 tests) and pkg/save (79 tests). The only completed failures are the five known pinned-template jobs (idle, rhythm, rpg2d, towerdefense2d, visualnovel), with no source-local failure identified.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agents bug Something isn't working documentation Improvements or additions to documentation pkg/resource pkg/save size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant