Skip to content

Commit 1f45761

Browse files
authored
docs(mc-config): rule the three config fork families — clamps, sync payload, singleton ownership (#61)
Settles the three config families that forked across the suite with no ruling to point at, corrects the ModMenu lang-key erratum, and codifies three conventions that were already near-universal but written down nowhere. Unblocks the eight member sweeps. Clamps: the entry point is `clamp()`, running after every path that populates the object — file load, ModMenu save, and sync payload decode. The helper set must log each correction, cover both integral and floating-point fields, and reject non-finite input; the naming family stays free and supersets are welcome, so the ruling does not churn hundreds of assignment sites across eight members. The substantive part is the non-finite requirement: `Math.clamp`, `Mth.clamp`, and a bare `value < min` test all pass `NaN` through, and Gson yields non-finite doubles from `NaN`/`Infinity` tokens and from legal-JSON overflows like `1e400`. Open-topped helpers need an explicit `isFinite` gate, since `+Infinity` satisfies every lower bound and then throws out of `toJson` on the next save. Singleton: rules the guarantees rather than the holder class, which is free — a volatile field, a lazy double-checked `get()`, a whole-reference swap on reload, one snapshot per method, and no in-place mutation of the live instance. Six of eight members already conform; the two that do not need one method each rather than a rename across 452 call sites. Sync payload: `ConfigSyncPayload`, id `<mod>:config_sync`, package `network/`, binding for new payloads. A shipped divergent id keeps it until a version bump, because renaming one is a wire break — a mismatched id falls through to vanilla's unknown-payload codec, which discards the bytes with no exception and no log, leaving the client quietly running its own local rules. Direction suffixes stay a per-mod decision; measured across the suite they are 33 of 53 payload classes in a clean split, and each member is internally consistent. Erratum: the ModMenu example used a reversed `<mod>.config.<field>` key order that no member uses. The prefix is `config.<mod>.*`, which `design/DESIGN-SYSTEM.md` already assigns, so this aligns the hub rather than setting new policy. The key table also gains the sectioned and enum-option shapes, the latter mandated by `HUD-STANDARD.md` section 4. Also codified: config-first `onInitialize` ordering, the `<Mod>Networking` registrar, and the `ClientPlayConnectionEvents.DISCONNECT` teardown seam — the last distinguished from its server-side namesake and from `SERVER_STOPPING`, which fires on leaving a singleplayer world and so looks correct locally while leaking against a dedicated server. Several of the originating survey's claims did not survive reconnaissance against the member repos, and the rulings follow the code instead. There is no typed-vs-GSON wire fork: all seven members put a GSON string on the wire. The client-only-field projection is inverted from the survey — meridian, prosperity, and distillation exclude their client blocks; cultivation, tribulation, mercantile, and respite ship HUD keys over the wire. The singleton split is not 4/4: all eight use `private static volatile`, and two of the four called non-conforming already implement textbook double-checked locking. No version handshake exists anywhere, so payload-id renames are non-fatal rather than safe. The registrar convention is 5/8, not 7/8, and mercantile's `SERVER_STOPPING` calls are additive server-side cleanup rather than a substitute for its client disconnect seam. Technical claims were verified against real sources rather than asserted: Gson 2.10.1 behavior for non-finite values on both the read and write paths, the clamp logic exercised across NaN and both infinities, Fabric API 4.3.0's silent-discard path for unregistered payload ids, the `DecoderException` disconnect, the 1 MiB S2C and 32767 C2S payload ceilings, and the size cap set from the measured serialization of the suite's largest config at 17,502 bytes pretty-printed and 12,253 compact. Closes #56
1 parent 51a31b5 commit 1f45761

4 files changed

Lines changed: 341 additions & 49 deletions

File tree

‎.ai/prompts/spec-writer.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ considered, name the chosen one and one sentence on why.>
7070
For each triggered `mc-*` skill, name it and the specific constraint it places
7171
on THIS change — not "consult it", but what it forces you to do:
7272
- `mc-networking` — <e.g. payload is a record implementing CustomPacketPayload
73-
with a StreamCodec; register both ends in <mod>Networking.>
73+
with a StreamCodec; register both ends in <Mod>Networking.>
7474
- `mc-registration` — <e.g. new items go through the central registry class,
7575
not an ad-hoc Registry.register call.>
7676
- <… or "No mc-* skill is triggered by this change." if none apply.>

0 commit comments

Comments
 (0)