← Commit history
drive.mjs+2−1
@@ -10,6 +10,7 @@ //   hero-studio toast "<text>" [--kind info|success|warn] narrate to the human //   hero-studio reroll                                    re-roll the circuitry pattern import path from 'path';+import { gateOpen } from './gate.mjs';  // --port <n> / HERO_STUDIO_PORT target a specific instance (hero-studio#15). const pi = process.argv.indexOf('--port');@@ -305,7 +306,7 @@ try {         if (!r.ok) return;         const st = await r.json();         if (!st || !st.page) return;-        rows.push({ port: p2, page: st.page, gateOpen: !!st.verify, posedAt: st.posedAt || null, approved: st.approved ? st.approved.file : null });+        rows.push({ port: p2, page: st.page, gateOpen: gateOpen(st), posedAt: st.posedAt || null, approved: st.approved ? st.approved.file : null });       } catch {}     }));     rows.sort((a, b) => a.port - b.port);
gate.mjsadded+14
@@ -0,0 +1,14 @@+// When is a studio's gate open? `approved` is the session's record of the+// last Generate and is never cleared, so "approved.page === page" alone+// read a re-posed gate as closed whenever that page had been generated+// earlier in the session (hero-studio#77: a second thread's pose then took+// over the live gate). The gate is open when it is posed and the last+// approval of that page came before the pose.+export function gateOpen(state) {+  if (!state || !state.verify || !state.page) return false;+  const a = state.approved;+  if (!a || a.page !== state.page) return true;+  const posed = Number(state.posedAt) || 0;+  const approvedAt = Number(a.ts) || 0;+  return posed > approvedAt;+}
package.json+3−2
@@ -2,7 +2,7 @@   "slug": "hero-studio",   "title": "Hero Studio",   "type": "app",-  "version": "0.25.1",+  "version": "0.25.2",   "description": "The hero-image lab with a human gate: `hero-studio pose <owner/slug>` opens the studio in front of the human, posed for their package, and blocks until they click Generate, producing the provenance-stamped 2000x1250 PNG the registry's hero gate requires. The image carries the title and artwork; the exported image also bakes the type pill (top right) and full wiki slug (bottom right); the page shows the hero bare, and only the homepage marquee overlays its own dynamic info. Every hero wears its PAGE OWNER's brand guide (<owner>/brand): colors, type, logo and background themes, Adom's included; an unresolved guide holds unbranded rather than borrowing Adom's look. Placement is fixed for all. The floating app window is the showcase: it auto-loads a real screenshot from the package's wiki page (screenshots/, docs/), takes a manual import, or a full-hero import (the human-ratified re-stamp path for existing heroes). The pose gate opens in verification mode: per-item checklist (title, subtitle, showcase, type match) and a Generate that unlocks only fully confirmed. Includes showcase bleeds, brand tile themes, gradient angles, pixel-faithful wiki marquee and index-card previews, and a component-hero mode with a photo/raytrace/phong fallback ladder.",   "license": "MIT",   "tags": [@@ -68,7 +68,7 @@     "test:render": "node test/render-view.mjs",     "test:renderer": "node test/renderer.mjs",     "test:syntax": "node test/syntax.mjs",-    "test": "node test/syntax.mjs && node test/brand.mjs && node test/render-view.mjs && node test/renderer.mjs && node test/platform.mjs && node test/pose-surface.mjs && node test/bind-and-tabs.mjs && node test/batch.mjs && node test/circuit-traces.mjs",+    "test": "node test/syntax.mjs && node test/gate.mjs && node test/brand.mjs && node test/render-view.mjs && node test/renderer.mjs && node test/platform.mjs && node test/pose-surface.mjs && node test/bind-and-tabs.mjs && node test/batch.mjs && node test/circuit-traces.mjs",     "test:traces": "node test/circuit-traces.mjs",     "prepublishOnly": "node test/syntax.mjs",     "test:platform": "node test/platform.mjs"@@ -86,6 +86,7 @@     "refresh-data.sh",     "server.js",     "pose.mjs",+    "gate.mjs",     "drive.mjs",     "doctor.mjs",     "renderer-paths.cjs",
page.json+3−2
@@ -2,7 +2,7 @@   "slug": "hero-studio",   "title": "Hero Studio",   "type": "app",-  "version": "0.25.1",+  "version": "0.25.2",   "description": "The hero-image lab with a human gate: `hero-studio pose <owner/slug>` opens the studio in front of the human, posed for their package, and blocks until they click Generate, producing the provenance-stamped 2000x1250 PNG the registry's hero gate requires. The image carries the title and artwork; the exported image also bakes the type pill (top right) and full wiki slug (bottom right); the page shows the hero bare, and only the homepage marquee overlays its own dynamic info. Every hero wears its PAGE OWNER's brand guide (<owner>/brand): colors, type, logo and background themes, Adom's included; an unresolved guide holds unbranded rather than borrowing Adom's look. Placement is fixed for all. The floating app window is the showcase: it auto-loads a real screenshot from the package's wiki page (screenshots/, docs/), takes a manual import, or a full-hero import (the human-ratified re-stamp path for existing heroes). The pose gate opens in verification mode: per-item checklist (title, subtitle, showcase, type match) and a Generate that unlocks only fully confirmed. Includes showcase bleeds, brand tile themes, gradient angles, pixel-faithful wiki marquee and index-card previews, and a component-hero mode with a photo/raytrace/phong fallback ladder.",   "license": "MIT",   "tags": [@@ -68,7 +68,7 @@     "test:render": "node test/render-view.mjs",     "test:renderer": "node test/renderer.mjs",     "test:syntax": "node test/syntax.mjs",-    "test": "node test/syntax.mjs && node test/brand.mjs && node test/render-view.mjs && node test/renderer.mjs && node test/platform.mjs && node test/pose-surface.mjs && node test/bind-and-tabs.mjs && node test/batch.mjs && node test/circuit-traces.mjs",+    "test": "node test/syntax.mjs && node test/gate.mjs && node test/brand.mjs && node test/render-view.mjs && node test/renderer.mjs && node test/platform.mjs && node test/pose-surface.mjs && node test/bind-and-tabs.mjs && node test/batch.mjs && node test/circuit-traces.mjs",     "test:traces": "node test/circuit-traces.mjs",     "prepublishOnly": "node test/syntax.mjs",     "test:platform": "node test/platform.mjs"@@ -87,6 +87,7 @@     "refresh-data.sh",     "server.js",     "pose.mjs",+    "gate.mjs",     "drive.mjs",     "doctor.mjs",     "renderer-paths.cjs",
pose.mjs+3−4
@@ -13,6 +13,7 @@ // browser, and when nothing opens, pose prints the studio URL and keeps // waiting: the gate stays open for whoever opens that URL. import { execFile, spawn } from 'child_process';+import { gateOpen } from './gate.mjs'; import { fileURLToPath } from 'url'; import path from 'path'; import os from 'os';@@ -177,8 +178,7 @@ if (!portPinned) { BASE = 'http://localhost:' + port + '/'; let state = null; try { state = await jf('state'); } catch {}-if (state && state.page === ref && state.verify-    && !(state.approved && state.approved.page === ref) && !('steal' in flags)) {+if (state && state.page === ref && gateOpen(state) && !('steal' in flags)) {   // Same page, gate already open: a second pose would silently clobber the   // first thread's staging (#24 ask 6). Refuse and NAME the holder.   const since = state.posedAt ? new Date(state.posedAt).toISOString() : 'unknown time';@@ -188,8 +188,7 @@ if (state && state.page === ref && state.verify   process.exit(4); } if (state && !portPinned) {-  const gateBusy = state.verify && state.page && state.page !== ref-    && !(state.approved && state.approved.page === state.page);+  const gateBusy = gateOpen(state) && state.page !== ref;   if (gateBusy) {     const busyFor = state.page;     let free = 0;
public/js/app.js+34
@@ -224,7 +224,20 @@ function applyGuide(hero, g, foreign) {     if (usable && logo) {       slot.style.setProperty('--owner-logo', 'url("' + logo + '")');       slot.classList.add('owner-logo');+      // The logo is a CSS background, so nothing else reports whether it+      // loaded: probe it, and let the lint fail a hero that would export with+      // an empty logo slot (hero-studio#76).+      if (slot.dataset.logoSrc !== logo) {+        slot.dataset.logoSrc = logo;+        slot.dataset.logoState = 'loading';+        const probe = new Image();+        probe.onload = () => { if (slot.dataset.logoSrc === logo) { slot.dataset.logoState = 'ok'; scheduleLint(); } };+        probe.onerror = () => { if (slot.dataset.logoSrc === logo) { slot.dataset.logoState = 'error'; scheduleLint(); } };+        probe.src = logo;+      }     } else {+      delete slot.dataset.logoSrc;+      delete slot.dataset.logoState;       slot.style.removeProperty('--owner-logo');       slot.classList.remove('owner-logo');     }@@ -1004,6 +1017,10 @@ function computeLint() {   const H = hero.getBoundingClientRect();   if (H.width < 60) return null;   const items = [];+  const logoSlot = hero.querySelector('.wordmark .wmark.owner-logo');+  if (logoSlot && logoSlot.offsetParent && logoSlot.dataset.logoState === 'error') {+    items.push({ id: 'owner-logo-missing', level: 'fail', el: null, msg: 'the owner logo did not load, so the logo slot would export empty; check the brand guide\'s logo file (Brand step) and the studio log for the brand asset error' });+  }   if (isTraceTheme() && !(state.showcase && state.showcase.full) && window.__traceError) {     items.push({ id: 'circuit-render', level: 'fail', el: null, msg: 'Circuit traces could not render: ' + window.__traceError });   }@@ -1630,6 +1647,23 @@ function isTraceTheme() { return state && ['circuit-field', 'circuit-tile'].incl const TRACE_DEFAULTS = { density: 0.8, scale: 1.4, strength: 0.22, clearance: 8 }; let traceModule, traceKey = '', traceRevision = 0; window.__traceReady = Promise.resolve();+// Every CSS background image inside #hero, loaded. The renderers wait on+// fonts and <img> elements; a CSS background (the owner logo) is in neither,+// so without this an export could beat the logo and ship an empty slot+// (hero-studio#76). Resolves after two frames so the loaded image is painted.+window.__heroAssetsReady = () => {+  const hero = document.getElementById('hero');+  if (!hero) return Promise.resolve();+  const urls = new Set();+  for (const el of [hero, ...hero.querySelectorAll('*')]) {+    const bg = getComputedStyle(el).backgroundImage;+    if (!bg || bg === 'none') continue;+    for (const m of bg.matchAll(/url\(["']?(.*?)["']?\)/g)) if (m[1] && !m[1].startsWith('data:')) urls.add(m[1]);+  }+  const load = (u) => new Promise((r) => { const i = new Image(); i.onload = i.onerror = r; i.src = u; setTimeout(r, 10000); });+  return Promise.all([...urls].map(load))+    .then(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))));+}; window.__tracePending = false; window.__traceError = ''; function measureTraceKeepouts(mod, clearance) {
render-hero.mjs+2
@@ -27,6 +27,8 @@ try {     { timeout: 30000, polling: 100 },   );   await new Promise(r => setTimeout(r, 400)); // one more frame for late layout+  // CSS background images (the owner logo) are not in document.images.+  await page.evaluate(() => (window.__heroAssetsReady ? window.__heroAssetsReady() : null));   await page.waitForFunction(() => !window.__tracePending, { timeout: 30000 });   await page.evaluate(async () => { await window.__traceReady; if (window.__traceError) throw new Error(window.__traceError); });   const hero = await page.$('#hero');
render-pup.mjs+9
@@ -68,6 +68,15 @@ for (let i = 0; i < 30 && !tracesReady; i++) {   else await sleep(1000); } if (!tracesReady) die('circuit composition did not settle before export');+// CSS background images (the owner logo) load on their own; wait for them.+await evalIn("window.__hsAssets='wait';(window.__heroAssetsReady?window.__heroAssetsReady():Promise.resolve()).then(function(){window.__hsAssets='ready'});'HS-ASSETS-STARTED'");+let assetsReady = false;+for (let i = 0; i < 15 && !assetsReady; i++) {+  const r = await evalIn("window.__hsAssets==='ready'?'HS-ASSETS-READY':'HS-ASSETS-WAIT'");+  if (r && r.includes('HS-ASSETS-READY')) assetsReady = true;+  else await sleep(1000);+}+if (!assetsReady) die('the hero\'s background images (the owner logo) did not load before export');  // 5. measure #hero in viewport pixels + devicePixelRatio. Numbers only, // joined with commas: no quotes means no escaping ambiguity in the transport.
server.js+20−5
@@ -127,6 +127,9 @@ let state = {   gradAngle: 155,   guides: true, };+// Brand asset bytes by guide sha + URL (see /brand/asset).+const brandAssetCache = new Map();+  // Change ledger (hero-studio#20): everything THIS review session changed, page // fields and pose state, with first-seen originals (slider spam coalesces to@@ -1253,16 +1256,28 @@ function route(req, res, url, p) {       if (f && f.url && f.source !== 'google') target = f.url;     }     if (!target) { res.writeHead(404); return res.end('no such brand asset'); }+    // Kept per guide version: a fetch from the wiki on every request took+    // 0.25 to 0.6 s, long enough for an export to beat the logo+    // (hero-studio#76). A new guide sha is a new key.+    const key = String(g.sha || '') + ' ' + target;+    const hit = brandAssetCache.get(key);+    if (hit) {+      res.writeHead(200, { 'Content-Type': hit.type, 'Cache-Control': 'no-cache' });+      return res.end(hit.buf);+    }     const headers = {};     Object.assign(headers, PLAT.authHeader());     fetch(target, { headers })       .then(async (r) => {-        if (!r.ok) { res.writeHead(r.status); return res.end('brand asset ' + r.status); }+        if (!r.ok) {+          logLine('warn', 'brand asset ' + role + ' answered ' + r.status + ' from the wiki');+          res.writeHead(r.status); return res.end('brand asset ' + r.status);+        }         const buf = Buffer.from(await r.arrayBuffer());-        res.writeHead(200, {-          'Content-Type': r.headers.get('content-type') || 'application/octet-stream',-          'Cache-Control': 'no-cache',-        });+        const type = r.headers.get('content-type') || 'application/octet-stream';+        if (brandAssetCache.size >= 32) brandAssetCache.delete(brandAssetCache.keys().next().value);+        brandAssetCache.set(key, { buf, type });+        res.writeHead(200, { 'Content-Type': type, 'Cache-Control': 'no-cache' });         res.end(buf);       })       .catch((e) => { res.writeHead(502); res.end('brand asset fetch failed: ' + String(e).slice(0, 120)); });