@forgeax/engine-render 0.1.31 → 0.1.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -1
- package/dist/assembly/webgpu-ready.d.ts +2 -1
- package/dist/assembly/webgpu-ready.d.ts.map +1 -1
- package/dist/assembly/webgpu-renderer.d.ts.map +1 -1
- package/dist/{chunk-C3DDSXYK.mjs → chunk-4NNZQCL3.mjs} +110 -35
- package/dist/chunk-4NNZQCL3.mjs.map +1 -0
- package/dist/{chunk-JRBDO2KB.mjs → chunk-6TFBXLRJ.mjs} +19 -7
- package/dist/chunk-6TFBXLRJ.mjs.map +1 -0
- package/dist/{chunk-FUUO4UND.mjs → chunk-DRR7D3KX.mjs} +3 -3
- package/dist/chunk-DRR7D3KX.mjs.map +1 -0
- package/dist/{chunk-S5UE2T5P.mjs → chunk-GWCEMDVR.mjs} +380 -4
- package/dist/chunk-GWCEMDVR.mjs.map +1 -0
- package/dist/{chunk-MDQJPY3T.mjs → chunk-JCIRYQ4V.mjs} +3 -3
- package/dist/{chunk-MDQJPY3T.mjs.map → chunk-JCIRYQ4V.mjs.map} +1 -1
- package/dist/{chunk-PSEQ6QPH.mjs → chunk-JRIPCMYC.mjs} +17 -10
- package/dist/chunk-JRIPCMYC.mjs.map +1 -0
- package/dist/{chunk-7MQ3XBSP.mjs → chunk-LULCA3OF.mjs} +4 -4
- package/dist/{chunk-7MQ3XBSP.mjs.map → chunk-LULCA3OF.mjs.map} +1 -1
- package/dist/{chunk-NO4WZCAH.mjs → chunk-S665NJNF.mjs} +3 -3
- package/dist/{chunk-NO4WZCAH.mjs.map → chunk-S665NJNF.mjs.map} +1 -1
- package/dist/components/depth-of-field.d.ts +28 -0
- package/dist/components/depth-of-field.d.ts.map +1 -0
- package/dist/components/directional-light.d.ts +2 -1
- package/dist/components/directional-light.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/construct-renderer.mjs +898 -328
- package/dist/construct-renderer.mjs.map +1 -1
- package/dist/extract/camera.d.ts.map +1 -1
- package/dist/features/depth-of-field/depth-of-field-assembly.d.ts +19 -0
- package/dist/features/depth-of-field/depth-of-field-assembly.d.ts.map +1 -0
- package/dist/features/depth-of-field/depth-of-field-feature.d.ts +43 -0
- package/dist/features/depth-of-field/depth-of-field-feature.d.ts.map +1 -0
- package/dist/features/depth-of-field/depth-of-field-inspection.d.ts +34 -0
- package/dist/features/depth-of-field/depth-of-field-inspection.d.ts.map +1 -0
- package/dist/features/depth-of-field/depth-of-field-params.d.ts +83 -0
- package/dist/features/depth-of-field/depth-of-field-params.d.ts.map +1 -0
- package/dist/features/types.d.ts +19 -1
- package/dist/features/types.d.ts.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +6 -5
- package/dist/index.mjs.map +1 -1
- package/dist/inspection-types.d.ts +35 -0
- package/dist/inspection-types.d.ts.map +1 -1
- package/dist/instances.d.ts +7 -0
- package/dist/instances.d.ts.map +1 -1
- package/dist/internal.mjs +6 -6
- package/dist/mesh-material-bindings.d.ts +3 -0
- package/dist/mesh-material-bindings.d.ts.map +1 -1
- package/dist/pipeline/standard-output/graph.d.ts.map +1 -1
- package/dist/pipeline/standard-output/types.d.ts +4 -2
- package/dist/pipeline/standard-output/types.d.ts.map +1 -1
- package/dist/pipeline/standard-post.d.ts.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/record/frame-snapshot.d.ts +21 -1
- package/dist/record/frame-snapshot.d.ts.map +1 -1
- package/dist/record/frame.d.ts.map +1 -1
- package/dist/record/main-pass.d.ts.map +1 -1
- package/dist/record/typed-frame-graph.d.ts +7 -0
- package/dist/record/typed-frame-graph.d.ts.map +1 -1
- package/dist/recovery/render-system-candidate.d.ts.map +1 -1
- package/dist/render-contract.d.ts +8 -1
- package/dist/render-contract.d.ts.map +1 -1
- package/dist/render-graph-primitives.d.ts +2 -0
- package/dist/render-graph-primitives.d.ts.map +1 -1
- package/dist/render-pipeline.d.ts +13 -1
- package/dist/render-pipeline.d.ts.map +1 -1
- package/dist/render-system-extract-tail.d.ts.map +1 -1
- package/dist/render-system-extract.d.ts +18 -4
- package/dist/render-system-extract.d.ts.map +1 -1
- package/dist/render-system.d.ts +2 -1
- package/dist/render-system.d.ts.map +1 -1
- package/dist/temporal/index.mjs +5 -5
- package/dist/typed-render-graph-primitives.d.ts.map +1 -1
- package/package.json +21 -21
- package/src/__tests__/gpu-driven-baseline.characterization.test.ts +12 -0
- package/src/__tests__/gpu-driven-production.integration.test.ts +27 -1
- package/src/__tests__/instances-store.unit.test.ts +15 -0
- package/src/__tests__/prepared-gpu-driven-pbr.integration.test.ts +28 -0
- package/src/assembly/webgpu-ready.ts +5 -5
- package/src/assembly/webgpu-renderer.ts +14 -14
- package/src/components/depth-of-field.ts +45 -0
- package/src/components/directional-light.ts +2 -1
- package/src/components/index.ts +1 -0
- package/src/extract/camera.ts +22 -2
- package/src/features/depth-of-field/__tests__/depth-of-field-params.unit.test.ts +943 -0
- package/src/features/depth-of-field/depth-of-field-assembly.ts +100 -0
- package/src/features/depth-of-field/depth-of-field-feature.ts +295 -0
- package/src/features/depth-of-field/depth-of-field-inspection.ts +237 -0
- package/src/features/depth-of-field/depth-of-field-params.ts +556 -0
- package/src/features/host.ts +1 -1
- package/src/features/types.ts +18 -1
- package/src/index.ts +32 -0
- package/src/inspection-types.ts +38 -0
- package/src/instances.ts +19 -5
- package/src/mesh-material-bindings.ts +4 -0
- package/src/pipeline/standard-output/graph.ts +3 -0
- package/src/pipeline/standard-output/types.ts +4 -1
- package/src/pipeline/standard-post.ts +21 -2
- package/src/plugin.ts +2 -0
- package/src/record/frame-snapshot.ts +26 -1
- package/src/record/frame.ts +39 -6
- package/src/record/main-pass.ts +1 -5
- package/src/record/typed-frame-graph.ts +106 -6
- package/src/recovery/render-system-candidate.ts +6 -0
- package/src/render-contract.ts +11 -0
- package/src/render-graph-primitives.ts +8 -1
- package/src/render-pipeline.ts +17 -1
- package/src/render-system-extract-tail.ts +87 -13
- package/src/render-system-extract.ts +103 -25
- package/src/render-system.ts +78 -0
- package/src/typed-render-graph-primitives.ts +3 -0
- package/dist/chunk-C3DDSXYK.mjs.map +0 -1
- package/dist/chunk-FUUO4UND.mjs.map +0 -1
- package/dist/chunk-JRBDO2KB.mjs.map +0 -1
- package/dist/chunk-PSEQ6QPH.mjs.map +0 -1
- package/dist/chunk-S5UE2T5P.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/points-lines/admission.ts","../src/point-shadow-inspection.ts","../src/ssr/admission.ts","../src/volume/inspection.ts","../src/reflection/filter.ts","../src/reflection/gpu-table.ts","../src/reflection/inspection.ts","../src/reflection/projection.ts","../src/scene/visibility/inspection.ts","../src/ssr/inspection.ts","../src/dynamic-geometry.ts"],"names":["pass","failure","err","ok","primitiveKey"],"mappings":";;;;;AA0DA,SAAS,YAAA,CACP,KAAA,EACA,SAAA,EACA,KAAA,EACA,OACA,QAAA,EAC0C;AAC1C,EAAA,OAAO,GAAA,CAAI,IAAI,4BAAA,CAAkB,EAAE,MAAA,EAAQ,KAAA,CAAM,MAAA,EAAQ,SAAA,EAAW,KAAA,EAAO,KAAA,EAAO,QAAA,EAAU,CAAC,CAAA;AAC/F;AAEA,SAAS,gBAAA,CACP,KAAA,EACA,OAAA,EACA,QAAA,EACA,MAAA,EAC0C;AAC1C,EAAA,OAAO,GAAA,CAAI,IAAI,gCAAA,CAAc,EAAE,MAAA,EAAQ,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAS,QAAA,EAAU,MAAA,EAAQ,CAAC,CAAA;AACnF;AAEA,SAAS,WACP,KAAA,EAIA;AACA,EAAA,MAAM,SAAA,GAAY,MAAM,MAAA,KAAW,MAAA;AACnC,EAAA,MAAM,QAAA,GAAW,MAAM,KAAA,KAAU,MAAA;AACjC,EAAA,IAAI,aAAa,QAAA,EAAU;AACzB,I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AAU,KAAA,KAAU,UAAA,EAAY,QAAA,IAAY,CAAA;AAAA,aAAA,IACnD,MAAA,CAAO,SAAA,CAAU,KAAA,KAAU,WAAA,EAAa,SAAA,IAAa,CAAA;AAAA,MAChE;AACA,MAAA,OAAO,OAAO,MAAA,CAAO;AAAA,QACnB,UAAA,EAAY,iBAAA;AAAA,QACZ,QAAA;AAAA,QACA,QAAA;AAAA,QACA,SAAA;AAAA,QACA,OAAA;AAAA,QACA,GAAI,cAAA,KAAmB,MAAA,GAAY,EAAC,GAAI,EAAE,cAAA,EAAe;AAAA,QACzD,GAAI,aAAA,KAAkB,MAAA,GAAY,EAAC,GAAI,EAAE,aAAA,EAAc;AAAA,QACvD,oBAAA;AAAA,QACA,WAAA;AAAA,QACA,SAAA;AAAA,QACA;AAAA,OACD,CAAA;AAAA,IACH,CAAA;AAAA,IACA,OAAA,GAAU;AACR,MAAA,QAAA,GAAW,IAAA;AACX,MAAA,OAAA,CAAQ,KAAA,EAAM;AACd,MAAA,iBAAA,CAAkB,KAAA,EAAM;AACxB,MAAA,SAAA,GAAY,CAAA;AAAA,IACd;AAAA,GACF;AACF","file":"chunk-7MQ3XBSP.mjs","sourcesContent":["import { err, type MaterialAsset, type MeshAsset, ok, type Result } from '@forgeax/engine-types';\nimport { type PointShape, PointShapeValue, pointShapeFromU32 } from '../components/points';\nimport type {\n PointsLinesBudgetExceededError,\n PointsLinesInvalidStyleError,\n PointsLinesMaterialUnsupportedError,\n PointsLinesStyleUnsupportedError,\n PointsLinesTopologyMismatchError,\n} from '../errors/render';\nimport {\n PointsLinesBudgetExceededError as BudgetError,\n PointsLinesInvalidStyleError as InvalidStyleError,\n PointsLinesMaterialUnsupportedError as MaterialError,\n PointsLinesStyleUnsupportedError as StyleError,\n PointsLinesTopologyMismatchError as TopologyError,\n} from '../errors/render';\n\nexport interface PointsStyleInput {\n readonly sizePx?: number;\n readonly shape?: number;\n}\n\nexport interface LinesStyleInput {\n readonly widthPx?: number;\n}\n\nexport interface PointsLinesAdmissionLimits {\n readonly maxPoints?: number;\n readonly maxSegments?: number;\n}\n\nexport interface PointsLinesAdmissionInput {\n readonly entity: number;\n readonly points?: PointsStyleInput;\n readonly lines?: LinesStyleInput;\n readonly mesh: MeshAsset;\n readonly material: MaterialAsset;\n readonly limits?: PointsLinesAdmissionLimits;\n readonly materialId?: string;\n}\n\nexport interface PointsLinesAdmission {\n readonly component: 'Points' | 'Lines';\n readonly shape?: PointShape;\n readonly sizePx?: number;\n readonly widthPx?: number;\n readonly pointCount: number;\n readonly segmentCount: number;\n readonly submeshes: readonly number[];\n}\n\nexport type PointsLinesAdmissionError =\n | PointsLinesInvalidStyleError\n | PointsLinesTopologyMismatchError\n | PointsLinesStyleUnsupportedError\n | PointsLinesMaterialUnsupportedError\n | PointsLinesBudgetExceededError;\n\nfunction invalidStyle(\n input: PointsLinesAdmissionInput,\n component: 'Points' | 'Lines' | 'Points/Lines',\n field: string,\n value: number | string | undefined,\n expected: string,\n): Result<never, PointsLinesAdmissionError> {\n return err(new InvalidStyleError({ entity: input.entity, component, field, value, expected }));\n}\n\nfunction topologyMismatch(\n input: PointsLinesAdmissionInput,\n submesh: number,\n expected: string,\n actual: string,\n): Result<never, PointsLinesAdmissionError> {\n return err(new TopologyError({ entity: input.entity, submesh, expected, actual }));\n}\n\nfunction checkStyle(\n input: PointsLinesAdmissionInput,\n): Result<\n { component: 'Points' | 'Lines'; shape?: PointShape; sizePx?: number; widthPx?: number },\n PointsLinesAdmissionError\n> {\n const hasPoints = input.points !== undefined;\n const hasLines = input.lines !== undefined;\n if (hasPoints && hasLines) {\n return invalidStyle(\n input,\n 'Points/Lines',\n 'components',\n 'Points + Lines',\n 'exactly one style component',\n );\n }\n if (!hasPoints && !hasLines) {\n return invalidStyle(input, 'Points/Lines', 'components', undefined, 'one style component');\n }\n\n if (hasPoints) {\n const sizePx = input.points?.sizePx ?? 4;\n const shapeValue = input.points?.shape ?? PointShapeValue.square;\n const shape = pointShapeFromU32(shapeValue);\n if (!Number.isFinite(sizePx) || sizePx <= 0) {\n return invalidStyle(input, 'Points', 'sizePx', sizePx, 'finite sizePx > 0');\n }\n if (shape === undefined) {\n return invalidStyle(input, 'Points', 'shape', shapeValue, \"shape is 'square' or 'circle'\");\n }\n return ok({ component: 'Points', shape, sizePx });\n }\n\n const widthPx = input.lines?.widthPx ?? 1;\n if (!Number.isFinite(widthPx) || widthPx <= 0) {\n return invalidStyle(input, 'Lines', 'widthPx', widthPx, 'finite widthPx > 0');\n }\n return ok({ component: 'Lines', widthPx });\n}\n\nfunction checkTopology(\n input: PointsLinesAdmissionInput,\n component: 'Points' | 'Lines',\n): Result<\n { pointCount: number; segmentCount: number; submeshes: readonly number[] },\n PointsLinesAdmissionError\n> {\n const expected = component === 'Points' ? 'point-list' : 'line-list';\n let pointCount = 0;\n let segmentCount = 0;\n const acceptedSubmeshes: number[] = [];\n let sawNonEmpty = false;\n\n for (const [submeshIndex, submesh] of input.mesh.submeshes.entries()) {\n const indexed = input.mesh.indices !== undefined && submesh.indexCount > 0;\n const elementCount = indexed ? submesh.indexCount : submesh.vertexCount;\n if (elementCount === 0) continue;\n sawNonEmpty = true;\n\n if (component === 'Lines' && submesh.topology === 'line-strip') {\n return err(\n new StyleError({\n lane: 'admission',\n field: 'topology',\n member: 'line-strip',\n supported: ['line-list'],\n }),\n );\n }\n if (submesh.topology !== expected) {\n return topologyMismatch(input, submeshIndex, expected, submesh.topology);\n }\n if (component === 'Lines' && elementCount % 2 !== 0) {\n return topologyMismatch(input, submeshIndex, 'line-list pairs', 'line-list odd tail');\n }\n acceptedSubmeshes.push(submeshIndex);\n if (component === 'Points') pointCount += elementCount;\n else segmentCount += elementCount / 2;\n }\n\n if (!sawNonEmpty) return topologyMismatch(input, 0, expected, 'empty-range');\n return ok({ pointCount, segmentCount, submeshes: acceptedSubmeshes });\n}\n\nfunction checkMaterial(input: PointsLinesAdmissionInput): Result<void, PointsLinesAdmissionError> {\n const passes = input.material.passes ?? [];\n const unlitModules = new Set(['forgeax_material::unlit', 'forgeax::default-unlit']);\n if (passes.length !== 1 || passes[0] === undefined) {\n const pass =\n passes.find(\n (candidate) => candidate.name === 'deferred' || candidate.name === 'shadow-caster',\n ) ?? passes[0];\n return err(\n new MaterialError({\n entity: input.entity,\n material: input.materialId ?? '<anonymous>',\n pass: pass?.name ?? '<empty>',\n module: pass?.program.module ?? '<empty>',\n reason: 'points-lines admission requires one unlit forward pass',\n }),\n );\n }\n const pass = passes[0];\n const lightMode = (pass.renderState?.tags as Record<string, unknown> | undefined)?.LightMode;\n if (\n !unlitModules.has(pass.program.module) ||\n pass.name !== 'forward' ||\n lightMode === 'ShadowCaster'\n ) {\n return err(\n new MaterialError({\n entity: input.entity,\n material: input.materialId ?? '<anonymous>',\n pass: pass.name,\n module: pass.program.module,\n reason: 'points-lines admission requires an engine-owned unlit forward pass',\n }),\n );\n }\n return ok(undefined);\n}\n\n/** Validate one complete Points/Lines candidate before any renderer publication. */\nexport function admitPointsLines(\n input: PointsLinesAdmissionInput,\n): Result<PointsLinesAdmission, PointsLinesAdmissionError> {\n const style = checkStyle(input);\n if (!style.ok) return style;\n const topology = checkTopology(input, style.value.component);\n if (!topology.ok) return topology;\n const material = checkMaterial(input);\n if (!material.ok) return material;\n\n if (style.value.component === 'Points' && input.limits?.maxPoints !== undefined) {\n if (topology.value.pointCount > input.limits.maxPoints) {\n return err(\n new BudgetError({\n lane: 'admission',\n requested: topology.value.pointCount,\n limit: input.limits.maxPoints,\n unit: 'points',\n }),\n );\n }\n }\n if (style.value.component === 'Lines' && input.limits?.maxSegments !== undefined) {\n if (topology.value.segmentCount > input.limits.maxSegments) {\n return err(\n new BudgetError({\n lane: 'admission',\n requested: topology.value.segmentCount,\n limit: input.limits.maxSegments,\n unit: 'segments',\n }),\n );\n }\n }\n\n return ok({ ...style.value, ...topology.value });\n}\n","import type { PointShadowSnapshot } from './render-system-extract';\n\n/**\n * Detached point-shadow budget facts from one completed extract/record frame.\n *\n * `requested` is the number of PointLight + PointLightShadow pairs. The\n * renderer owns the bounded cube-array atlas, so `admitted`, `shadowed`, and\n * `shadowAtlasOccupancy` are all derived from the layer sentinel emitted by\n * the same extract owner. No consumer needs to maintain a second budget\n * ledger.\n */\nexport interface PointShadowInspection {\n readonly status: 'inactive' | 'ready' | 'over-budget';\n readonly requested: number;\n readonly admitted: number;\n readonly shadowed: number;\n readonly shadowAtlasOccupancy: number;\n readonly shadowAtlasCapacity: number;\n}\n\n/** Project point-shadow snapshots to the public, JSON-safe inspection shape. */\nexport function inspectPointShadow(\n snapshots: readonly PointShadowSnapshot[],\n shadowAtlasCapacity: number,\n): PointShadowInspection {\n const requested = snapshots.length;\n const admitted = snapshots.reduce(\n (count, snapshot) =>\n snapshot.shadowAtlasLayer >= 0 && snapshot.shadowAtlasLayer < shadowAtlasCapacity\n ? count + 1\n : count,\n 0,\n );\n // Never publish a misleading `ready` state when any requested shadow owns\n // no atlas layer. The extract sentinel is the single admission projection;\n // a partial or all-sentinel frame is therefore a failed/over-budget\n // admission, not an active shadow path with incomplete output.\n const status =\n requested === 0\n ? ('inactive' as const)\n : requested > shadowAtlasCapacity || admitted !== requested\n ? ('over-budget' as const)\n : ('ready' as const);\n return Object.freeze({\n status,\n requested,\n admitted,\n // A point shadow only samples an atlas after it owns an atlas layer. Keep\n // these names explicit for AI diagnostics while deriving both from the\n // one layer projection above.\n shadowed: admitted,\n shadowAtlasOccupancy: admitted,\n shadowAtlasCapacity,\n });\n}\n","/**\n * Consumer-only SSR M0 admission.\n *\n * This module consumes detached producer receipts. It owns no capture,\n * device, graph, or recovery handle and therefore cannot repair a missing\n * producer. A complete receipt set is the only route to an admitted result.\n */\n\nimport {\n type RhiTextureFormatCapabilityReceipt,\n validateR32FloatReceipt,\n} from '@forgeax/engine-rhi';\nimport { err, ok, type Result } from '@forgeax/engine-types';\nimport type { ScreenSpaceReflectionData } from '../components/screen-space-reflection';\nimport type { ReflectionFallbackReceipt } from '../inspection-types';\nimport type {\n SsrConfigField,\n SsrConfigInvalidError,\n SsrConfigRange,\n SsrOwnerRecoveryAction,\n SsrSpatialUnavailableReason,\n SsrUnavailableError,\n} from './errors';\nimport type { SsrAdmissionIdentity } from './identity';\n\nexport const SSR_FORMAT_PROFILE = 'r32float-mip-sampled-storage' as const;\n\nexport const SSR_FORMAT_STAGES = Object.freeze([\n 'texture-create',\n 'mip-view',\n 'sampled-storage-bind-group',\n 'pipeline-bind',\n 'finish',\n 'submit',\n 'completion',\n 'readback',\n] as const);\n\nexport type { SsrAdmissionIdentity } from './identity';\n\nexport type SsrFormatStage = (typeof SSR_FORMAT_STAGES)[number];\n\n/**\n * The admission input is the real renderer owner receipt plus the one\n * integration identity supplied by the host. It deliberately does not\n * recreate submitted/source/LKG boolean flags.\n */\nexport type SsrReflectionFallbackReceipt = ReflectionFallbackReceipt & {\n readonly identity: SsrAdmissionIdentity;\n};\n\n/** RHI capability receipt with the same host-supplied integration identity. */\nexport type SsrFormatReceipt = RhiTextureFormatCapabilityReceipt & {\n readonly identity: SsrAdmissionIdentity;\n};\n\nexport interface SsrTemporalReceipt {\n readonly identity: SsrAdmissionIdentity;\n readonly successfulSubmit: true;\n readonly generation: number;\n}\n\nexport interface SsrAdmissionWork {\n readonly attachmentCount: number;\n readonly passCount: number;\n readonly bindingCount: number;\n readonly resourceCount: number;\n readonly historyCount: 0;\n readonly temporalDemand: 0;\n}\n\nexport interface SsrAdmissionBudget {\n readonly probeExecutions: 0 | 1;\n readonly resetCount: 0;\n readonly rebuildCount: 0;\n}\n\nexport interface SsrAdmissionFailure {\n readonly code:\n | 'ssr-not-requested'\n | 'ssr-reflection-fallback-unavailable'\n | 'ssr-format-unavailable'\n | 'ssr-temporal-unavailable'\n | 'ssr-receipt-identity-mismatch'\n | 'ssr-receipt-stale';\n readonly expected: string;\n readonly hint: string;\n readonly detail: Readonly<{\n readonly owner: 'producer' | 'format' | 'temporal' | 'consumer';\n /** Owner-directed action an AI consumer can take without parsing hint text. */\n readonly action: SsrOwnerRecoveryAction;\n readonly generation?: number;\n readonly identityField?: keyof SsrAdmissionIdentity;\n }>;\n}\n\nexport type SsrAdmissionResult =\n | {\n readonly status: 'admitted';\n readonly identity: SsrAdmissionIdentity | undefined;\n readonly generation: number;\n readonly work: SsrAdmissionWork;\n readonly budget: SsrAdmissionBudget;\n readonly failure?: undefined;\n }\n | {\n readonly status: 'fallback-only';\n readonly identity: SsrAdmissionIdentity | undefined;\n readonly generation: number;\n readonly work: SsrAdmissionWork;\n readonly budget: SsrAdmissionBudget;\n readonly failure: SsrAdmissionFailure;\n };\n\nexport interface SsrAdmissionInput {\n readonly requested: boolean;\n readonly identity: SsrAdmissionIdentity;\n readonly reflectionFallback?: SsrReflectionFallbackReceipt;\n readonly format?: SsrFormatReceipt;\n readonly temporal?: SsrTemporalReceipt;\n readonly previousGeneration?: number;\n}\n\n/** Public renderer projection consumed by the parent SSR feature. */\nexport interface SsrDependenciesInspection {\n readonly status: 'admitted' | 'fallback-only';\n /** Absent until the host binds an exact source/tree/lock/build identity. */\n readonly identity: SsrAdmissionIdentity | undefined;\n readonly requested: boolean;\n readonly reflectionFallback: ReflectionFallbackReceipt | undefined;\n readonly format: SsrFormatReceipt | undefined;\n readonly temporal: SsrTemporalReceipt | undefined;\n readonly admission: SsrAdmissionResult;\n readonly work: SsrAdmissionWork;\n readonly budget: SsrAdmissionBudget;\n readonly failure: SsrAdmissionFailure | undefined;\n}\n\nconst ZERO_WORK: SsrAdmissionWork = Object.freeze({\n attachmentCount: 0,\n passCount: 0,\n bindingCount: 0,\n resourceCount: 0,\n historyCount: 0,\n temporalDemand: 0,\n});\n\nconst ADMITTED_WORK: SsrAdmissionWork = Object.freeze({\n attachmentCount: 1,\n passCount: 1,\n bindingCount: 1,\n resourceCount: 1,\n historyCount: 0,\n temporalDemand: 0,\n});\n\nconst ZERO_BUDGET: SsrAdmissionBudget = Object.freeze({\n probeExecutions: 0,\n resetCount: 0,\n rebuildCount: 0,\n});\n\nconst ADMITTED_BUDGET: SsrAdmissionBudget = Object.freeze({\n probeExecutions: 1,\n resetCount: 0,\n rebuildCount: 0,\n});\n\nfunction identityFieldMismatch(\n expected: SsrAdmissionIdentity,\n actual: SsrAdmissionIdentity,\n): keyof SsrAdmissionIdentity | undefined {\n for (const field of ['sourceHead', 'sourceTree', 'lockSha256', 'buildSha256'] as const) {\n if (expected[field] !== actual[field]) return field;\n }\n return undefined;\n}\n\nfunction blocked(\n identity: SsrAdmissionIdentity | undefined,\n failure: SsrAdmissionFailure,\n generation = 0,\n): SsrAdmissionResult {\n return Object.freeze({\n status: 'fallback-only',\n identity,\n generation,\n work: ZERO_WORK,\n budget: ZERO_BUDGET,\n failure,\n });\n}\n\nfunction failure(\n code: SsrAdmissionFailure['code'],\n owner: SsrAdmissionFailure['detail']['owner'],\n hint: string,\n detail: Omit<SsrAdmissionFailure['detail'], 'owner' | 'action'> = {},\n): SsrAdmissionFailure {\n const action: SsrOwnerRecoveryAction = recoveryActionFor(code);\n return Object.freeze({\n code,\n expected: 'all producer, format, and temporal receipts share one admitted identity',\n hint,\n detail: Object.freeze({ owner, action, ...detail }),\n });\n}\n\nfunction recoveryActionFor(code: SsrAdmissionFailure['code']): SsrOwnerRecoveryAction {\n switch (code) {\n case 'ssr-reflection-fallback-unavailable':\n case 'ssr-receipt-identity-mismatch':\n return 'rebuild';\n case 'ssr-not-requested':\n case 'ssr-format-unavailable':\n case 'ssr-temporal-unavailable':\n case 'ssr-receipt-stale':\n return 'retry';\n }\n}\n\nfunction receiptFailure(\n input: SsrAdmissionInput,\n receipt: { readonly identity: SsrAdmissionIdentity },\n owner: SsrAdmissionFailure['detail']['owner'],\n): SsrAdmissionResult | undefined {\n const field = identityFieldMismatch(input.identity, receipt.identity);\n if (field === undefined) return undefined;\n return blocked(\n input.identity,\n failure('ssr-receipt-identity-mismatch', owner, 'rebuild the owner receipt for this identity', {\n identityField: field,\n }),\n );\n}\n\nfunction validFallback(receipt: SsrReflectionFallbackReceipt | undefined): boolean {\n return (\n receipt !== undefined &&\n receipt.candidateVisible === false &&\n Number.isFinite(receipt.coverage) &&\n receipt.coverage >= 0 &&\n receipt.coverage <= 1 &&\n (receipt.sourceKey === undefined || receipt.sourceKey.length > 0) &&\n (receipt.extent === undefined ||\n (receipt.extent.length === 3 &&\n receipt.extent.every((value) => Number.isFinite(value) && value > 0))) &&\n Number.isInteger(receipt.sourceGeneration) &&\n receipt.sourceGeneration >= 0 &&\n Number.isInteger(receipt.projectionGeneration) &&\n receipt.projectionGeneration >= 0 &&\n Number.isInteger(receipt.deviceGeneration) &&\n receipt.deviceGeneration >= 0 &&\n receipt.brdfSignature === 'standard-pbr-ibl-v1' &&\n ((receipt.source === 'probe' && (receipt.state === 'active' || receipt.state === 'lkg')) ||\n (receipt.source === 'skylight' && (receipt.state === 'active' || receipt.state === 'lkg')) ||\n (receipt.source === 'neutral' && receipt.state === 'neutral'))\n );\n}\n\nfunction validFormat(receipt: SsrFormatReceipt | undefined): boolean {\n if (\n receipt?.profile !== SSR_FORMAT_PROFILE ||\n receipt.verdict !== 'admitted' ||\n receipt.evidence !== 'real' ||\n !Number.isInteger(receipt.deviceGeneration) ||\n receipt.deviceGeneration < 0\n ) {\n return false;\n }\n if (\n !SSR_FORMAT_STAGES.every((stage) =>\n receipt.stages.some((entry) => entry.stage === stage && entry.verdict === 'admitted'),\n )\n ) {\n return false;\n }\n return validateR32FloatReceipt(receipt).ok;\n}\n\nfunction validTemporal(receipt: SsrTemporalReceipt | undefined): boolean {\n return (\n receipt?.successfulSubmit === true &&\n Number.isInteger(receipt.generation) &&\n receipt.generation >= 0\n );\n}\n\nexport function admitSsrM0(input: SsrAdmissionInput): SsrAdmissionResult {\n if (!input.requested) {\n return blocked(\n input.identity,\n failure('ssr-not-requested', 'consumer', 'request SSR before evaluating M0 admission'),\n );\n }\n if (input.reflectionFallback === undefined) {\n return blocked(\n input.identity,\n failure('ssr-reflection-fallback-unavailable', 'producer', 'use LKG, Skylight, or neutral'),\n );\n }\n const fallbackIdentityFailure = receiptFailure(input, input.reflectionFallback, 'producer');\n if (fallbackIdentityFailure !== undefined) return fallbackIdentityFailure;\n if (!validFallback(input.reflectionFallback)) {\n return blocked(\n input.identity,\n failure(\n 'ssr-reflection-fallback-unavailable',\n 'producer',\n 'inspect and rebuild the producer receipt',\n ),\n input.reflectionFallback.projectionGeneration,\n );\n }\n if (input.format === undefined) {\n return blocked(\n input.identity,\n failure('ssr-format-unavailable', 'format', 'probe the exact format profile for this device'),\n input.reflectionFallback.projectionGeneration,\n );\n }\n const formatIdentityFailure = receiptFailure(input, input.format, 'format');\n if (formatIdentityFailure !== undefined) return formatIdentityFailure;\n if (!validFormat(input.format)) {\n return blocked(\n input.identity,\n failure('ssr-format-unavailable', 'format', 'complete the full r32float profile probe'),\n input.reflectionFallback.projectionGeneration,\n );\n }\n // Prior submitted history is optional for fresh spatial SSR. If supplied,\n // its identity and validity still obey the temporal owner's contract.\n const temporalIdentityFailure =\n input.temporal === undefined ? undefined : receiptFailure(input, input.temporal, 'temporal');\n if (temporalIdentityFailure !== undefined) return temporalIdentityFailure;\n if (input.temporal !== undefined && !validTemporal(input.temporal)) {\n return blocked(\n input.identity,\n failure('ssr-temporal-unavailable', 'temporal', 'inspect and rebuild the temporal receipt'),\n input.reflectionFallback.projectionGeneration,\n );\n }\n if (\n input.previousGeneration !== undefined &&\n input.previousGeneration !== input.reflectionFallback.projectionGeneration\n ) {\n return blocked(\n input.identity,\n failure(\n 'ssr-receipt-stale',\n 'consumer',\n 'discard stale completion and reinspect the owners',\n {\n generation: input.reflectionFallback.projectionGeneration,\n },\n ),\n input.reflectionFallback.projectionGeneration,\n );\n }\n return Object.freeze({\n status: 'admitted',\n identity: input.identity,\n generation: input.reflectionFallback.projectionGeneration,\n work: ADMITTED_WORK,\n budget: ADMITTED_BUDGET,\n });\n}\n\n/**\n * Joins the live owner projections at the renderer boundary. The only casts\n * here add the host identity to receipts that otherwise remain canonical RHI\n * or ReflectionProbe PODs; no producer fact is copied or renamed.\n */\nexport function projectSsrDependencies(input: {\n readonly requested: boolean;\n readonly identity: SsrAdmissionIdentity | undefined;\n readonly reflectionFallback: ReflectionFallbackReceipt | undefined;\n readonly format: RhiTextureFormatCapabilityReceipt | undefined;\n readonly temporal: { readonly successfulSubmit: true; readonly generation: number } | undefined;\n readonly previousGeneration?: number;\n}): SsrDependenciesInspection {\n const identity = input.identity;\n const reflectionFallback =\n identity === undefined || input.reflectionFallback?.identity === undefined\n ? undefined\n : (input.reflectionFallback as SsrReflectionFallbackReceipt);\n const format =\n identity === undefined || input.format === undefined\n ? undefined\n : ({ ...input.format, identity } satisfies SsrFormatReceipt);\n const temporal =\n identity === undefined || input.temporal === undefined\n ? undefined\n : ({ identity, ...input.temporal } satisfies SsrTemporalReceipt);\n const admission =\n identity === undefined\n ? blocked(\n undefined,\n failure(\n input.requested ? 'ssr-receipt-identity-mismatch' : 'ssr-not-requested',\n 'consumer',\n input.requested\n ? 'bind the exact source, tree, lock, and build identity before admission'\n : 'request SSR before evaluating M0 admission',\n input.requested ? { identityField: 'sourceHead' } : {},\n ),\n )\n : admitSsrM0({\n requested: input.requested,\n identity,\n ...(reflectionFallback === undefined ? {} : { reflectionFallback }),\n ...(format === undefined ? {} : { format }),\n ...(temporal === undefined ? {} : { temporal }),\n ...(input.previousGeneration === undefined\n ? {}\n : { previousGeneration: input.previousGeneration }),\n });\n return Object.freeze({\n status: admission.status,\n identity,\n requested: input.requested,\n reflectionFallback: input.reflectionFallback,\n format,\n temporal,\n admission,\n work: admission.work,\n budget: admission.budget,\n failure: admission.failure,\n });\n}\n\nexport function zeroSsrAdmissionWork(): SsrAdmissionWork {\n return ZERO_WORK;\n}\n\n/**\n * Projects the admission decision into the existing temporal reset seam.\n * Admission never creates temporal history; only a changed committed\n * producer generation can request a reset through the coordinator.\n */\nexport function resolveSsrAdmissionGeneration(\n previousGeneration: number | undefined,\n nextGeneration: number | undefined,\n): { readonly changed: boolean; readonly generation: number | undefined } {\n return {\n changed:\n previousGeneration !== undefined &&\n nextGeneration !== undefined &&\n previousGeneration !== nextGeneration,\n generation: nextGeneration,\n };\n}\n\n/** Standard spatial lanes that may consume an SSR candidate. */\nexport type SsrSpatialLane = 'clustered' | 'deferred' | 'direct' | 'cpu-webgl2' | 'forward';\n\n/** Capability facts required by the M1 spatial path. */\nexport interface SsrSpatialCapabilities {\n readonly compute: boolean;\n readonly storageTexture: boolean;\n readonly rgba16floatRenderable: boolean;\n readonly r32floatSampledStorage: boolean;\n}\n\n/** Detached owner facts consumed by spatial admission. */\nexport interface SsrSpatialEnvironment {\n readonly lane: SsrSpatialLane;\n readonly m0: Pick<SsrAdmissionResult, 'status'>;\n readonly sceneInputs: boolean;\n /** Current-frame motion/coverage producer, not reusable previous-frame history. */\n readonly temporal: boolean;\n readonly reflectionFallback: boolean;\n readonly capabilities: SsrSpatialCapabilities;\n /** Recovery readiness is optional for callers that have no recovery fault. */\n readonly recovery?: boolean;\n}\n\n/** The only camera fields used by the spatial admission owner. */\nexport interface SsrSpatialCamera {\n readonly projection: 'perspective' | 'orthographic';\n readonly near: number;\n readonly far: number;\n readonly screenSpaceReflection?: ScreenSpaceReflectionData;\n}\n\nexport interface SsrSpatialWork {\n readonly attachmentCount: number;\n readonly passCount: number;\n readonly bindingCount: number;\n readonly resourceCount: number;\n readonly historyCount: 0;\n readonly temporalDemand: 0;\n}\n\nexport type SsrSpatialStatus =\n | 'not-requested'\n | 'requested'\n | 'admitted'\n | 'fallback-only'\n | 'structural-only';\n\nexport interface SsrSpatialAdmissionBase {\n readonly status: SsrSpatialStatus;\n readonly lane: SsrSpatialLane;\n readonly config: ScreenSpaceReflectionData | undefined;\n readonly viewRange: number;\n readonly work: SsrSpatialWork;\n}\n\nexport type SsrSpatialAdmission =\n | (SsrSpatialAdmissionBase & {\n readonly status: 'not-requested' | 'requested';\n readonly failure?: undefined;\n })\n | (SsrSpatialAdmissionBase & {\n readonly status: 'admitted';\n readonly config: ScreenSpaceReflectionData;\n readonly failure?: undefined;\n })\n | (SsrSpatialAdmissionBase & {\n readonly status: 'fallback-only' | 'structural-only';\n readonly failure: SsrConfigInvalidError | SsrUnavailableError;\n });\n\nconst ZERO_SPATIAL_WORK: SsrSpatialWork = Object.freeze({\n attachmentCount: 0,\n passCount: 0,\n bindingCount: 0,\n resourceCount: 0,\n historyCount: 0,\n temporalDemand: 0,\n});\n\nconst ADMITTED_SPATIAL_WORK: SsrSpatialWork = Object.freeze({\n attachmentCount: 3,\n passCount: 4,\n bindingCount: 4,\n resourceCount: 3,\n historyCount: 0,\n temporalDemand: 0,\n});\n\nfunction configRange(\n field: SsrConfigField,\n viewRange: number,\n maxDistance: number,\n): SsrConfigRange {\n switch (field) {\n case 'maxDistance':\n return { min: 0, minInclusive: false, max: viewRange, maxInclusive: true };\n case 'thickness':\n return { min: 0, minInclusive: false, max: maxDistance, maxInclusive: true };\n case 'maxRoughness':\n return { min: 0, minInclusive: true, max: 1, maxInclusive: true };\n }\n}\n\nfunction configError(\n field: SsrConfigField,\n value: number,\n range: SsrConfigRange,\n): SsrConfigInvalidError {\n const left = range.minInclusive ? '[' : '(';\n const right = range.maxInclusive ? ']' : ')';\n return Object.freeze({\n code: 'ssr-config-invalid',\n expected: `finite ${field} in ${left}${range.min}, ${range.max}${right}`,\n hint: `set ${field} to a finite value inside the reported range before retrying`,\n detail: Object.freeze({ field, value, range: Object.freeze(range) }),\n });\n}\n\n/** Validate one schema-derived component value against the active view. */\nexport function validateScreenSpaceReflection(\n config: ScreenSpaceReflectionData,\n input: { readonly viewRange: number },\n): Result<ScreenSpaceReflectionData, SsrConfigInvalidError> {\n const viewRange = input.viewRange;\n if (!Number.isFinite(viewRange) || viewRange <= 0) {\n return err(\n configError('maxDistance', config.maxDistance, configRange('maxDistance', viewRange, 0)),\n );\n }\n if (\n !Number.isFinite(config.maxDistance) ||\n config.maxDistance <= 0 ||\n config.maxDistance > viewRange\n ) {\n return err(\n configError(\n 'maxDistance',\n config.maxDistance,\n configRange('maxDistance', viewRange, config.maxDistance),\n ),\n );\n }\n if (\n !Number.isFinite(config.thickness) ||\n config.thickness <= 0 ||\n config.thickness > config.maxDistance\n ) {\n return err(\n configError(\n 'thickness',\n config.thickness,\n configRange('thickness', viewRange, config.maxDistance),\n ),\n );\n }\n if (!Number.isFinite(config.maxRoughness) || config.maxRoughness < 0 || config.maxRoughness > 1) {\n return err(\n configError(\n 'maxRoughness',\n config.maxRoughness,\n configRange('maxRoughness', viewRange, config.maxDistance),\n ),\n );\n }\n return ok(\n Object.freeze({\n maxDistance: config.maxDistance,\n thickness: config.thickness,\n maxRoughness: config.maxRoughness,\n }),\n );\n}\n\nfunction unavailable(\n lane: SsrSpatialLane,\n reason: SsrSpatialUnavailableReason,\n required: readonly string[],\n actual: Readonly<Record<string, boolean | number | string>>,\n): SsrUnavailableError {\n const recovery =\n reason === 'lane-unsupported' || reason === 'projection-unsupported'\n ? 'select a perspective clustered or deferred Standard lane'\n : reason === 'reflection-fallback-unavailable'\n ? 'repair the submitted reflection fallback owner receipt'\n : reason === 'temporal-unavailable'\n ? 'submit the matching temporal-v1 producer receipt'\n : reason === 'recovery-unavailable'\n ? 'complete device and producer recovery before retrying'\n : 'restore the required scene, capability, or format input before retrying';\n return Object.freeze({\n code: 'ssr-unavailable',\n expected: 'SSR spatial admission has a complete Standard input and capability set',\n hint: recovery,\n detail: Object.freeze({\n lane,\n reason,\n required: Object.freeze([...required]),\n actual: Object.freeze({ ...actual }),\n recovery,\n }),\n });\n}\n\nfunction unavailableResult(\n lane: SsrSpatialLane,\n viewRange: number,\n failure: SsrUnavailableError,\n): SsrSpatialAdmission {\n return Object.freeze({\n status: 'fallback-only',\n lane,\n config: undefined,\n viewRange,\n work: ZERO_SPATIAL_WORK,\n failure,\n });\n}\n\n/**\n * Admit the active camera's schema-derived component into the M1 spatial\n * path. No graph/resource handle crosses this boundary.\n */\nexport function admitSsrSpatial(input: {\n readonly camera: SsrSpatialCamera;\n readonly environment: SsrSpatialEnvironment;\n}): SsrSpatialAdmission {\n const camera = input.camera;\n const environment = input.environment;\n const viewRange = camera.far - camera.near;\n const config = camera.screenSpaceReflection;\n if (config === undefined) {\n return Object.freeze({\n status: 'not-requested',\n lane: environment.lane,\n config: undefined,\n viewRange,\n work: ZERO_SPATIAL_WORK,\n });\n }\n\n const valid = validateScreenSpaceReflection(config, { viewRange });\n if (!valid.ok) {\n return Object.freeze({\n status: 'fallback-only',\n lane: environment.lane,\n config,\n viewRange,\n work: ZERO_SPATIAL_WORK,\n failure: valid.error,\n });\n }\n\n if (environment.m0.status !== 'admitted') {\n return unavailableResult(\n environment.lane,\n viewRange,\n unavailable(\n environment.lane,\n 'reflection-fallback-unavailable',\n ['admitted M0 dependency receipt'],\n { m0: false },\n ),\n );\n }\n if (environment.lane !== 'clustered' && environment.lane !== 'deferred') {\n return unavailableResult(\n environment.lane,\n viewRange,\n unavailable(environment.lane, 'lane-unsupported', ['clustered or deferred Standard lane'], {\n lane: environment.lane,\n }),\n );\n }\n if (camera.projection !== 'perspective') {\n return unavailableResult(\n environment.lane,\n viewRange,\n unavailable(environment.lane, 'projection-unsupported', ['perspective camera'], {\n projection: camera.projection,\n }),\n );\n }\n if (!environment.sceneInputs) {\n return unavailableResult(\n environment.lane,\n viewRange,\n unavailable(\n environment.lane,\n 'scene-input-unavailable',\n ['deferred Standard scene/material/fallback inputs'],\n { sceneInputs: false },\n ),\n );\n }\n if (!environment.temporal) {\n return unavailableResult(\n environment.lane,\n viewRange,\n unavailable(environment.lane, 'temporal-unavailable', ['temporal-v1'], { temporal: false }),\n );\n }\n if (!environment.reflectionFallback) {\n return unavailableResult(\n environment.lane,\n viewRange,\n unavailable(\n environment.lane,\n 'reflection-fallback-unavailable',\n ['submitted BRDF-projected fallback'],\n { reflectionFallback: false },\n ),\n );\n }\n if (environment.recovery === false) {\n return unavailableResult(\n environment.lane,\n viewRange,\n unavailable(environment.lane, 'recovery-unavailable', ['ready device and owners'], {\n recovery: false,\n }),\n );\n }\n const capabilities = environment.capabilities;\n if (\n !capabilities.compute ||\n !capabilities.storageTexture ||\n !capabilities.rgba16floatRenderable\n ) {\n return unavailableResult(\n environment.lane,\n viewRange,\n unavailable(\n environment.lane,\n 'capability-unavailable',\n ['compute', 'storageTexture', 'rgba16floatRenderable'],\n {\n compute: capabilities.compute,\n storageTexture: capabilities.storageTexture,\n rgba16floatRenderable: capabilities.rgba16floatRenderable,\n },\n ),\n );\n }\n if (!capabilities.r32floatSampledStorage) {\n return unavailableResult(\n environment.lane,\n viewRange,\n unavailable(\n environment.lane,\n 'format-unavailable',\n ['r32float sampled and storage mip chain'],\n { r32floatSampledStorage: false },\n ),\n );\n }\n return Object.freeze({\n status: 'admitted',\n lane: environment.lane,\n config: valid.value,\n viewRange,\n work: ADMITTED_SPATIAL_WORK,\n });\n}\n","import type { TextureFormat } from '@forgeax/engine-rhi';\nimport type { VolumeRecoveryState, VolumeSelectedLightFacts } from './recovery';\nimport type { VolumetricFogResourceFacts } from './resources';\n\nexport type VolumetricFogInspectionStatus = 'off' | 'available' | 'unavailable' | 'degraded';\n\nexport type VolumetricFogResourceStage = 'none' | 'candidate' | 'accepted' | 'lkg' | 'recovering';\n\nexport interface VolumetricFogInspection {\n readonly status: VolumetricFogInspectionStatus;\n readonly resourceStage: VolumetricFogResourceStage;\n readonly guid: string | undefined;\n readonly generation: number | undefined;\n readonly digest: string | undefined;\n readonly candidateGeneration: number | undefined;\n readonly candidateDigest: string | undefined;\n readonly lkgGeneration: number | undefined;\n readonly candidateFailure: VolumeRecoveryState['candidateFailure'];\n readonly deviceEpoch: number;\n readonly format: TextureFormat | undefined;\n readonly passCount: number;\n readonly sampleCount: number;\n readonly memoryBytes: number;\n readonly resourceFacts: VolumetricFogResourceFacts | undefined;\n readonly selectedLight: VolumeSelectedLightFacts | undefined;\n readonly candidateSelectedLight: VolumeSelectedLightFacts | undefined;\n}\n\nexport interface VolumetricFogInspectionInput {\n readonly authored: boolean;\n readonly capability: 'available' | 'unavailable';\n readonly degraded?: boolean;\n readonly recovery?: VolumeRecoveryState;\n readonly acceptedDigest?: string;\n readonly format?: TextureFormat;\n readonly passCount?: number;\n readonly sampleCount?: number;\n readonly memoryBytes?: number;\n readonly resourceFacts?: VolumetricFogResourceFacts;\n}\n\nfunction resourceStage(input: VolumetricFogInspectionInput): VolumetricFogResourceStage {\n if (!input.authored || input.recovery === undefined) return 'none';\n if (input.recovery.status === 'candidate') return 'candidate';\n if (input.recovery.status === 'recovering') return 'recovering';\n if (input.recovery.status === 'degraded') return 'lkg';\n return 'accepted';\n}\n\nexport function inspectVolumetricFog(input: VolumetricFogInspectionInput): VolumetricFogInspection {\n const recovery = input.recovery;\n const status: VolumetricFogInspectionStatus = !input.authored\n ? 'off'\n : input.capability === 'unavailable'\n ? 'unavailable'\n : input.degraded === true || recovery?.status === 'degraded'\n ? 'degraded'\n : 'available';\n return Object.freeze({\n status,\n resourceStage: resourceStage(input),\n guid: recovery?.guid,\n generation: recovery?.generation,\n digest: input.acceptedDigest,\n candidateGeneration: recovery?.candidateGeneration,\n candidateDigest: recovery?.candidateDigest,\n lkgGeneration: recovery?.lkgGeneration,\n candidateFailure: recovery?.candidateFailure,\n deviceEpoch: recovery?.deviceEpoch ?? 0,\n format: input.format,\n passCount: input.passCount ?? 0,\n sampleCount: input.sampleCount ?? 0,\n memoryBytes: input.memoryBytes ?? 0,\n resourceFacts: input.resourceFacts,\n selectedLight: recovery?.selectedLight,\n candidateSelectedLight: recovery?.candidateSelectedLight,\n });\n}\n","export interface ProbeFilterState {\n readonly probeIndex: number;\n readonly faceCount: number;\n readonly mipCount: number;\n readonly cursor: number;\n readonly activeGeneration: number;\n}\n\nexport function createProbeFilterState(input: {\n readonly probeIndex: number;\n readonly faceCount?: number;\n readonly mipCount: number;\n readonly activeGeneration?: number;\n}): ProbeFilterState {\n return {\n probeIndex: input.probeIndex,\n faceCount: input.faceCount ?? 6,\n mipCount: input.mipCount,\n cursor: 0,\n activeGeneration: input.activeGeneration ?? 0,\n };\n}\n\nexport function advanceProbeFilter(\n state: ProbeFilterState,\n):\n | { readonly probeIndex: number; readonly faceIndex: number; readonly mipLevel: number }\n | undefined {\n const total = state.faceCount * state.mipCount;\n if (state.cursor >= total) return undefined;\n return {\n probeIndex: state.probeIndex,\n faceIndex: state.cursor % state.faceCount,\n mipLevel: Math.floor(state.cursor / state.faceCount),\n };\n}\n\nexport function commitProbeFilterStep(state: ProbeFilterState, success: boolean): ProbeFilterState {\n if (!success) return state;\n const nextCursor = state.cursor + 1;\n const complete = nextCursor >= state.faceCount * state.mipCount;\n return {\n ...state,\n cursor: nextCursor,\n activeGeneration: complete ? state.activeGeneration + 1 : state.activeGeneration,\n };\n}\n\nexport function probeFilterIsSteady(state: ProbeFilterState): boolean {\n return state.cursor >= state.faceCount * state.mipCount;\n}\n\nfunction normalize(vector: readonly [number, number, number]): [number, number, number] {\n const length = Math.hypot(vector[0], vector[1], vector[2]);\n if (length === 0) return [0, 0, 1];\n return [vector[0] / length, vector[1] / length, vector[2] / length];\n}\n\nexport function boxProjectReflectionDirection(\n direction: readonly [number, number, number],\n boxCenter: readonly [number, number, number],\n halfExtents: readonly [number, number, number],\n point: readonly [number, number, number],\n): [number, number, number] {\n const ray = normalize(direction);\n for (const axis of [0, 1, 2] as const) {\n if (Math.abs(point[axis] - boxCenter[axis]) >= halfExtents[axis]) return ray;\n }\n let distance = Number.POSITIVE_INFINITY;\n for (let axis = 0; axis < 3; axis += 1) {\n const component = ray[axis] ?? 0;\n if (component === 0) continue;\n const extent = halfExtents[axis] ?? 0;\n const edge = component > 0 ? (boxCenter[axis] ?? 0) + extent : (boxCenter[axis] ?? 0) - extent;\n const candidate = (edge - (point[axis] ?? 0)) / component;\n if (candidate > 0) distance = Math.min(distance, candidate);\n }\n if (!Number.isFinite(distance)) return ray;\n return normalize([\n (point[0] ?? 0) + ray[0] * distance - (boxCenter[0] ?? 0),\n (point[1] ?? 0) + ray[1] * distance - (boxCenter[1] ?? 0),\n (point[2] ?? 0) + ray[2] * distance - (boxCenter[2] ?? 0),\n ]);\n}\n","import type { Buffer, Sampler, TextureView } from '@forgeax/engine-rhi';\n\nexport interface ReflectionProbeTableRow {\n readonly primitiveKey?: string;\n readonly index: number;\n readonly worldId: number;\n readonly entityKey: number;\n readonly center: readonly [number, number, number];\n readonly halfExtents: readonly [number, number, number];\n readonly intensity: number;\n readonly generation: number;\n /** Renderer-owned filtered cube used by the Standard material lane. */\n readonly filteredView?: TextureView;\n /** Renderer-owned sampler paired with filteredView. */\n readonly sampler?: Sampler;\n /** Per-probe uniform payload; keeps MaterialAsset ABI unchanged. */\n readonly uniformBuffer?: Buffer;\n}\n\nexport interface ReflectionProbeTable {\n readonly rows: readonly ReflectionProbeTableRow[];\n readonly cpuIndexByPrimitive: (primitiveKey: string) => number | undefined;\n readonly gpuIndexByPrimitive: (primitiveKey: string) => number | undefined;\n}\n\nexport function buildReflectionProbeTable(\n rows: readonly ReflectionProbeTableRow[],\n): ReflectionProbeTable {\n const ordered = rows.slice().sort((a, b) => a.index - b.index);\n const indices = new Map<string, number>();\n for (const row of ordered) {\n if (row.primitiveKey !== undefined) indices.set(row.primitiveKey, row.index);\n }\n const indexFor = (primitiveKey: string): number | undefined => indices.get(primitiveKey);\n return {\n rows: Object.freeze(ordered),\n cpuIndexByPrimitive: indexFor,\n gpuIndexByPrimitive: indexFor,\n };\n}\n\nexport function reflectionProbeTableBytes(table: ReflectionProbeTable): number {\n return table.rows.length * 48;\n}\n","import type {\n ReflectionFallbackFailureStage,\n ReflectionFallbackInspection,\n ReflectionFallbackReceipt,\n ReflectionFallbackRecoveryAction,\n} from '../inspection-types';\n\nexport interface ReflectionFallbackFailureInput {\n readonly stage: ReflectionFallbackFailureStage;\n readonly code: string;\n readonly expected: string;\n readonly detail?: Readonly<Record<string, unknown>>;\n}\n\nfunction recoveryFor(\n receipt: ReflectionFallbackReceipt,\n failure?: ReflectionFallbackFailureInput,\n): ReflectionFallbackRecoveryAction {\n if (failure !== undefined) {\n const code = failure.code.toLowerCase();\n if (code.includes('device') || code.includes('format') || code.includes('capability')) {\n return 'rebuild';\n }\n if (failure.stage === 'prepare' || failure.stage === 'filter') return 'recapture';\n if (failure.stage === 'build' || failure.stage === 'encode') return 'rebuild';\n if (failure.stage === 'finish' || failure.stage === 'submit') return 'retry';\n // Completion failures may still retain a source-identical committed row;\n // use it as LKG, otherwise retry the producer completion.\n if (failure.stage === 'completion') {\n if (receipt.source === 'probe' && (receipt.state === 'active' || receipt.state === 'lkg')) {\n return 'use-LKG';\n }\n if (\n receipt.source === 'skylight' &&\n (receipt.state === 'active' || receipt.state === 'lkg')\n ) {\n return 'use-Skylight';\n }\n if (receipt.source === 'neutral' && receipt.state === 'neutral') return 'use-neutral';\n return 'retry';\n }\n }\n if (receipt.source === 'probe' && (receipt.state === 'active' || receipt.state === 'lkg')) {\n return 'use-LKG';\n }\n if (receipt.source === 'skylight' || receipt.state === 'lkg') return 'use-Skylight';\n return 'use-neutral';\n}\n\n/** Projects producer state and the latest closed failure into detached facts. */\nexport function inspectReflectionFallback(\n receipt: ReflectionFallbackReceipt,\n failure?: ReflectionFallbackFailureInput,\n): ReflectionFallbackInspection {\n return {\n receipt,\n recoveryAction: recoveryFor(receipt, failure),\n ...(failure === undefined\n ? {}\n : {\n failureStage: failure.stage,\n failureCode: failure.code,\n expected: failure.expected,\n ...(failure.detail === undefined ? {} : { detail: failure.detail }),\n }),\n };\n}\n","import type { ReflectionProbeUpdateIntent } from '../components/reflection-probe';\n\nexport const REFLECTION_PROBE_BYTES_PER_TEXEL = 8;\nexport const DEFAULT_REFLECTION_PROBE_LIMITS = Object.freeze({\n maxProbes: 16,\n maxResolution: 256,\n maxBytes: 64 * 1024 * 1024,\n});\n\nexport interface ReflectionProbeInput {\n readonly halfExtents: readonly [number, number, number];\n readonly priority: number;\n readonly intensity: number;\n readonly resolution: number;\n readonly boxProjection?: boolean;\n}\n\nexport interface ReflectionProbeFact extends ReflectionProbeInput {\n readonly worldId: number;\n readonly entityKey: number;\n readonly center: readonly [number, number, number];\n readonly revision: number;\n readonly updateIntent?: ReflectionProbeUpdateIntent;\n readonly invalidationVersion?: number;\n}\n\nexport interface ReflectionProbeAdmissionLimits {\n readonly maxProbes?: number;\n readonly maxResolution?: number;\n readonly maxBytes?: number;\n}\n\nexport interface ReflectionProbeInvalidInput {\n readonly code: 'reflection-probe-input-invalid';\n readonly field: string;\n readonly value: unknown;\n readonly expected: string;\n}\n\nexport interface ReflectionProbeBudgetFailure {\n readonly code: 'reflection-probe-budget-exceeded';\n readonly requested: number;\n readonly activeCount: number;\n readonly activeBytes: number;\n readonly maxProbes: number;\n readonly maxBytes: number;\n}\n\nexport type ReflectionProbeAdmission =\n | { readonly ok: true; readonly acceptedBytes: number }\n | { readonly ok: false; readonly error: ReflectionProbeBudgetFailure };\n\nexport function validateReflectionProbeInput(\n input: ReflectionProbeInput,\n): { readonly ok: true } | { readonly ok: false; readonly error: ReflectionProbeInvalidInput } {\n for (let index = 0; index < input.halfExtents.length; index += 1) {\n const value = input.halfExtents[index];\n if (value === undefined || !Number.isFinite(value) || value <= 0) {\n return {\n ok: false,\n error: {\n code: 'reflection-probe-input-invalid',\n field: `halfExtents[${index}]`,\n value,\n expected: 'a finite number greater than zero',\n },\n };\n }\n }\n if (!Number.isFinite(input.priority)) {\n return {\n ok: false,\n error: {\n code: 'reflection-probe-input-invalid',\n field: 'priority',\n value: input.priority,\n expected: 'a finite number',\n },\n };\n }\n if (!Number.isFinite(input.intensity) || input.intensity < 0) {\n return {\n ok: false,\n error: {\n code: 'reflection-probe-input-invalid',\n field: 'intensity',\n value: input.intensity,\n expected: 'a finite number greater than or equal to zero',\n },\n };\n }\n if (\n !Number.isInteger(input.resolution) ||\n input.resolution < 16 ||\n (input.resolution & (input.resolution - 1)) !== 0\n ) {\n return {\n ok: false,\n error: {\n code: 'reflection-probe-input-invalid',\n field: 'resolution',\n value: input.resolution,\n expected: 'a power of two of at least 16 pixels',\n },\n };\n }\n return { ok: true };\n}\n\nexport function estimateReflectionProbeBytes(\n resolution: number,\n limits: ReflectionProbeAdmissionLimits = DEFAULT_REFLECTION_PROBE_LIMITS,\n): number {\n const maxResolution = limits.maxResolution ?? DEFAULT_REFLECTION_PROBE_LIMITS.maxResolution;\n const clamped = Math.min(resolution, maxResolution);\n let filteredTexels = 0;\n for (let mip = 0; mip < 5; mip++) {\n const size = Math.max(1, Math.floor(clamped / 2 ** mip));\n filteredTexels += size * size;\n }\n // Raw cube + two alternating filtered cubes + their depth attachments.\n return (\n (clamped * clamped + 2 * filteredTexels) * 6 * REFLECTION_PROBE_BYTES_PER_TEXEL +\n 3 * clamped * clamped * 4\n );\n}\n\nexport function admitReflectionProbe(\n input: ReflectionProbeInput,\n current: { readonly acceptedCount: number; readonly acceptedBytes: number },\n limits: ReflectionProbeAdmissionLimits = DEFAULT_REFLECTION_PROBE_LIMITS,\n): ReflectionProbeAdmission {\n const maxProbes = limits.maxProbes ?? DEFAULT_REFLECTION_PROBE_LIMITS.maxProbes;\n const maxBytes = limits.maxBytes ?? DEFAULT_REFLECTION_PROBE_LIMITS.maxBytes;\n const maxResolution = limits.maxResolution ?? DEFAULT_REFLECTION_PROBE_LIMITS.maxResolution;\n const requested = estimateReflectionProbeBytes(input.resolution, { maxResolution });\n if (\n input.resolution > maxResolution ||\n current.acceptedCount >= maxProbes ||\n current.acceptedBytes + requested > maxBytes\n ) {\n return {\n ok: false,\n error: {\n code: 'reflection-probe-budget-exceeded',\n requested,\n activeCount: current.acceptedCount,\n activeBytes: current.acceptedBytes,\n maxProbes,\n maxBytes,\n },\n };\n }\n return { ok: true, acceptedBytes: current.acceptedBytes + requested };\n}\n\nexport interface ReflectionProbeSelection {\n readonly kind: 'probe';\n readonly worldId: number;\n readonly entityKey: number;\n readonly normalizedDistance: number;\n}\n\nexport interface SkylightSelection {\n readonly kind: 'skylight';\n}\n\nexport type ReflectionProbeSelectionResult = ReflectionProbeSelection | SkylightSelection;\n\nexport type ReflectionFallbackSource = 'probe' | 'skylight' | 'neutral';\n\nexport interface ReflectionFallbackProjectionInput {\n /** Stable renderable identity used to join the main-pass projection. */\n readonly renderableKey?: string;\n /** Stable producer source identity; never a live GPU handle. */\n readonly sourceKey?: string;\n readonly source: ReflectionFallbackSource;\n readonly coverage: number;\n readonly extent?: readonly [number, number, number];\n readonly linearHdr: readonly [number, number, number, number];\n readonly brdfSignature: string;\n}\n\nexport interface ReflectionFallbackProjection extends ReflectionFallbackProjectionInput {\n readonly source: ReflectionFallbackSource;\n}\n\nexport type ReflectionFallbackMismatchKind = 'source' | 'coverage' | 'extent' | 'brdf';\n\nexport interface ReflectionFallbackMismatch {\n readonly code:\n | 'reflection-fallback-source-mismatch'\n | 'reflection-fallback-coverage-mismatch'\n | 'reflection-fallback-extent-mismatch'\n | 'reflection-fallback-brdf-mismatch';\n readonly expected: string;\n readonly actual: string;\n}\n\nexport interface ReflectionFallbackInputInvalid {\n readonly code: 'reflection-fallback-input-invalid';\n readonly field: string;\n readonly expected: string;\n}\n\nexport type ReflectionFallbackProjectionResult =\n | { readonly ok: true; readonly value: ReflectionFallbackProjection }\n | { readonly ok: false; readonly error: ReflectionFallbackInputInvalid };\n\nexport function resolveReflectionFallbackSource(\n selection: ReflectionProbeSelectionResult,\n probeReady: boolean,\n skylightAvailable = true,\n): ReflectionFallbackSource {\n if (selection.kind === 'probe' && probeReady) return 'probe';\n // An unavailable probe follows the producer recovery order: use the active\n // Skylight when one exists, then the producer-owned neutral zero. Returning\n // neutral directly here would make the main Standard lighting lane and the\n // detached fallback projection disagree.\n if (skylightAvailable) return 'skylight';\n return 'neutral';\n}\n\nexport function reflectionFallbackCoverage(\n source: ReflectionFallbackSource,\n fact: ReflectionProbeFact | undefined,\n selection: ReflectionProbeSelectionResult,\n): number {\n if (source === 'neutral') return 0;\n if (source === 'skylight') return 1;\n if (fact === undefined || selection.kind !== 'probe') return 0;\n const normalized = Math.sqrt(Math.max(0, selection.normalizedDistance));\n return Math.max(0, Math.min(1, 1 - normalized / Math.sqrt(3)));\n}\n\nexport function reflectionFallbackSourceKey(\n source: ReflectionFallbackSource,\n selection: ReflectionProbeSelectionResult,\n skylight?: { readonly entityHandle: number; readonly equirectHandle: number },\n): string {\n if (source === 'probe' && selection.kind === 'probe') {\n return `probe:${selection.worldId}:${selection.entityKey}`;\n }\n if (source === 'skylight' && skylight !== undefined) {\n return `skylight:${skylight.entityHandle}:${skylight.equirectHandle}`;\n }\n return source;\n}\n\nexport function reflectionFallbackProjectionSignature(\n input: ReflectionFallbackProjectionInput,\n): string {\n return JSON.stringify({\n renderableKey: input.renderableKey,\n sourceKey: input.sourceKey,\n source: input.source,\n coverage: input.coverage,\n extent: input.extent,\n brdfSignature: input.brdfSignature,\n });\n}\n\nexport function deriveReflectionFallbackProjection(\n input: ReflectionFallbackProjectionInput,\n): ReflectionFallbackProjectionResult {\n if (!Number.isFinite(input.coverage) || input.coverage < 0 || input.coverage > 1) {\n return {\n ok: false,\n error: {\n code: 'reflection-fallback-input-invalid',\n field: 'coverage',\n expected: 'a finite number between zero and one',\n },\n };\n }\n if (input.extent?.some((value) => !Number.isFinite(value) || value <= 0)) {\n return {\n ok: false,\n error: {\n code: 'reflection-fallback-input-invalid',\n field: 'extent',\n expected: 'three finite numbers greater than zero',\n },\n };\n }\n if (input.linearHdr.some((value) => !Number.isFinite(value))) {\n return {\n ok: false,\n error: {\n code: 'reflection-fallback-input-invalid',\n field: 'linearHdr',\n expected: 'four finite linear HDR values',\n },\n };\n }\n if (input.brdfSignature.length === 0) {\n return {\n ok: false,\n error: {\n code: 'reflection-fallback-input-invalid',\n field: 'brdfSignature',\n expected: 'a non-empty BRDF signature',\n },\n };\n }\n const linearHdr = input.source === 'neutral' ? ([0, 0, 0, 0] as const) : [...input.linearHdr];\n return {\n ok: true,\n value: Object.freeze({\n ...(input.renderableKey === undefined ? {} : { renderableKey: input.renderableKey }),\n ...(input.sourceKey === undefined ? {} : { sourceKey: input.sourceKey }),\n source: input.source,\n coverage: input.coverage,\n ...(input.extent === undefined\n ? {}\n : {\n extent: Object.freeze([...input.extent]) as readonly [number, number, number],\n }),\n linearHdr: Object.freeze(linearHdr) as ReflectionFallbackProjection['linearHdr'],\n brdfSignature: input.brdfSignature,\n }),\n };\n}\n\nexport function validateReflectionFallbackCompatibility(\n expected: ReflectionFallbackProjectionInput,\n actual: ReflectionFallbackProjectionInput,\n): { readonly ok: true } | { readonly ok: false; readonly error: ReflectionFallbackMismatch } {\n const mismatch = (\n kind: ReflectionFallbackMismatchKind,\n expectedValue: string,\n actualValue: string,\n ): { readonly ok: false; readonly error: ReflectionFallbackMismatch } => ({\n ok: false,\n error: {\n code: `reflection-fallback-${kind}-mismatch` as ReflectionFallbackMismatch['code'],\n expected: expectedValue,\n actual: actualValue,\n },\n });\n if (expected.source !== actual.source) {\n return mismatch('source', expected.source, actual.source);\n }\n if (expected.coverage !== actual.coverage) {\n return mismatch('coverage', String(expected.coverage), String(actual.coverage));\n }\n const expectedExtent = expected.extent;\n const actualExtent = actual.extent;\n if (\n (expectedExtent === undefined && actualExtent !== undefined) ||\n (expectedExtent !== undefined &&\n (actualExtent === undefined ||\n expectedExtent.some((value, index) => value !== actualExtent[index])))\n ) {\n return mismatch('extent', JSON.stringify(expectedExtent), JSON.stringify(actualExtent));\n }\n if (expected.brdfSignature !== actual.brdfSignature) {\n return mismatch('brdf', expected.brdfSignature, actual.brdfSignature);\n }\n return { ok: true };\n}\n\nfunction contains(fact: ReflectionProbeFact, point: readonly [number, number, number]): boolean {\n return fact.halfExtents.every((extent, axis) => {\n const center = fact.center[axis] ?? 0;\n const coordinate = point[axis] ?? 0;\n return Math.abs(coordinate - center) <= extent;\n });\n}\n\nfunction normalizedDistance(\n fact: ReflectionProbeFact,\n point: readonly [number, number, number],\n): number {\n let squared = 0;\n for (let axis = 0; axis < 3; axis += 1) {\n const delta = (point[axis] ?? 0) - (fact.center[axis] ?? 0);\n const extent = fact.halfExtents[axis] ?? 1;\n squared += (delta / extent) ** 2;\n }\n return squared;\n}\n\nfunction isBetter(\n candidate: ReflectionProbeSelection,\n current: ReflectionProbeSelection,\n facts: readonly ReflectionProbeFact[],\n): boolean {\n const candidateFact = facts.find(\n (fact) => fact.worldId === candidate.worldId && fact.entityKey === candidate.entityKey,\n );\n const currentFact = facts.find(\n (fact) => fact.worldId === current.worldId && fact.entityKey === current.entityKey,\n );\n if (candidateFact === undefined || currentFact === undefined) return false;\n if (candidateFact.priority !== currentFact.priority)\n return candidateFact.priority > currentFact.priority;\n if (candidate.normalizedDistance !== current.normalizedDistance) {\n return candidate.normalizedDistance < current.normalizedDistance;\n }\n return (\n candidate.worldId < current.worldId ||\n (candidate.worldId === current.worldId && candidate.entityKey < current.entityKey)\n );\n}\n\nexport function selectReflectionProbe(\n facts: readonly ReflectionProbeFact[],\n primitiveCenter: readonly [number, number, number],\n): ReflectionProbeSelectionResult {\n let selected: ReflectionProbeSelection | undefined;\n for (const fact of facts) {\n if (!contains(fact, primitiveCenter)) continue;\n const candidate: ReflectionProbeSelection = {\n kind: 'probe',\n worldId: fact.worldId,\n entityKey: fact.entityKey,\n normalizedDistance: normalizedDistance(fact, primitiveCenter),\n };\n if (selected === undefined || isBetter(candidate, selected, facts)) selected = candidate;\n }\n return selected ?? { kind: 'skylight' };\n}\n\nexport interface ReflectionProbePrimitive {\n readonly worldId: number;\n readonly entityKey: number;\n /** Main-pass renderable key; world/entity is retained as the compatibility fallback. */\n readonly renderableKey?: string;\n readonly center: readonly [number, number, number];\n}\n\nexport interface ReflectionProbeProjectionSnapshot {\n readonly revision: number;\n readonly facts: readonly ReflectionProbeFact[];\n readonly selected: ReadonlyMap<string, ReflectionProbeSelectionResult>;\n readonly scannedPrimitives: number;\n}\n\nfunction primitiveKey(worldId: number, entityKey: number): string {\n return `${worldId}:${entityKey}`;\n}\n\nexport class ReflectionProbeProjection {\n private revision = 0;\n private facts: readonly ReflectionProbeFact[] = [];\n private selected = new Map<string, ReflectionProbeSelectionResult>();\n private signature = '';\n private scannedPrimitives = 0;\n\n update(\n facts: readonly ReflectionProbeFact[],\n primitives: readonly ReflectionProbePrimitive[],\n ): ReflectionProbeProjectionSnapshot {\n const nextFacts = facts\n .slice()\n .sort((a, b) => a.worldId - b.worldId || a.entityKey - b.entityKey);\n const signature = JSON.stringify({ facts: nextFacts, primitives });\n if (signature === this.signature) return this.snapshot();\n this.signature = signature;\n this.facts = nextFacts;\n this.selected = new Map();\n for (const primitive of primitives) {\n this.selected.set(\n primitive.renderableKey ?? primitiveKey(primitive.worldId, primitive.entityKey),\n selectReflectionProbe(nextFacts, primitive.center),\n );\n }\n this.scannedPrimitives = primitives.length;\n this.revision += 1;\n return this.snapshot();\n }\n\n snapshot(): ReflectionProbeProjectionSnapshot {\n return {\n revision: this.revision,\n facts: this.facts,\n selected: this.selected,\n scannedPrimitives: this.scannedPrimitives,\n };\n }\n\n selection(worldId: number, entityKey: number): ReflectionProbeSelectionResult {\n return this.selected.get(primitiveKey(worldId, entityKey)) ?? { kind: 'skylight' };\n }\n}\n","import { createVisibilityBudget } from './budget';\n\n/** Detached, bounded LOD/occlusion facts for renderer inspection consumers. */\n\nexport const LOD_OCCLUSION_INSPECTION_SCHEMA = 'forgeax::lod-occlusion-inspection::v2' as const;\nexport const LOD_OCCLUSION_INSPECTION_MAX_BYTES = 16 * 1024;\nconst MAX_INSPECTION_SAMPLES = 64;\n\nexport type LodOcclusionInspectionError = {\n readonly code: string;\n readonly expected: string;\n readonly hint: string;\n readonly detail?: Readonly<Record<string, string | number | boolean>>;\n};\n\nexport type LodOcclusionFallback =\n | { readonly active: false }\n | {\n readonly active: true;\n readonly reason: 'producer-failed' | 'page-exhausted' | 'query-failed' | 'device-loss';\n readonly error: LodOcclusionInspectionError;\n };\n\nexport type LodOcclusionDegradation =\n | { readonly active: false }\n | { readonly active: true; readonly reason: 'all-visible' | 'query-unavailable' };\n\nexport interface LodOcclusionInspectionSample {\n readonly primitiveSlot: number;\n readonly level: number;\n readonly visible: boolean;\n}\n\nexport interface LodOcclusionInspectionRow {\n readonly root: { readonly guid: string; readonly sourceKey: string };\n readonly view: {\n readonly attachmentId: string;\n readonly cameraEntity: number;\n readonly viewRole: 'main' | 'shadow' | 'reflection' | 'probe';\n readonly viewGeneration: number;\n };\n readonly slot: { readonly primitiveSlot: number; readonly slotGeneration: number };\n readonly generation: number;\n readonly count: {\n readonly candidates: number;\n readonly visible: number;\n readonly occluded: number;\n };\n readonly lodHistogram: readonly { readonly level: number; readonly count: number }[];\n /** Map latency for the most recently completed query page (bounded POD). */\n readonly queryLatencyUs: {\n readonly median: number;\n readonly p95: number;\n readonly last: number;\n };\n readonly pagePressure: { readonly used: number; readonly capacity: number };\n readonly fallback: LodOcclusionFallback;\n readonly degradation: LodOcclusionDegradation;\n readonly samples: readonly LodOcclusionInspectionSample[];\n}\n\nexport interface LodOcclusionInspectionSubmit {\n readonly frameId: number;\n readonly build: string;\n readonly deviceGeneration: number;\n}\n\n/**\n * Per-World attribution is only authoritative when the renderer publishes\n * the GPU facts from the same submit that owns the parent inspection. The\n * normal projection path remains useful diagnostics, but it must not be used\n * as evidence for a World-reorder or per-World LOD claim.\n */\nexport type LodOcclusionWorldAttribution =\n | { readonly status: 'unavailable'; readonly reason: 'projection-only' }\n | { readonly status: 'same-submit'; readonly submit: LodOcclusionInspectionSubmit };\n\nexport interface LodOcclusionWorldInspection {\n readonly attachmentId: string;\n readonly rows: readonly LodOcclusionInspectionRow[];\n readonly attribution: LodOcclusionWorldAttribution;\n}\n\nexport interface LodOcclusionInspectionBudget {\n readonly configuredQueryBudget: number;\n readonly effectiveQueryBudget: number;\n readonly settleSubmits: number;\n readonly retestSubmits: number;\n readonly expirySubmits: number;\n}\n\nexport interface LodOcclusionInspection extends LodOcclusionInspectionRow {\n readonly schema: typeof LOD_OCCLUSION_INSPECTION_SCHEMA;\n /** Atomic identity for the submit that produced every row below. */\n readonly submit: LodOcclusionInspectionSubmit;\n /** Immutable budget values used by the query and confidence owners. */\n readonly budget: LodOcclusionInspectionBudget;\n /** Stable attachment identity; array order is never an attribution key. */\n readonly worlds: readonly LodOcclusionWorldInspection[];\n}\n\nexport type LodOcclusionInspectionInput = Omit<\n LodOcclusionInspection,\n 'schema' | 'submit' | 'budget' | 'worlds'\n> & {\n readonly submit?: LodOcclusionInspectionSubmit;\n readonly budget?: LodOcclusionInspectionBudget;\n readonly worlds?: readonly LodOcclusionWorldInspectionInput[];\n};\n\nexport type LodOcclusionWorldInspectionInput = Omit<LodOcclusionWorldInspection, 'attribution'> & {\n readonly attribution?: LodOcclusionWorldAttribution;\n};\n\nexport type LodOcclusionInspectionAction =\n | { readonly action: 'none' }\n | { readonly action: 'rebuild'; readonly sourceKey: string; readonly reason: string }\n | { readonly action: 'cold-cook'; readonly sourceKey: string; readonly reason: string }\n | { readonly action: 'retry'; readonly sourceKey: string; readonly reason: string };\n\nfunction nonNegativeInteger(name: string, value: number): number {\n if (!Number.isInteger(value) || value < 0)\n throw new Error(`${name} must be a non-negative integer`);\n return value;\n}\n\nfunction copyError(error: LodOcclusionInspectionError): LodOcclusionInspectionError {\n return Object.freeze({\n code: error.code,\n expected: error.expected,\n hint: error.hint,\n ...(error.detail === undefined ? {} : { detail: Object.freeze({ ...error.detail }) }),\n });\n}\n\nfunction copyFallback(fallback: LodOcclusionFallback): LodOcclusionFallback {\n return fallback.active\n ? Object.freeze({ ...fallback, error: copyError(fallback.error) })\n : Object.freeze({ active: false });\n}\n\nfunction copySamples(\n samples: readonly LodOcclusionInspectionSample[],\n): readonly LodOcclusionInspectionSample[] {\n return Object.freeze(\n [...samples]\n .sort((left, right) => left.primitiveSlot - right.primitiveSlot)\n .slice(0, MAX_INSPECTION_SAMPLES)\n .map((sample) =>\n Object.freeze({\n primitiveSlot: nonNegativeInteger('sample.primitiveSlot', sample.primitiveSlot),\n level: nonNegativeInteger('sample.level', sample.level),\n visible: sample.visible,\n }),\n ),\n );\n}\n\nfunction copyWorldAttribution(\n attribution: LodOcclusionWorldAttribution | undefined,\n): LodOcclusionWorldAttribution {\n if (attribution === undefined) {\n return Object.freeze({ status: 'unavailable', reason: 'projection-only' });\n }\n if (attribution.status === 'same-submit') {\n if (typeof attribution.submit.build !== 'string' || attribution.submit.build.length === 0) {\n throw new Error('world.attribution.submit.build must be a non-empty string');\n }\n nonNegativeInteger('world.attribution.submit.frameId', attribution.submit.frameId);\n nonNegativeInteger(\n 'world.attribution.submit.deviceGeneration',\n attribution.submit.deviceGeneration,\n );\n return Object.freeze({\n status: 'same-submit',\n submit: Object.freeze({ ...attribution.submit }),\n });\n }\n if (attribution.status !== 'unavailable' || attribution.reason !== 'projection-only') {\n throw new Error('world.attribution must declare same-submit or projection-only');\n }\n return Object.freeze({ status: 'unavailable', reason: 'projection-only' });\n}\n\nfunction copyRow(row: LodOcclusionInspectionRow): LodOcclusionInspectionRow {\n for (const [name, value] of Object.entries({\n generation: row.generation,\n candidates: row.count.candidates,\n visible: row.count.visible,\n occluded: row.count.occluded,\n median: row.queryLatencyUs.median,\n p95: row.queryLatencyUs.p95,\n last: row.queryLatencyUs.last,\n pageUsed: row.pagePressure.used,\n pageCapacity: row.pagePressure.capacity,\n }))\n nonNegativeInteger(`inspection.${name}`, value);\n if (\n row.view.cameraEntity < 0 ||\n row.view.viewGeneration < 0 ||\n row.slot.primitiveSlot < 0 ||\n row.slot.slotGeneration < 0\n ) {\n throw new Error('inspection identity values must be non-negative');\n }\n if (row.pagePressure.used > row.pagePressure.capacity) {\n throw new Error('inspection page pressure exceeds capacity');\n }\n return Object.freeze({\n root: Object.freeze({ ...row.root }),\n view: Object.freeze({ ...row.view }),\n slot: Object.freeze({ ...row.slot }),\n generation: row.generation,\n count: Object.freeze({ ...row.count }),\n lodHistogram: Object.freeze(\n row.lodHistogram.map((histogram) =>\n Object.freeze({\n level: nonNegativeInteger('histogram.level', histogram.level),\n count: nonNegativeInteger('histogram.count', histogram.count),\n }),\n ),\n ),\n queryLatencyUs: Object.freeze({ ...row.queryLatencyUs }),\n pagePressure: Object.freeze({ ...row.pagePressure }),\n fallback: copyFallback(row.fallback),\n degradation: Object.freeze({ ...row.degradation }),\n samples: copySamples(row.samples),\n });\n}\n\nfunction copyWorlds(\n worlds: readonly LodOcclusionWorldInspectionInput[] | undefined,\n fallback: LodOcclusionInspectionRow,\n): readonly LodOcclusionWorldInspection[] {\n const source = worlds ?? [{ attachmentId: fallback.view.attachmentId, rows: [fallback] }];\n return Object.freeze(\n source.map((world) =>\n Object.freeze({\n attachmentId: world.attachmentId,\n rows: Object.freeze(world.rows.map((row) => copyRow(row))),\n attribution: copyWorldAttribution(world.attribution),\n }),\n ),\n );\n}\n\nexport function inspectLodOcclusion(input: LodOcclusionInspectionInput): LodOcclusionInspection {\n const row = copyRow(input);\n const defaultBudget = createVisibilityBudget();\n const budget = input.budget ?? {\n configuredQueryBudget: defaultBudget.configuredQueryBudget,\n effectiveQueryBudget: defaultBudget.effectiveQueryBudget,\n settleSubmits: defaultBudget.settleSubmits,\n retestSubmits: defaultBudget.retestSubmits,\n expirySubmits: defaultBudget.expirySubmits,\n };\n for (const [name, value] of Object.entries(budget))\n nonNegativeInteger(`inspection.budget.${name}`, value);\n const submit = input.submit ?? {\n frameId: input.generation,\n build: 'unknown',\n deviceGeneration: 0,\n };\n nonNegativeInteger('inspection.submit.frameId', submit.frameId);\n nonNegativeInteger('inspection.submit.deviceGeneration', submit.deviceGeneration);\n if (typeof submit.build !== 'string' || submit.build.length === 0) {\n throw new Error('inspection.submit.build must be a non-empty string');\n }\n const worlds = copyWorlds(input.worlds, row);\n for (const world of worlds) {\n if (\n world.attribution.status === 'same-submit' &&\n (world.attribution.submit.frameId !== submit.frameId ||\n world.attribution.submit.build !== submit.build ||\n world.attribution.submit.deviceGeneration !== submit.deviceGeneration)\n ) {\n throw new Error('world attribution must reference the parent inspection submit');\n }\n }\n const inspection: LodOcclusionInspection = Object.freeze({\n schema: LOD_OCCLUSION_INSPECTION_SCHEMA,\n ...row,\n submit: Object.freeze({ ...submit }),\n budget: Object.freeze({ ...budget }),\n worlds,\n });\n if (JSON.stringify(inspection).length > LOD_OCCLUSION_INSPECTION_MAX_BYTES) {\n throw new Error(`LOD occlusion inspection exceeds ${LOD_OCCLUSION_INSPECTION_MAX_BYTES} bytes`);\n }\n return inspection;\n}\n\nexport function serializeLodOcclusionInspection(inspection: LodOcclusionInspection): string {\n const serialized = JSON.stringify(inspection);\n if (serialized.length > LOD_OCCLUSION_INSPECTION_MAX_BYTES) {\n throw new Error(`LOD occlusion inspection exceeds ${LOD_OCCLUSION_INSPECTION_MAX_BYTES} bytes`);\n }\n return serialized;\n}\n\nexport function consumeLodOcclusionInspection(\n inspection: LodOcclusionInspection,\n): LodOcclusionInspectionAction {\n if (!inspection.fallback.active) return { action: 'none' };\n const { reason, error } = inspection.fallback;\n const action =\n error.code.startsWith('asset-') || reason === 'producer-failed'\n ? 'rebuild'\n : reason === 'query-failed' || reason === 'page-exhausted' || reason === 'device-loss'\n ? 'retry'\n : 'cold-cook';\n return { action, sourceKey: inspection.root.sourceKey, reason };\n}\n","// @forgeax/engine-render - bounded SSR spatial inspection projection.\n\nimport type { ScreenSpaceReflectionData } from '../components/screen-space-reflection';\nimport type { ReflectionFallbackSource } from '../inspection-types';\nimport type { SsrSpatialAdmission, SsrSpatialLane, SsrSpatialWork } from './admission';\nimport type { SsrConfigInvalidError, SsrUnavailableError } from './errors';\nimport type { SsrHistoryState } from './history';\n\nexport type SsrSpatialInspectionFailure = SsrConfigInvalidError | SsrUnavailableError;\n\nexport interface SsrSpatialHistoryInspection {\n readonly state: 'not-owned' | SsrHistoryState;\n readonly bytes: number;\n readonly resetCount: number;\n}\n\nexport interface SsrSpatialInspectionProjection {\n readonly status?: SsrSpatialInspection['status'];\n readonly coverage?: Partial<SsrSpatialInspection['coverage']>;\n readonly history?: SsrSpatialHistoryInspection;\n readonly passRoster?: readonly string[];\n readonly fallbackSource?: ReflectionFallbackSource;\n readonly failure?: SsrSpatialInspectionFailure;\n}\n\n/** Keep the public projection bounded even if a graph owner supplies a bad list. */\nexport const SSR_INSPECTION_MAX_PASSES = 64 as const;\n\nfunction nonNegativeSafeInteger(name: string, value: number): number {\n if (!Number.isSafeInteger(value) || value < 0) {\n throw new Error(`${name} must be a non-negative safe integer`);\n }\n return value;\n}\n\nfunction copyHistory(history: SsrSpatialHistoryInspection): SsrSpatialHistoryInspection {\n nonNegativeSafeInteger('SSR inspection history.bytes', history.bytes);\n nonNegativeSafeInteger('SSR inspection history.resetCount', history.resetCount);\n return Object.freeze({\n state: history.state,\n bytes: history.bytes,\n resetCount: history.resetCount,\n });\n}\n\nfunction copyCoverage(\n coverage: Partial<SsrSpatialInspection['coverage']> | undefined,\n): SsrSpatialInspection['coverage'] {\n const result = {\n hitCount: coverage?.hitCount ?? null,\n fallbackCount: coverage?.fallbackCount ?? null,\n excludedCount: coverage?.excludedCount ?? null,\n };\n for (const [key, value] of Object.entries(result)) {\n if (value !== null) nonNegativeSafeInteger(`SSR inspection coverage.${key}`, value);\n }\n return Object.freeze(result);\n}\n\nfunction copyPassRoster(passRoster: readonly string[] | undefined): readonly string[] {\n return Object.freeze(\n [...(passRoster ?? [])].slice(0, SSR_INSPECTION_MAX_PASSES).map((name, index) => {\n if (typeof name !== 'string' || name.length === 0) {\n throw new Error(`SSR inspection passRoster[${index}] must be a non-empty string`);\n }\n return name;\n }),\n );\n}\n\nexport interface SsrSpatialInspection {\n readonly status: 'not-requested' | 'requested' | 'admitted' | 'fallback-only' | 'structural-only';\n readonly lane: SsrSpatialLane;\n readonly config: ScreenSpaceReflectionData | undefined;\n readonly viewRange: number;\n readonly coverage: {\n /** Null means no GPU coverage measurement is available for this frame. */\n readonly hitCount: number | null;\n readonly fallbackCount: number | null;\n readonly excludedCount: number | null;\n };\n readonly history: SsrSpatialHistoryInspection;\n readonly work: SsrSpatialWork;\n readonly passRoster: readonly string[];\n readonly fallbackSource: ReflectionFallbackSource | undefined;\n readonly failure: SsrSpatialInspectionFailure | undefined;\n}\n\n/** Project only detached, bounded facts from the spatial admission result. */\nexport function projectSsrSpatialInspection(\n admission: SsrSpatialAdmission,\n projection: SsrSpatialInspectionProjection = {},\n): SsrSpatialInspection {\n const config = admission.config;\n return Object.freeze({\n status: projection.status ?? admission.status,\n lane: admission.lane,\n config:\n config === undefined\n ? undefined\n : Object.freeze({\n maxDistance: config.maxDistance,\n thickness: config.thickness,\n maxRoughness: config.maxRoughness,\n }),\n viewRange: admission.viewRange,\n coverage: copyCoverage(projection.coverage),\n history: copyHistory(\n projection.history ?? {\n state: 'not-owned' as const,\n bytes: 0,\n resetCount: 0,\n },\n ),\n work: Object.freeze({ ...admission.work }),\n passRoster: copyPassRoster(projection.passRoster),\n fallbackSource: projection.fallbackSource,\n failure: projection.failure ?? admission.failure,\n });\n}\n\nexport function serializeSsrSpatialInspection(inspection: SsrSpatialInspection): string {\n return JSON.stringify(inspection);\n}\n","import type { Handle, MeshAsset } from '@forgeax/engine-types';\nimport { err, ok, type Result } from '@forgeax/engine-types';\n\n/** A standard MeshAsset candidate prepared for one attached World generation. */\nexport interface DynamicGeometryPrepareInput {\n readonly world: object;\n /** Live ECS entity carrying MeshFilter + MeshRenderer on the attached World. */\n readonly entity?: number;\n /** Optional derived-physics entity whose fixed-step publication gates draw. */\n readonly physicsEntity?: number;\n readonly mesh: MeshAsset;\n /** Existing World.sharedRefs handle whose standard GPU residency is prepared. */\n readonly meshHandle?: Handle<'MeshAsset', 'shared'>;\n readonly revision: number;\n /** Material identity is a consumer fact; MaterialAsset stays in the World. */\n readonly materialIdentity?: string;\n /** Topology changes invalidate motion/history consumers. */\n readonly topologyRevision?: number;\n /** Captured by the Renderer host from the World FixedTime resource. */\n readonly fixedStep?: number;\n}\n\n/** Explicit ECS/fixed-step ordering proof used by Renderer admission. */\nexport interface DynamicGeometryOrdering {\n readonly world: object;\n readonly fixedStep: number;\n}\n\nexport type DynamicGeometryCandidateState =\n | 'prepared'\n | 'accepted'\n | 'published'\n | 'cancelled'\n | 'retired';\n\nexport interface DynamicGeometryCandidate {\n readonly candidateId: string;\n readonly generation: number;\n readonly owner: object;\n readonly world: object;\n readonly entity?: number;\n readonly physicsEntity?: number;\n /** False when the pure lifecycle was used without a shared MeshAsset handle. */\n readonly gpuReady: boolean;\n /** CPU/GPU geometry bytes reserved by this candidate budget. */\n readonly meshBytes: number;\n readonly revision: number;\n readonly topologyRevision: number;\n readonly materialIdentity?: string;\n readonly meshHandle?: Handle<'MeshAsset', 'shared'>;\n readonly fixedStep?: number;\n readonly mesh: MeshAsset;\n readonly state: DynamicGeometryCandidateState;\n}\n\n/** Receipt that ties candidate publication to the sole Renderer FrameReceipt. */\nexport interface DynamicGeometryReceipt {\n readonly candidateId: string;\n readonly generation: number;\n readonly revision: number;\n readonly topologyRevision: number;\n readonly fixedStep?: number;\n readonly frameId: number;\n readonly deviceGeneration: number;\n readonly frame: {\n readonly frameId: number;\n readonly deviceGeneration: number;\n readonly completed?: Promise<unknown>;\n };\n /** Whether the Renderer record stage consumed this candidate for this frame. */\n readonly recordStageConsumed: boolean;\n /** Actual frame fixed step; may be newer than the preparation step. */\n readonly publicationFixedStep?: number;\n}\n\nexport interface DynamicGeometryInspection {\n readonly generation: number;\n readonly prepared: number;\n readonly accepted: number;\n readonly published: number;\n readonly retired: number;\n readonly latestRevision?: number;\n readonly latestFrameId?: number;\n readonly historyInvalidations: number;\n readonly invalidated: number;\n readonly meshBytes: number;\n readonly maxMeshBytes: number;\n}\n\nexport type DynamicGeometryErrorCode =\n | 'dynamic-geometry-disposed'\n | 'dynamic-geometry-world-not-attached'\n | 'dynamic-geometry-invalid'\n | 'dynamic-geometry-gpu-failed'\n | 'dynamic-geometry-gpu-not-ready'\n | 'dynamic-geometry-budget-exceeded'\n | 'dynamic-geometry-stale'\n | 'dynamic-geometry-generation-mismatch'\n | 'dynamic-geometry-candidate-not-found'\n | 'dynamic-geometry-candidate-state'\n | 'dynamic-geometry-receipt-mismatch'\n | 'dynamic-geometry-ordering-required';\n\nexport interface DynamicGeometryErrorDetail {\n readonly code: DynamicGeometryErrorCode;\n readonly candidateId?: string;\n readonly revision?: number;\n readonly generation?: number;\n readonly actual?: unknown;\n}\n\nexport class DynamicGeometryError extends Error {\n readonly code: DynamicGeometryErrorCode;\n readonly expected: string;\n readonly hint: string;\n readonly detail: DynamicGeometryErrorDetail;\n\n constructor(\n code: DynamicGeometryErrorCode,\n expected: string,\n hint: string,\n detail: Omit<DynamicGeometryErrorDetail, 'code'> = {},\n ) {\n super(`${code}: ${expected}`);\n this.name = 'DynamicGeometryError';\n this.code = code;\n this.expected = expected;\n this.hint = hint;\n this.detail = Object.freeze({ code, ...detail });\n }\n}\n\ninterface CandidateRecord {\n readonly world: object;\n candidate: DynamicGeometryCandidate;\n /** Published history remains queryable for its completion fence, but a\n * newer topology must prevent that history from being consumed again. */\n historyInvalidated: boolean;\n acceptedFrame?: { readonly frameId: number; readonly deviceGeneration: number };\n}\n\n/**\n * A public candidate is a credential, not a mutable state object. Keep the\n * owner/world check in `current` cheap, then compare every scalar admission\n * fact before a caller can cancel, retire, or inspect another record by\n * copying its candidate id. The renderer-owned MeshAsset copy remains the\n * content source for the actual draw.\n */\nexport function sameCandidateCredential(\n candidate: DynamicGeometryCandidate,\n committed: DynamicGeometryCandidate,\n): boolean {\n return (\n candidate.candidateId === committed.candidateId &&\n candidate.owner === committed.owner &&\n candidate.world === committed.world &&\n candidate.generation === committed.generation &&\n candidate.entity === committed.entity &&\n candidate.physicsEntity === committed.physicsEntity &&\n candidate.gpuReady === committed.gpuReady &&\n candidate.meshBytes === committed.meshBytes &&\n candidate.revision === committed.revision &&\n candidate.topologyRevision === committed.topologyRevision &&\n candidate.materialIdentity === committed.materialIdentity &&\n candidate.meshHandle === committed.meshHandle &&\n candidate.fixedStep === committed.fixedStep\n );\n}\n\nfunction cloneTypedArray<T extends Float32Array | Uint16Array | Uint32Array>(value: T): T {\n return new (value.constructor as new (source: T) => T)(value);\n}\n\nfunction cloneMesh(mesh: MeshAsset): MeshAsset {\n const attributes = Object.fromEntries(\n Object.entries(mesh.attributes).map(([key, value]) => [\n key,\n value instanceof ArrayBuffer\n ? value.slice(0)\n : value === undefined\n ? undefined\n : cloneTypedArray(value as never),\n ]),\n ) as MeshAsset['attributes'];\n return Object.freeze({\n ...mesh,\n vertices: new Float32Array(mesh.vertices),\n ...(mesh.indices === undefined ? {} : { indices: cloneTypedArray(mesh.indices) }),\n attributes,\n ...(mesh.aabb === undefined ? {} : { aabb: new Float32Array(mesh.aabb) }),\n submeshes: Object.freeze(mesh.submeshes.map((submesh) => Object.freeze({ ...submesh }))),\n materialSlots: Object.freeze(mesh.materialSlots.map((slot) => Object.freeze({ ...slot }))),\n });\n}\n\nfunction cloneCandidate(candidate: DynamicGeometryCandidate): DynamicGeometryCandidate {\n return Object.freeze({ ...candidate, mesh: cloneMesh(candidate.mesh) });\n}\n\nfunction validateMesh(mesh: MeshAsset): string | undefined {\n if (mesh.kind !== 'mesh') return 'MeshAsset.kind must be mesh';\n if (!(mesh.vertices instanceof Float32Array) || mesh.vertices.length === 0) {\n return 'MeshAsset.vertices must be a non-empty Float32Array';\n }\n // vertices may be interleaved. Attribute layout validation belongs to the\n // mesh producer/residency path; this gate must not assume an xyz-only stride.\n if (\n mesh.indices !== undefined &&\n !(mesh.indices instanceof Uint16Array || mesh.indices instanceof Uint32Array)\n ) {\n return 'MeshAsset.indices must be Uint16Array or Uint32Array';\n }\n if (mesh.submeshes.length === 0)\n return 'MeshAsset.submeshes must contain at least one topology range';\n if (\n mesh.submeshes.some(\n (submesh) =>\n !Number.isSafeInteger(submesh.materialSlot) ||\n submesh.materialSlot < 0 ||\n submesh.materialSlot >= mesh.materialSlots.length,\n )\n ) {\n return 'MeshAsset.materialSlots must cover every referenced materialSlot';\n }\n if (mesh.vertices.some((value) => !Number.isFinite(value)))\n return 'MeshAsset.vertices must be finite';\n return undefined;\n}\n\nfunction meshByteSize(mesh: MeshAsset): number {\n let bytes = mesh.vertices.byteLength + (mesh.indices?.byteLength ?? 0);\n for (const value of Object.values(mesh.attributes)) {\n if (value instanceof ArrayBuffer) bytes += value.byteLength;\n else if (value !== undefined && ArrayBuffer.isView(value)) bytes += value.byteLength;\n }\n if (mesh.aabb !== undefined) bytes += mesh.aabb.byteLength;\n // Submesh/material metadata is intentionally bounded by the candidate\n // count. The reserved byte budget is for typed geometry and GPU upload\n // inputs, which are the resources that can exhaust the renderer.\n return bytes;\n}\n\n/**\n * Renderer-owned lifecycle for standard MeshAsset candidates. It deliberately\n * has no device, buffer, queue, or frame clock; the host supplies generation\n * and FrameReceipt facts at the boundaries below.\n */\nexport interface DynamicGeometryLifecycle {\n prepare(\n input: DynamicGeometryPrepareInput,\n generation: number,\n ): Result<DynamicGeometryCandidate, DynamicGeometryError>;\n accept(\n candidate: DynamicGeometryCandidate,\n ordering?: DynamicGeometryOrdering,\n ): Result<DynamicGeometryCandidate, DynamicGeometryError>;\n cancel(\n candidate: DynamicGeometryCandidate,\n completion?: Promise<unknown>,\n ): Result<void, DynamicGeometryError>;\n retire(candidate: DynamicGeometryCandidate): Result<void, DynamicGeometryError>;\n /** Release the count/byte budget after receipt-bound GPU cleanup completes. */\n finalizeRetirement(candidate: DynamicGeometryCandidate): Result<void, DynamicGeometryError>;\n receipt(candidate: DynamicGeometryCandidate): DynamicGeometryReceipt | undefined;\n publishFrame(\n frame: {\n readonly frameId: number;\n readonly deviceGeneration: number;\n readonly completed?: Promise<unknown>;\n },\n worlds?: readonly object[],\n fixedStep?: number,\n canPublish?: (candidate: DynamicGeometryCandidate) => boolean,\n ): readonly DynamicGeometryReceipt[];\n invalidateWorld(world: object, completion?: Promise<unknown>): void;\n invalidateGeneration(generation: number): void;\n inspect(): DynamicGeometryInspection;\n dispose(): void;\n}\n\nexport function createDynamicGeometryLifecycle(\n maxCandidates = 32,\n maxMeshBytes = 64 * 1024 * 1024,\n): DynamicGeometryLifecycle {\n const records = new Map<string, CandidateRecord>();\n const owner = {};\n let sequence = 0;\n let currentGeneration = 0;\n let disposed = false;\n let historyInvalidations = 0;\n let latestRevision: number | undefined;\n let latestFrameId: number | undefined;\n let retired = 0;\n let invalidated = 0;\n let meshBytes = 0;\n const latestRevisionByWorld = new WeakMap<object, Map<number | undefined, number>>();\n const latestTopologyRevisionByWorld = new WeakMap<object, Map<number | undefined, number>>();\n const publishedReceipts = new Map<string, DynamicGeometryReceipt>();\n\n const failure = (\n code: DynamicGeometryErrorCode,\n expected: string,\n hint: string,\n detail: Omit<DynamicGeometryErrorDetail, 'code'> = {},\n ): Result<never, DynamicGeometryError> =>\n err(new DynamicGeometryError(code, expected, hint, detail));\n\n const current = (candidate: DynamicGeometryCandidate): CandidateRecord | undefined => {\n const record = records.get(candidate.candidateId);\n if (\n record === undefined ||\n candidate.owner !== owner ||\n record.candidate.owner !== candidate.owner ||\n record.candidate.world !== candidate.world ||\n record.candidate.generation !== candidate.generation\n )\n return undefined;\n return record;\n };\n\n return {\n prepare(input, generation) {\n if (disposed)\n return failure('dynamic-geometry-disposed', 'renderer is alive', 'rebuild the Renderer');\n if (input.world === null || typeof input.world !== 'object') {\n return failure(\n 'dynamic-geometry-world-not-attached',\n 'candidate belongs to an attached World',\n 'attach the World before preparing geometry',\n );\n }\n if (!Number.isInteger(input.revision) || input.revision < 0) {\n return failure(\n 'dynamic-geometry-invalid',\n 'geometry revision is a non-negative integer',\n 'advance the consumer revision monotonically',\n { revision: input.revision },\n );\n }\n if (generation !== currentGeneration && currentGeneration !== 0) {\n return failure(\n 'dynamic-geometry-generation-mismatch',\n 'candidate uses the active renderer generation',\n 'discard stale generation work and prepare again',\n { generation, actual: currentGeneration },\n );\n }\n if (records.size >= maxCandidates) {\n return failure(\n 'dynamic-geometry-budget-exceeded',\n 'candidate count remains within the bounded renderer budget',\n 'cancel or retire an earlier candidate before retrying',\n { actual: records.size },\n );\n }\n const invalid = validateMesh(input.mesh);\n if (invalid !== undefined)\n return failure(\n 'dynamic-geometry-invalid',\n 'MeshAsset satisfies the standard geometry contract',\n invalid,\n );\n const candidateBytes = meshByteSize(input.mesh);\n if (\n !Number.isSafeInteger(candidateBytes) ||\n candidateBytes < 0 ||\n meshBytes > maxMeshBytes - candidateBytes\n ) {\n return failure(\n 'dynamic-geometry-budget-exceeded',\n 'candidate mesh bytes remain within the bounded renderer resource budget',\n 'cancel or retire an earlier candidate before retrying',\n { actual: { meshBytes, candidateBytes, maxMeshBytes } },\n );\n }\n const candidateId = `mesh:${generation}:${++sequence}:${input.revision}`;\n const candidate: DynamicGeometryCandidate = Object.freeze({\n candidateId,\n generation,\n owner,\n world: input.world,\n ...(input.entity === undefined ? {} : { entity: input.entity }),\n ...(input.physicsEntity === undefined ? {} : { physicsEntity: input.physicsEntity }),\n gpuReady: input.meshHandle !== undefined,\n meshBytes: candidateBytes,\n revision: input.revision,\n topologyRevision: input.topologyRevision ?? input.revision,\n ...(input.materialIdentity === undefined\n ? {}\n : { materialIdentity: input.materialIdentity }),\n ...(input.meshHandle === undefined ? {} : { meshHandle: input.meshHandle }),\n ...(input.fixedStep === undefined ? {} : { fixedStep: input.fixedStep }),\n mesh: cloneMesh(input.mesh),\n state: 'prepared',\n });\n records.set(candidateId, {\n world: input.world,\n candidate,\n historyInvalidated: false,\n });\n meshBytes += candidateBytes;\n currentGeneration = generation;\n // Keep the credential handed to the consumer separate from the\n // renderer-owned copy. Mesh typed arrays remain mutable at runtime even\n // when exposed through a readonly TypeScript field.\n return ok(cloneCandidate(candidate));\n },\n accept(candidate, ordering) {\n if (disposed)\n return failure('dynamic-geometry-disposed', 'renderer is alive', 'rebuild the Renderer');\n const record = current(candidate);\n if (record === undefined)\n return failure(\n 'dynamic-geometry-candidate-not-found',\n 'candidate is owned by this renderer',\n 'discard the stale credential',\n );\n if (candidate.generation !== currentGeneration) {\n return failure(\n 'dynamic-geometry-generation-mismatch',\n 'candidate generation matches the active renderer generation',\n 'prepare against the current renderer generation',\n { candidateId: candidate.candidateId },\n );\n }\n if (record.candidate.state !== 'prepared') {\n return failure(\n 'dynamic-geometry-candidate-state',\n 'candidate is prepared exactly once before acceptance',\n 'retain the accepted or published receipt',\n { candidateId: candidate.candidateId },\n );\n }\n if (!sameCandidateCredential(candidate, record.candidate)) {\n return failure(\n 'dynamic-geometry-receipt-mismatch',\n 'acceptance uses the exact prepared candidate credential',\n 'discard the altered credential and use the value returned by prepare',\n { candidateId: candidate.candidateId },\n );\n }\n if (ordering !== undefined) {\n if (\n ordering.world !== record.world ||\n !Number.isInteger(ordering.fixedStep) ||\n ordering.fixedStep < 0\n ) {\n return failure(\n 'dynamic-geometry-ordering-required',\n 'acceptance ordering names the candidate World and a non-negative fixed step',\n 'submit the PhysicsWorld publication ordering for the same attached World',\n { candidateId: candidate.candidateId, actual: ordering },\n );\n }\n }\n const newest = [...records.values()]\n .filter(\n (entry) =>\n entry.candidate.candidateId !== candidate.candidateId &&\n entry.world === record.world &&\n entry.candidate.entity === record.candidate.entity &&\n (entry.candidate.state === 'prepared' || entry.candidate.state === 'accepted'),\n )\n .map((entry) => entry.candidate.revision)\n .concat(latestRevisionByWorld.get(record.world)?.get(record.candidate.entity) ?? -1)\n .sort((a, b) => b - a)[0];\n if (newest !== undefined && record.candidate.revision <= newest) {\n return failure(\n 'dynamic-geometry-stale',\n 'accepted geometry revision is newer than the active candidate',\n 'advance topology revision before accepting',\n { candidateId: candidate.candidateId },\n );\n }\n const accepted = Object.freeze({\n ...record.candidate,\n ...(ordering === undefined ? {} : { fixedStep: ordering.fixedStep }),\n state: 'accepted' as const,\n });\n const previousTopologies = [...records.values()]\n .filter(\n (entry) =>\n entry.candidate.candidateId !== candidate.candidateId &&\n entry.world === record.world &&\n entry.candidate.entity === record.candidate.entity,\n )\n .map((entry) => entry.candidate.topologyRevision);\n const previousLatestTopology = latestTopologyRevisionByWorld\n .get(record.world)\n ?.get(record.candidate.entity);\n const newestTopology = previousTopologies\n .concat(previousLatestTopology === undefined ? [] : [previousLatestTopology])\n .sort((a, b) => b - a)[0];\n if (newestTopology !== undefined && accepted.topologyRevision < newestTopology) {\n return failure(\n 'dynamic-geometry-stale',\n 'accepted topology revision is not older than the active geometry history',\n 'advance topology revision before accepting a replacement candidate',\n { candidateId: candidate.candidateId },\n );\n }\n if (newestTopology !== undefined && accepted.topologyRevision > newestTopology) {\n historyInvalidations += 1;\n // Invalidate publication eligibility, not resource ownership. The host\n // cancels superseded candidates with their allocation completion fence.\n for (const previous of records.values()) {\n if (\n previous.world !== record.world ||\n previous.candidate.entity !== record.candidate.entity ||\n previous.candidate.candidateId === candidate.candidateId ||\n previous.candidate.topologyRevision >= accepted.topologyRevision\n )\n continue;\n if (!previous.historyInvalidated) {\n previous.historyInvalidated = true;\n invalidated += 1;\n }\n }\n }\n record.candidate = accepted;\n return ok(cloneCandidate(accepted));\n },\n cancel(candidate, completion) {\n const record = current(candidate);\n if (record === undefined)\n return failure(\n 'dynamic-geometry-candidate-not-found',\n 'candidate is owned by this renderer',\n 'discard the stale credential',\n );\n if (!sameCandidateCredential(candidate, record.candidate))\n return failure(\n 'dynamic-geometry-receipt-mismatch',\n 'cancellation uses the exact prepared candidate credential',\n 'discard the altered credential and use the value returned by prepare',\n { candidateId: candidate.candidateId },\n );\n if (record.candidate.state !== 'prepared' && record.candidate.state !== 'accepted') {\n return failure(\n 'dynamic-geometry-candidate-state',\n 'only prepared or accepted geometry can be cancelled once',\n 'retire published geometry or await the existing terminal cleanup',\n );\n }\n record.candidate = Object.freeze({ ...record.candidate, state: 'cancelled' as const });\n const release = (): void => {\n if (records.get(candidate.candidateId) !== record) return;\n records.delete(candidate.candidateId);\n meshBytes = Math.max(0, meshBytes - record.candidate.meshBytes);\n };\n if (completion === undefined) release();\n else void completion.then(release, release);\n return ok(undefined);\n },\n retire(candidate) {\n const record = current(candidate);\n if (record === undefined)\n return failure(\n 'dynamic-geometry-candidate-not-found',\n 'retirement uses a published candidate owned by this renderer',\n 'discard the stale credential and do not evict any unrelated mesh',\n { candidateId: candidate.candidateId },\n );\n if (!sameCandidateCredential(candidate, record.candidate))\n return failure(\n 'dynamic-geometry-receipt-mismatch',\n 'retirement uses the exact published candidate credential',\n 'discard the altered credential and use the value returned by publish',\n { candidateId: candidate.candidateId },\n );\n if (record.candidate.state !== 'published') {\n return failure(\n 'dynamic-geometry-candidate-state',\n 'only published geometry can enter receipt-bound retirement',\n 'publish the candidate from a submitted frame first',\n );\n }\n record.candidate = Object.freeze({ ...record.candidate, state: 'retired' as const });\n publishedReceipts.delete(candidate.candidateId);\n retired += 1;\n // Retiring is the logical state transition. Keep the candidate record\n // and its typed bytes until the owner calls `finalizeRetirement` after\n // every record-stage completion fence and GPU lease are gone. This is\n // what makes the declared count/byte budget include in-flight work.\n return ok(undefined);\n },\n finalizeRetirement(candidate) {\n const record = current(candidate);\n if (record === undefined)\n return failure(\n 'dynamic-geometry-candidate-not-found',\n 'retirement finalization uses a candidate retained by this lifecycle',\n 'discard the stale credential or finish the current receipt-bound retirement',\n );\n if (!sameCandidateCredential(candidate, record.candidate))\n return failure(\n 'dynamic-geometry-receipt-mismatch',\n 'retirement finalization uses the exact published candidate credential',\n 'discard the altered credential and use the value returned by publication',\n { candidateId: candidate.candidateId },\n );\n if (record.candidate.state !== 'retired')\n return failure(\n 'dynamic-geometry-candidate-state',\n 'only a retired candidate can release its deferred budget',\n 'retire the published candidate before finalizing its receipt-bound cleanup',\n { candidateId: candidate.candidateId },\n );\n records.delete(candidate.candidateId);\n meshBytes = Math.max(0, meshBytes - record.candidate.meshBytes);\n return ok(undefined);\n },\n publishFrame(frame, worlds, fixedStep, canPublish) {\n if (disposed || frame.deviceGeneration !== currentGeneration) return [];\n const receipts: DynamicGeometryReceipt[] = [];\n for (const record of records.values()) {\n const canRepeatPublished =\n record.candidate.state === 'published' &&\n // Attached Renderer publication revalidates the entity binding in\n // `canPublish`, so a history-invalidated candidate can still record\n // a real draw for its live entity. Detached lifecycle publication\n // remains one-shot once that history is invalidated.\n (canPublish !== undefined || !record.historyInvalidated);\n if (record.candidate.state !== 'accepted' && !canRepeatPublished) continue;\n if (worlds !== undefined && !worlds.includes(record.world)) continue;\n if (\n record.candidate.fixedStep !== undefined &&\n (fixedStep === undefined || record.candidate.fixedStep > fixedStep)\n ) {\n continue;\n }\n if (canPublish !== undefined && !canPublish(record.candidate)) continue;\n record.candidate = Object.freeze({ ...record.candidate, state: 'published' as const });\n const receipt = Object.freeze({\n candidateId: record.candidate.candidateId,\n generation: record.candidate.generation,\n revision: record.candidate.revision,\n topologyRevision: record.candidate.topologyRevision,\n ...(record.candidate.fixedStep === undefined\n ? {}\n : { fixedStep: record.candidate.fixedStep }),\n frameId: frame.frameId,\n deviceGeneration: frame.deviceGeneration,\n recordStageConsumed: canPublish !== undefined,\n ...(fixedStep === undefined ? {} : { publicationFixedStep: fixedStep }),\n frame: Object.freeze({ ...frame }),\n });\n receipts.push(receipt);\n publishedReceipts.set(record.candidate.candidateId, receipt);\n latestRevision = record.candidate.revision;\n latestFrameId = frame.frameId;\n if (!latestRevisionByWorld.has(record.world))\n latestRevisionByWorld.set(record.world, new Map());\n latestRevisionByWorld\n .get(record.world)\n ?.set(record.candidate.entity, record.candidate.revision);\n if (!latestTopologyRevisionByWorld.has(record.world))\n latestTopologyRevisionByWorld.set(record.world, new Map());\n latestTopologyRevisionByWorld\n .get(record.world)\n ?.set(record.candidate.entity, record.candidate.topologyRevision);\n }\n return receipts;\n },\n invalidateWorld(world, completion) {\n for (const [id, record] of records) {\n if (record.world !== world) continue;\n // An earlier terminal operation already owns this reservation's fence.\n if (record.candidate.state === 'cancelled' || record.candidate.state === 'retired')\n continue;\n publishedReceipts.delete(id);\n record.candidate = Object.freeze({ ...record.candidate, state: 'cancelled' as const });\n const release = (): void => {\n if (records.get(id) !== record) return;\n records.delete(id);\n meshBytes = Math.max(0, meshBytes - record.candidate.meshBytes);\n };\n if (completion === undefined) release();\n else void completion.then(release, release);\n invalidated += 1;\n }\n latestRevisionByWorld.delete(world);\n latestTopologyRevisionByWorld.delete(world);\n },\n invalidateGeneration(generation) {\n if (generation === currentGeneration) return;\n currentGeneration = generation;\n const invalidatedWorlds = new Set<object>();\n for (const [id, record] of records) {\n if (record.candidate.generation !== generation) {\n records.delete(id);\n publishedReceipts.delete(id);\n meshBytes = Math.max(0, meshBytes - record.candidate.meshBytes);\n invalidatedWorlds.add(record.world);\n invalidated += 1;\n }\n }\n for (const world of invalidatedWorlds) {\n latestRevisionByWorld.delete(world);\n latestTopologyRevisionByWorld.delete(world);\n }\n },\n receipt(candidate) {\n const receipt = publishedReceipts.get(candidate.candidateId);\n const record = records.get(candidate.candidateId);\n if (record === undefined || !sameCandidateCredential(candidate, record.candidate)) {\n return undefined;\n }\n return receipt?.generation === candidate.generation ? receipt : undefined;\n },\n inspect() {\n let prepared = 0;\n let accepted = 0;\n let published = 0;\n for (const record of records.values()) {\n if (record.candidate.state === 'prepared') prepared += 1;\n else if (record.candidate.state === 'accepted') accepted += 1;\n else if (record.candidate.state === 'published') published += 1;\n }\n return Object.freeze({\n generation: currentGeneration,\n prepared,\n accepted,\n published,\n retired,\n ...(latestRevision === undefined ? {} : { latestRevision }),\n ...(latestFrameId === undefined ? {} : { latestFrameId }),\n historyInvalidations,\n invalidated,\n meshBytes,\n maxMeshBytes,\n });\n },\n dispose() {\n disposed = true;\n records.clear();\n publishedReceipts.clear();\n meshBytes = 0;\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/points-lines/admission.ts","../src/point-shadow-inspection.ts","../src/ssr/admission.ts","../src/volume/inspection.ts","../src/reflection/filter.ts","../src/reflection/gpu-table.ts","../src/reflection/inspection.ts","../src/reflection/projection.ts","../src/scene/visibility/inspection.ts","../src/ssr/inspection.ts","../src/dynamic-geometry.ts"],"names":["pass","failure","err","ok","primitiveKey"],"mappings":";;;;;AA0DA,SAAS,YAAA,CACP,KAAA,EACA,SAAA,EACA,KAAA,EACA,OACA,QAAA,EAC0C;AAC1C,EAAA,OAAO,GAAA,CAAI,IAAI,4BAAA,CAAkB,EAAE,MAAA,EAAQ,KAAA,CAAM,MAAA,EAAQ,SAAA,EAAW,KAAA,EAAO,KAAA,EAAO,QAAA,EAAU,CAAC,CAAA;AAC/F;AAEA,SAAS,gBAAA,CACP,KAAA,EACA,OAAA,EACA,QAAA,E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AAU,MAAA;AAAA,IAClE,CAAA;AAAA,IACA,OAAA,GAAU;AACR,MAAA,IAAI,QAAA,GAAW,CAAA;AACf,MAAA,IAAI,QAAA,GAAW,CAAA;AACf,MAAA,IAAI,SAAA,GAAY,CAAA;AAChB,MAAA,KAAA,MAAW,MAAA,IAAU,OAAA,CAAQ,MAAA,EAAO,EAAG;AACrC,QAAA,IAAI,MAAA,CAAO,SAAA,CAAU,KAAA,KAAU,UAAA,EAAY,QAAA,IAAY,CAAA;AAAA,aAAA,IAC9C,MAAA,CAAO,SAAA,CAAU,KAAA,KAAU,UAAA,EAAY,QAAA,IAAY,CAAA;AAAA,aAAA,IACnD,MAAA,CAAO,SAAA,CAAU,KAAA,KAAU,WAAA,EAAa,SAAA,IAAa,CAAA;AAAA,MAChE;AACA,MAAA,OAAO,OAAO,MAAA,CAAO;AAAA,QACnB,UAAA,EAAY,iBAAA;AAAA,QACZ,QAAA;AAAA,QACA,QAAA;AAAA,QACA,SAAA;AAAA,QACA,OAAA;AAAA,QACA,GAAI,cAAA,KAAmB,MAAA,GAAY,EAAC,GAAI,EAAE,cAAA,EAAe;AAAA,QACzD,GAAI,aAAA,KAAkB,MAAA,GAAY,EAAC,GAAI,EAAE,aAAA,EAAc;AAAA,QACvD,oBAAA;AAAA,QACA,WAAA;AAAA,QACA,SAAA;AAAA,QACA;AAAA,OACD,CAAA;AAAA,IACH,CAAA;AAAA,IACA,OAAA,GAAU;AACR,MAAA,QAAA,GAAW,IAAA;AACX,MAAA,OAAA,CAAQ,KAAA,EAAM;AACd,MAAA,iBAAA,CAAkB,KAAA,EAAM;AACxB,MAAA,SAAA,GAAY,CAAA;AAAA,IACd;AAAA,GACF;AACF","file":"chunk-LULCA3OF.mjs","sourcesContent":["import { err, type MaterialAsset, type MeshAsset, ok, type Result } from '@forgeax/engine-types';\nimport { type PointShape, PointShapeValue, pointShapeFromU32 } from '../components/points';\nimport type {\n PointsLinesBudgetExceededError,\n PointsLinesInvalidStyleError,\n PointsLinesMaterialUnsupportedError,\n PointsLinesStyleUnsupportedError,\n PointsLinesTopologyMismatchError,\n} from '../errors/render';\nimport {\n PointsLinesBudgetExceededError as BudgetError,\n PointsLinesInvalidStyleError as InvalidStyleError,\n PointsLinesMaterialUnsupportedError as MaterialError,\n PointsLinesStyleUnsupportedError as StyleError,\n PointsLinesTopologyMismatchError as TopologyError,\n} from '../errors/render';\n\nexport interface PointsStyleInput {\n readonly sizePx?: number;\n readonly shape?: number;\n}\n\nexport interface LinesStyleInput {\n readonly widthPx?: number;\n}\n\nexport interface PointsLinesAdmissionLimits {\n readonly maxPoints?: number;\n readonly maxSegments?: number;\n}\n\nexport interface PointsLinesAdmissionInput {\n readonly entity: number;\n readonly points?: PointsStyleInput;\n readonly lines?: LinesStyleInput;\n readonly mesh: MeshAsset;\n readonly material: MaterialAsset;\n readonly limits?: PointsLinesAdmissionLimits;\n readonly materialId?: string;\n}\n\nexport interface PointsLinesAdmission {\n readonly component: 'Points' | 'Lines';\n readonly shape?: PointShape;\n readonly sizePx?: number;\n readonly widthPx?: number;\n readonly pointCount: number;\n readonly segmentCount: number;\n readonly submeshes: readonly number[];\n}\n\nexport type PointsLinesAdmissionError =\n | PointsLinesInvalidStyleError\n | PointsLinesTopologyMismatchError\n | PointsLinesStyleUnsupportedError\n | PointsLinesMaterialUnsupportedError\n | PointsLinesBudgetExceededError;\n\nfunction invalidStyle(\n input: PointsLinesAdmissionInput,\n component: 'Points' | 'Lines' | 'Points/Lines',\n field: string,\n value: number | string | undefined,\n expected: string,\n): Result<never, PointsLinesAdmissionError> {\n return err(new InvalidStyleError({ entity: input.entity, component, field, value, expected }));\n}\n\nfunction topologyMismatch(\n input: PointsLinesAdmissionInput,\n submesh: number,\n expected: string,\n actual: string,\n): Result<never, PointsLinesAdmissionError> {\n return err(new TopologyError({ entity: input.entity, submesh, expected, actual }));\n}\n\nfunction checkStyle(\n input: PointsLinesAdmissionInput,\n): Result<\n { component: 'Points' | 'Lines'; shape?: PointShape; sizePx?: number; widthPx?: number },\n PointsLinesAdmissionError\n> {\n const hasPoints = input.points !== undefined;\n const hasLines = input.lines !== undefined;\n if (hasPoints && hasLines) {\n return invalidStyle(\n input,\n 'Points/Lines',\n 'components',\n 'Points + Lines',\n 'exactly one style component',\n );\n }\n if (!hasPoints && !hasLines) {\n return invalidStyle(input, 'Points/Lines', 'components', undefined, 'one style component');\n }\n\n if (hasPoints) {\n const sizePx = input.points?.sizePx ?? 4;\n const shapeValue = input.points?.shape ?? PointShapeValue.square;\n const shape = pointShapeFromU32(shapeValue);\n if (!Number.isFinite(sizePx) || sizePx <= 0) {\n return invalidStyle(input, 'Points', 'sizePx', sizePx, 'finite sizePx > 0');\n }\n if (shape === undefined) {\n return invalidStyle(input, 'Points', 'shape', shapeValue, \"shape is 'square' or 'circle'\");\n }\n return ok({ component: 'Points', shape, sizePx });\n }\n\n const widthPx = input.lines?.widthPx ?? 1;\n if (!Number.isFinite(widthPx) || widthPx <= 0) {\n return invalidStyle(input, 'Lines', 'widthPx', widthPx, 'finite widthPx > 0');\n }\n return ok({ component: 'Lines', widthPx });\n}\n\nfunction checkTopology(\n input: PointsLinesAdmissionInput,\n component: 'Points' | 'Lines',\n): Result<\n { pointCount: number; segmentCount: number; submeshes: readonly number[] },\n PointsLinesAdmissionError\n> {\n const expected = component === 'Points' ? 'point-list' : 'line-list';\n let pointCount = 0;\n let segmentCount = 0;\n const acceptedSubmeshes: number[] = [];\n let sawNonEmpty = false;\n\n for (const [submeshIndex, submesh] of input.mesh.submeshes.entries()) {\n const indexed = input.mesh.indices !== undefined && submesh.indexCount > 0;\n const elementCount = indexed ? submesh.indexCount : submesh.vertexCount;\n if (elementCount === 0) continue;\n sawNonEmpty = true;\n\n if (component === 'Lines' && submesh.topology === 'line-strip') {\n return err(\n new StyleError({\n lane: 'admission',\n field: 'topology',\n member: 'line-strip',\n supported: ['line-list'],\n }),\n );\n }\n if (submesh.topology !== expected) {\n return topologyMismatch(input, submeshIndex, expected, submesh.topology);\n }\n if (component === 'Lines' && elementCount % 2 !== 0) {\n return topologyMismatch(input, submeshIndex, 'line-list pairs', 'line-list odd tail');\n }\n acceptedSubmeshes.push(submeshIndex);\n if (component === 'Points') pointCount += elementCount;\n else segmentCount += elementCount / 2;\n }\n\n if (!sawNonEmpty) return topologyMismatch(input, 0, expected, 'empty-range');\n return ok({ pointCount, segmentCount, submeshes: acceptedSubmeshes });\n}\n\nfunction checkMaterial(input: PointsLinesAdmissionInput): Result<void, PointsLinesAdmissionError> {\n const passes = input.material.passes ?? [];\n const unlitModules = new Set(['forgeax_material::unlit', 'forgeax::default-unlit']);\n if (passes.length !== 1 || passes[0] === undefined) {\n const pass =\n passes.find(\n (candidate) => candidate.name === 'deferred' || candidate.name === 'shadow-caster',\n ) ?? passes[0];\n return err(\n new MaterialError({\n entity: input.entity,\n material: input.materialId ?? '<anonymous>',\n pass: pass?.name ?? '<empty>',\n module: pass?.program.module ?? '<empty>',\n reason: 'points-lines admission requires one unlit forward pass',\n }),\n );\n }\n const pass = passes[0];\n const lightMode = (pass.renderState?.tags as Record<string, unknown> | undefined)?.LightMode;\n if (\n !unlitModules.has(pass.program.module) ||\n pass.name !== 'forward' ||\n lightMode === 'ShadowCaster'\n ) {\n return err(\n new MaterialError({\n entity: input.entity,\n material: input.materialId ?? '<anonymous>',\n pass: pass.name,\n module: pass.program.module,\n reason: 'points-lines admission requires an engine-owned unlit forward pass',\n }),\n );\n }\n return ok(undefined);\n}\n\n/** Validate one complete Points/Lines candidate before any renderer publication. */\nexport function admitPointsLines(\n input: PointsLinesAdmissionInput,\n): Result<PointsLinesAdmission, PointsLinesAdmissionError> {\n const style = checkStyle(input);\n if (!style.ok) return style;\n const topology = checkTopology(input, style.value.component);\n if (!topology.ok) return topology;\n const material = checkMaterial(input);\n if (!material.ok) return material;\n\n if (style.value.component === 'Points' && input.limits?.maxPoints !== undefined) {\n if (topology.value.pointCount > input.limits.maxPoints) {\n return err(\n new BudgetError({\n lane: 'admission',\n requested: topology.value.pointCount,\n limit: input.limits.maxPoints,\n unit: 'points',\n }),\n );\n }\n }\n if (style.value.component === 'Lines' && input.limits?.maxSegments !== undefined) {\n if (topology.value.segmentCount > input.limits.maxSegments) {\n return err(\n new BudgetError({\n lane: 'admission',\n requested: topology.value.segmentCount,\n limit: input.limits.maxSegments,\n unit: 'segments',\n }),\n );\n }\n }\n\n return ok({ ...style.value, ...topology.value });\n}\n","import type { PointShadowSnapshot } from './render-system-extract';\n\n/**\n * Detached point-shadow budget facts from one completed extract/record frame.\n *\n * `requested` is the number of PointLight + PointLightShadow pairs. The\n * renderer owns the bounded cube-array atlas, so `admitted`, `shadowed`, and\n * `shadowAtlasOccupancy` are all derived from the layer sentinel emitted by\n * the same extract owner. No consumer needs to maintain a second budget\n * ledger.\n */\nexport interface PointShadowInspection {\n readonly status: 'inactive' | 'ready' | 'over-budget';\n readonly requested: number;\n readonly admitted: number;\n readonly shadowed: number;\n readonly shadowAtlasOccupancy: number;\n readonly shadowAtlasCapacity: number;\n}\n\n/** Project point-shadow snapshots to the public, JSON-safe inspection shape. */\nexport function inspectPointShadow(\n snapshots: readonly PointShadowSnapshot[],\n shadowAtlasCapacity: number,\n): PointShadowInspection {\n const requested = snapshots.length;\n const admitted = snapshots.reduce(\n (count, snapshot) =>\n snapshot.shadowAtlasLayer >= 0 && snapshot.shadowAtlasLayer < shadowAtlasCapacity\n ? count + 1\n : count,\n 0,\n );\n // Never publish a misleading `ready` state when any requested shadow owns\n // no atlas layer. The extract sentinel is the single admission projection;\n // a partial or all-sentinel frame is therefore a failed/over-budget\n // admission, not an active shadow path with incomplete output.\n const status =\n requested === 0\n ? ('inactive' as const)\n : requested > shadowAtlasCapacity || admitted !== requested\n ? ('over-budget' as const)\n : ('ready' as const);\n return Object.freeze({\n status,\n requested,\n admitted,\n // A point shadow only samples an atlas after it owns an atlas layer. Keep\n // these names explicit for AI diagnostics while deriving both from the\n // one layer projection above.\n shadowed: admitted,\n shadowAtlasOccupancy: admitted,\n shadowAtlasCapacity,\n });\n}\n","/**\n * Consumer-only SSR M0 admission.\n *\n * This module consumes detached producer receipts. It owns no capture,\n * device, graph, or recovery handle and therefore cannot repair a missing\n * producer. A complete receipt set is the only route to an admitted result.\n */\n\nimport {\n type RhiTextureFormatCapabilityReceipt,\n validateR32FloatReceipt,\n} from '@forgeax/engine-rhi';\nimport { err, ok, type Result } from '@forgeax/engine-types';\nimport type { ScreenSpaceReflectionData } from '../components/screen-space-reflection';\nimport type { ReflectionFallbackReceipt } from '../inspection-types';\nimport type {\n SsrConfigField,\n SsrConfigInvalidError,\n SsrConfigRange,\n SsrOwnerRecoveryAction,\n SsrSpatialUnavailableReason,\n SsrUnavailableError,\n} from './errors';\nimport type { SsrAdmissionIdentity } from './identity';\n\nexport const SSR_FORMAT_PROFILE = 'r32float-mip-sampled-storage' as const;\n\nexport const SSR_FORMAT_STAGES = Object.freeze([\n 'texture-create',\n 'mip-view',\n 'sampled-storage-bind-group',\n 'pipeline-bind',\n 'finish',\n 'submit',\n 'completion',\n 'readback',\n] as const);\n\nexport type { SsrAdmissionIdentity } from './identity';\n\nexport type SsrFormatStage = (typeof SSR_FORMAT_STAGES)[number];\n\n/**\n * The admission input is the real renderer owner receipt plus the one\n * integration identity supplied by the host. It deliberately does not\n * recreate submitted/source/LKG boolean flags.\n */\nexport type SsrReflectionFallbackReceipt = ReflectionFallbackReceipt & {\n readonly identity: SsrAdmissionIdentity;\n};\n\n/** RHI capability receipt with the same host-supplied integration identity. */\nexport type SsrFormatReceipt = RhiTextureFormatCapabilityReceipt & {\n readonly identity: SsrAdmissionIdentity;\n};\n\nexport interface SsrTemporalReceipt {\n readonly identity: SsrAdmissionIdentity;\n readonly successfulSubmit: true;\n readonly generation: number;\n}\n\nexport interface SsrAdmissionWork {\n readonly attachmentCount: number;\n readonly passCount: number;\n readonly bindingCount: number;\n readonly resourceCount: number;\n readonly historyCount: 0;\n readonly temporalDemand: 0;\n}\n\nexport interface SsrAdmissionBudget {\n readonly probeExecutions: 0 | 1;\n readonly resetCount: 0;\n readonly rebuildCount: 0;\n}\n\nexport interface SsrAdmissionFailure {\n readonly code:\n | 'ssr-not-requested'\n | 'ssr-reflection-fallback-unavailable'\n | 'ssr-format-unavailable'\n | 'ssr-temporal-unavailable'\n | 'ssr-receipt-identity-mismatch'\n | 'ssr-receipt-stale';\n readonly expected: string;\n readonly hint: string;\n readonly detail: Readonly<{\n readonly owner: 'producer' | 'format' | 'temporal' | 'consumer';\n /** Owner-directed action an AI consumer can take without parsing hint text. */\n readonly action: SsrOwnerRecoveryAction;\n readonly generation?: number;\n readonly identityField?: keyof SsrAdmissionIdentity;\n }>;\n}\n\nexport type SsrAdmissionResult =\n | {\n readonly status: 'admitted';\n readonly identity: SsrAdmissionIdentity | undefined;\n readonly generation: number;\n readonly work: SsrAdmissionWork;\n readonly budget: SsrAdmissionBudget;\n readonly failure?: undefined;\n }\n | {\n readonly status: 'fallback-only';\n readonly identity: SsrAdmissionIdentity | undefined;\n readonly generation: number;\n readonly work: SsrAdmissionWork;\n readonly budget: SsrAdmissionBudget;\n readonly failure: SsrAdmissionFailure;\n };\n\nexport interface SsrAdmissionInput {\n readonly requested: boolean;\n readonly identity: SsrAdmissionIdentity;\n readonly reflectionFallback?: SsrReflectionFallbackReceipt;\n readonly format?: SsrFormatReceipt;\n readonly temporal?: SsrTemporalReceipt;\n readonly previousGeneration?: number;\n}\n\n/** Public renderer projection consumed by the parent SSR feature. */\nexport interface SsrDependenciesInspection {\n readonly status: 'admitted' | 'fallback-only';\n /** Absent until the host binds an exact source/tree/lock/build identity. */\n readonly identity: SsrAdmissionIdentity | undefined;\n readonly requested: boolean;\n readonly reflectionFallback: ReflectionFallbackReceipt | undefined;\n readonly format: SsrFormatReceipt | undefined;\n readonly temporal: SsrTemporalReceipt | undefined;\n readonly admission: SsrAdmissionResult;\n readonly work: SsrAdmissionWork;\n readonly budget: SsrAdmissionBudget;\n readonly failure: SsrAdmissionFailure | undefined;\n}\n\nconst ZERO_WORK: SsrAdmissionWork = Object.freeze({\n attachmentCount: 0,\n passCount: 0,\n bindingCount: 0,\n resourceCount: 0,\n historyCount: 0,\n temporalDemand: 0,\n});\n\nconst ADMITTED_WORK: SsrAdmissionWork = Object.freeze({\n attachmentCount: 1,\n passCount: 1,\n bindingCount: 1,\n resourceCount: 1,\n historyCount: 0,\n temporalDemand: 0,\n});\n\nconst ZERO_BUDGET: SsrAdmissionBudget = Object.freeze({\n probeExecutions: 0,\n resetCount: 0,\n rebuildCount: 0,\n});\n\nconst ADMITTED_BUDGET: SsrAdmissionBudget = Object.freeze({\n probeExecutions: 1,\n resetCount: 0,\n rebuildCount: 0,\n});\n\nfunction identityFieldMismatch(\n expected: SsrAdmissionIdentity,\n actual: SsrAdmissionIdentity,\n): keyof SsrAdmissionIdentity | undefined {\n for (const field of ['sourceHead', 'sourceTree', 'lockSha256', 'buildSha256'] as const) {\n if (expected[field] !== actual[field]) return field;\n }\n return undefined;\n}\n\nfunction blocked(\n identity: SsrAdmissionIdentity | undefined,\n failure: SsrAdmissionFailure,\n generation = 0,\n): SsrAdmissionResult {\n return Object.freeze({\n status: 'fallback-only',\n identity,\n generation,\n work: ZERO_WORK,\n budget: ZERO_BUDGET,\n failure,\n });\n}\n\nfunction failure(\n code: SsrAdmissionFailure['code'],\n owner: SsrAdmissionFailure['detail']['owner'],\n hint: string,\n detail: Omit<SsrAdmissionFailure['detail'], 'owner' | 'action'> = {},\n): SsrAdmissionFailure {\n const action: SsrOwnerRecoveryAction = recoveryActionFor(code);\n return Object.freeze({\n code,\n expected: 'all producer, format, and temporal receipts share one admitted identity',\n hint,\n detail: Object.freeze({ owner, action, ...detail }),\n });\n}\n\nfunction recoveryActionFor(code: SsrAdmissionFailure['code']): SsrOwnerRecoveryAction {\n switch (code) {\n case 'ssr-reflection-fallback-unavailable':\n case 'ssr-receipt-identity-mismatch':\n return 'rebuild';\n case 'ssr-not-requested':\n case 'ssr-format-unavailable':\n case 'ssr-temporal-unavailable':\n case 'ssr-receipt-stale':\n return 'retry';\n }\n}\n\nfunction receiptFailure(\n input: SsrAdmissionInput,\n receipt: { readonly identity: SsrAdmissionIdentity },\n owner: SsrAdmissionFailure['detail']['owner'],\n): SsrAdmissionResult | undefined {\n const field = identityFieldMismatch(input.identity, receipt.identity);\n if (field === undefined) return undefined;\n return blocked(\n input.identity,\n failure('ssr-receipt-identity-mismatch', owner, 'rebuild the owner receipt for this identity', {\n identityField: field,\n }),\n );\n}\n\nfunction validFallback(receipt: SsrReflectionFallbackReceipt | undefined): boolean {\n return (\n receipt !== undefined &&\n receipt.candidateVisible === false &&\n Number.isFinite(receipt.coverage) &&\n receipt.coverage >= 0 &&\n receipt.coverage <= 1 &&\n (receipt.sourceKey === undefined || receipt.sourceKey.length > 0) &&\n (receipt.extent === undefined ||\n (receipt.extent.length === 3 &&\n receipt.extent.every((value) => Number.isFinite(value) && value > 0))) &&\n Number.isInteger(receipt.sourceGeneration) &&\n receipt.sourceGeneration >= 0 &&\n Number.isInteger(receipt.projectionGeneration) &&\n receipt.projectionGeneration >= 0 &&\n Number.isInteger(receipt.deviceGeneration) &&\n receipt.deviceGeneration >= 0 &&\n receipt.brdfSignature === 'standard-pbr-ibl-v1' &&\n ((receipt.source === 'probe' && (receipt.state === 'active' || receipt.state === 'lkg')) ||\n (receipt.source === 'skylight' && (receipt.state === 'active' || receipt.state === 'lkg')) ||\n (receipt.source === 'neutral' && receipt.state === 'neutral'))\n );\n}\n\nfunction validFormat(receipt: SsrFormatReceipt | undefined): boolean {\n if (\n receipt?.profile !== SSR_FORMAT_PROFILE ||\n receipt.verdict !== 'admitted' ||\n receipt.evidence !== 'real' ||\n !Number.isInteger(receipt.deviceGeneration) ||\n receipt.deviceGeneration < 0\n ) {\n return false;\n }\n if (\n !SSR_FORMAT_STAGES.every((stage) =>\n receipt.stages.some((entry) => entry.stage === stage && entry.verdict === 'admitted'),\n )\n ) {\n return false;\n }\n return validateR32FloatReceipt(receipt).ok;\n}\n\nfunction validTemporal(receipt: SsrTemporalReceipt | undefined): boolean {\n return (\n receipt?.successfulSubmit === true &&\n Number.isInteger(receipt.generation) &&\n receipt.generation >= 0\n );\n}\n\nexport function admitSsrM0(input: SsrAdmissionInput): SsrAdmissionResult {\n if (!input.requested) {\n return blocked(\n input.identity,\n failure('ssr-not-requested', 'consumer', 'request SSR before evaluating M0 admission'),\n );\n }\n if (input.reflectionFallback === undefined) {\n return blocked(\n input.identity,\n failure('ssr-reflection-fallback-unavailable', 'producer', 'use LKG, Skylight, or neutral'),\n );\n }\n const fallbackIdentityFailure = receiptFailure(input, input.reflectionFallback, 'producer');\n if (fallbackIdentityFailure !== undefined) return fallbackIdentityFailure;\n if (!validFallback(input.reflectionFallback)) {\n return blocked(\n input.identity,\n failure(\n 'ssr-reflection-fallback-unavailable',\n 'producer',\n 'inspect and rebuild the producer receipt',\n ),\n input.reflectionFallback.projectionGeneration,\n );\n }\n if (input.format === undefined) {\n return blocked(\n input.identity,\n failure('ssr-format-unavailable', 'format', 'probe the exact format profile for this device'),\n input.reflectionFallback.projectionGeneration,\n );\n }\n const formatIdentityFailure = receiptFailure(input, input.format, 'format');\n if (formatIdentityFailure !== undefined) return formatIdentityFailure;\n if (!validFormat(input.format)) {\n return blocked(\n input.identity,\n failure('ssr-format-unavailable', 'format', 'complete the full r32float profile probe'),\n input.reflectionFallback.projectionGeneration,\n );\n }\n // Prior submitted history is optional for fresh spatial SSR. If supplied,\n // its identity and validity still obey the temporal owner's contract.\n const temporalIdentityFailure =\n input.temporal === undefined ? undefined : receiptFailure(input, input.temporal, 'temporal');\n if (temporalIdentityFailure !== undefined) return temporalIdentityFailure;\n if (input.temporal !== undefined && !validTemporal(input.temporal)) {\n return blocked(\n input.identity,\n failure('ssr-temporal-unavailable', 'temporal', 'inspect and rebuild the temporal receipt'),\n input.reflectionFallback.projectionGeneration,\n );\n }\n if (\n input.previousGeneration !== undefined &&\n input.previousGeneration !== input.reflectionFallback.projectionGeneration\n ) {\n return blocked(\n input.identity,\n failure(\n 'ssr-receipt-stale',\n 'consumer',\n 'discard stale completion and reinspect the owners',\n {\n generation: input.reflectionFallback.projectionGeneration,\n },\n ),\n input.reflectionFallback.projectionGeneration,\n );\n }\n return Object.freeze({\n status: 'admitted',\n identity: input.identity,\n generation: input.reflectionFallback.projectionGeneration,\n work: ADMITTED_WORK,\n budget: ADMITTED_BUDGET,\n });\n}\n\n/**\n * Joins the live owner projections at the renderer boundary. The only casts\n * here add the host identity to receipts that otherwise remain canonical RHI\n * or ReflectionProbe PODs; no producer fact is copied or renamed.\n */\nexport function projectSsrDependencies(input: {\n readonly requested: boolean;\n readonly identity: SsrAdmissionIdentity | undefined;\n readonly reflectionFallback: ReflectionFallbackReceipt | undefined;\n readonly format: RhiTextureFormatCapabilityReceipt | undefined;\n readonly temporal: { readonly successfulSubmit: true; readonly generation: number } | undefined;\n readonly previousGeneration?: number;\n}): SsrDependenciesInspection {\n const identity = input.identity;\n const reflectionFallback =\n identity === undefined || input.reflectionFallback?.identity === undefined\n ? undefined\n : (input.reflectionFallback as SsrReflectionFallbackReceipt);\n const format =\n identity === undefined || input.format === undefined\n ? undefined\n : ({ ...input.format, identity } satisfies SsrFormatReceipt);\n const temporal =\n identity === undefined || input.temporal === undefined\n ? undefined\n : ({ identity, ...input.temporal } satisfies SsrTemporalReceipt);\n const admission =\n identity === undefined\n ? blocked(\n undefined,\n failure(\n input.requested ? 'ssr-receipt-identity-mismatch' : 'ssr-not-requested',\n 'consumer',\n input.requested\n ? 'bind the exact source, tree, lock, and build identity before admission'\n : 'request SSR before evaluating M0 admission',\n input.requested ? { identityField: 'sourceHead' } : {},\n ),\n )\n : admitSsrM0({\n requested: input.requested,\n identity,\n ...(reflectionFallback === undefined ? {} : { reflectionFallback }),\n ...(format === undefined ? {} : { format }),\n ...(temporal === undefined ? {} : { temporal }),\n ...(input.previousGeneration === undefined\n ? {}\n : { previousGeneration: input.previousGeneration }),\n });\n return Object.freeze({\n status: admission.status,\n identity,\n requested: input.requested,\n reflectionFallback: input.reflectionFallback,\n format,\n temporal,\n admission,\n work: admission.work,\n budget: admission.budget,\n failure: admission.failure,\n });\n}\n\nexport function zeroSsrAdmissionWork(): SsrAdmissionWork {\n return ZERO_WORK;\n}\n\n/**\n * Projects the admission decision into the existing temporal reset seam.\n * Admission never creates temporal history; only a changed committed\n * producer generation can request a reset through the coordinator.\n */\nexport function resolveSsrAdmissionGeneration(\n previousGeneration: number | undefined,\n nextGeneration: number | undefined,\n): { readonly changed: boolean; readonly generation: number | undefined } {\n return {\n changed:\n previousGeneration !== undefined &&\n nextGeneration !== undefined &&\n previousGeneration !== nextGeneration,\n generation: nextGeneration,\n };\n}\n\n/** Standard spatial lanes that may consume an SSR candidate. */\nexport type SsrSpatialLane = 'clustered' | 'deferred' | 'direct' | 'cpu-webgl2' | 'forward';\n\n/** Capability facts required by the M1 spatial path. */\nexport interface SsrSpatialCapabilities {\n readonly compute: boolean;\n readonly storageTexture: boolean;\n readonly rgba16floatRenderable: boolean;\n readonly r32floatSampledStorage: boolean;\n}\n\n/** Detached owner facts consumed by spatial admission. */\nexport interface SsrSpatialEnvironment {\n readonly lane: SsrSpatialLane;\n readonly m0: Pick<SsrAdmissionResult, 'status'>;\n readonly sceneInputs: boolean;\n /** Current-frame motion/coverage producer, not reusable previous-frame history. */\n readonly temporal: boolean;\n readonly reflectionFallback: boolean;\n readonly capabilities: SsrSpatialCapabilities;\n /** Recovery readiness is optional for callers that have no recovery fault. */\n readonly recovery?: boolean;\n}\n\n/** The only camera fields used by the spatial admission owner. */\nexport interface SsrSpatialCamera {\n readonly projection: 'perspective' | 'orthographic';\n readonly near: number;\n readonly far: number;\n readonly screenSpaceReflection?: ScreenSpaceReflectionData;\n}\n\nexport interface SsrSpatialWork {\n readonly attachmentCount: number;\n readonly passCount: number;\n readonly bindingCount: number;\n readonly resourceCount: number;\n readonly historyCount: 0;\n readonly temporalDemand: 0;\n}\n\nexport type SsrSpatialStatus =\n | 'not-requested'\n | 'requested'\n | 'admitted'\n | 'fallback-only'\n | 'structural-only';\n\nexport interface SsrSpatialAdmissionBase {\n readonly status: SsrSpatialStatus;\n readonly lane: SsrSpatialLane;\n readonly config: ScreenSpaceReflectionData | undefined;\n readonly viewRange: number;\n readonly work: SsrSpatialWork;\n}\n\nexport type SsrSpatialAdmission =\n | (SsrSpatialAdmissionBase & {\n readonly status: 'not-requested' | 'requested';\n readonly failure?: undefined;\n })\n | (SsrSpatialAdmissionBase & {\n readonly status: 'admitted';\n readonly config: ScreenSpaceReflectionData;\n readonly failure?: undefined;\n })\n | (SsrSpatialAdmissionBase & {\n readonly status: 'fallback-only' | 'structural-only';\n readonly failure: SsrConfigInvalidError | SsrUnavailableError;\n });\n\nconst ZERO_SPATIAL_WORK: SsrSpatialWork = Object.freeze({\n attachmentCount: 0,\n passCount: 0,\n bindingCount: 0,\n resourceCount: 0,\n historyCount: 0,\n temporalDemand: 0,\n});\n\nconst ADMITTED_SPATIAL_WORK: SsrSpatialWork = Object.freeze({\n attachmentCount: 3,\n passCount: 4,\n bindingCount: 4,\n resourceCount: 3,\n historyCount: 0,\n temporalDemand: 0,\n});\n\nfunction configRange(\n field: SsrConfigField,\n viewRange: number,\n maxDistance: number,\n): SsrConfigRange {\n switch (field) {\n case 'maxDistance':\n return { min: 0, minInclusive: false, max: viewRange, maxInclusive: true };\n case 'thickness':\n return { min: 0, minInclusive: false, max: maxDistance, maxInclusive: true };\n case 'maxRoughness':\n return { min: 0, minInclusive: true, max: 1, maxInclusive: true };\n }\n}\n\nfunction configError(\n field: SsrConfigField,\n value: number,\n range: SsrConfigRange,\n): SsrConfigInvalidError {\n const left = range.minInclusive ? '[' : '(';\n const right = range.maxInclusive ? ']' : ')';\n return Object.freeze({\n code: 'ssr-config-invalid',\n expected: `finite ${field} in ${left}${range.min}, ${range.max}${right}`,\n hint: `set ${field} to a finite value inside the reported range before retrying`,\n detail: Object.freeze({ field, value, range: Object.freeze(range) }),\n });\n}\n\n/** Validate one schema-derived component value against the active view. */\nexport function validateScreenSpaceReflection(\n config: ScreenSpaceReflectionData,\n input: { readonly viewRange: number },\n): Result<ScreenSpaceReflectionData, SsrConfigInvalidError> {\n const viewRange = input.viewRange;\n if (!Number.isFinite(viewRange) || viewRange <= 0) {\n return err(\n configError('maxDistance', config.maxDistance, configRange('maxDistance', viewRange, 0)),\n );\n }\n if (\n !Number.isFinite(config.maxDistance) ||\n config.maxDistance <= 0 ||\n config.maxDistance > viewRange\n ) {\n return err(\n configError(\n 'maxDistance',\n config.maxDistance,\n configRange('maxDistance', viewRange, config.maxDistance),\n ),\n );\n }\n if (\n !Number.isFinite(config.thickness) ||\n config.thickness <= 0 ||\n config.thickness > config.maxDistance\n ) {\n return err(\n configError(\n 'thickness',\n config.thickness,\n configRange('thickness', viewRange, config.maxDistance),\n ),\n );\n }\n if (!Number.isFinite(config.maxRoughness) || config.maxRoughness < 0 || config.maxRoughness > 1) {\n return err(\n configError(\n 'maxRoughness',\n config.maxRoughness,\n configRange('maxRoughness', viewRange, config.maxDistance),\n ),\n );\n }\n return ok(\n Object.freeze({\n maxDistance: config.maxDistance,\n thickness: config.thickness,\n maxRoughness: config.maxRoughness,\n }),\n );\n}\n\nfunction unavailable(\n lane: SsrSpatialLane,\n reason: SsrSpatialUnavailableReason,\n required: readonly string[],\n actual: Readonly<Record<string, boolean | number | string>>,\n): SsrUnavailableError {\n const recovery =\n reason === 'lane-unsupported' || reason === 'projection-unsupported'\n ? 'select a perspective clustered or deferred Standard lane'\n : reason === 'reflection-fallback-unavailable'\n ? 'repair the submitted reflection fallback owner receipt'\n : reason === 'temporal-unavailable'\n ? 'submit the matching temporal-v1 producer receipt'\n : reason === 'recovery-unavailable'\n ? 'complete device and producer recovery before retrying'\n : 'restore the required scene, capability, or format input before retrying';\n return Object.freeze({\n code: 'ssr-unavailable',\n expected: 'SSR spatial admission has a complete Standard input and capability set',\n hint: recovery,\n detail: Object.freeze({\n lane,\n reason,\n required: Object.freeze([...required]),\n actual: Object.freeze({ ...actual }),\n recovery,\n }),\n });\n}\n\nfunction unavailableResult(\n lane: SsrSpatialLane,\n viewRange: number,\n failure: SsrUnavailableError,\n): SsrSpatialAdmission {\n return Object.freeze({\n status: 'fallback-only',\n lane,\n config: undefined,\n viewRange,\n work: ZERO_SPATIAL_WORK,\n failure,\n });\n}\n\n/**\n * Admit the active camera's schema-derived component into the M1 spatial\n * path. No graph/resource handle crosses this boundary.\n */\nexport function admitSsrSpatial(input: {\n readonly camera: SsrSpatialCamera;\n readonly environment: SsrSpatialEnvironment;\n}): SsrSpatialAdmission {\n const camera = input.camera;\n const environment = input.environment;\n const viewRange = camera.far - camera.near;\n const config = camera.screenSpaceReflection;\n if (config === undefined) {\n return Object.freeze({\n status: 'not-requested',\n lane: environment.lane,\n config: undefined,\n viewRange,\n work: ZERO_SPATIAL_WORK,\n });\n }\n\n const valid = validateScreenSpaceReflection(config, { viewRange });\n if (!valid.ok) {\n return Object.freeze({\n status: 'fallback-only',\n lane: environment.lane,\n config,\n viewRange,\n work: ZERO_SPATIAL_WORK,\n failure: valid.error,\n });\n }\n\n if (environment.m0.status !== 'admitted') {\n return unavailableResult(\n environment.lane,\n viewRange,\n unavailable(\n environment.lane,\n 'reflection-fallback-unavailable',\n ['admitted M0 dependency receipt'],\n { m0: false },\n ),\n );\n }\n if (environment.lane !== 'clustered' && environment.lane !== 'deferred') {\n return unavailableResult(\n environment.lane,\n viewRange,\n unavailable(environment.lane, 'lane-unsupported', ['clustered or deferred Standard lane'], {\n lane: environment.lane,\n }),\n );\n }\n if (camera.projection !== 'perspective') {\n return unavailableResult(\n environment.lane,\n viewRange,\n unavailable(environment.lane, 'projection-unsupported', ['perspective camera'], {\n projection: camera.projection,\n }),\n );\n }\n if (!environment.sceneInputs) {\n return unavailableResult(\n environment.lane,\n viewRange,\n unavailable(\n environment.lane,\n 'scene-input-unavailable',\n ['deferred Standard scene/material/fallback inputs'],\n { sceneInputs: false },\n ),\n );\n }\n if (!environment.temporal) {\n return unavailableResult(\n environment.lane,\n viewRange,\n unavailable(environment.lane, 'temporal-unavailable', ['temporal-v1'], { temporal: false }),\n );\n }\n if (!environment.reflectionFallback) {\n return unavailableResult(\n environment.lane,\n viewRange,\n unavailable(\n environment.lane,\n 'reflection-fallback-unavailable',\n ['submitted BRDF-projected fallback'],\n { reflectionFallback: false },\n ),\n );\n }\n if (environment.recovery === false) {\n return unavailableResult(\n environment.lane,\n viewRange,\n unavailable(environment.lane, 'recovery-unavailable', ['ready device and owners'], {\n recovery: false,\n }),\n );\n }\n const capabilities = environment.capabilities;\n if (\n !capabilities.compute ||\n !capabilities.storageTexture ||\n !capabilities.rgba16floatRenderable\n ) {\n return unavailableResult(\n environment.lane,\n viewRange,\n unavailable(\n environment.lane,\n 'capability-unavailable',\n ['compute', 'storageTexture', 'rgba16floatRenderable'],\n {\n compute: capabilities.compute,\n storageTexture: capabilities.storageTexture,\n rgba16floatRenderable: capabilities.rgba16floatRenderable,\n },\n ),\n );\n }\n if (!capabilities.r32floatSampledStorage) {\n return unavailableResult(\n environment.lane,\n viewRange,\n unavailable(\n environment.lane,\n 'format-unavailable',\n ['r32float sampled and storage mip chain'],\n { r32floatSampledStorage: false },\n ),\n );\n }\n return Object.freeze({\n status: 'admitted',\n lane: environment.lane,\n config: valid.value,\n viewRange,\n work: ADMITTED_SPATIAL_WORK,\n });\n}\n","import type { TextureFormat } from '@forgeax/engine-rhi';\nimport type { VolumeRecoveryState, VolumeSelectedLightFacts } from './recovery';\nimport type { VolumetricFogResourceFacts } from './resources';\n\nexport type VolumetricFogInspectionStatus = 'off' | 'available' | 'unavailable' | 'degraded';\n\nexport type VolumetricFogResourceStage = 'none' | 'candidate' | 'accepted' | 'lkg' | 'recovering';\n\nexport interface VolumetricFogInspection {\n readonly status: VolumetricFogInspectionStatus;\n readonly resourceStage: VolumetricFogResourceStage;\n readonly guid: string | undefined;\n readonly generation: number | undefined;\n readonly digest: string | undefined;\n readonly candidateGeneration: number | undefined;\n readonly candidateDigest: string | undefined;\n readonly lkgGeneration: number | undefined;\n readonly candidateFailure: VolumeRecoveryState['candidateFailure'];\n readonly deviceEpoch: number;\n readonly format: TextureFormat | undefined;\n readonly passCount: number;\n readonly sampleCount: number;\n readonly memoryBytes: number;\n readonly resourceFacts: VolumetricFogResourceFacts | undefined;\n readonly selectedLight: VolumeSelectedLightFacts | undefined;\n readonly candidateSelectedLight: VolumeSelectedLightFacts | undefined;\n}\n\nexport interface VolumetricFogInspectionInput {\n readonly authored: boolean;\n readonly capability: 'available' | 'unavailable';\n readonly degraded?: boolean;\n readonly recovery?: VolumeRecoveryState;\n readonly acceptedDigest?: string;\n readonly format?: TextureFormat;\n readonly passCount?: number;\n readonly sampleCount?: number;\n readonly memoryBytes?: number;\n readonly resourceFacts?: VolumetricFogResourceFacts;\n}\n\nfunction resourceStage(input: VolumetricFogInspectionInput): VolumetricFogResourceStage {\n if (!input.authored || input.recovery === undefined) return 'none';\n if (input.recovery.status === 'candidate') return 'candidate';\n if (input.recovery.status === 'recovering') return 'recovering';\n if (input.recovery.status === 'degraded') return 'lkg';\n return 'accepted';\n}\n\nexport function inspectVolumetricFog(input: VolumetricFogInspectionInput): VolumetricFogInspection {\n const recovery = input.recovery;\n const status: VolumetricFogInspectionStatus = !input.authored\n ? 'off'\n : input.capability === 'unavailable'\n ? 'unavailable'\n : input.degraded === true || recovery?.status === 'degraded'\n ? 'degraded'\n : 'available';\n return Object.freeze({\n status,\n resourceStage: resourceStage(input),\n guid: recovery?.guid,\n generation: recovery?.generation,\n digest: input.acceptedDigest,\n candidateGeneration: recovery?.candidateGeneration,\n candidateDigest: recovery?.candidateDigest,\n lkgGeneration: recovery?.lkgGeneration,\n candidateFailure: recovery?.candidateFailure,\n deviceEpoch: recovery?.deviceEpoch ?? 0,\n format: input.format,\n passCount: input.passCount ?? 0,\n sampleCount: input.sampleCount ?? 0,\n memoryBytes: input.memoryBytes ?? 0,\n resourceFacts: input.resourceFacts,\n selectedLight: recovery?.selectedLight,\n candidateSelectedLight: recovery?.candidateSelectedLight,\n });\n}\n","export interface ProbeFilterState {\n readonly probeIndex: number;\n readonly faceCount: number;\n readonly mipCount: number;\n readonly cursor: number;\n readonly activeGeneration: number;\n}\n\nexport function createProbeFilterState(input: {\n readonly probeIndex: number;\n readonly faceCount?: number;\n readonly mipCount: number;\n readonly activeGeneration?: number;\n}): ProbeFilterState {\n return {\n probeIndex: input.probeIndex,\n faceCount: input.faceCount ?? 6,\n mipCount: input.mipCount,\n cursor: 0,\n activeGeneration: input.activeGeneration ?? 0,\n };\n}\n\nexport function advanceProbeFilter(\n state: ProbeFilterState,\n):\n | { readonly probeIndex: number; readonly faceIndex: number; readonly mipLevel: number }\n | undefined {\n const total = state.faceCount * state.mipCount;\n if (state.cursor >= total) return undefined;\n return {\n probeIndex: state.probeIndex,\n faceIndex: state.cursor % state.faceCount,\n mipLevel: Math.floor(state.cursor / state.faceCount),\n };\n}\n\nexport function commitProbeFilterStep(state: ProbeFilterState, success: boolean): ProbeFilterState {\n if (!success) return state;\n const nextCursor = state.cursor + 1;\n const complete = nextCursor >= state.faceCount * state.mipCount;\n return {\n ...state,\n cursor: nextCursor,\n activeGeneration: complete ? state.activeGeneration + 1 : state.activeGeneration,\n };\n}\n\nexport function probeFilterIsSteady(state: ProbeFilterState): boolean {\n return state.cursor >= state.faceCount * state.mipCount;\n}\n\nfunction normalize(vector: readonly [number, number, number]): [number, number, number] {\n const length = Math.hypot(vector[0], vector[1], vector[2]);\n if (length === 0) return [0, 0, 1];\n return [vector[0] / length, vector[1] / length, vector[2] / length];\n}\n\nexport function boxProjectReflectionDirection(\n direction: readonly [number, number, number],\n boxCenter: readonly [number, number, number],\n halfExtents: readonly [number, number, number],\n point: readonly [number, number, number],\n): [number, number, number] {\n const ray = normalize(direction);\n for (const axis of [0, 1, 2] as const) {\n if (Math.abs(point[axis] - boxCenter[axis]) >= halfExtents[axis]) return ray;\n }\n let distance = Number.POSITIVE_INFINITY;\n for (let axis = 0; axis < 3; axis += 1) {\n const component = ray[axis] ?? 0;\n if (component === 0) continue;\n const extent = halfExtents[axis] ?? 0;\n const edge = component > 0 ? (boxCenter[axis] ?? 0) + extent : (boxCenter[axis] ?? 0) - extent;\n const candidate = (edge - (point[axis] ?? 0)) / component;\n if (candidate > 0) distance = Math.min(distance, candidate);\n }\n if (!Number.isFinite(distance)) return ray;\n return normalize([\n (point[0] ?? 0) + ray[0] * distance - (boxCenter[0] ?? 0),\n (point[1] ?? 0) + ray[1] * distance - (boxCenter[1] ?? 0),\n (point[2] ?? 0) + ray[2] * distance - (boxCenter[2] ?? 0),\n ]);\n}\n","import type { Buffer, Sampler, TextureView } from '@forgeax/engine-rhi';\n\nexport interface ReflectionProbeTableRow {\n readonly primitiveKey?: string;\n readonly index: number;\n readonly worldId: number;\n readonly entityKey: number;\n readonly center: readonly [number, number, number];\n readonly halfExtents: readonly [number, number, number];\n readonly intensity: number;\n readonly generation: number;\n /** Renderer-owned filtered cube used by the Standard material lane. */\n readonly filteredView?: TextureView;\n /** Renderer-owned sampler paired with filteredView. */\n readonly sampler?: Sampler;\n /** Per-probe uniform payload; keeps MaterialAsset ABI unchanged. */\n readonly uniformBuffer?: Buffer;\n}\n\nexport interface ReflectionProbeTable {\n readonly rows: readonly ReflectionProbeTableRow[];\n readonly cpuIndexByPrimitive: (primitiveKey: string) => number | undefined;\n readonly gpuIndexByPrimitive: (primitiveKey: string) => number | undefined;\n}\n\nexport function buildReflectionProbeTable(\n rows: readonly ReflectionProbeTableRow[],\n): ReflectionProbeTable {\n const ordered = rows.slice().sort((a, b) => a.index - b.index);\n const indices = new Map<string, number>();\n for (const row of ordered) {\n if (row.primitiveKey !== undefined) indices.set(row.primitiveKey, row.index);\n }\n const indexFor = (primitiveKey: string): number | undefined => indices.get(primitiveKey);\n return {\n rows: Object.freeze(ordered),\n cpuIndexByPrimitive: indexFor,\n gpuIndexByPrimitive: indexFor,\n };\n}\n\nexport function reflectionProbeTableBytes(table: ReflectionProbeTable): number {\n return table.rows.length * 48;\n}\n","import type {\n ReflectionFallbackFailureStage,\n ReflectionFallbackInspection,\n ReflectionFallbackReceipt,\n ReflectionFallbackRecoveryAction,\n} from '../inspection-types';\n\nexport interface ReflectionFallbackFailureInput {\n readonly stage: ReflectionFallbackFailureStage;\n readonly code: string;\n readonly expected: string;\n readonly detail?: Readonly<Record<string, unknown>>;\n}\n\nfunction recoveryFor(\n receipt: ReflectionFallbackReceipt,\n failure?: ReflectionFallbackFailureInput,\n): ReflectionFallbackRecoveryAction {\n if (failure !== undefined) {\n const code = failure.code.toLowerCase();\n if (code.includes('device') || code.includes('format') || code.includes('capability')) {\n return 'rebuild';\n }\n if (failure.stage === 'prepare' || failure.stage === 'filter') return 'recapture';\n if (failure.stage === 'build' || failure.stage === 'encode') return 'rebuild';\n if (failure.stage === 'finish' || failure.stage === 'submit') return 'retry';\n // Completion failures may still retain a source-identical committed row;\n // use it as LKG, otherwise retry the producer completion.\n if (failure.stage === 'completion') {\n if (receipt.source === 'probe' && (receipt.state === 'active' || receipt.state === 'lkg')) {\n return 'use-LKG';\n }\n if (\n receipt.source === 'skylight' &&\n (receipt.state === 'active' || receipt.state === 'lkg')\n ) {\n return 'use-Skylight';\n }\n if (receipt.source === 'neutral' && receipt.state === 'neutral') return 'use-neutral';\n return 'retry';\n }\n }\n if (receipt.source === 'probe' && (receipt.state === 'active' || receipt.state === 'lkg')) {\n return 'use-LKG';\n }\n if (receipt.source === 'skylight' || receipt.state === 'lkg') return 'use-Skylight';\n return 'use-neutral';\n}\n\n/** Projects producer state and the latest closed failure into detached facts. */\nexport function inspectReflectionFallback(\n receipt: ReflectionFallbackReceipt,\n failure?: ReflectionFallbackFailureInput,\n): ReflectionFallbackInspection {\n return {\n receipt,\n recoveryAction: recoveryFor(receipt, failure),\n ...(failure === undefined\n ? {}\n : {\n failureStage: failure.stage,\n failureCode: failure.code,\n expected: failure.expected,\n ...(failure.detail === undefined ? {} : { detail: failure.detail }),\n }),\n };\n}\n","import type { ReflectionProbeUpdateIntent } from '../components/reflection-probe';\n\nexport const REFLECTION_PROBE_BYTES_PER_TEXEL = 8;\nexport const DEFAULT_REFLECTION_PROBE_LIMITS = Object.freeze({\n maxProbes: 16,\n maxResolution: 256,\n maxBytes: 64 * 1024 * 1024,\n});\n\nexport interface ReflectionProbeInput {\n readonly halfExtents: readonly [number, number, number];\n readonly priority: number;\n readonly intensity: number;\n readonly resolution: number;\n readonly boxProjection?: boolean;\n}\n\nexport interface ReflectionProbeFact extends ReflectionProbeInput {\n readonly worldId: number;\n readonly entityKey: number;\n readonly center: readonly [number, number, number];\n readonly revision: number;\n readonly updateIntent?: ReflectionProbeUpdateIntent;\n readonly invalidationVersion?: number;\n}\n\nexport interface ReflectionProbeAdmissionLimits {\n readonly maxProbes?: number;\n readonly maxResolution?: number;\n readonly maxBytes?: number;\n}\n\nexport interface ReflectionProbeInvalidInput {\n readonly code: 'reflection-probe-input-invalid';\n readonly field: string;\n readonly value: unknown;\n readonly expected: string;\n}\n\nexport interface ReflectionProbeBudgetFailure {\n readonly code: 'reflection-probe-budget-exceeded';\n readonly requested: number;\n readonly activeCount: number;\n readonly activeBytes: number;\n readonly maxProbes: number;\n readonly maxBytes: number;\n}\n\nexport type ReflectionProbeAdmission =\n | { readonly ok: true; readonly acceptedBytes: number }\n | { readonly ok: false; readonly error: ReflectionProbeBudgetFailure };\n\nexport function validateReflectionProbeInput(\n input: ReflectionProbeInput,\n): { readonly ok: true } | { readonly ok: false; readonly error: ReflectionProbeInvalidInput } {\n for (let index = 0; index < input.halfExtents.length; index += 1) {\n const value = input.halfExtents[index];\n if (value === undefined || !Number.isFinite(value) || value <= 0) {\n return {\n ok: false,\n error: {\n code: 'reflection-probe-input-invalid',\n field: `halfExtents[${index}]`,\n value,\n expected: 'a finite number greater than zero',\n },\n };\n }\n }\n if (!Number.isFinite(input.priority)) {\n return {\n ok: false,\n error: {\n code: 'reflection-probe-input-invalid',\n field: 'priority',\n value: input.priority,\n expected: 'a finite number',\n },\n };\n }\n if (!Number.isFinite(input.intensity) || input.intensity < 0) {\n return {\n ok: false,\n error: {\n code: 'reflection-probe-input-invalid',\n field: 'intensity',\n value: input.intensity,\n expected: 'a finite number greater than or equal to zero',\n },\n };\n }\n if (\n !Number.isInteger(input.resolution) ||\n input.resolution < 16 ||\n (input.resolution & (input.resolution - 1)) !== 0\n ) {\n return {\n ok: false,\n error: {\n code: 'reflection-probe-input-invalid',\n field: 'resolution',\n value: input.resolution,\n expected: 'a power of two of at least 16 pixels',\n },\n };\n }\n return { ok: true };\n}\n\nexport function estimateReflectionProbeBytes(\n resolution: number,\n limits: ReflectionProbeAdmissionLimits = DEFAULT_REFLECTION_PROBE_LIMITS,\n): number {\n const maxResolution = limits.maxResolution ?? DEFAULT_REFLECTION_PROBE_LIMITS.maxResolution;\n const clamped = Math.min(resolution, maxResolution);\n let filteredTexels = 0;\n for (let mip = 0; mip < 5; mip++) {\n const size = Math.max(1, Math.floor(clamped / 2 ** mip));\n filteredTexels += size * size;\n }\n // Raw cube + two alternating filtered cubes + their depth attachments.\n return (\n (clamped * clamped + 2 * filteredTexels) * 6 * REFLECTION_PROBE_BYTES_PER_TEXEL +\n 3 * clamped * clamped * 4\n );\n}\n\nexport function admitReflectionProbe(\n input: ReflectionProbeInput,\n current: { readonly acceptedCount: number; readonly acceptedBytes: number },\n limits: ReflectionProbeAdmissionLimits = DEFAULT_REFLECTION_PROBE_LIMITS,\n): ReflectionProbeAdmission {\n const maxProbes = limits.maxProbes ?? DEFAULT_REFLECTION_PROBE_LIMITS.maxProbes;\n const maxBytes = limits.maxBytes ?? DEFAULT_REFLECTION_PROBE_LIMITS.maxBytes;\n const maxResolution = limits.maxResolution ?? DEFAULT_REFLECTION_PROBE_LIMITS.maxResolution;\n const requested = estimateReflectionProbeBytes(input.resolution, { maxResolution });\n if (\n input.resolution > maxResolution ||\n current.acceptedCount >= maxProbes ||\n current.acceptedBytes + requested > maxBytes\n ) {\n return {\n ok: false,\n error: {\n code: 'reflection-probe-budget-exceeded',\n requested,\n activeCount: current.acceptedCount,\n activeBytes: current.acceptedBytes,\n maxProbes,\n maxBytes,\n },\n };\n }\n return { ok: true, acceptedBytes: current.acceptedBytes + requested };\n}\n\nexport interface ReflectionProbeSelection {\n readonly kind: 'probe';\n readonly worldId: number;\n readonly entityKey: number;\n readonly normalizedDistance: number;\n}\n\nexport interface SkylightSelection {\n readonly kind: 'skylight';\n}\n\nexport type ReflectionProbeSelectionResult = ReflectionProbeSelection | SkylightSelection;\n\nexport type ReflectionFallbackSource = 'probe' | 'skylight' | 'neutral';\n\nexport interface ReflectionFallbackProjectionInput {\n /** Stable renderable identity used to join the main-pass projection. */\n readonly renderableKey?: string;\n /** Stable producer source identity; never a live GPU handle. */\n readonly sourceKey?: string;\n readonly source: ReflectionFallbackSource;\n readonly coverage: number;\n readonly extent?: readonly [number, number, number];\n readonly linearHdr: readonly [number, number, number, number];\n readonly brdfSignature: string;\n}\n\nexport interface ReflectionFallbackProjection extends ReflectionFallbackProjectionInput {\n readonly source: ReflectionFallbackSource;\n}\n\nexport type ReflectionFallbackMismatchKind = 'source' | 'coverage' | 'extent' | 'brdf';\n\nexport interface ReflectionFallbackMismatch {\n readonly code:\n | 'reflection-fallback-source-mismatch'\n | 'reflection-fallback-coverage-mismatch'\n | 'reflection-fallback-extent-mismatch'\n | 'reflection-fallback-brdf-mismatch';\n readonly expected: string;\n readonly actual: string;\n}\n\nexport interface ReflectionFallbackInputInvalid {\n readonly code: 'reflection-fallback-input-invalid';\n readonly field: string;\n readonly expected: string;\n}\n\nexport type ReflectionFallbackProjectionResult =\n | { readonly ok: true; readonly value: ReflectionFallbackProjection }\n | { readonly ok: false; readonly error: ReflectionFallbackInputInvalid };\n\nexport function resolveReflectionFallbackSource(\n selection: ReflectionProbeSelectionResult,\n probeReady: boolean,\n skylightAvailable = true,\n): ReflectionFallbackSource {\n if (selection.kind === 'probe' && probeReady) return 'probe';\n // An unavailable probe follows the producer recovery order: use the active\n // Skylight when one exists, then the producer-owned neutral zero. Returning\n // neutral directly here would make the main Standard lighting lane and the\n // detached fallback projection disagree.\n if (skylightAvailable) return 'skylight';\n return 'neutral';\n}\n\nexport function reflectionFallbackCoverage(\n source: ReflectionFallbackSource,\n fact: ReflectionProbeFact | undefined,\n selection: ReflectionProbeSelectionResult,\n): number {\n if (source === 'neutral') return 0;\n if (source === 'skylight') return 1;\n if (fact === undefined || selection.kind !== 'probe') return 0;\n const normalized = Math.sqrt(Math.max(0, selection.normalizedDistance));\n return Math.max(0, Math.min(1, 1 - normalized / Math.sqrt(3)));\n}\n\nexport function reflectionFallbackSourceKey(\n source: ReflectionFallbackSource,\n selection: ReflectionProbeSelectionResult,\n skylight?: { readonly entityHandle: number; readonly equirectHandle: number },\n): string {\n if (source === 'probe' && selection.kind === 'probe') {\n return `probe:${selection.worldId}:${selection.entityKey}`;\n }\n if (source === 'skylight' && skylight !== undefined) {\n return `skylight:${skylight.entityHandle}:${skylight.equirectHandle}`;\n }\n return source;\n}\n\nexport function reflectionFallbackProjectionSignature(\n input: ReflectionFallbackProjectionInput,\n): string {\n return JSON.stringify({\n renderableKey: input.renderableKey,\n sourceKey: input.sourceKey,\n source: input.source,\n coverage: input.coverage,\n extent: input.extent,\n brdfSignature: input.brdfSignature,\n });\n}\n\nexport function deriveReflectionFallbackProjection(\n input: ReflectionFallbackProjectionInput,\n): ReflectionFallbackProjectionResult {\n if (!Number.isFinite(input.coverage) || input.coverage < 0 || input.coverage > 1) {\n return {\n ok: false,\n error: {\n code: 'reflection-fallback-input-invalid',\n field: 'coverage',\n expected: 'a finite number between zero and one',\n },\n };\n }\n if (input.extent?.some((value) => !Number.isFinite(value) || value <= 0)) {\n return {\n ok: false,\n error: {\n code: 'reflection-fallback-input-invalid',\n field: 'extent',\n expected: 'three finite numbers greater than zero',\n },\n };\n }\n if (input.linearHdr.some((value) => !Number.isFinite(value))) {\n return {\n ok: false,\n error: {\n code: 'reflection-fallback-input-invalid',\n field: 'linearHdr',\n expected: 'four finite linear HDR values',\n },\n };\n }\n if (input.brdfSignature.length === 0) {\n return {\n ok: false,\n error: {\n code: 'reflection-fallback-input-invalid',\n field: 'brdfSignature',\n expected: 'a non-empty BRDF signature',\n },\n };\n }\n const linearHdr = input.source === 'neutral' ? ([0, 0, 0, 0] as const) : [...input.linearHdr];\n return {\n ok: true,\n value: Object.freeze({\n ...(input.renderableKey === undefined ? {} : { renderableKey: input.renderableKey }),\n ...(input.sourceKey === undefined ? {} : { sourceKey: input.sourceKey }),\n source: input.source,\n coverage: input.coverage,\n ...(input.extent === undefined\n ? {}\n : {\n extent: Object.freeze([...input.extent]) as readonly [number, number, number],\n }),\n linearHdr: Object.freeze(linearHdr) as ReflectionFallbackProjection['linearHdr'],\n brdfSignature: input.brdfSignature,\n }),\n };\n}\n\nexport function validateReflectionFallbackCompatibility(\n expected: ReflectionFallbackProjectionInput,\n actual: ReflectionFallbackProjectionInput,\n): { readonly ok: true } | { readonly ok: false; readonly error: ReflectionFallbackMismatch } {\n const mismatch = (\n kind: ReflectionFallbackMismatchKind,\n expectedValue: string,\n actualValue: string,\n ): { readonly ok: false; readonly error: ReflectionFallbackMismatch } => ({\n ok: false,\n error: {\n code: `reflection-fallback-${kind}-mismatch` as ReflectionFallbackMismatch['code'],\n expected: expectedValue,\n actual: actualValue,\n },\n });\n if (expected.source !== actual.source) {\n return mismatch('source', expected.source, actual.source);\n }\n if (expected.coverage !== actual.coverage) {\n return mismatch('coverage', String(expected.coverage), String(actual.coverage));\n }\n const expectedExtent = expected.extent;\n const actualExtent = actual.extent;\n if (\n (expectedExtent === undefined && actualExtent !== undefined) ||\n (expectedExtent !== undefined &&\n (actualExtent === undefined ||\n expectedExtent.some((value, index) => value !== actualExtent[index])))\n ) {\n return mismatch('extent', JSON.stringify(expectedExtent), JSON.stringify(actualExtent));\n }\n if (expected.brdfSignature !== actual.brdfSignature) {\n return mismatch('brdf', expected.brdfSignature, actual.brdfSignature);\n }\n return { ok: true };\n}\n\nfunction contains(fact: ReflectionProbeFact, point: readonly [number, number, number]): boolean {\n return fact.halfExtents.every((extent, axis) => {\n const center = fact.center[axis] ?? 0;\n const coordinate = point[axis] ?? 0;\n return Math.abs(coordinate - center) <= extent;\n });\n}\n\nfunction normalizedDistance(\n fact: ReflectionProbeFact,\n point: readonly [number, number, number],\n): number {\n let squared = 0;\n for (let axis = 0; axis < 3; axis += 1) {\n const delta = (point[axis] ?? 0) - (fact.center[axis] ?? 0);\n const extent = fact.halfExtents[axis] ?? 1;\n squared += (delta / extent) ** 2;\n }\n return squared;\n}\n\nfunction isBetter(\n candidate: ReflectionProbeSelection,\n current: ReflectionProbeSelection,\n facts: readonly ReflectionProbeFact[],\n): boolean {\n const candidateFact = facts.find(\n (fact) => fact.worldId === candidate.worldId && fact.entityKey === candidate.entityKey,\n );\n const currentFact = facts.find(\n (fact) => fact.worldId === current.worldId && fact.entityKey === current.entityKey,\n );\n if (candidateFact === undefined || currentFact === undefined) return false;\n if (candidateFact.priority !== currentFact.priority)\n return candidateFact.priority > currentFact.priority;\n if (candidate.normalizedDistance !== current.normalizedDistance) {\n return candidate.normalizedDistance < current.normalizedDistance;\n }\n return (\n candidate.worldId < current.worldId ||\n (candidate.worldId === current.worldId && candidate.entityKey < current.entityKey)\n );\n}\n\nexport function selectReflectionProbe(\n facts: readonly ReflectionProbeFact[],\n primitiveCenter: readonly [number, number, number],\n): ReflectionProbeSelectionResult {\n let selected: ReflectionProbeSelection | undefined;\n for (const fact of facts) {\n if (!contains(fact, primitiveCenter)) continue;\n const candidate: ReflectionProbeSelection = {\n kind: 'probe',\n worldId: fact.worldId,\n entityKey: fact.entityKey,\n normalizedDistance: normalizedDistance(fact, primitiveCenter),\n };\n if (selected === undefined || isBetter(candidate, selected, facts)) selected = candidate;\n }\n return selected ?? { kind: 'skylight' };\n}\n\nexport interface ReflectionProbePrimitive {\n readonly worldId: number;\n readonly entityKey: number;\n /** Main-pass renderable key; world/entity is retained as the compatibility fallback. */\n readonly renderableKey?: string;\n readonly center: readonly [number, number, number];\n}\n\nexport interface ReflectionProbeProjectionSnapshot {\n readonly revision: number;\n readonly facts: readonly ReflectionProbeFact[];\n readonly selected: ReadonlyMap<string, ReflectionProbeSelectionResult>;\n readonly scannedPrimitives: number;\n}\n\nfunction primitiveKey(worldId: number, entityKey: number): string {\n return `${worldId}:${entityKey}`;\n}\n\nexport class ReflectionProbeProjection {\n private revision = 0;\n private facts: readonly ReflectionProbeFact[] = [];\n private selected = new Map<string, ReflectionProbeSelectionResult>();\n private signature = '';\n private scannedPrimitives = 0;\n\n update(\n facts: readonly ReflectionProbeFact[],\n primitives: readonly ReflectionProbePrimitive[],\n ): ReflectionProbeProjectionSnapshot {\n const nextFacts = facts\n .slice()\n .sort((a, b) => a.worldId - b.worldId || a.entityKey - b.entityKey);\n const signature = JSON.stringify({ facts: nextFacts, primitives });\n if (signature === this.signature) return this.snapshot();\n this.signature = signature;\n this.facts = nextFacts;\n this.selected = new Map();\n for (const primitive of primitives) {\n this.selected.set(\n primitive.renderableKey ?? primitiveKey(primitive.worldId, primitive.entityKey),\n selectReflectionProbe(nextFacts, primitive.center),\n );\n }\n this.scannedPrimitives = primitives.length;\n this.revision += 1;\n return this.snapshot();\n }\n\n snapshot(): ReflectionProbeProjectionSnapshot {\n return {\n revision: this.revision,\n facts: this.facts,\n selected: this.selected,\n scannedPrimitives: this.scannedPrimitives,\n };\n }\n\n selection(worldId: number, entityKey: number): ReflectionProbeSelectionResult {\n return this.selected.get(primitiveKey(worldId, entityKey)) ?? { kind: 'skylight' };\n }\n}\n","import { createVisibilityBudget } from './budget';\n\n/** Detached, bounded LOD/occlusion facts for renderer inspection consumers. */\n\nexport const LOD_OCCLUSION_INSPECTION_SCHEMA = 'forgeax::lod-occlusion-inspection::v2' as const;\nexport const LOD_OCCLUSION_INSPECTION_MAX_BYTES = 16 * 1024;\nconst MAX_INSPECTION_SAMPLES = 64;\n\nexport type LodOcclusionInspectionError = {\n readonly code: string;\n readonly expected: string;\n readonly hint: string;\n readonly detail?: Readonly<Record<string, string | number | boolean>>;\n};\n\nexport type LodOcclusionFallback =\n | { readonly active: false }\n | {\n readonly active: true;\n readonly reason: 'producer-failed' | 'page-exhausted' | 'query-failed' | 'device-loss';\n readonly error: LodOcclusionInspectionError;\n };\n\nexport type LodOcclusionDegradation =\n | { readonly active: false }\n | { readonly active: true; readonly reason: 'all-visible' | 'query-unavailable' };\n\nexport interface LodOcclusionInspectionSample {\n readonly primitiveSlot: number;\n readonly level: number;\n readonly visible: boolean;\n}\n\nexport interface LodOcclusionInspectionRow {\n readonly root: { readonly guid: string; readonly sourceKey: string };\n readonly view: {\n readonly attachmentId: string;\n readonly cameraEntity: number;\n readonly viewRole: 'main' | 'shadow' | 'reflection' | 'probe';\n readonly viewGeneration: number;\n };\n readonly slot: { readonly primitiveSlot: number; readonly slotGeneration: number };\n readonly generation: number;\n readonly count: {\n readonly candidates: number;\n readonly visible: number;\n readonly occluded: number;\n };\n readonly lodHistogram: readonly { readonly level: number; readonly count: number }[];\n /** Map latency for the most recently completed query page (bounded POD). */\n readonly queryLatencyUs: {\n readonly median: number;\n readonly p95: number;\n readonly last: number;\n };\n readonly pagePressure: { readonly used: number; readonly capacity: number };\n readonly fallback: LodOcclusionFallback;\n readonly degradation: LodOcclusionDegradation;\n readonly samples: readonly LodOcclusionInspectionSample[];\n}\n\nexport interface LodOcclusionInspectionSubmit {\n readonly frameId: number;\n readonly build: string;\n readonly deviceGeneration: number;\n}\n\n/**\n * Per-World attribution is only authoritative when the renderer publishes\n * the GPU facts from the same submit that owns the parent inspection. The\n * normal projection path remains useful diagnostics, but it must not be used\n * as evidence for a World-reorder or per-World LOD claim.\n */\nexport type LodOcclusionWorldAttribution =\n | { readonly status: 'unavailable'; readonly reason: 'projection-only' }\n | { readonly status: 'same-submit'; readonly submit: LodOcclusionInspectionSubmit };\n\nexport interface LodOcclusionWorldInspection {\n readonly attachmentId: string;\n readonly rows: readonly LodOcclusionInspectionRow[];\n readonly attribution: LodOcclusionWorldAttribution;\n}\n\nexport interface LodOcclusionInspectionBudget {\n readonly configuredQueryBudget: number;\n readonly effectiveQueryBudget: number;\n readonly settleSubmits: number;\n readonly retestSubmits: number;\n readonly expirySubmits: number;\n}\n\nexport interface LodOcclusionInspection extends LodOcclusionInspectionRow {\n readonly schema: typeof LOD_OCCLUSION_INSPECTION_SCHEMA;\n /** Atomic identity for the submit that produced every row below. */\n readonly submit: LodOcclusionInspectionSubmit;\n /** Immutable budget values used by the query and confidence owners. */\n readonly budget: LodOcclusionInspectionBudget;\n /** Stable attachment identity; array order is never an attribution key. */\n readonly worlds: readonly LodOcclusionWorldInspection[];\n}\n\nexport type LodOcclusionInspectionInput = Omit<\n LodOcclusionInspection,\n 'schema' | 'submit' | 'budget' | 'worlds'\n> & {\n readonly submit?: LodOcclusionInspectionSubmit;\n readonly budget?: LodOcclusionInspectionBudget;\n readonly worlds?: readonly LodOcclusionWorldInspectionInput[];\n};\n\nexport type LodOcclusionWorldInspectionInput = Omit<LodOcclusionWorldInspection, 'attribution'> & {\n readonly attribution?: LodOcclusionWorldAttribution;\n};\n\nexport type LodOcclusionInspectionAction =\n | { readonly action: 'none' }\n | { readonly action: 'rebuild'; readonly sourceKey: string; readonly reason: string }\n | { readonly action: 'cold-cook'; readonly sourceKey: string; readonly reason: string }\n | { readonly action: 'retry'; readonly sourceKey: string; readonly reason: string };\n\nfunction nonNegativeInteger(name: string, value: number): number {\n if (!Number.isInteger(value) || value < 0)\n throw new Error(`${name} must be a non-negative integer`);\n return value;\n}\n\nfunction copyError(error: LodOcclusionInspectionError): LodOcclusionInspectionError {\n return Object.freeze({\n code: error.code,\n expected: error.expected,\n hint: error.hint,\n ...(error.detail === undefined ? {} : { detail: Object.freeze({ ...error.detail }) }),\n });\n}\n\nfunction copyFallback(fallback: LodOcclusionFallback): LodOcclusionFallback {\n return fallback.active\n ? Object.freeze({ ...fallback, error: copyError(fallback.error) })\n : Object.freeze({ active: false });\n}\n\nfunction copySamples(\n samples: readonly LodOcclusionInspectionSample[],\n): readonly LodOcclusionInspectionSample[] {\n return Object.freeze(\n [...samples]\n .sort((left, right) => left.primitiveSlot - right.primitiveSlot)\n .slice(0, MAX_INSPECTION_SAMPLES)\n .map((sample) =>\n Object.freeze({\n primitiveSlot: nonNegativeInteger('sample.primitiveSlot', sample.primitiveSlot),\n level: nonNegativeInteger('sample.level', sample.level),\n visible: sample.visible,\n }),\n ),\n );\n}\n\nfunction copyWorldAttribution(\n attribution: LodOcclusionWorldAttribution | undefined,\n): LodOcclusionWorldAttribution {\n if (attribution === undefined) {\n return Object.freeze({ status: 'unavailable', reason: 'projection-only' });\n }\n if (attribution.status === 'same-submit') {\n if (typeof attribution.submit.build !== 'string' || attribution.submit.build.length === 0) {\n throw new Error('world.attribution.submit.build must be a non-empty string');\n }\n nonNegativeInteger('world.attribution.submit.frameId', attribution.submit.frameId);\n nonNegativeInteger(\n 'world.attribution.submit.deviceGeneration',\n attribution.submit.deviceGeneration,\n );\n return Object.freeze({\n status: 'same-submit',\n submit: Object.freeze({ ...attribution.submit }),\n });\n }\n if (attribution.status !== 'unavailable' || attribution.reason !== 'projection-only') {\n throw new Error('world.attribution must declare same-submit or projection-only');\n }\n return Object.freeze({ status: 'unavailable', reason: 'projection-only' });\n}\n\nfunction copyRow(row: LodOcclusionInspectionRow): LodOcclusionInspectionRow {\n for (const [name, value] of Object.entries({\n generation: row.generation,\n candidates: row.count.candidates,\n visible: row.count.visible,\n occluded: row.count.occluded,\n median: row.queryLatencyUs.median,\n p95: row.queryLatencyUs.p95,\n last: row.queryLatencyUs.last,\n pageUsed: row.pagePressure.used,\n pageCapacity: row.pagePressure.capacity,\n }))\n nonNegativeInteger(`inspection.${name}`, value);\n if (\n row.view.cameraEntity < 0 ||\n row.view.viewGeneration < 0 ||\n row.slot.primitiveSlot < 0 ||\n row.slot.slotGeneration < 0\n ) {\n throw new Error('inspection identity values must be non-negative');\n }\n if (row.pagePressure.used > row.pagePressure.capacity) {\n throw new Error('inspection page pressure exceeds capacity');\n }\n return Object.freeze({\n root: Object.freeze({ ...row.root }),\n view: Object.freeze({ ...row.view }),\n slot: Object.freeze({ ...row.slot }),\n generation: row.generation,\n count: Object.freeze({ ...row.count }),\n lodHistogram: Object.freeze(\n row.lodHistogram.map((histogram) =>\n Object.freeze({\n level: nonNegativeInteger('histogram.level', histogram.level),\n count: nonNegativeInteger('histogram.count', histogram.count),\n }),\n ),\n ),\n queryLatencyUs: Object.freeze({ ...row.queryLatencyUs }),\n pagePressure: Object.freeze({ ...row.pagePressure }),\n fallback: copyFallback(row.fallback),\n degradation: Object.freeze({ ...row.degradation }),\n samples: copySamples(row.samples),\n });\n}\n\nfunction copyWorlds(\n worlds: readonly LodOcclusionWorldInspectionInput[] | undefined,\n fallback: LodOcclusionInspectionRow,\n): readonly LodOcclusionWorldInspection[] {\n const source = worlds ?? [{ attachmentId: fallback.view.attachmentId, rows: [fallback] }];\n return Object.freeze(\n source.map((world) =>\n Object.freeze({\n attachmentId: world.attachmentId,\n rows: Object.freeze(world.rows.map((row) => copyRow(row))),\n attribution: copyWorldAttribution(world.attribution),\n }),\n ),\n );\n}\n\nexport function inspectLodOcclusion(input: LodOcclusionInspectionInput): LodOcclusionInspection {\n const row = copyRow(input);\n const defaultBudget = createVisibilityBudget();\n const budget = input.budget ?? {\n configuredQueryBudget: defaultBudget.configuredQueryBudget,\n effectiveQueryBudget: defaultBudget.effectiveQueryBudget,\n settleSubmits: defaultBudget.settleSubmits,\n retestSubmits: defaultBudget.retestSubmits,\n expirySubmits: defaultBudget.expirySubmits,\n };\n for (const [name, value] of Object.entries(budget))\n nonNegativeInteger(`inspection.budget.${name}`, value);\n const submit = input.submit ?? {\n frameId: input.generation,\n build: 'unknown',\n deviceGeneration: 0,\n };\n nonNegativeInteger('inspection.submit.frameId', submit.frameId);\n nonNegativeInteger('inspection.submit.deviceGeneration', submit.deviceGeneration);\n if (typeof submit.build !== 'string' || submit.build.length === 0) {\n throw new Error('inspection.submit.build must be a non-empty string');\n }\n const worlds = copyWorlds(input.worlds, row);\n for (const world of worlds) {\n if (\n world.attribution.status === 'same-submit' &&\n (world.attribution.submit.frameId !== submit.frameId ||\n world.attribution.submit.build !== submit.build ||\n world.attribution.submit.deviceGeneration !== submit.deviceGeneration)\n ) {\n throw new Error('world attribution must reference the parent inspection submit');\n }\n }\n const inspection: LodOcclusionInspection = Object.freeze({\n schema: LOD_OCCLUSION_INSPECTION_SCHEMA,\n ...row,\n submit: Object.freeze({ ...submit }),\n budget: Object.freeze({ ...budget }),\n worlds,\n });\n if (JSON.stringify(inspection).length > LOD_OCCLUSION_INSPECTION_MAX_BYTES) {\n throw new Error(`LOD occlusion inspection exceeds ${LOD_OCCLUSION_INSPECTION_MAX_BYTES} bytes`);\n }\n return inspection;\n}\n\nexport function serializeLodOcclusionInspection(inspection: LodOcclusionInspection): string {\n const serialized = JSON.stringify(inspection);\n if (serialized.length > LOD_OCCLUSION_INSPECTION_MAX_BYTES) {\n throw new Error(`LOD occlusion inspection exceeds ${LOD_OCCLUSION_INSPECTION_MAX_BYTES} bytes`);\n }\n return serialized;\n}\n\nexport function consumeLodOcclusionInspection(\n inspection: LodOcclusionInspection,\n): LodOcclusionInspectionAction {\n if (!inspection.fallback.active) return { action: 'none' };\n const { reason, error } = inspection.fallback;\n const action =\n error.code.startsWith('asset-') || reason === 'producer-failed'\n ? 'rebuild'\n : reason === 'query-failed' || reason === 'page-exhausted' || reason === 'device-loss'\n ? 'retry'\n : 'cold-cook';\n return { action, sourceKey: inspection.root.sourceKey, reason };\n}\n","// @forgeax/engine-render - bounded SSR spatial inspection projection.\n\nimport type { ScreenSpaceReflectionData } from '../components/screen-space-reflection';\nimport type { ReflectionFallbackSource } from '../inspection-types';\nimport type { SsrSpatialAdmission, SsrSpatialLane, SsrSpatialWork } from './admission';\nimport type { SsrConfigInvalidError, SsrUnavailableError } from './errors';\nimport type { SsrHistoryState } from './history';\n\nexport type SsrSpatialInspectionFailure = SsrConfigInvalidError | SsrUnavailableError;\n\nexport interface SsrSpatialHistoryInspection {\n readonly state: 'not-owned' | SsrHistoryState;\n readonly bytes: number;\n readonly resetCount: number;\n}\n\nexport interface SsrSpatialInspectionProjection {\n readonly status?: SsrSpatialInspection['status'];\n readonly coverage?: Partial<SsrSpatialInspection['coverage']>;\n readonly history?: SsrSpatialHistoryInspection;\n readonly passRoster?: readonly string[];\n readonly fallbackSource?: ReflectionFallbackSource;\n readonly failure?: SsrSpatialInspectionFailure;\n}\n\n/** Keep the public projection bounded even if a graph owner supplies a bad list. */\nexport const SSR_INSPECTION_MAX_PASSES = 64 as const;\n\nfunction nonNegativeSafeInteger(name: string, value: number): number {\n if (!Number.isSafeInteger(value) || value < 0) {\n throw new Error(`${name} must be a non-negative safe integer`);\n }\n return value;\n}\n\nfunction copyHistory(history: SsrSpatialHistoryInspection): SsrSpatialHistoryInspection {\n nonNegativeSafeInteger('SSR inspection history.bytes', history.bytes);\n nonNegativeSafeInteger('SSR inspection history.resetCount', history.resetCount);\n return Object.freeze({\n state: history.state,\n bytes: history.bytes,\n resetCount: history.resetCount,\n });\n}\n\nfunction copyCoverage(\n coverage: Partial<SsrSpatialInspection['coverage']> | undefined,\n): SsrSpatialInspection['coverage'] {\n const result = {\n hitCount: coverage?.hitCount ?? null,\n fallbackCount: coverage?.fallbackCount ?? null,\n excludedCount: coverage?.excludedCount ?? null,\n };\n for (const [key, value] of Object.entries(result)) {\n if (value !== null) nonNegativeSafeInteger(`SSR inspection coverage.${key}`, value);\n }\n return Object.freeze(result);\n}\n\nfunction copyPassRoster(passRoster: readonly string[] | undefined): readonly string[] {\n return Object.freeze(\n [...(passRoster ?? [])].slice(0, SSR_INSPECTION_MAX_PASSES).map((name, index) => {\n if (typeof name !== 'string' || name.length === 0) {\n throw new Error(`SSR inspection passRoster[${index}] must be a non-empty string`);\n }\n return name;\n }),\n );\n}\n\nexport interface SsrSpatialInspection {\n readonly status: 'not-requested' | 'requested' | 'admitted' | 'fallback-only' | 'structural-only';\n readonly lane: SsrSpatialLane;\n readonly config: ScreenSpaceReflectionData | undefined;\n readonly viewRange: number;\n readonly coverage: {\n /** Null means no GPU coverage measurement is available for this frame. */\n readonly hitCount: number | null;\n readonly fallbackCount: number | null;\n readonly excludedCount: number | null;\n };\n readonly history: SsrSpatialHistoryInspection;\n readonly work: SsrSpatialWork;\n readonly passRoster: readonly string[];\n readonly fallbackSource: ReflectionFallbackSource | undefined;\n readonly failure: SsrSpatialInspectionFailure | undefined;\n}\n\n/** Project only detached, bounded facts from the spatial admission result. */\nexport function projectSsrSpatialInspection(\n admission: SsrSpatialAdmission,\n projection: SsrSpatialInspectionProjection = {},\n): SsrSpatialInspection {\n const config = admission.config;\n return Object.freeze({\n status: projection.status ?? admission.status,\n lane: admission.lane,\n config:\n config === undefined\n ? undefined\n : Object.freeze({\n maxDistance: config.maxDistance,\n thickness: config.thickness,\n maxRoughness: config.maxRoughness,\n }),\n viewRange: admission.viewRange,\n coverage: copyCoverage(projection.coverage),\n history: copyHistory(\n projection.history ?? {\n state: 'not-owned' as const,\n bytes: 0,\n resetCount: 0,\n },\n ),\n work: Object.freeze({ ...admission.work }),\n passRoster: copyPassRoster(projection.passRoster),\n fallbackSource: projection.fallbackSource,\n failure: projection.failure ?? admission.failure,\n });\n}\n\nexport function serializeSsrSpatialInspection(inspection: SsrSpatialInspection): string {\n return JSON.stringify(inspection);\n}\n","import type { Handle, MeshAsset } from '@forgeax/engine-types';\nimport { err, ok, type Result } from '@forgeax/engine-types';\n\n/** A standard MeshAsset candidate prepared for one attached World generation. */\nexport interface DynamicGeometryPrepareInput {\n readonly world: object;\n /** Live ECS entity carrying MeshFilter + MeshRenderer on the attached World. */\n readonly entity?: number;\n /** Optional derived-physics entity whose fixed-step publication gates draw. */\n readonly physicsEntity?: number;\n readonly mesh: MeshAsset;\n /** Existing World.sharedRefs handle whose standard GPU residency is prepared. */\n readonly meshHandle?: Handle<'MeshAsset', 'shared'>;\n readonly revision: number;\n /** Material identity is a consumer fact; MaterialAsset stays in the World. */\n readonly materialIdentity?: string;\n /** Topology changes invalidate motion/history consumers. */\n readonly topologyRevision?: number;\n /** Captured by the Renderer host from the World FixedTime resource. */\n readonly fixedStep?: number;\n}\n\n/** Explicit ECS/fixed-step ordering proof used by Renderer admission. */\nexport interface DynamicGeometryOrdering {\n readonly world: object;\n readonly fixedStep: number;\n}\n\nexport type DynamicGeometryCandidateState =\n | 'prepared'\n | 'accepted'\n | 'published'\n | 'cancelled'\n | 'retired';\n\nexport interface DynamicGeometryCandidate {\n readonly candidateId: string;\n readonly generation: number;\n readonly owner: object;\n readonly world: object;\n readonly entity?: number;\n readonly physicsEntity?: number;\n /** False when the pure lifecycle was used without a shared MeshAsset handle. */\n readonly gpuReady: boolean;\n /** CPU/GPU geometry bytes reserved by this candidate budget. */\n readonly meshBytes: number;\n readonly revision: number;\n readonly topologyRevision: number;\n readonly materialIdentity?: string;\n readonly meshHandle?: Handle<'MeshAsset', 'shared'>;\n readonly fixedStep?: number;\n readonly mesh: MeshAsset;\n readonly state: DynamicGeometryCandidateState;\n}\n\n/** Receipt that ties candidate publication to the sole Renderer FrameReceipt. */\nexport interface DynamicGeometryReceipt {\n readonly candidateId: string;\n readonly generation: number;\n readonly revision: number;\n readonly topologyRevision: number;\n readonly fixedStep?: number;\n readonly frameId: number;\n readonly deviceGeneration: number;\n readonly frame: {\n readonly frameId: number;\n readonly deviceGeneration: number;\n readonly completed?: Promise<unknown>;\n };\n /** Whether the Renderer record stage consumed this candidate for this frame. */\n readonly recordStageConsumed: boolean;\n /** Actual frame fixed step; may be newer than the preparation step. */\n readonly publicationFixedStep?: number;\n}\n\nexport interface DynamicGeometryInspection {\n readonly generation: number;\n readonly prepared: number;\n readonly accepted: number;\n readonly published: number;\n readonly retired: number;\n readonly latestRevision?: number;\n readonly latestFrameId?: number;\n readonly historyInvalidations: number;\n readonly invalidated: number;\n readonly meshBytes: number;\n readonly maxMeshBytes: number;\n}\n\nexport type DynamicGeometryErrorCode =\n | 'dynamic-geometry-disposed'\n | 'dynamic-geometry-world-not-attached'\n | 'dynamic-geometry-invalid'\n | 'dynamic-geometry-gpu-failed'\n | 'dynamic-geometry-gpu-not-ready'\n | 'dynamic-geometry-budget-exceeded'\n | 'dynamic-geometry-stale'\n | 'dynamic-geometry-generation-mismatch'\n | 'dynamic-geometry-candidate-not-found'\n | 'dynamic-geometry-candidate-state'\n | 'dynamic-geometry-receipt-mismatch'\n | 'dynamic-geometry-ordering-required';\n\nexport interface DynamicGeometryErrorDetail {\n readonly code: DynamicGeometryErrorCode;\n readonly candidateId?: string;\n readonly revision?: number;\n readonly generation?: number;\n readonly actual?: unknown;\n}\n\nexport class DynamicGeometryError extends Error {\n readonly code: DynamicGeometryErrorCode;\n readonly expected: string;\n readonly hint: string;\n readonly detail: DynamicGeometryErrorDetail;\n\n constructor(\n code: DynamicGeometryErrorCode,\n expected: string,\n hint: string,\n detail: Omit<DynamicGeometryErrorDetail, 'code'> = {},\n ) {\n super(`${code}: ${expected}`);\n this.name = 'DynamicGeometryError';\n this.code = code;\n this.expected = expected;\n this.hint = hint;\n this.detail = Object.freeze({ code, ...detail });\n }\n}\n\ninterface CandidateRecord {\n readonly world: object;\n candidate: DynamicGeometryCandidate;\n /** Published history remains queryable for its completion fence, but a\n * newer topology must prevent that history from being consumed again. */\n historyInvalidated: boolean;\n acceptedFrame?: { readonly frameId: number; readonly deviceGeneration: number };\n}\n\n/**\n * A public candidate is a credential, not a mutable state object. Keep the\n * owner/world check in `current` cheap, then compare every scalar admission\n * fact before a caller can cancel, retire, or inspect another record by\n * copying its candidate id. The renderer-owned MeshAsset copy remains the\n * content source for the actual draw.\n */\nexport function sameCandidateCredential(\n candidate: DynamicGeometryCandidate,\n committed: DynamicGeometryCandidate,\n): boolean {\n return (\n candidate.candidateId === committed.candidateId &&\n candidate.owner === committed.owner &&\n candidate.world === committed.world &&\n candidate.generation === committed.generation &&\n candidate.entity === committed.entity &&\n candidate.physicsEntity === committed.physicsEntity &&\n candidate.gpuReady === committed.gpuReady &&\n candidate.meshBytes === committed.meshBytes &&\n candidate.revision === committed.revision &&\n candidate.topologyRevision === committed.topologyRevision &&\n candidate.materialIdentity === committed.materialIdentity &&\n candidate.meshHandle === committed.meshHandle &&\n candidate.fixedStep === committed.fixedStep\n );\n}\n\nfunction cloneTypedArray<T extends Float32Array | Uint16Array | Uint32Array>(value: T): T {\n return new (value.constructor as new (source: T) => T)(value);\n}\n\nfunction cloneMesh(mesh: MeshAsset): MeshAsset {\n const attributes = Object.fromEntries(\n Object.entries(mesh.attributes).map(([key, value]) => [\n key,\n value instanceof ArrayBuffer\n ? value.slice(0)\n : value === undefined\n ? undefined\n : cloneTypedArray(value as never),\n ]),\n ) as MeshAsset['attributes'];\n return Object.freeze({\n ...mesh,\n vertices: new Float32Array(mesh.vertices),\n ...(mesh.indices === undefined ? {} : { indices: cloneTypedArray(mesh.indices) }),\n attributes,\n ...(mesh.aabb === undefined ? {} : { aabb: new Float32Array(mesh.aabb) }),\n submeshes: Object.freeze(mesh.submeshes.map((submesh) => Object.freeze({ ...submesh }))),\n materialSlots: Object.freeze(mesh.materialSlots.map((slot) => Object.freeze({ ...slot }))),\n });\n}\n\nfunction cloneCandidate(candidate: DynamicGeometryCandidate): DynamicGeometryCandidate {\n return Object.freeze({ ...candidate, mesh: cloneMesh(candidate.mesh) });\n}\n\nfunction validateMesh(mesh: MeshAsset): string | undefined {\n if (mesh.kind !== 'mesh') return 'MeshAsset.kind must be mesh';\n if (!(mesh.vertices instanceof Float32Array) || mesh.vertices.length === 0) {\n return 'MeshAsset.vertices must be a non-empty Float32Array';\n }\n // vertices may be interleaved. Attribute layout validation belongs to the\n // mesh producer/residency path; this gate must not assume an xyz-only stride.\n if (\n mesh.indices !== undefined &&\n !(mesh.indices instanceof Uint16Array || mesh.indices instanceof Uint32Array)\n ) {\n return 'MeshAsset.indices must be Uint16Array or Uint32Array';\n }\n if (mesh.submeshes.length === 0)\n return 'MeshAsset.submeshes must contain at least one topology range';\n if (\n mesh.submeshes.some(\n (submesh) =>\n !Number.isSafeInteger(submesh.materialSlot) ||\n submesh.materialSlot < 0 ||\n submesh.materialSlot >= mesh.materialSlots.length,\n )\n ) {\n return 'MeshAsset.materialSlots must cover every referenced materialSlot';\n }\n if (mesh.vertices.some((value) => !Number.isFinite(value)))\n return 'MeshAsset.vertices must be finite';\n return undefined;\n}\n\nfunction meshByteSize(mesh: MeshAsset): number {\n let bytes = mesh.vertices.byteLength + (mesh.indices?.byteLength ?? 0);\n for (const value of Object.values(mesh.attributes)) {\n if (value instanceof ArrayBuffer) bytes += value.byteLength;\n else if (value !== undefined && ArrayBuffer.isView(value)) bytes += value.byteLength;\n }\n if (mesh.aabb !== undefined) bytes += mesh.aabb.byteLength;\n // Submesh/material metadata is intentionally bounded by the candidate\n // count. The reserved byte budget is for typed geometry and GPU upload\n // inputs, which are the resources that can exhaust the renderer.\n return bytes;\n}\n\n/**\n * Renderer-owned lifecycle for standard MeshAsset candidates. It deliberately\n * has no device, buffer, queue, or frame clock; the host supplies generation\n * and FrameReceipt facts at the boundaries below.\n */\nexport interface DynamicGeometryLifecycle {\n prepare(\n input: DynamicGeometryPrepareInput,\n generation: number,\n ): Result<DynamicGeometryCandidate, DynamicGeometryError>;\n accept(\n candidate: DynamicGeometryCandidate,\n ordering?: DynamicGeometryOrdering,\n ): Result<DynamicGeometryCandidate, DynamicGeometryError>;\n cancel(\n candidate: DynamicGeometryCandidate,\n completion?: Promise<unknown>,\n ): Result<void, DynamicGeometryError>;\n retire(candidate: DynamicGeometryCandidate): Result<void, DynamicGeometryError>;\n /** Release the count/byte budget after receipt-bound GPU cleanup completes. */\n finalizeRetirement(candidate: DynamicGeometryCandidate): Result<void, DynamicGeometryError>;\n receipt(candidate: DynamicGeometryCandidate): DynamicGeometryReceipt | undefined;\n publishFrame(\n frame: {\n readonly frameId: number;\n readonly deviceGeneration: number;\n readonly completed?: Promise<unknown>;\n },\n worlds?: readonly object[],\n fixedStep?: number,\n canPublish?: (candidate: DynamicGeometryCandidate) => boolean,\n ): readonly DynamicGeometryReceipt[];\n invalidateWorld(world: object, completion?: Promise<unknown>): void;\n invalidateGeneration(generation: number): void;\n inspect(): DynamicGeometryInspection;\n dispose(): void;\n}\n\nexport function createDynamicGeometryLifecycle(\n maxCandidates = 32,\n maxMeshBytes = 64 * 1024 * 1024,\n): DynamicGeometryLifecycle {\n const records = new Map<string, CandidateRecord>();\n const owner = {};\n let sequence = 0;\n let currentGeneration = 0;\n let disposed = false;\n let historyInvalidations = 0;\n let latestRevision: number | undefined;\n let latestFrameId: number | undefined;\n let retired = 0;\n let invalidated = 0;\n let meshBytes = 0;\n const latestRevisionByWorld = new WeakMap<object, Map<number | undefined, number>>();\n const latestTopologyRevisionByWorld = new WeakMap<object, Map<number | undefined, number>>();\n const publishedReceipts = new Map<string, DynamicGeometryReceipt>();\n\n const failure = (\n code: DynamicGeometryErrorCode,\n expected: string,\n hint: string,\n detail: Omit<DynamicGeometryErrorDetail, 'code'> = {},\n ): Result<never, DynamicGeometryError> =>\n err(new DynamicGeometryError(code, expected, hint, detail));\n\n const current = (candidate: DynamicGeometryCandidate): CandidateRecord | undefined => {\n const record = records.get(candidate.candidateId);\n if (\n record === undefined ||\n candidate.owner !== owner ||\n record.candidate.owner !== candidate.owner ||\n record.candidate.world !== candidate.world ||\n record.candidate.generation !== candidate.generation\n )\n return undefined;\n return record;\n };\n\n return {\n prepare(input, generation) {\n if (disposed)\n return failure('dynamic-geometry-disposed', 'renderer is alive', 'rebuild the Renderer');\n if (input.world === null || typeof input.world !== 'object') {\n return failure(\n 'dynamic-geometry-world-not-attached',\n 'candidate belongs to an attached World',\n 'attach the World before preparing geometry',\n );\n }\n if (!Number.isInteger(input.revision) || input.revision < 0) {\n return failure(\n 'dynamic-geometry-invalid',\n 'geometry revision is a non-negative integer',\n 'advance the consumer revision monotonically',\n { revision: input.revision },\n );\n }\n if (generation !== currentGeneration && currentGeneration !== 0) {\n return failure(\n 'dynamic-geometry-generation-mismatch',\n 'candidate uses the active renderer generation',\n 'discard stale generation work and prepare again',\n { generation, actual: currentGeneration },\n );\n }\n if (records.size >= maxCandidates) {\n return failure(\n 'dynamic-geometry-budget-exceeded',\n 'candidate count remains within the bounded renderer budget',\n 'cancel or retire an earlier candidate before retrying',\n { actual: records.size },\n );\n }\n const invalid = validateMesh(input.mesh);\n if (invalid !== undefined)\n return failure(\n 'dynamic-geometry-invalid',\n 'MeshAsset satisfies the standard geometry contract',\n invalid,\n );\n const candidateBytes = meshByteSize(input.mesh);\n if (\n !Number.isSafeInteger(candidateBytes) ||\n candidateBytes < 0 ||\n meshBytes > maxMeshBytes - candidateBytes\n ) {\n return failure(\n 'dynamic-geometry-budget-exceeded',\n 'candidate mesh bytes remain within the bounded renderer resource budget',\n 'cancel or retire an earlier candidate before retrying',\n { actual: { meshBytes, candidateBytes, maxMeshBytes } },\n );\n }\n const candidateId = `mesh:${generation}:${++sequence}:${input.revision}`;\n const candidate: DynamicGeometryCandidate = Object.freeze({\n candidateId,\n generation,\n owner,\n world: input.world,\n ...(input.entity === undefined ? {} : { entity: input.entity }),\n ...(input.physicsEntity === undefined ? {} : { physicsEntity: input.physicsEntity }),\n gpuReady: input.meshHandle !== undefined,\n meshBytes: candidateBytes,\n revision: input.revision,\n topologyRevision: input.topologyRevision ?? input.revision,\n ...(input.materialIdentity === undefined\n ? {}\n : { materialIdentity: input.materialIdentity }),\n ...(input.meshHandle === undefined ? {} : { meshHandle: input.meshHandle }),\n ...(input.fixedStep === undefined ? {} : { fixedStep: input.fixedStep }),\n mesh: cloneMesh(input.mesh),\n state: 'prepared',\n });\n records.set(candidateId, {\n world: input.world,\n candidate,\n historyInvalidated: false,\n });\n meshBytes += candidateBytes;\n currentGeneration = generation;\n // Keep the credential handed to the consumer separate from the\n // renderer-owned copy. Mesh typed arrays remain mutable at runtime even\n // when exposed through a readonly TypeScript field.\n return ok(cloneCandidate(candidate));\n },\n accept(candidate, ordering) {\n if (disposed)\n return failure('dynamic-geometry-disposed', 'renderer is alive', 'rebuild the Renderer');\n const record = current(candidate);\n if (record === undefined)\n return failure(\n 'dynamic-geometry-candidate-not-found',\n 'candidate is owned by this renderer',\n 'discard the stale credential',\n );\n if (candidate.generation !== currentGeneration) {\n return failure(\n 'dynamic-geometry-generation-mismatch',\n 'candidate generation matches the active renderer generation',\n 'prepare against the current renderer generation',\n { candidateId: candidate.candidateId },\n );\n }\n if (record.candidate.state !== 'prepared') {\n return failure(\n 'dynamic-geometry-candidate-state',\n 'candidate is prepared exactly once before acceptance',\n 'retain the accepted or published receipt',\n { candidateId: candidate.candidateId },\n );\n }\n if (!sameCandidateCredential(candidate, record.candidate)) {\n return failure(\n 'dynamic-geometry-receipt-mismatch',\n 'acceptance uses the exact prepared candidate credential',\n 'discard the altered credential and use the value returned by prepare',\n { candidateId: candidate.candidateId },\n );\n }\n if (ordering !== undefined) {\n if (\n ordering.world !== record.world ||\n !Number.isInteger(ordering.fixedStep) ||\n ordering.fixedStep < 0\n ) {\n return failure(\n 'dynamic-geometry-ordering-required',\n 'acceptance ordering names the candidate World and a non-negative fixed step',\n 'submit the PhysicsWorld publication ordering for the same attached World',\n { candidateId: candidate.candidateId, actual: ordering },\n );\n }\n }\n const newest = [...records.values()]\n .filter(\n (entry) =>\n entry.candidate.candidateId !== candidate.candidateId &&\n entry.world === record.world &&\n entry.candidate.entity === record.candidate.entity &&\n (entry.candidate.state === 'prepared' || entry.candidate.state === 'accepted'),\n )\n .map((entry) => entry.candidate.revision)\n .concat(latestRevisionByWorld.get(record.world)?.get(record.candidate.entity) ?? -1)\n .sort((a, b) => b - a)[0];\n if (newest !== undefined && record.candidate.revision <= newest) {\n return failure(\n 'dynamic-geometry-stale',\n 'accepted geometry revision is newer than the active candidate',\n 'advance topology revision before accepting',\n { candidateId: candidate.candidateId },\n );\n }\n const accepted = Object.freeze({\n ...record.candidate,\n ...(ordering === undefined ? {} : { fixedStep: ordering.fixedStep }),\n state: 'accepted' as const,\n });\n const previousTopologies = [...records.values()]\n .filter(\n (entry) =>\n entry.candidate.candidateId !== candidate.candidateId &&\n entry.world === record.world &&\n entry.candidate.entity === record.candidate.entity,\n )\n .map((entry) => entry.candidate.topologyRevision);\n const previousLatestTopology = latestTopologyRevisionByWorld\n .get(record.world)\n ?.get(record.candidate.entity);\n const newestTopology = previousTopologies\n .concat(previousLatestTopology === undefined ? [] : [previousLatestTopology])\n .sort((a, b) => b - a)[0];\n if (newestTopology !== undefined && accepted.topologyRevision < newestTopology) {\n return failure(\n 'dynamic-geometry-stale',\n 'accepted topology revision is not older than the active geometry history',\n 'advance topology revision before accepting a replacement candidate',\n { candidateId: candidate.candidateId },\n );\n }\n if (newestTopology !== undefined && accepted.topologyRevision > newestTopology) {\n historyInvalidations += 1;\n // Invalidate publication eligibility, not resource ownership. The host\n // cancels superseded candidates with their allocation completion fence.\n for (const previous of records.values()) {\n if (\n previous.world !== record.world ||\n previous.candidate.entity !== record.candidate.entity ||\n previous.candidate.candidateId === candidate.candidateId ||\n previous.candidate.topologyRevision >= accepted.topologyRevision\n )\n continue;\n if (!previous.historyInvalidated) {\n previous.historyInvalidated = true;\n invalidated += 1;\n }\n }\n }\n record.candidate = accepted;\n return ok(cloneCandidate(accepted));\n },\n cancel(candidate, completion) {\n const record = current(candidate);\n if (record === undefined)\n return failure(\n 'dynamic-geometry-candidate-not-found',\n 'candidate is owned by this renderer',\n 'discard the stale credential',\n );\n if (!sameCandidateCredential(candidate, record.candidate))\n return failure(\n 'dynamic-geometry-receipt-mismatch',\n 'cancellation uses the exact prepared candidate credential',\n 'discard the altered credential and use the value returned by prepare',\n { candidateId: candidate.candidateId },\n );\n if (record.candidate.state !== 'prepared' && record.candidate.state !== 'accepted') {\n return failure(\n 'dynamic-geometry-candidate-state',\n 'only prepared or accepted geometry can be cancelled once',\n 'retire published geometry or await the existing terminal cleanup',\n );\n }\n record.candidate = Object.freeze({ ...record.candidate, state: 'cancelled' as const });\n const release = (): void => {\n if (records.get(candidate.candidateId) !== record) return;\n records.delete(candidate.candidateId);\n meshBytes = Math.max(0, meshBytes - record.candidate.meshBytes);\n };\n if (completion === undefined) release();\n else void completion.then(release, release);\n return ok(undefined);\n },\n retire(candidate) {\n const record = current(candidate);\n if (record === undefined)\n return failure(\n 'dynamic-geometry-candidate-not-found',\n 'retirement uses a published candidate owned by this renderer',\n 'discard the stale credential and do not evict any unrelated mesh',\n { candidateId: candidate.candidateId },\n );\n if (!sameCandidateCredential(candidate, record.candidate))\n return failure(\n 'dynamic-geometry-receipt-mismatch',\n 'retirement uses the exact published candidate credential',\n 'discard the altered credential and use the value returned by publish',\n { candidateId: candidate.candidateId },\n );\n if (record.candidate.state !== 'published') {\n return failure(\n 'dynamic-geometry-candidate-state',\n 'only published geometry can enter receipt-bound retirement',\n 'publish the candidate from a submitted frame first',\n );\n }\n record.candidate = Object.freeze({ ...record.candidate, state: 'retired' as const });\n publishedReceipts.delete(candidate.candidateId);\n retired += 1;\n // Retiring is the logical state transition. Keep the candidate record\n // and its typed bytes until the owner calls `finalizeRetirement` after\n // every record-stage completion fence and GPU lease are gone. This is\n // what makes the declared count/byte budget include in-flight work.\n return ok(undefined);\n },\n finalizeRetirement(candidate) {\n const record = current(candidate);\n if (record === undefined)\n return failure(\n 'dynamic-geometry-candidate-not-found',\n 'retirement finalization uses a candidate retained by this lifecycle',\n 'discard the stale credential or finish the current receipt-bound retirement',\n );\n if (!sameCandidateCredential(candidate, record.candidate))\n return failure(\n 'dynamic-geometry-receipt-mismatch',\n 'retirement finalization uses the exact published candidate credential',\n 'discard the altered credential and use the value returned by publication',\n { candidateId: candidate.candidateId },\n );\n if (record.candidate.state !== 'retired')\n return failure(\n 'dynamic-geometry-candidate-state',\n 'only a retired candidate can release its deferred budget',\n 'retire the published candidate before finalizing its receipt-bound cleanup',\n { candidateId: candidate.candidateId },\n );\n records.delete(candidate.candidateId);\n meshBytes = Math.max(0, meshBytes - record.candidate.meshBytes);\n return ok(undefined);\n },\n publishFrame(frame, worlds, fixedStep, canPublish) {\n if (disposed || frame.deviceGeneration !== currentGeneration) return [];\n const receipts: DynamicGeometryReceipt[] = [];\n for (const record of records.values()) {\n const canRepeatPublished =\n record.candidate.state === 'published' &&\n // Attached Renderer publication revalidates the entity binding in\n // `canPublish`, so a history-invalidated candidate can still record\n // a real draw for its live entity. Detached lifecycle publication\n // remains one-shot once that history is invalidated.\n (canPublish !== undefined || !record.historyInvalidated);\n if (record.candidate.state !== 'accepted' && !canRepeatPublished) continue;\n if (worlds !== undefined && !worlds.includes(record.world)) continue;\n if (\n record.candidate.fixedStep !== undefined &&\n (fixedStep === undefined || record.candidate.fixedStep > fixedStep)\n ) {\n continue;\n }\n if (canPublish !== undefined && !canPublish(record.candidate)) continue;\n record.candidate = Object.freeze({ ...record.candidate, state: 'published' as const });\n const receipt = Object.freeze({\n candidateId: record.candidate.candidateId,\n generation: record.candidate.generation,\n revision: record.candidate.revision,\n topologyRevision: record.candidate.topologyRevision,\n ...(record.candidate.fixedStep === undefined\n ? {}\n : { fixedStep: record.candidate.fixedStep }),\n frameId: frame.frameId,\n deviceGeneration: frame.deviceGeneration,\n recordStageConsumed: canPublish !== undefined,\n ...(fixedStep === undefined ? {} : { publicationFixedStep: fixedStep }),\n frame: Object.freeze({ ...frame }),\n });\n receipts.push(receipt);\n publishedReceipts.set(record.candidate.candidateId, receipt);\n latestRevision = record.candidate.revision;\n latestFrameId = frame.frameId;\n if (!latestRevisionByWorld.has(record.world))\n latestRevisionByWorld.set(record.world, new Map());\n latestRevisionByWorld\n .get(record.world)\n ?.set(record.candidate.entity, record.candidate.revision);\n if (!latestTopologyRevisionByWorld.has(record.world))\n latestTopologyRevisionByWorld.set(record.world, new Map());\n latestTopologyRevisionByWorld\n .get(record.world)\n ?.set(record.candidate.entity, record.candidate.topologyRevision);\n }\n return receipts;\n },\n invalidateWorld(world, completion) {\n for (const [id, record] of records) {\n if (record.world !== world) continue;\n // An earlier terminal operation already owns this reservation's fence.\n if (record.candidate.state === 'cancelled' || record.candidate.state === 'retired')\n continue;\n publishedReceipts.delete(id);\n record.candidate = Object.freeze({ ...record.candidate, state: 'cancelled' as const });\n const release = (): void => {\n if (records.get(id) !== record) return;\n records.delete(id);\n meshBytes = Math.max(0, meshBytes - record.candidate.meshBytes);\n };\n if (completion === undefined) release();\n else void completion.then(release, release);\n invalidated += 1;\n }\n latestRevisionByWorld.delete(world);\n latestTopologyRevisionByWorld.delete(world);\n },\n invalidateGeneration(generation) {\n if (generation === currentGeneration) return;\n currentGeneration = generation;\n const invalidatedWorlds = new Set<object>();\n for (const [id, record] of records) {\n if (record.candidate.generation !== generation) {\n records.delete(id);\n publishedReceipts.delete(id);\n meshBytes = Math.max(0, meshBytes - record.candidate.meshBytes);\n invalidatedWorlds.add(record.world);\n invalidated += 1;\n }\n }\n for (const world of invalidatedWorlds) {\n latestRevisionByWorld.delete(world);\n latestTopologyRevisionByWorld.delete(world);\n }\n },\n receipt(candidate) {\n const receipt = publishedReceipts.get(candidate.candidateId);\n const record = records.get(candidate.candidateId);\n if (record === undefined || !sameCandidateCredential(candidate, record.candidate)) {\n return undefined;\n }\n return receipt?.generation === candidate.generation ? receipt : undefined;\n },\n inspect() {\n let prepared = 0;\n let accepted = 0;\n let published = 0;\n for (const record of records.values()) {\n if (record.candidate.state === 'prepared') prepared += 1;\n else if (record.candidate.state === 'accepted') accepted += 1;\n else if (record.candidate.state === 'published') published += 1;\n }\n return Object.freeze({\n generation: currentGeneration,\n prepared,\n accepted,\n published,\n retired,\n ...(latestRevision === undefined ? {} : { latestRevision }),\n ...(latestFrameId === undefined ? {} : { latestFrameId }),\n historyInvalidations,\n invalidated,\n meshBytes,\n maxMeshBytes,\n });\n },\n dispose() {\n disposed = true;\n records.clear();\n publishedReceipts.clear();\n meshBytes = 0;\n },\n };\n}\n"]}
|