@deepblend/dsh-blender-contracts 0.15.0 → 0.17.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/lib/geometry-inspection.js +47 -5
- package/lib/index.js +5 -1
- package/lib/projections.js +3 -1
- package/lib/runtime-types.d.ts +22 -4
- package/lib/scene-patch.js +21 -6
- package/lib/sdk.d.ts +18 -2
- package/lib/sdk.js +3 -0
- package/lib/shot-render-selection.js +52 -0
- package/lib/spec-change-audit.js +16 -0
- package/lib/ui-api.js +4 -0
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { BlenderError, BlenderErrorCode } from './index.js'
|
|
2
2
|
|
|
3
3
|
export const GEOMETRY_INSPECTION_VERSION = 'deepblend.geometry-inspection/v1'
|
|
4
|
+
export const ASSET_BOUNDS_INSPECTION_VERSION = 'deepblend.geometry-inspection/v4'
|
|
5
|
+
export const ASSET_BOUNDS_LIMITS = Object.freeze({ meshes: 128, vertices: 2_000_000, polygons: 2_000_000 })
|
|
4
6
|
export const OBJECT_AXES_INSPECTION_VERSION = 'deepblend.geometry-inspection/v3'
|
|
5
7
|
export const OBJECT_AXES_BASIS = 'evaluated-object-axes-scaled'
|
|
6
8
|
export const SURFACE_INSPECTION_VERSION = 'deepblend.geometry-inspection/v2'
|
|
@@ -19,6 +21,16 @@ export function validateGeometrySelection(request) {
|
|
|
19
21
|
if (!Number.isSafeInteger(request.frame) || request.frame < 0 || request.frame > 1_000_000) refuse('an explicit integer frame from 0 to 1000000 is required.')
|
|
20
22
|
if (typeof request.checkpointSha256 !== 'string' || !/^[a-f0-9]{64}$/.test(request.checkpointSha256)) refuse('the expected checkpoint SHA256 is required.')
|
|
21
23
|
if (request.objectAxes !== undefined && typeof request.objectAxes !== 'boolean') refuse('objectAxes must be boolean.')
|
|
24
|
+
if (request.cameraId !== undefined && (typeof request.cameraId !== 'string' || !/^[a-zA-Z][a-zA-Z0-9._-]{0,127}$/.test(request.cameraId) || request.objectAxes === true || request.surfaceSamples !== undefined)) refuse('cameraId requires one explicit camera without object axes or surface samples.')
|
|
25
|
+
if (request.cameraMargin !== undefined && (request.cameraId === undefined || !Number.isFinite(request.cameraMargin) || request.cameraMargin < 0 || request.cameraMargin > .25)) refuse('cameraMargin requires cameraId and a finite margin from 0 to 0.25.')
|
|
26
|
+
if (request.assetInstanceIds !== undefined) {
|
|
27
|
+
if (!Array.isArray(request.assetInstanceIds) || request.assetInstanceIds.length < 1 ||
|
|
28
|
+
new Set(request.assetInstanceIds).size !== request.assetInstanceIds.length ||
|
|
29
|
+
request.assetInstanceIds.some(id => !request.entityIds.includes(id)) ||
|
|
30
|
+
request.objectAxes === true || request.surfaceSamples !== undefined) {
|
|
31
|
+
refuse('assetInstanceIds must select distinct requested asset roots; aggregate bounds cannot be combined with object axes or surface samples.')
|
|
32
|
+
}
|
|
33
|
+
}
|
|
22
34
|
if (request.surfaceSamples !== undefined) validateSurfaceSelection(request)
|
|
23
35
|
}
|
|
24
36
|
|
|
@@ -101,28 +113,38 @@ export function verifyGeometryReport(report, request) {
|
|
|
101
113
|
validateGeometrySelection(request)
|
|
102
114
|
const allowed = (value, keys) => value && typeof value === 'object' && Object.keys(value).every(key => keys.includes(key))
|
|
103
115
|
if (!report || Buffer.byteLength(JSON.stringify(report)) > GEOMETRY_INSPECTION_LIMITS.reportBytes ||
|
|
104
|
-
report.schemaVersion !== (request.objectAxes === true ? OBJECT_AXES_INSPECTION_VERSION : request.surfaceSamples === undefined ? GEOMETRY_INSPECTION_VERSION : SURFACE_INSPECTION_VERSION) || report.checkpointSha256 !== request.checkpointSha256 ||
|
|
116
|
+
report.schemaVersion !== (request.assetInstanceIds !== undefined || request.cameraId !== undefined ? ASSET_BOUNDS_INSPECTION_VERSION : request.objectAxes === true ? OBJECT_AXES_INSPECTION_VERSION : request.surfaceSamples === undefined ? GEOMETRY_INSPECTION_VERSION : SURFACE_INSPECTION_VERSION) || report.checkpointSha256 !== request.checkpointSha256 ||
|
|
105
117
|
report.frame !== request.frame || report.checkpointUnchanged !== true ||
|
|
106
118
|
typeof report.blenderVersion !== 'string' || !report.blenderVersion ||
|
|
107
119
|
!Array.isArray(report.objects) || report.objects.length !== request.entityIds.length ||
|
|
108
|
-
!allowed(report, ['schemaVersion', 'checkpointSha256', 'checkpointUnchanged', 'frame', 'blenderVersion', 'objects', ...(request.objectAxes === true ? ['objectAxisBasis'] : []), ...(request.surfaceSamples === undefined ? [] : ['surfaceSamples'])])) refuse('the report does not match the requested source, frame or selection.')
|
|
120
|
+
!allowed(report, ['schemaVersion', 'checkpointSha256', 'checkpointUnchanged', 'frame', 'blenderVersion', 'objects', ...(request.cameraId === undefined ? [] : ['camera']), ...(request.objectAxes === true ? ['objectAxisBasis'] : []), ...(request.surfaceSamples === undefined ? [] : ['surfaceSamples'])])) refuse('the report does not match the requested source, frame or selection.')
|
|
121
|
+
if (request.cameraId !== undefined) {
|
|
122
|
+
const camera = report.camera
|
|
123
|
+
if (!allowed(camera, ['id', 'type', 'margin', 'clipStartMeters', 'clipEndMeters']) || camera?.id !== request.cameraId || camera.type !== 'PERSP' ||
|
|
124
|
+
camera.margin !== (request.cameraMargin ?? .03) || !Number.isFinite(camera.clipStartMeters) || camera.clipStartMeters <= 0 ||
|
|
125
|
+
!Number.isFinite(camera.clipEndMeters) || camera.clipEndMeters <= camera.clipStartMeters) refuse('camera calibration differs from the requested framing selection.')
|
|
126
|
+
}
|
|
109
127
|
if (request.objectAxes === true && report.objectAxisBasis !== OBJECT_AXES_BASIS) refuse('object-local basis differs from evaluated scaled object-axis coordinates.')
|
|
110
128
|
const vector = (v, length) => Array.isArray(v) && v.length === length && v.every(Number.isFinite)
|
|
111
129
|
for (const [index, object] of report.objects.entries()) {
|
|
130
|
+
const aggregate = request.assetInstanceIds?.includes(request.entityIds[index]) === true
|
|
112
131
|
if (object?.entityId !== request.entityIds[index] || typeof object.type !== 'string' || !object.type) refuse('object identity differs from the selection.')
|
|
113
132
|
const keys = object.available === false ? ['entityId', 'type', 'available', 'unavailableReason'] :
|
|
114
|
-
['entityId', 'type', 'available', 'worldBoundsMeters', 'worldAxisExtentMm', 'worldMatrix', 'scale', 'vertexCount', 'polygonCount', ...(request.objectAxes === true ? ['objectAxisStatus', 'objectAxisBoundsMeters', 'objectAxisExtentMm', 'objectAxisWorldMatrix'] : [])]
|
|
133
|
+
['entityId', 'type', 'available', 'worldBoundsMeters', 'worldAxisExtentMm', 'worldMatrix', 'scale', 'vertexCount', 'polygonCount', ...(request.cameraId === undefined ? [] : ['cameraProjection']), ...(aggregate ? ['meshObjectCount'] : []), ...(request.objectAxes === true ? ['objectAxisStatus', 'objectAxisBoundsMeters', 'objectAxisExtentMm', 'objectAxisWorldMatrix'] : [])]
|
|
115
134
|
if (!allowed(object, keys)) refuse('unsupported measurement fields are not accepted; this protocol does not establish wall thickness or clearance.')
|
|
116
135
|
if (object.available === false) {
|
|
117
|
-
if (!['viewport-disabled', 'not-mesh', 'empty-or-invalid-geometry'].includes(object.unavailableReason) ||
|
|
136
|
+
if (![...['viewport-disabled', 'not-mesh', 'empty-or-invalid-geometry'], ...(aggregate ? ['geometry-budget-exceeded', 'unsupported-hierarchy'] : [])].includes(object.unavailableReason) ||
|
|
118
137
|
['worldBoundsMeters', 'worldAxisExtentMm', 'worldMatrix', 'vertexCount', 'polygonCount', 'scale'].some(k => Object.hasOwn(object, k))) refuse('an unavailable object must not contain measurements.')
|
|
119
138
|
continue
|
|
120
139
|
}
|
|
121
|
-
if (object.available !== true || object.type !==
|
|
140
|
+
if (object.available !== true || object.type !== (aggregate ? 'ASSET_MESH_SET' : 'MESH') ||
|
|
141
|
+
(aggregate && (!Number.isSafeInteger(object.meshObjectCount) || object.meshObjectCount < 1 || object.meshObjectCount > ASSET_BOUNDS_LIMITS.meshes ||
|
|
142
|
+
object.vertexCount > ASSET_BOUNDS_LIMITS.vertices || object.polygonCount > ASSET_BOUNDS_LIMITS.polygons)) || !allowed(object.worldBoundsMeters, ['min', 'max']) || !vector(object.worldBoundsMeters?.min, 3) ||
|
|
122
143
|
!vector(object.worldBoundsMeters?.max, 3) || !vector(object.worldAxisExtentMm, 3) || !vector(object.scale, 3) ||
|
|
123
144
|
!Array.isArray(object.worldMatrix) || object.worldMatrix.length !== 4 || !object.worldMatrix.every(row => vector(row, 4)) ||
|
|
124
145
|
!Number.isSafeInteger(object.vertexCount) || object.vertexCount <= 0 ||
|
|
125
146
|
!Number.isSafeInteger(object.polygonCount) || object.polygonCount < 0) refuse('a measured object contains invalid or non-finite geometry facts.')
|
|
147
|
+
if (request.cameraId !== undefined) verifyCameraProjection(object.cameraProjection, report.camera)
|
|
126
148
|
if (request.objectAxes === true && object.objectAxisStatus === 'unsupported-object-axis-basis') {
|
|
127
149
|
if (['objectAxisBoundsMeters','objectAxisExtentMm','objectAxisWorldMatrix'].some(k=>Object.hasOwn(object,k))) refuse('unavailable object-axis measurements must not contain numbers.')
|
|
128
150
|
const m=object.worldMatrix, lengths=[0,1,2].map(i=>Math.hypot(...m.slice(0,3).map(r=>r[i])))
|
|
@@ -167,3 +189,23 @@ export function verifyGeometryReport(report, request) {
|
|
|
167
189
|
if (request.surfaceSamples !== undefined) verifySurfaceSamples(report.surfaceSamples, request, report.objects)
|
|
168
190
|
return report
|
|
169
191
|
}
|
|
192
|
+
|
|
193
|
+
function verifyCameraProjection(projection, camera) {
|
|
194
|
+
const base = ['status', 'nearestDepthMeters', 'farthestDepthMeters', 'containedInClip']
|
|
195
|
+
if (['unavailable-render-hidden', 'geometry-budget-exceeded'].includes(projection?.status)) {
|
|
196
|
+
if (!only(projection, ['status'])) refuse('hidden framing must not contain fabricated measurements.')
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
if (!['measured', 'not-fully-in-front'].includes(projection?.status) ||
|
|
200
|
+
!Number.isFinite(projection.nearestDepthMeters) || !Number.isFinite(projection.farthestDepthMeters) || projection.nearestDepthMeters > projection.farthestDepthMeters ||
|
|
201
|
+
projection.containedInClip !== (projection.nearestDepthMeters >= camera.clipStartMeters && projection.farthestDepthMeters <= camera.clipEndMeters)) refuse('camera depth or clip evidence is invalid.')
|
|
202
|
+
if (projection.status === 'not-fully-in-front') {
|
|
203
|
+
if (!only(projection, base) || projection.nearestDepthMeters > 1e-8) refuse('camera-plane crossing must not contain a partial projection.')
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
const bounds = projection.normalizedBounds
|
|
207
|
+
if (!only(projection, [...base, 'normalizedBounds', 'containedInFrame']) || projection.nearestDepthMeters <= 1e-8 || !only(bounds, ['min', 'max']) ||
|
|
208
|
+
!Array.isArray(bounds?.min) || !Array.isArray(bounds?.max) || bounds.min.length !== 2 || bounds.max.length !== 2 ||
|
|
209
|
+
![...bounds.min, ...bounds.max].every(Number.isFinite) || bounds.min.some((v, i) => v > bounds.max[i]) ||
|
|
210
|
+
projection.containedInFrame !== bounds.min.every((v, i) => v >= camera.margin && bounds.max[i] <= 1-camera.margin)) refuse('camera frame containment disagrees with measured vertex projections.')
|
|
211
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -715,10 +715,12 @@ export {
|
|
|
715
715
|
|
|
716
716
|
export { ASSET_HEAD_BYTES, assetContentVerdict, describeAssetContent } from './asset-content.js'
|
|
717
717
|
export { redactHome, redactUrl } from './redact.js'
|
|
718
|
+
export { specChangeAudit } from './spec-change-audit.js'
|
|
718
719
|
export { assertKnownConfigKeys, declaredConfigKeys, describeUnknownConfigKeys } from './config-surface.js'
|
|
719
720
|
|
|
720
721
|
export {
|
|
721
722
|
CAMERA_UPDATE_FIELDS,
|
|
723
|
+
CAMERA_TARGET_UPDATE_HINT,
|
|
722
724
|
SCENE_OPERATION_NAMES,
|
|
723
725
|
validateScenePatch,
|
|
724
726
|
applyPatchToSpec,
|
|
@@ -885,5 +887,7 @@ export {
|
|
|
885
887
|
export { RECIPE_SCHEMA_VERSION, RECIPE_CAPABILITIES, RECIPE_LIMITS, RecipeError, recipeCapabilitiesForScene, validateRecipeManifest, validateRecipePackage, instantiateRecipe, instantiateRecipeLock } from './recipe.js'
|
|
886
888
|
export { planRecipeGeometryEdit, recipeGeometryParameters } from './recipe-parameters.js'
|
|
887
889
|
|
|
888
|
-
export { OBJECT_AXES_INSPECTION_VERSION, OBJECT_AXES_BASIS, GEOMETRY_INSPECTION_VERSION, GEOMETRY_INSPECTION_LIMITS, SURFACE_INSPECTION_VERSION, SURFACE_INSPECTION_LIMITS,
|
|
890
|
+
export { ASSET_BOUNDS_INSPECTION_VERSION, ASSET_BOUNDS_LIMITS, OBJECT_AXES_INSPECTION_VERSION, OBJECT_AXES_BASIS, GEOMETRY_INSPECTION_VERSION, GEOMETRY_INSPECTION_LIMITS, SURFACE_INSPECTION_VERSION, SURFACE_INSPECTION_LIMITS,
|
|
889
891
|
validateGeometrySelection, validateSurfaceSelection, verifySurfaceSamples, verifyGeometryReport } from './geometry-inspection.js'
|
|
892
|
+
export { SHOT_CAMERA_SELECTION_VERSION, SHOT_CAMERA_SELECTION_LIMITS, buildShotCameraSelection,
|
|
893
|
+
normalizeShotCameraSelection, shotCameraForFrame } from './shot-render-selection.js'
|
package/lib/projections.js
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* Owner: DeepBlend Studio — M1
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
import { specChangeAudit } from './spec-change-audit.js'
|
|
17
|
+
|
|
16
18
|
/**
|
|
17
19
|
* @typedef {object} JobReference
|
|
18
20
|
* @property {string} jobId
|
|
@@ -69,7 +71,7 @@ export function toCanonicalRevisionSummary({ manifest, checkpointPath = null })
|
|
|
69
71
|
stage: manifest.stage ?? null,
|
|
70
72
|
idempotencyKey: manifest.idempotencyKey ?? null,
|
|
71
73
|
sceneChanged: manifest.digestBefore !== manifest.digestAfter,
|
|
72
|
-
|
|
74
|
+
...specChangeAudit(manifest),
|
|
73
75
|
checkpoint: checkpointPath,
|
|
74
76
|
previews: manifest.previews ?? [],
|
|
75
77
|
validation: manifest.validation ?? null,
|
package/lib/runtime-types.d.ts
CHANGED
|
@@ -94,15 +94,21 @@ export interface RenderOverrides { engine?: EngineKey; width?: number; height?:
|
|
|
94
94
|
/** Default world-axis bounds; optional physical object axes include native scale. Neither certifies semantic body dimensions or wall thickness. */
|
|
95
95
|
export interface GeometryInspectionRequest extends RuntimeOptions {
|
|
96
96
|
checkpointPath: string; checkpointSha256: string; entityIds: string[]; frame: number; jobId?: string; objectAxes?: boolean; surfaceSamples?: unknown[];
|
|
97
|
+
assetInstanceIds?: string[]; cameraId?: string; cameraMargin?: number;
|
|
97
98
|
}
|
|
99
|
+
export type CameraProjection = { status: 'unavailable-render-hidden' | 'geometry-budget-exceeded' } |
|
|
100
|
+
{ status: 'not-fully-in-front'; nearestDepthMeters: number; farthestDepthMeters: number; containedInClip: boolean } |
|
|
101
|
+
{ status: 'measured'; nearestDepthMeters: number; farthestDepthMeters: number; containedInClip: boolean;
|
|
102
|
+
normalizedBounds: { min: [number, number]; max: [number, number] }; containedInFrame: boolean };
|
|
98
103
|
export type GeometryInspectionObject = { entityId: string; type: string } & (
|
|
99
|
-
{ available: false; unavailableReason: 'viewport-disabled' | 'not-mesh' | 'empty-or-invalid-geometry' } |
|
|
104
|
+
{ available: false; unavailableReason: 'viewport-disabled' | 'not-mesh' | 'empty-or-invalid-geometry' | 'unsupported-hierarchy' | 'geometry-budget-exceeded' } |
|
|
100
105
|
{ available: true; worldBoundsMeters: { min: Vec3; max: Vec3 }; worldAxisExtentMm: Vec3;
|
|
101
106
|
objectAxisStatus?: 'measured' | 'unsupported-object-axis-basis'; objectAxisBoundsMeters?: { min: Vec3; max: Vec3 }; objectAxisExtentMm?: Vec3; objectAxisWorldMatrix?: number[][];
|
|
102
|
-
worldMatrix: number[][]; scale: Vec3; vertexCount: number; polygonCount: number }
|
|
107
|
+
worldMatrix: number[][]; scale: Vec3; vertexCount: number; polygonCount: number; meshObjectCount?: number; cameraProjection?: CameraProjection }
|
|
103
108
|
);
|
|
104
109
|
export interface GeometryInspectionReport {
|
|
105
|
-
schemaVersion: 'deepblend.geometry-inspection/v1' | 'deepblend.geometry-inspection/v2' | 'deepblend.geometry-inspection/v3';
|
|
110
|
+
schemaVersion: 'deepblend.geometry-inspection/v1' | 'deepblend.geometry-inspection/v2' | 'deepblend.geometry-inspection/v3' | 'deepblend.geometry-inspection/v4';
|
|
111
|
+
camera?: { id: string; type: 'PERSP'; margin: number; clipStartMeters: number; clipEndMeters: number };
|
|
106
112
|
objectAxisBasis?: 'evaluated-object-axes-scaled'; surfaceSamples?: unknown[]; checkpointSha256: string; checkpointUnchanged: true;
|
|
107
113
|
frame: number; blenderVersion: string; objects: GeometryInspectionObject[];
|
|
108
114
|
}
|
|
@@ -156,6 +162,13 @@ export interface FrameSequenceRequest extends RuntimeOptions {
|
|
|
156
162
|
profile?: RenderProfile; frameRange?: [number, number]; jobId?: string; attemptToken?: string;
|
|
157
163
|
filePrefix?: string; padding?: number;
|
|
158
164
|
}
|
|
165
|
+
export interface ShotCameraSelection {
|
|
166
|
+
schemaVersion: 'deepblend.shot-camera-selection/v1'; mode: 'shots';
|
|
167
|
+
shots: Array<{ id: string; cameraId: string; frameRange: [number, number] }>;
|
|
168
|
+
}
|
|
169
|
+
export interface ShotFrameSequenceRequest extends Omit<FrameSequenceRequest, 'cameraId'> {
|
|
170
|
+
cameraSelection: ShotCameraSelection;
|
|
171
|
+
}
|
|
159
172
|
export interface FrameSequenceRun {
|
|
160
173
|
handle: FrameSequenceHandle; jobDirectory: string; framesDirectory: string; requestPath: string; planPath: string;
|
|
161
174
|
resultPath: string; eventsPath: string; processPath: string; argv: string[]; startedAt: number;
|
|
@@ -171,14 +184,17 @@ export interface FrameWrittenEvent {
|
|
|
171
184
|
attemptToken: string;
|
|
172
185
|
/** SHA256 of the complete PNG bytes after structural verification. */
|
|
173
186
|
sha256: string;
|
|
187
|
+
/** Actual camera read back for the explicit shot action; absent stays unknown. */
|
|
188
|
+
cameraId?: string; shotId?: string;
|
|
174
189
|
}
|
|
175
190
|
export type FrameProvenanceEvent = FrameConfiguredEvent | FrameWrittenEvent;
|
|
176
191
|
/** Configuration read back by the renderer, with the launch identity that requested it. */
|
|
177
192
|
export interface FrameRenderSource {
|
|
178
193
|
id: string; attempt: number; revisionId: string; cameraId: string | null; checkpointSha256: string | null;
|
|
179
194
|
requestedSamples: number | null; effectiveProfile: RenderProfile; renderConfig: MeasuredRenderConfig;
|
|
195
|
+
cameraSelection?: ShotCameraSelection;
|
|
180
196
|
}
|
|
181
|
-
export interface FrameSourceBinding { frame: number; sourceId: string; sha256: string }
|
|
197
|
+
export interface FrameSourceBinding { frame: number; sourceId: string; sha256: string; cameraId?: string; shotId?: string }
|
|
182
198
|
/** Shared by canonical jobs and delivery manifests; known means configuration/PNG evidence, not per-pixel samples. */
|
|
183
199
|
export interface FrameProvenanceSummary {
|
|
184
200
|
schemaVersion: 'deepblend.frame-sources/v1';
|
|
@@ -207,6 +223,8 @@ export interface BlenderRuntime {
|
|
|
207
223
|
renderPreview(request: RenderPreviewRequest): Promise<RuntimeActionResult<PreviewReport>>;
|
|
208
224
|
renderViews(request: RenderViewsRequest): Promise<RenderViewsResult>;
|
|
209
225
|
startFrameSequence(request: FrameSequenceRequest): Promise<FrameSequenceRun>;
|
|
226
|
+
/** Optional explicit capability; the Host must refuse, never silently fall back. */
|
|
227
|
+
startShotFrameSequence?(request: ShotFrameSequenceRequest): Promise<FrameSequenceRun>;
|
|
210
228
|
awaitFrameSequence(run: FrameSequenceRun): Promise<FrameSequenceOutcome>;
|
|
211
229
|
dispose(): void;
|
|
212
230
|
}
|
package/lib/scene-patch.js
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
import { compileSchema, formatIssues } from './json-schema.js'
|
|
20
20
|
import { collectionForKind, sceneSpecDigest, specHash } from './scene-spec.js'
|
|
21
21
|
import { referenceImageIssues } from './reference-images.js'
|
|
22
|
+
import { specChangeAudit } from './spec-change-audit.js'
|
|
22
23
|
import scenePatchSchema from './schemas/scene-patch.schema.json' with { type: 'json' }
|
|
23
24
|
|
|
24
25
|
const validatePatchStructure = compileSchema(scenePatchSchema, { id: 'scene-patch.schema.json' })
|
|
@@ -105,6 +106,14 @@ export function validateScenePatch(patch) {
|
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
108
|
for (const issue of structural) {
|
|
109
|
+
// Read projections use null for an absent target; write operations do not.
|
|
110
|
+
// Explain the valid alternatives without coercing the caller's intent.
|
|
111
|
+
const target = /^operations\[(\d+)\]\.(targetEntityId|targetPoint|clearTarget)$/.exec(issue.path)
|
|
112
|
+
const operation = target ? patch?.operations?.[Number(target[1])] : null
|
|
113
|
+
if (target && operation?.op === 'camera.update' && operation[target[2]] === null
|
|
114
|
+
&& ['type', 'const'].includes(issue.keyword)) {
|
|
115
|
+
issue.message += `. ${CAMERA_TARGET_UPDATE_HINT}`
|
|
116
|
+
}
|
|
108
117
|
errors.push({ code: 'PATCH_SCHEMA_INVALID', path: issue.path, message: `${issue.message} [${issue.keyword}]` })
|
|
109
118
|
}
|
|
110
119
|
if (errors.length > 0) {
|
|
@@ -177,7 +186,7 @@ export function validateScenePatch(patch) {
|
|
|
177
186
|
errors.push({
|
|
178
187
|
code: 'PATCH_CAMERA_TARGET_AMBIGUOUS',
|
|
179
188
|
path: at,
|
|
180
|
-
message: 'camera.update must choose one of targetEntityId, targetPoint or clearTarget',
|
|
189
|
+
message: 'camera.update must choose one of targetEntityId, targetPoint or clearTarget. ' + CAMERA_TARGET_UPDATE_HINT,
|
|
181
190
|
})
|
|
182
191
|
}
|
|
183
192
|
}
|
|
@@ -208,6 +217,13 @@ export function validateScenePatch(patch) {
|
|
|
208
217
|
* copies of one vocabulary is two too many, and the failure mode when they disagree is
|
|
209
218
|
* not a crash — it is a rejection that names the wrong problem.
|
|
210
219
|
*/
|
|
220
|
+
/** Shared model-facing recovery: invalid aim combinations stay refused. */
|
|
221
|
+
export const CAMERA_TARGET_UPDATE_HINT =
|
|
222
|
+
'Choose exactly one of targetEntityId, targetPoint or clearTarget when changing aim. ' +
|
|
223
|
+
'Set targetPoint alone for a world point, or targetEntityId alone for an entity; either replaces the previous target. ' +
|
|
224
|
+
'Use clearTarget: true only to remove targeting; do not pass null. ' +
|
|
225
|
+
'Retarget or clear cameras before removing their target entities.'
|
|
226
|
+
|
|
211
227
|
export const CAMERA_UPDATE_FIELDS = Object.freeze([
|
|
212
228
|
'lens', 'sensorWidth', 'clipping', 'transform', 'targetEntityId', 'targetPoint', 'clearTarget', 'fStop', 'role',
|
|
213
229
|
])
|
|
@@ -1067,7 +1083,7 @@ export function applyPatchToSpec(spec, patch) {
|
|
|
1067
1083
|
* @param {AppliedOperation[]} input.operations
|
|
1068
1084
|
* @param {object} input.request - the accepted patch, recorded verbatim.
|
|
1069
1085
|
* @param {{ revision: string, baseRevision: string, digestBefore: string, digestAfter: string,
|
|
1070
|
-
* specHashBefore?: string, specHashAfter?: string }} input.revision
|
|
1086
|
+
* specHashBefore?: string|null, specHashAfter?: string|null }} input.revision
|
|
1071
1087
|
* @param {import('./scene-spec.js').SceneSpecIssue[]} input.notices
|
|
1072
1088
|
* @returns {Record<string, unknown>}
|
|
1073
1089
|
*/
|
|
@@ -1081,11 +1097,10 @@ export function buildOperationManifest({ operations, request, revision, notices
|
|
|
1081
1097
|
specHashBefore: revision.specHashBefore ?? null,
|
|
1082
1098
|
specHashAfter: revision.specHashAfter ?? null,
|
|
1083
1099
|
// Two different questions, two different answers. `sceneChanged` excludes
|
|
1084
|
-
// project metadata and brief by design (see sceneSpecDigest)
|
|
1085
|
-
//
|
|
1100
|
+
// project metadata and brief by design (see sceneSpecDigest). The full-source
|
|
1101
|
+
// audit includes these fields and reports missing historical hashes as unknown.
|
|
1086
1102
|
sceneChanged: revision.digestBefore !== revision.digestAfter,
|
|
1087
|
-
|
|
1088
|
-
&& revision.specHashBefore !== revision.specHashAfter,
|
|
1103
|
+
...specChangeAudit(revision),
|
|
1089
1104
|
idempotencyKey: request.idempotencyKey,
|
|
1090
1105
|
actor: request.actor ?? null,
|
|
1091
1106
|
stage: request.stage ?? null,
|
package/lib/sdk.d.ts
CHANGED
|
@@ -5,6 +5,12 @@ import type {
|
|
|
5
5
|
} from './schema-types.js';
|
|
6
6
|
export type * from './schema-types.js';
|
|
7
7
|
export type * from './runtime-types.js';
|
|
8
|
+
import type { ShotCameraSelection } from './runtime-types.js';
|
|
9
|
+
export const SHOT_CAMERA_SELECTION_VERSION: 'deepblend.shot-camera-selection/v1';
|
|
10
|
+
export const SHOT_CAMERA_SELECTION_LIMITS: { readonly shots: 64; readonly bytes: 8192 };
|
|
11
|
+
export function buildShotCameraSelection(spec: Pick<SceneSpec, 'cameras' | 'shots'>, frames: number[]): ShotCameraSelection;
|
|
12
|
+
export function normalizeShotCameraSelection(value: unknown, frames?: number[]): ShotCameraSelection;
|
|
13
|
+
export function shotCameraForFrame(selection: ShotCameraSelection, frame: number): { shotId: string; cameraId: string };
|
|
8
14
|
|
|
9
15
|
export const BLENDER_PROTOCOL_VERSION: 'deepblend.blender/v1';
|
|
10
16
|
export const SCENE_SCHEMA_VERSION: 'deepblend.scene/v1';
|
|
@@ -44,6 +50,14 @@ export function compileSceneSpec(spec: SceneSpec): {
|
|
|
44
50
|
export function sceneSpecCanonicalText(spec: SceneSpec): string;
|
|
45
51
|
export function sceneSpecDigest(spec: SceneSpec): string;
|
|
46
52
|
export function specHash(spec: SceneSpec): string;
|
|
53
|
+
export type SpecChangeStatus = 'changed' | 'unchanged' | 'unknown';
|
|
54
|
+
export interface SpecChangeAudit {
|
|
55
|
+
/** Conservative compatibility flag: true means not proven unchanged. Use specChangeStatus for display. */
|
|
56
|
+
specChanged: boolean;
|
|
57
|
+
specChangeStatus: SpecChangeStatus;
|
|
58
|
+
}
|
|
59
|
+
/** Derives evidence from canonical full-document hashes, ignoring stored booleans/statuses. */
|
|
60
|
+
export function specChangeAudit(hashes?: { specHashBefore?: string | null; specHashAfter?: string | null }): SpecChangeAudit;
|
|
47
61
|
export function reviewInputsDigest(spec: SceneSpec): string;
|
|
48
62
|
export interface SceneSummary {
|
|
49
63
|
revision: string | null; revisionNumber: number | null; digest: string; schemaVersion: SceneSpec['schemaVersion'];
|
|
@@ -79,13 +93,15 @@ export interface OperationManifest {
|
|
|
79
93
|
schemaVersion: 'deepblend.operation-manifest/v1'; revision: string; baseRevision: string;
|
|
80
94
|
digestBefore: string; digestAfter: string; specHashBefore: string | null; specHashAfter: string | null;
|
|
81
95
|
sceneChanged: boolean; specChanged: boolean; idempotencyKey: string | undefined;
|
|
96
|
+
/** Absent in historical v1 records. Derive with specChangeAudit before displaying them. */
|
|
97
|
+
specChangeStatus?: SpecChangeStatus;
|
|
82
98
|
actor: string | null; stage: string | null; note: string | null; savedCheckpoint: boolean; renderedPreview: boolean;
|
|
83
99
|
operationCount: number; operations: AppliedOperation[]; notices: SceneSpecIssue[];
|
|
84
100
|
}
|
|
85
101
|
export function buildOperationManifest(input: {
|
|
86
102
|
operations: AppliedOperation[]; notices: SceneSpecIssue[]; request: ScenePatch;
|
|
87
|
-
revision: { revision: string; baseRevision: string; digestBefore: string; digestAfter: string; specHashBefore?: string; specHashAfter?: string };
|
|
88
|
-
}): OperationManifest;
|
|
103
|
+
revision: { revision: string; baseRevision: string; digestBefore: string; digestAfter: string; specHashBefore?: string | null; specHashAfter?: string | null };
|
|
104
|
+
}): OperationManifest & SpecChangeAudit;
|
|
89
105
|
export const RECIPE_SCHEMA_VERSION: 'deepblend.recipe/v1';
|
|
90
106
|
export const RECIPE_CAPABILITIES: ReadonlyArray<RecipeCapability>;
|
|
91
107
|
export const RECIPE_LIMITS: Readonly<{ sceneBytes: number; previewBytes: number; previewPixels: number }>;
|
package/lib/sdk.js
CHANGED
|
@@ -3,12 +3,15 @@ import { validateSceneSpec } from './scene-spec.js'
|
|
|
3
3
|
import { validateScenePatch } from './scene-patch.js'
|
|
4
4
|
import { BlenderError, BlenderErrorCode } from './index.js'
|
|
5
5
|
import { validateRecipeManifest, RecipeError } from './recipe.js'
|
|
6
|
+
export { SHOT_CAMERA_SELECTION_VERSION, SHOT_CAMERA_SELECTION_LIMITS, buildShotCameraSelection,
|
|
7
|
+
normalizeShotCameraSelection, shotCameraForFrame } from './shot-render-selection.js'
|
|
6
8
|
|
|
7
9
|
export {
|
|
8
10
|
BLENDER_PROTOCOL_VERSION, SCENE_SCHEMA_VERSION, SCENE_PATCH_VERSION, HOST_API_VERSION,
|
|
9
11
|
BlenderError, BlenderErrorCode, BlenderWarningCode, isBlenderError,
|
|
10
12
|
} from './index.js'
|
|
11
13
|
export { canonicalStringify, canonicalPretty, sha256, sha256Canonical } from './canonical.js'
|
|
14
|
+
export { specChangeAudit } from './spec-change-audit.js'
|
|
12
15
|
export {
|
|
13
16
|
validateSceneSpec, compileSceneSpec, sceneSpecCanonicalText, sceneSpecDigest, specHash,
|
|
14
17
|
reviewInputsDigest, summarizeSceneSpec,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { BlenderError, BlenderErrorCode } from './index.js'
|
|
2
|
+
|
|
3
|
+
export const SHOT_CAMERA_SELECTION_VERSION = 'deepblend.shot-camera-selection/v1'
|
|
4
|
+
export const SHOT_CAMERA_SELECTION_LIMITS = Object.freeze({ shots: 64, bytes: 8192 })
|
|
5
|
+
const id = value => typeof value === 'string' && /^[a-zA-Z][a-zA-Z0-9._-]{0,127}$/.test(value)
|
|
6
|
+
const fail = message => { throw new BlenderError(BlenderErrorCode.SCENE_SPEC_INVALID, `Shot camera selection: ${message}`) }
|
|
7
|
+
|
|
8
|
+
/** Resolve only a previously normalized selection; never choose a fallback camera. */
|
|
9
|
+
export function shotCameraForFrame(selection, frame) {
|
|
10
|
+
if (!Number.isSafeInteger(frame)) fail('requested frames must be integers.')
|
|
11
|
+
const matches = selection.shots.filter(shot => frame >= shot.frameRange[0] && frame <= shot.frameRange[1])
|
|
12
|
+
if (matches.length !== 1) fail(`frame ${frame} must belong to exactly one saved shot, found ${matches.length}.`)
|
|
13
|
+
return { shotId: matches[0].id, cameraId: matches[0].cameraId }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** A small immutable camera/range snapshot, without prompts or arbitrary shot metadata. */
|
|
17
|
+
export function normalizeShotCameraSelection(value, frames) {
|
|
18
|
+
if (!value || typeof value !== 'object' || Array.isArray(value) ||
|
|
19
|
+
value.schemaVersion !== SHOT_CAMERA_SELECTION_VERSION || value.mode !== 'shots' ||
|
|
20
|
+
Object.keys(value).some(key => !['schemaVersion', 'mode', 'shots'].includes(key)) ||
|
|
21
|
+
!Array.isArray(value.shots) || value.shots.length < 1 || value.shots.length > SHOT_CAMERA_SELECTION_LIMITS.shots) {
|
|
22
|
+
fail('use an explicit saved-shot selection with 1–64 shots.')
|
|
23
|
+
}
|
|
24
|
+
const seen = new Set()
|
|
25
|
+
const shots = value.shots.map(shot => {
|
|
26
|
+
if (!shot || typeof shot !== 'object' || Array.isArray(shot) || !id(shot.id) || !id(shot.cameraId) ||
|
|
27
|
+
Object.keys(shot).some(key => !['id', 'cameraId', 'frameRange'].includes(key)) || seen.has(shot.id) ||
|
|
28
|
+
!Array.isArray(shot.frameRange) || shot.frameRange.length !== 2 || !shot.frameRange.every(Number.isSafeInteger) ||
|
|
29
|
+
shot.frameRange[0] > shot.frameRange[1]) fail('each distinct shot needs its saved ID, camera ID and ordered integer frameRange.')
|
|
30
|
+
seen.add(shot.id)
|
|
31
|
+
return { id: shot.id, cameraId: shot.cameraId, frameRange: [...shot.frameRange] }
|
|
32
|
+
}).sort((a, b) => a.frameRange[0] - b.frameRange[0] || a.id.localeCompare(b.id))
|
|
33
|
+
for (let n = 1; n < shots.length; n++) {
|
|
34
|
+
if (shots[n].frameRange[0] <= shots[n - 1].frameRange[1]) fail(`shots ${shots[n - 1].id} and ${shots[n].id} overlap.`)
|
|
35
|
+
}
|
|
36
|
+
const selection = { schemaVersion: SHOT_CAMERA_SELECTION_VERSION, mode: 'shots', shots }
|
|
37
|
+
if (new TextEncoder().encode(JSON.stringify(selection)).byteLength > SHOT_CAMERA_SELECTION_LIMITS.bytes) fail('selection exceeds its 8192-byte metadata budget.')
|
|
38
|
+
if (frames !== undefined) {
|
|
39
|
+
if (!Array.isArray(frames) || !frames.length || frames.length > 100_000 || !frames.every(Number.isSafeInteger)) fail('select 1–100000 integer frames.')
|
|
40
|
+
for (const frame of frames) shotCameraForFrame(selection, frame)
|
|
41
|
+
}
|
|
42
|
+
return selection
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function buildShotCameraSelection(spec, frames) {
|
|
46
|
+
if (!Array.isArray(spec?.shots) || spec.shots.some(shot => !shot || typeof shot !== 'object' || Array.isArray(shot))) fail('the saved revision has no valid shot list.')
|
|
47
|
+
const selection = normalizeShotCameraSelection({ schemaVersion: SHOT_CAMERA_SELECTION_VERSION, mode: 'shots',
|
|
48
|
+
shots: spec.shots.map(shot => ({ id: shot.id, cameraId: shot.cameraId, frameRange: shot.frameRange })) }, frames)
|
|
49
|
+
const cameras = new Set((Array.isArray(spec.cameras) ? spec.cameras : []).filter(camera => camera && typeof camera === 'object').map(camera => camera.id))
|
|
50
|
+
for (const shot of selection.shots) if (!cameras.has(shot.cameraId)) fail(`shot ${shot.id} names missing saved camera ${shot.cameraId}.`)
|
|
51
|
+
return selection
|
|
52
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Compare canonical full-document hashes without treating missing history as evidence. */
|
|
2
|
+
const fullHash = value => typeof value === 'string' && /^[a-f0-9]{64}$/i.test(value) ? value.toLowerCase() : null
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Stored legacy booleans/statuses are deliberately ignored. No document is rewritten.
|
|
6
|
+
* `specChanged` remains a conservative compatibility flag: true means not proven unchanged.
|
|
7
|
+
* User-facing conclusions must use `specChangeStatus`, including its explicit unknown state.
|
|
8
|
+
* These are canonical SceneSpec hashes, not file-byte SHA256 or render-only scene digests.
|
|
9
|
+
* @param {{ specHashBefore?: string|null, specHashAfter?: string|null }} [hashes]
|
|
10
|
+
* @returns {{ specChanged: boolean, specChangeStatus: 'changed'|'unchanged'|'unknown' }}
|
|
11
|
+
*/
|
|
12
|
+
export function specChangeAudit(hashes = {}) {
|
|
13
|
+
const before = fullHash(hashes.specHashBefore), after = fullHash(hashes.specHashAfter)
|
|
14
|
+
const specChangeStatus = before === null || after === null ? 'unknown' : before === after ? 'unchanged' : 'changed'
|
|
15
|
+
return { specChanged: specChangeStatus !== 'unchanged', specChangeStatus }
|
|
16
|
+
}
|
package/lib/ui-api.js
CHANGED
|
@@ -90,6 +90,10 @@ export const UI_ROUTES = Object.freeze([
|
|
|
90
90
|
{ id: 'project.job', method: 'GET', path: '/deepblend/projects/:projectId/jobs/:jobId', write: false, summary: 'One job with its live progress.' },
|
|
91
91
|
{ id: 'project.job.cancel', method: 'POST', path: '/deepblend/projects/:projectId/jobs/:jobId/cancel', write: true, summary: 'Cancel a running job and verify the process is gone.' },
|
|
92
92
|
{ id: 'project.render', method: 'POST', path: '/deepblend/projects/:projectId/render', write: true, summary: 'Start a delivery render (or resume one).' },
|
|
93
|
+
{ id: 'project.editableSnapshots.create', method: 'POST', path: '/deepblend/projects/:projectId/editable-snapshots', write: true, summary: 'Prepare or resume an immutable editable snapshot of one explicit revision.' },
|
|
94
|
+
{ id: 'project.editableSnapshots.get', method: 'GET', path: '/deepblend/projects/:projectId/editable-snapshots/:exportId', write: false, summary: 'Read the fixed snapshot request and preparation state.' },
|
|
95
|
+
{ id: 'project.editableSnapshots.cancel', method: 'POST', path: '/deepblend/projects/:projectId/editable-snapshots/:exportId/cancel', write: true, summary: 'Cancel unfinished snapshot preparation without removing a ready export.' },
|
|
96
|
+
{ id: 'project.editableSnapshots.download', method: 'GET', path: '/deepblend/projects/:projectId/editable-snapshots/:exportId/download', write: false, summary: 'Download a verified ready snapshot through a bounded stream.' },
|
|
93
97
|
{ id: 'artifacts.open', method: 'GET', path: '/deepblend/artifacts/:projectId/*', write: false, summary: 'Serve one project-relative artifact (a preview PNG).' },
|
|
94
98
|
])
|
|
95
99
|
|
package/package.json
CHANGED