gitoriaLog in with ident

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitd924f398d924f398tracker 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`mred924f398/lib/jobs.hl

33.0 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 …). Opening one completes
  199. // it (components/show.hl); this job completes the rest in the background: at start it collects every incomplete, non-adult
  200. // title and does ONE per step on the app's clock, like the adult backfill — a step is the daily sync's work for one title
  201. // (1–3 TMDB requests + poster + TVmaze), requests queued meanwhile are served between two steps; then a pause of 260 ms per
  202. // TMDB request + 550 ms per TVmaze request (pauseMsAfter: ≤ 40 / 10 s, ≤ 20 / 10 s). RESUMES after a restart (the queue is
  203. // what is still incomplete); TMDB 404 marks the title (`detailsCheck`), a passing failure goes to the back of the queue (at
  204. // most 2 more tries per start). Waits while the daily sync or the adult backfill runs. Persisted every 10 titles + at the end.
  205. // Log: start, every TRACKER_REPAIR_LOG_EVERY (100) titles, each failure, done. TRACKER_REPAIR=0 switches it off (off too
  206. // without TMDB_READ_TOKEN). TRACKER_REPAIR_FAST=1 (the gate, fake TMDB only): 20 ms pause instead.
  207. repairOn = env('TRACKER_REPAIR') != '0' && syncEnabled
  208. repairFast = env('TRACKER_REPAIR_FAST') == '1'
  209. repairLogEvery = env('TRACKER_REPAIR_LOG_EVERY') != null ? toNumber(env('TRACKER_REPAIR_LOG_EVERY')) : 100
  210. repairQueue = null
  211. repairPos = 0
  212. repairDone = false
  213. repairAt = 0
  214. repairNextAt = 0
  215. repairTries = {}
  216. repairTotals = { titles = 0 complete = 0 failed = 0 adult = 0 newSeasons = 0 newEpisodes = 0 posters = 0 cast = 0 requests = 0 tvmazeRequests = 0 retries = 0 }
  217. repairLine = () => {
  218. b = repairTotals
  219. return b.titles + '/' + repairQueue.length + ' titles, complete=' + b.complete + ' failed=' + b.failed + ' adult=' + b.adult + ' newSeasons=' + b.newSeasons + ' newEpisodes=' + b.newEpisodes
  220. + ' posters=' + b.posters + ' cast=' + b.cast + ' requests=' + b.requests + ' tvmazeRequests=' + b.tvmazeRequests + ' retries=' + b.retries + ' seconds=' + ((now() - repairAt) / 1000)
  221. }
  222. repairTick = () => {
  223. if (repairDone) { return null }
  224. t = now()
  225. if (repairQueue == null) {
  226. repairQueue = detailsRepairQueue()
  227. repairAt = t
  228. console.log('details repair: start, ' + repairQueue.length + ' incomplete titles (' + (now() - t) + ' ms to find them)')
  229. if (repairQueue.length == 0) { repairDone = true console.log('details repair: nothing to do') }
  230. return null
  231. }
  232. if (t < repairNextAt) { return null }
  233. id = repairQueue[repairPos]
  234. r = completeStep(id)
  235. took = now() - t
  236. if (took > 1500) { console.log('details repair: slow step, show ' + id + ', ' + took + ' ms') }
  237. if (r.error != '') { console.log('details repair: ' + r.error) }
  238. repairNextAt = now() + (repairFast ? 20 : pauseMsAfter(r))
  239. // a series takes several steps: the same title again next time
  240. if (!r.done && !r.retry) { return null }
  241. repairPos = repairPos + 1
  242. if (r.retry && (repairTries[id] == null || repairTries[id] < 2)) {
  243. repairTries[id] = repairTries[id] == null ? 1 : repairTries[id] + 1
  244. q = repairQueue
  245. q.push(id)
  246. repairQueue = q
  247. repairTotals.retries = repairTotals.retries + 1
  248. } else if (!r.skipped) {
  249. // done: its counts (a failed first step: the request alone)
  250. sum = r.sum
  251. repairTotals.titles = repairTotals.titles + 1
  252. 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 }
  253. repairTotals.newSeasons = repairTotals.newSeasons + sum.newSeasons
  254. repairTotals.newEpisodes = repairTotals.newEpisodes + sum.newEpisodes
  255. repairTotals.posters = repairTotals.posters + sum.posters
  256. repairTotals.cast = repairTotals.cast + sum.cast
  257. repairTotals.requests = repairTotals.requests + (sum.steps == 0 ? r.requests : sum.requests)
  258. repairTotals.tvmazeRequests = repairTotals.tvmazeRequests + sum.tvmazeRequests
  259. }
  260. finished = repairPos >= repairQueue.length
  261. if (finished || repairPos % 10 == 0) { persistDetails() }
  262. if (!finished && !r.skipped && !r.retry && repairTotals.titles > 0 && repairTotals.titles % repairLogEvery == 0) { console.log('details repair: ' + repairLine()) }
  263. if (finished) {
  264. repairDone = true
  265. console.log('details repair done: ' + repairLine())
  266. }
  267. return null
  268. }
  269. // ---- THE KIND BACKFILL (tracker.worldapi.org#21, mission 068, backfill.hl kindTitle) ----------------------------------
  270. // Every TV title without a stored kind gets one: a title with a show genre (Reality / Talk / News) from the stored data (no
  271. // request), any other from TMDB's TV type (ONE request: GET /tv/<id>, then 260 ms pause). Starts once the adult backfill is
  272. // 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
  273. // /series to /shows at once (catalog.hl refreshCatalogShow). RESUMES after a restart (the queue = every TV title still without
  274. // a kind); a 404 stores the genres' answer + `kindCheck`; a passing failure goes to the back of the queue, at most 2 more tries
  275. // per start. Log: start, every TRACKER_KINDS_LOG_EVERY (500) titles, done. TRACKER_KINDS=0 switches it off; without
  276. // TMDB_READ_TOKEN it is off too (the lists still split by genre: shows.hl titleKind).
  277. kindsOn = env('TRACKER_KINDS') != '0' && syncEnabled
  278. kindsLogEvery = env('TRACKER_KINDS_LOG_EVERY') != null ? toNumber(env('TRACKER_KINDS_LOG_EVERY')) : 500
  279. kindQueue = null
  280. kindPos = 0
  281. kindDone = false
  282. kindAt = 0
  283. kindNextAt = 0
  284. kindTries = {}
  285. kindTotals = { titles = 0 series = 0 shows = 0 fromGenre = 0 moved = 0 requests = 0 errors = 0 retries = 0 }
  286. kindLine = () => {
  287. k = kindTotals
  288. return k.titles + '/' + kindQueue.length + ' titles, series=' + k.series + ' shows=' + k.shows + ' fromGenre=' + k.fromGenre + ' moved=' + k.moved
  289. + ' requests=' + k.requests + ' errors=' + k.errors + ' retries=' + k.retries + ' seconds=' + ((now() - kindAt) / 1000)
  290. }
  291. kindTick = () => {
  292. if (kindDone) { return null }
  293. t = now()
  294. if (kindQueue == null) {
  295. kindQueue = kindBackfillQueue()
  296. kindAt = t
  297. console.log('kind backfill: start, ' + kindQueue.length + ' TV titles without a kind (' + (now() - t) + ' ms to find them)')
  298. if (kindQueue.length == 0) { kindDone = true console.log('kind backfill: nothing to do') }
  299. return null
  300. }
  301. if (t < kindNextAt) { return null }
  302. id = kindQueue[kindPos]
  303. kindPos = kindPos + 1
  304. r = kindTitle(id)
  305. if (r.retry && (kindTries[id] == null || kindTries[id] < 2)) {
  306. kindTries[id] = kindTries[id] == null ? 1 : kindTries[id] + 1
  307. q = kindQueue
  308. q.push(id)
  309. kindQueue = q
  310. kindTotals.retries = kindTotals.retries + 1
  311. } else {
  312. kindTotals.titles = kindTotals.titles + 1
  313. if (r.kind == 'show') { kindTotals.shows = kindTotals.shows + 1 } else if (r.kind == 'series') { kindTotals.series = kindTotals.series + 1 }
  314. if (r.fromGenre) { kindTotals.fromGenre = kindTotals.fromGenre + 1 }
  315. }
  316. kindTotals.requests = kindTotals.requests + r.requests
  317. kindTotals.errors = kindTotals.errors + r.errors
  318. if (r.error != '') { console.log('kind backfill: ' + r.error) }
  319. // until now the genres decided (no show genre = series): only a title TMDB's type makes a SHOW changes its list
  320. if (r.kind == 'show' && !r.fromGenre) {
  321. refreshCatalogShow(id)
  322. kindTotals.moved = kindTotals.moved + 1
  323. }
  324. took = now() - t
  325. if (took > 1500) { console.log('kind backfill: slow step, show ' + id + ', ' + took + ' ms') }
  326. kindNextAt = now() + r.requests * msPerRequest
  327. finished = kindPos >= kindQueue.length
  328. if (finished || kindPos % 25 == 0) { persistSync() }
  329. if (!finished && kindTotals.titles > 0 && kindTotals.titles % kindsLogEvery == 0 && !r.retry) { console.log('kind backfill: ' + kindLine()) }
  330. if (finished) {
  331. kindDone = true
  332. console.log('kind backfill done: ' + kindLine())
  333. }
  334. return null
  335. }
  336. // ---- THE CREDITS JOB (tracker.worldapi.org#28, credits.hl creditsStep) ------------------------------------------------------
  337. // Every PUBLIC title (adult == false; adult/unknown are skipped) with a TMDB id gets its whole cast + crew once: at start (after
  338. // the adult backfill and the details repair are done) the job collects every such title without `creditsAt` and asks ONE per
  339. // step on the app's clock — one request (details + credits / aggregate_credits), then 260 ms (≤ 40 / 10 s); requests queued
  340. // meanwhile are served between two steps. Titles the details repair, the daily sync or an import already did carry `creditsAt`
  341. // and are not asked. RESUMES after a restart (the queue = what still has no credits); TMDB 404 / adult → `creditsCheck`, never
  342. // asked again; a passing failure goes to the back of the queue (at most 2 more tries per start). Waits while the daily sync
  343. // runs. Persisted (shows + people only) every 25 titles + at the end. Log: start, every TRACKER_CREDITS_LOG_EVERY (500) titles, failures, slow steps
  344. // (> 1.5 s), done. TRACKER_CREDITS=0 switches it off (off too without TMDB_READ_TOKEN). TRACKER_CREDITS_FAST=1 (the gate, fake
  345. // TMDB only): 20 ms pause instead.
  346. // MEMORY LIMIT: the runtime never frees what a fetch + JSON parse took (mission 061 measured ~6 MB more RSS per title on the real
  347. // 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
  348. // step the job reads its own RSS (/proc/self/status); above TRACKER_CREDITS_MAX_MB (16000) it PAUSES for this process (logged) and
  349. // goes on with what is left after the next restart (deploy, `docker restart`).
  350. creditsOn = env('TRACKER_CREDITS') != '0' && syncEnabled
  351. creditsFast = env('TRACKER_CREDITS_FAST') == '1'
  352. creditsLogEvery = env('TRACKER_CREDITS_LOG_EVERY') != null ? toNumber(env('TRACKER_CREDITS_LOG_EVERY')) : 500
  353. creditsQueueIds = null
  354. creditsPos = 0
  355. creditsDone = false
  356. creditsAt = 0
  357. creditsNextAt = 0
  358. creditsTries = {}
  359. creditsMaxMb = env('TRACKER_CREDITS_MAX_MB') != null ? toNumber(env('TRACKER_CREDITS_MAX_MB')) : 16000
  360. creditsTotals = { titles = 0 done = 0 failed = 0 cast = 0 crew = 0 people = 0 requests = 0 retries = 0 slowest = 0 }
  361. // this process' resident memory in MB (VmRSS), 0 when unknown
  362. rssMb = () => {
  363. if (!exists('/proc/self/status')) { return 0 }
  364. t = readFile('/proc/self/status')
  365. i = t != null ? t.indexOf('VmRSS:') : -1
  366. if (i < 0) { return 0 }
  367. kb = toNumber(t.slice(i + 6, t.indexOf('kB', i)).trim())
  368. return kb != null ? (kb - kb % 1024) / 1024 : 0
  369. }
  370. creditsLine = () => {
  371. b = creditsTotals
  372. return b.titles + '/' + creditsQueueIds.length + ' titles, done=' + b.done + ' failed=' + b.failed + ' cast=' + b.cast + ' crew=' + b.crew + ' people=' + b.people
  373. + ' requests=' + b.requests + ' retries=' + b.retries + ' slowestStepMs=' + b.slowest + ' seconds=' + ((now() - creditsAt) / 1000)
  374. }
  375. creditsTick = () => {
  376. if (creditsDone) { return null }
  377. t = now()
  378. if (creditsQueueIds == null) {
  379. creditsQueueIds = creditsQueue()
  380. creditsAt = t
  381. console.log('credits job: start, ' + creditsQueueIds.length + ' titles without credits (' + (now() - t) + ' ms to find them)')
  382. if (creditsQueueIds.length == 0) { creditsDone = true console.log('credits job: nothing to do') }
  383. return null
  384. }
  385. if (t < creditsNextAt) { return null }
  386. mb = rssMb()
  387. if (mb > creditsMaxMb) {
  388. creditsDone = true
  389. persistCredits()
  390. console.log('credits job: paused, RSS ' + mb + ' MB > TRACKER_CREDITS_MAX_MB ' + creditsMaxMb + ' — ' + (creditsQueueIds.length - creditsPos) + ' titles left for the next start; ' + creditsLine())
  391. return null
  392. }
  393. id = creditsQueueIds[creditsPos]
  394. creditsPos = creditsPos + 1
  395. r = creditsStep(id)
  396. took = now() - t
  397. if (took > creditsTotals.slowest) { creditsTotals.slowest = took }
  398. if (took > 1500) { console.log('credits job: slow step, show ' + id + ', ' + took + ' ms, cast=' + r.cast + ' crew=' + r.crew + ' people=' + r.people) }
  399. if (r.error != '') { console.log('credits job: ' + r.error) }
  400. creditsNextAt = now() + (creditsFast ? 20 : r.requests * msPerRequest)
  401. if (r.retry && (creditsTries[id] == null || creditsTries[id] < 2)) {
  402. creditsTries[id] = creditsTries[id] == null ? 1 : creditsTries[id] + 1
  403. q = creditsQueueIds
  404. q.push(id)
  405. creditsQueueIds = q
  406. creditsTotals.retries = creditsTotals.retries + 1
  407. } else if (!r.skipped) {
  408. creditsTotals.titles = creditsTotals.titles + 1
  409. if (r.error != '') { creditsTotals.failed = creditsTotals.failed + 1 } else { creditsTotals.done = creditsTotals.done + 1 }
  410. creditsTotals.cast = creditsTotals.cast + r.cast
  411. creditsTotals.crew = creditsTotals.crew + r.crew
  412. creditsTotals.people = creditsTotals.people + r.people
  413. }
  414. creditsTotals.requests = creditsTotals.requests + r.requests
  415. finished = creditsPos >= creditsQueueIds.length
  416. if (finished || creditsPos % 25 == 0) { persistCredits() }
  417. if (!finished && !r.skipped && !r.retry && creditsTotals.titles > 0 && creditsTotals.titles % creditsLogEvery == 0) { console.log('credits job: ' + creditsLine()) }
  418. if (finished) {
  419. creditsDone = true
  420. console.log('credits job done: ' + creditsLine())
  421. }
  422. return null
  423. }
  424. // ---- THE DUPLICATE MERGE (tracker.worldapi.org#31, mission 026, merge.hl) ----------------------------------------------------
  425. // The old tracker's duplicate titles (same type + TMDB id) become ONE record each — follows, watches, seasons, cast, credits and
  426. // timelines moved to the keeper, the others kept as tombstones whose slug and short id lead to it — and seasons that name a title
  427. // 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
  428. // item per tick (a duplicate group, or one title's stray seasons; no TMDB), so pages are served between two items. The TMDB jobs
  429. // below (daily sync, backfills, repair, credits, collections) wait until it is done: none of them works on a record that is about
  430. // to become a tombstone. RESUMES after a restart (the queue = what is still duplicated / stray). Persisted every 10 items and at
  431. // the end. Log: start, one line per tombstone / repaired title, done; with nothing to do one line. TRACKER_MERGE=0 switches it off.
  432. mergeOn = env('TRACKER_MERGE') != '0'
  433. mergeRun = { started = false done = !mergeOn at = 0 items = 0 slowest = 0 }
  434. mergeTick = () => {
  435. if (mergeRun.done) { return null }
  436. t = now()
  437. if (!mergeRun.started) {
  438. mergeRun.started = true
  439. mergeRun.at = t
  440. n = mergePrepare()
  441. st = mergeStats()
  442. console.log('merge: start, ' + st.groups + ' duplicate groups (' + st.records + ' records), ' + st.strayTitles + ' titles with stray seasons (' + st.ms + ' ms to find them)')
  443. if (n == 0) {
  444. mergeRun.done = true
  445. console.log('merge: nothing to do')
  446. }
  447. return null
  448. }
  449. r = mergeStep()
  450. mergeRun.items = mergeRun.items + 1
  451. took = now() - t
  452. if (took > mergeRun.slowest) { mergeRun.slowest = took }
  453. if (took > 1500) { console.log('merge: slow step, ' + took + ' ms') }
  454. if (r.done || mergeRun.items % 10 == 0) { persistMerge() }
  455. if (r.done) {
  456. mergeRun.done = true
  457. console.log('merge done: ' + mergeLine() + ' items=' + mergeRun.items + ' slowestStepMs=' + mergeRun.slowest + ' seconds=' + ((now() - mergeRun.at) / 1000))
  458. }
  459. return null
  460. }
  461. if (!mergeOn) { console.log('merge: off (TRACKER_MERGE=0)') }
  462. else {
  463. mergeClock = every(0.1)
  464. on mergeClock.tick(x) {
  465. mergeTick()
  466. return null
  467. }
  468. }
  469. // 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
  470. // between, only while no daily run is going on; the details repair only when neither has work; then the kind backfill (#21);
  471. // the credits job (#28) last
  472. clockOn = syncOn || backfillOn || repairOn || kindsOn || creditsOn
  473. clockTicks = 0
  474. 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') + ')') }
  475. if (!backfillOn) { console.log('adult backfill: off (' + (syncEnabled ? 'TRACKER_BACKFILL=0' : 'no TMDB_READ_TOKEN') + ')') }
  476. if (!repairOn) { console.log('details repair: off (' + (syncEnabled ? 'TRACKER_REPAIR=0' : 'no TMDB_READ_TOKEN') + ')') }
  477. if (!creditsOn) { console.log('credits job: off (' + (syncEnabled ? 'TRACKER_CREDITS=0' : 'no TMDB_READ_TOKEN') + ')') }
  478. if (!kindsOn) { console.log('kind backfill: off (' + (syncEnabled ? 'TRACKER_KINDS=0' : 'no TMDB_READ_TOKEN') + ')') }
  479. if (clockOn) {
  480. syncClock = every(0.1)
  481. on syncClock.tick(x) {
  482. clockTicks = clockTicks + 1
  483. // tracker#31: not before the duplicate merge is done
  484. if (!mergeRun.done) { return null }
  485. busy = syncQueue.length > 0 || syncPlanning
  486. if (syncOn && clockTicks % 10 == 0) { syncTick() }
  487. free = !busy && syncQueue.length == 0 && !syncPlanning
  488. if (backfillOn && free && !backfillDone) { backfillTick() }
  489. else if (repairOn && free && (!backfillOn || backfillDone) && !repairDone) { repairTick() }
  490. else if (kindsOn && free && (!backfillOn || backfillDone) && (!repairOn || repairDone) && !kindDone) { kindTick() }
  491. else if (creditsOn && free && (!backfillOn || backfillDone) && (!repairOn || repairDone) && (!kindsOn || kindDone)) { creditsTick() }
  492. return null
  493. }
  494. }
  495. // ---- THE SHORT-ID BACKFILL (mission 060, tracker.worldapi.org#27, shortids.hl shortIdStep) ----------------------------
  496. // 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,
  497. // as many records as fit into TRACKER_SHORTID_BUDGET_MS (default 40 ms) — no TMDB, only the tables — so a page waits at
  498. // most one batch. The queue is built at start (`ensureShortIds`) from what is still missing = it resumes after a restart.
  499. // Persisted every 20 batches and at the end. Log: start, every TRACKER_SHORTID_LOG_EVERY (5000) records, done; with nothing
  500. // to do one line. TRACKER_SHORTIDS=0 switches it off (the gate's resume check).
  501. shortIdOn = env('TRACKER_SHORTIDS') != '0'
  502. shortIdBudget = env('TRACKER_SHORTID_BUDGET_MS') != null ? toNumber(env('TRACKER_SHORTID_BUDGET_MS')) : 40
  503. shortIdLogEvery = env('TRACKER_SHORTID_LOG_EVERY') != null ? toNumber(env('TRACKER_SHORTID_LOG_EVERY')) : 5000
  504. shortIdRun = { at = 0 batches = 0 assigned = 0 nextLog = 0 slowest = 0 slowestPersist = 0 done = false }
  505. shortIdTick = () => {
  506. if (shortIdRun.done) { return null }
  507. t = now()
  508. r = shortIdStep(shortIdBudget)
  509. took = now() - t
  510. shortIdRun.batches = shortIdRun.batches + 1
  511. shortIdRun.assigned = shortIdRun.assigned + r.assigned
  512. if (took > shortIdRun.slowest) { shortIdRun.slowest = took }
  513. if (r.done || shortIdRun.batches % 20 == 0) {
  514. tp = now()
  515. persistShortIds()
  516. if (now() - tp > shortIdRun.slowestPersist) { shortIdRun.slowestPersist = now() - tp }
  517. }
  518. if (!r.done && shortIdRun.assigned >= shortIdRun.nextLog) {
  519. console.log('short ids: ' + shortIdRun.assigned + ' assigned, ' + r.left + ' left, ' + ((now() - shortIdRun.at) / 1000) + ' s')
  520. shortIdRun.nextLog = shortIdRun.nextLog + shortIdLogEvery
  521. }
  522. if (r.done) {
  523. shortIdRun.done = true
  524. s = shortIdStats()
  525. 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))
  526. }
  527. return null
  528. }
  529. if (!shortIdOn) { console.log('short ids: backfill off (TRACKER_SHORTIDS=0), ' + shortIdsLeft() + ' records without one') }
  530. else if (shortIdsLeft() == 0) { console.log('short ids: nothing to do') }
  531. else {
  532. shortIdRun.at = now()
  533. shortIdRun.nextLog = shortIdLogEvery
  534. console.log('short ids: backfill start, ' + shortIdsLeft() + ' records, ' + shortIdBudget + ' ms per batch')
  535. shortIdClock = every(0.1)
  536. on shortIdClock.tick(x) {
  537. shortIdTick()
  538. return null
  539. }
  540. }
  541. // ---- THE COLLECTION SEED (mission 066, tracker.worldapi.org#19, collections.hl seedStep) ------------------------------------
  542. // TMDB's movie collections become timelines: ONE movie per step (its details; once per collection the collection's parts), on
  543. // 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
  544. // sync or the adult backfill runs (they share TMDB's limit and the backfill brings the adult flags it skips by); since the merge
  545. // (mission 070) also until the details repair, the kind backfill and the credits job are done (or paused) — the LAST job. The queue =
  546. // every non-adult movie without a check row, so it RESUMES after a restart and does nothing once all are checked. Persisted
  547. // every TRACKER_COLLECTIONS_PERSIST_EVERY (25) steps and at the end. Log: start, every TRACKER_COLLECTIONS_LOG_EVERY (500) movies, done.
  548. // TRACKER_COLLECTIONS=0 switches it off; without TMDB_READ_TOKEN it is off too.
  549. collectionsOn = env('TRACKER_COLLECTIONS') != '0' && syncEnabled
  550. collectionsLogEvery = env('TRACKER_COLLECTIONS_LOG_EVERY') != null ? toNumber(env('TRACKER_COLLECTIONS_LOG_EVERY')) : 500
  551. collectionsPersistEvery = env('TRACKER_COLLECTIONS_PERSIST_EVERY') != null ? toNumber(env('TRACKER_COLLECTIONS_PERSIST_EVERY')) : 25
  552. collectionRun = { at = 0 steps = 0 nextAt = 0 done = false started = false slowest = 0 }
  553. collectionTick = () => {
  554. if (collectionRun.done) { return null }
  555. // mission 070 (merge): also behind the details repair, the kind backfill and the credits job — one TMDB pacing at a time
  556. if (!mergeRun.done || syncQueue.length > 0 || syncPlanning || (backfillOn && !backfillDone) || (repairOn && !repairDone) || (kindsOn && !kindDone) || (creditsOn && !creditsDone)) { return null }
  557. t = now()
  558. if (!collectionRun.started) {
  559. collectionRun.started = true
  560. collectionRun.at = t
  561. n = seedPrepare()
  562. console.log('collections: start, ' + n + ' movies to check (' + (now() - t) + ' ms to find them)')
  563. if (n == 0) { collectionRun.done = true console.log('collections: nothing to do') }
  564. return null
  565. }
  566. if (t < collectionRun.nextAt) { return null }
  567. r = seedStep()
  568. if (r.done) {
  569. collectionRun.done = true
  570. seedPersist()
  571. console.log('collections done: ' + seedLine() + ' seconds=' + ((now() - collectionRun.at) / 1000) + ' slowestStepMs=' + collectionRun.slowest)
  572. return null
  573. }
  574. collectionRun.steps = collectionRun.steps + 1
  575. took = now() - t
  576. if (took > collectionRun.slowest) { collectionRun.slowest = took }
  577. if (r.error != '') { console.log('collections: ' + r.error) }
  578. if (took > 1500) { console.log('collections: slow step, ' + took + ' ms') }
  579. collectionRun.nextAt = now() + r.requests * msPerRequest
  580. if (collectionRun.steps % collectionsPersistEvery == 0) { seedPersist() }
  581. if (collectionRun.steps % collectionsLogEvery == 0) { console.log('collections: ' + seedLine() + ' seconds=' + ((now() - collectionRun.at) / 1000)) }
  582. return null
  583. }
  584. if (!collectionsOn) { console.log('collections: off (' + (syncEnabled ? 'TRACKER_COLLECTIONS=0' : 'no TMDB_READ_TOKEN') + ')') }
  585. else {
  586. collectionClock = every(0.1)
  587. on collectionClock.tick(x) {
  588. collectionTick()
  589. return null
  590. }
  591. }

Branches

Latest commits

  • 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
  • 46b21389tracker (mission 070, conductor): the sync never destroys migrated data — the one-time summary step MOVES a copied summary to migratedSummary (marker summaries-moved.txt) instead of clearing it; a migrated record's first title/genres/homepage/tagline TMDB replaces → migratedTitle/migratedGenres/migratedHomepage/migratedTagline, a migrated season's/episode's title/summary → migratedTitle/migratedSummary (set once); tests/peek-shows.hl prints them; gate 325/0mre
  • 749019b0Merge t19 (tracker#19 franchises + timelines) into main (mission 070): conflicts README/STATUS/show.hl/project.hl/browser.mjs/faketmdb.mjs, both sides kept; franchise/timeline pages get #20's typed heading (Franchise | …, Timeline | …), their title links via titlePath (/movies|/series|/shows); the collection seed waits for repair, kinds and credits too; franchises.mjs URLs + 2 new checks; gates browser 323/0, kinds 32/0, franchises 50/0mre
  • daf49feaMerge t20 (tracker#20 typed headings + #21 series/shows split) into main (mission 070): conflicts README/STATUS/show.hl/project.hl/search.hl/components/search.hl/browser.mjs/faketmdb.mjs, both sides kept; clock order backfill → repair → kinds → credits; withDetailsFields stores tmdbType + kind; gates: browser.mjs URLs → /series|/movies, typed h1 selectors; kinds.mjs repair/credits off, fixture name = seed name; browser 323/0, kinds 32/0mre