Skip to content

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

Merge remote-tracking branch 'origin/main' into claim/issue-3484

[._.]/ Adam Eivy09ef061a6fba
diff --cc .changelog/NEXT.md
index 70eea40547,9f0576e357..68b75816b6
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@@ -72,6 -76,12 +76,14 @@@
- **`completeAgent` had three addresses, and the four callers that most needed one address were using the wrong one.** Continuing #3450's sequencing: `agentManagement.js`, `agentLifecycle.js`, `agentFinalization.js` and `agentCliSpawning.js` all reached the completion transition through the `cosAgents.js` barrel. These four are the callers the "move the caller above the facade" recipe cannot reach — the first two DEFINE transitions `agentOrchestrator.js` re-exports, so importing the facade from either is the cycle itself, and the other two are leaves those two must call to spawn and to finalize. So the rule they follow is the other half of the same property: above the facade's closure a transition comes from the facade, inside it from the module that DECLARES it (`cosAgentLifecycle.js`), and never from a barrel. `cleanupOrphanedAgents`'s `await import('./cos.js')` went with it — it was pulling `completeAgent` and `getAgents` through the `cos.js` re-export block while the module was already a static import three lines up, so the deferral bought no cycle protection at all. The new guard in `agentImportCycles.test.js` derives the transition names from the facade's export blocks and walks re-export edges to work out which modules forward them, so a barrel added later is covered without being named; it catches a named import, a renamed one, a namespace property read, a destructure off a namespace handle, and the three deferred spellings of the same reaches — including `const { completeAgent } = await import('./cos.js')`, the exact pattern this change deleted. Each bypass-probed.
+- **A Three.js part could be scaled to nothing, or reflected into a mirrored node, and the schema called both a valid transform.** Every geometry dimension in the scene spec is bounded to a positive number, but `partSchema.scale` reused the plain `finite` triple — so a provider-authored `[1, 0, 1]` collapsed the part to an invisible plane, and `[1, -1, 1]` reflected it, which three.js absorbs by flipping the front face for the negative world determinant. Neither throws, both export, and both survive a colour or silhouette check, so the resulting "the part is missing" or "the detail reads backwards" is chased anywhere except the one number that caused it. `scale` is now its own tuple floored at `1e-4` — zero, negative, and near-degenerate components are rejected with a `parts.N.scale.M` path — and the generation prompt states the bound alongside the parts shape, so the model is told to build a mirrored counterpart as its own part and to omit a part it doesn't want rendered, rather than discovering the bound through a rejected generation. Nothing in PortOS computes a scale: the value only ever arrives in the provider's JSON, no UI edits it, and no seed or reference data carries one, so the schema is the only place it can be caught. Tightening an authoring bound must not retroactively invalidate data accepted under the old one, though, so the bound applies to what a provider may *author*, not to what an install has already *stored*: `storedThreejsSculptSpecSchema` is the same schema with the original unbounded scale, and it is what the standalone-factory download validates against. An existing model therefore stays downloadable and exports exactly as it previews — the alternative was taking Copy/Download away from a `ready` record whose only remedy is a paid regeneration, or machine-repairing the stored spec, which would silently un-mirror an asymmetric part or resize a deliberately-collapsed one back into view. Both schemas come from one factory parameterized by the scale bound, so the 60-line reference/hierarchy `superRefine` is not duplicated to express the difference. `buildThreejsFactorySource()` also stopped calling bare `.parse` while it was there: a raw `ZodError` normalizes to an opaque 500, so a genuinely malformed stored spec now comes back as a 400 through the shared `failValidation`, naming the path (#3484).
+
- **The "Pick from Gallery" picker could only be narrowed by typing, so finding one object in one universe meant recalling a word from its prompt.** It now carries two dropdowns beside the search box: a scope select that groups every universe and media collection under `<optgroup>`s, and a type select built from the `entryCategory`/`entryKind` tags the Universe Builder stamps onto sidecars, labelled through the same `humanizeCategory` the Builder uses. Those two are separate vocabularies — a user-authored bucket can legitimately be keyed `canon` — so the type options are prefixed by which field they filter and grouped under Categories/Entry kinds rather than flattened into one list where the bucket and the stage would silently match each other. All three filters AND-combine, and both dropdowns list only universes/collections/types that actually match an image currently in the picker — a scope that can only ever produce an empty grid isn't offered, and a selection that stops matching resets itself to "All" rather than silently blanking the grid. Collection membership is matched on the stored `{ kind, ref }` pair (the same `<kind>:<ref>` string `normalizeImage` puts on `item.key`), not on a bare filename, so a collection holding video refs alongside images filters correctly. Both option fetches are best-effort: if the collections or universes call fails the picker keeps working, falling back to the universe name stamped on each sidecar, and the fetched lists are dropped on close so a reopen can't filter fresh images against stale membership. Sidecars are unvalidated JSON that also arrive from peers, so a tag that isn't a usable string is skipped rather than crashing the render — which surfaced a latent bug in the shared `humanizeCategory`: its label lookup wasn't `hasOwn`-guarded, so a user-authored category keyed `constructor` or `toString` resolved to an inherited function and handed every caller a label that throws on the next string method (#3479).
+
+ - **The Antigravity model dropdown made you pick your reasoning effort inside the model name.** `agy models` enumerates the effort tiers as separate ids (`gemini-3.6-flash-low|-medium|-high`), so there was no way to set the base model and the effort independently — and the Three.js Model Generator, which builds its own prompt-runner invocation, had no effort control at all. `ProviderModelSelector` grows optional `effort`/`onEffortChange` props that render a "Thinking effort" select for the effort-capable providers (Antigravity, Claude, Codex) and nothing for the rest, so callers need no guard of their own; a picker that wires those also passes `withEffort` to `useProviderModels` and then lists base models with the suffixes stripped and deduped. That pairing is deliberate rather than a global rewrite: in a picker with no effort control the suffixed ids are the only way to express a tier, so collapsing them there would strip the capability instead of relocating it. Verified against the real binary before building it: `agy` takes `--effort` as its own session flag and accepts the base id — but it validates the PAIR, erroring with `gemini-3.1-pro has no "medium" effort (available: low, high)`. So the tiers offered for an Antigravity model are derived from that provider's own catalog rather than assumed to be the full ladder, and an out-of-range effort clamps down to the nearest tier the model really has instead of producing an invocation agy rejects. A stored suffixed id — still what older installs and federated peers persist — splits into base plus `--effort`, the equivalent invocation, rather than being orphaned, and the picker seeds both controls from its two halves; one that somehow can't be split stays visible as its own option instead of blanking the select. The effort the record stores is the one that will ACTUALLY run — resolved server-side against the provider and model before persisting — so a level left over from a previous selection can not be saved and rendered for a run that never used it. Threading the effort down to `runPromptThroughProvider` also closed a gap on that path generally: it rides the provider clone the arg builders already read, and until now `buildCliArgs`/`buildTuiInvocation` emitted no effort flag at all for claude or codex there (#3480).
+
+ - **Composite boards were the only Universe Builder surface with no thumbnail, so a rendered board looked unrendered.** Characters, places, objects and category variations all show their latest render as an `EntryThumbSlot` avatar with a click-to-preview lightbox; the Composites tab showed label + prompt only. Nothing was missing server-side — `compile.js` already stamps an `entryRef` of kind `sheet` on each queued board render and the completion hook already appends the resulting filename to that board's `imageRefs[]`, so the data was sitting in the record with nothing reading it. Composite rows now render through the same `EntryCard` shell + three-state `EntryThumbSlot` the variation and canon rows use (in-flight spinner → rendered thumbnail → empty placeholder with a one-click render button), so their spacing and locked accent can no longer drift from the other surfaces, and clicking a board opens the same page-level lightbox with the real render prompt hydrated from the gallery sidecar. `useRenderJobQueue` had been dropping `sheet`-kind jobs on the grounds that no row consumed them; with every kind the server stamps now settled by a row, the filter is deleted rather than widened — an allowlist that already covers everything can only ever fail closed on the next kind added, silently, with no spinner and no error. Two things this collapsed rather than copied: the row settles through `EntryThumbSlot`'s existing `onComplete` bridge instead of opening a second `useMediaJobProgress` subscription against a jobId the slot is already watching (which is what the variation and canon rows do, at the cost of a row re-render per diffusion tick), and the two page-level job handlers that had each inlined the same append-dedupe-cap now share `appendImageRefById` in `lib/bibleLimits.js`, the client mirror of the server's `mapAppendImageRef` (three other surfaces still inline their own copy). The settle callback is memoized rather than rebuilt per render: `MediaJobThumb` fires its completion effect on `[filename, onFilename]`, so a fresh arrow would re-settle the same job on every keystroke in the builder draft, each one a full gallery refetch — there is a test that fails against the unstable form. Codex review then surfaced the gap that made the whole thing conditional: the draft never adopted the ids the server sanitizer mints, so a board added and rendered in the same session had no `id` to match the one the server stamped onto `entryJobs` — no spinner, no thumbnail until reload, and (now that sheet jobs are tracked) a pending entry with no consumer to clear it. `handleSave` had the server record in hand the whole time and only ever used it for the universe list, so it now adopts the minted ids into both the draft and its dirty baseline — backfilling only the draft would leave the page permanently dirty. That fixes variations, which had the identical latent bug, in the same place rather than special-casing boards. A second review round found the same mismatch in its other shape: on records written before entry ids were persisted at all, `ensureEntryId` mints a fresh uuid on every read, and `POST /render` migrates the record — persisting yet another set — before queueing jobs against it, so the draft is holding ids that exist nowhere. The render flow now reconciles from the persisted record before it enqueues, and the adopt rule is stated as "keep every id the server also has, replace the ones it does not": an id the server has never heard of cannot be the key anything is stored under, while a confirmed id is never re-pointed and so can never be pulled out from under an in-flight job. And a failed board render now says so, the way the variation and canon rows already did, instead of the spinner just vanishing — `EntryThumbSlot` reports the terminal status on a dedicated `onTerminalStatus` prop so a cancel can stay silent. That status deliberately does NOT ride on `onComplete`'s second argument, which was the first thing tried: `useSingleImageRender`'s `handleComplete(filename, key)` is wired straight into that prop by the base-style probe, so a status arriving where it expects a key looked up a job that did not exist, never cleared the real one, and left the probe spinning forever after a perfectly successful render. The full client suite did not catch it — the collision only shows up through a component boundary neither module's tests cross — so `EntryThumbSlot` now asserts `onComplete` is called with exactly one argument, which fails the moment anyone overloads it again.
+
+ ## Three.js Models
+
+ - **[issue-3483] Take a generated model apart and click any piece to find out what it is.** The preview used to render a finished model as one inert lump — the only way to check it was actually built from parts, rather than fused into a single shape, was to export the source and read it. An Explode slider now separates the assembly, and clicking any surface names the part it belongs to and lights up that whole component. Separation scales the layout outward from the model's centre instead of shoving every piece the same distance, so parts that were touching genuinely come apart, pieces sitting at the centre still clear their neighbours, and the camera re-frames to whatever the disassembly actually grew to. Surface detail — serrations, stria, trim, port floors — rides the part it belongs to instead of shattering into loose slivers, and clicking it selects that part; models are now generated with that distinction marked, and exported models carry it too.
diff --cc server/lib/threejsModel.js
index 62af977779,03b9f0fb13..ced9b1a2b8
--- a/server/lib/threejsModel.js
+++ b/server/lib/threejsModel.js
@@@ -280,25 -264,24 +280,30 @@@ export const threejsMaterialSchema = z.
anisotropy: z.number().finite().min(0).max(1).default(0),
});
-let partSchema;
-partSchema = z.lazy(() => z.object({
- id: idSchema,
- name: z.string().trim().min(1).max(120),
- geometry: threejsGeometrySchema.optional(),
- material: idSchema.optional(),
- position: vec3Schema.default([0, 0, 0]),
- rotationDegrees: vec3Schema.default([0, 0, 0]),
- scale: vec3Schema.default([1, 1, 1]),
- castShadow: z.boolean().default(true),
- receiveShadow: z.boolean().default(true),
- // Surface relief (serrations, stria, trim, port floors) belongs TO a part
- // rather than being one: it rides its parent when the model is taken apart,
- // and a click on it selects the parent. Without the flag a disassembly
- // shatters into a comb of loose slivers nobody can read or pick.
- explodeWithParent: z.boolean().default(false),
- children: z.array(partSchema).max(40).default([]),
-}));
+// The scale bound is the ONE thing that differs between what a provider may
+// author and what an install may already have stored, so the part hierarchy is
+// built from it rather than written twice.
+const makePartSchema = (scaleSchema) => {
+ let partSchema;
+ partSchema = z.lazy(() => z.object({
+ id: idSchema,
+ name: z.string().trim().min(1).max(120),
+ geometry: threejsGeometrySchema.optional(),
+ material: idSchema.optional(),
+ position: vec3Schema.default([0, 0, 0]),
+ rotationDegrees: vec3Schema.default([0, 0, 0]),
+ scale: scaleSchema.default([1, 1, 1]),
+ castShadow: z.boolean().default(true),
+ receiveShadow: z.boolean().default(true),
++ // Surface relief (serrations, stria, trim, port floors) belongs TO a part
++ // rather than being one: it rides its parent when the model is taken apart,
++ // and a click on it selects the parent. Without the flag a disassembly
++ // shatters into a comb of loose slivers nobody can read or pick.
++ explodeWithParent: z.boolean().default(false),
+ children: z.array(partSchema).max(40).default([]),
+ }));
+ return partSchema;
+};
const lightSchema = z.object({
type: z.enum(['ambient', 'hemisphere', 'directional', 'point', 'spot']),
diff --cc server/services/threejsModels/prompt.js
index 35959fe04d,abc75d8b79..f5026e5a44
--- a/server/services/threejsModels/prompt.js
+++ b/server/services/threejsModels/prompt.js
@@@ -55,8 -55,9 +55,9 @@@ Return one raw JSON object and nothing
"id":"stablePartId","name":"Readable part name",
"geometry": { ...one allowed geometry... },
"material":"materialId",
- "position":[x,y,z],"rotationDegrees":[x,y,z],"scale":[x,y,z],
+ "position":[x,y,z],"rotationDegrees":[x,y,z],"scale":[sx,sy,sz],
"castShadow":true,"receiveShadow":true,
+ "explodeWithParent":false,
"children":[ ...same part shape... ]
}],
"sockets": [{"name":"socketName","parentPartId":"partId","position":[x,y,z],"rotationDegrees":[x,y,z]}],