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: require a rendered scene for Blender readiness (#9390)
[._.]/ Adam Eivy7eba276d53a0
diff --git a/client/src/components/codeAnimation/ProductionContainment.jsx b/client/src/components/codeAnimation/ProductionContainment.jsxindex e84c9fdb9f..c7b1395a0b 100644--- a/client/src/components/codeAnimation/ProductionContainment.jsx+++ b/client/src/components/codeAnimation/ProductionContainment.jsx@@ -33,7 +33,7 @@ export default function ProductionContainment() {<div className="grid grid-cols-1 gap-2 text-sm md:grid-cols-3"><p>Sandbox: {mechanism.supported ? mechanism.id : <span className="text-port-warning">{mechanism.reason}</span>}</p><p>Browser lane: {lanes.browser.mechanism}</p>- <p>Blender lane: {lanes.blender.ready ? 'Ready' : <span className="text-port-warning">{lanes.blender.reason}</span>}</p>+ <p>Blender lane: {lanes.blender.ready ? 'Test scene rendered (production adapter pending)' : <span className="text-port-warning">{lanes.blender.reason}</span>}</p></div><div className="flex flex-wrap items-end gap-2"><div className="min-w-0 flex-1 basis-72">diff --git a/client/src/components/codeAnimation/ProductionProjects.test.jsx b/client/src/components/codeAnimation/ProductionProjects.test.jsxindex 2ea7654e4b..68a6013b0f 100644--- a/client/src/components/codeAnimation/ProductionProjects.test.jsx+++ b/client/src/components/codeAnimation/ProductionProjects.test.jsx@@ -197,5 +197,11 @@ describe('Production project rendered interactions', () => {await user.click(screen.getByRole('button', { name: 'Run containment check' }));expect(await screen.findByText(/Containment proven: 1 of 1 checks/)).toBeInTheDocument();expect(screen.getByText('Blender did not start under containment.')).toBeInTheDocument();+ api.probeCodeAnimationExecution.mockResolvedValue({ ...saved,+ probe: { passed: true, refused: null, checks: [], tools: { blender: { passed: true, detail: 'Cycles / CPU test scene rendered.' } } },+ lanes: { ...saved.lanes, blender: { ready: true, reason: null } } });+ await user.click(screen.getByRole('button', { name: 'Run containment check' }));+ expect(await screen.findByText(/Test scene rendered \(production adapter pending\)/)).toBeInTheDocument();+ expect(screen.getByText('Cycles / CPU test scene rendered.')).toBeInTheDocument();});});diff --git a/docs/CODE_ANIMATION_PACKAGES.md b/docs/CODE_ANIMATION_PACKAGES.mdindex 4f0c32895d..1b1c7d4774 100644--- a/docs/CODE_ANIMATION_PACKAGES.md+++ b/docs/CODE_ANIMATION_PACKAGES.md@@ -145,7 +145,8 @@ of those may contain PortOS data or the home directory.configured tools, the last containment check and each lane's readiness.Readiness fails closed: the Blender lane is ready only after a containmentcheck has passed in this server process with the currently configured- executable.+ executable, and its fixed test scene has rendered successfully. This is a+ runtime probe, not readiness of the pending Blender production-stage adapter.- `PUT /api/code-animation/execution/tools` sets `{ blender: { executable } }`(`null` clears it). Host control: it chooses what a worker runs.- `POST /api/code-animation/execution/probe` runs the containment check on@@ -159,12 +160,25 @@ of those may contain PortOS data or the home directory.or to the network. Positive control: the worker must still write its report.Separate runs must be terminated by the wall-time, disk, memory andcancellation limits with an empty process group. A configured Blender is then- started contained with `--background --factory-startup --version`.+ asked to build and render a fixed 64 × 64 cube scene under containment using+ `--background --factory-startup --disable-autoexec --python-exit-code 1`.+ The baseline is Blender 4.2.0, matching the existing pinned rigging runtime,+ with Cycles / CPU, eight samples and seed zero. Other versions remain+ unverified and fail this probe. The check decodes the PNG, requires the exact+ dimensions and nonblank pixels, validates the runtime/engine/device report,+ and records its image SHA-256 and elapsed time. A version banner, successful+ exit or `bpy` import alone cannot pass. No generated project code runs here;+ no dependency installation is attempted.Known limits: Blender is granted CPU rendering only — no GPU/Metal device orwindow-server access — and has not been verified under this profile on a-machine with Blender installed; a Blender that cannot start contained keeps its-lane refused. Seatbelt (`sandbox-exec`) is deprecated by Apple but remains the+machine with Blender installed; a Blender that cannot render the fixed scene+contained keeps its lane refused. CPU rendering can be substantially slower+than GPU rendering; this check does not measure final-film render cost.+EEVEE/GPU profiles, production scene building, pilot/final sequences, cadence,+artifacts and the independently authored painterly starter remain tracked in+#9390. Actual repeatable 10–15 second 1080p/24fps acceptance is still required;+synthetic protocol tests are not renderer acceptance. Seatbelt (`sandbox-exec`) is deprecated by Apple but remains themechanism Chromium and the private security assessment harness use. A hostthat already runs PortOS inside another sandbox may be unable to apply a nestedprofile; the check then fails and execution stays refused. Memory and totaldiff --git a/server/routes/codeAnimationExecution.test.js b/server/routes/codeAnimationExecution.test.jsindex c38504e636..442e6e7df8 100644--- a/server/routes/codeAnimationExecution.test.js+++ b/server/routes/codeAnimationExecution.test.js@@ -99,7 +99,7 @@ describe('Code Animation execution capability', () => {});expect(body.probe.passed).toBe(true);expect(body.probe.tools.blender).toMatchObject({ passed: false, version: null });- expect(body.lanes.blender).toEqual({ ready: false, reason: 'Blender did not start under containment.' });+ expect(body.lanes.blender).toEqual({ ready: false, reason: 'Blender did not render the supported test scene under containment.' });// Every owned workspace was removed, including the terminated ones.expect(await readdir(join(PATHS.data, 'code-animation-workspaces'))).toEqual([]);}, 60_000);diff --git a/server/services/codeAnimation/blenderProbe.js b/server/services/codeAnimation/blenderProbe.jsnew file mode 100644index 0000000000..d99152d648--- /dev/null+++ b/server/services/codeAnimation/blenderProbe.js@@ -0,0 +1,101 @@+/** On-demand fixed-scene proof, never execution of a project's source. */+import { createHash } from 'node:crypto';+import { readFile } from 'node:fs/promises';+import { join } from 'node:path';+import { z } from 'zod';+import { RIGGING_RUNTIME } from '../rigging/runtime.js';+import { runContainedWorker } from './containedWorker.js';++// Match the existing supported bpy baseline; this is not a claim that an import+// or a newer Blender version proves render compatibility.+const VERSION = RIGGING_RUNTIME.moduleVersion;+const reportSchema = z.object({+ version: z.literal(VERSION), engine: z.literal('CYCLES'), device: z.literal('CPU'),+ backend: z.literal('CPU'), width: z.literal(64), height: z.literal(64),+ seed: z.literal(0), samples: z.literal(8), frame: z.literal(1),+}).strict();++const SCENE = `import bpy, json, os+from mathutils import Vector+if bpy.app.version_string != ${JSON.stringify(VERSION)}:+ raise RuntimeError("Unsupported Blender version; expected ${VERSION}")+bpy.ops.wm.read_factory_settings(use_empty=True)+scene = bpy.context.scene+scene.render.engine = 'CYCLES'+scene.cycles.device = 'CPU'+scene.cycles.samples = 8+scene.cycles.seed = 0+scene.cycles.use_animated_seed = False+scene.cycles.use_denoising = False+scene.render.resolution_x = 64+scene.render.resolution_y = 64+scene.render.resolution_percentage = 100+scene.render.image_settings.file_format = 'PNG'+scene.render.image_settings.color_mode = 'RGBA'+scene.render.image_settings.color_depth = '8'+scene.frame_set(1)+bpy.ops.mesh.primitive_cube_add()+bpy.ops.object.camera_add(location=(4, -6, 3))+camera = bpy.context.object+camera.rotation_euler = (Vector((0, 0, 0)) - camera.location).to_track_quat('-Z', 'Y').to_euler()+scene.camera = camera+bpy.ops.object.light_add(type='AREA', location=(2, -3, 5))+bpy.context.object.data.energy = 500+bpy.context.object.data.shape = 'DISK'+bpy.context.object.data.size = 4+out = os.environ['PORTOS_WORKER_OUTPUT']+scene.render.filepath = os.path.join(out, 'probe.png')+bpy.ops.render.render(write_still=True)+with open(os.path.join(out, 'report.json'), 'w') as handle:+ json.dump(dict(version=bpy.app.version_string, engine=scene.render.engine,+ device=scene.cycles.device, backend='CPU', width=scene.render.resolution_x,+ height=scene.render.resolution_y, seed=scene.cycles.seed,+ samples=scene.cycles.samples, frame=scene.frame_current), handle)+`;++/**+ * A successful exit/version banner is insufficient: require a decoded,+ * nonuniform 64px PNG and exact runtime/engine evidence from the fixed script.+ * Only CPU Cycles is probed: EEVEE/GPU access is not granted by containment.+ * Injection covers failure contracts on CI; fixtures are not renderer proof.+ */+export async function probeBlenderRender({ executable, fingerprint }, workspaceRoot, { worker = runContainedWorker, signal } = {}) {+ if (!executable) return null;+ let evidence = null;+ let invalidOutput = false;+ const run = await worker({+ tool: { executable, argv: entry => ['--background', '--factory-startup', '--disable-autoexec', '--python-exit-code', '1', '--python', entry] },+ workspaceRoot, entrypoint: 'probe.py', files: [{ path: 'probe.py', content: SCENE }], signal,+ limits: { wallSeconds: 120, diskBytes: 64 * 1024 * 1024, maxFiles: 1000 },+ onOutput: async (directory, outputs) => {+ const report = outputs.find(file => file.path === 'report.json');+ const png = outputs.find(file => file.path === 'probe.png');+ if (!report || report.bytes > 16_384 || !png || png.bytes > 1024 * 1024) { invalidOutput = true; return; }+ // Decode under a strict pixel cap as well as the worker's file-size cap.+ const parsed = reportSchema.safeParse(JSON.parse(await readFile(join(directory, 'report.json'), 'utf8')));+ if (!parsed.success) { invalidOutput = true; return; }+ const bytes = await readFile(join(directory, 'probe.png'));+ const { default: sharp } = await import('sharp');+ const image = sharp(bytes, { limitInputPixels: 64 * 64 });+ const metadata = await image.metadata();+ if (metadata.format !== 'png' || metadata.width !== 64 || metadata.height !== 64) { invalidOutput = true; return; }+ const { data } = await image.ensureAlpha().raw().toBuffer({ resolveWithObject: true });+ let min = 255; let max = 0;+ for (let i = 0; i < data.length; i += 4) {+ const luma = (data[i] + data[i + 1] + data[i + 2]) / 3;+ min = Math.min(min, luma); max = Math.max(max, luma);+ }+ if (max - min < 8) { invalidOutput = true; return; }+ evidence = { ...parsed.data, imageSha256: createHash('sha256').update(bytes).digest('hex') };+ },+ }).catch(() => ({ status: 'failed', reason: 'probe-or-output-failed', processGroupClear: false }));+ const passed = run.status === 'completed' && run.processGroupClear === true && !invalidOutput && Boolean(evidence);+ return {+ executable, fingerprint, passed, version: passed ? evidence.version : null,+ render: passed ? evidence : null,+ durationMs: run.durationMs ?? null,+ detail: passed+ ? `Blender ${VERSION} rendered a 64 × 64 scene with Cycles / CPU under containment. CPU rendering may be slow; EEVEE, GPU rendering and production-sequence acceptance remain unverified.`+ : `Blender render check failed: expected ${VERSION}, Cycles / CPU and a valid nonblank 64 × 64 PNG inside containment. A version banner or bpy import is insufficient.`,+ };+}diff --git a/server/services/codeAnimation/blenderProbe.test.js b/server/services/codeAnimation/blenderProbe.test.jsnew file mode 100644index 0000000000..1e6e5738aa--- /dev/null+++ b/server/services/codeAnimation/blenderProbe.test.js@@ -0,0 +1,71 @@+import { afterAll, describe, expect, it, vi } from 'vitest';+import { mkdtemp, rm, writeFile } from 'node:fs/promises';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import sharp from 'sharp';+import { probeBlenderRender } from './blenderProbe.js';++const roots = [];+afterAll(async () => { await Promise.all(roots.map(root => rm(root, { recursive: true, force: true }))); });+const tool = { executable: '/example/Blender', fingerprint: 'example-runtime' };+const report = { version: '4.2.0', engine: 'CYCLES', device: 'CPU', backend: 'CPU', width: 64, height: 64, seed: 0, samples: 8, frame: 1 };+async function fixtureWorker({ metadata = report, width = 64, blank = false, corrupt = false, missing = false } = {}) {+ const directory = await mkdtemp(join(tmpdir(), 'portos-blender-probe-test-'));+ roots.push(directory);+ const pixels = Buffer.alloc(width * 64 * 3, 20);+ if (!blank) pixels.fill(200, pixels.length / 2);+ const png = corrupt ? Buffer.from('invalid PNG') : await sharp(pixels, { raw: { width, height: 64, channels: 3 } }).png().toBuffer();+ const json = typeof metadata === 'string' ? metadata : JSON.stringify(metadata);+ await writeFile(join(directory, 'probe.png'), png);+ await writeFile(join(directory, 'report.json'), json);+ return vi.fn(async options => {+ await options.onOutput(directory, missing ? [] : [{ path: 'report.json', bytes: Buffer.byteLength(json) }, { path: 'probe.png', bytes: png.length }]);+ return { status: 'completed', processGroupClear: true, durationMs: 12 };+ });+}++describe('Blender render readiness (synthetic worker evidence, not real Blender acceptance)', () => {+ it('requires a decoded image and exact runtime provenance, passing only fixed source through containment', async () => {+ const worker = await fixtureWorker();+ const controller = new AbortController();+ const result = await probeBlenderRender(tool, '/example/workspaces', { worker, signal: controller.signal });+ expect(result).toMatchObject({ passed: true, version: '4.2.0', render: { ...report, imageSha256: expect.stringMatching(/^[a-f0-9]{64}$/) }, durationMs: 12 });+ const options = worker.mock.calls[0][0];+ expect(options).toMatchObject({ entrypoint: 'probe.py', workspaceRoot: '/example/workspaces', signal: controller.signal });+ expect(options.tool.argv('/example/probe.py')).toEqual(['--background', '--factory-startup', '--disable-autoexec', '--python-exit-code', '1', '--python', '/example/probe.py']);+ expect(options.files[0].content).toContain('bpy.ops.render.render(write_still=True)');+ expect(result.detail).toContain('production-sequence acceptance remain unverified');+ });++ // These uniquely guard the native-renderer/API boundary: a successful exit+ // must never turn malformed artifacts into readiness.+ it.each([+ ['missing output', { missing: true }],+ ['invalid JSON', { metadata: '{' }],+ ['unsupported version', { metadata: { ...report, version: '4.3.0' } }],+ ['wrong engine', { metadata: { ...report, engine: 'BLENDER_EEVEE_NEXT' } }],+ ['wrong device', { metadata: { ...report, device: 'GPU' } }],+ ['wrong dimensions', { width: 32 }],+ ['blank image', { blank: true }],+ ['invalid PNG', { corrupt: true }],+ ])('refuses %s despite a successful worker exit', async (_name, config) => {+ const result = await probeBlenderRender(tool, '/example/workspaces', { worker: await fixtureWorker(config) });+ expect(result).toMatchObject({ passed: false, render: null, version: null });+ });++ it.each(['failed', 'terminated'])('refuses %s workers even with a Blender version banner', async status => {+ const result = await probeBlenderRender(tool, '/example/workspaces', {+ worker: async () => ({ status, reason: 'canceled', stdout: 'Blender 4.2.0', processGroupClear: true }),+ });+ expect(result.passed).toBe(false);+ });++ it('does not spawn a missing runtime, and contains worker failures without exposing diagnostics', async () => {+ const worker = vi.fn().mockRejectedValue(new Error('private diagnostic'));+ expect(await probeBlenderRender({ executable: null }, '/example/workspaces', { worker })).toBeNull();+ expect(worker).not.toHaveBeenCalled();+ const result = await probeBlenderRender(tool, '/example/workspaces', { worker });+ expect(result.passed).toBe(false);+ expect(JSON.stringify(result)).not.toContain('private diagnostic');+ });+});diff --git a/server/services/codeAnimation/execution.js b/server/services/codeAnimation/execution.jsindex acbf3df914..75190f41fa 100644--- a/server/services/codeAnimation/execution.js+++ b/server/services/codeAnimation/execution.js@@ -18,6 +18,7 @@ import {import { getSettings, updateSettings } from '../settings.js';import { cdpRequest } from '../browserService.js';import { currentContainmentMechanism, runContainedWorker } from './containedWorker.js';+import { probeBlenderRender } from './blenderProbe.js';const SETTINGS_KEY = 'codeAnimationExecution';const WORKSPACE_DIR = 'code-animation-workspaces';@@ -83,7 +84,7 @@ function blenderLane(mechanism, blender) {if (!evidence || evidence.executable !== blender.executable || evidence.fingerprint !== blender.fingerprint) {return { ready: false, reason: 'The configured Blender changed since the last containment check.' };}- if (!evidence.passed) return { ready: false, reason: 'Blender did not start under containment.' };+ if (!evidence.passed) return { ready: false, reason: 'Blender did not render the supported test scene under containment.' };return { ready: true, reason: null };}@@ -208,19 +209,6 @@ async function probeLimit(workspaceRoot, kind, limits, expected) {} finally { clearTimeout(timer); }}-async function probeBlender({ executable, fingerprint }, workspaceRoot) {- if (!executable) return null;- const run = await runContainedWorker({- tool: { executable, argv: () => ['--background', '--factory-startup', '--version'] }, workspaceRoot,- limits: { wallSeconds: 60, diskBytes: 64 * 1024 * 1024, maxFiles: 1000 },- }).catch((error) => ({ status: 'failed', reason: error.message, stdout: '' }));- const version = /^Blender \d+\.\d+(?:\.\d+)?/m.exec(run.stdout || '')?.[0] ?? null;- return {- executable, fingerprint, passed: run.status === 'completed' && Boolean(version), version,- detail: version ? `${version} started under containment (CPU only; no GPU device access is granted).` : `Blender did not start under containment (${run.status}${run.reason ? `: ${run.reason}` : ''}).`,- };-}-async function runProbe() {const started = Date.now();// Fail closed while checking, and if the check itself errors.@@ -238,7 +226,7 @@ async function runProbe() {await probeLimit(workspaceRoot, 'memory', { memoryBytes: 128 * 1024 * 1024 }, 'memory'),await probeLimit(workspaceRoot, 'cancel', {}, 'canceled'),];- const blender = await probeBlender(await inspectExecutable((await configuredTools()).blender.executable), workspaceRoot);+ const blender = await probeBlenderRender(await inspectExecutable((await configuredTools()).blender.executable), workspaceRoot);const browser = await cdpRequest('/json/version', { timeout: 2000 }).then((response) => response.ok, () => false);lastProbe = {probedAt: new Date().toISOString(), mechanism: mechanism.id, passed: checks.every((check) => check.passed),