@torrent-tv/proxy 2.89.6 → 2.89.8

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 (92) hide show
  1. package/AGENTS.md +32 -12
  2. package/CHANGELOG.md +2340 -2330
  3. package/assets/calibration/audio/NOTICE.md +19 -19
  4. package/assets/calibration/audio/manifest.json +98 -98
  5. package/biome.json +412 -412
  6. package/docs/browser-proxy-contract.md +155 -155
  7. package/docs/container-architecture.md +273 -273
  8. package/docs/encode-run-state.md +1 -1
  9. package/docs/playback-start-forecast.md +113 -98
  10. package/package.json +51 -50
  11. package/routes/api/sources/files/get.js +106 -106
  12. package/scripts/build-audio-samples.mjs +31 -31
  13. package/services/encode/EncodeRun.js +67 -15
  14. package/services/encode/EncodeRuns.js +19 -7
  15. package/services/encode/OutputOpening.js +784 -784
  16. package/services/encode/audio-calibration.js +67 -67
  17. package/services/encode/audio-work-rate.js +15 -15
  18. package/services/encode/encode-exit.js +2 -0
  19. package/services/encode/hwaccel.js +1894 -1894
  20. package/services/encode/output/index.js +24 -24
  21. package/services/encode/piece-completeness.js +60 -2
  22. package/services/encode/run-command.js +757 -755
  23. package/services/encode/segment-formats/index.js +1 -0
  24. package/services/encode/segment-formats/mp4-boxes.js +8 -1
  25. package/services/media/ContainerOrchestrator.js +202 -202
  26. package/services/media/KeyframeTables.js +356 -356
  27. package/services/media/SubtitleCues.js +592 -592
  28. package/services/media/audio-inventory.js +299 -299
  29. package/services/media/container/AviContainer.js +268 -268
  30. package/services/media/container/Container.js +632 -632
  31. package/services/media/container/ContainerFactory.js +38 -38
  32. package/services/media/container/MatroskaContainer.js +1031 -1031
  33. package/services/media/container/Mp4Container.js +1354 -1354
  34. package/services/media/container/SubtitleFileContainer.js +339 -339
  35. package/services/media/container/ebml-stream.js +174 -174
  36. package/services/media/container/matroska-clusters.js +1165 -1165
  37. package/services/media/container/unavailable.js +77 -77
  38. package/services/media/tracks/ContainerTrack.js +84 -84
  39. package/services/media/tracks/TextSubtitleTrack.js +295 -295
  40. package/services/storage/piece-store/shared-piece-store.js +1937 -1937
  41. package/services/storage/segment-store/SegmentStore.js +1294 -1294
  42. package/services/torrent/Contents.js +382 -382
  43. package/services/torrent/episode-naming.js +182 -182
  44. package/services/torrent/torrent-pool.js +2688 -2688
  45. package/services/torrent/worker/client.js +836 -836
  46. package/services/torrent/worker/held-bytes.js +231 -231
  47. package/services/torrent/worker/worker.js +1137 -1137
  48. package/services/transport/data-channel-handler.js +1373 -1373
  49. package/services/viewer/PriorityMap.js +421 -421
  50. package/test/audio-calibration.test.js +23 -23
  51. package/test/auto-quality-step.test.js +762 -762
  52. package/test/coalesce.test.js +39 -39
  53. package/test/coverage-follows-the-disk.test.js +5 -0
  54. package/test/decode-cost.test.js +475 -475
  55. package/test/encode-run.test.js +58 -0
  56. package/test/episode-naming.test.js +131 -131
  57. package/test/failed-encoder-still-serves-what-exists.test.js +1 -1
  58. package/test/fixtures/audio-frame-boundary.json +1 -1
  59. package/test/fixtures/refused-audio-20261002.json +10 -0
  60. package/test/fmp4-presentation-clock.test.js +4 -2
  61. package/test/format-keyed-outputs.test.js +78 -78
  62. package/test/health-metrics.test.js +11 -13
  63. package/test/held-read-ownership.test.js +77 -77
  64. package/test/helpers/encode-run.js +14 -6
  65. package/test/helpers/held-file.js +77 -77
  66. package/test/helpers/manager.js +62 -62
  67. package/test/helpers/matroska-file.js +296 -296
  68. package/test/keyframe-table-budget.test.js +123 -123
  69. package/test/matroska-cluster-discovery.test.js +323 -323
  70. package/test/one-output-one-session.test.js +273 -273
  71. package/test/output-speed.test.js +6 -1
  72. package/test/piece-completeness.test.js +37 -1
  73. package/test/quality-variants.test.js +1274 -1270
  74. package/test/rate-control-in-the-output.test.js +4 -3
  75. package/test/reads-not-yet-arrived.test.js +218 -218
  76. package/test/seek-frees-the-viewers-requests.test.js +1 -1
  77. package/test/segment-closed-on-both-branches.test.js +114 -114
  78. package/test/segment-judged-by-its-own-header.test.js +222 -222
  79. package/test/segment-serve-wiring.test.js +481 -481
  80. package/test/serving-existing-output.test.js +111 -111
  81. package/test/source-files-route.test.js +113 -113
  82. package/test/subtitle-cue-walk.test.js +385 -385
  83. package/test/subtitle-metadata.test.js +15 -15
  84. package/test/subtitle-plan-waits.test.js +125 -125
  85. package/test/subtitle-track-numbering.test.js +391 -391
  86. package/test/two-viewers-one-picture.test.js +508 -508
  87. package/test/viewer-requests-admission.test.js +92 -92
  88. package/test/viewer-starts-on-map.test.js +27 -27
  89. package/test/viewer-states.test.js +5 -2
  90. package/test/viewing-generations.test.js +390 -390
  91. package/test/whole-file-held-read.test.js +30 -30
  92. package/utils/coalesce.js +41 -41
package/biome.json CHANGED
@@ -1,412 +1,412 @@
1
- {
2
- "$schema": "https://biomejs.dev/schemas/2.5.7/schema.json",
3
- "files": {
4
- "includes": [
5
- "**/*.js",
6
- "!**/node_modules/**"
7
- ]
8
- },
9
- "formatter": {
10
- "enabled": false
11
- },
12
- "assist": {
13
- "enabled": false
14
- },
15
- "linter": {
16
- "enabled": true,
17
- "rules": {
18
- "preset": "none",
19
- "correctness": {
20
- "noUndeclaredVariables": "error",
21
- "noUnusedImports": "error",
22
- "noUnusedVariables": "error",
23
- "noUnusedPrivateClassMembers": "error",
24
- "noInvalidUseBeforeDeclaration": "error",
25
- "noPrivateImports": "error"
26
- }
27
- }
28
- },
29
- "overrides": [
30
- {
31
- "includes": [
32
- "services/torrent/demand/**",
33
- "services/encode/segment-formats/**",
34
- "services/encode/output/**",
35
- "services/viewer/**"
36
- ],
37
- "linter": {
38
- "rules": {
39
- "style": {
40
- "noRestrictedImports": {
41
- "level": "error",
42
- "options": {
43
- "patterns": [
44
- {
45
- "group": [
46
- "../**"
47
- ],
48
- "message": "This layer states facts and imports nothing above itself. Anything it needs from outside — a logger, a clock, a way to read bytes — is passed in."
49
- }
50
- ]
51
- }
52
- }
53
- }
54
- }
55
- }
56
- },
57
- {
58
- "includes": [
59
- "services/torrent/*.js"
60
- ],
61
- "linter": {
62
- "rules": {
63
- "style": {
64
- "noRestrictedImports": {
65
- "level": "error",
66
- "options": {
67
- "patterns": [
68
- {
69
- "group": [
70
- "../**",
71
- "!../../utils/**",
72
- "!../storage/keep.js",
73
- "!../viewer/PriorityMap.js"
74
- ],
75
- "message": "THE TORRENT COMPONENT: the swarm, its pieces, what to ask for and in what order, and what a torrent contains. It reads the shape of the priority map (`viewer/PriorityMap.js`) and the keeping period (`storage/keep.js`); the piece store is reached through what it does (`piece-store-of.js`) and is handed in where the thread is assembled (`worker/worker.js`)."
76
- }
77
- ]
78
- }
79
- }
80
- }
81
- }
82
- }
83
- },
84
- {
85
- "includes": [
86
- "services/encode/*.js"
87
- ],
88
- "linter": {
89
- "rules": {
90
- "style": {
91
- "noRestrictedImports": {
92
- "level": "error",
93
- "options": {
94
- "patterns": [
95
- {
96
- "group": [
97
- "../**",
98
- "!../media/ffmpeg-banner.js"
99
- ],
100
- "message": "THE ENCODING COMPONENT imports nothing outside itself: its outputs, cut tables, playlists, container formats and quality budget are directories of it. Anything else it needs — a logger, a viewer's position, a way to read bytes — is passed in."
101
- }
102
- ]
103
- }
104
- }
105
- }
106
- }
107
- }
108
- },
109
- {
110
- "includes": [
111
- "services/storage/*.js"
112
- ],
113
- "linter": {
114
- "rules": {
115
- "style": {
116
- "noRestrictedImports": {
117
- "level": "error",
118
- "options": {
119
- "patterns": [
120
- {
121
- "group": [
122
- "../**",
123
- "!../../utils/**"
124
- ],
125
- "message": "ONE LAYER, FOUR DIRECTORIES — bytes on a medium with a limit. What is held in memory (piece-store/), the produced segments (segment-store/), whole downloaded files (files/), and the one owner of the room all three take (storage/). They may reach each other and nothing above. Written as an exception to `../**` rather than as a list of forbidden layers, because a layer is not a directory: the blanket form cannot say \"my siblings\", and a list of names misses everything it forgets — `../../utils/logger.js` went straight through one on 2026-09-14."
126
- }
127
- ]
128
- }
129
- }
130
- }
131
- }
132
- }
133
- },
134
- {
135
- "includes": [
136
- "services/storage/*/**"
137
- ],
138
- "linter": {
139
- "rules": {
140
- "style": {
141
- "noRestrictedImports": {
142
- "level": "error",
143
- "options": {
144
- "patterns": [
145
- {
146
- "group": [
147
- "../../**",
148
- "!../../../utils/**"
149
- ],
150
- "message": "ONE LAYER, FOUR DIRECTORIES — bytes on a medium with a limit. What is held in memory (piece-store/), the produced segments (segment-store/), whole downloaded files (files/), and the one owner of the room all three take (storage/). They may reach each other and nothing above. Written as an exception to `../**` rather than as a list of forbidden layers, because a layer is not a directory: the blanket form cannot say \"my siblings\", and a list of names misses everything it forgets — `../../utils/logger.js` went straight through one on 2026-09-14."
151
- }
152
- ]
153
- }
154
- }
155
- }
156
- }
157
- }
158
- },
159
- {
160
- "includes": [
161
- "services/encode/quality/**"
162
- ],
163
- "linter": {
164
- "rules": {
165
- "style": {
166
- "noRestrictedImports": {
167
- "level": "error",
168
- "options": {
169
- "patterns": [
170
- {
171
- "group": [
172
- "../**",
173
- "../../**",
174
- "!../output/**",
175
- "!../../media/SourceFile.js",
176
- "!../available-share.js",
177
- "!../hwaccel.js",
178
- "!../learned-median.js",
179
- "!../torrent-cost.js",
180
- "!../encoder-readings.js",
181
- "!../audio-work-rate.js",
182
- "!../contention.js",
183
- "!../args.js",
184
- "!../encode-run-state.js",
185
- "!../throughput.js",
186
- "!../../../utils/**"
187
- ],
188
- "message": "What encoding costs, and which heights follow, is arithmetic over readings. Which sessions belong to one file, how many encoders run, where the viewers stand, what the swarm is delivering — all of it is passed in, so this can be asked without a session manager, a torrent or a disk. What it MAY reach is named one file at a time, and every name is a plain STATEMENT rather than machinery: the ladder and the cut table (output/, which is the same layer — кодирование), what a source decodes like, the measured shares and penalties, and the states a run can be in. `encode/EncodeRun.js` is deliberately not among them — it spawns processes. An ALLOW list rather than a forbid list, because the two fail in opposite directions: a name forgotten here blocks an import that should have been allowed, and a name forgotten in a forbid list lets a whole layer through. The old forbid list named `../container/**`, a directory that stopped existing when the media layer got its own, and would have let all of it in."
189
- }
190
- ]
191
- }
192
- }
193
- }
194
- }
195
- }
196
- },
197
- {
198
- "includes": [
199
- "services/torrent/download/**"
200
- ],
201
- "linter": {
202
- "rules": {
203
- "style": {
204
- "noRestrictedImports": {
205
- "level": "error",
206
- "options": {
207
- "patterns": [
208
- {
209
- "group": [
210
- "../../**",
211
- "../worker/**"
212
- ],
213
- "message": "What the swarm is told is decided from what is wanted (demand/) and what is held (storage/), and from nothing else."
214
- }
215
- ]
216
- }
217
- }
218
- }
219
- }
220
- }
221
- },
222
- {
223
- "includes": [
224
- "services/media/container/**",
225
- "services/media/tracks/**"
226
- ],
227
- "linter": {
228
- "rules": {
229
- "style": {
230
- "noRestrictedImports": {
231
- "level": "error",
232
- "options": {
233
- "patterns": [
234
- {
235
- "group": [
236
- "../**",
237
- "!../container/**",
238
- "!../tracks/**"
239
- ],
240
- "message": "THE MEDIA DOMAIN. A container answers for itself and hands out tracks/; a track is one stream inside one. They know nothing of torrents, encoders, viewers or this proxy's own logger: the four functions a container is built with are its whole outside world. Written as an exception to `../**` rather than as a list of forbidden layers — a list only catches what somebody remembered to write in it, and the list that stood here let `../../utils/logger.js` straight through."
241
- }
242
- ]
243
- }
244
- }
245
- }
246
- }
247
- }
248
- },
249
- {
250
- "includes": [
251
- "services/media/*.js"
252
- ],
253
- "linter": {
254
- "rules": {
255
- "style": {
256
- "noRestrictedImports": {
257
- "level": "error",
258
- "options": {
259
- "patterns": [
260
- {
261
- "group": [
262
- "../**",
263
- "!../../utils/**"
264
- ],
265
- "message": "THE MEDIA LAYER answers what a FILE says about itself: its containers, its tracks, where its keyframes are, and the plan for playing it. It may reach into its own domain and nothing else. What a torrent contains, which clusters may be read, where a viewer stands, what an encoder costs — all of it is passed in, so this can be asked with plain values and no torrent, no thread and no disk. Both reaches that stood here are gone: `torrent-worker/subtitle-cues.js` is now handed to SubtitleOrchestrator at the seam, and `torrent/Contents.js` is handed to the planner."
266
- }
267
- ]
268
- }
269
- }
270
- }
271
- }
272
- }
273
- },
274
- {
275
- "includes": [
276
- "services/server/controllers/**"
277
- ],
278
- "linter": {
279
- "rules": {
280
- "style": {
281
- "noRestrictedImports": {
282
- "level": "error",
283
- "options": {
284
- "patterns": [
285
- {
286
- "group": [
287
- "../../**"
288
- ],
289
- "message": "A controller translates a request for an orchestrator it is handed. It imports nothing of any component: parsing a file, converting it and naming its language are the media component's."
290
- }
291
- ]
292
- }
293
- }
294
- }
295
- }
296
- }
297
- },
298
- {
299
- "includes": [
300
- "services/torrent/worker/**",
301
- "!services/torrent/worker/worker.js"
302
- ],
303
- "linter": {
304
- "rules": {
305
- "style": {
306
- "noRestrictedImports": {
307
- "level": "error",
308
- "options": {
309
- "patterns": [
310
- {
311
- "group": [
312
- "../../server/**",
313
- "../../encode/**",
314
- "../../viewer/**",
315
- "../../storage/**",
316
- "../../transport/**",
317
- "../../media/**"
318
- ],
319
- "message": "The torrent thread serves bytes. What is produced from them, and for whom, is decided in the main thread; what stores them is handed in by `worker.js`, where this thread is assembled."
320
- }
321
- ]
322
- }
323
- }
324
- }
325
- }
326
- }
327
- },
328
- {
329
- "includes": [
330
- "services/torrent/worker/worker.js"
331
- ],
332
- "linter": {
333
- "rules": {
334
- "style": {
335
- "noRestrictedImports": {
336
- "level": "error",
337
- "options": {
338
- "patterns": [
339
- {
340
- "group": [
341
- "../../server/**",
342
- "../../encode/**",
343
- "../../viewer/**",
344
- "../../transport/**",
345
- "../../media/**"
346
- ],
347
- "message": "`worker.js` assembles the torrent thread: it may build the storage component's stores and hand them in, and nothing else outside the torrent component."
348
- }
349
- ]
350
- }
351
- }
352
- }
353
- }
354
- }
355
- },
356
- {
357
- "includes": [
358
- "services/server/*.js",
359
- "!services/server/wire-outputs.js"
360
- ],
361
- "linter": {
362
- "rules": {
363
- "style": {
364
- "noRestrictedImports": {
365
- "level": "error",
366
- "options": {
367
- "patterns": [
368
- {
369
- "group": [
370
- "../**",
371
- "!../encode/output/index.js",
372
- "!../storage/keep.js",
373
- "!../../utils/**",
374
- "!../../../utils/**"
375
- ],
376
- "message": "THE SERVER COMPONENT coordinates one request at a time through the narrow interfaces `wire-outputs.js` hands it. It imports no component's implementation: only the name of an output and of its playlist (`encode/output/index.js`) and the keeping period (`storage/keep.js`), which are definitions shared by both sides of an interface."
377
- }
378
- ]
379
- }
380
- }
381
- }
382
- }
383
- }
384
- },
385
- {
386
- "includes": [
387
- "services/transport/**"
388
- ],
389
- "linter": {
390
- "rules": {
391
- "style": {
392
- "noRestrictedImports": {
393
- "level": "error",
394
- "options": {
395
- "patterns": [
396
- {
397
- "group": [
398
- "../**",
399
- "!../../utils/**",
400
- "!../../../utils/**"
401
- ],
402
- "message": "THE TRANSPORT COMPONENT delivers bytes to a peer and takes requests from it. It imports nothing of another component: what it reports about the machine, and which files of evidence to keep, are handed in by `bin/cli.js`."
403
- }
404
- ]
405
- }
406
- }
407
- }
408
- }
409
- }
410
- }
411
- ]
412
- }
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/2.5.7/schema.json",
3
+ "files": {
4
+ "includes": [
5
+ "**/*.js",
6
+ "!**/node_modules/**"
7
+ ]
8
+ },
9
+ "formatter": {
10
+ "enabled": false
11
+ },
12
+ "assist": {
13
+ "enabled": false
14
+ },
15
+ "linter": {
16
+ "enabled": true,
17
+ "rules": {
18
+ "preset": "none",
19
+ "correctness": {
20
+ "noUndeclaredVariables": "error",
21
+ "noUnusedImports": "error",
22
+ "noUnusedVariables": "error",
23
+ "noUnusedPrivateClassMembers": "error",
24
+ "noInvalidUseBeforeDeclaration": "error",
25
+ "noPrivateImports": "error"
26
+ }
27
+ }
28
+ },
29
+ "overrides": [
30
+ {
31
+ "includes": [
32
+ "services/torrent/demand/**",
33
+ "services/encode/segment-formats/**",
34
+ "services/encode/output/**",
35
+ "services/viewer/**"
36
+ ],
37
+ "linter": {
38
+ "rules": {
39
+ "style": {
40
+ "noRestrictedImports": {
41
+ "level": "error",
42
+ "options": {
43
+ "patterns": [
44
+ {
45
+ "group": [
46
+ "../**"
47
+ ],
48
+ "message": "This layer states facts and imports nothing above itself. Anything it needs from outside — a logger, a clock, a way to read bytes — is passed in."
49
+ }
50
+ ]
51
+ }
52
+ }
53
+ }
54
+ }
55
+ }
56
+ },
57
+ {
58
+ "includes": [
59
+ "services/torrent/*.js"
60
+ ],
61
+ "linter": {
62
+ "rules": {
63
+ "style": {
64
+ "noRestrictedImports": {
65
+ "level": "error",
66
+ "options": {
67
+ "patterns": [
68
+ {
69
+ "group": [
70
+ "../**",
71
+ "!../../utils/**",
72
+ "!../storage/keep.js",
73
+ "!../viewer/PriorityMap.js"
74
+ ],
75
+ "message": "THE TORRENT COMPONENT: the swarm, its pieces, what to ask for and in what order, and what a torrent contains. It reads the shape of the priority map (`viewer/PriorityMap.js`) and the keeping period (`storage/keep.js`); the piece store is reached through what it does (`piece-store-of.js`) and is handed in where the thread is assembled (`worker/worker.js`)."
76
+ }
77
+ ]
78
+ }
79
+ }
80
+ }
81
+ }
82
+ }
83
+ },
84
+ {
85
+ "includes": [
86
+ "services/encode/*.js"
87
+ ],
88
+ "linter": {
89
+ "rules": {
90
+ "style": {
91
+ "noRestrictedImports": {
92
+ "level": "error",
93
+ "options": {
94
+ "patterns": [
95
+ {
96
+ "group": [
97
+ "../**",
98
+ "!../media/ffmpeg-banner.js"
99
+ ],
100
+ "message": "THE ENCODING COMPONENT imports nothing outside itself: its outputs, cut tables, playlists, container formats and quality budget are directories of it. Anything else it needs — a logger, a viewer's position, a way to read bytes — is passed in."
101
+ }
102
+ ]
103
+ }
104
+ }
105
+ }
106
+ }
107
+ }
108
+ },
109
+ {
110
+ "includes": [
111
+ "services/storage/*.js"
112
+ ],
113
+ "linter": {
114
+ "rules": {
115
+ "style": {
116
+ "noRestrictedImports": {
117
+ "level": "error",
118
+ "options": {
119
+ "patterns": [
120
+ {
121
+ "group": [
122
+ "../**",
123
+ "!../../utils/**"
124
+ ],
125
+ "message": "ONE LAYER, FOUR DIRECTORIES — bytes on a medium with a limit. What is held in memory (piece-store/), the produced segments (segment-store/), whole downloaded files (files/), and the one owner of the room all three take (storage/). They may reach each other and nothing above. Written as an exception to `../**` rather than as a list of forbidden layers, because a layer is not a directory: the blanket form cannot say \"my siblings\", and a list of names misses everything it forgets — `../../utils/logger.js` went straight through one on 2026-09-14."
126
+ }
127
+ ]
128
+ }
129
+ }
130
+ }
131
+ }
132
+ }
133
+ },
134
+ {
135
+ "includes": [
136
+ "services/storage/*/**"
137
+ ],
138
+ "linter": {
139
+ "rules": {
140
+ "style": {
141
+ "noRestrictedImports": {
142
+ "level": "error",
143
+ "options": {
144
+ "patterns": [
145
+ {
146
+ "group": [
147
+ "../../**",
148
+ "!../../../utils/**"
149
+ ],
150
+ "message": "ONE LAYER, FOUR DIRECTORIES — bytes on a medium with a limit. What is held in memory (piece-store/), the produced segments (segment-store/), whole downloaded files (files/), and the one owner of the room all three take (storage/). They may reach each other and nothing above. Written as an exception to `../**` rather than as a list of forbidden layers, because a layer is not a directory: the blanket form cannot say \"my siblings\", and a list of names misses everything it forgets — `../../utils/logger.js` went straight through one on 2026-09-14."
151
+ }
152
+ ]
153
+ }
154
+ }
155
+ }
156
+ }
157
+ }
158
+ },
159
+ {
160
+ "includes": [
161
+ "services/encode/quality/**"
162
+ ],
163
+ "linter": {
164
+ "rules": {
165
+ "style": {
166
+ "noRestrictedImports": {
167
+ "level": "error",
168
+ "options": {
169
+ "patterns": [
170
+ {
171
+ "group": [
172
+ "../**",
173
+ "../../**",
174
+ "!../output/**",
175
+ "!../../media/SourceFile.js",
176
+ "!../available-share.js",
177
+ "!../hwaccel.js",
178
+ "!../learned-median.js",
179
+ "!../torrent-cost.js",
180
+ "!../encoder-readings.js",
181
+ "!../audio-work-rate.js",
182
+ "!../contention.js",
183
+ "!../args.js",
184
+ "!../encode-run-state.js",
185
+ "!../throughput.js",
186
+ "!../../../utils/**"
187
+ ],
188
+ "message": "What encoding costs, and which heights follow, is arithmetic over readings. Which sessions belong to one file, how many encoders run, where the viewers stand, what the swarm is delivering — all of it is passed in, so this can be asked without a session manager, a torrent or a disk. What it MAY reach is named one file at a time, and every name is a plain STATEMENT rather than machinery: the ladder and the cut table (output/, which is the same layer — кодирование), what a source decodes like, the measured shares and penalties, and the states a run can be in. `encode/EncodeRun.js` is deliberately not among them — it spawns processes. An ALLOW list rather than a forbid list, because the two fail in opposite directions: a name forgotten here blocks an import that should have been allowed, and a name forgotten in a forbid list lets a whole layer through. The old forbid list named `../container/**`, a directory that stopped existing when the media layer got its own, and would have let all of it in."
189
+ }
190
+ ]
191
+ }
192
+ }
193
+ }
194
+ }
195
+ }
196
+ },
197
+ {
198
+ "includes": [
199
+ "services/torrent/download/**"
200
+ ],
201
+ "linter": {
202
+ "rules": {
203
+ "style": {
204
+ "noRestrictedImports": {
205
+ "level": "error",
206
+ "options": {
207
+ "patterns": [
208
+ {
209
+ "group": [
210
+ "../../**",
211
+ "../worker/**"
212
+ ],
213
+ "message": "What the swarm is told is decided from what is wanted (demand/) and what is held (storage/), and from nothing else."
214
+ }
215
+ ]
216
+ }
217
+ }
218
+ }
219
+ }
220
+ }
221
+ },
222
+ {
223
+ "includes": [
224
+ "services/media/container/**",
225
+ "services/media/tracks/**"
226
+ ],
227
+ "linter": {
228
+ "rules": {
229
+ "style": {
230
+ "noRestrictedImports": {
231
+ "level": "error",
232
+ "options": {
233
+ "patterns": [
234
+ {
235
+ "group": [
236
+ "../**",
237
+ "!../container/**",
238
+ "!../tracks/**"
239
+ ],
240
+ "message": "THE MEDIA DOMAIN. A container answers for itself and hands out tracks/; a track is one stream inside one. They know nothing of torrents, encoders, viewers or this proxy's own logger: the four functions a container is built with are its whole outside world. Written as an exception to `../**` rather than as a list of forbidden layers — a list only catches what somebody remembered to write in it, and the list that stood here let `../../utils/logger.js` straight through."
241
+ }
242
+ ]
243
+ }
244
+ }
245
+ }
246
+ }
247
+ }
248
+ },
249
+ {
250
+ "includes": [
251
+ "services/media/*.js"
252
+ ],
253
+ "linter": {
254
+ "rules": {
255
+ "style": {
256
+ "noRestrictedImports": {
257
+ "level": "error",
258
+ "options": {
259
+ "patterns": [
260
+ {
261
+ "group": [
262
+ "../**",
263
+ "!../../utils/**"
264
+ ],
265
+ "message": "THE MEDIA LAYER answers what a FILE says about itself: its containers, its tracks, where its keyframes are, and the plan for playing it. It may reach into its own domain and nothing else. What a torrent contains, which clusters may be read, where a viewer stands, what an encoder costs — all of it is passed in, so this can be asked with plain values and no torrent, no thread and no disk. Both reaches that stood here are gone: `torrent-worker/subtitle-cues.js` is now handed to SubtitleOrchestrator at the seam, and `torrent/Contents.js` is handed to the planner."
266
+ }
267
+ ]
268
+ }
269
+ }
270
+ }
271
+ }
272
+ }
273
+ },
274
+ {
275
+ "includes": [
276
+ "services/server/controllers/**"
277
+ ],
278
+ "linter": {
279
+ "rules": {
280
+ "style": {
281
+ "noRestrictedImports": {
282
+ "level": "error",
283
+ "options": {
284
+ "patterns": [
285
+ {
286
+ "group": [
287
+ "../../**"
288
+ ],
289
+ "message": "A controller translates a request for an orchestrator it is handed. It imports nothing of any component: parsing a file, converting it and naming its language are the media component's."
290
+ }
291
+ ]
292
+ }
293
+ }
294
+ }
295
+ }
296
+ }
297
+ },
298
+ {
299
+ "includes": [
300
+ "services/torrent/worker/**",
301
+ "!services/torrent/worker/worker.js"
302
+ ],
303
+ "linter": {
304
+ "rules": {
305
+ "style": {
306
+ "noRestrictedImports": {
307
+ "level": "error",
308
+ "options": {
309
+ "patterns": [
310
+ {
311
+ "group": [
312
+ "../../server/**",
313
+ "../../encode/**",
314
+ "../../viewer/**",
315
+ "../../storage/**",
316
+ "../../transport/**",
317
+ "../../media/**"
318
+ ],
319
+ "message": "The torrent thread serves bytes. What is produced from them, and for whom, is decided in the main thread; what stores them is handed in by `worker.js`, where this thread is assembled."
320
+ }
321
+ ]
322
+ }
323
+ }
324
+ }
325
+ }
326
+ }
327
+ },
328
+ {
329
+ "includes": [
330
+ "services/torrent/worker/worker.js"
331
+ ],
332
+ "linter": {
333
+ "rules": {
334
+ "style": {
335
+ "noRestrictedImports": {
336
+ "level": "error",
337
+ "options": {
338
+ "patterns": [
339
+ {
340
+ "group": [
341
+ "../../server/**",
342
+ "../../encode/**",
343
+ "../../viewer/**",
344
+ "../../transport/**",
345
+ "../../media/**"
346
+ ],
347
+ "message": "`worker.js` assembles the torrent thread: it may build the storage component's stores and hand them in, and nothing else outside the torrent component."
348
+ }
349
+ ]
350
+ }
351
+ }
352
+ }
353
+ }
354
+ }
355
+ },
356
+ {
357
+ "includes": [
358
+ "services/server/*.js",
359
+ "!services/server/wire-outputs.js"
360
+ ],
361
+ "linter": {
362
+ "rules": {
363
+ "style": {
364
+ "noRestrictedImports": {
365
+ "level": "error",
366
+ "options": {
367
+ "patterns": [
368
+ {
369
+ "group": [
370
+ "../**",
371
+ "!../encode/output/index.js",
372
+ "!../storage/keep.js",
373
+ "!../../utils/**",
374
+ "!../../../utils/**"
375
+ ],
376
+ "message": "THE SERVER COMPONENT coordinates one request at a time through the narrow interfaces `wire-outputs.js` hands it. It imports no component's implementation: only the name of an output and of its playlist (`encode/output/index.js`) and the keeping period (`storage/keep.js`), which are definitions shared by both sides of an interface."
377
+ }
378
+ ]
379
+ }
380
+ }
381
+ }
382
+ }
383
+ }
384
+ },
385
+ {
386
+ "includes": [
387
+ "services/transport/**"
388
+ ],
389
+ "linter": {
390
+ "rules": {
391
+ "style": {
392
+ "noRestrictedImports": {
393
+ "level": "error",
394
+ "options": {
395
+ "patterns": [
396
+ {
397
+ "group": [
398
+ "../**",
399
+ "!../../utils/**",
400
+ "!../../../utils/**"
401
+ ],
402
+ "message": "THE TRANSPORT COMPONENT delivers bytes to a peer and takes requests from it. It imports nothing of another component: what it reports about the machine, and which files of evidence to keep, are handed in by `bin/cli.js`."
403
+ }
404
+ ]
405
+ }
406
+ }
407
+ }
408
+ }
409
+ }
410
+ }
411
+ ]
412
+ }