@rig-c/review 4.9.1 → 4.11.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.
Files changed (51) hide show
  1. package/docs/DESIGN.md +5 -5
  2. package/docs/PANELS.md +3 -1
  3. package/docs/REVIEW_PACKAGE.md +143 -30
  4. package/docs/STABILITY.md +110 -3
  5. package/package.json +2 -2
  6. package/src/chest-landmarks.ts +9 -4
  7. package/src/cloth-recipe.ts +27 -7
  8. package/src/compare-html.ts +1 -1
  9. package/src/feedback-export.ts +2 -2
  10. package/src/feedback-validation.ts +11 -6
  11. package/src/frame-clock.ts +20 -4
  12. package/src/job-act.ts +60 -71
  13. package/src/job-api.ts +302 -46
  14. package/src/job-checkpoint-evidence.ts +17 -0
  15. package/src/job-cli.ts +3 -2
  16. package/src/job-contract.ts +107 -7
  17. package/src/job-front.ts +48 -12
  18. package/src/job-host.ts +7 -1
  19. package/src/job-session.ts +136 -26
  20. package/src/job-source.ts +133 -21
  21. package/src/job-store.ts +7 -4
  22. package/src/manifest.ts +59 -7
  23. package/src/open-workspace-state.ts +6 -1
  24. package/src/open.ts +3 -3
  25. package/src/rebuild.ts +42 -10
  26. package/src/session.ts +9 -4
  27. package/src/stage-comment.ts +2 -1
  28. package/web/catalog-en.ts +31 -6
  29. package/web/catalog-ko.ts +79 -54
  30. package/web/chest-editor.ts +236 -31
  31. package/web/cloth-panel.ts +1 -1
  32. package/web/compare.css +2 -2
  33. package/web/environment-world.ts +9 -0
  34. package/web/i18n.ts +1 -3
  35. package/web/inspection-persistence.ts +19 -6
  36. package/web/interview-panel.ts +13 -80
  37. package/web/job-rig-screen.ts +65 -37
  38. package/web/job-session.ts +204 -64
  39. package/web/label-placement.ts +25 -8
  40. package/web/main.ts +350 -114
  41. package/web/part-selection.ts +2 -1
  42. package/web/parts-viewport-provider.ts +21 -8
  43. package/web/rebuild-client.ts +3 -5
  44. package/web/rig-host.ts +5 -4
  45. package/web/rig-overlays.ts +3 -2
  46. package/web/rig-viewport-provider.ts +10 -6
  47. package/web/stage-comments.ts +24 -21
  48. package/web/styles.css +23 -51
  49. package/web/viewport-controller.ts +4 -0
  50. package/web/workspace-layout.ts +4 -4
  51. package/web/workspace-ui.ts +8 -6
@@ -55,6 +55,23 @@ export function checkpointEvidenceFields(holder: object, plan: JobPlanIdentity |
55
55
  }
56
56
  }
57
57
 
58
+ /** #983: the plan-level picture the owner signs against. Plan records only; one sealed raster, by the
59
+ * package page-image rule (png, jpg, webp). Absence must not materialize the field. */
60
+ export function planPictureFields(holder: object, plan: JobPlanIdentity | null,
61
+ files: readonly JobFileIdentity[]): {planPicture?: JobFileIdentity} {
62
+ if (!('planPicture' in holder)) return {};
63
+ try {
64
+ if (!plan) throw new Error('plan only');
65
+ const raw = exactObject(holder.planPicture, ['path', 'sha256'], 'JOB_SOURCE_MISMATCH');
66
+ const planPicture = {path: jobPath(raw.path), sha256: jobSha(raw.sha256)};
67
+ if (!/\.(png|jpe?g|webp)$/i.test(planPicture.path) ||
68
+ !files.some(seal => seal.path === planPicture.path && seal.sha256 === planPicture.sha256)) throw new Error('closure');
69
+ return {planPicture};
70
+ } catch {
71
+ throw new JobError('JOB_SOURCE_MISMATCH', 'PLAN_PICTURE_INVALID');
72
+ }
73
+ }
74
+
58
75
  /** The sealed document is the sole table body. Preserve columns, rows and scalars. */
59
76
  export function parseCheckpointTable(bytes: Buffer): JobCheckpointTable {
60
77
  try {
package/src/job-cli.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import {closeSync, constants, fstatSync, fsyncSync, lstatSync, openSync, readFileSync, renameSync, unlinkSync, writeSync} from 'node:fs';
3
3
  import {join} from 'node:path';
4
- import { JOB_API_SCHEMA, JOB_ACT_SCHEMA, JOB_PARTS_VERDICT_ACT_SCHEMA, JOB_RIG_REVIEW_ACT_SCHEMA, JOB_COMMENTS_ACT_SCHEMA, JOB_COMMENT_CONTEXT_ACT_SCHEMA, JOB_MESH_EDITS_ACT_SCHEMA, JOB_ENABLED_ACT_KINDS, jobRawActMediaType, jobStillByteLimit, jobActDeliveryLimit, jobResponseBodyLimit,
4
+ import { JOB_API_SCHEMA, JOB_ACT_SCHEMA, JOB_PARTS_VERDICT_ACT_SCHEMA, JOB_RIG_REVIEW_ACT_SCHEMA, JOB_COMMENTS_ACT_SCHEMA, JOB_COMMENT_CONTEXT_ACT_SCHEMA, JOB_MESH_EDITS_ACT_SCHEMA, JOB_CHEST_LANDMARKS_ACT_SCHEMA, JOB_ENABLED_ACT_KINDS, jobRawActMediaType, jobStillByteLimit, jobActDeliveryLimit, jobResponseBodyLimit,
5
5
  JOB_RECORD_ACT_KINDS, JOB_RECORD_ACT_SCHEMA,
6
6
  type JobAct, type JobMeshEditsAct, type JobAgentRequest, type JobApiSchema, type JobNextRequest, type JobNextRequestV3, type JobNextValue } from './job-contract.ts';
7
- import { assertJobApiSchema, jobFailure, jobHash, jobId, jobInteger, jobObject, jobWaitLimitMs, parseJobRequest, parseCommentsAct, parseContextCommentsAct, parseMeshEditsAct, parseRecordAct } from './job-api.ts';
7
+ import { assertJobApiSchema, jobFailure, jobHash, jobId, jobInteger, jobObject, jobWaitLimitMs, parseJobRequest, parseCommentsAct, parseContextCommentsAct, parseMeshEditsAct, parseChestLandmarksAct, parseRecordAct } from './job-api.ts';
8
8
  import { JobError } from './job-store.ts';
9
9
  import {validatePngBytes} from './comment-crops.ts';
10
10
  import {destinationDirectory} from './destination-directory.ts';
@@ -152,6 +152,7 @@ const consumerCommentsDecoders = {
152
152
  [JOB_COMMENTS_ACT_SCHEMA]: parseCommentsAct,
153
153
  [JOB_COMMENT_CONTEXT_ACT_SCHEMA]: parseContextCommentsAct,
154
154
  [JOB_MESH_EDITS_ACT_SCHEMA]: parseMeshEditsAct,
155
+ [JOB_CHEST_LANDMARKS_ACT_SCHEMA]: parseChestLandmarksAct,
155
156
  } as const;
156
157
 
157
158
  function parseConsumerAct(bytes: Buffer, job: string, actId: string): ConsumerAct {
@@ -19,6 +19,7 @@ import type { MarkRegion } from './stage-comment.ts';
19
19
  import type { PartsVerdict } from './parts-view.ts';
20
20
  import type { ControlNumericCamera, ControlPart } from './control.ts';
21
21
  import type { MeshOp, Vec } from './mesh-edit.ts';
22
+ import type { BustLandmarks } from './chest-landmarks.ts';
22
23
 
23
24
  export const JOB_API_SCHEMA = 'rig-review/job-api@2' as const;
24
25
  export const JOB_API_V3_SCHEMA = 'rig-review/job-api@3' as const;
@@ -35,6 +36,8 @@ export const JOB_COMMENTS_ACT_SCHEMA = 'rig-review/act@6' as const;
35
36
  export const JOB_COMMENT_CONTEXT_ACT_SCHEMA = 'rig-review/act@7' as const;
36
37
  /** @7 plus a mesh payload on a compiled rig's Request changes (#952). */
37
38
  export const JOB_MESH_EDITS_ACT_SCHEMA = 'rig-review/act@8' as const;
39
+ /** A compiled rig's Request changes carrying chest landmarks (#990). */
40
+ export const JOB_CHEST_LANDMARKS_ACT_SCHEMA = 'rig-review/act@9' as const;
38
41
  export const REVIEW_COMMENTS_SESSION_SCHEMA = 'rig-review-session/2' as const;
39
42
  export const REVIEW_COMMENTS_COMPARE_SESSION_SCHEMA = 'rig-review-compare-session/2' as const;
40
43
  export const PARTS_COMMENTS_VERDICT_SCHEMA = 'rig-review-parts-verdict/5' as const;
@@ -142,6 +145,29 @@ export type JobMeshEditsAct = JobRigMeshEditsAct | {
142
145
  readonly value: Extract<JobContextCommentsAct, {kind: Kind}>['value'] & {readonly meshEdits?: never};
143
146
  }
144
147
  }[keyof JobCommentsActValues];
148
+
149
+ /** Setup-pose rig px in the retained model's stage, shared by the seed and the edit. */
150
+ export type JobChestLandmarkValue = Pick<JobMeshEditValue, 'slot' | 'skin' | 'attachment' | 'basis'> & {
151
+ readonly source: Pick<JobMeshEditValue['source'], 'hash' | 'frame'>;
152
+ readonly bust: Readonly<BustLandmarks>;
153
+ };
154
+
155
+ export type JobPublishedChestLandmark = JobChestLandmarkValue & {
156
+ readonly source: JobChestLandmarkValue['source'] & {readonly configHash: JobSha256};
157
+ };
158
+
159
+ export interface JobChestLandmarkEdit {
160
+ readonly edit: JobChestLandmarkValue;
161
+ readonly sha256: JobSha256;
162
+ }
163
+
164
+ export type JobChestLandmarksAct = Omit<JobRigMeshEditsAct, 'schema' | 'value'> & {
165
+ readonly schema: typeof JOB_CHEST_LANDMARKS_ACT_SCHEMA;
166
+ readonly value: Omit<JobRigMeshEditsAct['value'], 'meshEdits'> & {
167
+ readonly meshEdits?: readonly JobMeshEdit[];
168
+ readonly chestLandmarks: readonly JobChestLandmarkEdit[];
169
+ };
170
+ };
145
171
  export type ReviewCommentsSession = Omit<ReviewSession, 'schema' | 'feedback' | 'checkpoints'> & {
146
172
  schema: typeof REVIEW_COMMENTS_SESSION_SCHEMA;
147
173
  checkpoints: Record<string, { outcome: 'pending' | 'pass' | 'fail' }>;
@@ -327,6 +353,7 @@ export type JobPlanTextProjection = {
327
353
  readonly record: {readonly path: 'project.json'; readonly sha256: string};
328
354
  readonly status: 'projected';
329
355
  readonly steps: readonly JobPlanTextStep[];
356
+ readonly questions?: Readonly<Record<string, string>>;
330
357
  } | {
331
358
  readonly schema: typeof JOB_PLAN_TEXT_SCHEMA;
332
359
  readonly record: {readonly path: 'project.json'; readonly sha256: string} | null;
@@ -342,7 +369,7 @@ export function parseJobPlanTextProjection(value: unknown): JobPlanTextProjectio
342
369
  Object.keys(input).some(key => !keys.includes(key))) return fail();
343
370
  return input as Record<string, unknown>;
344
371
  };
345
- const envelope = object(value, ['schema', 'record', 'status', 'steps', 'reason']);
372
+ const envelope = object(value, ['schema', 'record', 'status', 'steps', 'questions', 'reason']);
346
373
  if (envelope.schema !== JOB_PLAN_TEXT_SCHEMA || !Object.hasOwn(envelope, 'record') ||
347
374
  new TextEncoder().encode(JSON.stringify(value)).length > 512 * 1024) return fail();
348
375
  if (envelope.record !== null) {
@@ -350,11 +377,17 @@ export function parseJobPlanTextProjection(value: unknown): JobPlanTextProjectio
350
377
  if (record.path !== 'project.json' || typeof record.sha256 !== 'string' || !/^[a-f0-9]{64}$/.test(record.sha256)) return fail();
351
378
  }
352
379
  if (envelope.status === 'unavailable') {
353
- if (Object.hasOwn(envelope, 'steps') || !(JOB_PLAN_TEXT_UNAVAILABLE as readonly unknown[]).includes(envelope.reason)) return fail();
380
+ if (Object.hasOwn(envelope, 'steps') || Object.hasOwn(envelope, 'questions') ||
381
+ !(JOB_PLAN_TEXT_UNAVAILABLE as readonly unknown[]).includes(envelope.reason)) return fail();
354
382
  return value as JobPlanTextProjection;
355
383
  }
356
384
  if (envelope.status !== 'projected' || envelope.record === null || Object.hasOwn(envelope, 'reason') ||
357
385
  !Array.isArray(envelope.steps) || envelope.steps.length > 4096) return fail();
386
+ if (Object.hasOwn(envelope, 'questions')) {
387
+ const questions = envelope.questions;
388
+ if (!questions || typeof questions !== 'object' || Array.isArray(questions) ||
389
+ Object.entries(questions).some(([id, text]) => !id || id.length > 128 || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(id) || typeof text !== 'string')) return fail();
390
+ }
358
391
  const ids = new Set<string>();
359
392
  for (const raw of envelope.steps) {
360
393
  const row = object(raw, ['id', 'hash', ...JOB_PLAN_TEXT_FIELDS, 'issues']);
@@ -557,6 +590,7 @@ export type JobUIActValues = Omit<JobActValues, 'checkpoint' | 'parts-verdict' |
557
590
  readonly feedback?: readonly Feedback[];
558
591
  readonly general?: readonly string[];
559
592
  readonly meshEdits?: readonly JobMeshEdit[];
593
+ readonly chestLandmarks?: readonly JobChestLandmarkEdit[];
560
594
  });
561
595
  };
562
596
 
@@ -571,7 +605,7 @@ export interface JobActSources {
571
605
  readonly parts: JobPartsIdentity;
572
606
  };
573
607
  readonly 'review-verdict': (JobModelSourceBinding & {
574
- readonly selector: Extract<JobSelector, { kind: 'rig' | 'post' }>;
608
+ readonly selector: Extract<JobSelector, { kind: 'rig' | 'post' | 'draft' }>;
575
609
  readonly model: JobFileIdentity;
576
610
  });
577
611
  readonly signoff: JobModelSourceBinding;
@@ -626,7 +660,7 @@ export type JobPartsVerdictAct = Omit<Extract<JobLegacyAct, {kind: 'parts-verdic
626
660
 
627
661
  /** Historical @2 acts remain readable without being backfilled or relabelled.
628
662
  * Fresh comments use @6, live rig comments carrying context use @7, and rig verdicts carrying mesh edits use @8. */
629
- export type JobAct = JobLegacyAct | JobRigReviewAct | JobPartsVerdictAct | JobCommentsAct | JobContextCommentsAct | JobRigMeshEditsAct;
663
+ export type JobAct = JobLegacyAct | JobRigReviewAct | JobPartsVerdictAct | JobCommentsAct | JobContextCommentsAct | JobRigMeshEditsAct | JobChestLandmarksAct;
630
664
 
631
665
  /** Authenticated browser provenance. The daemon validates identity and hashes PNG bytes. */
632
666
  export interface JobRigCapture {
@@ -727,6 +761,8 @@ export interface JobPublication {
727
761
  readonly code: string;
728
762
  };
729
763
  readonly interview?: JobInterviewDiagnostics | null;
764
+ /** Producer-declared contour.bust for the displayed rig, sealed in source.sourceHash. */
765
+ readonly chestLandmarks?: readonly JobPublishedChestLandmark[];
730
766
  }
731
767
 
732
768
  export interface JobStatus {
@@ -830,6 +866,8 @@ export const JOB_ERROR_CODES = [
830
866
  'JOB_CURSOR_INVALID',
831
867
  'JOB_STORAGE_FAILED',
832
868
  'JOB_AGENT_ISOLATION_HOLE',
869
+ /** #1004: an option-set publication names one set twice (two subjects or two `sets` rows for one set). */
870
+ 'JOB_OPTION_SET_DUPLICATE',
833
871
  ] as const;
834
872
  export type JobErrorCode = typeof JOB_ERROR_CODES[number];
835
873
 
@@ -913,6 +951,8 @@ export interface JobDisplayReceipt {
913
951
 
914
952
  export interface JobDisplayPublication {
915
953
  readonly publication: JobPublication;
954
+ /** A declared rig draft verdict selects the rig screen even when parts are retained. */
955
+ readonly rigDraftVerdict?: true;
916
956
  /** Same-origin routes pinned to this publication and instance. No current alias. */
917
957
  readonly routes: {
918
958
  readonly entry: string;
@@ -934,6 +974,8 @@ export interface JobHostPorts {
934
974
  readonly after: JobCursor | null;
935
975
  readonly signal: AbortSignal;
936
976
  }): AsyncIterable<EventV3>;
977
+ /** Front-only opt-in. Semantic subscribers keep the durable event stream above. */
978
+ subscribeJobPage?(input: Parameters<JobHostPorts['subscribeJob']>[0]): AsyncIterable<EventV3 | JobProgressLineV3>;
937
979
  readPublication(jobId: JobId, publicationId: JobPublicationId): Promise<JobResult<DisplayPublicationV3>>;
938
980
  commitUIAct(jobId: JobId, request: Request): Promise<JobResult<ActV3>>;
939
981
  ackDisplayed(jobId: JobId, request: Request): Promise<JobResult<JobDisplayReceipt>>;
@@ -977,10 +1019,18 @@ export interface JobConsumerGrant {
977
1019
  readonly lifetime: 'until-explicit-close';
978
1020
  }
979
1021
 
1022
+ /** One option set of a publication: the question it answers and the set's id. */
1023
+ export interface RecordOptionSetRef {
1024
+ readonly questionId: string;
1025
+ readonly setId: string;
1026
+ }
1027
+
980
1028
  export interface RecordOptionResult {
981
1029
  readonly kind: 'option-set';
982
1030
  readonly questionId: string;
983
1031
  readonly setId: string;
1032
+ /** #1004: 2–64 sets published together, one ask each; `sets[0]` repeats `questionId`/`setId`. Absent for one set. */
1033
+ readonly sets?: readonly RecordOptionSetRef[];
984
1034
  }
985
1035
 
986
1036
  export interface RecordPlanResult {
@@ -1032,6 +1082,34 @@ export interface AskBatchValueV3 {
1032
1082
  readonly asks: readonly PendingAskV3[];
1033
1083
  }
1034
1084
 
1085
+ export interface JobProgressV3 {
1086
+ readonly seq: number;
1087
+ readonly phase: 'ingest' | 'build' | 'measure' | 'publish' | 'other';
1088
+ readonly text?: string;
1089
+ readonly step?: { readonly i: number; readonly n: number };
1090
+ readonly at: string;
1091
+ readonly generation: number;
1092
+ }
1093
+
1094
+ export type JobProgressRequestV3 = Omit<JobRequestBase, 'schema'> & Omit<JobProgressV3, 'at' | 'generation'> & {
1095
+ readonly schema: typeof JOB_API_V3_SCHEMA;
1096
+ readonly verb: 'progress';
1097
+ };
1098
+
1099
+ export interface JobProgressValueV3 {
1100
+ readonly status: 'accepted' | 'ignored';
1101
+ readonly seq: number;
1102
+ readonly at: string;
1103
+ }
1104
+
1105
+ /** Current host progress delivered only on the page stream. */
1106
+ export interface JobProgressLineV3 {
1107
+ readonly type: 'progress';
1108
+ readonly jobId: JobId;
1109
+ readonly progress: JobProgressV3 | null;
1110
+ readonly now: string;
1111
+ }
1112
+
1035
1113
  export type NextRequestV3 = Omit<JobNextRequest, 'schema'> & {
1036
1114
  readonly schema: typeof JOB_API_V3_SCHEMA;
1037
1115
  };
@@ -1044,6 +1122,7 @@ export type AgentRequestV3 =
1044
1122
  | PublishRequestV3
1045
1123
  | AskRequestV3
1046
1124
  | AskBatchRequestV3
1125
+ | JobProgressRequestV3
1047
1126
  | NextRequestV3
1048
1127
  | CloseRequestV3;
1049
1128
 
@@ -1092,12 +1171,16 @@ export interface RecordContextBase {
1092
1171
 
1093
1172
  export type OptionContext = RecordContextBase & {
1094
1173
  readonly checkpointEvidence?: never;
1174
+ readonly planPicture?: never;
1095
1175
  readonly plan: null;
1096
- readonly subjects: readonly [RecordPicksSubject];
1176
+ /** One `interview-picks` subject per published set, in set order. */
1177
+ readonly subjects: readonly RecordPicksSubject[];
1097
1178
  };
1098
1179
 
1099
1180
  export type PlanContext = RecordContextBase & {
1100
1181
  readonly checkpointEvidence?: readonly JobCheckpointEvidence[];
1182
+ /** #983: the sealed raster (an entry of `files`) the owner signs the plan against; drawn first. */
1183
+ readonly planPicture?: JobFileIdentity;
1101
1184
  readonly plan: JobPlanIdentity;
1102
1185
  readonly subjects: readonly RecordPlanSubject[];
1103
1186
  };
@@ -1142,16 +1225,30 @@ export interface RecordSourceBase {
1142
1225
 
1143
1226
  export type OptionSource = RecordSourceBase & {
1144
1227
  readonly checkpointEvidence?: never;
1228
+ readonly planPicture?: never;
1145
1229
  readonly subject: 'option-set';
1146
1230
  readonly selection: RecordOptionResult;
1147
1231
  readonly optionSet: { readonly id: string; readonly sha256: JobSha256 };
1148
1232
  readonly optionSetFile: JobFileIdentity;
1149
1233
  readonly plan: null;
1150
- readonly subjects: readonly [RecordPicksSubject];
1234
+ readonly subjects: readonly RecordPicksSubject[];
1235
+ /** #1004: present only when the publication carries 2–64 sets; row i binds `selection.sets[i]`.
1236
+ * On a publication the singular `selection`/`optionSet`/`optionSetFile` name the first set; on an act they name the act's set. */
1237
+ readonly optionSets?: readonly RecordOptionSetBinding[];
1151
1238
  };
1152
1239
 
1240
+ /** One published set's identity and the sealed file it was read from. */
1241
+ export interface RecordOptionSetBinding {
1242
+ readonly questionId: string;
1243
+ readonly setId: string;
1244
+ readonly optionSet: { readonly id: string; readonly sha256: JobSha256 };
1245
+ readonly optionSetFile: JobFileIdentity;
1246
+ }
1247
+
1153
1248
  export type PlanSource = RecordSourceBase & {
1154
1249
  readonly checkpointEvidence?: readonly JobCheckpointEvidence[];
1250
+ /** #983: equal to an entry of `files`; bound into `sourceHash` only when present. */
1251
+ readonly planPicture?: JobFileIdentity;
1155
1252
  readonly subject: 'plan';
1156
1253
  readonly selection: RecordPlanResult;
1157
1254
  readonly optionSet: null;
@@ -1224,7 +1321,7 @@ export type SourceV3 = JobSourceBinding | RecordSource;
1224
1321
  export type ActV3 = JobAct | RecordAct;
1225
1322
 
1226
1323
  /**
1227
- * `recordPublication`, `recordActSchema` and `askBatch` describe the host, not the current head.
1324
+ * `recordPublication`, `recordActSchema`, `askBatch` and `progress` describe the host, not the current head.
1228
1325
  * `ask-batch` applies only to a record-retained head publication; a package head refuses `JOB_REQUEST_INVALID`,
1229
1326
  * so a consumer checks the publication's mode as well as the flag (#972).
1230
1327
  */
@@ -1232,12 +1329,14 @@ export interface JobCapabilitiesV3 extends JobCapabilities {
1232
1329
  readonly recordPublication: true;
1233
1330
  readonly recordActSchema: typeof JOB_RECORD_ACT_SCHEMA;
1234
1331
  readonly askBatch: true;
1332
+ readonly progress: true;
1235
1333
  }
1236
1334
 
1237
1335
  export const JOB_CAPABILITIES_V3: JobCapabilitiesV3 = Object.freeze({
1238
1336
  recordPublication: true,
1239
1337
  recordActSchema: JOB_RECORD_ACT_SCHEMA,
1240
1338
  askBatch: true,
1339
+ progress: true,
1241
1340
  });
1242
1341
 
1243
1342
  export interface PendingAskV3 extends Omit<JobPendingAsk, 'subject' | 'source'> {
@@ -1280,6 +1379,7 @@ export interface ResponseValuesV3 {
1280
1379
  readonly publish: PublicationV3;
1281
1380
  readonly ask: PendingAskV3;
1282
1381
  readonly 'ask-batch': AskBatchValueV3;
1382
+ readonly progress: JobProgressValueV3;
1283
1383
  readonly next: NextValueV3;
1284
1384
  readonly close: { readonly status: 'closed'; readonly cursor: JobCursor | null };
1285
1385
  readonly 'fetch-act': ActV3;
package/src/job-front.ts CHANGED
@@ -5,7 +5,7 @@ import {checkpointEvidenceMetadata, readCheckpointEvidenceBytes} from './job-che
5
5
  import { JOB_API_SCHEMA, JOB_ACT_SCHEMA, type JobErrorCode, type JobHostPorts, type JobId, type JobPublicationMode, type JobResult, type JobReviewerBinding } from './job-contract.ts';
6
6
  import { createJobHostPorts, jobBody, jobHash, jobId, jobObject, jobPartsEnumeratorVersion } from './job-api.ts';
7
7
  import { JobSession } from './job-session.ts';
8
- import { assertJobRoot, assertRetainedSnapshotIntact, captureJobRoot, planTextMetadata, isRetainedRecordSource, loadRetainedJobReview, loadRetainedRecordRig, readPreviousDraftBytes, type JobRootIdentity } from './job-source.ts';
8
+ import { assertJobRoot, assertRetainedSnapshotIntact, captureJobRoot, planTextMetadata, isRetainedRecordSource, loadRetainedJobReview, loadRetainedRecordRig, retainedRecordPainting, readPreviousDraftBytes, retainedRigDraftVerdict, type JobRootIdentity } from './job-source.ts';
9
9
  import { checkedPath } from './interview-project.ts';
10
10
  import type { JobWorkerOptions } from './job-worker.ts';
11
11
  import { JobError, JobStore, jobCropReferences } from './job-store.ts';
@@ -28,6 +28,26 @@ const headers = {
28
28
  'Referrer-Policy': 'no-referrer',
29
29
  'Content-Security-Policy': "default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' blob: data:; media-src 'self' blob:; connect-src 'self'; base-uri 'none'; frame-ancestors 'none'; form-action 'none'",
30
30
  };
31
+ /** #1050 cache policy. Every capability-bearing or computed response keeps `no-store` (`headers`).
32
+ * A sealed snapshot file is served only under its publication's instance route, whose publication id is new on every
33
+ * publish and whose instance key binds the source hash, and the seal refuses any other bytes: one URL, one content.
34
+ * `private` because the loopback server holds one user's work and no shared cache may keep it. */
35
+ const sealedHeaders = (sha256: string) => ({...headers, 'Cache-Control': 'private, max-age=31536000, immutable', ETag: `"${sha256}"`});
36
+ /** The shipped page files keep one URL across review upgrades: revalidate each load (the job liveness gate still runs). */
37
+ const resourceHashes = new WeakMap<object, string>();
38
+ async function shippedResource(request: Request, body: BodyInit, type: string): Promise<Response> {
39
+ // Bun's bundle is a BuildArtifact: Blob-like, not a Blob instance. Its hash is kept for the artifact's life.
40
+ const blob = typeof body === 'object' && 'arrayBuffer' in body && typeof body.arrayBuffer === 'function' ? body as {arrayBuffer(): Promise<ArrayBuffer>} : null;
41
+ let hash = blob ? resourceHashes.get(blob) : undefined;
42
+ if (!hash && (typeof body === 'string' || body instanceof Uint8Array || blob)) {
43
+ hash = jobHash(blob ? new Uint8Array(await blob.arrayBuffer()) : body as string | Uint8Array);
44
+ if (blob) resourceHashes.set(blob, hash);
45
+ }
46
+ const etag = hash ? `"${hash}"` : null;
47
+ const responseHeaders = {...headers, 'Content-Type': type, ...(etag ? {'Cache-Control': 'no-cache', ETag: etag} : {})};
48
+ if (etag && request.headers.get('if-none-match') === etag) return new Response(null, {status: 304, headers: responseHeaders});
49
+ return new Response(request.method === 'HEAD' ? null : body, {headers: responseHeaders});
50
+ }
31
51
  interface CropFailureDiagnostic {
32
52
  field: string;
33
53
  expected: string | number[];
@@ -162,7 +182,8 @@ export function createJobFront(options: {
162
182
  request.signal.addEventListener('abort', stop, { once: true });
163
183
  if (request.signal.aborted)
164
184
  stop();
165
- const iterator = options.ports.subscribeJob({ jobId, after, signal: abort.signal })[Symbol.asyncIterator]();
185
+ const subscription = { jobId, after, signal: abort.signal };
186
+ const iterator = (options.ports.subscribeJobPage?.(subscription) ?? options.ports.subscribeJob(subscription))[Symbol.asyncIterator]();
166
187
  const encoder = new TextEncoder();
167
188
  const body = new ReadableStream<Uint8Array>({
168
189
  async pull(controller) {
@@ -205,9 +226,7 @@ export function createJobFront(options: {
205
226
  if (!name)
206
227
  return failure('JOB_REQUEST_INVALID', 404);
207
228
  const type = name === 'index.html' ? 'text/html; charset=utf-8' : name === 'main.js' ? 'text/javascript' : 'text/css';
208
- return new Response(request.method === 'HEAD' ? null : await options.resource(name), {
209
- headers: { ...headers, 'Content-Type': type },
210
- });
229
+ return shippedResource(request, await options.resource(name), type);
211
230
  }
212
231
  return {
213
232
  fetch: fetchJob,
@@ -268,7 +287,9 @@ export function retainedPublicationRoutes(session: JobSession) {
268
287
  const file = await safeFile(retained.snapshotRoot, relativePath);
269
288
  if (literal !== undefined && literal !== file)
270
289
  return failure('JOB_SOURCE_UNRETAINABLE', 404);
271
- return serveReference(request, file, seal.sha256, headers);
290
+ const cached = sealedHeaders(seal.sha256);
291
+ if (request.headers.get('if-none-match') === cached.ETag) return new Response(null, {status: 304, headers: cached});
292
+ return serveReference(request, file, seal.sha256, cached);
272
293
  };
273
294
  const reviewMetadata = (review: ReviewPackage | null) => json({
274
295
  ...checkpointEvidenceMetadata(retained.snapshotRoot, retained.source.checkpointEvidence),
@@ -289,15 +310,15 @@ export function retainedPublicationRoutes(session: JobSession) {
289
310
  capabilities: {playback: !!review?.manifest.model,
290
311
  interview: questions.length > 0 || (retained.interview?.records.length ?? 0) > 0 ||
291
312
  (retained.interview?.diagnostics.length ?? 0) > 0,
292
- preRig: retained.source.selector?.kind === 'draft', modeling: false, motion: false, feedback: true, audio: false},
313
+ preRig: retained.source.selector?.kind === 'draft' && !retainedRigDraftVerdict(retained), modeling: false, motion: false, feedback: true, audio: false},
293
314
  });
294
- const interviewMetadata = (rigPicture = false) => {
315
+ const interviewMetadata = (rigPicture = false, painting?: NonNullable<ReturnType<typeof retainedRecordPainting>>) => {
295
316
  const interview = isRetainedRecordSource(retained) ? undefined :
296
317
  retained.interview !== undefined ? retained.interview : display.publication.interview;
297
318
  return json({
298
319
  questions: questions.map(question => ({...question,
299
320
  ...(rigPicture && question.missingPicture === 'rig' ? {missingPicture: undefined} : {}),
300
- images: question.images.map((image, index) => ({name: image.name,
321
+ images: (painting && question.missingPicture ? [painting] : question.images).map((image, index) => ({name: image.name,
301
322
  url: `/api/interview/image/${question.ref.sha256}/${index}`})),
302
323
  })),
303
324
  ...(interview === undefined ? {} : {interview}),
@@ -324,6 +345,11 @@ export function retainedPublicationRoutes(session: JobSession) {
324
345
  return await sealedFile(member.path);
325
346
  }
326
347
  if (isRetainedRecordSource(retained)) {
348
+ // #983: the declared plan picture is an exact sealed member; no other file is reachable here.
349
+ if (path === 'api/plan-picture') {
350
+ const picture = retained.source.subject === 'plan' ? retained.source.planPicture : undefined;
351
+ return picture ? await sealedFile(picture.path) : failure('JOB_SOURCE_UNRETAINABLE', 404);
352
+ }
327
353
  // hasParts is projected only after validating the option's sealed draft closure.
328
354
  const question = retained.questions.find(question => question.hasParts);
329
355
  if (question && (path === 'api/stage-parts' || /^api\/stage-parts\/(image|page)\/(0|[1-9]\d*)$/.test(path))) {
@@ -349,7 +375,7 @@ export function retainedPublicationRoutes(session: JobSession) {
349
375
  const file = servedImage(parts, image[1] as 'image'|'page', Number(image[2]));
350
376
  return file ? await sealedFile(relative(retained.snapshotRoot,file).split('\\').join('/')) : failure('JOB_SOURCE_UNRETAINABLE',404);
351
377
  }
352
- if (path === 'api/review' || path === 'api/interview' || path.startsWith('assets/')) {
378
+ if (path === 'api/review' || path === 'api/interview' || path.startsWith('assets/') || interview) {
353
379
  let review: ReviewPackage | null = null;
354
380
  if (!question) {
355
381
  let pending = views.get(publicationId);
@@ -360,11 +386,21 @@ export function retainedPublicationRoutes(session: JobSession) {
360
386
  ({review} = await pending);
361
387
  }
362
388
  if (path === 'api/review') return reviewMetadata(review);
363
- if (path === 'api/interview') return interviewMetadata(!!review);
389
+ if (path === 'api/interview' || interview) {
390
+ const fallback = !review && questions.find(item => item.missingPicture);
391
+ const painting = fallback ? retainedRecordPainting(retained) : null;
392
+ if (fallback && !painting && !interview)
393
+ return failure('JOB_SOURCE_UNRETAINABLE', 409);
394
+ if (interview) {
395
+ if (painting && fallback && interview[1] === fallback.ref.sha256 && interview[2] === '0')
396
+ return await sealedFile(painting.ref.path);
397
+ return await interviewImage(interview);
398
+ }
399
+ return interviewMetadata(!!review, painting ?? undefined);
400
+ }
364
401
  try {return await reviewAsset(review);}
365
402
  catch {return failure('JOB_SOURCE_UNRETAINABLE', 404);}
366
403
  }
367
- if (interview) return await interviewImage(interview);
368
404
  return failure('JOB_REQUEST_INVALID', 404);
369
405
  }
370
406
  let pending = views.get(publicationId);
package/src/job-host.ts CHANGED
@@ -23,7 +23,7 @@ export type {
23
23
  JobRootIdentity,
24
24
  } from './job-source.ts';
25
25
  export {parseRecordAct} from './job-api.ts';
26
- export {parseCommentsAct, parseContextCommentsAct, parseMeshEditsAct} from './job-api.ts';
26
+ export {parseCommentsAct, parseContextCommentsAct, parseMeshEditsAct, parseChestLandmarksAct} from './job-api.ts';
27
27
  export {projectComments} from './stage-comment.ts';
28
28
  export {parseCommentsSession} from './session.ts';
29
29
  export {parseCommentsCompareSession} from './compare-session.ts';
@@ -31,12 +31,14 @@ export {parseCommentsPartsVerdict} from './parts-view.ts';
31
31
  export {projectSelectedCommentsFeedback} from './feedback-export.ts';
32
32
  export {
33
33
  JOB_COMMENTS_ACT_SCHEMA, JOB_COMMENT_CONTEXT_ACT_SCHEMA, JOB_MESH_EDITS_ACT_SCHEMA, REVIEW_COMMENTS_SESSION_SCHEMA,
34
+ JOB_CHEST_LANDMARKS_ACT_SCHEMA,
34
35
  REVIEW_COMMENTS_COMPARE_SESSION_SCHEMA, PARTS_COMMENTS_VERDICT_SCHEMA,
35
36
  } from './job-contract.ts';
36
37
  export type {
37
38
  JobComment, JobCommentAnchor, JobCommentFeedbackAnchor, JobCommentPartsAnchor, JobCommentImageAnchor,
38
39
  JobCommentsAct, JobCommentsActValues, ReviewCommentsSession,
39
40
  JobMeshEditValue, JobMeshEdit, JobMeshEditsAct,
41
+ JobChestLandmarkValue, JobPublishedChestLandmark, JobChestLandmarkEdit, JobChestLandmarksAct,
40
42
  JobCommentContext, JobContextComment, JobContextCommentsAct, CompareCommentsSession, PartsCommentsVerdict,
41
43
  } from './job-contract.ts';
42
44
  export {prepareJobRecordAct} from './job-act.ts';
@@ -128,6 +130,10 @@ export type {
128
130
  JobAskRequestV3,
129
131
  JobAskBatchRequestV3,
130
132
  JobAskBatchValueV3,
133
+ JobProgressRequestV3,
134
+ JobProgressValueV3,
135
+ JobProgressV3,
136
+ JobProgressLineV3,
131
137
  JobNextRequest,
132
138
  JobNextRequestV3,
133
139
  JobCloseRequest,