gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit3d9b2fd83d9b2fd8docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre3d9b2fd8/plugins/fs/server.hl

5.8 KB

  1. file(String path) {
  2. return __native("fs.file", path)
  3. }
  4. readFile(String path) {
  5. return __native("fs.read_file", path)
  6. }
  7. \* `readFile`, but a path that is not there answers null instead of failing: for what
  8. another process may delete between a probe and the read (the shared build cache). *\
  9. tryReadFile(String path) {
  10. return __native("fs.try_read_file", path)
  11. }
  12. \* Read a whole file as Bytes (ticket #88): every byte as it is on disk,
  13. nothing decoded — the way back for what writeFile stored from a Bytes. *\
  14. readBytes(String path) {
  15. return toBytes(__native("fs.read_file", path))
  16. }
  17. \* Name the file every path read, listed or probed is appended to (one line,
  18. `r|l|e <path>`), or stop with null — the build cache's record of what a
  19. build depends on (326 rung 12). *\
  20. traceReads(path) {
  21. return __native("fs.trace", path)
  22. }
  23. \* The SHA-256 of a file's bytes, 64 hex digits, or null when it cannot be
  24. read; `textDigest`, of a text's. Hashed natively (the build cache). *\
  25. fileDigest(String path) {
  26. return __native("fs.digest", path)
  27. }
  28. textDigest(String text) {
  29. return __native("fs.digest_text", text)
  30. }
  31. \* The path's last status change (ctime) in milliseconds since the epoch, or null
  32. when it is not there (#195): what the build cache compares with the moment a
  33. build began. *\
  34. changeTime(String path) {
  35. return __native("fs.change_time", path)
  36. }
  37. listDir(String path) {
  38. return __native("fs.list_dir", path)
  39. }
  40. \* Does this path exist? (mission 077) The one call in hl:fs that cannot fail:
  41. it answers true/false, never an Error event — probing a path is a question,
  42. not an operation. Relative paths resolve against the SCRIPT's directory like
  43. every other hl:fs path. *\
  44. exists(String path) {
  45. return __native("fs.exists", path)
  46. }
  47. \* Watch a directory tree for changes (the dev-reload bell): an ordinary
  48. event-loop source — register it and every save arrives as an event.
  49. __native("eventloop.register", watch("."), "changed")
  50. on changed(ev) { … ev.name … }
  51. `exclude` (2026-08-30) names directories the descent must NOT enter — a
  52. path string, or a list of them. Omit it and the whole tree is watched, as
  53. it always was. The paths are compared RESOLVED (relative ones against the
  54. script's directory, like every hl:fs path) and normalised, so `./sessions`,
  55. `sessions` and `var/../sessions` are the same directory, and a sibling
  56. named `sessions-old` is NOT inside `sessions`.
  57. watch(".", "./sessions")
  58. watch(".", ["./sessions", "/var/cache/app"])
  59. A program that writes to a directory it also watches needs this: without
  60. it the only escape was that the walker skips dot-directories (which it
  61. still does — `.git` is the reason), i.e. renaming the directory. *\
  62. watch(String path, exclude) {
  63. return __native("fs.watch", path, exclude)
  64. }
  65. \* Write a whole file, ATOMICALLY (2026-08-28). Everything above this line
  66. reads; hl:fs could report a file's `chmod` and never set one, which is why
  67. nothing in this language could persist anything until now.
  68. The write goes to a sibling temp file, is fsynced, and is then renamed over
  69. the target — so a concurrent reader sees the whole OLD file or the whole NEW
  70. one, never a half of either. That matters more than it sounds: the first
  71. caller is the session store, and a truncated session file does not read as
  72. an error, it reads as a logged-out user.
  73. `mode` defaults to 0600 — a file this program wrote, for this program. Pass
  74. one to loosen it; nothing here consults the umask on your behalf.
  75. `contents` is a String or a Bytes (ticket #88): a Bytes is written raw,
  76. byte for byte — an uploaded image stays an image. *\
  77. writeFile(
  78. String path
  79. contents \\ a String or a Bytes
  80. Number mode
  81. ) {
  82. if (hlTypeName(contents) == 'Bytes') {
  83. return __native("fs.write_file_hex", path, contents.hex(), mode)
  84. }
  85. return __native("fs.write_file", path, contents, mode)
  86. }
  87. \* Append to a file — the log's shape, not the session store's (2026-09-27, a
  88. creator ask after routger's two). Opened O_APPEND, never truncated: the file
  89. is created (at `mode`, default 0600, same as writeFile) if it is not there
  90. yet, and every call after that lands its bytes after whatever is already on
  91. disk. `writeFile`'s atomicity is a RENAME over a temp file — there is no
  92. "old" or "new" whole file to swap here, since an append MUTATES the one
  93. that is already there — but O_APPEND carries its own, narrower guarantee:
  94. the kernel positions a single write() at the CURRENT end of file and
  95. performs it as one operation, so two processes each appending one line
  96. never interleave their bytes mid-line, and a reader never sees a torn
  97. append. That is what "a single write of a line lands whole" buys — call it
  98. once per line (or per record) you want that guarantee for.
  99. `contents` is a String or a Bytes (ticket #88), same as writeFile: a Bytes
  100. is appended raw, byte for byte. *\
  101. appendFile(
  102. String path
  103. contents \\ a String or a Bytes
  104. Number mode
  105. ) {
  106. if (hlTypeName(contents) == 'Bytes') {
  107. return __native("fs.append_file_hex", path, contents.hex(), mode)
  108. }
  109. return __native("fs.append_file", path, contents, mode)
  110. }
  111. \* Make a directory and every missing parent. Already-there is SUCCESS: the
  112. caller wants the directory to exist, not to be the one who created it.
  113. `mode` defaults to 0700. *\
  114. mkDir(String path, Number mode) {
  115. return __native("fs.mk_dir", path, mode)
  116. }
  117. \* Delete a file or an empty directory. IDEMPOTENT: true when the path is gone on return, and a path
  118. that was already gone counts. A sweep must not fail because something else
  119. deleted the file first. *\
  120. remove(String path) {
  121. return __native("fs.remove", path)
  122. }
  123. \* The canonical absolute path of `path` (symlinks resolved, `.`/`..` folded;
  124. realpath(3)), or null when it is not there. `realPath('/proc/self/exe')` is
  125. the running binary. *\
  126. realPath(String path) {
  127. return __native("fs.real_path", path)
  128. }

Branches

Latest commits

  • 3d9b2fd8docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
  • 19b7e3c3deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
  • c8a596f4re-vendor Hybriel 66c3db71 (web batch 4); e2e: main menu marked after in-place sign-in is a normal check; report 014mre
  • 8f3dc1ectests: delivery allow-list for the stopped server's network errors uses the gate port, not 8700mre
  • 9cc8eddftests: notify and iplimit gate Chrome ports from env (NOTIFY_GATE_CHROME, IPLIMIT_GATE_CHROME_A/B)mre
  • d6da2d02tests: delivery and migration gate ports from env (DELIVERY_GATE_PORT, DELIVERY_GATE_CHROME, MIGRATION_GATE_CHROME) — hard-coded 8700-8719 collided with a worker during deploymre
  • 7276a008ident mission 013: re-vendor Hybriel master f9614007 (#200, #202 mpackdb copy fix); gates and e2e rerunmre
  • e13e30c3ident mission 013: report, mission, repro, LOGmre
  • eff734f3ident mission 013: in-place sign-out also closes the code step (no leftover code form); checksmre
  • b7a61546ident mission 013: e2e — in-place main-menu mark kept as a known gapmre
  • 59b43d81ident mission 013: sign out everywhere keeps this browser's own (signed-out) session so the page goes on in placemre
  • 716e14ffident mission 013: browser gate — Bob signs out everywhere (no second code request)mre
  • 5885f1c9ident mission 013 step 2: stopgap reload removed (in-place sign-in/out reach the shell via emit, notices back, route-marked main menu), gates updatedmre
  • 734ac0a9ident mission 013 step 1: re-vendor Hybriel ce6f2e0a (plugins whole; bin/ is git-ignored)mre
  • b37875ccident mission 012 part 3: real-Chrome fixes (brand 44 px, identity form width), e2e walk, report, logmre
  • f989c2ebident mission 012: stopgap reload after in-place sign-in/sign-out (until hybriel#193), gates wait for cold start, welcome end reloadsmre
  • 443291d4ident mission 012: /start on its own shell (no account), browser gate 152/0, reportmre
  • 021dd0fcident mission 012: browser gate waits cold start (IDENT_COLD_MS), header selectors, e2e checks; shell events from a page do not reach it (probe), current not marked, account-bar link 44 pxmre
  • 97f77b07ident mission 012 (WIP): onto the layouts theme dbe3de7, shell on AppHeader/MainMenu/UserMenu/Sidebar + ContentFirst, styles cut, check-theme gatemre
  • 8e4f435bpaths: projects moved into /media/STORAGE/projects/WorldAPI/mre