rig-review 4.7.0 → 4.9.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/docs/REVIEW_PACKAGE.md +23 -27
- package/docs/STABILITY.md +78 -17
- package/docs/WORKFLOWS.md +10 -0
- package/package.json +2 -2
- package/src/baseline.ts +37 -8
- package/src/feedback-export.ts +2 -2
- package/src/job-act-wait.ts +54 -0
- package/src/job-act.ts +24 -13
- package/src/job-api.ts +6 -10
- package/src/job-cli.ts +78 -40
- package/src/job-contract.ts +8 -3
- package/src/job-host.ts +2 -0
- package/src/job-session.ts +25 -8
- package/src/rebuild.ts +69 -16
- package/web/catalog-en.ts +1 -0
- package/web/catalog-ko.ts +1 -0
- package/web/i18n.ts +2 -2
- package/web/inspector-blocks.ts +2 -2
- package/web/job-rig-screen.ts +2 -4
- package/web/job-session.ts +4 -1
- package/web/main.ts +6 -3
- package/web/mesh-editor.ts +2 -3
- package/web/parts-viewport-provider.ts +1 -3
- package/src/create-pin-gate.ts +0 -3
package/src/job-api.ts
CHANGED
|
@@ -29,7 +29,6 @@ import { parseStageComment, hasStageComment, projectComments, commentModes } fro
|
|
|
29
29
|
import { validatePngCrop, validatePngCropMetadata } from './comment-crops.ts';
|
|
30
30
|
import {parseJobPartsIdentity} from './job-source.ts';
|
|
31
31
|
import {parseControlPart, parseControlView} from './control.ts';
|
|
32
|
-
import {EMIT_UNPINNED_CREATE_FIELDS} from './create-pin-gate.ts';
|
|
33
32
|
import {canonicalJson} from './canonical-json.ts';
|
|
34
33
|
import {MESH_EDIT_MAX_OPS, type Vec} from './mesh-edit.ts';
|
|
35
34
|
|
|
@@ -1528,25 +1527,22 @@ export function parseMeshEdits(raw: unknown): readonly JobMeshEdit[] {
|
|
|
1528
1527
|
}, 'JOB_ACT_INVALID');
|
|
1529
1528
|
}
|
|
1530
1529
|
|
|
1531
|
-
/**
|
|
1532
|
-
export function commentsActForEmission(act: JobCommentsAct | JobContextCommentsAct
|
|
1533
|
-
emitUnpinned: boolean = EMIT_UNPINNED_CREATE_FIELDS): JobCommentsAct | JobContextCommentsAct {
|
|
1530
|
+
/** Write @7 when a comment carries context, otherwise keep the @6 envelope. */
|
|
1531
|
+
export function commentsActForEmission(act: JobCommentsAct | JobContextCommentsAct): JobCommentsAct | JobContextCommentsAct {
|
|
1534
1532
|
const value = act.value as {comments: readonly JobContextComment[]};
|
|
1535
|
-
const
|
|
1536
|
-
const
|
|
1537
|
-
const next = {...structuredClone(act), schema, value: {...structuredClone(act.value), comments: structuredClone(comments)}};
|
|
1533
|
+
const schema = value.comments.some(comment => Object.hasOwn(comment, 'context')) ? JOB_COMMENT_CONTEXT_ACT_SCHEMA : JOB_COMMENTS_ACT_SCHEMA;
|
|
1534
|
+
const next = {...act, schema};
|
|
1538
1535
|
return schema === JOB_COMMENTS_ACT_SCHEMA ? parseCommentsAct(next) : parseContextCommentsAct(next);
|
|
1539
1536
|
}
|
|
1540
1537
|
|
|
1541
|
-
/**
|
|
1538
|
+
/** Write @8 for a rig verdict carrying mesh evidence. */
|
|
1542
1539
|
export function meshEditsActForEmission(act: JobCommentsAct | (Extract<JobCommentsAct, {kind: 'review-verdict'}> & {
|
|
1543
1540
|
readonly value: {readonly meshEdits: readonly JobMeshEdit[]};
|
|
1544
|
-
})
|
|
1541
|
+
})): JobCommentsAct | Extract<JobAct, {schema: typeof JOB_MESH_EDITS_ACT_SCHEMA}> {
|
|
1545
1542
|
if (!Object.hasOwn(act.value, 'meshEdits')) {
|
|
1546
1543
|
parseCommentsAct(act);
|
|
1547
1544
|
return act;
|
|
1548
1545
|
}
|
|
1549
|
-
if (!emitMeshEdits) throw new JobError('JOB_ACT_KIND_DISABLED');
|
|
1550
1546
|
return parseMeshEditsAct({...act, schema: JOB_MESH_EDITS_ACT_SCHEMA}) as Extract<JobAct, {schema: typeof JOB_MESH_EDITS_ACT_SCHEMA}>;
|
|
1551
1547
|
}
|
|
1552
1548
|
|
package/src/job-cli.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import {closeSync, constants, fstatSync, fsyncSync, lstatSync, openSync, readFileSync, renameSync, unlinkSync, writeSync} from 'node:fs';
|
|
3
3
|
import {join} from 'node:path';
|
|
4
|
-
import { JOB_API_SCHEMA, JOB_ACT_SCHEMA, JOB_PARTS_VERDICT_ACT_SCHEMA, JOB_RIG_REVIEW_ACT_SCHEMA, JOB_COMMENTS_ACT_SCHEMA, JOB_MESH_EDITS_ACT_SCHEMA, JOB_ENABLED_ACT_KINDS, jobRawActMediaType, jobStillByteLimit, jobActDeliveryLimit, jobResponseBodyLimit,
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { JOB_API_SCHEMA, JOB_ACT_SCHEMA, JOB_PARTS_VERDICT_ACT_SCHEMA, JOB_RIG_REVIEW_ACT_SCHEMA, JOB_COMMENTS_ACT_SCHEMA, JOB_COMMENT_CONTEXT_ACT_SCHEMA, JOB_MESH_EDITS_ACT_SCHEMA, JOB_ENABLED_ACT_KINDS, jobRawActMediaType, jobStillByteLimit, jobActDeliveryLimit, jobResponseBodyLimit,
|
|
5
|
+
JOB_RECORD_ACT_KINDS, JOB_RECORD_ACT_SCHEMA,
|
|
6
|
+
type JobAct, type JobMeshEditsAct, type JobAgentRequest, type JobApiSchema, type JobNextRequest, type JobNextRequestV3, type JobNextValue } from './job-contract.ts';
|
|
7
|
+
import { assertJobApiSchema, jobFailure, jobHash, jobId, jobInteger, jobObject, jobWaitLimitMs, parseJobRequest, parseCommentsAct, parseContextCommentsAct, parseMeshEditsAct, parseRecordAct } from './job-api.ts';
|
|
7
8
|
import { JobError } from './job-store.ts';
|
|
8
9
|
import {validatePngBytes} from './comment-crops.ts';
|
|
9
10
|
import {destinationDirectory} from './destination-directory.ts';
|
|
@@ -70,7 +71,7 @@ export function parseJobCLI(args: readonly string[]): { readonly endpoint: strin
|
|
|
70
71
|
if (verb === 'next') {
|
|
71
72
|
let waitMs = Number(values.get('wait-ms') ?? '0');
|
|
72
73
|
if (values.has('until')) {
|
|
73
|
-
if (values.get('until') !== 'act' || !Number.isSafeInteger(waitMs) || waitMs < 1 || waitMs >
|
|
74
|
+
if (values.get('until') !== 'act' || !Number.isSafeInteger(waitMs) || waitMs < 1 || waitMs > jobActWaitLimitMs) {
|
|
74
75
|
throw new JobError('JOB_REQUEST_INVALID');
|
|
75
76
|
}
|
|
76
77
|
waitUntilActMs = waitMs;
|
|
@@ -145,15 +146,21 @@ async function consumerBytes(stream: ReadableStream<Uint8Array> | null, maximum:
|
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
148
|
|
|
148
|
-
type ConsumerAct = JobAct |
|
|
149
|
+
type ConsumerAct = JobAct | JobMeshEditsAct;
|
|
150
|
+
|
|
151
|
+
const consumerCommentsDecoders = {
|
|
152
|
+
[JOB_COMMENTS_ACT_SCHEMA]: parseCommentsAct,
|
|
153
|
+
[JOB_COMMENT_CONTEXT_ACT_SCHEMA]: parseContextCommentsAct,
|
|
154
|
+
[JOB_MESH_EDITS_ACT_SCHEMA]: parseMeshEditsAct,
|
|
155
|
+
} as const;
|
|
149
156
|
|
|
150
157
|
function parseConsumerAct(bytes: Buffer, job: string, actId: string): ConsumerAct {
|
|
151
158
|
let value: unknown;
|
|
152
159
|
try { value = JSON.parse(new TextDecoder('utf-8', {fatal: true}).decode(bytes)); }
|
|
153
160
|
catch { throw new JobError('JOB_REQUEST_INVALID'); }
|
|
154
161
|
const act = jobObject(value, ['schema', 'actId', 'jobId', 'askId', 'publicationId', 'kind', 'authority', 'at', 'source', 'value', 'still']);
|
|
155
|
-
if (act.schema ===
|
|
156
|
-
const comments = act.schema
|
|
162
|
+
if (typeof act.schema === 'string' && Object.hasOwn(consumerCommentsDecoders, act.schema)) {
|
|
163
|
+
const comments = consumerCommentsDecoders[act.schema as keyof typeof consumerCommentsDecoders](act);
|
|
157
164
|
if (comments.jobId !== job || comments.actId !== actId) throw new JobError('JOB_ACT_INVALID');
|
|
158
165
|
return comments;
|
|
159
166
|
}
|
|
@@ -330,7 +337,8 @@ async function fetchActCommand(args: readonly string[], options: JobCLIOptions):
|
|
|
330
337
|
outputConsumerAct(bytes, png, act, destination, options);
|
|
331
338
|
}
|
|
332
339
|
|
|
333
|
-
async function readJobResponse(response: Response, interrupted?: Promise<never
|
|
340
|
+
async function readJobResponse(response: Response, interrupted?: Promise<never>,
|
|
341
|
+
schema: JobApiSchema = JOB_API_SCHEMA): Promise<unknown> {
|
|
334
342
|
const reader = response.body?.getReader();
|
|
335
343
|
if (!reader) throw new JobError('JOB_REQUEST_INVALID');
|
|
336
344
|
const chunks: Uint8Array[] = [];
|
|
@@ -357,12 +365,12 @@ async function readJobResponse(response: Response, interrupted?: Promise<never>)
|
|
|
357
365
|
let value: unknown;
|
|
358
366
|
try { value = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(Buffer.concat(chunks, size))); }
|
|
359
367
|
catch { throw new JobError('JOB_REQUEST_INVALID'); }
|
|
360
|
-
assertJobApiSchema(value !== null && typeof value === 'object' ? (value as { schema?: unknown }).schema : undefined);
|
|
368
|
+
assertJobApiSchema(value !== null && typeof value === 'object' ? (value as { schema?: unknown }).schema : undefined, schema);
|
|
361
369
|
return value;
|
|
362
370
|
}
|
|
363
371
|
|
|
364
372
|
/** Check the complete existing next batch before accepting its read cursor. */
|
|
365
|
-
function nextValue(value: unknown, request: JobNextRequest): JobNextValue {
|
|
373
|
+
function nextValue(value: unknown, request: JobNextRequest | JobNextRequestV3): JobNextValue {
|
|
366
374
|
const result = jobObject(value, ['schema', 'verb', 'jobId', 'requestId', 'generation', 'ok', 'value']);
|
|
367
375
|
if (result.ok !== true || result.verb !== 'next' || result.jobId !== request.jobId) throw new JobError('JOB_REQUEST_INVALID');
|
|
368
376
|
jobInteger(result.generation);
|
|
@@ -377,6 +385,13 @@ function nextValue(value: unknown, request: JobNextRequest): JobNextValue {
|
|
|
377
385
|
switch (event.type) {
|
|
378
386
|
case 'act': {
|
|
379
387
|
const actId = jobId((event.act as {actId?: unknown} | null)?.actId);
|
|
388
|
+
// A record-and-package host also finalizes record acts; the act's own schema picks the decoder.
|
|
389
|
+
if ((event.act as {schema?: unknown}).schema === JOB_RECORD_ACT_SCHEMA) {
|
|
390
|
+
const act = parseRecordAct(event.act);
|
|
391
|
+
if (act.jobId !== request.jobId || act.actId !== actId ||
|
|
392
|
+
!(JOB_RECORD_ACT_KINDS as readonly string[]).includes(act.kind)) throw new JobError('JOB_ACT_INVALID');
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
380
395
|
const act = parseConsumerAct(Buffer.from(JSON.stringify(event.act)), request.jobId, actId);
|
|
381
396
|
if (!(JOB_ENABLED_ACT_KINDS as readonly string[]).includes(act.kind)) throw new JobError('JOB_ACT_INVALID');
|
|
382
397
|
break;
|
|
@@ -400,13 +415,30 @@ function nextValue(value: unknown, request: JobNextRequest): JobNextValue {
|
|
|
400
415
|
return batch as unknown as JobNextValue;
|
|
401
416
|
}
|
|
402
417
|
|
|
403
|
-
|
|
404
|
-
|
|
418
|
+
/** The longest whole act wait an agent may ask for; each server `next` stays within `jobWaitLimitMs`. */
|
|
419
|
+
export const jobActWaitLimitMs = 600_000;
|
|
420
|
+
|
|
421
|
+
/** Outcome of one bounded act wait. `value` is the verbatim accepted response envelope. */
|
|
422
|
+
export type JobActWaitResult =
|
|
423
|
+
| {readonly kind: 'act' | 'closed'; readonly value: unknown; readonly batch: JobNextValue}
|
|
424
|
+
| {readonly kind: 'refused'; readonly value: unknown}
|
|
425
|
+
| {readonly kind: 'timeout'; readonly value: unknown; readonly batch: JobNextValue | null; readonly cursor: string | null};
|
|
426
|
+
|
|
427
|
+
/** One `next` exchange. The transport must honour `signal` and return the response unread. */
|
|
428
|
+
export type JobNextTransport = (request: JobNextRequest | JobNextRequestV3, signal: AbortSignal) => Promise<Response>;
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Transport-independent act wait shared by `job next --until act` and the host-bound
|
|
432
|
+
* `waitForJobAct`: cursor progression, one monotonic deadline, caller cancellation and
|
|
433
|
+
* the act / closed / refusal / timeout outcome. Caller cancellation rejects with its reason.
|
|
434
|
+
*/
|
|
435
|
+
export async function waitForActBatch(send: JobNextTransport, initial: JobNextRequest | JobNextRequestV3, waitMs: number,
|
|
436
|
+
signal?: AbortSignal): Promise<JobActWaitResult> {
|
|
405
437
|
const controller = new AbortController();
|
|
406
438
|
const timeout = new Error('JOB_NEXT_TIMEOUT');
|
|
407
|
-
const cancel = () => controller.abort(
|
|
408
|
-
|
|
409
|
-
if (
|
|
439
|
+
const cancel = () => controller.abort(signal?.reason);
|
|
440
|
+
signal?.addEventListener('abort', cancel, {once: true});
|
|
441
|
+
if (signal?.aborted) cancel();
|
|
410
442
|
const deadline = performance.now() + waitMs;
|
|
411
443
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
412
444
|
const expire = () => {
|
|
@@ -430,16 +462,16 @@ async function waitForAct(endpoint: string, initial: JobNextRequest, waitMs: num
|
|
|
430
462
|
}
|
|
431
463
|
let after = initial.after;
|
|
432
464
|
let lastResponse: unknown;
|
|
465
|
+
let lastBatch: JobNextValue | null = null;
|
|
433
466
|
try {
|
|
434
467
|
for (;;) {
|
|
435
468
|
const budget = remaining();
|
|
436
469
|
const request = {...initial, after, waitMs: Math.max(0, Math.floor(Math.min(budget, jobWaitLimitMs)))};
|
|
470
|
+
// An empty window that ended under a millisecond before the deadline would otherwise
|
|
471
|
+
// repeat zero-wait reads until it; sit out that remainder without another request.
|
|
472
|
+
if (!request.waitMs && lastBatch?.events.length === 0) await interrupted;
|
|
437
473
|
// A delayed transport must also dispose its body if cancellation won the race.
|
|
438
|
-
const pending = (
|
|
439
|
-
method: 'POST', redirect: 'error', signal: controller.signal,
|
|
440
|
-
headers: {'Content-Type': 'application/json', Authorization: 'Bearer ' + capability},
|
|
441
|
-
body: JSON.stringify(request),
|
|
442
|
-
}).then(response => {
|
|
474
|
+
const pending = send(request, controller.signal).then(response => {
|
|
443
475
|
if (controller.signal.aborted) {
|
|
444
476
|
try { void response.body?.cancel().catch(() => {}); } catch {}
|
|
445
477
|
controller.signal.throwIfAborted();
|
|
@@ -447,38 +479,44 @@ async function waitForAct(endpoint: string, initial: JobNextRequest, waitMs: num
|
|
|
447
479
|
return response;
|
|
448
480
|
});
|
|
449
481
|
const response = await Promise.race([pending, interrupted]);
|
|
450
|
-
const value = await readJobResponse(response, interrupted);
|
|
482
|
+
const value = await readJobResponse(response, interrupted, initial.schema);
|
|
451
483
|
remaining();
|
|
452
|
-
if (!response.ok || (value as {ok?: unknown}).ok === false) {
|
|
453
|
-
write(JSON.stringify(value));
|
|
454
|
-
process.exitCode = 1;
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
484
|
+
if (!response.ok || (value as {ok?: unknown}).ok === false) return {kind: 'refused', value};
|
|
457
485
|
const batch = nextValue(value, request);
|
|
458
486
|
remaining();
|
|
459
|
-
if (batch.events.some(event => event.type === 'act')) {
|
|
460
|
-
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
if (batch.status === 'closed' || batch.events.some(event => event.type === 'closed')) {
|
|
464
|
-
write(JSON.stringify(value));
|
|
465
|
-
console.error('JOB_CLOSED');
|
|
466
|
-
process.exitCode = 1;
|
|
467
|
-
return;
|
|
468
|
-
}
|
|
487
|
+
if (batch.events.some(event => event.type === 'act')) return {kind: 'act', value, batch};
|
|
488
|
+
if (batch.status === 'closed' || batch.events.some(event => event.type === 'closed')) return {kind: 'closed', value, batch};
|
|
469
489
|
lastResponse = value;
|
|
490
|
+
lastBatch = batch;
|
|
470
491
|
after = batch.cursor;
|
|
471
492
|
}
|
|
472
493
|
} catch (error) {
|
|
473
494
|
if (!controller.signal.aborted && performance.now() >= deadline) controller.abort(timeout);
|
|
474
495
|
if (controller.signal.reason !== timeout) throw error;
|
|
475
|
-
|
|
476
|
-
console.error('JOB_NEXT_TIMEOUT');
|
|
477
|
-
process.exitCode = 3;
|
|
496
|
+
return {kind: 'timeout', value: lastResponse, batch: lastBatch, cursor: after};
|
|
478
497
|
} finally {
|
|
479
498
|
clearTimeout(timer);
|
|
480
|
-
|
|
499
|
+
signal?.removeEventListener('abort', cancel);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
async function waitForAct(endpoint: string, initial: JobNextRequest, waitMs: number, capability: string,
|
|
504
|
+
write: (text: string) => void, options: JobCLIOptions): Promise<void> {
|
|
505
|
+
const result = await waitForActBatch((request, signal) => (options.fetch ?? fetch)(endpoint, {
|
|
506
|
+
method: 'POST', redirect: 'error', signal,
|
|
507
|
+
headers: {'Content-Type': 'application/json', Authorization: 'Bearer ' + capability},
|
|
508
|
+
body: JSON.stringify(request),
|
|
509
|
+
}), initial, waitMs, options.signal);
|
|
510
|
+
if (result.kind === 'timeout') {
|
|
511
|
+
if (result.value !== undefined) write(JSON.stringify(result.value));
|
|
512
|
+
console.error('JOB_NEXT_TIMEOUT');
|
|
513
|
+
process.exitCode = 3;
|
|
514
|
+
return;
|
|
481
515
|
}
|
|
516
|
+
write(JSON.stringify(result.value));
|
|
517
|
+
if (result.kind === 'act') return;
|
|
518
|
+
if (result.kind === 'closed') console.error('JOB_CLOSED');
|
|
519
|
+
process.exitCode = 1;
|
|
482
520
|
}
|
|
483
521
|
|
|
484
522
|
export async function jobCommand(args: readonly string[], options: JobCLIOptions = {}): Promise<void> {
|
package/src/job-contract.ts
CHANGED
|
@@ -31,7 +31,7 @@ export const JOB_RECORD_ACT_SCHEMA = 'rig-review/act@4' as const;
|
|
|
31
31
|
export const JOB_PARTS_VERDICT_ACT_SCHEMA = 'rig-review/act@5' as const;
|
|
32
32
|
/** Fresh checkpoint, parts-verdict, rig/post review-verdict and signoff writers. Image-review and interview-picks stay @2; record acts stay @4. */
|
|
33
33
|
export const JOB_COMMENTS_ACT_SCHEMA = 'rig-review/act@6' as const;
|
|
34
|
-
/** @6 plus an optional per-comment `context
|
|
34
|
+
/** @6 plus an optional per-comment `context` (#714). */
|
|
35
35
|
export const JOB_COMMENT_CONTEXT_ACT_SCHEMA = 'rig-review/act@7' as const;
|
|
36
36
|
/** @7 plus a mesh payload on a compiled rig's Request changes (#952). */
|
|
37
37
|
export const JOB_MESH_EDITS_ACT_SCHEMA = 'rig-review/act@8' as const;
|
|
@@ -625,8 +625,8 @@ export type JobPartsVerdictAct = Omit<Extract<JobLegacyAct, {kind: 'parts-verdic
|
|
|
625
625
|
};
|
|
626
626
|
|
|
627
627
|
/** Historical @2 acts remain readable without being backfilled or relabelled.
|
|
628
|
-
* Fresh
|
|
629
|
-
export type JobAct = JobLegacyAct | JobRigReviewAct | JobPartsVerdictAct | JobCommentsAct | JobRigMeshEditsAct;
|
|
628
|
+
* Fresh comments use @6, live rig comments carrying context use @7, and rig verdicts carrying mesh edits use @8. */
|
|
629
|
+
export type JobAct = JobLegacyAct | JobRigReviewAct | JobPartsVerdictAct | JobCommentsAct | JobContextCommentsAct | JobRigMeshEditsAct;
|
|
630
630
|
|
|
631
631
|
/** Authenticated browser provenance. The daemon validates identity and hashes PNG bytes. */
|
|
632
632
|
export interface JobRigCapture {
|
|
@@ -1223,6 +1223,11 @@ export type RecordAct = Pick<JobLegacyAct,
|
|
|
1223
1223
|
export type SourceV3 = JobSourceBinding | RecordSource;
|
|
1224
1224
|
export type ActV3 = JobAct | RecordAct;
|
|
1225
1225
|
|
|
1226
|
+
/**
|
|
1227
|
+
* `recordPublication`, `recordActSchema` and `askBatch` describe the host, not the current head.
|
|
1228
|
+
* `ask-batch` applies only to a record-retained head publication; a package head refuses `JOB_REQUEST_INVALID`,
|
|
1229
|
+
* so a consumer checks the publication's mode as well as the flag (#972).
|
|
1230
|
+
*/
|
|
1226
1231
|
export interface JobCapabilitiesV3 extends JobCapabilities {
|
|
1227
1232
|
readonly recordPublication: true;
|
|
1228
1233
|
readonly recordActSchema: typeof JOB_RECORD_ACT_SCHEMA;
|
package/src/job-host.ts
CHANGED
|
@@ -10,6 +10,8 @@ export type {
|
|
|
10
10
|
JobHostAttachFailure,
|
|
11
11
|
} from './job-front.ts';
|
|
12
12
|
export type {JobSessionOptions, JobSession} from './job-session.ts';
|
|
13
|
+
export {waitForJobAct} from './job-act-wait.ts';
|
|
14
|
+
export type {JobActWaitOptions, JobActWaitOutcome} from './job-act-wait.ts';
|
|
13
15
|
export type {JobWorkerOptions} from './job-worker.ts';
|
|
14
16
|
export {prepareJobRecordSource} from './job-source.ts';
|
|
15
17
|
export type {
|
package/src/job-session.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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_MESH_EDITS_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,
|
|
4
|
+
JOB_API_SCHEMA, JOB_API_V3_SCHEMA, JOB_ACT_SCHEMA, JOB_COMMENTS_ACT_SCHEMA, JOB_COMMENT_CONTEXT_ACT_SCHEMA, JOB_MESH_EDITS_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,
|
|
8
8
|
type JobSubject, type NextValueV3, type PendingAskV3, type PublicationV3, type RecordPublicationReader, type RecordSubject, type StatusV3,
|
|
9
9
|
} from './job-contract.ts';
|
|
10
10
|
import { bindJobAsk, bindJobRecordAsk, finalizeJobAct, parseUISubmission, prepareJobRecordAct, prepareJobStill } from './job-act.ts';
|
|
11
|
-
import { atSubject, isRecordSource, parseRecordSource, parseCommentsAct, parseMeshEditsAct, jobApiSchemaForMode, jobHash, jobPartsEnumeratorVersion, jobWaitLimitMs, requestDigest, sameCapability } from './job-api.ts';
|
|
11
|
+
import { atSubject, isRecordSource, parseRecordSource, parseCommentsAct, parseContextCommentsAct, parseMeshEditsAct, jobApiSchemaForMode, jobHash, jobPartsEnumeratorVersion, jobWaitLimitMs, requestDigest, sameCapability } from './job-api.ts';
|
|
12
12
|
import {
|
|
13
13
|
assertStoredCheckpointEvidence, assertJobRoot, assertJobSourceCurrent, assertRetainedSnapshotIntact, captureJobRoot, isRetainedRecordSource, loadRetainedJobReview, prepareJobSource, jobSnapshotHash, removeOwnedJobSnapshot, verifyJobRecordSourceFresh,
|
|
14
14
|
type JobPublicationReader, type JobRetainedSource, type JobRetainedSourceV3, type JobRootIdentity,
|
|
@@ -141,6 +141,8 @@ export class JobSession {
|
|
|
141
141
|
private operations = 0;
|
|
142
142
|
private disposed = false;
|
|
143
143
|
private observedGeneration: number;
|
|
144
|
+
/** A strict attach shares the live host's store but not its in-process listeners. */
|
|
145
|
+
private readonly attached: boolean;
|
|
144
146
|
|
|
145
147
|
/** Last durable generation successfully read by this session. Requires no I/O. */
|
|
146
148
|
get lastObservedGeneration(): number { return this.observedGeneration; }
|
|
@@ -160,6 +162,7 @@ export class JobSession {
|
|
|
160
162
|
}
|
|
161
163
|
this.publicationMode = options.publicationMode ?? (options.readRecordPublished ? 'record-and-package' : 'package-only');
|
|
162
164
|
this.apiSchema = jobApiSchemaForMode(this.publicationMode);
|
|
165
|
+
this.attached = readonlyTarget !== undefined;
|
|
163
166
|
const root = captureJobRoot(options.root), state = canonicalStatePath(options.stateDir);
|
|
164
167
|
if (within(root.path, state)) {
|
|
165
168
|
throw new JobError('JOB_SOURCE_UNRETAINABLE', 'Job state must be outside the designated work root');
|
|
@@ -450,7 +453,8 @@ export class JobSession {
|
|
|
450
453
|
|
|
451
454
|
async execute(input: JobAgentRequest | AgentRequestV3 | JobFetchActRequest | JobFetchActRequestV3, signal: AbortSignal): Promise<unknown> {
|
|
452
455
|
if (input.jobId !== this.jobId) throw new JobError('JOB_UNKNOWN');
|
|
453
|
-
|
|
456
|
+
// An attached session never sees the live host's notify(), so it watches shared writes like subscribe.
|
|
457
|
+
if (input.verb === 'next') return this.next(input.after, input.waitMs, signal, this.attached ? 'events' : false);
|
|
454
458
|
if (input.verb === 'fetch-act') {
|
|
455
459
|
const current = this.current();
|
|
456
460
|
if (!current.active) throw new JobError('JOB_CLOSED');
|
|
@@ -637,7 +641,8 @@ export class JobSession {
|
|
|
637
641
|
const storedAct = current.data.acts[actId];
|
|
638
642
|
if (!storedAct) throw new JobError('JOB_ACT_UNKNOWN');
|
|
639
643
|
// Validation must not replace the stored representation or reorder its keys.
|
|
640
|
-
if (
|
|
644
|
+
if (storedAct.schema === JOB_COMMENTS_ACT_SCHEMA) parseCommentsAct(storedAct);
|
|
645
|
+
if (storedAct.schema === JOB_COMMENT_CONTEXT_ACT_SCHEMA) parseContextCommentsAct(storedAct);
|
|
641
646
|
if (storedAct.schema === JOB_MESH_EDITS_ACT_SCHEMA) parseMeshEditsAct(storedAct);
|
|
642
647
|
const still = 'still' in storedAct ? storedAct.still : undefined;
|
|
643
648
|
const actBytes = Buffer.from(JSON.stringify(storedAct));
|
|
@@ -819,11 +824,16 @@ export class JobSession {
|
|
|
819
824
|
};
|
|
820
825
|
}
|
|
821
826
|
|
|
822
|
-
|
|
827
|
+
/**
|
|
828
|
+
* `observeWrites` polls the shared store revision for commits from other sessions. `'revision'` (subscribe)
|
|
829
|
+
* wakes on any commit; `'events'` (an attached act wait) wakes only once a commit left an event to deliver.
|
|
830
|
+
*/
|
|
831
|
+
private async next(after: string | null, waitMs: number, signal: AbortSignal,
|
|
832
|
+
observeWrites: false | 'revision' | 'events' = false): Promise<JobNextValue | NextValueV3> {
|
|
823
833
|
if (waitMs < 0 || waitMs > jobWaitLimitMs || !Number.isSafeInteger(waitMs)) throw new JobError('JOB_REQUEST_INVALID');
|
|
824
834
|
if (signal.aborted) throw new JobError('JOB_REQUEST_INVALID', 'Request cancelled');
|
|
825
835
|
// Capture before reading events so a commit between the read and listener registration still wakes us.
|
|
826
|
-
|
|
836
|
+
let revision = observeWrites ? this.store.revision(this.jobId) : null;
|
|
827
837
|
const ready = this.events(after);
|
|
828
838
|
if (ready.status !== 'timeout' || !waitMs) return ready;
|
|
829
839
|
await new Promise<void>((resolve, reject) => {
|
|
@@ -834,7 +844,14 @@ export class JobSession {
|
|
|
834
844
|
const fail = (error: unknown) => { if (settled) return; settled = true; cleanup(); reject(error); };
|
|
835
845
|
const abort = () => fail(new JobError('JOB_REQUEST_INVALID', 'Request cancelled'));
|
|
836
846
|
const changed = () => {
|
|
837
|
-
try {
|
|
847
|
+
try {
|
|
848
|
+
const observed = this.store.revision(this.jobId);
|
|
849
|
+
if (observed === revision) return;
|
|
850
|
+
if (observeWrites === 'revision') return finish();
|
|
851
|
+
// An act wait stays open across a write without a deliverable event (display receipt).
|
|
852
|
+
revision = observed;
|
|
853
|
+
if (this.events(after).status !== 'timeout') finish();
|
|
854
|
+
}
|
|
838
855
|
catch (error) { fail(error); }
|
|
839
856
|
};
|
|
840
857
|
const timer = setTimeout(finish, waitMs);
|
|
@@ -857,7 +874,7 @@ export class JobSession {
|
|
|
857
874
|
let after = input.after;
|
|
858
875
|
while (!input.signal.aborted) {
|
|
859
876
|
let value: JobNextValue | NextValueV3;
|
|
860
|
-
try { value = await this.next(after, jobWaitLimitMs, input.signal,
|
|
877
|
+
try { value = await this.next(after, jobWaitLimitMs, input.signal, 'revision'); }
|
|
861
878
|
catch (error) {
|
|
862
879
|
if (input.signal.aborted && error instanceof JobError && error.code === 'JOB_REQUEST_INVALID') return;
|
|
863
880
|
throw error;
|
package/src/rebuild.ts
CHANGED
|
@@ -11,7 +11,8 @@ import {MESH_DELTA_APPLIED_SOURCE,recordFor,type AnyJobView} from '../web/rebuil
|
|
|
11
11
|
* handoff and says whether it reproduces the inspected rig.
|
|
12
12
|
*/
|
|
13
13
|
import { createHash } from 'node:crypto';
|
|
14
|
-
import { existsSync } from 'node:fs';
|
|
14
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
15
|
+
import { createRequire } from 'node:module';
|
|
15
16
|
import { copyFile, mkdir, readFile, readdir, realpath, rename, rm, writeFile, lstat } from 'node:fs/promises';
|
|
16
17
|
import { dirname, isAbsolute, join, posix, relative, resolve, sep } from 'node:path';
|
|
17
18
|
import { object, packagePath, safeFile, type ReviewPackage } from './manifest.ts';
|
|
@@ -549,7 +550,7 @@ export interface ClothJob {
|
|
|
549
550
|
wallMs: { propose: number | null; build: number | null };
|
|
550
551
|
}
|
|
551
552
|
/** #111: what a cloth Apply runs with — the handoff's painting and keypoints (absolute), parts.json and the reader's tags; never from the client. */
|
|
552
|
-
export interface ClothPlan { source: string; keypoints: string; partsJson: unknown; targets: string[] }
|
|
553
|
+
export interface ClothPlan { source: string; keypoints: string; partsJson: unknown; targets: string[]; namedAssembly?: BuildPlan | RebuildError }
|
|
553
554
|
/**
|
|
554
555
|
* The tags the installed reader accepts, read off its own source (`src/cloth.ts`'s `CLOTH_TARGETS`); when that text
|
|
555
556
|
* does not state them, the tags the config's `cloth` block already declares (and `read: false`).
|
|
@@ -922,6 +923,24 @@ async function stageInputDigest(dir:string,spec:string):Promise<string>{
|
|
|
922
923
|
return sha256(JSON.stringify(rows));
|
|
923
924
|
}
|
|
924
925
|
export interface BuildPlan { source: string; full: string; head: string | null; inputsHash: string; inputs: AssembledView['inputs'] }
|
|
926
|
+
const assembledView = (plan: BuildPlan): AssembledView => ({
|
|
927
|
+
inputs: plan.inputs, refusals: [], checkFails: [], lines: [], seam: [], seamPairs: [],
|
|
928
|
+
recomposite: { line: null, before: null, after: null, errorMap: null }, parts: null,
|
|
929
|
+
});
|
|
930
|
+
|
|
931
|
+
/** Read the assembly stamp with the same installation that runs the producer CLI. */
|
|
932
|
+
function clothAssemblyChanges(producer: InstalledTool, config: string, manifest: unknown): string[] {
|
|
933
|
+
if (!hasAssemblyConfig(manifest)) return [];
|
|
934
|
+
const root = realpathSync(producer.root), requireProducer = createRequire(join(root, 'package.json'));
|
|
935
|
+
const reader = realpathSync(requireProducer.resolve('@rig-c/parts/assembly-reading'));
|
|
936
|
+
if (!reader.startsWith(root + sep)) throw new Error('The installed producer does not supply @rig-c/parts/assembly-reading');
|
|
937
|
+
const { assemblyConfigChanges } = requireProducer(reader) as {
|
|
938
|
+
assemblyConfigChanges(config: string, parts: unknown): string[];
|
|
939
|
+
};
|
|
940
|
+
// The successful propose command has already validated its parts manifest.
|
|
941
|
+
return assemblyConfigChanges(config, manifest);
|
|
942
|
+
}
|
|
943
|
+
const hasAssemblyConfig = (manifest: unknown) => !!manifest && typeof manifest === 'object' && Object.hasOwn(manifest, 'assembly_config');
|
|
925
944
|
/**
|
|
926
945
|
* The build's inputs for a patch (`null` refusal line when the handoff declares no painting and full run): the painting
|
|
927
946
|
* and the runs, and every config-relative file the patched config names for assemble, each resolved against the handoff
|
|
@@ -973,6 +992,7 @@ async function hashBuild(build: string, id: string, assetPrefix = '/rebuild'): P
|
|
|
973
992
|
|
|
974
993
|
/** One rebuild at a time per review instance; finished jobs stay readable by id. */
|
|
975
994
|
export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
995
|
+
const handoffBuildPlan = (config: JsonValue) => buildPlan(p.handoff!, config, abs => relative(p.root, abs).split(sep).join('/'));
|
|
976
996
|
const assetPrefix = options.assetPrefix ?? '/rebuild', stripPrefix = options.stripPrefix ?? '/density-strip';
|
|
977
997
|
const jobs = new Map<string, RebuildJob | PatchJob | DeltaJob | RetargetJob | AnimationJob>();
|
|
978
998
|
let running: string | null = null;
|
|
@@ -1639,14 +1659,14 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
|
1639
1659
|
await writeFile(join(dir, 'config.json'), JSON.stringify(doc, null, 2) + '\n', { mode: 0o600 });
|
|
1640
1660
|
}
|
|
1641
1661
|
/** #111: a cloth job whose written config declares limbs is built as `build` does; otherwise as `rig --config`. */
|
|
1642
|
-
const building = job.op === 'build' ||
|
|
1662
|
+
const building = () => job.op === 'build' || job.cloth?.route === 'build';
|
|
1643
1663
|
/** #115 (and #111's build route): assemble → rig → check on `config.json`, already written into the scratch directory. */
|
|
1644
|
-
async function runBuild(push: (line: string) => void, what: string): Promise<ProcessResult> {
|
|
1664
|
+
async function runBuild(push: (line: string) => void, what: string, { source, full, head }: BuildPlan): Promise<ProcessResult> {
|
|
1645
1665
|
// #112: build forwards `--environment` to its check stage (rig-parts build --help, 1.48.0).
|
|
1646
1666
|
if (world) await writeFile(join(dir, 'environment.json'), world.text, { mode: 0o600 });
|
|
1647
|
-
push(`review: ${producer.package} ${producer.version} build --config config.json (${what}) --source <handoff source> --full <handoff full>${
|
|
1667
|
+
push(`review: ${producer.package} ${producer.version} build --config config.json (${what}) --source <handoff source> --full <handoff full>${head ? ' --head <handoff head>' : ''} --seam-pairs${world ? ` --environment environment.json (the exported schedule, ${world.record.steps} step(s), sha256 ${world.record.sha256.slice(0, 16)})` : ''} → scratch out (assemble → rig → check)`);
|
|
1648
1668
|
// `--seam-pairs` (forwarded to check): the setup-pose seam split by pair on a pass too, so every Apply shows its `seam pair` lines.
|
|
1649
|
-
built = await runTool(producer.bin, ['build', '--config', 'config.json', '--source',
|
|
1669
|
+
built = await runTool(producer.bin, ['build', '--config', 'config.json', '--source', source, '--full', full, ...(head ? ['--head', head] : []), '--out', 'out', '--seam-pairs', ...(world ? ['--environment', 'environment.json'] : []), ...args], { cwd: dir, onLine: push });
|
|
1650
1670
|
const readout = buildReadout(built.lines);
|
|
1651
1671
|
// A check that ran and found a bar not met is check's judgment, kept beside the build (as for a `rig` patch):
|
|
1652
1672
|
// build prints "stopped at check; N bar(s) not met" (a check that refused its input says "no later stage ran").
|
|
@@ -1679,16 +1699,42 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
|
1679
1699
|
}
|
|
1680
1700
|
push(`review: the written config differs from cloth.json at ${c.written.count} path(s), every one under the sections propose splices${c.written.sections.length ? ` (${c.written.sections.join(', ')})` : ''}`);
|
|
1681
1701
|
let op: ProcessResult;
|
|
1682
|
-
if (c.route === 'build') op = await runBuild(push, 'the config propose wrote');
|
|
1702
|
+
if (c.route === 'build') op = await runBuild(push, 'the config propose wrote', plan!);
|
|
1683
1703
|
else {
|
|
1684
|
-
|
|
1685
|
-
|
|
1704
|
+
const changes = clothAssemblyChanges(producer, join(dir, 'config.json'), plan2.partsJson);
|
|
1705
|
+
if (changes.length) {
|
|
1706
|
+
let rebuild: BuildPlan;
|
|
1707
|
+
try {
|
|
1708
|
+
if (plan2.namedAssembly instanceof RebuildError) throw plan2.namedAssembly;
|
|
1709
|
+
rebuild = await handoffBuildPlan(patched);
|
|
1710
|
+
assertNamedFilesHeld(input, written, [dir, ...options.starts]);
|
|
1711
|
+
const held = newBuildFile(input as JsonValue, written as JsonValue);
|
|
1712
|
+
if (held) throw new RebuildError('EDIT_PATCH_PATH_HELD', `${held} names a file the handoff config does not; a patch may not name a new file (review sends no path)`);
|
|
1713
|
+
if (plan2.namedAssembly && rebuild.inputsHash !== plan2.namedAssembly.inputsHash) {
|
|
1714
|
+
throw new RebuildError('REBUILD_INPUTS_CHANGED', 'the package or its producer handoff changed during the rebuild');
|
|
1715
|
+
}
|
|
1716
|
+
} catch (error) {
|
|
1717
|
+
if (!(error instanceof RebuildError)) throw error;
|
|
1718
|
+
push(`review: ${error.message}`);
|
|
1719
|
+
return { exitCode: 1, lines: [error.message], stdout: [], wallMs: proposed.wallMs };
|
|
1720
|
+
}
|
|
1721
|
+
c.route = 'build';
|
|
1722
|
+
job.assembled = assembledView(rebuild);
|
|
1723
|
+
op = await runBuild(push, 'the config propose wrote', rebuild);
|
|
1724
|
+
if (op.exitCode === 0 && plan2.namedAssembly && (await handoffBuildPlan(patched)).inputsHash !== rebuild.inputsHash) {
|
|
1725
|
+
throw new RebuildError('REBUILD_INPUTS_CHANGED', 'the package or its producer handoff changed during the rebuild');
|
|
1726
|
+
}
|
|
1727
|
+
} else {
|
|
1728
|
+
push(`review: ${producer.package} ${producer.version} rig --config config.json (the config propose wrote) → scratch rig`);
|
|
1729
|
+
op = await runTool(producer.bin, ['rig', '--config', 'config.json', '--parts', inputs.parts, '--out', 'rig', ...args], { cwd: dir, onLine: push });
|
|
1730
|
+
}
|
|
1686
1731
|
}
|
|
1687
1732
|
c.wallMs.build = op.wallMs;
|
|
1688
1733
|
return { ...op, wallMs: proposed.wallMs + op.wallMs };
|
|
1689
1734
|
}
|
|
1690
1735
|
return apply(job, dir, inputs, resolved, {
|
|
1691
|
-
cmd: job.op === 'cloth' ? 'propose' : job.op,
|
|
1736
|
+
cmd: job.op === 'cloth' ? 'propose' : job.op,
|
|
1737
|
+
get spec() { return building() ? 'out/rig' : 'rig'; },
|
|
1692
1738
|
async run(push) {
|
|
1693
1739
|
if (job.op === 'cloth' && cloth) return runCloth(push);
|
|
1694
1740
|
if (job.op === 'build' && plan) {
|
|
@@ -1697,7 +1743,7 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
|
1697
1743
|
absolutizeBuildFiles(doc, value => (isAbsolute(value) ? value : resolve(dirname(inputs.config), value)));
|
|
1698
1744
|
await stageRequirements(dir, inputs.requirements, doc);
|
|
1699
1745
|
await writeFile(join(dir, 'config.json'), JSON.stringify(doc, null, 2) + '\n', { mode: 0o600 });
|
|
1700
|
-
return runBuild(push, `the handoff config with ${job.request.patch.ops.length} patch op(s)
|
|
1746
|
+
return runBuild(push, `the handoff config with ${job.request.patch.ops.length} patch op(s)`, plan);
|
|
1701
1747
|
}
|
|
1702
1748
|
if (job.op === 'retune') {
|
|
1703
1749
|
// retune reads the inspected rig and writes only --out; what it holds it refuses by name (RETUNE_REQUEST_HELD).
|
|
@@ -1737,7 +1783,7 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
|
1737
1783
|
},
|
|
1738
1784
|
wallMs: ms => { job.wallMs.op = ms; },
|
|
1739
1785
|
async flags(push) {
|
|
1740
|
-
if (building && built) {
|
|
1786
|
+
if (building() && built) {
|
|
1741
1787
|
job.exitCode = built.exitCode;
|
|
1742
1788
|
const lines = buildLines(built.lines);
|
|
1743
1789
|
job.producerLine = lines.filter(l => /^build:\s/.test(l)).at(-1) ?? job.producerLine;
|
|
@@ -1762,7 +1808,9 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
|
1762
1808
|
}, {
|
|
1763
1809
|
diff: files => { const rigJson = files.documents.find(d => d.file === 'rig.json'); job.files = files; job.diff = rigJson ? { count: rigJson.count, paths: rigJson.paths } : null; },
|
|
1764
1810
|
// #115: build runs check itself, on the parts it assembled; its check.json is read after the op (flags).
|
|
1765
|
-
|
|
1811
|
+
get check() {
|
|
1812
|
+
return building() ? undefined : (summary: CheckSummary, wallMs: number | null) => { job.wallMs.check = wallMs; job.check = summary; };
|
|
1813
|
+
},
|
|
1766
1814
|
// #139: a retune Apply reads the check retune ran on its revision (retune.json, bound by its hash rows) unless the
|
|
1767
1815
|
// Apply checks under an exported world (retune's check reads the default one) or the producer carries no line.
|
|
1768
1816
|
// #174: a remesh patch the same, from remesh.json — remesh checked the revision with the request's pack flags,
|
|
@@ -1826,7 +1874,11 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
|
1826
1874
|
if (building) {
|
|
1827
1875
|
const held = newBuildFile(original, patched);
|
|
1828
1876
|
if (held) throw new RebuildError('EDIT_PATCH_PATH_HELD', `${held} names a file the handoff config does not; a patch may not name a new file (review sends no path)`);
|
|
1829
|
-
plan = await
|
|
1877
|
+
plan = await handoffBuildPlan(patched);
|
|
1878
|
+
} else if (clothPlan && p.handoff!.full && hasAssemblyConfig(clothPlan.partsJson) && buildNamedFiles(patched).length) {
|
|
1879
|
+
// These assembly sidecars can sit outside the handoff's hashed run directories. Bind them before scratch reuse.
|
|
1880
|
+
try { clothPlan.namedAssembly = await handoffBuildPlan(patched); }
|
|
1881
|
+
catch (error) { if (!(error instanceof RebuildError)) throw error; clothPlan.namedAssembly = error; }
|
|
1830
1882
|
}
|
|
1831
1883
|
const route = patch.op.cmd === 'remesh' ? 'remesh' : clothing ? 'cloth' : building ? 'build' : patchRoute(patch.ops, resolved.producer.version);
|
|
1832
1884
|
const baselineNow = route === 'retune' ? await settledBaseline() : null;
|
|
@@ -1834,7 +1886,8 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
|
1834
1886
|
if (op === 'rig' || op === 'build' || op === 'cloth') {
|
|
1835
1887
|
try { assertWholeRigBaseline(await settledBaseline()); } catch (e) { if (e instanceof BaselineError) throw new RebuildError(e.code, e.message.slice(e.code.length + 2)); throw e; }
|
|
1836
1888
|
}
|
|
1837
|
-
const
|
|
1889
|
+
const buildIdentity = plan ?? clothPlan?.namedAssembly;
|
|
1890
|
+
const id = patchId({ sourceHash: p.sourceHash, configHash: rebuildConfigIdentity(inputs), patch, producer: `${resolved.producer.package}@${resolved.producer.version}`, compiler: `${resolved.compiler.package}@${resolved.compiler.version}`, op, ...(buildIdentity && !(buildIdentity instanceof RebuildError) ? { buildInputs: buildIdentity.inputsHash } : {}), ...(world ? { environment: world.record.sha256 } : {}), ...(clothPlan ? { cloth: p.handoff!.record.keypoints!.sha256 } : {}) });
|
|
1838
1891
|
const current = jobs.get(id);
|
|
1839
1892
|
if (current?.status === 'running') return { status: 202, body: snapshot(current) };
|
|
1840
1893
|
if (busy()) return { status: 200, body: { status: 'refused', error: busy(), producerLine: null } };
|
|
@@ -1846,7 +1899,7 @@ export function createRebuilds(p: ReviewPackage, options: RebuildOptions) {
|
|
|
1846
1899
|
const reused = await reuse<PatchJob>(dir, id);
|
|
1847
1900
|
if (reused) { jobs.set(id, reused); latestId = id; bodies.set(id, body); await landed(reused); return { status: 200, body: snapshot(reused) }; }
|
|
1848
1901
|
const job: PatchJob = { schema: REBUILD_SCHEMA, kind: 'patch', id, status: 'running', reused: false, op, request: { patch, patchSha256: patchSha256(patch), configHash: inputs.configHash }, producer: tool(resolved.producer), compiler: tool(resolved.compiler), lines: [], producerLine: null, exitCode: null, wallMs: { op: null, compile: null, check: null }, check: null, diff: null, files: null, remesh: null, build: null,
|
|
1849
|
-
...(plan ? { assembled:
|
|
1902
|
+
...(plan ? { assembled: assembledView(plan) } : {}),
|
|
1850
1903
|
...(world ? { environment: world.record } : {}),
|
|
1851
1904
|
...(clothPlan ? { cloth: { route: building ? 'build' as const : 'rig' as const, inputs: { source: p.handoff!.record.source?.path ?? '', keypoints: { ...p.handoff!.record.keypoints! } }, refusals: [], line: null, written: null, links: [], wallMs: { propose: null, build: null } } } : {}) };
|
|
1852
1905
|
jobs.set(id, job); running = id; bodies.set(id, body);
|
package/web/catalog-en.ts
CHANGED
|
@@ -3524,6 +3524,7 @@ export const enCatalog: Readonly<Record<string, string>> = {
|
|
|
3524
3524
|
"job.submit.JOB_STILL_UNAVAILABLE": "The retained rig image is unavailable — reopen the current rig review and try again.",
|
|
3525
3525
|
"job.submit.JOB_STILL_OUTPUT_FAILED": "The rig image could not be saved — ask the host operator to check the output destination.",
|
|
3526
3526
|
"Review was not submitted: {0}": "Review was NOT submitted: {0}",
|
|
3527
|
+
"JOB_CAPABILITY_LINK_LOST": "This page lost its access link. Open the original link again to restore access.",
|
|
3527
3528
|
"JOB_CAPABILITY_REQUIRED": "This page has lost its access. Ask the agent to open the job again.",
|
|
3528
3529
|
"JOB_CLOSED": "JOB_CLOSED",
|
|
3529
3530
|
"JOB_CURSOR_INVALID": "JOB_CURSOR_INVALID",
|
package/web/catalog-ko.ts
CHANGED
|
@@ -3524,6 +3524,7 @@ export const koCatalog: Readonly<Record<string, string>> = {
|
|
|
3524
3524
|
"job.submit.JOB_STILL_UNAVAILABLE": "보존된 리그 이미지를 사용할 수 없어요 — 현재 리그 리뷰를 다시 열고 제출해 주세요.",
|
|
3525
3525
|
"job.submit.JOB_STILL_OUTPUT_FAILED": "리그 이미지를 저장하지 못했어요 — 호스트 담당자에게 출력 위치 확인을 요청해 주세요.",
|
|
3526
3526
|
"Review was not submitted: {0}": "리뷰가 제출되지 않았어요: {0}",
|
|
3527
|
+
"JOB_CAPABILITY_LINK_LOST": "이 페이지가 접근 링크를 잃었어요. 처음 받은 링크를 다시 열어 주세요.",
|
|
3527
3528
|
"JOB_CAPABILITY_REQUIRED": "이 페이지의 접근 권한이 만료됐어요. 에이전트에게 작업을 다시 열어 달라고 요청해 주세요.",
|
|
3528
3529
|
"JOB_CLOSED": "JOB_CLOSED",
|
|
3529
3530
|
"JOB_CURSOR_INVALID": "JOB_CURSOR_INVALID",
|
package/web/i18n.ts
CHANGED
|
@@ -972,10 +972,10 @@ export function assertCatalogParity(
|
|
|
972
972
|
// Bar 2: Hardcoded visible string check across web/*.html and web/*.ts
|
|
973
973
|
function decodeHtmlEntities(str: string): string {
|
|
974
974
|
return str
|
|
975
|
-
.replace(/&/g, '&')
|
|
976
975
|
.replace(/</g, '<')
|
|
977
976
|
.replace(/>/g, '>')
|
|
978
|
-
.replace(/"/g, '"')
|
|
977
|
+
.replace(/"/g, '"')
|
|
978
|
+
.replace(/&/g, '&');
|
|
979
979
|
}
|
|
980
980
|
|
|
981
981
|
function isSingleSymbolOrKeycap(text: string): boolean {
|
package/web/inspector-blocks.ts
CHANGED
|
@@ -173,7 +173,7 @@ export function bindInspectorBlocks(options:InspectorBlocksOptions):InspectorBlo
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
/** Compose the real rig acts into C6; all fields, submit nodes and their listeners retain identity. */
|
|
176
|
-
export function mountRigInspector(root:Document=document,actHome?:HTMLElement):BottomPanel&{actBar:ActBar;answersRendered:boolean;syncActRow:()=>void;comments:{button:HTMLButtonElement;panel:HTMLElement}} {
|
|
176
|
+
export function mountRigInspector(root:Document=document,actHome?:HTMLElement):BottomPanel&{body:HTMLElement;actBar:ActBar;answersRendered:boolean;syncActRow:()=>void;comments:{button:HTMLButtonElement;panel:HTMLElement}} {
|
|
177
177
|
const inspector=root.querySelector<HTMLElement>('.inspector')!,body=inspector.querySelector<HTMLElement>('.inspector-body')!,heading=inspector.querySelector<HTMLElement>('.inspector-heading')!;
|
|
178
178
|
const feedback=root.getElementById('inspector-feedback')!,dialog=root.getElementById('review-dialog')!;
|
|
179
179
|
const [label,status,actions]=[feedback.querySelector<HTMLLabelElement>('label[for="review-status"]')!,root.getElementById('review-status')!,dialog.querySelector<HTMLElement>('.review-dialog-actions')!];
|
|
@@ -198,7 +198,7 @@ export function mountRigInspector(root:Document=document,actHome?:HTMLElement):B
|
|
|
198
198
|
// still use this row once its caller has hidden every answer control.
|
|
199
199
|
actHome.hidden=act.hidden||(!question&&!refusal);root.getElementById('dirty')!.hidden=!actHome.hidden;
|
|
200
200
|
};
|
|
201
|
-
return {...bottom,actBar,answersRendered:false,syncActRow,comments:{button:comment,panel:feedback}};
|
|
201
|
+
return {...bottom,body,actBar,answersRendered:false,syncActRow,comments:{button:comment,panel:feedback}};
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
export interface BottomPanel {
|