import assert from 'node:assert/strict' import { readFileSync, existsSync } from 'node:fs' import { resolve, join } from 'node:path' const dir = resolve(process.argv[2] || 'tools/city-massing/city/cad-bim/city-hybrid-v1') const tree = JSON.parse(readFileSync(join(dir, 'tileset.json'), 'utf8')) const report = JSON.parse(readFileSync(join(dir, 'manifest.json'), 'utf8')) assert.equal(report.farCoarseFiles, 74) assert.equal(report.fineFiles, 3023) assert.equal(tree.root.children.length, 74) let coarse = 0, fine = 0, paths = new Set() function walk(tile, parent = null) { if (tile.children?.length) assert.equal(tile.refine, 'REPLACE') if (tile.content?.uri) { const path = resolve(dir, tile.content.uri) assert.ok(existsSync(path), path) assert.ok(!paths.has(path), `duplicate content ${path}`) paths.add(path) if (/-lod1\.glb$/.test(tile.content.uri)) coarse++ if (/-lod0\.glb$/.test(tile.content.uri)) { fine++ assert.equal(tile.geometricError, 0) assert.ok(parent, 'fine leaf must have coarse parent') } } for (const child of tile.children || []) walk(child, tile) } walk(tree.root) assert.equal(coarse, 74) assert.equal(fine, 3023) console.log(JSON.stringify({ passed: true, coarse, fine, content: paths.size, policy: '74 coarse parents; fine leaves are local children, no global coarse handoff', traversalValidated: false }))