@rig-c/review 1.6.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,31 @@
1
+ /** Native evidence is cut from the bound original PNG, never from a displayed alpha mask. */
2
+ import {createHash} from 'node:crypto';
3
+ import {readFile} from 'node:fs/promises';
4
+ import {PNG} from 'pngjs';
5
+ import {parsePartsComment,assertPartsCommentBinding,type PartsComment} from './parts-comment.ts';
6
+ import {validatePngCrop,storePngCrop,readPngCrop} from './comment-crops.ts';
7
+ import {verdictSource,type PartsViewPackage} from './parts-view.ts';
8
+ export async function preparePartsComment(pkg:PartsViewPackage,raw:unknown,requireNative=false):Promise<PartsComment>{return resolvePartsComment(pkg,raw,requireNative,true);}
9
+ export async function validateStoredPartsComment(pkg:PartsViewPackage,raw:unknown):Promise<PartsComment>{return resolvePartsComment(pkg,raw,true,false);}
10
+ async function resolvePartsComment(pkg:PartsViewPackage,raw:unknown,requireNative:boolean,persist:boolean):Promise<PartsComment>{
11
+ const c=parsePartsComment(raw,requireNative),item=pkg.items.find(i=>i.name===c.part);
12
+ if(pkg.mode!=='parts'||!item)throw new Error('PARTS_COMMENT_UNAVAILABLE: original part image required');
13
+ const path=pkg.imagePaths[item.index],file=pkg.files.find(f=>f.abs===path);if(!path||!file)throw new Error('PARTS_COMMENT_UNAVAILABLE: bound original PNG required');
14
+ assertPartsCommentBinding(c,item,file.sha256,verdictSource(pkg).sha256);
15
+ if(c.view.comparison?.mode==='overlay'&&!pkg.painting)throw new Error('PARTS_COMPARISON_UNAVAILABLE: original painting required');
16
+ const bytes=await readFile(path);if(createHash('sha256').update(bytes).digest('hex')!==file.sha256)throw new Error('PARTS_COMMENT_STALE_SOURCE: original PNG changed');
17
+ validatePngCrop(c.crop);
18
+ const original=PNG.sync.read(bytes),r=c.imageRegion;
19
+ if(original.width!==item.w||original.height!==item.h)throw new Error('PARTS_COMMENT_IMAGE_SIZE: original dimensions differ from placement');
20
+ if(r.width*r.height>16777216)throw new Error('PARTS_COMMENT_CROP_LIMIT: native crop exceeds 16 million pixels');
21
+ const native=new PNG({width:r.width,height:r.height});for(let y=0;y<r.height;y++)original.data.copy(native.data,y*r.width*4,((r.y+y)*original.width+r.x)*4,((r.y+y)*original.width+r.x+r.width)*4);
22
+ if(requireNative){
23
+ const stored=await readPngCrop(c.nativeCrop!),decoded=PNG.sync.read(stored);
24
+ if(decoded.width!==r.width||decoded.height!==r.height||!decoded.data.equals(native.data))throw new Error('PARTS_COMMENT_NATIVE_CROP_TAMPERED: native crop differs from bound original');
25
+ if(persist)await storePngCrop(c.crop);else await readPngCrop(c.crop);
26
+ return c;
27
+ }
28
+ const png=PNG.sync.write(native),sha256=createHash('sha256').update(png).digest('hex'),nativeCrop={path:`comment-crops/${sha256}.png`,sha256,width:r.width,height:r.height};
29
+ await storePngCrop(c.crop);await storePngCrop({...nativeCrop,png:'data:image/png;base64,'+png.toString('base64')});
30
+ return {...c,nativeCrop};
31
+ }
@@ -0,0 +1,33 @@
1
+ /** Closed parts evidence. No synthetic model, frame, slot or package identity. */
2
+ import {parsePartsComparison,type PartsComparison} from './parts-comparison.ts';
3
+ import type {MarkRegion} from './stage-comment.ts';
4
+ export interface PartsCrop {path:string;sha256:string;width:number;height:number}
5
+ export interface PartsComment {
6
+ schema:'rig-review-parts-comment/1';id:string;summary:string;part:string;imageHash:string;sourceHash:string;
7
+ imageRegion:MarkRegion;rigRegion:MarkRegion;
8
+ view:{camera:{zoom:number;center:{x:number;y:number};viewport:{width:number;height:number}};cameraSync:boolean;referenceCamera:{zoom:number;center:{x:number;y:number};viewport:{width:number;height:number}}|null;background:string;alpha:boolean;footprints:boolean;mesh:boolean;comparison?:PartsComparison};
9
+ crop:PartsCrop&{png:string};nativeCrop:PartsCrop|null;
10
+ }
11
+ const fail=(code:string,why:string):never=>{throw new Error(code+': '+why);};
12
+ const obj=(v:unknown):Record<string,any>=>v!==null&&typeof v==='object'&&!Array.isArray(v)?v as Record<string,any>:fail('PARTS_COMMENT_INVALID','object required');
13
+ const exact=(v:Record<string,any>,keys:string[])=>{if(Object.keys(v).length!==keys.length||keys.some(k=>!Object.hasOwn(v,k)))fail('PARTS_COMMENT_INVALID','unknown or missing fields');};
14
+ const finite=(v:unknown):v is number=>typeof v==='number'&&Number.isFinite(v)&&Math.abs(v)<=Number.MAX_SAFE_INTEGER;
15
+ const hash=(v:unknown)=>typeof v==='string'&&/^[a-f0-9]{64}$/.test(v);
16
+ export function parsePartsComment(raw:unknown,prepared=true):PartsComment {
17
+ const v=obj(raw);exact(v,['schema','id','summary','part','imageHash','sourceHash','imageRegion','rigRegion','view','crop','nativeCrop']);
18
+ if(v.schema!=='rig-review-parts-comment/1'||typeof v.id!=='string'||!v.id||v.id.length>128||typeof v.summary!=='string'||!v.summary.trim()||v.summary.length>1000||typeof v.part!=='string'||!v.part||v.part.length>512||!hash(v.imageHash)||!hash(v.sourceHash))fail('PARTS_COMMENT_INVALID','schema, text or source binding');
19
+ for(const key of ['imageRegion','rigRegion']){const r=obj(v[key]);exact(r,['x','y','width','height']);if(!Object.values(r).every(finite))fail('PARTS_COMMENT_INVALID','finite region required');if(key==='imageRegion'&&!Object.values(r).every(Number.isSafeInteger))fail('PARTS_COMMENT_FRACTIONAL','image coordinates must be integer pixels');if(r.width<=0||r.height<=0)fail('PARTS_COMMENT_EMPTY','positive region required');}
20
+ const view=obj(v.view);exact(view,['camera','cameraSync','referenceCamera','background','alpha','footprints','mesh',...(Object.hasOwn(view,'comparison')?['comparison']:[])]);if(Object.hasOwn(view,'comparison'))parsePartsComparison(view.comparison);if(!['green','magenta','black','white','checker'].includes(view.background)||![view.alpha,view.footprints,view.mesh,view.cameraSync].every(n=>typeof n==='boolean'))fail('PARTS_COMMENT_INVALID','view state');
21
+ for(const rawCamera of [view.camera,...(view.referenceCamera===null?[]:[view.referenceCamera])]){const c=obj(rawCamera);exact(c,['zoom','center','viewport']);exact(obj(c.center),['x','y']);exact(obj(c.viewport),['width','height']);if(!finite(c.zoom)||c.zoom<=0||c.zoom>16||!Object.values(c.center).every(finite)||!Object.values(c.viewport).every(n=>finite(n)&&n>0&&n<=65536))fail('PARTS_CAMERA_RANGE','native scale or camera extent');}
22
+ for(const [crop,inline]of [[v.crop,true],[v.nativeCrop,false]] as const){if(crop===null&&!inline&&!prepared)continue;const p=obj(crop);exact(p,['path','sha256','width','height',...(inline?['png']:[])]);if(!hash(p.sha256)||p.path!==`comment-crops/${p.sha256}.png`||![p.width,p.height].every(n=>Number.isSafeInteger(n)&&n>0&&n<=16384)||inline&&(typeof p.png!=='string'||p.png.length>200000||p.width>1024||p.height>1024))fail('PARTS_COMMENT_CROP_INVALID','bounded content-addressed crop');}
23
+ return v as PartsComment;
24
+ }
25
+ /** Drag edges snap outward to whole native pixels. OOB is refused by the binding check, never clipped. */
26
+ export function snapImageRegion(r:MarkRegion):MarkRegion {if(r.width<=0||r.height<=0)return {x:Math.floor(r.x),y:Math.floor(r.y),width:0,height:0};const x=Math.floor(r.x),y=Math.floor(r.y);return {x,y,width:Math.ceil(r.x+r.width)-x,height:Math.ceil(r.y+r.height)-y};}
27
+ export function assertPartsCommentBinding(c:PartsComment,item:{name:string;x:number;y:number;w:number;h:number},imageHash:string,sourceHash:string):void {
28
+ if(c.part!==item.name)fail('PARTS_COMMENT_PART_MISMATCH','comment belongs to another part');
29
+ if(c.imageHash!==imageHash||c.sourceHash!==sourceHash)fail('PARTS_COMMENT_STALE_SOURCE','original image or package source hash differs');
30
+ const camera=c.view.camera,fit=Math.max(.001,Math.min((camera.viewport.width-24)/item.w,(camera.viewport.height-24)/item.h));if(camera.zoom<Math.min(fit,1))fail('PARTS_CAMERA_RANGE','native zoom below fit/1 minimum');
31
+ const r=c.imageRegion;if(r.x<0||r.y<0||r.x+r.width>item.w||r.y+r.height>item.h)fail('PARTS_COMMENT_OUT_OF_BOUNDS','region exceeds original image');
32
+ if(c.rigRegion.x!==item.x+r.x||c.rigRegion.y!==item.y+r.y||c.rigRegion.width!==r.width||c.rigRegion.height!==r.height)fail('PARTS_COMMENT_RIG_REGION','rig region must be exact placement plus image region');
33
+ }
@@ -0,0 +1,20 @@
1
+ /** Visual comparison settings are evidence, never a producer verdict. Older comments omit them. */
2
+ export interface PartsComparison {mode:'part'|'overlay';opacity:number}
3
+ export const defaultPartsComparison = ():PartsComparison => ({mode:'part',opacity:.5});
4
+ export function parsePartsComparison(raw:unknown):PartsComparison {
5
+ const v=raw as PartsComparison;
6
+ if(!v||typeof v!=='object'||Array.isArray(v)||Object.keys(v).length!==2||!['mode','opacity'].every(k=>Object.hasOwn(v,k))||!['part','overlay'].includes(v.mode)||typeof v.opacity!=='number'||!Number.isFinite(v.opacity)||v.opacity<0||v.opacity>1)throw new Error('PARTS_COMPARISON_INVALID: part/overlay mode and opacity 0..1 required');
7
+ return v;
8
+ }
9
+ export interface PaintingRectangle {x:number;y:number;width:number;height:number}
10
+ /** Whole-canvas geometry of parts@2.17.0 sourceInRig: trunc(source size * declared scale).
11
+ * This validates original input dimensions, not equality with the producer's resampled pixels. */
12
+ export function assertOriginalPaintingSize(width:number,height:number,rigSize:readonly number[]|null,scale:unknown):void {
13
+ if(typeof scale!=='number'||!Number.isFinite(scale)||scale<=0||!rigSize||!rigSize.every(n=>Number.isSafeInteger(n)&&n>0))throw new Error('PARTS_PAINTING_MAPPING: declared rig_size and positive scale_rig_per_source required');
14
+ if(Math.trunc(width*scale)!==rigSize[0]||Math.trunc(height*scale)!==rigSize[1])throw new Error('PARTS_PAINTING_SIZE: original painting dimensions times declared scale must match the rig canvas');
15
+ }
16
+ /** Exact continuous source rectangle for a visual comparison. No pixel pairing, rounding or producer resampler. */
17
+ export function paintingRectangle(item:{x:number;y:number;w:number;h:number},rigSize:readonly number[],painting:{width:number;height:number}):PaintingRectangle {
18
+ const x=painting.width/rigSize[0]!,y=painting.height/rigSize[1]!;
19
+ return {x:item.x*x,y:item.y*y,width:item.w*x,height:item.h*y};
20
+ }
@@ -3,7 +3,9 @@ import { readFile } from 'node:fs/promises';
3
3
  import { appRoot, buildWeb } from './build.ts';
4
4
  import { accessGate } from './open-protocol.ts';
5
5
  import { createLiveLifecycle, LIVE_PATH, type LiveExitInfo, type UpgradableServer } from './live-lifecycle.ts';
6
- import { partsViewJson, readVerdict, saveVerdict, servedImage, type PartsViewPackage } from './parts-view.ts';
6
+ import {preparePartsComment} from './parts-comment-crops.ts';
7
+ import {serveReference} from './reference.ts';
8
+ import { partsViewJson, exportPartsVerdict, assertPartsUnchanged, readVerdict, saveVerdict, servedImage, type PartsViewPackage } from './parts-view.ts';
7
9
 
8
10
  const headers = { 'X-Content-Type-Options': 'nosniff', 'Cache-Control': 'no-store', 'Content-Security-Policy': "default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' blob: data:; connect-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'" };
9
11
  const json = (value: unknown, status = 200) => Response.json(value, { status, headers });
@@ -52,18 +54,21 @@ export async function startPartsServer(pkg: PartsViewPackage, options: PartsServ
52
54
  }
53
55
  live.onRequestStart(url.pathname);
54
56
  try {
55
- if (url.pathname === '/api/parts' && req.method === 'GET') return json(partsViewJson(pkg, await readVerdict(pkg)));
57
+ if (url.pathname === '/api/parts' && req.method === 'GET'){await assertPartsUnchanged(pkg);return json(partsViewJson(pkg,await readVerdict(pkg)));}
58
+ if(url.pathname==='/api/parts/comment'&&req.method==='POST'){if(req.headers.get('origin')!==origin)return json({error:'Same-origin Origin required'},403);await assertPartsUnchanged(pkg);return json({comment:await preparePartsComment(pkg,await bodyJson(req))});}
59
+ if(url.pathname==='/api/parts/export'&&req.method==='GET'){const saved=await readVerdict(pkg);if(!saved.verdict)return json({error:'PARTS_VERDICT_UNAVAILABLE: save a verdict first'},409);return new Response(exportPartsVerdict(saved.verdict,url.searchParams.get('format')==='issue'?'issue':'json'),{headers:{...headers,'Content-Type':url.searchParams.get('format')==='issue'?'text/markdown':'application/json'}});}
56
60
  if (url.pathname === '/api/parts/verdict' && req.method === 'POST') {
57
61
  if (req.headers.get('origin') !== origin) return json({ error: 'Same-origin Origin required' }, 403);
58
62
  saving = true;
59
63
  try { return json({ verdict: await saveVerdict(pkg, await bodyJson(req)) }); } finally { saving = false; }
60
64
  }
65
+ if(url.pathname==='/api/parts/painting'&&req.method==='GET'){if(!pkg.painting)return json({error:'PARTS_REFERENCE_UNAVAILABLE: supply --painting to compare the original painting'},404);return serveReference(req,pkg.painting.abs,pkg.painting.sha256,headers);}
61
66
  const image = /^\/api\/parts\/(image|page)\/(\d+)$/.exec(url.pathname);
62
67
  if (image && (req.method === 'GET' || req.method === 'HEAD')) {
63
68
  const path = servedImage(pkg, image[1] as 'image' | 'page', Number(image[2]));
64
69
  if (!path) return json({ error: 'Not found' }, 404);
65
- const file = Bun.file(path);
66
- return new Response(req.method === 'HEAD' ? null : file, { headers: { ...headers, 'Content-Security-Policy': "default-src 'none'; sandbox", 'Content-Type': file.type || 'application/octet-stream' } });
70
+ const pinned=pkg.files.find(f=>f.abs===path);if(!pinned)return json({error:'PARTS_IMAGE_UNBOUND'},409);return serveReference(req,path,pinned.sha256,headers);
71
+
67
72
  }
68
73
  if (url.pathname === '/parts.js') return new Response(req.method === 'HEAD' ? null : bundle, { headers: { ...headers, 'Content-Type': 'text/javascript' } });
69
74
  if (url.pathname === '/' || url.pathname === '/parts.html') return new Response(req.method === 'HEAD' ? null : await readFile(appRoot + 'web/parts.html'), { headers: { ...headers, 'Content-Type': 'text/html; charset=utf-8' } });
package/src/parts-view.ts CHANGED
@@ -10,18 +10,22 @@
10
10
  * - `mesh_report.json` rows: `contour.bridges.faint[]` (rig-parts #326), each a faint island the mesh left out;
11
11
  * - `check.json`: a gate whose `status` is FAIL or WARN, `seam_pairs` and `figure_openings`, on every part they name.
12
12
  *
13
- * The sign-off is `rig-review-parts-verdict/1` (docs/PARTS_VIEW.md), written beside `parts.json` by default. Its
13
+ * The sign-off is `rig-review-parts-verdict/2` (docs/PARTS_VIEW.md), written beside `parts.json` by default. Its
14
14
  * `source.sha256` is the sha256 over the UTF-8 lines `<path>\t<sha256>\n`, sorted by path bytewise, where every path
15
15
  * is relative to the verdict file's directory. rig-c/create recomputes it, so the definition is fixed here.
16
16
  */
17
+ import {assertOriginalPaintingSize} from './parts-comparison.ts';
18
+ import {parsePartsComment,assertPartsCommentBinding,type PartsComment} from './parts-comment.ts';
19
+ import {preparePartsComment,validateStoredPartsComment} from './parts-comment-crops.ts';
20
+ import {resolvedCropPath} from './comment-crops.ts';
17
21
  import { createHash } from 'node:crypto';
18
22
  import { existsSync } from 'node:fs';
19
23
  import { mkdir, readFile, realpath, rename, rm, stat, writeFile } from 'node:fs/promises';
20
24
  import { basename, dirname, isAbsolute, join, posix, relative, resolve, sep } from 'node:path';
21
25
  import { PNG } from 'pngjs';
22
- import { loadReview, safeFile, packagePath } from './manifest.ts';
26
+ import { loadReview, safeFile, packagePath, type ReviewPackage } from './manifest.ts';
23
27
 
24
- export const PARTS_VERDICT_SCHEMA = 'rig-review-parts-verdict/1';
28
+ export const PARTS_VERDICT_SCHEMA = 'rig-review-parts-verdict/2';
25
29
  export const PARTS_VERDICT_FILE = 'parts-review.json';
26
30
  export const PARTS_NOTE_LIMIT = 10000;
27
31
  export type PartsViewMode = 'parts' | 'atlas';
@@ -55,6 +59,7 @@ export type ProducerFlag =
55
59
  root: string; status: string | null; entry: Record<string, unknown> };
56
60
 
57
61
  export interface PartsViewPackage {
62
+ painting?:{sha256:string;width:number;height:number;abs:string};
58
63
  mode: PartsViewMode;
59
64
  root: string;
60
65
  title: string;
@@ -76,7 +81,7 @@ export interface PartsViewPackage {
76
81
  pagePaths: string[];
77
82
  }
78
83
 
79
- export interface PartsViewOptions { rig?: string; meshReport?: string; check?: string; verdict?: string }
84
+ export interface PartsViewOptions { rig?: string; meshReport?: string; check?: string; verdict?: string;painting?:string }
80
85
 
81
86
  const record = (v: unknown): Record<string, unknown> | null => v && typeof v === 'object' && !Array.isArray(v) ? v as Record<string, unknown> : null;
82
87
  const finite = (v: unknown, min: number): v is number => typeof v === 'number' && Number.isFinite(v) && v >= min;
@@ -288,6 +293,13 @@ async function loadPartsMode(root: string, options: PartsViewOptions): Promise<P
288
293
  imagePaths.push(real);
289
294
  items.push({ name: part.name, index, x: part.x, y: part.y, w: part.w, h: part.h, image: true });
290
295
  }
296
+ let painting:PartsViewPackage['painting'];if(options.painting){
297
+ const candidate=resolve(options.painting),rel=relative(resolve(root),candidate);if(!rel||rel==='..'||rel.startsWith('..'+sep)||isAbsolute(rel))refuse('PARTS_PAINTING_OUTSIDE','painting must be inside the parts package');
298
+ let abs:string,bytes:Buffer;try{abs=await insideRoot(root,candidate,'PARTS_PAINTING_OUTSIDE','painting');packagePath(relative(root,abs).split(sep).join('/'),'painting');bytes=await readFile(abs);}catch(error){if(error instanceof Error&&error.message.startsWith('PARTS_PAINTING_OUTSIDE:'))throw error;refuse('PARTS_PAINTING_UNAVAILABLE','painting must be a readable portable package PNG');}
299
+ let png:PNG;try{png=PNG.sync.read(bytes!);}catch{refuse('PARTS_PAINTING_PNG','painting must be a valid PNG');}
300
+ assertOriginalPaintingSize(png!.width,png!.height,rigSize,doc.scale_rig_per_source);
301
+ const file={abs:abs!,bytes:bytes!.length,sha256:createHash('sha256').update(bytes!).digest('hex')};painting={...file,width:png!.width,height:png!.height};files.push(file);
302
+ }
291
303
  const { flags, files: flagFiles, notes } = await producerFlags(root, null, seen, options);
292
304
  const protectedPaths = [join(root, 'rig.json'), join(root, 'config.json'), join(root, 'review.json'), join(root, 'report.json')];
293
305
  if (basename(root) === 'rig') protectedPaths.push(...['parts.json', 'config.json', 'review.json', 'report.json'].map(name => join(dirname(root), name)));
@@ -307,13 +319,20 @@ async function loadPartsMode(root: string, options: PartsViewOptions): Promise<P
307
319
  files.push({ abs: rigPath, bytes: rigBytes.length, sha256: createHash('sha256').update(rigBytes).digest('hex') });
308
320
  if (report) files.push(report);
309
321
  }
310
- return { mode: 'parts', root, title: basename(root) === 'rig' ? basename(dirname(root)) : basename(root), rigSize, items, pages: [], flags, files, flagFiles, flagNotes: notes, protectedPaths, verdictPath, imagePaths, pagePaths: [] };
322
+ return { ...(painting?{painting}:{}),mode: 'parts', root, title: basename(root) === 'rig' ? basename(dirname(root)) : basename(root), rigSize, items, pages: [], flags, files, flagFiles, flagNotes: notes, protectedPaths, verdictPath, imagePaths, pagePaths: [] };
311
323
  }
312
324
 
313
325
  async function loadAtlasMode(input: string, options: PartsViewOptions): Promise<PartsViewPackage> {
326
+ if(options.painting)refuse('PARTS_PAINTING_UNAVAILABLE','atlas regions have no rig placement; use a pre-rig parts package');
314
327
  const p = await loadReview(input);
328
+ if (!p.manifest.model) return refuse('PARTS_VIEW_NO_ATLAS', `${input} holds neither parts.json nor a compiled model with pages`);
329
+ return loadPartsAtlas(p, options);
330
+ }
331
+
332
+ /** Atlas inspector bound to an already loaded package; never rediscover a different source. */
333
+ export async function loadPartsAtlas(p: ReviewPackage, options: PartsViewOptions = {}): Promise<PartsViewPackage> {
315
334
  const modelPath = p.manifest.model;
316
- if (!modelPath) return refuse('PARTS_VIEW_NO_ATLAS', `${input} holds neither parts.json nor a compiled model with pages`);
335
+ if (!modelPath) return refuse('PARTS_VIEW_NO_ATLAS', `The inspected package holds no compiled model with pages`);
317
336
  const modelAbs = await safeFile(p.root, modelPath);
318
337
  const model = record(JSON.parse(await readFile(modelAbs, 'utf8')));
319
338
  const pagesRaw = model?.pages;
@@ -392,6 +411,7 @@ export interface PartsVerdict {
392
411
  source: ReturnType<typeof verdictSource>;
393
412
  status: VerdictStatus;
394
413
  parts: Record<string, { outcome: PartOutcome; note: string; flags: string[]; mesh?: { outcome: PartOutcome; note: string } }>;
414
+ comments: PartsComment[];
395
415
  updatedAt: string;
396
416
  }
397
417
 
@@ -402,7 +422,7 @@ export interface VerdictSubmission { status: VerdictStatus; parts: Record<string
402
422
  export const itemNames = (pkg: Pick<PartsViewPackage, 'items'>): string[] => [...new Set(pkg.items.map(i => i.name))];
403
423
 
404
424
  /** Builds the verdict document, or refuses by name. Pure but for the clock. */
405
- export function buildVerdict(pkg: Pick<PartsViewPackage, 'mode' | 'items' | 'flags' | 'files' | 'flagFiles' | 'verdictPath'>, input: unknown, version: string, now = new Date()): PartsVerdict {
425
+ export function buildVerdict(pkg: Pick<PartsViewPackage, 'mode' | 'items' | 'flags' | 'files' | 'flagFiles' | 'verdictPath' | 'imagePaths' | 'painting'>, input: unknown, version: string, now = new Date()): PartsVerdict {
406
426
  const body = record(input);
407
427
  if (!body) return refuse('PARTS_VERDICT_INVALID', 'expected { status, parts }');
408
428
  const status = body.status;
@@ -436,7 +456,9 @@ export function buildVerdict(pkg: Pick<PartsViewPackage, 'mode' | 'items' | 'fla
436
456
  const outcomes = Object.values(parts).flatMap(p => p.mesh ? [p.outcome, p.mesh.outcome] : [p.outcome]);
437
457
  if (status === 'approved' && outcomes.some(o => o !== 'clean')) refuse('PARTS_VERDICT_NOT_CLEAN', `approved needs every part clean; ${outcomes.filter(o => o !== 'clean').length} are not`);
438
458
  if (status === 'changes-requested' && !outcomes.includes('flagged')) refuse('PARTS_VERDICT_NOTHING_FLAGGED', 'changes-requested needs at least one flagged part');
439
- return { schema: PARTS_VERDICT_SCHEMA, mode: pkg.mode, tool: { name: '@rig-c/review', version }, source: verdictSource(pkg), status, parts, updatedAt: now.toISOString() };
459
+ const comments=body.comments??[];if(!Array.isArray(comments)||comments.length>1000)refuse('PARTS_COMMENT_LIMIT','comments must be an array of at most 1000 entries');
460
+ const ids=new Set<string>();for(const raw of comments as unknown[]){const c=parsePartsComment(raw);if(c.view.comparison?.mode==='overlay'&&!pkg.painting)refuse('PARTS_COMPARISON_UNAVAILABLE','original painting required');const item=pkg.items.find(i=>i.name===c.part);if(!item||pkg.mode!=='parts')refuse('PARTS_COMMENT_UNAVAILABLE','original part required');if(ids.has(c.id))refuse('PARTS_COMMENT_DUPLICATE','duplicate comment id');ids.add(c.id);const file=pkg.files.find(f=>f.abs===pkg.imagePaths[item!.index]);assertPartsCommentBinding(c,item!,file?.sha256??'',verdictSource(pkg).sha256);}
461
+ return { schema: PARTS_VERDICT_SCHEMA, mode: pkg.mode, tool: { name: '@rig-c/review', version }, source: verdictSource(pkg), status, parts, comments:comments as PartsComment[], updatedAt: now.toISOString() };
440
462
  }
441
463
 
442
464
  /** Every file the package was loaded from still has the bytes it was loaded with. */
@@ -455,7 +477,10 @@ async function packageVersion(): Promise<string> {
455
477
  export async function saveVerdict(pkg: PartsViewPackage, input: unknown): Promise<PartsVerdict> {
456
478
  await assertVerdictDestination(pkg);
457
479
  await assertPartsUnchanged(pkg);
480
+ await readVerdict(pkg); // Existing read-side evidence errors must never become an implicit reset.
458
481
  const verdict = buildVerdict(pkg, input, await packageVersion());
482
+ for(const comment of verdict.comments)await preparePartsComment(pkg,comment,true);
483
+ await assertPartsUnchanged(pkg);
459
484
  await mkdir(dirname(pkg.verdictPath), { recursive: true });
460
485
  const tmp = `${pkg.verdictPath}.${crypto.randomUUID()}.tmp`;
461
486
  try {
@@ -476,18 +501,23 @@ export type VerdictStale = 'files' | 'flags' | null;
476
501
  */
477
502
  export async function readVerdict(pkg: PartsViewPackage): Promise<{ verdict: PartsVerdict | null; stale: VerdictStale }> {
478
503
  let raw: unknown;
479
- try { raw = JSON.parse(await readFile(pkg.verdictPath, 'utf8')); } catch { return { verdict: null, stale: null }; }
504
+ let text:string;try{text=await readFile(pkg.verdictPath,'utf8');}catch(error){if((error as NodeJS.ErrnoException).code==='ENOENT')return {verdict:null,stale:null};throw new Error('PARTS_VERDICT_READ: saved verdict cannot be read');}
505
+ try{raw=JSON.parse(text);}catch{throw new Error('PARTS_VERDICT_INVALID: saved verdict is not valid JSON');}
480
506
  const v = record(raw), source = record(v?.source), now = verdictSource(pkg);
481
- if (!v || v.schema !== PARTS_VERDICT_SCHEMA || v.mode !== pkg.mode || source?.sha256 !== now.sha256) return { verdict: null, stale: 'files' };
507
+ if(!v||![PARTS_VERDICT_SCHEMA,'rig-review-parts-verdict/1'].includes(String(v.schema))||typeof source?.sha256!=='string')throw new Error('PARTS_VERDICT_INVALID: saved verdict schema or binding is invalid');
508
+ if(v.mode!==pkg.mode||source.sha256!==now.sha256)return {verdict:null,stale:'files'};
482
509
  if (JSON.stringify(source.flags) !== JSON.stringify(now.flags)) return { verdict: null, stale: 'flags' };
483
- return { verdict: v as unknown as PartsVerdict, stale: null };
510
+ const date=new Date(String(v.updatedAt));if(!Number.isFinite(date.getTime()))throw new Error('PARTS_VERDICT_INVALID: saved verdict date is invalid');
511
+ const normalized=buildVerdict(pkg,{...v,comments:v.schema==='rig-review-parts-verdict/1'?[]:v.comments},String(record(v.tool)?.version??''),date);for(const c of normalized.comments)await validateStoredPartsComment(pkg,c);return {verdict:normalized,stale:null};
484
512
  }
485
513
 
486
514
  /** What the page reads: no absolute path leaves the server but the verdict file's name. */
487
515
  export function partsViewJson(pkg: PartsViewPackage, saved: { verdict: PartsVerdict | null; stale: VerdictStale }) {
488
516
  return {
489
517
  schema: 'rig-review-parts-view/1', mode: pkg.mode, title: pkg.title, rigSize: pkg.rigSize,
490
- items: pkg.items, pages: pkg.pages, flags: pkg.flags,
518
+ painting:pkg.painting?{sha256:pkg.painting.sha256,width:pkg.painting.width,height:pkg.painting.height}:null,
519
+ sourceHash:verdictSource(pkg).sha256,
520
+ items:pkg.items.map(item=>({...item,...(pkg.mode==='parts'?{imageHash:pkg.files.find(f=>f.abs===pkg.imagePaths[item.index])?.sha256}:{})})), pages: pkg.pages, flags: pkg.flags,
491
521
  flagSources: pkg.flagFiles.map(f => basename(f.abs)), flagMissing: pkg.flagNotes,
492
522
  verdictFile: basename(pkg.verdictPath), verdict: saved.verdict, verdictStale: saved.stale,
493
523
  };
@@ -499,3 +529,10 @@ export function servedImage(pkg: PartsViewPackage, kind: 'image' | 'page', index
499
529
  return Number.isInteger(index) && index >= 0 && index < list.length ? list[index]! : null;
500
530
  }
501
531
 
532
+
533
+ /** Both export forms preserve original text, native and rig coordinates and resolved evidence. */
534
+ export function exportPartsVerdict(verdict:PartsVerdict,format:'json'|'issue'):string {
535
+ const comments=verdict.comments.map(c=>{const {png,...crop}=c.crop;return {...c,crop:{...crop,path:resolvedCropPath(crop.path)},nativeCrop:c.nativeCrop?{...c.nativeCrop,path:resolvedCropPath(c.nativeCrop.path)}:null};});
536
+ if(format==='json')return JSON.stringify({...verdict,comments},null,2)+'\n';
537
+ return [`# Parts review`, `Source: ${verdict.source.sha256}`,`Status: ${verdict.status}`,...Object.entries(verdict.parts).flatMap(([name,p])=>[`\n## ${name}`,`${p.outcome}: ${p.note}`,...comments.filter(c=>c.part===name).flatMap(c=>[`\n### ${c.summary}`,`Part: ${c.part} · image SHA-256: ${c.imageHash}`,`Image region: ${JSON.stringify(c.imageRegion)}`,`Rig region: ${JSON.stringify(c.rigRegion)}`,`Viewport crop: ${c.crop.path} · SHA-256 ${c.crop.sha256}`,`Native crop: ${c.nativeCrop!.path} · SHA-256 ${c.nativeCrop!.sha256}`,`View: ${JSON.stringify(c.view)}`])])].join('\n')+'\n';
538
+ }
package/src/server.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import {stagePartsRoutes} from './stage-parts.ts';
1
2
  import {createControlServer,type ControlIdentity} from './control-server.ts';
2
3
  import { readFile } from 'node:fs/promises';
3
4
  import { appRoot, buildWeb } from './build.ts';
@@ -17,7 +18,7 @@ import { createEnvironmentCheck, ENVIRONMENT_CHECK_LIMIT, EnvironmentCheckError
17
18
  import { createLiveLifecycle, LIVE_PATH, type LiveExitInfo, type UpgradableServer } from './live-lifecycle.ts';
18
19
  import { homedir } from 'node:os';
19
20
  import { join } from 'node:path';
20
- const headers={ 'X-Content-Type-Options':'nosniff','Cache-Control':'no-store','Content-Security-Policy':"default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' blob: data:; media-src 'self'; connect-src 'self'; font-src 'self'; base-uri 'none'; frame-ancestors 'none'; form-action 'none'",'Referrer-Policy':'no-referrer'};
21
+ const headers={ 'X-Content-Type-Options':'nosniff','Cache-Control':'no-store','Content-Security-Policy':"default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' blob: data:; media-src 'self'; frame-src 'self'; connect-src 'self'; font-src 'self'; base-uri 'none'; frame-ancestors 'none'; form-action 'none'",'Referrer-Policy':'no-referrer'};
21
22
  /** Request shapes the page or an edit card got wrong: 400. Everything else a refusal names is an outcome (200). */
22
23
  const MALFORMED=new Set(['REBUILD_REQUEST_INVALID','DENSITY_STRIP_REQUEST_INVALID','DENSITY_STRIP_FIELD','MESH_PATCH_SCOPE','EDIT_PATCH_INVALID','EDIT_PATCH_OP_UNKNOWN','EDIT_PATCH_POINTER_INVALID','EDIT_PATCH_CMD_UNKNOWN','EDIT_PATCH_ARG_UNKNOWN','BONES_OP_OUT_OF_SCOPE','RETARGET_REQUEST_INVALID']);
23
24
  function json(data:unknown,status=200){return Response.json(data,{status,headers});}
@@ -31,6 +32,7 @@ async function bodyJson(req:Request,limit=1024*1024,what='Session payload exceed
31
32
  /** `capability` (open workers and foreground CLI serving) gates every non-GET request; tests may omit it.
32
33
  * `cwd` is where the producer is looked for after the package's own directories (review's working directory by default). */
33
34
  export async function startServer(p:ReviewPackage,options:{port?:number;stateDir?:string;open?:OpenIdentity;initialAnimation?:string;activity?:()=>void;control?:ControlIdentity;capability?:string;cwd?:string;stripConcurrency?:number;graceMs?:number;unopenedTimeoutMs?:number;exitOnClose?:boolean;onClose?:(info:LiveExitInfo)=>void|Promise<void>;log?:(line:string)=>void;viewOnly?:boolean}={}){
35
+ const stageParts=stagePartsRoutes({single:p});
34
36
  const bundle=await buildWeb();
35
37
  const unchanged=()=>assertReviewUnchanged(p);
36
38
  const stateDir=options.stateDir??process.env.RIG_REVIEW_STATE_DIR??join(homedir(),'.local','state','rig-c-review'),starts=[p.root,options.cwd??process.cwd()];
@@ -66,6 +68,8 @@ export async function startServer(p:ReviewPackage,options:{port?:number;stateDir
66
68
  }
67
69
  live.onRequestStart(url.pathname);
68
70
  try {
71
+ const stageResponse=await stageParts(req);if(stageResponse)return stageResponse;
72
+
69
73
  const controlled=await control?.(req,origin);if(controlled)return controlled;
70
74
  options.activity?.();const gate=openGate(req,options.open);if(gate){if(gate.status===200){try{await unchanged();}catch{return staleOpenStatus(options.open!);}if(!live.rearmUnopened())return json({error:'Server is closing'},503);}return gate;}
71
75
  if(req.method==='PUT'&&url.pathname==='/api/session'){
@@ -0,0 +1,37 @@
1
+ /** Read-only embedding of the existing atlas inspector. No browser-supplied filesystem paths or verdict writes. */
2
+ import {readFile} from 'node:fs/promises';
3
+ import {appRoot,buildWeb} from './build.ts';
4
+ import type {ReviewPackage} from './manifest.ts';
5
+ import {loadPartsAtlas,assertPartsUnchanged,partsViewJson,servedImage} from './parts-view.ts';
6
+ import {serveReference,assertReviewUnchanged} from './reference.ts';
7
+ export function stagePartsRoutes(packages:{single:ReviewPackage}|{a:ReviewPackage;b:ReviewPackage},loadAtlas:typeof loadPartsAtlas=loadPartsAtlas) {
8
+ const loaded=new Map<string,ReturnType<typeof loadPartsAtlas>>();let bundle:Promise<Blob>|undefined;
9
+ const headers={'X-Content-Type-Options':'nosniff','Cache-Control':'no-store','Referrer-Policy':'no-referrer','Content-Security-Policy':"default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' blob: data:; connect-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'self'"};
10
+ return async(req:Request):Promise<Response|null>=>{
11
+ const url=new URL(req.url),path=url.pathname,read=req.method==='GET'||req.method==='HEAD';
12
+ if(!read)return null;
13
+ if(['/stage-parts.html','/parts.js','/parts.css'].includes(path)){
14
+ if(path==='/parts.js'){bundle??=buildWeb('parts');return new Response(req.method==='HEAD'?null:await bundle,{headers:{...headers,'Content-Type':'text/javascript'}});}
15
+ return new Response(req.method==='HEAD'?null:await readFile(appRoot+'web/'+(path==='/stage-parts.html'?'parts.html':'parts.css')),{headers:{...headers,'Content-Type':path.endsWith('.css')?'text/css':'text/html; charset=utf-8'}});
16
+ }
17
+ const match=('single' in packages?/^\/api\/stage-parts(?:\/(image|page)\/(\d+))?$/:/^\/api\/compare\/(a|b)\/stage-parts(?:\/(image|page)\/(\d+))?$/).exec(path);
18
+ if(!match)return null;
19
+ const key='single' in packages?'single':match[1] as 'a'|'b',p='single' in packages?packages.single:packages[key as 'a'|'b'];
20
+ const kind=match['single' in packages?1:2] as 'image'|'page'|undefined,index=match['single' in packages?2:3];
21
+ try{
22
+ let promise=loaded.get(key);
23
+ const initializing=!promise;
24
+ if(!promise){
25
+ // Publish only a promise whose resolved value has passed BOTH sides of loading.
26
+ // Keeping a rejected promise prevents an unchecked failed load becoming a usable pin.
27
+ promise=(async()=>{await assertReviewUnchanged(p);const pkg=await loadAtlas(p);await assertReviewUnchanged(p);await assertPartsUnchanged(pkg);return pkg;})();
28
+ loaded.set(key,promise);
29
+ }
30
+ const pkg=await promise;if(!pkg.pages.length||!pkg.items.length)throw new Error('Atlas regions unavailable');
31
+ if(!kind&&!initializing){await assertReviewUnchanged(p);await assertPartsUnchanged(pkg);}
32
+ if(kind){const model=pkg.files[0]!;await serveReference(new Request(req.url,{method:'HEAD'}),model.abs,model.sha256,headers);}
33
+ if(kind){const file=servedImage(pkg,kind,Number(index));if(!file)return Response.json({error:'PARTS_IMAGE_UNAVAILABLE'},{status:404,headers});const pinned=pkg.files.find(f=>f.abs===file);if(!pinned)throw new Error('Unbound atlas page');return await serveReference(req,file,pinned.sha256,headers);}
34
+ return Response.json({...partsViewJson(pkg,{verdict:null,stale:null}),readOnly:true,inspectionSourceHash:p.sourceHash},{headers});
35
+ }catch{return Response.json({error:'PARTS_ATLAS_UNAVAILABLE: the inspected package has no usable atlas or its source changed.'},{status:409,headers});}
36
+ };
37
+ }
@@ -1,7 +1,7 @@
1
1
  /** Fit-relative inspection cameras. Images and world geometry retain their own units. */
2
2
  export interface CameraPoint {x:number;y:number}
3
3
  export interface PaneCamera {zoom:number;center:CameraPoint|null}
4
- export interface CameraFrame {space:'image'|'world';center:CameraPoint;baseScale:number;width:number;height:number}
4
+ export interface CameraFrame {space:'image'|'world';center:CameraPoint;baseScale:number;width:number;height:number;fitScale?:number}
5
5
  export interface CameraSignature {zoom:number;pan:CameraPoint}
6
6
  export const clampZoom=(zoom:number):number=>Math.max(.25,Math.min(8,zoom));
7
7
  export function cameraFrame(space:CameraFrame['space'],box:{x:number;y:number;width:number;height:number},width:number,height:number,marginX=0,marginY=0):CameraFrame|null {
@@ -13,20 +13,21 @@ export function cameraSignature(camera:PaneCamera,frame:CameraFrame):CameraSigna
13
13
  return {zoom:camera.zoom,pan:{x:(frame.center.x-center.x)*scale/frame.width,y:(frame.space==='world'?center.y-frame.center.y:frame.center.y-center.y)*scale/frame.height}};
14
14
  }
15
15
  /** Match the closed numeric observation before a candidate can replace a live camera. */
16
- export function assertCameraView(camera:PaneCamera,frame:CameraFrame):void {
16
+ export function assertCameraView(camera:PaneCamera,frame:CameraFrame,range={min:.25,max:8}):void {
17
17
  const center=camera.center??frame.center,scale=frame.baseScale*camera.zoom,width=frame.width/scale,height=frame.height/scale;
18
18
  const coordinate=(value:number)=>Number.isFinite(value)&&Math.abs(value)<=Number.MAX_SAFE_INTEGER;
19
- if(![center.x,center.y,center.x-width/2,center.y-height/2,(frame.center.x-center.x)*scale,(frame.center.y-center.y)*scale].every(coordinate)||![width,height].every(value=>Number.isFinite(value)&&value>0&&value<=Number.MAX_SAFE_INTEGER)||!Number.isFinite(scale)||scale<=0||!Number.isFinite(camera.zoom)||camera.zoom<.25||camera.zoom>8||![frame.width,frame.height].every(value=>Number.isFinite(value)&&value>0&&value<=65536))throw new Error('VIEW_CAMERA_RANGE: derived camera exceeds numeric source-coordinate limits');
19
+ if(![center.x,center.y,center.x-width/2,center.y-height/2,(frame.center.x-center.x)*scale,(frame.center.y-center.y)*scale].every(coordinate)||![width,height].every(value=>Number.isFinite(value)&&value>0&&value<=Number.MAX_SAFE_INTEGER)||!Number.isFinite(scale)||scale<=0||!Number.isFinite(camera.zoom)||camera.zoom<range.min||camera.zoom>range.max||![frame.width,frame.height].every(value=>Number.isFinite(value)&&value>0&&value<=65536))throw new Error('VIEW_CAMERA_RANGE: derived camera exceeds numeric source-coordinate limits');
20
20
  }
21
- export function cameraFromSignature(value:CameraSignature,frame:CameraFrame):PaneCamera {
22
- if(![value.zoom,value.pan.x,value.pan.y].every(Number.isFinite)||value.zoom<.25||value.zoom>8)throw new Error('Camera signature requires finite pan and zoom 0.25..8');
21
+ export function cameraFromSignature(value:CameraSignature,frame:CameraFrame,range={min:.25,max:8}):PaneCamera {
22
+ if(![value.zoom,value.pan.x,value.pan.y].every(Number.isFinite)||value.zoom<range.min||value.zoom>range.max)throw new Error('Camera signature requires finite pan and zoom 0.25..8');
23
23
  const scale=frame.baseScale*value.zoom;
24
24
  const camera={zoom:value.zoom,center:{x:frame.center.x-value.pan.x*frame.width/scale,y:frame.center.y+(frame.space==='world'?1:-1)*value.pan.y*frame.height/scale}};
25
- assertCameraView(camera,frame);return camera;
25
+ assertCameraView(camera,frame,range);return camera;
26
26
  }
27
27
  /** Zoom preserves the point under the cursor when frame and point are given, or the viewport center otherwise. */
28
- export function zoomSignature(value:CameraSignature,factor:number,frame?:Pick<CameraFrame,'width'|'height'>|null,point?:CameraPoint|null):CameraSignature {
29
- const zoom=clampZoom(value.zoom*factor),ratio=zoom/value.zoom;
28
+ export function zoomSignature(value:CameraSignature,factor:number,frame?:Pick<CameraFrame,'width'|'height'>|null,point?:CameraPoint|null,range?:{min:number;max:number}):CameraSignature {
29
+ const candidate=value.zoom*factor;if(range&&(!Number.isFinite(candidate)||candidate<range.min||candidate>range.max))throw new Error('PARTS_CAMERA_RANGE: native zoom outside supported range');
30
+ const zoom=range?candidate:clampZoom(candidate),ratio=zoom/value.zoom;
30
31
  const ox=frame&&point&&frame.width>0&&Number.isFinite(point.x)?(point.x-frame.width/2)/frame.width*(ratio-1):0;
31
32
  const oy=frame&&point&&frame.height>0&&Number.isFinite(point.y)?(point.y-frame.height/2)/frame.height*(ratio-1):0;
32
33
  return {zoom,pan:{x:value.pan.x*ratio-ox,y:value.pan.y*ratio-oy}};
package/web/catalog-en.ts CHANGED
@@ -1,4 +1,19 @@
1
1
  export const enCatalog: Readonly<Record<string, string>> = {
2
+ "Atlas source build": "Atlas source build",
3
+ "1 Parts + mesh": "1 Parts + mesh",
4
+ "2 Interview": "2 Interview",
5
+ "3 Rig + animation": "3 Rig + animation",
6
+ "4 Direction": "4 Direction",
7
+ "Inspection stages": "Inspection stages",
8
+ "Open setup mesh instruments": "Open setup mesh instruments",
9
+ "Parts and atlas inspection": "Parts and atlas inspection",
10
+ "INTERVIEW_UNAVAILABLE: no interview consumer contract is installed.": "INTERVIEW_UNAVAILABLE: no interview consumer contract is installed.",
11
+ "DIRECTION_UNAVAILABLE: no direction inspection contract is installed.": "DIRECTION_UNAVAILABLE: no direction inspection contract is installed.",
12
+ "MODEL_UNAVAILABLE: no compiled model is supplied in this inspection.": "MODEL_UNAVAILABLE: no compiled model is supplied in this inspection.",
13
+ "Atlas inspection, read only — inspected package. Applied scratch atlas, pre-rig parts, mesh sign-off and draft corrections are unavailable here.": "Atlas inspection, read only — inspected package. Applied scratch atlas, pre-rig parts, mesh sign-off and draft corrections are unavailable here.",
14
+ "Embedded atlas inspection is read-only. Use the parts command for a separate sign-off.": "Embedded atlas inspection is read-only. Use the parts command for a separate sign-off.",
15
+ "PARTS_ATLAS_UNAVAILABLE: the inspected package has no usable atlas or its source changed.": "PARTS_ATLAS_UNAVAILABLE: the inspected package has no usable atlas or its source changed.",
16
+
2
17
  " (Apply's default pack flags)": " (Apply's default pack flags)",
3
18
  " (No playback reference · time display only)": " (No playback reference · time display only)",
4
19
  " (before this change)": " (before this change)",
@@ -3082,6 +3097,13 @@ export const enCatalog: Readonly<Record<string, string>> = {
3082
3097
  "{gate} {status} on {part}": "{gate} {status} on {part}",
3083
3098
  "Check line {path}": "Check line {path}",
3084
3099
  "Producer line": "Producer line",
3100
+ "Block {gate}: {status} · {part}": "Block {gate}: {status} · {part}",
3101
+ "{root} · 1 row": "{root} · 1 row",
3102
+ "{root} · {count} rows": "{root} · {count} rows",
3103
+ "mesh {mesh} · check {check}": "mesh {mesh} · check {check}",
3104
+ "mesh {mesh}": "mesh {mesh}",
3105
+ "check {check}": "check {check}",
3106
+ "Grouped by source and producer root; counts are rows, not a classification of defects.": "Grouped by source and producer root; counts are rows, not a classification of defects.",
3085
3107
  "Page {name}: {width}×{height} px, 1 region. The background shows through padding; a region box is the packer's, and pixels outside it are bleed.": "Page {name}: {width}×{height} px, 1 region. The background shows through padding; a region box is the packer's, and pixels outside it are bleed.",
3086
3108
  "Tinted: the footprint of the part drawn in front ({names}).": "Tinted: the footprint of the part drawn in front ({names}).",
3087
3109
  "The saved sign-off is for different producer flags; this review starts fresh.": "The saved sign-off is for different producer flags; this review starts fresh.",
@@ -3091,4 +3113,36 @@ export const enCatalog: Readonly<Record<string, string>> = {
3091
3113
  "Pink: art pixels outside every triangle.": "Pink: art pixels outside every triangle.",
3092
3114
  "Mesh outcome": "Mesh outcome",
3093
3115
  "Mesh note": "Mesh note",
3116
+ "1:1": "1:1",
3117
+ "Export issue": "Export issue",
3118
+ "PARTS_COMMENT_UNAVAILABLE: original part image required": "PARTS_COMMENT_UNAVAILABLE: original part image required",
3119
+ "PARTS_REFERENCE_UNAVAILABLE: supply --painting to compare the original painting": "PARTS_REFERENCE_UNAVAILABLE: supply --painting to compare the original painting",
3120
+ "PARTS_COMMENT_STALE_SOURCE: reopen the bound source": "PARTS_COMMENT_STALE_SOURCE: reopen the bound source",
3121
+ "PARTS_COMMENT_STALE_SOURCE: original PNG changed": "PARTS_COMMENT_STALE_SOURCE: original PNG changed",
3122
+ "PARTS_COMMENT_OUT_OF_BOUNDS: region exceeds original image": "PARTS_COMMENT_OUT_OF_BOUNDS: region exceeds original image",
3123
+ "PARTS_COMMENT_EMPTY: positive region required": "PARTS_COMMENT_EMPTY: positive region required",
3124
+ "PARTS_CAMERA_RANGE: native zoom outside {0}..{1}": "PARTS_CAMERA_RANGE: native zoom outside {0}..{1}",
3125
+ "PARTS_COMMENT_CROP_LIMIT: native crop exceeds 16 million pixels": "PARTS_COMMENT_CROP_LIMIT: native crop exceeds 16 million pixels",
3126
+ "Export JSON": "Export JSON",
3127
+ "PARTS_CAMERA_RANGE: native zoom outside supported range": "PARTS_CAMERA_RANGE: native zoom outside supported range",
3128
+ "Comments on this part: {count}": "Comments on this part: {count}",
3129
+ "COMMENT_CROP_STATE_UNAVAILABLE: stored crop cannot be read": "COMMENT_CROP_STATE_UNAVAILABLE: stored crop cannot be read",
3130
+ "PARTS_COMMENT_NATIVE_CROP_TAMPERED: native crop differs from bound original": "PARTS_COMMENT_NATIVE_CROP_TAMPERED: native crop differs from bound original",
3131
+ "PARTS_VERDICT_READ: saved verdict cannot be read": "PARTS_VERDICT_READ: saved verdict cannot be read",
3132
+ "PARTS_VERDICT_INVALID: saved verdict is not valid JSON": "PARTS_VERDICT_INVALID: saved verdict is not valid JSON",
3133
+ "PARTS_VERDICT_INVALID: saved verdict schema or binding is invalid": "PARTS_VERDICT_INVALID: saved verdict schema or binding is invalid",
3134
+ "PARTS_VERDICT_INVALID: saved verdict date is invalid": "PARTS_VERDICT_INVALID: saved verdict date is invalid",
3135
+ "Painting comparison": "Painting comparison",
3136
+ "Overlay": "Overlay",
3137
+ "Part opacity": "Part opacity",
3138
+ "PARTS_COMPARISON_UNAVAILABLE: original painting required": "PARTS_COMPARISON_UNAVAILABLE: original painting required",
3139
+ "PARTS_COMPARISON_INVALID: part/overlay mode and opacity 0..1 required": "PARTS_COMPARISON_INVALID: part/overlay mode and opacity 0..1 required",
3140
+ "PARTS_PAINT_FAILED: view could not be rendered; select the part to retry": "PARTS_PAINT_FAILED: view could not be rendered; select the part to retry",
3141
+ "Assembled": "Assembled",
3142
+ "Visible": "Visible",
3143
+ "Show {name} in assembly": "Show {name} in assembly",
3144
+ "Assembly unavailable: atlas regions carry no rig placement.": "Assembly unavailable: atlas regions carry no rig placement.",
3145
+ "Assembly unavailable: rig_size is not declared.": "Assembly unavailable: rig_size is not declared.",
3146
+ "Assembled package \u00b7 {count} visible parts. Selection and verdict remain per part.": "Assembled package · {count} visible parts. Selection and verdict remain per part.",
3147
+ "PARTS_COMMENT_UNAVAILABLE: select the individual part view to comment": "PARTS_COMMENT_UNAVAILABLE: select the individual part view to comment",
3094
3148
  };
package/web/catalog-ko.ts CHANGED
@@ -1,4 +1,19 @@
1
1
  export const koCatalog: Readonly<Record<string, string>> = {
2
+ "Atlas source build": "아틀라스 소스 빌드",
3
+ "1 Parts + mesh": "1 파츠 + 메시",
4
+ "2 Interview": "2 인터뷰",
5
+ "3 Rig + animation": "3 리그 + 애니메이션",
6
+ "4 Direction": "4 연출",
7
+ "Inspection stages": "검사 단계",
8
+ "Open setup mesh instruments": "Setup 메시 도구 열기",
9
+ "Parts and atlas inspection": "파츠 및 아틀라스 검사",
10
+ "INTERVIEW_UNAVAILABLE: no interview consumer contract is installed.": "INTERVIEW_UNAVAILABLE: 인터뷰 소비자 계약이 설치되어 있지 않습니다.",
11
+ "DIRECTION_UNAVAILABLE: no direction inspection contract is installed.": "DIRECTION_UNAVAILABLE: 연출 검사 계약이 설치되어 있지 않습니다.",
12
+ "MODEL_UNAVAILABLE: no compiled model is supplied in this inspection.": "MODEL_UNAVAILABLE: 이 검사에 컴파일된 모델이 제공되지 않았습니다.",
13
+ "Atlas inspection, read only — inspected package. Applied scratch atlas, pre-rig parts, mesh sign-off and draft corrections are unavailable here.": "검사 입력 패키지의 아틀라스 · 읽기 전용. 적용된 임시 빌드의 아틀라스, 리깅 전 파츠, 메시 승인, 초안 수정 기능은 이 화면에서 사용할 수 없습니다.",
14
+ "Embedded atlas inspection is read-only. Use the parts command for a separate sign-off.": "내장 아틀라스 검사는 읽기 전용입니다. 별도 승인은 parts 명령을 사용하세요.",
15
+ "PARTS_ATLAS_UNAVAILABLE: the inspected package has no usable atlas or its source changed.": "PARTS_ATLAS_UNAVAILABLE: 검사 패키지에 사용 가능한 아틀라스가 없거나 원본이 변경되었습니다.",
16
+
2
17
  " (Apply's default pack flags)": " (적용의 기본 패킹 플래그)",
3
18
  " (No playback reference · time display only)": " (재생 레퍼런스 없음 · 시간 표시 전용)",
4
19
  " (before this change)": " (이 변경 이전)",
@@ -3082,6 +3097,13 @@ export const koCatalog: Readonly<Record<string, string>> = {
3082
3097
  "{gate} {status} on {part}": "{part}에서 {gate} {status}",
3083
3098
  "Check line {path}": "체크 줄 {path}",
3084
3099
  "Producer line": "프로듀서 원문",
3100
+ "Block {gate}: {status} · {part}": "블록 {gate}: {status} · {part}",
3101
+ "{root} · 1 row": "{root} · 1행",
3102
+ "{root} · {count} rows": "{root} · {count}행",
3103
+ "mesh {mesh} · check {check}": "메시 {mesh} · 체크 {check}",
3104
+ "mesh {mesh}": "메시 {mesh}",
3105
+ "check {check}": "체크 {check}",
3106
+ "Grouped by source and producer root; counts are rows, not a classification of defects.": "출처와 프로듀서 루트별로 묶었습니다. 수치는 행 수이며 결함 분류가 아닙니다.",
3085
3107
  "Page {name}: {width}×{height} px, 1 region. The background shows through padding; a region box is the packer's, and pixels outside it are bleed.": "페이지 {name}: {width}×{height} px, 영역 1개. 패딩에는 배경이 비쳐 보이고, 영역 상자는 패커가 정한 것이며 상자 밖의 픽셀은 블리드입니다.",
3086
3108
  "Tinted: the footprint of the part drawn in front ({names}).": "색칠된 부분: 앞에 그려지는 파츠의 풋프린트({names}).",
3087
3109
  "The saved sign-off is for different producer flags; this review starts fresh.": "저장된 승인은 다른 프로듀서 플래그에 대해 내려진 것이라, 이번 검수는 처음부터 시작합니다.",
@@ -3091,4 +3113,36 @@ export const koCatalog: Readonly<Record<string, string>> = {
3091
3113
  "Pink: art pixels outside every triangle.": "분홍색: 모든 삼각형 밖의 원화 픽셀.",
3092
3114
  "Mesh outcome": "메시 판정",
3093
3115
  "Mesh note": "메시 메모",
3116
+ "1:1": "1:1",
3117
+ "Export issue": "이슈 내보내기",
3118
+ "PARTS_COMMENT_UNAVAILABLE: original part image required": "PARTS_COMMENT_UNAVAILABLE: 원본 파트 이미지가 필요해요",
3119
+ "PARTS_REFERENCE_UNAVAILABLE: supply --painting to compare the original painting": "PARTS_REFERENCE_UNAVAILABLE: 원화 비교에는 --painting 입력이 필요해요",
3120
+ "PARTS_COMMENT_STALE_SOURCE: reopen the bound source": "PARTS_COMMENT_STALE_SOURCE: 연결된 원본을 다시 열어 주세요",
3121
+ "PARTS_COMMENT_STALE_SOURCE: original PNG changed": "PARTS_COMMENT_STALE_SOURCE: 원본 PNG가 변경됐어요",
3122
+ "PARTS_COMMENT_OUT_OF_BOUNDS: region exceeds original image": "PARTS_COMMENT_OUT_OF_BOUNDS: 영역이 원본 이미지 밖이에요",
3123
+ "PARTS_COMMENT_EMPTY: positive region required": "PARTS_COMMENT_EMPTY: 넓이가 있는 영역이 필요해요",
3124
+ "PARTS_CAMERA_RANGE: native zoom outside {0}..{1}": "PARTS_CAMERA_RANGE: 네이티브 배율이 {0}..{1} 범위 밖이에요",
3125
+ "PARTS_COMMENT_CROP_LIMIT: native crop exceeds 16 million pixels": "PARTS_COMMENT_CROP_LIMIT: 네이티브 크롭이 1,600만 픽셀을 넘어요",
3126
+ "Export JSON": "JSON 내보내기",
3127
+ "PARTS_CAMERA_RANGE: native zoom outside supported range": "PARTS_CAMERA_RANGE: 네이티브 배율이 지원 범위 밖이에요",
3128
+ "Comments on this part: {count}": "이 파트의 코멘트: {count}",
3129
+ "COMMENT_CROP_STATE_UNAVAILABLE: stored crop cannot be read": "COMMENT_CROP_STATE_UNAVAILABLE: 저장된 크롭을 읽을 수 없어요",
3130
+ "PARTS_COMMENT_NATIVE_CROP_TAMPERED: native crop differs from bound original": "PARTS_COMMENT_NATIVE_CROP_TAMPERED: 네이티브 크롭이 연결된 원본과 달라요",
3131
+ "PARTS_VERDICT_READ: saved verdict cannot be read": "PARTS_VERDICT_READ: 저장된 판정을 읽을 수 없어요",
3132
+ "PARTS_VERDICT_INVALID: saved verdict is not valid JSON": "PARTS_VERDICT_INVALID: 저장된 판정이 올바른 JSON이 아니에요",
3133
+ "PARTS_VERDICT_INVALID: saved verdict schema or binding is invalid": "PARTS_VERDICT_INVALID: 저장된 판정의 스키마나 원본 연결이 잘못됐어요",
3134
+ "PARTS_VERDICT_INVALID: saved verdict date is invalid": "PARTS_VERDICT_INVALID: 저장된 판정의 날짜가 잘못됐어요",
3135
+ "Painting comparison": "원화 비교",
3136
+ "Overlay": "오버레이",
3137
+ "Part opacity": "파츠 불투명도",
3138
+ "PARTS_COMPARISON_UNAVAILABLE: original painting required": "PARTS_COMPARISON_UNAVAILABLE: 원본 원화가 필요해요",
3139
+ "PARTS_COMPARISON_INVALID: part/overlay mode and opacity 0..1 required": "PARTS_COMPARISON_INVALID: 파트/오버레이 모드와 0..1 불투명도가 필요해요",
3140
+ "PARTS_PAINT_FAILED: view could not be rendered; select the part to retry": "PARTS_PAINT_FAILED: 화면을 그리지 못했어요. 파츠를 선택해 다시 시도해 주세요",
3141
+ "Assembled": "조립 보기",
3142
+ "Visible": "표시",
3143
+ "Show {name} in assembly": "조립 보기에서 {name} 표시",
3144
+ "Assembly unavailable: atlas regions carry no rig placement.": "조립 불가: 아틀라스 영역에는 리그 배치 정보가 없어요.",
3145
+ "Assembly unavailable: rig_size is not declared.": "조립 불가: rig_size가 선언되지 않았어요.",
3146
+ "Assembled package \u00b7 {count} visible parts. Selection and verdict remain per part.": "조립 패키지 · 파트 {count}개 표시. 선택과 판정은 파트별로 유지돼요.",
3147
+ "PARTS_COMMENT_UNAVAILABLE: select the individual part view to comment": "PARTS_COMMENT_UNAVAILABLE: 댓글을 쓰려면 개별 파트 보기로 전환해 주세요",
3094
3148
  };
package/web/compare.css CHANGED
@@ -276,3 +276,19 @@ main{position:relative}.viewbar,.toolbar{anchor-name:--stage-comment-bar}#stage-
276
276
  .settings-toggle::before{content:"▾";font-size:10px;line-height:1}
277
277
  .settings-toggle[aria-expanded=true]::before{content:"▴"}
278
278
  :root:lang(ko){word-break:keep-all;overflow-wrap:break-word}
279
+
280
+ /* Stage navigation retains mounted inspection tools and their state. */
281
+ .review-stage-nav{display:flex;gap:4px;flex-wrap:wrap;align-items:center}
282
+ .review-stage-nav button{font:inherit;white-space:nowrap;padding:5px 8px}
283
+ .review-stage-nav [aria-current="step"]{font-weight:700;text-decoration:underline;text-underline-offset:4px}
284
+ .review-stage-panel{position:fixed;inset:0;z-index:90;display:flex;flex-direction:column;padding:12px;background:var(--bg);color:inherit;overflow:auto}
285
+ .review-stage-panel[hidden]{display:none}
286
+ .review-stage-panel iframe{width:100%;flex:1;min-height:240px;border:0;background:var(--bg)}
287
+ .review-stage-panel iframe[hidden]{display:none}
288
+ .topbar,.pv-top{flex-wrap:wrap}
289
+
290
+ /* Setup/Animate/Compare are instruments within stage 3, never additional primary stages. */
291
+ :root[data-inspection-stage]:not([data-inspection-stage="3"]) .mode-switch{display:none}
292
+ :root[data-inspection-stage="1"] #mode-build-picker{display:flex!important}
293
+ :root[data-inspection-stage="1"] #mode-build-picker>.eyebrow{display:none}
294
+ :root[data-inspection-stage="2"] #mode-build-picker,:root[data-inspection-stage="4"] #mode-build-picker{display:none!important}