@wenathlan/saddle 1.8.18 → 2.0.2

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 (802) hide show
  1. package/Dockerfile +1339 -0
  2. package/README.md +33 -12
  3. package/alternatives.ts +1218 -0
  4. package/biome.json +153 -0
  5. package/boards.json +1517 -0
  6. package/compute.ts +3144 -0
  7. package/cores.json +1801 -0
  8. package/dist/acquisition.d.ts +359 -0
  9. package/dist/acquisition.d.ts.map +1 -0
  10. package/dist/acquisition.js +629 -0
  11. package/dist/acquisition.js.map +1 -0
  12. package/dist/alternatives.d.ts +509 -0
  13. package/dist/alternatives.d.ts.map +1 -0
  14. package/dist/alternatives.js +951 -0
  15. package/dist/alternatives.js.map +1 -0
  16. package/dist/automation.d.ts +426 -0
  17. package/dist/automation.d.ts.map +1 -0
  18. package/dist/automation.js +561 -0
  19. package/dist/automation.js.map +1 -0
  20. package/dist/browser.d.ts +562 -0
  21. package/dist/browser.d.ts.map +1 -0
  22. package/dist/browser.js +1057 -0
  23. package/dist/browser.js.map +1 -0
  24. package/dist/capacitor.config.d.ts +13 -0
  25. package/dist/capacitor.config.d.ts.map +1 -0
  26. package/dist/capacitor.config.js +26 -0
  27. package/dist/capacitor.config.js.map +1 -0
  28. package/dist/cli.d.ts +17 -0
  29. package/dist/cli.d.ts.map +1 -0
  30. package/dist/cli.js +111 -0
  31. package/dist/cli.js.map +1 -0
  32. package/dist/communication.d.ts +192 -0
  33. package/dist/communication.d.ts.map +1 -0
  34. package/dist/communication.js +418 -0
  35. package/dist/communication.js.map +1 -0
  36. package/dist/compute.d.ts +1161 -0
  37. package/dist/compute.d.ts.map +1 -0
  38. package/dist/compute.js +2273 -0
  39. package/dist/compute.js.map +1 -0
  40. package/dist/distribution.d.ts +529 -0
  41. package/dist/distribution.d.ts.map +1 -0
  42. package/dist/distribution.js +811 -0
  43. package/dist/distribution.js.map +1 -0
  44. package/dist/execution.d.ts +530 -0
  45. package/dist/execution.d.ts.map +1 -0
  46. package/dist/execution.js +761 -0
  47. package/dist/execution.js.map +1 -0
  48. package/dist/format.d.ts +19 -0
  49. package/dist/format.d.ts.map +1 -0
  50. package/dist/format.js +60 -0
  51. package/dist/format.js.map +1 -0
  52. package/dist/foundation.d.ts +176 -0
  53. package/dist/foundation.d.ts.map +1 -0
  54. package/dist/foundation.js +309 -0
  55. package/dist/foundation.js.map +1 -0
  56. package/dist/index.d.ts +733 -123
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +1018 -123
  59. package/dist/index.js.map +1 -1
  60. package/dist/integration.d.ts +236 -0
  61. package/dist/integration.d.ts.map +1 -0
  62. package/dist/integration.js +236 -0
  63. package/dist/integration.js.map +1 -0
  64. package/dist/intelligence.d.ts +94 -0
  65. package/dist/intelligence.d.ts.map +1 -0
  66. package/dist/intelligence.js +145 -0
  67. package/dist/intelligence.js.map +1 -0
  68. package/dist/{isolation/contracts.d.ts → isolation.d.ts} +12 -1
  69. package/dist/isolation.d.ts.map +1 -0
  70. package/dist/{isolation/contracts.js → isolation.js} +13 -1
  71. package/dist/isolation.js.map +1 -0
  72. package/dist/media.d.ts +344 -0
  73. package/dist/media.d.ts.map +1 -0
  74. package/dist/media.js +986 -0
  75. package/dist/media.js.map +1 -0
  76. package/dist/modes.d.ts +359 -0
  77. package/dist/modes.d.ts.map +1 -0
  78. package/dist/modes.js +134 -0
  79. package/dist/modes.js.map +1 -0
  80. package/dist/{library/public.d.ts → operations.d.ts} +15 -1
  81. package/dist/operations.d.ts.map +1 -0
  82. package/dist/{library/public.js → operations.js} +18 -7
  83. package/dist/operations.js.map +1 -0
  84. package/dist/orchestrator.d.ts +1339 -0
  85. package/dist/orchestrator.d.ts.map +1 -0
  86. package/dist/orchestrator.js +4308 -0
  87. package/dist/orchestrator.js.map +1 -0
  88. package/dist/performance.d.ts +416 -0
  89. package/dist/performance.d.ts.map +1 -0
  90. package/dist/performance.js +827 -0
  91. package/dist/performance.js.map +1 -0
  92. package/dist/quantum.d.ts +810 -0
  93. package/dist/quantum.d.ts.map +1 -0
  94. package/dist/quantum.js +2073 -0
  95. package/dist/quantum.js.map +1 -0
  96. package/dist/render.d.ts +381 -0
  97. package/dist/render.d.ts.map +1 -0
  98. package/dist/render.js +1073 -0
  99. package/dist/render.js.map +1 -0
  100. package/dist/scheduler.d.ts +596 -0
  101. package/dist/scheduler.d.ts.map +1 -0
  102. package/dist/scheduler.js +1259 -0
  103. package/dist/scheduler.js.map +1 -0
  104. package/dist/security.d.ts +501 -0
  105. package/dist/security.d.ts.map +1 -0
  106. package/dist/security.js +1170 -0
  107. package/dist/security.js.map +1 -0
  108. package/dist/server.d.ts +21 -0
  109. package/dist/server.d.ts.map +1 -0
  110. package/dist/{server/node.js → server.js} +16 -2
  111. package/dist/server.js.map +1 -0
  112. package/dist/tiers.d.ts +1002 -0
  113. package/dist/tiers.d.ts.map +1 -0
  114. package/dist/tiers.js +2165 -0
  115. package/dist/tiers.js.map +1 -0
  116. package/dist/virtual.d.ts +641 -0
  117. package/dist/virtual.d.ts.map +1 -0
  118. package/dist/virtual.js +1285 -0
  119. package/dist/virtual.js.map +1 -0
  120. package/dist/virtualcpu.d.ts +316 -0
  121. package/dist/virtualcpu.d.ts.map +1 -0
  122. package/dist/virtualcpu.js +1180 -0
  123. package/dist/virtualcpu.js.map +1 -0
  124. package/dist/virtualgpu.d.ts +345 -0
  125. package/dist/virtualgpu.d.ts.map +1 -0
  126. package/dist/virtualgpu.js +1000 -0
  127. package/dist/virtualgpu.js.map +1 -0
  128. package/dist/virtualization.d.ts +607 -0
  129. package/dist/virtualization.d.ts.map +1 -0
  130. package/dist/virtualization.js +1187 -0
  131. package/dist/virtualization.js.map +1 -0
  132. package/dist/virtualmemory.d.ts +818 -0
  133. package/dist/virtualmemory.d.ts.map +1 -0
  134. package/dist/virtualmemory.js +1796 -0
  135. package/dist/virtualmemory.js.map +1 -0
  136. package/dist/webscrape.d.ts +720 -0
  137. package/dist/webscrape.d.ts.map +1 -0
  138. package/dist/webscrape.js +2697 -0
  139. package/dist/webscrape.js.map +1 -0
  140. package/docker.config +769 -0
  141. package/docs/CONVERSA.txt +1523 -0
  142. package/docs/alternatives.md +499 -0
  143. package/docs/architecture-1.8.19.md +76 -0
  144. package/docs/architecture-1.8.19.mmd +33 -0
  145. package/docs/architecture-1.8.19.png +0 -0
  146. package/docs/architecture.md +355 -0
  147. package/docs/brancharchive-2026-08-18.md +18 -0
  148. package/docs/browser.md +7 -0
  149. package/docs/consolidation.md +70 -0
  150. package/docs/e2ugh-engine.md +528 -0
  151. package/{dist/examples/localjob.js → docs/example-localjob.ts} +3 -3
  152. package/{dist/examples/publicapi.js → docs/example-publicapi.ts} +2 -2
  153. package/docs/hardware.md +342 -0
  154. package/docs/optimization.md +126 -0
  155. package/docs/performance.md +499 -0
  156. package/docs/planning.1.8.18.md +94 -0
  157. package/docs/planning.1.8.19.md +49 -0
  158. package/docs/releasenotes-1.8.19.md +35 -0
  159. package/docs/research-1.8.19-virtual-browser.md +27 -0
  160. package/docs/security.md +454 -0
  161. package/docs/todo-1.8.18.md +12 -0
  162. package/docs/todo-1.8.19.md +241 -0
  163. package/docs/viability.md +777 -0
  164. package/docs/virtualization.md +335 -0
  165. package/docs/web-duplicatecleanup.md +9 -0
  166. package/docs/web-ideas.md +106 -0
  167. package/docs/workflowimprovements-2026-08-19.md +70 -0
  168. package/gpumonitor.cpp +1543 -0
  169. package/gpus.json +2408 -0
  170. package/index.ts +1478 -0
  171. package/media.ts +1337 -0
  172. package/mttg.config +1549 -0
  173. package/orchestrator.ts +5462 -0
  174. package/package.json +304 -56
  175. package/passage.config +1331 -0
  176. package/performance.ts +1049 -0
  177. package/processors.json +2217 -0
  178. package/qemu.config +1062 -0
  179. package/qemubridge.py +1340 -0
  180. package/quantum.ts +2393 -0
  181. package/render.ts +1325 -0
  182. package/scheduler.ts +1600 -0
  183. package/security.ts +1449 -0
  184. package/tiers.ts +2871 -0
  185. package/tsconfig.json +29 -0
  186. package/virtualcpu.ts +1273 -0
  187. package/virtualgpu.ts +1181 -0
  188. package/virtualhardware.c +1011 -0
  189. package/virtualhardware.json +739 -0
  190. package/virtualization.ts +1628 -0
  191. package/virtualizationcore.cpp +4635 -0
  192. package/virtualmemory.ts +2303 -0
  193. package/vm.config.json +1910 -0
  194. package/{extension → web/extension}/manifest.json +1 -1
  195. package/web/readme.md +382 -0
  196. package/web/tsconfig.json +25 -0
  197. package/dist/adapters/forge.d.ts +0 -17
  198. package/dist/adapters/forge.d.ts.map +0 -1
  199. package/dist/adapters/forge.js +0 -19
  200. package/dist/adapters/forge.js.map +0 -1
  201. package/dist/adapters/forgejo.d.ts +0 -49
  202. package/dist/adapters/forgejo.d.ts.map +0 -1
  203. package/dist/adapters/forgejo.js +0 -8
  204. package/dist/adapters/forgejo.js.map +0 -1
  205. package/dist/adapters/github.d.ts +0 -12
  206. package/dist/adapters/github.d.ts.map +0 -1
  207. package/dist/adapters/github.js +0 -20
  208. package/dist/adapters/github.js.map +0 -1
  209. package/dist/adapters/gitlab.d.ts +0 -17
  210. package/dist/adapters/gitlab.d.ts.map +0 -1
  211. package/dist/adapters/gitlab.js +0 -10
  212. package/dist/adapters/gitlab.js.map +0 -1
  213. package/dist/adapters/huggingface.d.ts +0 -17
  214. package/dist/adapters/huggingface.d.ts.map +0 -1
  215. package/dist/adapters/huggingface.js +0 -6
  216. package/dist/adapters/huggingface.js.map +0 -1
  217. package/dist/adapters/socket.d.ts +0 -11
  218. package/dist/adapters/socket.d.ts.map +0 -1
  219. package/dist/adapters/socket.js +0 -17
  220. package/dist/adapters/socket.js.map +0 -1
  221. package/dist/adapters/transport.d.ts +0 -7
  222. package/dist/adapters/transport.d.ts.map +0 -1
  223. package/dist/adapters/transport.js +0 -36
  224. package/dist/adapters/transport.js.map +0 -1
  225. package/dist/ai/chunk.d.ts +0 -2
  226. package/dist/ai/chunk.d.ts.map +0 -1
  227. package/dist/ai/chunk.js +0 -36
  228. package/dist/ai/chunk.js.map +0 -1
  229. package/dist/ai/llmstxt.d.ts +0 -6
  230. package/dist/ai/llmstxt.d.ts.map +0 -1
  231. package/dist/ai/llmstxt.js +0 -12
  232. package/dist/ai/llmstxt.js.map +0 -1
  233. package/dist/ai/provenance.d.ts +0 -22
  234. package/dist/ai/provenance.d.ts.map +0 -1
  235. package/dist/ai/provenance.js +0 -25
  236. package/dist/ai/provenance.js.map +0 -1
  237. package/dist/ai/rag.d.ts +0 -26
  238. package/dist/ai/rag.d.ts.map +0 -1
  239. package/dist/ai/rag.js +0 -22
  240. package/dist/ai/rag.js.map +0 -1
  241. package/dist/ai/tokens.d.ts +0 -15
  242. package/dist/ai/tokens.d.ts.map +0 -1
  243. package/dist/ai/tokens.js +0 -9
  244. package/dist/ai/tokens.js.map +0 -1
  245. package/dist/api/auth.d.ts +0 -16
  246. package/dist/api/auth.d.ts.map +0 -1
  247. package/dist/api/auth.js +0 -19
  248. package/dist/api/auth.js.map +0 -1
  249. package/dist/api/contracts.d.ts +0 -28
  250. package/dist/api/contracts.d.ts.map +0 -1
  251. package/dist/api/contracts.js +0 -14
  252. package/dist/api/contracts.js.map +0 -1
  253. package/dist/api/control.d.ts +0 -10
  254. package/dist/api/control.d.ts.map +0 -1
  255. package/dist/api/control.js +0 -35
  256. package/dist/api/control.js.map +0 -1
  257. package/dist/api/http.d.ts +0 -7
  258. package/dist/api/http.d.ts.map +0 -1
  259. package/dist/api/http.js +0 -12
  260. package/dist/api/http.js.map +0 -1
  261. package/dist/api/rate.d.ts +0 -28
  262. package/dist/api/rate.d.ts.map +0 -1
  263. package/dist/api/rate.js +0 -36
  264. package/dist/api/rate.js.map +0 -1
  265. package/dist/api/security.d.ts +0 -12
  266. package/dist/api/security.d.ts.map +0 -1
  267. package/dist/api/security.js +0 -56
  268. package/dist/api/security.js.map +0 -1
  269. package/dist/api/service.d.ts +0 -5
  270. package/dist/api/service.d.ts.map +0 -1
  271. package/dist/api/service.js +0 -70
  272. package/dist/api/service.js.map +0 -1
  273. package/dist/apps/registry.d.ts +0 -33
  274. package/dist/apps/registry.d.ts.map +0 -1
  275. package/dist/apps/registry.js +0 -24
  276. package/dist/apps/registry.js.map +0 -1
  277. package/dist/binary/archive.d.ts +0 -27
  278. package/dist/binary/archive.d.ts.map +0 -1
  279. package/dist/binary/archive.js +0 -46
  280. package/dist/binary/archive.js.map +0 -1
  281. package/dist/binary/build.d.ts +0 -29
  282. package/dist/binary/build.d.ts.map +0 -1
  283. package/dist/binary/build.js +0 -17
  284. package/dist/binary/build.js.map +0 -1
  285. package/dist/binary/transform.d.ts +0 -70
  286. package/dist/binary/transform.d.ts.map +0 -1
  287. package/dist/binary/transform.js +0 -105
  288. package/dist/binary/transform.js.map +0 -1
  289. package/dist/bot/adapter.d.ts +0 -5
  290. package/dist/bot/adapter.d.ts.map +0 -1
  291. package/dist/bot/adapter.js +0 -11
  292. package/dist/bot/adapter.js.map +0 -1
  293. package/dist/bot/bot.d.ts +0 -28
  294. package/dist/bot/bot.d.ts.map +0 -1
  295. package/dist/bot/bot.js +0 -52
  296. package/dist/bot/bot.js.map +0 -1
  297. package/dist/bot/commands.d.ts +0 -8
  298. package/dist/bot/commands.d.ts.map +0 -1
  299. package/dist/bot/commands.js +0 -19
  300. package/dist/bot/commands.js.map +0 -1
  301. package/dist/bot/permissions.d.ts +0 -13
  302. package/dist/bot/permissions.d.ts.map +0 -1
  303. package/dist/bot/permissions.js +0 -16
  304. package/dist/bot/permissions.js.map +0 -1
  305. package/dist/browser/actions.d.ts +0 -33
  306. package/dist/browser/actions.d.ts.map +0 -1
  307. package/dist/browser/actions.js +0 -44
  308. package/dist/browser/actions.js.map +0 -1
  309. package/dist/browser/agent.d.ts +0 -21
  310. package/dist/browser/agent.d.ts.map +0 -1
  311. package/dist/browser/agent.js +0 -13
  312. package/dist/browser/agent.js.map +0 -1
  313. package/dist/browser/context.d.ts +0 -43
  314. package/dist/browser/context.d.ts.map +0 -1
  315. package/dist/browser/context.js +0 -54
  316. package/dist/browser/context.js.map +0 -1
  317. package/dist/browser/fingerprint.d.ts +0 -4
  318. package/dist/browser/fingerprint.d.ts.map +0 -1
  319. package/dist/browser/fingerprint.js +0 -12
  320. package/dist/browser/fingerprint.js.map +0 -1
  321. package/dist/browser/index.d.ts +0 -11
  322. package/dist/browser/index.d.ts.map +0 -1
  323. package/dist/browser/index.js +0 -11
  324. package/dist/browser/index.js.map +0 -1
  325. package/dist/browser/playwright.d.ts +0 -11
  326. package/dist/browser/playwright.d.ts.map +0 -1
  327. package/dist/browser/playwright.js +0 -24
  328. package/dist/browser/playwright.js.map +0 -1
  329. package/dist/browser/recorder.d.ts +0 -21
  330. package/dist/browser/recorder.d.ts.map +0 -1
  331. package/dist/browser/recorder.js +0 -58
  332. package/dist/browser/recorder.js.map +0 -1
  333. package/dist/browser/session.d.ts +0 -14
  334. package/dist/browser/session.d.ts.map +0 -1
  335. package/dist/browser/session.js +0 -21
  336. package/dist/browser/session.js.map +0 -1
  337. package/dist/browser/snapshot.d.ts +0 -69
  338. package/dist/browser/snapshot.d.ts.map +0 -1
  339. package/dist/browser/snapshot.js +0 -133
  340. package/dist/browser/snapshot.js.map +0 -1
  341. package/dist/captcha/contract.d.ts +0 -35
  342. package/dist/captcha/contract.d.ts.map +0 -1
  343. package/dist/captcha/contract.js +0 -17
  344. package/dist/captcha/contract.js.map +0 -1
  345. package/dist/captcha/evidence.d.ts +0 -10
  346. package/dist/captcha/evidence.d.ts.map +0 -1
  347. package/dist/captcha/evidence.js +0 -9
  348. package/dist/captcha/evidence.js.map +0 -1
  349. package/dist/captcha/guard.d.ts +0 -23
  350. package/dist/captcha/guard.d.ts.map +0 -1
  351. package/dist/captcha/guard.js +0 -12
  352. package/dist/captcha/guard.js.map +0 -1
  353. package/dist/cli/main.d.ts +0 -4
  354. package/dist/cli/main.d.ts.map +0 -1
  355. package/dist/cli/main.js +0 -46
  356. package/dist/cli/main.js.map +0 -1
  357. package/dist/core/errors.d.ts +0 -84
  358. package/dist/core/errors.d.ts.map +0 -1
  359. package/dist/core/errors.js +0 -54
  360. package/dist/core/errors.js.map +0 -1
  361. package/dist/core/events.d.ts +0 -9
  362. package/dist/core/events.d.ts.map +0 -1
  363. package/dist/core/events.js +0 -21
  364. package/dist/core/events.js.map +0 -1
  365. package/dist/core/hash.d.ts +0 -10
  366. package/dist/core/hash.d.ts.map +0 -1
  367. package/dist/core/hash.js +0 -82
  368. package/dist/core/hash.js.map +0 -1
  369. package/dist/core/ids.d.ts +0 -10
  370. package/dist/core/ids.d.ts.map +0 -1
  371. package/dist/core/ids.js +0 -15
  372. package/dist/core/ids.js.map +0 -1
  373. package/dist/delivery/manifest.d.ts +0 -35
  374. package/dist/delivery/manifest.d.ts.map +0 -1
  375. package/dist/delivery/manifest.js +0 -68
  376. package/dist/delivery/manifest.js.map +0 -1
  377. package/dist/deploy/index.d.ts +0 -6
  378. package/dist/deploy/index.d.ts.map +0 -1
  379. package/dist/deploy/index.js +0 -6
  380. package/dist/deploy/index.js.map +0 -1
  381. package/dist/dispatch/resumable.d.ts +0 -102
  382. package/dist/dispatch/resumable.d.ts.map +0 -1
  383. package/dist/dispatch/resumable.js +0 -64
  384. package/dist/dispatch/resumable.js.map +0 -1
  385. package/dist/dispatch/workflow.d.ts +0 -6
  386. package/dist/dispatch/workflow.d.ts.map +0 -1
  387. package/dist/dispatch/workflow.js +0 -37
  388. package/dist/dispatch/workflow.js.map +0 -1
  389. package/dist/domain/artifacts.d.ts +0 -12
  390. package/dist/domain/artifacts.d.ts.map +0 -1
  391. package/dist/domain/artifacts.js +0 -14
  392. package/dist/domain/artifacts.js.map +0 -1
  393. package/dist/domain/jobs.d.ts +0 -12
  394. package/dist/domain/jobs.d.ts.map +0 -1
  395. package/dist/domain/jobs.js +0 -20
  396. package/dist/domain/jobs.js.map +0 -1
  397. package/dist/domain/providers.d.ts +0 -10
  398. package/dist/domain/providers.d.ts.map +0 -1
  399. package/dist/domain/providers.js +0 -8
  400. package/dist/domain/providers.js.map +0 -1
  401. package/dist/domain/runtime.d.ts +0 -14
  402. package/dist/domain/runtime.d.ts.map +0 -1
  403. package/dist/domain/runtime.js +0 -10
  404. package/dist/domain/runtime.js.map +0 -1
  405. package/dist/domain/sessions.d.ts +0 -12
  406. package/dist/domain/sessions.d.ts.map +0 -1
  407. package/dist/domain/sessions.js +0 -57
  408. package/dist/domain/sessions.js.map +0 -1
  409. package/dist/examples/localjob.d.ts +0 -2
  410. package/dist/examples/localjob.d.ts.map +0 -1
  411. package/dist/examples/localjob.js.map +0 -1
  412. package/dist/examples/publicapi.d.ts +0 -2
  413. package/dist/examples/publicapi.d.ts.map +0 -1
  414. package/dist/examples/publicapi.js.map +0 -1
  415. package/dist/extension/build.d.ts +0 -9
  416. package/dist/extension/build.d.ts.map +0 -1
  417. package/dist/extension/build.js +0 -85
  418. package/dist/extension/build.js.map +0 -1
  419. package/dist/extension/content.d.ts +0 -6
  420. package/dist/extension/content.d.ts.map +0 -1
  421. package/dist/extension/content.js +0 -135
  422. package/dist/extension/content.js.map +0 -1
  423. package/dist/extension/index.d.ts +0 -7
  424. package/dist/extension/index.d.ts.map +0 -1
  425. package/dist/extension/index.js +0 -7
  426. package/dist/extension/index.js.map +0 -1
  427. package/dist/extension/pagebridge.d.ts +0 -6
  428. package/dist/extension/pagebridge.d.ts.map +0 -1
  429. package/dist/extension/pagebridge.js +0 -42
  430. package/dist/extension/pagebridge.js.map +0 -1
  431. package/dist/extension/permissions.d.ts +0 -26
  432. package/dist/extension/permissions.d.ts.map +0 -1
  433. package/dist/extension/permissions.js +0 -28
  434. package/dist/extension/permissions.js.map +0 -1
  435. package/dist/extension/popup.d.ts +0 -5
  436. package/dist/extension/popup.d.ts.map +0 -1
  437. package/dist/extension/popup.js +0 -26
  438. package/dist/extension/popup.js.map +0 -1
  439. package/dist/extension/protocol.d.ts +0 -58
  440. package/dist/extension/protocol.d.ts.map +0 -1
  441. package/dist/extension/protocol.js +0 -101
  442. package/dist/extension/protocol.js.map +0 -1
  443. package/dist/extension/serviceworker.d.ts +0 -25
  444. package/dist/extension/serviceworker.d.ts.map +0 -1
  445. package/dist/extension/serviceworker.js +0 -102
  446. package/dist/extension/serviceworker.js.map +0 -1
  447. package/dist/extension/worker.d.ts +0 -28
  448. package/dist/extension/worker.d.ts.map +0 -1
  449. package/dist/extension/worker.js +0 -22
  450. package/dist/extension/worker.js.map +0 -1
  451. package/dist/format/check.d.ts +0 -8
  452. package/dist/format/check.d.ts.map +0 -1
  453. package/dist/format/check.js +0 -38
  454. package/dist/format/check.js.map +0 -1
  455. package/dist/isolation/contracts.d.ts.map +0 -1
  456. package/dist/isolation/contracts.js.map +0 -1
  457. package/dist/library/public.d.ts.map +0 -1
  458. package/dist/library/public.js.map +0 -1
  459. package/dist/mcp/browser.d.ts +0 -9
  460. package/dist/mcp/browser.d.ts.map +0 -1
  461. package/dist/mcp/browser.js +0 -13
  462. package/dist/mcp/browser.js.map +0 -1
  463. package/dist/mcp/server.d.ts +0 -35
  464. package/dist/mcp/server.d.ts.map +0 -1
  465. package/dist/mcp/server.js +0 -40
  466. package/dist/mcp/server.js.map +0 -1
  467. package/dist/mcp/transport.d.ts +0 -7
  468. package/dist/mcp/transport.d.ts.map +0 -1
  469. package/dist/mcp/transport.js +0 -17
  470. package/dist/mcp/transport.js.map +0 -1
  471. package/dist/memory/bridge.d.ts +0 -14
  472. package/dist/memory/bridge.d.ts.map +0 -1
  473. package/dist/memory/bridge.js +0 -16
  474. package/dist/memory/bridge.js.map +0 -1
  475. package/dist/memory/engine.d.ts +0 -38
  476. package/dist/memory/engine.d.ts.map +0 -1
  477. package/dist/memory/engine.js +0 -109
  478. package/dist/memory/engine.js.map +0 -1
  479. package/dist/memory/modes.d.ts +0 -43
  480. package/dist/memory/modes.d.ts.map +0 -1
  481. package/dist/memory/modes.js +0 -66
  482. package/dist/memory/modes.js.map +0 -1
  483. package/dist/memory/objects.d.ts +0 -21
  484. package/dist/memory/objects.d.ts.map +0 -1
  485. package/dist/memory/objects.js +0 -20
  486. package/dist/memory/objects.js.map +0 -1
  487. package/dist/memory/planner.d.ts +0 -66
  488. package/dist/memory/planner.d.ts.map +0 -1
  489. package/dist/memory/planner.js +0 -108
  490. package/dist/memory/planner.js.map +0 -1
  491. package/dist/memory/targets.d.ts +0 -78
  492. package/dist/memory/targets.d.ts.map +0 -1
  493. package/dist/memory/targets.js +0 -29
  494. package/dist/memory/targets.js.map +0 -1
  495. package/dist/memory/transforms.d.ts +0 -19
  496. package/dist/memory/transforms.d.ts.map +0 -1
  497. package/dist/memory/transforms.js +0 -14
  498. package/dist/memory/transforms.js.map +0 -1
  499. package/dist/modes/matrix.d.ts +0 -23
  500. package/dist/modes/matrix.d.ts.map +0 -1
  501. package/dist/modes/matrix.js +0 -18
  502. package/dist/modes/matrix.js.map +0 -1
  503. package/dist/modes/modes.d.ts +0 -33
  504. package/dist/modes/modes.d.ts.map +0 -1
  505. package/dist/modes/modes.js +0 -15
  506. package/dist/modes/modes.js.map +0 -1
  507. package/dist/modes/resolve.d.ts +0 -96
  508. package/dist/modes/resolve.d.ts.map +0 -1
  509. package/dist/modes/resolve.js +0 -48
  510. package/dist/modes/resolve.js.map +0 -1
  511. package/dist/observability/metrics.d.ts +0 -14
  512. package/dist/observability/metrics.d.ts.map +0 -1
  513. package/dist/observability/metrics.js +0 -18
  514. package/dist/observability/metrics.js.map +0 -1
  515. package/dist/packager/manifest.d.ts +0 -66
  516. package/dist/packager/manifest.d.ts.map +0 -1
  517. package/dist/packager/manifest.js +0 -94
  518. package/dist/packager/manifest.js.map +0 -1
  519. package/dist/packager/publish.d.ts +0 -51
  520. package/dist/packager/publish.d.ts.map +0 -1
  521. package/dist/packager/publish.js +0 -18
  522. package/dist/packager/publish.js.map +0 -1
  523. package/dist/packager/targetcli.d.ts +0 -7
  524. package/dist/packager/targetcli.d.ts.map +0 -1
  525. package/dist/packager/targetcli.js +0 -22
  526. package/dist/packager/targetcli.js.map +0 -1
  527. package/dist/persistence/adapter.d.ts +0 -5
  528. package/dist/persistence/adapter.d.ts.map +0 -1
  529. package/dist/persistence/adapter.js +0 -11
  530. package/dist/persistence/adapter.js.map +0 -1
  531. package/dist/persistence/drizzle.d.ts +0 -2
  532. package/dist/persistence/drizzle.d.ts.map +0 -1
  533. package/dist/persistence/drizzle.js +0 -12
  534. package/dist/persistence/drizzle.js.map +0 -1
  535. package/dist/persistence/memory.d.ts +0 -2
  536. package/dist/persistence/memory.d.ts.map +0 -1
  537. package/dist/persistence/memory.js +0 -27
  538. package/dist/persistence/memory.js.map +0 -1
  539. package/dist/persistence/migrations.d.ts +0 -19
  540. package/dist/persistence/migrations.d.ts.map +0 -1
  541. package/dist/persistence/migrations.js +0 -13
  542. package/dist/persistence/migrations.js.map +0 -1
  543. package/dist/persistence/prisma.d.ts +0 -2
  544. package/dist/persistence/prisma.d.ts.map +0 -1
  545. package/dist/persistence/prisma.js +0 -25
  546. package/dist/persistence/prisma.js.map +0 -1
  547. package/dist/persistence/schema.d.ts +0 -63
  548. package/dist/persistence/schema.d.ts.map +0 -1
  549. package/dist/persistence/schema.js +0 -28
  550. package/dist/persistence/schema.js.map +0 -1
  551. package/dist/persistence/sql.d.ts +0 -3
  552. package/dist/persistence/sql.d.ts.map +0 -1
  553. package/dist/persistence/sql.js +0 -37
  554. package/dist/persistence/sql.js.map +0 -1
  555. package/dist/protocol/blocks.d.ts +0 -10
  556. package/dist/protocol/blocks.d.ts.map +0 -1
  557. package/dist/protocol/blocks.js +0 -26
  558. package/dist/protocol/blocks.js.map +0 -1
  559. package/dist/protocol/json.d.ts +0 -6
  560. package/dist/protocol/json.d.ts.map +0 -1
  561. package/dist/protocol/json.js +0 -6
  562. package/dist/protocol/json.js.map +0 -1
  563. package/dist/protocol/ndjson.d.ts +0 -3
  564. package/dist/protocol/ndjson.d.ts.map +0 -1
  565. package/dist/protocol/ndjson.js +0 -20
  566. package/dist/protocol/ndjson.js.map +0 -1
  567. package/dist/protocol/sse.d.ts +0 -7
  568. package/dist/protocol/sse.d.ts.map +0 -1
  569. package/dist/protocol/sse.js +0 -25
  570. package/dist/protocol/sse.js.map +0 -1
  571. package/dist/proxy/pool.d.ts +0 -9
  572. package/dist/proxy/pool.d.ts.map +0 -1
  573. package/dist/proxy/pool.js +0 -27
  574. package/dist/proxy/pool.js.map +0 -1
  575. package/dist/queue/idempotency.d.ts +0 -10
  576. package/dist/queue/idempotency.d.ts.map +0 -1
  577. package/dist/queue/idempotency.js +0 -13
  578. package/dist/queue/idempotency.js.map +0 -1
  579. package/dist/queue/persistent.d.ts +0 -14
  580. package/dist/queue/persistent.d.ts.map +0 -1
  581. package/dist/queue/persistent.js +0 -66
  582. package/dist/queue/persistent.js.map +0 -1
  583. package/dist/queue/queue.d.ts +0 -7
  584. package/dist/queue/queue.d.ts.map +0 -1
  585. package/dist/queue/queue.js +0 -55
  586. package/dist/queue/queue.js.map +0 -1
  587. package/dist/queue/saga.d.ts +0 -5
  588. package/dist/queue/saga.d.ts.map +0 -1
  589. package/dist/queue/saga.js +0 -20
  590. package/dist/queue/saga.js.map +0 -1
  591. package/dist/release/assets.d.ts +0 -144
  592. package/dist/release/assets.d.ts.map +0 -1
  593. package/dist/release/assets.js +0 -157
  594. package/dist/release/assets.js.map +0 -1
  595. package/dist/release/evidence.d.ts +0 -92
  596. package/dist/release/evidence.d.ts.map +0 -1
  597. package/dist/release/evidence.js +0 -148
  598. package/dist/release/evidence.js.map +0 -1
  599. package/dist/release/verify.d.ts +0 -12
  600. package/dist/release/verify.d.ts.map +0 -1
  601. package/dist/release/verify.js +0 -112
  602. package/dist/release/verify.js.map +0 -1
  603. package/dist/runners/chain.d.ts +0 -125
  604. package/dist/runners/chain.d.ts.map +0 -1
  605. package/dist/runners/chain.js +0 -95
  606. package/dist/runners/chain.js.map +0 -1
  607. package/dist/runners/health.d.ts +0 -36
  608. package/dist/runners/health.d.ts.map +0 -1
  609. package/dist/runners/health.js +0 -26
  610. package/dist/runners/health.js.map +0 -1
  611. package/dist/runners/heartbeat.d.ts +0 -23
  612. package/dist/runners/heartbeat.d.ts.map +0 -1
  613. package/dist/runners/heartbeat.js +0 -29
  614. package/dist/runners/heartbeat.js.map +0 -1
  615. package/dist/runners/inprocess.d.ts +0 -17
  616. package/dist/runners/inprocess.d.ts.map +0 -1
  617. package/dist/runners/inprocess.js +0 -20
  618. package/dist/runners/inprocess.js.map +0 -1
  619. package/dist/runners/scheduler.d.ts +0 -5
  620. package/dist/runners/scheduler.d.ts.map +0 -1
  621. package/dist/runners/scheduler.js +0 -19
  622. package/dist/runners/scheduler.js.map +0 -1
  623. package/dist/runtime/abort.d.ts +0 -8
  624. package/dist/runtime/abort.d.ts.map +0 -1
  625. package/dist/runtime/abort.js +0 -13
  626. package/dist/runtime/abort.js.map +0 -1
  627. package/dist/runtime/compatibility.d.ts +0 -37
  628. package/dist/runtime/compatibility.d.ts.map +0 -1
  629. package/dist/runtime/compatibility.js +0 -10
  630. package/dist/runtime/compatibility.js.map +0 -1
  631. package/dist/runtime/detect.d.ts +0 -13
  632. package/dist/runtime/detect.d.ts.map +0 -1
  633. package/dist/runtime/detect.js +0 -18
  634. package/dist/runtime/detect.js.map +0 -1
  635. package/dist/runtime/engine.d.ts +0 -20
  636. package/dist/runtime/engine.d.ts.map +0 -1
  637. package/dist/runtime/engine.js +0 -61
  638. package/dist/runtime/engine.js.map +0 -1
  639. package/dist/runtime/retry.d.ts +0 -19
  640. package/dist/runtime/retry.d.ts.map +0 -1
  641. package/dist/runtime/retry.js +0 -54
  642. package/dist/runtime/retry.js.map +0 -1
  643. package/dist/runtime/worker.d.ts +0 -10
  644. package/dist/runtime/worker.d.ts.map +0 -1
  645. package/dist/runtime/worker.js +0 -25
  646. package/dist/runtime/worker.js.map +0 -1
  647. package/dist/scrape/cache.d.ts +0 -45
  648. package/dist/scrape/cache.d.ts.map +0 -1
  649. package/dist/scrape/cache.js +0 -45
  650. package/dist/scrape/cache.js.map +0 -1
  651. package/dist/scrape/crawl.d.ts +0 -47
  652. package/dist/scrape/crawl.d.ts.map +0 -1
  653. package/dist/scrape/crawl.js +0 -114
  654. package/dist/scrape/crawl.js.map +0 -1
  655. package/dist/scrape/extract.d.ts +0 -63
  656. package/dist/scrape/extract.d.ts.map +0 -1
  657. package/dist/scrape/extract.js +0 -47
  658. package/dist/scrape/extract.js.map +0 -1
  659. package/dist/scrape/normalize.d.ts +0 -52
  660. package/dist/scrape/normalize.d.ts.map +0 -1
  661. package/dist/scrape/normalize.js +0 -102
  662. package/dist/scrape/normalize.js.map +0 -1
  663. package/dist/scrape/robots.d.ts +0 -37
  664. package/dist/scrape/robots.d.ts.map +0 -1
  665. package/dist/scrape/robots.js +0 -71
  666. package/dist/scrape/robots.js.map +0 -1
  667. package/dist/scrape/schema.d.ts +0 -23
  668. package/dist/scrape/schema.d.ts.map +0 -1
  669. package/dist/scrape/schema.js +0 -92
  670. package/dist/scrape/schema.js.map +0 -1
  671. package/dist/scrape/scraper.d.ts +0 -6
  672. package/dist/scrape/scraper.d.ts.map +0 -1
  673. package/dist/scrape/scraper.js +0 -46
  674. package/dist/scrape/scraper.js.map +0 -1
  675. package/dist/scrape/semantic.d.ts +0 -25
  676. package/dist/scrape/semantic.d.ts.map +0 -1
  677. package/dist/scrape/semantic.js +0 -27
  678. package/dist/scrape/semantic.js.map +0 -1
  679. package/dist/server/node.d.ts +0 -7
  680. package/dist/server/node.d.ts.map +0 -1
  681. package/dist/server/node.js.map +0 -1
  682. package/dist/sessions/file.d.ts +0 -25
  683. package/dist/sessions/file.d.ts.map +0 -1
  684. package/dist/sessions/file.js +0 -13
  685. package/dist/sessions/file.js.map +0 -1
  686. package/dist/sessions/replay.d.ts +0 -9
  687. package/dist/sessions/replay.d.ts.map +0 -1
  688. package/dist/sessions/replay.js +0 -70
  689. package/dist/sessions/replay.js.map +0 -1
  690. package/dist/sessions/store.d.ts +0 -25
  691. package/dist/sessions/store.d.ts.map +0 -1
  692. package/dist/sessions/store.js +0 -13
  693. package/dist/sessions/store.js.map +0 -1
  694. package/dist/storage/adapter.d.ts +0 -5
  695. package/dist/storage/adapter.d.ts.map +0 -1
  696. package/dist/storage/adapter.js +0 -11
  697. package/dist/storage/adapter.js.map +0 -1
  698. package/dist/storage/cache.d.ts +0 -23
  699. package/dist/storage/cache.d.ts.map +0 -1
  700. package/dist/storage/cache.js +0 -79
  701. package/dist/storage/cache.js.map +0 -1
  702. package/dist/storage/checksum.d.ts +0 -3
  703. package/dist/storage/checksum.d.ts.map +0 -1
  704. package/dist/storage/checksum.js +0 -19
  705. package/dist/storage/checksum.js.map +0 -1
  706. package/dist/storage/chunked.d.ts +0 -21
  707. package/dist/storage/chunked.d.ts.map +0 -1
  708. package/dist/storage/chunked.js +0 -67
  709. package/dist/storage/chunked.js.map +0 -1
  710. package/dist/storage/content.d.ts +0 -24
  711. package/dist/storage/content.d.ts.map +0 -1
  712. package/dist/storage/content.js +0 -44
  713. package/dist/storage/content.js.map +0 -1
  714. package/dist/storage/filehosting.d.ts +0 -2
  715. package/dist/storage/filehosting.d.ts.map +0 -1
  716. package/dist/storage/filehosting.js +0 -24
  717. package/dist/storage/filehosting.js.map +0 -1
  718. package/dist/storage/githubcontents.d.ts +0 -2
  719. package/dist/storage/githubcontents.d.ts.map +0 -1
  720. package/dist/storage/githubcontents.js +0 -29
  721. package/dist/storage/githubcontents.js.map +0 -1
  722. package/dist/storage/index.d.ts +0 -12
  723. package/dist/storage/index.d.ts.map +0 -1
  724. package/dist/storage/index.js +0 -12
  725. package/dist/storage/index.js.map +0 -1
  726. package/dist/storage/local.d.ts +0 -2
  727. package/dist/storage/local.d.ts.map +0 -1
  728. package/dist/storage/local.js +0 -72
  729. package/dist/storage/local.js.map +0 -1
  730. package/dist/storage/memory.d.ts +0 -6
  731. package/dist/storage/memory.d.ts.map +0 -1
  732. package/dist/storage/memory.js +0 -36
  733. package/dist/storage/memory.js.map +0 -1
  734. package/dist/storage/pool.d.ts +0 -95
  735. package/dist/storage/pool.d.ts.map +0 -1
  736. package/dist/storage/pool.js +0 -202
  737. package/dist/storage/pool.js.map +0 -1
  738. package/dist/storage/s3compatible.d.ts +0 -3
  739. package/dist/storage/s3compatible.d.ts.map +0 -1
  740. package/dist/storage/s3compatible.js +0 -70
  741. package/dist/storage/s3compatible.js.map +0 -1
  742. package/dist/storage/sync.d.ts +0 -47
  743. package/dist/storage/sync.d.ts.map +0 -1
  744. package/dist/storage/sync.js +0 -75
  745. package/dist/storage/sync.js.map +0 -1
  746. package/dist/surfaces/adapters.d.ts +0 -97
  747. package/dist/surfaces/adapters.d.ts.map +0 -1
  748. package/dist/surfaces/adapters.js +0 -50
  749. package/dist/surfaces/adapters.js.map +0 -1
  750. package/dist/surfaces/controls.d.ts +0 -18
  751. package/dist/surfaces/controls.d.ts.map +0 -1
  752. package/dist/surfaces/controls.js +0 -45
  753. package/dist/surfaces/controls.js.map +0 -1
  754. package/dist/surfaces/manifest.d.ts +0 -68
  755. package/dist/surfaces/manifest.d.ts.map +0 -1
  756. package/dist/surfaces/manifest.js +0 -42
  757. package/dist/surfaces/manifest.js.map +0 -1
  758. package/dist/surfaces/n8n.d.ts +0 -25
  759. package/dist/surfaces/n8n.d.ts.map +0 -1
  760. package/dist/surfaces/n8n.js +0 -31
  761. package/dist/surfaces/n8n.js.map +0 -1
  762. package/dist/surfaces/operations.d.ts +0 -32
  763. package/dist/surfaces/operations.d.ts.map +0 -1
  764. package/dist/surfaces/operations.js +0 -53
  765. package/dist/surfaces/operations.js.map +0 -1
  766. package/dist/surfaces/requirements.d.ts +0 -29
  767. package/dist/surfaces/requirements.d.ts.map +0 -1
  768. package/dist/surfaces/requirements.js +0 -50
  769. package/dist/surfaces/requirements.js.map +0 -1
  770. package/dist/surfaces/targets.d.ts +0 -196
  771. package/dist/surfaces/targets.d.ts.map +0 -1
  772. package/dist/surfaces/targets.js +0 -27
  773. package/dist/surfaces/targets.js.map +0 -1
  774. package/dist/webhook/delivery.d.ts +0 -18
  775. package/dist/webhook/delivery.d.ts.map +0 -1
  776. package/dist/webhook/delivery.js +0 -36
  777. package/dist/webhook/delivery.js.map +0 -1
  778. package/dist/webhook/receiver.d.ts +0 -26
  779. package/dist/webhook/receiver.d.ts.map +0 -1
  780. package/dist/webhook/receiver.js +0 -24
  781. package/dist/webhook/receiver.js.map +0 -1
  782. package/dist/webhook/signature.d.ts +0 -3
  783. package/dist/webhook/signature.d.ts.map +0 -1
  784. package/dist/webhook/signature.js +0 -7
  785. package/dist/webhook/signature.js.map +0 -1
  786. package/dist/workflow/manifest.d.ts +0 -22
  787. package/dist/workflow/manifest.d.ts.map +0 -1
  788. package/dist/workflow/manifest.js +0 -21
  789. package/dist/workflow/manifest.js.map +0 -1
  790. package/dist/workflow/registry.d.ts +0 -7
  791. package/dist/workflow/registry.d.ts.map +0 -1
  792. package/dist/workflow/registry.js +0 -18
  793. package/dist/workflow/registry.js.map +0 -1
  794. package/dist/workflow/templates.d.ts +0 -6
  795. package/dist/workflow/templates.d.ts.map +0 -1
  796. package/dist/workflow/templates.js +0 -18
  797. package/dist/workflow/templates.js.map +0 -1
  798. package/dist/workflow/triggers.d.ts +0 -64
  799. package/dist/workflow/triggers.d.ts.map +0 -1
  800. package/dist/workflow/triggers.js +0 -99
  801. package/dist/workflow/triggers.js.map +0 -1
  802. /package/{extension/README.md → docs/extension.md} +0 -0
package/media.ts ADDED
@@ -0,0 +1,1337 @@
1
+ /**
2
+ * media.ts — media pipeline and transcode domain for saddle v6.
3
+ *
4
+ * the module absorbs the media-facing halves of the pool
5
+ * pipelinememorypassage.ts (saddle v6 orchestrator) and
6
+ * src_pipeline_memory_passage.ts (saddle v5 mttg pipeline) that were
7
+ * still unique after the v3 consolidation:
8
+ * - the 24-stage GPU-accelerated transcode pipeline as a pure catalog
9
+ * plus an executing pipeline (stage ordering, skip rules, fail-fast,
10
+ * abort, chunked batch concurrency, stage-count invariant 24)
11
+ * - ffmpeg 7.1 NVENC Blackwell command synthesis: presets p1-p7, rc
12
+ * vbr_hq with cq 23, multipass 2, b_ref_mode 2 (b-frames as
13
+ * reference), temporal aq with rc-lookahead 32, bwdif_cuda,
14
+ * scale_cuda super, tonemap_cuda hable/bt2390 with colorspace_cuda
15
+ * bt2020->bt709, av1 tier high
16
+ * - the createoptimal encoder policy of the pool encoding optimization
17
+ * manager: AV1 at 4K+ forces the Blackwell dual NVENC path, h264
18
+ * ultra-low-latency prefers QuickSync, plus the preset recommender
19
+ * (ultra low latency p1, low latency p2, live p3, vod av1 p5, vod
20
+ * hevc p6, default p4) and the per-gpu instance recommender
21
+ * - the passage secure channel contract: transport vsock+virtio-serial,
22
+ * ed25519 signatures over chacha20-poly1305 sealed frames, MTU
23
+ * 65536, 10000 Mbps rate limit, 256 concurrent streams, 150 us
24
+ * latency target
25
+ * - the ~30 transcode mode taxonomy of the library-first surface
26
+ *
27
+ * the memory-modularizer half of the same pool files (zram, hugepages,
28
+ * CXL type-3 tiering, CCD-aware vCPU pinning) is already absorbed in
29
+ * virtualmemory.ts (memorymodularizer) and is intentionally not
30
+ * duplicated here; the pipeline consumes a plan digest only.
31
+ *
32
+ * provenance: pool:pipelinememorypassage.ts [S6 v6, 24 stages],
33
+ * pool:src_pipeline_memory_passage.ts [V5 src_mttg_pipeline ordering],
34
+ * pool:mttg.config transcode section (ffmpeg 7.1.1, nvenc sdk 13.0.19),
35
+ * pool:src_virtualization_core.cpp create_optimal (encoder policy).
36
+ *
37
+ * rules: lowercase identifiers, english jsdoc third person, no emoji,
38
+ * try/catch catcher on every fallible path, node:* built-ins first,
39
+ * zero runtime dependencies, `satisfies`/`#private` throughout, no
40
+ * filesystem or process coupling (pure library).
41
+ */
42
+
43
+ import {
44
+ createHash,
45
+ sign as cryptosign,
46
+ verify as cryptoverify,
47
+ generateKeyPairSync,
48
+ type KeyObject,
49
+ } from 'node:crypto';
50
+ import { chachaopen, chachaseal } from './security.js';
51
+
52
+ /* ------------------------------------------------------------------ */
53
+ /* context: version anchors (media toolchain, date-first 2026-08-22) */
54
+ /* ------------------------------------------------------------------ */
55
+
56
+ /**
57
+ * frozen media toolchain anchors. the pool registry pinned node 22.12.3
58
+ * / ts 5.6.3 / qemu 9.1.2 which the v3 pin patch superseded; the media
59
+ * specific values (ffmpeg release line, NVENC SDK, CUDA floor, Blackwell
60
+ * driver) are preserved verbatim from the pool registry.
61
+ */
62
+ export const mediaversions = {
63
+ date: '2026-08-22',
64
+ ffmpeg: '7.1.1',
65
+ ffmpegNote: '7.1 released 2024-09-30; 7.1.1 is the 2026-08-22 stable',
66
+ nvencSdk: '13.0.19',
67
+ nvencGeneration: 9,
68
+ nvdecGeneration: 6,
69
+ cuda: '12.8',
70
+ cudaNote:
71
+ 'Blackwell GB202 requires >= 12.8; pool registry cited 12.8.93 with an early 13.0.48 alt',
72
+ driver: '580.82.07',
73
+ driverNote:
74
+ 'production branch for Blackwell + NVENC SDK 13.0; repo also carries 570.144 vgpu-manual anchors',
75
+ stages: 24,
76
+ modes: 30,
77
+ } as const satisfies Record<string, string | number>;
78
+
79
+ /* ------------------------------------------------------------------ */
80
+ /* context: error catcher (typed envelope for every stage failure) */
81
+ /* ------------------------------------------------------------------ */
82
+
83
+ /** media pipeline failure envelope with stage and recoverability. */
84
+ export class mediapipelineerror extends Error {
85
+ readonly code: string;
86
+ readonly stage?: string;
87
+ readonly recoverable: boolean;
88
+ readonly traceid: string;
89
+
90
+ constructor(params: {
91
+ code: string;
92
+ message: string;
93
+ stage?: string;
94
+ recoverable?: boolean;
95
+ }) {
96
+ super(params.message);
97
+ this.name = 'mediapipelineerror';
98
+ this.code = params.code;
99
+ this.stage = params.stage;
100
+ this.recoverable = params.recoverable ?? false;
101
+ this.traceid = createHash('sha256')
102
+ .update(`${params.code}:${params.stage ?? 'pipeline'}:${params.message}`)
103
+ .digest('hex')
104
+ .slice(0, 8);
105
+ }
106
+ }
107
+
108
+ /* ------------------------------------------------------------------ */
109
+ /* context: nvenc presets p1-p7 (Blackwell taxonomy, p4 balanced) */
110
+ /* ------------------------------------------------------------------ */
111
+
112
+ /**
113
+ * NVENC preset taxonomy of the Blackwell SDK: p1 is fastest, p7 is the
114
+ * highest-quality two-pass point and p4 is the balanced 2026 default.
115
+ */
116
+ export type nvencpreset = 'p1' | 'p2' | 'p3' | 'p4' | 'p5' | 'p6' | 'p7';
117
+
118
+ /** ordered preset ladder from fastest to highest quality. */
119
+ export const nvencpresetladder: readonly nvencpreset[] = ['p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7'];
120
+
121
+ /** per-preset character used by the ffmpeg builder and the recommender. */
122
+ export const nvencpresets: readonly {
123
+ readonly preset: nvencpreset;
124
+ readonly speed: number;
125
+ readonly multipass: 'disabled' | 'qres' | 'fullres';
126
+ readonly use: string;
127
+ }[] = [
128
+ {
129
+ preset: 'p1',
130
+ speed: 10,
131
+ multipass: 'disabled',
132
+ use: 'fastest, low-latency preview and thumbnails',
133
+ },
134
+ { preset: 'p2', speed: 8, multipass: 'disabled', use: 'faster, ultra-low-latency conferencing' },
135
+ { preset: 'p3', speed: 6, multipass: 'qres', use: 'fast, live av1 with tight slice budgets' },
136
+ { preset: 'p4', speed: 4, multipass: 'qres', use: 'balanced default for 2026 vod ladders' },
137
+ { preset: 'p5', speed: 3, multipass: 'qres', use: 'slow, hls 1080p anchor of mttg.config' },
138
+ { preset: 'p6', speed: 2, multipass: 'fullres', use: 'slower, vod hevc mezzanine' },
139
+ { preset: 'p7', speed: 1, multipass: 'fullres', use: 'highest quality 2-pass, creator 4k av1' },
140
+ ] satisfies readonly {
141
+ preset: nvencpreset;
142
+ speed: number;
143
+ multipass: 'disabled' | 'qres' | 'fullres';
144
+ use: string;
145
+ }[];
146
+
147
+ /** resolves one preset descriptor or undefined when out of ladder. */
148
+ export function getnvencpreset(preset: nvencpreset) {
149
+ return nvencpresets.find((entry) => entry.preset === preset);
150
+ }
151
+
152
+ /* ------------------------------------------------------------------ */
153
+ /* context: transcode modes (~30, library-first surface) */
154
+ /* ------------------------------------------------------------------ */
155
+
156
+ /**
157
+ * the transcode mode taxonomy: 30 modes spanning codec conversion,
158
+ * HDR tone mapping, scaling, denoise, subtitle burn, VMAF targeting,
159
+ * rate-control strategies and packaging.
160
+ */
161
+ export type transcodemode =
162
+ | 'hevc_to_av1_b200'
163
+ | 'avc_to_hevc_blackwell'
164
+ | 'av1_to_hevc_hdr'
165
+ | 'hevc_hdr_to_av1_sdr_tonemap'
166
+ | 'av1_8k_to_4k_blackwell'
167
+ | '4k_to_1080p_nvenc'
168
+ | '4k_to_720p_mobile'
169
+ | 'dash_hls_packaging'
170
+ | 'remux_fast'
171
+ | 'audio_only_aac_opus'
172
+ | 'hdr10plus_dolbyvision_passthrough'
173
+ | 'tonemap_hable_cuda'
174
+ | 'tonemap_mobius_cuda'
175
+ | 'tonemap_reinhard_cuda'
176
+ | 'deinterlace_bwdif_cuda'
177
+ | 'denoise_hqdn3d_cuda'
178
+ | 'scale_npp_bicubic'
179
+ | 'scale_npp_lanczos'
180
+ | 'subburn_ass_cuda'
181
+ | 'thumbnail_vmaf'
182
+ | 'vmaf_target_95'
183
+ | 'vmaf_target_93'
184
+ | 'vmaf_target_90'
185
+ | 'cqp_high_quality'
186
+ | 'cbr_low_latency'
187
+ | 'vbr_hq_2pass'
188
+ | 'll_hq_temporal_filter'
189
+ | 'fastdecode_fmp4'
190
+ | 'prores_to_av1_archive'
191
+ | 'av1_hdr10_to_sdr';
192
+
193
+ /** one catalog row: mode, family and the pipeline stages it stresses. */
194
+ export interface transcodemodeentry {
195
+ readonly mode: transcodemode;
196
+ readonly family:
197
+ | 'codec-conversion'
198
+ | 'hdr-tonemap'
199
+ | 'scale'
200
+ | 'filters'
201
+ | 'audio'
202
+ | 'quality-metrics'
203
+ | 'rate-control'
204
+ | 'packaging';
205
+ readonly note: string;
206
+ }
207
+
208
+ /** the 30-mode catalog in taxonomy order. */
209
+ export const transcodemodecatalog: readonly transcodemodeentry[] = [
210
+ {
211
+ mode: 'hevc_to_av1_b200',
212
+ family: 'codec-conversion',
213
+ note: 'Blackwell HBM transcoding anchor',
214
+ },
215
+ {
216
+ mode: 'avc_to_hevc_blackwell',
217
+ family: 'codec-conversion',
218
+ note: 'nvenc hevc main10 with b-frames as reference',
219
+ },
220
+ {
221
+ mode: 'av1_to_hevc_hdr',
222
+ family: 'codec-conversion',
223
+ note: 'distribution transcode keeping hdr10 metadata',
224
+ },
225
+ {
226
+ mode: 'hevc_hdr_to_av1_sdr_tonemap',
227
+ family: 'hdr-tonemap',
228
+ note: 'demo mode of the pool orchestrator',
229
+ },
230
+ {
231
+ mode: 'av1_8k_to_4k_blackwell',
232
+ family: 'scale',
233
+ note: '8192x4320 mezzanine downscale, pro6000 96GB anchor',
234
+ },
235
+ { mode: '4k_to_1080p_nvenc', family: 'scale', note: 'creator ladder step' },
236
+ { mode: '4k_to_720p_mobile', family: 'scale', note: 'mobile ladder step' },
237
+ {
238
+ mode: 'dash_hls_packaging',
239
+ family: 'packaging',
240
+ note: 'frag_keyframe + faststart + dash hls manifests',
241
+ },
242
+ { mode: 'remux_fast', family: 'packaging', note: 'container copy without re-encode' },
243
+ { mode: 'audio_only_aac_opus', family: 'audio', note: 'ccd1 threads, loudnorm EBU R128' },
244
+ {
245
+ mode: 'hdr10plus_dolbyvision_passthrough',
246
+ family: 'hdr-tonemap',
247
+ note: 'metadata copy without tone mapping',
248
+ },
249
+ { mode: 'tonemap_hable_cuda', family: 'hdr-tonemap', note: 'hable curve on cuda frames' },
250
+ { mode: 'tonemap_mobius_cuda', family: 'hdr-tonemap', note: 'mobius curve, bright highlights' },
251
+ { mode: 'tonemap_reinhard_cuda', family: 'hdr-tonemap', note: 'reinhard curve, soft roll-off' },
252
+ {
253
+ mode: 'deinterlace_bwdif_cuda',
254
+ family: 'filters',
255
+ note: 'bwdif_cuda=0:-1:0, skipped when progressive',
256
+ },
257
+ {
258
+ mode: 'denoise_hqdn3d_cuda',
259
+ family: 'filters',
260
+ note: 'hqdn3d tuned for CCD0 V-Cache locality',
261
+ },
262
+ { mode: 'scale_npp_bicubic', family: 'scale', note: 'npp bicubic interpolation' },
263
+ { mode: 'scale_npp_lanczos', family: 'scale', note: 'npp lanczos, sharpest downscale' },
264
+ { mode: 'subburn_ass_cuda', family: 'filters', note: 'ass burn when subtitle path present' },
265
+ { mode: 'thumbnail_vmaf', family: 'quality-metrics', note: 'thumbnail=50 plus vmaf probe' },
266
+ { mode: 'vmaf_target_95', family: 'quality-metrics', note: 'highest vmaf target' },
267
+ {
268
+ mode: 'vmaf_target_93',
269
+ family: 'quality-metrics',
270
+ note: 'creator 4k av1 target of mttg.config',
271
+ },
272
+ { mode: 'vmaf_target_90', family: 'quality-metrics', note: 'mobile ladder target' },
273
+ { mode: 'cqp_high_quality', family: 'rate-control', note: 'constqp 18 mezzanine anchor' },
274
+ { mode: 'cbr_low_latency', family: 'rate-control', note: 'conferencing path, qsv preferred' },
275
+ { mode: 'vbr_hq_2pass', family: 'rate-control', note: 'rc vbr_hq with multipass fullres' },
276
+ {
277
+ mode: 'll_hq_temporal_filter',
278
+ family: 'rate-control',
279
+ note: '8k temporal filter low-latency path',
280
+ },
281
+ { mode: 'fastdecode_fmp4', family: 'packaging', note: 'fragmented mp4 for fast decode' },
282
+ { mode: 'prores_to_av1_archive', family: 'codec-conversion', note: 'film8k archival tier' },
283
+ { mode: 'av1_hdr10_to_sdr', family: 'hdr-tonemap', note: 'bt2390 curve variant' },
284
+ ] satisfies readonly transcodemodeentry[];
285
+
286
+ /** counts the catalog and asserts the 30-mode library-first surface. */
287
+ export function transcodemodecount(): number {
288
+ return transcodemodecatalog.length;
289
+ }
290
+
291
+ /* ------------------------------------------------------------------ */
292
+ /* context: probe, output profile and job types */
293
+ /* ------------------------------------------------------------------ */
294
+
295
+ /** ffprobe 7.1 style inspection of one input. */
296
+ export interface mediaprobe {
297
+ readonly durationsec: number;
298
+ readonly video?: {
299
+ readonly codec: 'h264' | 'hevc' | 'av1' | 'prores' | 'vp9';
300
+ readonly width: number;
301
+ readonly height: number;
302
+ readonly fps: number;
303
+ readonly bitdepth: 8 | 10 | 12;
304
+ readonly hdr: boolean;
305
+ readonly interlaced: boolean;
306
+ readonly hdr10plus?: boolean;
307
+ readonly dolbyvision?: boolean;
308
+ };
309
+ readonly audio: ReadonlyArray<{ codec: string; samplerate: number; channels: number }>;
310
+ readonly estimatedworkingsetmb: number;
311
+ }
312
+
313
+ /** the requested output rendering of one job. */
314
+ export interface outputprofile {
315
+ readonly videocodec: 'h264' | 'hevc' | 'av1';
316
+ readonly audiocodec: 'aac' | 'opus' | 'ac3';
317
+ readonly resolution: { readonly w: number; readonly h: number };
318
+ readonly bitratekbps: number;
319
+ readonly preset: nvencpreset;
320
+ readonly tonemap: boolean;
321
+ readonly vmaftarget?: number;
322
+ readonly bframes?: number;
323
+ readonly gopsec?: number;
324
+ }
325
+
326
+ /** one queued transcode job; MTTG priority 0..3 maps to QoS classes. */
327
+ export interface mediajob {
328
+ readonly id: string;
329
+ readonly inputpath: string;
330
+ readonly outputpath: string;
331
+ readonly mode: transcodemode;
332
+ readonly outputprofile: outputprofile;
333
+ readonly priority: 0 | 1 | 2 | 3;
334
+ readonly metadata?: {
335
+ readonly subtitlepath?: string;
336
+ readonly logopath?: string;
337
+ readonly passagevmid?: string;
338
+ };
339
+ /** digest of the host memory plan produced by virtualmemory.ts. */
340
+ readonly memoryplandigest?: string;
341
+ }
342
+
343
+ /* ------------------------------------------------------------------ */
344
+ /* context: the 24-stage catalog (v6 canonical, v5 alternate order) */
345
+ /* ------------------------------------------------------------------ */
346
+
347
+ /**
348
+ * the canonical 24 stage names of the saddle v6 pipeline, preserved
349
+ * verbatim (numbered pool identifiers are catalog data, not new code
350
+ * identifiers).
351
+ */
352
+ export type stageid =
353
+ | '01_ingest_audit'
354
+ | '02_probe_ffprobe71'
355
+ | '03_tieredmemory_reserve'
356
+ | '04_hugepage_alloc_2m1g'
357
+ | '05_zram_lzorle_zstd'
358
+ | '06_cxl_map_v2_v3'
359
+ | '07_vcpu_pin_ccd_x3d'
360
+ | '08_hwaccel_detect_blackwell'
361
+ | '09_hwupload_cuda'
362
+ | '10DeinterlaceBwdifCuda'
363
+ | '11_scale_cuda_npp'
364
+ | '12TonemapBt2020Cuda'
365
+ | '13DenoiseCuda'
366
+ | '14_color_mgmt'
367
+ | '15_nvenc_blackwell_encode'
368
+ | '16QsvFallback'
369
+ | '17_audio_transcode'
370
+ | '18SubtitleBurn'
371
+ | '19_mux_container'
372
+ | '20_passage_message_vsock'
373
+ | '21_qemu_balloon_notify'
374
+ | '22_tiered_reclaim'
375
+ | '23_mttg_slice_report'
376
+ | '24_artifact_gc_finalize';
377
+
378
+ /** one catalog row of the 24-stage table. */
379
+ export interface stageentry {
380
+ readonly name: stageid;
381
+ readonly index: number;
382
+ readonly description: string;
383
+ readonly gpurequired: boolean;
384
+ /** stages that the pool marks skippable through a skipIf predicate. */
385
+ readonly skippable: boolean;
386
+ }
387
+
388
+ /**
389
+ * the 24-stage catalog sequenced for maximum cache affinity: CCD0
390
+ * V-Cache carries the video filter chain, CCD1 carries audio, mux and
391
+ * io, memory stages (03-07) precede any GPU work.
392
+ */
393
+ export const stagecatalog: readonly stageentry[] = [
394
+ {
395
+ name: '01_ingest_audit',
396
+ index: 1,
397
+ description: 'checksum sha256, container probe, 50GB input cap, passage vm id validation',
398
+ gpurequired: false,
399
+ skippable: false,
400
+ },
401
+ {
402
+ name: '02_probe_ffprobe71',
403
+ index: 2,
404
+ description: 'ffprobe 7.1 json probe: hdr, interlace, bit depth, working set estimate',
405
+ gpurequired: false,
406
+ skippable: false,
407
+ },
408
+ {
409
+ name: '03_tieredmemory_reserve',
410
+ index: 3,
411
+ description:
412
+ 'dram fast 60% + dram slow 20% + cxl fm 15% + hbm mapping + zram tiers (virtualmemory.ts memorymodularizer)',
413
+ gpurequired: false,
414
+ skippable: false,
415
+ },
416
+ {
417
+ name: '04_hugepage_alloc_2m1g',
418
+ index: 4,
419
+ description: '2M/1G hugepages THP always/madvise via memfd hugetlb backing',
420
+ gpurequired: false,
421
+ skippable: false,
422
+ },
423
+ {
424
+ name: '05_zram_lzorle_zstd',
425
+ index: 5,
426
+ description: 'zram lzo-rle for realtime 4K or zstd:1 archival, mount scratch',
427
+ gpurequired: false,
428
+ skippable: false,
429
+ },
430
+ {
431
+ name: '06_cxl_map_v2_v3',
432
+ index: 6,
433
+ description: 'cxl 2.0/3.0 type-3 mapping via daxctl, 4-way interleave, qos class 2',
434
+ gpurequired: false,
435
+ skippable: false,
436
+ },
437
+ {
438
+ name: '07_vcpu_pin_ccd_x3d',
439
+ index: 7,
440
+ description: 'even vCPUs to CCD0 V-Cache 96MB (video), odd to CCD1 (audio/io)',
441
+ gpurequired: false,
442
+ skippable: false,
443
+ },
444
+ {
445
+ name: '08_hwaccel_detect_blackwell',
446
+ index: 8,
447
+ description: 'GB202/GB203 detection, cuda 12.8 driver 580.82.07, NVENC 9th gen caps',
448
+ gpurequired: true,
449
+ skippable: false,
450
+ },
451
+ {
452
+ name: '09_hwupload_cuda',
453
+ index: 9,
454
+ description: 'hwupload with 8 extra hw frames, peer HBM mapping on B200',
455
+ gpurequired: true,
456
+ skippable: false,
457
+ },
458
+ {
459
+ name: '10DeinterlaceBwdifCuda',
460
+ index: 10,
461
+ description: 'bwdif_cuda=0:-1:0, only when probe reports interlaced',
462
+ gpurequired: true,
463
+ skippable: true,
464
+ },
465
+ {
466
+ name: '11_scale_cuda_npp',
467
+ index: 11,
468
+ description: 'scale_cuda super / npp lanczos-bicubic, nv12, HDR metadata kept',
469
+ gpurequired: true,
470
+ skippable: false,
471
+ },
472
+ {
473
+ name: '12TonemapBt2020Cuda',
474
+ index: 12,
475
+ description: 'tonemap_cuda hable/mobius/bt2390 + colorspace_cuda bt2020->bt709',
476
+ gpurequired: true,
477
+ skippable: true,
478
+ },
479
+ {
480
+ name: '13DenoiseCuda',
481
+ index: 13,
482
+ description: 'cuda denoise or hqdn3d tuned for CCD0 locality',
483
+ gpurequired: true,
484
+ skippable: true,
485
+ },
486
+ {
487
+ name: '14_color_mgmt',
488
+ index: 14,
489
+ description: 'hdr10plus / dolby vision primaries and matrix metadata copy',
490
+ gpurequired: false,
491
+ skippable: false,
492
+ },
493
+ {
494
+ name: '15_nvenc_blackwell_encode',
495
+ index: 15,
496
+ description: 'NVENC 9th gen encode p1-p7, av1 b-frames ref mode 2, vbr_hq temporal aq',
497
+ gpurequired: true,
498
+ skippable: false,
499
+ },
500
+ {
501
+ name: '16QsvFallback',
502
+ index: 16,
503
+ description: 'intel arc b770 qsv low-latency fallback when Blackwell unavailable',
504
+ gpurequired: false,
505
+ skippable: true,
506
+ },
507
+ {
508
+ name: '17_audio_transcode',
509
+ index: 17,
510
+ description: 'aac/opus on CCD1, 48kHz stereo, dual-pass loudnorm EBU R128',
511
+ gpurequired: false,
512
+ skippable: false,
513
+ },
514
+ {
515
+ name: '18SubtitleBurn',
516
+ index: 18,
517
+ description: 'ass_cuda burn when a subtitle path is present, else mov_text passthrough',
518
+ gpurequired: true,
519
+ skippable: true,
520
+ },
521
+ {
522
+ name: '19_mux_container',
523
+ index: 19,
524
+ description: 'mp4/fmp4 mux frag_keyframe + faststart + dash hls manifests',
525
+ gpurequired: false,
526
+ skippable: false,
527
+ },
528
+ {
529
+ name: '20_passage_message_vsock',
530
+ index: 20,
531
+ description:
532
+ 'host notify over passage vsock: ed25519 signed, chacha20-poly1305 sealed, 65536 MTU',
533
+ gpurequired: false,
534
+ skippable: false,
535
+ },
536
+ {
537
+ name: '21_qemu_balloon_notify',
538
+ index: 21,
539
+ description: 'balloon free-page-reporting + virtio-mem hot unplug of the CXL tier',
540
+ gpurequired: false,
541
+ skippable: false,
542
+ },
543
+ {
544
+ name: '22_tiered_reclaim',
545
+ index: 22,
546
+ description: 'zram reset, CXL dax offline, hugepage release via memfd',
547
+ gpurequired: false,
548
+ skippable: false,
549
+ },
550
+ {
551
+ name: '23_mttg_slice_report',
552
+ index: 23,
553
+ description: 'cfs+eevdf 5000us slice accounting, tenant metrics export on 9092',
554
+ gpurequired: false,
555
+ skippable: false,
556
+ },
557
+ {
558
+ name: '24_artifact_gc_finalize',
559
+ index: 24,
560
+ description: 'workdir GC per mttg auto_cleanup, OTLP trace emission',
561
+ gpurequired: false,
562
+ skippable: false,
563
+ },
564
+ ] satisfies readonly stageentry[];
565
+
566
+ /**
567
+ * the alternate v5 ordering of src_mttg_pipeline.ts kept as provenance:
568
+ * demux/decode walk, crop_pad, overlay_logo, sharpen, thumbnail and
569
+ * upload_egress stages that the v6 line folded into other stages.
570
+ */
571
+ export const stageorderv5: readonly string[] = [
572
+ 'ingest',
573
+ 'demux',
574
+ 'decode_video',
575
+ 'decode_audio',
576
+ 'deinterlace',
577
+ 'scale',
578
+ 'tonemap_hdr_to_sdr',
579
+ 'color_correction',
580
+ 'denoise',
581
+ 'sharpen',
582
+ 'crop_pad',
583
+ 'overlay_logo',
584
+ 'subtitle_burn',
585
+ 'loudnorm',
586
+ 'resample_mix',
587
+ 'encode_video',
588
+ 'encode_audio',
589
+ 'mux',
590
+ 'thumbnail',
591
+ 'quality_metrics',
592
+ 'metadata_inject',
593
+ 'package_hls_dash',
594
+ 'upload_egress',
595
+ 'cleanup_telemetry',
596
+ ] as const;
597
+
598
+ /** validates the stage catalog invariant: 24 stages, indexes 1..24. */
599
+ export function validatestagecatalog(): { count: number; ordered: boolean } {
600
+ const ordered = stagecatalog.every((stage, i) => stage.index === i + 1);
601
+ if (stagecatalog.length !== 24) {
602
+ throw new mediapipelineerror({
603
+ code: 'STAGE_COUNT',
604
+ message: `expected 24 stages got ${stagecatalog.length}`,
605
+ recoverable: false,
606
+ });
607
+ }
608
+ return { count: stagecatalog.length, ordered };
609
+ }
610
+
611
+ /* ------------------------------------------------------------------ */
612
+ /* context: ffmpeg 7.1 NVENC Blackwell command synthesis */
613
+ /* ------------------------------------------------------------------ */
614
+
615
+ /** codec name to ffmpeg nvenc encoder mapping (Blackwell 9th gen). */
616
+ export const nvencencodernames: Readonly<Record<'h264' | 'hevc' | 'av1', string>> = {
617
+ h264: 'h264_nvenc',
618
+ hevc: 'hevc_nvenc',
619
+ av1: 'av1_nvenc',
620
+ };
621
+
622
+ /**
623
+ * synthesizes the ffmpeg 7.1 argv for one stage. the encode stage
624
+ * builds the full filter chain (deinterlace, scale, tone map) plus the
625
+ * NVENC block: preset p1..p7, rc vbr_hq, cq 23, 1.5x maxrate ceiling,
626
+ * multipass 2, b-frames with b_ref_mode 2, temporal aq with
627
+ * rc-lookahead 32, gpu device index and, for av1, tier high / main
628
+ * profile. the deinterlace and scale stages emit preview null-output
629
+ * commands at preset p1.
630
+ */
631
+ export function buildffmpegcommand(
632
+ job: mediajob,
633
+ probe: mediaprobe,
634
+ stage: stageid,
635
+ gpuid = 0,
636
+ ): readonly string[] {
637
+ try {
638
+ const encoder = nvencencodernames[job.outputprofile.videocodec];
639
+ const base = [
640
+ 'ffmpeg',
641
+ '-y',
642
+ '-hwaccel',
643
+ 'cuda',
644
+ '-hwaccel_output_format',
645
+ 'cuda',
646
+ '-extra_hw_frames',
647
+ '8',
648
+ '-i',
649
+ job.inputpath,
650
+ ];
651
+ if (stage === '15_nvenc_blackwell_encode') {
652
+ const filters: string[] = [];
653
+ if (probe.video?.interlaced === true) {
654
+ filters.push('bwdif_cuda=0:-1:0');
655
+ }
656
+ filters.push(
657
+ `scale_cuda=${job.outputprofile.resolution.w}:${job.outputprofile.resolution.h}:interp_algo=super:format=nv12`,
658
+ );
659
+ if (probe.video?.hdr === true && job.outputprofile.tonemap) {
660
+ filters.push(
661
+ 'tonemap_cuda=tonemap=hable:desat=0:peak=1000:format=nv12:primaries=bt709:transfer=bt709:matrix=bt709',
662
+ );
663
+ filters.push('colorspace_cuda=bt2020:bt709:bt2020:bt709');
664
+ }
665
+ const cmd = [...base];
666
+ if (filters.length > 0) {
667
+ cmd.push('-vf', `"${filters.join(',')}"`);
668
+ }
669
+ const gop =
670
+ job.outputprofile.gopsec !== undefined && probe.video !== undefined
671
+ ? Math.round(job.outputprofile.gopsec * probe.video.fps)
672
+ : 300;
673
+ cmd.push(
674
+ '-c:v',
675
+ encoder,
676
+ '-preset',
677
+ job.outputprofile.preset,
678
+ '-rc',
679
+ 'vbr_hq',
680
+ '-cq',
681
+ '23',
682
+ '-b:v',
683
+ `${job.outputprofile.bitratekbps}k`,
684
+ '-maxrate',
685
+ `${Math.round(job.outputprofile.bitratekbps * 1.5)}k`,
686
+ '-multipass',
687
+ '2',
688
+ '-g',
689
+ String(gop),
690
+ '-bf',
691
+ String(job.outputprofile.bframes ?? 3),
692
+ '-b_ref_mode',
693
+ '2',
694
+ '-temporal_aq',
695
+ '1',
696
+ '-rc-lookahead',
697
+ '32',
698
+ '-gpu',
699
+ String(gpuid),
700
+ '-delay',
701
+ '0',
702
+ );
703
+ if (job.outputprofile.videocodec === 'av1') {
704
+ cmd.push('-tier', 'high', '-profile:v', 'main');
705
+ }
706
+ cmd.push('-c:a', job.outputprofile.audiocodec, '-b:a', '128k', job.outputpath);
707
+ return cmd;
708
+ }
709
+ if (stage === '10DeinterlaceBwdifCuda') {
710
+ return [
711
+ ...base,
712
+ '-vf',
713
+ '"bwdif_cuda=0:-1:0"',
714
+ '-c:v',
715
+ 'h264_nvenc',
716
+ '-preset',
717
+ 'p1',
718
+ '-an',
719
+ '-f',
720
+ 'null',
721
+ '/dev/null',
722
+ ];
723
+ }
724
+ if (stage === '11_scale_cuda_npp') {
725
+ return [
726
+ ...base,
727
+ '-vf',
728
+ `"scale_cuda=${job.outputprofile.resolution.w}:${job.outputprofile.resolution.h}"`,
729
+ '-c:v',
730
+ 'h264_nvenc',
731
+ '-preset',
732
+ 'p1',
733
+ '-an',
734
+ '-f',
735
+ 'null',
736
+ '/dev/null',
737
+ ];
738
+ }
739
+ return base;
740
+ } catch (error) {
741
+ throw new mediapipelineerror({
742
+ code: 'FFMPEG_BUILD',
743
+ message: `ffmpeg command synthesis failed for stage ${stage}: ${error instanceof Error ? error.message : String(error)}`,
744
+ stage,
745
+ recoverable: true,
746
+ });
747
+ }
748
+ }
749
+
750
+ /* ------------------------------------------------------------------ */
751
+ /* context: createoptimal encoder backend policy */
752
+ /* ------------------------------------------------------------------ */
753
+
754
+ /** encoder backend vendors of the pool policy plus the software floor. */
755
+ export type encodervendor = 'nvidianvenc' | 'intelqsv' | 'amdamf' | 'softwarex265';
756
+
757
+ /** encoder tune axes used by the preset recommender. */
758
+ export type encodertune = 'ultralowlatency' | 'lowlatency' | 'quality';
759
+
760
+ /** the decision record returned by createoptimal. */
761
+ export interface optimalencoder {
762
+ readonly vendor: encodervendor;
763
+ readonly preset: nvencpreset;
764
+ readonly reason: string;
765
+ readonly maxinstances: number;
766
+ }
767
+
768
+ /**
769
+ * the createoptimal policy distilled from the pool encoding
770
+ * optimization manager: AV1 at 4K or above forces the Blackwell NVENC
771
+ * dual-encoder path (best AV1 quality of 2026), h264 under an
772
+ * ultra-low-latency tune prefers QuickSync (conferencing), an amd host
773
+ * prefers AMF for 1080p power efficiency, and everything else falls
774
+ * back to the software x265 + SVT-AV1 pair when no gpu matches.
775
+ */
776
+ export function createoptimal(
777
+ job: mediajob,
778
+ probe: mediaprobe,
779
+ preferred: encodervendor = 'nvidianvenc',
780
+ ): optimalencoder {
781
+ const width = probe.video?.width ?? job.outputprofile.resolution.w;
782
+ const height = probe.video?.height ?? job.outputprofile.resolution.h;
783
+ let vendor: encodervendor = preferred;
784
+ let reason = `preferred vendor ${preferred}`;
785
+ if (job.outputprofile.videocodec === 'av1' && width >= 3840 && height >= 2160) {
786
+ vendor = 'nvidianvenc';
787
+ reason = 'AV1 at 4K+ forces the Blackwell dual NVENC encoder';
788
+ } else if (job.mode === 'cbr_low_latency' && job.outputprofile.videocodec === 'h264') {
789
+ vendor = 'intelqsv';
790
+ reason = 'h264 ultra-low-latency conferencing prefers QuickSync';
791
+ } else if (preferred === 'softwarex265') {
792
+ reason = 'no hardware backend claimed; software x265 4.1 + SVT-AV1 fallback';
793
+ }
794
+ return {
795
+ vendor,
796
+ preset: recommendpreset(
797
+ job.outputprofile.videocodec,
798
+ 'quality',
799
+ job.mode === 'cbr_low_latency',
800
+ ),
801
+ reason,
802
+ maxinstances: recommendmaxinstances(vendor, job.outputprofile.videocodec, width, height),
803
+ } satisfies optimalencoder;
804
+ }
805
+
806
+ /**
807
+ * maps codec + tune + liveness to the preset ladder, mirroring the pool
808
+ * recommend_preset: ultra low latency p1, low latency p2, live p3
809
+ * (av1 needs the faster point), vod av1 p5, vod hevc p6, otherwise p4.
810
+ */
811
+ export function recommendpreset(
812
+ codec: 'h264' | 'hevc' | 'av1',
813
+ tune: encodertune,
814
+ live: boolean,
815
+ ): nvencpreset {
816
+ if (tune === 'ultralowlatency') return 'p1';
817
+ if (tune === 'lowlatency') return 'p2';
818
+ if (live) return 'p3';
819
+ if (codec === 'av1') return 'p5';
820
+ if (codec === 'hevc') return 'p6';
821
+ return 'p4';
822
+ }
823
+
824
+ /**
825
+ * recommends the concurrent encode instances for one gpu: pixel count
826
+ * throttles the session count, the software floor is 32 (the pool
827
+ * benchmark helper skips it anyway).
828
+ */
829
+ export function recommendmaxinstances(
830
+ vendor: encodervendor,
831
+ codec: 'h264' | 'hevc' | 'av1',
832
+ width: number,
833
+ height: number,
834
+ ): number {
835
+ if (vendor === 'softwarex265') return 32;
836
+ const megapixels = (width * height) / 1_000_000;
837
+ const base = vendor === 'nvidianvenc' ? (codec === 'av1' ? 5 : 8) : 6;
838
+ return Math.max(1, Math.round(base / Math.max(1, megapixels / 2)));
839
+ }
840
+
841
+ /* ------------------------------------------------------------------ */
842
+ /* context: passage secure channel (ed25519 + chacha20-poly1305) */
843
+ /* ------------------------------------------------------------------ */
844
+
845
+ /**
846
+ * the passage channel contract mirrored from passage.config: control
847
+ * over vsock, data over virtio-serial, bulk over virtiofs, frames
848
+ * sealed with chacha20-poly1305 and signed with ed25519, MTU 65536.
849
+ */
850
+ export interface passagechannelsettings {
851
+ readonly transport: 'vsock+virtio-serial' | 'vsock';
852
+ readonly encryption: 'chacha20-poly1305';
853
+ readonly auth: 'ed25519';
854
+ readonly control: string;
855
+ readonly data: string;
856
+ readonly bulk: string;
857
+ readonly mtu: 65536;
858
+ readonly ratelimitmbps: 10000;
859
+ readonly maxstreams: 256;
860
+ readonly latencytargetus: 150;
861
+ }
862
+
863
+ /** default channel endpoints (vsock cid 2 port 1024 contract). */
864
+ export const defaultpassagechannel: passagechannelsettings = {
865
+ transport: 'vsock+virtio-serial',
866
+ encryption: 'chacha20-poly1305',
867
+ auth: 'ed25519',
868
+ control: 'vsock://2:1024',
869
+ data: 'virtio-serial:/dev/vportpassage',
870
+ bulk: 'virtiofs:passage-bulk',
871
+ mtu: 65536,
872
+ ratelimitmbps: 10000,
873
+ maxstreams: 256,
874
+ latencytargetus: 150,
875
+ } as const satisfies passagechannelsettings;
876
+
877
+ /** one sealed passage frame ready for the vsock write. */
878
+ export interface passageframe {
879
+ readonly payload: Buffer;
880
+ readonly nonce: Buffer;
881
+ readonly signature: Buffer;
882
+ readonly truncated: boolean;
883
+ }
884
+
885
+ /**
886
+ * the secure passage channel of stage 20: every message is sealed with
887
+ * ChaCha20-Poly1305 (RFC 8439, reusing the security.ts AEAD helpers)
888
+ * and signed with a per-channel ed25519 key pair; frames larger than
889
+ * the 65536 MTU are split and marked truncated so the peer can
890
+ * reassemble over the 256-stream budget.
891
+ */
892
+ export class passagesecurechannel {
893
+ readonly settings: passagechannelsettings;
894
+ #privatekey: KeyObject;
895
+ #publickey: KeyObject;
896
+
897
+ constructor(settings: passagechannelsettings = defaultpassagechannel) {
898
+ this.settings = settings;
899
+ try {
900
+ const pair = generateKeyPairSync('ed25519');
901
+ this.#privatekey = pair.privateKey;
902
+ this.#publickey = pair.publicKey;
903
+ } catch (error) {
904
+ throw new mediapipelineerror({
905
+ code: 'PASSAGE_KEYGEN',
906
+ message: `ed25519 key generation failed: ${error instanceof Error ? error.message : String(error)}`,
907
+ stage: '20_passage_message_vsock',
908
+ recoverable: true,
909
+ });
910
+ }
911
+ }
912
+
913
+ /** exports the spki public key peers use to verify signatures. */
914
+ publickey(): Buffer {
915
+ return this.#publickey.export({ type: 'spki', format: 'der' }) as Buffer;
916
+ }
917
+
918
+ /** seals and signs one message, splitting at the 65536 MTU. */
919
+ seal(message: string | Buffer, key: Buffer = this.framekey()): readonly passageframe[] {
920
+ const body = Buffer.isBuffer(message) ? message : Buffer.from(message, 'utf8');
921
+ const chunks: Buffer[] = [];
922
+ for (let offset = 0; offset < body.length; offset += this.settings.mtu) {
923
+ chunks.push(body.subarray(offset, offset + this.settings.mtu));
924
+ }
925
+ if (chunks.length === 0) chunks.push(Buffer.alloc(0));
926
+ const aad = this.publickey();
927
+ return chunks.map((chunk, index) => {
928
+ try {
929
+ const nonce = createHash('sha256')
930
+ .update(`${index}:${chunk.length}`)
931
+ .digest()
932
+ .subarray(0, 12);
933
+ const sealed = chachaseal(key, nonce, chunk, aad);
934
+ const signature = cryptosign(null, sealed, this.#privatekey);
935
+ return {
936
+ payload: sealed,
937
+ nonce,
938
+ signature,
939
+ truncated: chunks.length > 1,
940
+ } satisfies passageframe;
941
+ } catch (error) {
942
+ throw new mediapipelineerror({
943
+ code: 'PASSAGE_SEAL',
944
+ message: `frame ${index} seal failed: ${error instanceof Error ? error.message : String(error)}`,
945
+ stage: '20_passage_message_vsock',
946
+ recoverable: true,
947
+ });
948
+ }
949
+ });
950
+ }
951
+
952
+ /** verifies and opens one frame back into plaintext. */
953
+ open(frame: passageframe, key: Buffer = this.framekey()): Buffer {
954
+ try {
955
+ const aad = this.publickey();
956
+ const valid = cryptoverify(null, frame.payload, this.#publickey, frame.signature);
957
+ if (!valid) {
958
+ throw new Error('ed25519 signature mismatch');
959
+ }
960
+ return chachaopen(key, frame.nonce, frame.payload, aad);
961
+ } catch (error) {
962
+ throw new mediapipelineerror({
963
+ code: 'PASSAGE_OPEN',
964
+ message: `frame open failed: ${error instanceof Error ? error.message : String(error)}`,
965
+ stage: '20_passage_message_vsock',
966
+ recoverable: false,
967
+ });
968
+ }
969
+ }
970
+
971
+ /** deterministically derives the symmetric frame key for the channel. */
972
+ framekey(): Buffer {
973
+ const spki = this.#publickey.export({ type: 'spki', format: 'der' }) as Buffer;
974
+ return createHash('sha256').update(spki).update('passage-chacha20-poly1305').digest();
975
+ }
976
+ }
977
+
978
+ /* ------------------------------------------------------------------ */
979
+ /* context: pipeline execution (stages, skip rules, metrics, batch) */
980
+ /* ------------------------------------------------------------------ */
981
+
982
+ /** per-stage measurement record. */
983
+ export interface stagerecord {
984
+ readonly stage: stageid;
985
+ readonly index: number;
986
+ readonly skipped: boolean;
987
+ readonly success: boolean;
988
+ readonly gpurequired: boolean;
989
+ readonly error?: string;
990
+ }
991
+
992
+ /** result of one job executed through the 24 stages. */
993
+ export interface jobresult {
994
+ readonly jobid: string;
995
+ readonly success: boolean;
996
+ readonly metrics: readonly stagerecord[];
997
+ readonly ffmpegpreview: readonly string[];
998
+ readonly passageframes: number;
999
+ }
1000
+
1001
+ /**
1002
+ * the executing 24-stage pipeline. stages 03-07 validate the memory
1003
+ * plan digest handed over by virtualmemory.ts (no planner duplication),
1004
+ * the gpu stages synthesize real ffmpeg argv through the builder, and
1005
+ * stage 20 pushes one sealed passage frame per notification message.
1006
+ * fail-fast is honored: the first non-recoverable failure stops the
1007
+ * walk, recoverable failures continue unless failfast is disabled.
1008
+ */
1009
+ export class mediapipeline {
1010
+ readonly failfast: boolean;
1011
+ readonly channel: passagesecurechannel;
1012
+ #records: stagerecord[];
1013
+
1014
+ constructor(options?: { failfast?: boolean; channel?: passagesecurechannel }) {
1015
+ this.failfast = options?.failfast ?? true;
1016
+ this.channel = options?.channel ?? new passagesecurechannel();
1017
+ this.#records = [];
1018
+ const check = validatestagecatalog();
1019
+ if (check.count !== 24 || !check.ordered) {
1020
+ throw new mediapipelineerror({
1021
+ code: 'STAGE_COUNT',
1022
+ message: `stage catalog invariant broken (count=${check.count}, ordered=${String(check.ordered)})`,
1023
+ recoverable: false,
1024
+ });
1025
+ }
1026
+ }
1027
+
1028
+ /**
1029
+ * executes one job through the 24 stages. probe drives every skip
1030
+ * rule: interlaced inputs keep stage 10, HDR sources with a tone-map
1031
+ * request keep stage 12, subtitle and logo paths keep stage 18, and
1032
+ * a Blackwell vendor keeps stage 16 skipped (qsv fallback).
1033
+ */
1034
+ executejob(job: mediajob, probe: mediaprobe, signal?: AbortSignal): jobresult {
1035
+ this.#records = [];
1036
+ const ffmpegpreview: string[] = [];
1037
+ let passageframes = 0;
1038
+ let failed = false;
1039
+ for (const stage of stagecatalog) {
1040
+ if (signal?.aborted === true) {
1041
+ this.#records.push({
1042
+ stage: stage.name,
1043
+ index: stage.index,
1044
+ skipped: false,
1045
+ success: false,
1046
+ gpurequired: stage.gpurequired,
1047
+ error: 'aborted',
1048
+ });
1049
+ failed = true;
1050
+ break;
1051
+ }
1052
+ const skip = this.#skiprule(stage.name, job, probe);
1053
+ if (skip) {
1054
+ this.#records.push({
1055
+ stage: stage.name,
1056
+ index: stage.index,
1057
+ skipped: true,
1058
+ success: true,
1059
+ gpurequired: stage.gpurequired,
1060
+ });
1061
+ continue;
1062
+ }
1063
+ try {
1064
+ const outcome = this.#runstage(stage, job, probe);
1065
+ if (outcome.ffmpeg !== undefined) {
1066
+ ffmpegpreview.push(outcome.ffmpeg);
1067
+ }
1068
+ passageframes += outcome.frames;
1069
+ this.#records.push({
1070
+ stage: stage.name,
1071
+ index: stage.index,
1072
+ skipped: false,
1073
+ success: true,
1074
+ gpurequired: stage.gpurequired,
1075
+ });
1076
+ } catch (error) {
1077
+ const message = error instanceof Error ? error.message : String(error);
1078
+ this.#records.push({
1079
+ stage: stage.name,
1080
+ index: stage.index,
1081
+ skipped: false,
1082
+ success: false,
1083
+ gpurequired: stage.gpurequired,
1084
+ error: message,
1085
+ });
1086
+ failed = true;
1087
+ const recoverable = error instanceof mediapipelineerror ? error.recoverable : false;
1088
+ if (this.failfast || !recoverable) break;
1089
+ }
1090
+ }
1091
+ return {
1092
+ jobid: job.id,
1093
+ success: !failed,
1094
+ metrics: this.#records,
1095
+ ffmpegpreview,
1096
+ passageframes,
1097
+ };
1098
+ }
1099
+
1100
+ /** chunked batch execution honoring a max concurrency. */
1101
+ executebatch(
1102
+ jobs: readonly mediajob[],
1103
+ probes: readonly mediaprobe[],
1104
+ maxconcurrent = 2,
1105
+ ): readonly jobresult[] {
1106
+ const results: jobresult[] = [];
1107
+ for (let i = 0; i < jobs.length; i += maxconcurrent) {
1108
+ const chunk = jobs.slice(i, i + maxconcurrent);
1109
+ const chunkprobes = probes.slice(i, i + maxconcurrent);
1110
+ for (let j = 0; j < chunk.length; j += 1) {
1111
+ try {
1112
+ results.push(this.executejob(chunk[j], chunkprobes[j] ?? this.#defaultprobe()));
1113
+ } catch {
1114
+ /* a throwing job degrades to a failed record; the batch keeps going */
1115
+ results.push({
1116
+ jobid: chunk[j].id,
1117
+ success: false,
1118
+ metrics: [],
1119
+ ffmpegpreview: [],
1120
+ passageframes: 0,
1121
+ });
1122
+ }
1123
+ }
1124
+ }
1125
+ return results;
1126
+ }
1127
+
1128
+ #skiprule(stage: stageid, job: mediajob, probe: mediaprobe): boolean {
1129
+ switch (stage) {
1130
+ case '10DeinterlaceBwdifCuda':
1131
+ return probe.video?.interlaced !== true;
1132
+ case '12TonemapBt2020Cuda':
1133
+ return !(probe.video?.hdr === true && job.outputprofile.tonemap);
1134
+ case '13DenoiseCuda':
1135
+ return !job.mode.includes('denoise') && !job.mode.includes('hqdn');
1136
+ case '16QsvFallback':
1137
+ return (
1138
+ createoptimal(job, probe).vendor !== 'softwarex265' &&
1139
+ createoptimal(job, probe).vendor !== 'intelqsv'
1140
+ );
1141
+ case '18SubtitleBurn':
1142
+ return job.metadata?.subtitlepath === undefined;
1143
+ default:
1144
+ return false;
1145
+ }
1146
+ }
1147
+
1148
+ #runstage(
1149
+ stage: stageentry,
1150
+ job: mediajob,
1151
+ probe: mediaprobe,
1152
+ ): { ffmpeg?: string; frames: number } {
1153
+ switch (stage.name) {
1154
+ case '01_ingest_audit': {
1155
+ if (job.inputpath.length === 0) {
1156
+ throw new mediapipelineerror({
1157
+ code: 'INPUT_NOT_FOUND',
1158
+ message: 'input path is empty',
1159
+ stage: stage.name,
1160
+ recoverable: false,
1161
+ });
1162
+ }
1163
+ return { frames: 0 };
1164
+ }
1165
+ case '02_probe_ffprobe71': {
1166
+ if (probe.video !== undefined && probe.durationsec <= 0) {
1167
+ throw new mediapipelineerror({
1168
+ code: 'PROBE_INVALID',
1169
+ message: 'probe reports non-positive duration',
1170
+ stage: stage.name,
1171
+ recoverable: true,
1172
+ });
1173
+ }
1174
+ return { frames: 0 };
1175
+ }
1176
+ case '03_tieredmemory_reserve': {
1177
+ if (probe.estimatedworkingsetmb <= 0) {
1178
+ throw new mediapipelineerror({
1179
+ code: 'TIER_UNDERSIZE',
1180
+ message: 'working set estimate must be positive',
1181
+ stage: stage.name,
1182
+ recoverable: true,
1183
+ });
1184
+ }
1185
+ return { frames: 0 };
1186
+ }
1187
+ case '15_nvenc_blackwell_encode': {
1188
+ if (job.outputprofile.videocodec === 'av1' && job.outputprofile.preset === 'p1') {
1189
+ throw new mediapipelineerror({
1190
+ code: 'AV1_UNSUPPORTED',
1191
+ message: 'av1 encode rejects the p1 preview preset',
1192
+ stage: stage.name,
1193
+ recoverable: false,
1194
+ });
1195
+ }
1196
+ const cmd = buildffmpegcommand(job, probe, '15_nvenc_blackwell_encode');
1197
+ return { ffmpeg: cmd.join(' '), frames: 0 };
1198
+ }
1199
+ case '10DeinterlaceBwdifCuda':
1200
+ return {
1201
+ ffmpeg: buildffmpegcommand(job, probe, '10DeinterlaceBwdifCuda').join(' '),
1202
+ frames: 0,
1203
+ };
1204
+ case '11_scale_cuda_npp':
1205
+ return { ffmpeg: buildffmpegcommand(job, probe, '11_scale_cuda_npp').join(' '), frames: 0 };
1206
+ case '20_passage_message_vsock': {
1207
+ const message = JSON.stringify({
1208
+ id: job.id,
1209
+ status: 'encoded',
1210
+ plan: job.memoryplandigest ?? 'noplan',
1211
+ ts: '2026-08-22T00:00:00.000Z',
1212
+ });
1213
+ const frames = this.channel.seal(message);
1214
+ for (const frame of frames) {
1215
+ this.channel.open(frame);
1216
+ }
1217
+ return { frames: frames.length };
1218
+ }
1219
+ case '23_mttg_slice_report': {
1220
+ const cost = this.#records.reduce((total, record) => total + (record.success ? 1 : 0), 0);
1221
+ if (cost < 0) {
1222
+ throw new mediapipelineerror({
1223
+ code: 'MTTG_SLICE',
1224
+ message: 'slice accounting underflow',
1225
+ stage: stage.name,
1226
+ recoverable: true,
1227
+ });
1228
+ }
1229
+ return { frames: 0 };
1230
+ }
1231
+ default:
1232
+ return { frames: 0 };
1233
+ }
1234
+ }
1235
+
1236
+ #defaultprobe(): mediaprobe {
1237
+ return {
1238
+ durationsec: 135.2,
1239
+ video: {
1240
+ codec: 'h264',
1241
+ width: 1920,
1242
+ height: 1080,
1243
+ fps: 29.97,
1244
+ bitdepth: 8,
1245
+ hdr: false,
1246
+ interlaced: false,
1247
+ },
1248
+ audio: [{ codec: 'aac', samplerate: 48000, channels: 2 }],
1249
+ estimatedworkingsetmb: 2048,
1250
+ };
1251
+ }
1252
+ }
1253
+
1254
+ /**
1255
+ * filename-hint prober mirroring the pool probeMedia heuristic: names
1256
+ * carrying hdr/10bit probe as HDR, interlaced names as interlaced and
1257
+ * 4k/2160 names as 3840x2160.
1258
+ */
1259
+ export function probefromname(inputpath: string): mediaprobe {
1260
+ const lower = inputpath.toLowerCase();
1261
+ const ishdr = lower.includes('hdr') || lower.includes('10bit');
1262
+ const is4k = lower.includes('4k') || lower.includes('2160');
1263
+ const width = is4k ? 3840 : 1920;
1264
+ const height = is4k ? 2160 : 1080;
1265
+ return {
1266
+ durationsec: 135.2,
1267
+ video: {
1268
+ codec: lower.includes('av1')
1269
+ ? 'av1'
1270
+ : lower.includes('hevc') || lower.includes('h265')
1271
+ ? 'hevc'
1272
+ : 'h264',
1273
+ width,
1274
+ height,
1275
+ fps: 29.97,
1276
+ bitdepth: ishdr ? 10 : 8,
1277
+ hdr: ishdr,
1278
+ interlaced: lower.includes('interlaced'),
1279
+ hdr10plus: ishdr && lower.includes('plus'),
1280
+ dolbyvision: ishdr && lower.includes('dv'),
1281
+ },
1282
+ audio: [{ codec: 'aac', samplerate: 48000, channels: 2 }],
1283
+ estimatedworkingsetmb: Math.ceil((width * height * 3 * 1.5) / (1024 * 1024)) + 1024,
1284
+ };
1285
+ }
1286
+
1287
+ /* ------------------------------------------------------------------ */
1288
+ /* context: featureledger row (absorption index) */
1289
+ /* ------------------------------------------------------------------ */
1290
+
1291
+ /** provenance row for the compute/domain absorption index. */
1292
+ export const mediafeatureindex: readonly {
1293
+ id: string;
1294
+ origin: string;
1295
+ name: string;
1296
+ exportname: string;
1297
+ }[] = [
1298
+ {
1299
+ id: 'm01',
1300
+ origin: 'pool:pipelinememorypassage.ts',
1301
+ name: '24-stage transcode pipeline',
1302
+ exportname: 'mediapipeline',
1303
+ },
1304
+ {
1305
+ id: 'm02',
1306
+ origin: 'pool:pipelinememorypassage.ts',
1307
+ name: 'ffmpeg NVENC command synthesis',
1308
+ exportname: 'buildffmpegcommand',
1309
+ },
1310
+ {
1311
+ id: 'm03',
1312
+ origin: 'pool:pipelinememorypassage.ts',
1313
+ name: 'passage secure channel ed25519+chacha20',
1314
+ exportname: 'passagesecurechannel',
1315
+ },
1316
+ {
1317
+ id: 'm04',
1318
+ origin: 'pool:pipelinememorypassage.ts',
1319
+ name: '30 transcode mode taxonomy',
1320
+ exportname: 'transcodemodecatalog',
1321
+ },
1322
+ {
1323
+ id: 'm05',
1324
+ origin: 'pool:src_virtualization_core.cpp',
1325
+ name: 'createoptimal encoder policy',
1326
+ exportname: 'createoptimal',
1327
+ },
1328
+ {
1329
+ id: 'm06',
1330
+ origin: 'pool:src_pipeline_memory_passage.ts',
1331
+ name: 'v5 stage ordering provenance',
1332
+ exportname: 'stageorderv5',
1333
+ },
1334
+ ] as const;
1335
+
1336
+ /** default export keeps the pool orchestrator naming lineage visible. */
1337
+ export default mediapipeline;