gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit3ac859953ac85995ident#43 ident#44: plain declarations for never-reassigned lets, one envString helper, named route functions and audience rule out of project.hlmre3ac85995/reports/009-code-order.md

8.6 KB

  1. # Report 009: ident code order, no behaviour change
  2. **Where:** commits on main in loreana:/media/STORAGE/projects/ident.worldapi.org:
  3. - `9101716`: file moves (1/4)
  4. - `d2e7f91`: topics, map and thin wrappers (2/4)
  5. - `fe18351`: `let` (3/4)
  6. - the docs + tests commit (4/4), which also holds this report and the mission brief
  7. Not pushed, not deployed. No `.env` read (the real-data runs use code-only copies without `.env`). Only ports 8750–8759 were used. Every server was stopped by its PID; nothing of mine is still running, and 8750–8759 are free.
  8. ## Counts (before → after; `python3 tests/letcount.py .`)
  9. | | before (f8bdcbc) | after |
  10. |---|---|---|
  11. | `.hl` files in the root | 10 | **1** (project.hl) |
  12. | project.hl lines | 338 | **132** (index comment, PWA config, routes, mailer, audience, server, one hook) |
  13. | `let` total | 453 | 164 |
  14. | `let` never reassigned | **290** | **0** |
  15. The 164 `let`s left are all needed:
  16. - 99 are reassigned;
  17. - 49 are in a loop body (Hybriel refuses a plain declaration there on the 2nd pass);
  18. - 14 have the name of a member of the file: `me` in the faces, which is also a component member;
  19. - 2 are declared twice in one function (see "Found").
  20. `tests/letcount.py` (from gitoria) now has the kinds `member` and `twice` too, so "never" means "should be plain".
  21. ## Layout
  22. The full file map is in README "Files". Imports go one way only:
  23. - util ← identities-helpers ← identities ← accounts ← login-helpers ← login
  24. - util ← apps-helpers ← invites-helpers ← invites ← apps ← selector / notify ← api-helpers ← api ← project.hl
  25. **Topic files** (each holds its central logic and every write to its tables):
  26. - **`lib/login.hl`**: the code tables otp / sends / ipsends, the limits, `checkCode` and the pending sign-in.
  27. - It gained `signInWithCode`, the logic of the verifyCode face.
  28. - Helpers: `lib/login-helpers.hl` (`newOtp`, `otpHash`, `ipBucket`).
  29. - **`lib/accounts.hl`**: the accounts table, the sessions and sign out everywhere.
  30. - It gained `createAccount`, which before was inside `checkCode`.
  31. - `dropUserSessions` moved here from project.hl. project.hl hands it the server by reference.
  32. - **`lib/identities.hl`**: the identities table, the short ids and the identity CRUD.
  33. - It gained `addDefaultIdentity` (was in `checkCode`) and `identityRecord` / `accountOfIdentity` (were in notify.hl).
  34. - Helpers: `lib/identities-helpers.hl` (fields, avatar, label, the short id's alphabet).
  35. - **`lib/apps.hl`**: apps, connections, requests, grants, the login button and the exchange.
  36. - `appOfSecret` moved here from notify.hl.
  37. - The person's side of an invite moved here (`openInvite`, `grantInvite`), because it creates and uses login requests.
  38. - `grantRequest` is the dispatch that was in the chooseIdentity face.
  39. - Helpers: `lib/apps-helpers.hl` (app form, origins, return URL, keys).
  40. - **`lib/invites.hl`** now owns its table. `invitesTable` was declared in apps.hl, and apps.hl deleted invites directly.
  41. - Now `deleteApp` calls `dropInvitesOf`, and `acceptInvite` writes the acceptance.
  42. - Helpers: `lib/invites-helpers.hl`.
  43. - **`lib/selector.hl`**: the pick ids, the list and `codeOfPick` (was a loop inside the endpoint).
  44. - **`lib/notify.hl`**: kinds, effective settings, sending, the inbox and the per-app page.
  45. - Helpers: `lib/notify-helpers.hl` (checks, stamp, the two hand sorts, on/off).
  46. **Shared and routes:**
  47. - **`lib/util.hl`**: `dir`, `envNumber`, `countOf` / `first` / `merged`, `str`, `isId` / `isList` / `isObject`, `oldestFirst`, `hasControl`, `urlChars`, `normEmail` / `validEmail`, `checkTimeZone`.
  48. - Before, `isList`, `isObject` and `str` existed twice (apps / notify / store).
  49. - **`lib/api.hl`**: every function route from project.hl, as thin wrappers.
  50. - Also the selector's two CORS endpoints (were in selector.hl).
  51. - Also `codePage(route, req, &srv, Home)`.
  52. - **`lib/api-helpers.hl`**: the old api.hl, plus `inviteCaller`, `field`, `baseOf`, `hexId` and the selector's CORS answers and caller check.
  53. **Moved, unchanged:**
  54. - `mail.hl` → `lib/mail.hl`
  55. - `jsoncheck.hl` → `lib/jsoncheck.hl`
  56. - `styles.hl` → `components/styles.hl`
  57. - `tools/` import from `lib/`
  58. **Faces made thin:**
  59. - verifyCode → `signInWithCode`
  60. - chooseIdentity → `grantRequest`
  61. The one-line `signOut` session write stays in its face. A face's `session` is the framework's own (as gitoria did it).
  62. ## Tests
  63. | test | result |
  64. |---|---|
  65. | gate `tests/browser.mjs` (8750, 8751, Chrome 8752–8759) | **152 passed, 0 failed** before and after each step |
  66. | apps / selector / migration / iplimit / notify | **107 / 99 / 33 / 39 / 130, 0 failed** before and after each step |
  67. | hardening / signoutall / shortid / invites | **17 / 6 / 19 / 44, 0 failed** before and after each step |
  68. | live-data reads + writes, old vs new | **291 / 291 the same** |
  69. How the other nine gates run: `.scratch/m009/runall.mjs` runs them as temporary port-remapped copies (8750–8757), one by one. Outputs are in `.scratch/m009/gate-<name>-<before|step1|step2|step3>.txt`. The commands are in README "Test" → "Same output".
  70. **Live-data comparison** (new `tests/realdata-baseline.mjs` + `tests/realdata-compare.py`):
  71. - **Data:** a copy of Byrodin's `storage/mpackdb`, taken 2026-10-03. Each run gets a fresh copy.
  72. - **Code:** each tree runs from a code-only copy without `.env`. Mail goes to a sink file.
  73. - **Reads (187):**
  74. - every page, signed in as az5b2 (session file for account 0mufd5afy0xm) and signed out: `/`, `/start`, `/apps`, `/inbox`, the 8 live connection pages, `/code`, `/signin/…`;
  75. - the browser modules, the worker and the manifest;
  76. - every live app's `/login` variants and selector calls (in / out / foreign origin / preflight);
  77. - the refused API calls.
  78. - **Writes (104):**
  79. - identities and the time zone;
  80. - a new app with its secret and new secret;
  81. - the login button and the exchange, the selector choose and exchange;
  82. - kinds and notifications (also urgent, unregistered and refused ones);
  83. - inbox mark, switches and override;
  84. - invites (create, mail, list, open, accept, get, revoke) and migrate-ids;
  85. - the OTP login of a new address and of the creator's: wrong code, right code, the code page before and after;
  86. - the app login on `/signin/<rid>/code` and "Other address";
  87. - the address and IP limits;
  88. - sign out everywhere, disconnect, app delete;
  89. - finally the whole stored state (`tools/dump-store.hl` on a copy).
  90. - **Masks:** only what changes per run (times, random ids, codes, keys, short ids of new identities, source positions, module hashes). Two runs of the OLD tree compare clean (291/291).
  91. - **After step 2:**
  92. - 4 browser modules differ, but only in source positions and the import tables (the comparator checks the code and the imported functions);
  93. - the worker's `hl-shell-<hash>` cache name differs (it follows the code hash).
  94. - **After step 3:**
  95. - also `var` → `const` in the client code of main.hl;
  96. - 0 real differences.
  97. ## Found (in STATUS "Lessons")
  98. 1. **A plain declaration may not repeat a name inside one function.** In `lib/notify.hl sendNotification`, both `if` blocks declare `c` (`checkUrl` of the icon, then of the link). As plain declarations, the second one aborts with "Cannot reassign immutable variable 'c'". It showed up as notify gate 45/3 and a 500 on the real-data `w-notify`. Both stay `let`. `.scratch/m009/twice.py` searched every file: this was the only case.
  99. 2. **A `let` with a member's name must stay.** Without `let`, `me = accountOfSession(session)` in a face would assign the component's member. gitoria's `unlet.py` already refuses these (CLASH, 14 cases).
  100. 3. Moving statics between lib files did not change the browser modules at all; only the component's own line shifts move source positions.
  101. ## Open
  102. - **Not deployed** (that is the architect's job). Use the normal `./deploy.sh`. There is no data change.
  103. - deploy.sh's rsync does not delete, so the 9 old root files stay on Byrodin: api.hl, apps.hl, invites.hl, jsoncheck.hl, mail.hl, notify.hl, selector.hl, store.hl, styles.hl. They are unused; delete them by hand after the deploy.
  104. - **Long files left as they are:**
  105. - `components/home.hl` (587 lines; it is UI);
  106. - `lib/notify.hl` (384);
  107. - `lib/apps.hl` (276).
  108. - **Not touched:** `testapp/` (a test app with its own project.hl). It is outside the scan, like in tickets and gitoria.
  109. - **Scratch** (gitignored) in `.scratch/m009/`. The folder also holds the 2026-09-24 UUID-migration files (old mission 009: deploy-*, rehearsal-*, cmp009.py …); they were not touched. Mine:
  110. - `old/` (the old tree, code only);
  111. - `gates.sh`, `runall.mjs`, `step.sh`;
  112. - `unlet.py`, `twice.py`, `letcount.py`;
  113. - the gate outputs.
  114. - **Deleted after the run:** the live-data copy, the dump and every baseline output (they hold live data).

Branches

Latest commits

  • 3ac85995ident#43 ident#44: plain declarations for never-reassigned lets, one envString helper, named route functions and audience rule out of project.hlmre
  • c7eef14aMerge branch 'nv1-navigate' into mainIdent
  • 644f9775|||PR ident#36 navigate() instead of window.location in the shell, start shell and homemre
  • 4ca2f921deploy.sh: tar --hard-dereference so backups hold no hard linksmre
  • 23971fb7ident#49: media queries in the language's @media formmre
  • 73f4f97dident: re-vendor to hybriel day38b (mpackdb store-open fix)mre
  • aa056c03ident: a startup error prints its message before exit 1 (hybriel#247)mre
  • ee37a861ident#G48: gitoria's registration gets the wildcard origin of its repo addresses at load (gate tests/gitoria-origin.mjs)mre
  • dc6d486fident#27: the docs gate expects the new Access entry in the main menumre
  • d277633cident#27: README: identity access and the introspect endpointmre
  • e999b0d3ident#27: the Access tab — one key per identity for all its apps: give access in three steps, the overview matrix, a cell's sheet (since, last use, level, rotate, revoke), the app's check POST /api/introspect, agent identities hidden from the login picker, an inbox icon in the header's icon style (gate: tests/access.mjs)mre
  • 436206fcident#47: deploy.sh runs the sign-in gate on the deploy's own port slot, like the sessionwrites and docs gates (the default 8700 can be taken by another process)mre
  • a4887ea3ident#47: the selector's sign-in frame no longer has a Continue button; the identity row itself is the link (gate tests/signin.mjs fails on the old code)mre
  • d8ec703dident#45: /docs shows docs/IDENT.md (hl:markdown, vendored from ac1ed9da), one Docs entry in the main menu, README for developers only, gates tests/docs.mjs and tests/sessionwrites.mjs in deploy.shmre
  • ec6aad35Merge branch 'a28g-amp-callsites' into d45-docsmre
  • 6bfbd3f2ident#45: docs/IDENT.md, what ident is and how it works; CONCEPT.md marks one id per app as droppedmre
  • c0edca26ident#28 A28G: write & at every call that hands a session to an &-parameter; gate tests/sessionwrites.mjs pins that sign-in, pending address, embed sign-in and selector land in the session filesmre
  • 80965c08ident#28: README says the deploy goes through the standbymre
  • 2f41670cident#28: ident-standby service on port 45012 (no background round in the standby) and deploy.sh hands over through standby-swap.shmre
  • a544b261ident#28: README names the new vendored Hybrielmre