gitoriaLog in with ident

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit7d7d44877d7d4487tracker#33 (mission 029): reduced titles — every title TMDB's details never went through this app (no detailsAt, no tmdbSync) is incomplete (shows.hl isIncomplete; the old tracker's migrated rows passed #26's test: 5,697 non-adult on the live copy, 691 series without seasons); the repair job does the visibly reduced first (shows.hl missingParts), the page completes one on open; a title TMDB has no poster for (The Remaining) shows the placeholder; tools/count-incomplete.hl; gate fixtures stand for synced titles (tmdbSync), tests/seed-reduced.hl + #33 checks; gates 347/0, 32/0, 52/0mre7d7d4487/lib/jobs.hl

33.2 KB

  1. // lib/jobs.hl — THE BACKGROUND JOBS (mission 028: out of project.hl, unchanged): the daily TMDB sync run, the adult and kind
  2. // backfills, the details repair, the credits job, the duplicate merge, the short-id backfill and the collection seed — each with
  3. // its queue, its pause, its log lines, and the clocks that drive them (which job runs when, which one waits for which). The work
  4. // of ONE step is the topic's own (sync.hl, backfill.hl, details.hl, credits.hl, merge.hl, shortids.hl, collections.hl).
  5. // A CLASS, not statics: its state (queues, positions, totals) is rewritten on every step, and a static cannot be reassigned —
  6. // project.hl makes the one instance (`jobs = new Jobs()`) after the server, as these lines ran there before; constructing it
  7. // starts the clocks and logs which jobs are off.
  8. import { env } from 'hl:proc'
  9. import { readFile, exists } from 'hl:fs'
  10. import { now, timestamp, every } from 'hl:time'
  11. import { syncEnabled, pauseMsAfter, msPerRequest } from './tmdb.hl'
  12. import { syncShow, syncShowDelta, persistSync } from './sync.hl'
  13. import { emptyTotals, addTotals, totalsLine } from './sync-helpers.hl'
  14. import { planStart, planStep, planIds, planLine, markSynced, isFollowedInRun } from './dailysync.hl'
  15. import { adultBackfillQueue, backfillTitle, kindBackfillQueue, kindTitle } from './backfill.hl'
  16. import { detailsRepairQueue, completeStep, persistDetails, applySynced } from './details.hl'
  17. import { persistCredits, creditsQueue, creditsStep } from './credits.hl'
  18. import { allFollowedShowIds } from './follows.hl'
  19. import { refreshCatalogShow } from './catalog.hl'
  20. import { searchTitleChanged, searchTitleRenamed } from './search.hl'
  21. import { mergePrepare, mergeStep, mergeStats, mergeLine, persistMerge } from './merge.hl'
  22. import { shortIdStep, shortIdStats, persistShortIds, shortIdsLeft } from './shortids.hl'
  23. import { seedPrepare, seedStep, seedLine, seedPersist } from './collections.hl'
  24. // ---- THE DAILY TMDB SYNC (tracker.worldapi.org#9, sync.hl; tracker#18, dailysync.hl) -------------------------
  25. // Once a day at TRACKER_SYNC_HOUR (UTC, default 4 — hl:time has no time zones; the container runs UTC). hl:web serves ONE
  26. // request at a time, so the run never takes the server for itself: a 1-second clock does ONE step per tick and returns — the
  27. // requests that queued meanwhile are served between two ticks, and a tick never starts inside a page render.
  28. // tracker#18: the run first asks TMDB's and TVmaze's CHANGE LISTS since the last run (dailysync.hl — one list page per step)
  29. // and then syncs only the titles of ours that changed, followed ones first — every title stays current, not only the followed
  30. // ones. FULL WALK (every followed show, as before #18) on the first run, after a gap > 14 days, or when a change list fails.
  31. // A title's step: sync.hl syncShow (1–3 TMDB requests + maybe its poster, TVmaze) + details.hl applySynced (the record's
  32. // title, overview, tagline … and cast/crew from the same details answer). After a step that made n requests the next waits
  33. // n × 260 ms (TMDB: ≤ 40 requests / 10 s) + 550 ms per TVmaze request (≤ 20 / 10 s, tracker.worldapi.org#12).
  34. // The finished run stores its day (dailysync.hl markSynced). Log: "tmdb sync: start, …", the change lists ("tmdb sync:
  35. // changes since …"), errors, slow steps, "tmdb sync done: mode=… changeRequests=… <totals>".
  36. // TRACKER_SYNC=0 switches it off; without TMDB_READ_TOKEN it is off too (logged once).
  37. syncHour = env('TRACKER_SYNC_HOUR') != null ? toNumber(env('TRACKER_SYNC_HOUR')) : 4
  38. syncOn = env('TRACKER_SYNC') != '0' && syncEnabled
  39. syncQueue = []
  40. syncPlanning = false
  41. syncMode = ''
  42. syncMark = false
  43. syncChangeRequests = 0
  44. syncAt = 0
  45. syncDay = ''
  46. syncNextAt = 0
  47. syncTotals = emptyTotals()
  48. syncFinish = () => {
  49. persistDetails()
  50. if (syncMark) { markSynced(syncDay) }
  51. console.log('tmdb sync done: mode=' + syncMode + ' changeRequests=' + syncChangeRequests + ' ' + totalsLine(syncTotals) + ' seconds=' + ((now() - syncAt) / 1000))
  52. return null
  53. }
  54. syncTick = () => {
  55. t = now()
  56. if (syncQueue.length == 0 && !syncPlanning) {
  57. stamp = timestamp(t)
  58. day = stamp.slice(0, 10)
  59. if (toNumber(stamp.slice(11, 13)) != syncHour || day == syncDay) { return null }
  60. syncDay = day
  61. syncAt = t
  62. syncNextAt = 0
  63. syncTotals = emptyTotals()
  64. syncChangeRequests = 0
  65. p = planStart(day, null)
  66. syncMode = p.mode
  67. syncMark = true
  68. if (p.mode == 'delta') {
  69. syncPlanning = true
  70. console.log('tmdb sync: start, changes ' + p.why)
  71. return null
  72. }
  73. syncQueue = allFollowedShowIds()
  74. console.log('tmdb sync: start, ' + syncQueue.length + ' followed shows, full walk (' + p.why + ')')
  75. if (syncQueue.length == 0) { syncFinish() }
  76. return null
  77. }
  78. if (t < syncNextAt) { return null }
  79. if (syncPlanning) {
  80. ps = planStep()
  81. syncChangeRequests = syncChangeRequests + ps.requests + ps.tvmazeRequests
  82. syncTotals.requests = syncTotals.requests + ps.requests
  83. syncTotals.tvmazeRequests = syncTotals.tvmazeRequests + ps.tvmazeRequests
  84. syncNextAt = now() + pauseMsAfter(ps)
  85. if (!ps.done) { return null }
  86. syncPlanning = false
  87. console.log('tmdb sync: ' + planLine())
  88. if (ps.failed != '') {
  89. // a change list could not be read: the old full walk, and the day is not advanced (the next run asks again)
  90. syncMode = 'full'
  91. syncMark = false
  92. syncQueue = allFollowedShowIds()
  93. console.log('tmdb sync: change list failed, full walk of ' + syncQueue.length + ' followed shows instead')
  94. } else {
  95. syncQueue = planIds()
  96. }
  97. if (syncQueue.length == 0) { syncFinish() }
  98. return null
  99. }
  100. id = syncQueue[0]
  101. rest = []
  102. let i = 1
  103. while (i < syncQueue.length) { rest.push(syncQueue[i]) i = i + 1 }
  104. syncQueue = rest
  105. // tracker#18: in a delta run a title nobody follows gets the light step (changed seasons, no TVmaze)
  106. r = syncMode == 'delta' && !isFollowedInRun(id) ? syncShowDelta(id) : syncShow(id)
  107. // tracker#18 + #28: the record's own fields (title, overview, tagline …) and the cast + crew from the same details answer
  108. if (r.details != null) {
  109. c = applySynced(id, r.details)
  110. if (c.error != '') { console.log('tmdb sync: ' + c.error) }
  111. if (c.renamed) { searchTitleRenamed(id) }
  112. }
  113. // the public lists (catalog.hl, tracker.worldapi.org#13): this show's place by its newest released episode; the sync
  114. // also brings TMDB's adult flag (mission 054) → the search's view of it too
  115. refreshCatalogShow(id)
  116. searchTitleChanged(id)
  117. took = now() - t
  118. syncTotals = addTotals(syncTotals, r)
  119. if (r.error != '') { console.log('tmdb sync: ' + r.error) }
  120. // a step blocks every request meanwhile (Saturday Night Live, 53 seasons, 4 requests: ~1.7 s) — say so in the log
  121. if (took > 1500) { console.log('tmdb sync: slow step, show ' + id + ', ' + r.requests + ' requests, ' + took + ' ms') }
  122. syncNextAt = now() + pauseMsAfter(r)
  123. if (syncQueue.length > 0 && syncTotals.shows % 10 == 0) { persistDetails() }
  124. if (syncQueue.length == 0) { syncFinish() }
  125. return null
  126. }
  127. // ---- THE ADULT-FLAG BACKFILL (mission 054, backfill.hl backfillTitle) -----------------------------------
  128. // The public lists and the search show only titles TMDB says are not adult (shows.hl isPublicTitle; unknown = hidden). At
  129. // start the app collects every title whose flag is still unknown and asks TMDB for ONE title per step — like the daily
  130. // sync, on the same clock, so requests queued meanwhile are served between two steps: one details request (adult,
  131. // poster_path, external ids) + the poster file when missing, then a pause of 260 ms per TMDB API request (≤ 40 / 10 s;
  132. // the poster comes from TMDB's image host, not the API, and is not counted). Each answered title goes into the lists
  133. // (catalog.hl refreshCatalogShow) and the search at once. RESUMES after a restart: the queue is built from what is
  134. // still unknown. Stops when the queue is empty; titles TMDB answers 404 for are marked (`adultCheck`) and stay hidden; a
  135. // passing failure (no answer, 429, 5xx) goes to the back of the queue, at most 2 more tries per start.
  136. // While the daily sync runs, the backfill waits. Log: start, every TRACKER_BACKFILL_LOG_EVERY (500) titles, done.
  137. // TRACKER_BACKFILL=0 switches it off; without TMDB_READ_TOKEN it is off too.
  138. backfillOn = env('TRACKER_BACKFILL') != '0' && syncEnabled
  139. backfillLogEvery = env('TRACKER_BACKFILL_LOG_EVERY') != null ? toNumber(env('TRACKER_BACKFILL_LOG_EVERY')) : 500
  140. backfillQueue = null
  141. backfillPos = 0
  142. backfillDone = false
  143. backfillAt = 0
  144. backfillNextAt = 0
  145. backfillTries = {}
  146. backfillTotals = { titles = 0 adult = 0 notAdult = 0 unknown = 0 posters = 0 ids = 0 requests = 0 errors = 0 retries = 0 }
  147. backfillLine = () => {
  148. b = backfillTotals
  149. return b.titles + '/' + backfillQueue.length + ' titles, adult=' + b.adult + ' notAdult=' + b.notAdult + ' unknown=' + b.unknown + ' posters=' + b.posters
  150. + ' ids=' + b.ids + ' requests=' + b.requests + ' errors=' + b.errors + ' retries=' + b.retries + ' seconds=' + ((now() - backfillAt) / 1000)
  151. }
  152. backfillTick = () => {
  153. if (backfillDone) { return null }
  154. t = now()
  155. if (backfillQueue == null) {
  156. backfillQueue = adultBackfillQueue()
  157. backfillAt = t
  158. console.log('adult backfill: start, ' + backfillQueue.length + ' titles without an adult flag (' + (now() - t) + ' ms to find them)')
  159. if (backfillQueue.length == 0) { backfillDone = true console.log('adult backfill: nothing to do') }
  160. return null
  161. }
  162. if (t < backfillNextAt) { return null }
  163. id = backfillQueue[backfillPos]
  164. backfillPos = backfillPos + 1
  165. r = backfillTitle(id)
  166. if (r.retry && (backfillTries[id] == null || backfillTries[id] < 2)) {
  167. backfillTries[id] = backfillTries[id] == null ? 1 : backfillTries[id] + 1
  168. q = backfillQueue
  169. q.push(id)
  170. backfillQueue = q
  171. backfillTotals.retries = backfillTotals.retries + 1
  172. } else {
  173. backfillTotals.titles = backfillTotals.titles + 1
  174. if (r.adult == true) { backfillTotals.adult = backfillTotals.adult + 1 } else if (r.adult == false) { backfillTotals.notAdult = backfillTotals.notAdult + 1 } else { backfillTotals.unknown = backfillTotals.unknown + 1 }
  175. }
  176. backfillTotals.posters = backfillTotals.posters + r.posters
  177. backfillTotals.ids = backfillTotals.ids + r.ids
  178. backfillTotals.requests = backfillTotals.requests + r.requests
  179. backfillTotals.errors = backfillTotals.errors + r.errors
  180. if (r.error != '') { console.log('adult backfill: ' + r.error) }
  181. if (r.adult != null) {
  182. refreshCatalogShow(id)
  183. searchTitleChanged(id)
  184. }
  185. took = now() - t
  186. if (took > 1500) { console.log('adult backfill: slow step, show ' + id + ', ' + took + ' ms') }
  187. backfillNextAt = now() + r.requests * msPerRequest
  188. finished = backfillPos >= backfillQueue.length
  189. if (finished || backfillPos % 25 == 0) { persistSync() }
  190. if (!finished && backfillTotals.titles > 0 && backfillTotals.titles % backfillLogEvery == 0 && !r.retry) { console.log('adult backfill: ' + backfillLine()) }
  191. if (finished) {
  192. backfillDone = true
  193. console.log('adult backfill done: ' + backfillLine())
  194. }
  195. return null
  196. }
  197. // ---- THE DETAILS REPAIR (tracker.worldapi.org#26, details.hl completeStep) ----------------------------------------
  198. // Titles the person pages added from a filmography (#16) are MINIMAL (no poster, seasons, ids, cast …), and (tracker#33, mission
  199. // 029) the old tracker's migrated rows were never synced (5,697 on the live copy, 691 series without seasons) — shows.hl
  200. // isIncomplete. Opening one completes it (components/show.hl); this job completes the rest in the background: at start it
  201. // collects every incomplete, non-adult title (the visibly reduced ones first, details.hl detailsRepairQueue) and does ONE per
  202. // step on the app's clock, like the adult backfill — a step is the daily sync's work for one title
  203. // (1–3 TMDB requests + poster + TVmaze), requests queued meanwhile are served between two steps; then a pause of 260 ms per
  204. // TMDB request + 550 ms per TVmaze request (pauseMsAfter: ≤ 40 / 10 s, ≤ 20 / 10 s). RESUMES after a restart (the queue is
  205. // what is still incomplete); TMDB 404 marks the title (`detailsCheck`), a passing failure goes to the back of the queue (at
  206. // most 2 more tries per start). Waits while the daily sync or the adult backfill runs. Persisted every 10 titles + at the end.
  207. // Log: start, every TRACKER_REPAIR_LOG_EVERY (100) titles, each failure, done. TRACKER_REPAIR=0 switches it off (off too
  208. // without TMDB_READ_TOKEN). TRACKER_REPAIR_FAST=1 (the gate, fake TMDB only): 20 ms pause instead.
  209. repairOn = env('TRACKER_REPAIR') != '0' && syncEnabled
  210. repairFast = env('TRACKER_REPAIR_FAST') == '1'
  211. repairLogEvery = env('TRACKER_REPAIR_LOG_EVERY') != null ? toNumber(env('TRACKER_REPAIR_LOG_EVERY')) : 100
  212. repairQueue = null
  213. repairPos = 0
  214. repairDone = false
  215. repairAt = 0
  216. repairNextAt = 0
  217. repairTries = {}
  218. repairTotals = { titles = 0 complete = 0 failed = 0 adult = 0 newSeasons = 0 newEpisodes = 0 posters = 0 cast = 0 requests = 0 tvmazeRequests = 0 retries = 0 }
  219. repairLine = () => {
  220. b = repairTotals
  221. return b.titles + '/' + repairQueue.length + ' titles, complete=' + b.complete + ' failed=' + b.failed + ' adult=' + b.adult + ' newSeasons=' + b.newSeasons + ' newEpisodes=' + b.newEpisodes
  222. + ' posters=' + b.posters + ' cast=' + b.cast + ' requests=' + b.requests + ' tvmazeRequests=' + b.tvmazeRequests + ' retries=' + b.retries + ' seconds=' + ((now() - repairAt) / 1000)
  223. }
  224. repairTick = () => {
  225. if (repairDone) { return null }
  226. t = now()
  227. if (repairQueue == null) {
  228. repairQueue = detailsRepairQueue()
  229. repairAt = t
  230. console.log('details repair: start, ' + repairQueue.length + ' incomplete titles (' + (now() - t) + ' ms to find them)')
  231. if (repairQueue.length == 0) { repairDone = true console.log('details repair: nothing to do') }
  232. return null
  233. }
  234. if (t < repairNextAt) { return null }
  235. id = repairQueue[repairPos]
  236. r = completeStep(id)
  237. took = now() - t
  238. if (took > 1500) { console.log('details repair: slow step, show ' + id + ', ' + took + ' ms') }
  239. if (r.error != '') { console.log('details repair: ' + r.error) }
  240. repairNextAt = now() + (repairFast ? 20 : pauseMsAfter(r))
  241. // a series takes several steps: the same title again next time
  242. if (!r.done && !r.retry) { return null }
  243. repairPos = repairPos + 1
  244. if (r.retry && (repairTries[id] == null || repairTries[id] < 2)) {
  245. repairTries[id] = repairTries[id] == null ? 1 : repairTries[id] + 1
  246. q = repairQueue
  247. q.push(id)
  248. repairQueue = q
  249. repairTotals.retries = repairTotals.retries + 1
  250. } else if (!r.skipped) {
  251. // done: its counts (a failed first step: the request alone)
  252. sum = r.sum
  253. repairTotals.titles = repairTotals.titles + 1
  254. if (r.adult == true) { repairTotals.adult = repairTotals.adult + 1 } else if (sum.steps == 0) { repairTotals.failed = repairTotals.failed + 1 } else { repairTotals.complete = repairTotals.complete + 1 }
  255. repairTotals.newSeasons = repairTotals.newSeasons + sum.newSeasons
  256. repairTotals.newEpisodes = repairTotals.newEpisodes + sum.newEpisodes
  257. repairTotals.posters = repairTotals.posters + sum.posters
  258. repairTotals.cast = repairTotals.cast + sum.cast
  259. repairTotals.requests = repairTotals.requests + (sum.steps == 0 ? r.requests : sum.requests)
  260. repairTotals.tvmazeRequests = repairTotals.tvmazeRequests + sum.tvmazeRequests
  261. }
  262. finished = repairPos >= repairQueue.length
  263. if (finished || repairPos % 10 == 0) { persistDetails() }
  264. if (!finished && !r.skipped && !r.retry && repairTotals.titles > 0 && repairTotals.titles % repairLogEvery == 0) { console.log('details repair: ' + repairLine()) }
  265. if (finished) {
  266. repairDone = true
  267. console.log('details repair done: ' + repairLine())
  268. }
  269. return null
  270. }
  271. // ---- THE KIND BACKFILL (tracker.worldapi.org#21, mission 068, backfill.hl kindTitle) ----------------------------------
  272. // Every TV title without a stored kind gets one: a title with a show genre (Reality / Talk / News) from the stored data (no
  273. // request), any other from TMDB's TV type (ONE request: GET /tv/<id>, then 260 ms pause). Starts once the adult backfill is
  274. // done (or off), waits while the daily sync runs, ONE title per step on the same clock. A title that becomes a SHOW moves from
  275. // /series to /shows at once (catalog.hl refreshCatalogShow). RESUMES after a restart (the queue = every TV title still without
  276. // a kind); a 404 stores the genres' answer + `kindCheck`; a passing failure goes to the back of the queue, at most 2 more tries
  277. // per start. Log: start, every TRACKER_KINDS_LOG_EVERY (500) titles, done. TRACKER_KINDS=0 switches it off; without
  278. // TMDB_READ_TOKEN it is off too (the lists still split by genre: shows.hl titleKind).
  279. kindsOn = env('TRACKER_KINDS') != '0' && syncEnabled
  280. kindsLogEvery = env('TRACKER_KINDS_LOG_EVERY') != null ? toNumber(env('TRACKER_KINDS_LOG_EVERY')) : 500
  281. kindQueue = null
  282. kindPos = 0
  283. kindDone = false
  284. kindAt = 0
  285. kindNextAt = 0
  286. kindTries = {}
  287. kindTotals = { titles = 0 series = 0 shows = 0 fromGenre = 0 moved = 0 requests = 0 errors = 0 retries = 0 }
  288. kindLine = () => {
  289. k = kindTotals
  290. return k.titles + '/' + kindQueue.length + ' titles, series=' + k.series + ' shows=' + k.shows + ' fromGenre=' + k.fromGenre + ' moved=' + k.moved
  291. + ' requests=' + k.requests + ' errors=' + k.errors + ' retries=' + k.retries + ' seconds=' + ((now() - kindAt) / 1000)
  292. }
  293. kindTick = () => {
  294. if (kindDone) { return null }
  295. t = now()
  296. if (kindQueue == null) {
  297. kindQueue = kindBackfillQueue()
  298. kindAt = t
  299. console.log('kind backfill: start, ' + kindQueue.length + ' TV titles without a kind (' + (now() - t) + ' ms to find them)')
  300. if (kindQueue.length == 0) { kindDone = true console.log('kind backfill: nothing to do') }
  301. return null
  302. }
  303. if (t < kindNextAt) { return null }
  304. id = kindQueue[kindPos]
  305. kindPos = kindPos + 1
  306. r = kindTitle(id)
  307. if (r.retry && (kindTries[id] == null || kindTries[id] < 2)) {
  308. kindTries[id] = kindTries[id] == null ? 1 : kindTries[id] + 1
  309. q = kindQueue
  310. q.push(id)
  311. kindQueue = q
  312. kindTotals.retries = kindTotals.retries + 1
  313. } else {
  314. kindTotals.titles = kindTotals.titles + 1
  315. if (r.kind == 'show') { kindTotals.shows = kindTotals.shows + 1 } else if (r.kind == 'series') { kindTotals.series = kindTotals.series + 1 }
  316. if (r.fromGenre) { kindTotals.fromGenre = kindTotals.fromGenre + 1 }
  317. }
  318. kindTotals.requests = kindTotals.requests + r.requests
  319. kindTotals.errors = kindTotals.errors + r.errors
  320. if (r.error != '') { console.log('kind backfill: ' + r.error) }
  321. // until now the genres decided (no show genre = series): only a title TMDB's type makes a SHOW changes its list
  322. if (r.kind == 'show' && !r.fromGenre) {
  323. refreshCatalogShow(id)
  324. kindTotals.moved = kindTotals.moved + 1
  325. }
  326. took = now() - t
  327. if (took > 1500) { console.log('kind backfill: slow step, show ' + id + ', ' + took + ' ms') }
  328. kindNextAt = now() + r.requests * msPerRequest
  329. finished = kindPos >= kindQueue.length
  330. if (finished || kindPos % 25 == 0) { persistSync() }
  331. if (!finished && kindTotals.titles > 0 && kindTotals.titles % kindsLogEvery == 0 && !r.retry) { console.log('kind backfill: ' + kindLine()) }
  332. if (finished) {
  333. kindDone = true
  334. console.log('kind backfill done: ' + kindLine())
  335. }
  336. return null
  337. }
  338. // ---- THE CREDITS JOB (tracker.worldapi.org#28, credits.hl creditsStep) ------------------------------------------------------
  339. // Every PUBLIC title (adult == false; adult/unknown are skipped) with a TMDB id gets its whole cast + crew once: at start (after
  340. // the adult backfill and the details repair are done) the job collects every such title without `creditsAt` and asks ONE per
  341. // step on the app's clock — one request (details + credits / aggregate_credits), then 260 ms (≤ 40 / 10 s); requests queued
  342. // meanwhile are served between two steps. Titles the details repair, the daily sync or an import already did carry `creditsAt`
  343. // and are not asked. RESUMES after a restart (the queue = what still has no credits); TMDB 404 / adult → `creditsCheck`, never
  344. // asked again; a passing failure goes to the back of the queue (at most 2 more tries per start). Waits while the daily sync
  345. // runs. Persisted (shows + people only) every 25 titles + at the end. Log: start, every TRACKER_CREDITS_LOG_EVERY (500) titles, failures, slow steps
  346. // (> 1.5 s), done. TRACKER_CREDITS=0 switches it off (off too without TMDB_READ_TOKEN). TRACKER_CREDITS_FAST=1 (the gate, fake
  347. // TMDB only): 20 ms pause instead.
  348. // MEMORY LIMIT: the runtime never frees what a fetch + JSON parse took (mission 061 measured ~6 MB more RSS per title on the real
  349. // data, 300 fetches of a 440 KB JSON = +2.7 GB in a 10-line script) — the whole job in one process would add ~35 GB. Before every
  350. // step the job reads its own RSS (/proc/self/status); above TRACKER_CREDITS_MAX_MB (16000) it PAUSES for this process (logged) and
  351. // goes on with what is left after the next restart (deploy, `docker restart`).
  352. creditsOn = env('TRACKER_CREDITS') != '0' && syncEnabled
  353. creditsFast = env('TRACKER_CREDITS_FAST') == '1'
  354. creditsLogEvery = env('TRACKER_CREDITS_LOG_EVERY') != null ? toNumber(env('TRACKER_CREDITS_LOG_EVERY')) : 500
  355. creditsQueueIds = null
  356. creditsPos = 0
  357. creditsDone = false
  358. creditsAt = 0
  359. creditsNextAt = 0
  360. creditsTries = {}
  361. creditsMaxMb = env('TRACKER_CREDITS_MAX_MB') != null ? toNumber(env('TRACKER_CREDITS_MAX_MB')) : 16000
  362. creditsTotals = { titles = 0 done = 0 failed = 0 cast = 0 crew = 0 people = 0 requests = 0 retries = 0 slowest = 0 }
  363. // this process' resident memory in MB (VmRSS), 0 when unknown
  364. rssMb = () => {
  365. if (!exists('/proc/self/status')) { return 0 }
  366. t = readFile('/proc/self/status')
  367. i = t != null ? t.indexOf('VmRSS:') : -1
  368. if (i < 0) { return 0 }
  369. kb = toNumber(t.slice(i + 6, t.indexOf('kB', i)).trim())
  370. return kb != null ? (kb - kb % 1024) / 1024 : 0
  371. }
  372. creditsLine = () => {
  373. b = creditsTotals
  374. return b.titles + '/' + creditsQueueIds.length + ' titles, done=' + b.done + ' failed=' + b.failed + ' cast=' + b.cast + ' crew=' + b.crew + ' people=' + b.people
  375. + ' requests=' + b.requests + ' retries=' + b.retries + ' slowestStepMs=' + b.slowest + ' seconds=' + ((now() - creditsAt) / 1000)
  376. }
  377. creditsTick = () => {
  378. if (creditsDone) { return null }
  379. t = now()
  380. if (creditsQueueIds == null) {
  381. creditsQueueIds = creditsQueue()
  382. creditsAt = t
  383. console.log('credits job: start, ' + creditsQueueIds.length + ' titles without credits (' + (now() - t) + ' ms to find them)')
  384. if (creditsQueueIds.length == 0) { creditsDone = true console.log('credits job: nothing to do') }
  385. return null
  386. }
  387. if (t < creditsNextAt) { return null }
  388. mb = rssMb()
  389. if (mb > creditsMaxMb) {
  390. creditsDone = true
  391. persistCredits()
  392. console.log('credits job: paused, RSS ' + mb + ' MB > TRACKER_CREDITS_MAX_MB ' + creditsMaxMb + ' — ' + (creditsQueueIds.length - creditsPos) + ' titles left for the next start; ' + creditsLine())
  393. return null
  394. }
  395. id = creditsQueueIds[creditsPos]
  396. creditsPos = creditsPos + 1
  397. r = creditsStep(id)
  398. took = now() - t
  399. if (took > creditsTotals.slowest) { creditsTotals.slowest = took }
  400. if (took > 1500) { console.log('credits job: slow step, show ' + id + ', ' + took + ' ms, cast=' + r.cast + ' crew=' + r.crew + ' people=' + r.people) }
  401. if (r.error != '') { console.log('credits job: ' + r.error) }
  402. creditsNextAt = now() + (creditsFast ? 20 : r.requests * msPerRequest)
  403. if (r.retry && (creditsTries[id] == null || creditsTries[id] < 2)) {
  404. creditsTries[id] = creditsTries[id] == null ? 1 : creditsTries[id] + 1
  405. q = creditsQueueIds
  406. q.push(id)
  407. creditsQueueIds = q
  408. creditsTotals.retries = creditsTotals.retries + 1
  409. } else if (!r.skipped) {
  410. creditsTotals.titles = creditsTotals.titles + 1
  411. if (r.error != '') { creditsTotals.failed = creditsTotals.failed + 1 } else { creditsTotals.done = creditsTotals.done + 1 }
  412. creditsTotals.cast = creditsTotals.cast + r.cast
  413. creditsTotals.crew = creditsTotals.crew + r.crew
  414. creditsTotals.people = creditsTotals.people + r.people
  415. }
  416. creditsTotals.requests = creditsTotals.requests + r.requests
  417. finished = creditsPos >= creditsQueueIds.length
  418. if (finished || creditsPos % 25 == 0) { persistCredits() }
  419. if (!finished && !r.skipped && !r.retry && creditsTotals.titles > 0 && creditsTotals.titles % creditsLogEvery == 0) { console.log('credits job: ' + creditsLine()) }
  420. if (finished) {
  421. creditsDone = true
  422. console.log('credits job done: ' + creditsLine())
  423. }
  424. return null
  425. }
  426. // ---- THE DUPLICATE MERGE (tracker.worldapi.org#31, mission 026, merge.hl) ----------------------------------------------------
  427. // The old tracker's duplicate titles (same type + TMDB id) become ONE record each — follows, watches, seasons, cast, credits and
  428. // timelines moved to the keeper, the others kept as tombstones whose slug and short id lead to it — and seasons that name a title
  429. // without being in its list are merged into their twin or linked (merge.hl has the rules). On its own clock (every 0.1 s) ONE
  430. // item per tick (a duplicate group, or one title's stray seasons; no TMDB), so pages are served between two items. The TMDB jobs
  431. // below (daily sync, backfills, repair, credits, collections) wait until it is done: none of them works on a record that is about
  432. // to become a tombstone. RESUMES after a restart (the queue = what is still duplicated / stray). Persisted every 10 items and at
  433. // the end. Log: start, one line per tombstone / repaired title, done; with nothing to do one line. TRACKER_MERGE=0 switches it off.
  434. mergeOn = env('TRACKER_MERGE') != '0'
  435. mergeRun = { started = false done = !mergeOn at = 0 items = 0 slowest = 0 }
  436. mergeTick = () => {
  437. if (mergeRun.done) { return null }
  438. t = now()
  439. if (!mergeRun.started) {
  440. mergeRun.started = true
  441. mergeRun.at = t
  442. n = mergePrepare()
  443. st = mergeStats()
  444. console.log('merge: start, ' + st.groups + ' duplicate groups (' + st.records + ' records), ' + st.strayTitles + ' titles with stray seasons (' + st.ms + ' ms to find them)')
  445. if (n == 0) {
  446. mergeRun.done = true
  447. console.log('merge: nothing to do')
  448. }
  449. return null
  450. }
  451. r = mergeStep()
  452. mergeRun.items = mergeRun.items + 1
  453. took = now() - t
  454. if (took > mergeRun.slowest) { mergeRun.slowest = took }
  455. if (took > 1500) { console.log('merge: slow step, ' + took + ' ms') }
  456. if (r.done || mergeRun.items % 10 == 0) { persistMerge() }
  457. if (r.done) {
  458. mergeRun.done = true
  459. console.log('merge done: ' + mergeLine() + ' items=' + mergeRun.items + ' slowestStepMs=' + mergeRun.slowest + ' seconds=' + ((now() - mergeRun.at) / 1000))
  460. }
  461. return null
  462. }
  463. if (!mergeOn) { console.log('merge: off (TRACKER_MERGE=0)') }
  464. else {
  465. mergeClock = every(0.1)
  466. on mergeClock.tick(x) {
  467. mergeTick()
  468. return null
  469. }
  470. }
  471. // ONE clock for all five (a tick every 0.1 s): the daily sync's step once a second as before; the backfill's steps in
  472. // between, only while no daily run is going on; the details repair only when neither has work; then the kind backfill (#21);
  473. // the credits job (#28) last
  474. clockOn = syncOn || backfillOn || repairOn || kindsOn || creditsOn
  475. clockTicks = 0
  476. if (syncOn) { console.log('tmdb sync: daily at ' + syncHour + ':00 UTC') } else { console.log('tmdb sync: off (' + (syncEnabled ? 'TRACKER_SYNC=0' : 'no TMDB_READ_TOKEN') + ')') }
  477. if (!backfillOn) { console.log('adult backfill: off (' + (syncEnabled ? 'TRACKER_BACKFILL=0' : 'no TMDB_READ_TOKEN') + ')') }
  478. if (!repairOn) { console.log('details repair: off (' + (syncEnabled ? 'TRACKER_REPAIR=0' : 'no TMDB_READ_TOKEN') + ')') }
  479. if (!creditsOn) { console.log('credits job: off (' + (syncEnabled ? 'TRACKER_CREDITS=0' : 'no TMDB_READ_TOKEN') + ')') }
  480. if (!kindsOn) { console.log('kind backfill: off (' + (syncEnabled ? 'TRACKER_KINDS=0' : 'no TMDB_READ_TOKEN') + ')') }
  481. if (clockOn) {
  482. syncClock = every(0.1)
  483. on syncClock.tick(x) {
  484. clockTicks = clockTicks + 1
  485. // tracker#31: not before the duplicate merge is done
  486. if (!mergeRun.done) { return null }
  487. busy = syncQueue.length > 0 || syncPlanning
  488. if (syncOn && clockTicks % 10 == 0) { syncTick() }
  489. free = !busy && syncQueue.length == 0 && !syncPlanning
  490. if (backfillOn && free && !backfillDone) { backfillTick() }
  491. else if (repairOn && free && (!backfillOn || backfillDone) && !repairDone) { repairTick() }
  492. else if (kindsOn && free && (!backfillOn || backfillDone) && (!repairOn || repairDone) && !kindDone) { kindTick() }
  493. else if (creditsOn && free && (!backfillOn || backfillDone) && (!repairOn || repairDone) && (!kindsOn || kindDone)) { creditsTick() }
  494. return null
  495. }
  496. }
  497. // ---- THE SHORT-ID BACKFILL (mission 060, tracker.worldapi.org#27, shortids.hl shortIdStep) ----------------------------
  498. // Every show and person without a short id gets one in the background: on its own clock (every 0.1 s) ONE batch per tick,
  499. // as many records as fit into TRACKER_SHORTID_BUDGET_MS (default 40 ms) — no TMDB, only the tables — so a page waits at
  500. // most one batch. The queue is built at start (`ensureShortIds`) from what is still missing = it resumes after a restart.
  501. // Persisted every 20 batches and at the end. Log: start, every TRACKER_SHORTID_LOG_EVERY (5000) records, done; with nothing
  502. // to do one line. TRACKER_SHORTIDS=0 switches it off (the gate's resume check).
  503. shortIdOn = env('TRACKER_SHORTIDS') != '0'
  504. shortIdBudget = env('TRACKER_SHORTID_BUDGET_MS') != null ? toNumber(env('TRACKER_SHORTID_BUDGET_MS')) : 40
  505. shortIdLogEvery = env('TRACKER_SHORTID_LOG_EVERY') != null ? toNumber(env('TRACKER_SHORTID_LOG_EVERY')) : 5000
  506. shortIdRun = { at = 0 batches = 0 assigned = 0 nextLog = 0 slowest = 0 slowestPersist = 0 done = false }
  507. shortIdTick = () => {
  508. if (shortIdRun.done) { return null }
  509. t = now()
  510. r = shortIdStep(shortIdBudget)
  511. took = now() - t
  512. shortIdRun.batches = shortIdRun.batches + 1
  513. shortIdRun.assigned = shortIdRun.assigned + r.assigned
  514. if (took > shortIdRun.slowest) { shortIdRun.slowest = took }
  515. if (r.done || shortIdRun.batches % 20 == 0) {
  516. tp = now()
  517. persistShortIds()
  518. if (now() - tp > shortIdRun.slowestPersist) { shortIdRun.slowestPersist = now() - tp }
  519. }
  520. if (!r.done && shortIdRun.assigned >= shortIdRun.nextLog) {
  521. console.log('short ids: ' + shortIdRun.assigned + ' assigned, ' + r.left + ' left, ' + ((now() - shortIdRun.at) / 1000) + ' s')
  522. shortIdRun.nextLog = shortIdRun.nextLog + shortIdLogEvery
  523. }
  524. if (r.done) {
  525. shortIdRun.done = true
  526. s = shortIdStats()
  527. console.log('short ids done: assigned=' + shortIdRun.assigned + ' oldKept=' + s.oldKept + ' batches=' + shortIdRun.batches + ' slowestBatchMs=' + shortIdRun.slowest + ' slowestPersistMs=' + shortIdRun.slowestPersist + ' seconds=' + ((now() - shortIdRun.at) / 1000))
  528. }
  529. return null
  530. }
  531. if (!shortIdOn) { console.log('short ids: backfill off (TRACKER_SHORTIDS=0), ' + shortIdsLeft() + ' records without one') }
  532. else if (shortIdsLeft() == 0) { console.log('short ids: nothing to do') }
  533. else {
  534. shortIdRun.at = now()
  535. shortIdRun.nextLog = shortIdLogEvery
  536. console.log('short ids: backfill start, ' + shortIdsLeft() + ' records, ' + shortIdBudget + ' ms per batch')
  537. shortIdClock = every(0.1)
  538. on shortIdClock.tick(x) {
  539. shortIdTick()
  540. return null
  541. }
  542. }
  543. // ---- THE COLLECTION SEED (mission 066, tracker.worldapi.org#19, collections.hl seedStep) ------------------------------------
  544. // TMDB's movie collections become timelines: ONE movie per step (its details; once per collection the collection's parts), on
  545. // its own 0.1 s clock like the adult backfill — a pause of 260 ms per TMDB request made (≤ 40 / 10 s). It WAITS while the daily
  546. // sync or the adult backfill runs (they share TMDB's limit and the backfill brings the adult flags it skips by); since the merge
  547. // (mission 070) also until the details repair, the kind backfill and the credits job are done (or paused) — the LAST job. The queue =
  548. // every non-adult movie without a check row, so it RESUMES after a restart and does nothing once all are checked. Persisted
  549. // every TRACKER_COLLECTIONS_PERSIST_EVERY (25) steps and at the end. Log: start, every TRACKER_COLLECTIONS_LOG_EVERY (500) movies, done.
  550. // TRACKER_COLLECTIONS=0 switches it off; without TMDB_READ_TOKEN it is off too.
  551. collectionsOn = env('TRACKER_COLLECTIONS') != '0' && syncEnabled
  552. collectionsLogEvery = env('TRACKER_COLLECTIONS_LOG_EVERY') != null ? toNumber(env('TRACKER_COLLECTIONS_LOG_EVERY')) : 500
  553. collectionsPersistEvery = env('TRACKER_COLLECTIONS_PERSIST_EVERY') != null ? toNumber(env('TRACKER_COLLECTIONS_PERSIST_EVERY')) : 25
  554. collectionRun = { at = 0 steps = 0 nextAt = 0 done = false started = false slowest = 0 }
  555. collectionTick = () => {
  556. if (collectionRun.done) { return null }
  557. // mission 070 (merge): also behind the details repair, the kind backfill and the credits job — one TMDB pacing at a time
  558. if (!mergeRun.done || syncQueue.length > 0 || syncPlanning || (backfillOn && !backfillDone) || (repairOn && !repairDone) || (kindsOn && !kindDone) || (creditsOn && !creditsDone)) { return null }
  559. t = now()
  560. if (!collectionRun.started) {
  561. collectionRun.started = true
  562. collectionRun.at = t
  563. n = seedPrepare()
  564. console.log('collections: start, ' + n + ' movies to check (' + (now() - t) + ' ms to find them)')
  565. if (n == 0) { collectionRun.done = true console.log('collections: nothing to do') }
  566. return null
  567. }
  568. if (t < collectionRun.nextAt) { return null }
  569. r = seedStep()
  570. if (r.done) {
  571. collectionRun.done = true
  572. seedPersist()
  573. console.log('collections done: ' + seedLine() + ' seconds=' + ((now() - collectionRun.at) / 1000) + ' slowestStepMs=' + collectionRun.slowest)
  574. return null
  575. }
  576. collectionRun.steps = collectionRun.steps + 1
  577. took = now() - t
  578. if (took > collectionRun.slowest) { collectionRun.slowest = took }
  579. if (r.error != '') { console.log('collections: ' + r.error) }
  580. if (took > 1500) { console.log('collections: slow step, ' + took + ' ms') }
  581. collectionRun.nextAt = now() + r.requests * msPerRequest
  582. if (collectionRun.steps % collectionsPersistEvery == 0) { seedPersist() }
  583. if (collectionRun.steps % collectionsLogEvery == 0) { console.log('collections: ' + seedLine() + ' seconds=' + ((now() - collectionRun.at) / 1000)) }
  584. return null
  585. }
  586. if (!collectionsOn) { console.log('collections: off (' + (syncEnabled ? 'TRACKER_COLLECTIONS=0' : 'no TMDB_READ_TOKEN') + ')') }
  587. else {
  588. collectionClock = every(0.1)
  589. on collectionClock.tick(x) {
  590. collectionTick()
  591. return null
  592. }
  593. }

Branches

Latest commits

  • 7d7d4487tracker#33 (mission 029): reduced titles — every title TMDB's details never went through this app (no detailsAt, no tmdbSync) is incomplete (shows.hl isIncomplete; the old tracker's migrated rows passed #26's test: 5,697 non-adult on the live copy, 691 series without seasons); the repair job does the visibly reduced first (shows.hl missingParts), the page completes one on open; a title TMDB has no poster for (The Remaining) shows the placeholder; tools/count-incomplete.hl; gate fixtures stand for synced titles (tmdbSync), tests/seed-reduced.hl + #33 checks; gates 347/0, 32/0, 52/0mre
  • 661c2592tracker: report 028mre
  • 27c916fatracker mission 028: README ("Code order", the new file map), STATUS (counts before/after, tests, how to repeat, open), LOGmre
  • d924f398tracker mission 028: comments name the new files (sync.hl, dailysync.hl, backfill.hl, credits.hl, jobs.hl, images.hl …); tools/ref-params.py + tools/lambda-audit.py also scan lib/ (they globbed the root only), lambda-audit counts a plain `x = p` alias like `let x = p`mre
  • 2e89b968tracker mission 028 (code order) 5/5 let: `let` only where a variable is reassigned — 667 never-reassigned lets became plain declarations (project.hl, lib/, components/, tools/, tests/); kept: 264 in loop bodies (a plain declaration there is 'Cannot reassign' on the 2nd pass), 234 reassigned, 27 whose name is also a member/outer/free name (a plain write would rebind it); tools/let-audit.py decides and fixes (README 'Code order'); tests/realdata-m028.{sh,mjs} = the page-output diff on a real copy; gates 342/0, 32/0, 52/0, real-copy pages identicalmre
  • 54796ff2tracker mission 028 (code order) 4/5 thin faces + last copies: the show page's check/follow faces call lib/watches.hl toggleWatched / toggleSeasonWatched (seasonAllWatched moved there) and lib/follows.hl toggleFollowed; both logins (header selector face, /login/callback) share lib/users.hl userOfCode; todayStr/listOf copies in components and the export readers copied into tools/migrate.hl + tools/old-short-ids.hl now once (lib/util.hl, lib/export.hl); gates 342/0, 32/0, 52/0; old-short-ids output byte-identical, migrate output identicalmre
  • 06b078e3tracker mission 028 (code order) 3/5 project.hl is the map: config, routes, wiring and a feature → file index (914 → 258 lines); the background jobs (daily sync run, backfills, details repair, credits job, merge, short ids, collection seed) moved unchanged into lib/jobs.hl (a class: their state is reassigned every step, a static cannot be; one instance made after the server), the login callback into lib/users.hl, poster/photo serving into lib/images.hl, the /shows/<slug> rule into lib/shows.hl showsMovedPath; route handlers are thin wrappers; gates 342/0, 32/0, 52/0, real-copy pages identicalmre
  • 94716fd2tracker mission 028 (code order) 2/5 util + topics: lib/util.hl holds envOr, storageDir, postersDir, profilesDir, newId, hexDigits, todayStr, dateOr, textOr, hasId, listOr, firstOf, sortDesc once (were copied into up to 5 files); tmdbsync.hl split into tmdb.hl (TMDB/TVmaze requests), sync.hl (one title's sync), sync-helpers.hl, backfill.hl; details.hl split into details.hl, credits.hl, credits-helpers.hl (isIncomplete to shows.hl); search-helpers.hl (words, query, ranking, slugs); collections.hl (the TMDB collection seed, out of franchises.hl); deltasync.hl renamed dailysync.hl; no behaviour change: gates 342/0, 32/0, 52/0, real-copy pages identicalmre
  • 186079b0tracker mission 028 (code order) 1/5 move: every root .hl except project.hl into lib/ (styles.hl into components/), import paths only; gates 342/0, 32/0, 52/0; real-copy pages identicalmre
  • 4f47f181tracker: report 027mre
  • dc1d4be4tracker mission 027: Hybriel master 06617221 vendored (plugin allocator fixes 3a781359 + 413f60e4); real copy RSS through first-start jobs + 400 loads flat ~2.55 GB (190aa11d 2.3 -> 5.6 GB), page times <= 1.1x; gates 342/0, 32/0, 52/0mre
  • 84e1b3e1tracker: reports 025 + 026mre
  • dc40d859tracker#31 (mission 026): duplicate titles merged — the 68 type+tmdbId pairs held by 157 records were the old tracker's (all migrated); merge.hl repair job (own clock, before the TMDB jobs) keeps one keeper per title (follows/watches > old short id > oldest), moves follows, watches, seasons, cast, credits, timelines, tombstones the rest (mergedInto, never deleted), slugs + short ids 301 to the keeper; stray seasons merged into their listed twin (Reacher S3 watches) or linked when watched; search import re-checks before its put; deploy.sh waits up to 90 s for 200; real copy 68 -> 0 dup ids, az5b2 follows/watches equal; gates 342/0, 32/0, 52/0mre
  • 2667da05tracker#30 (mission 025): /my/ pages from slim cached title cards, episode rows and watch sets (after the jobs /my/series 1.8 s -> 0.06 s, /my/unwatched 4.1 -> 0.18 s); timeline page shows its name once; franchise widget under the poster/title; movies with TV leftovers (First Contact) go through the details repair; tools/count-tmdb-ids.hl; gates 327/0, 52/0, 32/0mre
  • 3909810dantcolony#40: mission references in README/STATUS/docs point to the moved missionsmre
  • e63b1d28antcolony#40: history (LOG.md), worker briefs (missions/) and reports moved here from antcolony, numbered per project; old numbers in antcolony docs/mission-map.mdmre
  • 1cda451dtracker: Hybriel master 190aa11d (#127 both shapes, GC correctness fc838894) — conductor adopts despite /my/series 2.4x after jobs (memory 8.0 → 1.7 GB boot); see reports/071mre
  • c1fa2f2etracker (mission 071): Hybriel master 190aa11d measured on the real copy vs the live binary 8590df63 — NOT adopted (after the first-start jobs /my/series 2.4x slower, /series 1.6x, RSS swings 7.4-12.2 GB; fresh it is flat at 1.7-2.2 GB and /my/unwatched faster), vendor stays 8efba065, candidate kept in .scratch/w071/vendor-190aa11d; tests/kinds.mjs: collection seed off (its TMDB request broke check 1 in 1 of 4 runs); tests/realdata-071.sh + realdata-071-bench.mjs + tools/realdata-071-table.py; README + STATUS (numbers, how to repeat); gates 325/0, 32/0, 50/0mre
  • 8081350atracker docs (mission 070): README (summary, Config HL_GC_BYTES — kept at Hybriel's default, the 256 MiB setting is taken out of docker-compose.yml again: the jobs grew to 12+ GB with it too, see STATUS), Test (three gates), Deploy (first start ~50 min: kinds then seed, restart once after collections done, memory numbers), Vendored Hybriel 8efba065 + #48 audit, Files; STATUS mission 070 entry (merges, migrated counts, lambda audit, gates, RSS old vs new, how to repeat, open points); docs/kinds.md + docs/franchises.md job order; tests/realdata-070-*.sh, tools/count-migrated.hl, tools/ref-params.py, tools/lambda-audit.pymre
  • 1ad19c8ctracker: re-vendor Hybriel master 8efba065 (#126 GC by bytes, #48 lambda parameters copy) (mission 070): bin/hybriel sha256 50361e95…, plugins core crypto data fetch fs http http1 mpackdb proc smtp time web; lambda audit: 13 lambdas change a passed record/list (11 through a local alias), no caller relies on it — unchanged; 319 read-only lambda parameters get & (no copy per call: /my/schedule 2.35 → 0.46 s, /my/unwatched 13.7 → 5.7 s on the real copy); /my/unwatched one merge sort instead of n² inserts; docker-compose HL_GC_BYTES=268435456; deploy.sh runs kinds.mjs + franchises.mjs too (default ports 8700–8710); tests/realdata-070.mjs; gates browser 325/0, kinds 32/0, franchises 50/0mre