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: flag identity details that all name the same multi-part set as fused (#3503)
[._.]/ Adam Eivyb153a76f41b3
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex c34bbbed2b..1f0ce50c7b 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -97,6 +97,8 @@- **[issue-3482] A model that looks perfect head-on and like cardboard the moment you orbit it now says so before you find out yourself.** Since the spec gained extruded outlines, a generation can score a near-perfect match against its reference — right silhouette, right colour zones, right part count — while every load-bearing piece is a flat slab standing on its own depth plane, because a head-on comparison actively rewards that flatness. A new cross-section check reads the finished geometry instead of the picture: it counts how many distinct planes each mesh actually occupies on its thinnest axis (a fan of four hundred triangles sharing one Z value has no profile at all) and treats an unbevelled extrusion as the two-plane slab it is by construction. It reports at the level of the whole model rather than per part, because a flat extrusion is the *right* answer for a badge, a sign, or a panel — the finding fires only when the majority of the subject's identity-defining features have nothing but flat parts behind them, and it names the parts responsible. The result sits beside the assembly-coverage findings on the model's page, and a Refine you didn't steer now asks for real depth as well as for the promises the last pass didn't build. The generation prompt was closing the loop from the other end too: it sold extrude for silhouettes without ever saying when extrude is the wrong answer, so it now states that a body with a real cross-section — a torso, a housing, a grip, a shell that varies in thickness — must not be an unbevelled extrusion, and gates on a subject that isn't genuinely plate-like not having every identity part flat along one axis.+- **[issue-3503] A fused model could hide from the assembly check by wearing a second part id.** The fusion finding only looked at features that named exactly *one* part, so a spec that aimed eight defining features at the same *two* parts — every one of them "hull and base" — reported completely clean, even though nothing in it distinguishes one feature from another. Features are now grouped by the whole set of parts they name, so any group of two or more defining features sharing an identical set is reported the same way a shared single part already was, with the finding naming the parts and how many features are riding them. Sets that merely overlap ("hull and base" beside "base and mast") are left alone — sharing a part is ordinary attribution, not fusion. And the existing rule that a set nothing was built on went *unbuilt* rather than fused still holds, so a refinement pass is never handed both "split this mesh" and "this mesh does not exist" about the same features.+## Internal- **[issue-3497] The Chief of Staff no longer re-reads and re-parses its task lists on every scheduler tick** — an unchanged list is served from memory instead, which matters most on installs whose task history has grown large. Edits made outside PortOS (a text editor, a restore, a sync peer) are still picked up immediately.diff --git a/server/lib/README.md b/server/lib/README.mdindex c02c7d1607..6ab954c41f 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -150,7 +150,7 @@ 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`). || `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. |-| `threejsModelCoverage.js` | `evaluateThreejsPartCoverage(spec)` — structural assembly gate over an already-validated Three.js spec: flags promised features fused onto one mesh, geometry claimed by no detail, and details nothing was built for (folded minor relief stays a `note`). `buildThreejsCoverageFeedback(coverage)` turns the error findings into default refinement feedback. |+| `threejsModelCoverage.js` | `evaluateThreejsPartCoverage(spec)` — 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`). `buildThreejsCoverageFeedback(coverage)` turns the error findings into default refinement feedback. || `pgFileFacade.js` | Shared PG/file store-backend backbone for the six storage dispatchers (pipeline series/issues, story builder, universe builder, catalog user-types, writers room). `isFileBackend()` (dev/test escape-hatch predicate) · `resolvePgBackend({ requirement, migrate?, loadDb, makePg })` (health-check → `ensureSchema` → one-time migration → import `db.js` → build the PG backend) · `createPgFileFacade({ makeFile, makePg })` (promise-memoized lazy selection so concurrent first calls don't run the migration twice; returns `{ getBackend, getBackendName, reset }`). Each store keeps its own `makeFile`/`makePg` factories + public surface. `createRecordStoreBackendSelector({ label, loadFileBackend, loadDbBackend, requireDbMessage?, isTestMode?, onDbReady? })` wraps the same backbone for the stores whose backends are whole MODULES rather than built objects (Creative Director, Music Video, Sprites) → `{ selectBackend, getBackendName }` where the name is `'file'`/`'postgres'`; `isTestMode` lets a store use the stronger `isTestRunner()` signal (Sprites). || `multipart.js` | Streaming multipart/form-data parser. || `safetensors.js` | `readSafetensorsHeader(path)` reads only the JSON header of a `.safetensors` file (never the tensor payload). `detectFlux2VariantFromHeader(header)` / `detectFlux2Variant(path)` classify a LoRA as FLUX.2 Klein `'4b'` (hidden dim 3072) vs `'9b'` (4096) by transformer-block tensor shapes, so the LoRA picker can hide off-variant weights that would silently fail to load. |diff --git a/server/lib/threejsModelCoverage.js b/server/lib/threejsModelCoverage.jsindex 05228cbd6b..f20d51b8d4 100644--- a/server/lib/threejsModelCoverage.js+++ b/server/lib/threejsModelCoverage.js@@ -56,69 +56,85 @@ export function evaluateThreejsPartCoverage(spec) {const label = (id) => byId.get(id)?.name || id;const findings = [];- // 1. Fusion — details whose ONLY implementing part is the same single part.- // `detailSchema` does not constrain `implementationPartIds` to be unique, so- // `['hull','hull']` validates; without the dedupe the arity test below reads- // it as a two-part detail and the fusion gate silently stops looking at the- // most fused spec there is. Deliberate scope limit: a group of details that- // all name the SAME multi-part set is not reported — the issue defines fusion- // as collapsing onto one part, and two parts is already an assembly.- const partIdsOf = (detail) => [...new Set(detail.implementationPartIds || [])];- const soleImplementers = new Map();+ // 1. Fusion — details whose implementing parts are the SAME set. Grouping by+ // the sorted, deduped id set (not by a single id) is what catches the spec+ // that aims eight identity details at the same two parts: one fused assembly+ // wearing a second part id reads exactly as clean as a real assembly unless+ // the key carries the whole set. `detailSchema` does not constrain+ // `implementationPartIds` to be unique, so `['hull','hull']` validates — the+ // dedupe is what keeps the most fused spec there is from keying itself apart+ // from `['hull']`. Only *identical* sets group: `['a','b']` and `['b','c']`+ // merely overlap, which is ordinary attribution and would fire on almost+ // every real spec.+ const partIdsOf = (detail) => [...new Set(detail.implementationPartIds || [])].sort();+ const sharedSets = new Map();for (const detail of details) {const ids = partIdsOf(detail);- if (ids.length !== 1) continue;- const group = soleImplementers.get(ids[0]) || [];- group.push(detail);- soleImplementers.set(ids[0], group);+ if (ids.length === 0) continue;+ // `|` cannot appear in a part id (`idSchema` is `[A-Za-z][A-Za-z0-9_-]*`),+ // so the joined key is unambiguous — no set can collide with another.+ const key = ids.join('|');+ const group = sharedSets.get(key) || { ids, details: [] };+ group.details.push(detail);+ sharedSets.set(key, group);}// Details already accounted for by a shared-part finding, so the folded-relief// pass below cannot report the same detail a second time.const groupedDetails = new Set();- for (const [partId, group] of soleImplementers) {- const sharedPart = byId.get(partId);- // Nothing was built on this part or anywhere beneath it, so the details did- // not fuse onto it — they went unbuilt. Leaving the group to the folded and- // unbuilt passes below keeps the gate from reporting a fusion that never- // happened alongside the "nothing was built" finding that describes the same- // details, which would hand the next refinement pass two opposite orders.- if (group.length < 2 || !sharedPart?.subtreeHasGeometry) continue;- for (const detail of group) groupedDetails.add(detail);+ for (const { ids, details: group } of sharedSets.values()) {+ const sharedParts = ids.map((id) => byId.get(id)).filter(Boolean);+ // Nothing was built on these parts or anywhere beneath them, so the details+ // did not fuse onto them — they went unbuilt. Leaving the group to the+ // folded and unbuilt passes below keeps the gate from reporting a fusion+ // that never happened alongside the "nothing was built" finding that+ // describes the same details, which would hand the next refinement pass two+ // opposite orders.+ if (group.length < 2 || !sharedParts.some((part) => part.subtreeHasGeometry)) continue;const ranked = group.filter((detail) => RANKED_PRIORITIES.has(detail.priority));if (ranked.length >= 2) {+ for (const detail of group) groupedDetails.add(detail);const features = ranked.map((detail) => detail.feature);// Re-attribute or rebuild? The answer is not "is the shared part a mesh"- // — it is whether enough unclaimed geometry already exists beneath it to- // give every ranked feature a home. Telling the provider to rebuild parts- // it already modelled duplicates geometry; telling it to re-attribute to- // children that do not exist wastes a whole provider round-trip and lands- // back here next pass. A shared part that is itself a mesh houses one of- // the features legitimately, so it only needs children for the rest.+ // — it is whether enough unclaimed geometry already exists beneath the set+ // to give every ranked feature a home. Telling the provider to rebuild+ // parts it already modelled duplicates geometry; telling it to+ // re-attribute to children that do not exist wastes a whole provider+ // round-trip and lands back here next pass. Each shared part that is+ // itself a mesh houses one of the features legitimately, so the set only+ // needs children for the rest.const unclaimedDescendants = parts.filter((part) => part.hasGeometry- && part.ancestorIds.includes(partId)+ && part.ancestorIds.some((ancestorId) => ids.includes(ancestorId))&& !implementedIds.has(part.id)).length;- const needHomes = ranked.length - (sharedPart.hasGeometry ? 1 : 0);+ const needHomes = ranked.length - sharedParts.filter((part) => part.hasGeometry).length;const remedy = unclaimedDescendants >= needHomes? 'Point each detail at the specific child part that implements it.': 'Build each as its own part instead of one fused mesh.';+ const names = listSpecNames(ids.map(label));+ const message = ids.length === 1+ ? `${features.length} promised features collapsed onto the single part "${label(ids[0])}" (${listSpecNames(features)}). ${remedy}`+ : `${features.length} promised features are all attributed to the same ${ids.length} parts (${names}) with no per-feature geometry distinguishing them (${listSpecNames(features)}). ${remedy}`;findings.push({code: 'fused-parts',severity: 'error',- partIds: [partId],+ partIds: ids,features,- message: `${features.length} promised features collapsed onto the single part "${label(partId)}" (${listSpecNames(features)}). ${remedy}`,+ message,});continue;}- // At most one ranked feature owns the part and the rest are minor: relief- // folded into the piece it rides on. A right answer is not a defect.+ // At most one ranked feature owns the set and the rest are minor: relief+ // folded into the piece it rides on. A right answer is not a defect. Only+ // said for a single part — "folded into its parent" is a claim about one+ // mesh, and a multi-part set has no single piece the relief rides on.+ if (ids.length !== 1) continue;+ for (const detail of group) groupedDetails.add(detail);findings.push({code: 'folded-detail',severity: 'note',- partIds: [partId],+ partIds: ids,features: group.map((detail) => detail.feature),- message: `${group.length} details share the single part "${label(partId)}" (${listSpecNames(group.map((detail) => detail.feature))}). Folding minor relief into the piece it rides on is expected.`,+ message: `${group.length} details share the single part "${label(ids[0])}" (${listSpecNames(group.map((detail) => detail.feature))}). Folding minor relief into the piece it rides on is expected.`,});}diff --git a/server/lib/threejsModelCoverage.test.js b/server/lib/threejsModelCoverage.test.jsindex 88a32dee90..947ffe3d64 100644--- a/server/lib/threejsModelCoverage.test.js+++ b/server/lib/threejsModelCoverage.test.js@@ -143,6 +143,102 @@ describe('evaluateThreejsPartCoverage', () => {expect(coverage.errorCount).toBe(1);});+ it('errors when several identity features all name the same multi-part set', () => {+ // A fused assembly wearing a second part id: nothing distinguishes the+ // three features from one another, they just all point at the same pair.+ const coverage = evaluateThreejsPartCoverage(makeSpec({+ parts: [+ { id: 'hull', name: 'Hull', geometry: box(2), material: 'shell' },+ { id: 'base', name: 'Base', geometry: box(1), material: 'shell' },+ ],+ detailInventory: [+ detail('Boxy hull', ['hull', 'base'], 'identity'),+ detail('Recessed lens', ['hull', 'base'], 'identity'),+ // Same set, written in the other order — the key sorts before joining.+ detail('Sensor ring', ['base', 'hull'], 'identity'),+ ],+ }));++ expect(codes(coverage)).toEqual(['fused-parts']);+ expect(coverage.errorCount).toBe(1);+ expect(coverage.findings[0]).toMatchObject({+ severity: 'error',+ partIds: ['base', 'hull'],+ features: ['Boxy hull', 'Recessed lens', 'Sensor ring'],+ });+ expect(coverage.findings[0].message).toContain('the same 2 parts');+ expect(coverage.findings[0].message).toContain('Hull');+ expect(coverage.findings[0].message).toContain('Base');+ });++ it('does not report a fusion onto a multi-part set nothing was built on', () => {+ // Same guard the single-part path carries: a set whose parts hold no+ // geometry anywhere went unbuilt, it did not fuse. Reporting both would+ // hand the next refinement pass two opposite orders.+ const coverage = evaluateThreejsPartCoverage(makeSpec({+ parts: [+ { id: 'hull', name: 'Hull', geometry: box(2), material: 'shell' },+ { id: 'anchor', name: 'Anchor' },+ { id: 'mount', name: 'Mount' },+ ],+ detailInventory: [+ detail('Boxy hull', ['hull'], 'identity'),+ detail('Recessed lens', ['anchor', 'mount'], 'identity'),+ detail('Sensor ring', ['anchor', 'mount'], 'identity'),+ detail('Vent grille', ['mount', 'anchor'], 'identity'),+ ],+ }));++ expect(codes(coverage)).toEqual(['unbuilt-detail', 'unbuilt-detail', 'unbuilt-detail']);+ expect(coverage.errorCount).toBe(3);+ });++ it('does not flag details whose part sets merely overlap', () => {+ // Partial overlap is ordinary attribution — treating it as fusion would+ // fire on almost every real spec.+ const coverage = evaluateThreejsPartCoverage(makeSpec({+ parts: [+ { id: 'alpha', name: 'Alpha', geometry: box(1), material: 'shell' },+ { id: 'bravo', name: 'Bravo', geometry: box(1), material: 'shell' },+ { id: 'charlie', name: 'Charlie', geometry: box(1), material: 'shell' },+ ],+ detailInventory: [+ detail('Swept forward shell', ['alpha', 'bravo'], 'identity'),+ detail('Tapered tail', ['bravo', 'charlie'], 'identity'),+ ],+ }));++ expect(coverage.findings).toEqual([]);+ });++ it('tells a multi-part set with unclaimed geometry children to re-attribute', () => {+ // Both shared parts are bare groups with two spare meshes beneath them —+ // enough homes for the ranked features, so rebuilding would duplicate+ // geometry the provider already got right.+ const coverage = evaluateThreejsPartCoverage(makeSpec({+ parts: [+ {+ id: 'head',+ name: 'Head',+ children: [{ id: 'skull', name: 'Skull', geometry: box(0.8), material: 'shell' }],+ },+ {+ id: 'neck',+ name: 'Neck',+ children: [{ id: 'collar', name: 'Collar', geometry: box(0.4), material: 'shell' }],+ },+ ],+ detailInventory: [+ detail('Domed skull', ['head', 'neck'], 'identity'),+ detail('Ribbed collar', ['head', 'neck'], 'identity'),+ ],+ }));++ const fused = coverage.findings.find((finding) => finding.code === 'fused-parts');+ expect(fused.message).toContain('Point each detail at the specific child part');+ expect(fused.message).not.toContain('one fused mesh');+ });+it('does not report a fusion onto a part nothing was built on', () => {// Two details sharing a locator that carries no geometry anywhere did not// fuse — they went unbuilt. Reporting both would tell the next refinement