rig-review 2.4.3 → 2.4.5
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.
- package/package.json +1 -1
- package/src/interview-project.ts +3 -1
- package/src/interview-routes.ts +1 -0
- package/src/parts-view.ts +26 -15
- package/web/catalog-en.ts +1 -0
- package/web/catalog-ko.ts +1 -0
- package/web/interview-panel.ts +1 -0
package/package.json
CHANGED
package/src/interview-project.ts
CHANGED
|
@@ -245,8 +245,10 @@ export function readProject(root: string, now = Date.now()) {
|
|
|
245
245
|
const expectedStage = allowed.length === 1 ? allowed[0]! :
|
|
246
246
|
['rig_type','reference','seethrough','assemble'].includes(String(item.id)) ? 'interview' : 'rigging-interview';
|
|
247
247
|
const set = validateSet(raw, item.id, [expectedStage]);
|
|
248
|
+
if (object(raw.context).kind === 'scene') throw new Error('INTERVIEW_CONTEXT_KIND_UNSUPPORTED: scene');
|
|
248
249
|
const editable = entry.answer === undefined;
|
|
249
|
-
if (editable && (
|
|
250
|
+
if (editable && (set.stage === 'interview' || set.stage === 'rigging-interview') &&
|
|
251
|
+
(object(interview.order).spec !== 'rig-create/stage-order@2' || !Number.isFinite(date(object(interview.order).choices_adopted_at)))) {
|
|
250
252
|
throw new Error('INTERVIEW_CHOICE_REQUIRED: Adopt create choices before selecting');
|
|
251
253
|
}
|
|
252
254
|
if (editable && approval(project, set.stage === 'interview' ? 'plan-approved' : set.stage, now)) return invalid('Question approval is still live');
|
package/src/interview-routes.ts
CHANGED
|
@@ -35,6 +35,7 @@ async function body(req: Request) {
|
|
|
35
35
|
export const interviewRefusals = [
|
|
36
36
|
'INTERVIEW_UNAVAILABLE', 'INTERVIEW_SOURCE_MISMATCH', 'INTERVIEW_CHOICE_INVALID',
|
|
37
37
|
'INTERVIEW_CHOICE_CONSTRAINT', 'INTERVIEW_CHOICE_REQUIRED', 'INTERVIEW_OPTIONS_INVALID',
|
|
38
|
+
'INTERVIEW_CONTEXT_KIND_UNSUPPORTED',
|
|
38
39
|
'INTERVIEW_OPTIONS_FILE', 'INTERVIEW_OPTIONS_STALE', 'INTERVIEW_PICKS_OUTPUT',
|
|
39
40
|
] as const;
|
|
40
41
|
export function interviewRequest(path: string) {
|
package/src/parts-view.ts
CHANGED
|
@@ -104,11 +104,14 @@ export async function insideRoot(root: string, path: string, code: string, what:
|
|
|
104
104
|
return real;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
const bytes = await readFile(abs);
|
|
107
|
+
function hashBytes(abs: string, bytes: Buffer): LocalFile {
|
|
109
108
|
return { abs, bytes: bytes.length, sha256: createHash('sha256').update(bytes).digest('hex') };
|
|
110
109
|
}
|
|
111
110
|
|
|
111
|
+
async function hashFile(abs: string): Promise<LocalFile> {
|
|
112
|
+
return hashBytes(abs, await readFile(abs));
|
|
113
|
+
}
|
|
114
|
+
|
|
112
115
|
/** A part name is a file stem under `parts/`: no separators, no traversal. */
|
|
113
116
|
function partFileName(name: string): string {
|
|
114
117
|
if (!name || name === '.' || name === '..' || /[/\\\x00-\x1f]/.test(name)) refuse('PARTS_NAME_INVALID', `part name ${JSON.stringify(name)} is not a file name under parts/`);
|
|
@@ -230,8 +233,13 @@ export function checkReadings(doc: unknown, names: ReadonlySet<string>): Produce
|
|
|
230
233
|
return labelled ? rows : checkFlags(doc, names).map(f => ({...f, classification:'unclassified' as const, ...(f.kind === 'check' ? {line:JSON.stringify(f.entry)} : {})}));
|
|
231
234
|
}
|
|
232
235
|
|
|
233
|
-
|
|
234
|
-
try { return JSON.parse(
|
|
236
|
+
function parseJson(bytes: Buffer, what: string): unknown {
|
|
237
|
+
try { return JSON.parse(bytes.toString('utf8')); } catch (e) { return refuse('PARTS_FLAGS_MALFORMED', `${what}: ${e instanceof Error ? e.message : String(e)}`); }
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
async function readJsonBytes(abs: string, what: string): Promise<{ bytes: Buffer; value: unknown }> {
|
|
241
|
+
try { const bytes = await readFile(abs); return { bytes, value: JSON.parse(bytes.toString('utf8')) }; }
|
|
242
|
+
catch (e) { return refuse('PARTS_FLAGS_MALFORMED', `${what}: ${e instanceof Error ? e.message : String(e)}`); }
|
|
235
243
|
}
|
|
236
244
|
|
|
237
245
|
/**
|
|
@@ -239,8 +247,9 @@ async function readJson(abs: string, what: string): Promise<unknown> {
|
|
|
239
247
|
* writes `mesh_report.json` beside `parts.json` in `rig/`, and `check` writes `check/check.json` beside `rig/`.
|
|
240
248
|
* `rigDir` is that `rig/` directory (parts mode) or null (atlas mode: explicit paths only, or `buildRoot`'s files).
|
|
241
249
|
*/
|
|
242
|
-
async function producerFlags(rigDir: string | null, buildRoot: string | null, names: ReadonlySet<string>, options: PartsViewOptions): Promise<{ flags: ProducerFlag[]; readings: ProducerFlag[]; files: LocalFile[]; notes: string[] }> {
|
|
250
|
+
async function producerFlags(rigDir: string | null, buildRoot: string | null, names: ReadonlySet<string>, options: PartsViewOptions): Promise<{ flags: ProducerFlag[]; readings: ProducerFlag[]; files: LocalFile[]; notes: string[]; meshReport: unknown }> {
|
|
243
251
|
const flags: ProducerFlag[] = [], readings: ProducerFlag[] = [], files: LocalFile[] = [], notes: string[] = [];
|
|
252
|
+
let meshReport: unknown = null;
|
|
244
253
|
// A discovered file must resolve inside the directory it was discovered in; a path given on the command line is the user's own choice.
|
|
245
254
|
const pick = async (explicit: string | undefined, candidates: ([string, string] | null)[], what: string): Promise<string | null> => {
|
|
246
255
|
if (explicit !== undefined) return realpath(resolve(explicit));
|
|
@@ -248,12 +257,12 @@ async function producerFlags(rigDir: string | null, buildRoot: string | null, na
|
|
|
248
257
|
return found ? insideRoot(found[0], found[1], 'PARTS_FLAGS_OUTSIDE', what) : null;
|
|
249
258
|
};
|
|
250
259
|
const mesh = await pick(options.meshReport, [rigDir ? [rigDir, join(rigDir, 'mesh_report.json')] : null, buildRoot ? [buildRoot, join(buildRoot, 'rig', 'mesh_report.json')] : null], 'mesh_report.json');
|
|
251
|
-
if (mesh) {
|
|
260
|
+
if (mesh) { const bytes = await readFile(mesh); files.push(hashBytes(mesh, bytes)); meshReport = parseJson(bytes, 'mesh_report.json'); flags.push(...meshReportFlags(meshReport, names)); }
|
|
252
261
|
else notes.push('mesh_report.json');
|
|
253
262
|
const check = await pick(options.check, [rigDir ? [dirname(rigDir), join(dirname(rigDir), 'check', 'check.json')] : null, buildRoot ? [buildRoot, join(buildRoot, 'check', 'check.json')] : null], 'check/check.json');
|
|
254
|
-
if (check) { files.push(
|
|
263
|
+
if (check) { const bytes = await readFile(check); files.push(hashBytes(check, bytes)); const doc = parseJson(bytes, 'check.json'); flags.push(...checkFlags(doc, names)); readings.push(...checkReadings(doc, names)); }
|
|
255
264
|
else notes.push('check.json');
|
|
256
|
-
return { flags, readings, files, notes };
|
|
265
|
+
return { flags, readings, files, notes, meshReport };
|
|
257
266
|
}
|
|
258
267
|
|
|
259
268
|
/** Exact attachment identity and UV-derived geometry; never reconstruct through weights. */
|
|
@@ -322,12 +331,13 @@ async function locateMeshRasters(rig: unknown, root: string, items: ViewItem[],
|
|
|
322
331
|
|
|
323
332
|
async function loadPartsMode(root: string, options: PartsViewOptions): Promise<PartsViewPackage> {
|
|
324
333
|
const partsJson = await insideRoot(root, join(root, 'parts.json'), 'PARTS_FILE_OUTSIDE', 'parts.json');
|
|
325
|
-
const
|
|
334
|
+
const { bytes: partsBytes, value: partsRaw } = await readJsonBytes(partsJson, 'parts.json');
|
|
335
|
+
const doc = record(partsRaw);
|
|
326
336
|
const list = doc?.parts;
|
|
327
337
|
if (!doc || !Array.isArray(list)) return refuse('PARTS_JSON_MALFORMED', 'parts.json has no parts[] array');
|
|
328
338
|
const size = doc.rig_size;
|
|
329
339
|
const rigSize: [number, number] | null = Array.isArray(size) && size.length === 2 && finite(size[0], 1) && finite(size[1], 1) ? [size[0], size[1]] : null;
|
|
330
|
-
const items: ViewItem[] = [], imagePaths: string[] = [], files: LocalFile[] = [
|
|
340
|
+
const items: ViewItem[] = [], imagePaths: string[] = [], files: LocalFile[] = [hashBytes(partsJson, partsBytes)];
|
|
331
341
|
const seen = new Set<string>();
|
|
332
342
|
for (const [index, raw] of list.entries()) {
|
|
333
343
|
const p = record(raw);
|
|
@@ -337,7 +347,7 @@ async function loadPartsMode(root: string, options: PartsViewOptions): Promise<P
|
|
|
337
347
|
seen.add(part.name);
|
|
338
348
|
const abs = join(root, 'parts', partFileName(part.name));
|
|
339
349
|
if (!existsSync(abs)) refuse('PARTS_IMAGE_MISSING', `parts/${part.name}.png is named in parts.json and is not on disk`);
|
|
340
|
-
//
|
|
350
|
+
// Resolved to its current real path inside root before hashing; full path-replacement pinning stays tracked in #479.
|
|
341
351
|
const real = await insideRoot(root, abs, 'PARTS_IMAGE_OUTSIDE', `parts/${part.name}.png`);
|
|
342
352
|
files.push(await hashFile(real));
|
|
343
353
|
imagePaths.push(real);
|
|
@@ -368,7 +378,7 @@ async function loadPartsMode(root: string, options: PartsViewOptions): Promise<P
|
|
|
368
378
|
assertOriginalPaintingSize(png!.width,png!.height,rigSize,doc.scale_rig_per_source);
|
|
369
379
|
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);
|
|
370
380
|
}
|
|
371
|
-
const { flags, readings, files: flagFiles, notes } = await producerFlags(root, null, seen, options);
|
|
381
|
+
const { flags, readings, files: flagFiles, notes, meshReport } = await producerFlags(root, null, seen, options);
|
|
372
382
|
const protectedPaths = [join(root, 'rig.json'), join(root, 'config.json'), join(root, 'review.json'), join(root, 'report.json')];
|
|
373
383
|
if (basename(root) === 'rig') protectedPaths.push(...['parts.json', 'config.json', 'review.json', 'report.json'].map(name => join(dirname(root), name)));
|
|
374
384
|
if (options.rig !== undefined) protectedPaths.push(resolve(options.rig));
|
|
@@ -381,7 +391,7 @@ async function loadPartsMode(root: string, options: PartsViewOptions): Promise<P
|
|
|
381
391
|
let rig: unknown;
|
|
382
392
|
try { rig = JSON.parse(rigBytes.toString('utf8')); }
|
|
383
393
|
catch (e) { return refuse('PARTS_MESH_MALFORMED', `rig.json: ${e instanceof Error ? e.message : String(e)}`); }
|
|
384
|
-
readPartMeshes(rig, items, report ?
|
|
394
|
+
readPartMeshes(rig, items, report ? meshReport : null);
|
|
385
395
|
await locateMeshRasters(rig, dirname(rigPath), items, imagePaths, files);
|
|
386
396
|
// Bind exactly the bytes parsed above, even if the path is replaced during raster checks.
|
|
387
397
|
files.push({ abs: rigPath, bytes: rigBytes.length, sha256: createHash('sha256').update(rigBytes).digest('hex') });
|
|
@@ -402,10 +412,11 @@ export async function loadPartsAtlas(p: ReviewPackage, options: PartsViewOptions
|
|
|
402
412
|
const modelPath = p.manifest.model;
|
|
403
413
|
if (!modelPath) return refuse('PARTS_VIEW_NO_ATLAS', `The inspected package holds no compiled model with pages`);
|
|
404
414
|
const modelAbs = await safeFile(p.root, modelPath);
|
|
405
|
-
const
|
|
415
|
+
const modelBytes = await readFile(modelAbs);
|
|
416
|
+
const model = record(JSON.parse(modelBytes.toString('utf8')));
|
|
406
417
|
const pagesRaw = model?.pages;
|
|
407
418
|
if (!Array.isArray(pagesRaw)) return refuse('PARTS_VIEW_NO_ATLAS', `${modelPath} declares no pages`);
|
|
408
|
-
const pages: ViewPage[] = [], pagePaths: string[] = [], items: ViewItem[] = [], files: LocalFile[] = [
|
|
419
|
+
const pages: ViewPage[] = [], pagePaths: string[] = [], items: ViewItem[] = [], files: LocalFile[] = [hashBytes(modelAbs, modelBytes)];
|
|
409
420
|
const names = new Set<string>();
|
|
410
421
|
for (const raw of pagesRaw) {
|
|
411
422
|
const page = record(raw);
|
package/web/catalog-en.ts
CHANGED
|
@@ -45,6 +45,7 @@ export const enCatalog: Readonly<Record<string, string>> = {
|
|
|
45
45
|
"DIRECTION_VERSION_UNAVAILABLE: this draft has no recorded rig review package.": "DIRECTION_VERSION_UNAVAILABLE: this draft has no recorded rig review package.",
|
|
46
46
|
"PARTS_VERDICT_READ_ONLY: a pending parts review and an explicit verdict output directory are required.": "PARTS_VERDICT_READ_ONLY: a pending parts review and an explicit verdict output directory are required.",
|
|
47
47
|
"INTERVIEW_OPTIONS_STALE": "INTERVIEW_OPTIONS_STALE: Project or source changed. Reopen the inspection.",
|
|
48
|
+
"INTERVIEW_CONTEXT_KIND_UNSUPPORTED": "INTERVIEW_CONTEXT_KIND_UNSUPPORTED: The scene option context is unsupported.",
|
|
48
49
|
"interview.joinedDraft": "Draft {0} · project {1} · source {2}",
|
|
49
50
|
"interview.joined": "Create version {0} · project SHA-256 {1} · inspection SHA-256 {2}",
|
|
50
51
|
"interview.mismatch": "INTERVIEW_SOURCE_MISMATCH: The inspection does not match the designated Create package.",
|
package/web/catalog-ko.ts
CHANGED
|
@@ -45,6 +45,7 @@ export const koCatalog: Readonly<Record<string, string>> = {
|
|
|
45
45
|
"DIRECTION_VERSION_UNAVAILABLE: this draft has no recorded rig review package.": "DIRECTION_VERSION_UNAVAILABLE: 이 초안에는 기록된 리그 검토 패키지가 없습니다.",
|
|
46
46
|
"PARTS_VERDICT_READ_ONLY: a pending parts review and an explicit verdict output directory are required.": "PARTS_VERDICT_READ_ONLY: 대기 중인 파츠 검토와 명시적으로 지정한 판정 출력 디렉터리가 필요합니다.",
|
|
47
47
|
"INTERVIEW_OPTIONS_STALE": "INTERVIEW_OPTIONS_STALE: 프로젝트 또는 원본이 바뀌었어요. 검토를 다시 여세요.",
|
|
48
|
+
"INTERVIEW_CONTEXT_KIND_UNSUPPORTED": "INTERVIEW_CONTEXT_KIND_UNSUPPORTED: scene 선택지 문맥은 지원하지 않습니다.",
|
|
48
49
|
"interview.joinedDraft": "초안 {0} · 프로젝트 {1} · 원본 {2}",
|
|
49
50
|
"interview.joined": "Create 버전 {0} · 프로젝트 SHA-256 {1} · 검토 SHA-256 {2}",
|
|
50
51
|
"interview.mismatch": "INTERVIEW_SOURCE_MISMATCH: 검토 대상이 지정한 Create 패키지와 일치하지 않아요.",
|
package/web/interview-panel.ts
CHANGED
|
@@ -10,6 +10,7 @@ export const interviewErrors: Readonly<Record<string,string>> = {
|
|
|
10
10
|
INTERVIEW_CHOICE_INVALID:'interview.invalid',
|
|
11
11
|
INTERVIEW_CHOICE_CONSTRAINT:'interview.constraint',
|
|
12
12
|
INTERVIEW_CHOICE_REQUIRED:'interview.required',
|
|
13
|
+
INTERVIEW_CONTEXT_KIND_UNSUPPORTED:'INTERVIEW_CONTEXT_KIND_UNSUPPORTED',
|
|
13
14
|
INTERVIEW_OPTIONS_INVALID:'interview.invalidOptions',
|
|
14
15
|
INTERVIEW_OPTIONS_FILE:'interview.file',
|
|
15
16
|
INTERVIEW_OPTIONS_STALE:'interview.stale',
|