gitoriaLog in with ident

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit06b078e306b078e3tracker 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 identicalmre06b078e3/plugins/proc/server.hl

10.0 KB

  1. \* hl:proc — child processes as INSTANCE EVENTS.
  2. let server = spawn('llama-server -m ' + model + ' --port 8480')
  3. on server.line({ line, stream }) { … } \\ stream: 'stdout' | 'stderr'
  4. on server.exit({ exit, pid }) { … } \\ always arrives, kill or not
  5. server.kill() \\ SIGTERM; exit still fires
  6. server.write(text) \\ to its stdin ({ stdin = 'pipe' }): String or Bytes, raw
  7. server.end() \\ close its stdin: it reads EOF
  8. A child spawned with `{ binary = true }` delivers its output as raw Bytes
  9. instead of text lines — `on server.data({ data, stream })`, one event per
  10. chunk as it arrives, nothing split and nothing replaced. The default stays
  11. text lines.
  12. `stream` names the PIPE, not a verdict — most servers (llama.cpp included)
  13. write their whole LOG to stderr, keeping stdout for data.
  14. A CHILD DIES WITH ITS PARENT: every child is started with the kernel's
  15. parent-death signal set to SIGTERM (Linux PR_SET_PDEATHSIG), so when this
  16. program exits — any exit, a crash or Ctrl-C included — its children get
  17. SIGTERM and no orphan keeps a port. There is no option to turn it off. The
  18. setting is the child's own and is not inherited by what IT starts, so a
  19. process meant to outlive you is started one level down, by the child:
  20. spawnArgs([ 'sh', '-c', 'long-job &' ]).
  21. A command that CANNOT START has no exit — it is an ERROR: caught by
  22. `on server.Error(e)` (this instance) or the global `on Error(e)`; uncaught
  23. it is a located crash naming the binary and the errno. A finished child
  24. retires its event source, so a program whose children are done simply ends.
  25. THE PROGRAM PATH follows the Hybriel path rule: `spawn('bin/llama-server …')`
  26. resolves bin/ against THIS SCRIPT's directory (like imports and hl:fs) — a
  27. copied build folder next to your .hl file just works. A bare name searches
  28. PATH; absolute stays absolute.
  29. OPTIONS, the last argument of spawn and spawnArgs, all optional: `cwd`
  30. is the directory the child starts in — a relative one resolves against
  31. THIS SCRIPT's directory, like the program path; `env` is added to the
  32. environment the child inherits (`{ LANG = 'C' DEBUG = null }` sets LANG
  33. and removes DEBUG); `binary = true` delivers the output as Bytes (above);
  34. `stdin = 'pipe'` makes the child's stdin writable with write() and end()
  35. — without it the child inherits this program's stdin, as before.
  36. let st = spawn('git', [ 'status', '--short' ], { cwd = 'repo' })
  37. There is NO SHELL — no quoting, no expansion (the safety property, not a
  38. gap). `spawnArgs([ 'sh', '-c', pipeline ])` is how you ASK for one,
  39. explicitly. *\
  40. /* Gate file (docs campaign): __native lives only here; the Process class
  41. (process.hl) carries the instance events and their declarations. */
  42. \* Start a child from ONE command string: split on WHITESPACE RUNS (spaces,
  43. tabs AND newlines — a command written across lines is one command); a
  44. quoted argument is GROUPED and its quotes stripped ('{"a": 1}' arrives as
  45. one argv entry). A command that cannot start is an Error — caught by
  46. `on server.Error(e)` or the global `on Error(e)`. *\
  47. spawn(
  48. String cmd \\ the program and its arguments, whitespace-separated — or, with `args`, the program alone
  49. Hybrid args = null \\ the arguments as a list, each passed as is (cmd is then not split)
  50. Hybrid options = null \\ { cwd, env, stdin, binary } — see the head of this file
  51. ) {
  52. if (args == null) {
  53. return new Process().start(cmd, options)
  54. }
  55. return new Process().startArgs([cmd] + args, options)
  56. }
  57. \* The LIST form — argv exactly as given: for arguments that contain spaces,
  58. or to ask for a shell explicitly: spawnArgs([ 'sh', '-c', pipeline ]). *\
  59. spawnArgs(
  60. Hybrid args \\ argv entries, one string each — args[0] is the program
  61. Hybrid options = null \\ { cwd, env, stdin, binary }, as for spawn
  62. ) {
  63. return new Process().startArgs(args, options)
  64. }
  65. \* RUN A PROGRAM AND WAIT FOR IT (ticket #80): the blocking twin of spawn,
  66. for code that needs the output NOW — a page's root that is being
  67. constructed on the server, a build step, a script. It answers once the
  68. program has exited:
  69. let log = run([ 'git', 'log', '--oneline', '-5' ], { cwd = 'repo' })
  70. log.exit \\ the exit status (128 + n when signal n ended it)
  71. log.lines \\ stdout, one String per line, no newlines
  72. log.stderr \\ stderr, the same
  73. `command` is a String (split like spawn's) or an argv list, passed as is.
  74. `options` are spawn's `cwd`, `env` and `binary` — with `binary = true`
  75. stdout comes back whole as `data`, a Bytes, instead of `lines` — and
  76. `timeout`, in seconds: past it the program is killed and the call is an
  77. Error. `stdin`, a String or a Bytes (ticket #91), is what the program
  78. reads: written to it whole, then closed, so it reads EOF —
  79. let r = run([ 'git', 'upload-pack', '--stateless-rpc', dir ], { stdin = req.bytes binary = true })
  80. Without `stdin` the program's stdin is empty (/dev/null); a program that
  81. waited for input would otherwise hold the caller forever.
  82. The wait holds the fiber that called, as fetch() does, so a server keeps
  83. a run short or bounds it with `timeout`. A command that cannot start is an
  84. Error, as for spawn; a program that ran and failed is not — read `exit`. *\
  85. run(
  86. command \\ the program and its arguments: a String, whitespace-separated, or a list
  87. Hybrid options = null \\ { cwd, env, binary, stdin, timeout } — see above
  88. ) {
  89. // stdin crosses the plugin boundary as hex (the ABI has no Bytes), beside the options
  90. let o = options
  91. let feed = null
  92. if (o != null && o.stdin != null) {
  93. let t = hlTypeName(o.stdin)
  94. if (t == 'Bytes') {
  95. feed = o.stdin.hex()
  96. o.stdin = null
  97. } else if (t == 'String') {
  98. feed = toBytes(o.stdin).hex()
  99. o.stdin = null
  100. }
  101. }
  102. let r = __native("proc.run", command, o, feed)
  103. // a failure an `on Error` handler absorbed leaves the call yielding null
  104. if (r == null) {
  105. return null
  106. }
  107. if (options != null && options.binary == true) {
  108. return { exit = r.exit data = toBytes(r.out) stderr = linesOf(r.err) }
  109. }
  110. return { exit = r.exit lines = linesOf(r.out) stderr = linesOf(r.err) }
  111. }
  112. // A stream's text as its lines: split at each newline, and a final newline ends
  113. // the last line rather than starting an empty one — spawn's `line` events say the same.
  114. linesOf(String text) {
  115. let nl = "
  116. "
  117. let out = []
  118. if (text == '') {
  119. return out
  120. }
  121. for (l of text.split(nl)) {
  122. out.push(l)
  123. }
  124. if (text.endsWith(nl)) {
  125. out.pop()
  126. }
  127. return out
  128. }
  129. \* The terminal's own input as instance events — `input = stdin()`, then
  130. `on input.line(text)` per typed line and `on input.eof()` at Ctrl-D. A joined
  131. terminal realm (SPEC "Joining a realm") reads its keyboard here. *\
  132. stdin() {
  133. return new Stdin().start()
  134. }
  135. \* One environment variable, null when unset. The runtime loads a `.env`
  136. beside the project's entry BEFORE anything runs (KEY=VALUE lines, #
  137. comments; the real environment always wins), so env('OPENROUTER_KEY')
  138. reads either source through one call. *\
  139. env(
  140. String name \\ the variable's name
  141. ) {
  142. return __native("proc.env", name)
  143. }
  144. \* THE PROGRAM'S OWN ARGUMENTS (mission 317) — the strings that follow the
  145. entry on the command line, in order, as a list; an empty list when there
  146. were none.
  147. hybriel lex.hl a b // args() is ['a', 'b']
  148. ./lex a b // the compiled binary answers the same
  149. EVERYTHING AFTER THE ENTRY IS THE PROGRAM'S, unchanged: `hybriel
  150. [runtime flags] <file> [app args]` (creator ruling 2026-09-27). Flags
  151. included — `hybriel t.hl x --post --strict --` gives
  152. ['x', '--post', '--strict', '--']; hybriel's own flags (--strict,
  153. --offline, --strict-boundaries) are written BEFORE the entry.
  154. A project DIRECTORY entry is the same: every argument after it is the
  155. program's. Joining a realm is a runtime flag, written before the entry:
  156. `hybriel --realm=<name> <projectDir>` (SPEC "Joining a realm").
  157. Built here rather than handed over whole because a `__native` call answers
  158. with ONE value and a list is what the caller wants: the count and the i-th
  159. argument are the two questions the runtime can answer, and the list is the
  160. language's own. *\
  161. args() {
  162. let out = []
  163. let n = __native("proc.argc")
  164. let i = 0
  165. while (i < n) {
  166. out.push(__native("proc.arg", i))
  167. i = i + 1
  168. }
  169. return out
  170. }
  171. \* WRITE TO THIS PROGRAM'S OWN STDOUT, RAW (ruling on ticket #42): a String's
  172. bytes or a Bytes, exactly as they are — no newline, no text form, unlike
  173. console.log. For a binary protocol on stdout. Answers how many bytes went. *\
  174. writeStdout(
  175. data \\ a String or a Bytes
  176. ) {
  177. if (hlTypeName(data) == 'Bytes') {
  178. return __native("proc.write_stdout_hex", data.hex())
  179. }
  180. return __native("proc.write_stdout", data)
  181. }
  182. \* WRITE TO THIS PROGRAM'S OWN STDERR, RAW: writeStdout's twin on the error
  183. stream — a String's bytes or a Bytes, exactly as they are, no newline.
  184. Answers how many bytes went. *\
  185. writeStderr(
  186. data \\ a String or a Bytes
  187. ) {
  188. if (hlTypeName(data) == 'Bytes') {
  189. return __native("proc.write_stderr_hex", data.hex())
  190. }
  191. return __native("proc.write_stderr", data)
  192. }
  193. \* END THIS PROGRAM NOW with an exit status (ruling on ticket #36): 0 is
  194. success, anything up to 255 tells the shell it failed. Nothing after the
  195. call runs. An uncaught error still exits 1 by itself. *\
  196. exit(
  197. Number code = 0 \\ the exit status, 0-255
  198. ) {
  199. __native("proc.exit", code)
  200. }
  201. \* THE PROGRAM'S OWN DIRECTORY, absolute (ticket #37): the directory of the
  202. entry script on the interpreter, the directory the executable sits in for
  203. a compiled binary (a binary knows no build directory). cwd() is where the
  204. user launched from; file() is the calling file's path. *\
  205. dir() {
  206. return __native("proc.dir")
  207. }
  208. \* The process's current working directory, absolute — where the USER
  209. launched from. Your own files resolve script-relatively everywhere
  210. (imports, hl:fs, spawn); cwd() is for tools whose subject is the caller's
  211. directory: a formatter, a scaffolder. *\
  212. cwd() {
  213. return __native("proc.cwd")
  214. }

Branches

Latest commits

  • 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
  • 20e09d89Merge t18 (tracker#18 delta sync) into main (mission 070): conflicts README/STATUS/show.hl/project.hl/browser.mjs, both sides kept; pageShowOf summary = summaryOfmre
  • f83571c3tracker#18 (mission 067): daily sync by change lists — TMDB /tv|movie/changes (since the stored day, paged) + TVmaze /updates/shows → only our changed titles (followed: full step, unfollowed: light step — changed seasons, no TVmaze), full walk on first run / gap > 14 days / failed list; show record refreshed (title, tmdbSummary, tagline, status, genres …; renamed titles re-indexed); summary = the creator's own text (page: summary > tmdbSummary > tvmazeSummary), one-time clear of copied summaries (9,647 on the live copy); gate 261, tests/realdata-018*.mjs, README + STATUSmre
  • 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