feat: combat flavor pools behind flavorVersion with fv URL param (#89)#153
Merged
Conversation
Relocate the four inline combat prose pools (scenario hooks, tactics-by-type, treasure-by-tier, name prefixes) verbatim from encounter-generator.ts into src/lib/flavor-pools.ts, exported through getFlavorPools(version) with FlavorVersion = 1 | 2. Version 2 currently resolves to the same frozen v1 content through the single POOLS_BY_VERSION indirection point; issue #93 repoints it at generated src/data/encounter-flavor.ts. GenerateOptions gains flavorVersion (default 1) and every prose helper draws from the resolved pools, so same seed + same flavorVersion stays byte-identical and existing callers are untouched by construction. Also swap schemas.test.ts's tactics/treasure cross-checks from scraping encounter-generator.ts source text to importing the real exported v1 pools: the scrape existed only because Task B's scope fence forbade touching src/, the extraction mandated by issue #89 invalidates that workaround, and importing the actual pool objects is a strictly stronger cross-check. Assertions are unchanged in meaning (schema enum keys must exactly match the engine pool keys).
New generations call the generator with flavorVersion: 2 and write fv=2 into the share URL alongside the seed. Hydration maps fv=2 to version 2 and anything else (including its absence) to version 1 via the pure parseFlavorVersionParam helper, so pre-versioning share links keep replaying their original v1 prose byte-for-byte.
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.
Summary
Third slice of Phase 1 (milestone: LLM Generators — Phase 1). Implements spec §5's flavor-pool versioning mechanism for the combat generator:
src/lib/flavor-pools.ts— the four inline pools (20 scenario hooks, 14×3 tactics, 4×4 treasure, 10 name prefixes) extracted verbatim (review verified byte-identity programmatically against the pre-extraction source: 88/88 strings identical, key order preserved) behindgetFlavorPools(version)with a singlePOOLS_BY_VERSIONindirection point that issue First generation run, review PR, and v2 golden pins #93 will repoint at generated data. v2 currently resolves to frozen v1 content.flavorVersion?: 1 | 2threaded throughGenerateOptions— library default 1, so every existing caller and all seed-contract tests are untouched by construction. No RNG draw-order changes;random.tsuntouched.fvURL param on /encounters: new generations use flavorVersion 2 and writefv=2; hydration maps anything else to v1, so pre-existing share links reproduce exactly what they did..gitignore: local SRD reference extracts (build-time input,scripts/vendor/precedent).Notes for review
scripts/flavor/schemas.test.tsswapped its source-text scrape of the (now relocated) pool consts for real imports ofgetFlavorPools(1)— assertions equivalent-or-stronger. The scrape only existed because the earlier issue's scope fence forbade touchingsrc/.fv=2(recipes don't draw flavor pools) — deliberate config uniformity, noted for First generation run, review PR, and v2 golden pins #93.Test plan
npm run typecheckclean ·npx vitest run42 files, 652/652 ·npm run lint0 errors ·npm run flavor:checkexit 0 ·npm run buildstatic export succeedsparseFlavorVersionParammappingCloses #89