rig-review 2.7.0 → 2.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.
- package/docs/PANELS.md +1 -1
- package/docs/PARTS_VIEW.md +2 -0
- package/docs/REVIEW_PACKAGE.md +32 -14
- package/docs/STABILITY.md +80 -4
- package/docs/WORKFLOWS.md +3 -1
- package/package.json +2 -2
- package/src/handoff.ts +192 -25
- package/src/interview-project.ts +186 -10
- package/src/job-act.ts +59 -11
- package/src/job-api.ts +194 -13
- package/src/job-contract.ts +117 -7
- package/src/job-front.ts +165 -26
- package/src/job-host.ts +118 -1
- package/src/job-session.ts +193 -46
- package/src/job-source.ts +88 -16
- package/src/joined-project.ts +83 -12
- package/src/manifest.ts +5 -3
- package/src/open.ts +5 -4
- package/src/rebuild.ts +445 -51
- package/src/reference.ts +3 -3
- package/src/server.ts +2 -2
- package/src/stage-parts.ts +47 -15
- package/web/catalog-en.ts +6 -0
- package/web/catalog-ko.ts +6 -0
- package/web/job-session.ts +483 -84
- package/web/main.ts +353 -43
- package/web/part-selection.ts +2 -0
- package/web/parts.ts +22 -4
- package/web/rebuild-client.ts +14 -2
- package/web/stage-nav.ts +20 -12
package/src/joined-project.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { lstatSync, readdirSync } from 'node:fs';
|
|
2
|
-
import { join, relative, sep } from 'node:path';
|
|
3
|
-
import { boundBytes, checkedPath, digest, jsonObject, literalPath, object, readProject, readRegular } from './interview-project.ts';
|
|
2
|
+
import { join, posix, relative, sep } from 'node:path';
|
|
3
|
+
import { boundBytes, checkedPath, digest, jsonObject, literalPath, object, partsDraftEditable, readProject, readRegular, type SetRef } from './interview-project.ts';
|
|
4
|
+
import { configNamedReferences, DIRECTORY_INPUT_RECEIPT, plateReceiptSpec, receiptSpec } from './handoff.ts';
|
|
4
5
|
import { DIRECTION_MAX_BYTES, readDirectionInspection } from './direction-inspection.ts';
|
|
5
6
|
import { outputDirectory } from './interview-picks.ts';
|
|
6
7
|
import { packagePath, type ReviewPackage } from './manifest.ts';
|
|
@@ -10,12 +11,25 @@ export type ProjectDesignation={root:string;picksDir:string}&(
|
|
|
10
11
|
{version:number;postVersion?:number;draftId?:never;partsVerdictDir?:never} |
|
|
11
12
|
{draftId:string;partsVerdictDir?:string;version?:never;postVersion?:never}
|
|
12
13
|
);
|
|
14
|
+
interface DraftRecord {
|
|
15
|
+
id:string;
|
|
16
|
+
kind:'draft-rig';
|
|
17
|
+
at:string;
|
|
18
|
+
producer:{name:string;version:string};
|
|
19
|
+
config:SetRef;
|
|
20
|
+
config_inputs?:(SetRef&{directory?:string;spec?:string})[];
|
|
21
|
+
parts:{path:string;files:SetRef[]};
|
|
22
|
+
files:SetRef[];
|
|
23
|
+
}
|
|
13
24
|
interface DraftSource {
|
|
25
|
+
record:DraftRecord;
|
|
26
|
+
editable:boolean;
|
|
14
27
|
parts:string;
|
|
15
28
|
rig:string;
|
|
16
29
|
meshReport:string;
|
|
17
30
|
model:string;
|
|
18
31
|
files:ReadonlyMap<string,string>;
|
|
32
|
+
starts?:readonly string[];
|
|
19
33
|
}
|
|
20
34
|
interface JoinedSource {
|
|
21
35
|
review:ReviewPackage;
|
|
@@ -31,8 +45,8 @@ export const interviewMismatch = 'INTERVIEW_SOURCE_MISMATCH';
|
|
|
31
45
|
export const interviewStale = 'INTERVIEW_OPTIONS_STALE';
|
|
32
46
|
export const directionStale = 'DIRECTION_SOURCE_STALE';
|
|
33
47
|
|
|
34
|
-
export function joinProject(p: ReviewPackage, designation: ProjectDesignation):JoinedSource {
|
|
35
|
-
if(designation.draftId!==undefined)return joinDraft(p,designation);
|
|
48
|
+
export function joinProject(p: ReviewPackage, designation: ProjectDesignation, options: { starts?: readonly string[] } = {}):JoinedSource {
|
|
49
|
+
if(designation.draftId!==undefined)return joinDraft(p,designation,options);
|
|
36
50
|
const opened = readProject(designation.root);
|
|
37
51
|
const {root, hash, project} = opened;
|
|
38
52
|
const {version} = designation;
|
|
@@ -148,18 +162,21 @@ export function joinProject(p: ReviewPackage, designation: ProjectDesignation):J
|
|
|
148
162
|
available:opened.questions.length > 0 || opened.historical.length > 0};
|
|
149
163
|
}
|
|
150
164
|
/** Match the draft writer's explicit parts and rig inventories, independently of a production version. */
|
|
151
|
-
function joinDraft(p:ReviewPackage,designation:Extract<ProjectDesignation,{draftId:string}
|
|
165
|
+
function joinDraft(p:ReviewPackage,designation:Extract<ProjectDesignation,{draftId:string}>,options:{starts?:readonly string[]}={}):JoinedSource {
|
|
152
166
|
const opened=readProject(designation.root);
|
|
153
167
|
const {root,hash,project}=opened;
|
|
154
168
|
const {draftId}=designation;
|
|
155
169
|
const path='derived/drafts/'+draftId;
|
|
156
170
|
const fail=():never=>{throw new Error('INTERVIEW_SOURCE_MISMATCH: expected the selected Create pre-rig draft and exact recorded files');};
|
|
157
|
-
if(!/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/.test(draftId)||!Array.isArray(project.versions)||
|
|
171
|
+
if(!/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/.test(draftId)||!Array.isArray(project.versions)||
|
|
158
172
|
!Array.isArray(project.drafts)||!Array.isArray(project.signoffs)||!p.manifest.model||!p.reviewedSource.rig||
|
|
159
173
|
p.direction||p.handoffInputs)return fail();
|
|
160
174
|
const matches=project.drafts.map(object).filter(draft=>draft.id===draftId);
|
|
161
175
|
const record=matches[0],parts=object(record?.parts);
|
|
162
|
-
|
|
176
|
+
const producer=object(record?.producer);
|
|
177
|
+
if(matches.length!==1||record?.kind!=='draft-rig'||typeof record.at!=='string'||!Number.isFinite(Date.parse(record.at))||
|
|
178
|
+
producer.name!=='@rig-c/parts'||typeof producer.version!=='string'||!producer.version.trim()||
|
|
179
|
+
!literalPath(parts.path)||!parts.path.startsWith(path+'/')||
|
|
163
180
|
!Array.isArray(parts.files)||!Array.isArray(record.files)||
|
|
164
181
|
(record.config_inputs!==undefined&&!Array.isArray(record.config_inputs)))return fail();
|
|
165
182
|
const files=new Map<string,string>();
|
|
@@ -176,10 +193,45 @@ function joinDraft(p:ReviewPackage,designation:Extract<ProjectDesignation,{draft
|
|
|
176
193
|
return paths;
|
|
177
194
|
};
|
|
178
195
|
let draft:DraftSource;
|
|
196
|
+
let assertInventory:()=>void;
|
|
197
|
+
const searchStarts=options.starts??[...(p.cwd?[p.cwd]:[]),process.cwd()];
|
|
179
198
|
try{
|
|
180
199
|
inventory([record.config,...(record.config_inputs??[])],path);
|
|
200
|
+
const config=object(record.config),doc=jsonObject(boundBytes(root,config as unknown as SetRef));
|
|
201
|
+
const configDir=posix.dirname(config.path as string);
|
|
202
|
+
const {partsRoot,references}=configNamedReferences(doc,[join(root,configDir),root,p.root,...searchStarts]);
|
|
203
|
+
const rawInputs=(record.config_inputs??[]).map(object);
|
|
204
|
+
for(const entry of rawInputs){
|
|
205
|
+
if(entry.directory!==undefined){
|
|
206
|
+
if(!literalPath(entry.directory)||!entry.directory.startsWith(path+'/')||entry.path!==`${entry.directory}/${DIRECTORY_INPUT_RECEIPT}`||typeof entry.spec!=='string'||!entry.spec)return fail();
|
|
207
|
+
checkedPath(root,entry.directory,true);
|
|
208
|
+
const bytes=boundBytes(root,{path:entry.path as string,sha256:entry.sha256 as string});
|
|
209
|
+
if(receiptSpec(bytes)!==entry.spec)return fail();
|
|
210
|
+
}else if(entry.spec!==undefined)return fail();
|
|
211
|
+
}
|
|
212
|
+
for(const ref of references){
|
|
213
|
+
if(!literalPath(ref.value))return fail();
|
|
214
|
+
const resolved=posix.join(configDir,ref.value);
|
|
215
|
+
if(ref.kind==='plate'){
|
|
216
|
+
const expectedSpec=plateReceiptSpec(partsRoot,`config ${ref.at}`);
|
|
217
|
+
const receiptPath=`${resolved}/${DIRECTORY_INPUT_RECEIPT}`;
|
|
218
|
+
if(!rawInputs.some(entry=>entry.path===receiptPath&&entry.directory===resolved&&entry.spec===expectedSpec))return fail();
|
|
219
|
+
}else if(!rawInputs.some(entry=>entry.path===resolved&&entry.directory===undefined)){
|
|
220
|
+
return fail();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
181
223
|
const input=inventory(parts.files,parts.path);
|
|
182
224
|
if(!input.includes(parts.path+'/parts.json')||!input.some(file=>file.startsWith(parts.path+'/parts/')))return fail();
|
|
225
|
+
const manifest=jsonObject(boundBytes(root,{path:parts.path+'/parts.json',sha256:files.get(parts.path+'/parts.json')!}));
|
|
226
|
+
if(!Array.isArray(manifest.parts)||manifest.parts.some(part=>{
|
|
227
|
+
const {name}=object(part);
|
|
228
|
+
return !literalPath(name)||name.includes('/')||!input.includes(parts.path+'/parts/'+name+'.png');
|
|
229
|
+
}))return fail();
|
|
230
|
+
if(manifest.painting_in_rig!==undefined){
|
|
231
|
+
const painting=object(manifest.painting_in_rig);
|
|
232
|
+
if(!literalPath(painting.path)||!input.includes(parts.path+'/'+painting.path)||
|
|
233
|
+
files.get(parts.path+'/'+painting.path)!==painting.sha256)return fail();
|
|
234
|
+
}
|
|
183
235
|
const output=inventory(record.files,path);
|
|
184
236
|
const rigs=output.filter(file=>file.endsWith('/rig.json'));
|
|
185
237
|
if(rigs.length!==1)return fail();
|
|
@@ -190,22 +242,41 @@ function joinDraft(p:ReviewPackage,designation:Extract<ProjectDesignation,{draft
|
|
|
190
242
|
if(!output.includes(meshReport)||!output.includes(dir+'/motion.json')||
|
|
191
243
|
!model.startsWith(checkRoot+'/check/')||!output.includes(model)||files.get(model)!==p.reviewedSource.rig.sha256||
|
|
192
244
|
![...p.files].every(file=>output.includes(relative(root,join(p.root,file)).split(sep).join('/'))))return fail();
|
|
193
|
-
|
|
194
|
-
|
|
245
|
+
const directoryInventory=(prefix:string,expected:string[])=>{
|
|
246
|
+
const remaining=new Set(expected);
|
|
247
|
+
const visit=(prefix:string)=>{
|
|
248
|
+
for(const entry of readdirSync(checkedPath(root,prefix,true),{withFileTypes:true})){
|
|
249
|
+
const file=prefix+'/'+entry.name;
|
|
250
|
+
if(!literalPath(file))return fail();
|
|
251
|
+
if(entry.isDirectory())visit(file);
|
|
252
|
+
else if(!entry.isFile()||!remaining.delete(file))return fail();
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
visit(prefix);
|
|
256
|
+
if(remaining.size)return fail();
|
|
257
|
+
};
|
|
258
|
+
assertInventory=()=>{
|
|
259
|
+
directoryInventory(parts.path+'/parts',input.filter(file=>file.startsWith(parts.path+'/parts/')));
|
|
260
|
+
directoryInventory(checkRoot,output);
|
|
261
|
+
};
|
|
262
|
+
assertInventory();
|
|
263
|
+
draft={record:record as unknown as DraftRecord,editable:partsDraftEditable(project),
|
|
264
|
+
parts:checkedPath(root,parts.path,true),rig:checkedPath(root,rig),meshReport:checkedPath(root,meshReport),
|
|
265
|
+
model:checkedPath(root,model),files:new Map([...files].map(([file,sha])=>[checkedPath(root,file),sha])),
|
|
266
|
+
starts:[join(root,configDir),root,p.root,...searchStarts]};
|
|
195
267
|
for(const [path,sha256] of files)boundBytes(root,{path,sha256});
|
|
196
268
|
}catch{return fail();}
|
|
197
269
|
outputDirectory(root,designation.picksDir,project);
|
|
198
270
|
const assertCurrent=async()=>{
|
|
199
271
|
try{
|
|
200
272
|
await assertReviewUnchanged(p);
|
|
273
|
+
assertInventory();
|
|
201
274
|
for(const [path,sha256] of files)boundBytes(root,{path,sha256});
|
|
202
275
|
if(digest(readRegular(checkedPath(root,'project.json'),8*1024*1024))!==hash)throw new Error('Project changed');
|
|
203
276
|
}catch{throw new Error(interviewStale+': project or draft changed; reopen the project');}
|
|
204
277
|
};
|
|
205
278
|
const dir=designation.partsVerdictDir;
|
|
206
279
|
// An explicit output selects the write surface. A recorded parts approval closes it.
|
|
207
|
-
const pending=['parts','parts-review'].includes(String(project.stage))&&
|
|
208
|
-
!project.signoffs.map(object).some(signoff=>signoff.stage==='parts-review');
|
|
209
280
|
let verdictDirectory:JoinedSource['verdictDirectory'];
|
|
210
281
|
if(dir!==undefined){
|
|
211
282
|
const locate=()=>{
|
|
@@ -217,7 +288,7 @@ function joinDraft(p:ReviewPackage,designation:Extract<ProjectDesignation,{draft
|
|
|
217
288
|
catch{throw new Error('PARTS_VERDICT_OUTPUT');}
|
|
218
289
|
};
|
|
219
290
|
const original=lstatSync(locate());
|
|
220
|
-
if(
|
|
291
|
+
if(draft.editable)verdictDirectory=()=>{
|
|
221
292
|
const output=locate(),stat=lstatSync(output);
|
|
222
293
|
if(stat.dev!==original.dev||stat.ino!==original.ino)throw new Error('PARTS_VERDICT_OUTPUT');
|
|
223
294
|
return output;
|
package/src/manifest.ts
CHANGED
|
@@ -31,6 +31,8 @@ export interface ReviewPackage { direction?:DirectionInspection; setsHash?:strin
|
|
|
31
31
|
buildRoot?: string;
|
|
32
32
|
/** #305: viewer-only open (`--view-only`). */
|
|
33
33
|
viewOnly?: boolean;
|
|
34
|
+
/** Logical working directory passed at load/open time for resolving an external producer (`options.cwd`). */
|
|
35
|
+
cwd?: string;
|
|
34
36
|
/** #329: the handoff's source painting, served at a fixed route by its pinned hash; absent when the handoff knows none. */
|
|
35
37
|
sourcePainting?: SourcePainting }
|
|
36
38
|
function fail(field: string, expected: string): never { throw new Error(`${field}: expected ${expected}`); }
|
|
@@ -86,7 +88,7 @@ export function parseManifest(input: unknown): ReviewManifest {
|
|
|
86
88
|
return manifest;
|
|
87
89
|
}
|
|
88
90
|
/** `options.handoff` are the explicit `--config …` flags; they win over the manifest block and discovery. */
|
|
89
|
-
export async function loadReview(input: string, options: { handoff?: HandoffFlags } = {}): Promise<ReviewPackage> {
|
|
91
|
+
export async function loadReview(input: string, options: { handoff?: HandoffFlags; cwd?: string } = {}): Promise<ReviewPackage> {
|
|
90
92
|
const inputPath=await realpath(resolve(input));const directory=(await stat(inputPath)).isDirectory();
|
|
91
93
|
if(directory){try{await stat(resolve(inputPath,'review.json'));return loadReview(resolve(inputPath,'review.json'),options);}catch(e){if((e as NodeJS.ErrnoException).code!=='ENOENT')throw e;}
|
|
92
94
|
// #149: a rig-parts build root without a model of its own opens as its check package, exactly as opening check/ does.
|
|
@@ -118,7 +120,7 @@ export async function loadReview(input: string, options: { handoff?: HandoffFlag
|
|
|
118
120
|
}
|
|
119
121
|
const reportPath=files.has('report.json')?'report.json':authoringPath('report.json');let report:ReportSeeds|null=null;let modelMetadata:Record<string,unknown>|null=null;let directionInput:unknown;
|
|
120
122
|
// The handoff files are hashed beside the package: their record joins the reviewed identity (and so the session file).
|
|
121
|
-
const {handoff,reason:handoffReason}=await resolveHandoff(root,manifest.producer,options.handoff);
|
|
123
|
+
const {handoff,reason:handoffReason}=await resolveHandoff(root,manifest.producer,options.handoff,{starts:[options.cwd??process.cwd()]});
|
|
122
124
|
// #329: the source painting the handoff knows is the first reference, outside the package's own files.
|
|
123
125
|
const painting=sourcePainting(manifest,handoff,directory);
|
|
124
126
|
const hash = createHash('sha256');hash.update(JSON.stringify(manifest));hash.update('\0');const fileHashes=new Map<string,string>();
|
|
@@ -135,7 +137,7 @@ export async function loadReview(input: string, options: { handoff?: HandoffFlag
|
|
|
135
137
|
const reviewedSource:ReviewedSource={packageRevision:manifest.revision,...await toolVersions(),rig:rigPath?{path:rigPath,sha256:fileHashes.get(rigPath)!}:null,motion:motionPath?{path:motionPath,sha256:fileHashes.get(motionPath)!}:null,...(handoff?{handoff:handoff.record}:{})};
|
|
136
138
|
const direction=manifest.direction?readDirectionInspection(directionInput,{path:manifest.direction,sha256:fileHashes.get(manifest.direction)!},reviewedSource.rig):undefined;
|
|
137
139
|
const feedbackCatalog:FeedbackCatalog={rig:manifest.id,bones:modelNames(modelMetadata,'bones'),slots:modelNames(modelMetadata,'slots'),animations:modelAnimations(modelMetadata),clock:report?.clock??null,clockAnimation:report?.animation??null,...(discoverTurnDials(modelMetadata).length?{turnDials:discoverTurnDials(modelMetadata)}:{})};
|
|
138
|
-
return {...(direction?{direction}:{}),...(manifest.sets?{setsHash:fileHashes.get(manifest.sets)!}:{}),referenceHashes:Object.fromEntries(manifest.references.map(r=>[r.id,r.id===painting?.id?painting.sha256:fileHashes.get(r.path)!])),root,manifestPath,manifest,sourceHash:hash.digest('hex'),reviewedSource,files,report,feedbackCatalog,handoff,handoffReason,...(handoff?.flags?{handoffInputs:handoff.flags}:{}),...(buildRoot?{buildRoot}:{}),...(painting?{sourcePainting:painting}:{})};
|
|
140
|
+
return {...(direction?{direction}:{}),...(manifest.sets?{setsHash:fileHashes.get(manifest.sets)!}:{}),referenceHashes:Object.fromEntries(manifest.references.map(r=>[r.id,r.id===painting?.id?painting.sha256:fileHashes.get(r.path)!])),root,manifestPath,manifest,sourceHash:hash.digest('hex'),reviewedSource,files,report,feedbackCatalog,handoff,handoffReason,...(handoff?.flags?{handoffInputs:handoff.flags}:{}),...(buildRoot?{buildRoot}:{}),...(painting?{sourcePainting:painting}:{}),...(options.cwd?{cwd:options.cwd}:{})};
|
|
139
141
|
}
|
|
140
142
|
|
|
141
143
|
/** #329: the reference id and served path of the handoff's source painting; the path is a name, never a package file. */
|
package/src/open.ts
CHANGED
|
@@ -43,9 +43,9 @@ const appRoot=fileURLToPath(new URL('..',import.meta.url));
|
|
|
43
43
|
const digest=(value:unknown)=>createHash('sha256').update(JSON.stringify(value)).digest('hex');
|
|
44
44
|
const sleep=(ms:number)=>new Promise(resolveSleep=>setTimeout(resolveSleep,ms));
|
|
45
45
|
export const defaultStateDir=()=>process.env.RIG_REVIEW_STATE_DIR??join(homedir(),'.local','state','rig-c-review');
|
|
46
|
-
export async function loadOpenPackage(inputs:OpenInputs):Promise<OpenPackage>{
|
|
46
|
+
export async function loadOpenPackage(inputs:OpenInputs,options:{cwd?:string}={}):Promise<OpenPackage>{
|
|
47
47
|
// Handoff flags become canonical absolute paths here, so the worker and every reload read exactly these files.
|
|
48
|
-
if(!inputs.compare){const base=await loadReferencedReview(inputs.input,inputs.reference,handoffFlags(inputs));const joined=inputs.project?joinProject(base,inputs.project):undefined;const p=joined?.review??base,selection=selectAnimation([{label:'single',catalog:p.feedbackCatalog,report:p.report}],inputs.animation,true);if(inputs.viewOnly)p.viewOnly=true;return {mode:'single',p,selection,contentHash:p.sourceHash,...(joined?{joined}:{}),inputs:{input:p.manifestPath,...(joined?{project:joined.designation}:{}),...(selectedReference(p)?{reference:selectedReference(p)!.path}:{}),...(selection?{animation:selection.name}:{}),...(inputs.control?{control:true}:{}),...(p.handoffInputs??{})}};}
|
|
48
|
+
if(!inputs.compare){const base=await loadReferencedReview(inputs.input,inputs.reference,handoffFlags(inputs),options.cwd);const joined=inputs.project?joinProject(base,inputs.project,{starts:[options.cwd??process.cwd()]}):undefined;const p=joined?.review??base,selection=selectAnimation([{label:'single',catalog:p.feedbackCatalog,report:p.report}],inputs.animation,true);if(inputs.viewOnly)p.viewOnly=true;return {mode:'single',p,selection,contentHash:p.sourceHash,...(joined?{joined}:{}),inputs:{input:p.manifestPath,...(joined?{project:joined.designation}:{}),...(selectedReference(p)?{reference:selectedReference(p)!.path}:{}),...(selection?{animation:selection.name}:{}),...(inputs.control?{control:true}:{}),...(p.handoffInputs??{})}};}
|
|
49
49
|
if(inputs.project)throw new Error('INTERVIEW_SOURCE_MISMATCH: compare takes no joined project');
|
|
50
50
|
if(handoffFlags(inputs))throw new HandoffError('HANDOFF_FLAGS_INVALID','--config','compare takes no producer handoff; open one package with --config');
|
|
51
51
|
if(!inputs.reference)throw new Error('open compare: explicit --reference required');
|
|
@@ -130,7 +130,7 @@ export async function prepareOpenTarget(inputs: OpenInputs, options: OpenOptions
|
|
|
130
130
|
const viewOnly=options.viewOnly??inputs.viewOnly??false;
|
|
131
131
|
for(const path of [inputs.input,...(inputs.compare!==undefined?[inputs.compare]:[])])await assertOpenInput(path);
|
|
132
132
|
if(inputs.compare!==undefined&&!inputs.reference)throw new Error('OPEN_REFERENCE_REQUIRED: compare: explicit --reference required');
|
|
133
|
-
let p:OpenPackage;try{p=await loadOpenPackage(inputs);}catch(error){throw await openRefusal(error,inputs);}
|
|
133
|
+
let p:OpenPackage;try{p=await loadOpenPackage(inputs,{cwd:options.cwd});}catch(error){throw await openRefusal(error,inputs);}
|
|
134
134
|
fingerprint??=await openFingerprint();const key=openKey(p,fingerprint);
|
|
135
135
|
// #187: canonical (symlinks and ancestors resolved) and outside every supplied folder: the package, the build root a check package belongs to, the handoff root.
|
|
136
136
|
const stateDir=destinationDirectory(options.stateDir??defaultStateDir(),'OPEN_STATE_INVALID: the state directory path has a non-directory component or a symlink loop'),roots=p.mode==='single'?stateRoots(p.p):[...stateRoots(p.p.a),...stateRoots(p.p.b)];
|
|
@@ -168,7 +168,8 @@ async function ensureWorker(p:OpenPackage,key:string,fingerprint:string,stateDir
|
|
|
168
168
|
export async function runOpenWorker(requestPath:string):Promise<void>{
|
|
169
169
|
const raw=await smallJson(requestPath) as WorkerRequest;if(raw.schema!=='rig-review-open-request/1'||!raw.identity||!recordValue({schema:'rig-review-open-instance/1',...raw.identity,pid:process.pid,origin:'http://127.0.0.1:1',mode:'single',capability:'0'.repeat(64)},raw.identity.key))throw new Error('open worker: invalid request');
|
|
170
170
|
const spec=raw,control=await realpath(join(spec.stateDir,'open'));if(dirname(await realpath(requestPath))!==control||spec.request!==requestPath||spec.registry!==join(control,spec.identity.key+'.json')||!Number.isSafeInteger(spec.idleMs)||spec.idleMs<100)throw new Error('open worker: invalid state locations or idle limit');
|
|
171
|
-
const
|
|
171
|
+
const workerCwd=typeof spec.cwd==='string'&&isAbsolute(spec.cwd)?spec.cwd:undefined;
|
|
172
|
+
const p=await loadOpenPackage(spec.inputs,{cwd:workerCwd}),fingerprint=await openFingerprint();if(fingerprint!==spec.identity.fingerprint||openKey(p,fingerprint)!==spec.identity.key||p.contentHash!==spec.identity.contentHash)throw new Error('open worker: inputs changed before startup');
|
|
172
173
|
if(spec.inputs.control&&(!spec.controlToken||!/^[a-f0-9-]{36}$/.test(spec.controlToken)))throw new Error('open control: invalid private capability');
|
|
173
174
|
// The worker mints its own page capability; it lives only in this process and the private record.
|
|
174
175
|
const removeRecord=async()=>{const current=await readRecord(spec.registry,spec.identity.key);if(current?.nonce===spec.identity.nonce)await unlink(spec.registry).catch(()=>{});};
|