@rig-c/review 3.7.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.
Files changed (109) hide show
  1. package/README.md +3 -3
  2. package/docs/DESIGN.md +145 -74
  3. package/docs/PANELS.md +20 -12
  4. package/docs/PARTS_VIEW.md +133 -76
  5. package/docs/REVIEW_PACKAGE.md +446 -100
  6. package/docs/STABILITY.md +132 -198
  7. package/docs/WORKFLOWS.md +41 -120
  8. package/package.json +4 -3
  9. package/skills/rig-review/SKILL.md +41 -27
  10. package/src/build.ts +10 -2
  11. package/src/cli.ts +17 -16
  12. package/src/comment-crops.ts +6 -1
  13. package/src/compare-html.ts +22 -24
  14. package/src/compare-server.ts +1 -1
  15. package/src/compare-session.ts +41 -3
  16. package/src/correction-handoff.ts +27 -4
  17. package/src/create-pin-gate.ts +3 -0
  18. package/src/direction-inspection.ts +6 -2
  19. package/src/feedback-export.ts +68 -1
  20. package/src/front.ts +5 -200
  21. package/src/handoff.ts +1 -1
  22. package/src/interview-routes.ts +1 -1
  23. package/src/interview-scene.ts +3 -3
  24. package/src/job-act.ts +77 -73
  25. package/src/job-api.ts +326 -13
  26. package/src/job-checkpoint-evidence.ts +113 -0
  27. package/src/job-cli.ts +27 -14
  28. package/src/job-contract.ts +284 -62
  29. package/src/job-front.ts +192 -61
  30. package/src/job-host.ts +23 -4
  31. package/src/job-session.ts +109 -24
  32. package/src/job-source.ts +227 -58
  33. package/src/job-store.ts +80 -6
  34. package/src/job-worker.ts +1 -47
  35. package/src/joined-project.ts +61 -4
  36. package/src/manifest.ts +32 -4
  37. package/src/open-workspace.ts +12 -12
  38. package/src/open.ts +19 -12
  39. package/src/parts-comment-crops.ts +126 -31
  40. package/src/parts-comment.ts +351 -28
  41. package/src/parts-server.ts +19 -7
  42. package/src/parts-view.ts +588 -109
  43. package/src/scene-inspection.ts +50 -0
  44. package/src/server.ts +31 -22
  45. package/src/session.ts +58 -0
  46. package/src/stage-comment.ts +48 -1
  47. package/src/stage-parts.ts +23 -11
  48. package/web/animation-inspection.ts +1 -1
  49. package/web/bones-panel.ts +1 -3
  50. package/web/catalog-en.ts +175 -39
  51. package/web/catalog-ko.ts +175 -39
  52. package/web/cloth-panel.ts +1 -2
  53. package/web/compare.css +3 -13
  54. package/web/compare.html +3 -3
  55. package/web/compare.ts +69 -64
  56. package/web/cuts-panel.ts +1 -3
  57. package/web/density-strip-panel.ts +1 -2
  58. package/web/direction-panel.ts +22 -6
  59. package/web/i18n.ts +13 -1
  60. package/web/idle-panel.ts +1 -2
  61. package/web/index.html +1 -5
  62. package/web/inspection-persistence.ts +2 -1
  63. package/web/inspector-blocks.ts +149 -40
  64. package/web/instance-access.ts +24 -5
  65. package/web/interview-panel.ts +224 -175
  66. package/web/job-rig-capture.ts +164 -21
  67. package/web/job-rig-screen.ts +344 -0
  68. package/web/job-session.ts +611 -1443
  69. package/web/main.ts +614 -151
  70. package/web/mesh-panel.ts +1 -2
  71. package/web/owner-workspace.ts +88 -109
  72. package/web/part-selection.ts +47 -6
  73. package/web/part-thumbnails.ts +20 -6
  74. package/web/parts-render.ts +26 -19
  75. package/web/parts-viewport-provider.ts +181 -7
  76. package/web/physics-panel.ts +1 -2
  77. package/web/readings-panel.ts +1 -2
  78. package/web/requirements-panel.ts +1 -3
  79. package/web/retained-frame-stage.ts +105 -0
  80. package/web/retarget-panel.ts +2 -3
  81. package/web/rig-fields-panel.ts +1 -2
  82. package/web/rig-host.ts +64 -0
  83. package/web/rig-viewport-provider.ts +65 -16
  84. package/web/scene-plates.ts +57 -4
  85. package/web/stage-comments.ts +103 -46
  86. package/web/styles.css +117 -63
  87. package/web/view-controls.ts +201 -12
  88. package/web/viewport-capture.ts +12 -2
  89. package/web/viewport-controller.ts +107 -27
  90. package/web/viewport-pair.ts +2 -1
  91. package/web/workspace-preferences.ts +5 -4
  92. package/web/workspace-ui.ts +151 -19
  93. package/src/front-worker.ts +0 -2
  94. package/src/interview-server.ts +0 -54
  95. package/src/job-hub.ts +0 -304
  96. package/src/job-image-set.ts +0 -50
  97. package/web/interview.css +0 -28
  98. package/web/interview.html +0 -17
  99. package/web/interview.ts +0 -40
  100. package/web/job-hub.css +0 -14
  101. package/web/job-hub.html +0 -5
  102. package/web/job-hub.ts +0 -179
  103. package/web/owner-workspace.css +0 -14
  104. package/web/owner-workspace.html +0 -5
  105. package/web/parts-flags.ts +0 -48
  106. package/web/parts.css +0 -104
  107. package/web/parts.html +0 -49
  108. package/web/parts.ts +0 -604
  109. package/web/stage-nav.ts +0 -136
package/src/job-cli.ts CHANGED
@@ -1,9 +1,9 @@
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_RIG_REVIEW_ACT_SCHEMA, JOB_ENABLED_ACT_KINDS, jobRawActMediaType, jobStillByteLimit,
5
- type JobAct, type JobAgentRequest, type JobNextRequest, type JobNextValue } from './job-contract.ts';
6
- import { assertJobApiSchema, jobFailure, jobHash, jobId, jobInteger, jobObject, jobWaitLimitMs, parseJobRequest } from './job-api.ts';
4
+ import { JOB_API_SCHEMA, JOB_ACT_SCHEMA, JOB_PARTS_VERDICT_ACT_SCHEMA, JOB_RIG_REVIEW_ACT_SCHEMA, JOB_COMMENTS_ACT_SCHEMA, JOB_ENABLED_ACT_KINDS, jobRawActMediaType, jobStillByteLimit, jobActDeliveryLimit, jobResponseBodyLimit,
5
+ type JobAct, type JobCommentsAct, type JobAgentRequest, type JobNextRequest, type JobNextValue } from './job-contract.ts';
6
+ import { assertJobApiSchema, jobFailure, jobHash, jobId, jobInteger, jobObject, jobWaitLimitMs, parseJobRequest, parseCommentsAct } from './job-api.ts';
7
7
  import { JobError } from './job-store.ts';
8
8
  import {validatePngBytes} from './comment-crops.ts';
9
9
  import {destinationDirectory} from './destination-directory.ts';
@@ -145,12 +145,23 @@ async function consumerBytes(stream: ReadableStream<Uint8Array> | null, maximum:
145
145
  }
146
146
  }
147
147
 
148
- function parseConsumerAct(bytes: Buffer, job: string, actId: string): JobAct {
148
+ type ConsumerAct = JobAct | JobCommentsAct;
149
+
150
+ function parseConsumerAct(bytes: Buffer, job: string, actId: string): ConsumerAct {
149
151
  let value: unknown;
150
152
  try { value = JSON.parse(new TextDecoder('utf-8', {fatal: true}).decode(bytes)); }
151
153
  catch { throw new JobError('JOB_REQUEST_INVALID'); }
152
154
  const act = jobObject(value, ['schema', 'actId', 'jobId', 'askId', 'publicationId', 'kind', 'authority', 'at', 'source', 'value', 'still']);
153
- if (act.jobId !== job || act.actId !== actId || (act.schema !== JOB_ACT_SCHEMA && act.schema !== JOB_RIG_REVIEW_ACT_SCHEMA)) {
155
+ if (act.schema === JOB_COMMENTS_ACT_SCHEMA) {
156
+ const comments = parseCommentsAct(act);
157
+ if (comments.jobId !== job || comments.actId !== actId) throw new JobError('JOB_ACT_INVALID');
158
+ return comments;
159
+ }
160
+ if (act.jobId !== job || act.actId !== actId ||
161
+ (act.schema !== JOB_ACT_SCHEMA && act.schema !== JOB_RIG_REVIEW_ACT_SCHEMA && act.schema !== JOB_PARTS_VERDICT_ACT_SCHEMA)) {
162
+ throw new JobError('JOB_ACT_INVALID');
163
+ }
164
+ if (act.schema === JOB_PARTS_VERDICT_ACT_SCHEMA && (act.kind !== 'parts-verdict' || act.still !== undefined)) {
154
165
  throw new JobError('JOB_ACT_INVALID');
155
166
  }
156
167
  if (act.schema === JOB_RIG_REVIEW_ACT_SCHEMA) {
@@ -174,7 +185,8 @@ function unlinkOwned(path: string, identity: {dev: number; ino: number}): void {
174
185
  }
175
186
  }
176
187
 
177
- function outputConsumerAct(actBytes: Buffer, png: Buffer | undefined, act: JobAct, destination: string | undefined, options: JobCLIOptions): void {
188
+ function outputConsumerAct(actBytes: Buffer, png: Buffer | undefined, act: ConsumerAct, destination: string | undefined, options: JobCLIOptions): void {
189
+ const still = 'still' in act ? act.still : undefined;
178
190
  let temporary: string | undefined;
179
191
  let temporaryIdentity: {dev: number; ino: number} | undefined;
180
192
  let installed: string | undefined;
@@ -184,7 +196,7 @@ function outputConsumerAct(actBytes: Buffer, png: Buffer | undefined, act: JobAc
184
196
  let lockDescriptor: number | undefined;
185
197
  let emitted = 0;
186
198
  try {
187
- if (png && destination && act.schema === JOB_RIG_REVIEW_ACT_SCHEMA) {
199
+ if (png && destination && still) {
188
200
  const directory = destinationDirectory(destination, 'JOB_STILL_OUTPUT_FAILED', false);
189
201
  const directoryDescriptor = openSync(directory, constants.O_RDONLY | (constants.O_DIRECTORY ?? 0) | constants.O_NOFOLLOW);
190
202
  try {
@@ -200,13 +212,13 @@ function outputConsumerAct(actBytes: Buffer, png: Buffer | undefined, act: JobAc
200
212
  }
201
213
  throw error;
202
214
  }
203
- const target = join(directory, act.still.path);
215
+ const target = join(directory, still.path);
204
216
  let existing = false;
205
217
  try {
206
218
  const descriptor = openSync(target, constants.O_RDONLY | constants.O_NOFOLLOW);
207
219
  try {
208
220
  const info = fstatSync(descriptor);
209
- if (!info.isFile() || info.size > jobStillByteLimit || jobHash(readFileSync(descriptor)) !== act.still.sha256) {
221
+ if (!info.isFile() || info.size > jobStillByteLimit || jobHash(readFileSync(descriptor)) !== still.sha256) {
210
222
  throw new JobError('JOB_STILL_OUTPUT_FAILED');
211
223
  }
212
224
  existing = true;
@@ -301,16 +313,17 @@ async function fetchActCommand(args: readonly string[], options: JobCLIOptions):
301
313
  if (response.headers.get('content-type')?.split(';')[0] !== accept) throw new JobError('JOB_REQUEST_INVALID');
302
314
  return bytes;
303
315
  }
304
- const bytes = await read(jobRawActMediaType, 512 * 1024);
316
+ const bytes = await read(jobRawActMediaType, jobActDeliveryLimit);
305
317
  const act = parseConsumerAct(bytes, job, actId);
318
+ const still = 'still' in act ? act.still : undefined;
306
319
  const destination = values.get('still-out');
307
- if (act.schema === JOB_RIG_REVIEW_ACT_SCHEMA && destination === undefined) throw new JobError('JOB_STILL_OUTPUT_FAILED');
320
+ if (still && destination === undefined) throw new JobError('JOB_STILL_OUTPUT_FAILED');
308
321
  let png: Buffer | undefined;
309
322
  if (destination !== undefined) {
310
- if (act.schema !== JOB_RIG_REVIEW_ACT_SCHEMA) throw new JobError('JOB_STILL_UNAVAILABLE');
323
+ if (!still) throw new JobError('JOB_STILL_UNAVAILABLE');
311
324
  png = await read('image/png', jobStillByteLimit);
312
325
  try {
313
- if (png.length < 33 || jobHash(png) !== act.still.sha256) throw new Error('hash');
326
+ if (png.length < 33 || jobHash(png) !== still.sha256) throw new Error('hash');
314
327
  validatePngBytes(png, png.readUInt32BE(16), png.readUInt32BE(20));
315
328
  } catch { throw new JobError('JOB_STILL_CAPTURE_FAILED'); }
316
329
  }
@@ -327,7 +340,7 @@ async function readJobResponse(response: Response, interrupted?: Promise<never>)
327
340
  const { done, value } = await (interrupted ? Promise.race([reader.read(), interrupted]) : reader.read());
328
341
  if (done) break;
329
342
  size += value.byteLength;
330
- if (size > 1024 * 1024) {
343
+ if (size > jobResponseBodyLimit) {
331
344
  try { void reader.cancel().catch(() => {}); } catch {}
332
345
  throw new JobError('JOB_BODY_LIMIT');
333
346
  }
@@ -12,6 +12,12 @@
12
12
  */
13
13
 
14
14
  import type { JobPublicationReader } from './job-source.ts';
15
+ import type { PartsIssue } from './parts-comment.ts';
16
+ import type { Feedback, ReviewSession } from './session.ts';
17
+ import type { CompareFeedback, CompareSession } from './compare-session.ts';
18
+ import type { MarkRegion } from './stage-comment.ts';
19
+ import type { PartsVerdict } from './parts-view.ts';
20
+ import type { ControlNumericCamera, ControlPart } from './control.ts';
15
21
 
16
22
  export const JOB_API_SCHEMA = 'rig-review/job-api@2' as const;
17
23
  export const JOB_API_V3_SCHEMA = 'rig-review/job-api@3' as const;
@@ -20,6 +26,144 @@ export const JOB_ACT_SCHEMA = 'rig-review/act@2' as const;
20
26
  export const JOB_RIG_REVIEW_ACT_SCHEMA = 'rig-review/act@3' as const;
21
27
  /** Record-source acts only under opt-in API@3. Package/image acts retain @2/@3. */
22
28
  export const JOB_RECORD_ACT_SCHEMA = 'rig-review/act@4' as const;
29
+ /** New parts verdicts only. Historical @2 parts-verdict acts remain readable. */
30
+ export const JOB_PARTS_VERDICT_ACT_SCHEMA = 'rig-review/act@5' as const;
31
+ /** Fresh checkpoint, parts-verdict, rig/post review-verdict and signoff writers. Image-review and interview-picks stay @2; record acts stay @4. */
32
+ export const JOB_COMMENTS_ACT_SCHEMA = 'rig-review/act@6' as const;
33
+ /** @6 plus an optional per-comment `context`. Emitted only behind EMIT_UNPINNED_CREATE_FIELDS (#714). */
34
+ export const JOB_COMMENT_CONTEXT_ACT_SCHEMA = 'rig-review/act@7' as const;
35
+ export const REVIEW_COMMENTS_SESSION_SCHEMA = 'rig-review-session/2' as const;
36
+ export const REVIEW_COMMENTS_COMPARE_SESSION_SCHEMA = 'rig-review-compare-session/2' as const;
37
+ export const PARTS_COMMENTS_VERDICT_SCHEMA = 'rig-review-parts-verdict/5' as const;
38
+
39
+ export type JobCommentFeedbackAnchor = Omit<Feedback, 'summary'> | Omit<CompareFeedback, 'summary'>;
40
+ export type JobCommentPartsAnchor = Omit<PartsIssue, 'summary'>;
41
+ export type JobCommentImageAnchor = { readonly name: string } | {
42
+ readonly name: string;
43
+ readonly imageRegion: MarkRegion;
44
+ readonly crop: PartsIssue['crop'];
45
+ readonly nativeCrop: NonNullable<PartsIssue['nativeCrop']>;
46
+ };
47
+ export type JobCommentAnchor = JobCommentFeedbackAnchor | JobCommentPartsAnchor | JobCommentImageAnchor
48
+ | { readonly checkpointId: string; readonly planStepId: string };
49
+ export interface JobComment { readonly text: string; readonly anchor?: JobCommentAnchor }
50
+ /** Where a comment was made, so opening it can restore that view (#714, act@7).
51
+ * Every field is optional and copies a value an existing pin or restore path already carries.
52
+ */
53
+ export interface JobCommentContext {
54
+ /** The ask subject, its source hash and its version selector, bound to the act's own source. */
55
+ readonly subject?: {
56
+ readonly ask: JobSubject;
57
+ readonly sourceHash: JobSha256;
58
+ readonly selector?: JobSelector;
59
+ };
60
+ /** Workspace mode: StageComment.mode and InspectionSelection.mode. */
61
+ readonly mode?: 'setup' | 'animate' | 'compare';
62
+ /** Inspector tab: InspectionSelection.inspector. */
63
+ readonly tab?: 'view' | 'rig' | 'playback' | 'feedback';
64
+ /** Selected part: InspectionSelection.part. */
65
+ readonly part?: ControlPart;
66
+ /** Marked region in world space: StageComment.world and PartsIssue.rigRegion. */
67
+ readonly region?: MarkRegion;
68
+ /** Parts view mode: PartsIssue.view.mode. */
69
+ readonly viewMode?: 'item' | 'assembled';
70
+ /** Numeric camera: StageComment.camera. */
71
+ readonly camera?: ControlNumericCamera;
72
+ /** Explicit frame: StageComment.frame. */
73
+ readonly frame?: { readonly index: number; readonly basis: 'producer' | 'reference' };
74
+ }
75
+ export interface JobContextComment extends JobComment { readonly context?: JobCommentContext }
76
+ export interface JobCommentsActValues {
77
+ readonly checkpoint: { readonly checkpointId: string; readonly planStepId: string;
78
+ readonly outcome: 'pass' | 'fail'; readonly comments: readonly JobComment[] };
79
+ readonly 'parts-verdict': { readonly verdict: 'approved' | 'changes-requested'; readonly comments: readonly JobComment[] };
80
+ readonly 'review-verdict': { readonly stage: JobReviewStage; readonly verdict: JobVerdict; readonly comments: readonly JobComment[] };
81
+ readonly signoff: { readonly stage: string; readonly decision: 'approved'; readonly comments: readonly JobComment[] };
82
+ readonly reopen: { readonly stage: string; readonly comments: readonly JobComment[] };
83
+ }
84
+ export type JobCommentsAct = {
85
+ [Kind in keyof JobCommentsActValues]: {
86
+ readonly schema: typeof JOB_COMMENTS_ACT_SCHEMA;
87
+ readonly actId: string; readonly jobId: string; readonly askId: string; readonly publicationId: string;
88
+ readonly kind: Kind; readonly authority: JobHumanAuthority; readonly at: string;
89
+ readonly source: Exclude<SourceV3, OptionSource>; readonly value: JobCommentsActValues[Kind]; readonly still?: JobRigStill;
90
+ }
91
+ }[keyof JobCommentsActValues];
92
+ /** act@7: the @6 envelope whose comments may carry `context`. */
93
+ export type JobContextCommentsAct = {
94
+ [Kind in keyof JobCommentsActValues]: Omit<Extract<JobCommentsAct, { readonly kind: Kind }>, 'schema' | 'value'> & {
95
+ readonly schema: typeof JOB_COMMENT_CONTEXT_ACT_SCHEMA;
96
+ readonly value: Omit<JobCommentsActValues[Kind], 'comments'> & { readonly comments: readonly JobContextComment[] };
97
+ }
98
+ }[keyof JobCommentsActValues];
99
+ export type ReviewCommentsSession = Omit<ReviewSession, 'schema' | 'feedback' | 'checkpoints'> & {
100
+ schema: typeof REVIEW_COMMENTS_SESSION_SCHEMA;
101
+ checkpoints: Record<string, { outcome: 'pending' | 'pass' | 'fail' }>;
102
+ comments: JobComment[];
103
+ };
104
+ export type CompareCommentsSession = Omit<CompareSession, 'schema' | 'feedback'> & {
105
+ schema: typeof REVIEW_COMMENTS_COMPARE_SESSION_SCHEMA; comments: JobComment[];
106
+ };
107
+ export type PartsCommentsVerdict = Omit<PartsVerdict, 'schema' | 'issues'> & {
108
+ schema: typeof PARTS_COMMENTS_VERDICT_SCHEMA; comments: JobComment[];
109
+ };
110
+ export const JOB_PANEL_COMPOSITION_SCHEMA = 'rig-review/panels@1' as const;
111
+
112
+ export type PanelSlot = 'left' | 'stage' | 'toolbar' | 'side';
113
+ export const PANEL_COMPONENTS = [
114
+ 'parts.canvas', 'parts.list', 'parts.issues', 'parts.layers', 'act.submit',
115
+ 'interview.picks', 'plan.body', 'rig.playback', 'scene.composite',
116
+ ] as const;
117
+ export type PanelComponent = typeof PANEL_COMPONENTS[number];
118
+ export interface JobPanelComposition {
119
+ readonly schema: typeof JOB_PANEL_COMPOSITION_SCHEMA;
120
+ readonly left?: readonly PanelComponent[];
121
+ readonly stage?: readonly PanelComponent[];
122
+ readonly toolbar?: readonly PanelComponent[];
123
+ readonly side?: readonly PanelComponent[];
124
+ }
125
+ export function isPanelComponent(value: string): value is PanelComponent {
126
+ return (PANEL_COMPONENTS as readonly string[]).includes(value);
127
+ }
128
+
129
+ export function parsePanelComposition(input: unknown): JobPanelComposition {
130
+ if (input === null || typeof input !== 'object' || Array.isArray(input) || Object.getPrototypeOf(input) !== Object.prototype) {
131
+ throw new Error('JOB_PANELS_INVALID: panels must be a plain object');
132
+ }
133
+ const p = input as Record<string, unknown>;
134
+ if (p.schema !== JOB_PANEL_COMPOSITION_SCHEMA) {
135
+ throw new Error(`JOB_PANELS_INVALID: panels.schema must be ${JOB_PANEL_COMPOSITION_SCHEMA}`);
136
+ }
137
+ for (const key of Object.keys(p)) {
138
+ if (!['schema', 'left', 'stage', 'toolbar', 'side'].includes(key)) {
139
+ throw new Error(`JOB_PANELS_INVALID: unknown panel slot ${key}`);
140
+ }
141
+ }
142
+ const slot = (value: unknown, field: string): PanelComponent[] => {
143
+ if (!Array.isArray(value) || value.length > 32) {
144
+ throw new Error(`JOB_PANELS_INVALID: ${field} must be an array of at most 32 components`);
145
+ }
146
+ return value.map((item, index) => {
147
+ if (typeof item !== 'string' || !item.trim() || item.length > 128 || /[\r\n\0]/.test(item)) {
148
+ throw new Error(`JOB_PANELS_INVALID: ${field}[${index}] must be a nonblank component id`);
149
+ }
150
+ // Unknown component IDs are preserved in their declared slot so the host renders JOB_PANEL_UNKNOWN: <id>.
151
+ return item as PanelComponent;
152
+ });
153
+ };
154
+ const stage = slot(p.stage, 'panels.stage');
155
+ const side = slot(p.side, 'panels.side');
156
+ if (stage.length !== 1 || side.length < 1 || side[side.length - 1] !== 'act.submit') {
157
+ throw new Error('JOB_PANELS_INVALID: stage must have exactly one component and side must end with act.submit');
158
+ }
159
+ return {
160
+ schema: JOB_PANEL_COMPOSITION_SCHEMA,
161
+ ...(p.left === undefined ? {} : { left: slot(p.left, 'panels.left') }),
162
+ stage,
163
+ ...(p.toolbar === undefined ? {} : { toolbar: slot(p.toolbar, 'panels.toolbar') }),
164
+ side,
165
+ };
166
+ }
23
167
  export const JOB_RECORD_READER_ID = 'rig-create/publication-reader/2' as const;
24
168
  export const JOB_RECORD_SOURCE_SCHEMA = 'rig-review-job-record-source/1' as const;
25
169
  export const JOB_RECORD_INSTANCE_SCHEMA = 'rig-review-job-record-instance/1' as const;
@@ -28,8 +172,11 @@ export type JobPublicationMode = typeof JOB_PUBLICATION_MODES[number];
28
172
  export type JobApiSchema = typeof JOB_API_SCHEMA | typeof JOB_API_V3_SCHEMA;
29
173
  export const jobStillByteLimit = 8 * 1024 * 1024;
30
174
  export const jobCaptureBodyLimit = 12 * 1024 * 1024;
175
+ /** Full act plus its envelope; comment pixels use separate private storage. */
176
+ export const jobActDeliveryLimit = 16 * 1024 * 1024;
177
+ export const jobResponseBodyLimit = jobActDeliveryLimit + 64 * 1024;
31
178
  export const jobRawActMediaType = 'application/vnd.rig-review.act+json';
32
- export const JOB_PARTS_ENUMERATOR_RANGE = '>=2.25.0 <4.0.0' as const;
179
+ export const JOB_PARTS_ENUMERATOR_RANGE = '>=2.25.0 <3.0.0' as const;
33
180
 
34
181
  export const JOB_ENABLED_ACT_KINDS = [
35
182
  'interview-picks',
@@ -58,6 +205,9 @@ export const JOB_PLAN_BOUND_SIGNOFF_STAGES = [
58
205
  'post-interview',
59
206
  ] as const;
60
207
 
208
+ /** Record-only approval stages; not part of the public job-host runtime exports. */
209
+ export const JOB_RECORD_SIGNOFF_STAGES = [...JOB_PLAN_BOUND_SIGNOFF_STAGES, 'direction-review', 'interview'] as const;
210
+
61
211
  /** Reserved kinds have no accepted value shape and cannot be asked or submitted.
62
212
  * Described correction awaits the joint Create #182 context allowlist.
63
213
  * Mesh edit awaits the joint Parts #1159 freeze. Proposal 6ff03ec9 discusses
@@ -87,6 +237,23 @@ export interface JobFileIdentity {
87
237
  readonly sha256: JobSha256;
88
238
  }
89
239
 
240
+ /** Optional sealed decision material, bound verbatim to the published source. */
241
+ export interface JobCheckpointEvidence {
242
+ readonly schema: 'rig-review-checkpoint-evidence/1';
243
+ readonly checkpointId: string;
244
+ readonly planStepId: string;
245
+ readonly tiles: readonly (JobFileIdentity & {readonly id: string; readonly label: string})[];
246
+ readonly table: JobFileIdentity & {readonly label?: string};
247
+ readonly routesText: string;
248
+ readonly recommendationText: string;
249
+ }
250
+
251
+ export interface JobCheckpointTable {
252
+ readonly schema: 'rig-review-checkpoint-table/1';
253
+ readonly columns: readonly string[];
254
+ readonly rows: readonly (readonly (string | number | boolean | null)[])[];
255
+ }
256
+
90
257
  /** IDs and existing step hashes published by Create #184 for the displayed plan.
91
258
  * Review retains these values without importing or computing Create's internal
92
259
  * stepHash. Create validates them with its existing writer. No plan revision
@@ -101,6 +268,79 @@ export interface JobPlanIdentity {
101
268
  readonly steps: readonly JobPlanStepIdentity[];
102
269
  }
103
270
 
271
+ /** Ephemeral owner metadata, projected by the daemon from the sealed project. */
272
+ export const JOB_PLAN_TEXT_SCHEMA = 'rig-review/job-plan-text@1' as const;
273
+ export const JOB_PLAN_TEXT_FIELDS = ['does', 'produces', 'bar', 'rests_on'] as const;
274
+ export type JobPlanTextField = typeof JOB_PLAN_TEXT_FIELDS[number];
275
+ export interface JobPlanTextStep {
276
+ readonly id: string;
277
+ readonly hash: string;
278
+ does?: string;
279
+ produces?: string;
280
+ bar?: string;
281
+ rests_on?: readonly string[];
282
+ readonly issues: {field: JobPlanTextField; reason: 'absent' | 'invalid' | 'limit'}[];
283
+ }
284
+ export const JOB_PLAN_TEXT_UNAVAILABLE = [
285
+ 'PLAN_TEXT_RECORD_UNAVAILABLE', 'PLAN_TEXT_RECORD_UNSUPPORTED', 'PLAN_TEXT_STEPS_ABSENT',
286
+ 'PLAN_TEXT_STEPS_INVALID', 'PLAN_TEXT_MAPPING_UNAVAILABLE', 'PLAN_TEXT_LIMIT',
287
+ ] as const;
288
+ export type JobPlanTextProjection = {
289
+ readonly schema: typeof JOB_PLAN_TEXT_SCHEMA;
290
+ readonly record: {readonly path: 'project.json'; readonly sha256: string};
291
+ readonly status: 'projected';
292
+ readonly steps: readonly JobPlanTextStep[];
293
+ } | {
294
+ readonly schema: typeof JOB_PLAN_TEXT_SCHEMA;
295
+ readonly record: {readonly path: 'project.json'; readonly sha256: string} | null;
296
+ readonly status: 'unavailable';
297
+ readonly reason: typeof JOB_PLAN_TEXT_UNAVAILABLE[number];
298
+ };
299
+
300
+ /** Closed delivery grammar. Field contents have the normal daemon's authority. */
301
+ export function parseJobPlanTextProjection(value: unknown): JobPlanTextProjection {
302
+ const fail = (): never => {throw new Error('PLAN_TEXT_METADATA_INVALID');};
303
+ const object = (input: unknown, keys: readonly string[]): Record<string, unknown> => {
304
+ if (!input || typeof input !== 'object' || Array.isArray(input) ||
305
+ Object.keys(input).some(key => !keys.includes(key))) return fail();
306
+ return input as Record<string, unknown>;
307
+ };
308
+ const envelope = object(value, ['schema', 'record', 'status', 'steps', 'reason']);
309
+ if (envelope.schema !== JOB_PLAN_TEXT_SCHEMA || !Object.hasOwn(envelope, 'record') ||
310
+ new TextEncoder().encode(JSON.stringify(value)).length > 512 * 1024) return fail();
311
+ if (envelope.record !== null) {
312
+ const record = object(envelope.record, ['path', 'sha256']);
313
+ if (record.path !== 'project.json' || typeof record.sha256 !== 'string' || !/^[a-f0-9]{64}$/.test(record.sha256)) return fail();
314
+ }
315
+ if (envelope.status === 'unavailable') {
316
+ if (Object.hasOwn(envelope, 'steps') || !(JOB_PLAN_TEXT_UNAVAILABLE as readonly unknown[]).includes(envelope.reason)) return fail();
317
+ return value as JobPlanTextProjection;
318
+ }
319
+ if (envelope.status !== 'projected' || envelope.record === null || Object.hasOwn(envelope, 'reason') ||
320
+ !Array.isArray(envelope.steps) || envelope.steps.length > 4096) return fail();
321
+ const ids = new Set<string>();
322
+ for (const raw of envelope.steps) {
323
+ const row = object(raw, ['id', 'hash', ...JOB_PLAN_TEXT_FIELDS, 'issues']);
324
+ if (typeof row.id !== 'string' || row.id.length > 128 || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(row.id) ||
325
+ ids.has(row.id) || typeof row.hash !== 'string' || !/^[a-f0-9]{64}$/.test(row.hash) || !Array.isArray(row.issues)) return fail();
326
+ ids.add(row.id);
327
+ const missing = JOB_PLAN_TEXT_FIELDS.filter(field => !Object.hasOwn(row, field));
328
+ if (row.issues.length !== missing.length) return fail();
329
+ row.issues.forEach((rawIssue, index) => {
330
+ const issue = object(rawIssue, ['field', 'reason']);
331
+ if (issue.field !== missing[index] || typeof issue.reason !== 'string' || !['absent', 'invalid', 'limit'].includes(issue.reason)) fail();
332
+ });
333
+ for (const field of JOB_PLAN_TEXT_FIELDS) {
334
+ if (!Object.hasOwn(row, field)) continue;
335
+ const content = row[field];
336
+ if (field === 'rests_on') {
337
+ if (!Array.isArray(content) || content.length > 4096 || content.some(item => typeof item !== 'string')) return fail();
338
+ } else if (typeof content !== 'string') return fail();
339
+ }
340
+ }
341
+ return value as JobPlanTextProjection;
342
+ }
343
+
104
344
  /** Literal work-root-relative manifest path, validated at runtime. */
105
345
  export type JobPartsManifestPath = string;
106
346
  /** Literal path relative to the bound manifest directory. */
@@ -145,16 +385,13 @@ export type JobSelector =
145
385
  | { readonly kind: 'rig'; readonly version: number }
146
386
  | { readonly kind: 'post'; readonly version: number; readonly rigVersion: number };
147
387
 
148
- /** The original model branch keeps required explicit nulls. The image branch
149
- * omits model and selector entirely. The daemon derives the binding from
388
+ /** The model source keeps required explicit nulls. The daemon derives its binding from
150
389
  * validated retained bytes and the actual displayed publication. Clients never
151
390
  * provide trusted source hashes or transfer old approval onto a new binding.
152
391
  */
153
392
  export interface JobModelSourceBinding {
393
+ readonly checkpointEvidence?: readonly JobCheckpointEvidence[];
154
394
  readonly subject?: never;
155
- readonly imageSet?: never;
156
- readonly imageSetDigest?: never;
157
- readonly duplicateHashes?: never;
158
395
  readonly sourceHash: JobSha256;
159
396
  readonly projectHash: JobSha256 | null;
160
397
  readonly package: { readonly id: string; readonly revision: string };
@@ -167,35 +404,9 @@ export interface JobModelSourceBinding {
167
404
  readonly parts: JobPartsIdentity | null;
168
405
  }
169
406
 
170
- /** Trusted-reader input. Hashes are optional claims, checked against retained bytes. */
171
- export interface JobImageSetInput {
172
- readonly purpose: 'plate-adoption';
173
- readonly images: readonly {
174
- readonly role: 'source' | 'candidate' | 'reference';
175
- readonly name: string;
176
- readonly path: string;
177
- readonly sha256?: JobSha256;
178
- }[];
179
- }
180
-
181
- export interface JobImageSet {
182
- readonly purpose: 'plate-adoption';
183
- readonly images: readonly (Omit<JobImageSetInput['images'][number], 'sha256'> & {readonly sha256: JobSha256})[];
184
- }
185
-
186
- export interface JobImageSourceBinding extends Omit<JobModelSourceBinding,
187
- 'subject' | 'model' | 'selector' | 'imageSet' | 'imageSetDigest' | 'duplicateHashes'> {
188
- readonly subject: 'image-set';
189
- readonly model?: never;
190
- readonly selector?: never;
191
- readonly imageSet: JobImageSet;
192
- readonly imageSetDigest: JobSha256;
193
- readonly duplicateHashes: readonly {readonly names: readonly string[]; readonly sha256: JobSha256}[];
194
- }
195
-
196
- export type JobSourceBinding = JobModelSourceBinding | JobImageSourceBinding;
197
- export interface JobCapabilities { readonly imageSetVerdict: true }
198
- export const JOB_CAPABILITIES: JobCapabilities = Object.freeze({imageSetVerdict: true});
407
+ export type JobSourceBinding = JobModelSourceBinding;
408
+ export interface JobCapabilities {}
409
+ export const JOB_CAPABILITIES: JobCapabilities = Object.freeze({});
199
410
 
200
411
  export interface JobModelReviewValue {
201
412
  readonly stage: 'rig-review' | 'direction-review';
@@ -228,6 +439,22 @@ export type JobVerdict = 'pending' | 'approved' | 'changes-requested';
228
439
  export type JobPartOutcome = 'pending' | 'clean' | 'flagged';
229
440
  export type JobReviewStage = 'rig-review' | 'direction-review' | 'image-review';
230
441
 
442
+ export type PartsVerdictValue = {
443
+ readonly verdict: 'approved' | 'changes-requested';
444
+ readonly issues: readonly PartsIssue[];
445
+ readonly words: string;
446
+ };
447
+
448
+ export interface JobLegacyPartsVerdictValue {
449
+ readonly verdict: JobVerdict;
450
+ readonly parts: readonly {
451
+ readonly partId: string;
452
+ readonly part: { readonly outcome: JobPartOutcome; readonly note: string };
453
+ readonly mesh: { readonly outcome: JobPartOutcome; readonly note: string };
454
+ }[];
455
+ readonly words: string;
456
+ }
457
+
231
458
  export interface JobActValues {
232
459
  readonly 'interview-picks': {
233
460
  readonly questionId: string;
@@ -251,15 +478,7 @@ export interface JobActValues {
251
478
  */
252
479
  readonly words: string;
253
480
  };
254
- readonly 'parts-verdict': {
255
- readonly verdict: JobVerdict;
256
- readonly parts: readonly {
257
- readonly partId: string;
258
- readonly part: { readonly outcome: JobPartOutcome; readonly note: string };
259
- readonly mesh: { readonly outcome: JobPartOutcome; readonly note: string };
260
- }[];
261
- readonly words: string;
262
- };
481
+ readonly 'parts-verdict': PartsVerdictValue;
263
482
  readonly 'review-verdict': JobModelReviewValue | JobImageReviewValue;
264
483
  readonly signoff: {
265
484
  /** An explicitly declared Create stage. Validation belongs to its writer. */
@@ -280,8 +499,11 @@ export interface JobActValues {
280
499
  * supplies checkpoint ID, outcome and words only. Create derives execution
281
500
  * stage from its authoritative step phase/order. Review never stamps a stage.
282
501
  */
283
- export type JobUIActValues = Omit<JobActValues, 'checkpoint'> & {
502
+ export type JobUIActValues = Omit<JobActValues, 'checkpoint' | 'review-verdict'> & {
284
503
  readonly checkpoint: Omit<JobActValues['checkpoint'], 'planStepId'>;
504
+ readonly 'review-verdict': JobImageReviewValue
505
+ | (JobModelReviewValue & {readonly stage: 'direction-review'})
506
+ | (JobModelReviewValue & {readonly stage: 'rig-review'; readonly feedback?: readonly Feedback[]});
285
507
  };
286
508
 
287
509
  export interface JobActSources {
@@ -294,7 +516,7 @@ export interface JobActSources {
294
516
  readonly selector: Extract<JobSelector, { kind: 'draft' }>;
295
517
  readonly parts: JobPartsIdentity;
296
518
  };
297
- readonly 'review-verdict': JobImageSourceBinding | (JobModelSourceBinding & {
519
+ readonly 'review-verdict': (JobModelSourceBinding & {
298
520
  readonly selector: Extract<JobSelector, { kind: 'rig' | 'post' }>;
299
521
  readonly model: JobFileIdentity;
300
522
  });
@@ -319,9 +541,9 @@ export type JobLegacyAct = {
319
541
  readonly authority: JobHumanAuthority;
320
542
  readonly at: string;
321
543
  } & (Kind extends 'review-verdict' ? (
322
- | {readonly source: Exclude<JobActSources['review-verdict'], JobImageSourceBinding>; readonly value: JobModelReviewValue}
323
- | {readonly source: JobImageSourceBinding; readonly value: JobImageReviewValue}
324
- ) : {readonly source: JobActSources[Kind]; readonly value: JobActValues[Kind]});
544
+ | {readonly source: JobActSources['review-verdict']; readonly value: JobModelReviewValue | JobImageReviewValue}
545
+ ) : Kind extends 'parts-verdict' ? {readonly source: JobActSources['parts-verdict']; readonly value: JobLegacyPartsVerdictValue}
546
+ : {readonly source: JobActSources[Kind]; readonly value: JobActValues[Kind]});
325
547
  }[JobEnabledActKind];
326
548
 
327
549
  export type JobRigStill = {
@@ -343,8 +565,14 @@ export type JobRigReviewAct = Omit<Extract<JobLegacyAct, {kind: 'review-verdict'
343
565
  readonly still: JobRigStill;
344
566
  };
345
567
 
346
- /** Historical @2 rig acts remain readable without being backfilled or relabelled. */
347
- export type JobAct = JobLegacyAct | JobRigReviewAct;
568
+ export type JobPartsVerdictAct = Omit<Extract<JobLegacyAct, {kind: 'parts-verdict'}>, 'schema' | 'value'> & {
569
+ readonly schema: typeof JOB_PARTS_VERDICT_ACT_SCHEMA;
570
+ readonly value: PartsVerdictValue;
571
+ };
572
+
573
+ /** Historical @2 acts remain readable without being backfilled or relabelled.
574
+ * Fresh checkpoint, parts, rig/post verdict and signoff acts are written as act@6. */
575
+ export type JobAct = JobLegacyAct | JobRigReviewAct | JobPartsVerdictAct | JobCommentsAct;
348
576
 
349
577
  /** Authenticated browser provenance. The daemon validates identity and hashes PNG bytes. */
350
578
  export interface JobRigCapture {
@@ -532,12 +760,6 @@ export const JOB_ERROR_CODES = [
532
760
  'JOB_ROOT_REPLACED',
533
761
  'JOB_PUBLICATION_UNKNOWN',
534
762
  'JOB_SNAPSHOT_RECLAIMED',
535
- 'JOB_IMAGE_SET_UNSUPPORTED',
536
- 'JOB_IMAGE_SET_INVALID',
537
- 'JOB_IMAGE_SET_DUPLICATE_NAME',
538
- 'JOB_IMAGE_SET_DUPLICATE_PATH',
539
- 'JOB_IMAGE_SET_ROLE_INVALID',
540
- 'JOB_IMAGE_SET_PATH_REFUSED',
541
763
  'JOB_ASK_INVALID',
542
764
  'JOB_ASK_SUPERSEDED',
543
765
  'JOB_ACT_UNKNOWN',
@@ -774,7 +996,7 @@ export interface RecordCheckpointSubject {
774
996
  readonly checkpointId: string;
775
997
  }
776
998
 
777
- export type RecordSignoffStage = typeof JOB_PLAN_BOUND_SIGNOFF_STAGES[number];
999
+ export type RecordSignoffStage = typeof JOB_RECORD_SIGNOFF_STAGES[number];
778
1000
 
779
1001
  export interface RecordSignoffSubject {
780
1002
  readonly kind: 'signoff';
@@ -803,11 +1025,13 @@ export interface RecordContextBase {
803
1025
  }
804
1026
 
805
1027
  export type OptionContext = RecordContextBase & {
1028
+ readonly checkpointEvidence?: never;
806
1029
  readonly plan: null;
807
1030
  readonly subjects: readonly [RecordPicksSubject];
808
1031
  };
809
1032
 
810
1033
  export type PlanContext = RecordContextBase & {
1034
+ readonly checkpointEvidence?: readonly JobCheckpointEvidence[];
811
1035
  readonly plan: JobPlanIdentity;
812
1036
  readonly subjects: readonly RecordPlanSubject[];
813
1037
  };
@@ -843,9 +1067,6 @@ export interface RecordSourceBase {
843
1067
  readonly direction?: never;
844
1068
  readonly appliedResult?: never;
845
1069
  readonly parts?: never;
846
- readonly imageSet?: never;
847
- readonly imageSetDigest?: never;
848
- readonly duplicateHashes?: never;
849
1070
  readonly sourceHash: JobSha256;
850
1071
  readonly projectHash: JobSha256;
851
1072
  readonly record: ProjectRecord;
@@ -854,6 +1075,7 @@ export interface RecordSourceBase {
854
1075
  }
855
1076
 
856
1077
  export type OptionSource = RecordSourceBase & {
1078
+ readonly checkpointEvidence?: never;
857
1079
  readonly subject: 'option-set';
858
1080
  readonly selection: RecordOptionResult;
859
1081
  readonly optionSet: { readonly id: string; readonly sha256: JobSha256 };
@@ -863,6 +1085,7 @@ export type OptionSource = RecordSourceBase & {
863
1085
  };
864
1086
 
865
1087
  export type PlanSource = RecordSourceBase & {
1088
+ readonly checkpointEvidence?: readonly JobCheckpointEvidence[];
866
1089
  readonly subject: 'plan';
867
1090
  readonly selection: RecordPlanResult;
868
1091
  readonly optionSet: null;
@@ -940,7 +1163,6 @@ export interface JobCapabilitiesV3 extends JobCapabilities {
940
1163
  }
941
1164
 
942
1165
  export const JOB_CAPABILITIES_V3: JobCapabilitiesV3 = Object.freeze({
943
- imageSetVerdict: true,
944
1166
  recordPublication: true,
945
1167
  recordActSchema: JOB_RECORD_ACT_SCHEMA,
946
1168
  });