Skip to content
Merged
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
18 changes: 18 additions & 0 deletions .github/workflows/evalmath-mechinterp-preflight.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: EvalMath mechanistic-resolution preflight safety
on:
pull_request:
paths:
- 'skills/evalmath-mechinterp-power/**'
- '.github/workflows/evalmath-mechinterp-preflight.yml'
workflow_dispatch:
jobs:
independent-root-preflight:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Pure-standard-library mechanistic resolution tests
run: python -m unittest discover -s skills/evalmath-mechinterp-power/scripts -p 'test_*.py' -v
Comment on lines +10 to +18
2 changes: 2 additions & 0 deletions skills/evalmath-mechinterp-power/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Start from the declared *scientific effect*. Ask what physical change in a model

- Fewer than the planned independent roots, even if 64 or 8,192 scored outputs are available. One task transformed 64 ways is one task family for generalization.
- The minimum meaningful effect lies inside the matched-sham variation interval, or below measurement resolution. Increase the causal contrast or improve the instrument before expanding the same evaluation.
- The independent-development root-mean causal effect does not exceed the calibrated mechanistic variation floor. A larger *hypothetical target* cannot substitute for the observed pilot signal. In particular, all-zero paired root effects have sample variance zero, which makes a naive normal-power calculation wrongly forecast very few confirmation roots. See BPD-AMM-03's 64-root negative example and require redesign while preserving its untouched confirmation partition.
- A normal-approximation power estimate suggests fewer independent roots than are needed for even an all-positive exact sign test under the registered Bonferroni comparison family. The planner enforces this discrete minimum before returning READY.
- No sealed held-out readout, especially after iterative intervention or architecture selection. Allocate new root families rather than rerunning on the same 64 cases.
- Multiple baselines/intervention directions were screened and only the winner is reported. Account for the *actual* comparison family and adaptive use. Direction-count gates, such as 4/6 seeds, are weak evidence without world-level uncertainty.
- A parity or algebraically generated task comes with an exact specialized solver. Label it a structural ceiling and test the proposed neural mechanism separately.
Expand Down
27 changes: 22 additions & 5 deletions skills/evalmath-mechinterp-power/scripts/preflight.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,30 +63,47 @@ def preflight(spec):
raise ValueError('external_sham_source required')
floor=max(floor or F(0),fraction(external,'external_sham_floor'))
variation=max(min_effect,resolution,floor or F(0))
observed_mean=sum(effects,F(0))/len(effects)
sigma=stdev(map(float,effects)) if len(effects)>=2 else None
delta=float(target-variation)
z=NormalDist().inv_cdf(1-float(alpha)/(2*m))+NormalDist().inv_cdf(.80)
required=max(2,math.ceil((z*sigma/delta)**2)) if sigma is not None and delta>0 else None
mde=float(variation)+z*sigma/math.sqrt(g) if sigma is not None else None
# Even an ideal, all-positive exact sign test cannot clear a one-sided
# Bonferroni family with fewer than this many independent model roots.
min_sign_roots=0
while m*F(1,2)**min_sign_roots>alpha:
min_sign_roots+=1
# A zero-variance null development pilot contains no information for
# extrapolating a positive, hypothetical target's normal-approximation
# variance. Do not turn that zero into a 2-root power claim.
pilot_variance_uninformative=(sigma==0 and observed_mean<=variation)
required=(max(min_sign_roots,2,math.ceil((z*sigma/delta)**2))
if sigma is not None and delta>0 and not pilot_variance_uninformative else None)
mde=(float(variation)+z*sigma/math.sqrt(g)
if sigma is not None and not pilot_variance_uninformative else None)
reasons=[]
if not spec.get('pilot_from_development_only') is True:reasons.append('development_pilot_unverified')
if not spec.get('heldout_sealed') is True:reasons.append('heldout_unsealed')
if not spec.get('units_independent') is True:reasons.append('independence_unverified')
if floor is None:reasons.append('sham_quantile_uncalibrated')
if len(effects)<8:reasons.append('too_few_pilot_worlds')
if delta<=0:reasons.append('target_below_mechanistic_variation_floor')
if observed_mean<=variation:
reasons.append('pilot_effect_not_above_mechanistic_variation_floor')
if pilot_variance_uninformative:
reasons.append('zero_variance_pilot_power_uninformative')
if required is None or required>g:reasons.append('confirmation_underpowered')
return {'schema':'EvalMath/mechinterp-power-preflight/v1','experiment_id':spec['experiment_id'],
'decision':'REDESIGN_OR_PILOT_ONLY' if reasons else 'READY_FOR_CONFIRMATION',
'reasons':reasons,'independent_unit':spec['independent_unit'],
'pilot_worlds':len(effects),'planned_confirmation_worlds':g,
'mean_pilot_effect':float(sum(effects,F(0))/len(effects)),
'mean_pilot_effect':float(observed_mean),
'pilot_world_sigma':sigma,'observed_worst_sham':float(max(shams)),
'upper_sham_quantile':float(floor) if floor is not None else None,'order_statistic_rank':rank,
'mechanistic_variation_floor':float(variation),'target_effect':float(target),
'planned_comparisons':m,'approx_worlds_for_80pct_power':required,
'planned_comparisons':m,'minimum_exact_sign_test_roots':min_sign_roots,
'approx_worlds_for_80pct_power':required,
'approx_resolvable_effect':mde,
'limits':'Normal-based power is planning only. Root and sham independence, symmetry, readout sealing, and the scientific effect floor require independent audits. Repeated outcomes within a root are never additional worlds.'}
'limits':'Normal-based power is planning only. A zero-effect zero-variance pilot cannot support extrapolating a hypothetical positive effect. Root and sham independence, symmetry, readout sealing, and the scientific effect floor require independent audits. Repeated outcomes within a root are never additional worlds.'}


def main():
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
"""Regression tests for root-level mechanistic-resolution and zero-effect pilots."""
from __future__ import annotations
import importlib.util
from pathlib import Path
import unittest

spec=importlib.util.spec_from_file_location('evalmath_mechinterp_preflight',Path(__file__).with_name('preflight.py'))
pf=importlib.util.module_from_spec(spec)
assert spec.loader is not None
spec.loader.exec_module(pf)


def pilot(*,effects=None,shams=None,confirm=128, comparisons=3):
effects=effects if effects is not None else ['0/1']*64
shams=shams if shams is not None else ['1/128']*63 + ['24/128']
return {'schema_version':1,'experiment_id':'BPD-AMM-03',
'independent_unit':'trained physical model and factors root',
'alpha':'1/20','scientific_min_effect':'1/10',
'target_effect':'1/5','measurement_resolution':'1/128',
'sham_quantile':'19/20','sham_confidence':'19/20',
'planned_comparisons':comparisons,'confirm_units_planned':confirm,
'pilot_from_development_only':True,'heldout_sealed':True,
'units_independent':True,
'pilot':[{'unit_id':f'root-{i}','paired_effect':effect,'sham_effects':[shams[i]]}
for i,effect in enumerate(effects)]}


class RootPowerGuardTests(unittest.TestCase):
def test_amm03_all_zero_effect_is_not_confirmation_ready(self):
out=pf.preflight(pilot())
self.assertEqual(out['decision'],'REDESIGN_OR_PILOT_ONLY')
self.assertEqual(out['mean_pilot_effect'],0.)
self.assertEqual(out['mechanistic_variation_floor'],.1875)
self.assertEqual(out['minimum_exact_sign_test_roots'],6)
self.assertIsNone(out['approx_worlds_for_80pct_power'])
self.assertIn('zero_variance_pilot_power_uninformative',out['reasons'])
self.assertIn('pilot_effect_not_above_mechanistic_variation_floor',out['reasons'])

def test_positive_pilot_with_root_variation_can_pass(self):
effects=['1/4' if i%2 else '15/64' for i in range(64)]
out=pf.preflight(pilot(effects=effects,shams=['1/128']*64))
self.assertEqual(out['decision'],'READY_FOR_CONFIRMATION')
self.assertGreater(out['mean_pilot_effect'],out['mechanistic_variation_floor'])
self.assertGreaterEqual(out['approx_worlds_for_80pct_power'],6)

def test_constant_positive_pilot_still_requires_exact_sign_roots(self):
out=pf.preflight(pilot(effects=['1/4']*64,shams=['0']*64))
self.assertEqual(out['decision'],'READY_FOR_CONFIRMATION')
self.assertEqual(out['approx_worlds_for_80pct_power'],6)
self.assertEqual(out['minimum_exact_sign_test_roots'],6)
not_enough=pf.preflight(pilot(effects=['1/4']*64,shams=['0']*64,confirm=4))
self.assertIn('confirmation_underpowered',not_enough['reasons'])

def test_observed_pilot_below_floor_blocks_optimistic_target(self):
p=pilot(effects=['5/128' if i%2 else '6/128' for i in range(64)],shams=['1/128']*64)
out=pf.preflight(p)
self.assertEqual(out['decision'],'REDESIGN_OR_PILOT_ONLY')
self.assertIn('pilot_effect_not_above_mechanistic_variation_floor',out['reasons'])

def test_insufficient_sham_roots_still_block(self):
out=pf.preflight(pilot(effects=['1/4']*8,shams=['0']*8))
self.assertEqual(out['decision'],'REDESIGN_OR_PILOT_ONLY')
self.assertIn('sham_quantile_uncalibrated',out['reasons'])

def test_duplicate_independent_root_rejected(self):
p=pilot();p['pilot'][1]['unit_id']=p['pilot'][0]['unit_id']
with self.assertRaises(ValueError):pf.preflight(p)


if __name__=='__main__':unittest.main()
Loading