gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit5c481bfd5c481bfdident#31: sign in to ident inside the selector's panel (email, code, identity in an iframe; a new address goes to ident in the same tab and comes back)mre5c481bfd/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

  • 5c481bfdident#31: sign in to ident inside the selector's panel (email, code, identity in an iframe; a new address goes to ident in the same tab and comes back)mre
  • 061abfe2ident: the apps gate waits until the test app's login button stops moving before it clicks (the page grows after load and the click missed about every second run)mre
  • 45f7e4daident: the user menu's Sign out waits for the server before it reloads (the apps gate failed because the session could still be signed in)mre
  • f07658c7ident: home page shows the account once (account bar removed, the user menu carries email, Sign out, Sign out everywhere); wildcard origins https://*.domain for apps on many subdomains; gates follow (WIP: gates not re-run after the last edits)mre
  • f2c43bbbtheme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
  • 6d4f996esessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
  • 029eb5e5deploy: security gate (tests/security.mjs)mre
  • d3c065a8security audit (SI): uploadMax 0, Secure __Host- cookie behind https, headers on function routes/files, page CSP+referrer meta, app/identity caps, tests/security.mjs, reportmre
  • 5561a0cbreport I4-mobilemre
  • 4ca2ed20404 page in the shell (viewport, status 404, way home); phone: account actions live in the user menu so the open menu covers nothing; mobile gate; signoutall waits for a cold startmre
  • 9baad745tests: browser gate waits for the reloaded document (offline reload race under CPU throttle); HL_CPU_THROTTLE knobmre
  • b96796bdtests: wait for hydration before real clicks after a navigation (H2)mre
  • 9722964fre-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
  • c9b196c9tests/iplimit: wait for the welcome form itself after B's first login (identities list renders before it); mission 017 reportmre
  • 72e0f587ident#26: identity page with "Used in" (app, since, last use, Notif. chip, empty state); lastLogin recorded at exchange; gates + lisbeth E2E; mission 016 reportmre
  • 94576fbcident#26 WIP: identity page /identity/:iid with "Used in" (app, since, last use, Notif. chip), lastLogin recorded at exchange, "Used in…" link on the identities list; apps gate 4b, e2e-usedin.mjsmre
  • 349cb502tests/invites: wait for hydration on the code page before entering the code (native GET submit raced the welcome form); mission 015 reportmre
  • d1bf4720tests: no hard-coded ports — every gate's ports and fixture origins come from <GATE>_PORT / _CHROME env (defaults unchanged; Bob/fixture origins follow, selector cookie name too)mre
  • 6280c92fre-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
  • 147744bftests/migration: the fixture app origin follows MIGRATION_GATE_TESTAPP_PORT (oldstore-009 OLD_TESTAPP)mre