Files
amethyst/tools/r8-verify
Claude 2d1e398910 refactor: move the on-disk stores to kotlinx, closing the last reflective binding
The scheduled-post, PoW-queue and resource-usage files were the last three places
Jackson derived JSON keys from Kotlin constructor parameter names. They are
@Serializable now, so kotlinx bakes every key in as a string literal and the five
keep rules that protected them are gone.

    reflection contract   24 checks -> 19
    ScheduledPost -> z3h, PersistedPoWJob -> i2e, PowJobsFile -> ake

These files are user data — queued posts that are pre-signed and waiting, posts
already sent that are still mining — so a format shift would not crash, it would
silently empty the queue on the first launch after an update. Both new test
classes pin the format against the exact bytes the Jackson build wrote, captured
from it before the switch: they assert kotlinx decodes that string AND re-encodes
it byte for byte, which is what a downgrade, or an older `amy` sharing the same
file, depends on. `encodeDefaults = true` is load-bearing — without it kotlinx
drops `"version":1` from every file it rewrites, and there is a test for that too.

Also closed the door behind this. JacksonMapper.fromJsonTo is generic, so nothing
stopped a new OptimizedSerializable being passed to it and bound reflectively —
fine in debug, obfuscated one-letter JSON keys on the wire in release. That is
exactly how NIP-47 and CLINK got there. It now fails loudly on the first call for
a type with no registered deserializer, naming the two ways out.

One entry deliberately kept: ScheduledPostStatus' constants. The enum is still
the on-disk format, and a plain @Serializable enum is not obviously immune —
kotlinx builds its descriptor from the entries and I have not proven those names
are literals rather than Enum.name read at runtime. The blanket enum rule already
covers it, so keeping the check costs nothing, and "every queued post's status
unreadable" is not a good thing to guess at. The contract says so in place.

Verified: full ./gradlew test green, R8 release build green, 19/19 contract
checks, the three DTOs confirmed renamed and the enum constants confirmed still
present in the shipped DEX.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DEoxktEZyTrAS33vVZBiwm
2026-09-19 12:58:18 +00:00
..