notes
All repositories: gitoria
6.5 KB
# Report 002 (w085): notes code order, no behaviour change**Where:** commits on main in loreana:/media/STORAGE/projects/notes.worldapi.org (parent 47dad68):- `8cda541`: file moves (1/4)- `3f8cb38`: topics, map and thin wrappers (2/4)- `47db4fc`: `let` (3/4)- the docs + tests commit (4/4), which also holds this report and the mission briefNot pushed, not deployed. No `.env` read. Only ports 8760–8764 and 8767–8769 were used (8765/8766 skipped). Every server was stopped by its PID; nothing of mine is still running.## Counts (before → after; `python3 tests/letcount.py .`)| | before (47dad68) | after ||---|---|---|| `.hl` files in the root | 5 | **1** (project.hl) || project.hl lines | 183 | **91** (index comment, PWA config, routes, audience, server) || `let` total | 114 | 34 || `let` never reassigned | **71** | **0** |The 34 `let`s left are all needed:- 19 are reassigned;- 15 are re-bound in a loop body. Hybriel refuses a plain declaration there on its 2nd pass (tickets lesson).## LayoutThe full file map is in README "Files". Imports only go one way: util ← users, notes-helpers ← notes ← api-helpers ← api ← project.hl.- **`lib/notes.hl`**: the table and every write to it.- Holds `noteOf`, `metaRows`, `noteView`, `newNote`, `pushNote` (sync and conflict rules) and `removeNote` (tombstone).- `notes-helpers.hl`: `textError` (the size limit), `isAlive`, `stampOf` (version stamps) and `copyMark`.- **`lib/users.hl`**: the users table, the ident config and the exchange.- `userOfLoginCode` is new here: the single exchange + `ensureUser` step. Before, the login route and the `notesLogin` face each had their own copy.- `tagOf` moved here out of project.hl.- **`lib/api.hl`**: every function route, as thin wrappers:- `/login/callback` and `loginFailed` (this was `failed`). Both take `&req` and `&sessions`;- `/api/me`;- `/api/notes`.- **`lib/api-helpers.hl`**: `reply`, `isText`, `isTime`, `safePath`.- **`lib/util.hl`**: `envOr`, `storageDir`, `countOfList`, `firstOf`, `isHex`, `isIdentId`. Before, these were in users.hl and notes.hl imported them from there.- **`lib/jsoncheck.hl`** stays a file of its own: it is the workaround for hybriel #12. Its comment now names the right call site.- **Moved:** `styles.hl` → `components/styles.hl`. `tools/migrate-short-ids.hl` now imports from `lib/`.- **Face made thin:** `notesLogin` → `userOfLoginCode`. The session writes stay in the face, because a face's `session` parameter is the framework's own.- **Removed** (dead since notes#2 moved the notes area to the browser; called nowhere): `createNote`, `saveNote`, `noteRows`, `noteTextOf`, `subjectOf`, `rowOf`, `aliveOf`, `maxSubject`, `untitled`.- `deleteNote`'s one write is now inline in `removeNote`. It was its only caller, and the checks it repeated were already done there.## Tests| test | result ||---|---|| gate `tests/browser.mjs` (app 8760, ident 8761, Chrome 8767–8769) | **50 passed, 0 failed** before and after each step || `tests/short-id-switch.mjs` (a copy with its fixed ports moved to 8760/8761) | **18/0** before and after each step || live-data reads + writes | identical, except **4 intended differences** (below) |The commands are in `.scratch/w085/gates.sh` and `step.sh`, and in README "Test".**Live-data comparison** (new `tests/realdata-baseline.mjs` and `tests/realdata-compare.py`; how to run: README "Test" → "Same output"):- **Data:** a copy of Byrodin's `storage/mpackdb` (1 user, 40 notes), taken 2026-10-03. Each run gets a fresh copy.- **Ident:** a fake ident on port + 5 answers `/api/exchange`, so the successful login paths run too.- **Reads** (243), signed in as az5b2 (users `0muh6o5a3kkd`) through a session file, and signed out:- `/`, every `/note/<id>`, unknown notes and addresses, `/login/failed`;- the static files, the manifest and the browser modules;- `/api/me`, `/api/notes`, every `/api/notes?id=`;- 20 refusals of the POST endpoint;- `/login/callback` failing six ways, with and without a session.- **Writes** (43):- saving a new note, retrying it, saving the same text, an edit;- a conflict both ways, an unknown id, a stale save on a real note;- deleting with the wrong base, then the right one, then again; deleting nothing; saving after the delete;- a successful login callback with seven `next` values, with and without a session;- the faces: four failing logins, one that works, logout;- the pages and API reads that follow.- **Masks:** two runs of the OLD code compare clean (286/286). The masks: source positions, `?v=` hashes, seed time, and for writes the new ids, the `edited` stamps and the login tags.- **Browser modules:** two differ only in imported-statics tables and positions. The script's structural check passes them.**The 4 differences (intended, the same fix as gitoria mission 002):**- **What changed:** `/login/failed`, opened after a failed `/login/callback` in a browser that already has a session, now shows its reason. Examples: "ident refused the login (403: code expired)", "GET only".- **Before:** it always said "the login did not finish — try again".- **Cause:** the old `failed(req, why)` was a second call. It got a COPY of `req`, so its session write was lost.- **Fix:** project.hl hands `&req` and `&server.sessions` to the route.- **To undo it:** pass `req` by value to `loginFailed` in lib/api.hl.- **Unchanged:** after a successful login, the page still shows the default text.**Step 3 (`let`) against step 2:** 0 different.**Other checks:**- A server started without `NOTES_STORAGE` still reads its own `./storage/mpackdb`: 40 notes, on the old tree and the new one.## Found (in STATUS)1. **The by-value `failed(req, why)` was a real bug.** The old #48 audit (mission 069) had said no `&` was needed. README now notes that this was wrong.2. **The live-data run needs a fixed `NOTES_PUBLIC_URL`.** The login link carries the URL, so two runs on two ports only compare when it is the same.3. **Plain declarations in sibling blocks work.** `ed`, `after`, `cid` and `cp` in pushNote are plain now, and the conflict paths run in the live-data run.## Not done / open- **Not deployed** (that is the architect's job). Use the normal `deploy.sh`. There is no data change.- deploy.sh's rsync does not delete, so the old root `notes.hl`, `users.hl`, `jsoncheck.hl` and `styles.hl` stay on Byrodin. They are unused and can be removed by hand.- **Scratch** (gitignored) in `.scratch/w085/`:- `old/` (the old tree);- `gates.sh`, `step.sh`, `unlet.py`, `nostore.mjs`;- the gate outputs.- **Deleted after the run:** the live-data copy and every baseline output (they hold live notes).
Branches
Latest commits
- 1f3198b6tests/cdp.mjs: HL_CPU_THROTTLE=<rate> optional CPU throttling for gate runsmre
- 39cf9fdfre-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
- db07aa84tests: short-id-switch ports from env (NOTES_SWITCH_IDENT_PORT/_PORT), defaults unchangedmre
- ef9f9feere-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
- 5485467cdocker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
- 86ea4a85deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
- edeab20fnotes mission 015: mission, report, LOG, STATUSmre
- 542a0383notes mission 015: e2e-chrome E2E_HOST (own cookie jar in the shared Chrome)mre
- 8b30f510notes mission 015: main-menu from layouts 0bcc629, current = true kept (route marks only /), server-HTML marker checksmre
- 84b574c4notes mission 015: re-vendor plugins from hybriel f9614007 (incl. web, #117)mre
- 447da53dnotes mission 014: report — remaining gates and lisbeth E2E proofmre
- fd9f92c3notes mission 014: report (partial), LOG, STATUSmre
- b2501360notes mission 014: open() sets asking=false before flush(0) (hybriel#196)mre
- 9414ce59notes mission 014: merge theme 76f99f6, components 3794c59, strict single-press openAsk (fails on old open())mre
- c08c655anotes 013: theme re-copied from layouts 76f99f6 (menu marks the current page), current = true on the menu item, e2e marker checks, reportmre
- 21c8f65dnotes mission 012: STATUSmre
- 0bbb3dd9notes mission 012: delete section of the browser gate de-flaked (openAsk: calm wait, press again when the question closes by itself); report 012mre
- f431bdf8notes mission 011: notes on the layouts theme (ListFirst shell), styles cut, check-theme gate, E2E extended; reportmre
- 1a8603d1notes mission 011 WIP: deploy.sh gate summary also matches check-theme, browser.mjs logout via the user menumre
- dae2e508notes mission 011 WIP: theme dbe3de7, shell on AppHeader/MainMenu/UserMenu/Sidebar + ListFirst, styles cut to the app's own, check-theme gate, e2e auditmre