Concept Mill benches: versioned prompt data, a round driver over raven-image, a structural screen, bench rows

benches/nibu.yaml owns prompt text and item identity; bench.mjs plans frozen rounds, previews captions, renders through raven-image and screens renders on Raven's Ollama; build.mjs adds one Mill row per bench item (menuGroup, promptText, generation, grade badge) and passes withoutEnlargement. A grade ranks and never hides.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-27 20:13:09 +01:00
commit 1ee54116c3
6 changed files with 741 additions and 29 deletions

View file

@ -0,0 +1,347 @@
// The Concept Mill's bench driver: the only path from a prompt bench to Raven.
//
// node scripts/concept-mill/bench.mjs plan <bench> <slug> [--items a,b] [--seeds N] [--size WxH] [--label L] [--seeds-file f.json]
// node scripts/concept-mill/bench.mjs captions <recipe> --renders <dir>
// node scripts/concept-mill/bench.mjs render <recipe> --renders <dir>
// node scripts/concept-mill/bench.mjs screen <recipe> --renders <dir>
//
// A bench (benches/<bench>.yaml) owns prompt text, item identity and the
// operator's word; the prompt rules and the standard frame clause live in the
// guideline it points at. `plan` freezes one round into rounds/<bench>/<round>.yaml
// (the exact text each image sends, and its seed). `render` calls raven-image
// per image; the PNG and the <image>.json record of the exact caption land in
// <renders>/<bench>/<round>/. `screen` grades each render on Raven's Ollama and
// writes <image>.screen.json; a grade ranks and annotates, it never hides.
//
// Environment: RAVEN_IMAGE (a path, or a JSON array command such as
// ["py","-3","<path>"]; default raven-image on PATH), RAVEN_URL (read by
// raven-image; this driver does not own the tunnel), OLLAMA_URL (default
// http://10.77.0.4:11434), SCREEN_MODEL (default qwen3.5:4b).
// js-yaml and sharp come from GameCult-Quartz, as for build.mjs.
import { createRequire } from "node:module"
import { createHash } from "node:crypto"
import { spawnSync } from "node:child_process"
import fs from "node:fs"
import path from "node:path"
import { fileURLToPath, pathToFileURL } from "node:url"
const here = path.dirname(fileURLToPath(import.meta.url))
export const repoRoot = path.resolve(here, "..", "..")
const quartzRoot = process.env.GAMECULT_QUARTZ_ROOT ?? path.resolve(repoRoot, "..", "GameCult-Quartz")
const quartzRequire = createRequire(path.join(quartzRoot, "package.json"))
export const yaml = quartzRequire("js-yaml")
export const sharp = quartzRequire("sharp")
export const benchDir = path.join(here, "benches")
export const roundDir = path.join(here, "rounds")
const guidelinePath = path.join(repoRoot, "Aetheria", "Brainstorming", "Faction Ship Concept Prompts.md")
const ID = /^[a-z0-9]+(-[a-z0-9]+)*$/
export const GRADE_RANK = { pass: 0, doubt: 1, fail: 2 }
export class BenchError extends Error {
name = "BenchError"
}
const fail = (message) => {
throw new BenchError(message)
}
const sha256 = (data) => createHash("sha256").update(data).digest("hex")
// ---------- guideline: the frame clause and the screen rubric ----------
function guideline() {
return fs.readFileSync(guidelinePath, "utf8").replace(/\r\n/g, "\n")
}
export function standardFrame() {
const line = guideline()
.split("\n")
.find((l) => l.startsWith("**Standard frame clause:**"))
if (!line) fail("the guideline has no '**Standard frame clause:**' line")
return line.slice("**Standard frame clause:**".length).trim()
}
export function rubric() {
const lines = guideline().split("\n")
const at = lines.findIndex((l) => /^#{2,4} Structural screen\s*$/.test(l))
if (at < 0) fail("the guideline has no 'Structural screen' heading")
const open = lines.findIndex((l, i) => i > at && l.startsWith("```"))
const close = lines.findIndex((l, i) => i > open && open >= 0 && l.startsWith("```"))
if (open < 0 || close < 0) fail("the Structural screen heading has no fenced rubric block")
const text = lines.slice(open + 1, close).join("\n")
return { text, sha: sha256(text) }
}
// ---------- benches and recipes ----------
export function loadBench(name) {
if (!ID.test(name)) fail(`bench name '${name}' is not a lowercase id`)
const file = path.join(benchDir, `${name}.yaml`)
if (!fs.existsSync(file)) fail(`no bench file for '${name}'`)
const bench = yaml.load(fs.readFileSync(file, "utf8"))
if (bench.bench !== name) fail(`${name}: the bench field must equal the file name`)
for (const f of ["title", "ship", "brief", "rules", "compose", "frame", "groups"]) {
if (bench[f] === undefined) fail(`${name}: missing ${f}`)
}
const frameOk = bench.frame === "standard" || (bench.frame?.text && bench.frame?.reason)
if (!frameOk) fail(`${name}: frame is 'standard' or {text, reason}`)
const items = new Map()
const groupKeys = new Set()
for (const group of bench.groups) {
if (!ID.test(group.key ?? "") || groupKeys.has(group.key)) fail(`${name}: bad or duplicate group key`)
groupKeys.add(group.key)
for (const item of group.items ?? []) {
if (!ID.test(item.id ?? "")) fail(`${name}: item id '${item.id}' is not a lowercase id`)
if (items.has(item.id)) fail(`${name}: duplicate item id ${item.id}`)
if (!item.name || !item.text) fail(`${name}/${item.id}: name and text are required`)
if (item.bet !== undefined && !["safe", "moonshot"].includes(item.bet)) fail(`${name}/${item.id}: bet is safe or moonshot`)
items.set(item.id, { item, group })
}
}
return { ...bench, items }
}
export function composeText(bench, group, item) {
const frame = bench.frame === "standard" ? standardFrame() : bench.frame.text.trim()
const blocks = { item: item.text, group: group.clause, frame }
return bench.compose
.map((b) => {
if (!(b in blocks)) fail(`${bench.bench}: unknown compose block ${b}`)
return blocks[b]
})
.filter(Boolean)
.join(", ")
}
export function loadRecipe(file) {
const recipe = yaml.load(fs.readFileSync(file, "utf8"))
for (const f of ["bench", "round", "size", "images"]) if (recipe[f] === undefined) fail(`recipe ${path.basename(file)}: missing ${f}`)
return recipe
}
export function benchNames() {
return fs.readdirSync(benchDir).filter((f) => f.endsWith(".yaml")).map((f) => f.slice(0, -5)).sort()
}
export function recipeFiles(bench) {
const dir = path.join(roundDir, bench)
if (!fs.existsSync(dir)) return []
return fs.readdirSync(dir).filter((f) => f.endsWith(".yaml")).sort().map((f) => path.join(dir, f))
}
export const imageDir = (recipe, renders) => path.join(renders, recipe.bench, recipe.round)
export const imageBase = (recipe, renders, image) => path.join(imageDir(recipe, renders), image.id)
// ---------- plan ----------
function derivedSeed(round, item, k) {
return parseInt(sha256(`${round}:${item}:${k}`).slice(0, 12), 16)
}
function plan(args) {
const [benchName, slug] = args._
if (!benchName || !slug) fail("usage: plan <bench> <slug> [--items a,b] [--seeds N] [--size WxH] [--label L] [--seeds-file f.json]")
if (!ID.test(slug)) fail("the round slug is a lowercase id")
const bench = loadBench(benchName)
const round = `${new Date().toISOString().slice(0, 10)}-${slug}`
const file = path.join(roundDir, benchName, `${round}.yaml`)
if (fs.existsSync(file)) fail(`recipe ${round} already exists; a recipe is never edited, plan a new slug`)
const size = args.size ?? "1024x1024"
if (!/^\d+x\d+$/.test(size)) fail("--size is WxH")
const explicit = args["seeds-file"] ? JSON.parse(fs.readFileSync(args["seeds-file"], "utf8")) : null
const wanted = args.items ? args.items.split(",") : [...bench.items.keys()].filter((id) => !explicit || id in explicit)
const perItem = Number(args.seeds ?? 2)
const images = []
for (const id of wanted) {
const entry = bench.items.get(id)
if (!entry) fail(`no item '${id}' in bench ${benchName}`)
const seeds = explicit ? explicit[id] : Array.from({ length: perItem }, (_, i) => derivedSeed(round, id, i + 1))
if (!seeds?.length) fail(`no seeds for item ${id}`)
const text = composeText(bench, entry.group, entry.item)
seeds.forEach((seed, i) => images.push({ id: `${benchName}-${round}-${id}-${i + 1}`, item: id, k: i + 1, seed, text }))
}
const recipe = { bench: benchName, round, label: args.label ?? slug, size, enhance: true, images }
fs.mkdirSync(path.dirname(file), { recursive: true })
fs.writeFileSync(file, yaml.dump(recipe, { lineWidth: -1, noRefs: true }))
console.log(`bench: wrote ${path.relative(repoRoot, file)} (${images.length} images)`)
}
// ---------- raven-image ----------
function ravenCommand() {
const raw = process.env.RAVEN_IMAGE ?? "raven-image"
const cmd = raw.trim().startsWith("[") ? JSON.parse(raw) : [raw]
return { program: cmd[0], lead: cmd.slice(1) }
}
function raven(argv) {
const { program, lead } = ravenCommand()
const run = spawnSync(program, [...lead, ...argv], { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 })
if (run.error) fail(`cannot run raven-image: ${run.error.code ?? "error"}`)
return run
}
const sizeOf = (recipe) => recipe.size
// ---------- captions ----------
function captions(args, recipe) {
const renders = path.resolve(args.renders ?? fail("--renders <dir> is required"))
const texts = new Map()
for (const image of recipe.images) texts.set(image.text, [...(texts.get(image.text) ?? []), image.id])
const entries = [...texts.entries()]
const out = [`# Captions: ${recipe.bench} ${recipe.round}`, "", "What the upsampler made of each distinct prompt, read before a render is spent. Look for attractors: a boat on water, a car, a bottle, a person.", ""]
entries.forEach(([text, ids], i) => {
const run = raven(["--caption-only", text, "--size", sizeOf(recipe), ...(i < entries.length - 1 ? ["--keep-loaded"] : [])])
if (run.status === 75) fail(`Raven is busy or off; ${entries.length - i} captions remain`)
if (run.status !== 0) fail(`raven-image --caption-only exited ${run.status}`)
out.push(`## ${ids.join(", ")}`, "", `Sent: ${text}`, "", `Caption: ${run.stdout.trim()}`, "")
console.log(`bench: caption ${i + 1}/${entries.length}`)
})
fs.mkdirSync(imageDir(recipe, renders), { recursive: true })
fs.writeFileSync(path.join(imageDir(recipe, renders), "captions.md"), out.join("\n"))
}
// ---------- render ----------
function render(args, recipe) {
const renders = path.resolve(args.renders ?? fail("--renders <dir> is required"))
fs.mkdirSync(imageDir(recipe, renders), { recursive: true })
const done = (image) => {
const base = imageBase(recipe, renders, image)
return fs.existsSync(`${base}.png`) && fs.existsSync(`${base}.json`)
}
const todo = recipe.images.filter((i) => !done(i))
console.log(`bench: ${recipe.images.length - todo.length} of ${recipe.images.length} already rendered; ${todo.length} to do`)
for (const [n, image] of todo.entries()) {
const base = imageBase(recipe, renders, image)
const argv = [image.text, "--size", sizeOf(recipe), "--seed", String(image.seed), "-o", `${base}.png`]
if (recipe.enhance === false) argv.push("--no-enhance")
if (n < todo.length - 1) argv.push("--keep-loaded")
const run = raven(argv)
if (run.status === 75) {
console.error(`bench: Raven is busy or off; stopped with ${todo.length - n} images remaining (run render again later)`)
process.exit(75)
}
if (run.status !== 0 || !done(image)) fail(`raven-image exited ${run.status} on ${image.id}; ${todo.length - n} images remaining`)
console.log(`bench: rendered ${recipe.images.length - todo.length + n + 1}/${recipe.images.length} ${image.id}`)
}
}
// ---------- screen ----------
function firstJson(text) {
const start = text.indexOf("{")
for (let end = text.lastIndexOf("}"); end > start; end = text.lastIndexOf("}", end - 1)) {
try {
return JSON.parse(text.slice(start, end + 1))
} catch {}
}
return null
}
const CHECKS = ["closed", "symmetric", "attached", "solid", "perspective", "spacecraft"]
export function gradeOf(checks) {
const failed = CHECKS.filter((c) => checks[c] === false).length
if (checks.spacecraft === false || failed >= 3) return "fail"
return failed ? "doubt" : "pass"
}
async function ollama(base, route, body) {
const res = await fetch(`${base}${route}`, {
method: body ? "POST" : "GET",
headers: { "content-type": "application/json" },
body: body ? JSON.stringify(body) : undefined,
signal: AbortSignal.timeout(600_000),
})
if (!res.ok) throw new Error(`ollama ${route} answered ${res.status}`)
return res.json()
}
async function screen(args, recipe) {
const renders = path.resolve(args.renders ?? fail("--renders <dir> is required"))
const base = process.env.OLLAMA_URL ?? "http://10.77.0.4:11434"
const model = process.env.SCREEN_MODEL ?? "qwen3.5:4b"
const { text: prompt, sha } = rubric()
const tags = await ollama(base, "/api/tags")
const digest = tags.models.find((m) => m.name === model)?.digest
if (!digest) fail(`model ${model} is not on the screen host`)
let graded = 0
let skipped = 0
const problems = []
for (const image of recipe.images) {
const stem = imageBase(recipe, renders, image)
const record = `${stem}.screen.json`
if (!fs.existsSync(`${stem}.png`)) continue
if (fs.existsSync(record)) {
const old = JSON.parse(fs.readFileSync(record, "utf8"))
if (old.rubric_sha256 === sha && old.model === model) {
skipped++
continue
}
}
const jpeg = await sharp(`${stem}.png`).resize(512, 512, { fit: "inside" }).jpeg({ quality: 85 }).toBuffer()
const started = Date.now()
let checks = null
let reason = ""
for (let attempt = 0; attempt < 4 && !checks; attempt++) {
try {
const reply = await ollama(base, "/api/chat", {
model,
stream: false,
think: false,
format: "json",
options: { temperature: 0 },
messages: [{ role: "user", content: prompt, images: [jpeg.toString("base64")] }],
})
const parsed = firstJson(reply.message?.content ?? "")
if (parsed && CHECKS.every((c) => typeof parsed[c] === "boolean")) {
checks = Object.fromEntries(CHECKS.map((c) => [c, parsed[c]]))
reason = String(parsed.reason ?? "").trim()
}
} catch (e) {
// The screen host's GPU may be Deru's at this moment; wait and ask again, never preempt.
await new Promise((r) => setTimeout(r, 30_000))
}
}
if (!checks) {
problems.push(image.id)
continue
}
const out = { image: image.id, model, digest, rubric_sha256: sha, checks, grade: gradeOf(checks), reason, seconds: Math.round((Date.now() - started) / 100) / 10, utc: new Date().toISOString() }
fs.writeFileSync(record, JSON.stringify(out, null, 1) + "\n")
graded++
console.log(`bench: ${image.id} ${out.grade} (${out.seconds}s)`)
}
console.log(`bench: screen graded ${graded}, kept ${skipped}, unreadable ${problems.length}`)
if (problems.length) fail(`no usable reply for ${problems.join(", ")}`)
}
// ---------- main ----------
function parseArgs(argv) {
const args = { _: [] }
for (let i = 0; i < argv.length; i++) {
if (argv[i].startsWith("--")) args[argv[i].slice(2)] = argv[++i]
else args._.push(argv[i])
}
return args
}
async function main() {
const [cmd, ...rest] = process.argv.slice(2)
const args = parseArgs(rest)
if (cmd === "plan") return plan(args)
const handlers = { captions, render, screen }
if (!handlers[cmd]) fail("commands: plan, captions, render, screen")
const file = args._[0] ?? fail(`usage: ${cmd} <recipe> --renders <dir>`)
await handlers[cmd](args, loadRecipe(path.resolve(file)))
}
if (process.argv[1] && import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href) {
main().catch((e) => {
console.error(`bench: ${e instanceof BenchError ? e.message : e.stack}`)
process.exit(1)
})
}

View file

@ -0,0 +1,206 @@
# A Concept Mill prompt bench: versioned prompt data for one ship, read by
# bench.mjs (plan, captions, render, screen) and build.mjs (the Mill's rows).
#
# This file owns the prompt text, the item identity and the operator's word on
# the bench's renders. It owns no prompt rule: `rules` points at the guideline
# section that does, and the standard frame clause is read from there.
#
# Item ids are explicit, stable and never reused; they are never positions.
# A round recipe (rounds/nibu/) freezes what was sent to Raven. Per-image
# fields (operator, pick, screen_override) are set only with the operator's
# word, keyed by image id (<bench>-<round>-<item>-<k>).
bench: nibu
title: Nibu
# Ship-level readout, shared by every row of this bench.
ship:
faction: Alakrita
code: ALK
role: Space yacht
desig: Nibu stand-in
crew: TBD
mass: TBD
brief: >-
Nibu is a small space yacht, a shuttle in the sense of Inara's in Firefly: a
self-contained home that can ride docked to a larger ship, with a full living
space (lounge, bedroom, bath, galley) in 28th-century hyper-luxury, for an
extended, private and secure romp. Alakrita language: 2010s supercars turned
up to 11, carried by flowing curves and layered sweeping panels, a glossy
shell, dark mechanism glimpsed through deliberate openings, not a car
silhouette. Centuries of crews and refits; in Terminus she comes out of a
junkyard, a degraded hull with high-grade systems inside.
rules: "Aetheria/Brainstorming/Faction Ship Concept Prompts.md#Prompting for Image-to-3D"
# A prompt is these blocks in order, joined by ", ": the item text, the group's
# clause (if it has one), the frame.
compose: [item, group, frame]
# `frame: standard` reads the guideline's "Standard frame clause" line. An
# override carries its reason.
frame:
reason: >-
Glossy hyper-luxury craft at living scale; the standard clause says matte
finishes throughout. Frozen as rendered on 2026-11-27 so the recorded seeds
reproduce.
text: >-
Concept art render of a single luxury spacecraft about thirty metres long,
large enough to live in, rows of cabin windows showing its scale, floating
in empty white space, three-quarter front view from slightly above, the
whole craft in frame, soft even studio lighting, no water, no landing gear,
no people
groups:
- key: showroom
title: "Showroom"
note: "Nibu as Alakrita built her: a small luxury spacecraft with a full living space, 28th-century hyper-luxury."
clause: "in showroom condition"
items:
- id: pearl
name: "Pearl"
text: "A small luxury spacecraft about thirty metres long, glossy pearl-white hull of long flowing curves, layered sweeping side panels like hypercar fenders, a long band of smoked lounge windows along each flank, dark graphite machinery glimpsed through a few deliberate vents, twin rear thruster nozzles"
- id: teardrop
name: "Teardrop"
text: "A compact luxury spacecraft shaped like a stretched teardrop, deep sculpted scoops flowing from bow to stern, glossy white bodywork over a dark carbon keel, a panoramic glass lounge at the bow, rows of cabin portholes, recessed thrusters"
- id: blade-wedge
name: "Blade wedge"
text: "A sharp wedge-shaped luxury spacecraft, faceted bow sweeping back into muscular rear haunches, layered aero blades along the flanks, gloss white with exposed carbon inserts, slit windows of a full living deck, four thrusters set in a low rear diffuser"
- id: haunches
name: "Haunches"
text: "A small luxury spacecraft with pronounced rear haunches over its engines, a narrow waist and a wide stern, flowing hull panels overlapping like scales, gloss ivory paint, a black glass bridge set far forward, a long skylight over the main cabin"
- id: two-decks
name: "Two decks"
text: "A luxury spacecraft with two decks under one flowing glossy white shell, an upper observation lounge with wraparound glass and a lower sleeping deck with a strip of windows, sweeping supercar panels, thrusters tucked under the stern"
- id: split-hull
name: "Split hull"
text: "A small luxury spacecraft whose hull divides into two sweeping side pods joined by a sculpted glass bridge lounge, flowing curves, gloss white over gunmetal, air gaps between panels revealing pipes and actuators"
- id: long-bow
name: "Long bow"
text: "A sleek luxury spacecraft with a seamless monocoque hull, a long low bow, cab-forward bridge glass, a sweeping shoulder line from bow to stern, carbon splitter fins, small precise thrusters, a discreet boarding ramp"
- id: reactor-under-glass
name: "Reactor under glass"
text: "A small luxury spacecraft with a glass engine cover over its stern showing a polished reactor and coiled conduits like a mid-engine supercar, flowing white hull wrapping a full living cabin with long windows, low wide stance"
- key: eleven
title: "Turned up to 11"
note: "Push the supercar language past anything that could drive on a road, at yacht scale."
clause: "in showroom condition"
items:
- id: triple-fender
name: "Triple fender"
text: "A luxury spacecraft with three layers of overlapping sweeping fender panels down each side, each layer peeling away from the hull to show dark machinery beneath, glossy white, low wide stance, a long band of cabin glass"
- id: blade-forest
name: "Blade forest"
text: "A luxury spacecraft covered in dozens of thin aerodynamic blades fanning back along its flanks and stern, glossy white blades over a black carbon core, sharp bow, glowing thruster cluster in a deep rear diffuser"
- id: all-diffuser
name: "All diffuser"
text: "A small luxury spacecraft whose entire stern is a sculpted diffuser of vertical fins with six thruster nozzles between them, flowing white hull forward with a glass lounge, aggressive and wide"
- id: offset-bridge
name: "Offset bridge"
text: "An asymmetric luxury spacecraft with the bridge offset to one side like a racing car driver pod, the flowing hull sweeping around it, glossy white, a long cabin skylight on the other side"
- id: stretched
name: "Stretched"
text: "A very long and low luxury spacecraft, needle bow, hull four times longer than wide, flowing panels pulled back as if in motion, gloss pearl paint, a continuous ribbon of cabin windows, thrusters stacked at the stern"
- id: shark-gills
name: "Shark gills"
text: "A luxury spacecraft with rows of deep curved gill vents along each flank glowing faintly from within, flowing white hull, pronounced haunches, black bridge glass, a skylight over the main suite"
- id: carbon-jewel
name: "Carbon jewel"
text: "A small luxury spacecraft built like a jewel-cut hypercar, glossy white panels set into an exposed woven carbon frame, sharp creases meeting soft curves, polished metal thruster bells, faceted cabin windows"
- id: spoiler-crown
name: "Spoiler crown"
text: "A luxury spacecraft with a huge swan-neck spoiler wing arching over its stern, flowing white hull, sculpted side intakes, the wing struts carrying thrusters, a sun deck under glass"
- key: suite
title: "The suite"
note: "A full living space for a billionaire bachelor's extended, private and secure romp: lounge, bedroom, bath, galley."
clause: "in showroom condition"
items:
- id: glass-belly
name: "Glass belly"
text: "A small luxury spacecraft with its lounge and bedroom visible through a curved glass belly, warm light inside, flowing white luxury hull above, sweeping panels, discreet thrusters"
- id: seam-glow
name: "Seam glow"
text: "A luxury spacecraft with soft warm light glowing through the seams between its curved hull panels and through privacy-tinted cabin windows, glossy white hull, elegant and inviting"
- id: filigree
name: "Filigree"
text: "A hyper-luxury spacecraft with fine engraved filigree inlays on its glossy white hull panels, champagne-gold trim along the creases, smoked cabin glass, a bedroom skylight, slim thrusters"
- id: eyelids
name: "Eyelids"
text: "A small luxury spacecraft with a soft-glowing sensor band across its bow shaded by curved panels like eyelids, giving it a gentle attentive face, flowing white hull, long cabin windows behind"
- id: docking-collar
name: "Docking collar"
text: "An elegant luxury spacecraft with a polished docking collar ring on its dorsal spine, framed by flowing white hull panels, built to ride docked to a larger ship like a guest suite, cabin windows along both sides"
- id: observation-suite
name: "Observation suite"
text: "A luxury spacecraft whose stern opens into a bubble observation suite with a large bed facing the stars, flowing white hull cradling it, short wings, twin thrusters"
- id: private-and-secure
name: "Private and secure"
text: "A discreet hyper-luxury spacecraft, flowing glossy white hull with privacy-tinted windows, flush-fitting armoured shutters ready to close over the cabin glass, concealed sensor blisters, no visible markings"
- key: custody
title: "Custody scars"
note: "Centuries of owners: refits, repairs and claims layered over the original elegance."
items:
- id: primer-panel
name: "Primer panel"
text: "A small luxury spacecraft with flowing glossy white curves, one hull panel replaced with a crude flat panel in raw grey primer, mismatched bolts, the original sweeping lines interrupted"
- id: industrial-collar
name: "Industrial collar"
text: "An elegant luxury spacecraft with a heavy industrial docking collar bolted onto its graceful dorsal spine, thick cables strapped along the hull, glossy white paint scuffed around the new hardware"
- id: welded-armour
name: "Welded armour"
text: "A luxury spacecraft with flowing white curves partly covered by crude welded armour plates, rough weld seams across the sculpted panels, cabin windows plated over with steel"
- id: wrong-thruster
name: "Wrong thruster"
text: "A sleek luxury spacecraft with one of its elegant thrusters replaced by a blocky industrial thruster from another maker, mismatched colours, flowing hull otherwise intact"
- id: claim-stencils
name: "Claim stencils"
text: "A small luxury spacecraft with salvage-claim stencils and registry numbers painted over its glossy curves, paint scraped where older markings were removed, flowing panels"
- id: cable-runs
name: "Cable runs"
text: "A luxury spacecraft with bundles of external cables and pipes strapped along its flowing white hull by later crews, a crude sensor mast added on top, the original sculpted lines still visible"
- id: patchwork
name: "Patchwork"
text: "A luxury spacecraft repaired many times, panels in three shades of white and grey, some original glossy curved panels and some flat replacements, riveted patches, worn but elegant"
- key: junkyard
title: "Junkyard"
note: "Terminus Nibu: a degraded hull with high-grade systems inside."
items:
- id: gleam-within
name: "Gleam within"
text: "A derelict luxury spacecraft with faded cracked white paint and pitted flowing panels, but pristine gleaming high-tech machinery visible through its openings and broken windows"
- id: yellowed-pearl
name: "Yellowed pearl"
text: "An old luxury spacecraft whose pearl paint has yellowed and flaked, several hull panels missing to expose immaculate polished mechanisms underneath, flowing curves still graceful"
- id: cracked-glass
name: "Cracked glass"
text: "An abandoned luxury spacecraft with its lounge glass cracked and patched with metal plates, dented flowing white hull, a thruster bell scorched dark, sculpted lines intact"
- id: half-restored
name: "Half restored"
text: "A small luxury spacecraft half restored: one side glossy white with flowing sculpted panels and clean cabin glass, the other side bare frame and exposed machinery"
- id: stripped
name: "Stripped"
text: "A luxury spacecraft stripped by salvagers, most outer panels removed leaving a few sweeping white curves on a dark mechanical skeleton, still recognisably elegant"
- key: wild
title: "Wildcards"
note: "Odd angles on the brief. Most will miss; one might be her."
clause: "in showroom condition"
items:
- id: wing-body
name: "Wing-body"
text: "A luxury spacecraft with a wide, flat, flowing wing-body that tapers to a whip-thin tail, gill slits along its underside showing dark machinery, glossy white top with a long cabin skylight"
- id: cut-crystal
name: "Cut crystal"
text: "A luxury spacecraft with the faceted, jewel-like proportions of cut crystal, a sculpted glossy white hull rising to a faceted glass lounge on top, flowing curves meeting crisp facets, precise thrusters"
- id: racing-livery
name: "Racing livery"
text: "A luxury spacecraft with flowing hypercar curves and a bold motorsport livery stripe running bow to stern, glossy white base, carbon aero details, long cabin windows"
- id: plan-view
name: "Plan view"
text: "A luxury spacecraft whose top-down outline is a hypercar plan view stretched into a dart, flowing white panels, deep side intakes, a glass lounge at the centre, thrusters at the stern"
- id: ribs
name: "Ribs"
text: "A luxury spacecraft with a flowing white outer shell held by a few exposed sculpted ribs, dark machinery visible between them, cabin glass between the ribs, elegant and light"
- id: swept-wings
name: "Swept wings"
text: "A small luxury spacecraft with short swept wings that flow out of its hull panels like sculpted fenders, glossy white, smoked cabin glass, thrusters at the wingtips"

View file

@ -1,28 +1,28 @@
// Builds the Concept Mill's manifest and render derivatives from ships.yaml.
// Builds the Concept Mill's manifest and render derivatives from two inputs:
// ships.yaml (hand-curated ships) and the prompt benches (benches/<bench>.yaml
// with their frozen rounds in rounds/<bench>/, rendered through bench.mjs).
//
// node scripts/concept-mill/build.mjs [--renders <dir>] [--force]
//
// For every variant with a `source`, it writes a 1600 px WebP and a thumbnail
// into Aetheria/media/concept-mill/ and publishes the render's .md record as
// prompts/<image>.txt. Originals are only read. Existing derivatives are kept
// unless --force is given, so a run without the renders on disk still works.
// It then reads each variant's hypothesis and verdict from its published
// record and writes the manifest the page component imports.
// For every variant with a `source`, and every bench image, it writes a WebP
// of at most 1600 px (never enlarged) and a thumbnail into
// Aetheria/media/concept-mill/ and publishes the render's record as
// prompts/<image>.txt: the .md for a ships.yaml render, text generated from
// raven-image's <image>.json for a bench render. Originals are only read.
// Existing derivatives are kept unless --force is given, so a run without the
// renders on disk still works. It then writes the manifest the page component
// imports. A bench item with renders is one row; its images are the variants.
// A screen grade ranks and annotates a bench render; none removes one.
//
// js-yaml and sharp come from GameCult-Quartz, which the site build already
// requires beside this repo (or at GAMECULT_QUARTZ_ROOT).
import { createRequire } from "node:module"
import fs from "node:fs/promises"
import path from "node:path"
import { fileURLToPath } from "node:url"
import { GRADE_RANK, benchNames, imageBase, loadBench, loadRecipe, recipeFiles, repoRoot, rubric, sharp, yaml } from "./bench.mjs"
const here = path.dirname(fileURLToPath(import.meta.url))
const repoRoot = path.resolve(here, "..", "..")
const quartzRoot = process.env.GAMECULT_QUARTZ_ROOT ?? path.resolve(repoRoot, "..", "GameCult-Quartz")
const quartzRequire = createRequire(path.join(quartzRoot, "package.json"))
const yaml = quartzRequire("js-yaml")
const sharp = quartzRequire("sharp")
const args = process.argv.slice(2)
const flag = (name) => args.includes(name)
@ -48,6 +48,12 @@ const SECTIONS = [
const exists = (p) => fs.access(p).then(() => true, () => false)
async function derive(image, png) {
const opts = { width: FULL_WIDTH, withoutEnlargement: true }
await sharp(png).resize(opts).webp({ quality: 82 }).toFile(path.join(mediaDir, `${image}.webp`))
await sharp(png).resize({ ...opts, width: THUMB_WIDTH }).webp({ quality: 72 }).toFile(path.join(mediaDir, `${image}-thumb.webp`))
}
async function ingest(variant) {
const full = path.join(mediaDir, `${variant.image}.webp`)
const thumb = path.join(mediaDir, `${variant.image}-thumb.webp`)
@ -59,8 +65,7 @@ async function ingest(variant) {
if (!(await exists(png)) || !(await exists(md))) {
throw new Error(`${variant.image}: derivatives missing and source not found at ${png}`)
}
await sharp(png).resize({ width: FULL_WIDTH }).webp({ quality: 82 }).toFile(full)
await sharp(png).resize({ width: THUMB_WIDTH }).webp({ quality: 72 }).toFile(thumb)
await derive(variant.image, png)
await fs.copyFile(md, record)
return true
}
@ -128,15 +133,144 @@ for (const ship of data.ships) {
crew: String(ship.crew),
hardpoints: ship.hardpoints.map(([qty, size, mount]) => ({ qty: String(qty), size, mount })),
variants,
menuGroup: ship.faction,
defaultVariant: variants[ship.variants.findIndex((v) => v.pick || v.default)]?.id ?? variants[variants.length - 1].id,
})
}
// Menu order: section, then faction in first-seen order, then file order.
// ---------- bench rows ----------
// One row per bench item that has renders; its variants are that item's images,
// in round order then by k. Ship ids and bench row ids share one namespace.
const readJson = async (file) => JSON.parse(await fs.readFile(file, "utf8"))
function benchRecord(bench, group, item, recipe, image, run, screen) {
const lines = [
`# ${image.id}`,
"",
`Bench: ${bench.title} (${bench.bench}) · round ${recipe.label} (${recipe.round}) · group ${group.title}`,
`Item: ${item.id} · ${item.name}${item.bet ? ` · ${item.bet}` : ""}`,
`Group note: ${group.note}`,
"",
"## Text sent to the upsampler",
"",
image.text,
"",
"## Final caption",
"",
"The exact text the image model's encoder received.",
"",
run.caption,
"",
"## Generation",
"",
`Model ${run.models?.["1"]} · upsampler ${run.models?.["10"] ?? "off"} · seed ${run.seed} · ${run.size} · ${run.steps} steps · cfg ${run.cfg} · ${run.sampler}/${run.scheduler} · raven-image ${String(run.client_sha256).slice(0, 12)}, graph ${String(run.graph_sha256).slice(0, 12)} · ${run.utc}`,
]
if (screen) {
lines.push("", "## Structural screen", "", `${screen.model} (${String(screen.digest).slice(0, 12)}), rubric ${screen.rubric_sha256.slice(0, 12)}: ${screen.grade}. ${screen.reason}`)
if (screen.override) lines.push(`Operator correction: ${screen.override.grade}. ${screen.override.reason}`)
}
return lines.join("\n") + "\n"
}
// An unscreened render ranks as a doubt: no grade is no reason to bury it.
const rank = (v) => GRADE_RANK[v.screen?.grade ?? "doubt"]
const benchRows = []
let staleScreens = 0
try {
const currentRubric = rubric().sha
for (const name of benchNames()) {
const bench = loadBench(name)
const recipes = recipeFiles(name).map(loadRecipe)
const known = new Set(recipes.flatMap((r) => r.images.map((i) => i.id)))
for (const id of Object.keys(bench.images ?? {})) if (!known.has(id)) fail(`${name}: images.${id} names no recipe image`)
for (const [itemId, { item, group }] of bench.items) {
const rowId = `${name}-${itemId}`
if (shipIds.has(rowId)) fail(`bench row id ${rowId} collides with a ship id`)
const variants = []
for (const recipe of recipes) {
const roundId = recipe.round.replace(/^\d{4}-\d{2}-\d{2}-/, "")
for (const image of recipe.images.filter((i) => i.item === itemId).sort((a, b) => a.k - b.k)) {
const stem = imageBase(recipe, rendersRoot, image)
const have = (await exists(path.join(mediaDir, `${image.id}.webp`))) && (await exists(path.join(mediaDir, `${image.id}-thumb.webp`)))
const rendered = (await exists(`${stem}.png`)) && (await exists(`${stem}.json`))
if ((await exists(`${stem}.png`)) !== (await exists(`${stem}.json`))) fail(`${image.id}: the render and its .json record must both exist`)
if (!have && !rendered) continue
const mine = bench.images?.[image.id] ?? {}
const model = (await exists(`${stem}.screen.json`)) ? await readJson(`${stem}.screen.json`) : null
if (model && model.rubric_sha256 !== currentRubric) staleScreens++
const override = mine.screen_override
if (override && !(override.grade in GRADE_RANK && override.reason)) fail(`${image.id}: screen_override needs a grade and a reason`)
let screen
if (model) screen = { grade: model.grade, reason: model.reason, corrected: false }
if (override) screen = { grade: override.grade, reason: override.reason, corrected: true, modelGrade: model?.grade }
if (rendered) {
const run = await readJson(`${stem}.json`)
if (!have || force) await derive(image.id, `${stem}.png`)
const record = benchRecord(bench, group, item, recipe, image, run, model && { ...model, override })
const target = path.join(promptDir, `${image.id}.txt`)
if (!(await exists(target)) || (await fs.readFile(target, "utf8")) !== record) {
await fs.writeFile(target, record)
ingested++
}
}
if (!(await exists(path.join(promptDir, `${image.id}.txt`)))) fail(`${image.id}: missing prompts/${image.id}.txt`)
variants.push({
id: `${roundId}-${image.k}`,
round: recipe.label,
image: `${mediaUrl}${image.id}.webp`,
thumb: `${mediaUrl}${image.id}-thumb.webp`,
prompt: `${mediaUrl}prompts/${image.id}.txt`,
hypothesis: group.note,
promptText: image.text,
generation: `FLUX.3 Klein · seed ${image.seed} · ${recipe.size} · upsampler ${recipe.enhance === false ? "off" : "on"}`,
operator: mine.operator,
pick: Boolean(mine.pick),
screen,
})
}
}
if (!variants.length) continue
if (new Set(variants.map((v) => v.id)).size !== variants.length) fail(`${rowId}: duplicate variant id`)
if (variants.filter((v) => v.pick).length > 1) fail(`${rowId}: more than one pick variant`)
const status = item.status ?? { kind: "new", stamp: "UNREVIEWED", verdict: "Bench prompt; awaiting the operator" }
if (!SECTIONS.some((s) => s.kind === status.kind)) fail(`${rowId}: unknown status kind`)
// Default: the lab pick, else the best-graded render (latest round first).
const best = [...variants].reverse().sort((a, b) => rank(a) - rank(b))[0]
benchRows.push({
id: rowId,
name: item.name,
code: bench.ship.code,
faction: bench.ship.faction,
role: bench.ship.role,
desig: bench.ship.desig,
crew: String(bench.ship.crew),
mass: bench.ship.mass,
hardpoints: [],
loadout: [],
concept: bench.brief.replace(/\s+/g, " ").trim(),
notes: `${item.bet ? `${item.bet === "safe" ? "Safe bet" : "Moonshot"}. ` : ""}${group.note}`,
beaten: "",
status,
variants,
menuGroup: `${bench.title} · ${group.title}`,
defaultVariant: (variants.find((v) => v.pick) ?? best).id,
})
shipIds.add(rowId)
}
}
} catch (e) {
if (e.name === "BenchError") fail(e.message)
throw e
}
if (staleScreens) console.warn(`concept-mill: ${staleScreens} screen grades predate the current rubric; run bench.mjs screen to re-screen`)
ships.push(...benchRows)
// Menu order: section, then menu group in first-seen order, then file order.
const ordered = SECTIONS.flatMap(({ kind }) => {
const inSection = ships.filter((s) => s.status.kind === kind)
const factions = [...new Set(inSection.map((s) => s.faction))]
return factions.flatMap((f) => inSection.filter((s) => s.faction === f))
const groups = [...new Set(inSection.map((s) => s.menuGroup))]
return groups.flatMap((g) => inSection.filter((s) => s.menuGroup === g))
})
const manifest = {

View file

@ -18,6 +18,11 @@
# .md record) relative to the renders root, for variants the build ingests.
# `pick: true` marks the lab's choice (shown as LAB PICK and opened first).
# `operator` holds a verdict the operator gave on that render, verbatim.
#
# Flux bench renders (the prompt benches) are not listed here. benches/<bench>.yaml
# holds a bench's prompts and the operator's words on its renders (keyed by image
# id), rounds/<bench>/ holds each frozen round, and bench.mjs renders them through
# raven-image. build.mjs adds one row per bench item to the manifest.
# The vote slot in the readout stays hidden until this is enabled and an
# endpoint exists (planned: Bifrost vote API, concept-mill-votes-plan.md).

View file

@ -13,12 +13,17 @@ type Variant = {
verdict?: string
operator?: string
pick: boolean
promptText?: string
generation?: string
// A bench render's structural grade: a rank and an annotation, never a filter.
screen?: { grade: "pass" | "doubt" | "fail"; reason: string; corrected: boolean; modelGrade?: string }
}
type Ship = {
id: string
name: string
code: string
faction: string
menuGroup: string
role: string
desig: string
crew: string
@ -85,12 +90,12 @@ function setup(root: HTMLElement) {
const inSection = ships.filter((s) => s.status.kind === section.kind)
if (!inSection.length) continue
menuHtml += `<section class="cm-group is-${section.kind}"><h2>${esc(section.title)} <span>${inSection.length}</span></h2>`
for (const faction of [...new Set(inSection.map((s) => s.faction))]) {
menuHtml += `<h3>${esc(faction)}</h3><ul>`
for (const ship of inSection.filter((s) => s.faction === faction)) {
for (const group of [...new Set(inSection.map((s) => s.menuGroup))]) {
menuHtml += `<h3>${esc(group)}</h3><ul>`
for (const ship of inSection.filter((s) => s.menuGroup === group)) {
const i = ships.indexOf(ship)
const v = ship.variants.find((x) => x.id === ship.defaultVariant)!
menuHtml += `<li><button type="button" class="cm-item is-${ship.status.kind}" data-ship="${i}"><img src="${v.thumb}" alt="" loading="lazy" width="720" height="540" /><span class="cm-item-name">${esc(ship.name)}</span><span class="cm-item-role">${esc(ship.role)}${ship.variants.length > 1 ? ` · ${ship.variants.length} renders` : ""}</span></button></li>`
menuHtml += `<li><button type="button" class="cm-item is-${ship.status.kind}" data-ship="${i}"><img src="${v.thumb}" alt="" loading="lazy" width="720" height="540" /><span class="cm-item-name">${esc(ship.name)}</span><span class="cm-item-role">${esc(ship.role)}${ship.variants.length > 1 ? ` · ${ship.variants.length} renders` : ""}${ship.variants.some((x) => x.screen) ? ` · ${ship.variants.reduce((n, x) => n + (x.screen?.grade === "pass" ? 1 : 0), 0)} pass` : ""}</span></button></li>`
}
menuHtml += `</ul>`
}
@ -273,13 +278,13 @@ function setup(root: HTMLElement) {
? `<div class="cm-rounds" role="group" aria-label="Render rounds">${ship.variants
.map(
(v) =>
`<button type="button" data-variant="${esc(v.id)}" class="${v.id === variant.id ? "is-current" : ""}${v.pick ? " is-pick" : ""}" aria-pressed="${v.id === variant.id}"><img src="${v.thumb}" alt="" loading="lazy" width="720" height="540" /><span>${esc(v.round)}</span></button>`,
`<button type="button" data-variant="${esc(v.id)}" class="${v.id === variant.id ? "is-current" : ""}${v.pick ? " is-pick" : ""}" aria-pressed="${v.id === variant.id}"><img src="${v.thumb}" alt="" loading="lazy" width="720" height="540" /><span>${esc(v.round)}</span>${v.screen ? `<b class="cm-grade is-${v.screen.grade}" title="${esc(`${v.screen.corrected ? "Corrected by the operator" : "Structural screen"}: ${v.screen.grade}`)}">${v.screen.grade}${v.screen.corrected ? " *" : ""}</b>` : ""}</button>`,
)
.join("")}</div>`
: ""
const note =
variant.hypothesis || variant.verdict || variant.operator
? `<div class="cm-variant-note">${variant.hypothesis ? `<p><span class="cm-k">Hypothesis</span>${esc(variant.hypothesis)}</p>` : ""}${variant.verdict ? `<p><span class="cm-k">Lab verdict</span>${esc(variant.verdict)}</p>` : ""}${variant.operator ? `<p class="cm-operator"><span class="cm-k">Operator</span>“${esc(variant.operator)}”</p>` : ""}</div>`
variant.hypothesis || variant.verdict || variant.operator || variant.promptText || variant.screen
? `<div class="cm-variant-note">${variant.hypothesis ? `<p><span class="cm-k">Hypothesis</span>${esc(variant.hypothesis)}</p>` : ""}${variant.promptText ? `<p><span class="cm-k">Prompt</span>${esc(variant.promptText)}</p>` : ""}${variant.generation ? `<p><span class="cm-k">Generation</span>${esc(variant.generation)}</p>` : ""}${variant.screen ? `<p><span class="cm-k">${variant.screen.corrected ? "Screen, corrected" : "Screen"}</span>${esc(variant.screen.grade)}${variant.screen.corrected && variant.screen.modelGrade ? ` (model: ${esc(variant.screen.modelGrade)})` : ""}${variant.screen.reason ? `: ${esc(variant.screen.reason)}` : ""}</p>` : ""}${variant.verdict ? `<p><span class="cm-k">Lab verdict</span>${esc(variant.verdict)}</p>` : ""}${variant.operator ? `<p class="cm-operator"><span class="cm-k">Operator</span>“${esc(variant.operator)}”</p>` : ""}</div>`
: ""
const tally = votesOn && tallies?.[ship.id]
const votes = votesOn
@ -301,14 +306,14 @@ function setup(root: HTMLElement) {
<div><dt>Mass class</dt><dd>${esc(ship.mass)}</dd></div>
<div class="cm-wide"><dt>Status</dt><dd>${esc(ship.status.verdict)}</dd></div>
</dl>
<div class="cm-row" style="--i:3">
${ship.hardpoints.length ? `<div class="cm-row" style="--i:3">
<p class="cm-label">Hardpoints <span class="cm-glyphs" aria-hidden="true">${glyphs}</span></p>
<table class="cm-hp"><thead><tr><th>Qty</th><th>Size</th><th>Mount · arc</th></tr></thead><tbody>${rows}</tbody></table>
</div>
<div class="cm-row" style="--i:4"><p class="cm-label">Default loadout</p><ul class="cm-loadout">${ship.loadout.map((x) => `<li>${esc(x)}</li>`).join("")}</ul></div>
</div>` : ""}
${ship.loadout.length ? `<div class="cm-row" style="--i:4"><p class="cm-label">Default loadout</p><ul class="cm-loadout">${ship.loadout.map((x) => `<li>${esc(x)}</li>`).join("")}</ul></div>` : ""}
<div class="cm-row" style="--i:5"><p class="cm-label">Play concept</p><p>${esc(ship.concept)}</p></div>
<div class="cm-row" style="--i:6"><p class="cm-label">Notes</p><p>${esc(ship.notes)}</p></div>
<div class="cm-row cm-beaten" style="--i:7"><p class="cm-label">Beaten by</p><p>${esc(ship.beaten)}</p></div>
${ship.beaten ? `<div class="cm-row cm-beaten" style="--i:7"><p class="cm-label">Beaten by</p><p>${esc(ship.beaten)}</p></div>` : ""}
${votes}
<p class="cm-links cm-row" style="--i:8"><a href="${variant.prompt}" target="_blank" rel="noopener" data-router-ignore data-no-popover="true">Prompt record ↗</a><a href="${variant.image}" target="_blank" rel="noopener" data-router-ignore data-no-popover="true">Full render ↗</a></p>`
if (animate && !reduce) {

View file

@ -621,6 +621,21 @@ $narrow: "(max-width: 800px)";
&:focus-visible img {
outline: 1px solid var(--cm-action);
}
// A bench render's structural grade: it ranks, it never hides.
.cm-grade {
display: block;
font-weight: 400;
color: var(--cm-new);
&.is-pass {
color: var(--cm-data);
}
&.is-fail {
color: var(--cm-scrap);
}
}
}
}