@automovie/ingest 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -2
  3. package/lib/AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.d.ts +5 -0
  4. package/lib/AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.js +8 -0
  5. package/lib/AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.js.map +1 -0
  6. package/lib/AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.d.ts +5 -0
  7. package/lib/AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.js +15 -0
  8. package/lib/AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.js.map +1 -0
  9. package/lib/AutoMovieExternalModelIngestProfile.d.ts +11 -0
  10. package/lib/AutoMovieExternalModelIngestProfile.js +3 -0
  11. package/lib/AutoMovieExternalModelIngestProfile.js.map +1 -0
  12. package/lib/AutoMovieExternalMotionAdoptionDecision.d.ts +11 -0
  13. package/lib/AutoMovieExternalMotionAdoptionDecision.js +3 -0
  14. package/lib/AutoMovieExternalMotionAdoptionDecision.js.map +1 -0
  15. package/lib/AutoMovieGltfMotionInterpretationProfile.d.ts +9 -0
  16. package/lib/AutoMovieGltfMotionInterpretationProfile.js +3 -0
  17. package/lib/AutoMovieGltfMotionInterpretationProfile.js.map +1 -0
  18. package/lib/IAutoMovieExternalModelInspection.d.ts +48 -0
  19. package/lib/IAutoMovieExternalModelInspection.js +3 -0
  20. package/lib/IAutoMovieExternalModelInspection.js.map +1 -0
  21. package/lib/IAutoMovieExternalModelResource.d.ts +18 -0
  22. package/lib/IAutoMovieExternalModelResource.js +3 -0
  23. package/lib/IAutoMovieExternalModelResource.js.map +1 -0
  24. package/lib/IAutoMovieExternalMotionAdoption.d.ts +23 -0
  25. package/lib/IAutoMovieExternalMotionAdoption.js +3 -0
  26. package/lib/IAutoMovieExternalMotionAdoption.js.map +1 -0
  27. package/lib/IAutoMovieExternalMotionBoneMapping.d.ts +15 -0
  28. package/lib/IAutoMovieExternalMotionBoneMapping.js +3 -0
  29. package/lib/IAutoMovieExternalMotionBoneMapping.js.map +1 -0
  30. package/lib/IAutoMovieExternalMotionInspection.d.ts +25 -0
  31. package/lib/IAutoMovieExternalMotionInspection.js +3 -0
  32. package/lib/IAutoMovieExternalMotionInspection.js.map +1 -0
  33. package/lib/IAutoMovieExternalMotionNativeDecision.d.ts +20 -0
  34. package/lib/IAutoMovieExternalMotionNativeDecision.js +3 -0
  35. package/lib/IAutoMovieExternalMotionNativeDecision.js.map +1 -0
  36. package/lib/IAutoMovieExternalMotionNativeHandoff.d.ts +18 -0
  37. package/lib/IAutoMovieExternalMotionNativeHandoff.js +3 -0
  38. package/lib/IAutoMovieExternalMotionNativeHandoff.js.map +1 -0
  39. package/lib/IAutoMovieExternalMotionNodeInspection.d.ts +21 -0
  40. package/lib/IAutoMovieExternalMotionNodeInspection.js +3 -0
  41. package/lib/IAutoMovieExternalMotionNodeInspection.js.map +1 -0
  42. package/lib/IAutoMovieExternalMotionRetargetDecision.d.ts +24 -0
  43. package/lib/IAutoMovieExternalMotionRetargetDecision.js +3 -0
  44. package/lib/IAutoMovieExternalMotionRetargetDecision.js.map +1 -0
  45. package/lib/IAutoMovieExternalMotionRetargetHandoff.d.ts +22 -0
  46. package/lib/IAutoMovieExternalMotionRetargetHandoff.js +3 -0
  47. package/lib/IAutoMovieExternalMotionRetargetHandoff.js.map +1 -0
  48. package/lib/IAutoMovieExternalMotionSource.d.ts +18 -0
  49. package/lib/IAutoMovieExternalMotionSource.js +3 -0
  50. package/lib/IAutoMovieExternalMotionSource.js.map +1 -0
  51. package/lib/IAutoMovieIngestResult.d.ts +17 -0
  52. package/lib/IAutoMovieIngestResult.js +3 -0
  53. package/lib/IAutoMovieIngestResult.js.map +1 -0
  54. package/lib/adoptAutoMovieExternalMotion.d.ts +32 -0
  55. package/lib/adoptAutoMovieExternalMotion.js +215 -0
  56. package/lib/adoptAutoMovieExternalMotion.js.map +1 -0
  57. package/lib/audio/IAutoMovieDecodedProductionAudioAsset.d.ts +28 -0
  58. package/lib/audio/IAutoMovieDecodedProductionAudioAsset.js +3 -0
  59. package/lib/audio/IAutoMovieDecodedProductionAudioAsset.js.map +1 -0
  60. package/lib/audio/IAutoMovieProductionAudioProcessing.d.ts +18 -0
  61. package/lib/audio/IAutoMovieProductionAudioProcessing.js +3 -0
  62. package/lib/audio/IAutoMovieProductionAudioProcessing.js.map +1 -0
  63. package/lib/audio/IAutoMovieProductionWaveSourceFormat.d.ts +39 -0
  64. package/lib/audio/IAutoMovieProductionWaveSourceFormat.js +3 -0
  65. package/lib/audio/IAutoMovieProductionWaveSourceFormat.js.map +1 -0
  66. package/lib/audio/decodeProductionAudioAsset.d.ts +33 -0
  67. package/lib/audio/decodeProductionAudioAsset.js +257 -0
  68. package/lib/audio/decodeProductionAudioAsset.js.map +1 -0
  69. package/lib/audio/index.d.ts +4 -0
  70. package/lib/audio/index.js +21 -0
  71. package/lib/audio/index.js.map +1 -0
  72. package/lib/decodeAutoMoviePpmImage.d.ts +30 -0
  73. package/lib/decodeAutoMoviePpmImage.js +84 -0
  74. package/lib/decodeAutoMoviePpmImage.js.map +1 -0
  75. package/lib/humanoidSkeleton.d.ts +24 -0
  76. package/lib/humanoidSkeleton.js +80 -0
  77. package/lib/humanoidSkeleton.js.map +1 -0
  78. package/lib/index.d.ts +23 -0
  79. package/lib/index.js +40 -0
  80. package/lib/index.js.map +1 -0
  81. package/lib/ingestDocument.d.ts +23 -0
  82. package/lib/ingestDocument.js +173 -0
  83. package/lib/ingestDocument.js.map +1 -0
  84. package/lib/inspectAutoMovieExternalModelBytes.d.ts +32 -0
  85. package/lib/inspectAutoMovieExternalModelBytes.js +219 -0
  86. package/lib/inspectAutoMovieExternalModelBytes.js.map +1 -0
  87. package/lib/internal/COMPONENT_BYTES.d.ts +2 -0
  88. package/lib/internal/COMPONENT_BYTES.js +13 -0
  89. package/lib/internal/COMPONENT_BYTES.js.map +1 -0
  90. package/lib/internal/IAccessorSource.d.ts +16 -0
  91. package/lib/internal/IAccessorSource.js +3 -0
  92. package/lib/internal/IAccessorSource.js.map +1 -0
  93. package/lib/internal/IExternalModelAccessorReader.d.ts +9 -0
  94. package/lib/internal/IExternalModelAccessorReader.js +3 -0
  95. package/lib/internal/IExternalModelAccessorReader.js.map +1 -0
  96. package/lib/internal/IHumanoidSlot.d.ts +15 -0
  97. package/lib/internal/IHumanoidSlot.js +3 -0
  98. package/lib/internal/IHumanoidSlot.js.map +1 -0
  99. package/lib/internal/IParsedContainer.d.ts +16 -0
  100. package/lib/internal/IParsedContainer.js +3 -0
  101. package/lib/internal/IParsedContainer.js.map +1 -0
  102. package/lib/internal/SHAPE_COMPONENTS.d.ts +6 -0
  103. package/lib/internal/SHAPE_COMPONENTS.js +25 -0
  104. package/lib/internal/SHAPE_COMPONENTS.js.map +1 -0
  105. package/lib/internal/accessorElementByteLength.d.ts +12 -0
  106. package/lib/internal/accessorElementByteLength.js +28 -0
  107. package/lib/internal/accessorElementByteLength.js.map +1 -0
  108. package/lib/internal/accessorReader.d.ts +16 -0
  109. package/lib/internal/accessorReader.js +52 -0
  110. package/lib/internal/accessorReader.js.map +1 -0
  111. package/lib/internal/accessorValues.d.ts +18 -0
  112. package/lib/internal/accessorValues.js +38 -0
  113. package/lib/internal/accessorValues.js.map +1 -0
  114. package/lib/internal/collectExternalResources.d.ts +13 -0
  115. package/lib/internal/collectExternalResources.js +51 -0
  116. package/lib/internal/collectExternalResources.js.map +1 -0
  117. package/lib/internal/compareCodeUnits.d.ts +12 -0
  118. package/lib/internal/compareCodeUnits.js +17 -0
  119. package/lib/internal/compareCodeUnits.js.map +1 -0
  120. package/lib/internal/composeLocalTransform.d.ts +21 -0
  121. package/lib/internal/composeLocalTransform.js +53 -0
  122. package/lib/internal/composeLocalTransform.js.map +1 -0
  123. package/lib/internal/decodeDataUri.d.ts +14 -0
  124. package/lib/internal/decodeDataUri.js +61 -0
  125. package/lib/internal/decodeDataUri.js.map +1 -0
  126. package/lib/internal/decodeGlb.d.ts +13 -0
  127. package/lib/internal/decodeGlb.js +56 -0
  128. package/lib/internal/decodeGlb.js.map +1 -0
  129. package/lib/internal/decodeJson.d.ts +12 -0
  130. package/lib/internal/decodeJson.js +77 -0
  131. package/lib/internal/decodeJson.js.map +1 -0
  132. package/lib/internal/fileExtension.d.ts +12 -0
  133. package/lib/internal/fileExtension.js +21 -0
  134. package/lib/internal/fileExtension.js.map +1 -0
  135. package/lib/internal/finiteTuple.d.ts +14 -0
  136. package/lib/internal/finiteTuple.js +29 -0
  137. package/lib/internal/finiteTuple.js.map +1 -0
  138. package/lib/internal/gltfHumanoidBones.d.ts +15 -0
  139. package/lib/internal/gltfHumanoidBones.js +39 -0
  140. package/lib/internal/gltfHumanoidBones.js.map +1 -0
  141. package/lib/internal/humanoidBoneOfName.d.ts +18 -0
  142. package/lib/internal/humanoidBoneOfName.js +67 -0
  143. package/lib/internal/humanoidBoneOfName.js.map +1 -0
  144. package/lib/internal/inspectExternalModelHierarchy.d.ts +12 -0
  145. package/lib/internal/inspectExternalModelHierarchy.js +51 -0
  146. package/lib/internal/inspectExternalModelHierarchy.js.map +1 -0
  147. package/lib/internal/inspectExternalMotion.d.ts +23 -0
  148. package/lib/internal/inspectExternalMotion.js +152 -0
  149. package/lib/internal/inspectExternalMotion.js.map +1 -0
  150. package/lib/internal/inspectExternalMotionNodes.d.ts +15 -0
  151. package/lib/internal/inspectExternalMotionNodes.js +58 -0
  152. package/lib/internal/inspectExternalMotionNodes.js.map +1 -0
  153. package/lib/internal/integerIndex.d.ts +12 -0
  154. package/lib/internal/integerIndex.js +23 -0
  155. package/lib/internal/integerIndex.js.map +1 -0
  156. package/lib/internal/integerIndices.d.ts +12 -0
  157. package/lib/internal/integerIndices.js +23 -0
  158. package/lib/internal/integerIndices.js.map +1 -0
  159. package/lib/internal/nonNegativeInteger.d.ts +12 -0
  160. package/lib/internal/nonNegativeInteger.js +22 -0
  161. package/lib/internal/nonNegativeInteger.js.map +1 -0
  162. package/lib/internal/object.d.ts +12 -0
  163. package/lib/internal/object.js +21 -0
  164. package/lib/internal/object.js.map +1 -0
  165. package/lib/internal/optionalArray.d.ts +12 -0
  166. package/lib/internal/optionalArray.js +18 -0
  167. package/lib/internal/optionalArray.js.map +1 -0
  168. package/lib/internal/optionalObject.d.ts +12 -0
  169. package/lib/internal/optionalObject.js +18 -0
  170. package/lib/internal/optionalObject.js.map +1 -0
  171. package/lib/internal/optionalStringArray.d.ts +12 -0
  172. package/lib/internal/optionalStringArray.js +22 -0
  173. package/lib/internal/optionalStringArray.js.map +1 -0
  174. package/lib/internal/positiveInteger.d.ts +12 -0
  175. package/lib/internal/positiveInteger.js +22 -0
  176. package/lib/internal/positiveInteger.js.map +1 -0
  177. package/lib/internal/readMotionAccessor.d.ts +15 -0
  178. package/lib/internal/readMotionAccessor.js +41 -0
  179. package/lib/internal/readMotionAccessor.js.map +1 -0
  180. package/lib/internal/requiredArray.d.ts +12 -0
  181. package/lib/internal/requiredArray.js +21 -0
  182. package/lib/internal/requiredArray.js.map +1 -0
  183. package/lib/internal/uniqueStrings.d.ts +12 -0
  184. package/lib/internal/uniqueStrings.js +18 -0
  185. package/lib/internal/uniqueStrings.js.map +1 -0
  186. package/lib/internal/validNodeIndex.d.ts +12 -0
  187. package/lib/internal/validNodeIndex.js +20 -0
  188. package/lib/internal/validNodeIndex.js.map +1 -0
  189. package/lib/internal/validateAccessorRange.d.ts +14 -0
  190. package/lib/internal/validateAccessorRange.js +37 -0
  191. package/lib/internal/validateAccessorRange.js.map +1 -0
  192. package/lib/internal/validateHumanoidSkinning.d.ts +20 -0
  193. package/lib/internal/validateHumanoidSkinning.js +91 -0
  194. package/lib/internal/validateHumanoidSkinning.js.map +1 -0
  195. package/lib/internal/validatePayloadClosure.d.ts +21 -0
  196. package/lib/internal/validatePayloadClosure.js +74 -0
  197. package/lib/internal/validatePayloadClosure.js.map +1 -0
  198. package/lib/internal/validateSparseAccessor.d.ts +14 -0
  199. package/lib/internal/validateSparseAccessor.js +50 -0
  200. package/lib/internal/validateSparseAccessor.js.map +1 -0
  201. package/lib/internal/vrmHumanoidBones.d.ts +15 -0
  202. package/lib/internal/vrmHumanoidBones.js +132 -0
  203. package/lib/internal/vrmHumanoidBones.js.map +1 -0
  204. package/lib/isAutoMovieExternalModelIngestProfile.d.ts +18 -0
  205. package/lib/isAutoMovieExternalModelIngestProfile.js +24 -0
  206. package/lib/isAutoMovieExternalModelIngestProfile.js.map +1 -0
  207. package/package.json +45 -3
  208. package/src/AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.ts +7 -0
  209. package/src/AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.ts +21 -0
  210. package/src/AutoMovieExternalModelIngestProfile.ts +15 -0
  211. package/src/AutoMovieExternalMotionAdoptionDecision.ts +14 -0
  212. package/src/AutoMovieGltfMotionInterpretationProfile.ts +10 -0
  213. package/src/IAutoMovieExternalModelInspection.ts +62 -0
  214. package/src/IAutoMovieExternalModelResource.ts +20 -0
  215. package/src/IAutoMovieExternalMotionAdoption.ts +30 -0
  216. package/src/IAutoMovieExternalMotionBoneMapping.ts +17 -0
  217. package/src/IAutoMovieExternalMotionInspection.ts +32 -0
  218. package/src/IAutoMovieExternalMotionNativeDecision.ts +25 -0
  219. package/src/IAutoMovieExternalMotionNativeHandoff.ts +22 -0
  220. package/src/IAutoMovieExternalMotionNodeInspection.ts +26 -0
  221. package/src/IAutoMovieExternalMotionRetargetDecision.ts +31 -0
  222. package/src/IAutoMovieExternalMotionRetargetHandoff.ts +28 -0
  223. package/src/IAutoMovieExternalMotionSource.ts +20 -0
  224. package/src/IAutoMovieIngestResult.ts +19 -0
  225. package/src/adoptAutoMovieExternalMotion.ts +387 -0
  226. package/src/audio/IAutoMovieDecodedProductionAudioAsset.ts +35 -0
  227. package/src/audio/IAutoMovieProductionAudioProcessing.ts +21 -0
  228. package/src/audio/IAutoMovieProductionWaveSourceFormat.ts +50 -0
  229. package/src/audio/decodeProductionAudioAsset.ts +451 -0
  230. package/src/audio/index.ts +4 -0
  231. package/src/decodeAutoMoviePpmImage.ts +103 -0
  232. package/src/humanoidSkeleton.ts +105 -0
  233. package/src/index.ts +23 -0
  234. package/src/ingestDocument.ts +242 -0
  235. package/src/inspectAutoMovieExternalModelBytes.ts +346 -0
  236. package/src/internal/COMPONENT_BYTES.ts +12 -0
  237. package/src/internal/IAccessorSource.ts +18 -0
  238. package/src/internal/IExternalModelAccessorReader.ts +12 -0
  239. package/src/internal/IHumanoidSlot.ts +17 -0
  240. package/src/internal/IParsedContainer.ts +18 -0
  241. package/src/internal/SHAPE_COMPONENTS.ts +27 -0
  242. package/src/internal/accessorElementByteLength.ts +24 -0
  243. package/src/internal/accessorReader.ts +76 -0
  244. package/src/internal/accessorValues.ts +35 -0
  245. package/src/internal/collectExternalResources.ts +69 -0
  246. package/src/internal/compareCodeUnits.ts +15 -0
  247. package/src/internal/composeLocalTransform.ts +56 -0
  248. package/src/internal/decodeDataUri.ts +70 -0
  249. package/src/internal/decodeGlb.ts +70 -0
  250. package/src/internal/decodeJson.ts +76 -0
  251. package/src/internal/fileExtension.ts +18 -0
  252. package/src/internal/finiteTuple.ts +33 -0
  253. package/src/internal/gltfHumanoidBones.ts +48 -0
  254. package/src/internal/humanoidBoneOfName.ts +75 -0
  255. package/src/internal/inspectExternalModelHierarchy.ts +61 -0
  256. package/src/internal/inspectExternalMotion.ts +292 -0
  257. package/src/internal/inspectExternalMotionNodes.ts +81 -0
  258. package/src/internal/integerIndex.ts +28 -0
  259. package/src/internal/integerIndices.ts +24 -0
  260. package/src/internal/nonNegativeInteger.ts +22 -0
  261. package/src/internal/object.ts +22 -0
  262. package/src/internal/optionalArray.ts +17 -0
  263. package/src/internal/optionalObject.ts +20 -0
  264. package/src/internal/optionalStringArray.ts +22 -0
  265. package/src/internal/positiveInteger.ts +22 -0
  266. package/src/internal/readMotionAccessor.ts +60 -0
  267. package/src/internal/requiredArray.ts +19 -0
  268. package/src/internal/uniqueStrings.ts +16 -0
  269. package/src/internal/validNodeIndex.ts +19 -0
  270. package/src/internal/validateAccessorRange.ts +53 -0
  271. package/src/internal/validateHumanoidSkinning.ts +152 -0
  272. package/src/internal/validatePayloadClosure.ts +116 -0
  273. package/src/internal/validateSparseAccessor.ts +109 -0
  274. package/src/internal/vrmHumanoidBones.ts +176 -0
  275. package/src/isAutoMovieExternalModelIngestProfile.ts +28 -0
@@ -0,0 +1,32 @@
1
+ import type { AutoMovieExternalMotionAdoptionDecision } from "./AutoMovieExternalMotionAdoptionDecision";
2
+ import type { IAutoMovieExternalModelInspection } from "./IAutoMovieExternalModelInspection";
3
+ import type { IAutoMovieExternalMotionAdoption } from "./IAutoMovieExternalMotionAdoption";
4
+ import type { IAutoMovieExternalMotionSource } from "./IAutoMovieExternalMotionSource";
5
+ /**
6
+ * Select one inspected take and validate the author's native or retarget decision without fetching bytes, choosing a provider or inferring a rig.
7
+ *
8
+ * The inspection must come from the `gltf-motion-v1` profile under the glTF meter, right-handed, Y-up interpretation, and the source must repeat its path and byte length with a lowercase SHA-256 digest. Every track of the selected take must target a mapped node, translation only on the node mapped to `hips`, and never scale or weights, because humanoid motion carries neither. Each mapped bone's parent and rest in the declared source rig must equal what the inspected hierarchy implies: the nearest mapped ancestor and the node's local TRS composed through every unmapped helper between them. The comparison is exact, so an author computes the rest from the inspected transforms rather than retyping rounded values. The first violation throws with the field it concerns.
9
+ *
10
+ * The caller supplies an unmodified inspector result and binds the digest to the resident bytes; adoption checks digest spelling, not a hash. Rig admission here requires a non-blank id, unique bone names and `hips`, but basis comparisons cover only mapped bones and do not validate constraints or unmapped rests. Helper TRS composition follows fixed floating-point arithmetic and drops shear when a helper's non-uniform scale does not commute with a child rotation; exact agreement proves agreement with that representation, not exact affine geometry.
11
+ *
12
+ * @param props.inspection Inspection of the exact source bytes.
13
+ * @param props.source Manifest identity of those bytes.
14
+ * @param props.decision The author's use of one take.
15
+ * @returns A receipt that shares no objects with its inputs.
16
+ *
17
+ * @evidence contracts/development/implementation.md#principled-implementation Path and byte length compare with caller-supplied inspected facts, while the digest is checked only for spelling. Sets establish mapping uniqueness, and each mapped basis is recomputed by nearest-mapped-ancestor walks and fixed-order `composeLocalTransform` arithmetic; binary64 rounding and discarded shear remain, and constraints and unmapped rests receive no basis check.
18
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Identity/selection, rig binding and retarget-only fields have separate local owners; humanoid import shares transform composition and the engine validation owner supplies the common SHA-256 spelling predicate.
19
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No take, rig, bone or path is special-cased; the runtime mode check exists for untyped callers, and the digest regular expression is the manifest's documented `sha256:` format rather than a fixture value.
20
+ * @evidence contracts/development/common.md#meaningful-documentation The documentation distinguishes digest spelling from byte authentication, mapped-basis checks from complete rig admission, and exact arithmetic agreement from affine exactness; it also gives supported channels, first-refusal behavior and ownership of receipt copies.
21
+ * @evidence contracts/development/implementation.md#efficient-algorithms Copy cost follows the selected take's tracks/keyframes and source-rig size; hash-map setup follows the mapping and node counts. Mapping size M adds O(M log M) prefix-scanning node-id comparisons plus text-dependent identity/hash work; mapped bones times helper-chain lengths drive basis walks, and take lookup scans the declared take inventory without an assumed population bound.
22
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Adoption validates one decision against one inspection per call and shares no work across calls; the inspection it reads is already the caller's reused result.
23
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The temporary maps and sets die with the call; the receipt retains copies of the take, rig and mapping proportional to their size and is owned by the caller, with no handle or task.
24
+ */
25
+ export declare const adoptAutoMovieExternalMotion: (props: {
26
+ /** Unmodified result of inspecting the source's exact resident bytes. */
27
+ inspection: IAutoMovieExternalModelInspection;
28
+ /** Manifest identity whose digest-to-byte binding the caller establishes. */
29
+ source: IAutoMovieExternalMotionSource;
30
+ /** Explicit take, rig and mapping, with retarget fields in retarget mode. */
31
+ decision: AutoMovieExternalMotionAdoptionDecision;
32
+ }) => IAutoMovieExternalMotionAdoption;
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.adoptAutoMovieExternalMotion = void 0;
4
+ const engine_1 = require("@automovie/engine");
5
+ const AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE_1 = require("./AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE");
6
+ const compareCodeUnits_1 = require("./internal/compareCodeUnits");
7
+ const composeLocalTransform_1 = require("./internal/composeLocalTransform");
8
+ /**
9
+ * Select one inspected take and validate the author's native or retarget decision without fetching bytes, choosing a provider or inferring a rig.
10
+ *
11
+ * The inspection must come from the `gltf-motion-v1` profile under the glTF meter, right-handed, Y-up interpretation, and the source must repeat its path and byte length with a lowercase SHA-256 digest. Every track of the selected take must target a mapped node, translation only on the node mapped to `hips`, and never scale or weights, because humanoid motion carries neither. Each mapped bone's parent and rest in the declared source rig must equal what the inspected hierarchy implies: the nearest mapped ancestor and the node's local TRS composed through every unmapped helper between them. The comparison is exact, so an author computes the rest from the inspected transforms rather than retyping rounded values. The first violation throws with the field it concerns.
12
+ *
13
+ * The caller supplies an unmodified inspector result and binds the digest to the resident bytes; adoption checks digest spelling, not a hash. Rig admission here requires a non-blank id, unique bone names and `hips`, but basis comparisons cover only mapped bones and do not validate constraints or unmapped rests. Helper TRS composition follows fixed floating-point arithmetic and drops shear when a helper's non-uniform scale does not commute with a child rotation; exact agreement proves agreement with that representation, not exact affine geometry.
14
+ *
15
+ * @param props.inspection Inspection of the exact source bytes.
16
+ * @param props.source Manifest identity of those bytes.
17
+ * @param props.decision The author's use of one take.
18
+ * @returns A receipt that shares no objects with its inputs.
19
+ *
20
+ * @evidence contracts/development/implementation.md#principled-implementation Path and byte length compare with caller-supplied inspected facts, while the digest is checked only for spelling. Sets establish mapping uniqueness, and each mapped basis is recomputed by nearest-mapped-ancestor walks and fixed-order `composeLocalTransform` arithmetic; binary64 rounding and discarded shear remain, and constraints and unmapped rests receive no basis check.
21
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Identity/selection, rig binding and retarget-only fields have separate local owners; humanoid import shares transform composition and the engine validation owner supplies the common SHA-256 spelling predicate.
22
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No take, rig, bone or path is special-cased; the runtime mode check exists for untyped callers, and the digest regular expression is the manifest's documented `sha256:` format rather than a fixture value.
23
+ * @evidence contracts/development/common.md#meaningful-documentation The documentation distinguishes digest spelling from byte authentication, mapped-basis checks from complete rig admission, and exact arithmetic agreement from affine exactness; it also gives supported channels, first-refusal behavior and ownership of receipt copies.
24
+ * @evidence contracts/development/implementation.md#efficient-algorithms Copy cost follows the selected take's tracks/keyframes and source-rig size; hash-map setup follows the mapping and node counts. Mapping size M adds O(M log M) prefix-scanning node-id comparisons plus text-dependent identity/hash work; mapped bones times helper-chain lengths drive basis walks, and take lookup scans the declared take inventory without an assumed population bound.
25
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Adoption validates one decision against one inspection per call and shares no work across calls; the inspection it reads is already the caller's reused result.
26
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The temporary maps and sets die with the call; the receipt retains copies of the take, rig and mapping proportional to their size and is owned by the caller, with no handle or task.
27
+ */
28
+ const adoptAutoMovieExternalMotion = (props) => {
29
+ if (props.inspection.profile !== "gltf-motion-v1")
30
+ throw new Error('External motion adoption requires the "gltf-motion-v1" inspection profile.');
31
+ const motion = props.inspection.motion;
32
+ if (motion === undefined)
33
+ throw new Error("External source has no inspected motion takes.");
34
+ if (motion.interpretation !== AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE_1.AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE)
35
+ throw new Error(`External motion interpretation "${String(motion.interpretation)}" is unsupported.`);
36
+ if (props.source.path.trim().length === 0)
37
+ throw new Error("External motion source path must be non-blank.");
38
+ if (props.source.path !== motion.path)
39
+ throw new Error(`External motion source path "${props.source.path}" does not match inspected path "${motion.path}".`);
40
+ if (Number.isSafeInteger(props.source.byteLength) === false ||
41
+ props.source.byteLength <= 0 ||
42
+ props.source.byteLength !== motion.byteLength)
43
+ throw new Error(`External motion source byteLength ${props.source.byteLength} does not match inspected byteLength ${motion.byteLength}.`);
44
+ if (engine_1.SHA256_DIGEST_PATTERN.test(props.source.digest) === false)
45
+ throw new Error(`External motion source digest "${props.source.digest}" must be a lowercase SHA-256 digest.`);
46
+ const decision = props.decision;
47
+ if (decision.mode !== "native" && decision.mode !== "retarget")
48
+ throw new Error(`Unsupported external motion adoption mode "${String(decision.mode)}".`);
49
+ const selected = motion.takes.find((take) => take.id === decision.take);
50
+ if (selected === undefined)
51
+ throw new Error(`External motion take "${decision.take}" is not present in the inspected source.`);
52
+ const binding = validateMotionBinding({
53
+ decision,
54
+ take: selected,
55
+ nodes: motion.nodes,
56
+ });
57
+ const source = { ...props.source };
58
+ const take = cloneClip(selected);
59
+ if (decision.mode === "native")
60
+ return {
61
+ source,
62
+ mode: "native",
63
+ take,
64
+ handoff: { mode: "native", ...binding },
65
+ };
66
+ return {
67
+ source,
68
+ mode: "retarget",
69
+ take,
70
+ handoff: {
71
+ mode: "retarget",
72
+ ...binding,
73
+ ...validateRetargetDecision(decision),
74
+ },
75
+ };
76
+ };
77
+ exports.adoptAutoMovieExternalMotion = adoptAutoMovieExternalMotion;
78
+ const validateMotionBinding = (props) => {
79
+ const sourceRig = props.decision.sourceRig;
80
+ if (sourceRig.id.trim().length === 0)
81
+ throw new Error("External motion source rig id must be non-blank.");
82
+ if (sourceRig.bones.length === 0)
83
+ throw new Error("External motion source rig has no bones.");
84
+ const sourceBones = new Map();
85
+ for (const bone of sourceRig.bones) {
86
+ if (sourceBones.has(bone.bone))
87
+ throw new Error(`External motion source rig duplicates bone "${bone.bone}".`);
88
+ sourceBones.set(bone.bone, bone);
89
+ }
90
+ if (sourceBones.has("hips") === false)
91
+ throw new Error('External motion source rig is missing required bone "hips".');
92
+ const mapping = props.decision.mapping;
93
+ if (mapping.length === 0)
94
+ throw new Error("External motion semantic mapping must not be empty.");
95
+ const availableNodes = new Map(props.nodes.map((node) => [node.id, node]));
96
+ const nodeToBone = new Map();
97
+ const mappedBones = new Set();
98
+ for (const entry of mapping) {
99
+ if (availableNodes.has(entry.node) === false)
100
+ throw new Error(`External motion mapping node "${entry.node}" is not present in the inspected source.`);
101
+ if (sourceBones.has(entry.bone) === false)
102
+ throw new Error(`External motion mapping bone "${entry.bone}" is absent from source rig "${sourceRig.id}".`);
103
+ if (nodeToBone.has(entry.node))
104
+ throw new Error(`External motion mapping duplicates node "${entry.node}".`);
105
+ if (mappedBones.has(entry.bone))
106
+ throw new Error(`External motion mapping duplicates bone "${entry.bone}".`);
107
+ nodeToBone.set(entry.node, entry.bone);
108
+ mappedBones.add(entry.bone);
109
+ }
110
+ for (const track of props.take.tracks) {
111
+ if (track.channel.kind !== "node")
112
+ throw new Error("External motion semantic conversion supports only node tracks.");
113
+ const bone = nodeToBone.get(track.channel.node);
114
+ if (bone === undefined)
115
+ throw new Error(`External motion track node "${track.channel.node}" has no explicit semantic mapping.`);
116
+ if (track.channel.path === "translation" && bone !== "hips")
117
+ throw new Error(`External motion translation for node "${track.channel.node}" must map to hips.`);
118
+ if (track.channel.path === "scale" || track.channel.path === "weights")
119
+ throw new Error(`External motion ${track.channel.path} channel for node "${track.channel.node}" is unsupported by humanoid motion conversion.`);
120
+ }
121
+ for (const entry of mapping) {
122
+ const bone = sourceBones.get(entry.bone);
123
+ const expected = inspectedBoneBasis(availableNodes.get(entry.node), availableNodes, nodeToBone);
124
+ if (bone.parent !== expected.parent)
125
+ throw new Error(`External motion source rig bone "${entry.bone}" parent ${JSON.stringify(bone.parent)} does not match inspected parent ${JSON.stringify(expected.parent)}.`);
126
+ assertTransformMatches(entry.bone, bone.rest, expected.rest);
127
+ }
128
+ return {
129
+ sourceRig: cloneSkeleton(sourceRig),
130
+ mapping: mapping
131
+ .map((entry) => ({ ...entry }))
132
+ .sort((left, right) => (0, compareCodeUnits_1.compareCodeUnits)(left.node, right.node)),
133
+ };
134
+ };
135
+ /** The parent and rest a mapped node implies: walk to the nearest mapped ancestor, then fold every unmapped helper's TRS into the node's own, nearest helper first. A node without a mapped ancestor keeps its local TRS. */
136
+ const inspectedBoneBasis = (node, nodes, nodeToBone) => {
137
+ const helpers = [];
138
+ let parentId = node.parent;
139
+ while (parentId !== null) {
140
+ const mappedParent = nodeToBone.get(parentId);
141
+ if (mappedParent !== undefined) {
142
+ let rest = node.transform;
143
+ for (const helper of helpers)
144
+ rest = (0, composeLocalTransform_1.composeLocalTransform)(helper.transform, rest);
145
+ return { parent: mappedParent, rest };
146
+ }
147
+ const parent = nodes.get(parentId);
148
+ helpers.push(parent);
149
+ parentId = parent.parent;
150
+ }
151
+ return { parent: null, rest: node.transform };
152
+ };
153
+ const assertTransformMatches = (bone, actual, expected) => {
154
+ const components = [
155
+ ["translation.x", actual.translation.x, expected.translation.x],
156
+ ["translation.y", actual.translation.y, expected.translation.y],
157
+ ["translation.z", actual.translation.z, expected.translation.z],
158
+ ["rotation.x", actual.rotation.x, expected.rotation.x],
159
+ ["rotation.y", actual.rotation.y, expected.rotation.y],
160
+ ["rotation.z", actual.rotation.z, expected.rotation.z],
161
+ ["rotation.w", actual.rotation.w, expected.rotation.w],
162
+ ["scale.x", actual.scale.x, expected.scale.x],
163
+ ["scale.y", actual.scale.y, expected.scale.y],
164
+ ["scale.z", actual.scale.z, expected.scale.z],
165
+ ];
166
+ for (const [path, value, inspected] of components)
167
+ if (value !== inspected)
168
+ throw new Error(`External motion source rig bone "${bone}" rest ${path} ${value} does not match inspected value ${inspected}.`);
169
+ };
170
+ const validateRetargetDecision = (decision) => {
171
+ if (decision.target.trim().length === 0)
172
+ throw new Error("External motion target identity must be non-blank.");
173
+ if (Number.isFinite(decision.translationScale) === false ||
174
+ decision.translationScale <= 0)
175
+ throw new Error(`External motion translationScale must be finite and positive, but was ${decision.translationScale}.`);
176
+ return {
177
+ target: decision.target,
178
+ translationScale: decision.translationScale,
179
+ };
180
+ };
181
+ const cloneClip = (clip) => ({
182
+ ...clip,
183
+ tracks: clip.tracks.map((track) => ({
184
+ ...track,
185
+ channel: { ...track.channel },
186
+ times: [...track.times],
187
+ values: [...track.values],
188
+ })),
189
+ });
190
+ const cloneSkeleton = (skeleton) => ({
191
+ id: skeleton.id,
192
+ bones: skeleton.bones.map((bone) => ({
193
+ ...bone,
194
+ rest: {
195
+ translation: { ...bone.rest.translation },
196
+ rotation: { ...bone.rest.rotation },
197
+ scale: { ...bone.rest.scale },
198
+ },
199
+ constraint: bone.constraint === null
200
+ ? null
201
+ : {
202
+ ...bone.constraint,
203
+ flexion: bone.constraint.flexion === null
204
+ ? null
205
+ : { ...bone.constraint.flexion },
206
+ abduction: bone.constraint.abduction === null
207
+ ? null
208
+ : { ...bone.constraint.abduction },
209
+ twist: bone.constraint.twist === null
210
+ ? null
211
+ : { ...bone.constraint.twist },
212
+ },
213
+ })),
214
+ });
215
+ //# sourceMappingURL=adoptAutoMovieExternalMotion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adoptAutoMovieExternalMotion.js","sourceRoot":"","sources":["../src/adoptAutoMovieExternalMotion.ts"],"names":[],"mappings":";;;AAAA,8CAA0D;AAU1D,iHAA8G;AAW9G,kEAA+D;AAC/D,4EAAyE;AAEzE;;;;;;;;;;;;;;;;;;;GAmBG;AACI,MAAM,4BAA4B,GASA,CAAC,KASzC,EAAoC,EAAE;IACrC,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,KAAK,gBAAgB;QAC/C,MAAM,IAAI,KAAK,CACb,4EAA4E,CAC7E,CAAC;IACJ,MAAM,MAAM,GACV,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC;IAC1B,IAAI,MAAM,KAAK,SAAS;QACtB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,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IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;aACnC;KACR,CAAC,CACH;CACF,CAAC,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { IAutoMovieProductionAudioProcessing } from "./IAutoMovieProductionAudioProcessing";
2
+ import type { IAutoMovieProductionWaveSourceFormat } from "./IAutoMovieProductionWaveSourceFormat";
3
+ /**
4
+ * One decoded WAVE source: its declared facts, the processing applied, and mono samples available to a caller's mixer.
5
+ *
6
+ * The `source*` facts and `durationSeconds` describe the file before downmix and resampling, because a render plan records them as the asset's identity; only `samples` and `processing` describe the output. Reporting the output as the source would let a resampled asset claim the plan's rate and hide a duration disagreement.
7
+ *
8
+ * @evidence contracts/development/design.md#principled-representation Source envelope facts, processing lineage and sample storage remain separate so consumers can compare declared source/output relationships. The Float32Array carries no rate metadata and this record cannot independently prove that its samples were generated at the declared rate.
9
+ * @evidence contracts/development/design.md#minimal-and-owned-surface Source facts, processing and samples are three named parts of one decoder result instead of separate return paths, and the render package reuses the two nested types as its wave identity.
10
+ * @evidence contracts/development/design.md#prohibited-design-shortcuts The decoder fills repeated source fields and `sourceFormat` from the same parsed values; this structural type neither correlates independently supplied records nor authenticates mutable sample bytes.
11
+ * @evidence contracts/development/common.md#meaningful-documentation The comments state which fields describe the file and which the output, the units of rate and duration, and that samples are finite mono values at the requested rate.
12
+ */
13
+ export interface IAutoMovieDecodedProductionAudioAsset {
14
+ /** Source rate in samples per second, before resampling. */
15
+ sourceSampleRate: number;
16
+ /** Source channel count, 1 or 2, before the mono downmix. */
17
+ sourceChannels: number;
18
+ /** Number of complete sample frames in the source `data` chunk. */
19
+ sourceFrames: number;
20
+ /** Source runtime in seconds, `sourceFrames / sourceSampleRate`. */
21
+ durationSeconds: number;
22
+ /** The file's own format declaration as parsed. */
23
+ sourceFormat: IAutoMovieProductionWaveSourceFormat;
24
+ /** The downmix and resampling applied to produce `samples`. */
25
+ processing: IAutoMovieProductionAudioProcessing;
26
+ /** Finite mono samples in [-1, 1] for PCM sources at `processing.outputSampleRate`; a new buffer the caller owns. */
27
+ samples: Float32Array;
28
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IAutoMovieDecodedProductionAudioAsset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAutoMovieDecodedProductionAudioAsset.js","sourceRoot":"","sources":["../../src/audio/IAutoMovieDecodedProductionAudioAsset.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The deterministic conversion `decodeProductionAudioAsset` applied to turn a WAVE source into mono mixer input, recorded so a render plan can check it against the source format it claims.
3
+ *
4
+ * @evidence contracts/development/design.md#principled-representation Stage kind, downmix coefficients and requested output rate let the render identity validator compare declared processing with source channels and rate; the record does not prove sample contents or specify a general resampling algorithm independently of the decoder.
5
+ * @evidence contracts/development/design.md#minimal-and-owned-surface One flat record names the stage combination and its parameters; the render package's wave identity validator reads these four fields and nothing else.
6
+ * @evidence contracts/development/design.md#prohibited-design-shortcuts Literal channel and stage vocabulary constrain names, but independent fields and numeric arrays do not enforce stage/rate/matrix correlation; the decoder produces those relations and the render wave-identity validator checks them.
7
+ * @evidence contracts/development/common.md#meaningful-documentation The comments give the stage order, the output channel and rate meaning, and the row-by-column orientation and only values of the downmix matrix.
8
+ */
9
+ export interface IAutoMovieProductionAudioProcessing {
10
+ /** Stages applied, in source order: `copy` for mono at the target rate, `downmix` for stereo at the target rate, `resample` for mono at another rate, and `downmix-resample` for stereo at another rate. */
11
+ kind: "copy" | "downmix" | "resample" | "downmix-resample";
12
+ /** Mixer-facing channel count; the decoder always folds to mono. */
13
+ outputChannels: 1;
14
+ /** Output rate in samples per second, the rate the caller requested. */
15
+ outputSampleRate: number;
16
+ /** Downmix coefficients with one row per output channel and one column per source channel: `[[1]]` for mono and `[[0.5, 0.5]]` for stereo. */
17
+ matrix: readonly (readonly number[])[];
18
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IAutoMovieProductionAudioProcessing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAutoMovieProductionAudioProcessing.js","sourceRoot":"","sources":["../../src/audio/IAutoMovieProductionAudioProcessing.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Exact supported WAVE declaration before processing.
3
+ *
4
+ * These are the file's own facts, read from its format envelope and never inferred from its channel count: an extensible header names its speakers through `dwChannelMask` and its encoding through the full SubFormat GUID, while a legacy header carries the default mono front-center or stereo front-left/front-right semantics and says so in `layout.source`. The literal unions are the decoder's whole supported subset, so a value outside them was refused rather than recorded.
5
+ *
6
+ * @evidence contracts/development/design.md#principled-representation Each field mirrors a WAVEFORMATEX or WAVEFORMATEXTENSIBLE field the decoder reads, with the layout source and mask recording whether the speakers came from `dwChannelMask` or from the legacy default.
7
+ * @evidence contracts/development/design.md#minimal-and-owned-surface One record keeps the envelope facts apart from the processing lineage, which lets the render plan validate a source identity separately from the conversion applied to it.
8
+ * @evidence contracts/development/design.md#prohibited-design-shortcuts Closed unions constrain each vocabulary independently, while numeric ranges and encoding/precision/channel/layout/GUID relations remain producer invariants checked by the decoder and render wave-identity validator, not guarantees of this erased type.
9
+ * @evidence contracts/development/common.md#meaningful-documentation The comments state where each fact comes from, which header spelling sets the mask and GUID, and that the literal unions are the supported subset.
10
+ */
11
+ export interface IAutoMovieProductionWaveSourceFormat {
12
+ /** Media-family discriminant; WAVE is the only decoded family. */
13
+ kind: "wave";
14
+ /** Format-envelope spelling: `wave-format-ex` for a legacy tag, or `wave-format-extensible` for tag `0xFFFE` with a cbSize of at least 22. */
15
+ header: "wave-format-ex" | "wave-format-extensible";
16
+ /** Sample encoding: little-endian signed 16-bit PCM or 32-bit IEEE float. */
17
+ encoding: "pcm-s16le" | "float-f32le";
18
+ /** Bits each encoded channel sample occupies (`wBitsPerSample`). */
19
+ containerBits: 16 | 32;
20
+ /** Meaningful bits inside the container; `wValidBitsPerSample` for an extensible header, otherwise the container size. Always equal to `containerBits`, since partial precision is refused. */
21
+ validBits: 16 | 32;
22
+ /** Source rate in samples per second, before any resampling. */
23
+ sampleRate: number;
24
+ /** Source channel count, before the mono downmix. */
25
+ channels: 1 | 2;
26
+ /** Ordered speaker semantics and where they were declared. */
27
+ layout: {
28
+ /** Mono or stereo, matching `channels`. */
29
+ kind: "mono" | "stereo";
30
+ /** Speakers in channel order. */
31
+ speakers: ["front-center"] | ["front-left", "front-right"];
32
+ /** `channel-mask` when an extensible header declared the speakers, `legacy-default` when a legacy header implied them. */
33
+ source: "legacy-default" | "channel-mask";
34
+ /** The declared `dwChannelMask` (`0x4` mono, `0x3` stereo), or `null` for a legacy header, which has none. */
35
+ mask: number | null;
36
+ };
37
+ /** Lowercase canonical SubFormat GUID text of an extensible header, or `null` for a legacy header, which has none. */
38
+ subFormatGuid: string | null;
39
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IAutoMovieProductionWaveSourceFormat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAutoMovieProductionWaveSourceFormat.js","sourceRoot":"","sources":["../../src/audio/IAutoMovieProductionWaveSourceFormat.ts"],"names":[],"mappings":""}
@@ -0,0 +1,33 @@
1
+ import type { IAutoMovieDecodedProductionAudioAsset } from "./IAutoMovieDecodedProductionAudioAsset";
2
+ /**
3
+ * Decode one complete supported RIFF/WAVE file into finite mono samples at a requested rate.
4
+ *
5
+ * The parser walks the RIFF chunks by id, requires the declared RIFF extent, `nBlockAlign`, and `nAvgBytesPerSec` to agree with the format fields, and refuses a duplicate `fmt ` or `data` chunk, an odd chunk without its pad byte, and terminal bytes too short for a chunk header. An extensible header follows the Microsoft WAVEFORMATEXTENSIBLE contract (https://learn.microsoft.com/en-us/windows/win32/api/mmreg/ns-mmreg-waveformatextensible): "The cbSize member must be at least 22", `wValidBitsPerSample` "can be any value not exceeding the container size", "the channels specified in dwChannelMask must be present in the prescribed order (from least significant bit up)" with SPEAKER_FRONT_LEFT `0x1`, SPEAKER_FRONT_RIGHT `0x2`, and SPEAKER_FRONT_CENTER `0x4`, and "the number of bits set in dwChannelMask should be the same as the number of channels". The SubFormat is admitted only when every byte after its leading 16-bit tag equals the `xxxxxxxx-0000-0010-8000-00aa00389b71` template that Ksmedia.h's `IS_VALID_WAVEFORMATEX_GUID` compares (https://learn.microsoft.com/en-us/windows-hardware/drivers/audio/converting-between-format-tags-and-subformat-guids), so a vendor GUID whose low word happens to read as PCM is not decoded as PCM.
6
+ *
7
+ * The supported subset is deliberately narrow: 16-bit PCM in a 16-bit container, 32-bit IEEE float in a 32-bit container, mono front-center, and stereo front-left/front-right. A legal declaration outside it, such as 20 valid bits in a 24-bit container or a front-left/front-center pair, is refused as unsupported by field rather than misread as the nearest supported layout. Every decoded sample is checked finite before the mono fold and before any resampling, so a NaN or infinity in one channel refuses the whole asset at its frame and channel instead of averaging into a plausible number.
8
+ *
9
+ * PCM codes scale by 1/32768, so -32768 reads as exactly -1 and 32767 just under 1. Stereo folds to the mean of its two channels. A source at another rate is resampled by linear interpolation between neighboring source samples, holding the last sample past the end, to `round(frames * rate / sourceRate)` samples, which may round to zero for a short source and a low target rate. No low-pass filter runs first, so downsampling a source with content above the target Nyquist frequency aliases it.
10
+ *
11
+ * Field admission refusals throw `Audio asset "<path>" [<reason>] <message>`, where the reason names the field, such as `riff-size`, `block-align`, or `unsupported-wave-layout`. Buffer size follows source frames and the requested rate ratio; this function imposes no product memory budget, so platform allocation errors may propagate outside that refusal format.
12
+ *
13
+ * @param props.path Asset path, used only in refusal messages.
14
+ * @param props.bytes Complete file bytes; they are only read.
15
+ * @param props.sampleRate Output rate in samples per second; a positive safe integer.
16
+ * @returns The source facts as declared and new mono samples the caller owns.
17
+ *
18
+ * @evidence contracts/development/implementation.md#principled-implementation Chunks are found by id in RIFF order with the even-byte pad rule, the format fields are checked against WAVEFORMATEXTENSIBLE's own consistency rules and the KSDATAFORMAT GUID template, samples scale by 1/32768 or read as IEEE floats, and resampling is two-tap linear interpolation; that interpolation has no anti-alias filter, which the documentation states as the remaining limitation when a source is downsampled.
19
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure One linear pass validates the container, a second folds frames to mono, and a third resamples only when the rates differ; private refusal, chunk and hex helpers keep WAVE parsing local, while production speech probes consume the public decoder's format facts and mono samples.
20
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No file, path or rate is special-cased: every unsupported declaration throws with a field-named reason instead of decoding as the nearest supported layout, and the only constants are the WAVE format tags, speaker masks and GUID tail the Microsoft contract defines.
21
+ * @evidence contracts/development/common.md#meaningful-documentation The documentation cites the WAVEFORMATEXTENSIBLE rules it enforces, lists the supported subset, gives the PCM scale, stereo fold, resampled length and aliasing limitation, and states the refusal message shape and parameter units.
22
+ * @evidence contracts/development/implementation.md#efficient-algorithms Time follows RIFF chunk headers, source frames times channels and output samples; storage follows source and output frames, each encoded sample is read once through one DataView, and the mono buffer becomes the result when rates match.
23
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work The decoder is a pure function of one call's bytes and rate and coordinates no work across requests; any caching of decoded assets would belong to its caller.
24
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The call owns source-frame mono storage and, on resampling, rate-ratio-sized output storage; no product memory budget bounds a requested allocation. Temporary buffers become collectable on return/throw, the returned buffer transfers to its caller, and no raw bytes, handles or tasks are retained.
25
+ */
26
+ export declare const decodeProductionAudioAsset: (props: {
27
+ /** Diagnostic identity only; the decoder opens no file. */
28
+ path: string;
29
+ /** Complete resident RIFF/WAVE bytes, borrowed without mutation. */
30
+ bytes: Uint8Array;
31
+ /** Positive safe-integer output samples per second. */
32
+ sampleRate: number;
33
+ }) => IAutoMovieDecodedProductionAudioAsset;