from pathlib import Path
import sys
from fractions import Fraction as F
sys.path.insert(0,str(Path(__file__).resolve().parents[1]))
from runner import *

run('Recover the exile pair','What are the two radii from the shared 5436 BC node to 606 and 536 BC?',
 lambda:model('exile_key',{'held_node':5436,'endpoints':[606,536],'radii':[5436-606,5436-536],'units70':[F(5436-606,70),F(5436-536,70)],'endpoint_gap':606-536}),
 'The 4830/4900 pair is 69×70 / 70×70, with the stated 70-year separation.',
 'Apply the Prophetic Key with the Shem/SP node held.', ['Comparative_Study.md §5 table','user note'])

run('Apply the local Prophetic Key','Does the established 70/69 Key move 606 to 536 about 5436?',
 lambda:{'image':key(606,5436,F(70,69)),'expanded_radius':F(4830*70,69),'gain':F(4830,69),'held_image':key(5436,5436,F(70,69))},
 'The anchored Key fixes 5436 and maps 606 exactly to 536; the gain is 70 years.',
 'Attach the unchanged 7700-year upper edge and distinguish local from global action.', ['File17.md Key inventory'])

run('Lift the local action to the joined path','How does the Key change the LXX-head-to-exile total when the upper edge stays fixed?',
 lambda:{'before':[13136,5436,606],'after':[13136,5436,536],'legs_before':[7700,4830],'legs_after':[7700,4900],'totals':[13136-606,13136-536]},
 'A local action on the final radius changes 12530 to 12600 while retaining the 7700 edge.',
 'Check that a whole-span expansion would be a different operation.')

run('Check the whole-span alternative','Would expanding all 12530 years by 70/69 reproduce the same total?',
 lambda:{'whole_expansion':F(12530*70,69),'excess_over12600':F(12530*70,69)-12600,'extra_gain_on7700':F(7700,69)},
 'Whole-span expansion exceeds 12600 by 7700/69; the successful relation is explicitly a local Key action.',
 'Read the source’s two 1260 decompositions before their tenfold placement.', ['Strategy.md §5C'])

run('Bind the 1260 decompositions','How does File17 classify 770+490 and 777+483?',
 lambda:{'source':'File17 §§8.1,12.1','status':'inferred component structures','equations':[[770,490,770+490],[777,483,777+483]],'Lamech_role':'777 is MT Lamech lifespan in the scalar bridge'},
 'Both decompositions are inherited source relations; this study tests their placement in the inverse/Babylonian path.',
 'Scale the duration components, retaining a duration rather than a calendar-date operation.', ['File17.md §§8.1,12.1'])

run('Place the first tenfold partition','Does the named Shem node realize ten times 770+490?',
 lambda:{'nodes':[13136,5436,536],'normalized_legs':[F(13136-5436,10),F(5436-536,10)],'normalized_total':F(13136-536,10)},
 'The source-named 5436 node realizes 10×(770+490)=12600 exactly.',
 'Solve for the alternative cut while holding both outer endpoints fixed.')

run('Locate the alternative cut','Where must the 7770+4830 division fall inside the same 12600 interval?',
 lambda:model('fixed_total_cuts',{'outer':[13136,536],'named_cut':5436,'alternative_cut':13136-7770,'alternative_check':536+4830,'cut_displacement':5436-(13136-7770),'leg_pairs':[[7700,4900],[7770,4830]],'alternative_role':'generated partition coordinate; no event identification claimed'}),
 'The other cut is 5366 BC, 70 years later than 5436; both partitions retain the same outer endpoints.',
 'Relate that 70-year cut movement to the supplied exile interval without naming a new event.')

run('Identify the common 70-year transfer','What elementary repartition converts the two tenfold decompositions?',
 lambda:{'first':[7700,4900],'delta':[70,-70],'second':[7700+70,4900-70],'total_change':70-70,'refined_chain':[13136,5436,5366,536],'refined_legs':[7700,70,4830]},
 'Moving 70 years across the internal cut converts 7700+4900 to 7770+4830. It is a conserved-total repartition.',
 'Check how the two 4830 intervals are related.')

run('Transport the 4830 radius','Is 5366→536 related exactly to the original 5436→606 exile radius?',
 lambda:{'original':[5436,606],'translated':[5436-70,606-70],'target':[5366,536],'lengths':[5436-606,5366-536]},
 'Translating both endpoints by −70 carries the original 4830 radius onto the alternative partition’s final leg.',
 'Classify the local Key and the conserved-total transfer as two operations on shared inputs.')

run('Separate the two mechanisms','What changes under the Key, and what changes under the repartition?',
 lambda:model('two_70_operations',{'local_key':{'held':5436,'moving_endpoint':[606,536],'radius':[4830,4900],'whole_total':[12530,12600]},'repartition':{'held_outer':[13136,536],'moving_cut':[5436,5366],'legs':[[7700,4900],[7770,4830]],'whole_total':[12600,12600]},'dependency':'same inherited 70 and 4830/4900 carrier; not independent confirmations'}),
 'The Key grows one radius; the repartition preserves the total and moves its cut. Together they connect the inverse path with the inherited prophetic carrier.',
 'Next test the SP junction against the full LXX Shem edge rather than only one endpoint.')
