{
  "runtime": "/mnt/data/v266_clean_grip_contract_base/NEXT11_V266_CLEAN_GRIP_CONTRACT_BASE_ROOT/assets/nexprod/nexprod01-runtime-candidate.mjs",
  "sha256": "385ad055c7de0a1596816574a93b9941885ed4075b9e09e34e3970c0092bb14e",
  "lineCount": 3016,
  "constants": {
    "localGreen": "{x:0.93966,y:0.70339,z:0.42636}",
    "localPink": "{x:-0.08284,y:0.62487,z:0.34506}",
    "pinkLegTarget": "{x:-0.10186,y:0.76352,z:-0.33015}",
    "deltaV195": "{x:0.04303, y:-0.00036, z:-0.02451}"
  },
  "windows": [
    {
      "name": "V238 approved finger layer",
      "start": 2321,
      "end": 2352,
      "lines": [
        {
          "line": 2321,
          "text": "    // V238 PRODUCTION CLEAN APPROVED GRIP"
        },
        {
          "line": 2322,
          "text": "    // Consolidated single source of truth from V236/V237. This replaces the legacy curl-profile"
        },
        {
          "line": 2323,
          "text": "    // for the approved right-hand shin/leg grip route. No target chasing, no hand/wrist/leg writes."
        },
        {
          "line": 2324,
          "text": "    // To temporarily compare legacy V200, set globalThis.__NEX_V238_USE_LEGACY_V200_FINGER_CLOSE=true before load."
        },
        {
          "line": 2325,
          "text": "    if(side==='R' && globalThis.__NEX_V238_USE_LEGACY_V200_FINGER_CLOSE!==true){"
        },
        {
          "line": 2326,
          "text": "      const axes={x:new THREE.Vector3(1,0,0),y:new THREE.Vector3(0,1,0),z:new THREE.Vector3(0,0,1)};"
        },
        {
          "line": 2327,
          "text": "      const approvedTerms={"
        },
        {
          "line": 2328,
          "text": "        index:[{seg:0,axis:'z',sign:1,amount:0.36,role:'V238_INDEX_MCP_VISUAL_AUDIT_APPROVED'},{seg:1,axis:'z',sign:1,amount:0.72,role:'V234_STOP_ON_CONTACT_PIP'},{seg:2,axis:'z',sign:1,amount:0.36,role:'V234_STOP_ON_CONTACT_DIP'}],"
        },
        {
          "line": 2329,
          "text": "        middle:[{seg:0,axis:'z',sign:1,amount:0.84,role:'V234_STOP_ON_CONTACT_MCP'},{seg:1,axis:'z',sign:1,amount:0.72,role:'V234_STOP_ON_CONTACT_PIP'},{seg:2,axis:'z',sign:1,amount:0.36,role:'V234_STOP_ON_CONTACT_DIP'}],"
        },
        {
          "line": 2330,
          "text": "        ring:[{seg:0,axis:'z',sign:1,amount:0.84,role:'V234_STOP_ON_CONTACT_MCP'},{seg:1,axis:'z',sign:1,amount:0.72,role:'V234_STOP_ON_CONTACT_PIP'},{seg:2,axis:'z',sign:1,amount:0.06,role:'V234_STOP_ON_CONTACT_DIP'}],"
        },
        {
          "line": 2331,
          "text": "        pinky:[{seg:0,axis:'z',sign:1,amount:0.84,role:'V234_STOP_ON_CONTACT_MCP'},{seg:1,axis:'z',sign:1,amount:0.68,role:'V234_STOP_ON_CONTACT_PIP'}]"
        },
        {
          "line": 2332,
          "text": "      };"
        },
        {
          "line": 2333,
          "text": "      for(const chain of v68FingerChains(side)){"
        },
        {
          "line": 2334,
          "text": "        if(chain.finger==='thumb'){"
        },
        {
          "line": 2335,
          "text": "          for(const b of chain.bones){ const base=v68BaseQuatByUuid.get(b.uuid); if(base) b.quaternion.copy(base); }"
        },
        {
          "line": 2336,
          "text": "          rows.push({finger:'thumb',active:false,reason:'V238 approved grip keeps thumb writer off; V199 wrist/palm/leg lock remains authority'});"
        },
        {
          "line": 2337,
          "text": "          continue;"
        },
        {
          "line": 2338,
          "text": "        }"
        },
        {
          "line": 2339,
          "text": "        const terms=approvedTerms[chain.finger]||[];"
        },
        {
          "line": 2340,
          "text": "        for(const t of terms){"
        },
        {
          "line": 2341,
          "text": "          const b=chain.bones[t.seg]; if(!b) continue;"
        },
        {
          "line": 2342,
          "text": "          const base=v68BaseQuatByUuid.get(b.uuid) || b.quaternion.clone();"
        },
        {
          "line": 2343,
          "text": "          const axis=axes[t.axis]; if(!axis) continue;"
        },
        {
          "line": 2344,
          "text": "          const q=new THREE.Quaternion().setFromAxisAngle(axis, t.sign*t.amount);"
        },
        {
          "line": 2345,
          "text": "          b.quaternion.copy(base.clone().multiply(q));"
        },
        {
          "line": 2346,
          "text": "          rows.push({finger:chain.finger,bone:b.name,segment:t.seg,axis:t.axis,sign:t.sign,amount:t.amount,active:true,role:t.role});"
        },
        {
          "line": 2347,
          "text": "        }"
        },
        {
          "line": 2348,
          "text": "      }"
        },
        {
          "line": 2349,
          "text": "      model.updateMatrixWorld(true);"
        },
        {
          "line": 2350,
          "text": "      try{ const __v239ApprovedGrip={schema:'NEXPROD01_V239_WIRING_FIXED_APPROVED_GRIP',active:true,side:gripSide,source:'V236_ALL_Z_STOP_INDEX_MCP_0p36',terms:approvedTerms,rows,policy:'Canonical clean grip: all finger joints use z+ curl plane; MCP -> PIP -> DIP; index MCP override z+0.36 from user-approved V235 audit. Only finger bones are written. No hand, wrist, arm, thumb or leg mutation.'}; globalThis.__NEXPROD01_V239_APPROVED_GRIP=__v239ApprovedGrip; globalThis.__NEXPROD01_V238_APPROVED_GRIP=__v239ApprovedGrip; }catch(e){}"
        },
        {
          "line": 2351,
          "text": "      return globalThis.__NEXPROD01_V238_APPROVED_GRIP || {active:true,side:gripSide,rows};"
        },
        {
          "line": 2352,
          "text": "    }"
        }
      ]
    },
    {
      "name": "V189 neutral pre-snap right hand frame",
      "start": 2582,
      "end": 2633,
      "lines": [
        {
          "line": 2582,
          "text": "  function v189NeutralPreSnapRightHandFrame(targets, rawTargets){"
        },
        {
          "line": 2583,
          "text": "    const out={...(targets||{})};"
        },
        {
          "line": 2584,
          "text": "    const side='R', F='R_Forearm', H='R_Hand', M='R_PalmBase', I='R_PalmIndexBase', P='R_PalmPinkyBase';"
        },
        {
          "line": 2585,
          "text": "    const before=v93Basis(out, side);"
        },
        {
          "line": 2586,
          "text": "    if(!out[F]||!out[H]||!restTargetPoints?.[H]||!restTargetPoints?.[M]||!restTargetPoints?.[I]||!restTargetPoints?.[P]){"
        },
        {
          "line": 2587,
          "text": "      return {targets:out,audit:{schema:'NEXPROD01_V189_PRE_SNAP_NEUTRAL_APPROACH',applied:false,reason:'missing_required_targets_or_rest_points',before}};"
        },
        {
          "line": 2588,
          "text": "    }"
        },
        {
          "line": 2589,
          "text": "    // Pre-snap rule: hand long axis must be the forearm continuation. No palm-snap, no thumb-down, no finger curl."
        },
        {
          "line": 2590,
          "text": "    let y=safeNorm(sub(out[H],out[F]), {x:0,y:-1,z:0});"
        },
        {
          "line": 2591,
          "text": "    // Keep roll only as a passive neutral roll hint. Do not use object/vrist normal here."
        },
        {
          "line": 2592,
          "text": "    let xRef=null, xSource='none';"
        },
        {
          "line": 2593,
          "text": "    if(rawTargets?.[I]&&rawTargets?.[P]){ xRef=sub(rawTargets[I],rawTargets[P]); xSource='raw_I_minus_P_projected'; }"
        },
        {
          "line": 2594,
          "text": "    else if(out[I]&&out[P]){ xRef=sub(out[I],out[P]); xSource='current_I_minus_P_projected'; }"
        },
        {
          "line": 2595,
          "text": "    const projected=(v)=> v ? projectPerp(v,y) : null;"
        },
        {
          "line": 2596,
          "text": "    let x=projected(xRef);"
        },
        {
          "line": 2597,
          "text": "    if(!x || len(x)<1e-6){"
        },
        {
          "line": 2598,
          "text": "      if(out.R_Upperarm&&out.L_Upperarm){ x=projected(sub(out.R_Upperarm,out.L_Upperarm)); xSource='body_lateral_projected'; }"
        },
        {
          "line": 2599,
          "text": "    }"
        },
        {
          "line": 2600,
          "text": "    if(!x || len(x)<1e-6){"
        },
        {
          "line": 2601,
          "text": "      x=projectPerp({x:1,y:0,z:0},y); xSource='world_x_projected_fallback';"
        },
        {
          "line": 2602,
          "text": "    }"
        },
        {
          "line": 2603,
          "text": "    x=safeNorm(x,{x:1,y:0,z:0});"
        },
        {
          "line": 2604,
          "text": "    let z=safeNorm(crossP(x,y), {x:0,y:0,z:1});"
        },
        {
          "line": 2605,
          "text": "    // Re-orthogonalize exactly like orthonormalBasisFromBranch: x = index-pinky, y = wrist->center."
        },
        {
          "line": 2606,
          "text": "    y=safeNorm(crossP(z,x), y);"
        },
        {
          "line": 2607,
          "text": "    const rst=orthonormalBasisFromBranch(restTargetPoints[H],restTargetPoints[I],restTargetPoints[P],restTargetPoints[M]);"
        },
        {
          "line": 2608,
          "text": "    const qRest=qFromBasis(rst.x,rst.y,rst.z);"
        },
        {
          "line": 2609,
          "text": "    const qTarget=qFromBasis(toThree(x),toThree(y),toThree(z));"
        },
        {
          "line": 2610,
          "text": "    const qDelta=qTarget.clone().multiply(qRest.clone().invert());"
        },
        {
          "line": 2611,
          "text": "    const Orest=restTargetPoints[H];"
        },
        {
          "line": 2612,
          "text": "    for(const K of [M,I,P]) out[K]=addP(out[H], quatRotatePoint(qDelta, sub(restTargetPoints[K],Orest)));"
        },
        {
          "line": 2613,
          "text": "    const after=v93Basis(out, side);"
        },
        {
          "line": 2614,
          "text": "    const afterAngles=after?.angles||{};"
        },
        {
          "line": 2615,
          "text": "    const pass=(afterAngles.mcpCenter_vs_forearm??999)<=10 && (afterAngles.palmRay_vs_forearm??999)<=20;"
        },
        {
          "line": 2616,
          "text": "    return {targets:out,audit:{schema:'NEXPROD01_V189_PRE_SNAP_NEUTRAL_APPROACH',applied:true,phase:'pre_snap_only',snapDisabled:true,fingersDisabled:true,thumbDisabled:true,settleDisabled:true,xRollSource:xSource,beforeAngles:before?.angles||null,afterAngles,pass,policy:'Build a neutral Nex hand frame before snap: visual MCP/hand long axis follows forearm. Do not use object normal, thumb-down, palm settle or fingers at this stage.'}};"
        },
        {
          "line": 2617,
          "text": "  }"
        },
        {
          "line": 2618,
          "text": ""
        },
        {
          "line": 2619,
          "text": ""
        },
        {
          "line": 2620,
          "text": "  function v194ThenarPatchSnapOnly(targets, rawTargets){"
        },
        {
          "line": 2621,
          "text": "    const out={...(targets||{})};"
        },
        {
          "line": 2622,
          "text": "    const side='R', T='R_Thigh', K='R_Calf', F='R_Foot', U='R_Upperarm', E='R_Forearm', H='R_Hand', M='R_PalmBase', I='R_PalmIndexBase', P='R_PalmPinkyBase';"
        },
        {
          "line": 2623,
          "text": "    const required=[T,K,F,U,E,H,M,I,P];"
        },
        {
          "line": 2624,
          "text": "    const before=v93Basis(out, side);"
        },
        {
          "line": 2625,
          "text": "    if(!required.every(k=>out[k])) return {targets:out,audit:{schema:'NEXPROD01_V194_THENAR_PATCH_SNAP_ONLY',applied:false,reason:'missing_targets',present:Object.keys(out).filter(k=>k.startsWith('R_')),before}};"
        },
        {
          "line": 2626,
          "text": "    const pnum=(name, fallback)=>{ const v=Number(globalThis[name]); return Number.isFinite(v)?v:fallback; };"
        },
        {
          "line": 2627,
          "text": "    const sideBias=pnum('__NEX_V194_SIDE_BIAS', 0.42);     // + = index/thenar side, - = pinky-side control"
        },
        {
          "line": 2628,
          "text": "    const proximalT=pnum('__NEX_V194_PROXIMAL_T', 0.32);   // wrist -> MCP-center fraction"
        },
        {
          "line": 2629,
          "text": "    const contactT=pnum('__NEX_V194_CONTACT_T', 0.125);    // foot -> calf fraction"
        },
        {
          "line": 2630,
          "text": "    const radiusM=pnum('__NEX_V194_RADIUS_M', 0.028);"
        },
        {
          "line": 2631,
          "text": "    const clearanceM=pnum('__NEX_V194_CLEARANCE_M', 0.002);"
        },
        {
          "line": 2632,
          "text": "    const mcpCenter={x:(out[I].x+out[P].x)/2,y:(out[I].y+out[P].y)/2,z:(out[I].z+out[P].z)/2};"
        },
        {
          "line": 2633,
          "text": "    const palmCenter={x:(out[M].x+out[I].x+out[P].x)/3,y:(out[M].y+out[I].y+out[P].y)/3,z:(out[M].z+out[I].z+out[P].z)/3};"
        }
      ]
    },
    {
      "name": "V194 thenar patch historical right snap attempt",
      "start": 2636,
      "end": 2672,
      "lines": [
        {
          "line": 2636,
          "text": "    // Thenar/contact patch: proximal palm pad biased toward index/thumb side. This is intentionally not PalmBase/MCP-center."
        },
        {
          "line": 2637,
          "text": "    const thenarPatch=addP(addP(out[H],scaleP(longVec,proximalT)), scaleP(mcpSpan,sideBias));"
        },
        {
          "line": 2638,
          "text": "    const oppositePatch=addP(addP(out[H],scaleP(longVec,proximalT)), scaleP(mcpSpan,-sideBias));"
        },
        {
          "line": 2639,
          "text": "    const centerPatch=addP(out[H],scaleP(longVec,proximalT));"
        },
        {
          "line": 2640,
          "text": "    const axis=safeNorm(sub(out[K],out[F]),{x:0,y:1,z:0});"
        },
        {
          "line": 2641,
          "text": "    const axisPoint=addP(out[F],scaleP(sub(out[K],out[F]),contactT));"
        },
        {
          "line": 2642,
          "text": "    const radialOf=(q)=>{ const rel=sub(q,axisPoint); const t=dot(rel,axis); const perp=sub(rel,scaleP(axis,t)); const d=len(perp); return {t, d, perp, signedClearance:d-(radiusM+clearanceM)}; };"
        },
        {
          "line": 2643,
          "text": "    let radial=projectPerp(sub(thenarPatch,axisPoint),axis);"
        },
        {
          "line": 2644,
          "text": "    if(!radial||len(radial)<1e-6) radial=projectPerp(sub(centerPatch,axisPoint),axis);"
        },
        {
          "line": 2645,
          "text": "    radial=safeNorm(radial||{x:-1,y:0,z:0},{x:-1,y:0,z:0});"
        },
        {
          "line": 2646,
          "text": "    const contact=addP(axisPoint,scaleP(radial,radiusM+clearanceM));"
        },
        {
          "line": 2647,
          "text": "    const delta=sub(contact,thenarPatch);"
        },
        {
          "line": 2648,
          "text": "    const desiredH=addP(out[H],delta);"
        },
        {
          "line": 2649,
          "text": "    const l1=len(sub(out[E],out[U])), l2=len(sub(out[H],out[E])), d=len(sub(desiredH,out[U]));"
        },
        {
          "line": 2650,
          "text": "    const minReach=Math.abs(l1-l2)+1e-6, maxReach=l1+l2-1e-6;"
        },
        {
          "line": 2651,
          "text": "    const patchesBefore={thenar:roundObj(thenarPatch),opposite:roundObj(oppositePatch),center:roundObj(centerPatch),contact:roundObj(contact),axisPoint:roundObj(axisPoint)};"
        },
        {
          "line": 2652,
          "text": "    const clearBefore={thenar:+radialOf(thenarPatch).signedClearance.toFixed(5),opposite:+radialOf(oppositePatch).signedClearance.toFixed(5),center:+radialOf(centerPatch).signedClearance.toFixed(5),palmCenter:+radialOf(palmCenter).signedClearance.toFixed(5)};"
        },
        {
          "line": 2653,
          "text": "    if(!(d>=minReach && d<=maxReach)){"
        },
        {
          "line": 2654,
          "text": "      return {targets:out,audit:{schema:'NEXPROD01_V194_THENAR_PATCH_SNAP_ONLY',applied:false,reason:'thenar_patch_desired_wrist_unreachable_without_wrist_bend',params:{sideBias,proximalT,contactT,radiusM,clearanceM},beforeAngles:before?.angles||null,patchesBefore,clearBefore,reach:{distance:+d.toFixed(5),minReach:+minReach.toFixed(5),maxReach:+maxReach.toFixed(5)},policy:'Fail instead of bending wrist. V194 tests the thenar/palm-thumb-side patch as the first contact point. No fingers, thumb-down, wrist-settle or leg move.'}};"
        },
        {
          "line": 2655,
          "text": "    }"
        },
        {
          "line": 2656,
          "text": "    // Translation-only handframe. Hand/three palm landmarks move rigidly; no roll/settle/finger target is solved here."
        },
        {
          "line": 2657,
          "text": "    const u=safeNorm(sub(desiredH,out[U]),{x:0,y:-1,z:0});"
        },
        {
          "line": 2658,
          "text": "    const x=(l1*l1-l2*l2+d*d)/(2*d), hh=Math.sqrt(Math.max(0,l1*l1-x*x));"
        },
        {
          "line": 2659,
          "text": "    const rel=sub(out[E],out[U]), axial=scaleP(u,dot(rel,u));"
        },
        {
          "line": 2660,
          "text": "    let bend=sub(rel,axial);"
        },
        {
          "line": 2661,
          "text": "    if(len(bend)<1e-7){ const rawRel=(rawTargets?.[E]&&rawTargets?.[U])?sub(rawTargets[E],rawTargets[U]):{x:1,y:0,z:0}; bend=sub(rawRel,scaleP(u,dot(rawRel,u))); }"
        },
        {
          "line": 2662,
          "text": "    const n=safeNorm(bend,{x:1,y:0,z:0});"
        },
        {
          "line": 2663,
          "text": "    out[E]=addP(out[U],addP(scaleP(u,x),scaleP(n,hh)));"
        },
        {
          "line": 2664,
          "text": "    for(const KK of [H,M,I,P]) out[KK]=addP(out[KK],delta);"
        },
        {
          "line": 2665,
          "text": "    const after=v93Basis(out,side); const a=after?.angles||{};"
        },
        {
          "line": 2666,
          "text": "    const shifted=(q)=>addP(q,delta);"
        },
        {
          "line": 2667,
          "text": "    const clearAfter={thenar:+radialOf(shifted(thenarPatch)).signedClearance.toFixed(5),opposite:+radialOf(shifted(oppositePatch)).signedClearance.toFixed(5),center:+radialOf(shifted(centerPatch)).signedClearance.toFixed(5),palmCenter:+radialOf(shifted(palmCenter)).signedClearance.toFixed(5)};"
        },
        {
          "line": 2668,
          "text": "    const penetrationGuardPass=clearAfter.opposite>=-0.001 && clearAfter.center>=-0.001 && clearAfter.palmCenter>=-0.001;"
        },
        {
          "line": 2669,
          "text": "    const contactPass=Math.abs(clearAfter.thenar)<=0.002;"
        },
        {
          "line": 2670,
          "text": "    const neutralPass=(a.mcpCenter_vs_forearm??999)<=12 && (a.palmRay_vs_forearm??999)<=22;"
        },
        {
          "line": 2671,
          "text": "    return {targets:out,audit:{schema:'NEXPROD01_V194_THENAR_PATCH_SNAP_ONLY',applied:true,phase:'thenar_patch_translation_snap_only',params:{sideBias,proximalT,contactT,radiusM,clearanceM},beforeAngles:before?.angles||null,afterAngles:a,pass:contactPass&&penetrationGuardPass&&neutralPass,contactPass,penetrationGuardPass,neutralPass,patchesBefore,patchesAfter:{thenar:roundObj(shifted(thenarPatch)),opposite:roundObj(shifted(oppositePatch)),center:roundObj(shifted(centerPatch)),contact:roundObj(contact)},clearBefore,clearAfter,translationM:+len(delta).toFixed(5),translation:roundObj(delta),reach:{distance:+d.toFixed(5),minReach:+minReach.toFixed(5),maxReach:+maxReach.toFixed(5)},policy:'First contact is the thumb-side palm/thenar patch. Both sides are checked: thenar should touch, opposite/palm-center should not penetrate. Fingers, thumb-down, wrist-settle and leg movement remain disabled.'}};"
        },
        {
          "line": 2672,
          "text": "  }"
        }
      ]
    },
    {
      "name": "V198 V195 delta single-writer right snap",
      "start": 2675,
      "end": 2707,
      "lines": [
        {
          "line": 2675,
          "text": "  function v198ActualV195DeltaGreenYellowSingleWriter(targets, rawTargets){"
        },
        {
          "line": 2676,
          "text": "    const out={...(targets||{})};"
        },
        {
          "line": 2677,
          "text": "    const side='R', U='R_Upperarm', E='R_Forearm', H='R_Hand', M='R_PalmBase', I='R_PalmIndexBase', P='R_PalmPinkyBase', K='R_Calf', F='R_Foot', Toe='R_ToeBase';"
        },
        {
          "line": 2678,
          "text": "    const before=v93Basis(out, side);"
        },
        {
          "line": 2679,
          "text": "    const required=[U,E,H,M,I,P,K,F];"
        },
        {
          "line": 2680,
          "text": "    if(!required.every(k=>out[k])) return {targets:out,audit:{schema:'NEXPROD01_V198_V195_DELTA_SINGLE_WRITER',applied:false,reason:'missing_targets',before}};"
        },
        {
          "line": 2681,
          "text": "    const deltaV195={x:0.04303, y:-0.00036, z:-0.02451};"
        },
        {
          "line": 2682,
          "text": "    const desiredH=addP(out[H],deltaV195);"
        },
        {
          "line": 2683,
          "text": "    const l1=len(sub(out[E],out[U])), l2=len(sub(out[H],out[E]));"
        },
        {
          "line": 2684,
          "text": "    const minReach=Math.abs(l1-l2)+1e-6, maxReach=l1+l2-1e-6, dDesired=len(sub(desiredH,out[U]));"
        },
        {
          "line": 2685,
          "text": "    let targetH=desiredH, armDelta=deltaV195, clamped=false, legDelta={x:0,y:0,z:0};"
        },
        {
          "line": 2686,
          "text": "    if(dDesired<minReach || dDesired>maxReach){"
        },
        {
          "line": 2687,
          "text": "      clamped=true;"
        },
        {
          "line": 2688,
          "text": "      const dir=safeNorm(sub(desiredH,out[U]), safeNorm(sub(out[H],out[U]),{x:0,y:-1,z:0}));"
        },
        {
          "line": 2689,
          "text": "      const clampedD=Math.max(minReach,Math.min(maxReach,dDesired));"
        },
        {
          "line": 2690,
          "text": "      targetH=addP(out[U],scaleP(dir,clampedD));"
        },
        {
          "line": 2691,
          "text": "      armDelta=sub(targetH,out[H]);"
        },
        {
          "line": 2692,
          "text": "      legDelta=sub(armDelta,deltaV195);"
        },
        {
          "line": 2693,
          "text": "    }"
        },
        {
          "line": 2694,
          "text": "    const d=len(sub(targetH,out[U]));"
        },
        {
          "line": 2695,
          "text": "    const u=safeNorm(sub(targetH,out[U]),{x:0,y:-1,z:0});"
        },
        {
          "line": 2696,
          "text": "    const xx=(l1*l1-l2*l2+d*d)/(2*d), hh=Math.sqrt(Math.max(0,l1*l1-xx*xx));"
        },
        {
          "line": 2697,
          "text": "    const rel=sub(out[E],out[U]), axial=scaleP(u,dot(rel,u));"
        },
        {
          "line": 2698,
          "text": "    let bend=sub(rel,axial);"
        },
        {
          "line": 2699,
          "text": "    if(len(bend)<1e-7){ const rawRel=(rawTargets?.[E]&&rawTargets?.[U])?sub(rawTargets[E],rawTargets[U]):{x:1,y:0,z:0}; bend=sub(rawRel,scaleP(u,dot(rawRel,u))); }"
        },
        {
          "line": 2700,
          "text": "    const n=safeNorm(bend,{x:1,y:0,z:0});"
        },
        {
          "line": 2701,
          "text": "    out[E]=addP(out[U],addP(scaleP(u,xx),scaleP(n,hh)));"
        },
        {
          "line": 2702,
          "text": "    for(const KK of [H,M,I,P]) out[KK]=addP(out[KK],armDelta);"
        },
        {
          "line": 2703,
          "text": "    if(clamped){ for(const KK of [K,F,Toe]) if(out[KK]) out[KK]=addP(out[KK],legDelta); }"
        },
        {
          "line": 2704,
          "text": "    const after=v93Basis(out, side); const a=after?.angles||{};"
        },
        {
          "line": 2705,
          "text": "    const neutralPass=(a.mcpCenter_vs_forearm??999)<=12 && (a.palmRay_vs_forearm??999)<=22;"
        },
        {
          "line": 2706,
          "text": "    return {targets:out,audit:{schema:'NEXPROD01_V198_V195_DELTA_SINGLE_WRITER',applied:true,deltaV195:roundObj(deltaV195),clamped,armDelta:roundObj(armDelta),armDeltaM:+len(armDelta).toFixed(5),legDelta:roundObj(legDelta),legDeltaM:+len(legDelta).toFixed(5),reach:{desiredDistance:+dDesired.toFixed(5),minReach:+minReach.toFixed(5),maxReach:+maxReach.toFixed(5),missing:+Math.max(0,dDesired-maxReach).toFixed(5)},beforeAngles:before?.angles||null,afterAngles:a,neutralPass,pass:neutralPass,policy:'V198: single writer green->yellow. Fingers/thumb/wrist settle off.'}};"
        },
        {
          "line": 2707,
          "text": "  }"
        }
      ]
    },
    {
      "name": "V199 lock green / roll pink wrist only",
      "start": 2709,
      "end": 2756,
      "lines": [
        {
          "line": 2709,
          "text": "  function v199LockGreenRollPinkWristOnly(targets, rawTargets){"
        },
        {
          "line": 2710,
          "text": "    const out={...(targets||{})};"
        },
        {
          "line": 2711,
          "text": "    const side='R', U='R_Upperarm', E='R_Forearm', H='R_Hand', M='R_PalmBase', I='R_PalmIndexBase', P='R_PalmPinkyBase', K='R_Calf', F='R_Foot', Toe='R_ToeBase';"
        },
        {
          "line": 2712,
          "text": "    const before=v93Basis(out, side);"
        },
        {
          "line": 2713,
          "text": "    const required=[U,E,H,M,I,P,K,F];"
        },
        {
          "line": 2714,
          "text": "    if(!required.every(k=>out[k])) return {targets:out,audit:{schema:'NEXPROD01_V199_LOCK_GREEN_ROLL_PINK',applied:false,reason:'missing_targets',before}};"
        },
        {
          "line": 2715,
          "text": "    const localGreen={x:0.93966,y:0.70339,z:0.42636};   // fixed V195 green thenar vertex local coords"
        },
        {
          "line": 2716,
          "text": "    const localPink ={x:-0.08284,y:0.62487,z:0.34506};  // fixed V195 magenta/opposite-palm vertex local coords"
        },
        {
          "line": 2717,
          "text": "    const pinkLegTarget={x:-0.10186,y:0.76352,z:-0.33015}; // V198 closest lower-leg surface near pink; diagnostic target only"
        },
        {
          "line": 2718,
          "text": "    const makeBasis=(O)=>{"
        },
        {
          "line": 2719,
          "text": "      const C=scaleP(addP(addP(O[M],O[I]),O[P]),1/3);"
        },
        {
          "line": 2720,
          "text": "      let y=safeNorm(sub(C,O[H]),{x:0,y:-1,z:0});"
        },
        {
          "line": 2721,
          "text": "      let x=projectPerp(sub(O[I],O[P]),y); x=safeNorm(x,{x:1,y:0,z:0});"
        },
        {
          "line": 2722,
          "text": "      let z=safeNorm(crossP(x,y),{x:0,y:0,z:1});"
        },
        {
          "line": 2723,
          "text": "      y=safeNorm(crossP(z,x),y);"
        },
        {
          "line": 2724,
          "text": "      return {x,y,z,handLen:Math.max(0.001,len(sub(C,O[H]))),handSpan:Math.max(0.001,len(sub(O[I],O[P])))};"
        },
        {
          "line": 2725,
          "text": "    };"
        },
        {
          "line": 2726,
          "text": "    const pointLocal=(O,L)=>{ const b=makeBasis(O); return addP(O[H],addP(addP(scaleP(b.x,L.x*b.handSpan),scaleP(b.y,L.y*b.handLen)),scaleP(b.z,L.z*b.handSpan))); };"
        },
        {
          "line": 2727,
          "text": "    const rotateAround=(pt,pivot,axis,deg)=>{"
        },
        {
          "line": 2728,
          "text": "      const th=deg*Math.PI/180, ct=Math.cos(th), st=Math.sin(th), v=sub(pt,pivot), c=crossP(axis,v), ad=dot(axis,v);"
        },
        {
          "line": 2729,
          "text": "      return addP(pivot,{x:v.x*ct+c.x*st+axis.x*ad*(1-ct), y:v.y*ct+c.y*st+axis.y*ad*(1-ct), z:v.z*ct+c.z*st+axis.z*ad*(1-ct)});"
        },
        {
          "line": 2730,
          "text": "    };"
        },
        {
          "line": 2731,
          "text": "    const mode=String(globalThis.__NEX_V199_MODE||'wristPivotMoveLeg');"
        },
        {
          "line": 2732,
          "text": "    const roll=Number.isFinite(Number(globalThis.__NEX_V199_ROLL_DEG))?Number(globalThis.__NEX_V199_ROLL_DEG):55;"
        },
        {
          "line": 2733,
          "text": "    const green0=pointLocal(out,localGreen), pink0=pointLocal(out,localPink);"
        },
        {
          "line": 2734,
          "text": "    const axis=safeNorm(sub(out[H],out[E]),{x:0,y:-1,z:0});"
        },
        {
          "line": 2735,
          "text": "    const beforePinkDist=len(sub(pink0,pinkLegTarget));"
        },
        {
          "line": 2736,
          "text": "    let legDelta={x:0,y:0,z:0};"
        },
        {
          "line": 2737,
          "text": "    if(mode==='contactPivot'){"
        },
        {
          "line": 2738,
          "text": "      // Locked green is the pivot. Wrist may move; used to test pure contact-locked roll."
        },
        {
          "line": 2739,
          "text": "      const pivot=green0;"
        },
        {
          "line": 2740,
          "text": "      for(const KK of [H,M,I,P]) out[KK]=rotateAround(out[KK],pivot,axis,roll);"
        },
        {
          "line": 2741,
          "text": "    } else {"
        },
        {
          "line": 2742,
          "text": "      // More conservative anatomical wrist roll: rotate the palm plate about the wrist/forearm axis."
        },
        {
          "line": 2743,
          "text": "      // Then move the leg contact marker with the resulting green point so green/yellow remains snapped without moving the wrist past reach."
        },
        {
          "line": 2744,
          "text": "      const pivot=out[H];"
        },
        {
          "line": 2745,
          "text": "      for(const KK of [M,I,P]) out[KK]=rotateAround(out[KK],pivot,axis,roll);"
        },
        {
          "line": 2746,
          "text": "      const greenAfterHand=pointLocal(out,localGreen);"
        },
        {
          "line": 2747,
          "text": "      legDelta=sub(greenAfterHand,green0);"
        },
        {
          "line": 2748,
          "text": "      // V199C micro-correction from actual fixed skinned markers after V199B: move the second snap body, not the hand."
        },
        {
          "line": 2749,
          "text": "      legDelta=addP(legDelta,{x:-0.0055,y:-0.0034,z:-0.0016});"
        },
        {
          "line": 2750,
          "text": "      for(const KK of [K,F,Toe]) if(out[KK]) out[KK]=addP(out[KK],legDelta);"
        },
        {
          "line": 2751,
          "text": "    }"
        },
        {
          "line": 2752,
          "text": "    const green1=pointLocal(out,localGreen), pink1=pointLocal(out,localPink);"
        },
        {
          "line": 2753,
          "text": "    const pinkTarget1=addP(pinkLegTarget,legDelta);"
        },
        {
          "line": 2754,
          "text": "    const after=v93Basis(out,side); const a=after?.angles||{};"
        },
        {
          "line": 2755,
          "text": "    const l1=len(sub(out[E],out[U])), l2=len(sub(out[H],out[E])), d=len(sub(out[H],out[U])), maxReach=l1+l2-1e-6, minReach=Math.abs(l1-l2)+1e-6;"
        },
        {
          "line": 2756,
          "text": "    return {targets:out,audit:{schema:'NEXPROD01_V199_LOCK_GREEN_ROLL_PINK',applied:true,mode,rollDeg:roll,greenLockPolicy:mode==='contactPivot'?'green point is fixed pivot':'wrist is fixed; lower-leg is translated by green-point residual to preserve green/yellow contact',greenBefore:roundObj(green0),greenAfter:roundObj(green1),pinkBefore:roundObj(pink0),pinkAfter:roundObj(pink1),pinkLegTargetBefore:roundObj(pinkLegTarget),pinkLegTargetAfter:roundObj(pinkTarget1),legDelta:roundObj(legDelta),legDeltaM:+len(legDelta).toFixed(5),pinkDistanceBefore:+beforePinkDist.toFixed(5),pinkDistanceAfter:+len(sub(pink1,pinkTarget1)).toFixed(5),reach:{distance:+d.toFixed(5),minReach:+minReach.toFixed(5),maxReach:+maxReach.toFixed(5),overMax:+Math.max(0,d-maxReach).toFixed(5)},beforeAngles:before?.angles||null,afterAngles:a,policy:'V199 only: after V198 green-yellow single-writer contact, rotate the wrist/palm plate so fixed magenta point approaches lower leg. No fingers, no thumb writer, no additional snap/cylinder/t sweep.'}};"
        }
      ]
    },
    {
      "name": "commit loop right-only truth/probe calls",
      "start": 2860,
      "end": 2893,
      "lines": [
        {
          "line": 2860,
          "text": "    try { globalThis.__NEXPROD01_V157_REAL_MEDIAPIPE_HAND_FRAME=v157SourceHand.audit; } catch(e) {}"
        },
        {
          "line": 2861,
          "text": "    const ikSourceLockPass=!!(sourceLock?.profileHash && sourceLock?.frameHash && approvalGate?.ikApproved && approvalGate?.nexTestEligible);"
        },
        {
          "line": 2862,
          "text": "    const retargetedBaseTargets=buildRetargetedActualLengthTargets(rawTargets);"
        },
        {
          "line": 2863,
          "text": "    const invariantAuthority=applyAuthoredInvariantPointAuthority(c, rawTargets, retargetedBaseTargets);"
        },
        {
          "line": 2864,
          "text": "    const retargetedTargets=invariantAuthority.targets;"
        },
        {
          "line": 2865,
          "text": "    const biomechAtlas=biomechAtlasNormalizeTargets(retargetedTargets, rawTargets);"
        },
        {
          "line": 2866,
          "text": "    const sourceContact=sourceContactAuthorityForCase(c);"
        },
        {
          "line": 2867,
          "text": "    // V183 neutral hand-snap feasibility stage: one owner decides whether the other snap point"
        },
        {
          "line": 2868,
          "text": "    // (the raised ankle) must move before the hand is solved. This replaces the previous separate"
        },
        {
          "line": 2869,
          "text": "    // V169 closer + V175 leg-out patches so no later body patch moves the ankle into a solved hand."
        },
        {
          "line": 2870,
          "text": "    const v183Closer=v169MoveRaisedLegTowardGluteOnly(biomechAtlas.targets,0.065);"
        },
        {
          "line": 2871,
          "text": "    let v183SnapTargets=v183Closer.targets;"
        },
        {
          "line": 2872,
          "text": "    const v183LegOut=v175AngleRaisedLegOutward(v183SnapTargets,-10);"
        },
        {
          "line": 2873,
          "text": "    v183SnapTargets=v183LegOut.targets;"
        },
        {
          "line": 2874,
          "text": "    biomechAtlas.targets=v183SnapTargets;"
        },
        {
          "line": 2875,
          "text": "    try { globalThis.__NEXPROD01_V184_SNAP_ONLY_FEASIBILITY={schema:'NEXPROD01_V184_SNAP_ONLY_FEASIBILITY',applied:true,closer:v183Closer.audit,legOut:v183LegOut.audit,policy:'Pre-snap feasibility only: raised ankle is placed before any hand frame is solved. No post-contact body patches.'}; } catch(e) {}"
        },
        {
          "line": 2876,
          "text": "    try { globalThis.__NEXPROD01_V169_LEG_CLOSER_ONLY={applied:false,reason:'superseded_by_V183_neutral_snap_feasibility'}; } catch(e) {}"
        },
        {
          "line": 2877,
          "text": "    try { globalThis.__NEXPROD01_V175_LEG_OUT={applied:false,reason:'superseded_by_V183_neutral_snap_feasibility'}; } catch(e) {}"
        },
        {
          "line": 2878,
          "text": "    const v266GripContract=v266ApplyCleanGripContract(biomechAtlas.targets, rawTargets, sourceContact, {caseId:c.caseId, phase:c.phase});"
        },
        {
          "line": 2879,
          "text": "    biomechAtlas.targets=v266GripContract.targets;"
        },
        {
          "line": 2880,
          "text": "    const v189Neutral={targets:biomechAtlas.targets,audit:v266GripContract.stages.v189||{schema:'NEXPROD01_V189_PRE_SNAP_NEUTRAL_APPROACH',applied:false,reason:'blocked_by_V266_clean_grip_contract',requestedSide:v266GripContract.audit.requestedSide}};"
        },
        {
          "line": 2881,
          "text": "    const v198Snap={targets:biomechAtlas.targets,audit:v266GripContract.stages.v198||{schema:'NEXPROD01_V198_V195_DELTA_SINGLE_WRITER',applied:false,reason:'blocked_by_V266_clean_grip_contract',requestedSide:v266GripContract.audit.requestedSide}};"
        },
        {
          "line": 2882,
          "text": "    const v199Roll={targets:biomechAtlas.targets,audit:v266GripContract.stages.v199||{schema:'NEXPROD01_V199_LOCK_GREEN_ROLL_PINK',applied:false,reason:'blocked_by_V266_clean_grip_contract',requestedSide:v266GripContract.audit.requestedSide}};"
        },
        {
          "line": 2883,
          "text": "    try { globalThis.__NEXPROD01_V266_CLEAN_GRIP_CONTRACT=v266GripContract.audit; } catch(e) {}"
        },
        {
          "line": 2884,
          "text": "    try { globalThis.__NEXPROD01_V189_PRE_SNAP_NEUTRAL_APPROACH=v189Neutral.audit; } catch(e) {}"
        },
        {
          "line": 2885,
          "text": "    try { globalThis.__NEXPROD01_V198_V195_DELTA_SINGLE_WRITER=v198Snap.audit; } catch(e) {}"
        },
        {
          "line": 2886,
          "text": "    try { globalThis.__NEXPROD01_V199_LOCK_GREEN_ROLL_PINK=v199Roll.audit; } catch(e) {}"
        },
        {
          "line": 2887,
          "text": "    const v110Grip={targets:biomechAtlas.targets,audit:{schema:'NEXPROD01_V266_CLEAN_GRIP_CONTRACT_NO_DISTAL_GRIP_YET',applied:!!v266GripContract.audit.applied,reason:v266GripContract.audit.applied?'clean grip contract completed pre-finger right golden path; fingers still owned by approved V238/V239 layer':'grip contract blocked; no palm/finger authority for this side yet',contract:v266GripContract.audit,v189:v189Neutral.audit,v198:v198Snap.audit,v199:v199Roll.audit,policy:'V266 sequence: one named contract wraps neutral pre-snap -> green/yellow contact -> wrist roll. It explicitly blocks side=L until the contract is parameterized from the right source-of-truth.'}};"
        },
        {
          "line": 2888,
          "text": "    try { globalThis.__NEXPROD01_V110_DISTAL_GRIP_COUPLED=v110Grip.audit; } catch(e) {}"
        },
        {
          "line": 2889,
          "text": "    let v102LegReach={targets:biomechAtlas.targets,audit:{applied:false,reason:'v110_distal_coupled_authority'}};"
        },
        {
          "line": 2890,
          "text": "    let v98GripContact={targets:biomechAtlas.targets,audit:{applied:false,reason:'v110_distal_coupled_authority'}};"
        },
        {
          "line": 2891,
          "text": "    let v100GripSurface={targets:biomechAtlas.targets,audit:{applied:false,reason:'v110_distal_coupled_authority'}};"
        },
        {
          "line": 2892,
          "text": "    if(false && !v110Grip.audit?.applied){"
        },
        {
          "line": 2893,
          "text": "      v102LegReach=v102RestoreHeelToGluteReach(biomechAtlas.targets, rawTargets, sourceContact); biomechAtlas.targets=v102LegReach.targets;"
        }
      ]
    }
  ],
  "grep": {
    "right_only_call_sites": [
      {
        "line": 2325,
        "text": "if(side==='R' && globalThis.__NEX_V238_USE_LEGACY_V200_FINGER_CLOSE!==true){"
      },
      {
        "line": 2584,
        "text": "const side='R', F='R_Forearm', H='R_Hand', M='R_PalmBase', I='R_PalmIndexBase', P='R_PalmPinkyBase';"
      },
      {
        "line": 2622,
        "text": "const side='R', T='R_Thigh', K='R_Calf', F='R_Foot', U='R_Upperarm', E='R_Forearm', H='R_Hand', M='R_PalmBase', I='R_PalmIndexBase', P='R_PalmPinkyBase';"
      },
      {
        "line": 2677,
        "text": "const side='R', U='R_Upperarm', E='R_Forearm', H='R_Hand', M='R_PalmBase', I='R_PalmIndexBase', P='R_PalmPinkyBase', K='R_Calf', F='R_Foot', Toe='R_ToeBase';"
      },
      {
        "line": 2711,
        "text": "const side='R', U='R_Upperarm', E='R_Forearm', H='R_Hand', M='R_PalmBase', I='R_PalmIndexBase', P='R_PalmPinkyBase', K='R_Calf', F='R_Foot', Toe='R_ToeBase';"
      },
      {
        "line": 2923,
        "text": "v140GripHandQaTint=v140InstallGripHandQaTint('R'); commit.v140GripHandQaTint=v140GripHandQaTint;"
      },
      {
        "line": 2924,
        "text": "v151MeshTruth=v151ActualMeshTruthDiag('R'); commit.v151MeshTruth=v151MeshTruth;"
      }
    ],
    "generic_grip_side_sites": [
      {
        "line": 452,
        "text": "const refSourceContact=sourceContactAuthorityForCase({...c,phase:0});"
      },
      {
        "line": 923,
        "text": "function applyOneWriterCommit(targets, sourceContact=null){"
      },
      {
        "line": 1023,
        "text": "const activeGroups=activeContactGroupsFromIk(targets,sourceContact);"
      },
      {
        "line": 1065,
        "text": "function v98ReconcileNonFloorGripContact(targets, rawTargets, sourceContact){"
      },
      {
        "line": 1067,
        "text": "const rules=(sourceContact?.rules||[]).filter(r=>r?.nonFloorContact===true && r?.gripSide && /grip|heel|shin|hook/i.test(String(r?.type||'')+' '+String(r?.contactStyle||'')+' '+String(r?.targetLimb||'')));"
      },
      {
        "line": 1070,
        "text": "const side=String(rule.gripSide||'').toUpperCase()==='R'?'R':'L';"
      },
      {
        "line": 1075,
        "text": "const sourceContactDelta=sub(rawTargets[M],rawTargets[F]);"
      },
      {
        "line": 1076,
        "text": "const desiredPalm=addP(out[F],sourceContactDelta);"
      },
      {
        "line": 1108,
        "text": "sourcePalmFootDelta:roundObj(sourceContactDelta), beforePalmFootDelta:roundObj(sub(targets[M],targets[F])), afterPalmFootDelta:roundObj(afterPalmFoot),"
      },
      {
        "line": 1119,
        "text": "function v110SolveDistalAxisGripCoupled(targets, rawTargets, sourceContact){"
      },
      {
        "line": 1121,
        "text": "const rules=(sourceContact?.rules||[]).filter(r=>r?.nonFloorContact===true && r?.gripSide && Array.isArray(r?.cylinderAxis) && r.cylinderAxis.length===2 && Number.isFinite(+r?.capsuleRadiusMeters) && /lower_shin|distal|ankle|calf/i.test(String(r?.targetLimb||'')+' '+String(r?.surface||'')));"
      },
      {
        "line": 1125,
        "text": "const side=String(rule.gripSide||'').toUpperCase()==='R'?'R':'L';"
      },
      {
        "line": 1327,
        "text": "function v102RestoreHeelToGluteReach(targets, rawTargets, sourceContact){"
      },
      {
        "line": 1329,
        "text": "const rules=(sourceContact?.rules||[]).filter(r=>r?.nonFloorContact===true && r?.gripSide && Number.isFinite(+r?.capsuleRadiusMeters) && Array.isArray(r?.cylinderAxis));"
      },
      {
        "line": 1339,
        "text": "const side=String(rule.gripSide||'').toUpperCase()==='R'?'R':'L';"
      },
      {
        "line": 1367,
        "text": "function v100ResolveNonFloorGripCapsuleSurface(targets, rawTargets, sourceContact){"
      },
      {
        "line": 1369,
        "text": "const rules=(sourceContact?.rules||[]).filter(r=>r?.nonFloorContact===true && r?.gripSide && Number.isFinite(+r?.capsuleRadiusMeters) && Array.isArray(r?.cylinderAxis) && r.cylinderAxis.length===2);"
      },
      {
        "line": 1373,
        "text": "const side=String(rule.gripSide||'').toUpperCase()==='R'?'R':'L';"
      },
      {
        "line": 1425,
        "text": "function sourceContactAuthorityForCase(c){"
      },
      {
        "line": 1440,
        "text": "function activeContactGroupsFromIk(targets, sourceContact=null){"
      },
      {
        "line": 1449,
        "text": "if(sourceContact?.activeGroups?.length){"
      },
      {
        "line": 1450,
        "text": "const hasV53HandFloor=(sourceContact.rules||[]).some(r=>/v54_palmbase_floor_contact_authority|v53_floor_resolved_hand_support|hand_floor_contact_point_authority/i.test(String(r?.type||'')));"
      },
      {
        "line": 1452,
        "text": "return [...new Set(sourceContact.activeGroups)];"
      },
      {
        "line": 1454,
        "text": "const allowed=new Set(sourceContact.activeGroups);"
      },
      {
        "line": 1456,
        "text": "band=Math.max(0.12,...(sourceContact.rules||[]).map(r=>Number(r?.toleranceMeters)||0));"
      },
      {
        "line": 1462,
        "text": "function contactGateForProfile(profileId, contacts, targets, sourceContact=null){ const active=activeContactGroupsFromIk(targets,sourceContact); const rows=active.map(g=>{ const row=contacts.groups[g]; const minY=Number.isFinite(row?.minY)?row.minY:null; return {group:g,minY,penetration:minY===null?null:Math.max(0,-minY),status:minY===null?'missing':(minY>=-0.002?'clear':'penetrating'),sensor:row?.minPoint||null}; }); const maxPenetration=Math.max(0,...rows.map(r=>r.penetration||0)); const minActive=Math.min(...rows.map(r=>Number.isFinite(r.minY)?r.minY:Infinity)); const maxActive=Math.max(...rows.map(r=>Number.isFinite(r.minY)?r.minY:-Infinity)); const supportSpread=Number.isFinite(minActive)&&Number.isFinite(maxActive)?maxActive-minActive:null; const sourceTolerance=Math.max(0.18,...(sourceContact?.rules||[]).map(r=>Number(r?.toleranceMeters)||0)); const spreadTol=sourceContact?.used ? Math.max(0.18, sourceTolerance*4) : 0.18; return {floorY:0,contactAuthority:sourceContact?.used?'canonical_ik_contactRules':'generic_low_end_effector_fallback',sourceContact:sourceContact||null,activeGroups:active,rows,minActiveY:Number.isFinite(minActive)?+minActive.toFixed(5):null,maxActiveY:Number.isFinite(maxActive)?+maxActive.toFixed(5):null,supportSpread:supportSpread===null?null:+supportSpread.toFixed(5),supportSpreadTolerance:+spreadTol.toFixed(5),maxPenetration:+maxPenetration.toFixed(5),pass:rows.length>0 && rows.every(r=>r.status==='clear')&&(supportSpread===null?false:supportSpread<=spreadTol)}; }"
      },
      {
        "line": 1482,
        "text": "function floorCanonicalizeByIkSupport(targets, sourceContact=null){"
      },
      {
        "line": 1483,
        "text": "const active=activeContactGroupsFromIk(targets,sourceContact);"
      },
      {
        "line": 1930,
        "text": "function v68GripRule(sourceContact){"
      },
      {
        "line": 1931,
        "text": "const rules = sourceContact?.rules || [];"
      },
      {
        "line": 1932,
        "text": "return rules.find(r => /shin_grip|heel_shin_grip|heel_hook|compact_heel_hook|outer_shin_grip|outer_shin|palmbase_contact|finger_grip|biorig_v126_full_grip/i.test(String(r?.type||'')) && r?.gripSide) || null;"
      },
      {
        "line": 2269,
        "text": "const gripSide=side;"
      },
      {
        "line": 2313,
        "text": "try{ globalThis.__NEXPROD01_V216_BIOMECH_SAFE_FINGER_ROLLBACK={schema:'NEXPROD01_V216_BIOMECH_SAFE_FINGER_ROLLBACK',active:true,side:gripSide,rows,caps,policy:'V215 visual QA rejected broken fingers. V216 backs out contact-at-any-cost. Default route is conservative and cap-gated; set __NEX_V216_DISABLE=true to use V200 fallback.'}; }catch(e){}"
      },
      {
        "line": 2314,
        "text": "return globalThis.__NEXPROD01_V216_BIOMECH_SAFE_FINGER_ROLLBACK || {active:true,side:gripSide,rows,caps};"
      },
      {
        "line": 2319,
        "text": "const gripSide=side;"
      },
      {
        "line": 2350,
        "text": "try{ const __v239ApprovedGrip={schema:'NEXPROD01_V239_WIRING_FIXED_APPROVED_GRIP',active:true,side:gripSide,source:'V236_ALL_Z_STOP_INDEX_MCP_0p36',terms:approvedTerms,rows,policy:'Canonical clean grip: all finger joints use z+ curl plane; MCP -> PIP -> DIP; index MCP override z+0.36 from user-approved V235 audit. Only finger bones are written. No hand, wrist, arm, thumb or leg mutation.'}; globalThis.__NEXPROD01_V239_APPROVED_GRIP=__v239ApprovedGrip; globalThis.__NEXPROD01_V238_APPROVED_GRIP=__v239ApprovedGrip; }catch(e){}"
      },
      {
        "line": 2351,
        "text": "return globalThis.__NEXPROD01_V238_APPROVED_GRIP || {active:true,side:gripSide,rows};"
      },
      {
        "line": 2392,
        "text": "try{ globalThis.__NEXPROD01_V200_LOCKED_HAND_FINGER_CLOSE={schema:'NEXPROD01_V200_LOCKED_HAND_FINGER_CLOSE',active:true,side:gripSide,curlScale,sign,spreadScale,includeThumb,rows,policy:'After V199 palm/wrist lock: fingers only rotate in their own bones. They may not translate hand, wrist, arm, snap points, or leg. Thumb writer remains off unless includeThumb=true.'}; }catch(e){}"
      },
      {
        "line": 2393,
        "text": "return globalThis.__NEXPROD01_V200_LOCKED_HAND_FINGER_CLOSE || {active:true,side:gripSide,rows};"
      },
      {
        "line": 2396,
        "text": "function v68ApplyShinGripFingerLayer(sourceContact, targets=null){"
      },
      {
        "line": 2398,
        "text": "const rule = v68GripRule(sourceContact);"
      },
      {
        "line": 2400,
        "text": "const gripSide = String(rule.gripSide || '').toUpperCase() === 'R' ? 'R' : 'L';"
      },
      {
        "line": 2401,
        "text": "const freeSide = gripSide === 'L' ? 'R' : 'L';"
      },
      {
        "line": 2415,
        "text": "const grip = distalAxisGrip ? v200ApplyLockedHandFingerClose(gripSide) : v68ApplyFingerPreset(gripSide, presetName);"
      },
      {
        "line": 2416,
        "text": "const v84TipArc = distalAxisGrip ? {schema:'NEXPROD01_V200_LOCKED_HAND_FINGER_CLOSE_LAYER', active:true, reason:'initial palm/wrist contact accepted from V199; now rotate fingers only', policy:'V200: no hand/arm/leg writer in finger phase; only finger bone rotations from locked V199 hand state.'} : v84ApplyHeelHookFingerTipCCD(gripSide, targets, rule);"
      },
      {
        "line": 2417,
        "text": "try{globalThis.__NEXPROD01_V184_SNAP_ONLY={applied:false, gripSide, fingersPaused:false, thumbPaused:true, supersededBy:'V200_LOCKED_HAND_FINGER_CLOSE', policy:'Snap/wrist is V199 baseline; V200 begins finger close only.'};}catch(e){}"
      },
      {
        "line": 2422,
        "text": "return {schema:'NEXPROD01_V84_COMPACT_HEEL_HOOK_WITH_FINGERTIP_CCD_LAYER', v84TipArc, version:'BioRig_V126_43_HAND05_PLUS_MEDIAPIPE_21PT_FRAME', ...presetMeta, axisMap:{L:{forward:'yPos',normal:'xNeg',thumb:'index_side_down'},R:{forward:'yPos',normal:'xPos',thumb:'index_side_down'}}, enabled:true, active:true, gripSide, freeSide, ruleType:rule.type, wristPolicy:rule.wristPolicy||'near_straight_thumb_down', mediapipeHandFrame:rule.mediapipeHandFrame||null, thumbVectorConstraint:rule.thumbVectorConstraint||'thumb_cmc_to_thumb_tip_world_y_negative', policy:'V81_HEEL_CUP_HOOK_RUNTIME_META: V81 uses the user reference as a heel-cup hook: palm cups heel/ankle volume, fingers cross shoe/heel, thumb opposes down/in, wrist stays near forearm line and the hand reads as pulling the lower leg forward. V80 used the first facit heel-hook; V79 made thumb direction first-class. Finger layer remains child-layer curl after body IK.', grip, free};"
      },
      {
        "line": 2512,
        "text": "function v93BuildHandControlProbe(side, c, rawTargets, finalTargets, afterCommitTargets, afterFinalTargets, sourceContact, fingerLayer){"
      },
      {
        "line": 2535,
        "text": "sourceContactRule:(sourceContact?.rules||[]).map(r=>({type:r.type, gripSide:r.gripSide, handPreset:r.handPreset, contactStyle:r.contactStyle, wristPolicy:r.wristPolicy, thumbVectorConstraint:r.thumbVectorConstraint})),"
      },
      {
        "line": 2765,
        "text": "function v266ResolveGripSideFromSourceContact(sourceContact){"
      },
      {
        "line": 2767,
        "text": "const rules=sourceContact?.rules||[];"
      },
      {
        "line": 2768,
        "text": "const rule=rules.find(r=>r && r.gripSide) || null;"
      },
      {
        "line": 2769,
        "text": "const side=String(rule?.gripSide||'R').toUpperCase();"
      },
      {
        "line": 2774,
        "text": "function v266ApplyCleanGripContract(targets, rawTargets, sourceContact, opts={}){"
      },
      {
        "line": 2775,
        "text": "const requestedSide=v266ResolveGripSideFromSourceContact(sourceContact);"
      },
      {
        "line": 2866,
        "text": "const sourceContact=sourceContactAuthorityForCase(c);"
      },
      {
        "line": 2878,
        "text": "const v266GripContract=v266ApplyCleanGripContract(biomechAtlas.targets, rawTargets, sourceContact, {caseId:c.caseId, phase:c.phase});"
      },
      {
        "line": 2893,
        "text": "v102LegReach=v102RestoreHeelToGluteReach(biomechAtlas.targets, rawTargets, sourceContact); biomechAtlas.targets=v102LegReach.targets;"
      },
      {
        "line": 2894,
        "text": "v98GripContact=v98ReconcileNonFloorGripContact(biomechAtlas.targets, rawTargets, sourceContact); biomechAtlas.targets=v98GripContact.targets;"
      },
      {
        "line": 2895,
        "text": "v100GripSurface=v100ResolveNonFloorGripCapsuleSurface(biomechAtlas.targets, rawTargets, sourceContact); biomechAtlas.targets=v100GripSurface.targets;"
      },
      {
        "line": 2900,
        "text": "const floorCanonical=floorCanonicalizeByIkSupport(biomechAtlas.targets, sourceContact);"
      },
      {
        "line": 2919,
        "text": "commit=applyOneWriterCommit(finalTargets,sourceContact);"
      },
      {
        "line": 2921,
        "text": "v68ShinGripFingerLayer=v68ApplyShinGripFingerLayer(sourceContact, finalTargets);"
      },
      {
        "line": 2946,
        "text": "const v93RightHandControlProbe = v93BuildHandControlProbe('R', c, rawTargets, finalTargets, v93AfterCommitTargets, after, sourceContact, v68ShinGripFingerLayer); commit.v157SourceHandFrame=v157SourceHand.audit;"
      },
      {
        "line": 2954,
        "text": "const contactGate=contactGateForProfile(c.profileId,contactSamples,metricTargets,sourceContact);"
      },
      {
        "line": 2956,
        "text": "const rawBoneOriginContactGate=contactGateForProfile(c.profileId,rawBoneOriginContactSamples,metricTargets,sourceContact);"
      },
      {
        "line": 3006,
        "text": "const metrics={minDot:+minDot.toFixed(5),avgDot:+avgDot.toFixed(5),landmarks,rawLandmarks,runtimeTargetLandmarks,strictNormalization,invariantPointAuthority:invariantAuthority.audit,finalInvariantPointAuthority:finalInvariantAuthority.audit,semanticLandmarkMap,semanticActualReadback,branchRigidFit,normIkVsNexBranchSignature:normIkVsNexBranch,ikSourceLock,ikNexTruth:truthGate,rawBoneOriginTruth:rawBoneOriginTruthGate,rawIkFidelity:sourceFidelityGate,rawAbsoluteLandmarkDiagnostic,sourceDerivedCanonical,sourceContact,v98GripContact:v98GripContact.audit,rawBoneOriginContactGate,wholeBodyFloor,morphology,hingeIntegrity,biomechConstraints,runtimeTargetSelfCompare:runtimeTargetGate,v68ShinGripFingerLayer,v93RightHandControlProbe,rootTravel:+dist(after.Hip,before.Hip).toFixed(5)};"
      }
    ]
  }
}