Skip to content

fix(brain): numeric version comparison + subprocess migrations - #1013

Merged
namastex888 merged 1 commit into
devfrom
fix/brain-update-bugs
Apr 3, 2026
Merged

namastex888 merged 1 commit into
devfrom
fix/brain-update-bugs

Conversation

@namastex888

Copy link
Copy Markdown
Contributor

Summary

Two bugs found during /review of PR #1010 (dev→main):

1. [HIGH] Module cache — migrations run stale code

await import('@automagik/genie-brain') after git pull + rebuild returns the cached pre-update module. New migrations from the pulled version are silently skipped.

Fix: Run migrations via bun -e subprocess which loads the rebuilt code from disk, bypassing the import cache.

2. [MEDIUM] Lexicographic version comparison

latestCore > localCore is string comparison. "260403.9" > "260403.10" → true (wrong, because "9" > "1").

Fix: Added compareVersions() that splits on . and compares segments numerically.

Test plan

  • 1824 tests pass (6 new for compareVersions)
  • Typecheck, lint, dead-code clean
  • Multi-digit segment test: compareVersions('260403.10', '260403.9') > 0 ✓
  • Equal versions: compareVersions('260403.1', '260403.1') === 0 ✓
  • Different segment counts: compareVersions('260403', '260403.0') === 0 ✓

Two bugs from PR review of #1010:

1. Version comparison used string comparison (`latestCore > localCore`)
   which fails on multi-digit segments: "260403.9" > "260403.10" is
   true lexicographically but wrong numerically. Added compareVersions()
   that splits on "." and compares segments as numbers.

2. Post-update migrations ran via `import()` which returns the cached
   pre-update module — new migrations from the pulled version would be
   silently skipped. Replaced with subprocess execution via `bun -e`
   which loads the rebuilt code from disk.

Tests: 6 new tests for compareVersions covering multi-digit segments,
different segment counts, and major version differences.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Apr 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 96814646-0ac1-4189-af45-05d167809809

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/brain-update-bugs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@namastex888
namastex888 merged commit 6202097 into dev Apr 3, 2026
5 of 6 checks passed
@namastex888
namastex888 deleted the fix/brain-update-bugs branch April 10, 2026 16:18
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.

1 participant