A 3D model pipeline, pushed by GPT-6-Astra

agent (cont.)

+21:45
  • exec_commandsed -n '323,360p' tools/gear.py; sed -n '140,163p' tools/outfit.py; sed -n '239,251p' tools/outfit.py; sed -n '1388,1415p' review/vroid-02/index.html; cat review/astra/finalize.py

    command

    sed -n '323,360p' tools/gear.py; sed -n '140,163p' tools/outfit.py; sed -n '239,251p' tools/outfit.py; sed -n '1388,1415p' review/vroid-02/index.html; cat review/astra/finalize.py

    result, 4 lines

    Script completed
    Wall time 0.1 seconds
    Output:
    {"chunk_id":"8bc3e2","wall_time_seconds":0.00000575,"exit_code":0,"original_token_count":1932,"output":"def spear(fit, length=2.0, grip=0.55, head=0.26, hand=\"R\", shaft_role=\"wood\", name=\"spear\"):\n    \"\"\"A spear held a little behind its middle: an ash shaft, a leaf blade with a socket, a butt cap.\"\"\"\n    fist, fwd, side, flat, _ = _hand_frame(fit, hand)\n    start = fist - fwd * grip\n    out = [O.tube(f\"{name}_shaft\", shaft_role, start, fwd, length, 0.0135)]\n    tip0 = start + fwd * length\n    out.append(O.tube(f\"{name}_socket\", \"steel\", tip0 - fwd * 0.06, fwd, 0.08, 0.016, 0.012))\n    leaf = [(0.0, 0.0), (0.024, head * 0.30), (0.018, head * 0.65), (0.0, head), (-0.018, head * 0.65), (-0.024, head * 0.30)]\n    out.append(flat_piece(f\"{name}_head\", \"steel\", leaf, tip0 + fwd * 0.015, side, fwd, thickness=0.006))\n    out.append(O.ball(f\"{name}_butt\", \"steel\", start - fwd * 0.01, 0.016, squash=(1, 1, 1.6)))\n    _bind(fit, out, f\"J_Bip_{hand}_Hand\")\n    return _group(out, \"weapon\")\n\n\ndef axe(fit, haft=0.85, blade=0.24, double=False, hand=\"R\", shaft_role=\"wood\", name=\"axe\", grip=0.18):\n    \"\"\"An axe: a haft with a bearded crescent blade (two for a great axe), a langet and a pommel.\"\"\"\n    fist, fwd, side, flat, _ = _hand_frame(fit, hand)\n    start = fist - fwd * grip\n    out = [O.tube(f\"{name}_haft\", shaft_role, start, fwd, haft, 0.016, 0.018)]\n    top = start + fwd * (haft - 0.02)\n    a = np.linspace(-1, 1, 15)\n    edge = [(blade * (0.72 + 0.28 * math.cos(x * 1.25)), blade * 0.62 * x) for x in a]\n    beard = [(blade * 0.30, -blade * 0.62), (0.03, -blade * 0.16), (0.03, blade * 0.12), (blade * 0.30, blade * 0.58)]\n    cres = [(0.02, -0.05)] + [p_ for p_ in beard[:1]] + edge + [beard[-1]] + [(0.02, 0.05)]\n    for k, sg in enumerate((1, -1) if double else (1,)):\n        pts = [(sg * x, y) for x, y in cres]\n        out.append(flat_piece(f\"{name}_blade{k}\", \"steel\", pts, top, side, fwd, thickness=0.009))\n    out.append(O.box(f\"{name}_eye\", \"steel\", top, (side, flat, fwd), (0.026, 0.022, 0.06)))\n    out.append(O.ball(f\"{name}_pommel\", \"steel\", start, 0.022, squash=(1, 1, 0.8)))\n    _bind(fit, out, f\"J_Bip_{hand}_Hand\")\n    return _group(out, \"weapon\")\n\n\ndef dagger(fit, blade=0.24, hand=\"R\", name=\"dagger\"):\n    fist, fwd, side, flat, _ = _hand_frame(fit, hand)\n    out = [O.tube(f\"{name}_grip\", \"leather\", fist - fwd * 0.06, fwd, 0.11, 0.011)]\n    g = fist + fwd * 0.055\n    out.append(O.box(f\"{name}_guard\", \"steel\", g, (side, flat, fwd), (0.040, 0.008, 0.007)))\ndef ribbon(name, role, curve, width=0.006, lift=0.002, normals=None, away=None, closed=False):\n    \"\"\"A band along a 3D polyline, lifted off a surface. normals: the surface normal at each\n    point (the band lies flat on it); otherwise it faces away from `away`.\"\"\"\n    C = np.asarray(curve, float)\n    N = None if normals is None else np.asarray(normals, float)\n    if closed:\n        C = np.concatenate([C, C[:1]])\n        N = None if N is None else np.concatenate([N, N[:1]])\n    t = np.gradient(C, axis=0)\n    t /= np.maximum(np.linalg.norm(t, axis=1, keepdims=True), 1e-9)\n    nrm = N if N is not None else C - np.asarray(away if away is not None else C.mean(0))\n    nrm = nrm - t * np.einsum(\"ij,ij->i\", nrm, t)[:, None]\n    nrm /= np.maximum(np.linalg.norm(nrm, axis=1, keepdims=True), 1e-9)\n    side = np.cross(t, nrm)\n    P = np.stack([C - side * width / 2 + nrm * lift, C + side * width / 2 + nrm * lift], 1)\n    pos, tri = grid_mesh(P)\n    vn = np.repeat(nrm, 2, axis=0)\n    if (vertex_normals(pos, tri) * vn).sum(1).mean() < 0:\n        tri = tri[:, ::-1]\n    return piece(name, role, pos, tri, nrm=vn)\n\n\n# ---- body fit -----------------------------------------------------------------------\nclass Fit:\ndef inherit(child, parent):\n    \"\"\"Trim and hardware take the weights of the nearest vertex of the piece they sit on.\"\"\"\n    _, i = cKDTree(parent[\"pos\"]).query(child[\"pos\"])\n    child[\"J\"], child[\"W\"], child[\"jnames\"] = parent[\"J\"][i], parent[\"W\"][i], parent[\"jnames\"]\n    return child\n\n\ndef near_normals(pc, pts):\n    return pc[\"nrm\"][cKDTree(pc[\"pos\"]).query(pts)[1]]\n\n\n# ---- garments ------------------------------------------------------------------------\ndef wrap(fit, name, role, bones, offset, min_w=0.5, exclude=(), y_min=None, y_max=None, subdiv=0,\nfunction render() {\n  const meshes = allMeshes(), cs = active();\n  applySkin(meshes);\n  const cloths = cs.flatMap(c => c.cloths);\n  if (state.mode === \"3d\") {\n    meshes.forEach(o => o.material = o.userData.mat3d);\n    cloths.forEach(c => c.lines3d.visible = trimsShown(c));\n    sun.position.copy(camera.position).add(new THREE.Vector3(-3, 4, 0)); sun.target.position.copy(ctl.target); sun.target.updateMatrixWorld();\n    R.setRenderTarget(null); R.setClearColor(0x191626, 1); R.clear(); R.render(scene, camera); R.setClearColor(0x000000, 0);\n    return;\n  }\n  const buf = R.getDrawingBufferSize(new THREE.Vector2());\n  targetsFor(buf.x, buf.y);\n  cloths.forEach(c => c.lines3d.visible = false);\n  meshes.forEach(o => { o.material = o.userData.mats.painted; o.material.uniforms.uPass.value = 0; });\n  const G = GRADE[state.view === \"bust\" ? \"bust\" : \"battle\"];      // stage grade, shared by the characters and the stage\n  for (const o of meshes) { const mu = o.material.uniforms; mu.uAmbient.value.set(...G.ambient); mu.uKeyCol.value.set(...G.key); mu.uRimCol.value.set(...G.rim); }\n  // the info pass (roles, ids, depth) first: the colour pass reads it for cast shadows\n  meshes.forEach(o => {                              // unbound while it is drawn: reading it now would be a feedback loop\n    const mu = o.material.uniforms; mu.uPass.value = 1; mu.uCastOn.value = 0; mu.tCastInfo.value = null; mu.tCastDepth.value = null;\n  });\n  R.setRenderTarget(targets.rtInfo); R.clear(); R.render(scene, camera);\n  const ppmBuf = buf.y / (camera.top - camera.bottom) * camera.zoom;\n  for (const o of meshes) {\n    const mu = o.material.uniforms;\n    mu.uPass.value = 0; mu.uCastOn.value = 1; mu.tCastInfo.value = targets.rtInfo.texture; mu.tCastDepth.value = targets.rtInfo.depthTexture;\n    mu.uCastRes.value.set(buf.x, buf.y); mu.uCastNear.value = camera.near; mu.uCastFar.value = camera.far; mu.uCastPpm.value = ppmBuf;\n  }\n\"\"\"Assemble the portable, offline review page and its single image in ~/out.\"\"\"\nfrom pathlib import Path\nimport json\nimport shutil\nROOT=Path(__file__).resolve().parents[2]\nWORK=ROOT/'review/out/astra'\nOUT=Path.home()/'out'\nOUT.mkdir(parents=True,exist_ok=True)\nbuild=json.loads((WORK/'site/build.json').read_text())\nrender=json.loads((WORK/'warden.json').read_text())\npage=(ROOT/'review/astra/page.html').read_text()\npage=page.replace('FINAL_VISUAL_CRITIQUE',\n    'The sleeves still look inflated. Next I would author their folds for a reaching pose, then test one step '\n    'and one expression. The cape is posed for this still; its motion remains untested.')\npage=page.replace('TIMING_TEXT',\n    f'Final build: {build[\"build_seconds\"]:.1f} s. Headless render: {render[\"render_seconds\"]:.1f} s, '\n    'including browser startup, at 2× resolution. About 20 minutes overall, including reading, revisions and checks. '\n    'Run from the worktree; these scripts write only to review/out/astra. '\n    'The page and PNG need no network connection.')\npage=page.replace('The current strong woman, her AvatarSample face and hair, the garment and armour kits, the rig tools, and a copy of the painted renderer. Headless Chromium. No generated illustration or borrowed reference art.',\n    'Current strong woman, AvatarSample U face and S hair. Existing garment, armour and rig tools; '\n    'a copy of the painted renderer, with quieter hair shine and a stronger face shadow. '\n    'Terrain from the same primitive kit. Headless Chromium.')\n(OUT/'index.html').write_text(page)\nshutil.copyfile(WORK/'warden.png',OUT/'warden.png')\nprint(OUT/'index.html')\n"}
  • exec_commandcat > review/astra-finish/design.py <<'PY'

    command

    cat > review/astra-finish/design.py <<'PY'
    """Reedwatch: authored garment patterns, forged shells and swept crop.
    All dimensions are metres. No sample hair or predesigned costume is used.
    """
    import numpy as np
    from scipy.interpolate import PchipInterpolator
    import outfit as O
    import hair as H
    import gear as G
    from fitting import vertex_normals
    
    
    def grid(fit,name,role,g,bone=None,thick=.003,centre=None):
        centre=np.asarray(centre if centre is not None else [0,1,0])
        if thick:
            pos,tri,_=O.thick_grid(np.asarray(g),thick,centre)
        else: pos,tri=O.grid_mesh(np.asarray(g))
        pc=O.piece(name,role,pos,tri,outward_from=centre)
        fit.bind(pc,rigid=bone) if bone else fit.bind(pc,allow=('Hips','Spine','Chest','UpperChest','Neck'))
        pc['group']= 'armour' if role in ('steel','gold','darkmetal') else 'coat'
        return pc
    
    
    def edge(out,parent,name,line,role='binding',r=.0025):
        out.append(O.inherit(O.pipe(name,role,np.asarray(line),r=r,seg=6),parent))
    
    
    def rings(fit,name,role,centres,radii,bone=None,nu=40,thick=.003,fold=0):
        C=np.asarray(centres); radii=np.asarray(radii)
        T=np.gradient(C,axis=0);T/=np.linalg.norm(T,axis=1)[:,None]
        a=np.linspace(0,2*np.pi,nu)
        X=np.cross(T,np.tile([0,0,1.],(len(T),1))); X/=np.linalg.norm(X,axis=1)[:,None]
        Z=np.cross(X,T)
        rr=1+fold*np.cos(a[None,:]*5+np.arange(len(C))[:,None]*.7)
        g=C[:,None]+X[:,None]*(radii[:,0,None]*np.cos(a)[None,:]*rr)[...,None]+Z[:,None]*(radii[:,1,None]*np.sin(a)[None,:]*rr)[...,None]
        pc=grid(fit,name,role,g,bone,thick,C.mean(0))
        if not bone: fit.bind(pc,allow=('UpperArm','LowerArm','Hand'))
        return pc,g
    
    
    def hairstyle(fit):
        ch=H.head_chart(fit)
        # Short nape and exposed right temple; an offset crown sweeps left.
        cap=H.cap('reed_crop_foundation',ch,lambda u:float(np.interp(u,[-180,-125,-85,-55,0,40,75,110,180],[125,112,94,68,54,66,88,113,125])),lift=.009,crown=.006)
        out=[cap]
        # Large clumps define the silhouette; finer locks only break their tips.
        paths=[
          ('forelock',[('uv',42,29,.014),('uv',20,38,.033),('uv',-14,56,.033),('uv',-37,80,.022),('uv',-51,99,.010)],.063,.013),
          ('crown',[('uv',65,22,.012),('uv',6,20,.034),('uv',-55,38,.028),('uv',-82,74,.018),('uv',-94,103,.012)],.064,.015),
          ('wave',[('uv',62,39,.012),('uv',26,52,.031),('uv',-1,72,.026),('uv',-21,89,.016)],.039,.011),
          ('temple',[('uv',-63,54,.017),('uv',-72,83,.022),('uv',-72,113,.012)],.030,.009),
          ('split',[('uv',25,32,.030),('uv',-3,51,.041),('uv',-29,76,.033),('uv',-38,87,.025)],.020,.007),
          ('right',[('uv',70,48,.009),('uv',80,74,.010),('uv',88,101,.008)],.027,.006),
        ]
        for nm,path,w,t in paths:
            out.append(H.lock('reed_crop_'+nm,ch,path,w,thick=t,n=36,seg=12,profile=lambda t:H.clump(t,.46,.5)))
        for k,u in enumerate([108,132,156,180,204,228,252]):
            out.append(H.lock('reed_nape_'+str(k),ch,[('uv',u,30,.010),('uv',u-12,67,.018),('uv',u-17,103,.015),('uv',u-20,126,.006)],.044,thick=.009,n=28,seg=10,taper=(.65,1)))
        # One loose hooked strand, part of the designed sweep, not the sample bob.
        out.append(H.lock('reed_tip',ch,[('uv',-10,28,.031),('uv',-54,35,.047),('uv',-86,62,.029)],.017,thick=.006,n=24))
        for pc in out: fit.bind(pc,rigid='J_Bip_C_Head')
        return out
    
    
    def costume(fit):
        B=fit.bone; hip=B['J_Bip_C_Hips']; neck=B['J_Bip_C_Neck']; h=hip[1]
        out=hairstyle(fit)
        # The body is reshaped in the build. Only the close underlayers use body offsets.
        trousers=O.wrap(fit,'reed_trousers','trouser',('Hips','UpperLeg','LowerLeg'),offset=.011,y_max=h+.03,subdiv=1)
        gloves=O.wrap(fit,'reed_gloves','glove',('Hand','Thumb','Index','Middle','Ring','Little'),offset=.003,min_w=.3,smooth=4)
        out.extend([trousers,gloves]);trousers['group']='trousers';gloves['group']='gloves'
        # Authored body of the coat: broad chest plane, pinched belt, high shoulder yoke.
        ys=np.array([h-.06,h+.06,h+.20,h+.35,neck[1]-.115,neck[1]-.035])
        widths=np.array([.185,.157,.174,.203,.207,.082])
        depths=np.array([.128,.120,.143,.155,.120,.069])
        cy=np.linspace(ys[0],ys[-1],32);rw=PchipInterpolator(ys,widths)(cy);rd=PchipInterpolator(ys,depths)(cy)
        U=np.linspace(-np.pi,np.pi,81)
        gg=np.empty((len(cy),len(U),3))
        gg[:,:,0]=rw[:,None]*np.sign(np.sin(U))*np.abs(np.sin(U))**.82
        gg[:,:,1]=cy[:,None]
        gg[:,:,2]=-.020-rd[:,None]*np.sign(np.cos(U))*np.abs(np.cos(U))**.75
        bodice=grid(fit,'reed_coat_body','signature',gg,centre=[0,h+.25,0]);out.append(bodice)
        # Three long panels, with cut-away fronts, distinct hem lengths and real lining.
        for k,(lo,hi,length) in enumerate([(-167,-20,.62),(16,163,.52),(157,203,.59)]):
            U=np.radians(np.linspace(lo,hi,35));T=np.linspace(0,1,28)
            g=np.zeros((len(T),len(U),3))
            for i,t in enumerate(T):
                a=U+(.10*np.sin(U))*t
                flare=t**1.25
                w=.179+.125*flare;d=.128+.070*flare
                folds=.010*np.sin(5*U+.4)*t**.8+.005*np.sin(10*U)*t
                g[i,:,0]=(w+folds)*np.sin(a)-.025*t*t
                g[i,:,1]=h+.01-length*t+.032*np.cos(U*2)*t*t
                g[i,:,2]=-.02-(d+folds)*np.cos(a)+.055*t*t
            pc=grid(fit,'reed_tail_'+str(k),'signature',g,bone='J_Bip_C_Hips',thick=.004,centre=[0,h-.2,0]);out.append(pc)
            # Separate inner lining with opposite normals, inset from the outer fabric.
            p,t=O.grid_mesh(g);nn=vertex_normals(p,t)
            radial=p-np.array([0,h-.2,0]);radial[:,1]=0
            if np.mean((nn*radial).sum(1))<0:nn=-nn;t=t[:,::-1]
            lin=O.piece('reed_lining_'+str(k),'lining',p-nn*.0045,t[:,::-1],nrm=-nn)
            fit.bind(lin,rigid='J_Bip_C_Hips');lin['group']='coat';out.append(lin)
            for j,line in enumerate([g[-1],g[:,0],g[:,-1]]):edge(out,pc,f'reed_tail_binding_{k}_{j}',line,r=.0035)
            # A long seam gives the broad panel a deliberate cut.
            edge(out,pc,f'reed_tail_seam_{k}',g[:,len(U)//2],role='seam',r=.0013)
        # Tailored sleeves with elbow compression; no spherical puff sleeve modifier.
        for s in 'LR':
            a,b,c=[B[f'J_Bip_{s}_{j}'] for j in ['UpperArm','LowerArm','Hand']]
            t=np.linspace(0,1,30)
            C=np.array([a+(b-a)*v*2 if v<.5 else b+(c-b)*(v-.5)*2 for v in t])
            rad=np.interp(t,[0,.12,.35,.48,.56,.72,1],[.083,.078,.065,.064,.057,.052,.039])
            rad+=.004*np.sin(t*45)*np.exp(-((t-.53)/.13)**2)
            pc,g=rings(fit,'reed_sleeve_'+s,'sleeve',C,np.c_[rad,rad*.93],thick=.002,fold=.035)
            out.append(pc);edge(out,pc,'sleeve_seam_'+s,g[:,9],role='seam',r=.0016)
            # Broad dark leather bracer with a contrasting inlaid ridge.
            C=np.array([b+(c-b)*v for v in np.linspace(.40,.96,10)])
            rad=np.linspace(.060,.043,len(C))
            br,g=rings(fit,'reed_bracer_'+s,'leather',C,np.c_[rad,rad*.94],bone=f'J_Bip_{s}_LowerArm',thick=.004)
            br['group']='bracers';out.append(br)
            for j,line in enumerate([g[0],g[-1]]):edge(out,br,f'bracer_binding_{s}_{j}',line,'darkmetal',.003)
        # Raised folded neck scarf, with a short diagonal tab tucked under the harness.
        collar,rim,_=O.collar(fit,'reed_storm_collar','sleeve',height_back=.065,height_front=.045,gap_deg=29,offset=.014)
        out.append(collar);edge(out,collar,'collar_binding',rim,'lining',.0028)
        # Forged cuirass: explicit lofted cross-sections, no breast fitting or ray wrapping.
        ys=np.array([h+.09,h+.18,h+.36,neck[1]-.13,neck[1]-.09])
        ws=[.143,.164,.193,.172,.112];ds=[.148,.171,.192,.171,.134]
        Y=np.linspace(ys[0],ys[-1],18);W=PchipInterpolator(ys,ws)(Y);D=PchipInterpolator(ys,ds)(Y)
        U=np.linspace(-1.28,1.28,23)
        g=np.zeros((len(Y),len(U),3))
        for i,y in enumerate(Y):
            g[i,:,0]=W[i]*np.sin(U)
            g[i,:,1]=y+.022*np.cos(U*1.2)*(1-i/(len(Y)-1))
            # A single raised central ridge across a continuous front, not two cups.
            g[i,:,2]=-.025-D[i]*(.48+.52*np.cos(U))-.006*(1-np.abs(U)/1.28)
        cuirass=grid(fit,'reed_cuirass','darkmetal',g,bone='J_Bip_C_Chest',thick=.007,centre=[0,h+.3,0]);out.append(cuirass)
        for j,line in enumerate([g[0],g[-1],g[:,0],g[:,-1]]):edge(out,cuirass,'cuirass_roll_'+str(j),line,'steel',.003)
        edge(out,cuirass,'cuirass_keel',g[:,len(U)//2],'steel',.0019)
        # Small pale river gate device at the upper centre. Three reeds, restrained and legible.
        y=h+.39; z=float(np.interp(y,Y,g[:,len(U)//2,2]))-.004
        for k in [-1,0,1]:
            line=np.array([[k*.011,y-.028,z],[k*.011,y+.015,z],[k*.011+(0 if k==0 else k*.008),y+.029,z]])
            edge(out,cuirass,'gate_reed_'+str(k),line,'gold',.0018)
        # Articulated left shoulder, designed as three angular overlapping leaves.
        a=B['J_Bip_L_UpperArm']
        for k in range(3):
            U=np.linspace(-1.5,1.5,27);T=np.linspace(0,1,8)
            g=np.zeros((len(T),len(U),3))
            for i,t in enumerate(T):
                g[i,:,0]=a[0]-.010-(.075+k*.033+t*.042)*np.cos(U)
                g[i,:,1]=a[1]+.057-k*.041-t*.039+.017*np.cos(U)
                g[i,:,2]=a[2]+(.105+.007*k)*np.sin(U)
            pc=grid(fit,'reed_shoulder_leaf_'+str(k),'steel',g,bone='J_Bip_L_UpperArm',thick=.006,centre=a);out.append(pc)
            edge(out,pc,'shoulder_roll_'+str(k),g[-1],'darkmetal',.0035)
            for x in [2,-3]:
                riv=O.ball('shoulder_rivet_'+str(k)+'_'+str(x),'gold',g[-2,x],.0038)
                out.append(O.inherit(riv,pc))
        # A diagonal leather baldric crosses the shell and secures the shoulder.
        path=np.array([[-.12,neck[1]-.095,-.161],[-.10,h+.40,-.220],[.012,h+.28,-.227],[.135,h+.11,-.181]])
        path=H._smooth_path(path,36)
        strap=O.ribbon('reed_harness','leather',path,width=.034,normals=np.tile([0,0,-1.],(len(path),1)),lift=.005)
        fit.bind(strap,allow=('Chest','Spine','Hips'));strap['group']='harness';out.append(strap)
        for dx in [-.012,.012]:edge(out,strap,'harness_stitch_'+str(dx),path+[dx,0,-.006],'binding',.001)
        # A proper belt and two small asymmetrical hip pouches.
        U=np.linspace(-np.pi,np.pi,80);T=np.linspace(0,1,4)
        g=np.array([np.c_[.191*np.sin(U),np.full(len(U),h+.065-.044*t),-.02-.145*np.cos(U)] for t in T])
        belt=grid(fit,'reed_belt','leather',g,bone='J_Bip_C_Hips',centre=hip);out.append(belt)
        buckle=O.box('reed_buckle','gold',[.04,h+.044,-.172],np.eye(3),[.027,.024,.006]);out.append(fit.bind(buckle,rigid='J_Bip_C_Hips'))
        inset=O.box('buckle_inset','leather',[.04,h+.044,-.179],np.eye(3),[.019,.015,.002]);out.append(fit.bind(inset,rigid='J_Bip_C_Hips'))
        for k,(x,y,z) in enumerate([(-.195,h-.045,-.06),(.186,h-.055,.045)]):
            pc=O.box('reed_pouch_'+str(k),'leather',[x,y,z],np.eye(3),[.043,.063,.040]);out.append(fit.bind(pc,rigid='J_Bip_C_Hips'))
            flap=O.box('pouch_flap_'+str(k),'binding',[x,y+.045,z-.043],np.eye(3),[.044,.018,.004]);out.append(fit.bind(flap,rigid='J_Bip_C_Hips'))
        # New boots: shaped shafts, angular toes, separate thick soles and straps.
        for s in 'LR':
            knee,foot=[B[f'J_Bip_{s}_{j}'] for j in ['LowerLeg','Foot']]
            T=np.linspace(0,1,20);C=foot[None]+(knee-foot)[None]*T[:,None]*.85
            rad=np.interp(T,[0,.25,.65,1],[.052,.055,.073,.067]);pc,g=rings(fit,'reed_bootshaft_'+s,'boot',C,np.c_[rad,rad*.91],bone=f'J_Bip_{s}_LowerLeg',thick=.003,fold=.012)
            pc['group']='boots';out.append(pc)
            edge(out,pc,'boot_top_'+s,g[-1],'binding',.003)
            # Rounded-square toe and low heel, rather than a wrapped stocking foot.
            y0=.026;zz=np.array([.082,.050,-.045,-.170,-.200])+foot[2]
            widths=[.040,.050,.059,.053,.038];heights=[.058,.095,.092,.050,.032]
            U=np.linspace(0,2*np.pi,33);C=[]
            for z,w,hh in zip(zz,widths,heights):
                C.append(np.c_[foot[0]+w*np.sign(np.cos(U))*np.abs(np.cos(U))**.65,y0+hh*(.5+.5*np.sin(U)),np.full(len(U),z)])
            pc=grid(fit,'reed_shoe_'+s,'boot',np.array(C),bone=f'J_Bip_{s}_Foot',thick=.004,centre=foot);pc['group']='boots';out.append(pc)
            for dz in [-.10,-.045]:
                c=np.array([[foot[0]-.052,.069,foot[2]+dz],[foot[0]-.025,.098,foot[2]+dz],[foot[0]+.025,.098,foot[2]+dz],[foot[0]+.052,.069,foot[2]+dz]])
                edge(out,pc,'boot_strap_'+s+str(dz),c,'leather',.007)
            # Sole perimeter, an original rounded rectangle.
            u=np.linspace(0,2*np.pi,65)
            per=np.c_[foot[0]+.060*np.sign(np.sin(u))*np.abs(np.sin(u))**.55,np.full(len(u),.027),foot[2]-.060+.151*np.sign(np.cos(u))*np.abs(np.cos(u))**.6]
            sole,g2=rings(fit,'unused','boot',np.array([[0,0,0],[0,1,0]]),np.array([[1,1],[1,1]]),bone=f'J_Bip_{s}_Foot') if False else (None,None)
            sg=np.stack([per,per+[0,-.020,0]])
            pc=grid(fit,'reed_sole_'+s,'sole',sg,bone=f'J_Bip_{s}_Foot',centre=foot,thick=.003);pc['group']='boots';out.append(pc)
        # Bespoke reed spear: a narrow leaf with one hooked pruning spur and socket bands.
        fist,fwd,side,flat,_=G._hand_frame(fit,'R');start=fist-fwd*.93;tip=start+fwd*1.94
        weapon=[O.tube('reed_ashshaft','wood',start,fwd,1.94,.012,.010)]
        leaf=[(0,0),(.025,.035),(.040,.11),(.014,.28),(0,.36),(-.012,.245),(-.023,.10),(-.020,.035)]
        weapon.append(G.flat_piece('reed_spearblade','steel',leaf,tip,side,fwd,thickness=.008))
        spur=[(-.012,-.014),(-.064,.016),(-.087,.067),(-.070,.045),(-.030,.034),(0,.055)]
        weapon.append(G.flat_piece('reed_hook','darkmetal',spur,tip,side,fwd,thickness=.007))
        for k in range(3):weapon.append(O.tube('reed_socket_band_'+str(k),'gold',tip-fwd*(.015+k*.029),fwd,.012,.016))
        weapon.append(O.tube('reed_ferrule','steel',start,fwd,.10,.016,.013))
        for k in range(13):weapon.append(O.tube('reed_grip_wrap_'+str(k),'leather',fist+fwd*(k*.014-.09),fwd,.008,.014))
        for pc in weapon:fit.bind(pc,rigid='J_Bip_R_Hand');pc['group']='weapon'
        out+=weapon
        return out
    PY

    result, 4 lines

    Script completed
    Wall time 0.1 seconds
    Output:
    {"chunk_id":"302327","wall_time_seconds":0.00000416,"exit_code":0,"original_token_count":0,"output":""}

agent

+23:38

The new design now has its own geometry: swept hair clumps, a long split coat, a single-ridge cuirass, overlapping shoulder leaves, fitted sleeves, shaped boots and a hooked reed spear. The body changes lengthen the legs slightly and reduce the bulk through the chest and arms; the armour supplies the stronger upper silhouette.

I’m moving into rendered checks now. That is where I’ll judge whether these shapes actually work together and correct the fit, rather than treating the generated meshes as finished.

  • exec_commandrg -n '^def collar' tools/outfit.py; cp review/astra/prepare.py review/astra-finish/prepare.py; cp review/astra/capture.js review/astra-finish/capture.js; cp review/astra/shoot.cjs review/astra-finish/shoot.cjs; python3 - <<'PY'

    command

    rg -n '^def collar' tools/outfit.py; cp review/astra/prepare.py review/astra-finish/prepare.py; cp review/astra/capture.js review/astra-finish/capture.js; cp review/astra/shoot.cjs review/astra-finish/shoot.cjs; python3 - <<'PY'
    from pathlib import Path
    for name in ['prepare.py','shoot.cjs']:
     p=Path('review/astra-finish')/name;s=p.read_text().replace('review/out/astra','review/out/astra-finish').replace("review/astra/capture.js","review/astra-finish/capture.js")
     p.write_text(s)
    s=Path('review/astra/build.py').read_text();s=s[:s.index('def warden')]+s[s.index('def main'):];s=s.replace("'review/out/astra/site'","'review/out/astra-finish/site'")
    s=s.replace('def main():','from design import costume\n\ndef main():')
    s=s.replace("shape=dict(CAST[body]['shape'], rest={'Fcl_BRW_Angry':0.20,'Fcl_EYE_Close':0.08}, arm_out=4)","shape=dict(CAST[body]['shape'], head=.96, neck=.97, chest=.92, torso=.97, arms=.92, legs=.97, leg_len=1.045, hands=.97, shoulders=1.05, eye=.96, iris=.94, jaw=.002, nose=.002, rest={'Fcl_BRW_Angry':.28,'Fcl_EYE_Close':.10}, arm_out=4)")
    s=s.replace("'J_Bip_C_Head':P.rot((0,1,0),12)","'J_Bip_C_Head':P.rot((0,1,0),8)@P.rot((1,0,0),-3)")
    s=s.replace('costume=warden)','costume=costume,hair_trim=-1)')
    a=s.index('    portrait.paint=');b=s.index('    clips=',a)
    s=s[:a]+'''    portrait.paint=dict(signature='#23585b',sleeve='#b4b59c',lining='#c4b68a',binding='#ad985e',seam='#163f41',
            darkmetal=dict(kind='steel',base='#4c6267'),trouser='#424a45',sole='#272f2e',
            doublet='#303e42',heraldry='#b7ad83',steel='#8eadaf',gold='#bd9957',metal='#8eadaf',leather='#644332',
            boot='#354441',glove='#543d32',hair='#8f4025',skin='#e1b394',wood=dict(kind='leather',base='#544237'),
            grain=dict(signature=.02,sleeve=.02,lining=.015))
        pal=dict({**vp.PALETTE,**CAST[body]['colors']},A='#322421',B='#542c23',C='#8f4025',D='#ad5932',E='#d18c59',
                 M='#23585b',S='#424a45',N='#c4b68a',v='#354441',x='#543d32',H='#bd9957',
                 r='#273b35',s='#72816a',t='#c3bd86')
    ''' +s[b:]
    s=s.replace("clips={'idle':[(0,pose),(1,pose)],'watch':[(0,pose),(1,pose)],'apose':[(0,P.BUST),(1,P.BUST)]}","""breath=P.merge(pose,{'J_Bip_C_Chest':P.rot((0,1,0),-4)@P.rot((1,0,0),-.6), 'J_Bip_C_Head':P.rot((0,1,0),10)@P.rot((1,0,0),-2)})
        look=P.merge(pose,{'J_Bip_C_Head':P.rot((0,1,0),-18)@P.rot((1,0,0),-1)})
        clips={'idle':[(0,pose),(1.8,breath),(3.6,pose)],'watch':[(0,pose),(1,pose)],'look':[(0,pose),(1.2,look),(2.4,look),(3.6,pose)],'apose':[(0,P.BUST),(1,P.BUST)]}""")
    s=s.replace('    from stage import causeway','    sys.path.insert(0,str(ROOT/"review/astra"))\n    from stage import causeway')
    s=s.replace("'Border warden'","'Reedwatch warden'")
    Path('review/astra-finish/build.py').write_text(s)
    PY
    OPENBLAS_NUM_THREADS=1 python3 review/astra-finish/build.py

    result, 4 lines

    Script completed
    Wall time 1.2 seconds
    Output:
    {"chunk_id":"ae02b7","wall_time_seconds":1.001854513,"session_id":1942,"original_token_count":27,"output":"328:def collar(fit, name, role, height_back=0.044, height_front=0.028, gap_deg=50, clear=(0.009, 0.015),\n"}
  • exec_command, write_stdin, clock__curr_timesed -n '328,335p' tools/outfit.py; sed -n '1,45p' review/astra-finish/build.py; cat review/astra-finish/timing.json (+2 more)

    input

    text(await tools.exec_command({cmd:"sed -n '328,335p' tools/outfit.py; sed -n '1,45p' review/astra-finish/build.py; cat review/astra-finish/timing.json","max_output_tokens":1000}));
    text(await tools.write_stdin({session_id:1942,chars:"","yield_time_ms":1000,"max_output_tokens":2000}));
    text(await tools.clock__curr_time({}));
    

    result, 4 lines

    Script completed
    Wall time 1.4 seconds
    Output:
    {"chunk_id":"5c7916","wall_time_seconds":0.0000043,"exit_code":0,"original_token_count":603,"output":"def collar(fit, name, role, height_back=0.044, height_front=0.028, gap_deg=50, clear=(0.009, 0.015),\n           thickness=0.0035, seg=40, rows=6):\n    \"\"\"A standing collar fitted to the neck: radius from ray casts to the neck skin plus clearance\n    (flaring toward the top), taller at the back, base lower at the front (the jugular notch).\"\"\"\n    nk = fit.bone[\"J_Bip_C_Neck\"]\n    half = math.radians(180 - gap_deg / 2)\n    ang = np.linspace(-half, half, seg)                     # 0 = back (+z), +-pi = front (-z)\n    neck = Surface(fit.pos, fit.tris_for((\"Neck\", \"UpperChest\", \"Head\", \"Shoulder\"), min_w=0.3))\n\"\"\"One isolated costume study. Reads the cached body, never rebuilds shared data.\nRun: OPENBLAS_NUM_THREADS=1 python3 review/astra/build.py\n\"\"\"\nfrom pathlib import Path\nimport base64\nimport json\nimport sys\nimport time\n\nROOT = Path(__file__).resolve().parents[2]\nsys.path[:0] = [str(ROOT / 'tools'), str(ROOT / 'art/cast')]\nimport numpy as np\nimport cage\nfrom cast import CAST\nimport vroid_portrait as vp\nimport export_glb as E\nimport outfit as O\nimport gear as G\nimport mobs\nimport poses as P\nfrom fitting import Surface, merge_surfaces\nfrom rig import Rig, grip_points\nfrom vrm import VRM, bone_weight\nfrom fitting import vertex_normals\n\nOUT = ROOT / 'review/out/astra-finish/site'\nOUT.mkdir(parents=True, exist_ok=True)\n\n\nfrom design import costume\n\ndef main():\n    start=time.perf_counter()\n    body='arm_f_strong'\n    path=Path(cage.path_for(body,CAST[body]['cage']))\n    if not path.is_file(): raise SystemExit('Cached body missing; this study will not rebuild data.')\n    shape=dict(CAST[body]['shape'], head=.96, neck=.97, chest=.92, torso=.97, arms=.92, legs=.97, leg_len=1.045, hands=.97, shoulders=1.05, eye=.96, iris=.94, jaw=.002, nose=.002, rest={'Fcl_BRW_Angry':.28,'Fcl_EYE_Close':.10}, arm_out=4)\n    v=VRM(str(path)); rig=Rig(v,shape,ortho=True)\n    pose=P.merge(P.BUST,P.fist('R'),P.fist('L',curl=(18,25,18),thumb=10),{\n        'J_Bip_C_Hips':P.move(0,-0.018,0,r=P.rot((0,0,1),-2)),\n        'J_Bip_C_Chest':P.rot((0,1,0),-5),\n        'J_Bip_C_Head':P.rot((0,1,0),8)@P.rot((1,0,0),-3),\n        'J_Bip_L_UpperLeg':P.rot((0,0,1),-6)@P.rot((1,0,0),7),\n        'J_Bip_R_UpperLeg':P.rot((0,0,1),4)@P.rot((1,0,0),-5),\n    })\n{\"started\":\"2026-11-15T03:34:07Z\",\"steps\":[],\"note\":\"Wall time includes inspection, design, coding and render iterations; subprocess times logged separately.\"}\n"}{"chunk_id":"d50551","wall_time_seconds":1.250058881,"exit_code":1,"original_token_count":178,"output":"Traceback (most recent call last):\n  File \"~/work/lowmarch/review/astra-finish/build.py\", line 96, in <module>\n    if __name__=='__main__': main()\n  File \"~/work/lowmarch/review/astra-finish/build.py\", line 59, in main\n    portrait=vp.Portrait(str(path),shape=shape,pose=P.BUST,costume=costume,hair_trim=-1)\n  File \"~/work/lowmarch/tools/vroid_portrait.py\", line 996, in __init__\n    for pc in costume(fit):\n  File \"~/work/lowmarch/review/astra-finish/design.py\", line 120, in costume\n    collar,rim,_=O.collar(fit,'reed_storm_collar','sleeve',height_back=.065,height_front=.045,gap_deg=29,offset=.014)\nTypeError: collar() got an unexpected keyword argument 'offset'\n"}{"current_time":"2026-11-15 03:37:19 UTC"}
  • exec_commandpython3 - <<'PY' (+1 more)

    command

    python3 - <<'PY'
    p='review/astra-finish/design.py'
    s=open(p).read().replace('gap_deg=29,offset=.014','gap_deg=29,clear=(.014,.019)')
    open(p,'w').write(s)
    PY
    OPENBLAS_NUM_THREADS=1 python3 review/astra-finish/build.py
    
    python3 review/astra-finish/prepare.py

    result, 4 lines

    Script completed
    Wall time 1.4 seconds
    Output:
    {"chunk_id":"df802c","wall_time_seconds":1.00073524,"session_id":97113,"original_token_count":0,"output":""}{"chunk_id":"af9319","wall_time_seconds":0.059506245,"exit_code":0,"original_token_count":17,"output":"~/work/lowmarch/review/out/astra-finish/site/index.html\n"}
  • write_stdin, exec_commandpoll session 97113 (+1 more)

    input

    text(await tools.write_stdin({session_id:97113,chars:"","yield_time_ms":1000,"max_output_tokens":1000}));
    text(await tools.exec_command({cmd:"python3 review/astra-finish/patch_lens_flattice.py review/out/astra-finish/site","max_output_tokens":1000}));
    

    result, 4 lines

    Script completed
    Wall time 5.1 seconds
    Output:
    {"chunk_id":"1f5c01","wall_time_seconds":5.001225354,"session_id":97113,"original_token_count":0,"output":""}{"chunk_id":"dfc61b","wall_time_seconds":0.00000383,"exit_code":0,"original_token_count":12,"output":"patched review/out/astra-finish/site/index.html\n"}
  • exec_command, write_stdinpython3 - <<'PY' (+1 more)

    input

    text(await tools.exec_command({cmd:"python3 - <<'PY'\np='review/astra-finish/capture.js'\ns=open(p).read().replace(\"holdPose(options.pose || 'watch',0);\",\"holdPose(options.pose || 'watch',options.time || 0);\")\ns=s.replace('    render();','    lensAndFlat({lens:options.lens || 0, flat:options.flat || 0, whole:options.whole || false},centre,options.span || 2.72,w,h,options.pitch ?? 4);\\n    render();')\nopen(p,'w').write(s)\np='review/astra-finish/prepare.py';s=open(p).read()+\"\\nimport subprocess\\nsubprocess.run(['python3',str(ROOT/'review/astra-finish/patch_lens_flattice.py'),str(OUT)],check=True)\\n\";open(p,'w').write(s)\nPY\npython3 review/astra-finish/prepare.py","max_output_tokens":1000}));
    text(await tools.write_stdin({session_id:97113,chars:"","yield_time_ms":1000,"max_output_tokens":1000}));
    

    result, 4 lines

    Script completed
    Wall time 0.3 seconds
    Output:
    {"chunk_id":"bd1553","wall_time_seconds":0.133246311,"exit_code":0,"original_token_count":36,"output":"patched ~/work/lowmarch/review/out/astra-finish/site/index.html\n~/work/lowmarch/review/out/astra-finish/site/index.html\n"}{"chunk_id":"fd5363","wall_time_seconds":0.00000293,"exit_code":0,"original_token_count":43,"output":"{\"build_seconds\": 17.627, \"body\": \"~/.local/share/lowmarch/vroid/lowmarch_bodies/cage/arm_f_strong_4ad9ea3b57cd9a77.vrm\", \"glb_bytes\": 4631744, \"pieces\": 524}\n"}
  • exec_commandNODE_PATH=~/context/sortie-node_modules node review/astra-finish/shoot.cjs '{"background":true}' blockout.png

    command

    NODE_PATH=~/context/sortie-node_modules node review/astra-finish/shoot.cjs '{"background":true}' blockout.png

    result, 4 lines

    Script completed
    Wall time 1.2 seconds
    Output:
    {"chunk_id":"4f5e99","wall_time_seconds":1.00221209,"session_id":86663,"original_token_count":0,"output":""}
  • exec_command, write_stdinsed -n '396,462p' tools/export_glb.py; cat review/astra/check.py (+1 more)

    input

    text(await tools.exec_command({cmd:"sed -n '396,462p' tools/export_glb.py; cat review/astra/check.py","max_output_tokens":2400}));
    text(await tools.write_stdin({session_id:86663,chars:"","yield_time_ms":1000,"max_output_tokens":1500}));
    

    result, 4 lines

    Script completed
    Wall time 5.2 seconds
    Output:
    {"chunk_id":"5dbe2f","wall_time_seconds":0.00000519,"exit_code":0,"original_token_count":1078,"output":"        i = names[nm]\n        while i is not None and i not in joints:\n            joints.add(i)\n            i = parent.get(i)\n    order = sorted(joints)\n    jidx = {nodes_v[i].get(\"name\"): k for k, i in enumerate(order)}\n    ref = portrait.pose_ref\n    local_ref = {i: F4 @ v.local_matrix(i, ref) @ F4 for i in order}\n    world_ref = {}\n\n    def wref(i):\n        if i not in world_ref:\n            world_ref[i] = (wref(parent[i]) @ local_ref[i]) if parent.get(i) in joints else local_ref[i]\n        return world_ref[i]\n\n    # glTF assembly (reuses the static exporter's buffer helpers by building a fresh document)\n    bin_ = bytearray()\n    views, accessors, meshes, gnodes, materials, textures, images, anims = [], [], [], [], [], [], [], []\n    tex_index = {}\n\n    def add_view(data, target=None):\n        while len(bin_) % 4:\n            bin_.append(0)\n        off = len(bin_)\n        bin_.extend(data)\n        vw = dict(buffer=0, byteOffset=off, byteLength=len(data))\n        if target:\n            vw[\"target\"] = target\n        views.append(vw)\n        return len(views) - 1\n\n    def add_acc(arr, kind, comp, target=None, minmax=False):\n        arr = np.ascontiguousarray(arr)\n        a = dict(bufferView=add_view(arr.tobytes(), target), componentType=comp, count=int(arr.shape[0]), type=kind)\n        if minmax or (kind == \"VEC3\" and comp == 5126):\n            a[\"min\"] = np.atleast_1d(arr.min(0)).tolist()\n            a[\"max\"] = np.atleast_1d(arr.max(0)).tolist()\n        accessors.append(a)\n        return len(accessors) - 1\n\n    def add_texture(key, rgba, limit=None):\n        if key in tex_index:\n            return tex_index[key]\n        im = Image.fromarray(rgba)\n        lim = limit or max_tex\n        if max(im.size) > lim:\n            k = lim / max(im.size)\n            im = im.resize((max(1, int(im.width * k)), max(1, int(im.height * k))), Image.LANCZOS)\n        b = io.BytesIO()\n        im.save(b, \"PNG\", optimize=True)\n        images.append(dict(bufferView=add_view(b.getvalue()), mimeType=\"image/png\"))\n        textures.append(dict(source=len(images) - 1, sampler=0))\n        tex_index[key] = len(textures) - 1\n        return tex_index[key]\n\n    # joint nodes\n    node_of = {}\n    for i in order:\n        t, q, sc = _trs(local_ref[i])\n        node_of[i] = len(gnodes)\n        gnodes.append(dict(name=nodes_v[i].get(\"name\"), translation=t.tolist(), rotation=q.tolist(), scale=sc.tolist()))\n    for i in order:\n        kids = [node_of[c] for c in nodes_v[i].get(\"children\", []) if c in joints]\n        if kids:\n            gnodes[node_of[i]][\"children\"] = kids\n    roots = [node_of[i] for i in order if parent.get(i) not in joints]\n    ibm = np.stack([np.linalg.inv(wref(i)).T for i in order]).astype(np.float32)   # column-major\n\"\"\"Targeted checks for the single study pose; no cast rebuild or full test suite.\"\"\"\nfrom pathlib import Path\nimport json\nimport pickle\nimport sys\nimport numpy as np\nROOT=Path(__file__).resolve().parents[2]\nsys.path[:0]=[str(ROOT/'tools')]\nimport checks\nOUT=ROOT/'review/out/astra/site'\np=pickle.loads((OUT/'portrait.pkl').read_bytes())\npose={k:np.array(v) for k,v in json.loads((OUT/'pose.json').read_text()).items()}\nlimbs=[f'{s}_{part}' for s in 'LR' for part in ['UpperArm','LowerArm']]\nclear=checks.Body(p.v,p.shape).clearance(pose,limbs)\ngeometry=[]\nfor part in p.prims:\n    if not np.isfinite(part['pos']).all(): raise AssertionError(part['material']+' has non-finite positions')\n    if len(part['tri']) and (part['tri'].min()<0 or part['tri'].max()>=len(part['pos'])):\n        raise AssertionError(part['material']+' has invalid indices')\n    if 'W' in part and not np.allclose(part['W'].sum(1),1,atol=1e-4):\n        raise AssertionError(part['material']+' has unnormalised weights')\n    geometry.append({'name':part['material'],'vertices':len(part['pos']),'triangles':len(part['tri'])})\nresult={'arm_clearance_mm':{k:round(v*1000,2) for k,v in clear.items()},'finite_geometry':True,\n        'indices_valid':True,'weights_normalised':True,'pieces':len(geometry),\n        'scope':'One authored pose. Does not validate cloth motion, expressions or every view.'}\n(OUT/'checks.json').write_text(json.dumps(result,indent=2))\nprint(json.dumps(result,indent=2))\nif min(clear.values()) < -.005: raise SystemExit('Arm clearance below -5 mm: inspect the pose.')\n"}{"chunk_id":"456e68","wall_time_seconds":5.002673137,"session_id":86663,"original_token_count":0,"output":""}
  • clock__curr_time, write_stdinclock__curr_time (+1 more)

    input

    text(await tools.clock__curr_time({}));
    text(await tools.write_stdin({session_id:86663,chars:"","yield_time_ms":1000,"max_output_tokens":2500}));
    

    result, 4 lines

    Script completed
    Wall time 0.0 seconds
    Output:
    {"current_time":"2026-11-15 03:38:05 UTC"}{"chunk_id":"35f7e9","wall_time_seconds":0.00000292,"exit_code":0,"original_token_count":25,"output":"{\n  render_seconds: 12.289,\n  errors: [],\n  options: { background: true },\n  file: 'blockout.png'\n}\n"}
  • view_image~/work/lowmarch/review/out/astra-finish/blockout.png

    input

    image((await tools.view_image({path:"~/work/lowmarch/review/out/astra-finish/blockout.png"})).image_url);
    

    result, 4 lines

    Script completed
    Wall time 0.1 seconds
    Output:
    
    blockout.png
    blockout.png
  • exec_commandpython3 - <<'PY' (+1 more)

    command

    python3 - <<'PY'
    from pathlib import Path
    p=Path('review/astra-finish/design.py');s=p.read_text()
    s=s.replace("ys=np.array([h-.06,h+.06", "ys=np.array([h+.025,h+.06")
    s=s.replace('g[i,:,1]=h+.01-length*t','g[i,:,1]=h+.045-length*t')
    s=s.replace("-.025*t*t","-.065*t*t")
    s=s.replace("+.055*t*t","+.075*t*t")
    s=s.replace("C=np.array([a+(b-a)*v*2 if v<.5 else b+(c-b)*(v-.5)*2 for v in t])","C=PchipInterpolator([0,.13,.56,1],np.array([[a[0]*.60,neck[1]-.065,a[2]],a,b,c]),axis=0)(t)")
    s=s.replace("[0,.12,.35,.48,.56,.72,1],[.083,.078,.065,.064,.057,.052,.039]","[0,.13,.35,.50,.60,.76,1],[.063,.077,.067,.063,.058,.050,.039]")
    a=s.index('    collar,rim,_=O.collar');b=s.index('    # Forged cuirass',a)
    s=s[:a]+'''    collar,cg=rings(fit,'reed_storm_collar','sleeve',np.array([neck+[0,-.045,0],neck+[0,-.008,0],neck+[0,.025,0]]),np.array([[.090,.080],[.061,.058],[.065,.060]]),bone='J_Bip_C_Neck',thick=.004)
        out.append(collar);edge(out,collar,'collar_binding',cg[-1],'lining',.002)
    ''' +s[b:]
    s=s.replace("y0+hh*(.5+.5*np.sin(U))","y0+hh*np.maximum(0,np.sin(U))")
    s=s.replace("start=fist-fwd*.93;tip=start+fwd*1.94","start=fist-fwd*1.06;tip=start+fwd*2.06")
    s=s.replace("start,fwd,1.94,.012,.010","start,fwd,2.06,.012,.010")
    # no unused experimental branch
    s='\n'.join(l for l in s.split('\n') if "if False else" not in l)
    p.write_text(s)
    PY
    OPENBLAS_NUM_THREADS=1 python3 review/astra-finish/build.py
    
    python3 - <<'PY'
    import json,datetime
    p='review/astra-finish/timing.json';d=json.load(open(p));now=datetime.datetime.now(datetime.timezone.utc).isoformat();d['steps']=[{'label':'Inventory, design and first custom model','start':d['started'],'end':now}];open(p,'w').write(json.dumps(d,indent=2))
    PY

    result, 4 lines

    Script completed
    Wall time 1.3 seconds
    Output:
    {"chunk_id":"33ce91","wall_time_seconds":1.001166938,"session_id":88999,"original_token_count":0,"output":""}{"chunk_id":"80d3e2","wall_time_seconds":0.00000558,"exit_code":0,"original_token_count":0,"output":""}