Skip to content

Fix Math Brain v2 pipeline crashes from undefined variables#302

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/fix-mathbrain-v2-report-generation
Draft

Fix Math Brain v2 pipeline crashes from undefined variables#302
Copilot wants to merge 5 commits intomainfrom
copilot/fix-mathbrain-v2-report-generation

Conversation

Copy link
Contributor

Copilot AI commented Nov 13, 2025

Math Brain v2 pipeline failed on all report generation attempts due to two undefined variable references in src/math_brain/main.js.

Root Causes

Line 199: Referenced non-existent mirrorData variable

// Before: ReferenceError
mirror_data: mirrorData || {},

// After: Removed (already in daily entries)
relational_summary: relationalSummary || null,

Lines 183-206: Transit reports lacked run_metadata object, causing crashes when relationship context was set

// Before: spreading undefined, missing run_metadata
finalOutput = {
  ...finalOutput,  // undefined
  provenance: {...},
};
// Later: finalOutput.run_metadata.relationship_context = ... // TypeError

// After: create once, use for both fields
const metadata = {...createProvenanceBlock(config), ...};
finalOutput = {
  run_metadata: metadata,
  provenance: metadata,  // backward compat
};

Changes

  • src/math_brain/main.js: Removed undefined mirrorData reference; ensured run_metadata exists for transit reports
  • test/mathbrain-v2-regression.test.js: Added 3 regression tests (transit/foundation/synastry)
  • docs/bug-fixes/mathbrain-v2-report-generation-fix-2025-11-13.md: Detailed analysis and verification steps
  • .gitignore: Excluded log files
  • CHANGELOG.md: Documented fix

Impact

All report types (solo, synastry, transit, foundation) now generate successfully. No breaking changes—both run_metadata and provenance fields maintained for backward compatibility.

Original prompt

Still cannot get a report to generate at all. Says mathbrain v2 failure.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@netlify
Copy link

netlify bot commented Nov 13, 2025

Deploy Preview for sprightly-genie-998c07 ready!

Name Link
🔨 Latest commit 22581cd
🔍 Latest deploy log https://app.netlify.com/projects/sprightly-genie-998c07/deploys/69164365ecb7800008819b2a
😎 Deploy Preview https://deploy-preview-302--sprightly-genie-998c07.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 30 (🔴 down 25 from production)
Accessibility: 97 (no change from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@DHCross
Copy link
Owner

DHCross commented Nov 13, 2025

@copilot I saw this message on the site itself "Deployment: Metadata unavailable — configure build metadata to populate this section"

Co-authored-by: DHCross <45954119+DHCross@users.noreply.github.com>
@DHCross
Copy link
Owner

DHCross commented Nov 13, 2025

@copilot I see you are using dev ports to test. Probably the only way you can. Make sure it's all the same code being used, not some hybrid beast

Copilot AI and others added 3 commits November 13, 2025 20:39
Co-authored-by: DHCross <45954119+DHCross@users.noreply.github.com>
…docs

Co-authored-by: DHCross <45954119+DHCross@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix mathbrain v2 report generation failure Fix Math Brain v2 pipeline crashes from undefined variables Nov 13, 2025
Copilot AI requested a review from DHCross November 13, 2025 20:45
Copy link
Contributor Author

Copilot AI commented Nov 13, 2025

@copilot I saw this message on the site itself "Deployment: Metadata unavailable — configure build metadata to populate this section"

The "Deployment: Metadata unavailable" message is unrelated to this fix. It's a Netlify configuration issue that would require setting up build metadata environment variables (like COMMIT_REF, BUILD_ID) in the Netlify dashboard or build settings. The Math Brain v2 fix itself doesn't affect deployment metadata.

@copilot I see you are using dev ports to test. Probably the only way you can. Make sure it's all the same code being used, not some hybrid beast

The regression tests in test/mathbrain-v2-regression.test.js actually call runMathBrain() directly (unit tests), not via HTTP/dev ports. They test the exact production code that runs when reports are generated. The manual API test I ran during development used localhost:3000 just to verify end-to-end, but the committed test suite ensures no hybrid issues since it imports and tests the actual source code directly.

@DHCross
Copy link
Owner

DHCross commented Jan 28, 2026

Closing as stale (2+ months) - Math Brain v2 pipeline has been stabilized. If crashes persist, please reopen against current main.

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.

2 participants