@rig-c/review 4.0.0 → 4.0.1

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/README.md CHANGED
@@ -18,7 +18,7 @@ The app provides one inspection workspace for setup geometry and motion, compile
18
18
 
19
19
  ## Place in the toolchain
20
20
 
21
- [Parts](https://github.com/rig-c/parts) → [Pose](https://github.com/rig-c/pose) →
21
+ [Create](https://github.com/rig-c/create) → [Parts](https://github.com/rig-c/parts) → [Pose](https://github.com/rig-c/pose) →
22
22
  [Core / rigc](https://github.com/rig-c/core) → **Review** →
23
23
  [Play](https://github.com/rig-c/play) → **Adapter** (consumer integration).
24
24
 
@@ -81,7 +81,7 @@ http://127.0.0.1:4318/?workspace=<incarnation>#cap=…
81
81
  | <a id="control-the-current-inspection-page"></a>Control an opted-in inspection | `control` | [Inspection control — WORKFLOWS](docs/WORKFLOWS.md#control-the-current-inspection-page) |
82
82
  | <a id="keep-and-share-an-inspection"></a>Restore a view link or local draft | View link, draft | [Keep and share — WORKFLOWS](docs/WORKFLOWS.md#keep-and-share-an-inspection) |
83
83
  | <a id="launcher-contract"></a>Start or reuse the launcher | `open` | [Launcher contract — WORKFLOWS](docs/WORKFLOWS.md#launcher-contract) |
84
- | <a id="managed-front-and-write-capability"></a>Use the managed front and write capability | `open` | [Managed front — WORKFLOWS](docs/WORKFLOWS.md#managed-front-and-write-capability) |
84
+ | <a id="managed-front-and-write-capability"></a>Use the owner workspace and write capability | `open` | [Owner workspace — WORKFLOWS](docs/WORKFLOWS.md#managed-front-and-write-capability) |
85
85
 
86
86
  ## License
87
87
 
@@ -1,6 +1,6 @@
1
1
  # Review package and existing-folder adapter v1
2
2
 
3
- The toolchain delivery flow is **Parts → Pose → Core (rigc) → Review → Play →
3
+ The toolchain delivery flow is **Create → Parts → Pose → Core (rigc) → Review → Play →
4
4
  Adapter**. Review supplies human inspection and feedback bound to the exact
5
5
  reviewed sources; it neither replaces Core's build validation nor authors motion.
6
6
  The app uses the published `@rig-c/play` loader/player to preview artifacts during
package/docs/STABILITY.md CHANGED
@@ -412,7 +412,7 @@ preserve capability, origin, size, cancellation and replay checks.
412
412
 
413
413
  ## Changelog
414
414
 
415
- - Breaking, next cut 4.0.0 (#806): remove `startJobHub` and its `JobHubOptions`, `JobHubJobOptions`, `JobHubJob` and `JobOwnerHub` types; the uncalled semantic-job hub is deleted.
415
+ - Breaking, 4.0.0 (#806): remove `startJobHub` and its `JobHubOptions`, `JobHubJobOptions`, `JobHubJob` and `JobOwnerHub` types; the uncalled semantic-job hub is deleted.
416
416
 
417
417
  ## Named export inventory
418
418
 
package/docs/WORKFLOWS.md CHANGED
@@ -496,7 +496,7 @@ On the view you are inspecting, choose **Comment · C (n)**, drag over the detai
496
496
 
497
497
  The four-stage navigator preserves this entry and its explicit save behavior. Compiled sessions reuse the atlas surface read-only; see [Four inspection stages](PANELS.md#four-inspection-stages).
498
498
 
499
- The managed front forwards a query only to the landing page; every other route refuses one. Stage navigation never changes CLI arguments or package bindings.
499
+ The current owner workspace accepts optional, nonduplicated `workspace` (matching the host incarnation) and `lang=en|ko` queries at `/`; `/main.js` and `/styles.css` accept only an optional `?lang=en` or `?lang=ko`, while workspace API and live routes reject queries. For allowed `/instances/<key>/…` routes, it passes landing-page queries (`/` or `/index.html`) to the in-process target handler and refuses queries on other target routes. Stage navigation never changes CLI arguments or package bindings.
500
500
 
501
501
  ## Standing live job workflow
502
502
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rig-c/review",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "type": "module",
5
5
  "description": "Local human rig inspection and structured feedback export",
6
6
  "license": "MIT",
package/src/job-front.ts CHANGED
@@ -224,7 +224,7 @@ export function jobWindowResources() {
224
224
  }
225
225
 
226
226
  interface RetainedView {
227
- review: ReviewPackage;
227
+ review: ReviewPackage | null;
228
228
  parts: PartsViewPackage | null;
229
229
  }
230
230
 
@@ -238,6 +238,12 @@ export function retainedPublicationRoutes(session: JobSession) {
238
238
  if (crop) session.authorize('ui', request.headers.get('X-Review-Capability'));
239
239
  return await session.readPublicationResponse(publicationId, async retained => {
240
240
  const display = session.displayPublication(publicationId);
241
+ // Retain history, but expose images only for this publication's declared questions.
242
+ const questions = retained.questions.map(question => ({...question,
243
+ images: retained.subjects.some(subject => subject.kind === 'interview-picks' &&
244
+ subject.setId === question.set.id && subject.questionId === question.set.question)
245
+ ? question.images : [],
246
+ }));
241
247
  if (key !== display.publication.instanceKey) return failure('JOB_DISPLAY_MISMATCH', 409);
242
248
  if (crop && session.status().publication?.publicationId !== publicationId)
243
249
  return failure('JOB_ACT_SOURCE_STALE', 409);
@@ -264,6 +270,31 @@ export function retainedPublicationRoutes(session: JobSession) {
264
270
  return await sealedFile(member.path);
265
271
  }
266
272
  if (isRetainedRecordSource(retained)) {
273
+ // hasParts is projected only after validating the option's sealed draft closure.
274
+ const question = retained.questions.find(question => question.hasParts);
275
+ if (question && (path === 'api/stage-parts' || /^api\/stage-parts\/(image|page)\/(0|[1-9]\d*)$/.test(path))) {
276
+ let pending = views.get(publicationId);
277
+ if (!pending) {
278
+ pending = (async () => {
279
+ const context = (question.set as unknown as {context:{parts:{path:string;files:{path:string;sha256:string}[]}}}).context;
280
+ const root = join(retained.snapshotRoot, context.parts.path);
281
+ const parts = await loadPartsView(root);
282
+ for (const file of [...parts.files, ...parts.flagFiles]) {
283
+ const path = relative(retained.snapshotRoot, file.abs).split('\\').join('/');
284
+ if (!context.parts.files.some(bound => bound.path === path && bound.sha256 === file.sha256)) throw new JobError('JOB_SOURCE_UNRETAINABLE');
285
+ }
286
+ return {review:null, parts};
287
+ })();
288
+ views.set(publicationId, pending);
289
+ }
290
+ const {parts} = await pending;
291
+ if (!parts) throw new JobError('JOB_SOURCE_UNRETAINABLE');
292
+ if (path === 'api/stage-parts') return json({...partsViewJson(parts, {verdict:null,stale:null}),
293
+ sourceHash:retained.source.sourceHash,inspectionSourceHash:retained.source.sourceHash,readOnly:true});
294
+ const image = /^api\/stage-parts\/(image|page)\/(0|[1-9]\d*)$/.exec(path)!;
295
+ const file = servedImage(parts, image[1] as 'image'|'page', Number(image[2]));
296
+ return file ? await sealedFile(relative(retained.snapshotRoot,file).split('\\').join('/')) : failure('JOB_SOURCE_UNRETAINABLE',404);
297
+ }
267
298
  if (path === 'api/review') {
268
299
  return json({
269
300
  ...checkpointEvidenceMetadata(retained.snapshotRoot, retained.source.checkpointEvidence),
@@ -283,7 +314,7 @@ export function retainedPublicationRoutes(session: JobSession) {
283
314
  });
284
315
  }
285
316
  if (path === 'api/interview') {
286
- return json({questions: retained.questions.map(question => ({...question,
317
+ return json({questions: questions.map(question => ({...question,
287
318
  images: question.images.map((image, index) => ({name: image.name,
288
319
  url: `/api/interview/image/${question.ref.sha256}/${index}`})),
289
320
  }))});
@@ -331,6 +362,7 @@ export function retainedPublicationRoutes(session: JobSession) {
331
362
  views.set(publicationId, pending);
332
363
  }
333
364
  const {review, parts} = await pending;
365
+ if (!review) throw new JobError('JOB_SOURCE_MISMATCH');
334
366
  await assertReviewUnchanged(review);
335
367
  if (retained.checkpointEvidencePackageHash !== undefined && retained.checkpointEvidencePackageHash !== review.sourceHash) {
336
368
  throw new JobError('JOB_SOURCE_MISMATCH');
@@ -359,7 +391,7 @@ export function retainedPublicationRoutes(session: JobSession) {
359
391
  if (path === 'api/interview') {
360
392
  const interview = retained.interview !== undefined ? retained.interview : display.publication.interview;
361
393
  return json({
362
- questions: retained.questions.map(question => ({...question,
394
+ questions: questions.map(question => ({...question,
363
395
  images: question.images.map((image, index) => ({name: image.name,
364
396
  url: `/api/interview/image/${question.ref.sha256}/${index}`})),
365
397
  })),
package/src/job-source.ts CHANGED
@@ -922,13 +922,30 @@ function decodeRetainedRecordProject(
922
922
  }
923
923
  }
924
924
  }
925
+ // Older record readers retained only inputs/evidence. Keep those records usable,
926
+ // but expose a parts picture only when the option's entire draft closure is sealed.
927
+ let hasBoundParts = false;
928
+ const boundParts = ctx?.kind === 'parts' ? asPlainObject(ctx.parts) : null;
929
+ if (boundParts && typeof boundParts.path === 'string' && Array.isArray(boundParts.files)) {
930
+ try {
931
+ const root = jobPath(boundParts.path), paths = new Set<string>();
932
+ hasBoundParts = boundParts.files.every(value => {
933
+ const file = asPlainObject(value);
934
+ if (!file) return false;
935
+ const path = jobPath(file.path), sha = jobSha(file.sha256);
936
+ if (!path.startsWith(root + '/') || paths.has(path) || sealMap.get(path) !== sha) return false;
937
+ paths.add(path);
938
+ return true;
939
+ }) && paths.has(root + '/parts.json');
940
+ } catch {hasBoundParts = false;}
941
+ }
925
942
  return {
926
943
  questions: [{
927
944
  ref,
928
945
  set,
929
946
  editable: true,
930
947
  images,
931
- hasParts: false,
948
+ hasParts: hasBoundParts,
932
949
  }],
933
950
  optionSetFile: ref,
934
951
  };
@@ -132,6 +132,13 @@ export function createJobRigScreen(options: {
132
132
  if (jobRigScreenSubject(candidate.publication.source)) {picture = await prepare(candidate, signal, true);break;}
133
133
  previous = candidate.publication.previousPublicationId;
134
134
  }
135
+ if (!picture && inspection.interview?.questions.some(question => question.hasParts)) {
136
+ const response = await fetch(options.routes(display).api('stage-parts'), {signal});
137
+ if (!response.ok) throw new Error('JOB_VISUAL_UNAVAILABLE');
138
+ const parts = await response.json() as PartsSubjectData;
139
+ if (parts.sourceHash !== source.sourceHash || parts.mode !== 'parts') throw new Error('JOB_DISPLAY_MISMATCH');
140
+ picture = {jobRigScreen:true,display,entry:options.routes(display).entry,checkpoints:new Set(),parts};
141
+ }
135
142
  if(signal.aborted)throw new Error('JOB_PRELOAD_CANCELLED');
136
143
  return {jobRigScreen:true,display,entry:options.routes(display).entry,checkpoints:new Set(),record:{inspection,forms,picture}};
137
144
  } catch(error) {inspection.dispose();throw error;}
@@ -241,7 +248,7 @@ export function createJobRigScreen(options: {
241
248
  attach:value=>{screen=value;screen.pendingSubjects?.(pendingSubjects());refreshRecordForms();},
242
249
  displayed:()=>ready.resolve(),failed:error=>ready.reject(error)};
243
250
  }
244
- if(!review)throw new Error('JOB_DISPLAY_MISMATCH');
251
+ if(!review&&!prepared.parts)throw new Error('JOB_DISPLAY_MISMATCH');
245
252
  return {access,pendingSubjects,navigation,...prepared.refusal?{unavailable:prepared.refusal}:{},...prepared.display.publication.source.direction?{direction:{publicationId:prepared.display.publication.publicationId,sourceHash:prepared.display.publication.source.sourceHash}}:{},
246
253
  reviewState(issues,sending) {
247
254
  if(sending)return options.translate('job.parts.sending');
@@ -261,10 +268,10 @@ export function createJobRigScreen(options: {
261
268
  if(path==='/api/session'){const act=options.window.state().pending.filter(ask=>ask.publicationId===prepared.display.publication.publicationId&&ask.subject.kind==='parts-verdict').at(-1)?.act;return Promise.resolve({subject:'parts',issues:act?.kind==='parts-verdict'&&act.schema==='rig-review/act@6'?commentPartsIssues(act.value.comments):act?.kind==='parts-verdict'&&act.schema==='rig-review/act@5'?act.value.issues:[]});}
262
269
  return undefined;
263
270
  }
264
- if (path === '/api/review') return Promise.resolve(structuredClone(review));
271
+ if (path === '/api/review') return Promise.resolve(structuredClone(review!));
265
272
  if (path === '/api/access') return Promise.resolve({capabilityRequired: true, control: false});
266
- if (path === '/api/session') return Promise.resolve({schema: 'rig-review-session/1', id: review.manifest.id, revision: review.manifest.revision,
267
- sourceHash: review.sourceHash, reviewedSource: structuredClone(review.reviewedSource), status: 'pending', checkpoints: {}, feedback: [],
273
+ if (path === '/api/session') return Promise.resolve({schema: 'rig-review-session/1', id: review!.manifest.id, revision: review!.manifest.revision,
274
+ sourceHash: review!.sourceHash, reviewedSource: structuredClone(review!.reviewedSource), status: 'pending', checkpoints: {}, feedback: [],
268
275
  feedbackWarnings: [], updatedAt: null} satisfies ReviewSession);
269
276
  return Promise.reject(new Error('JOB_REVIEW_READ_ONLY'));
270
277
  },
@@ -792,7 +792,6 @@ export interface JobPreparedInspection {
792
792
  parts: JobPartsInventory | null;
793
793
  partImages: Map<string, HTMLImageElement>;
794
794
  partPages?: Map<number, HTMLImageElement>;
795
- interviewImages: Map<string, HTMLImageElement>;
796
795
  checkpointEvidence?: readonly {
797
796
  packet: JobCheckpointEvidence;
798
797
  table: JobCheckpointTable;
@@ -962,7 +961,6 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
962
961
  throw new Error('JOB_SOURCE_MISMATCH');
963
962
  const references: JobReferenceView[] = [];
964
963
  const partImages = new Map<string, HTMLImageElement>();
965
- const interviewImages = new Map<string, HTMLImageElement>();
966
964
  const partPages = new Map<number, HTMLImageElement>();
967
965
  const preload: Promise<void>[] = [];
968
966
  const source = display.publication.source;
@@ -1123,10 +1121,6 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
1123
1121
  preload.push(image(routes.api('stage-parts/page/' + page.index))
1124
1122
  .then(element => { partPages.set(page.index, element); }));
1125
1123
  }
1126
- for (const question of interview?.questions ?? [])
1127
- for (const asset of question.images) {
1128
- preload.push(image(routes.instance(asset.url)).then(element => { element.alt = asset.name; interviewImages.set(asset.url, element); }));
1129
- }
1130
1124
  const preloaded = await Promise.allSettled(preload);
1131
1125
  const failed = preloaded.find(result => result.status === 'rejected');
1132
1126
  if (failed?.status === 'rejected')
@@ -1171,7 +1165,7 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
1171
1165
  const order = [metadata.sourcePainting?.id, ...(metadata.manifest?.references.map(reference => reference.id) ?? [])];
1172
1166
  references.sort((a, b) => order.indexOf(a.id) - order.indexOf(b.id));
1173
1167
  return {
1174
- display, metadata, interview, parts, partImages, partPages, interviewImages, checkpointEvidence, references, assets, rigRoot,
1168
+ display, metadata, interview, parts, partImages, partPages, checkpointEvidence, references, assets, rigRoot,
1175
1169
  get rigPresentation() { return rigPresentation; },
1176
1170
  set rigPresentation(value) {
1177
1171
  clearRigPresentation();
@@ -1400,7 +1394,7 @@ export interface JobFormDependencies {
1400
1394
  fields.prepend(legacyNotice);
1401
1395
  }
1402
1396
  interviewForm=createInterviewForm({question,id:'interview-answer-'+ask.askId,node,form,fieldset:fields,source,
1403
- images:question.images.map(image=>{const visual=prepared.interviewImages.get(image.url);if(!visual)throw new Error('JOB_VISUAL_UNAVAILABLE');return {name:image.name,src:visual.src};}),answered:ask.status==='answered'});
1397
+ images:question.images.map(image=>({name:image.name,src:jobPublicationRoutes(prepared.display,location.origin).instance(image.url)})),answered:ask.status==='answered'});
1404
1398
  disposeInterview=interviewForm.dispose;read=interviewForm.read;
1405
1399
  submitKey = 'interview.save';
1406
1400
  }