Skip to content

Play result validator improvements - #88

Merged
283375 merged 20 commits into
masterfrom
refactor/warnings-20261106
Nov 11, 2026
Merged

283375 merged 20 commits into
masterfrom
refactor/warnings-20261106

Conversation

@283375

@283375 283375 commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator
  • Rework play result warnings into enum-driven model
  • Fix warning correctness
  • Add validator unit tests
  • Add a hint and a detailed message per warning
  • Add docs/play-result-mechanisms.md for future reference
  • Moved to :shared (Prepare multiplatform support #24):
    • ArcaeaFormatters
    • Warning UI components and their string resources
    • Basic text/UI helpers and DISABLED_ALPHA

@283375

283375 commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator Author

/opencode Review this PR. Avoid external directory access (/home, /tmp, etc.) as it will block unattended session with permission requests.

@283375
283375 marked this pull request as ready for review November 10, 2026 19:21
@opencode-agent

Copy link
Copy Markdown

Review: Play result validator improvements

Overall this is a solid refactor. Moving the validator into :shared, replacing the ad-hoc warning classes with a PlayResultWarning enum + PlayResultWarningDetail, and centralizing the null-handling policy is a clear improvement, and the new PlayResultValidatorTest (974 lines) covers the tricky cases well. I found no blocking defects.

Findings

1. Historical Room schemas/migrations were edited (shared/schemas/.../{7..13}.json, Migration_6_7.kt:19, Migration_7_8.kt:84)
The 100000000.0 → 10000000.0 and score >= 100000000 → score >= 10000000 changes are a real bug fix (the old factor was 10× too large; the Kotlin PlayResultCalculated had the same bug and is fixed too). But editing already-shipped migration sources/schema snapshots is non-standard. It doesn't repair DBs that already ran those migrations, and schemas 4–6 still carry the old buggy SQL, so the historical record is now inconsistent. Confirm this is only for migration-test consistency, since views are dropped at v14/15 anyway.

2. Integer overflow on corrupt inputs

  • PlayResultWarning.kt:17: 10_000_000 + notes overflows for notes > Int.MAX_VALUE - 10_000_000, making SCORE_IMPOSSIBLE's maximum negative and SCORE_OUT_OF_RANGE's guard always return early.
  • Common.kt:20-21: base.toInt() wraps for very large pure/far (e.g. notes = 1, pure = 2_000_000_000).

The validator is specifically for corrupted data, so using Long/clamping here would be more robust. Low severity (real charts are small).

3. Behavior change: score 0 with positive judgments and no chart info is no longer flagged (PlayResultWarning.kt:49-62)
EMPTY_PLAY_RESULT only fires when score and all counts are zero/null. The old SCORE_IS_ZERO warned on any score == 0. With a missing ChartInfo, a record like score=0, pure=5, far=0, lost=0 now produces no warning (SCORE_OUT_OF_RANGE needs notes). If this is intentional, ignore; otherwise a cheap score == 0 && (pure > 0 || far > 0) check would preserve the old coverage.

4. Nit: missing final newline in app/src/main/res/values/strings.xml and app/src/main/res/values-zh-rCN/strings.xml, while .editorconfig sets insert_final_newline = true.

5. Nit: ArcaeaPlayResultClearType.toDisplayString() (ArcaeaPlayResultClearType.kt:16) now hardcodes English Title-Case labels in core/constants. It's still unlocalized (it was uppercase English before), so not a regression, but presentation strings in core are a layering smell and the app is bilingual. Consider resolving these via Compose resources where displayed.

6. Scope note: 2,083 additions mix validator refactor, score/precision fixes, DB migration/schema edits, resource moves, and label unification. The individual commits look coherent, but splitting the score/migration bug fixes from the validator refactor would make this easier to review and revert.

Verified

  • All old ArcaeaPlayResultValidator* / helpers.ArcaeaFormatters / helpers.*ItemAlpha references were updated; no stale imports.
  • Warning/action/message resource keys are complete and consistent between values and values-zh-rCN; no leftover app play_result_validator_* keys.
  • New score formula matches the intended floor((pure·10M + far·5M)/notes) and the added sweep over note counts 1..3000 is a good regression guard.
  • Null-value policies in the enum KDoc match the implementations, and CLEAR_TYPE_MISSING remains B50-only as before.

github run

@283375
283375 merged commit 697c25d into master Nov 11, 2026
4 checks passed
@283375
283375 deleted the refactor/warnings-20261106 branch November 11, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant