Skip to content

Fix Force Generator faction ruleset bugs - #348

Merged
HammerGS merged 1 commit into
mainfrom
fix-force-generator-errors
May 12, 2026
Merged

Fix Force Generator faction ruleset bugs#348
HammerGS merged 1 commit into
mainfrom
fix-force-generator-errors

Conversation

@HammerGS

@HammerGS HammerGS commented May 12, 2026

Copy link
Copy Markdown
Member

Summary

Sweep of faction ruleset XML files (data/forcegenerator/faction_rules/) for predicate/assertion errors that the Force Generator engine silently ignored or that caused infinite generation loops.

Paired with the engine-side fixes in megamek#fix-force-generator-errors.

Itemized Fixes

# File(s) Sites Bug Fix
1 CHH.xml, CLAN.GC.xml 8 ifYearBetween is not a recognized predicate; never matched, so the option always "passed" the date filter Renamed to documented ifDateBetween (ProtoMek attachments now correctly gated to year ≥ 3060)
2 CHH.xml, CLAN.GC.xml, CSL.xml 46 ifRating="strike" and ifRole="strike"strike is a flag, not a rating/role, so cavalry-cluster weighting never fired Replaced with ifFlags="strike"
3 CHH.xml, CLAN.GC.xml, CSL.xml 9 ifRole="testTrinary" — same flag-vs-role mix-up on <changeEschelon> predicates Replaced with ifFlags="testTrinary"
4 CHH.xml, CLAN.GC.xml, CSL.xml 9 ifFlags="adHoc" — case mismatch (canonical form is lowercase adhoc) Replaced with ifFlags="adhoc"
5 FS.xml 1 <role ifRole="lct"> — LCT is consistently a flag elsewhere in FS.xml Replaced with ifFlags="lct"
6 CHH.xml, CLAN.GC.xml 2 flags="mekTankStar" missing + prefix — wipes inherited flags rather than adding Replaced with flags="+mekTankStar"
7 CHH.xml, CLAN.GC.xml, CSA.xml, CSL.xml 31 role="-testTrinary" in <changeEschelon> options — tried to remove from roles when testTrinary is a flag. After fix #3 made the changeEschelon predicate match, this no-op caused the testTrinary flag to never clear, producing an infinite loop in Ruleset.buildForceTree when generating CHH/CLAN.GC/CSL AeroSpaceFighter Trinaries Replaced with flags="-testTrinary"
8 formationRulesetSchema.xsd 1 ifYearBetween declared in schema but never implemented in Java Kept declaration with comment noting it as a deprecated alias

Impact

  • CHH Touman/Cluster generation now completes (was freezing with infinite loop after fix Fix: Fixed Camo Directory for Clan Sea Fox Camo #3 alone — pre-existing data bug correct BLORD faction data #7 surfaced once predicate matching worked).
  • No more anachronistic ProtoMek attachments in pre-3060 Clan forces.
  • Strike Clusters now produce distinct compositions vs. Cavalry/Assault Clusters.
  • Tank/Aero Trinaries correctly downgrade to Binaries post-3071 or in adhoc clusters.

🤖 Generated with Claude Code

Sweep for predicate/assertion errors in faction_rules XML that the engine
treated as silent no-ops or caused infinite loops during force generation.

- CHH/CLAN.GC: replace ifYearBetween (8 sites) with documented ifDateBetween.
  The engine never honored the ifYearBetween alias, so ProtoMek attachments
  fired anachronistically (CHH/CLAN.GC clusters got ProtoMeks at year 2900).
- CHH/CLAN.GC/CSL: change ifRating="strike" and ifRole="strike" (46 sites)
  to ifFlags="strike". "strike" is a flag, not a rating/role, so the
  cavalry-cluster weighting never fired.
- CHH/CLAN.GC/CSL: change ifRole="testTrinary" (9 sites) to
  ifFlags="testTrinary". Same flag-vs-role mix-up.
- CHH/CLAN.GC/CSL: change ifFlags="adHoc" (9 sites) to "adhoc" — case
  mismatch with the canonical lowercase form set elsewhere.
- FS: change <role ifRole="lct"> to ifFlags="lct" — LCT is a flag everywhere
  else in FS.xml.
- CHH/CLAN.GC: add missing + prefix to flags="mekTankStar" (2 sites) so the
  flag is added rather than wiping the inherited flag set.
- CHH/CLAN.GC/CSA/CSL: change role="-testTrinary" (31 sites) to
  flags="-testTrinary" in <changeEschelon> options. This is the most
  important fix — without it the testTrinary flag was never cleared after
  the changeEschelon fired, causing an infinite loop in
  Ruleset.buildForceTree for CHH AeroSpaceFighter Trinaries (observed:
  7.5M iterations producing a 1 GB log file).
- formationRulesetSchema.xsd: keep the ifYearBetween attribute declaration
  but mark it as a deprecated alias kept for backwards compatibility.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@HammerGS HammerGS added AI Assisted Development This project/code contains AI use under the supervision of a human developer. With Human testing. AI Generated Fix AI-generated fix. Requires human testing and review before merging. and removed AI Assisted Development This project/code contains AI use under the supervision of a human developer. With Human testing. labels May 12, 2026
@HammerGS
HammerGS merged commit 3412bbe into main May 12, 2026
6 checks passed
@HammerGS
HammerGS deleted the fix-force-generator-errors branch May 12, 2026 17:37
HammerGS added a commit that referenced this pull request May 13, 2026
Pulled locally to support the Force Generator integration work in
mekhq feat/force-generator-company-generation. Fixes ratgen rulesets
for CHH / CLAN.GC / CSA / CSL / FS and adds a schema entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Fix AI-generated fix. Requires human testing and review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant