rig-review 2.10.0 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/REVIEW_PACKAGE.md +56 -0
- package/package.json +1 -1
- package/src/job-contract.ts +73 -0
- package/src/job-front.ts +9 -5
- package/src/job-source.ts +84 -7
- package/web/catalog-en.ts +18 -0
- package/web/catalog-ko.ts +18 -0
- package/web/job-session.ts +79 -13
- package/web/styles.css +18 -0
package/docs/REVIEW_PACKAGE.md
CHANGED
|
@@ -1360,3 +1360,59 @@ with the earlier closed key set refuse evidence-bearing sources. New consumers
|
|
|
1360
1360
|
require the signed extended contract. Owner-screen integration,
|
|
1361
1361
|
EN/KO visual verification and later release serving have their own acceptance
|
|
1362
1362
|
steps.
|
|
1363
|
+
|
|
1364
|
+
### Sealed plan step text
|
|
1365
|
+
|
|
1366
|
+
Both publication-pinned `api/review` responses append delivery-only `planText`
|
|
1367
|
+
when the accepted source has a plan. The daemon authenticates `project.json`
|
|
1368
|
+
from that publication's retained snapshot against its record seal and existing
|
|
1369
|
+
`projectHash`, then projects `does`, `produces`, `bar` and `rests_on`.
|
|
1370
|
+
|
|
1371
|
+
The projected envelope has ordered keys `schema`, `record`, `status`, `steps`.
|
|
1372
|
+
`schema` is `rig-review/job-plan-text@1`, `record` is `{path:"project.json",sha256}`,
|
|
1373
|
+
and `status` is `projected`. Rows follow the accepted plan's exact id/hash order.
|
|
1374
|
+
Each row has `id`, `hash`, optional `does`, `produces`, `bar`, `rests_on`, then
|
|
1375
|
+
`issues`. Each field supplies exactly one value or an ordered
|
|
1376
|
+
`{field,reason:"absent"|"invalid"|"limit"}` issue. Scalar values are strings and
|
|
1377
|
+
`rests_on` is an ordered string array. Empty strings/arrays, whitespace, line
|
|
1378
|
+
endings, Unicode form, duplicate references and array order are preserved.
|
|
1379
|
+
Producer extras stay outside this display projection.
|
|
1380
|
+
|
|
1381
|
+
D1 matches only accepted ids, preserving source order and existing checkpoint
|
|
1382
|
+
aliases (`planStepId ?? checkpointId`). D2 retains its existing whole-plan
|
|
1383
|
+
count/ordered-id admission checks. Hashes are the producer's opaque accepted
|
|
1384
|
+
identities. The existing reader retains responsibility for their semantic value.
|
|
1385
|
+
|
|
1386
|
+
The unavailable envelope has `schema`, `record` (or null),
|
|
1387
|
+
`status:"unavailable"`, `reason`. Named reasons are
|
|
1388
|
+
`PLAN_TEXT_RECORD_UNAVAILABLE`, `PLAN_TEXT_RECORD_UNSUPPORTED`,
|
|
1389
|
+
`PLAN_TEXT_STEPS_ABSENT`, `PLAN_TEXT_STEPS_INVALID`,
|
|
1390
|
+
`PLAN_TEXT_MAPPING_UNAVAILABLE` and `PLAN_TEXT_LIMIT`. The UI shows the named
|
|
1391
|
+
absence and existing ids/hashes. Partial valid fields remain visible beside
|
|
1392
|
+
their missing/invalid field labels. Existing act authority and historical
|
|
1393
|
+
metadata omission retain their fallback behavior.
|
|
1394
|
+
|
|
1395
|
+
The server retains its 8 MiB project read bound. Display limits are 4,096 plan
|
|
1396
|
+
steps, 4,096 `rests_on` entries and 512 KiB UTF-8 for `planText`. Whole owner
|
|
1397
|
+
metadata retains its 2 MiB bound. A small unavailable envelope replaces an
|
|
1398
|
+
oversized projection. If that envelope also exceeds the response budget, the
|
|
1399
|
+
server returns `JOB_BODY_LIMIT` with `PLAN_TEXT_LIMIT`. Values remain complete
|
|
1400
|
+
within the admitted display budget.
|
|
1401
|
+
|
|
1402
|
+
The browser checks the closed grammar, metadata/source association, record SHA
|
|
1403
|
+
and ordered id/hash mapping. Field values have the normal daemon's authority.
|
|
1404
|
+
Type-valid post-server text mutation can pass those checks. The server's sealed
|
|
1405
|
+
record authentication and the browser's source/grammar checks are their
|
|
1406
|
+
respective validation boundaries. Checkpoint evidence retains its established
|
|
1407
|
+
raw-member authentication.
|
|
1408
|
+
|
|
1409
|
+
This metadata is produced at response time. Source/act schemas, producer reader
|
|
1410
|
+
DTOs, stable `job-host` exports, durable state and canonical hash preimages retain
|
|
1411
|
+
their existing definitions. Checkpoint and signoff values continue through their
|
|
1412
|
+
existing forms, outcome select and submission lifecycle.
|
|
1413
|
+
|
|
1414
|
+
Under HQ ruling 7896ec71, the official D2 consumer gate is the supported
|
|
1415
|
+
record-checkpoint flow following Create #395 integration. Create owns the actual
|
|
1416
|
+
producer receipt. Review's plan-signoff rendering has synthetic UI coverage.
|
|
1417
|
+
Normal CLI plan-signoff bootstrap and `plan-approved` act@4 ingestion are a
|
|
1418
|
+
separate Create follow-up. (Naru, 2026-11-11)
|
package/package.json
CHANGED
package/src/job-contract.ts
CHANGED
|
@@ -178,6 +178,79 @@ export interface JobPlanIdentity {
|
|
|
178
178
|
readonly steps: readonly JobPlanStepIdentity[];
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
/** Ephemeral owner metadata, projected by the daemon from the sealed project. */
|
|
182
|
+
export const JOB_PLAN_TEXT_SCHEMA = 'rig-review/job-plan-text@1' as const;
|
|
183
|
+
export const JOB_PLAN_TEXT_FIELDS = ['does', 'produces', 'bar', 'rests_on'] as const;
|
|
184
|
+
export type JobPlanTextField = typeof JOB_PLAN_TEXT_FIELDS[number];
|
|
185
|
+
export interface JobPlanTextStep {
|
|
186
|
+
readonly id: string;
|
|
187
|
+
readonly hash: string;
|
|
188
|
+
does?: string;
|
|
189
|
+
produces?: string;
|
|
190
|
+
bar?: string;
|
|
191
|
+
rests_on?: readonly string[];
|
|
192
|
+
readonly issues: {field: JobPlanTextField; reason: 'absent' | 'invalid' | 'limit'}[];
|
|
193
|
+
}
|
|
194
|
+
export const JOB_PLAN_TEXT_UNAVAILABLE = [
|
|
195
|
+
'PLAN_TEXT_RECORD_UNAVAILABLE', 'PLAN_TEXT_RECORD_UNSUPPORTED', 'PLAN_TEXT_STEPS_ABSENT',
|
|
196
|
+
'PLAN_TEXT_STEPS_INVALID', 'PLAN_TEXT_MAPPING_UNAVAILABLE', 'PLAN_TEXT_LIMIT',
|
|
197
|
+
] as const;
|
|
198
|
+
export type JobPlanTextProjection = {
|
|
199
|
+
readonly schema: typeof JOB_PLAN_TEXT_SCHEMA;
|
|
200
|
+
readonly record: {readonly path: 'project.json'; readonly sha256: string};
|
|
201
|
+
readonly status: 'projected';
|
|
202
|
+
readonly steps: readonly JobPlanTextStep[];
|
|
203
|
+
} | {
|
|
204
|
+
readonly schema: typeof JOB_PLAN_TEXT_SCHEMA;
|
|
205
|
+
readonly record: {readonly path: 'project.json'; readonly sha256: string} | null;
|
|
206
|
+
readonly status: 'unavailable';
|
|
207
|
+
readonly reason: typeof JOB_PLAN_TEXT_UNAVAILABLE[number];
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
/** Closed delivery grammar. Field contents have the normal daemon's authority. */
|
|
211
|
+
export function parseJobPlanTextProjection(value: unknown): JobPlanTextProjection {
|
|
212
|
+
const fail = (): never => {throw new Error('PLAN_TEXT_METADATA_INVALID');};
|
|
213
|
+
const object = (input: unknown, keys: readonly string[]): Record<string, unknown> => {
|
|
214
|
+
if (!input || typeof input !== 'object' || Array.isArray(input) ||
|
|
215
|
+
Object.keys(input).some(key => !keys.includes(key))) return fail();
|
|
216
|
+
return input as Record<string, unknown>;
|
|
217
|
+
};
|
|
218
|
+
const envelope = object(value, ['schema', 'record', 'status', 'steps', 'reason']);
|
|
219
|
+
if (envelope.schema !== JOB_PLAN_TEXT_SCHEMA || !Object.hasOwn(envelope, 'record') ||
|
|
220
|
+
new TextEncoder().encode(JSON.stringify(value)).length > 512 * 1024) return fail();
|
|
221
|
+
if (envelope.record !== null) {
|
|
222
|
+
const record = object(envelope.record, ['path', 'sha256']);
|
|
223
|
+
if (record.path !== 'project.json' || typeof record.sha256 !== 'string' || !/^[a-f0-9]{64}$/.test(record.sha256)) return fail();
|
|
224
|
+
}
|
|
225
|
+
if (envelope.status === 'unavailable') {
|
|
226
|
+
if (Object.hasOwn(envelope, 'steps') || !(JOB_PLAN_TEXT_UNAVAILABLE as readonly unknown[]).includes(envelope.reason)) return fail();
|
|
227
|
+
return value as JobPlanTextProjection;
|
|
228
|
+
}
|
|
229
|
+
if (envelope.status !== 'projected' || envelope.record === null || Object.hasOwn(envelope, 'reason') ||
|
|
230
|
+
!Array.isArray(envelope.steps) || envelope.steps.length > 4096) return fail();
|
|
231
|
+
const ids = new Set<string>();
|
|
232
|
+
for (const raw of envelope.steps) {
|
|
233
|
+
const row = object(raw, ['id', 'hash', ...JOB_PLAN_TEXT_FIELDS, 'issues']);
|
|
234
|
+
if (typeof row.id !== 'string' || row.id.length > 128 || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(row.id) ||
|
|
235
|
+
ids.has(row.id) || typeof row.hash !== 'string' || !/^[a-f0-9]{64}$/.test(row.hash) || !Array.isArray(row.issues)) return fail();
|
|
236
|
+
ids.add(row.id);
|
|
237
|
+
const missing = JOB_PLAN_TEXT_FIELDS.filter(field => !Object.hasOwn(row, field));
|
|
238
|
+
if (row.issues.length !== missing.length) return fail();
|
|
239
|
+
row.issues.forEach((rawIssue, index) => {
|
|
240
|
+
const issue = object(rawIssue, ['field', 'reason']);
|
|
241
|
+
if (issue.field !== missing[index] || typeof issue.reason !== 'string' || !['absent', 'invalid', 'limit'].includes(issue.reason)) fail();
|
|
242
|
+
});
|
|
243
|
+
for (const field of JOB_PLAN_TEXT_FIELDS) {
|
|
244
|
+
if (!Object.hasOwn(row, field)) continue;
|
|
245
|
+
const content = row[field];
|
|
246
|
+
if (field === 'rests_on') {
|
|
247
|
+
if (!Array.isArray(content) || content.length > 4096 || content.some(item => typeof item !== 'string')) return fail();
|
|
248
|
+
} else if (typeof content !== 'string') return fail();
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return value as JobPlanTextProjection;
|
|
252
|
+
}
|
|
253
|
+
|
|
181
254
|
/** Literal work-root-relative manifest path, validated at runtime. */
|
|
182
255
|
export type JobPartsManifestPath = string;
|
|
183
256
|
/** Literal path relative to the bound manifest directory. */
|
package/src/job-front.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {checkpointEvidenceMetadata, readCheckpointEvidenceBytes} from './job-che
|
|
|
3
3
|
import { JOB_API_SCHEMA, JOB_ACT_SCHEMA, type JobErrorCode, type JobHostPorts, type JobId, type JobPublicationMode, type JobResult, type JobReviewerBinding } from './job-contract.ts';
|
|
4
4
|
import { createJobHostPorts, jobBody, jobHash, jobId, jobObject, jobPartsEnumeratorVersion } from './job-api.ts';
|
|
5
5
|
import { JobSession } from './job-session.ts';
|
|
6
|
-
import { assertJobRoot, assertRetainedSnapshotIntact, captureJobRoot, isRetainedRecordSource, type JobRootIdentity } from './job-source.ts';
|
|
6
|
+
import { assertJobRoot, assertRetainedSnapshotIntact, captureJobRoot, planTextMetadata, isRetainedRecordSource, type JobRootIdentity } from './job-source.ts';
|
|
7
7
|
import type { JobWorkerOptions } from './job-worker.ts';
|
|
8
8
|
import { JobError, JobStore } from './job-store.ts';
|
|
9
9
|
import { loadReview, safeFile, packagePath, type ReviewPackage } from './manifest.ts';
|
|
@@ -265,9 +265,13 @@ export function retainedPublicationRoutes(session: JobSession) {
|
|
|
265
265
|
if (key !== display.publication.instanceKey) return failure('JOB_DISPLAY_MISMATCH', 409);
|
|
266
266
|
if (crop && session.status().publication?.publicationId !== publicationId)
|
|
267
267
|
return failure('JOB_ACT_SOURCE_STALE', 409);
|
|
268
|
-
const json = (value: unknown) =>
|
|
269
|
-
|
|
270
|
-
|
|
268
|
+
const json = (value: Record<string, unknown>) => {
|
|
269
|
+
const payload = path === 'api/review' ? planTextMetadata(retained, value) : value;
|
|
270
|
+
const body = JSON.stringify(payload);
|
|
271
|
+
return new Response(request.method === 'HEAD' ? null : body, {
|
|
272
|
+
headers: {...headers, 'Content-Type': 'application/json'},
|
|
273
|
+
});
|
|
274
|
+
};
|
|
271
275
|
const sealedFile = async (relativePath: string) => {
|
|
272
276
|
const seal = retained.seals.find(file => file.path === relativePath);
|
|
273
277
|
if (!seal) return failure('JOB_SOURCE_UNRETAINABLE', 404);
|
|
@@ -442,7 +446,7 @@ export function retainedPublicationRoutes(session: JobSession) {
|
|
|
442
446
|
const code = error instanceof JobError ? error.code :
|
|
443
447
|
error instanceof Error && error.message.startsWith('PARTS_COMMENT_STALE_SOURCE:')
|
|
444
448
|
? 'PARTS_COMMENT_STALE_SOURCE' : 'JOB_SOURCE_MISMATCH';
|
|
445
|
-
const message = error instanceof JobError && /^
|
|
449
|
+
const message = error instanceof JobError && /^(CHECKPOINT_EVIDENCE|PLAN_TEXT)_[A-Z_]+$/.test(error.message)
|
|
446
450
|
? error.message : undefined;
|
|
447
451
|
return failure(code, errorStatus[code as JobErrorCode] ?? 409, undefined, message);
|
|
448
452
|
}
|
package/src/job-source.ts
CHANGED
|
@@ -5,12 +5,12 @@ import { mkdir, open, rm, writeFile } from 'node:fs/promises';
|
|
|
5
5
|
import { dirname, isAbsolute, join, posix, relative, resolve, sep } from 'node:path';
|
|
6
6
|
import { PNG } from 'pngjs';
|
|
7
7
|
import {
|
|
8
|
-
JOB_API_V3_SCHEMA,
|
|
8
|
+
JOB_API_V3_SCHEMA, JOB_PLAN_TEXT_FIELDS, JOB_PLAN_TEXT_SCHEMA,
|
|
9
9
|
JOB_PARTS_ENUMERATOR_RANGE,
|
|
10
10
|
} from './job-contract.ts';
|
|
11
11
|
import type {
|
|
12
12
|
JobCheckpointEvidence, JobFileIdentity, JobImageSetInput, JobInterviewDiagnostics, JobInterviewRecord, JobModelSourceBinding, JobPartsEnumerator, JobPartsFileReference, JobPartsIdentity, JobPlanIdentity, JobPublishRequest,
|
|
13
|
-
JobSelector, JobSourceBinding, JobSubject,
|
|
13
|
+
JobSelector, JobSourceBinding, JobSubject, JobPlanTextProjection, JobPlanTextStep,
|
|
14
14
|
OptionContext, OptionSource, PackageResultV3, PlanContext, PlanSource, ProjectRecord, PublishRequestV3,
|
|
15
15
|
RecordFreeze, RecordOptionResult, RecordPlanResult, RecordPublicationReader, RecordPublishedContext,
|
|
16
16
|
RecordReaderInput, RecordResult, RecordSource, RecordSubject,
|
|
@@ -655,7 +655,7 @@ async function readRecordPublishedPhase(
|
|
|
655
655
|
return parseRecordPublishedContext(raw, input.result, input.record);
|
|
656
656
|
}
|
|
657
657
|
|
|
658
|
-
function readProjectRecordBytes(root: string, record: ProjectRecord): {
|
|
658
|
+
function readProjectRecordBytes(root: string, record: ProjectRecord, allowLegacySchema = false): {
|
|
659
659
|
readonly bytes: Buffer;
|
|
660
660
|
readonly project: Record<string, unknown>;
|
|
661
661
|
} {
|
|
@@ -663,15 +663,15 @@ function readProjectRecordBytes(root: string, record: ProjectRecord): {
|
|
|
663
663
|
try {
|
|
664
664
|
stat = lstatSync(join(root, record.path));
|
|
665
665
|
} catch {
|
|
666
|
-
throw new JobError('JOB_RECORD_MOVED');
|
|
666
|
+
throw new JobError(allowLegacySchema ? 'JOB_SOURCE_UNRETAINABLE' : 'JOB_RECORD_MOVED');
|
|
667
667
|
}
|
|
668
|
-
if (!stat.isFile()) throw new JobError('JOB_RECORD_MOVED');
|
|
668
|
+
if (!stat.isFile()) throw new JobError(allowLegacySchema ? 'JOB_SOURCE_UNRETAINABLE' : 'JOB_RECORD_MOVED');
|
|
669
669
|
if (stat.size > maxProjectBytes) throw new JobError('JOB_SOURCE_UNRETAINABLE');
|
|
670
670
|
let bytes: Buffer;
|
|
671
671
|
try {
|
|
672
672
|
bytes = sourceBytes(root, record.path);
|
|
673
673
|
} catch {
|
|
674
|
-
throw new JobError('JOB_RECORD_MOVED');
|
|
674
|
+
throw new JobError(allowLegacySchema ? 'JOB_SOURCE_UNRETAINABLE' : 'JOB_RECORD_MOVED');
|
|
675
675
|
}
|
|
676
676
|
if (jobHash(bytes) !== record.sha256) throw new JobError('JOB_RECORD_MOVED');
|
|
677
677
|
let project: Record<string, unknown>;
|
|
@@ -680,7 +680,7 @@ function readProjectRecordBytes(root: string, record: ProjectRecord): {
|
|
|
680
680
|
} catch {
|
|
681
681
|
throw new JobError('JOB_RECORD_INCOMPLETE');
|
|
682
682
|
}
|
|
683
|
-
if (project.schema !== 'rig-create/project@0') throw new JobError('JOB_RECORD_INCOMPLETE');
|
|
683
|
+
if (!allowLegacySchema && project.schema !== 'rig-create/project@0') throw new JobError('JOB_RECORD_INCOMPLETE');
|
|
684
684
|
return { bytes, project };
|
|
685
685
|
}
|
|
686
686
|
|
|
@@ -712,6 +712,83 @@ function readClosureFileBytes(root: string, file: JobFileIdentity): Buffer {
|
|
|
712
712
|
return bytes;
|
|
713
713
|
}
|
|
714
714
|
|
|
715
|
+
/** Delivery-only projection through the existing retained record reader. */
|
|
716
|
+
export function projectRetainedPlanText(retained: JobRetainedSourceV3): JobPlanTextProjection | undefined {
|
|
717
|
+
const {source, record} = retained;
|
|
718
|
+
const plan = source.plan;
|
|
719
|
+
if (!plan) return undefined;
|
|
720
|
+
let identity: {path: 'project.json'; sha256: string} | null = null;
|
|
721
|
+
const unavailable = (reason: Extract<JobPlanTextProjection, {status:'unavailable'}>['reason']): JobPlanTextProjection =>
|
|
722
|
+
({schema:JOB_PLAN_TEXT_SCHEMA, record:identity, status:'unavailable', reason});
|
|
723
|
+
if (!record || !source.projectHash) return unavailable('PLAN_TEXT_RECORD_UNAVAILABLE');
|
|
724
|
+
if (record.path !== 'project.json') return unavailable('PLAN_TEXT_RECORD_UNSUPPORTED');
|
|
725
|
+
const seals = retained.seals.filter(file => file.path === record.path);
|
|
726
|
+
if (record.sha256 !== source.projectHash || seals.length !== 1 || seals[0]!.sha256 !== record.sha256 ||
|
|
727
|
+
isRetainedRecordSource(retained) && (!retained.source.files.some(file => file.path === record.path && file.sha256 === record.sha256) ||
|
|
728
|
+
retained.source.record.path !== record.path || retained.source.record.sha256 !== record.sha256)) {
|
|
729
|
+
throw new JobError('JOB_SOURCE_MISMATCH', 'PLAN_TEXT_RECORD_MISMATCH');
|
|
730
|
+
}
|
|
731
|
+
identity = {path:'project.json', sha256:record.sha256};
|
|
732
|
+
let project: Record<string, unknown>;
|
|
733
|
+
try {project = readProjectRecordBytes(retained.snapshotRoot, identity, true).project;}
|
|
734
|
+
catch (error) {
|
|
735
|
+
if (error instanceof JobError && error.code === 'JOB_RECORD_MOVED')
|
|
736
|
+
throw new JobError('JOB_SOURCE_MISMATCH', 'PLAN_TEXT_RECORD_HASH_MISMATCH');
|
|
737
|
+
throw new JobError('JOB_SOURCE_UNRETAINABLE', 'PLAN_TEXT_RECORD_UNAVAILABLE');
|
|
738
|
+
}
|
|
739
|
+
if (project.schema !== 'rig-create/project@0') return unavailable('PLAN_TEXT_RECORD_UNSUPPORTED');
|
|
740
|
+
if (!Object.hasOwn(project, 'plan')) return unavailable('PLAN_TEXT_STEPS_ABSENT');
|
|
741
|
+
const rawPlan = asPlainObject(project.plan);
|
|
742
|
+
if (!rawPlan) return unavailable('PLAN_TEXT_STEPS_INVALID');
|
|
743
|
+
if (!Object.hasOwn(rawPlan, 'steps')) return unavailable('PLAN_TEXT_STEPS_ABSENT');
|
|
744
|
+
const rawSteps = rawPlan.steps;
|
|
745
|
+
if (!Array.isArray(rawSteps)) return unavailable('PLAN_TEXT_STEPS_INVALID');
|
|
746
|
+
if (plan.steps.length > 4096) return unavailable('PLAN_TEXT_LIMIT');
|
|
747
|
+
if (isRetainedRecordSource(retained) && (rawSteps.length !== plan.steps.length ||
|
|
748
|
+
rawSteps.some((raw, index) => asPlainObject(raw)?.id !== plan.steps[index]?.id)))
|
|
749
|
+
return unavailable('PLAN_TEXT_MAPPING_UNAVAILABLE');
|
|
750
|
+
const wanted = new Set(plan.steps.map(step => step.id));
|
|
751
|
+
const matched = new Map<string, Record<string, unknown> | null>();
|
|
752
|
+
for (const raw of rawSteps) {
|
|
753
|
+
const step = asPlainObject(raw);
|
|
754
|
+
if (typeof step?.id === 'string' && wanted.has(step.id))
|
|
755
|
+
matched.set(step.id, matched.has(step.id) ? null : step);
|
|
756
|
+
}
|
|
757
|
+
if (plan.steps.some(step => !matched.get(step.id))) return unavailable('PLAN_TEXT_MAPPING_UNAVAILABLE');
|
|
758
|
+
const steps = plan.steps.map<JobPlanTextStep>(step => {
|
|
759
|
+
const raw = matched.get(step.id)!;
|
|
760
|
+
const fields: Omit<JobPlanTextStep, 'id' | 'hash' | 'issues'> = {};
|
|
761
|
+
const issues: JobPlanTextStep['issues'] = [];
|
|
762
|
+
for (const field of JOB_PLAN_TEXT_FIELDS) {
|
|
763
|
+
const value = raw[field];
|
|
764
|
+
if (!Object.hasOwn(raw, field)) issues.push({field, reason:'absent'});
|
|
765
|
+
else if (field === 'rests_on') {
|
|
766
|
+
if (!Array.isArray(value) || value.some(item => typeof item !== 'string')) issues.push({field, reason:'invalid'});
|
|
767
|
+
else if (value.length > 4096) issues.push({field, reason:'limit'});
|
|
768
|
+
else fields.rests_on = value;
|
|
769
|
+
} else if (typeof value === 'string') fields[field] = value;
|
|
770
|
+
else issues.push({field, reason:'invalid'});
|
|
771
|
+
}
|
|
772
|
+
return {id:step.id, hash:step.hash, ...fields, issues};
|
|
773
|
+
});
|
|
774
|
+
const projection: JobPlanTextProjection = {schema:JOB_PLAN_TEXT_SCHEMA, record:identity, status:'projected', steps};
|
|
775
|
+
return Buffer.byteLength(JSON.stringify(projection)) > 512 * 1024 ? unavailable('PLAN_TEXT_LIMIT') : projection;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/** Keep the normal owner metadata budget, including the small fallback itself. */
|
|
779
|
+
export function planTextMetadata(retained: JobRetainedSourceV3, metadata: Record<string, unknown>): Record<string, unknown> {
|
|
780
|
+
const projection = projectRetainedPlanText(retained);
|
|
781
|
+
if (!projection) return metadata;
|
|
782
|
+
let result = {...metadata, planText:projection};
|
|
783
|
+
if (Buffer.byteLength(JSON.stringify(result)) > 2 * 1024 * 1024) {
|
|
784
|
+
result = {...metadata, planText:{schema:JOB_PLAN_TEXT_SCHEMA, record:projection.record,
|
|
785
|
+
status:'unavailable', reason:'PLAN_TEXT_LIMIT'}};
|
|
786
|
+
if (Buffer.byteLength(JSON.stringify(result)) > 2 * 1024 * 1024)
|
|
787
|
+
throw new JobError('JOB_BODY_LIMIT', 'PLAN_TEXT_LIMIT');
|
|
788
|
+
}
|
|
789
|
+
return result;
|
|
790
|
+
}
|
|
791
|
+
|
|
715
792
|
function decodeRetainedRecordProject(
|
|
716
793
|
snapshotRoot: string,
|
|
717
794
|
seals: readonly JobFileIdentity[],
|
package/web/catalog-en.ts
CHANGED
|
@@ -89,6 +89,24 @@ export const enCatalog: Readonly<Record<string, string>> = {
|
|
|
89
89
|
"interview.other": "Describe your choice",
|
|
90
90
|
"interview.otherPending": "Other stays pending until a tailored set is offered and explicitly picked.",
|
|
91
91
|
"interview.autoPending": "Auto stays pending until the agent records the covered decision.",
|
|
92
|
+
"job.plan.does": "Does",
|
|
93
|
+
"job.plan.produces": "Produces",
|
|
94
|
+
"job.plan.bar": "Bar",
|
|
95
|
+
"job.plan.rests_on": "Rests on",
|
|
96
|
+
"job.plan.noText": "Step text is not available; showing ids and hashes.",
|
|
97
|
+
"job.plan.field.absent": "Not supplied in this record.",
|
|
98
|
+
"job.plan.field.invalid": "The supplied field has an unsupported type.",
|
|
99
|
+
"job.plan.field.limit": "The supplied field exceeds the display limit.",
|
|
100
|
+
"PLAN_TEXT_RECORD_UNAVAILABLE": "The retained project record is unavailable.",
|
|
101
|
+
"PLAN_TEXT_RECORD_UNSUPPORTED": "This retained record has no supported project text.",
|
|
102
|
+
"PLAN_TEXT_STEPS_ABSENT": "The record supplies no plan steps.",
|
|
103
|
+
"PLAN_TEXT_STEPS_INVALID": "The record has an unsupported plan step list.",
|
|
104
|
+
"PLAN_TEXT_MAPPING_UNAVAILABLE": "Record steps cannot be matched to the displayed plan.",
|
|
105
|
+
"PLAN_TEXT_LIMIT": "Plan text exceeds the display delivery limit.",
|
|
106
|
+
"PLAN_TEXT_METADATA_INVALID": "Plan text metadata is invalid.",
|
|
107
|
+
"PLAN_TEXT_SOURCE_MISMATCH": "Plan text belongs to a different displayed source.",
|
|
108
|
+
"PLAN_TEXT_RECORD_MISMATCH": "The retained plan record binding differs from the displayed source.",
|
|
109
|
+
"PLAN_TEXT_RECORD_HASH_MISMATCH": "The retained plan record bytes differ from their seal.",
|
|
92
110
|
"interview.recommended": "AI recommendation",
|
|
93
111
|
"interview.note": "Note (optional)",
|
|
94
112
|
"interview.save": "Save explicit picks",
|
package/web/catalog-ko.ts
CHANGED
|
@@ -89,6 +89,24 @@ export const koCatalog: Readonly<Record<string, string>> = {
|
|
|
89
89
|
"interview.other": "원하는 선택을 설명하세요",
|
|
90
90
|
"interview.otherPending": "맞춤 세트가 제시되고 직접 선택할 때까지 기타 응답은 보류됩니다.",
|
|
91
91
|
"interview.autoPending": "에이전트가 해당 결정을 기록할 때까지 자동 위임은 보류됩니다.",
|
|
92
|
+
"job.plan.does": "할 일",
|
|
93
|
+
"job.plan.produces": "산출물",
|
|
94
|
+
"job.plan.bar": "기준",
|
|
95
|
+
"job.plan.rests_on": "근거 답변",
|
|
96
|
+
"job.plan.noText": "단계 설명을 읽을 수 없어 ID와 해시만 표시합니다.",
|
|
97
|
+
"job.plan.field.absent": "이 기록에 제공되지 않았습니다.",
|
|
98
|
+
"job.plan.field.invalid": "제공된 필드의 형식을 지원하지 않습니다.",
|
|
99
|
+
"job.plan.field.limit": "제공된 필드가 표시 한도를 초과합니다.",
|
|
100
|
+
"PLAN_TEXT_RECORD_UNAVAILABLE": "보존된 프로젝트 기록을 읽을 수 없습니다.",
|
|
101
|
+
"PLAN_TEXT_RECORD_UNSUPPORTED": "이 보존 기록의 프로젝트 설명 형식을 지원하지 않습니다.",
|
|
102
|
+
"PLAN_TEXT_STEPS_ABSENT": "기록에 계획 단계가 제공되지 않았습니다.",
|
|
103
|
+
"PLAN_TEXT_STEPS_INVALID": "기록의 계획 단계 목록 형식을 지원하지 않습니다.",
|
|
104
|
+
"PLAN_TEXT_MAPPING_UNAVAILABLE": "기록의 단계를 표시된 계획과 연결할 수 없습니다.",
|
|
105
|
+
"PLAN_TEXT_LIMIT": "계획 설명이 표시 전달 한도를 초과합니다.",
|
|
106
|
+
"PLAN_TEXT_METADATA_INVALID": "계획 설명 메타데이터가 올바르지 않습니다.",
|
|
107
|
+
"PLAN_TEXT_SOURCE_MISMATCH": "계획 설명이 표시된 원본과 일치하지 않습니다.",
|
|
108
|
+
"PLAN_TEXT_RECORD_MISMATCH": "보존된 계획 기록의 연결이 표시된 원본과 다릅니다.",
|
|
109
|
+
"PLAN_TEXT_RECORD_HASH_MISMATCH": "보존된 계획 기록의 바이트가 봉인 해시와 다릅니다.",
|
|
92
110
|
"interview.recommended": "AI 추천",
|
|
93
111
|
"interview.note": "메모 (선택 사항)",
|
|
94
112
|
"interview.save": "선택 기록 저장",
|
package/web/job-session.ts
CHANGED
|
@@ -23,6 +23,7 @@ import type {
|
|
|
23
23
|
import {enCatalog} from './catalog-en.ts';
|
|
24
24
|
import {koCatalog} from './catalog-ko.ts';
|
|
25
25
|
import {t} from './i18n.ts';
|
|
26
|
+
import {JOB_PLAN_TEXT_FIELDS, parseJobPlanTextProjection, type JobPlanTextProjection} from '../src/job-contract.ts';
|
|
26
27
|
import {JOB_HUB_READY, jobHubMessageMatches, type JobHubBinding} from './job-hub.ts';
|
|
27
28
|
import {recordJobRigDraw, freezeJobRigCapture, copyJobRigViewport, createJobRigSubmission, jobRigPixelPlacement,
|
|
28
29
|
type JobRigDraw, type JobRigDrawState} from './job-rig-capture.ts';
|
|
@@ -132,6 +133,23 @@ export function prepareJobForms<Form>(
|
|
|
132
133
|
return prepared;
|
|
133
134
|
}
|
|
134
135
|
|
|
136
|
+
/** Association checks for normal daemon-authoritative plan text metadata. */
|
|
137
|
+
export function jobPlanTextForSource(value: unknown, source: SourceV3): JobPlanTextProjection | undefined {
|
|
138
|
+
if (value === undefined) return undefined;
|
|
139
|
+
const projection = parseJobPlanTextProjection(value);
|
|
140
|
+
const mismatch = () => {throw new Error('PLAN_TEXT_SOURCE_MISMATCH');};
|
|
141
|
+
if (!source.plan) return mismatch();
|
|
142
|
+
if (projection.record && (projection.record.sha256 !== source.projectHash ||
|
|
143
|
+
isRecordSource(source) && (source.record.path !== projection.record.path ||
|
|
144
|
+
source.record.sha256 !== projection.record.sha256 ||
|
|
145
|
+
!source.files.some(file => file.path === projection.record!.path && file.sha256 === projection.record!.sha256))))
|
|
146
|
+
return mismatch();
|
|
147
|
+
if (projection.status === 'projected' && (projection.steps.length !== source.plan.steps.length ||
|
|
148
|
+
projection.steps.some((row, index) => row.id !== source.plan!.steps[index]?.id || row.hash !== source.plan!.steps[index]?.hash)))
|
|
149
|
+
return mismatch();
|
|
150
|
+
return projection;
|
|
151
|
+
}
|
|
152
|
+
|
|
135
153
|
/** C2 publishes the plan mapping in the ask. Legacy checkpoint metadata is optional guidance. */
|
|
136
154
|
export function jobCheckpointContext(
|
|
137
155
|
ask: PendingAskV3,
|
|
@@ -619,6 +637,7 @@ type JobCheckpointEvidenceMetadata = Omit<JobCheckpointEvidence, 'tiles' | 'tabl
|
|
|
619
637
|
};
|
|
620
638
|
export interface JobInspectionMetadata {
|
|
621
639
|
checkpointEvidence?: readonly JobCheckpointEvidenceMetadata[];
|
|
640
|
+
planText?: JobPlanTextProjection;
|
|
622
641
|
manifest: ReviewManifest;
|
|
623
642
|
recordSource?: undefined;
|
|
624
643
|
sourceHash: string;
|
|
@@ -642,6 +661,7 @@ export interface JobInspectionMetadata {
|
|
|
642
661
|
}
|
|
643
662
|
export interface JobRecordInspectionMetadata {
|
|
644
663
|
checkpointEvidence?: readonly JobCheckpointEvidenceMetadata[];
|
|
664
|
+
planText?: JobPlanTextProjection;
|
|
645
665
|
manifest?: undefined;
|
|
646
666
|
recordSource: RecordSource;
|
|
647
667
|
sourceHash: string;
|
|
@@ -859,6 +879,7 @@ export async function prepareJobInspection(display: DisplayPublicationV3, signal
|
|
|
859
879
|
}
|
|
860
880
|
const objectUrls: string[] = [];
|
|
861
881
|
const media: HTMLVideoElement[] = [];
|
|
882
|
+
if (metadata.planText !== undefined) metadata.planText = jobPlanTextForSource(metadata.planText, publishedSource);
|
|
862
883
|
const rigRoot = document.createElement('div');
|
|
863
884
|
rigRoot.id = 'rig-root';
|
|
864
885
|
let assets: ModelAssets | null = null;
|
|
@@ -1778,6 +1799,59 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1778
1799
|
}
|
|
1779
1800
|
return gallery;
|
|
1780
1801
|
}
|
|
1802
|
+
function planTextList(plan: NonNullable<SourceV3['plan']>, projection: JobPlanTextProjection | undefined,
|
|
1803
|
+
selectedId?: string): HTMLElement {
|
|
1804
|
+
const section = node('section');
|
|
1805
|
+
section.className = 'job-plan-text';
|
|
1806
|
+
if (!projection || projection.status === 'unavailable') {
|
|
1807
|
+
section.append(node('p', 'job.plan.noText'));
|
|
1808
|
+
if (projection) section.append(node('p', projection.reason));
|
|
1809
|
+
}
|
|
1810
|
+
const list = node('ol');
|
|
1811
|
+
list.className = 'job-plan-steps';
|
|
1812
|
+
for (const step of plan.steps) {
|
|
1813
|
+
if (selectedId !== undefined && step.id !== selectedId) continue;
|
|
1814
|
+
const item = node('li');
|
|
1815
|
+
item.dataset.jobPlanStep = step.id;
|
|
1816
|
+
const details = node('details');
|
|
1817
|
+
details.open = true;
|
|
1818
|
+
const title = node('summary');
|
|
1819
|
+
title.textContent = step.id;
|
|
1820
|
+
const hash = node('code');
|
|
1821
|
+
hash.className = 'job-source';
|
|
1822
|
+
hash.textContent = step.hash;
|
|
1823
|
+
details.append(title, hash);
|
|
1824
|
+
const row = projection?.status === 'projected' ? projection.steps.find(row => row.id === step.id && row.hash === step.hash) : undefined;
|
|
1825
|
+
if (row) {
|
|
1826
|
+
const fields = node('dl');
|
|
1827
|
+
for (const field of JOB_PLAN_TEXT_FIELDS) {
|
|
1828
|
+
const term = node('dt', 'job.plan.' + field);
|
|
1829
|
+
const value = node('dd');
|
|
1830
|
+
value.dataset.jobPlanField = field;
|
|
1831
|
+
const issue = row.issues.find(issue => issue.field === field);
|
|
1832
|
+
if (issue) value.append(node('span', 'job.plan.field.' + issue.reason));
|
|
1833
|
+
else if (field === 'rests_on') {
|
|
1834
|
+
const rests = node('ul');
|
|
1835
|
+
for (const text of row.rests_on!) {const rest = node('li'); rest.textContent = text; rests.append(rest);}
|
|
1836
|
+
value.append(rests);
|
|
1837
|
+
} else value.textContent = row[field]!;
|
|
1838
|
+
fields.append(term, value);
|
|
1839
|
+
}
|
|
1840
|
+
details.append(fields);
|
|
1841
|
+
}
|
|
1842
|
+
item.append(details); list.append(item);
|
|
1843
|
+
}
|
|
1844
|
+
list.addEventListener('keydown', event => {
|
|
1845
|
+
const key = event as KeyboardEvent;
|
|
1846
|
+
if (!['ArrowUp', 'ArrowDown'].includes(key.key) || !(key.target instanceof HTMLElement) || key.target.tagName !== 'SUMMARY') return;
|
|
1847
|
+
const summaries = [...list.querySelectorAll<HTMLElement>('summary')];
|
|
1848
|
+
const index = summaries.indexOf(key.target);
|
|
1849
|
+
const next = summaries[index + (key.key === 'ArrowDown' ? 1 : -1)];
|
|
1850
|
+
if (next) {key.preventDefault(); next.focus();}
|
|
1851
|
+
});
|
|
1852
|
+
section.append(list);
|
|
1853
|
+
return section;
|
|
1854
|
+
}
|
|
1781
1855
|
function formFor(ask: PendingAskV3, prepared: JobPreparedInspection): JobForm {
|
|
1782
1856
|
if (ask.publicationId !== prepared.display.publication.publicationId)
|
|
1783
1857
|
throw new Error('JOB_DISPLAY_MISMATCH');
|
|
@@ -1872,10 +1946,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1872
1946
|
fields.prepend(heading);
|
|
1873
1947
|
const guidance = node('p');
|
|
1874
1948
|
guidance.textContent = checkpoint.note;
|
|
1875
|
-
|
|
1876
|
-
planStep.className = 'job-source';
|
|
1877
|
-
planStep.textContent = checkpoint.step.id + ' · ' + checkpoint.step.hash;
|
|
1878
|
-
fields.append(planStep, guidance);
|
|
1949
|
+
fields.append(guidance, planTextList(ask.source.plan!, prepared.metadata.planText, checkpoint.step.id));
|
|
1879
1950
|
const evidence = prepared.checkpointEvidence?.find(item => item.packet.checkpointId === subject.checkpointId);
|
|
1880
1951
|
const declared = ask.source.checkpointEvidence?.find(item => item.checkpointId === subject.checkpointId);
|
|
1881
1952
|
if (Boolean(declared) !== Boolean(evidence) || evidence &&
|
|
@@ -1930,7 +2001,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1930
2001
|
const outcome = selectValues(['', 'pass', 'fail'], ['Pending', 'Pass', 'job.fail']);
|
|
1931
2002
|
outcome.required = true;
|
|
1932
2003
|
outcome.name = 'outcome';
|
|
1933
|
-
fields.append(outcome);
|
|
2004
|
+
fields.append(outcome, note.parentElement!);
|
|
1934
2005
|
read = () => ({ checkpointId: subject.checkpointId, outcome: outcome.value as 'pass' | 'fail', words: note.value });
|
|
1935
2006
|
submitKey = 'job.saveCheckpoint';
|
|
1936
2007
|
}
|
|
@@ -1973,6 +2044,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1973
2044
|
const stage = node('p');
|
|
1974
2045
|
stage.textContent = subject.stage;
|
|
1975
2046
|
fields.append(stage);
|
|
2047
|
+
if (ask.source.plan) fields.append(planTextList(ask.source.plan, prepared.metadata.planText), note.parentElement!);
|
|
1976
2048
|
read = () => ({ stage: subject.stage, decision: 'approved', words: note.value });
|
|
1977
2049
|
submitKey = 'job.signoff';
|
|
1978
2050
|
}
|
|
@@ -2620,14 +2692,8 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
2620
2692
|
summary.append(optionLine);
|
|
2621
2693
|
}
|
|
2622
2694
|
else {
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
for (const step of source.plan.steps) {
|
|
2626
|
-
const item = node('li');
|
|
2627
|
-
item.textContent = step.id + ' · ' + step.hash;
|
|
2628
|
-
list.append(item);
|
|
2629
|
-
}
|
|
2630
|
-
summary.append(list);
|
|
2695
|
+
root.dataset.jobPlanWorkspace = '';
|
|
2696
|
+
summary.append(identity, binding, planTextList(source.plan, prepared.metadata.planText));
|
|
2631
2697
|
}
|
|
2632
2698
|
stage.prepend(summary);
|
|
2633
2699
|
controls.hidden = pair.hidden = transport.hidden = true;
|
package/web/styles.css
CHANGED
|
@@ -498,3 +498,21 @@ body.job-window{display:grid;grid-template-rows:auto auto minmax(0,1fr);height:1
|
|
|
498
498
|
.job-window [data-job-checkpoint-evidence] th,.job-window [data-job-checkpoint-evidence] td{padding:6px 10px;border:1px solid var(--border);text-align:left;white-space:pre-wrap;overflow-wrap:anywhere}
|
|
499
499
|
.job-window [data-job-checkpoint-evidence] caption{text-align:left;margin-bottom:8px}
|
|
500
500
|
.job-window [data-job-checkpoint-evidence] pre{white-space:pre-wrap;overflow-wrap:anywhere}
|
|
501
|
+
|
|
502
|
+
.job-window .job-plan-text{min-width:0;overflow-wrap:anywhere}
|
|
503
|
+
.job-window .job-plan-steps{padding-left:1.4rem;margin:8px 0}
|
|
504
|
+
.job-window .job-plan-steps>li{margin:8px 0}
|
|
505
|
+
.job-window .job-plan-steps summary{cursor:pointer;font-weight:600;overflow-wrap:anywhere}
|
|
506
|
+
.job-window .job-plan-steps code{display:block;overflow-wrap:anywhere}
|
|
507
|
+
.job-window .job-plan-steps dl{margin:8px 0}
|
|
508
|
+
.job-window .job-plan-steps dt{font-weight:600;margin-top:8px}
|
|
509
|
+
.job-window .job-plan-steps dd{margin:2px 0 8px;white-space:pre-wrap;overflow-wrap:anywhere}
|
|
510
|
+
.job-window .job-plan-steps dd ul{padding-left:1.2rem;margin:0}
|
|
511
|
+
|
|
512
|
+
.job-window .job-inspection[data-job-plan-workspace]{grid-template-columns:minmax(0,1fr) minmax(0,1fr);grid-template-rows:minmax(0,1fr)}
|
|
513
|
+
.job-window .job-inspection[data-job-plan-workspace]>.job-sidebar{display:none}
|
|
514
|
+
.job-window .job-inspection[data-job-plan-workspace]>.job-stage{grid-column:1;grid-row:1;min-width:0;overflow:auto;padding:12px}
|
|
515
|
+
.job-window .job-inspection[data-job-plan-workspace]>.job-forms{grid-column:2;grid-row:1;min-width:0;min-height:0;border-top:0;border-left:1px solid var(--border)}
|
|
516
|
+
|
|
517
|
+
.job-window .job-inspection[data-job-plan-workspace]>.job-stage .job-source,
|
|
518
|
+
.job-window .job-inspection[data-job-plan-workspace]>.job-stage pre{min-width:0;white-space:pre-wrap;overflow-wrap:anywhere}
|