rig-review 2.3.0 → 2.4.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.
@@ -1081,7 +1081,7 @@ the host-owned integration example are in
1081
1081
 
1082
1082
  ### Exact displayed source and local draft retention
1083
1083
 
1084
- - **Daemon-derived source binding.** `JobSourceBinding` requires non-null `sourceHash` (`JobSha256`) and `package` (`id` and `revision`), and requires explicit values or explicit `null` for its typed nullable fields (`projectHash`, `selector` as `draft` / `rig` / `post`, `model`, `direction`, `optionSet`, `appliedResult`, `plan`, `parts`). Original input paths are literal project-relative or package-relative provenance only, and no public field names a Review state directory or stored document. The daemon derives `JobSourceBinding` from validated retained bytes and the actual displayed publication. Clients never provide trusted source hashes or transfer prior approval onto a new binding.
1084
+ - **Daemon-derived source binding.** The original model branch of `JobSourceBinding` requires non-null `sourceHash` (`JobSha256`) and `package` (`id` and `revision`), and requires explicit values or explicit `null` for its typed nullable fields (`projectHash`, `selector` as `draft` / `rig` / `post`, `model`, `direction`, `optionSet`, `appliedResult`, `plan`, `parts`). Original input paths are literal project-relative or package-relative provenance only, and no public field names a Review state directory or stored document. The daemon derives `JobSourceBinding` from validated retained bytes and the actual displayed publication. Clients never provide trusted source hashes or transfer prior approval onto a new binding.
1085
1085
  - **Display receipt and UI submission.** `JobDisplayPublication` pins same-origin `routes` (`entry`, `apiBase`, `assetsBase`) to that specific `publicationId` and `instanceKey` without a mutable current alias. All metadata, images, runtime assets, routes and pending form dependencies prepare before the visible swap; paint and the single `displayedNonce` acknowledgment precede retirement of the previous view, and failed preparation or acknowledgment restores the prior view and draft. After `ackDisplayed` validates `JobDisplayAcknowledgment` (`publicationId`, `pageId`, `sourceHash`), it returns `JobDisplayReceipt` containing the page-scoped `displayedNonce` secret (never returned by the agent or consumer API). `JobUISubmission` supplies `publicationId`, `askId`, `pageId`, `displayedNonce`, `expectedGeneration`, `submissionId`, `kind` and `value` (`JobUIActValues`). Neither `authority` nor `source` is accepted from the browser. The daemon derives both from the validated nonce and displayed publication (`JOB_DISPLAY_MISMATCH`, `JOB_ACT_SOURCE_STALE`). Retrying the same `submissionId` returns the same immutable `JobAct`, while a changed payload refuses.
1086
1086
  - **Old drafts retained and flagged without rebinding.** When a new publication updates or replaces the displayed source, older local drafts remain retained in storage under their original source binding and are flagged without rebinding or transferring onto the new publication.
1087
1087
 
@@ -1091,11 +1091,38 @@ the host-owned integration example are in
1091
1091
  - **`interview-picks`.** `JobActValues['interview-picks']` carries `questionId`, ordered `selections` (`itemId`, `optionId`, nullable `otherText`) and `note`, with non-null `source.optionSet` (`id` and `sha256`).
1092
1092
  - **`checkpoint`.** `JobActValues['checkpoint']` carries `checkpointId`, `planStepId`, `outcome` restricted to `'pass'` or `'fail'` and required `words` as a `string`. `pending` stays in the UI draft only and never produces a finalized act. Only `'pass'` is eligible for Create's checkpoint sign-off writer, whereas `'fail'` is feedback or a named consumer refusal and never an approval write. `words` is preserved verbatim including empty or whitespace-only strings, matching Create's writer without adding a UI gate. In `JobSubject`, `checkpointId` defaults to the Create plan step ID and optional `planStepId` is required when the displayed Review checkpoint ID differs, matching [Create #184](https://github.com/rig-c/create/issues/184) without alias inference or browser trust. The browser supplies `checkpointId`, `outcome` and `words` only (`JobUIActValues['checkpoint']`), the daemon copies resolved `planStepId` from the validated ask and requires `source.plan`, and Create derives execution stage from its authoritative step phase and order without Review stamping a stage.
1093
1093
  - **`parts-verdict`.** `JobActValues['parts-verdict']` carries `verdict` (`'pending'`, `'approved'` or `'changes-requested'`), `parts` (`partId`, `part` outcome and note, `mesh` outcome and note with `JobPartOutcome` as `'pending'`, `'clean'` or `'flagged'`) and `words`, requiring non-null `source.projectHash`, a `draft` selector and `source.parts`.
1094
- - **`review-verdict`.** `JobActValues['review-verdict']` carries `stage` (`'rig-review'` or `'direction-review'`), `verdict` and `words`, requiring a `rig` or `post` selector and non-null `source.model` with runtime stage, selector and direction consistency checks.
1094
+ - **`review-verdict`.** The original model branch carries `stage` (`'rig-review'` or `'direction-review'`), `verdict` and `words`, requiring a `rig` or `post` selector and non-null `source.model` with runtime stage, selector and direction consistency checks. The HQ-approved #522 image branch uses `'image-review'`, `source.subject = "image-set"`, daemon-derived image identities, digest and duplicate groups, with `model` and `selector` absent. It retains the same human verdict act and supports optional name-bound image notes. [Image-set verdict extension](STABILITY.md#image-set-verdict-extension).
1095
1095
  - **`signoff`.** `JobActValues['signoff']` carries `stage` (validated by Create's writer), `decision` restricted to `'approved'` only (changes requested are a verdict, never a signoff) and required `words` preserved verbatim including empty or whitespace-only strings. A verdict, a signoff and a Create stage transition are three separate writes, and `JobAct` grants no transition authority. Every stage in `JOB_PLAN_BOUND_SIGNOFF_STAGES` (`'plan-approved'`, `'rigging-interview'`, `'post-interview'`) requires non-null `source.plan` with exact displayed step IDs and hashes before act creation, while other stages keep `source.plan` nullable where appropriate.
1096
1096
  - **Create-published step IDs and hashes.** `JobPlanIdentity` holds `steps` (`id` and `hash`) published by [Create #184](https://github.com/rig-c/create/issues/184) for the displayed plan. Review retains these values without importing or recomputing Create's internal `stepHash`. Create validates them through its existing `steps` and `step_hashes` writer logic, with no separate plan revision hash or additional revision gate in this contract.
1097
1097
  - **C4 manifest-referenced parts PNG identity.** C4 binds the exact public `partsFileReferences(dir)` array from `@rig-c/parts/src/parts.ts`, whose contract is frozen at Parts 2.25.0. The trusted host resolves an installed version in `JOB_PARTS_ENUMERATOR_RANGE` (`>=2.25.0 <3.0.0`), supplies its actual version and official callback through `partsEnumerator`, and declares `partsEnumeratorId`. `JobPartsIdentity.enumeratorVersion` carries that actual version. Manifest paths are work-root-relative and image paths are relative to the manifest directory. Each image carries `path`, bounded-string `role` and raw-byte `sha256`. Review compares the claimed array positionally with the official array, preserving its role/order/duplicate semantics. Upstream roles include `part`, `alternate`, `depth`, `painting` and `figure_mask`. Review bounds shape and paths, refuses traversal/symlinks, decodes PNGs and hashes retained bytes. Missing references refuse with row, role and path, including a missing sibling figure mask when a render copy exists. Unreferenced extras stay outside this parts identity. Composite source hashes use `rig-review-job-source/2`. Create #184 production reader/projection and official-hook wiring remain pending.
1098
1098
 
1099
+ ### Image-set publication and human comparison
1100
+
1101
+ Before asking, agents read `next.value.capabilities.imageSetVerdict` through the
1102
+ existing authenticated semantic API or `session next` CLI and require true with
1103
+ `assertJobImageSetCapability`. Hub metadata carries the same capability. Missing
1104
+ support refuses locally with `JOB_IMAGE_SET_UNSUPPORTED`, while the frozen older
1105
+ parser rejects the new stage with `JOB_ASK_INVALID`.
1106
+
1107
+ The trusted publication reader returns optional `imageSet` with purpose
1108
+ `plate-adoption` and 2–8 ordered `{role, name, path, sha256?}` rows. It uses the
1109
+ existing producer-held frozen record callback, with no inferred plate schema.
1110
+ Exactly one source, at least one candidate and optional references are allowed.
1111
+ Names and job-root-relative paths are unique, contained and symlink-checked.
1112
+ The daemon validates supplied hashes, retains exact bytes and rechecks them at
1113
+ ask and finalize. The hub displays the images side by side in producer order,
1114
+ with their names, roles and hashes. Decode and paint precede display acknowledgment.
1115
+ Equal bytes remain visible and are flagged in `source.duplicateHashes`.
1116
+
1117
+ Image acts carry `source.imageSetDigest`, SHA-256 of UTF-8
1118
+ `JSON.stringify(images.map(({role, name, sha256}) => ({role, name, sha256})))`.
1119
+ Exact key order, array order and Unicode strings are preserved. Paths remain in
1120
+ the source identity and are excluded from that ordered-list digest. The
1121
+ image-only source hash additionally binds the frozen record. Optional image notes
1122
+ use exact member names and human words. Every source identity and digest is
1123
+ server-derived. Consumer fetch, human authority, drafts, nonce and cursor rules
1124
+ apply through the existing cycle. [Public shapes and refusals](STABILITY.md#image-set-verdict-extension).
1125
+
1099
1126
  ### C4 schema and stored-state compatibility
1100
1127
 
1101
1128
  API@1 and unsupported requests refuse `JOB_REQUEST_INVALID` with `JOB_API_SCHEMA_MISMATCH`, HTTP 400, the current API@2 response schema and unchanged generation. The CLI checks response schema before consuming its value. Consumer writers must also check act@2. JobData and host descriptors carry explicit `apiSchema` and `actSchema` markers. Missing or old stored markers refuse `JOB_STORED_SCHEMA_MISMATCH` before credentials, status or replay. Authenticated active-listener reuse compares declared hook IDs, API/act schemas and the actual enumerator version. A stopped listener can be explicitly restarted for the same job with new valid hook IDs. Old retained documents and approvals remain under their original schemas and are never migrated or relabelled. Legacy one-shot contracts retain their documented boundaries.
@@ -1107,4 +1134,4 @@ The manifest and complete retained image rows enter the composite source hash. L
1107
1134
  - **Sibling binding ownership.** `JOB_CONSUMER_AUTH_MODE` is `'writer-owned-sibling-fetch-capability'` (`JobConsumerGrant` with `jobId`, `operation` set to `'fetch-act'`, `actKinds` and `lifetime` set to `'until-explicit-close'`). [Create #184](https://github.com/rig-c/create/issues/184) owns creation and path of a private writer-owned sibling binding outside `project.json` whose versioned record carries only the semantic job locator (Create's production reader/writer readback integration remains pending [Create #184](https://github.com/rig-c/create/issues/184)). The binding is never tracked in version control, never present in unstaged project output and never shipped in templates, public examples or fixtures.
1108
1135
  - **Agent isolation and capability lifecycle.** The consumer writer reads its own sibling binding directly. Agents never construct, parse or carry Review session, picks, verdict, applied-record or sibling-binding files. Actual separate-UID isolation remains required for Review's distinct state unreadability test (`JOB_AGENT_ISOLATION_HOLE`), and no same-user forger-resistance claim is made. The random per-job bearer capability grants finalized act fetch (`fetch-act`) only, via exact loopback routes and `Authorization`. Neither `next` nor `status` returns it, and human metadata alone never authenticates a fetch. The capability dies at explicit `close`, old project history cannot restore it, each new job incarnation receives a new grant, invalid grants refuse with `JOB_CAPABILITY_REQUIRED` or `JOB_AUTHORITY_REFUSED` and closed-job fetches refuse with `JOB_CLOSED`. No self-service grant API exists.
1109
1136
  - **Consumer deduplication and future in-process mesh consumption.** Consumer writers deduplicate `actId` before current-source checks, then validate each new source and atomically commit the writer result plus replay identity. Replaying an applied `actId` returns the existing record, while a new stale act refuses before mutation. Verdict, signoff and stage transition remain three separate consumer writes. Once `mesh-edit` is jointly frozen with [Parts #1159](https://github.com/rig-c/parts/issues/1159), Create will fetch a finalized mesh act and pass its typed value in process to Parts' public exported API owned by [Parts #1159](https://github.com/rig-c/parts/issues/1159), with Parts reading neither Review nor Create storage and taking no Create-project argument, while standalone `--delta` remains legacy outside this cycle.
1110
- - **Error codes.** `JOB_ERROR_CODES` enumerates the closed refusal set (`JOB_REQUEST_INVALID`, `JOB_BODY_LIMIT`, `JOB_LOOPBACK_REQUIRED`, `JOB_SAME_ORIGIN_REQUIRED`, `JOB_CAPABILITY_REQUIRED`, `JOB_AUTHORITY_REFUSED`, `JOB_UNKNOWN`, `JOB_CLOSED`, `JOB_GENERATION_STALE`, `JOB_IDEMPOTENCY_CONFLICT`, `JOB_FREEZE_REQUIRED`, `JOB_RECORD_INCOMPLETE`, `JOB_RECORD_MOVED`, `JOB_SOURCE_MISMATCH`, `JOB_SOURCE_UNRETAINABLE`, `JOB_ROOT_REPLACED`, `JOB_PUBLICATION_UNKNOWN`, `JOB_ASK_INVALID`, `JOB_ASK_SUPERSEDED`, `JOB_ACT_UNKNOWN`, `JOB_ACT_INVALID`, `JOB_ACT_KIND_DISABLED`, `JOB_ACT_SOURCE_STALE`, `JOB_DISPLAY_MISMATCH`, `JOB_CURSOR_INVALID`, `JOB_STORAGE_FAILED`, `JOB_AGENT_ISOLATION_HOLE`), each returning bounded safe detail with no arbitrary worker text or private paths.
1137
+ - **Error codes.** `JOB_ERROR_CODES` enumerates the closed refusal set (`JOB_REQUEST_INVALID`, `JOB_BODY_LIMIT`, `JOB_LOOPBACK_REQUIRED`, `JOB_SAME_ORIGIN_REQUIRED`, `JOB_CAPABILITY_REQUIRED`, `JOB_AUTHORITY_REFUSED`, `JOB_UNKNOWN`, `JOB_CLOSED`, `JOB_GENERATION_STALE`, `JOB_IDEMPOTENCY_CONFLICT`, `JOB_FREEZE_REQUIRED`, `JOB_RECORD_INCOMPLETE`, `JOB_RECORD_MOVED`, `JOB_SOURCE_MISMATCH`, `JOB_SOURCE_UNRETAINABLE`, `JOB_ROOT_REPLACED`, `JOB_PUBLICATION_UNKNOWN`, `JOB_IMAGE_SET_UNSUPPORTED`, `JOB_IMAGE_SET_INVALID`, `JOB_IMAGE_SET_DUPLICATE_NAME`, `JOB_IMAGE_SET_DUPLICATE_PATH`, `JOB_IMAGE_SET_ROLE_INVALID`, `JOB_IMAGE_SET_PATH_REFUSED`, `JOB_ASK_INVALID`, `JOB_ASK_SUPERSEDED`, `JOB_ACT_UNKNOWN`, `JOB_ACT_INVALID`, `JOB_ACT_KIND_DISABLED`, `JOB_ACT_SOURCE_STALE`, `JOB_DISPLAY_MISMATCH`, `JOB_CURSOR_INVALID`, `JOB_STORAGE_FAILED`, `JOB_AGENT_ISOLATION_HOLE`), each returning bounded safe detail with no arbitrary worker text or private paths.
package/docs/STABILITY.md CHANGED
@@ -60,6 +60,7 @@ interface JobPublishedContext {
60
60
  readonly selector: JobSelector | null;
61
61
  readonly plan: JobPlanIdentity | null;
62
62
  readonly parts: JobPartsIdentity | null;
63
+ readonly imageSet?: JobImageSetInput;
63
64
  readonly subjects: readonly JobSubject[];
64
65
  readonly partIds: readonly string[];
65
66
  readonly files: readonly JobFileIdentity[];
@@ -239,6 +240,90 @@ Consumer-owned adoption remains external and pending in
239
240
  [embedded consumer example](WORKFLOWS.md#embedded-semantic-jobs) for trusted-hook
240
241
  ownership and the ordinary semantic cycle.
241
242
 
243
+ ## Image-set verdict extension
244
+
245
+ Review #522 adds an HQ-approved image branch to `rig-review/job-api@2` and
246
+ `rig-review/act@2`. The original model source and value keep their exact fields
247
+ and serialization. Model acts carry no image discriminant, digest, duplicate
248
+ array or added nulls. The image branch carries `source.subject = "image-set"`
249
+ and omits `model` and `selector` entirely. Its ask and value use
250
+ `{kind: "review-verdict", stage: "image-review"}` and the existing human UI
251
+ verdict lifecycle. HQ exact-head dependency sign-off is required before landing.
252
+ The current `src/job-contract.ts` candidate SHA-256 is
253
+ `e7d2be222af6be6cc4718a57fbfef6de606a0c6268efc7b32b15e1bd75bcce65`.
254
+ The Tower records the final signed head separately.
255
+
256
+ Agents discover support through `session next <job-url> --wait-ms 0`, reading
257
+ `response.value.capabilities.imageSetVerdict === true`. API callers send the
258
+ existing `next` request with their agent bearer capability. The authenticated
259
+ hub `/hub/host` and owner `/hub/api/jobs` metadata also advertise that capability.
260
+ `JOB_CAPABILITIES` is the current immutable capability object.
261
+ `assertJobImageSetCapability(response.value.capabilities)` throws
262
+ `JOB_IMAGE_SET_UNSUPPORTED` when support is absent. Call it before asking.
263
+ An older installed parser refuses `image-review` with `JOB_ASK_INVALID`.
264
+ The preserved parser control uses its exact original function body and shared
265
+ current validators. It does not run an older server.
266
+
267
+ The trusted `JobPublicationReader` may return optional `imageSet` in its
268
+ `JobPublishedContext`. The existing callback runs only when publication supplies
269
+ a non-null frozen record. A Create root still requires its producer-owned reader.
270
+ Review defines this return value, with no new producer record format or Parts
271
+ adoption adapter. `result.selector` is null for image publication.
272
+
273
+ ```ts
274
+ interface JobImageSetInput {
275
+ readonly purpose: 'plate-adoption';
276
+ readonly images: readonly {
277
+ readonly role: 'source' | 'candidate' | 'reference';
278
+ readonly name: string;
279
+ readonly path: string;
280
+ readonly sha256?: string;
281
+ }[];
282
+ }
283
+ function assertJobImageSetCapability(capabilities: unknown): void;
284
+ ```
285
+
286
+ The ordered set has 2–8 rows, exactly one `source`, at least one `candidate`, and
287
+ optional `reference` rows. Names and paths must each be unique. Names use the
288
+ existing nonempty 128-unit text bound. Paths are literal job-root-relative paths
289
+ with the existing 4096-unit bound and regular-file, containment and symlink
290
+ checks. Files retain the existing 64 MiB per-file and 256 MiB total source limits.
291
+ Every supplied hash must match disk bytes. The daemon hashes retained inputs,
292
+ seals them, derives ask bindings from checked disk bytes and rechecks at finalize.
293
+ Equal hashes are allowed and produce ordered `source.duplicateHashes` groups of
294
+ `{names: string[], sha256: string}`. Groups appear by first hash occurrence and
295
+ names retain producer order. An empty group array is explicit on image sources.
296
+
297
+ `source.imageSet` contains required derived hashes. `source.imageSetDigest` is
298
+ SHA-256 over the UTF-8 bytes of the following exact JSON serialization.
299
+
300
+ ```ts
301
+ JSON.stringify(images.map(({role, name, sha256}) => ({role, name, sha256})))
302
+ ```
303
+
304
+ Property order is `role`, `name`, `sha256`. Array order and strings remain exact,
305
+ with no whitespace insertion or Unicode normalization. Paths are excluded from
306
+ this digest. The separate source hash binds the package source hash, frozen
307
+ record and complete image set including paths under `rig-review-job-image-set/1`.
308
+ Consumers can hash their designated bytes and reconstruct the ordered digest
309
+ without parsing Review's private files.
310
+
311
+ The image value is `{stage: "image-review", verdict, words, imageNotes?}`.
312
+ Optional notes are `{name, words}` rows with unique member names and exact human
313
+ text. Unknown fields, duplicate names and nonmember notes refuse. The UI omits
314
+ empty optional notes and preserves whitespace-only notes. Source hashes, digests,
315
+ duplicate groups and authority are daemon-owned and rejected in UI values.
316
+ All images decode and reach the existing painted lifecycle boundary before
317
+ `ackDisplayed` supplies a nonce and enables submission. Retained routes serve only
318
+ sealed indexed image rows. Drafts, visibility messages, replay and writer-owned
319
+ `fetch-act` keep their existing publication/source and capability bindings.
320
+
321
+ New named refusals are `JOB_IMAGE_SET_UNSUPPORTED`, `JOB_IMAGE_SET_INVALID`,
322
+ `JOB_IMAGE_SET_DUPLICATE_NAME`, `JOB_IMAGE_SET_DUPLICATE_PATH`,
323
+ `JOB_IMAGE_SET_ROLE_INVALID` and `JOB_IMAGE_SET_PATH_REFUSED`.
324
+ Disk hash mismatches use `JOB_SOURCE_MISMATCH`. A verdict ask with neither a valid
325
+ model binding nor a valid image-set binding uses `JOB_ASK_INVALID`.
326
+
242
327
  ## Named export inventory
243
328
 
244
329
  The exact runtime exports are listed below. Constants preserve their literal
@@ -246,6 +331,8 @@ values from the frozen semantic contract.
246
331
 
247
332
  - `startJobHost`
248
333
  - `startJobHub`
334
+ - `assertJobImageSetCapability`
335
+ - `JOB_CAPABILITIES`
249
336
  - `JOB_API_SCHEMA`
250
337
  - `JOB_ACT_SCHEMA`
251
338
  - `JOB_PARTS_ENUMERATOR_RANGE`
@@ -291,6 +378,13 @@ without aliases or copied wire shapes.
291
378
  - `JobPartsEnumerator`
292
379
  - `JobSelector`
293
380
  - `JobSourceBinding`
381
+ - `JobModelSourceBinding`
382
+ - `JobImageSourceBinding`
383
+ - `JobImageSetInput`
384
+ - `JobImageSet`
385
+ - `JobCapabilities`
386
+ - `JobModelReviewValue`
387
+ - `JobImageReviewValue`
294
388
  - `JobReviewerBinding`
295
389
  - `JobHumanAuthority`
296
390
  - `JobVerdict`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rig-review",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "type": "module",
5
5
  "description": "Local human rig inspection and structured feedback export",
6
6
  "license": "MIT",
package/src/job-act.ts CHANGED
@@ -8,6 +8,8 @@ import { jobId, jobInteger, jobObject, requestDigest } from './job-api.ts';
8
8
  import { validatePicks } from './interview-picks.ts';
9
9
  import type { JobRetainedSource } from './job-source.ts';
10
10
  import { JobError } from './job-store.ts';
11
+ import { checkedPath, readRegular } from './interview-project.ts';
12
+ import { prepareJobImageSet } from './job-image-set.ts';
11
13
 
12
14
  function words(value: unknown): string {
13
15
  if (typeof value !== 'string' || value.length > 10_000) throw new JobError('JOB_ACT_INVALID');
@@ -25,6 +27,16 @@ function requirePlan(source: JobSourceBinding): void {
25
27
 
26
28
  export function bindJobAsk(subject: JobSubject, retained: JobRetainedSource): JobSourceBinding {
27
29
  const source = structuredClone(retained.source);
30
+ if (source.subject === 'image-set') {
31
+ if (subject.kind !== 'review-verdict' || subject.stage !== 'image-review') throw new JobError('JOB_ASK_INVALID');
32
+ const identity = prepareJobImageSet(source.imageSet,
33
+ path => readRegular(checkedPath(retained.root.path, path), 64 * 1024 * 1024));
34
+ if (requestDigest(identity) !== requestDigest({imageSet: source.imageSet,
35
+ imageSetDigest: source.imageSetDigest, duplicateHashes: source.duplicateHashes})) {
36
+ throw new JobError('JOB_SOURCE_MISMATCH');
37
+ }
38
+ return {...source, ...identity};
39
+ }
28
40
  const declared = retained.subjects.some(candidate => requestDigest(candidate) === requestDigest(subject));
29
41
  switch (subject.kind) {
30
42
  case 'interview-picks': {
@@ -43,7 +55,7 @@ export function bindJobAsk(subject: JobSubject, retained: JobRetainedSource): Jo
43
55
  source.selector.id !== subject.draftId || !retained.partIds.length) throw new JobError('JOB_ASK_INVALID');
44
56
  return source;
45
57
  case 'review-verdict':
46
- if (!source.model || (subject.stage === 'rig-review' ? source.selector?.kind !== 'rig' :
58
+ if (subject.stage === 'image-review' || !source.model || (subject.stage === 'rig-review' ? source.selector?.kind !== 'rig' :
47
59
  source.selector?.kind !== 'post' || !source.direction)) throw new JobError('JOB_ASK_INVALID');
48
60
  return source;
49
61
  case 'signoff':
@@ -87,6 +99,29 @@ export function finalizeJobAct(options: {
87
99
  authority: { actor: 'human' as const, channel: 'review-ui' as const, reviewer: structuredClone(reviewer) },
88
100
  at,
89
101
  };
102
+ if (source.subject === 'image-set') {
103
+ if (submission.kind !== 'review-verdict' || ask.subject.kind !== 'review-verdict' ||
104
+ ask.subject.stage !== 'image-review') throw new JobError('JOB_ACT_INVALID');
105
+ const value = jobObject(submission.value, ['stage', 'verdict', 'words', 'imageNotes']);
106
+ if (value.stage !== 'image-review') throw new JobError('JOB_ACT_INVALID');
107
+ let imageNotes: {name: string; words: string}[] | undefined;
108
+ if (value.imageNotes !== undefined) {
109
+ if (!Array.isArray(value.imageNotes) || value.imageNotes.length > source.imageSet.images.length) {
110
+ throw new JobError('JOB_ACT_INVALID');
111
+ }
112
+ const names = new Set<string>();
113
+ imageNotes = value.imageNotes.map(raw => {
114
+ const note = jobObject(raw, ['name', 'words']);
115
+ if (typeof note.name !== 'string' || names.has(note.name) ||
116
+ !source.imageSet.images.some(image => image.name === note.name)) throw new JobError('JOB_ACT_INVALID');
117
+ names.add(note.name);
118
+ return {name: note.name, words: words(note.words)};
119
+ });
120
+ }
121
+ return {...envelope, kind: 'review-verdict', source, value: {stage: 'image-review',
122
+ verdict: choice(value.verdict, ['pending', 'approved', 'changes-requested'] as const), words: words(value.words),
123
+ ...(imageNotes === undefined ? {} : {imageNotes})}};
124
+ }
90
125
  switch (submission.kind) {
91
126
  case 'interview-picks': {
92
127
  const value = jobObject(submission.value, ['questionId', 'selections', 'note']);
@@ -146,7 +181,7 @@ export function finalizeJobAct(options: {
146
181
  }
147
182
  case 'review-verdict': {
148
183
  const value = jobObject(submission.value, ['stage', 'verdict', 'words']);
149
- if (ask.subject.kind !== 'review-verdict' || value.stage !== ask.subject.stage) throw new JobError('JOB_ACT_INVALID');
184
+ if (ask.subject.kind !== 'review-verdict' || ask.subject.stage === 'image-review' || value.stage !== ask.subject.stage) throw new JobError('JOB_ACT_INVALID');
150
185
  return { ...envelope, kind: 'review-verdict', source: { ...source, model: source.model!,
151
186
  selector: source.selector as Extract<NonNullable<JobSourceBinding['selector']>, { kind: 'rig' | 'post' }> }, value: {
152
187
  stage: ask.subject.stage, verdict: choice(value.verdict, ['pending', 'approved', 'changes-requested'] as const), words: words(value.words),
package/src/job-api.ts CHANGED
@@ -114,7 +114,7 @@ export function parseJobSubject(value: unknown): JobSubject {
114
114
  return { kind: item.kind, draftId: jobId(item.draftId) };
115
115
  case 'review-verdict':
116
116
  jobObject(item, ['kind', 'stage']);
117
- if (item.stage !== 'rig-review' && item.stage !== 'direction-review') throw new JobError('JOB_ASK_INVALID');
117
+ if (item.stage !== 'rig-review' && item.stage !== 'direction-review' && item.stage !== 'image-review') throw new JobError('JOB_ASK_INVALID');
118
118
  return { kind: item.kind, stage: item.stage };
119
119
  case 'signoff':
120
120
  jobObject(item, ['kind', 'stage']);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Review #484 contract freeze candidate for Lane B, Create #182 and Parts #1159.
2
+ * Review #484 contract for Lane B, Create #182 and Parts #1159, with the HQ-approved #522 image branch.
3
3
  * People submit through the UI. Agents use publish, ask, next and close.
4
4
  * Public values contain semantic data and original source provenance. Private
5
5
  * session, picks, verdict, applied-record and snapshot formats stay behind ports.
@@ -121,11 +121,16 @@ export type JobSelector =
121
121
  | { readonly kind: 'rig'; readonly version: number }
122
122
  | { readonly kind: 'post'; readonly version: number; readonly rigVersion: number };
123
123
 
124
- /** Nulls are required explicit values. The daemon derives the binding from
124
+ /** The original model branch keeps required explicit nulls. The image branch
125
+ * omits model and selector entirely. The daemon derives the binding from
125
126
  * validated retained bytes and the actual displayed publication. Clients never
126
127
  * provide trusted source hashes or transfer old approval onto a new binding.
127
128
  */
128
- export interface JobSourceBinding {
129
+ export interface JobModelSourceBinding {
130
+ readonly subject?: never;
131
+ readonly imageSet?: never;
132
+ readonly imageSetDigest?: never;
133
+ readonly duplicateHashes?: never;
129
134
  readonly sourceHash: JobSha256;
130
135
  readonly projectHash: JobSha256 | null;
131
136
  readonly package: { readonly id: string; readonly revision: string };
@@ -138,6 +143,48 @@ export interface JobSourceBinding {
138
143
  readonly parts: JobPartsIdentity | null;
139
144
  }
140
145
 
146
+ /** Trusted-reader input. Hashes are optional claims, checked against retained bytes. */
147
+ export interface JobImageSetInput {
148
+ readonly purpose: 'plate-adoption';
149
+ readonly images: readonly {
150
+ readonly role: 'source' | 'candidate' | 'reference';
151
+ readonly name: string;
152
+ readonly path: string;
153
+ readonly sha256?: JobSha256;
154
+ }[];
155
+ }
156
+
157
+ export interface JobImageSet {
158
+ readonly purpose: 'plate-adoption';
159
+ readonly images: readonly (Omit<JobImageSetInput['images'][number], 'sha256'> & {readonly sha256: JobSha256})[];
160
+ }
161
+
162
+ export interface JobImageSourceBinding extends Omit<JobModelSourceBinding,
163
+ 'subject' | 'model' | 'selector' | 'imageSet' | 'imageSetDigest' | 'duplicateHashes'> {
164
+ readonly subject: 'image-set';
165
+ readonly model?: never;
166
+ readonly selector?: never;
167
+ readonly imageSet: JobImageSet;
168
+ readonly imageSetDigest: JobSha256;
169
+ readonly duplicateHashes: readonly {readonly names: readonly string[]; readonly sha256: JobSha256}[];
170
+ }
171
+
172
+ export type JobSourceBinding = JobModelSourceBinding | JobImageSourceBinding;
173
+ export interface JobCapabilities { readonly imageSetVerdict: true }
174
+ export const JOB_CAPABILITIES: JobCapabilities = Object.freeze({imageSetVerdict: true});
175
+
176
+ export interface JobModelReviewValue {
177
+ readonly stage: 'rig-review' | 'direction-review';
178
+ readonly verdict: JobVerdict;
179
+ readonly words: string;
180
+ }
181
+ export interface JobImageReviewValue {
182
+ readonly stage: 'image-review';
183
+ readonly verdict: JobVerdict;
184
+ readonly words: string;
185
+ readonly imageNotes?: readonly {readonly name: string; readonly words: string}[];
186
+ }
187
+
141
188
  /** Trusted host bootstrap declares who the window was opened for. The UI cannot
142
189
  * type or override this binding. It is not keyboard-user authentication. Create
143
190
  * maps role to its existing by authority and preserves the declared identity.
@@ -155,7 +202,7 @@ export interface JobHumanAuthority {
155
202
 
156
203
  export type JobVerdict = 'pending' | 'approved' | 'changes-requested';
157
204
  export type JobPartOutcome = 'pending' | 'clean' | 'flagged';
158
- export type JobReviewStage = 'rig-review' | 'direction-review';
205
+ export type JobReviewStage = 'rig-review' | 'direction-review' | 'image-review';
159
206
 
160
207
  export interface JobActValues {
161
208
  readonly 'interview-picks': {
@@ -189,11 +236,7 @@ export interface JobActValues {
189
236
  }[];
190
237
  readonly words: string;
191
238
  };
192
- readonly 'review-verdict': {
193
- readonly stage: JobReviewStage;
194
- readonly verdict: JobVerdict;
195
- readonly words: string;
196
- };
239
+ readonly 'review-verdict': JobModelReviewValue | JobImageReviewValue;
197
240
  readonly signoff: {
198
241
  /** An explicitly declared Create stage. Validation belongs to its writer. */
199
242
  readonly stage: string;
@@ -218,20 +261,20 @@ export type JobUIActValues = Omit<JobActValues, 'checkpoint'> & {
218
261
  };
219
262
 
220
263
  export interface JobActSources {
221
- readonly 'interview-picks': JobSourceBinding & {
264
+ readonly 'interview-picks': JobModelSourceBinding & {
222
265
  readonly optionSet: NonNullable<JobSourceBinding['optionSet']>;
223
266
  };
224
- readonly checkpoint: JobSourceBinding & { readonly plan: JobPlanIdentity };
225
- readonly 'parts-verdict': JobSourceBinding & {
267
+ readonly checkpoint: JobModelSourceBinding & { readonly plan: JobPlanIdentity };
268
+ readonly 'parts-verdict': JobModelSourceBinding & {
226
269
  readonly projectHash: JobSha256;
227
270
  readonly selector: Extract<JobSelector, { kind: 'draft' }>;
228
271
  readonly parts: JobPartsIdentity;
229
272
  };
230
- readonly 'review-verdict': JobSourceBinding & {
273
+ readonly 'review-verdict': JobImageSourceBinding | (JobModelSourceBinding & {
231
274
  readonly selector: Extract<JobSelector, { kind: 'rig' | 'post' }>;
232
275
  readonly model: JobFileIdentity;
233
- };
234
- readonly signoff: JobSourceBinding;
276
+ });
277
+ readonly signoff: JobModelSourceBinding;
235
278
  }
236
279
 
237
280
  /** Immutable, finalized explicit UI submissions only. All human text and ordered
@@ -251,9 +294,10 @@ export type JobAct = {
251
294
  readonly kind: Kind;
252
295
  readonly authority: JobHumanAuthority;
253
296
  readonly at: string;
254
- readonly source: JobActSources[Kind];
255
- readonly value: JobActValues[Kind];
256
- };
297
+ } & (Kind extends 'review-verdict' ? (
298
+ | {readonly source: Exclude<JobActSources['review-verdict'], JobImageSourceBinding>; readonly value: JobModelReviewValue}
299
+ | {readonly source: JobImageSourceBinding; readonly value: JobImageReviewValue}
300
+ ) : {readonly source: JobActSources[Kind]; readonly value: JobActValues[Kind]});
257
301
  }[JobEnabledActKind];
258
302
 
259
303
  export type JobSubject =
@@ -377,6 +421,12 @@ export const JOB_ERROR_CODES = [
377
421
  'JOB_SOURCE_UNRETAINABLE',
378
422
  'JOB_ROOT_REPLACED',
379
423
  'JOB_PUBLICATION_UNKNOWN',
424
+ 'JOB_IMAGE_SET_UNSUPPORTED',
425
+ 'JOB_IMAGE_SET_INVALID',
426
+ 'JOB_IMAGE_SET_DUPLICATE_NAME',
427
+ 'JOB_IMAGE_SET_DUPLICATE_PATH',
428
+ 'JOB_IMAGE_SET_ROLE_INVALID',
429
+ 'JOB_IMAGE_SET_PATH_REFUSED',
380
430
  'JOB_ASK_INVALID',
381
431
  'JOB_ASK_SUPERSEDED',
382
432
  'JOB_ACT_UNKNOWN',
@@ -413,6 +463,7 @@ export type JobEvent = {
413
463
  );
414
464
 
415
465
  export interface JobNextValue {
466
+ readonly capabilities?: JobCapabilities;
416
467
  readonly events: readonly JobEvent[];
417
468
  readonly cursor: JobCursor | null;
418
469
  readonly status: 'events' | 'timeout' | 'closed';
package/src/job-front.ts CHANGED
@@ -259,6 +259,12 @@ function retainedPublicationRoutes(session: JobSession) {
259
259
  if (!image) return failure('JOB_SOURCE_UNRETAINABLE', 404);
260
260
  return await sealedFile(image.ref.path);
261
261
  }
262
+ const imageSetImage = /^api\/image-set\/(0|[1-9]\d*)$/.exec(path);
263
+ if (imageSetImage && retained.source.subject === 'image-set') {
264
+ const image = retained.source.imageSet.images[Number(imageSetImage[1])];
265
+ if (!image) return failure('JOB_SOURCE_UNRETAINABLE', 404);
266
+ return await sealedFile(image.path);
267
+ }
262
268
  if (path === 'api/stage-parts') {
263
269
  if (!parts) return failure('JOB_SOURCE_UNRETAINABLE', 409);
264
270
  return json({...partsViewJson(parts, {verdict: null, stale: null}), sourceHash: retained.source.sourceHash,
package/src/job-host.ts CHANGED
@@ -7,6 +7,7 @@ export type {JobSessionOptions, JobSession} from './job-session.ts';
7
7
  export type {JobWorkerOptions} from './job-worker.ts';
8
8
  export type {JobPublicationReader, JobPublishedContext} from './job-source.ts';
9
9
  export {
10
+ JOB_CAPABILITIES,
10
11
  JOB_API_SCHEMA,
11
12
  JOB_ACT_SCHEMA,
12
13
  JOB_PARTS_ENUMERATOR_RANGE,
@@ -70,3 +71,6 @@ export type {
70
71
  JobHostPorts,
71
72
  JobConsumerGrant,
72
73
  } from './job-contract.ts';
74
+
75
+ export {assertJobImageSetCapability} from './job-image-set.ts';
76
+ export type {JobCapabilities, JobImageSetInput, JobImageSet, JobImageSourceBinding, JobModelSourceBinding, JobModelReviewValue, JobImageReviewValue} from './job-contract.ts';
package/src/job-hub.ts CHANGED
@@ -4,7 +4,7 @@ import {mkdir, unlink} from 'node:fs/promises';
4
4
  import {join} from 'node:path';
5
5
  import {buildWeb} from './build.ts';
6
6
  import {jobBody, jobObject, sameCapability} from './job-api.ts';
7
- import {JOB_API_SCHEMA, JOB_ACT_SCHEMA, type JobHostPorts, type JobReviewerBinding} from './job-contract.ts';
7
+ import {JOB_API_SCHEMA, JOB_ACT_SCHEMA, JOB_CAPABILITIES, type JobCapabilities, type JobHostPorts, type JobReviewerBinding} from './job-contract.ts';
8
8
  import {assertJobHostCompatible, createJobRequestContext, installJobWriterBinding, jobHostIdentity,
9
9
  jobWindowResources, type JobHostOptions, type JobHostRecord} from './job-front.ts';
10
10
  import {JobSession} from './job-session.ts';
@@ -43,6 +43,7 @@ export interface JobHubRow {
43
43
  }
44
44
  export interface JobHubList {
45
45
  schema: 'rig-review-job-hub/1';
46
+ capabilities?: JobCapabilities;
46
47
  incarnation: string;
47
48
  limit: number;
48
49
  jobs: JobHubRow[];
@@ -196,8 +197,8 @@ export async function startJobHub(options: JobHubOptions): Promise<JobOwnerHub>
196
197
  entry: `/jobs/${selected[1]}/?hub=${incarnation}`, capability: member.session.hostCredentials().ui}, {headers: responseHeaders});
197
198
  }
198
199
  if (url.pathname === '/hub/host') return Response.json({schema, incarnation, pid: process.pid,
199
- origin, apiSchema: JOB_API_SCHEMA, actSchema: JOB_ACT_SCHEMA}, {headers: responseHeaders});
200
- return Response.json({schema, incarnation, limit: maximumJobs, jobs: [...members.values()].filter(member => member.ready).map(member => {
200
+ origin, apiSchema: JOB_API_SCHEMA, actSchema: JOB_ACT_SCHEMA, capabilities: JOB_CAPABILITIES}, {headers: responseHeaders});
201
+ return Response.json({schema, incarnation, capabilities: JOB_CAPABILITIES, limit: maximumJobs, jobs: [...members.values()].filter(member => member.ready).map(member => {
201
202
  const status = member.session.status();
202
203
  return {jobId: status.jobId, generation: status.generation, status: status.status,
203
204
  publication: status.publication && {publicationId: status.publication.publicationId,
@@ -0,0 +1,50 @@
1
+ import type {JobImageSetInput, JobImageSourceBinding} from './job-contract.ts';
2
+ import {jobHash, jobObject, jobPath, jobSha, jobText} from './job-api.ts';
3
+ import {JobError} from './job-store.ts';
4
+
5
+ /** Check discovery before sending an image ask, including against older hubs. */
6
+ export function assertJobImageSetCapability(capabilities: unknown): void {
7
+ if (!capabilities || typeof capabilities !== 'object' ||
8
+ (capabilities as {imageSetVerdict?: unknown}).imageSetVerdict !== true) {
9
+ throw new JobError('JOB_IMAGE_SET_UNSUPPORTED');
10
+ }
11
+ }
12
+
13
+ /** Hash the actual bytes. Array order and exact Unicode strings are significant. */
14
+ export function prepareJobImageSet(input: JobImageSetInput,
15
+ readBytes: (path: string) => Uint8Array): Pick<JobImageSourceBinding, 'imageSet' | 'imageSetDigest' | 'duplicateHashes'> {
16
+ try { jobObject(input, ['purpose', 'images']); }
17
+ catch { throw new JobError('JOB_IMAGE_SET_INVALID'); }
18
+ if (input.purpose !== 'plate-adoption' || !Array.isArray(input.images) ||
19
+ input.images.length < 2 || input.images.length > 8) throw new JobError('JOB_IMAGE_SET_INVALID');
20
+ const names = new Set<string>(), paths = new Set<string>();
21
+ const hashes = new Map<string, string[]>();
22
+ const images = input.images.map(raw => {
23
+ let name: string;
24
+ try {
25
+ jobObject(raw, ['role', 'name', 'path', 'sha256']);
26
+ name = jobText(raw.name);
27
+ if (raw.sha256 !== undefined) jobSha(raw.sha256);
28
+ } catch { throw new JobError('JOB_IMAGE_SET_INVALID'); }
29
+ if (!['source', 'candidate', 'reference'].includes(raw.role)) throw new JobError('JOB_IMAGE_SET_ROLE_INVALID');
30
+ let path: string;
31
+ try { path = jobPath(raw.path); }
32
+ catch { throw new JobError('JOB_IMAGE_SET_PATH_REFUSED'); }
33
+ if (names.has(name)) throw new JobError('JOB_IMAGE_SET_DUPLICATE_NAME');
34
+ if (paths.has(path)) throw new JobError('JOB_IMAGE_SET_DUPLICATE_PATH');
35
+ names.add(name); paths.add(path);
36
+ let bytes: Uint8Array;
37
+ try { bytes = readBytes(path); }
38
+ catch { throw new JobError('JOB_IMAGE_SET_PATH_REFUSED'); }
39
+ const sha256 = jobHash(bytes);
40
+ if (raw.sha256 !== undefined && raw.sha256 !== sha256) throw new JobError('JOB_SOURCE_MISMATCH');
41
+ const group = hashes.get(sha256) ?? [];
42
+ group.push(name); hashes.set(sha256, group);
43
+ return {role: raw.role, name, path, sha256};
44
+ });
45
+ if (images.filter(image => image.role === 'source').length !== 1 ||
46
+ !images.some(image => image.role === 'candidate')) throw new JobError('JOB_IMAGE_SET_ROLE_INVALID');
47
+ const canonical = images.map(({role, name, sha256}) => ({role, name, sha256}));
48
+ return {imageSet: {purpose: input.purpose, images}, imageSetDigest: jobHash(JSON.stringify(canonical)),
49
+ duplicateHashes: [...hashes].filter(([, names]) => names.length > 1).map(([sha256, names]) => ({names, sha256}))};
50
+ }
@@ -2,7 +2,7 @@ import { randomBytes, randomUUID } from 'node:crypto';
2
2
  import { rm } from 'node:fs/promises';
3
3
  import { isAbsolute, relative, sep } from 'node:path';
4
4
  import {
5
- JOB_API_SCHEMA, JOB_ACT_SCHEMA, JOB_ENABLED_ACT_KINDS, type JobPartsEnumerator, type JobAct, type JobAgentRequest, type JobDisplayAcknowledgment,
5
+ JOB_API_SCHEMA, JOB_ACT_SCHEMA, JOB_CAPABILITIES, JOB_ENABLED_ACT_KINDS, type JobPartsEnumerator, type JobAct, type JobAgentRequest, type JobDisplayAcknowledgment,
6
6
  type JobDisplayPublication, type JobDisplayReceipt, type JobEvent, type JobFetchActRequest,
7
7
  type JobNextValue, type JobPendingAsk, type JobPublication, type JobReviewerBinding, type JobStatus,
8
8
  } from './job-contract.ts';
@@ -329,7 +329,7 @@ export class JobSession {
329
329
  size += bytes;
330
330
  batch.push(event);
331
331
  }
332
- return { events: batch, cursor: batch.at(-1)?.cursor ?? after,
332
+ return { capabilities: JOB_CAPABILITIES, events: batch, cursor: batch.at(-1)?.cursor ?? after,
333
333
  status: batch.length ? 'events' : current.active ? 'timeout' : 'closed' };
334
334
  }
335
335
 
package/src/job-source.ts CHANGED
@@ -5,7 +5,7 @@ import { dirname, isAbsolute, join, posix, relative, resolve, sep } from 'node:p
5
5
  import { PNG } from 'pngjs';
6
6
  import { JOB_PARTS_ENUMERATOR_RANGE } from './job-contract.ts';
7
7
  import type {
8
- JobFileIdentity, JobPartsEnumerator, JobPartsFileReference, JobPartsIdentity, JobPlanIdentity, JobPublishRequest,
8
+ JobFileIdentity, JobImageSetInput, JobModelSourceBinding, JobPartsEnumerator, JobPartsFileReference, JobPartsIdentity, JobPlanIdentity, JobPublishRequest,
9
9
  JobSelector, JobSourceBinding, JobSubject,
10
10
  } from './job-contract.ts';
11
11
  import { checkedPath, readProject, readRegular, type InterviewQuestion } from './interview-project.ts';
@@ -14,6 +14,7 @@ import { openKey } from './open.ts';
14
14
  import { assertReviewUnchanged } from './reference.ts';
15
15
  import { jobHash, jobId, jobPartsEnumeratorVersion, jobObject, jobPath, jobSha, jobText, requestDigest } from './job-api.ts';
16
16
  import { JobError } from './job-store.ts';
17
+ import { prepareJobImageSet } from './job-image-set.ts';
17
18
 
18
19
  export interface JobRootIdentity {
19
20
  readonly path: string;
@@ -27,6 +28,7 @@ export interface JobRootIdentity {
27
28
  * referenced-image enumeration belongs to the public Parts #1163 surface.
28
29
  */
29
30
  export interface JobPublishedContext {
31
+ readonly imageSet?: JobImageSetInput;
30
32
  readonly selector: JobSelector | null;
31
33
  readonly plan: JobPlanIdentity | null;
32
34
  readonly parts: JobPartsIdentity | null;
@@ -330,6 +332,9 @@ export async function prepareJobSource(options: {
330
332
  const seals: JobFileIdentity[] = [];
331
333
  try {
332
334
  await mkdir(snapshotRoot, { recursive: true, mode: 0o700 });
335
+ const imageSet = context.imageSet === undefined ? null : prepareJobImageSet(context.imageSet,
336
+ path => sourceBytes(root.path, path));
337
+ for (const image of imageSet?.imageSet.images ?? []) add(image.path, image.sha256);
333
338
  const parts = await prepareParts(root.path, snapshotRoot, context.parts, options.partsEnumerator);
334
339
  for (const [path, bytes] of parts.bytes) add(path, jobHash(bytes));
335
340
  if (wanted.size > maxSourceFiles) throw new JobError('JOB_SOURCE_UNRETAINABLE', 'PARTS_REFERENCE_LIMIT');
@@ -366,7 +371,7 @@ export async function prepareJobSource(options: {
366
371
  const originalIdentity = (file: { path: string; sha256: string } | null): JobFileIdentity | null => file && ({
367
372
  path: rootRelative(root.path, resolve(review.root, file.path)), sha256: file.sha256,
368
373
  });
369
- const source: JobSourceBinding = {
374
+ const modelSource: JobModelSourceBinding = {
370
375
  sourceHash: project || context.plan || context.parts ? jobHash(JSON.stringify({
371
376
  schema: 'rig-review-job-source/2', packageSourceHash: review.sourceHash,
372
377
  record, selector: context.selector, plan: context.plan, parts: parts.identity, files: seals,
@@ -378,6 +383,14 @@ export async function prepareJobSource(options: {
378
383
  direction: originalIdentity(review.direction?.file ?? null),
379
384
  optionSet: null, appliedResult: null, plan: context.plan, parts: parts.identity,
380
385
  };
386
+ let source: JobSourceBinding = modelSource;
387
+ if (imageSet) {
388
+ if (modelSource.model || modelSource.selector) throw new JobError('JOB_IMAGE_SET_INVALID');
389
+ const {model, selector, ...common} = modelSource;
390
+ source = {...common, subject: 'image-set', ...imageSet,
391
+ sourceHash: jobHash(JSON.stringify({schema: 'rig-review-job-image-set/1',
392
+ packageSourceHash: modelSource.sourceHash, record, imageSet: imageSet.imageSet}))};
393
+ }
381
394
  const boundReview = { ...review, sourceHash: source.sourceHash };
382
395
  const prepared: JobRetainedSource = {
383
396
  root, record, seals, snapshotRoot,
@@ -386,7 +399,7 @@ export async function prepareJobSource(options: {
386
399
  instanceKey: openKey({ mode: 'single', p: boundReview, inputs: { input: review.manifestPath },
387
400
  contentHash: source.sourceHash, selection: null }, options.fingerprint),
388
401
  label: review.manifest.title,
389
- visual: review.manifest.model || review.manifest.references.length ? { status: 'available' } :
402
+ visual: imageSet || review.manifest.model || review.manifest.references.length ? { status: 'available' } :
390
403
  { status: 'unavailable', code: 'MODEL_UNAVAILABLE' },
391
404
  subjects: context.subjects,
392
405
  questions: (project?.questions ?? []).map(question => {
package/web/catalog-en.ts CHANGED
@@ -3345,6 +3345,23 @@ export const enCatalog: Readonly<Record<string, string>> = {
3345
3345
  "JOB_ACT_SOURCE_STALE": "JOB_ACT_SOURCE_STALE",
3346
3346
  "JOB_ACT_UNKNOWN": "JOB_ACT_UNKNOWN",
3347
3347
  "JOB_AGENT_ISOLATION_HOLE": "JOB_AGENT_ISOLATION_HOLE",
3348
+ "job.imageSetTitle": "Image comparison",
3349
+ "job.imageSetDigest": "Image set SHA-256",
3350
+ "job.imageNote": "Optional image note",
3351
+ "job.imageRole.source": "Source",
3352
+ "job.imageRole.candidate": "Candidate",
3353
+ "job.imageRole.reference": "Reference",
3354
+ "job.identicalImages": "Identical bytes appear elsewhere in this set.",
3355
+ "image-set": "image-set",
3356
+ "plate-adoption": "plate-adoption",
3357
+ "image-review": "image-review",
3358
+ "rig-review-job-image-set/1": "rig-review-job-image-set/1",
3359
+ "JOB_IMAGE_SET_UNSUPPORTED": "JOB_IMAGE_SET_UNSUPPORTED",
3360
+ "JOB_IMAGE_SET_INVALID": "JOB_IMAGE_SET_INVALID",
3361
+ "JOB_IMAGE_SET_DUPLICATE_NAME": "JOB_IMAGE_SET_DUPLICATE_NAME",
3362
+ "JOB_IMAGE_SET_DUPLICATE_PATH": "JOB_IMAGE_SET_DUPLICATE_PATH",
3363
+ "JOB_IMAGE_SET_ROLE_INVALID": "JOB_IMAGE_SET_ROLE_INVALID",
3364
+ "JOB_IMAGE_SET_PATH_REFUSED": "JOB_IMAGE_SET_PATH_REFUSED",
3348
3365
  "JOB_ASK_INVALID": "JOB_ASK_INVALID",
3349
3366
  "JOB_ASK_SUPERSEDED": "JOB_ASK_SUPERSEDED",
3350
3367
  "JOB_AUTHORITY_REFUSED": "JOB_AUTHORITY_REFUSED",
package/web/catalog-ko.ts CHANGED
@@ -3345,6 +3345,23 @@ export const koCatalog: Readonly<Record<string, string>> = {
3345
3345
  "JOB_ACT_SOURCE_STALE": "JOB_ACT_SOURCE_STALE",
3346
3346
  "JOB_ACT_UNKNOWN": "JOB_ACT_UNKNOWN",
3347
3347
  "JOB_AGENT_ISOLATION_HOLE": "JOB_AGENT_ISOLATION_HOLE",
3348
+ "job.imageSetTitle": "이미지 비교",
3349
+ "job.imageSetDigest": "이미지 세트 SHA-256",
3350
+ "job.imageNote": "이미지 메모 (선택)",
3351
+ "job.imageRole.source": "원본",
3352
+ "job.imageRole.candidate": "후보",
3353
+ "job.imageRole.reference": "참조",
3354
+ "job.identicalImages": "이 세트에 같은 바이트의 이미지가 있어요.",
3355
+ "image-set": "image-set",
3356
+ "plate-adoption": "plate-adoption",
3357
+ "image-review": "image-review",
3358
+ "rig-review-job-image-set/1": "rig-review-job-image-set/1",
3359
+ "JOB_IMAGE_SET_UNSUPPORTED": "JOB_IMAGE_SET_UNSUPPORTED",
3360
+ "JOB_IMAGE_SET_INVALID": "JOB_IMAGE_SET_INVALID",
3361
+ "JOB_IMAGE_SET_DUPLICATE_NAME": "JOB_IMAGE_SET_DUPLICATE_NAME",
3362
+ "JOB_IMAGE_SET_DUPLICATE_PATH": "JOB_IMAGE_SET_DUPLICATE_PATH",
3363
+ "JOB_IMAGE_SET_ROLE_INVALID": "JOB_IMAGE_SET_ROLE_INVALID",
3364
+ "JOB_IMAGE_SET_PATH_REFUSED": "JOB_IMAGE_SET_PATH_REFUSED",
3348
3365
  "JOB_ASK_INVALID": "JOB_ASK_INVALID",
3349
3366
  "JOB_ASK_SUPERSEDED": "JOB_ASK_SUPERSEDED",
3350
3367
  "JOB_AUTHORITY_REFUSED": "JOB_AUTHORITY_REFUSED",
@@ -500,6 +500,7 @@ import type { ModelAssets, RigPlayer } from '@rig-c/play';
500
500
  import type { PartInspection } from './part-selection.ts';
501
501
  import type { Checkpoint, ReviewManifest, ReviewedSource } from '../src/manifest.ts';
502
502
  import type { DirectionInspection } from '../src/direction-inspection.ts';
503
+ import type { FeedbackCatalog } from '../src/feedback-validation.ts';
503
504
  import type { InterviewQuestion } from '../src/interview-project.ts';
504
505
  export interface JobInspectionMetadata {
505
506
  manifest: ReviewManifest;
@@ -520,9 +521,7 @@ export interface JobInspectionMetadata {
520
521
  preRig?: boolean;
521
522
  playback: boolean;
522
523
  };
523
- feedbackCatalog: {
524
- slots: string[];
525
- };
524
+ feedbackCatalog: Pick<FeedbackCatalog, 'slots'>;
526
525
  }
527
526
  type JobInterview = {
528
527
  questions: (Omit<InterviewQuestion, 'images'> & {
@@ -605,6 +604,7 @@ export interface JobPreparedInspection {
605
604
  parts: JobPartsInventory | null;
606
605
  partImages: Map<string, HTMLImageElement>;
607
606
  interviewImages: Map<string, HTMLImageElement>;
607
+ imageSetImages?: readonly HTMLImageElement[];
608
608
  references: JobReferenceView[];
609
609
  assets: ModelAssets | null;
610
610
  player: RigPlayer | null;
@@ -729,6 +729,22 @@ export async function prepareJobInspection(display: JobDisplayPublication, signa
729
729
  const partImages = new Map<string, HTMLImageElement>();
730
730
  const interviewImages = new Map<string, HTMLImageElement>();
731
731
  const preload: Promise<void>[] = [];
732
+ const imageSetImages: HTMLImageElement[] = [];
733
+ const source = display.publication.source;
734
+ if (source.subject === 'image-set') {
735
+ if (metadata.sourceHash !== source.sourceHash || metadata.manifest.model)
736
+ throw new Error('JOB_DISPLAY_MISMATCH');
737
+ const canonical = source.imageSet.images.map(({role, name, sha256}) => ({role, name, sha256}));
738
+ if (source.imageSet.images.length < 2 || source.imageSet.images.length > 8 ||
739
+ await jobDigest(new TextEncoder().encode(JSON.stringify(canonical))) !== source.imageSetDigest)
740
+ throw new Error('JOB_SOURCE_MISMATCH');
741
+ for (const [index, entry] of source.imageSet.images.entries()) {
742
+ preload.push(image(routes.api('image-set/' + index), entry.sha256).then(element => {
743
+ element.alt = entry.name;
744
+ imageSetImages[index] = element;
745
+ }));
746
+ }
747
+ }
732
748
  for (const reference of metadata.manifest.references) {
733
749
  preload.push((async () => {
734
750
  if (reference.type === 'image') {
@@ -862,7 +878,7 @@ export async function prepareJobInspection(display: JobDisplayPublication, signa
862
878
  resolvePage: (name, url) => routes.assertAsset(new URL(name, url).href) });
863
879
  const loadedAssets = assets;
864
880
  const parts = await import('./part-selection.ts');
865
- const catalog = await parts.loadPartModel(modelUrl, modelHash, metadata.feedbackCatalog.slots, checkedFetch);
881
+ const catalog = await parts.loadPartModel(modelUrl, modelHash, metadata.feedbackCatalog.slots ?? [], checkedFetch);
866
882
  resetToSetup = () => {
867
883
  player?.dispose();
868
884
  player = new runtime.RigPlayer(rigRoot, loadedAssets);
@@ -873,7 +889,7 @@ export async function prepareJobInspection(display: JobDisplayPublication, signa
873
889
  };
874
890
  resetToSetup();
875
891
  }
876
- if (!player && !references.length && !partImages.size)
892
+ if (!player && !references.length && !partImages.size && !imageSetImages.length)
877
893
  throw new Error('JOB_VISUAL_UNAVAILABLE');
878
894
  if (signal.aborted)
879
895
  throw new Error('JOB_PRELOAD_CANCELLED');
@@ -881,7 +897,7 @@ export async function prepareJobInspection(display: JobDisplayPublication, signa
881
897
  const order = [metadata.sourcePainting?.id, ...metadata.manifest.references.map(reference => reference.id)];
882
898
  references.sort((a, b) => order.indexOf(a.id) - order.indexOf(b.id));
883
899
  return {
884
- display, metadata, interview, parts, partImages, interviewImages, references, assets, rigRoot,
900
+ display, metadata, interview, parts, partImages, interviewImages, imageSetImages, references, assets, rigRoot,
885
901
  get player() { return player; },
886
902
  get inspection() { return inspection; },
887
903
  setupPose: () => resetToSetup(),
@@ -1171,7 +1187,27 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
1171
1187
  const verdict = selectValues(['pending', 'approved', 'changes-requested'], ['Pending', 'Approved', 'Changes requested']);
1172
1188
  verdict.name = 'verdict';
1173
1189
  fields.append(verdict);
1174
- read = () => ({ stage: subject.stage, verdict: verdict.value as 'pending' | 'approved' | 'changes-requested', words: note.value });
1190
+ const stage = subject.stage;
1191
+ if (stage === 'image-review') {
1192
+ const source = ask.source;
1193
+ if (source.subject !== 'image-set') throw new Error('JOB_ACT_SOURCE_STALE');
1194
+ const imageNotes = source.imageSet.images.map((image, index) => {
1195
+ const group = node('fieldset');
1196
+ const name = node('legend');
1197
+ name.textContent = image.name;
1198
+ group.append(name);
1199
+ fields.append(group);
1200
+ return {name: image.name, input: textArea(group, 'job.imageNote', 'image-note-' + index)};
1201
+ });
1202
+ read = () => {
1203
+ const notes = imageNotes.filter(note => note.input.value !== '')
1204
+ .map(note => ({name: note.name, words: note.input.value}));
1205
+ return {stage, verdict: verdict.value as 'pending' | 'approved' | 'changes-requested', words: note.value,
1206
+ ...(notes.length ? {imageNotes: notes} : {})};
1207
+ };
1208
+ } else {
1209
+ read = () => ({ stage, verdict: verdict.value as 'pending' | 'approved' | 'changes-requested', words: note.value });
1210
+ }
1175
1211
  }
1176
1212
  else if (subject.kind === 'signoff') {
1177
1213
  const stage = node('p');
@@ -1281,10 +1317,11 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
1281
1317
  sidebar.append(binding);
1282
1318
  const parts = node('select');
1283
1319
  parts.id = 'job-part';
1320
+ parts.disabled = !prepared.metadata.manifest.model || prepared.metadata.feedbackCatalog.slots === null;
1284
1321
  const whole = node('option', 'job.wholeRig');
1285
1322
  whole.value = '';
1286
1323
  parts.append(whole);
1287
- for (const slot of prepared.metadata.feedbackCatalog.slots) {
1324
+ for (const slot of prepared.metadata.feedbackCatalog.slots ?? []) {
1288
1325
  const option = node('option');
1289
1326
  option.value = slot;
1290
1327
  option.textContent = slot;
@@ -1398,6 +1435,57 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
1398
1435
  coordinates.id = 'coordinates';
1399
1436
  coordinates.hidden = true;
1400
1437
  stage.append(controls, pair, transport, numeric, coordinates);
1438
+ const source = prepared.display.publication.source;
1439
+ if (source.subject === 'image-set') {
1440
+ const heading = node('h2', 'job.imageSetTitle');
1441
+ const digest = node('p');
1442
+ digest.className = 'job-source';
1443
+ digest.style.overflowWrap = 'anywhere';
1444
+ const digestLabel = node('span', 'job.imageSetDigest');
1445
+ const digestValue = node('code');
1446
+ digestValue.textContent = source.imageSetDigest;
1447
+ digest.append(digestLabel, document.createTextNode(' '), digestValue);
1448
+ const gallery = node('section');
1449
+ gallery.dataset.jobImageSet = '';
1450
+ gallery.style.display = 'grid';
1451
+ gallery.style.gridAutoFlow = 'column';
1452
+ gallery.style.gridAutoColumns = 'minmax(180px, 1fr)';
1453
+ gallery.style.gap = '16px';
1454
+ gallery.style.overflow = 'auto';
1455
+ gallery.style.minHeight = '0';
1456
+ gallery.style.flex = '1';
1457
+ for (const [index, image] of source.imageSet.images.entries()) {
1458
+ const element = prepared.imageSetImages?.[index];
1459
+ if (!element) throw new Error('JOB_VISUAL_UNAVAILABLE');
1460
+ const figure = node('figure');
1461
+ figure.style.margin = '0';
1462
+ figure.style.minWidth = '0';
1463
+ figure.dataset.imageName = image.name;
1464
+ const name = node('h3');
1465
+ name.textContent = image.name;
1466
+ name.style.overflowWrap = 'anywhere';
1467
+ const role = node('p', 'job.imageRole.' + image.role);
1468
+ const hash = node('code');
1469
+ hash.className = 'job-source';
1470
+ hash.style.display = 'block';
1471
+ hash.style.overflowWrap = 'anywhere';
1472
+ hash.textContent = image.sha256;
1473
+ element.style.width = '100%';
1474
+ element.style.height = 'auto';
1475
+ element.style.maxHeight = '70vh';
1476
+ element.style.objectFit = 'contain';
1477
+ figure.append(name, role, element, hash);
1478
+ if (source.duplicateHashes.some(group => group.names.includes(image.name)))
1479
+ figure.append(node('p', 'job.identicalImages'));
1480
+ gallery.append(figure);
1481
+ }
1482
+ stage.prepend(heading, digest, gallery);
1483
+ controls.hidden = pair.hidden = transport.hidden = true;
1484
+ controls.style.display = pair.style.display = transport.style.display = 'none';
1485
+ for (const child of sidebar.children) {
1486
+ if (child instanceof HTMLElement && child !== identity && child !== binding) child.hidden = true;
1487
+ }
1488
+ }
1401
1489
  const formsHost = node('section');
1402
1490
  formsHost.className = 'job-forms';
1403
1491
  formsHost.dataset.jobForms = '';
@@ -1433,7 +1521,8 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
1433
1521
  direction.hidden = panel !== '4';
1434
1522
  for (const [askId, entry] of forms) {
1435
1523
  const ask = window.state().pending.find(item => item.askId === askId);
1436
- entry.form.hidden = panel === '2' && ask?.subject.kind !== 'interview-picks';
1524
+ entry.form.hidden = current?.display.publication.source.subject !== 'image-set' &&
1525
+ panel === '2' && ask?.subject.kind !== 'interview-picks';
1437
1526
  }
1438
1527
  }
1439
1528
  function pose(seekReference = true): void {
@@ -1516,7 +1605,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
1516
1605
  time = 0;
1517
1606
  compatibilityNotice = true;
1518
1607
  }
1519
- if (selectedPart && !prepared.metadata.feedbackCatalog.slots.includes(selectedPart)) {
1608
+ if (selectedPart && !(prepared.metadata.feedbackCatalog.slots ?? []).includes(selectedPart)) {
1520
1609
  selectedPart = '';
1521
1610
  compatibilityNotice = true;
1522
1611
  }
@@ -1595,6 +1684,10 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
1595
1684
  }
1596
1685
  },
1597
1686
  async painted(prepared, signal) {
1687
+ for (const image of prepared.imageSetImages ?? []) {
1688
+ if (!image.isConnected || !image.complete || !image.naturalWidth || !image.naturalHeight)
1689
+ throw new Error('JOB_VISUAL_UNAVAILABLE');
1690
+ }
1598
1691
  await reference()?.seek(time, signal);
1599
1692
  if (prepared.player) {
1600
1693
  prepared.player.draw();
package/web/main.ts CHANGED
@@ -1127,7 +1127,7 @@ async function playPreview():Promise<void> {
1127
1127
  }
1128
1128
  function localDraft():boolean{return !!comments?.draft()||dirty||!!input('feedback-summary').value.trim()||!!input('feedback-start').value.trim()||!!input('feedback-end').value.trim()||!!select('feedback-category').value||!!input('feedback-target-name').value.trim()&&input('feedback-target-name').value!==data.manifest.id;}
1129
1129
  function controlState():ControlInspection {
1130
- const box=assets?.stage??player?.bounds(),center=box?{x:box.x+box.width/2,y:box.y+box.height/2}:null;
1130
+ const box=assets?.stage??player?.bounds(),center=viewport.paneFrame('rig')?.center??(box?{x:box.x+box.width/2,y:box.y+box.height/2}:null);
1131
1131
  return {part:parts?.value()??null,partGeneration:parts?.observation()?.generation??null,view:numericView(),theme:appearance?.get()??'system',layout:'auto',effectiveLayout:el('stage-layout').dataset.orientation==='vertical'?'column':'row',cameras:{rig:{zoom:player?viewport.state.zoom:1,pan:{x:center&&viewport.state.cameraCenter?(center.x-viewport.state.cameraCenter.x)*viewport.state.rigScale:0,y:center&&viewport.state.cameraCenter?(viewport.state.cameraCenter.y-center.y)*viewport.state.rigScale:0}},reference:{zoom:referenceSize?viewport.state.referenceZoom:1,pan:{x:referenceSize&&viewport.state.referenceCenter?(referenceSize.width/2-viewport.state.referenceCenter.x)*viewport.state.referenceScale:0,y:referenceSize&&viewport.state.referenceCenter?(referenceSize.height/2-viewport.state.referenceCenter.y)*viewport.state.referenceScale:0}}},animation:animation||null,time,playing,loop:canRepeatIdle()?'idle':'off',layers:{images:!!player&&layers.images,meshes:!!player&&layers.mesh,bones:!!player&&layers.bones},ready:!!data,seeking:seekingControl||!!video?.seeking||!!persistence?.restoring(),dirty:localDraft(),busy:saving||stripBusy||!!persistence?.restoring(),feedbackEligible:!persistence?.restoring(),comparison:controlComparison(layoutEligibility()),capabilities:{camera:!!player,referenceCamera:!!referenceSize,animation:!!player,time:duration>0,playback:duration>0,layers:{images:!!player,meshes:!!player,bones:!!player}}};
1132
1132
  }
1133
1133
  async function applyControl(command:ControlCommand,signal:AbortSignal):Promise<void> {
@@ -1,16 +1,40 @@
1
1
  /** Existing compiled rig/reference rendering for the shared inspection viewport. */
2
- import type {ModelAssets,RigPlayer,PoseBounds} from '@rig-c/play';
2
+ import type {ModelAssets,RigPlayer,PoseBounds,PosedFrame} from '@rig-c/play';
3
3
  import type {ViewportProvider,ViewportState,ViewportController} from './viewport-controller.ts';
4
4
  import {dragImpulse} from '../src/environment.ts';
5
5
  import {CLICK_SLOP_PX} from './stage-pick.ts';
6
6
  export interface RigViewportHost {
7
7
  el:ViewportProvider['el'];player:()=>RigPlayer|null;assets:()=>ModelAssets|null;
8
8
  referenceSize:()=>{width:number;height:number}|null;view:()=>string;referenceGeneration:()=>number;
9
- parts:()=>{value:()=>unknown;bounds:()=>PoseBounds|null}|null;
9
+ parts:()=>{value:()=>unknown;bounds:()=>PoseBounds|null;frame?:(side:'single')=>PosedFrame|undefined}|null;
10
10
  text:(id:string,value:string)=>void;message:ViewportProvider['message'];redrawOverlay:(fresh:boolean)=>void;
11
11
  }
12
12
  export function createRigViewportProvider(host:RigViewportHost,state:ViewportState):ViewportProvider {
13
13
  const {el,text,message,redrawOverlay}=host;const input=(id:string)=>el<HTMLInputElement>(id),button=(id:string)=>el<HTMLButtonElement>(id);
14
+ const framingBoxes=new WeakMap<RigPlayer,{assets:ModelAssets|null;box:PoseBounds}>();
15
+ function positiveBounds(box:PoseBounds|null|undefined):box is PoseBounds {
16
+ return !!box&&box.width>0&&box.height>0&&[box.x,box.y,box.width,box.height,box.x+box.width,box.y+box.height].every(Number.isFinite);
17
+ }
18
+ function rigFramingBox():PoseBounds|null {
19
+ const player=host.player(),assets=host.assets();if(!player)return null;
20
+ const declared=assets?.stage;
21
+ // A model without a positive declared stage keeps its existing live pose/filter basis.
22
+ if(!positiveBounds(declared))return player.bounds();
23
+ const cached=framingBoxes.get(player);if(cached&&cached.assets===assets)return cached.box;
24
+ const stage={...declared},frame=host.parts()?.frame?.('single');
25
+ // present() records a successful draw. A prepared pose or later player slot filter
26
+ // must not become the whole-rig framing basis merely because bounds() is positive.
27
+ if(!frame||frame.generation===undefined||frame.generation!==player.generation||player.slots!==null)return stage;
28
+ const drawn=player.bounds();
29
+ if(!positiveBounds(drawn))return stage;
30
+ const x=Math.min(stage.x,drawn.x),y=Math.min(stage.y,drawn.y);
31
+ const box={x,y,width:Math.max(stage.x+stage.width,drawn.x+drawn.width)-x,
32
+ height:Math.max(stage.y+stage.height,drawn.y+drawn.height)-y};
33
+ if(!positiveBounds(box))return null;
34
+ // bounds() follows the live pose/filter. Keep one framing basis per loaded player/assets,
35
+ // including when a semantic publication is temporarily replaced and then restored.
36
+ framingBoxes.set(player,{assets,box});return box;
37
+ }
14
38
  function referenceFit(controller:ViewportController): void {
15
39
  const referenceSize=host.referenceSize();const {paneFrame}=controller;
16
40
  if (!referenceSize || !paneFrame('reference')) return;
@@ -26,7 +50,7 @@ function render(controller:ViewportController): void {
26
50
  const player=host.player(),assets=host.assets();const {paneFrame,renderNumericView,renderCameraControls}=controller;
27
51
  referenceFit(controller);renderNumericView();renderCameraControls();
28
52
  if (!player || !assets) return;
29
- const box: PoseBounds | null = assets.stage ?? player.bounds(); if (!box || box.width <= 0 || box.height <= 0) return;
53
+ const box=rigFramingBox();if(!box||box.width<=0||box.height<=0)return;
30
54
  const viewport = el('rig-viewport');if(!paneFrame('rig'))return;
31
55
  const scale = state.rigScale = Math.max(.001,Math.min((viewport.clientWidth - 28) / box.width, (viewport.clientHeight - 58) / box.height) * state.zoom);
32
56
  const center = state.cameraCenter ?? { x: box.x + box.width / 2, y: box.y + box.height / 2 };state.displayedCenter={...center};
@@ -36,8 +60,8 @@ function render(controller:ViewportController): void {
36
60
 
37
61
  function renderControls(controller:ViewportController):void {const {availableCamera,paneCamera}=controller;input('camera-sync').checked=state.cameraSync;const target=availableCamera();text('zoom-value',`${Math.round((target?paneCamera(target).zoom:1)*100)}% · ${target==='reference'?'Reference':'Rig'}`);button('fit').textContent=state.cameraSync?'Fit views':'Fit active';text('coordinates',state.cameraSync?'Cameras synchronized · drag to pan · scroll to zoom':'Independent cameras · drag to pan · scroll to zoom');}
38
62
  return {el,message,render,renderControls,
39
- geometry:target=>{const assets=host.assets(),player=host.player(),referenceSize=host.referenceSize();const box=target==='rig'?assets?.stage??player?.bounds():referenceSize?{x:0,y:0,...referenceSize}:null;if(!box||target==='rig'&&!player)return null;return {space:target==='rig'?'world':'image',box,marginX:target==='rig'?28:24,marginY:target==='rig'?58:56};},
40
- layoutKey:()=>{const assets=host.assets(),player=host.player(),referenceSize=host.referenceSize(),view=host.view(),referenceGeneration=host.referenceGeneration();const boxKey=assets?.stage??player?.bounds();return ['rig','reference'].map(target=>{const v=el(target+'-viewport');return `${v.clientWidth}:${v.clientHeight}`;}).join('|')+view+referenceGeneration+!!player+JSON.stringify(referenceSize)+JSON.stringify(boxKey);},
63
+ geometry:target=>{const referenceSize=host.referenceSize();const box=target==='rig'?rigFramingBox():referenceSize?{x:0,y:0,...referenceSize}:null;if(!box)return null;return {space:target==='rig'?'world':'image',box,marginX:target==='rig'?28:24,marginY:target==='rig'?58:56};},
64
+ layoutKey:()=>{const player=host.player(),referenceSize=host.referenceSize(),view=host.view(),referenceGeneration=host.referenceGeneration();const boxKey=rigFramingBox();return ['rig','reference'].map(target=>{const v=el(target+'-viewport');return `${v.clientWidth}:${v.clientHeight}`;}).join('|')+view+referenceGeneration+!!player+JSON.stringify(referenceSize)+JSON.stringify(boxKey);},
41
65
  selection:target=>{const parts=host.parts(),part=parts?.value();return {selected:!!part,bounds:target==='rig'&&part?parts?.bounds()??null:null};}
42
66
  };
43
67
  }