@automovie/template 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 (742) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -2
  3. package/build/resolveTemplateVersions.ts +92 -0
  4. package/build/syncScaffoldInstructions.ts +28 -0
  5. package/lib/AUTOMOVIE_TEMPLATE_CATALOGS.d.ts +14 -0
  6. package/lib/AUTOMOVIE_TEMPLATE_CATALOGS.js +52 -0
  7. package/lib/AUTOMOVIE_TEMPLATE_CATALOGS.js.map +1 -0
  8. package/lib/AUTOMOVIE_TEMPLATE_VERSIONS.d.ts +2 -0
  9. package/lib/AUTOMOVIE_TEMPLATE_VERSIONS.js +42 -0
  10. package/lib/AUTOMOVIE_TEMPLATE_VERSIONS.js.map +1 -0
  11. package/lib/AutoMovieScaffoldLayer.d.ts +15 -0
  12. package/lib/AutoMovieScaffoldLayer.js +3 -0
  13. package/lib/AutoMovieScaffoldLayer.js.map +1 -0
  14. package/lib/FILE_ATTRIBUTE_DIRECTORY.d.ts +2 -0
  15. package/lib/FILE_ATTRIBUTE_DIRECTORY.js +6 -0
  16. package/lib/FILE_ATTRIBUTE_DIRECTORY.js.map +1 -0
  17. package/lib/IAutoMovieCatalogVersionProps.d.ts +16 -0
  18. package/lib/IAutoMovieCatalogVersionProps.js +3 -0
  19. package/lib/IAutoMovieCatalogVersionProps.js.map +1 -0
  20. package/lib/IAutoMovieScaffoldProps.d.ts +14 -0
  21. package/lib/IAutoMovieScaffoldProps.js +3 -0
  22. package/lib/IAutoMovieScaffoldProps.js.map +1 -0
  23. package/lib/IAutoMovieScaffoldSourceEntry.d.ts +18 -0
  24. package/lib/IAutoMovieScaffoldSourceEntry.js +3 -0
  25. package/lib/IAutoMovieScaffoldSourceEntry.js.map +1 -0
  26. package/lib/IAutoMovieTemplateDependencyVersionsProps.d.ts +17 -0
  27. package/lib/IAutoMovieTemplateDependencyVersionsProps.js +3 -0
  28. package/lib/IAutoMovieTemplateDependencyVersionsProps.js.map +1 -0
  29. package/lib/IAutoMovieWorkspacePackageVersions.d.ts +34 -0
  30. package/lib/IAutoMovieWorkspacePackageVersions.js +3 -0
  31. package/lib/IAutoMovieWorkspacePackageVersions.js.map +1 -0
  32. package/lib/IBoundChild.d.ts +71 -0
  33. package/lib/IBoundChild.js +3 -0
  34. package/lib/IBoundChild.js.map +1 -0
  35. package/lib/IBoundChildStatus.d.ts +20 -0
  36. package/lib/IBoundChildStatus.js +3 -0
  37. package/lib/IBoundChildStatus.js.map +1 -0
  38. package/lib/IBoundParent.d.ts +61 -0
  39. package/lib/IBoundParent.js +3 -0
  40. package/lib/IBoundParent.js.map +1 -0
  41. package/lib/IBoundParentStatus.d.ts +14 -0
  42. package/lib/IBoundParentStatus.js +3 -0
  43. package/lib/IBoundParentStatus.js.map +1 -0
  44. package/lib/ICreateResult.d.ts +27 -0
  45. package/lib/ICreateResult.js +3 -0
  46. package/lib/ICreateResult.js.map +1 -0
  47. package/lib/IScaffoldCompletedFilePublicationOutcome.d.ts +16 -0
  48. package/lib/IScaffoldCompletedFilePublicationOutcome.js +3 -0
  49. package/lib/IScaffoldCompletedFilePublicationOutcome.js.map +1 -0
  50. package/lib/IScaffoldCompletedPublication.d.ts +15 -0
  51. package/lib/IScaffoldCompletedPublication.js +3 -0
  52. package/lib/IScaffoldCompletedPublication.js.map +1 -0
  53. package/lib/IScaffoldFileSnapshot.d.ts +24 -0
  54. package/lib/IScaffoldFileSnapshot.js +3 -0
  55. package/lib/IScaffoldFileSnapshot.js.map +1 -0
  56. package/lib/IScaffoldParentPublicationRequest.d.ts +26 -0
  57. package/lib/IScaffoldParentPublicationRequest.js +3 -0
  58. package/lib/IScaffoldParentPublicationRequest.js.map +1 -0
  59. package/lib/IScaffoldPartialFilePublicationOutcome.d.ts +22 -0
  60. package/lib/IScaffoldPartialFilePublicationOutcome.js +3 -0
  61. package/lib/IScaffoldPartialFilePublicationOutcome.js.map +1 -0
  62. package/lib/IScaffoldPhysicalDirectory.d.ts +20 -0
  63. package/lib/IScaffoldPhysicalDirectory.js +3 -0
  64. package/lib/IScaffoldPhysicalDirectory.js.map +1 -0
  65. package/lib/IScaffoldPosixConstants.d.ts +24 -0
  66. package/lib/IScaffoldPosixConstants.js +3 -0
  67. package/lib/IScaffoldPosixConstants.js.map +1 -0
  68. package/lib/IScaffoldPublicationEntry.d.ts +20 -0
  69. package/lib/IScaffoldPublicationEntry.js +3 -0
  70. package/lib/IScaffoldPublicationEntry.js.map +1 -0
  71. package/lib/IScaffoldPublicationFailure.d.ts +18 -0
  72. package/lib/IScaffoldPublicationFailure.js +3 -0
  73. package/lib/IScaffoldPublicationFailure.js.map +1 -0
  74. package/lib/IScaffoldPublicationOptions.d.ts +17 -0
  75. package/lib/IScaffoldPublicationOptions.js +3 -0
  76. package/lib/IScaffoldPublicationOptions.js.map +1 -0
  77. package/lib/IScaffoldPublicationReceipt.d.ts +25 -0
  78. package/lib/IScaffoldPublicationReceipt.js +3 -0
  79. package/lib/IScaffoldPublicationReceipt.js.map +1 -0
  80. package/lib/IScaffoldRefusedFilePublicationOutcome.d.ts +18 -0
  81. package/lib/IScaffoldRefusedFilePublicationOutcome.js +3 -0
  82. package/lib/IScaffoldRefusedFilePublicationOutcome.js.map +1 -0
  83. package/lib/IScaffoldSyncPlan.d.ts +25 -0
  84. package/lib/IScaffoldSyncPlan.js +3 -0
  85. package/lib/IScaffoldSyncPlan.js.map +1 -0
  86. package/lib/IScaffoldSyncProps.d.ts +16 -0
  87. package/lib/IScaffoldSyncProps.js +3 -0
  88. package/lib/IScaffoldSyncProps.js.map +1 -0
  89. package/lib/IWindowsFileInformation.d.ts +20 -0
  90. package/lib/IWindowsFileInformation.js +3 -0
  91. package/lib/IWindowsFileInformation.js.map +1 -0
  92. package/lib/IWindowsLibrary.d.ts +127 -0
  93. package/lib/IWindowsLibrary.js +3 -0
  94. package/lib/IWindowsLibrary.js.map +1 -0
  95. package/lib/SCAFFOLD_SYNC_STATE_FILE.d.ts +4 -0
  96. package/lib/SCAFFOLD_SYNC_STATE_FILE.js +8 -0
  97. package/lib/SCAFFOLD_SYNC_STATE_FILE.js.map +1 -0
  98. package/lib/ScaffoldFilePublicationOutcome.d.ts +14 -0
  99. package/lib/ScaffoldFilePublicationOutcome.js +3 -0
  100. package/lib/ScaffoldFilePublicationOutcome.js.map +1 -0
  101. package/lib/ScaffoldParentChangedError.d.ts +11 -0
  102. package/lib/ScaffoldParentChangedError.js +19 -0
  103. package/lib/ScaffoldParentChangedError.js.map +1 -0
  104. package/lib/ScaffoldPublicationError.d.ts +17 -0
  105. package/lib/ScaffoldPublicationError.js +46 -0
  106. package/lib/ScaffoldPublicationError.js.map +1 -0
  107. package/lib/assertOrdinaryFile.d.ts +13 -0
  108. package/lib/assertOrdinaryFile.js +20 -0
  109. package/lib/assertOrdinaryFile.js.map +1 -0
  110. package/lib/assertOrdinarySingleLinkFile.d.ts +13 -0
  111. package/lib/assertOrdinarySingleLinkFile.js +22 -0
  112. package/lib/assertOrdinarySingleLinkFile.js.map +1 -0
  113. package/lib/assertScaffoldOwnership.d.ts +13 -0
  114. package/lib/assertScaffoldOwnership.js +24 -0
  115. package/lib/assertScaffoldOwnership.js.map +1 -0
  116. package/lib/assertScaffoldPhysicalDirectory.d.ts +16 -0
  117. package/lib/assertScaffoldPhysicalDirectory.js +26 -0
  118. package/lib/assertScaffoldPhysicalDirectory.js.map +1 -0
  119. package/lib/assertScaffoldProjectName.d.ts +18 -0
  120. package/lib/assertScaffoldProjectName.js +34 -0
  121. package/lib/assertScaffoldProjectName.js.map +1 -0
  122. package/lib/attachScaffoldSyncState.d.ts +18 -0
  123. package/lib/attachScaffoldSyncState.js +30 -0
  124. package/lib/attachScaffoldSyncState.js.map +1 -0
  125. package/lib/captureEmptyScaffoldPhysicalDirectory.d.ts +13 -0
  126. package/lib/captureEmptyScaffoldPhysicalDirectory.js +69 -0
  127. package/lib/captureEmptyScaffoldPhysicalDirectory.js.map +1 -0
  128. package/lib/captureScaffoldFile.d.ts +13 -0
  129. package/lib/captureScaffoldFile.js +67 -0
  130. package/lib/captureScaffoldFile.js.map +1 -0
  131. package/lib/captureScaffoldPhysicalDirectory.d.ts +13 -0
  132. package/lib/captureScaffoldPhysicalDirectory.js +63 -0
  133. package/lib/captureScaffoldPhysicalDirectory.js.map +1 -0
  134. package/lib/combineScaffoldFailures.d.ts +19 -0
  135. package/lib/combineScaffoldFailures.js +32 -0
  136. package/lib/combineScaffoldFailures.js.map +1 -0
  137. package/lib/createAutoMovieCatalogVersionResolver.d.ts +17 -0
  138. package/lib/createAutoMovieCatalogVersionResolver.js +64 -0
  139. package/lib/createAutoMovieCatalogVersionResolver.js.map +1 -0
  140. package/lib/createScaffoldSyncState.d.ts +12 -0
  141. package/lib/createScaffoldSyncState.js +26 -0
  142. package/lib/createScaffoldSyncState.js.map +1 -0
  143. package/lib/createScaffoldVariables.d.ts +25 -0
  144. package/lib/createScaffoldVariables.js +41 -0
  145. package/lib/createScaffoldVariables.js.map +1 -0
  146. package/lib/ensureScaffoldBaseDirectory.d.ts +19 -0
  147. package/lib/ensureScaffoldBaseDirectory.js +89 -0
  148. package/lib/ensureScaffoldBaseDirectory.js.map +1 -0
  149. package/lib/ensureScaffoldFileDirectory.d.ts +25 -0
  150. package/lib/ensureScaffoldFileDirectory.js +103 -0
  151. package/lib/ensureScaffoldFileDirectory.js.map +1 -0
  152. package/lib/index.d.ts +47 -0
  153. package/lib/index.js +64 -0
  154. package/lib/index.js.map +1 -0
  155. package/lib/inside.d.ts +12 -0
  156. package/lib/inside.js +57 -0
  157. package/lib/inside.js.map +1 -0
  158. package/lib/isScaffoldInstruction.d.ts +12 -0
  159. package/lib/isScaffoldInstruction.js +29 -0
  160. package/lib/isScaffoldInstruction.js.map +1 -0
  161. package/lib/listAutoMovieScaffoldFiles.d.ts +17 -0
  162. package/lib/listAutoMovieScaffoldFiles.js +87 -0
  163. package/lib/listAutoMovieScaffoldFiles.js.map +1 -0
  164. package/lib/loadWindowsLibrary.d.ts +13 -0
  165. package/lib/loadWindowsLibrary.js +180 -0
  166. package/lib/loadWindowsLibrary.js.map +1 -0
  167. package/lib/mergeScaffoldFiles.d.ts +18 -0
  168. package/lib/mergeScaffoldFiles.js +37 -0
  169. package/lib/mergeScaffoldFiles.js.map +1 -0
  170. package/lib/missingPath.d.ts +12 -0
  171. package/lib/missingPath.js +18 -0
  172. package/lib/missingPath.js.map +1 -0
  173. package/lib/nativeError.d.ts +12 -0
  174. package/lib/nativeError.js +17 -0
  175. package/lib/nativeError.js.map +1 -0
  176. package/lib/openPosixParent.d.ts +13 -0
  177. package/lib/openPosixParent.js +135 -0
  178. package/lib/openPosixParent.js.map +1 -0
  179. package/lib/openWindowsParent.d.ts +13 -0
  180. package/lib/openWindowsParent.js +224 -0
  181. package/lib/openWindowsParent.js.map +1 -0
  182. package/lib/overwriteScaffoldFile.d.ts +22 -0
  183. package/lib/overwriteScaffoldFile.js +214 -0
  184. package/lib/overwriteScaffoldFile.js.map +1 -0
  185. package/lib/physicalDirectoryIdentity.d.ts +15 -0
  186. package/lib/physicalDirectoryIdentity.js +65 -0
  187. package/lib/physicalDirectoryIdentity.js.map +1 -0
  188. package/lib/physicalVersion.d.ts +13 -0
  189. package/lib/physicalVersion.js +18 -0
  190. package/lib/physicalVersion.js.map +1 -0
  191. package/lib/planScaffoldPublication.d.ts +22 -0
  192. package/lib/planScaffoldPublication.js +100 -0
  193. package/lib/planScaffoldPublication.js.map +1 -0
  194. package/lib/planScaffoldSync.d.ts +14 -0
  195. package/lib/planScaffoldSync.js +102 -0
  196. package/lib/planScaffoldSync.js.map +1 -0
  197. package/lib/publishFiles.d.ts +23 -0
  198. package/lib/publishFiles.js +124 -0
  199. package/lib/publishFiles.js.map +1 -0
  200. package/lib/publishNativeScaffoldFile.d.ts +21 -0
  201. package/lib/publishNativeScaffoldFile.js +211 -0
  202. package/lib/publishNativeScaffoldFile.js.map +1 -0
  203. package/lib/publishScaffoldCandidate.d.ts +24 -0
  204. package/lib/publishScaffoldCandidate.js +70 -0
  205. package/lib/publishScaffoldCandidate.js.map +1 -0
  206. package/lib/readAutoMovieScaffoldSources.d.ts +20 -0
  207. package/lib/readAutoMovieScaffoldSources.js +103 -0
  208. package/lib/readAutoMovieScaffoldSources.js.map +1 -0
  209. package/lib/readScaffoldSyncFile.d.ts +16 -0
  210. package/lib/readScaffoldSyncFile.js +64 -0
  211. package/lib/readScaffoldSyncFile.js.map +1 -0
  212. package/lib/renderScaffold.d.ts +19 -0
  213. package/lib/renderScaffold.js +33 -0
  214. package/lib/renderScaffold.js.map +1 -0
  215. package/lib/renderScaffoldEntries.d.ts +20 -0
  216. package/lib/renderScaffoldEntries.js +106 -0
  217. package/lib/renderScaffoldEntries.js.map +1 -0
  218. package/lib/renderScaffoldInstructions.d.ts +17 -0
  219. package/lib/renderScaffoldInstructions.js +23 -0
  220. package/lib/renderScaffoldInstructions.js.map +1 -0
  221. package/lib/renderScaffoldLayer.d.ts +20 -0
  222. package/lib/renderScaffoldLayer.js +28 -0
  223. package/lib/renderScaffoldLayer.js.map +1 -0
  224. package/lib/renderTemplate.d.ts +19 -0
  225. package/lib/renderTemplate.js +56 -0
  226. package/lib/renderTemplate.js.map +1 -0
  227. package/lib/renderWorkspaceProductionScaffold.d.ts +19 -0
  228. package/lib/renderWorkspaceProductionScaffold.js +30 -0
  229. package/lib/renderWorkspaceProductionScaffold.js.map +1 -0
  230. package/lib/renderWorkspaceScaffold.d.ts +19 -0
  231. package/lib/renderWorkspaceScaffold.js +33 -0
  232. package/lib/renderWorkspaceScaffold.js.map +1 -0
  233. package/lib/replaceSharedScaffoldFile.d.ts +30 -0
  234. package/lib/replaceSharedScaffoldFile.js +106 -0
  235. package/lib/replaceSharedScaffoldFile.js.map +1 -0
  236. package/lib/resolveAutoMovieCatalogVersion.d.ts +19 -0
  237. package/lib/resolveAutoMovieCatalogVersion.js +24 -0
  238. package/lib/resolveAutoMovieCatalogVersion.js.map +1 -0
  239. package/lib/resolveAutoMovieTemplateDependencyVersions.d.ts +19 -0
  240. package/lib/resolveAutoMovieTemplateDependencyVersions.js +62 -0
  241. package/lib/resolveAutoMovieTemplateDependencyVersions.js.map +1 -0
  242. package/lib/resolveScaffoldPosixConstants.d.ts +13 -0
  243. package/lib/resolveScaffoldPosixConstants.js +44 -0
  244. package/lib/resolveScaffoldPosixConstants.js.map +1 -0
  245. package/lib/scaffoldAssetDirectory.d.ts +19 -0
  246. package/lib/scaffoldAssetDirectory.js +63 -0
  247. package/lib/scaffoldAssetDirectory.js.map +1 -0
  248. package/lib/scaffoldPhysicalIdentity.d.ts +18 -0
  249. package/lib/scaffoldPhysicalIdentity.js +22 -0
  250. package/lib/scaffoldPhysicalIdentity.js.map +1 -0
  251. package/lib/scaffoldSharedSkillDirectory.d.ts +17 -0
  252. package/lib/scaffoldSharedSkillDirectory.js +62 -0
  253. package/lib/scaffoldSharedSkillDirectory.js.map +1 -0
  254. package/lib/scaffoldSharedSkillPath.d.ts +17 -0
  255. package/lib/scaffoldSharedSkillPath.js +66 -0
  256. package/lib/scaffoldSharedSkillPath.js.map +1 -0
  257. package/lib/skills/3d-modeling/conditioning.md +82 -0
  258. package/lib/skills/3d-modeling/crafting.md +82 -0
  259. package/lib/skills/3d-modeling/diffusion.md +34 -0
  260. package/lib/skills/3d-modeling/inspection.md +54 -0
  261. package/lib/skills/3d-modeling/lofting.md +43 -0
  262. package/lib/skills/3d-modeling/modularization.md +31 -0
  263. package/lib/skills/3d-modeling/recovery.md +29 -0
  264. package/lib/skills/3d-modeling/rigging.md +97 -0
  265. package/lib/skills/3d-modeling/sources.md +29 -0
  266. package/lib/skills/contracts/development/common.md +13 -0
  267. package/lib/skills/contracts/development/design.md +28 -0
  268. package/lib/skills/contracts/development/implementation.md +49 -0
  269. package/lib/skills/contracts/development/testing.md +27 -0
  270. package/lib/skills/development/repair.md +13 -0
  271. package/lib/skills/documentation/SKILL.md +25 -0
  272. package/lib/skills/documentation/writing.md +51 -0
  273. package/lib/skills/motion/authoring.md +51 -0
  274. package/lib/skills/motion/contacts.md +39 -0
  275. package/lib/skills/motion/laws.md +23 -0
  276. package/lib/skills/motion/layers.md +7 -0
  277. package/lib/skills/motion/transitions.md +27 -0
  278. package/lib/skills/motion/variation.md +23 -0
  279. package/lib/skills/motion/verification.md +36 -0
  280. package/lib/skills/prompting/SKILL.md +80 -0
  281. package/lib/skills/visual-debugging/capture.md +60 -0
  282. package/lib/skills/visual-debugging/comparison.md +35 -0
  283. package/lib/skills/visual-debugging/correction-rounds.md +34 -0
  284. package/lib/skills/visual-debugging/passes.md +29 -0
  285. package/lib/skills/visual-debugging/rendering-cost.md +5 -0
  286. package/lib/syncScaffold.d.ts +19 -0
  287. package/lib/syncScaffold.js +28 -0
  288. package/lib/syncScaffold.js.map +1 -0
  289. package/lib/writeFiles.d.ts +20 -0
  290. package/lib/writeFiles.js +33 -0
  291. package/lib/writeFiles.js.map +1 -0
  292. package/lib/writeScaffoldFile.d.ts +35 -0
  293. package/lib/writeScaffoldFile.js +107 -0
  294. package/lib/writeScaffoldFile.js.map +1 -0
  295. package/lib/writtenVersion.d.ts +13 -0
  296. package/lib/writtenVersion.js +18 -0
  297. package/lib/writtenVersion.js.map +1 -0
  298. package/package.json +59 -3
  299. package/scaffold/instructions/.agents/skills/$documentation +0 -0
  300. package/scaffold/instructions/.agents/skills/$prompting +0 -0
  301. package/scaffold/instructions/.agents/skills/3d-modeling/$conditioning.md +0 -0
  302. package/scaffold/instructions/.agents/skills/3d-modeling/$crafting.md +0 -0
  303. package/scaffold/instructions/.agents/skills/3d-modeling/$diffusion.md +0 -0
  304. package/scaffold/instructions/.agents/skills/3d-modeling/$inspection.md +0 -0
  305. package/scaffold/instructions/.agents/skills/3d-modeling/$lofting.md +0 -0
  306. package/scaffold/instructions/.agents/skills/3d-modeling/$modularization.md +0 -0
  307. package/scaffold/instructions/.agents/skills/3d-modeling/$recovery.md +0 -0
  308. package/scaffold/instructions/.agents/skills/3d-modeling/$rigging.md +0 -0
  309. package/scaffold/instructions/.agents/skills/3d-modeling/$sources.md +0 -0
  310. package/scaffold/instructions/.agents/skills/3d-modeling/SKILL.md +32 -0
  311. package/scaffold/instructions/.agents/skills/3d-modeling/coarse-forms.md +25 -0
  312. package/scaffold/instructions/.agents/skills/audio/SKILL.md +28 -0
  313. package/scaffold/instructions/.agents/skills/audio/acquisition.md +25 -0
  314. package/scaffold/instructions/.agents/skills/audio/local-speech.md +11 -0
  315. package/scaffold/instructions/.agents/skills/audio/sound-effects.md +29 -0
  316. package/scaffold/instructions/.agents/skills/contracts/SKILL.md +41 -0
  317. package/scaffold/instructions/.agents/skills/contracts/development/$common.md +0 -0
  318. package/scaffold/instructions/.agents/skills/contracts/development/$design.md +0 -0
  319. package/scaffold/instructions/.agents/skills/contracts/development/$implementation.md +0 -0
  320. package/scaffold/instructions/.agents/skills/contracts/development/$testing.md +0 -0
  321. package/scaffold/instructions/.agents/skills/contracts/development/SKILL.md +22 -0
  322. package/scaffold/instructions/.agents/skills/contracts/development/behaviors.md +25 -0
  323. package/scaffold/instructions/.agents/skills/contracts/development/composition.md +29 -0
  324. package/scaffold/instructions/.agents/skills/contracts/development/entities.md +27 -0
  325. package/scaffold/instructions/.agents/skills/contracts/development/statements/behaviors.md +42 -0
  326. package/scaffold/instructions/.agents/skills/contracts/development/statements/composition.md +32 -0
  327. package/scaffold/instructions/.agents/skills/contracts/development/statements/entities.md +34 -0
  328. package/scaffold/instructions/.agents/skills/contracts/story/SKILL.md +44 -0
  329. package/scaffold/instructions/.agents/skills/contracts/story/shared/discovery/brief.md +9 -0
  330. package/scaffold/instructions/.agents/skills/contracts/story/shared/discovery/common.md +9 -0
  331. package/scaffold/instructions/.agents/skills/contracts/story/shared/discovery/narratives.md +9 -0
  332. package/scaffold/instructions/.agents/skills/contracts/story/shared/discovery/screenplay.md +9 -0
  333. package/scaffold/instructions/.agents/skills/contracts/story/shared/discovery/scripts.md +9 -0
  334. package/scaffold/instructions/.agents/skills/contracts/story/shared/discovery/settings.md +9 -0
  335. package/scaffold/instructions/.agents/skills/contracts/story/shared/discovery/treatments.md +9 -0
  336. package/scaffold/instructions/.agents/skills/contracts/story/shared/naturalness/common.md +17 -0
  337. package/scaffold/instructions/.agents/skills/contracts/story/shared/naturalness/obligations/common.md +9 -0
  338. package/scaffold/instructions/.agents/skills/contracts/story/shared/naturalness/obligations/realized.md +9 -0
  339. package/scaffold/instructions/.agents/skills/contracts/story/shared/naturalness/obligations/screenplay.md +9 -0
  340. package/scaffold/instructions/.agents/skills/contracts/story/shared/naturalness/obligations/scripts.md +9 -0
  341. package/scaffold/instructions/.agents/skills/contracts/story/shared/naturalness/realized.md +9 -0
  342. package/scaffold/instructions/.agents/skills/contracts/story/shared/naturalness/screenplay.md +13 -0
  343. package/scaffold/instructions/.agents/skills/contracts/story/shared/naturalness/scripts.md +9 -0
  344. package/scaffold/instructions/.agents/skills/contracts/story/shared/obligations/brief.md +9 -0
  345. package/scaffold/instructions/.agents/skills/contracts/story/shared/obligations/common.md +13 -0
  346. package/scaffold/instructions/.agents/skills/contracts/story/shared/obligations/index.md +13 -0
  347. package/scaffold/instructions/.agents/skills/contracts/story/shared/obligations/narratives.md +13 -0
  348. package/scaffold/instructions/.agents/skills/contracts/story/shared/obligations/review.md +13 -0
  349. package/scaffold/instructions/.agents/skills/contracts/story/shared/obligations/screenplay.md +13 -0
  350. package/scaffold/instructions/.agents/skills/contracts/story/shared/obligations/scripts.md +13 -0
  351. package/scaffold/instructions/.agents/skills/contracts/story/shared/obligations/settings.md +13 -0
  352. package/scaffold/instructions/.agents/skills/contracts/story/shared/obligations/treatments.md +13 -0
  353. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/brief.md +13 -0
  354. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/common.md +13 -0
  355. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/index.md +13 -0
  356. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/narratives.md +13 -0
  357. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/realized.md +13 -0
  358. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/research.md +13 -0
  359. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/review.md +13 -0
  360. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/screenplay.md +17 -0
  361. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/scripts.md +13 -0
  362. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/settings.md +13 -0
  363. package/scaffold/instructions/.agents/skills/contracts/story/shared/principles/treatments.md +13 -0
  364. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/discovery/brief.md +21 -0
  365. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/discovery/common.md +42 -0
  366. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/discovery/narratives.md +8 -0
  367. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/discovery/screenplay.md +15 -0
  368. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/discovery/scripts.md +11 -0
  369. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/discovery/settings.md +25 -0
  370. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/discovery/treatments.md +9 -0
  371. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/naturalness/common.md +94 -0
  372. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/naturalness/obligations/common.md +20 -0
  373. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/naturalness/obligations/realized.md +15 -0
  374. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/naturalness/obligations/screenplay.md +11 -0
  375. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/naturalness/obligations/scripts.md +17 -0
  376. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/naturalness/realized.md +19 -0
  377. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/naturalness/screenplay.md +25 -0
  378. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/naturalness/scripts.md +19 -0
  379. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/obligations/brief.md +17 -0
  380. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/obligations/common.md +31 -0
  381. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/obligations/index.md +15 -0
  382. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/obligations/narratives.md +43 -0
  383. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/obligations/review.md +37 -0
  384. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/obligations/screenplay.md +26 -0
  385. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/obligations/scripts.md +26 -0
  386. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/obligations/settings.md +38 -0
  387. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/obligations/treatments.md +31 -0
  388. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/brief.md +21 -0
  389. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/common.md +15 -0
  390. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/index.md +17 -0
  391. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/narratives.md +41 -0
  392. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/realized.md +17 -0
  393. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/research.md +34 -0
  394. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/review.md +37 -0
  395. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/screenplay.md +82 -0
  396. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/scripts.md +45 -0
  397. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/settings.md +34 -0
  398. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/principles/treatments.md +27 -0
  399. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/upstream/screenplay.md +14 -0
  400. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/upstream/scripts.md +12 -0
  401. package/scaffold/instructions/.agents/skills/contracts/story/shared/statements/upstream/treatments.md +10 -0
  402. package/scaffold/instructions/.agents/skills/contracts/story/shared/upstream/screenplay.md +9 -0
  403. package/scaffold/instructions/.agents/skills/contracts/story/shared/upstream/scripts.md +9 -0
  404. package/scaffold/instructions/.agents/skills/contracts/story/shared/upstream/treatments.md +9 -0
  405. package/scaffold/instructions/.agents/skills/development/$repair.md +0 -0
  406. package/scaffold/instructions/.agents/skills/development/SKILL.md +33 -0
  407. package/scaffold/instructions/.agents/skills/development/entities.md +43 -0
  408. package/scaffold/instructions/.agents/skills/development/reuse.md +47 -0
  409. package/scaffold/instructions/.agents/skills/development/source-layout.md +69 -0
  410. package/scaffold/instructions/.agents/skills/development/testing.md +27 -0
  411. package/scaffold/instructions/.agents/skills/evidence/SKILL.md +16 -0
  412. package/scaffold/instructions/.agents/skills/evidence/adoption.md +11 -0
  413. package/scaffold/instructions/.agents/skills/evidence/answering.md +11 -0
  414. package/scaffold/instructions/.agents/skills/evidence/configuration.md +23 -0
  415. package/scaffold/instructions/.agents/skills/image/SKILL.md +69 -0
  416. package/scaffold/instructions/.agents/skills/motion/$authoring.md +0 -0
  417. package/scaffold/instructions/.agents/skills/motion/$contacts.md +0 -0
  418. package/scaffold/instructions/.agents/skills/motion/$laws.md +0 -0
  419. package/scaffold/instructions/.agents/skills/motion/$layers.md +0 -0
  420. package/scaffold/instructions/.agents/skills/motion/$transitions.md +0 -0
  421. package/scaffold/instructions/.agents/skills/motion/$variation.md +0 -0
  422. package/scaffold/instructions/.agents/skills/motion/$verification.md +0 -0
  423. package/scaffold/instructions/.agents/skills/motion/SKILL.md +55 -0
  424. package/scaffold/instructions/.agents/skills/motion/catalog-cases.md +11 -0
  425. package/scaffold/instructions/.agents/skills/motion/control-channels.md +19 -0
  426. package/scaffold/instructions/.agents/skills/motion/frame-evaluation.md +25 -0
  427. package/scaffold/instructions/.agents/skills/motion/method-references.md +23 -0
  428. package/scaffold/instructions/.agents/skills/motion/physical-feedback.md +31 -0
  429. package/scaffold/instructions/.agents/skills/motion/retargeting.md +23 -0
  430. package/scaffold/instructions/.agents/skills/motion/segment-review.md +17 -0
  431. package/scaffold/instructions/.agents/skills/motion/staging.md +29 -0
  432. package/scaffold/instructions/.agents/skills/production/SKILL.md +45 -0
  433. package/scaffold/instructions/.agents/skills/production/assembly.md +30 -0
  434. package/scaffold/instructions/.agents/skills/production/media-records.md +29 -0
  435. package/scaffold/instructions/.agents/skills/production/project-context.md +25 -0
  436. package/scaffold/instructions/.agents/skills/production/stage-caches.md +30 -0
  437. package/scaffold/instructions/.agents/skills/production/sustained-runs.md +21 -0
  438. package/scaffold/instructions/.agents/skills/production/sync-and-reorganization.md +21 -0
  439. package/scaffold/instructions/.agents/skills/review/SKILL.md +24 -0
  440. package/scaffold/instructions/.agents/skills/review/delivery-review.md +65 -0
  441. package/scaffold/instructions/.agents/skills/review/estimation.md +48 -0
  442. package/scaffold/instructions/.agents/skills/review/independent-reading.md +39 -0
  443. package/scaffold/instructions/.agents/skills/review/narrative-rounds.md +53 -0
  444. package/scaffold/instructions/.agents/skills/review/source-review.md +31 -0
  445. package/scaffold/instructions/.agents/skills/story/SKILL.md +20 -0
  446. package/scaffold/instructions/.agents/skills/story/correction/SKILL.md +13 -0
  447. package/scaffold/instructions/.agents/skills/story/correction/inspection.md +29 -0
  448. package/scaffold/instructions/.agents/skills/story/correction/repair.md +35 -0
  449. package/scaffold/instructions/.agents/skills/story/document-layout.md +38 -0
  450. package/scaffold/instructions/.agents/skills/story/evidence/SKILL.md +13 -0
  451. package/scaffold/instructions/.agents/skills/story/evidence/answer-placement.md +13 -0
  452. package/scaffold/instructions/.agents/skills/story/evidence/answer-writing.md +23 -0
  453. package/scaffold/instructions/.agents/skills/story/layers/SKILL.md +17 -0
  454. package/scaffold/instructions/.agents/skills/story/layers/brief.md +29 -0
  455. package/scaffold/instructions/.agents/skills/story/layers/notation.md +34 -0
  456. package/scaffold/instructions/.agents/skills/story/layers/screenplay.md +15 -0
  457. package/scaffold/instructions/.agents/skills/story/layers/scripts.md +11 -0
  458. package/scaffold/instructions/.agents/skills/story/layers/settings.md +39 -0
  459. package/scaffold/instructions/.agents/skills/story/layers/treatments.md +9 -0
  460. package/scaffold/instructions/.agents/skills/story/naturalness/SKILL.md +13 -0
  461. package/scaffold/instructions/.agents/skills/story/naturalness/rewriting.md +17 -0
  462. package/scaffold/instructions/.agents/skills/story/naturalness/transfer.md +11 -0
  463. package/scaffold/instructions/.agents/skills/story/planning/SKILL.md +15 -0
  464. package/scaffold/instructions/.agents/skills/story/planning/direction.md +14 -0
  465. package/scaffold/instructions/.agents/skills/story/planning/discovery.md +20 -0
  466. package/scaffold/instructions/.agents/skills/story/planning/requirements.md +25 -0
  467. package/scaffold/instructions/.agents/skills/story/planning/research.md +25 -0
  468. package/scaffold/instructions/.agents/skills/story/workflow.md +61 -0
  469. package/scaffold/instructions/.agents/skills/video/SKILL.md +29 -0
  470. package/scaffold/instructions/.agents/skills/video/diffusion.md +33 -0
  471. package/scaffold/instructions/.agents/skills/video/generation.md +27 -0
  472. package/scaffold/instructions/.agents/skills/video/prompts.md +51 -0
  473. package/scaffold/instructions/.agents/skills/visual-debugging/$capture.md +0 -0
  474. package/scaffold/instructions/.agents/skills/visual-debugging/$comparison.md +0 -0
  475. package/scaffold/instructions/.agents/skills/visual-debugging/$correction-rounds.md +0 -0
  476. package/scaffold/instructions/.agents/skills/visual-debugging/$passes.md +0 -0
  477. package/scaffold/instructions/.agents/skills/visual-debugging/$rendering-cost.md +0 -0
  478. package/scaffold/instructions/.agents/skills/visual-debugging/SKILL.md +30 -0
  479. package/scaffold/instructions/AGENTS.md +96 -0
  480. package/scaffold/instructions/CLAUDE.md +1 -0
  481. package/scaffold/production/PROJECT.md +3 -0
  482. package/scaffold/production/README.md +146 -0
  483. package/scaffold/production/_gitignore +20 -0
  484. package/scaffold/production/evidence.config.ts +12 -0
  485. package/scaffold/production/index.html +20 -0
  486. package/scaffold/production/lint.config.ts +46 -0
  487. package/scaffold/production/package.json +54 -0
  488. package/scaffold/production/src/IFilm.ts +41 -0
  489. package/scaffold/production/src/IFilmProduction.ts +80 -0
  490. package/scaffold/production/src/clampProductionSeconds.ts +21 -0
  491. package/scaffold/production/src/composition/films/index.ts +10 -0
  492. package/scaffold/production/src/composition/films/starter.ts +45 -0
  493. package/scaffold/production/src/executable/capture.ts +489 -0
  494. package/scaffold/production/src/executable/physics.ts +48 -0
  495. package/scaffold/production/src/executable/planCaptureStills.ts +65 -0
  496. package/scaffold/production/src/executable/recovery/node/artifact/archiveAutoMovieRecoveryModel.ts +171 -0
  497. package/scaffold/production/src/executable/recovery/node/artifact/createAutoMovieRecoveryArtifact.ts +268 -0
  498. package/scaffold/production/src/executable/recovery/node/artifact/index.ts +3 -0
  499. package/scaffold/production/src/executable/recovery/node/artifact/writeAutoMovieRecoveryArtifact.ts +303 -0
  500. package/scaffold/production/src/executable/recovery/node/cli.ts +12 -0
  501. package/scaffold/production/src/executable/recovery/node/index.ts +9 -0
  502. package/scaffold/production/src/executable/recovery/node/internal/IAutoMovieRecoveryMemoryUsage.ts +25 -0
  503. package/scaffold/production/src/executable/recovery/node/internal/RecoveryFileVectorTable.ts +95 -0
  504. package/scaffold/production/src/executable/recovery/node/internal/RecoveryFileVectorTableInput.ts +50 -0
  505. package/scaffold/production/src/executable/recovery/node/internal/createRecoveryFileVectorTable.ts +181 -0
  506. package/scaffold/production/src/executable/recovery/node/internal/observeRecoveryAtlas.ts +492 -0
  507. package/scaffold/production/src/executable/recovery/node/internal/readAutoMovieRecoveryBoundedFile.ts +57 -0
  508. package/scaffold/production/src/executable/recovery/node/internal/readRecoveryCameraImages.ts +80 -0
  509. package/scaffold/production/src/executable/recovery/node/internal/readRecoveryFixedReference.ts +26 -0
  510. package/scaffold/production/src/executable/recovery/node/internal/recovery.ts +272 -0
  511. package/scaffold/production/src/executable/recovery/node/internal/recoveryAtlas.ts +152 -0
  512. package/scaffold/production/src/executable/recovery/node/internal/recoveryCameraMap.ts +113 -0
  513. package/scaffold/production/src/executable/recovery/node/internal/recoveryCameraScene.ts +117 -0
  514. package/scaffold/production/src/executable/recovery/node/internal/recoveryCameras.ts +158 -0
  515. package/scaffold/production/src/executable/recovery/node/internal/recoveryContourPath.ts +185 -0
  516. package/scaffold/production/src/executable/recovery/node/internal/recoveryImages.ts +176 -0
  517. package/scaffold/production/src/executable/recovery/node/internal/recoveryLocal.ts +151 -0
  518. package/scaffold/production/src/executable/recovery/node/internal/recoveryOpen.ts +237 -0
  519. package/scaffold/production/src/executable/recovery/node/mesh/createAutoMovieRecoveryContourFileMesh.ts +265 -0
  520. package/scaffold/production/src/executable/recovery/node/mesh/createAutoMovieRecoveryMeshSpool.ts +252 -0
  521. package/scaffold/production/src/executable/recovery/node/mesh/index.ts +3 -0
  522. package/scaffold/production/src/executable/recovery/node/mesh/readAutoMovieRecoveryMeshFrontier.ts +239 -0
  523. package/scaffold/production/src/executable/recovery/node/publishAutoMovieRecoveryArtifact.ts +63 -0
  524. package/scaffold/production/src/executable/recovery/node/reconstruction/index.ts +1 -0
  525. package/scaffold/production/src/executable/recovery/node/reconstruction/reconstructAutoMovieRecoveryLocal.ts +473 -0
  526. package/scaffold/production/src/executable/recovery/node/runAutoMovieRecoveryCommand.ts +148 -0
  527. package/scaffold/production/src/executable/render/headlessCapture/AutoMovieHeadlessCaptureError.ts +1 -0
  528. package/scaffold/production/src/executable/render/headlessCapture/AutoMovieHeadlessCaptureErrorCode.ts +1 -0
  529. package/scaffold/production/src/executable/render/headlessCapture/AutoMovieHeadlessWaitUntil.ts +1 -0
  530. package/scaffold/production/src/executable/render/headlessCapture/IAutoMovieHeadlessCaptureOptions.ts +79 -0
  531. package/scaffold/production/src/executable/render/headlessCapture/IAutoMovieHeadlessCaptureSession.ts +39 -0
  532. package/scaffold/production/src/executable/render/headlessCapture/IAutoMovieHeadlessFrameWriter.ts +20 -0
  533. package/scaffold/production/src/executable/render/headlessCapture/IAutoMovieHeadlessLocator.ts +1 -0
  534. package/scaffold/production/src/executable/render/headlessCapture/IAutoMovieHeadlessPage.ts +1 -0
  535. package/scaffold/production/src/executable/render/headlessCapture/createHeadlessCaptureAdapter.ts +92 -0
  536. package/scaffold/production/src/executable/render/headlessCapture/index.ts +9 -0
  537. package/scaffold/production/src/executable/render/node/IAutoMovieViewerVideoOptions.ts +128 -0
  538. package/scaffold/production/src/executable/render/node/IAutoMovieViewerVideoResult.ts +43 -0
  539. package/scaffold/production/src/executable/render/node/IProductionRenditionClip.ts +44 -0
  540. package/scaffold/production/src/executable/render/node/acquireViewerBrowser.ts +24 -0
  541. package/scaffold/production/src/executable/render/node/addProductionMp4Sample.ts +89 -0
  542. package/scaffold/production/src/executable/render/node/appendLosslessVideoClip.ts +62 -0
  543. package/scaffold/production/src/executable/render/node/assembleProductionChunkVideoMp4.ts +167 -0
  544. package/scaffold/production/src/executable/render/node/assertProductionFeatureUsesRenditionClips.ts +184 -0
  545. package/scaffold/production/src/executable/render/node/assertProductionFeatureUsesRenditionVideo.ts +127 -0
  546. package/scaffold/production/src/executable/render/node/assertProductionRenditionClipDelivery.ts +102 -0
  547. package/scaffold/production/src/executable/render/node/cache/IAutoMovieDirectoryArtifactStore.ts +59 -0
  548. package/scaffold/production/src/executable/render/node/cache/IAutoMovieViewerFrameCacheReport.ts +30 -0
  549. package/scaffold/production/src/executable/render/node/cache/cacheViewerCaptureSession.ts +187 -0
  550. package/scaffold/production/src/executable/render/node/cache/composeViewerFrameKeys.ts +55 -0
  551. package/scaffold/production/src/executable/render/node/cache/createAutoMovieArtifactMiddleware.ts +107 -0
  552. package/scaffold/production/src/executable/render/node/cache/createAutoMovieDirectoryArtifactStore.ts +203 -0
  553. package/scaffold/production/src/executable/render/node/cache/digestAutoMovieSourceTree.ts +66 -0
  554. package/scaffold/production/src/executable/render/node/cache/readViewerFrameStates.ts +95 -0
  555. package/scaffold/production/src/executable/render/node/capture/DEFAULT_CHROME_EXECUTABLE.ts +11 -0
  556. package/scaffold/production/src/executable/render/node/capture/IAutoMoviePageOperationFailure.ts +13 -0
  557. package/scaffold/production/src/executable/render/node/capture/IAutoMoviePageRenderAndSeeArtifact.ts +30 -0
  558. package/scaffold/production/src/executable/render/node/capture/IAutoMoviePageRenderAndSeeOptions.ts +51 -0
  559. package/scaffold/production/src/executable/render/node/capture/IAutoMoviePageSequenceMetadata.ts +27 -0
  560. package/scaffold/production/src/executable/render/node/capture/IAutoMoviePageSequenceRenderArtifact.ts +44 -0
  561. package/scaffold/production/src/executable/render/node/capture/IAutoMoviePageSequenceRenderOptions.ts +43 -0
  562. package/scaffold/production/src/executable/render/node/capture/IAutoMovieSequenceDissolvePixelCheck.ts +39 -0
  563. package/scaffold/production/src/executable/render/node/capture/captureRenderAndSee.ts +233 -0
  564. package/scaffold/production/src/executable/render/node/capture/captureSequenceRenderAndSee.ts +377 -0
  565. package/scaffold/production/src/executable/render/node/capture/index.ts +14 -0
  566. package/scaffold/production/src/executable/render/node/capture/preserveCleanupFailure.ts +34 -0
  567. package/scaffold/production/src/executable/render/node/capture/renderAndSeeCommand.ts +169 -0
  568. package/scaffold/production/src/executable/render/node/capture/renderSequenceAndSeeCommand.ts +165 -0
  569. package/scaffold/production/src/executable/render/node/capture/verifySequenceDissolvePixels.ts +179 -0
  570. package/scaffold/production/src/executable/render/node/conformProductionRenditionVideoMp4.ts +86 -0
  571. package/scaffold/production/src/executable/render/node/conformProductionVisualDeliveryVideoMp4.ts +230 -0
  572. package/scaffold/production/src/executable/render/node/decodeAutoMovieDelivery.ts +253 -0
  573. package/scaffold/production/src/executable/render/node/equalRational.ts +36 -0
  574. package/scaffold/production/src/executable/render/node/exactProductionClockProduct.ts +26 -0
  575. package/scaffold/production/src/executable/render/node/exportModelToGLB.ts +267 -0
  576. package/scaffold/production/src/executable/render/node/index.ts +27 -0
  577. package/scaffold/production/src/executable/render/node/loadModelGltfCore.ts +18 -0
  578. package/scaffold/production/src/executable/render/node/mixAutoMovieAudioCues.ts +74 -0
  579. package/scaffold/production/src/executable/render/node/muxProductionFeatureMp4.ts +170 -0
  580. package/scaffold/production/src/executable/render/node/neutralTrackPresentation.ts +59 -0
  581. package/scaffold/production/src/executable/render/node/normalizeProductionH264Mp4.ts +110 -0
  582. package/scaffold/production/src/executable/render/node/openLosslessVideoTrack.ts +81 -0
  583. package/scaffold/production/src/executable/render/node/parseMp4.ts +46 -0
  584. package/scaffold/production/src/executable/render/node/parseProductionMp4Output.ts +70 -0
  585. package/scaffold/production/src/executable/render/node/parseProductionRenditionClip.ts +92 -0
  586. package/scaffold/production/src/executable/render/node/planViewerVideo.ts +140 -0
  587. package/scaffold/production/src/executable/render/node/probeParsedProductionVideoMp4.ts +48 -0
  588. package/scaffold/production/src/executable/render/node/probeProductionPngPicture.ts +223 -0
  589. package/scaffold/production/src/executable/render/node/probeProductionRenderedMedia.ts +355 -0
  590. package/scaffold/production/src/executable/render/node/probeProductionVideoMp4.ts +27 -0
  591. package/scaffold/production/src/executable/render/node/probeVideoTrack.ts +220 -0
  592. package/scaffold/production/src/executable/render/node/productionRenditionVideoPlan.ts +149 -0
  593. package/scaffold/production/src/executable/render/node/recordViewerPlayback.ts +137 -0
  594. package/scaffold/production/src/executable/render/node/renderViewerFrames.ts +139 -0
  595. package/scaffold/production/src/executable/render/node/renderViewerVideo.ts +301 -0
  596. package/scaffold/production/src/executable/render/node/renderViewerVideoSession.ts +75 -0
  597. package/scaffold/production/src/executable/render/node/residentMp4Box.ts +36 -0
  598. package/scaffold/production/src/executable/render/node/residentPngJs.ts +26 -0
  599. package/scaffold/production/src/executable/render/node/runViewerVideoEncoder.ts +58 -0
  600. package/scaffold/production/src/executable/render/node/sameSampleDescription.ts +43 -0
  601. package/scaffold/production/src/executable/render/node/sameSampleFlags.ts +28 -0
  602. package/scaffold/production/src/executable/render/node/sampleBytes.ts +46 -0
  603. package/scaffold/production/src/executable/render/node/sampleDescription.ts +40 -0
  604. package/scaffold/production/src/executable/render/node/sampleOptions.ts +37 -0
  605. package/scaffold/production/src/executable/render/node/serializeDescriptionBox.ts +29 -0
  606. package/scaffold/production/src/executable/render/node/trimProductionAudioPresentation.ts +115 -0
  607. package/scaffold/production/src/executable/render/node/verifySampleStorage.ts +86 -0
  608. package/scaffold/production/src/executable/render/node/writeViewerFrameSheet.ts +101 -0
  609. package/scaffold/production/src/executable/render.ts +92 -0
  610. package/scaffold/production/src/executable/review.ts +54 -0
  611. package/scaffold/production/src/executable/viewer/inspection/createViewerDiskSource.ts +119 -0
  612. package/scaffold/production/src/executable/viewer/inspection/readViewerMaintainedSourceFiles.ts +64 -0
  613. package/scaffold/production/src/executable/viewer/node/capture/AutoMovieHeadlessCaptureError.ts +41 -0
  614. package/scaffold/production/src/executable/viewer/node/capture/AutoMovieHeadlessCaptureErrorCode.ts +22 -0
  615. package/scaffold/production/src/executable/viewer/node/capture/AutoMovieHeadlessWaitUntil.ts +18 -0
  616. package/scaffold/production/src/executable/viewer/node/capture/IAutoMovieHeadlessLocator.ts +32 -0
  617. package/scaffold/production/src/executable/viewer/node/capture/IAutoMovieHeadlessPage.ts +130 -0
  618. package/scaffold/production/src/executable/viewer/node/capture/IViewerCaptureOptions.ts +38 -0
  619. package/scaffold/production/src/executable/viewer/node/capture/IViewerCaptureSession.ts +41 -0
  620. package/scaffold/production/src/executable/viewer/node/capture/createViewerCaptureSession.ts +154 -0
  621. package/scaffold/production/src/executable/viewer/node/capture/index.ts +8 -0
  622. package/scaffold/production/src/executable/viewer/node/index.ts +2 -0
  623. package/scaffold/production/src/executable/viewer/process/ProcessOwnership.ts +102 -0
  624. package/scaffold/production/src/executable/viewer/process/internal/IProcessChildObservation.ts +18 -0
  625. package/scaffold/production/src/executable/viewer/process/internal/IProcessOwnershipHost.ts +70 -0
  626. package/scaffold/production/src/executable/viewer/process/internal/ProcessOwnershipController.ts +125 -0
  627. package/scaffold/production/src/executable/viewer/process/internal/WindowsProcessOwnershipPrograms.ts +52 -0
  628. package/scaffold/production/src/executable/viewer/process/internal/createNodeProcessOwnershipHost.ts +41 -0
  629. package/scaffold/production/src/executable/viewer/process/internal/decodeLinuxProcessIdentity.ts +22 -0
  630. package/scaffold/production/src/executable/viewer/process/internal/decodePosixProcessIdentity.ts +24 -0
  631. package/scaffold/production/src/executable/viewer/process/internal/decodeWindowsProcessResult.ts +24 -0
  632. package/scaffold/production/src/executable/viewer/process/internal/readNativeProcessIdentity.ts +45 -0
  633. package/scaffold/production/src/executable/viewer/process/internal/requireProcessId.ts +15 -0
  634. package/scaffold/production/src/executable/viewer/process/internal/resolveProcessIdentityReadError.ts +15 -0
  635. package/scaffold/production/src/executable/viewer/process/internal/runWindowsProcessOperation.ts +41 -0
  636. package/scaffold/production/src/executable/viewer/process/internal/selectProcessOwnershipTree.ts +68 -0
  637. package/scaffold/production/src/main.ts +197 -0
  638. package/scaffold/production/src/selectFilm.ts +34 -0
  639. package/scaffold/production/test/features/executable/test_plan_capture_stills.ts +75 -0
  640. package/scaffold/production/test/features/test_clamp_production_seconds.ts +39 -0
  641. package/scaffold/production/test/features/test_select_film.ts +59 -0
  642. package/scaffold/production/test/features/testing/test_test_execution.ts +57 -0
  643. package/scaffold/production/test/features/testing/test_test_selection.ts +78 -0
  644. package/scaffold/production/test/helpers/assessTestExecution.ts +22 -0
  645. package/scaffold/production/test/helpers/selectTestFiles.ts +79 -0
  646. package/scaffold/production/test/index.ts +64 -0
  647. package/scaffold/production/test/tsconfig.json +6 -0
  648. package/scaffold/production/tsconfig.json +34 -0
  649. package/scaffold/production/tsconfig.test.json +9 -0
  650. package/scaffold/production/vite.config.ts +35 -0
  651. package/scaffold/workspace/README.md +42 -0
  652. package/scaffold/workspace/_gitignore +9 -0
  653. package/scaffold/workspace/package.json +19 -0
  654. package/scaffold/workspace/pnpm-workspace.yaml +46 -0
  655. package/src/AUTOMOVIE_TEMPLATE_CATALOGS.ts +48 -0
  656. package/src/AUTOMOVIE_TEMPLATE_VERSIONS.ts +39 -0
  657. package/src/AutoMovieScaffoldLayer.ts +18 -0
  658. package/src/FILE_ATTRIBUTE_DIRECTORY.ts +2 -0
  659. package/src/IAutoMovieCatalogVersionProps.ts +18 -0
  660. package/src/IAutoMovieScaffoldProps.ts +14 -0
  661. package/src/IAutoMovieScaffoldSourceEntry.ts +19 -0
  662. package/src/IAutoMovieTemplateDependencyVersionsProps.ts +19 -0
  663. package/src/IAutoMovieWorkspacePackageVersions.ts +44 -0
  664. package/src/IBoundChild.ts +86 -0
  665. package/src/IBoundChildStatus.ts +24 -0
  666. package/src/IBoundParent.ts +65 -0
  667. package/src/IBoundParentStatus.ts +15 -0
  668. package/src/ICreateResult.ts +35 -0
  669. package/src/IScaffoldCompletedFilePublicationOutcome.ts +17 -0
  670. package/src/IScaffoldCompletedPublication.ts +17 -0
  671. package/src/IScaffoldFileSnapshot.ts +28 -0
  672. package/src/IScaffoldParentPublicationRequest.ts +29 -0
  673. package/src/IScaffoldPartialFilePublicationOutcome.ts +25 -0
  674. package/src/IScaffoldPhysicalDirectory.ts +22 -0
  675. package/src/IScaffoldPosixConstants.ts +30 -0
  676. package/src/IScaffoldPublicationEntry.ts +22 -0
  677. package/src/IScaffoldPublicationFailure.ts +18 -0
  678. package/src/IScaffoldPublicationOptions.ts +19 -0
  679. package/src/IScaffoldPublicationReceipt.ts +29 -0
  680. package/src/IScaffoldRefusedFilePublicationOutcome.ts +20 -0
  681. package/src/IScaffoldSyncPlan.ts +26 -0
  682. package/src/IScaffoldSyncProps.ts +16 -0
  683. package/src/IWindowsFileInformation.ts +24 -0
  684. package/src/IWindowsLibrary.ts +148 -0
  685. package/src/SCAFFOLD_SYNC_STATE_FILE.ts +5 -0
  686. package/src/ScaffoldFilePublicationOutcome.ts +18 -0
  687. package/src/ScaffoldParentChangedError.ts +14 -0
  688. package/src/ScaffoldPublicationError.ts +58 -0
  689. package/src/assertOrdinaryFile.ts +20 -0
  690. package/src/assertOrdinarySingleLinkFile.ts +26 -0
  691. package/src/assertScaffoldOwnership.ts +29 -0
  692. package/src/assertScaffoldPhysicalDirectory.ts +29 -0
  693. package/src/assertScaffoldProjectName.ts +34 -0
  694. package/src/attachScaffoldSyncState.ts +30 -0
  695. package/src/captureEmptyScaffoldPhysicalDirectory.ts +45 -0
  696. package/src/captureScaffoldFile.ts +34 -0
  697. package/src/captureScaffoldPhysicalDirectory.ts +34 -0
  698. package/src/combineScaffoldFailures.ts +35 -0
  699. package/src/createAutoMovieCatalogVersionResolver.ts +117 -0
  700. package/src/createScaffoldSyncState.ts +33 -0
  701. package/src/createScaffoldVariables.ts +50 -0
  702. package/src/ensureScaffoldBaseDirectory.ts +55 -0
  703. package/src/ensureScaffoldFileDirectory.ts +75 -0
  704. package/src/index.ts +48 -0
  705. package/src/inside.ts +25 -0
  706. package/src/isScaffoldInstruction.ts +29 -0
  707. package/src/listAutoMovieScaffoldFiles.ts +56 -0
  708. package/src/loadWindowsLibrary.ts +277 -0
  709. package/src/mergeScaffoldFiles.ts +39 -0
  710. package/src/missingPath.ts +16 -0
  711. package/src/nativeError.ts +15 -0
  712. package/src/openPosixParent.ts +155 -0
  713. package/src/openWindowsParent.ts +305 -0
  714. package/src/overwriteScaffoldFile.ts +262 -0
  715. package/src/physicalDirectoryIdentity.ts +33 -0
  716. package/src/physicalVersion.ts +18 -0
  717. package/src/planScaffoldPublication.ts +100 -0
  718. package/src/planScaffoldSync.ts +122 -0
  719. package/src/publishFiles.ts +120 -0
  720. package/src/publishNativeScaffoldFile.ts +287 -0
  721. package/src/publishScaffoldCandidate.ts +94 -0
  722. package/src/readAutoMovieScaffoldSources.ts +82 -0
  723. package/src/readScaffoldSyncFile.ts +66 -0
  724. package/src/renderScaffold.ts +43 -0
  725. package/src/renderScaffoldEntries.ts +110 -0
  726. package/src/renderScaffoldInstructions.ts +22 -0
  727. package/src/renderScaffoldLayer.ts +38 -0
  728. package/src/renderTemplate.ts +62 -0
  729. package/src/renderWorkspaceProductionScaffold.ts +35 -0
  730. package/src/renderWorkspaceScaffold.ts +43 -0
  731. package/src/replaceSharedScaffoldFile.ts +88 -0
  732. package/src/resolveAutoMovieCatalogVersion.ts +27 -0
  733. package/src/resolveAutoMovieTemplateDependencyVersions.ts +70 -0
  734. package/src/resolveScaffoldPosixConstants.ts +50 -0
  735. package/src/scaffoldAssetDirectory.ts +30 -0
  736. package/src/scaffoldPhysicalIdentity.ts +21 -0
  737. package/src/scaffoldSharedSkillDirectory.ts +25 -0
  738. package/src/scaffoldSharedSkillPath.ts +31 -0
  739. package/src/syncScaffold.ts +38 -0
  740. package/src/writeFiles.ts +48 -0
  741. package/src/writeScaffoldFile.ts +88 -0
  742. package/src/writtenVersion.ts +19 -0
@@ -0,0 +1,74 @@
1
+ import { decodeProductionAudioAsset } from "@automovie/ingest";
2
+ import {
3
+ encodeAutoMovieWavPcm16,
4
+ mixAutoMovieAudioPcm,
5
+ } from "@automovie/render";
6
+ import { createHash } from "node:crypto";
7
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
8
+ import path from "node:path";
9
+
10
+ /**
11
+ * Mix WAV assets into one stereo 16-bit PCM WAV soundtrack, usable as
12
+ * `renderViewerVideo`'s `audioMix`.
13
+ *
14
+ * A thin file shell over the pure laws: every referenced asset is read once
15
+ * and decoded by the public Ingest decoder (16-bit PCM or 32-bit float, mono
16
+ * or stereo folded to mono, resampled linearly to the output rate), the cues
17
+ * are summed by {@link mixAutoMovieAudioPcm} into `round(durationSeconds *
18
+ * sampleRate)` frames, and the result is encoded by
19
+ * {@link encodeAutoMovieWavPcm16}. Unreferenced assets are not read. The
20
+ * output and its SHA-256 are deterministic for equal inputs.
21
+ *
22
+ * @returns The written path and the SHA-256 of its bytes.
23
+ * @evidence contracts/development/common.md#meaningful-documentation Gives the purpose (Mix WAV assets into one stereo 16-bit PCM WAV soundtrack, usable as `renderViewerVideo`'s `audioMix`) and documents the returned value as stated in this comment.
24
+ * @evidence contracts/development/implementation.md#principled-implementation Implements the documented behavior (Mix WAV assets into one stereo 16-bit PCM WAV soundtrack, usable as `renderViewerVideo`'s `audioMix`) directly over its typed inputs (`input`) as nested iteration of depth 2 (for-of over new Set( input.cues.map((c: mixAutoM; map over input.cues), delegating to `decodeProductionAudioAsset`, `readFile`, `mixAutoMovieAudioPcm`, `Math.round`, `encodeAutoMovieWavPcm16`; the premises are the units, frames and ranges stated in its parameter documentation, enforced only where the body throws (1 throw site). Apart from structural 0, 1 and 2 the body uses no numeric literal.
25
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure One async operation of 36 lines and 7 top-level statements that reuses `decodeProductionAudioAsset`, `readFile`, `mixAutoMovieAudioPcm`, `Math.round`, `encodeAutoMovieWavPcm16` from their owners instead of copying them; it adds no option, layer or abstraction beyond its documented parameters.
26
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Scanning the body finds no `any`, type assertion, non-null assertion, suppression directive or TODO, and no branch keyed on a consumer, fixture or expected answer; values come from its parameters.
27
+ * @evidence contracts/development/implementation.md#efficient-algorithms Cost is driven by the sizes of `input`; the dominant cost is nested iteration of depth 2 (for-of over new Set( input.cues.map((c: mixAutoM; map over input.cues), performed once per call with 12 allocation sites (literals and constructed values). No speedup is claimed and none is measured.
28
+ * @evidence contracts/development/implementation.md#reuse-equivalent-work Awaits 3 calls per invocation and shares no result or in-flight work between invocations: equivalence of effectful calls is not decided here, so every call repeats its effects.
29
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The body touches I/O, timers, listeners or process state; it retains nothing after it settles beyond its result, and any handle it opens is owned and released by the call or by its callees.
30
+ */
31
+ export async function mixAutoMovieAudioCues(input: {
32
+ /** Output samples per second. */ sampleRate: number;
33
+ /** Output length, seconds; positive. */ durationSeconds: number;
34
+ /** WAV file path by asset id. */ assets: Readonly<Record<string, string>>;
35
+ /** The cues, as {@link mixAutoMovieAudioPcm.ICue}. */ cues: readonly mixAutoMovieAudioPcm.ICue[];
36
+ /** Output WAV path; its directory is created. */ outputPath: string;
37
+ /** Linear gain on every cue; 1 by default. */ master?: number;
38
+ /** Edge fade, seconds; 0.004 by default. */ fadeSeconds?: number;
39
+ }): Promise<{ path: string; sha256: string }> {
40
+ const sources: Record<string, Float32Array> = {};
41
+ for (const id of new Set(
42
+ input.cues.map((c: mixAutoMovieAudioPcm.ICue): string => c.asset),
43
+ )) {
44
+ const file: string | undefined = input.assets[id];
45
+ if (file === undefined)
46
+ throw new Error(`Audio cue names an unknown asset: ${id}`);
47
+ sources[id] = decodeProductionAudioAsset({
48
+ path: file,
49
+ bytes: new Uint8Array(await readFile(file)),
50
+ sampleRate: input.sampleRate,
51
+ }).samples;
52
+ }
53
+ const mixed: ReturnType<typeof mixAutoMovieAudioPcm> = mixAutoMovieAudioPcm({
54
+ sampleRate: input.sampleRate,
55
+ frames: Math.round(input.durationSeconds * input.sampleRate),
56
+ sources,
57
+ cues: input.cues,
58
+ ...(input.master === undefined ? {} : { master: input.master }),
59
+ ...(input.fadeSeconds === undefined
60
+ ? {}
61
+ : { fadeSeconds: input.fadeSeconds }),
62
+ });
63
+ const bytes: Uint8Array = encodeAutoMovieWavPcm16(
64
+ mixed.left,
65
+ mixed.right,
66
+ input.sampleRate,
67
+ );
68
+ await mkdir(path.dirname(input.outputPath), { recursive: true });
69
+ await writeFile(input.outputPath, bytes);
70
+ return {
71
+ path: input.outputPath,
72
+ sha256: createHash("sha256").update(bytes).digest("hex"),
73
+ };
74
+ }
@@ -0,0 +1,170 @@
1
+ import type {
2
+ IAutoMovieProductionMediaProbe,
3
+ IAutoMovieProductionVideoProbe,
4
+ } from "@automovie/interface";
5
+ import type { IsoFileOptions, Movie, Sample, Track, createFile } from "mp4box";
6
+
7
+ import { addProductionMp4Sample } from "./addProductionMp4Sample";
8
+ import { exactProductionClockProduct } from "./exactProductionClockProduct";
9
+ import { parseMp4 } from "./parseMp4";
10
+ import { parseProductionMp4Output } from "./parseProductionMp4Output";
11
+ import { probeParsedProductionVideoMp4 } from "./probeParsedProductionVideoMp4";
12
+ import { probeProductionRenderedMedia } from "./probeProductionRenderedMedia";
13
+ import { residentMp4Box } from "./residentMp4Box";
14
+ import { sampleBytes } from "./sampleBytes";
15
+ import { sampleDescription } from "./sampleDescription";
16
+ import { sampleOptions } from "./sampleOptions";
17
+ import { trimProductionAudioPresentation } from "./trimProductionAudioPresentation";
18
+
19
+ /**
20
+ * Mux one single-track H.264 video MP4 and one Opus audio-mix MP4 of exactly the same runtime into a two-track feature MP4, copying every coded sample unchanged.
21
+ *
22
+ * The video must pass the production video probe and the audio the audio-mix probe, including its Opus delivery profile. Their movie runtimes must be exactly equal, decided by cross-multiplying durations and timescales. The output keeps both tracks' media clocks, uses the video timescale as the movie clock, and gives the audio track one edit that skips the Opus priming samples and presents exactly the audio's runtime. The result is re-probed as a delivered feature before it is returned.
23
+ *
24
+ * Throws the probes' refusals for an invalid input, `MP4 presentation clocks must be positive safe integers.` for a zero or unsafe runtime term, `Feature mux requires byte sources with exactly equal track runtimes.` for unequal runtimes, and the feature probe's refusal if the written file does not verify.
25
+ *
26
+ * No production module calls this function at present; only tests reach it.
27
+ *
28
+ * @evidence contracts/development/implementation.md#principled-implementation Samples are copied with their own timing and flags, so neither elementary stream is decoded or re-encoded, and runtime equality is the exact integer identity `videoDuration * audioTimescale = audioDuration * videoTimescale`; the presentation length in 48 kHz samples is an exact BigInt quotient because the Opus profile already proved it whole.
29
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Input admission is the existing video and audio-mix probes, the audio edit is `trimProductionAudioPresentation`, and the output check is the feature probe; this function owns only the runtime proof and the two-track copy. The gap is that no production consumer remains.
30
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Unequal or unsafe runtimes are refused rather than padded or trimmed to fit, the audio probe's kind is checked rather than cast, and no input is special-cased.
31
+ * @evidence contracts/development/common.md#meaningful-documentation The doc states what each input must pass, the runtime rule, how the output clocks and the audio edit are formed, the final verification, and every refusal.
32
+ * @evidence contracts/development/implementation.md#efficient-algorithms The video parse is shared by its admission and copy, the audio is parsed twice because its probe exposes no parsed form, each video and audio sample is appended once, and the output is parsed once. Byte copying and serialization scale with the encoded bytes, but each admitted track's residency proof additionally costs O(M + S log(M + 1)) for its S samples and the parsed file's M media boxes, with box and returned-list inspection on top; the whole mux is not strictly linear in the input bytes.
33
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each call muxes one caller-held pair of byte arrays and retains no result; equal inputs give byte-identical output that a caller may store.
34
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The copied input parses, source sample views, output sample payloads and boxes, serialized output, and output probe's copied buffer and tables can coexist during verification. The audio admission parse is temporary to its probe; the copy parse stays referenced by this call. Input bytes, samples and boxes are uncapped, and no exact peak ratio is established; after return only the returned array is retained by the caller, with no handle or background task.
35
+ */
36
+ export const muxProductionFeatureMp4: (props: {
37
+ video: Uint8Array;
38
+ audio: Uint8Array;
39
+ }) => Uint8Array = (props: {
40
+ /** Single-track H.264 video MP4. */
41
+ video: Uint8Array;
42
+
43
+ /** Single-track Opus audio-mix MP4 of the same runtime. */
44
+ audio: Uint8Array;
45
+ }): Uint8Array => {
46
+ const video: { file: ReturnType<typeof createFile>; movie: Movie } =
47
+ parseProductionMp4Output(props.video);
48
+ const videoProbe: IAutoMovieProductionVideoProbe =
49
+ probeParsedProductionVideoMp4(props.video, video);
50
+ const audioProbe: IAutoMovieProductionMediaProbe =
51
+ probeProductionRenderedMedia({
52
+ kind: "audio-mix",
53
+ mediaType: "audio/mp4",
54
+ bytes: props.audio,
55
+ });
56
+ if (audioProbe.kind !== "audio")
57
+ throw new Error("Feature mux requires an audio-mix MP4 audio track.");
58
+ const audio: { file: ReturnType<typeof createFile>; movie: Movie } = parseMp4(
59
+ props.audio,
60
+ );
61
+ const videoTrack: Track = video.movie.videoTracks[0]!;
62
+ const audioTrack: Track = audio.movie.audioTracks[0]!;
63
+ if (
64
+ exactProductionClockProduct(
65
+ videoProbe.presentation.movieDuration,
66
+ audioProbe.timebase.movieTimescale,
67
+ ) !==
68
+ exactProductionClockProduct(
69
+ audioProbe.timebase.movieDuration,
70
+ videoProbe.presentation.movieTimescale,
71
+ )
72
+ )
73
+ throw new Error(
74
+ "Feature mux requires byte sources with exactly equal track runtimes.",
75
+ );
76
+ // The audio-mix probe's Opus profile proved the presentation a whole number
77
+ // of samples on its 48 kHz clock, and the runtime comparison proved the
78
+ // movie timescale a positive safe integer, so this quotient is exact.
79
+ const presentationSamples: number = Number(
80
+ exactProductionClockProduct(
81
+ audioProbe.timebase.movieDuration,
82
+ audioProbe.sampleRate,
83
+ ) / BigInt(audioProbe.timebase.movieTimescale),
84
+ );
85
+ const output: ReturnType<typeof createFile> = residentMp4Box().createFile();
86
+ output.init({
87
+ brands: ["isom", "iso2", "mp41", "Opus"],
88
+ timescale: videoTrack.timescale,
89
+ duration: videoTrack.duration,
90
+ });
91
+ copyTrack({
92
+ output,
93
+ source: video.file,
94
+ bytes: props.video,
95
+ track: videoTrack,
96
+ name: "AutoMovie H.264 feature",
97
+ });
98
+ const outputAudioTrack: number = copyTrack({
99
+ output,
100
+ source: audio.file,
101
+ bytes: props.audio,
102
+ track: audioTrack,
103
+ name: "AutoMovie deterministic mix",
104
+ });
105
+ trimProductionAudioPresentation({
106
+ file: output,
107
+ track: outputAudioTrack,
108
+ mediaTimescale: audioTrack.timescale,
109
+ movieTimescale: videoTrack.timescale,
110
+ primingSamples: audioProbe.primingSamples,
111
+ presentationSamples,
112
+ });
113
+ const bytes: Uint8Array = new Uint8Array(output.getBuffer().buffer);
114
+ probeProductionRenderedMedia({
115
+ kind: "feature",
116
+ mediaType: "video/mp4",
117
+ bytes,
118
+ });
119
+ return bytes;
120
+ };
121
+
122
+ /** Add one track mirroring `track` to `output` and copy every sample into it. */
123
+ const copyTrack: (props: {
124
+ output: ReturnType<typeof createFile>;
125
+ source: ReturnType<typeof createFile>;
126
+ bytes: Uint8Array;
127
+ track: Track;
128
+ name: string;
129
+ }) => number = (props: {
130
+ output: ReturnType<typeof createFile>;
131
+ source: ReturnType<typeof createFile>;
132
+ bytes: Uint8Array;
133
+ track: Track;
134
+ name: string;
135
+ }): number => {
136
+ const samples: Sample[] = props.source.getTrackSamplesInfo(props.track.id);
137
+ const description: ReturnType<typeof sampleDescription> = sampleDescription(
138
+ samples[0]!,
139
+ );
140
+ const options: IsoFileOptions = {
141
+ type: description.type,
142
+ hdlr: props.track.type === "audio" ? "soun" : "vide",
143
+ name: props.name,
144
+ timescale: props.track.timescale,
145
+ media_duration: props.track.duration,
146
+ duration: props.track.duration,
147
+ language: props.track.language,
148
+ description_boxes: description.boxes,
149
+ };
150
+ if (props.track.video !== undefined) {
151
+ options.width = props.track.video.width;
152
+ options.height = props.track.video.height;
153
+ }
154
+ if (props.track.audio !== undefined) {
155
+ options.samplerate = props.track.audio.sample_rate;
156
+ options.channel_count = props.track.audio.channel_count;
157
+ options.samplesize = props.track.audio.sample_size;
158
+ }
159
+ const id: number = props.output.addTrack(options);
160
+ // mp4box's addSample copies the payload into the output's media box, so a
161
+ // view of the source bytes is passed instead of a second copy.
162
+ for (const sample of samples)
163
+ addProductionMp4Sample(
164
+ props.output,
165
+ id,
166
+ sampleBytes(props.bytes, sample),
167
+ sampleOptions(sample),
168
+ );
169
+ return id;
170
+ };
@@ -0,0 +1,59 @@
1
+ import { AUTOMOVIE_MP4_UNITY_MATRIX } from "@automovie/render";
2
+ import type { Entry, Track } from "mp4box";
3
+
4
+ import { equalRational } from "./equalRational";
5
+
6
+ /**
7
+ * Whether `track` presents its media untransformed, starting at the media
8
+ * time `presentationStart`.
9
+ *
10
+ * The track must carry the ISO unity display matrix, and its movie duration
11
+ * over the movie timescale must equal its media duration over the media
12
+ * timescale exactly. Its edit list must be either empty, with
13
+ * `presentationStart` 0, or one edit that starts at `presentationStart` in
14
+ * media ticks, plays at rate 1, and lasts the media duration on the movie
15
+ * clock. Those are the only presentations a lossless splice may join; anything
16
+ * else would change reviewed pixels or reviewed timing. A clock term that is
17
+ * not a safe integer, or a timescale that is not positive, answers false.
18
+ *
19
+ * @evidence contracts/development/implementation.md#principled-implementation ISO/IEC 14496-12 presents a track through its matrix and edit list, so a unity matrix and at most one rate-1 edit spanning the whole media from the first presented sample leave the media timeline unchanged; durations on different clocks are compared by exact cross-multiplication through `equalRational`, which also refuses unsafe terms and non-positive timescales.
20
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure The clip parser and the feature-uses-clips proof ask the same question of a clip and of a delivered feature, and the matrix is read from `AUTOMOVIE_MP4_UNITY_MATRIX`, which the delivery profile also reads.
21
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No tolerance is applied to any duration or edit field, and an empty edit, a second edit or a non-unit rate answers false rather than being interpreted.
22
+ * @evidence contracts/development/common.md#meaningful-documentation The doc states every condition, the unit of `presentationStart`, why only these presentations are admissible, and which invalid clocks answer false.
23
+ * @evidenceExclude contracts/development/implementation.md#efficient-algorithms The check reads nine matrix terms and at most one edit, so no algorithm or data structure is chosen.
24
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each call judges one track once, cheaper than any cached verdict.
25
+ * @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources The function retains no reference to the track and opens nothing.
26
+ */
27
+ export const neutralTrackPresentation: (
28
+ track: Track,
29
+ presentationStart: number,
30
+ ) => boolean = (track: Track, presentationStart: number): boolean => {
31
+ if (
32
+ Array.from(track.matrix).some(
33
+ (value: number, index: number): boolean =>
34
+ value !== AUTOMOVIE_MP4_UNITY_MATRIX[index],
35
+ ) ||
36
+ equalRational(
37
+ track.movie_duration,
38
+ track.movie_timescale,
39
+ track.duration,
40
+ track.timescale,
41
+ ) === false
42
+ )
43
+ return false;
44
+ const edits: Entry[] = track.edits ?? [];
45
+ const edit: Entry | undefined = edits[0];
46
+ if (edit === undefined) return presentationStart === 0;
47
+ return (
48
+ edits.length === 1 &&
49
+ edit.media_time === presentationStart &&
50
+ edit.media_rate_integer === 1 &&
51
+ edit.media_rate_fraction === 0 &&
52
+ equalRational(
53
+ edit.segment_duration,
54
+ track.movie_timescale,
55
+ track.duration,
56
+ track.timescale,
57
+ )
58
+ );
59
+ };
@@ -0,0 +1,110 @@
1
+ import type { IAutoMovieProductionVideoProbe } from "@automovie/interface";
2
+ import {
3
+ AUTOMOVIE_MP4_SRGB_COLOUR,
4
+ assertProductionVideoProfile,
5
+ resolveProductionVideoProfile,
6
+ } from "@automovie/render";
7
+ import type { BoxKind, Movie, Sample, Track, createFile } from "mp4box";
8
+
9
+ import { addProductionMp4Sample } from "./addProductionMp4Sample";
10
+ import { openLosslessVideoTrack } from "./openLosslessVideoTrack";
11
+ import { parseMp4 } from "./parseMp4";
12
+ import { probeProductionVideoMp4 } from "./probeProductionVideoMp4";
13
+ import { residentMp4Box } from "./residentMp4Box";
14
+ import { sampleBytes } from "./sampleBytes";
15
+ import { sampleDescription } from "./sampleDescription";
16
+ import { sampleOptions } from "./sampleOptions";
17
+
18
+ /**
19
+ * Rewrite a single-track H.264 MP4 so its sample entry declares sRGB through an `nclx` colour box, copying every coded sample unchanged.
20
+ *
21
+ * The output has one track on the source's media timescale, a duration of `samples * firstSampleDuration` ticks, the source's raster and language, no edit list, and the source's sample entry with every `colr` box, `nclx` or ICC, replaced by one `nclx` box spelling `AUTOMOVIE_MP4_SRGB_COLOUR`. The written file is re-probed and must pass the delivery profile resolved from its own raster and frame rate before it is returned.
22
+ *
23
+ * The rewrite relabels; it never converts pixels and does not read the colour description in the stream's own parameter sets. It is correct only for a stream whose samples were encoded from full-range sRGB with BT.709 coefficients, and a stream encoded otherwise is mislabelled, not refused.
24
+ *
25
+ * Throws `H.264 normalization requires exactly one video track.`, `H.264 normalization requires a video raster.`, `H.264 normalization requires resident video samples.`, the parser's and the container helpers' refusals, and the probe's or the delivery profile's refusal of the written file. No production module calls it at present; the test fixtures that author H.264 inputs reach it.
26
+ *
27
+ * @evidence contracts/development/implementation.md#principled-implementation Samples are copied byte for byte with their own timing and flags, so the elementary stream is untouched, and the `nclx` payload is the H.273 code points in the ISO layout written through the colour box's inherited raw-payload writer; dropping a source edit list and declaring `samples * firstSampleDuration` cannot change an admitted output, because the profile then requires one constant duration, a media duration of exactly that product, and no edit other than one full-length edit at media time zero. The unresolved limitation is the relabelling premise stated in the doc.
28
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure The output container comes from `openLosslessVideoTrack`, sample payloads from `sampleBytes` and their options from `sampleOptions`, the same helpers the lossless splice writers use, so this function owns only the colour-box replacement and the final profile proof. The gap is that no production consumer remains.
29
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The colour box is built with mp4box's own `colr` class and its public `data` payload rather than by replacing a writer method, the profile is resolved from the written file rather than assumed, and no input is special-cased; the relabelling of a differently encoded stream remains the violation the doc names.
30
+ * @evidence contracts/development/common.md#meaningful-documentation The doc states the output's clock, raster, edit list and sample entry, the final verification, the relabelling limitation, every refusal, and that only test fixtures call it.
31
+ * @evidence contracts/development/implementation.md#efficient-algorithms The input is parsed once, each of S samples is appended once from a byte view that mp4box copies into a media box, and the serialized output is parsed once. Byte copying and serialization scale with the encoded bytes; the output probe additionally performs O(M + S log(M + 1)) residency work for M output media boxes and inspects the parsed boxes and returned lists, so the full rewrite is not strictly linear in the encoded bytes.
32
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each call rewrites the bytes it is handed and keeps no result; equal inputs give byte-identical output that a caller may store.
33
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources During verification the input parse and its copied buffer, source sample views, output sample payloads and boxes, serialized output, and output probe's copied buffer and tables can coexist. Their sizes depend on the uncapped input bytes, sample count and box structure; an exact peak ratio is not established. These objects become collectable when their calls finish, and this function retains only the returned array through its caller, with no handle or background task.
34
+ */
35
+ export const normalizeProductionH264Mp4: (bytes: Uint8Array) => Uint8Array = (
36
+ bytes: Uint8Array,
37
+ ): Uint8Array => {
38
+ const source: { file: ReturnType<typeof createFile>; movie: Movie } =
39
+ parseMp4(bytes);
40
+ const track: Track | undefined = source.movie.videoTracks[0];
41
+ if (track === undefined || source.movie.tracks.length !== 1)
42
+ throw new Error("H.264 normalization requires exactly one video track.");
43
+ if (track.video === undefined)
44
+ throw new Error("H.264 normalization requires a video raster.");
45
+ const samples: Sample[] = source.file.getTrackSamplesInfo(track.id) ?? [];
46
+ const first: Sample | undefined = samples[0];
47
+ if (first === undefined)
48
+ throw new Error("H.264 normalization requires resident video samples.");
49
+ const description: ReturnType<typeof sampleDescription> =
50
+ sampleDescription(first);
51
+ const output: { file: ReturnType<typeof createFile>; track: number } =
52
+ openLosslessVideoTrack({
53
+ label: "Normalized H.264 video",
54
+ name: "AutoMovie explicit sRGB H.264",
55
+ timescale: track.timescale,
56
+ sampleDuration: first.duration,
57
+ frames: samples.length,
58
+ description: {
59
+ type: description.type,
60
+ boxes: [
61
+ ...description.boxes.filter(
62
+ (box: BoxKind): boolean => box.type !== "colr",
63
+ ),
64
+ productionSrgbColorBox(),
65
+ ],
66
+ },
67
+ width: track.video.width,
68
+ height: track.video.height,
69
+ language: track.language,
70
+ });
71
+ for (const sample of samples)
72
+ addProductionMp4Sample(
73
+ output.file,
74
+ output.track,
75
+ sampleBytes(bytes, sample),
76
+ sampleOptions(sample),
77
+ );
78
+ const normalized: Uint8Array = new Uint8Array(output.file.getBuffer().buffer);
79
+ const probe: IAutoMovieProductionVideoProbe =
80
+ probeProductionVideoMp4(normalized);
81
+ assertProductionVideoProfile({
82
+ expected: resolveProductionVideoProfile({
83
+ width: probe.width,
84
+ height: probe.height,
85
+ frameRate: probe.frameRate,
86
+ }),
87
+ actual: probe,
88
+ });
89
+ return normalized;
90
+ };
91
+
92
+ /**
93
+ * An `nclx` colour box spelling `AUTOMOVIE_MP4_SRGB_COLOUR`.
94
+ *
95
+ * The eleven-byte payload is the ISO `colr` layout: the four-character colour type, the three 16-bit H.273 code points, and a final byte whose high bit is the full-range flag. mp4box's `colr` class has no field writer and writes its `data` payload with its own size and header accounting, so the payload is supplied through that public field.
96
+ */
97
+ const productionSrgbColorBox: () => BoxKind = (): BoxKind => {
98
+ const box: InstanceType<
99
+ ReturnType<typeof residentMp4Box>["BoxParser"]["box"]["colr"]
100
+ > = new (residentMp4Box().BoxParser.box.colr)();
101
+ const payload: Uint8Array = new Uint8Array(11);
102
+ payload.set([0x6e, 0x63, 0x6c, 0x78]);
103
+ const fields: DataView = new DataView(payload.buffer);
104
+ fields.setUint16(4, AUTOMOVIE_MP4_SRGB_COLOUR.primaries);
105
+ fields.setUint16(6, AUTOMOVIE_MP4_SRGB_COLOUR.transfer);
106
+ fields.setUint16(8, AUTOMOVIE_MP4_SRGB_COLOUR.matrix);
107
+ payload[10] = Number(AUTOMOVIE_MP4_SRGB_COLOUR.fullRange) << 7;
108
+ box.data = payload;
109
+ return box;
110
+ };
@@ -0,0 +1,81 @@
1
+ import type { createFile } from "mp4box";
2
+
3
+ import { residentMp4Box } from "./residentMp4Box";
4
+ import type { sampleDescription } from "./sampleDescription";
5
+
6
+ /**
7
+ * Open a new in-memory MP4 with one empty video track that copied H.264 samples are appended to.
8
+ *
9
+ * The movie and media clocks both use `timescale`, and the declared duration is `frames * sampleDuration` ticks on that clock. The track reuses the source `description` boxes by reference, retaining their decoder configuration for copied samples. Throws `<label> duration exceeds the exact MP4 clock range.` when that duration is not a safe integer, before any file is created; individual ISO field representability remains the writer's responsibility rather than a consequence of JavaScript safe-integer admission.
10
+ *
11
+ * @evidence contracts/development/implementation.md#principled-implementation The duration is written as exact integer ticks after a safe-integer check, because an MP4 clock is an integer count and a rounded product would declare a runtime the samples do not have; the brands are the ISO base-media set every production video already carries.
12
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Chunk assembly, repaint conform, visual-lane conform and H.264 normalization open their output through this helper, so the container shape and safe-integer duration refusal live here once and each writer supplies its track name and source facts.
13
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The function copies the caller's description, raster and language without substitution and refuses an unrepresentable duration instead of clamping it.
14
+ * @evidence contracts/development/common.md#meaningful-documentation The doc states the clock both boxes use, how the duration is formed and in what unit, why the description is reused, and the refusal with its message.
15
+ * @evidence contracts/development/implementation.md#efficient-algorithms Cost is constant in the frame count: one multiplication, one box tree of fixed shape, and the description boxes attached by reference, since mp4box's `addTrack` adds them to the sample entry without copying.
16
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each call opens a distinct output file for one writer invocation, so no two calls produce interchangeable results.
17
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The returned file object is the caller's and holds the track, the referenced source description boxes and every sample later appended to it until the caller drops it; it opens no OS handle or task.
18
+ */
19
+ export const openLosslessVideoTrack: (props: {
20
+ label: string;
21
+ name: string;
22
+ timescale: number;
23
+ sampleDuration: number;
24
+ frames: number;
25
+ description: ReturnType<typeof sampleDescription>;
26
+ width: number;
27
+ height: number;
28
+ language: string;
29
+ }) => { file: ReturnType<typeof createFile>; track: number } = (props: {
30
+ /** Subject of the clock-range refusal, such as `Assembled chunk video`. */
31
+ label: string;
32
+
33
+ /** Human-readable track name written into the handler box. */
34
+ name: string;
35
+
36
+ /** Media and movie timescale, in ticks per second. */
37
+ timescale: number;
38
+
39
+ /** Duration of every sample to be appended, in ticks. */
40
+ sampleDuration: number;
41
+
42
+ /** Number of samples the track will hold. */
43
+ frames: number;
44
+
45
+ /** Sample entry the appended samples were encoded under. */
46
+ description: ReturnType<typeof sampleDescription>;
47
+
48
+ /** Coded raster width in pixels. */
49
+ width: number;
50
+
51
+ /** Coded raster height in pixels. */
52
+ height: number;
53
+
54
+ /** ISO 639-2/T track language copied from the source track. */
55
+ language: string;
56
+ }): { file: ReturnType<typeof createFile>; track: number } => {
57
+ const duration: number = props.frames * props.sampleDuration;
58
+ if (Number.isSafeInteger(duration) === false)
59
+ throw new Error(
60
+ `${props.label} duration exceeds the exact MP4 clock range.`,
61
+ );
62
+ const file: ReturnType<typeof createFile> = residentMp4Box().createFile();
63
+ file.init({
64
+ brands: ["isom", "iso2", "mp41"],
65
+ timescale: props.timescale,
66
+ duration,
67
+ });
68
+ const track: number = file.addTrack({
69
+ type: props.description.type,
70
+ hdlr: "vide",
71
+ name: props.name,
72
+ timescale: props.timescale,
73
+ media_duration: duration,
74
+ duration,
75
+ width: props.width,
76
+ height: props.height,
77
+ language: props.language,
78
+ description_boxes: props.description.boxes,
79
+ });
80
+ return { file, track };
81
+ };
@@ -0,0 +1,46 @@
1
+ import type { Movie, createFile } from "mp4box";
2
+
3
+ import { residentMp4Box } from "./residentMp4Box";
4
+
5
+ /**
6
+ * Parse MP4 bytes and answer with the parsed file and its movie summary.
7
+ *
8
+ * Errors the parser reports through its error callback are collected and thrown together as `MP4 parser rejected input: <module>: <message>; ...`; an exception the parser throws synchronously propagates unchanged. When the parser never reports a ready movie, the summary is read from the file as parsed, so a file without a movie box yields a summary with no tracks rather than a refusal.
9
+ *
10
+ * Callers either probed the bytes already or verify the parsed fields themselves afterwards, which is why this admits a stream the delivered-output gate would refuse. It is deliberately not merged with `parseProductionMp4Output`: that one is the strict delivery gate, and requiring its leading file-type box and parsed movie header here would refuse inputs these writers compare sample by sample before trusting anything about them.
11
+ *
12
+ * @evidence contracts/development/implementation.md#principled-implementation The whole stream is appended at file offset zero and flushed, which mp4box documents as the way to parse a complete in-memory file; the bytes are copied into a fresh `ArrayBuffer` because the parser takes an `ArrayBuffer` it tags with its file offset and keeps, and the caller's array may be a view or shared memory.
13
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure The normalizer, the feature mux and the two splice proofs share this permissive parse and apply their own checks, while the strict gate stays separate for the reason the doc gives.
14
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Every parser error refuses the input; none is filtered, and nothing on the parser is replaced, its callbacks being the published hooks for these events.
15
+ * @evidence contracts/development/common.md#meaningful-documentation The doc states what is returned, the refusal and its message, that synchronous exceptions propagate, how a missing movie reads, and why this parse is not the strict gate.
16
+ * @evidence contracts/development/implementation.md#efficient-algorithms One copy costs O(B) for B encoded bytes, then one append/flush delegates box parsing and expanded sample-table construction to mp4box. Those costs also depend on parsed box and sample populations, including counts represented compactly in the input tables; this boundary establishes no strict byte-only time or memory bound and imposes no population cap.
17
+ * @evidence contracts/development/implementation.md#reuse-equivalent-work This entry creates a new parse and keeps no cross-call cache. Some callers already probed the same bytes, notably the feature mux's audio input, but that probe returns facts without a parser handle; the caller therefore parses again for copying rather than reusing the hidden admission parse.
18
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The returned file holds a copied input buffer, parsed boxes and expanded sample tables for its caller-owned lifetime; source bytes and parser error arrays can coexist during the call. None of these input-dependent populations has an admission cap here, and the parser opens no file handle or background task.
19
+ */
20
+ export const parseMp4: (bytes: Uint8Array) => {
21
+ file: ReturnType<typeof createFile>;
22
+ movie: Movie;
23
+ } = (
24
+ bytes: Uint8Array,
25
+ ): { file: ReturnType<typeof createFile>; movie: Movie } => {
26
+ const file: ReturnType<typeof createFile> = residentMp4Box().createFile();
27
+ let movie: Movie | null = null;
28
+ const errors: string[] = [];
29
+ file.onReady = (value: Movie): void => {
30
+ movie = value;
31
+ };
32
+ file.onError = (module: string, message: string): void => {
33
+ errors.push(`${module}: ${message}`);
34
+ };
35
+ file.appendBuffer(
36
+ residentMp4Box().MP4BoxBuffer.fromArrayBuffer(
37
+ Uint8Array.from(bytes).buffer,
38
+ 0,
39
+ ),
40
+ true,
41
+ );
42
+ file.flush();
43
+ if (errors.length !== 0)
44
+ throw new Error(`MP4 parser rejected input: ${errors.join("; ")}`);
45
+ return { file, movie: movie ?? file.getInfo() };
46
+ };
@@ -0,0 +1,70 @@
1
+ import type { Movie, createFile } from "mp4box";
2
+
3
+ import { residentMp4Box } from "./residentMp4Box";
4
+
5
+ /**
6
+ * Parse delivered or intermediate MP4 bytes under the strict output gate.
7
+ *
8
+ * Admission requires at least 16 bytes, a leading ISO file-type box whose declared size is at least 16 and fits the stream and whose major brand is not blank, a parsed movie box, and no parser error. Throws, in that order, `MP4 output is too short to contain a media track.`, `MP4 output has no leading ISO base-media compatible brand box.`, `MP4 parser rejected output: <detail>` for a parser error or a synchronous parser exception, and `MP4 output has no parsed movie metadata.` Every video probe and the rendered media probe run it before reading a track.
9
+ *
10
+ * This is deliberately not merged with `parseMp4`: that one admits bytes whose fields its callers verify afterwards, sample by sample, while this one refuses a stream that does not announce itself as ISO base media before anything reads a track from it.
11
+ *
12
+ * @evidence contracts/development/implementation.md#principled-implementation ISO/IEC 14496-12 requires the file-type box first in a conforming file, so the header is checked by its big-endian size and four-character type before the parser runs; the parse then appends the whole stream at offset zero and flushes, and the movie summary must report a movie box because a track cannot exist without one.
13
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure One gate decides admission for every probe that reads delivered media, and it normalizes both parser failure channels, the error callback and a thrown exception, into one refusal, so the probes start from a parsed file or a named refusal.
14
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A thrown parser exception is converted into a refusal with its original text, never swallowed, and no brand is required beyond being present, because which brands are acceptable is the delivery profile's question.
15
+ * @evidence contracts/development/common.md#meaningful-documentation The doc lists every admission condition and each refusal with its message in order, who runs the gate, and why it differs from `parseMp4`.
16
+ * @evidence contracts/development/implementation.md#efficient-algorithms The header gate reads twelve bytes through a view, and copying B encoded bytes costs O(B). One append/flush then delegates box parsing and expanded sample-table construction to mp4box; parsed box and sample populations also drive that work, including compact table counts. No byte-only worst-case guarantee or parsed-population cap is established here.
17
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Callers that need both the parse and a probe pass this parse on to `probeParsedProductionVideoMp4`, and no call re-parses bytes another call already parsed.
18
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The returned file holds the copied buffer and the parsed box tree until the caller drops it; on refusal everything is local and collectable, and no handle or task is opened.
19
+ */
20
+ export const parseProductionMp4Output: (bytes: Uint8Array) => {
21
+ file: ReturnType<typeof createFile>;
22
+ movie: Movie;
23
+ } = (
24
+ bytes: Uint8Array,
25
+ ): { file: ReturnType<typeof createFile>; movie: Movie } => {
26
+ if (bytes.byteLength < 16)
27
+ throw new Error("MP4 output is too short to contain a media track.");
28
+ const header: Buffer = Buffer.from(
29
+ bytes.buffer,
30
+ bytes.byteOffset,
31
+ bytes.byteLength,
32
+ );
33
+ const ftypSize: number = header.readUInt32BE(0);
34
+ if (
35
+ header.toString("ascii", 4, 8) !== "ftyp" ||
36
+ ftypSize < 16 ||
37
+ ftypSize > bytes.byteLength ||
38
+ header.toString("ascii", 8, 12).trim().length === 0
39
+ )
40
+ throw new Error(
41
+ "MP4 output has no leading ISO base-media compatible brand box.",
42
+ );
43
+ const file: ReturnType<typeof createFile> = residentMp4Box().createFile();
44
+ const errors: string[] = [];
45
+ let ready: Movie | null = null;
46
+ file.onError = (module: string, message: string): void => {
47
+ errors.push(`${module}: ${message}`);
48
+ };
49
+ file.onReady = (info: Movie): void => {
50
+ ready = info;
51
+ };
52
+ try {
53
+ file.appendBuffer(
54
+ residentMp4Box().MP4BoxBuffer.fromArrayBuffer(
55
+ Uint8Array.from(bytes).buffer,
56
+ 0,
57
+ ),
58
+ true,
59
+ );
60
+ file.flush();
61
+ } catch (error) {
62
+ throw new Error(`MP4 parser rejected output: ${String(error)}`);
63
+ }
64
+ const movie: Movie = ready ?? file.getInfo();
65
+ if (errors.length !== 0)
66
+ throw new Error(`MP4 parser rejected output: ${errors.join("; ")}`);
67
+ if (movie.hasMoov === false)
68
+ throw new Error("MP4 output has no parsed movie metadata.");
69
+ return { file, movie };
70
+ };