Fix swapped hidden-stem Ten Gods for branch 巳 (Si) - #2
Open
kye0602 wants to merge 1 commit into
Open
Conversation
BRANCH_HIDDEN_STEMS listed 巳 as 丙·戊·庚, but buildPillar() in core/pillars.ts aligns the hidden-stem array with lunar-javascript's getXxxShiShenZhi() by positional index, and lunar-javascript uses the classical order 丙·庚·戊. 巳 was the only branch whose order diverged, so the Ten Gods of its 戊 and 庚 hidden stems came out swapped for any chart containing 巳. element/polarity stayed correct because they are derived per-stem (STEM_TO_ELEMENT[stem]). Reorder 巳 to the classical 本·中·余 order 丙·庚·戊 to realign with lunar-javascript, and add a regression test asserting every hidden-stem tenGod equals calculateTenGod(dayMaster, stem) across all pillars. Fixes openfate-ai#1 Co-Authored-By: Claude Opus 4.8 <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.
Fixes #1.
BRANCH_HIDDEN_STEMSlisted 巳 as丙·戊·庚, butbuildPillar()aligns the hidden-stem array with lunar-javascript'sgetXxxShiShenZhi()by positional index, and lunar-javascript uses the classical order丙·庚·戊. 巳 was the only branch whose order diverged, so the Ten Gods of its戊and庚hidden stems came out swapped for every chart containing 巳.element/polaritystayed correct because they are derived per-stem (STEM_TO_ELEMENT[stem]) — that's the tell-tale.Change
src/constants.ts— reorder 巳 to the classical 本·中·余 order丙·庚·戊, realigning with lunar-javascript.tests/hidden-stems.test.ts— regression test asserting (a) 巳's order is丙·庚·戊, and (b) every hidden-stemtenGodequalscalculateTenGod(dayMaster, stem)across all pillars. This fails on the old ordering and passes now.Verification
npm test→ 121 pass / 0 fail.Note
This realigns the two orderings. A more defensive alternative (described in #1) is to stop relying on positional alignment with lunar-javascript and derive each hidden-stem Ten God directly from the engine's own
calculateTenGod(dayMaster, hiddenStem.stem), which removes the dual-source-of-truth coupling entirely. Happy to switch to that approach if preferred.