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 branch 'main' into feat/hoist-sprite-lock-fixtures

Bryandero9828dd7ebd02b1
diff --cc server/services/sprites/atlas.test.js
index ac1d6b680e,e4a179f2a6..f64d68e824
--- a/server/services/sprites/atlas.test.js
+++ b/server/services/sprites/atlas.test.js
@@@ -19,14 -19,15 +19,17 @@@ import sharp from 'sharp'
import { mkdir, writeFile, readFile, rm } from 'fs/promises';
import { createHash } from 'crypto';
import {
+ capSharpThreads,
lockAllAnchors as lockAllAnchorsFixture,
+ lockAllAnchorsReal,
placeCandidate,
trackSpan as fullSpan,
writeWalkFramePng,
+ normalizeManifestForComparison,
} from './spriteTestFixtures.js';
+ const restoreSharpThreads = capSharpThreads();
+ afterAll(restoreSharpThreads);
const TEST_ROOT = mkdtempSync(join(tmpdir(), 'sprite-atlas-test-'));
vi.mock('../../lib/fileUtils.js', async (importOriginal) => {
diff --cc server/services/sprites/spriteTestFixtures.js
index 93b7d7b834,66bd1c40bc..8c9a67dcda
--- a/server/services/sprites/spriteTestFixtures.js
+++ b/server/services/sprites/spriteTestFixtures.js
@@@ -17,11 -17,33 +17,35 @@@
*/
import { join } from 'path';
import sharp from 'sharp';
-import { mkdir, writeFile } from 'fs/promises';
-import { SPRITE_DIRECTIONS } from './prompts.js';
+import {
+ mkdir, writeFile, readFile, copyFile,
+} from 'fs/promises';
+import { SPRITE_DIRECTIONS, ANCHOR_DIRECTIONS } from './prompts.js';
+ /**
+ * Cap libvips at one thread per call, for a suite whose images are all tiny.
+ * Returns the restore function the caller MUST hand to `afterAll`.
+ *
+ * Every sprite fixture and every compiled atlas cell is a 40–192px image, so a
+ * Sharp call's cost is its per-call overhead, not its pixel count — and the
+ * thread pool's setup/join IS most of that overhead at this size. CI already
+ * saturates each runner with several Vitest workers, so the pool only
+ * oversubscribes the box on top of that; the sprite suites measured markedly
+ * less system time with it capped (#6004).
+ *
+ * `sharp.concurrency` reaches past the module graph into libvips itself, so it
+ * is PROCESS state: Vitest resets the module registry between files but reuses
+ * the worker process, and an uncapped setting would otherwise stick to every
+ * later file in that worker — including the imageGen suites that raster
+ * 700–1200px images near their hook timeout. Hence the restore, and hence
+ * calling this from a suite rather than running it on import.
+ */
+ export function capSharpThreads() {
+ const previous = sharp.concurrency();
+ sharp.concurrency(1);
+ return () => sharp.concurrency(previous);
+ }
+
// Sharp PNG encoding is the expensive part; the same raw pixels show up in
// dozens of tests. Cache the encoded buffer per unique pixel config and
// `writeFile` it — still a real PNG, just not re-encoded every time.
diff --cc server/services/sprites/walk.test.js
index 9ededb4e73,594ad19484..995dfc164f
--- a/server/services/sprites/walk.test.js
+++ b/server/services/sprites/walk.test.js
@@@ -15,10 -15,10 +15,12 @@@ import { tmpdir } from 'os'
import { join } from 'path';
import { mkdir, writeFile, readFile, rm } from 'fs/promises';
import { createHash } from 'crypto';
-import { capSharpThreads, lockAllAnchors, expectCarriesCorrection } from './spriteTestFixtures.js';
+import {
- lockAllAnchors, lockAllAnchorsReal, expectCarriesCorrection, normalizeManifestForComparison,
++ capSharpThreads, lockAllAnchors, lockAllAnchorsReal, expectCarriesCorrection, normalizeManifestForComparison,
+} from './spriteTestFixtures.js';
+ const restoreSharpThreads = capSharpThreads();
+ afterAll(restoreSharpThreads);
const TEST_ROOT = mkdtempSync(join(tmpdir(), 'sprite-walk-test-'));
vi.mock('../../lib/fileUtils.js', async (importOriginal) => {