Repository navigation
feat: Phase 3 — code-generation engine + AUX_VARS_R_VEC pre-work - #5
Merged
Merged
Conversation
Pre-work (before generateCode):
- docs/SAE-CATALOGUE.md §1: add {{AUX_VARS_R_VEC}} token (quoted R
character-vector form, for column-selection contexts)
- src/catalogue/bhf-eblup.ts, reblup.ts, hb-unit.ts: rename non-standard
{{AUX_VARS_R_QUOTED}} to {{AUX_VARS_R_VEC}} in all c(...) index positions
Code-generation engine (src/engine/codegen.ts):
- UserInputs and GeneratedCode interfaces per PHASES.md §3a
- buildTokenMap(): maps all {{TOKEN}} names to user-supplied values;
defaults survey.csv / census.csv / 200 sims / bootstrap MSE
- substituteTokens(): global regex replace, no unreplaced tokens escape
- Stata v14 fallback: stataVersion < stataMinVersion and fallback non-null
→ use stataV14Fallback template, set usedFallback:true + fallbackNote
- R and Stata footers appended: MSE/RMSE interpretation + next-steps note
Snapshot tests (src/engine/codegen.test.ts, 50 assertions):
- fh-eblup: library(sae), fhsae command, all vars, no {{ tokens
- bhf-eblup: library(sae), mixed command, all vars, AUX_VARS_R_VEC quoted form
- ebp-censuseb (stataVersion:14): usedFallback true, Stata uses mixed
- glmm-binary: library(lme4), meglm command, bernoulli logit family
- Fallback boundary: v16<17 triggers fallback; v17>=17 uses full template
- Token edge cases: single var, three vars, custom N_SIM, purity check
All 430 tests pass (380 pre-existing + 50 new).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Pre-work (before generateCode):
Code-generation engine (src/engine/codegen.ts):
Snapshot tests (src/engine/codegen.test.ts, 50 assertions):
All 430 tests pass (380 pre-existing + 50 new).