gitoriaLog in with ident

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit8751adb88751adb8tracker: report 032mre8751adb8/project.hl

19.1 KB

  1. // project.hl — tracker.worldapi.org: THE MAP (mission 028, docs: README "Files"). Config, the routes and how the parts are wired;
  2. // what each feature does is in the file named here, not in this one.
  3. //
  4. // login (ident only, the header's selector + button) lib/users.hl, components/main.hl, login.js, /login/* below
  5. // the shell: header, main menu, user menu, sidebar components/main.hl (theme/shell/*, vendored from layouts.worldapi.org)
  6. // /genres · /people (the main menu) · /settings lib/catalog.hl genreList · lib/people.hl peoplePage · components/settings.hl
  7. // titles: records, slugs, kinds, list caches lib/shows.hl a title's page: components/show.hl
  8. // public lists /movies /series /shows /genres, home lib/catalog.hl
  9. // components/{movies,allseries,allshows,genre,home,tilelist}.hl
  10. // follows · watches · /my/* lib/follows.hl · lib/watches.hl
  11. // components/{myshows,mymovies,unwatched,schedule}.hl
  12. // search, web search, import lib/search.hl (+ search-helpers.hl) components/search.hl
  13. // people, a person's page and filmography fill lib/people.hl components/person.hl
  14. // cast + crew, the credits job lib/credits.hl (+ credits-helpers.hl)
  15. // a title completed from TMDB (details repair) lib/details.hl
  16. // TMDB / TVmaze requests, posters lib/tmdb.hl
  17. // the sync of one title · which titles a day lib/sync.hl (+ sync-helpers.hl) · lib/dailysync.hl
  18. // adult flag + kind backfills lib/backfill.hl
  19. // short ids (/<shortId>) lib/shortids.hl
  20. // franchises + timelines · TMDB collection seed lib/franchises.hl · lib/collections.hl
  21. // components/franchise*.hl, timelineedit.hl
  22. // duplicate titles merged lib/merge.hl
  23. // the background jobs and their clocks lib/jobs.hl (one instance, made below after the server)
  24. // poster + photo files lib/images.hl
  25. // shared helpers (env, paths, dates, ids, lists) lib/util.hl
  26. // styles · design tokens · the WorldAPI theme components/styles.hl · shared/tokens.hl · theme/ (never edited here)
  27. //
  28. // Config (env; no committed secret — the first deploy registers this app in ident and sets these, done by the architect, as
  29. // with ident's own .env for SMTP): TRACKER_PORT (45008), TRACKER_URL (this app's own public address, for the return URL),
  30. // IDENT_URL (https://ident.worldapi.org), TRACKER_KEY (pk_…), TRACKER_SECRET (sk_…), TRACKER_STORAGE, TRACKER_SESSIONS,
  31. // TRACKER_WATCH, TMDB_READ_TOKEN; the jobs' switches and limits: lib/jobs.hl (README "Config").
  32. import WebFramework from 'hl:web'
  33. import { Response } from 'hl:http1'
  34. import { env } from 'hl:proc'
  35. import { now } from 'hl:time'
  36. import Styles from './components/styles.hl'
  37. import Home from './components/home.hl'
  38. import LoginFailed from './components/loginfailed.hl'
  39. import Show from './components/show.hl'
  40. import Unwatched from './components/unwatched.hl'
  41. import Schedule from './components/schedule.hl'
  42. import MyShows from './components/myshows.hl'
  43. import MyMovies from './components/mymovies.hl'
  44. import Movies from './components/movies.hl'
  45. import AllShows from './components/allshows.hl'
  46. import AllSeries from './components/allseries.hl'
  47. import Search from './components/search.hl'
  48. import Person from './components/person.hl'
  49. import Genre from './components/genre.hl'
  50. import Genres from './components/genres.hl'
  51. import People from './components/people.hl'
  52. import Settings from './components/settings.hl'
  53. import Franchises from './components/franchises.hl'
  54. import Franchise from './components/franchise.hl'
  55. import FranchiseEdit from './components/franchiseedit.hl'
  56. import TimelineEdit from './components/timelineedit.hl'
  57. import { dark, darker } from './shared/tokens.hl'
  58. import { postersDir, profilesDir } from './lib/util.hl'
  59. import { loginCallbackOf } from './lib/users.hl'
  60. import { imageResponse, isSafePosterName } from './lib/images.hl'
  61. import { ensureIndex } from './lib/search.hl'
  62. import { showsMovedPath, warmTitleCaches, warmEpisodeKeys, movedSlugs, movedPathOf, personById } from './lib/shows.hl'
  63. import { allWatchedEpisodeIds } from './lib/watches.hl'
  64. import { allFollowedShowIds } from './lib/follows.hl'
  65. import { ensureShortIds, shortIdPath } from './lib/shortids.hl'
  66. import { guestPersonId, warmPeopleView, peopleViewStats } from './lib/people.hl'
  67. import { moveCopiedSummaries } from './lib/dailysync.hl'
  68. import { ensureFranchises } from './lib/franchises.hl'
  69. import Jobs from './lib/jobs.hl'
  70. static appTitle = "tracker"
  71. // ---- THE INSTALLABLE APP (tracker.worldapi.org#10), the same way calendar.worldapi.org does it: hl:web's own web app
  72. // manifest (/__hl/manifest.webmanifest, linked from every head with the apple-touch-icon and theme-color) and service
  73. // worker (/__hl/sw.js) from these settings — no JavaScript of ours. Icons in icons/ (icon.svg is the source, the PNGs
  74. // are rendered from it with rsvg-convert, README "Icons"). The theme colour is the header's background (darker), the
  75. // splash background the page's (dark) — both off the tokens, not written out again.
  76. appThemeColor = darker.value
  77. appBackgroundColor = dark.value
  78. appIcons = [
  79. { src = '/icons/icon-192.png' sizes = '192x192' purpose = 'any' }
  80. { src = '/icons/icon-512.png' sizes = '512x512' purpose = 'any' }
  81. { src = '/icons/icon-192.png' sizes = '192x192' purpose = 'maskable' }
  82. { src = '/icons/icon-512.png' sizes = '512x512' purpose = 'maskable' }
  83. ]
  84. appTouchIcon = '/icons/apple-touch-icon.png'
  85. appFavicon = '/icons/favicon.svg'
  86. // OFFLINE: only the shell — the header and `/` (components/main.hl says "You are offline" while the browser has no
  87. // network). The data pages are not kept: without a network they get hl:web's "Unavailable offline" page.
  88. offline = [ Home ]
  89. styles = Styles
  90. port = env('TRACKER_PORT') != null ? toNumber(env('TRACKER_PORT')) : 45008
  91. watching = env('TRACKER_WATCH') != '0'
  92. // read by hl:web's own manifest config (WebFramework.hl `cfg.sessionDir`), not the constructor call below
  93. sessionDir = env('TRACKER_SESSIONS') != null ? env('TRACKER_SESSIONS') : null
  94. // ---- the function routes: each checks its input, asks the topic, answers ---------------------------------------------------
  95. // /login/callback?ident_code=… (lib/users.hl): the code exchanged, this app's session signed in, back to the page (`?next=`)
  96. loginCallback = (&route, &req) => { return loginCallbackOf(server.sessions, req) }
  97. // /posters/<name>, /profiles/<name> (lib/images.hl): the file, else the placeholder
  98. posterRoute = (&route, &req) => { return imageResponse(postersDir, route.params != null ? route.params.name : null, 'poster') }
  99. profileRoute = (&route, &req) => { return imageResponse(profilesDir, route.params != null ? route.params.name : null, 'photo') }
  100. // the old addresses of the personal lists (tracker.worldapi.org#8): they all live under /my/ now — a permanent redirect so old
  101. // links keep working (architect's decision)
  102. movedTo = (&path) => { return new Response('moved to ' + path, { status = 301 headers = { 'Location' = path 'Content-Type' = 'text/plain; charset=utf-8' } }) }
  103. notFoundText = (&text) => { return new Response(text, { status = 404 headers = { 'Content-Type' = 'text/plain; charset=utf-8' } }) }
  104. unwatchedMoved = (&route, &req) => { return movedTo('/my/unwatched') }
  105. scheduleMoved = (&route, &req) => { return movedTo('/my/schedule') }
  106. // mission 058: the show page's genre pills linked `/genre/<x>` (no page there) — the genre pages are `/genres/<x>`
  107. genreMoved = (&route, &req) => {
  108. g = route.params != null ? route.params.genre : null
  109. return movedTo(isSafePosterName(g) ? '/genres/' + g : '/')
  110. }
  111. // mission 060 (tracker.worldapi.org#27): `/<shortId>` → 301 to the title's or person's page (lib/shortids.hl); upper case is
  112. // read as lower case; anything else is a 404
  113. shortIdRoute = (&route, &req) => {
  114. sid = route.params != null ? route.params.sid : null
  115. path = sid != null && hlTypeName(sid) == 'String' ? shortIdPath(sid.toLowerCase()) : null
  116. if (path == null) { return notFoundText('not found') }
  117. return movedTo(path)
  118. }
  119. // mission 062: a GUEST STAR's link (components/show.hl castRowsOf) — `/person/tmdb/<tmdbId>?show=<show id>` creates the person
  120. // (lib/people.hl guestPersonId) or finds the one we have, then 302 → `/person/<slug>`. A function route: the browser loads it
  121. // itself (hl:web's client router hands every non-component link to the browser)
  122. guestRoute = (&route, &req) => {
  123. t = route.params != null ? route.params.tmdb : null
  124. tmdbId = t != null && hlTypeName(t) == 'String' && t.length <= 10 ? toNumber(t) : null
  125. if (tmdbId == null || tmdbId < 1) { return notFoundText('not found') }
  126. q = req.query != null ? req.query : {}
  127. r = guestPersonId(tmdbId, q.show)
  128. p = r.id != null ? personById(r.id) : null
  129. if (p == null || p.urlSegment == null) { return notFoundText('not found: ' + (r.error != null ? r.error : 'no such person')) }
  130. return new Response('see /person/' + p.urlSegment, { status = 302 headers = { 'Location' = '/person/' + p.urlSegment 'Cache-Control' = 'no-store' 'Content-Type' = 'text/plain; charset=utf-8' } })
  131. }
  132. // tracker#32 (mission 031): the header's search field sends GET /find?q=<text> (the theme's AppHeader form); a page cannot read a
  133. // query string, so this answers 302 → /search/<text> ('/', '?', '#' as spaces, like components/search.hl), no text → /search
  134. findRoute = (&route, &req) => {
  135. q = req.query != null && req.query.q != null && hlTypeName(req.query.q) == 'String' ? req.query.q.replaceAll('/', ' ').replaceAll('?', ' ').replaceAll('#', ' ').trim() : ''
  136. to = q != '' ? '/search/' + encodeURIComponent(q) : '/search'
  137. return new Response('see ' + to, { status = 302 headers = { 'Location' = to 'Cache-Control' = 'no-store' 'Content-Type' = 'text/plain; charset=utf-8' } })
  138. }
  139. // /shows/<slug> (tracker.worldapi.org#21, mission 068): a series or movie (or a merged duplicate's slug) answers 301 to its page
  140. // (lib/shows.hl showsMovedPath). hl:web has no way for a component route to answer a redirect, so this is a FUNCTION route, and
  141. // for a show (or an unknown slug: the page's own "Not found") it renders the title page the way hl:web renders a component
  142. // route (WebFramework.hl `on http.request`, the `component` branch): the Show component matched at /series/<slug> — same
  143. // component, same params — with the cookie's session, a new one (and its cookie) when the browser brought none. In the browser
  144. // a link to /shows/<slug> is then a full page load; every other title page stays a client-side navigation.
  145. showsRoute = (&route, &req) => {
  146. slug = route.params != null ? route.params.slug : null
  147. to = showsMovedPath(slug)
  148. if (to != null) { return movedTo(to) }
  149. m = server.router.match('/series/' + slug)
  150. let s = req.session
  151. fresh = s == null
  152. if (fresh) { s = server.sessions.mint() }
  153. let res = server.page(m, s, server.hostOf(req.headers['host']), server.requestHeaders(req.headers))
  154. if (fresh) { res.headers['Set-Cookie'] = server.sessions.cookieHeader(s.id) }
  155. return res
  156. }
  157. // tracker#31 (mission 026): the slug of a merged duplicate, or a keeper's former slug → 301 to the keeper's page (lib/shows.hl
  158. // movedSlugs, read at boot). A component route cannot redirect, so each such slug gets its own function route under /movies/ and
  159. // /series/ (/shows/ is showsRoute). A title merged while this process runs answers the keeper's page under its old slug (shows.hl
  160. // showBySlug) until the next start.
  161. slugMoved = (&route, &req) => {
  162. to = movedPathOf(req.path)
  163. if (to == null) { return notFoundText('not found') }
  164. return movedTo(to)
  165. }
  166. routes = [
  167. { pattern = "/favicon.ico" file = "./icons/favicon.ico" headers = { 'Cache-Control' = 'no-cache' } }
  168. // the installable app (tracker.worldapi.org#10): the icons (manifest and service worker are hl:web's own, from appIcons / offline)
  169. { pattern = "/icons/icon-192.png" file = "./icons/icon-192.png" headers = { 'Cache-Control' = 'no-cache' } }
  170. { pattern = "/icons/icon-512.png" file = "./icons/icon-512.png" headers = { 'Cache-Control' = 'no-cache' } }
  171. { pattern = "/icons/apple-touch-icon.png" file = "./icons/apple-touch-icon.png" headers = { 'Cache-Control' = 'no-cache' } }
  172. { pattern = "/icons/favicon.svg" file = "./icons/favicon.svg" headers = { 'Cache-Control' = 'no-cache' } }
  173. { pattern = "/login/callback" function = loginCallback }
  174. { pattern = "/login/failed" component = LoginFailed }
  175. { pattern = "/login.js" file = "./login.js" headers = { 'Cache-Control' = 'no-cache' } }
  176. { pattern = "/posters/:name" function = posterRoute }
  177. // tracker.worldapi.org#13: every movie / every series, 24 per page — the page is a PATH segment (`/movies/page/2`), a
  178. // page component cannot read `?page=` (hybriel#11) — and the movies the user follows
  179. { pattern = "/movies" component = Movies }
  180. { pattern = "/movies/page/:page" component = Movies }
  181. // tracker.worldapi.org#21 (mission 068): series and shows split — /series lists the series, /shows the shows; a title's page
  182. // is /movies/<slug>, /series/<slug> or /shows/<slug> (one component; /shows/<slug> is showsRoute above)
  183. { pattern = "/movies/:slug" component = Show }
  184. { pattern = "/series" component = AllSeries }
  185. { pattern = "/series/page/:page" component = AllSeries }
  186. { pattern = "/series/:slug" component = Show }
  187. { pattern = "/shows" component = AllShows }
  188. { pattern = "/shows/page/:page" component = AllShows }
  189. { pattern = "/shows/:slug" function = showsRoute }
  190. { pattern = "/my/movies" component = MyMovies }
  191. { pattern = "/my/unwatched" component = Unwatched }
  192. { pattern = "/my/schedule" component = Schedule }
  193. // #21: /my/series and /my/shows (one component, components/myshows.hl; any other word there is its "Not found")
  194. { pattern = "/my/:tv" component = MyShows }
  195. { pattern = "/unwatched" function = unwatchedMoved }
  196. { pattern = "/schedule" function = scheduleMoved }
  197. // tracker.worldapi.org#14: the search — `/search/<text>` (hl:web gives a page no query string, so not `?q=`)
  198. { pattern = "/search/:q?" component = Search }
  199. { pattern = "/find" function = findRoute }
  200. // tracker.worldapi.org#16: a person's page (the show page's cast and the search link here) and their photo
  201. { pattern = "/person/tmdb/:tmdb" function = guestRoute }
  202. { pattern = "/person/:slug" component = Person }
  203. { pattern = "/profiles/:name" function = profileRoute }
  204. // mission 058 (tracker.worldapi.org#25): a genre's movies and series, like /movies (the page in the path)
  205. { pattern = "/genres/:genre" component = Genre }
  206. { pattern = "/genres/:genre/page/:page" component = Genre }
  207. { pattern = "/genre/:genre" function = genreMoved }
  208. // tracker#32 (mission 031): the main menu's Genres and People, the user menu's Settings
  209. { pattern = "/genres" component = Genres }
  210. // tracker#37 (mission 032): /people = everyone, the one updated last first, 24 per page (the page in the path, like /movies)
  211. { pattern = "/people" component = People }
  212. { pattern = "/people/page/:page" component = People }
  213. { pattern = "/settings" component = Settings }
  214. // tracker.worldapi.org#19 (mission 066): franchises and timelines, the creator's editor (`/franchises/edit` before the slug)
  215. { pattern = "/franchises" component = Franchises }
  216. { pattern = "/franchises/edit" component = FranchiseEdit }
  217. { pattern = "/franchises/:slug" component = Franchise }
  218. { pattern = "/timelines/:tslug" component = Franchise }
  219. { pattern = "/timelines/:slug/edit" component = TimelineEdit }
  220. { pattern = "/" component = Home }
  221. // mission 060 (tracker.worldapi.org#27): a short id → its page (LAST: every named one-segment route above wins)
  222. { pattern = "/:sid" function = shortIdRoute }
  223. ]
  224. // WHO GETS THE PUSH: the login state reaches the tabs of one session (components/main.hl trackerSignedIn/Out).
  225. tagOf = (&session) => { return session != null && session.data != null ? session.data.tag : null }
  226. audience = {
  227. trackerSignedIn = (tag, &session) => { return tag != null && tagOf(session) == tag }
  228. trackerSignedOut = (tag, &session) => { return tag != null && tagOf(session) == tag }
  229. }
  230. // cookies are per host, not per port: an own name keeps this app's session apart from
  231. // ident's own (and from any other worldapi app sharing a dev host), see ident README "Design
  232. // tokens" / hybriel#10 hybriel#17.
  233. sessionCookie = 'trackersid'
  234. // tracker.worldapi.org#14: the search index (lib/search.hl) is built once here at boot (~0.6 s on the real data), not by the
  235. // first search
  236. searchIndexReady = ensureIndex()
  237. // mission 060: every short id in use (one map over shows AND persons) and the records still without one, before the first request
  238. shortIdsReady = ensureShortIds()
  239. // tracker#30 (mission 025): the slim list caches (lib/shows.hl cardOf / episodeRowsOf) of every followed title, before the first
  240. // /my/ load — not filled by that load
  241. titleCachesStart = now()
  242. titleCachesWarm = warmTitleCaches(allFollowedShowIds())
  243. episodeKeysWarm = warmEpisodeKeys(allWatchedEpisodeIds())
  244. console.log('list caches: ' + titleCachesWarm + ' followed titles, ' + episodeKeysWarm + ' watched episodes in ' + (now() - titleCachesStart) + ' ms')
  245. // tracker#37 (mission 032, lib/people.hl): /people's order (everyone, the one updated last first) and the photos from the titles'
  246. // casts, before the first /people load — not built by that load
  247. peopleViewStart = now()
  248. peopleViewWarm = warmPeopleView()
  249. console.log('people view: ' + peopleViewWarm + ' people, ' + peopleViewStats().castProfiles + ' cast photos in ' + (now() - peopleViewStart) + ' ms')
  250. // tracker#18, ONCE (lib/dailysync.hl moveCopiedSummaries): a `summary` that is only the migrated copy of tmdbSummary is MOVED to
  251. // `migratedSummary` (mission 070: kept, not shown) — the current TMDB text shows; the creator's own texts stay
  252. summariesMoved = moveCopiedSummaries()
  253. if (summariesMoved.ran) { console.log('summaries: moved ' + summariesMoved.moved + ' copies of tmdbSummary to migratedSummary, kept ' + summariesMoved.kept + ' own texts, errors ' + summariesMoved.errors + ', ' + summariesMoved.ms + ' ms') }
  254. // mission 066: which timelines every title is in (one scan of the timelines), before the first show page
  255. franchisesReady = ensureFranchises()
  256. // tracker#31: the moved slugs' routes first, then `routes` as written (hl:web reads the written list for the pages it serves)
  257. movedSlugList = movedSlugs()
  258. withMovedSlugs = () => {
  259. out = []
  260. for (m of movedSlugList) {
  261. out.push({ pattern = '/movies/' + m.slug function = slugMoved })
  262. out.push({ pattern = '/series/' + m.slug function = slugMoved })
  263. }
  264. for (r of routes) { out.push(r) }
  265. return out
  266. }
  267. allRoutes = withMovedSlugs()
  268. console.log('moved slugs: ' + movedSlugList.length + ' (301 to the keeper)')
  269. server = new WebFramework(routes = allRoutes, styles = styles, port = port, sessionCookie = sessionCookie, watchMode = watching)
  270. // ---- THE BACKGROUND JOBS (lib/jobs.hl): the daily TMDB sync, the backfills, the details repair, the credits job, the duplicate
  271. // merge, the short-id backfill, the collection seed — constructing it starts their clocks and logs which ones are off
  272. jobs = new Jobs()
  273. on Error(e) { console.log('error absorbed: ' + e.message) }

Branches

Latest commits

  • 8751adb8tracker: report 032mre
  • 9bce1f65tracker mission 032: STATUS gate files + the hour-boundary flakemre
  • 718bfb89tracker#37 (mission 032): /people = everyone, last updated first (updatedAt stamped by the person fill; view built at boot, touched people first at once), photo + name tiles (person colour) with the /movies pagination, /people/<letter> removed; photo = our file, tmdbProfile, a cast/crew entry's profile (in-memory map at boot), else the new 'no photo' placeholder; new cast/crew/created_by people keep tmdbProfile; search people rows with the photo; /settings = the heading only; util.hl sortDesc starts from sorted runs (same result, 105k: 1.6 s -> 0.15 s); gates 369/0, 32/0, 52/0, check-theme 0; README/STATUS/LOGmre
  • 96ba683adeploy.sh: a gate without a 'passed,' line (check-theme) no longer ends the scriptmre
  • eb3b9205tracker: report 031mre
  • 9b5d2e89tracker mission 031: README (What it does, Test: four gates + the #32 checks, Files: theme/, new pages), STATUS (real copy, A/B load, how to repeat, open points), LOGmre
  • 39950e4ctracker#32 (mission 031): the WorldAPI theme (theme/ vendored verbatim from layouts.worldapi.org 85b5654; styles.hl inherits it: accent green-dark, type colours 1-6; own base/header rules, row lines, genre-pill and inverted-button frames removed, the season foldable keeps its line; check-theme 21 -> 0, 4th deploy gate; main actions class primary) and the #32 header (theme AppHeader/MainMenu/UserMenu/Sidebar/ContentFirst: desktop brand, search, Series|Shows|Movies|Genres|People, user icon with Unwatched..Settings, Logout; signed out the ident selector, phone the iD icon dropdown; phone menu in the sidebar overlay; marked entry by :has); /find -> /search/<q>, /genres, /people(/<letter>), /settings; main { ContentFirst { slot } } works around the hl:web one-line slot bug; gates 365/0, 32/0, 52/0, check-theme 0mre
  • a386dc92tracker: reports 029 + 030mre
  • 71e0fd7dtracker missions 029 + 030: README (What it does, Files, gate count), STATUS (real-copy numbers, how to repeat, open points), LOGmre
  • d36ea6eatracker#34 + #35 (mission 030): Follow directly under the poster, as wide as the poster (show.hl, styles.hl); the status pill next to a series' title — TVmaze's status (new tvmazeStatus, stored by the sync's TVmaze merge) else TMDB's, TVmaze Ended + TMDB Canceled = Canceled, inverted (filled, dark text, no border), green running / yellow pending / red canceled / muted ended (shows.hl statusOf); the daily delta asks TVmaze's status of an unfollowed series TVmaze's change list names (dailysync.hl syncRunStep, sync.hl syncTvmazeStatus); the status backfill after the details repair (backfill.hl, jobs.hl statusTick; resumable, 550 ms per TVmaze request); gates 354/0, 32/0, 52/0mre
  • 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