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
address review (claude): keep sparse alpha frames degenerate
[._.]/ Adam Eivy4e99c59d4a98
diff --git a/server/lib/imageFrameStats.js b/server/lib/imageFrameStats.jsindex 0ab1f05b1e..ecec6671f5 100644--- a/server/lib/imageFrameStats.js+++ b/server/lib/imageFrameStats.js@@ -52,6 +52,12 @@ export const NEAR_EMPTY_ENTROPY_FLOOR = 0.05;// 16x16 is reported as unjudgeable (`ok: null`) rather than degenerate.export const MIN_JUDGEABLE_PIXELS = 256;+// Match NEAR_EMPTY_ENTROPY_FLOOR's roughly 0.5% signal floor for alpha-only+// silhouettes. Both visible and transparent coverage must clear this floor;+// a couple of transparent holes in an otherwise flat opaque sheet are not a+// meaningful silhouette.+export const ALPHA_COVERAGE_FLOOR = 255 * 0.005;+export const FRAME_REASON = {SOLID_FILL: 'solid-fill',FULLY_TRANSPARENT: 'fully-transparent',@@ -120,7 +126,12 @@ export async function describeFrameStats(input) {// just the normal PNG case and must not rescue a flat fill.const alpha = metadata.hasAlpha ? perChannel[perChannel.length - 1] : null;const alphaCarriesContent = Boolean(- alpha && !stats.isOpaque && alpha.max > alpha.min && alpha.stdev >= SOLID_FILL_STDEV_EPSILON,+ alpha+ && !stats.isOpaque+ && alpha.max > alpha.min+ && alpha.stdev >= SOLID_FILL_STDEV_EPSILON+ && alpha.mean >= ALPHA_COVERAGE_FLOOR+ && alpha.mean <= 255 - ALPHA_COVERAGE_FLOOR,);// Only the colour channels decide "flat" — a fully-OPAQUE alpha channel isdiff --git a/server/lib/imageFrameStats.test.js b/server/lib/imageFrameStats.test.jsindex 11f7ceec16..1405f97d47 100644--- a/server/lib/imageFrameStats.test.js+++ b/server/lib/imageFrameStats.test.js@@ -105,6 +105,24 @@ describe('describeFrameStats', () => {expect(isDegenerateFrame(stats)).toBe(false);});+ it('rejects an RGBA frame with only a few visible pixels', async () => {+ const buf = await fromPixels((x, y) => (+ x === 0 && y === 0 ? [255, 255, 255, 255] : [0, 0, 0, 0]+ ), { channels: 4 });+ const stats = await describeFrameStats(buf);+ expect(stats.ok).toBe(false);+ expect(stats.reason).toBe(FRAME_REASON.NEAR_EMPTY);+ });++ it('rejects a flat RGBA frame with only a few transparent pixels', async () => {+ const buf = await fromPixels((x, y) => (+ x < 2 && y === 0 ? [40, 40, 40, 0] : [40, 40, 40, 255]+ ), { channels: 4 });+ const stats = await describeFrameStats(buf);+ expect(stats.ok).toBe(false);+ expect(stats.reason).toBe(FRAME_REASON.SOLID_FILL);+ });+it('rejects a near-empty frame whose single stray pixel leaves entropy at the floor', async () => {const buf = await fromPixels((x, y) => (x === 0 && y === 0 ? [255, 255, 255] : [0, 0, 0]));const stats = await describeFrameStats(buf);diff --git a/server/services/sprites/walkFrames.test.js b/server/services/sprites/walkFrames.test.jsindex 61e509991b..cff7a1a68e 100644--- a/server/services/sprites/walkFrames.test.js+++ b/server/services/sprites/walkFrames.test.js@@ -66,6 +66,9 @@ const healthyPng = () => {};const transparentPng = () => makeRgbaPng(() => [0, 0, 0, 0]);+const nearEmptyPng = () => makeRgbaPng((x, y) => (+ x === 0 && y === 0 ? [255, 255, 255, 255] : [0, 0, 0, 0]+));let seq = 0;const newId = () => `frametest-${++seq}`;@@ -179,6 +182,21 @@ describe('verifyPackagedFrames — byte mode (compile gate)', () => {});});+ it('rejects a near-empty packed frame instead of treating alpha speckle as content', async () => {+ const id = newId();+ const healthy = await healthyPng();+ const frameBytes = Array(8).fill(healthy);+ frameBytes[4] = await nearEmptyPng();+ const manifest = await makeFrames(id, { frameBytes });++ await expect(verifyPackagedFrames(id, manifest, { bytes: true }))+ .rejects.toMatchObject({+ status: 422,+ code: 'ATLAS_COMPILE_INVALID',+ message: expect.stringContaining(`Direction east frame 4 (${manifest.frames[4].phase}) has no content`),+ });+ });+it('compiles a set when every decoded frame has content', async () => {const id = newId();const healthy = await healthyPng();