refactor(reworks): deterministic ReworkCenter? do not merge#454
Draft
stephenkirk wants to merge 4 commits into
Draft
refactor(reworks): deterministic ReworkCenter? do not merge#454stephenkirk wants to merge 4 commits into
stephenkirk wants to merge 4 commits into
Conversation
… + ledger + pure projection) Replace the in-place center-mutation model (mp_<layer>_<prop> smearing, the "NULL" sentinel, prefix-scan restore, incremental rarity re-sort) with a three-tier engine: a frozen deep-copied vanilla baseline, a normalized override ledger, and G.P_* recomputed as a pure projection of (table_id, key, active-layer-chain). - ApplyReworks is the sole writer of G.P_*, run at run start (symmetric on both clients); idempotent under repeated/varied call history - PreviewReworks computes into an isolated _PREVIEW_VIEW; menu + replay sites no longer mutate live center state (kills the asymmetric-preview desync), guarded by a _PREVIEW_ACTIVE phase check - rebuild_rarity_pools rebuilds buckets wholesale with a stable (.order, key) sort so two clients land byte-identical regardless of call history - LoadReworks kept as a thin shim -> ApplyReworks (~70 release.lua sites unchanged) - migrate m_glass (numbers unchanged); add j_sixth_sense rarity rework under a now-defined release layer to exercise the rarity path - add tests/test_rework_determinism.lua (30 checks: purity, preview isolation, rarity determinism, frozen-baseline immutability, SP modifier-drop) Produced via a competitive multi-agent workflow. Verified: 9/9 luac, 30/30 determinism test, ruleset shape snapshot unchanged (10 pass / 4 known-stale fail). Known caveats (pre-merge review): rarity-bucket membership assumes integer rarities; preview_center proxy is __index-only; no live two-client engine proof yet. Full migration of release.lua's ~58 joker reworks is follow-up.
…omments; recursive shape harness
- idol_rare: replace the j_mp_idol_rare reimpl with MP.ReworkCenter("j_idol",
experimental: rarity 3 / cost 8); drop j_idol from banned_silent, list it in
reworked_jokers for the info panel (vanilla keys skip the auto-mp_include graft,
so it isn't pool-gated), remove the dead j_mp_idol_rare loc (en-us, ru)
- fix preview_center crash: Card:set_ability finds center_key by identity scan of
G.P_CENTERS, which the preview proxy fails; set it from the key at the call site
- trim the LLM-verbose comments across the rework engine and definition files
(cut old-model history + repeated determinism restatements; keep contracts)
- tests: lua_files_in now recurses (find) so rulesets/experimental/*.lua load;
regenerate ruleset shape snapshot (15 rulesets, incl. WIP release ruleset)
Game:start_run applies reworks but nothing reverted them on the way out, so leaving a run left G.P_CENTERS holding the last run's reworked numbers — the vanilla collection screen would show them until the next run started. Wrap Game:main_menu (covers pause-quit / game-over / disconnect) to call ApplyReworks(nil): empty layer chain rebuilds every owned prop and the rarity pools from the frozen baseline. Idempotent, local cosmetic fix, not a desync.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A probably-overcomplex prototype of ReworkCenter that, in theory, doesn't desync: trades the old in-place center mutation for a frozen baseline + ledger + pure projection, so reworks stop depending on what order you clicked through the menu. Verified entirely against stubbed game globals, so trust it about as far as you'd trust any three-tier engine.
Allan please add details