Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(forge): give every seed mesh gate refusal guidance a creator can act on

nirholasf31b0aa2f220
diff --git a/api/_lib/seed-mesh-gate.js b/api/_lib/seed-mesh-gate.js
index 66bae16fc..45cb04d33 100644
--- a/api/_lib/seed-mesh-gate.js
+++ b/api/_lib/seed-mesh-gate.js
@@ -115,8 +115,22 @@ export function gateMesh(buf, { category = 'avatar' } = {}) {
// cannot drift from the rule it describes, and so a reason code can never ship
// without an explanation (tests/seed-mesh-gate.test.js asserts exactly that).
-/** Every reason code gateMesh can emit, with the guidance a creator needs. */
+/**
+ * Every reason code gateMesh can emit, with the guidance a creator needs, plus
+ * the two range checks (`vertex_count`, `file_weight`) that stand in when
+ * neither end of a bound was breached.
+ */
export const MESH_GATE_RULES = Object.freeze({
+ vertex_count: {
+ label: 'Geometry density',
+ why: 'Dense enough to read as a real object, without so much geometry that the viewer stalls on a phone.',
+ fix: 'Nothing to do. This model sits inside the range the catalog accepts.',
+ },
+ file_weight: {
+ label: 'File weight',
+ why: 'Heavy enough to be a real textured asset, light enough to load before a visitor gives up.',
+ fix: 'Nothing to do. This model sits inside the range the catalog accepts.',
+ },
not_valid_glb: {
label: 'Readable glTF 2.0',
why: 'The file is not a binary glTF. Nothing downstream can open it, so no other check can even run.',
@@ -166,6 +180,18 @@ export const MESH_GATE_RULES = Object.freeze({
const fmtInt = (n) => Number(n || 0).toLocaleString('en-US');
+// The bounding-box diagonal is in the model's own units, and submissions arrive
+// in metres, centimetres and arbitrary scales alike. A raw `88387.306` is noise:
+// the only thing this check asks is whether the box has any extent at all, so
+// the number is reported at a precision that reads, without implying a unit.
+function fmtExtent(n) {
+ const d = Number(n || 0);
+ if (!(d > 0)) return 'collapsed to a point';
+ if (d >= 1000) return `${fmtInt(Math.round(d))} units across`;
+ if (d >= 1) return `${d.toFixed(2)} units across`;
+ return `${d.toFixed(3)} units across`;
+}
+
function fmtBytes(n) {
const b = Number(n || 0);
if (b >= 1024 * 1024) return `${(b / 1024 / 1024).toFixed(1)} MB`;
@@ -205,35 +231,34 @@ export function explainMeshGate(verdict, { category = 'avatar' } = {}) {
};
}
+ // Vertex count and file size each have a floor AND a ceiling, but they are one
+ // measurement and one concept apiece. Rendering them as two rows showing the
+ // identical number is noise, so the pair collapses into a single check that
+ // reports the range and adopts whichever end was breached.
+ const range = (id, lowId, highId, actual, low, high) => {
+ const breached = failed.has(lowId) ? lowId : failed.has(highId) ? highId : null;
+ return {
+ id: breached || id,
+ status: breached ? 'fail' : 'pass',
+ actual,
+ bound: breached === lowId ? `at least ${low}` : breached === highId ? `at most ${high}` : `${low} to ${high}`,
+ // A passing range check describes the range, not the floor's failure
+ // mode: "too coarse to read" is the wrong caption on a model that is
+ // neither too coarse nor too dense.
+ ...rule(breached || id),
+ };
+ };
+
const checks = [
- {
- id: 'vertices_below_floor',
- status: failed.has('vertices_below_floor') ? 'fail' : 'pass',
- actual: `${fmtInt(m.vertexCount)} vertices`,
- bound: `at least ${fmtInt(b.minVertices)}`,
- ...rule('vertices_below_floor'),
- },
- {
- id: 'vertices_above_ceiling',
- status: failed.has('vertices_above_ceiling') ? 'fail' : 'pass',
- actual: `${fmtInt(m.vertexCount)} vertices`,
- bound: `at most ${fmtInt(b.maxVertices)}`,
- ...rule('vertices_above_ceiling'),
- },
- {
- id: 'file_too_small',
- status: failed.has('file_too_small') ? 'fail' : 'pass',
- actual: fmtBytes(m.sizeBytes),
- bound: `at least ${fmtBytes(b.minBytes)}`,
- ...rule('file_too_small'),
- },
- {
- id: 'file_too_large',
- status: failed.has('file_too_large') ? 'fail' : 'pass',
- actual: fmtBytes(m.sizeBytes),
- bound: `at most ${fmtBytes(b.maxBytes)}`,
- ...rule('file_too_large'),
- },
+ range(
+ 'vertex_count',
+ 'vertices_below_floor',
+ 'vertices_above_ceiling',
+ `${fmtInt(m.vertexCount)} vertices`,
+ fmtInt(b.minVertices),
+ fmtInt(b.maxVertices),
+ ),
+ range('file_weight', 'file_too_small', 'file_too_large', fmtBytes(m.sizeBytes), fmtBytes(b.minBytes), fmtBytes(b.maxBytes)),
{
id: 'no_textures',
status: !b.requireTexture ? 'skipped' : failed.has('no_textures') ? 'fail' : 'pass',
@@ -244,8 +269,8 @@ export function explainMeshGate(verdict, { category = 'avatar' } = {}) {
{
id: 'zero_volume',
status: failed.has('zero_volume') ? 'fail' : 'pass',
- actual: `${Number(m.bboxDiagonal || 0).toFixed(3)} diagonal`,
- bound: 'greater than 0',
+ actual: fmtExtent(m.bboxDiagonal),
+ bound: 'must have extent',
...rule('zero_volume'),
},
{
diff --git a/tests/seed-mesh-gate.test.js b/tests/seed-mesh-gate.test.js
index 4c73764fb..5cfa20657 100644
--- a/tests/seed-mesh-gate.test.js
+++ b/tests/seed-mesh-gate.test.js
@@ -196,9 +196,27 @@ describe('explainMeshGate', () => {
const report = explainMeshGate(gateMesh(healthy({ verts: 12_000 }), { category: 'avatar' }), { category: 'avatar' });
expect(report.pass).toBe(true);
expect(report.headline).toBe('Clears the catalog bar');
- const density = report.checks.find((c) => c.id === 'vertices_below_floor');
+ const density = report.checks.find((c) => c.id === 'vertex_count');
expect(density.actual).toBe('12,000 vertices');
- expect(density.bound).toBe(`at least ${SEED_MESH_BOUNDS.minVertices.toLocaleString('en-US')}`);
+ expect(density.bound).toBe(
+ `${SEED_MESH_BOUNDS.minVertices.toLocaleString('en-US')} to ${SEED_MESH_BOUNDS.maxVertices.toLocaleString('en-US')}`,
+ );
+ });
+
+ it('collapses a floor/ceiling pair into one row instead of two identical ones', () => {
+ // Vertex count is one measurement. Showing it twice (once against the floor,
+ // once against the ceiling) put the same number on screen twice.
+ const report = explainMeshGate(gateMesh(healthy(), { category: 'avatar' }), { category: 'avatar' });
+ const labels = report.checks.map((c) => c.label);
+ expect(new Set(labels).size, `duplicate rows: ${labels.join(', ')}`).toBe(labels.length);
+ });
+
+ it('adopts the breached end of a range, and only that end', () => {
+ const thin = explainMeshGate(gateMesh(healthy({ verts: 300 }), {}), {});
+ const row = thin.checks.find((c) => c.label === 'Geometry density');
+ expect(row.id).toBe('vertices_below_floor');
+ expect(row.status).toBe('fail');
+ expect(row.bound).toBe(`at least ${SEED_MESH_BOUNDS.minVertices.toLocaleString('en-US')}`);
});
it('stamps the gate version so a verdict is comparable only within one', () => {
@@ -245,9 +263,26 @@ describe('explainMeshGate', () => {
it('formats bytes and counts for a human, not in raw units', () => {
const report = explainMeshGate(gateMesh(healthy({}, { binBytes: 2_500_000 }), {}), {});
- const size = report.checks.find((c) => c.id === 'file_too_large');
+ const size = report.checks.find((c) => c.id === 'file_weight');
expect(size.actual).toMatch(/^2\.\d MB$/);
- expect(size.bound).toBe('at most 80.0 MB');
+ expect(size.bound).toBe('20 KB to 80.0 MB');
+ });
+
+ it('reports the bounding box at a precision that reads, without implying a unit', () => {
+ // Submissions arrive in metres and in centimetres, so a raw float like
+ // 88387.306 is noise on a check that only asks "does it have extent".
+ const big = explainMeshGate(gateMesh(healthy({ bbox: [-50_000, 50_000] }), {}), {});
+ expect(big.checks.find((c) => c.id === 'zero_volume').actual).toMatch(/^[\d,]+ units across$/);
+
+ const small = explainMeshGate(gateMesh(healthy({ bbox: [-1, 1] }), {}), {});
+ expect(small.checks.find((c) => c.id === 'zero_volume').actual).toBe('3.46 units across');
+ });
+
+ it('says a collapsed box is collapsed rather than printing 0.000', () => {
+ const report = explainMeshGate(gateMesh(healthy({ bbox: [0, 0] }), {}), {});
+ const row = report.checks.find((c) => c.id === 'zero_volume');
+ expect(row.status).toBe('fail');
+ expect(row.actual).toBe('collapsed to a point');
});
it('names the failing checks in the summary so the reason is visible unopened', () => {