Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
refactor: fail fast on a material-family keyword claimed by two families
[._.]/ Adam Eivyd69dc27a4c5d
diff --git a/client/src/pages/ThreejsModelDetail.test.jsx b/client/src/pages/ThreejsModelDetail.test.jsxindex 975e6e84c1..a6ff9ae65c 100644--- a/client/src/pages/ThreejsModelDetail.test.jsx+++ b/client/src/pages/ThreejsModelDetail.test.jsx@@ -241,7 +241,6 @@ describe('ThreejsModelDetail material plausibility gate', () => {const implausible = {materialCount: 3,matchedMaterialCount: 2,- implausibleMaterialCount: 1,errorCount: 0,warningCount: 1,noteCount: 0,diff --git a/server/lib/threejsModel.js b/server/lib/threejsModel.jsindex db19c67f59..8307dbe9ad 100644--- a/server/lib/threejsModel.js+++ b/server/lib/threejsModel.js@@ -786,9 +786,18 @@ const MATERIAL_FAMILY_PRIORS = [},];-const MATERIAL_KEYWORD_FAMILIES = new Map(- MATERIAL_FAMILY_PRIORS.flatMap((prior) => prior.keywords.map((keyword) => [keyword, prior]))-);+// A keyword claimed by two families would silently resolve to whichever entry+// is declared last, which is exactly the confident-nonsense the ambiguity rule+// above exists to prevent — so a collision fails at import rather than at+// review time.+const MATERIAL_KEYWORD_FAMILIES = MATERIAL_FAMILY_PRIORS.reduce((map, prior) => {+ for (const keyword of prior.keywords) {+ const owner = map.get(keyword);+ if (owner) throw new Error(`material family keyword "${keyword}" is claimed by both ${owner.family} and ${prior.family}`);+ map.set(keyword, prior);+ }+ return map;+}, new Map());// `basic` is unlit, so none of these channels reach the renderer at all; the// physical-only ones are parsed for every type but only forwarded by@@ -841,7 +850,7 @@ const matchMaterialFamily = (id) => {** @param {object} spec a spec that has already passed `threejsSculptSpecSchema`* @returns {{findings: Array, errorCount: number, warningCount: number, noteCount: number,- * materialCount: number, matchedMaterialCount: number, implausibleMaterialCount: number}}+ * materialCount: number, matchedMaterialCount: number}}*/export function evaluateThreejsMaterialPlausibility(spec) {const materials = (spec?.materials && typeof spec.materials === 'object') ? spec.materials : {};@@ -882,9 +891,10 @@ export function evaluateThreejsMaterialPlausibility(spec) {errorCount: 0,warningCount: findings.length,noteCount: 0,+ // One finding per implausible material, so `warningCount` is also the count+ // of materials that failed — no separate tally that could disagree with it.materialCount: Object.keys(materials).length,matchedMaterialCount: matched,- implausibleMaterialCount: findings.length,};}diff --git a/server/services/threejsModels/index.js b/server/services/threejsModels/index.jsindex aa3c9fce6e..f19c7459d3 100644--- a/server/services/threejsModels/index.js+++ b/server/services/threejsModels/index.js@@ -166,7 +166,7 @@ async function executeGeneration({console.warn(`⚠️ Three.js model ${id} cross-part penetration: ${penetration.errorCount} error, ${penetration.warningCount} warning finding(s) over ${penetration.comparedPairCount} compared pair(s)`);}if (materialPlausibility.warningCount > 0) {- console.warn(`⚠️ Three.js model ${id} material plausibility: ${materialPlausibility.implausibleMaterialCount} of ${materialPlausibility.matchedMaterialCount} recognized material(s) carry values their substance does not support`);+ console.warn(`⚠️ Three.js model ${id} material plausibility: ${materialPlausibility.warningCount} of ${materialPlausibility.matchedMaterialCount} recognized material(s) carry values their substance does not support`);}if (rig.articulationReady) {console.log(`🦴 Three.js model ${id} declares an articulation graph: ${rig.jointCount} joint(s), ${rig.socketCount} pivot socket(s)`);