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
- 1ed5457etracker#20 + #21 (mission 068): typed headings "<Type> | <name>" in type colours; TV titles split into Series (/series) and Shows (/shows) by TMDB type + Reality/Talk/News genres — kind stored by sync/import/adult backfill + new kind backfill (resumes), /movies/<slug>, /shows/<slug> of a series/movie → 301, /my/series + /my/shows, home 5 tiles + 3 rows, search/filmography labels; gates kinds 32 + browser 266, tests/realdata-068.mjs, tools/count-kinds.hl, docs/kinds.md, README + STATUSmre
- fa1f9dfatracker#29 (mission 063): unwatched check muted grey outline + check (accent only on hover), watched stays solid — no code regression, the accent outline read as ticked; gate checks real checks visibly (computed style + screenshot pixel) on /my/unwatched, show, movie, /my/movies; gate 266, tests/realdata-063.mjs, README + STATUSmre
- d8b12d67tracker#27 (mission 060): short ids for movies, series and persons — old 702 kept (data/old-short-ids.json), new random [a-z0-9]{5} unique across both, claimed at creation, background backfill (resumes), shown under poster/photo, /<shortId> → 301; gate 259, tests/realdata-060*, README + STATUSmre
- f14db671tracker#22-#25 (mission 058): episode air dates, season check = all episodes watched, movie watched check (+ /my/movies count), /genres/<genre> pages (movies + series, newest first, paginated); gate 238, tests/realdata-058.mjs, README + STATUSmre
- 1704ec45tracker#17 (mission 057): season caret down/up, skeleton rows while a season loads, sessionless showSeasonEpisodes face (no page re-mount), client-only close; gate 214, tests/realdata-057.mjs, README + STATUSmre
- f2fe3e36mission 056: README + STATUS (merge, fixes, Hybriel 8590df63, real-data check), tests/realdata-056.mjs, tools/check-public-slugs.hlmre
- f40c250emission 056: re-vendor hybriel master 8590df63 (#121, #122); an adult title's page is Not found for non-followers; gate: leave the page before stopping the servermre
- 2b7fdd6cmission 056: signed-out header one row on phones ("Log in", nowrap), backfill skips adult titles' posters, gate checksmre
- 2c53d5efMerge branch 't16-person' (tracker#16 person pages) into main; filmography shows only public titles (054 adult flag), gate race fix (backfill start line)mre
- c171227emission 054: hide adult/unknown titles from the public lists and the search; in-app adult-flag backfill (TMDB details + poster per title, resumes), gate + real-data proofmre
- 139fafd8tracker#16: short bio (4 lines, click = all), real-data check script, README + STATUSmre
- 93be9476tracker#16: person pages /person/<slug> with the filmography fetched from TMDB on the first visit (step by step), gatemre
- 47a3cae6STATUS: mission 053 merge commit idsmre
- dcc5eecaMerge branch 't14-search'mre
- 03edc783Merge branch 't15-tvmaze'mre
- 71b46345tracker#15: numbering check by date or title, placeholder titles in other languages, docs + real-data proofmre
- 6bb2daf1tracker#13: homepage (tiles, intro, latest movies/shows), /shows, /movies/page/N, /my/movies; lists cached in memorymre
- b8bd1157tracker#14: README + STATUS (search, real-data numbers, gate, merge notes)mre
- 65c694a8tracker#14: search — header magnifier, /search/<text> (in-memory word-prefix index over titles + people), Fetch from web (TMDB search/multi, ours left out), Add = import via syncShow; gate +25 checks, real-data scriptmre
- 34f2c15btracker#15: TVmaze merge in the sync (gaps only: new episodes/seasons, empty titles/air dates; numbering check), fake TVmaze episodes + gatemre