tracker
All repositories: gitoria
13.3 KB
// hl:core/AST — WHAT A FILE READS AND WHAT IT WRITES, from the compiler's own AST.//// The language has always been able to hand a caller the SYNTAX of a node// (`hlSyntax`) and the list of members a file declares (`hlMembers`). What it// never answered is what that syntax DOES with names: which members an// expression reads, which members a handler writes. Every consumer that needed// it wrote its own walk — hl:web's tree builder decides per tag what counts as// a read, and its browser half rediscovers the same set at runtime by walking// the DOM against the tree and JSON-comparing state afterwards (FRAMEWORK_AUDIT// §3). Two copies of one answer drift, and neither could see a write at all.//// The answer is the language's, so it lives here. `query(file)` is a table of// one file's (and, recursively, its project's) members, derivations, handlers// and methods, each with the names it reads and the names it writes, every node// carrying a stable site id `file:line:col`.//// NOTHING HERE KNOWS WHAT A VIEW IS. There is no attr, text, region, key or// component vocabulary in this file and none in the runtime rule beneath it: a// member is a member. A caller that wants one member's answer — hl:web wants// `View`'s — passes that member's NAME as the filter. That is the only way to// narrow the query, and it is a name, not a concept.//// import { query } from 'hl:core/AST'// let q = query('components/home.hl') // recursive, every member// let v = query('components/home.hl', true, 'View')//// THE GENERATION. Reflection reads a parse that is valid until the next// analysis; this package runs one of its own (`hlProject()`) the first time it// is asked and keeps the handle. `refresh()` runs a new one — a dev reload, or// a caller that changed a file. A static cannot be reassigned, so the handle// lives in a static hybrid, which can.static state = { gen = 0; graph = null; }// The live analysis generation, started on first use.static analysis = () => {if (state.gen == 0) {let g = hlProject()state.graph = gstate.gen = g.analysisGen}return state.gen}// A NEW ANALYSIS: the parses this package answers from are replaced, and every// handle a caller still holds from the old one is refused by the language.static refresh = () => {let g = hlProject()state.graph = gstate.gen = g.analysisGenreturn state.gen}// …of a project this run did not boot: a directory, a manifest, or an entry// file. The keys every answer below is filed under are that project's.static analyseFrom = (path) => {let g = hlProject(path)state.graph = gstate.gen = g.analysisGenreturn state.gen}// The project graph the generation belongs to (`hlProject()`'s answer).static project = () => {analysis()return state.graph}// ---- the reflection surface, without the generation argument ------------------// `hlSyntax` and `hlMembers` are the ambient names the framework still calls;// here they are statics of a package, which is where they belong.static syntax = (file, node) => { return hlSyntax(analysis(), file, node) }static members = (file) => { return hlMembers(analysis(), file) }static methods = (file) => { return hlMethods(analysis(), file) }static handlers = (file) => { return hlEvents(analysis(), file).handles }static denotes = (file, name) => { return hlDenotes(analysis(), file, name) }static file = (file) => { return hlFile(analysis(), file) }// ---- the syntax of one node, as a tree ----------------------------------------// Every node carries its tag, its site id and the two answers the language gives// for it: the free names it READS and the names it WRITES. The shape below is// the shape `hlSyntax` returns, followed one child at a time — there is no// interpretation of any tag, only its children.//// AN `on` HANDLER IS A LEAF HERE ON PURPOSE. Its body is not evaluated by the// literal that carries it, so the names inside are the HANDLER's reads and// writes, not the literal's; the node answers for them and the walk stops.static tree = (file, node) => {let n = hlSyntax(analysis(), file, node)if (n == null) { return null }let out = { tag = n.tag; site = n.site; line = n.line; col = n.col; reads = n.reads; writes = n.writes; }if (n.tag == 'object_expression') {let kids = []for (h of n.entries) { kids.push(tree(file, h)) }out.entries = kids} else if (n.tag == 'object_property') {out.key = n.keyout.value = tree(file, n.value)} else if (n.tag == 'view_for') {// A `for` ENTRY NAMES ITS LIST AND ITS ROW VARIABLE. The list is read in// the scope standing around the `for`; the row variable is bound inside// the body and every read of it there resolves as kind 'row'.out.row = n.varNameout.list = tree(file, n.list)out.body = tree(file, n.body)} else if (n.tag == 'view_if') {out.condition = tree(file, n.condition)out.consequent = tree(file, n.consequent)out.alternate = tree(file, n.alternate)} else if (n.tag == 'on_statement') {out.event = n.eventout.scope = n.scopeout.realm = n.realmout.handler = n.handler} else if (n.tag == 'identifier' || n.tag == 'new_expression') {out.name = n.name} else if (n.tag == 'literal') {out.kind = n.kindout.text = n.text} else if (n.tag == 'member_expression') {out.object = tree(file, n.object)out.property = tree(file, n.property)out.computed = n.computed} else if (n.tag == 'call_expression') {out.callee = tree(file, n.callee)let args = []for (h of n.args) { args.push(tree(file, h)) }out.args = args} else if (n.tag == 'binary_expression') {out.operator = n.operatorout.left = tree(file, n.left)out.right = tree(file, n.right)} else if (n.tag == 'unary_expression') {out.operator = n.operatorout.operand = tree(file, n.operand)} else if (n.tag == 'conditional_expression') {out.condition = tree(file, n.condition)out.consequent = tree(file, n.consequent)out.alternate = tree(file, n.alternate)} else if (n.tag == 'array_expression') {let els = []for (h of n.elements) { els.push(tree(file, h)) }out.elements = els}return out}// ---- names ---------------------------------------------------------------------// A read or a write is `{ name, kind, isStatic, path?, key? }`. `kind` is the// language's own resolution of the bare name: 'member', 'method', 'handler',// 'class' (a default import), 'import' (a braced one), 'plugin', 'row' (bound by// an enclosing `for` entry), 'local' (a lambda, handler or method parameter, or// a `let`), 'none' (nothing this file declares — an ambient or a typo).// the names of a read/write list, as plain stringsstatic namesOf = (list) => {let out = []for (r of list) { if (!out.includes(r.name)) { out.push(r.name) } }return out}// the subset of a read/write list that resolves to a member of the file itselfstatic membersOf = (list) => {let out = []for (r of list) {if (r.kind == 'member' && !r.isStatic && !out.includes(r.name)) { out.push(r.name) }}return out}// ---- one file's answer ---------------------------------------------------------// every `on` node inside a member's syntax tree, flattened, each at its sitestatic nestedHandlers = (member, node, &into) => {if (node == null) { return into }if (node.tag == 'on_statement') {into.push({ member = member; event = node.event; scope = node.scope; realm = node.realm; site = node.site; reads = node.reads; writes = node.writes; nested = true; })return into}if (node.entries != null) { for (c of node.entries) { nestedHandlers(member, c, into) } }if (node.args != null) { for (c of node.args) { nestedHandlers(member, c, into) } }if (node.elements != null) { for (c of node.elements) { nestedHandlers(member, c, into) } }if (node.value != null) { nestedHandlers(member, node.value, into) }if (node.list != null) { nestedHandlers(member, node.list, into) }if (node.body != null) { nestedHandlers(member, node.body, into) }if (node.condition != null) { nestedHandlers(member, node.condition, into) }if (node.consequent != null) { nestedHandlers(member, node.consequent, into) }if (node.alternate != null) { nestedHandlers(member, node.alternate, into) }if (node.object != null) { nestedHandlers(member, node.object, into) }if (node.property != null) { nestedHandlers(member, node.property, into) }if (node.callee != null) { nestedHandlers(member, node.callee, into) }if (node.left != null) { nestedHandlers(member, node.left, into) }if (node.right != null) { nestedHandlers(member, node.right, into) }if (node.operand != null) { nestedHandlers(member, node.operand, into) }return into}static one = (key, member) => {let gen = analysis()let f = hlFile(gen, key)let out = { key = key; class = f.class; members = []; derivations = []; handlers = []; methods = []; reaches = []; }for (m of hlMembers(gen, key)) {// (Hybriel has no `continue`: the body is guarded instead.)if (member == null || m.name == member) {let entry = { name = m.name; type = m.type; mandatory = m.mandatory; isStatic = m.isStatic; site = key + ':' + m.line + ':' + m.col; default = null; reads = []; writes = []; syntax = null; }if (m.hasValue) {let n = hlSyntax(gen, key, m.node)entry.default = n.siteentry.reads = n.readsentry.writes = n.writesentry.syntax = tree(key, m.node)// A DERIVATION IS AN INITIALIZER READ THE OTHER WAY: the same table,// listed by the names the value depends on.out.derivations.push({ name = m.name; site = n.site; reads = n.reads; })nestedHandlers(m.name, entry.syntax, out.handlers)for (r of n.reads) {if (r.kind == 'class' && r.key != null && !out.reaches.includes(r.key)) { out.reaches.push(r.key) }}}out.members.push(entry)}}// The DECLARED handlers and methods answer for their whole body. A member// filter narrows the member table only — a handler is not a member, and// hiding the writes would make the filtered answer a lie about the file.for (h of hlEvents(gen, key).handles) {let n = hlSyntax(gen, key, h.node)out.handlers.push({ member = null; event = h.event; scope = h.scope; realm = h.realm; params = h.params; site = n.site; reads = n.reads; writes = n.writes; nested = false; })}for (mm of hlMethods(gen, key)) {// A literal's inline `on` is hoisted as a method over the SAME body// (parser `inlineHandlerEntry`); it already answered at its site above.if (!mm.inlineHandler) {let n = hlSyntax(gen, key, mm.node)out.methods.push({ name = mm.name; params = mm.params; site = n.site; reads = n.reads; writes = n.writes; })}}// WHAT THIS FILE REACHES: every import the language resolved to another file// of the project, and every composed reference a member's syntax read.if (state.graph.files[key] != null) {for (imp of state.graph.files[key].imports) {if (imp.key != null && !out.reaches.includes(imp.key)) { out.reaches.push(imp.key) }}}if (f.wrapper != null && !out.reaches.includes(f.wrapper)) { out.reaches.push(f.wrapper) }for (k of f.inherits) { if (!out.reaches.includes(k)) { out.reaches.push(k) } }return out}// ---- the query -----------------------------------------------------------------// `query(file, recursive = true, member = null)`:// files — one answer per file reached, keyed by the analysis key// order — the keys in the order they were reached, `file` first// Recursive follows what each file reaches (its imports, its wrapper, what it// inherits, and the composed references its members read), each file once.static query = (file, recursive, member) => {let rec = recursive == null ? true : recursivelet want = member == null ? null : memberanalysis()let out = { root = file; files = {}; order = []; }let queue = [file]let seen = {}while (queue.length > 0) {let key = queue.shift()if (seen[key] == null) {seen[key] = true// A key the analysis does not hold is not this package's to parse —// the root is answered regardless, because the caller named it.if (state.graph.files[key] != null || key == file) {let answer = one(key, want)out.files[key] = answerout.order.push(key)if (rec) {for (k of answer.reaches) { if (seen[k] == null) { queue.push(k) } }}}}}return out}// EVERY FILE THE ANALYSIS HOLDS, once. A project's root reaches nearly all of// them; this reaches the rest too, which is what a whole-project report wants.static queryAll = (member) => {analysis()let out = { root = null; files = {}; order = []; }for (k of state.graph.files.keys()) {out.files[k] = one(k, member)out.order.push(k)}return out}// ---- what `hybriel --graph` carries, per file -----------------------------------// THE ONE DOCUMENT ASKS THIS PACKAGE (creator, 2026-09-14: the language scans// EVERYTHING by default and a filter only narrows). `--graph` prints the// language graph, and every file record in it carries the four tables below —// the same objects `query()` puts in `files[key]`, handed to the writer as they// are. There is no second walk and no second rendering: a person reads that// JSON, and a program imports `query` and gets the same answer as values.static tables = (path, member) => {if (path == null) { analysis() } else { analyseFrom(path) }let q = queryAll(member)let out = {}for (k of q.order) {let f = q.files[k]out[k] = { members = f.members; derivations = f.derivations; methods = f.methods; handlers = f.handlers; }}return out}
Branches
- mainmain branch
Latest commits
- 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
- 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