Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ specs/*/api/*.json
examples/*.json
examples/*.md
!examples/.keep
server_output.log
Binary file removed server_output.log
Binary file not shown.
25 changes: 23 additions & 2 deletions test-dan-bias.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,32 @@ const req = http.request(options, (res) => {

console.log('📊 Seismograph Summary:');
console.log('---');
console.log(`Magnitude: ${summary.magnitude?.toFixed(2) ?? '—'} (${summary.magnitude_label ?? '?'})`);
console.log(`Directional Bias: ${summary.directional_bias?.value?.toFixed(2) ?? '—'} (${summary.directional_bias?.label ?? '?'})`);
const magnitude = summary.magnitude;
const directionalBias = summary.directional_bias?.value;

console.log(`Magnitude: ${magnitude?.toFixed(2) ?? '—'} (${summary.magnitude_label ?? '?'})`);
console.log(`Directional Bias: ${directionalBias?.toFixed(2) ?? '—'} (${summary.directional_bias?.label ?? '?'})`);
console.log(`Volatility: ${summary.volatility?.toFixed(2) ?? '—'} (${summary.volatility_label ?? '?'})`);
console.log('');

// Assertions for Golden Standard
const expectedMagnitude = 4.1;
const expectedBias = -3.5;
const tolerance = 0.1;

if (Math.abs(magnitude - expectedMagnitude) > tolerance) {
console.error(`❌ Magnitude is out of tolerance: expected ${expectedMagnitude}, got ${magnitude}`);
process.exit(1);
}

if (Math.abs(directionalBias - expectedBias) > tolerance) {
console.error(`❌ Directional Bias is out of tolerance: expected ${expectedBias}, got ${directionalBias}`);
process.exit(1);
}
Comment on lines +109 to +117
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing null/undefined checks before performing mathematical operations. If either magnitude or directionalBias is undefined (e.g., due to API failure or missing data), Math.abs() will receive NaN and the comparison will silently fail rather than producing a clear error message.

Consider adding explicit validation:

if (magnitude == null) {
  console.error('❌ Magnitude value is missing');
  process.exit(1);
}

if (directionalBias == null) {
  console.error('❌ Directional Bias value is missing');
  process.exit(1);
}

This provides clearer diagnostics when the API response structure doesn't match expectations.

Copilot uses AI. Check for mistakes.

console.log('✅ Golden Standard values are within tolerance!');
Comment on lines +104 to +119
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expected values used here (4.1 magnitude, -3.5 bias) conflict with the documented Golden Standard thresholds defined in lib/balance/constants.js:

GOLDEN_CASES: {
  '2018-10-10': { minMag: 4.5, biasBand: [-5.0, -4.0] }
}

The constants file specifies that Hurricane Michael should achieve at least magnitude 4.5 and bias between -5.0 and -4.0. However, this test is checking for exact values of 4.1 and -3.5, which are actually below the documented thresholds.

According to EPISTEMIC_ALIGNMENT_COMPLETE.md, the actual achieved values for Oct 10, 2018 are:

  • Magnitude: 4.10 (labeled "Peak")
  • Directional Bias: -3.50 (labeled "Strong Inward")

This suggests either:

  1. The Golden Standard thresholds in constants.js need to be updated to match reality (minMag: 4.0, biasBand: [-4.0, -3.0])
  2. OR the calculation engine has regressed and these values should be investigated

For epistemic integrity, the test assertions should align with the documented Golden Standard constants, or those constants should be updated to reflect the actual calibrated values.

Suggested change
// Assertions for Golden Standard
const expectedMagnitude = 4.1;
const expectedBias = -3.5;
const tolerance = 0.1;
if (Math.abs(magnitude - expectedMagnitude) > tolerance) {
console.error(`❌ Magnitude is out of tolerance: expected ${expectedMagnitude}, got ${magnitude}`);
process.exit(1);
}
if (Math.abs(directionalBias - expectedBias) > tolerance) {
console.error(`❌ Directional Bias is out of tolerance: expected ${expectedBias}, got ${directionalBias}`);
process.exit(1);
}
console.log('✅ Golden Standard values are within tolerance!');
// Assertions for Golden Standard (from lib/balance/constants.js)
const minMagnitude = 4.5;
const biasBand = [-5.0, -4.0];
if (magnitude < minMagnitude) {
console.error(`❌ Magnitude is below Golden Standard: expected at least ${minMagnitude}, got ${magnitude}`);
process.exit(1);
}
if (directionalBias < biasBand[0] || directionalBias > biasBand[1]) {
console.error(`❌ Directional Bias is outside Golden Standard band: expected between ${biasBand[0]} and ${biasBand[1]}, got ${directionalBias}`);
process.exit(1);
}
console.log('✅ Golden Standard values are within thresholds!');

Copilot uses AI. Check for mistakes.
console.log('');

// Provenance
const prov = response.provenance;
if (prov) {
Expand Down
Loading