@rig-c/review 2.13.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/docs/PARTS_VIEW.md +1 -1
- package/docs/REVIEW_PACKAGE.md +32 -91
- package/docs/STABILITY.md +27 -194
- package/docs/WORKFLOWS.md +0 -107
- package/package.json +1 -1
- package/skills/rig-review/SKILL.md +11 -25
- package/src/build.ts +2 -2
- package/src/direction-inspection.ts +6 -2
- package/src/front.ts +4 -193
- package/src/interview-scene.ts +3 -3
- package/src/job-act.ts +1 -35
- package/src/job-api.ts +27 -19
- package/src/job-cli.ts +3 -3
- package/src/job-contract.ts +14 -50
- package/src/job-front.ts +17 -44
- package/src/job-host.ts +1 -4
- package/src/job-session.ts +22 -10
- package/src/job-source.ts +3 -17
- package/src/job-store.ts +80 -6
- package/src/job-worker.ts +1 -47
- package/src/manifest.ts +23 -4
- package/src/open.ts +2 -3
- package/src/scene-inspection.ts +50 -0
- package/src/server.ts +1 -1
- package/web/catalog-en.ts +37 -27
- package/web/catalog-ko.ts +37 -27
- package/web/compare.css +0 -4
- package/web/direction-panel.ts +22 -6
- package/web/inspector-blocks.ts +8 -4
- package/web/job-rig-capture.ts +62 -12
- package/web/job-rig-screen.ts +75 -55
- package/web/job-session.ts +89 -1091
- package/web/main.ts +113 -56
- package/web/parts-viewport-provider.ts +8 -3
- package/web/retained-frame-stage.ts +7 -7
- package/web/rig-host.ts +5 -3
- package/web/rig-viewport-provider.ts +2 -0
- package/web/scene-plates.ts +57 -4
- package/web/styles.css +12 -82
- package/web/viewport-capture.ts +12 -2
- package/web/workspace-ui.ts +5 -6
- package/src/front-worker.ts +0 -2
- package/src/job-hub.ts +0 -304
- package/src/job-image-set.ts +0 -73
- package/web/job-hub.ts +0 -160
package/src/job-api.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {checkpointEvidenceFields} from './job-checkpoint-evidence.ts';
|
|
|
2
2
|
import { createHash, timingSafeEqual } from 'node:crypto';
|
|
3
3
|
import {
|
|
4
4
|
JOB_ACT_SCHEMA, JOB_API_SCHEMA, JOB_API_V3_SCHEMA, JOB_ENABLED_ACT_KINDS, JOB_PARTS_ENUMERATOR_RANGE,
|
|
5
|
-
JOB_PLAN_BOUND_SIGNOFF_STAGES, JOB_RECORD_ACT_SCHEMA, JOB_RECORD_INSTANCE_SCHEMA, JOB_RECORD_SOURCE_SCHEMA,
|
|
5
|
+
JOB_PLAN_BOUND_SIGNOFF_STAGES, JOB_RECORD_SIGNOFF_STAGES, JOB_RECORD_ACT_SCHEMA, JOB_RECORD_INSTANCE_SCHEMA, JOB_RECORD_SOURCE_SCHEMA,
|
|
6
6
|
JOB_RESERVED_ACT_KINDS,
|
|
7
7
|
type AgentRequestV3, type FetchActRequestV3, type JobAgentRequest, type JobApiSchema,
|
|
8
8
|
type JobCheckpointEvidence, type JobDisplayAcknowledgment, type JobErrorCode, type JobFetchActRequest, type JobFileIdentity,
|
|
@@ -24,7 +24,6 @@ import { parseFeedback } from './session.ts';
|
|
|
24
24
|
import { parsePartsIssue } from './parts-comment.ts';
|
|
25
25
|
import { parseStageComment, hasStageComment, projectComments, commentModes } from './stage-comment.ts';
|
|
26
26
|
import { validatePngCrop, validatePngCropMetadata } from './comment-crops.ts';
|
|
27
|
-
import {parseJobImageSetBinding} from './job-image-set.ts';
|
|
28
27
|
import {parseJobPartsIdentity} from './job-source.ts';
|
|
29
28
|
import {parseControlPart, parseControlView} from './control.ts';
|
|
30
29
|
import {EMIT_UNPINNED_CREATE_FIELDS} from './create-pin-gate.ts';
|
|
@@ -257,7 +256,7 @@ export function parseRecordSubject(value: unknown): RecordSubject {
|
|
|
257
256
|
case 'signoff': {
|
|
258
257
|
jobObject(item, ['kind', 'stage']);
|
|
259
258
|
const stage = jobId(item.stage);
|
|
260
|
-
if (!(
|
|
259
|
+
if (!(JOB_RECORD_SIGNOFF_STAGES as readonly string[]).includes(stage)) {
|
|
261
260
|
throw new JobError('JOB_ASK_INVALID');
|
|
262
261
|
}
|
|
263
262
|
return { kind: 'signoff', stage: stage as RecordSignoffStage };
|
|
@@ -1151,7 +1150,7 @@ export function parseRecordAct(value: unknown): RecordAct {
|
|
|
1151
1150
|
if (source.subject !== 'plan' || source.plan.steps.length === 0) throw new JobError('JOB_ACT_INVALID');
|
|
1152
1151
|
const rawValue = exactObject(item.value, ['stage', 'decision', 'words'], 'JOB_ACT_INVALID');
|
|
1153
1152
|
const stage = asCode(() => jobId(rawValue.stage), 'JOB_ACT_INVALID');
|
|
1154
|
-
if (!(
|
|
1153
|
+
if (!(JOB_RECORD_SIGNOFF_STAGES as readonly string[]).includes(stage) || rawValue.decision !== 'approved') {
|
|
1155
1154
|
throw new JobError('JOB_ACT_INVALID');
|
|
1156
1155
|
}
|
|
1157
1156
|
asCode(() => validateRecordAskSubject({ kind: 'signoff', stage }, source), 'JOB_ACT_INVALID');
|
|
@@ -1254,8 +1253,7 @@ function parseCommentAnchor(raw: unknown, text: string, source?: SourceV3 | stri
|
|
|
1254
1253
|
if ('name' in item) {
|
|
1255
1254
|
commentsObject(item, ['name'], ['imageRegion', 'crop', 'nativeCrop']);
|
|
1256
1255
|
const name = jobText(item.name);
|
|
1257
|
-
if (source
|
|
1258
|
-
!source.imageSet.images.some(image => image.name === name))) throw new JobError('JOB_ACT_SOURCE_STALE');
|
|
1256
|
+
if (source) throw new JobError('JOB_ACT_SOURCE_STALE');
|
|
1259
1257
|
if (Object.keys(item).length === 1) return {name};
|
|
1260
1258
|
commentsObject(item, ['name', 'imageRegion', 'crop', 'nativeCrop']);
|
|
1261
1259
|
const region = commentsObject(item.imageRegion, ['x', 'y', 'width', 'height']);
|
|
@@ -1312,7 +1310,7 @@ function parseCommentContext(raw: unknown, source?: SourceV3 | string): JobComme
|
|
|
1312
1310
|
if (selector === null) throw new JobError('JOB_ACT_INVALID');
|
|
1313
1311
|
const bound = typeof source === 'string' ? source : source?.sourceHash;
|
|
1314
1312
|
if (bound && sourceHash !== bound) throw new JobError('JOB_ACT_SOURCE_STALE');
|
|
1315
|
-
if (selector && source && typeof source !== 'string' && !('record' in source) &&
|
|
1313
|
+
if (selector && source && typeof source !== 'string' && !('record' in source) &&
|
|
1316
1314
|
JSON.stringify(selector) !== JSON.stringify(source.selector)) throw new JobError('JOB_ACT_SOURCE_STALE');
|
|
1317
1315
|
out.subject = {ask, sourceHash, ...(selector ? {selector} : {})};
|
|
1318
1316
|
}
|
|
@@ -1365,14 +1363,12 @@ function commentsSource(raw: unknown): Exclude<SourceV3, OptionSource> {
|
|
|
1365
1363
|
if (record.subject !== 'plan') throw new JobError('JOB_ACT_INVALID');
|
|
1366
1364
|
return record;
|
|
1367
1365
|
}
|
|
1368
|
-
const image = !!raw && typeof raw === 'object' && (raw as {subject?: unknown}).subject === 'image-set';
|
|
1369
1366
|
const common = ['sourceHash', 'projectHash', 'package', 'direction', 'optionSet', 'appliedResult', 'plan', 'parts'];
|
|
1370
|
-
const item = commentsObject(raw,
|
|
1371
|
-
[...common, 'selector', 'model'], image ? [] : ['checkpointEvidence']);
|
|
1367
|
+
const item = commentsObject(raw, [...common, 'selector', 'model'], ['checkpointEvidence']);
|
|
1372
1368
|
jobSha(item.sourceHash); if (item.projectHash !== null) jobSha(item.projectHash);
|
|
1373
1369
|
const pkg = commentsObject(item.package, ['id', 'revision']); jobText(pkg.id); jobText(pkg.revision);
|
|
1374
|
-
for (const key of
|
|
1375
|
-
|
|
1370
|
+
for (const key of ['direction', 'model']) if (item[key] !== null) parseFileRow(item[key], 'JOB_ACT_INVALID');
|
|
1371
|
+
parseJobSelector(item.selector);
|
|
1376
1372
|
if (item.optionSet !== null) {
|
|
1377
1373
|
const set = commentsObject(item.optionSet, ['id', 'sha256']); jobId(set.id); jobSha(set.sha256);
|
|
1378
1374
|
}
|
|
@@ -1395,7 +1391,6 @@ function commentsSource(raw: unknown): Exclude<SourceV3, OptionSource> {
|
|
|
1395
1391
|
});
|
|
1396
1392
|
checkpointEvidenceFields(item, item.plan as JobPlanIdentity | null, subjects, files);
|
|
1397
1393
|
}
|
|
1398
|
-
if (image) parseJobImageSetBinding({imageSet: item.imageSet, imageSetDigest: item.imageSetDigest, duplicateHashes: item.duplicateHashes});
|
|
1399
1394
|
return structuredClone(item) as unknown as Exclude<SourceV3, OptionSource>;
|
|
1400
1395
|
}
|
|
1401
1396
|
|
|
@@ -1434,7 +1429,6 @@ function decodeCommentsAct(raw: unknown, withContext: boolean): JobCommentsAct |
|
|
|
1434
1429
|
};
|
|
1435
1430
|
const keys = typeof item.kind === 'string' && Object.hasOwn(fields, item.kind) ? fields[item.kind] : undefined;
|
|
1436
1431
|
if (!keys) throw new JobError('JOB_ACT_INVALID');
|
|
1437
|
-
if (source.subject === 'image-set' && item.kind !== 'review-verdict') throw new JobError('JOB_ACT_INVALID');
|
|
1438
1432
|
const value = commentsObject(item.value, keys);
|
|
1439
1433
|
const comments = withContext ? decodeComments(value.comments, source, true) : parseComments(value.comments, source);
|
|
1440
1434
|
if (comments.some(comment => comment.anchor && 'side' in comment.anchor)) throw new JobError('JOB_ACT_INVALID');
|
|
@@ -1445,19 +1439,19 @@ function decodeCommentsAct(raw: unknown, withContext: boolean): JobCommentsAct |
|
|
|
1445
1439
|
if (typeof value.outcome !== 'string' || !['pass', 'fail'].includes(value.outcome)) throw new JobError('JOB_ACT_INVALID');
|
|
1446
1440
|
assertCommentsCheckpointBinding(source, checkpointId, planStepId);
|
|
1447
1441
|
} else if (item.kind === 'parts-verdict') {
|
|
1448
|
-
if ('record' in source || source.
|
|
1442
|
+
if ('record' in source || source.selector?.kind !== 'draft' || !source.parts || !source.projectHash ||
|
|
1449
1443
|
typeof value.verdict !== 'string' || !['approved', 'changes-requested'].includes(value.verdict)) throw new JobError('JOB_ACT_INVALID');
|
|
1450
1444
|
const issues = comments.filter(comment => comment.anchor && 'schema' in comment.anchor).length;
|
|
1451
1445
|
if ((value.verdict === 'approved') !== (issues === 0)) throw new JobError('JOB_ACT_INVALID');
|
|
1452
1446
|
} else if (item.kind === 'review-verdict') {
|
|
1453
1447
|
if ('record' in source || typeof value.verdict !== 'string' || !['pending', 'approved', 'changes-requested'].includes(value.verdict)) throw new JobError('JOB_ACT_INVALID');
|
|
1454
|
-
if (source.
|
|
1455
|
-
!source.model || (value.stage === 'rig-review' ? source.selector?.kind !== 'rig' : value.stage !== 'direction-review' || source.selector?.kind !== 'post' || !source.direction)) throw new JobError('JOB_ACT_INVALID');
|
|
1448
|
+
if (!source.model || (value.stage === 'rig-review' ? source.selector?.kind !== 'rig' : value.stage !== 'direction-review' || source.selector?.kind !== 'post' || !source.direction)) throw new JobError('JOB_ACT_INVALID');
|
|
1456
1449
|
} else {
|
|
1457
1450
|
const stage = jobId(value.stage);
|
|
1458
1451
|
if (item.kind === 'signoff' && value.decision !== 'approved') throw new JobError('JOB_ACT_INVALID');
|
|
1459
1452
|
if (item.kind === 'reopen' && !('record' in source)) throw new JobError('JOB_ACT_INVALID');
|
|
1460
|
-
|
|
1453
|
+
const planBoundStages = 'record' in source ? JOB_RECORD_SIGNOFF_STAGES : JOB_PLAN_BOUND_SIGNOFF_STAGES;
|
|
1454
|
+
if (item.kind === 'signoff' && (planBoundStages as readonly string[]).includes(stage) && !source.plan?.steps.length) throw new JobError('JOB_ACT_INVALID');
|
|
1461
1455
|
}
|
|
1462
1456
|
if ('record' in source) validateRecordAskSubject(item.kind === 'checkpoint' ? {kind: item.kind, checkpointId: value.checkpointId} :
|
|
1463
1457
|
{kind: item.kind, stage: value.stage}, source);
|
|
@@ -1497,7 +1491,10 @@ export async function jobBody(request: Request, maximum = jobBodyLimit): Promise
|
|
|
1497
1491
|
chunks.push(value);
|
|
1498
1492
|
}
|
|
1499
1493
|
const value = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(Buffer.concat(chunks)));
|
|
1500
|
-
|
|
1494
|
+
const hasCommentImages = ['parts-verdict', 'review-verdict', 'checkpoint', 'signoff', 'reopen'].includes(value?.kind) &&
|
|
1495
|
+
/"png":"data:image\/png;base64,/.test(JSON.stringify(value?.value));
|
|
1496
|
+
const rigCapture = value?.kind === 'review-verdict' && value?.value?.stage === 'rig-review' && value.capture;
|
|
1497
|
+
if (size > jobBodyLimit && !(maximum > jobBodyLimit && (rigCapture || hasCommentImages))) {
|
|
1501
1498
|
throw new JobError('JOB_BODY_LIMIT');
|
|
1502
1499
|
}
|
|
1503
1500
|
return value;
|
|
@@ -1547,6 +1544,17 @@ export function createJobHostPorts(session: JobSession, origin: string): JobHost
|
|
|
1547
1544
|
let input: JobAgentRequest | AgentRequestV3 | JobFetchActRequest | FetchActRequestV3 | null = null;
|
|
1548
1545
|
let responseSchema: typeof JOB_API_SCHEMA | typeof JOB_API_V3_SCHEMA = session.apiSchema;
|
|
1549
1546
|
try {
|
|
1547
|
+
const cropUrl = new URL(request.url);
|
|
1548
|
+
const crop = new RegExp('^' + base + '/comment-crops/([a-f0-9]{64})\\.png$').exec(cropUrl.pathname);
|
|
1549
|
+
if (crop && request.method === 'GET' && cropUrl.origin === origin && !cropUrl.search && !cropUrl.hash) {
|
|
1550
|
+
if (request.headers.get('sec-fetch-site') === 'cross-site' ||
|
|
1551
|
+
request.headers.get('origin') !== null && request.headers.get('origin') !== origin) {
|
|
1552
|
+
throw new JobError('JOB_SAME_ORIGIN_REQUIRED');
|
|
1553
|
+
}
|
|
1554
|
+
session.authorize('ui-evidence', request.headers.get('X-Review-Capability'));
|
|
1555
|
+
return new Response(new Uint8Array(session.readCommentCrop(crop[1]!)),
|
|
1556
|
+
{headers: {...responseHeaders, 'Content-Type': 'image/png'}});
|
|
1557
|
+
}
|
|
1550
1558
|
gate(request, base + '/api', false);
|
|
1551
1559
|
const body = await jobBody(request);
|
|
1552
1560
|
const mode: JobPublicationMode =
|
package/src/job-cli.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import {closeSync, constants, fstatSync, fsyncSync, lstatSync, openSync, readFileSync, renameSync, unlinkSync, writeSync} from 'node:fs';
|
|
3
3
|
import {join} from 'node:path';
|
|
4
|
-
import { JOB_API_SCHEMA, JOB_ACT_SCHEMA, JOB_PARTS_VERDICT_ACT_SCHEMA, JOB_RIG_REVIEW_ACT_SCHEMA, JOB_COMMENTS_ACT_SCHEMA, JOB_ENABLED_ACT_KINDS, jobRawActMediaType, jobStillByteLimit,
|
|
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
5
|
type JobAct, type JobCommentsAct, type JobAgentRequest, type JobNextRequest, type JobNextValue } from './job-contract.ts';
|
|
6
6
|
import { assertJobApiSchema, jobFailure, jobHash, jobId, jobInteger, jobObject, jobWaitLimitMs, parseJobRequest, parseCommentsAct } from './job-api.ts';
|
|
7
7
|
import { JobError } from './job-store.ts';
|
|
@@ -313,7 +313,7 @@ async function fetchActCommand(args: readonly string[], options: JobCLIOptions):
|
|
|
313
313
|
if (response.headers.get('content-type')?.split(';')[0] !== accept) throw new JobError('JOB_REQUEST_INVALID');
|
|
314
314
|
return bytes;
|
|
315
315
|
}
|
|
316
|
-
const bytes = await read(jobRawActMediaType,
|
|
316
|
+
const bytes = await read(jobRawActMediaType, jobActDeliveryLimit);
|
|
317
317
|
const act = parseConsumerAct(bytes, job, actId);
|
|
318
318
|
const still = 'still' in act ? act.still : undefined;
|
|
319
319
|
const destination = values.get('still-out');
|
|
@@ -340,7 +340,7 @@ async function readJobResponse(response: Response, interrupted?: Promise<never>)
|
|
|
340
340
|
const { done, value } = await (interrupted ? Promise.race([reader.read(), interrupted]) : reader.read());
|
|
341
341
|
if (done) break;
|
|
342
342
|
size += value.byteLength;
|
|
343
|
-
if (size >
|
|
343
|
+
if (size > jobResponseBodyLimit) {
|
|
344
344
|
try { void reader.cancel().catch(() => {}); } catch {}
|
|
345
345
|
throw new JobError('JOB_BODY_LIMIT');
|
|
346
346
|
}
|
package/src/job-contract.ts
CHANGED
|
@@ -112,7 +112,7 @@ export const JOB_PANEL_COMPOSITION_SCHEMA = 'rig-review/panels@1' as const;
|
|
|
112
112
|
export type PanelSlot = 'left' | 'stage' | 'toolbar' | 'side';
|
|
113
113
|
export const PANEL_COMPONENTS = [
|
|
114
114
|
'parts.canvas', 'parts.list', 'parts.issues', 'parts.layers', 'act.submit',
|
|
115
|
-
'interview.picks', 'plan.body', 'rig.playback', 'scene.composite',
|
|
115
|
+
'interview.picks', 'plan.body', 'rig.playback', 'scene.composite',
|
|
116
116
|
] as const;
|
|
117
117
|
export type PanelComponent = typeof PANEL_COMPONENTS[number];
|
|
118
118
|
export interface JobPanelComposition {
|
|
@@ -172,6 +172,9 @@ export type JobPublicationMode = typeof JOB_PUBLICATION_MODES[number];
|
|
|
172
172
|
export type JobApiSchema = typeof JOB_API_SCHEMA | typeof JOB_API_V3_SCHEMA;
|
|
173
173
|
export const jobStillByteLimit = 8 * 1024 * 1024;
|
|
174
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;
|
|
175
178
|
export const jobRawActMediaType = 'application/vnd.rig-review.act+json';
|
|
176
179
|
export const JOB_PARTS_ENUMERATOR_RANGE = '>=2.25.0 <3.0.0' as const;
|
|
177
180
|
|
|
@@ -202,6 +205,9 @@ export const JOB_PLAN_BOUND_SIGNOFF_STAGES = [
|
|
|
202
205
|
'post-interview',
|
|
203
206
|
] as const;
|
|
204
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
|
+
|
|
205
211
|
/** Reserved kinds have no accepted value shape and cannot be asked or submitted.
|
|
206
212
|
* Described correction awaits the joint Create #182 context allowlist.
|
|
207
213
|
* Mesh edit awaits the joint Parts #1159 freeze. Proposal 6ff03ec9 discusses
|
|
@@ -379,17 +385,13 @@ export type JobSelector =
|
|
|
379
385
|
| { readonly kind: 'rig'; readonly version: number }
|
|
380
386
|
| { readonly kind: 'post'; readonly version: number; readonly rigVersion: number };
|
|
381
387
|
|
|
382
|
-
/** The
|
|
383
|
-
* 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
|
|
384
389
|
* validated retained bytes and the actual displayed publication. Clients never
|
|
385
390
|
* provide trusted source hashes or transfer old approval onto a new binding.
|
|
386
391
|
*/
|
|
387
392
|
export interface JobModelSourceBinding {
|
|
388
393
|
readonly checkpointEvidence?: readonly JobCheckpointEvidence[];
|
|
389
394
|
readonly subject?: never;
|
|
390
|
-
readonly imageSet?: never;
|
|
391
|
-
readonly imageSetDigest?: never;
|
|
392
|
-
readonly duplicateHashes?: never;
|
|
393
395
|
readonly sourceHash: JobSha256;
|
|
394
396
|
readonly projectHash: JobSha256 | null;
|
|
395
397
|
readonly package: { readonly id: string; readonly revision: string };
|
|
@@ -402,36 +404,9 @@ export interface JobModelSourceBinding {
|
|
|
402
404
|
readonly parts: JobPartsIdentity | null;
|
|
403
405
|
}
|
|
404
406
|
|
|
405
|
-
|
|
406
|
-
export interface
|
|
407
|
-
|
|
408
|
-
readonly images: readonly {
|
|
409
|
-
readonly role: 'source' | 'candidate' | 'reference';
|
|
410
|
-
readonly name: string;
|
|
411
|
-
readonly path: string;
|
|
412
|
-
readonly sha256?: JobSha256;
|
|
413
|
-
}[];
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
export interface JobImageSet {
|
|
417
|
-
readonly purpose: 'plate-adoption';
|
|
418
|
-
readonly images: readonly (Omit<JobImageSetInput['images'][number], 'sha256'> & {readonly sha256: JobSha256})[];
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
export interface JobImageSourceBinding extends Omit<JobModelSourceBinding,
|
|
422
|
-
'subject' | 'model' | 'selector' | 'imageSet' | 'imageSetDigest' | 'duplicateHashes' | 'checkpointEvidence'> {
|
|
423
|
-
readonly checkpointEvidence?: never;
|
|
424
|
-
readonly subject: 'image-set';
|
|
425
|
-
readonly model?: never;
|
|
426
|
-
readonly selector?: never;
|
|
427
|
-
readonly imageSet: JobImageSet;
|
|
428
|
-
readonly imageSetDigest: JobSha256;
|
|
429
|
-
readonly duplicateHashes: readonly {readonly names: readonly string[]; readonly sha256: JobSha256}[];
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
export type JobSourceBinding = JobModelSourceBinding | JobImageSourceBinding;
|
|
433
|
-
export interface JobCapabilities { readonly imageSetVerdict: true }
|
|
434
|
-
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({});
|
|
435
410
|
|
|
436
411
|
export interface JobModelReviewValue {
|
|
437
412
|
readonly stage: 'rig-review' | 'direction-review';
|
|
@@ -541,7 +516,7 @@ export interface JobActSources {
|
|
|
541
516
|
readonly selector: Extract<JobSelector, { kind: 'draft' }>;
|
|
542
517
|
readonly parts: JobPartsIdentity;
|
|
543
518
|
};
|
|
544
|
-
readonly 'review-verdict':
|
|
519
|
+
readonly 'review-verdict': (JobModelSourceBinding & {
|
|
545
520
|
readonly selector: Extract<JobSelector, { kind: 'rig' | 'post' }>;
|
|
546
521
|
readonly model: JobFileIdentity;
|
|
547
522
|
});
|
|
@@ -566,8 +541,7 @@ export type JobLegacyAct = {
|
|
|
566
541
|
readonly authority: JobHumanAuthority;
|
|
567
542
|
readonly at: string;
|
|
568
543
|
} & (Kind extends 'review-verdict' ? (
|
|
569
|
-
| {readonly source:
|
|
570
|
-
| {readonly source: JobImageSourceBinding; readonly value: JobImageReviewValue}
|
|
544
|
+
| {readonly source: JobActSources['review-verdict']; readonly value: JobModelReviewValue | JobImageReviewValue}
|
|
571
545
|
) : Kind extends 'parts-verdict' ? {readonly source: JobActSources['parts-verdict']; readonly value: JobLegacyPartsVerdictValue}
|
|
572
546
|
: {readonly source: JobActSources[Kind]; readonly value: JobActValues[Kind]});
|
|
573
547
|
}[JobEnabledActKind];
|
|
@@ -786,12 +760,6 @@ export const JOB_ERROR_CODES = [
|
|
|
786
760
|
'JOB_ROOT_REPLACED',
|
|
787
761
|
'JOB_PUBLICATION_UNKNOWN',
|
|
788
762
|
'JOB_SNAPSHOT_RECLAIMED',
|
|
789
|
-
'JOB_IMAGE_SET_UNSUPPORTED',
|
|
790
|
-
'JOB_IMAGE_SET_INVALID',
|
|
791
|
-
'JOB_IMAGE_SET_DUPLICATE_NAME',
|
|
792
|
-
'JOB_IMAGE_SET_DUPLICATE_PATH',
|
|
793
|
-
'JOB_IMAGE_SET_ROLE_INVALID',
|
|
794
|
-
'JOB_IMAGE_SET_PATH_REFUSED',
|
|
795
763
|
'JOB_ASK_INVALID',
|
|
796
764
|
'JOB_ASK_SUPERSEDED',
|
|
797
765
|
'JOB_ACT_UNKNOWN',
|
|
@@ -1028,7 +996,7 @@ export interface RecordCheckpointSubject {
|
|
|
1028
996
|
readonly checkpointId: string;
|
|
1029
997
|
}
|
|
1030
998
|
|
|
1031
|
-
export type RecordSignoffStage = typeof
|
|
999
|
+
export type RecordSignoffStage = typeof JOB_RECORD_SIGNOFF_STAGES[number];
|
|
1032
1000
|
|
|
1033
1001
|
export interface RecordSignoffSubject {
|
|
1034
1002
|
readonly kind: 'signoff';
|
|
@@ -1099,9 +1067,6 @@ export interface RecordSourceBase {
|
|
|
1099
1067
|
readonly direction?: never;
|
|
1100
1068
|
readonly appliedResult?: never;
|
|
1101
1069
|
readonly parts?: never;
|
|
1102
|
-
readonly imageSet?: never;
|
|
1103
|
-
readonly imageSetDigest?: never;
|
|
1104
|
-
readonly duplicateHashes?: never;
|
|
1105
1070
|
readonly sourceHash: JobSha256;
|
|
1106
1071
|
readonly projectHash: JobSha256;
|
|
1107
1072
|
readonly record: ProjectRecord;
|
|
@@ -1198,7 +1163,6 @@ export interface JobCapabilitiesV3 extends JobCapabilities {
|
|
|
1198
1163
|
}
|
|
1199
1164
|
|
|
1200
1165
|
export const JOB_CAPABILITIES_V3: JobCapabilitiesV3 = Object.freeze({
|
|
1201
|
-
imageSetVerdict: true,
|
|
1202
1166
|
recordPublication: true,
|
|
1203
1167
|
recordActSchema: JOB_RECORD_ACT_SCHEMA,
|
|
1204
1168
|
});
|
package/src/job-front.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {buildWeb} from './build.ts';
|
|
1
2
|
import {PNG} from 'pngjs';
|
|
2
3
|
import {checkpointEvidenceMetadata, readCheckpointEvidenceBytes} from './job-checkpoint-evidence.ts';
|
|
3
4
|
/** Disjoint live-job routes. The backend receives the original authenticated Request. */
|
|
@@ -6,7 +7,7 @@ import { createJobHostPorts, jobBody, jobHash, jobId, jobObject, jobPartsEnumera
|
|
|
6
7
|
import { JobSession } from './job-session.ts';
|
|
7
8
|
import { assertJobRoot, assertRetainedSnapshotIntact, captureJobRoot, planTextMetadata, isRetainedRecordSource, type JobRootIdentity } from './job-source.ts';
|
|
8
9
|
import type { JobWorkerOptions } from './job-worker.ts';
|
|
9
|
-
import { JobError, JobStore } from './job-store.ts';
|
|
10
|
+
import { JobError, JobStore, jobCropReferences } from './job-store.ts';
|
|
10
11
|
import { loadReview, safeFile, packagePath, type ReviewPackage } from './manifest.ts';
|
|
11
12
|
import { serveReference, assertReviewUnchanged } from './reference.ts';
|
|
12
13
|
import {preparePartsComment} from './parts-comment-crops.ts';
|
|
@@ -99,8 +100,7 @@ function result<Value>(value: JobResult<Value>): Response {
|
|
|
99
100
|
export function createJobFront(options: {
|
|
100
101
|
origin: string;
|
|
101
102
|
ports: JobHostPorts;
|
|
102
|
-
|
|
103
|
-
resource: (name: 'index.html' | 'job.js' | 'styles.css') => Promise<BodyInit>;
|
|
103
|
+
resource: (name: 'index.html' | 'main.js' | 'styles.css') => Promise<BodyInit>;
|
|
104
104
|
publication?: (jobId: string, publicationId: string, instanceKey: string, path: string, request: Request) => Promise<Response>;
|
|
105
105
|
}) {
|
|
106
106
|
const origin = new URL(options.origin);
|
|
@@ -146,6 +146,7 @@ export function createJobFront(options: {
|
|
|
146
146
|
const liveness = await options.ports.jobLiveness(jobId);
|
|
147
147
|
if (!liveness.ok)
|
|
148
148
|
return result(liveness);
|
|
149
|
+
if (/^comment-crops\/[a-f0-9]{64}\.png$/.test(route) && request.method === 'GET') return options.ports.handleJobApi(request);
|
|
149
150
|
if (route === 'events' && request.method === 'GET') {
|
|
150
151
|
const keys = [...url.searchParams.keys()];
|
|
151
152
|
if (keys.length > 1 || keys.some(key => key !== 'after'))
|
|
@@ -170,7 +171,7 @@ export function createJobFront(options: {
|
|
|
170
171
|
controller.close();
|
|
171
172
|
}
|
|
172
173
|
else {
|
|
173
|
-
controller.enqueue(encoder.encode(
|
|
174
|
+
controller.enqueue(encoder.encode(jobCropReferences(next.value) + '\n'));
|
|
174
175
|
if (next.value.type === 'closed') {
|
|
175
176
|
stop();
|
|
176
177
|
controller.close();
|
|
@@ -187,14 +188,7 @@ export function createJobFront(options: {
|
|
|
187
188
|
});
|
|
188
189
|
return new Response(body, { headers: { ...headers, 'Content-Type': 'application/x-ndjson' } });
|
|
189
190
|
}
|
|
190
|
-
|
|
191
|
-
if (embedded) {
|
|
192
|
-
if (!options.hubIncarnation || url.searchParams.get('hub') !== options.hubIncarnation ||
|
|
193
|
-
[...url.searchParams.keys()].some(key => !['hub', 'lang'].includes(key) || url.searchParams.getAll(key).length !== 1) ||
|
|
194
|
-
url.searchParams.has('lang') && !['en', 'ko'].includes(url.searchParams.get('lang')!)) {
|
|
195
|
-
return failure('JOB_REQUEST_INVALID', 400);
|
|
196
|
-
}
|
|
197
|
-
} else if (url.search && !(route === '' && ['?lang=en', '?lang=ko'].includes(url.search))) {
|
|
191
|
+
if (url.search && !(route === '' && ['?lang=en', '?lang=ko'].includes(url.search))) {
|
|
198
192
|
return failure('JOB_REQUEST_INVALID', 400);
|
|
199
193
|
}
|
|
200
194
|
const instance = /^publications\/([A-Za-z0-9][A-Za-z0-9._-]{0,127})\/instances\/([a-f0-9]{64})\/(.*)$/.exec(route);
|
|
@@ -204,14 +198,12 @@ export function createJobFront(options: {
|
|
|
204
198
|
const publication = /^publications\/([A-Za-z0-9][A-Za-z0-9._-]{0,127})$/.exec(route);
|
|
205
199
|
if (publication)
|
|
206
200
|
return result(await options.ports.readPublication(jobId, publication[1]!));
|
|
207
|
-
const name = route === '' ? 'index.html' : route === '
|
|
201
|
+
const name = route === '' ? 'index.html' : route === 'main.js' ? 'main.js' : route === 'styles.css' ? 'styles.css' : null;
|
|
208
202
|
if (!name)
|
|
209
203
|
return failure('JOB_REQUEST_INVALID', 404);
|
|
210
|
-
const type = name === 'index.html' ? 'text/html; charset=utf-8' : name === '
|
|
204
|
+
const type = name === 'index.html' ? 'text/html; charset=utf-8' : name === 'main.js' ? 'text/javascript' : 'text/css';
|
|
211
205
|
return new Response(request.method === 'HEAD' ? null : await options.resource(name), {
|
|
212
|
-
headers: { ...headers, 'Content-Type': type,
|
|
213
|
-
'Content-Security-Policy': headers['Content-Security-Policy'].replace("frame-ancestors 'none'", "frame-ancestors 'self'"),
|
|
214
|
-
} : {}) },
|
|
206
|
+
headers: { ...headers, 'Content-Type': type },
|
|
215
207
|
});
|
|
216
208
|
}
|
|
217
209
|
return {
|
|
@@ -223,27 +215,13 @@ export function createJobFront(options: {
|
|
|
223
215
|
/** Installed files are fixed here. A job request never selects a local pathname. */
|
|
224
216
|
export function jobWindowResources() {
|
|
225
217
|
let bundle: Promise<Blob> | null = null;
|
|
226
|
-
return async (name: 'index.html' | '
|
|
227
|
-
if (name === 'index.html')
|
|
228
|
-
return '<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">' +
|
|
229
|
-
'<title>rig-review</title><link rel="stylesheet" href="styles.css"></head>' +
|
|
230
|
-
'<body data-job-window><script type="module" src="job.js"></script></body></html>';
|
|
231
|
-
}
|
|
218
|
+
return async (name: 'index.html' | 'main.js' | 'styles.css'): Promise<BodyInit> => {
|
|
219
|
+
if (name === 'index.html') return await Bun.file(new URL('../web/index.html', import.meta.url)).text();
|
|
232
220
|
if (name === 'styles.css')return await Bun.file(new URL('../web/styles.css', import.meta.url)).text();
|
|
233
|
-
bundle ??=
|
|
221
|
+
bundle ??= buildWeb();
|
|
234
222
|
return bundle;
|
|
235
223
|
};
|
|
236
224
|
}
|
|
237
|
-
export async function buildJobWindow(): Promise<Blob> {
|
|
238
|
-
const source = new URL('../web/job-session.ts', import.meta.url).pathname;
|
|
239
|
-
const result = await Bun.build({ entrypoints: [source], target: 'browser', format: 'esm', minify: false });
|
|
240
|
-
if (!result.success)
|
|
241
|
-
throw new Error(result.logs.map(log => log.message).join('\n'));
|
|
242
|
-
const output = result.outputs.find(output => output.path.endsWith('.js'));
|
|
243
|
-
if (!output)
|
|
244
|
-
throw new Error('JOB_WINDOW_BUNDLE_MISSING');
|
|
245
|
-
return output;
|
|
246
|
-
}
|
|
247
225
|
|
|
248
226
|
interface RetainedView {
|
|
249
227
|
review: ReviewPackage;
|
|
@@ -365,7 +343,8 @@ export function retainedPublicationRoutes(session: JobSession) {
|
|
|
365
343
|
reviewedSource: review.reviewedSource,
|
|
366
344
|
initialAnimation: null,
|
|
367
345
|
setsHash: review.setsHash,
|
|
368
|
-
direction: review.direction,
|
|
346
|
+
direction: review.direction && {...review.direction, ...(retained.source.selector?.kind==='post'?{postVersion:retained.source.selector.version}:{})},
|
|
347
|
+
scene: review.scene,
|
|
369
348
|
referenceHashes: review.referenceHashes,
|
|
370
349
|
sourcePainting: review.sourcePainting && {...review.sourcePainting, url: '/review-painting'},
|
|
371
350
|
feedbackCatalog: review.feedbackCatalog,
|
|
@@ -393,12 +372,6 @@ export function retainedPublicationRoutes(session: JobSession) {
|
|
|
393
372
|
if (!image) return failure('JOB_SOURCE_UNRETAINABLE', 404);
|
|
394
373
|
return await sealedFile(image.ref.path);
|
|
395
374
|
}
|
|
396
|
-
const imageSetImage = /^api\/image-set\/(0|[1-9]\d*)$/.exec(path);
|
|
397
|
-
if (imageSetImage && retained.source.subject === 'image-set') {
|
|
398
|
-
const image = retained.source.imageSet.images[Number(imageSetImage[1])];
|
|
399
|
-
if (!image) return failure('JOB_SOURCE_UNRETAINABLE', 404);
|
|
400
|
-
return await sealedFile(image.path);
|
|
401
|
-
}
|
|
402
375
|
if (crop) {
|
|
403
376
|
if (!parts) return failure('JOB_SOURCE_UNRETAINABLE', 409);
|
|
404
377
|
if (request.headers.get('origin') !== new URL(request.url).origin)
|
|
@@ -812,8 +785,8 @@ function attachFailure(error: unknown): Response {
|
|
|
812
785
|
|
|
813
786
|
/** One live job request context. Its caller publishes it only after descriptor installation. */
|
|
814
787
|
export function createJobRequestContext(session: JobSession, startup: JobHostOptions, origin: string,
|
|
815
|
-
identity: ReturnType<typeof jobHostIdentity>, resource = jobWindowResources(),
|
|
816
|
-
listenerIncarnation: string =
|
|
788
|
+
identity: ReturnType<typeof jobHostIdentity>, resource = jobWindowResources(),
|
|
789
|
+
listenerIncarnation: string = randomUUID(), accepting: () => boolean = () => true) {
|
|
817
790
|
const ports = createJobHostPorts(session, new URL(origin).origin);
|
|
818
791
|
// This legacy GET projection and its property order are deliberately unchanged.
|
|
819
792
|
const record: JobHostRecord = {
|
|
@@ -833,7 +806,7 @@ export function createJobRequestContext(session: JobSession, startup: JobHostOpt
|
|
|
833
806
|
fingerprint: startup.fingerprint,
|
|
834
807
|
pid: process.pid,
|
|
835
808
|
};
|
|
836
|
-
const front = createJobFront({origin, ports, resource,
|
|
809
|
+
const front = createJobFront({origin, ports, resource, publication: retainedPublicationRoutes(session)});
|
|
837
810
|
let requests = 0, stopped = false, published = false;
|
|
838
811
|
let captured: ObservedFiles;
|
|
839
812
|
let descriptorBytes: string;
|
package/src/job-host.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/** Stable installed managed owner host and semantic A/B contract. See docs/STABILITY.md. */
|
|
2
2
|
export {startJobHost} from './job-front.ts';
|
|
3
|
-
export {startJobHub} from './job-hub.ts';
|
|
4
|
-
export type {JobHubOptions, JobHubJobOptions, JobHubJob, JobOwnerHub} from './job-hub.ts';
|
|
5
3
|
export type {
|
|
6
4
|
JobHostOptions,
|
|
7
5
|
JobOwnerHost,
|
|
@@ -221,7 +219,6 @@ export type {
|
|
|
221
219
|
UISubmissionV3,
|
|
222
220
|
} from './job-contract.ts';
|
|
223
221
|
|
|
224
|
-
export {
|
|
225
|
-
export type {JobCapabilities, JobImageSetInput, JobImageSet, JobImageSourceBinding, JobModelSourceBinding, JobModelReviewValue, JobImageReviewValue} from './job-contract.ts';
|
|
222
|
+
export type {JobCapabilities, JobModelSourceBinding, JobModelReviewValue} from './job-contract.ts';
|
|
226
223
|
|
|
227
224
|
export type {JobCheckpointEvidence, JobCheckpointTable} from './job-contract.ts';
|
package/src/job-session.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomBytes, randomUUID } from 'node:crypto';
|
|
2
2
|
import { dirname, isAbsolute, join, relative, sep } from 'node:path';
|
|
3
3
|
import {
|
|
4
|
-
JOB_API_SCHEMA, JOB_API_V3_SCHEMA, JOB_ACT_SCHEMA, JOB_COMMENTS_ACT_SCHEMA, JOB_PARTS_VERDICT_ACT_SCHEMA, JOB_RIG_REVIEW_ACT_SCHEMA, JOB_RECORD_READER_ID, jobStillByteLimit, JOB_CAPABILITIES, JOB_CAPABILITIES_V3, JOB_ENABLED_ACT_KINDS,
|
|
4
|
+
JOB_API_SCHEMA, JOB_API_V3_SCHEMA, JOB_ACT_SCHEMA, JOB_COMMENTS_ACT_SCHEMA, JOB_PARTS_VERDICT_ACT_SCHEMA, JOB_RIG_REVIEW_ACT_SCHEMA, JOB_RECORD_READER_ID, jobStillByteLimit, jobActDeliveryLimit, JOB_CAPABILITIES, JOB_CAPABILITIES_V3, JOB_ENABLED_ACT_KINDS,
|
|
5
5
|
type ActV3, type AgentRequestV3, type EventV3, type JobPartsEnumerator, type JobAct, type JobAgentRequest, type JobDisplayAcknowledgment,
|
|
6
6
|
type JobDisplayPublication, type JobDisplayPublicationV3, type JobDisplayReceipt, type JobEvent, type JobFetchActRequest, type JobFetchActRequestV3,
|
|
7
7
|
type JobNextValue, type JobPendingAsk, type JobPublication, type JobPublicationMode, type JobReviewerBinding,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
assertStoredCheckpointEvidence, assertJobRoot, assertJobSourceCurrent, assertRetainedSnapshotIntact, captureJobRoot, isRetainedRecordSource, prepareJobSource, jobSnapshotHash, removeOwnedJobSnapshot, verifyJobRecordSourceFresh,
|
|
14
14
|
type JobPublicationReader, type JobRetainedSource, type JobRetainedSourceV3, type JobRootIdentity,
|
|
15
15
|
} from './job-source.ts';
|
|
16
|
-
import { JobError, JobStore, type JobSnapshotOwner, type StoredJob } from './job-store.ts';
|
|
16
|
+
import { JobError, JobStore, jobCropReferences, type JobSnapshotOwner, type StoredJob } from './job-store.ts';
|
|
17
17
|
import { canonicalStatePath } from './state-dir.ts';
|
|
18
18
|
import { loadReview } from './manifest.ts';
|
|
19
19
|
import { loadPartsView } from './parts-view.ts';
|
|
@@ -234,11 +234,12 @@ export class JobSession {
|
|
|
234
234
|
return { jobId: this.jobId, fetchCapability: current.data.fetchCapability };
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
authorize(role: 'agent' | 'ui' | 'consumer', given: string | null): void {
|
|
237
|
+
authorize(role: 'agent' | 'ui' | 'ui-evidence' | 'consumer', given: string | null): void {
|
|
238
238
|
const current = this.current();
|
|
239
239
|
if (role === 'consumer' && !current.active) throw new JobError('JOB_CLOSED');
|
|
240
|
-
const
|
|
241
|
-
|
|
240
|
+
const ui = role === 'ui' || role === 'ui-evidence';
|
|
241
|
+
const secret = role === 'agent' ? current.data.agentCapability : ui ? current.data.uiCapability : current.data.fetchCapability;
|
|
242
|
+
if (!secret || !sameCapability(given, ui ? secret : 'Bearer ' + secret)) {
|
|
242
243
|
throw new JobError('JOB_CAPABILITY_REQUIRED');
|
|
243
244
|
}
|
|
244
245
|
if (role === 'ui' && !current.active) throw new JobError('JOB_CLOSED');
|
|
@@ -405,7 +406,7 @@ export class JobSession {
|
|
|
405
406
|
|
|
406
407
|
private event(data: JobData, value: JobEventPayload): EventV3 {
|
|
407
408
|
const event: EventV3 = { ...value, cursor: randomUUID(), jobId: this.jobId, generation: data.generation };
|
|
408
|
-
if (Buffer.byteLength(
|
|
409
|
+
if (Buffer.byteLength(jobCropReferences(event)) > maximumEventBytes) {
|
|
409
410
|
throw new JobError('JOB_BODY_LIMIT', 'Job event exceeds its delivery bound');
|
|
410
411
|
}
|
|
411
412
|
data.events.push(event);
|
|
@@ -457,7 +458,7 @@ export class JobSession {
|
|
|
457
458
|
jobId: this.jobId,
|
|
458
459
|
generation: fresh.data.generation,
|
|
459
460
|
};
|
|
460
|
-
if (Buffer.byteLength(
|
|
461
|
+
if (Buffer.byteLength(jobCropReferences(event)) > maximumEventBytes) {
|
|
461
462
|
throw new JobError('JOB_BODY_LIMIT', 'Job event exceeds its delivery bound');
|
|
462
463
|
}
|
|
463
464
|
fresh.data.events.push(event);
|
|
@@ -615,7 +616,7 @@ export class JobSession {
|
|
|
615
616
|
}
|
|
616
617
|
if (!still) throw new JobError('JOB_STILL_CAPTURE_FAILED');
|
|
617
618
|
const stored = this.store.readStill(this.jobId, actId);
|
|
618
|
-
if (!stored || stored.png.byteLength > jobStillByteLimit || stored.actBytes.byteLength >
|
|
619
|
+
if (!stored || stored.png.byteLength > jobStillByteLimit || stored.actBytes.byteLength > jobActDeliveryLimit ||
|
|
619
620
|
stored.sha256 !== still.sha256 || jobHash(stored.png) !== still.sha256 ||
|
|
620
621
|
still.path !== still.sha256 + '.png' ||
|
|
621
622
|
!Buffer.from(stored.actBytes).equals(actBytes)) {
|
|
@@ -624,6 +625,16 @@ export class JobSession {
|
|
|
624
625
|
return Buffer.from(png ? stored.png : stored.actBytes);
|
|
625
626
|
}
|
|
626
627
|
|
|
628
|
+
readCommentCrop(sha256: string): Buffer {
|
|
629
|
+
const current = this.current();
|
|
630
|
+
let referenced = false;
|
|
631
|
+
jobCropReferences(current.data.events, hash => { if (hash === sha256) referenced = true; });
|
|
632
|
+
if (!/^[a-f0-9]{64}$/.test(sha256) || !referenced) {
|
|
633
|
+
throw new JobError('JOB_ACT_UNKNOWN');
|
|
634
|
+
}
|
|
635
|
+
return this.store.readCrop(sha256);
|
|
636
|
+
}
|
|
637
|
+
|
|
627
638
|
ackDisplayed(input: JobDisplayAcknowledgment): JobDisplayReceipt {
|
|
628
639
|
const current = this.current();
|
|
629
640
|
let receipt: JobDisplayReceipt;
|
|
@@ -759,8 +770,9 @@ export class JobSession {
|
|
|
759
770
|
let size = 0;
|
|
760
771
|
for (const event of events.slice(index + 1, index + 65)) {
|
|
761
772
|
const bytes = Buffer.byteLength(JSON.stringify(event));
|
|
762
|
-
|
|
763
|
-
if (
|
|
773
|
+
const metadataBytes = Buffer.byteLength(jobCropReferences(event));
|
|
774
|
+
if (metadataBytes > maximumEventBytes || bytes > jobActDeliveryLimit) throw new JobError('JOB_BODY_LIMIT', 'Stored job event exceeds its delivery bound');
|
|
775
|
+
if (batch.length && size + bytes > jobActDeliveryLimit) break;
|
|
764
776
|
size += bytes;
|
|
765
777
|
batch.push(event);
|
|
766
778
|
}
|