Skip to content

Fix swapped hidden-stem Ten Gods for branch 巳 (Si) - #2

Open
kye0602 wants to merge 1 commit into
openfate-ai:mainfrom
kye0602:fix/si-hidden-stem-tengod-order
Open

Fix swapped hidden-stem Ten Gods for branch 巳 (Si)#2
kye0602 wants to merge 1 commit into
openfate-ai:mainfrom
kye0602:fix/si-hidden-stem-tengod-order

Conversation

@kye0602

@kye0602 kye0602 commented Jun 23, 2026

Copy link
Copy Markdown

Fixes #1.

BRANCH_HIDDEN_STEMS listed 巳 as 丙·戊·庚, but buildPillar() 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 every chart containing 巳. element/polarity stayed 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-stem tenGod equals calculateTenGod(dayMaster, stem) across all pillars. This fails on the old ordering and passes now.

Verification

npm test121 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.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

地支「巳」藏干十神错位:戊 与 庚 的十神被对调(与 lunar-javascript 顺序不一致)

1 participant