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
fix: move the environment/render-profile contract into a dependency-free module so client CI can import it (#4630)
[._.]/ Adam Eivyfc72678db400
diff --git a/client/src/lib/threejsEnvironment.test.js b/client/src/lib/threejsEnvironment.test.jsindex bd999779cc..b17f5cb7c2 100644--- a/client/src/lib/threejsEnvironment.test.js+++ b/client/src/lib/threejsEnvironment.test.js@@ -33,7 +33,7 @@ import {DEFAULT_THREEJS_ENVIRONMENT as SERVER_DEFAULT,THREEJS_RENDER_PROFILE as SERVER_RENDER_PROFILE,resolveThreejsEnvironment,-} from '../../../server/lib/threejsModel.js';+} from '../../../server/lib/threejsModelEnvironment.js';import {THREEJS_ENVIRONMENT_PRESETS,DEFAULT_THREEJS_ENVIRONMENT,diff --git a/server/lib/README.md b/server/lib/README.mdindex 9846d79c48..ca8c7aeb5c 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -176,9 +176,10 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `imageWatermark.js` | `removeCornerWatermark` (erases the visible Gemini/Nano-Banana bottom-right ✦ via dependency-free harmonic/Laplace inpaint) + pure helpers `resolveWatermarkRegion` / `inpaintRegion`. Distinct from SynthID regen — this targets the *visible* corner logo. || `localImageFilename.js` | `localImageFilename(urlOrPath)` resolves a stored image reference to the bare gallery-image filename under `data/images/` (or null for empty/external-URL/non-image-path) — the unit the peer-sync asset pipeline hashes + transfers. Single source of truth for the authors/artists/albums/Creative-Director filename resolvers (`headshotImageFilename`/`portraitImageFilename`/`coverImageFilename`/`startingImageFilename` are thin wrappers). Also exports `assetBasename(pathOrName)`, the shared strip-querystring→basename primitive (reused by moodBoard's `imageUrlToAppAsset`). || `localMemory.js` | Shared best-effort local-model unload + available-memory report (`prepareLocalMemory`) for GPU-heavy local work; only loopback Ollama / LM Studio backends are evicted. |-| `threejsModel.js` | Validated declarative procedural-model schema plus deterministic standalone Three.js factory export for the Three.js Models workspace. Also the cross-section gate: `evaluateThreejsFlatness(spec)` counts distinct vertex planes per axis — relative to the mesh's own size, with a rotation-invariant zero-volume check behind it — and treats an `extrude` with no bevel thickness as the two-plane slab it is to report when the majority of identity-priority features are built only from flat parts — a model that reads right head-on and like cardboard when orbited. `buildThreejsFlatnessFeedback(flatness)` turns that into default refinement feedback; `listSpecNames(names)` is the shared capped name-list formatter both gates use in finding messages. Also the material-plausibility gate: `evaluateThreejsMaterialPlausibility(spec)` keys a bounded per-family prior table (metal, wood, plastic, glass, fabric, ceramic, rubber, stone, leather, paper) off tokens in each material's id and reports channels whose values the named substance does not support — metalness 0.9 oak, transmission 1.0 steel — skipping any id that names no family or two, and any channel the material's `type` never forwards to Three.js. Advisory only: it never clamps, because a stylized model may legitimately break every prior. `buildThreejsMaterialFeedback(plausibility)` turns that into default refinement feedback. The same pass emits a `reflective-material-without-environment` note when a spec authors reflective channels (metalness above 0.6, or any transmission/clearcoat/iridescence) while `environment.preset` is `none` — those channels read off an environment, so in that scene their values cannot be judged at all. `THREEJS_ENVIRONMENT_PRESETS` / `resolveThreejsEnvironment(spec)` are the bounded `{ preset, intensity }` block and its `none`-defaulting reader (a spec stored before it shipped has no key and was rendered with no environment), and `THREEJS_RENDER_PROFILE` is the colour-space/tone-map/exposure contract `buildThreejsFactorySource()` stamps onto `root.userData.sculptRuntime.render` and exports as `renderProfile`, so a consumer wiring their own `WebGLRenderer` reproduces the model instead of a differently tone-mapped approximation. |+| `threejsModel.js` | Validated declarative procedural-model schema plus deterministic standalone Three.js factory export for the Three.js Models workspace. Also the cross-section gate: `evaluateThreejsFlatness(spec)` counts distinct vertex planes per axis — relative to the mesh's own size, with a rotation-invariant zero-volume check behind it — and treats an `extrude` with no bevel thickness as the two-plane slab it is to report when the majority of identity-priority features are built only from flat parts — a model that reads right head-on and like cardboard when orbited. `buildThreejsFlatnessFeedback(flatness)` turns that into default refinement feedback; `listSpecNames(names)` is the shared capped name-list formatter both gates use in finding messages. Also the material-plausibility gate: `evaluateThreejsMaterialPlausibility(spec)` keys a bounded per-family prior table (metal, wood, plastic, glass, fabric, ceramic, rubber, stone, leather, paper) off tokens in each material's id and reports channels whose values the named substance does not support — metalness 0.9 oak, transmission 1.0 steel — skipping any id that names no family or two, and any channel the material's `type` never forwards to Three.js. Advisory only: it never clamps, because a stylized model may legitimately break every prior. `buildThreejsMaterialFeedback(plausibility)` turns that into default refinement feedback. The same pass emits a `reflective-material-without-environment` note when a spec authors reflective channels (metalness above 0.6, or any transmission/clearcoat/iridescence) while `environment.preset` is `none` — those channels read off an environment, so in that scene their values cannot be judged at all. The spec carries an optional `environment` block (see `threejsModelEnvironment.js`), and `buildThreejsFactorySource()` stamps its render profile onto `root.userData.sculptRuntime.render` and exports it as `renderProfile`, so a consumer wiring their own `WebGLRenderer` reproduces the model instead of a differently tone-mapped approximation. || `threejsModelAnimation.js` | `summarizeThreejsAnimation(spec)` — clip inventory *and* playback gate over an already-validated Three.js spec: `{ animated, clipCount, cueCount, sequenceCount, movingPartCount, longestClipSeconds, findings, warningCount, clips }`. The schema proves a declared `animation` block is well *formed* (sequences on real parts, inside their clip, never two on one channel at once, never a cue without motion); this reports what the model *declared* — one entry per clip with its role, duration, sequence and distinct-cue counts — plus the ways a well-formed clip still plays badly: a clip authored against a pose the assembly does not build (`clip-start-pose-mismatch`), a handover between sequences that do not meet (`clip-sequence-jump`), a `loop: true` clip that does not return to where it began, a one-shot `idle`, an unfired cue, a long dead tail, and an articulation graph with no clip at all. Advisory warnings only — a static assembly is a complete answer. `buildThreejsAnimationFeedback(animation)` turns those findings into default refinement feedback. A spec with no `animation` key summarizes as not animated — never as evaluated-and-empty. || `threejsModelCoverage.js` | `evaluateThreejsPartCoverage(spec, { family })` — structural assembly gate over an already-validated Three.js spec: flags promised features fused onto the same part set, geometry claimed by no detail, and details nothing was built for (folded minor relief stays a `note`). With a subject family it also warns on a required component the spec never mentions at all — the one check that can fault a spec for what it failed to *promise*. `buildThreejsCoverageFeedback(coverage)` turns the error findings (plus any family gap) into default refinement feedback. |+| `threejsModelEnvironment.js` | The image-based-lighting and render-profile half of the procedural sculpt contract, kept **dependency-free** so the client suite can import it to assert parity with `client/src/lib/threejsEnvironment.js` (`threejsModel.js` pulls in zod, which the client CI job does not install). `THREEJS_ENVIRONMENT_PRESETS` (`none`/`neutral`/`studio`) is the bounded preset list the spec schema builds its enum from; `resolveThreejsEnvironment(spec)` normalizes a spec's `{ preset, intensity }` block, reading an absent, partial, or unrecognized one as `DEFAULT_THREEJS_ENVIRONMENT` per field — a record stored before the block shipped has no key and was rendered with no environment, so `none` is the honest reading of it. `THREEJS_RENDER_PROFILE` is the output-colour-space / tone-mapping / exposure contract `buildThreejsFactorySource()` stamps onto every export. || `threejsModelFamilies.js` | Curated subject-family checklists for Three.js generation. `THREEJS_MODEL_FAMILY_OPTIONS` / `THREEJS_MODEL_FAMILY_IDS` drive the picker and route validation; `buildThreejsFamilyChecklist(id)` returns the prompt block spliced into generation (`''` for the default `general`, so an un-narrowed subject keeps the unchanged general-purpose prompt); `findMissingFamilyComponents(spec, id)` reports which required components the spec never mentions. || `threejsModelPenetration.js` | `evaluateThreejsPenetration(spec)` — cross-part penetration gate over an already-validated Three.js spec, the one check that compares two parts to each other. Rebuilds each part's world placement (the same `THREE.Euler` 'XYZ' composition the preview applies), derives an analytic solid per geometry type, and samples one part's interior against another's to flag a part entirely buried inside an unrelated one (`error`) or unrelated parts occupying substantially the same space (`warning`). Parts in the same subtree and declared `attachmentPartIds` are exempt — embedding is what those relationships are *for* — and a shallow or transparent-container overlap is reported as an undecided `note`, never as a defect. `buildThreejsPenetrationFeedback(penetration)` turns the errors and warnings (never the undecided notes) into default refinement feedback. || `threejsModelPhysicalAudit.js` | `evaluateThreejsPhysicalAudit(spec)` — pure bounds and pose audit gate over an already-validated Three.js spec: inspects static resting poses and animated clip poses to detect floating parts (`floating-part`), swallowed geometry (`buried-geometry`), z-fighting coplanar surfaces (`coplanar-surface`), and unprovenanced appearing geometry (`unprovenanced-transition`). `buildThreejsPhysicalAuditFeedback(physicalAudit)` turns actionable findings into default refinement feedback. |diff --git a/server/lib/index.js b/server/lib/index.jsindex 8139d1e22a..53e0404e92 100644--- a/server/lib/index.js+++ b/server/lib/index.js@@ -52,6 +52,7 @@ export * from './sharedSchemas.js';export * from './threejsModel.js';export * from './threejsModelAnimation.js';export * from './threejsModelCoverage.js';+export * from './threejsModelEnvironment.js';export * from './threejsModelFamilies.js';export * from './threejsModelPenetration.js';export * from './threejsModelPhysicalAudit.js';diff --git a/server/lib/threejsModel.js b/server/lib/threejsModel.jsindex 84ebce51fa..03995a72df 100644--- a/server/lib/threejsModel.js+++ b/server/lib/threejsModel.js@@ -10,6 +10,11 @@import { z } from 'zod';import { failValidation } from './errorHandler.js';+import {+ resolveThreejsEnvironment,+ THREEJS_ENVIRONMENT_PRESETS,+ THREEJS_RENDER_PROFILE,+} from './threejsModelEnvironment.js';import { THREEJS_PLAYER_SOURCE } from './threejsModelPlayerSource.js';const idSchema = z.string().trim().min(1).max(80).regex(/^[A-Za-z][A-Za-z0-9_-]*$/);@@ -316,69 +321,14 @@ const lightSchema = z.object({penumbra: z.number().finite().min(0).max(1).default(0.25),});-/**- * The image-based lighting the spec is authored against.- *- * `lights` alone are punctual: they light a surface but give it nothing to- * REFLECT, and every reflective PBR channel the material schema accepts —- * `metalness`, `transmission`, `clearcoat`, `iridescence` — reads off an- * environment or reads off nothing at all. A conductor in a scene with no- * environment renders near-black however plausible its values are, so a- * refinement pass has every incentive to "fix" the look by authoring- * implausible values back in.- *- * Both presets are built locally from three's own primitives (see- * `client/src/lib/threejsEnvironment.js`) — PortOS never fetches an HDR to- * render a local model.- */-export const THREEJS_ENVIRONMENT_PRESETS = ['none', 'neutral', 'studio'];-+// The environment/render-profile half of the contract lives in its own+// dependency-free module so the client suite can import it to assert parity —+// this file imports zod, which the client CI job does not install.const environmentSchema = z.object({preset: z.enum(THREEJS_ENVIRONMENT_PRESETS).default('none'),intensity: z.number().finite().min(0).max(4).default(1),});-/**- * What a spec with no `environment` key means. A record stored before this block- * shipped was authored and rendered with no environment at all, so `none` is the- * honest reading of it — not a retroactive claim that it had one.- */-export const DEFAULT_THREEJS_ENVIRONMENT = Object.freeze({ preset: 'none', intensity: 1 });--/**- * The spec's environment, normalized for a caller that must not care whether the- * key is present. Tolerant of a partially-filled block so a stored record that- * predates a field reads as the default for it rather than `undefined`.- */-export const resolveThreejsEnvironment = (spec) => {- const environment = spec?.environment;- if (!environment || typeof environment !== 'object') return { ...DEFAULT_THREEJS_ENVIRONMENT };- return {- preset: THREEJS_ENVIRONMENT_PRESETS.includes(environment.preset)- ? environment.preset- : DEFAULT_THREEJS_ENVIRONMENT.preset,- intensity: typeof environment.intensity === 'number' && Number.isFinite(environment.intensity)- ? environment.intensity- : DEFAULT_THREEJS_ENVIRONMENT.intensity,- };-};--/**- * The renderer settings a PortOS-authored spec is composed against, stamped onto- * the exported factory so a consumer wiring their own `WebGLRenderer` reproduces- * the model instead of a differently tone-mapped approximation of it. These are- * the react-three-fiber `<Canvas>` defaults the preview runs on; two renders of- * the same spec are only comparable when both sides agree on them.- *- * Data only. The factory never constructs a renderer, exactly as it never- * constructs a scene or a camera.- */-export const THREEJS_RENDER_PROFILE = Object.freeze({- outputColorSpace: 'srgb',- toneMapping: 'ACESFilmic',- toneMappingExposure: 1,-});-const socketSchema = z.object({name: idSchema,parentPartId: idSchema,diff --git a/server/lib/threejsModel.test.js b/server/lib/threejsModel.test.jsindex c08b75efdd..413ddd72ee 100644--- a/server/lib/threejsModel.test.js+++ b/server/lib/threejsModel.test.js@@ -5,11 +5,11 @@ import {buildThreejsMaterialFeedback,evaluateThreejsFlatness,evaluateThreejsMaterialPlausibility,- resolveThreejsEnvironment,storedThreejsSculptSpecSchema,threejsGeometrySchema,threejsSculptSpecSchema,} from './threejsModel.js';+import { resolveThreejsEnvironment } from './threejsModelEnvironment.js';const squareOutline = [[-1, -1], [1, -1], [1, 1], [-1, 1]];const validExtrude = () => ({diff --git a/server/lib/threejsModelEnvironment.js b/server/lib/threejsModelEnvironment.jsnew file mode 100644index 0000000000..77479ce254--- /dev/null+++ b/server/lib/threejsModelEnvironment.js@@ -0,0 +1,63 @@+/**+ * The image-based-lighting and render-profile half of the procedural sculpt+ * contract (`threejsModel.js`), kept in its own DEPENDENCY-FREE module.+ *+ * `spec.lights` alone are punctual: they light a surface but give it nothing to+ * REFLECT, and every reflective PBR channel the material schema accepts —+ * `metalness`, `transmission`, `clearcoat`, `iridescence` — reads off an+ * environment or reads off nothing at all. A conductor in a scene with no+ * environment renders near-black however plausible its values are, so a+ * refinement pass has every incentive to "fix" the look by authoring+ * implausible values back in.+ *+ * The client mirrors all of this in `client/src/lib/threejsEnvironment.js`, and+ * its suite asserts the two agree — which is why nothing here may import+ * anything. `threejsModel.js` pulls in `zod`, which the client CI job does not+ * install, so a client test importing it fails to resolve at all.+ *+ * Both presets are built locally from three's own primitives — PortOS never+ * fetches an HDR to render a local model.+ */++export const THREEJS_ENVIRONMENT_PRESETS = ['none', 'neutral', 'studio'];++/**+ * What a spec with no `environment` key means. A record stored before this block+ * shipped was authored and rendered with no environment at all, so `none` is the+ * honest reading of it — not a retroactive claim that it had one.+ */+export const DEFAULT_THREEJS_ENVIRONMENT = Object.freeze({ preset: 'none', intensity: 1 });++/**+ * The spec's environment, normalized for a caller that must not care whether the+ * key is present. Tolerant of a partially-filled block so a stored record that+ * predates a field reads as the default for it rather than `undefined`.+ */+export const resolveThreejsEnvironment = (spec) => {+ const environment = spec?.environment;+ if (!environment || typeof environment !== 'object') return { ...DEFAULT_THREEJS_ENVIRONMENT };+ return {+ preset: THREEJS_ENVIRONMENT_PRESETS.includes(environment.preset)+ ? environment.preset+ : DEFAULT_THREEJS_ENVIRONMENT.preset,+ intensity: typeof environment.intensity === 'number' && Number.isFinite(environment.intensity)+ ? environment.intensity+ : DEFAULT_THREEJS_ENVIRONMENT.intensity,+ };+};++/**+ * The renderer settings a PortOS-authored spec is composed against, stamped onto+ * the exported factory so a consumer wiring their own `WebGLRenderer` reproduces+ * the model instead of a differently tone-mapped approximation of it. These are+ * the react-three-fiber `<Canvas>` defaults the preview runs on; two renders of+ * the same spec are only comparable when both sides agree on them.+ *+ * Data only. The exported factory never constructs a renderer, exactly as it+ * never constructs a scene or a camera.+ */+export const THREEJS_RENDER_PROFILE = Object.freeze({+ outputColorSpace: 'srgb',+ toneMapping: 'ACESFilmic',+ toneMappingExposure: 1,+});