Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
style(comments): replace the banned dash characters that block the push
nirholas4452283f259e
diff --git a/api/_lib/forge-job-options.js b/api/_lib/forge-job-options.jsindex 3cdc6428a..4b4ea4522 100644--- a/api/_lib/forge-job-options.js+++ b/api/_lib/forge-job-options.js@@ -51,7 +51,7 @@ export async function bindJobToOptions(jobHandle, opts, { redis } = {}) {/*** Resolve the post-generation choices bound to a job handle, or null when none- * were bound (the common case — no options requested, or Redis unavailable).+ * were bound (the common case: no options requested, or Redis unavailable).*/export async function optionsForJob(jobHandle, { redis } = {}) {const r = client(redis);diff --git a/api/_lib/forge-options.js b/api/_lib/forge-options.jsindex b46b16f0c..a87e5817c 100644--- a/api/_lib/forge-options.js+++ b/api/_lib/forge-options.js@@ -8,7 +8,7 @@// • output_format — glb (default) or a compressed variant (draco / meshopt)// • texture_size — bake textures at a specific resolution// • target_polycount — explicit geometry budget on poly-aware backends-// • derive_pbr — the ONE exception to "off by default": the material+// • derive_pbr : the ONE exception to "off by default": the material// completion pass (glb-pbr-derive.js) runs on every delivered mesh, because// an albedo-only material is a defect rather than a preference. Send// `derive_pbr: false` to receive the lane's own materials untouched.@@ -45,7 +45,7 @@ function compressionFor(format) {* compression: 'none' | 'draco' | 'meshopt',* textureSize: number | null,* targetPolycount: number | null,- * derivePbr: boolean, // material completion pass — true unless opted out+ * derivePbr: boolean, // material completion pass, true unless opted out* hasOptions: boolean, // true iff any non-default option was supplied* errors: Array<{ field: string, message: string }>,* }}@@ -113,7 +113,7 @@ export function normalizeForgeOptions(body) {}}- // derive_pbr — opt-OUT. Anything other than an explicit boolean false leaves+ // derive_pbr: opt-OUT. Anything other than an explicit boolean false leaves// the completion pass on; a non-boolean value is reported rather than// silently coerced, so `derive_pbr: "no"` never reads as true.let derivePbr = true;diff --git a/api/_lib/forge-store.js b/api/_lib/forge-store.jsindex aaf3995b2..b66f17669 100644--- a/api/_lib/forge-store.js+++ b/api/_lib/forge-store.js@@ -21,7 +21,7 @@ import { putObject, publicUrl, deleteObject, keyFromPublicUrl, objectStorageConfimport { recordDailyActivity, maybeAwardFirstCreation } from './streaks.js';import { recordGenerationEvent } from './forge-events.js';import { scoreGlbQuality } from './glb-quality.js';-import { compressGlb } from './glb-compress.js';+import { compressGlb, deliveryCompressionOptions } from './glb-compress.js';import { classifyModelCategory } from './forge-classify.js';import { cleanupGlb } from './glb-cleanup.js';import { derivePbrChannels } from './glb-pbr-derive.js';@@ -273,7 +273,7 @@ const COPY_TIMEOUT_MS = 120_000;// Score, clean, derive PBR channels for, and (optionally) compress a freshly// downloaded GLB before it lands in the bucket. Every step is pure, local, and-// best-effort: a failure never blocks delivery — it just means the response+// best-effort: a failure never blocks delivery; it just means the response// carries no quality signal, or ships the un-cleaned / uncompressed bytes.// `compress` is one of COMPRESSION_MODES ('draco' | 'meshopt') or falsy to// skip. `cleanup` runs the codec-independent geometry cleanup (glb-cleanup.js)@@ -448,6 +448,61 @@ function gradeDeliveredMesh({ buffer, creationId, sourceUrl }) {.catch((err) => console.warn('[forge-store] simulation-readiness grading failed:', err?.message));}+// The web-delivery variant of a finished mesh: meshopt geometry plus WebP+// textures capped at 2048 px (api/_lib/glb-compress.js). On the six production+// forge outputs sampled on 2026-09-04 it cut 1.25-3.34 MB down to 0.11-0.67 MB,+// which on a phone over slow 4G is the difference between a mesh that arrives in+// seconds and one that does not arrive at all.+//+// Two deliberate choices:+//+// 1. It is a SECOND object, never a replacement. `glb_url` keeps exactly the+// bytes the caller's `output_format` asked for, so the download action hands+// back the full-resolution original and a third-party consumer with a bare+// GLTFLoader is never handed an EXT_meshopt_compression file it cannot+// decode. Our own viewers ask for `web_glb_url` and fall back on a decode+// failure.+// 2. It runs AFTER the row is flipped to 'done', fire-and-forget, exactly like+// gradeDeliveredMesh above. The pass costs 2-6 s of CPU; the person waiting+// on their generation must never wait on it, and must never lose a finished+// model because a compression bug or an instance recycle killed the request.+// A row whose variant never lands simply keeps `web_glb_url` null, and every+// reader treats null as "serve glb_url".+//+// Skips meshes already small enough that the pass cannot pay for itself.+const WEB_VARIANT_MIN_BYTES = 512 * 1024;+// Below this the variant is not worth a second object: keep storage honest.+const WEB_VARIANT_MIN_GAIN = 0.9;++export function buildWebVariant({ buffer, creationId, keyPrefix, clientKey }) {+ if (!buffer?.length || buffer.length < WEB_VARIANT_MIN_BYTES) return Promise.resolve(null);+ const key = `${keyPrefix}.web.glb`;+ return Promise.resolve()+ .then(() => compressGlb(buffer, deliveryCompressionOptions()))+ .then(async (result) => {+ if (result.grew || result.outputBytes > buffer.length * WEB_VARIANT_MIN_GAIN) return null;+ await putObject({+ key,+ body: result.buffer,+ contentType: 'model/gltf-binary',+ metadata: { source: 'forge-web-variant' },+ });+ await sql`+ update forge_creations+ set web_glb_key = ${key},+ web_glb_url = ${publicUrl(key)},+ web_size_bytes = ${result.outputBytes},+ updated_at = now()+ where id = ${creationId}${clientKey ? sql` and client_key = ${clientKey}` : sql``}+ `;+ return { key, url: publicUrl(key), bytes: result.outputBytes };+ })+ .catch((err) => {+ console.warn('[forge-store] web delivery variant failed:', err?.message);+ return null;+ });+}+// Copy a finished generation into durable storage and flip the row to 'done'.// Copies the mesh (required) and the reference image (best-effort). Returns the// durable { id, glbUrl, previewImageUrl, quality, compression } or null on any@@ -554,6 +609,9 @@ export async function materializeCreation({ replicateJobId, clientKey, glbUrl, q});// Every delivered mesh gets a physics grade, cached by content hash.gradeDeliveredMesh({ buffer: glb.buffer, creationId: existing.id, sourceUrl: glb.publicUrl });+ // …and a phone-sized delivery variant. See buildWebVariant for why this is+ // a second object and why it runs after the row is already 'done'.+ buildWebVariant({ buffer: glb.buffer, creationId: existing.id, keyPrefix, clientKey });// A finished, signed-in creation is a qualifying streak action + the// trigger for the "first creation" badge. Fire-and-forget — never blocks// delivery of the model itself.diff --git a/api/_lib/migrations/20260904020000_sniper_risk_officer.sql b/api/_lib/migrations/20260904020000_sniper_risk_officer.sqlindex 3deee0ebc..a663bd32c 100644--- a/api/_lib/migrations/20260904020000_sniper_risk_officer.sql+++ b/api/_lib/migrations/20260904020000_sniper_risk_officer.sql@@ -11,7 +11,7 @@---- This migration adds:----- 1. agent_sniper_strategies.risk_officer_level — per-strategy enforcement.+-- 1. agent_sniper_strategies.risk_officer_level: per-strategy enforcement.-- 'shadow' (default): the review runs and is recorded, and changes nothing.-- 'enforce': a 'block' severity aborts the buy; a smaller-- size_adjustment shrinks it.@@ -20,12 +20,12 @@-- buys with real SOL, so arming it is an owner decision, not a deploy-time-- default, and shadow rows are the evidence that decision needs.----- 2. agent_sniper_strategies.risk_officer_model — optional per-strategy model+-- 2. agent_sniper_strategies.risk_officer_model: optional per-strategy model-- override. Left null, the officer uses SNIPER_RISK_OFFICER_MODEL, which-- deliberately differs from the buy-side judge's model so the second-- opinion is not an echo of the first.----- 3. sniper_risk_reviews — append-only ledger of every review, enforced or+-- 3. sniper_risk_reviews: append-only ledger of every review, enforced or-- not. A shadow row records the veto that WOULD have been cast against a-- position that actually opened, so the position's realized P&L later says-- whether the officer was right.diff --git a/scripts/inspect-glb-materials.mjs b/scripts/inspect-glb-materials.mjsindex d6fd8e6d2..bb331447e 100755--- a/scripts/inspect-glb-materials.mjs+++ b/scripts/inspect-glb-materials.mjs@@ -26,6 +26,7 @@import { readFile } from 'node:fs/promises';import { basename, resolve } from 'node:path';+import { pathToFileURL } from 'node:url';import { Buffer } from 'node:buffer';import { NodeIO } from '@gltf-transform/core';import { ALL_EXTENSIONS } from '@gltf-transform/extensions';@@ -35,7 +36,7 @@ import sharp from 'sharp';// The five texture slots glTF 2.0 defines on a metallic-roughness material, in// the order a reader cares about them: what colour is it, what shape is the// surface, how does it reflect, where is it occluded, does it glow.-const CHANNELS = Object.freeze([+export const CHANNELS = Object.freeze([{ key: 'baseColor', label: 'baseColor', get: (m) => m.getBaseColorTexture() },{ key: 'normal', label: 'normal', get: (m) => m.getNormalTexture() },{ key: 'metallicRoughness', label: 'metallicRoughness', get: (m) => m.getMetallicRoughnessTexture() },@@ -113,7 +114,7 @@ function resolutionOf(info) {* style choice, and a non-zero metalness with no metallicRoughness map means* every texel reflects identically.*/-function expectedGaps(material, channels) {+export function expectedGaps(material, channels) {const gaps = [];if (!channels.baseColor?.present) return gaps; // untextured material: nothing impliedif (!channels.normal?.present) gaps.push('normal');@@ -122,7 +123,7 @@ function expectedGaps(material, channels) {return gaps;}-async function inspectOne({ source, label }) {+export async function inspectOne({ source, label }) {const bytes = await loadBytes(source);const io = new NodeIO().registerExtensions(ALL_EXTENSIONS)@@ -148,7 +149,7 @@ async function inspectOne({ source, label }) {}// A primitive with no material takes glTF's default material, whose- // metallicFactor and roughnessFactor are both 1.0 — it renders as rough bare+ // metallicFactor and roughnessFactor are both 1.0, so it renders as rough bare// metal. Counting these separately matters because such a model reports// "0 materials" rather than "1 broken material".let unmaterialed = 0;@@ -200,7 +201,7 @@ function printReport(report) {}/** The markdown lane table that ships in workers/texture/README.md. */-function printMatrix(reports) {+export function printMatrix(reports) {const header = ['Lane / model', ...CHANNELS.map((c) => c.label), 'Extensions'];const rows = reports.map((r) => {// One row per model, collapsing its materials: a channel counts as@@ -270,7 +271,13 @@ async function main() {if (args.strict && gapped.length > 0) process.exit(1);}-main().catch((err) => {- console.error(err);- process.exit(2);-});+// Only run the CLI when this file is executed directly; importing it from a+// test or another script must stay side-effect free.+const invokedDirectly =+ process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href;+if (invokedDirectly) {+ main().catch((err) => {+ console.error(err);+ process.exit(2);+ });+}diff --git a/scripts/probe-generation-suite.mjs b/scripts/probe-generation-suite.mjsindex b47beddb9..5cf6b3d87 100644--- a/scripts/probe-generation-suite.mjs+++ b/scripts/probe-generation-suite.mjs@@ -1,7 +1,7 @@#!/usr/bin/env node// @ts-check/**- * scripts/probe-generation-suite.mjs — run every generation-suite flow against a+ * scripts/probe-generation-suite.mjs: run every generation-suite flow against a* live deployment and report what actually produced an artifact.** A catalog entry saying `configured: true` only means an env var exists. This@@ -20,6 +20,7 @@*/import { writeFileSync } from 'node:fs';+import { deflateSync } from 'node:zlib';const args = process.argv.slice(2);function flag(name, fallback = null) {@@ -121,11 +122,11 @@ function inspectGlb(buf) {}// Poll a job endpoint that answers { status: queued|running|done|failed }.-async function pollJob(pollPath, { budgetMs = 420_000, intervalMs = 6_000, jobKey = 'job' } = {}) {+async function pollJob(pollPath, { budgetMs = 420_000, intervalMs = 6_000, jobKey = 'job', headers = {} } = {}) {const deadline = Date.now() + budgetMs;let last = null;while (Date.now() < deadline) {- const r = await req(pollPath, { timeoutMs: 30_000 });+ const r = await req(pollPath, { timeoutMs: 30_000, headers });last = r;const status = String(r.json?.status || '').toLowerCase();log(`poll ${jobKey}: ${r.status} ${status || r.text.slice(0, 90)}`);@@ -137,6 +138,74 @@ async function pollJob(pollPath, { budgetMs = 420_000, intervalMs = 6_000, jobKereturn last || { status: 0, json: null, text: 'poll budget exhausted' };}+// Mint a real session from the QA account documented in CLAUDE.md's self-unblock+// playbook, so authed surfaces are probed as a signed-in user rather than only+// asserting that they challenge. Returns a cookie header, or null when the+// credentials are absent.+let qaCookieCache;+async function qaSession() {+ if (qaCookieCache !== undefined) return qaCookieCache;+ const email = process.env.AUDIT_EMAIL;+ const password = process.env.AUDIT_PASSWORD;+ if (!email || !password) {+ qaCookieCache = null;+ return null;+ }+ try {+ const res = await fetch(`${BASE}/api/auth/login`, {+ method: 'POST',+ headers: { 'content-type': 'application/json', 'user-agent': UA },+ body: JSON.stringify({ email, password }),+ signal: AbortSignal.timeout(30_000),+ });+ const setCookie = res.headers.getSetCookie?.() || [];+ const cookie = setCookie.map((c) => c.split(';')[0]).join('; ');+ qaCookieCache = res.ok && cookie ? cookie : null;+ if (!qaCookieCache) log(`QA login failed: HTTP ${res.status}`);+ } catch (err) {+ log(`QA login error: ${err?.message}`);+ qaCookieCache = null;+ }+ return qaCookieCache;+}++// A fully-white 8x8 PNG: the Magic Brush mask that selects the whole surface.+// Built here rather than committed as a fixture so the probe stays one file.+function solidMaskPng() {+ const crc = (buf) => {+ let c = ~0;+ for (const b of buf) {+ c ^= b;+ for (let k = 0; k < 8; k++) c = (c >>> 1) ^ (0xedb88320 & -(c & 1));+ }+ return ~c >>> 0;+ };+ const chunk = (type, data) => {+ const len = Buffer.alloc(4);+ len.writeUInt32BE(data.length);+ const body = Buffer.concat([Buffer.from(type, 'ascii'), data]);+ const cs = Buffer.alloc(4);+ cs.writeUInt32BE(crc(body));+ return Buffer.concat([len, body, cs]);+ };+ const size = 8;+ const ihdr = Buffer.alloc(13);+ ihdr.writeUInt32BE(size, 0);+ ihdr.writeUInt32BE(size, 4);+ ihdr[8] = 8; // bit depth+ ihdr[9] = 0; // greyscale+ const raw = Buffer.concat(+ Array.from({ length: size }, () => Buffer.concat([Buffer.from([0]), Buffer.alloc(size, 0xff)])),+ );+ const png = Buffer.concat([+ Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),+ chunk('IHDR', ihdr),+ chunk('IDAT', deflateSync(raw)),+ chunk('IEND', Buffer.alloc(0)),+ ]);+ return png.toString('base64');+}+const results = [];function record(name, endpoint, ok, detail, extra = {}) {results.push({ name, endpoint, ok, detail, ...extra });@@ -216,8 +285,9 @@ async function probeTextTo3d() {return record('text-to-3d', 'POST /api/forge', false, `HTTP ${post.status}: ${post.text.slice(0, 200)}`);}let glbUrl = post.json?.glb_url || post.json?.glbUrl;- if (!glbUrl && post.json?.poll_url) {- const done = await pollJob(post.json.poll_url, { jobKey: 'text-to-3d', budgetMs: 480_000 });+ const pollPath = post.json?.poll_url || (post.json?.job_id ? `/api/forge?job=${encodeURIComponent(post.json.job_id)}` : null);+ if (!glbUrl && pollPath) {+ const done = await pollJob(pollPath, { jobKey: 'text-to-3d', budgetMs: 600_000 });glbUrl = done.json?.glb_url || done.json?.glbUrl;if (!glbUrl) {return record('text-to-3d', 'POST /api/forge', false, `job ${done.json?.status || done.status}: ${done.json?.error || done.text.slice(0, 160)}`);@@ -257,8 +327,9 @@ async function probeImageTo3d() {return record('image-to-3d', 'POST /api/forge', false, `HTTP ${post.status}: ${post.text.slice(0, 200)}`);}let glbUrl = post.json?.glb_url || post.json?.glbUrl;- if (!glbUrl && post.json?.poll_url) {- const done = await pollJob(post.json.poll_url, { jobKey: 'image-to-3d', budgetMs: 480_000 });+ const pollPath = post.json?.poll_url || (post.json?.job_id ? `/api/forge?job=${encodeURIComponent(post.json.job_id)}` : null);+ if (!glbUrl && pollPath) {+ const done = await pollJob(pollPath, { jobKey: 'image-to-3d', budgetMs: 600_000 });glbUrl = done.json?.glb_url || done.json?.glbUrl;}if (!glbUrl) return record('image-to-3d', 'POST /api/forge', false, `no glb_url: ${post.text.slice(0, 200)}`);@@ -277,7 +348,7 @@ async function probeRig() {if (!selected('rig')) return;const post = await req('/api/forge?action=rig', {method: 'POST',- body: { mesh_url: REF_MESH },+ body: { glb_url: REF_MESH },timeoutMs: 60_000,});if (post.status !== 202 && post.status !== 200) {@@ -330,26 +401,41 @@ async function probeMotion() {async function probeRetexture() {if (!selected('retexture')) return;- const probe = await req('/api/studio/retexture-region');+ // Magic Brush is a signed-in surface. Without a session the only thing a probe+ // can prove is that the gateway challenges correctly, which is not the bar+ // this table sets, so mint a real session from the QA account first.+ const cookie = await qaSession();+ if (!cookie) {+ return record('retexture', 'POST /api/studio/retexture-region', false, 'no QA session: set AUDIT_EMAIL/AUDIT_PASSWORD (npm run audit:web:provision)');+ }+ const auth = { cookie };+ const probe = await req('/api/studio/retexture-region', { headers: auth });const ok = probe.status === 200 || probe.status === 405;record('retexture (probe)', 'GET /api/studio/retexture-region', ok, ok ? `capability probe HTTP ${probe.status}` : `HTTP ${probe.status}: ${probe.text.slice(0, 140)}`);const post = await req('/api/studio/retexture-region', {method: 'POST',- body: { mesh_url: REF_MESH, prompt: 'weathered bronze with green patina' },+ headers: auth,+ body: {+ mesh_url: REF_MESH,+ prompt: 'weathered bronze with green patina',+ mask_b64: solidMaskPng(),+ texture_size: 1024,+ },timeoutMs: 90_000,});if (post.status === 503) return record('retexture', 'POST /api/studio/retexture-region', false, `unconfigured: ${post.json?.message || post.text.slice(0, 140)}`);if (post.status !== 202 && post.status !== 200) {- return record('retexture', 'POST /api/studio/retexture-region', false, `HTTP ${post.status}: ${post.text.slice(0, 180)}`);+ return record('retexture', 'POST /api/studio/retexture-region', false, `HTTP ${post.status}: ${post.text.slice(0, 200)}`);}- const jobId = post.json?.job_id;- if (!jobId) return record('retexture', 'POST /api/studio/retexture-region', Boolean(post.json?.result_url), post.text.slice(0, 160));- const done = await pollJob(`/api/studio/retexture-region?job=${encodeURIComponent(jobId)}`, { jobKey: 'retexture' });+ const jobToken = post.json?.job || post.json?.job_id;+ if (!jobToken) return record('retexture', 'POST /api/studio/retexture-region', Boolean(post.json?.result_url), post.text.slice(0, 160));+ const done = await pollJob(`/api/studio/retexture-region?job=${encodeURIComponent(jobToken)}`, { jobKey: 'retexture', headers: auth });const url = done.json?.result_url;if (!url) return record('retexture', 'POST /api/studio/retexture-region', false, `job ${done.json?.status || done.status}: ${done.json?.error || done.text.slice(0, 160)}`);- const s = await sniff(url);- const glb = s.ok ? inspectGlb(s.buf) : null;- record('retexture', 'POST /api/studio/retexture-region', Boolean(glb && glb.images > 0), glb ? `${glb.images} texture image(s), ${glb.materials} materials` : `not a mesh: ${s.detail}`, { artifact: url });+ const s2 = await sniff(url);+ const glb = s2.ok ? inspectGlb(s2.buf) : null;+ const textured = Boolean(glb ? glb.images > 0 : s2.kind === 'png' || s2.kind === 'webp' || s2.kind === 'jpeg');+ record('retexture', 'POST /api/studio/retexture-region', textured, glb ? `${glb.images} texture image(s), ${glb.materials} materials` : `${s2.bytes} B ${s2.kind}`, { artifact: url });}async function probeX402() {diff --git a/workers/agent-sniper/executor.js b/workers/agent-sniper/executor.jsindex 3b68cee6b..4a89e6942 100644--- a/workers/agent-sniper/executor.js+++ b/workers/agent-sniper/executor.js@@ -381,7 +381,7 @@ export async function executeBuy({ cfg, strat, mint, throttle }) {// 6. quote + price-impact circuit breaker. Priced through a helper so the// trade can be re-quoted at a smaller size if the risk officer (6c)- // cuts it — the impact we RECORD must describe the trade we actually+ // cuts it; the impact we RECORD must describe the trade we actually// send, not the larger one that was refused.const quoteFor = async (size) => {if (ammEntry) {@@ -472,7 +472,7 @@ export async function executeBuy({ cfg, strat, mint, throttle }) {}}- // 6c. adversarial Risk Officer — the independent second opinion. Every+ // 6c. adversarial Risk Officer: the independent second opinion. Every// gate above answers a question with a number; this one is handed the// proposed trade plus the agent's own thesis and told to find what the// agent missed. Runs LAST so it sees the real price impact and the realdiff --git a/workers/agent-sniper/risk-officer.js b/workers/agent-sniper/risk-officer.jsindex 1812aa941..02b0d4622 100644--- a/workers/agent-sniper/risk-officer.js+++ b/workers/agent-sniper/risk-officer.js@@ -1,4 +1,4 @@-// agent-sniper — adversarial pre-trade Risk Officer.+// agent-sniper: adversarial pre-trade Risk Officer.//// The executor already enforces a stack of MECHANICAL gates before any buy is// broadcast: Mayhem exclusion, the market-cap band, throttle/concurrency/budget@@ -20,17 +20,17 @@// default. Three levels, per strategy (`agent_sniper_strategies.risk_officer_level`)// with an env default (`SNIPER_RISK_OFFICER`)://-// 'shadow' (default) — the review runs and is recorded, and NOTHING changes.+// 'shadow' (default): the review runs and is recorded, and NOTHING changes.// Fire-and-forget, so it adds zero latency to the buy// path. This is how the owner gets the evidence to arm// it: `sniper_risk_reviews` accumulates the vetoes it// WOULD have cast against the positions that actually// opened, and their realized P&L answers whether the// officer was right.-// 'enforce' — awaited before the broadcast. A 'block' severity kills+// 'enforce' : awaited before the broadcast. A 'block' severity kills// the buy; a smaller `size_adjustment` shrinks it. Never// upsizes: an adversarial reviewer may only reduce risk.-// 'off' — never called.+// 'off' : never called.//// FAIL OPEN, unlike the firewall. The firewall proves a coin is not a honeypot,// so an unavailable firewall must block ('couldn't prove it's safe' is not@@ -69,7 +69,7 @@ const SYSTEM_PROMPT = ['Veto (severity "block") ONLY for concrete, nameable danger: a creator with a rug','history, extreme holder concentration, price impact that eats the edge, a failed','or warned safety check, or a breach of the mandate. Default to NOT vetoing on a',- 'thin-but-clean setup — the agent already skipped the obvious junk, and a reviewer',+ 'thin-but-clean setup, the agent already skipped the obvious junk, and a reviewer','that blocks everything is the same as no reviewer at all.','','Prefer a smaller size over a full veto when the concern is size-shaped rather',@@ -102,7 +102,13 @@ function lamportsToSol(l) {*/export function resolveRiskOfficerLevel(strat, envDefault = process.env.SNIPER_RISK_OFFICER) {const perStrategy = String(strat?.risk_officer_level || '').trim().toLowerCase();- if (RISK_OFFICER_LEVELS.includes(perStrategy)) return perStrategy;+ if (perStrategy) {+ // A value IS set on the row. If it is not one we recognise (hand-edited row,+ // a level from a newer deploy) it degrades to 'shadow' and stops here — it+ // must NOT fall through to an env default that might be 'enforce', because+ // then a typo in a strategy would silently arm the thing nobody armed.+ return RISK_OFFICER_LEVELS.includes(perStrategy) ? perStrategy : 'shadow';+ }const env = String(envDefault || '').trim().toLowerCase();if (RISK_OFFICER_LEVELS.includes(env)) return env;return 'shadow';@@ -110,7 +116,7 @@ export function resolveRiskOfficerLevel(strat, envDefault = process.env.SNIPER_R/*** Parse the model's answer into a normalized review, or null when it is not- * usable. Null always fails open — an unparseable review never blocks a trade.+ * usable. Null always fails open: an unparseable review never blocks a trade.** Tolerates the two things models actually do wrong here: wrapping the JSON in* a ```json fence, and emitting `veto: true` with `severity: "caution"` (or the@@ -157,7 +163,7 @@ export function parseReview(text) {}/**- * Turn a review into the trade's actual outcome. PURE — the executor calls this+ * Turn a review into the trade's actual outcome. PURE: the executor calls this* and acts on the result, and the tests call it with no network or DB.** Contract:@@ -165,7 +171,7 @@ export function parseReview(text) {* • A missing/degraded review is always a no-op (fail open).* • 'block' aborts. 'caution' never aborts on its own.* • A size adjustment may only SHRINK the trade, and never below the network's- * minimum tradeable size — a suggestion under that floor clamps up to the+ * minimum tradeable size: a suggestion under that floor clamps up to the* floor rather than aborting, because the officer asked for less risk, not* for no trade.*/@@ -194,7 +200,7 @@ export function applyReview({ review, level, perTradeLamports, minTradeLamports}/**- * The brief. Only facts the caller actually has — an omitted field is omitted,+ * The brief. Only facts the caller actually has: an omitted field is omitted,* never guessed, because a fabricated holder count is exactly the kind of thing* an adversarial reviewer would (correctly) veto on.*/@@ -223,7 +229,7 @@ export function reviewBrief({ mint, sizeSol, budgetLeftSol, slotsLeft, priceImpa`PROPOSED: BUY ${Number(sizeSol).toFixed(4)} SOL of ${mint.symbol || mint.mint.slice(0, 6)}.`,agentReason ? `AGENT'S REASON: "${String(agentReason).slice(0, 400)}"` : 'AGENT\'S REASON: (rule-based entry, no stated thesis)','',- 'FACTS (on-chain / feed data — do not invent any others):',+ 'FACTS (on-chain / feed data, do not invent any others):',...lines.map((l) => `- ${l}`),'','MANDATE REMAINING:',