calendar
All repositories: gitoria
19.4 KB
# calendar.worldapi.orgThe creator's calendar (CONCEPT.md), in Hybriel on hl:web. The month view at `/` — prev / next buttons on top, month nameand year between them, today marked, weeks start on Monday, names in the browser's language — and, since ticket #2,**login with ident and private events**. https://calendar.worldapi.orgSince mission 006 the page is the layouts theme (`theme/`, layouts.worldapi.org dbe3de7) in its **ContentFirst** shell: a month is one big content area, so no list beside it. Mobile first: ☰ menu (MainMenu + Sidebar, "Calendar") and the user menu (the user icon: signed in → Log out; signed out → Log in with ident); taps ≥ 44 px, inputs ≥ 16 px at 390 px. `components/styles.hl` keeps only the app's own rules; the month-view fork keeps only **its own** styles in its `styles.hl` part (the month grid, event chips, editor), everything else (colours, buttons, header, menus) comes from the theme. `node theme/check-theme.mjs .` (in deploy.sh) fails on hard-coded colours, decorative borders and odd radii.Current Hybriel vendor: **day59**, SOURCE `436919b2459edb70b0a2d4b236f435489707d090` (2026-11-11), binary SHA-256 `6a19ab3a4b31a8786c5f418634835c434d679908f31f51b35cad3d70deb1824c`. All 11 plugin directories are complete sources from that commit, including README files, with shared libraries from the verified day59 set; bin/ is the set bin/ plus lib/. This supersedes the historical vendor entries below.## Use- Signed out: the month view and "Log in with ident" (top right; the identity selector or the button).- Signed in: click a day to add an event, click an event to edit or delete it. An event has a title, "At a time" (from /to, date and time) or "All day" (from / to, dates), a place and notes. It shows on every day it covers (a day shows fourchips, the fourth says "+N more"). Only the owner sees, changes or deletes an event.- Events are stored as **WorldAPI Events** (https://worldapi.org/standards/event): `$type $version $kind $title$description $start $end $timezone $location $status $visibility $created $updated` plus `owner` (users `@id`). Timedevents: local wall-clock `$start`/`$end` + `$timezone` (the browser's); all-day: `$kind = 'allday'`, date `$start`, exclusivedate `$end` (left out for one day); `$created`/`$updated` are UTC instants; `$visibility` is always `private`.- **Short ids (ident#23, antcolony mission 039)**: `users.identity` holds what ident's exchange answers — since ident#23 the identity'spublic 5-character short id (`a68sz`), before that the per-app id (32 hex); `lib/util.hl isIdentId` accepts both (the old`isHex` check refused short ids). The switch: one-off `tools/migrate-short-ids.hl` (old → short id, idempotent, never`finish`), gate `node tests/short-id-switch.mjs` (ports 8722/8723, no browser), runbook`antcolony-docs/docs/short-id-switch.md` (Byrodin: `/CONTAINERS/projects/antcolony/docs/short-id-switch.md` once synced).## Reminders and notifications (ticket #4)- **Reminder settings** (button under the month, signed in): the calendar's default reminders — 1 hour before and the day before at20:00 until changed. Every event without reminders of its own gets them. In an event, "Calendar's" / "Own" chooses; "Own" is a listof rows (N minutes before, N hours before, N days before at HH:MM), also none at all.- Stored as WorldAPI Event `$reminders` (`{ $before: 'PT1H' }`, `{ $days_before: 1, $time: '20:00' }`); no `$reminders` = inherit; thedefaults are the Calendar's `$reminders` in `storage/mpackdb/settings.db` (one row per owner).- The page keeps the events of the next days with the reminders that apply (`soon`, part of the page state — the offline layer stores it)and sets one browser timer per reminder of the next 7 days (`arm()`; set again after every save / delete / paging and every 10 minutesof use). A timer shows the notification (hl:web `notify`, through the service worker). "Turn on notifications" is the click the browserwants before it allows them.- **Missed reminders (calendar#9):** a phone freezes or drops an app it switched away from, and its timers with it. Eachdevice keeps in `localStorage` (`calendar-reminded-until-<users @id>`) the instant up to which it planned or showed thereminders; every `arm()` first shows, at once, the reminders that came due since then for events that have not startedyet (one per event, "Starts at 14:00" instead of "Starts in 1 hour"; none kept yet = the last 12 hours). `arm()` alsoruns whenever the app is shown again (`visibilitychange` → visible, `pageshow`; listeners set on the first touch).- **Offline:** the timers need no network, and the offline page has `soon`. An event saved while the server cannot be reached shows at once,its reminders are set, and the save waits in hl:web's emit queue until the connection is back.- **Limits (Hybriel gaps, calendar mission 003, report `reports/003-notifications-never-fired.md`):** (1) a timer lives only whilethe app is open AND in front — on a phone that is almost never at the reminder time; a closed, frozen or dropped app is onlyreached by **Web Push**, and Hybriel has none (hl:crypto: no ES256 / ECDH / HKDF / AES-GCM for VAPID and the payload; hl:web'sservice worker has no `push` listener; no `pushManager.subscribe`). (2) hl:web has no client hook when a page is shown, sonothing is planned (and "Turn on notifications" is not offered) until the first pointer / focus / touch on the month view.`notifyAt` cannot cancel, so `arm()` uses `setTimeout` directly and calls `notify` (hl:web: through the service worker's`showNotification`, which Chrome on Android requires — `new Notification()` is refused there).- Code: `components/month-view/reminders.hl` (rows ↔ `$reminders`, describe, time-zone instants, the plan) shared by `lib/settings.hl` (settingstable), `lib/events.hl` (`upcoming`) and `month-view.hl` (editor, timers).## Web Push (calendar#9 part 2: reminders reach the phone with the page closed)- Turning notifications off for a device: "Turn off on this device" (kept per user in the browser). Turning notifications on (button "Turn on notifications", or at the first visit of a device that already allowed them) subscribes the device(`subscribePush`) and hands the subscription + the device's time zone to the face `calPushSave`; `lib/push.hl` stores it in`storage/mpackdb/push.db` (one row per endpoint, max 10 per user). The server's clock (`CALENDAR_PUSH_EVERY` seconds, default 30) sendsevery reminder that came due to every subscription of the owner (`sendPush`, VAPID + aes128gcm), at most 15 min late; 404/410 drops thesubscription. The service worker (hl:web) shows it; the tag is the page's own, so a page that is open shows ONE notification.- Settings (env / `.env`, all three or none; without them there is no push and nothing else changes): `CALENDAR_PUSH_PUBLIC`,`CALENDAR_PUSH_PRIVATE`, `CALENDAR_PUSH_SUBJECT` (`mailto:…`). Make the pair once: `./bin/hybriel tools/vapid-keys.hl`, put the three lines intothe server's `.env` (Byrodin, beside project.hl; docker `--env-file`). NEVER commit the private key. A new pair invalidates stored subscriptions(devices re-subscribe at their next visit; delete `push.db*`). Test only: `CALENDAR_PUSH_ALLOW_HTTP=1` allows http endpoints (the gate's fake service).- Gate: `PUSH_GATE_PORT=8788 node tests/push.mjs` (fake push service that decrypts like a user agent); `tests/push-real.mjs` = the real FCM run by hand.## LayoutCode order (antcolony `docs/code-order.md`, calendar mission 001): `project.hl` is the map (config, routes, audience, anindex of which file handles what); one `lib/` file per topic holds its central logic, `lib/<topic>-helpers.hl` what itlooks up; the function route and the faces are thin wrappers. `let` only for a variable that is reassigned (or re-boundin a loop body). Imports go one way: util ← users, settings, events-helpers ← events ← api-helpers ← api ← project.hl.| file | what ||---|---|| `project.hl` | the map: index comment, PWA config, routes, audience, server || `lib/events.hl` | `events` table (`storage/mpackdb/events.db`, index `owner`) and every write to it (`saveEvent` / `createEvent` / `changeEvent` / `deleteEvent`), `eventsBetween`, `upcoming`, `soonOf`, the faces' answers `calendarView` / `settingsView` || `lib/events-helpers.hl` | `build` (page fields → WorldAPI Event, strict validation), `viewOf`, `isLocalId`, `validWindow`, `byStart`, size limits || `lib/settings.hl` | `settings` table (`storage/mpackdb/settings.db`, unique `owner`): the default reminders (`defaultsOf`, `saveDefaults`) || `lib/users.hl` | `users` table (ident identity → user `@id`), ident config + exchange, `userOfLoginCode` (both logins), `userIdOfSession`, `tagOf` || `lib/api.hl` | `/login/callback` (+ `loginFailed`; take `&req`, `&sessions`) || `lib/api-helpers.hl` | `safePath` (the login's `?next=`) || `lib/util.hl` | `envOr`, `storageDir`, `countOfList`, `firstOf`, `isHex`, `isIdentId` || `components/main.hl` | the shell with the login, faces `calendarLogin` / `calendarLogOut` || `components/calendar.hl` | the page `/` and the faces `calLoad` / `calSave` / `calDelete` / `calSettingsLoad` / `calSettingsSave` / `calSaveQueued` || `components/loginfailed.hl` | `/login/failed` || `components/styles.hl` | the app's OWN CSS only (month grid, chips, editor); the look comes from `theme/` (layouts dbe3de7) and the tokens || `theme/` | the layouts theme (shell ContentFirst / AppHeader / MainMenu / UserMenu / Sidebar) + `check-theme.mjs` || `tools/migrate-short-ids.hl` | one-off ident#23 migration || `tests/browser.mjs`, `tests/short-id-switch.mjs`, `tests/notify-paths.mjs` | the gates (below) || `tests/realdata-baseline.mjs`, `tests/realdata-compare.py` | same-output check of two code trees on a live-data copy (below) || `tests/letcount.py` | code-order counts: root `.hl` files, project.hl lines, `let`s (`-v` lists any that should be plain) |- `components/month-view/` the month view, vendored from components.hybriel.worldapi.org and EXTENDED here (events on thedays, the editor; `dates.hl` = date helpers shared with the server; it carries its own `Style`). Re-vendoring needs these changes carried over.- `login.js` is the ident selector bridge and stays by caramboleyo's explicit rule (RULINGS 2026-10-26). The month view reads the browser's today / language / time zone itself (Hybriel `Date` / `Intl` in a handler, on the first pointer / focus / touch), no `month-view.js`.- PWA (ticket #3): installable and offline through hl:web's own support — `appIcons`, `appThemeColor`, `offline = [ Calendar ]` in project.hl (manifest link in the head, `/__hl/manifest.webmanifest`, `/__hl/sw.js`); icons in `icons/`. No JavaScript of ours.- **Mission 009:** vendored again = Hybriel master **022a3ac1** (bin/hybriel sha256 `6e0f77d7…`, plugins whole); the reminder times use hl:time `fromLocal` in the browser too (`components/month-view/reminders.hl`; the page and the Web Push clock run the same `planBetween` / `missed`, no `lib/push-plan.hl`); `tests/dst.mjs` + `tests/dst/` check them across DST.- `bin/hybriel` + `plugins/` (core crypto data fetch fs http http1 mpackdb proc time web) are vendored = the shared STATIC Hybriel build**0f396652** (2026-10-19, `/media/STORAGE/claude-scratch/vendor-0f396652`, README.txt there), bin/hybriel sha256 `60fa02f3…c39080`(statically linked); previous copy 06617221 (sha256 `21059cc7…d77bdb`). Compose: cache volume `hybriel-cache` + `HL_CACHE_DIR` + tmpfs /tmp +`init: true`; a gate start waits up to 150 s (cold compile ~20 s). Gates: `CALENDAR_GATE_PORT=8760 CALENDAR_GATE_IDENT_PORT=8761 CALENDAR_GATE_CHROME=8762-8769node tests/browser.mjs` 78/0, `NOTIFY_GATE_PORT=8760 NOTIFY_GATE_SCRATCH=<short path> node tests/notify-paths.mjs` 7/0 (3 Hybriel gaps; Chrome'ssocket path must stay < 108 chars), `CALENDAR_SWITCH_IDENT_PORT=8760 CALENDAR_SWITCH_PORT=8761 node tests/short-id-switch.mjs` 18/0 (not in deploy.sh).Memory: `LOADS=N PAGES=N node .scratch/w074/memtest.mjs <app dir> <mpackdb copy> <label> 0muh8y8myb5z` (port 8760, Chrome8761–8769; RSS marks every 250): 1000 loads + 1000 pagings new 194 → 214 → 218 MB, old 190aa11d 194 → 227 → 231 MB.Before: master 190aa11d (2026-10-02, antcolony mission 072: fc838894 GC correctness (string index / plugin error read freed memory),038d84b3 #126 returned closure scopes, #127 d98926c6/04df4428; no lambda semantics change since 8efba065), sha256`860f5e61…0a23626`, built read-only from `git archive 190aa11d`; previous copy (8efba065) in `.scratch/pre-072/`. Gates:`CALENDAR_GATE_PORT=8720 CALENDAR_GATE_IDENT_PORT=8721 CALENDAR_GATE_CHROME=8722-8729 node tests/browser.mjs` 78/0,`CALENDAR_SWITCH_IDENT_PORT=8730 CALENDAR_SWITCH_PORT=8731 node tests/short-id-switch.mjs` 18/0. Memory:`.scratch/w072/memtest.mjs` (port 8720, Chrome 8721-8728, same args): 200+200 new 194 → 214 → 215 MB (old 283 → 368 → 376),1000+1000 new 229 → 233 MB — flat.Before: master 8efba065 (2026-10-02, antcolony mission 069: #126 memory freed by bytes too, #48 lambda parameters COPY; earlier ff51cf46 #113,#115/#116, #118, client SVG namespace, hl:markdown #111; #103–#106, #94, #83, #82, #95–#97). Built from aread-only `git archive master` (`zig build -Doptimize=ReleaseFast -Dtarget=x86_64-linux-gnu.2.39` in `native/`, zig =hybriel's `native/zig-toolchain` link), sha256 `56b108f3…f4f201ea`. **No local patch**: re-vendor = copy binary + theplugins above, run both gates. Previous copy (ff51cf46): `.scratch/pre-069/`.- **Lambdas copy their arguments (hybriel #48)**: `f = (x) => { x.n = 1 }` changes a COPY; a lambda that must change thecaller's hybrid/list takes `&x`. Audit 2026-10-02 (`python3 .scratch/w069/lambdas.py` / `lambdas2.py`, 64 lambdas): nonewrites a parameter the caller reads — `project.hl` failed/loginCallback save `req.session` themselves, the rest build newvalues. WRONG for `failed(req, why)` with a cookie: its write was lost ("the login did not finish" instead of thereason) — fixed in calendar mission 001 by `&req`/`&sessions` (lib/api.hl). Probe: `bin/hybriel .scratch/w069/probe48.hl`. New lambdas: use `&` when the caller relies on the change.- Memory check (#126): `node .scratch/w069/memtest.mjs <app copy> <mpackdb copy> <label> <users @id>` (port 8730, Chrome8722-8729; env LOADS/PAGES): RSS at boot, after N signed-in page loads, after N month pagings (calLoad), after 5 s idle.- `validWindow` / `soonOf` (were plain members of `components/calendar.hl` since antcolony mission 048) are statics in`lib/events-helpers.hl` / `lib/events.hl` since calendar mission 001; the gate checks both (bad window refused, `soon`).- Language of the first render (calendar#6): `components/calendar.hl` declares `headers = null` (hybriel #105) and hands`headers['accept-language']` to `MonthView { acceptLanguage = requestLanguage }`; `names.hl` knows en de fr es it nl pt,any other → neutral names until the browser fills in its own. Names written by the server stay while paging.- Reminder timers: `arm()` creates the `setTimeout` closure inline in its `while` loop — `p` is a new binding per pass(hybriel #106). On an older Hybriel the closures shared `p` and only the last reminder fired (antcolony mission 037 proved it:gate on 13ef4f9b → "the notifications came on time" FAIL, only "Has its own reminder" came).## Run, test, deploy- `CALENDAR_PORT=8700 ./bin/hybriel project.hl` (env: `CALENDAR_WATCH=0` no watcher, `HL_HOST`, `CALENDAR_SESSIONS`,`CALENDAR_STORAGE`, `CALENDAR_PUBLIC_URL` default https://calendar.worldapi.org, `IDENT_URL`, `IDENT_EXCHANGE_URL`,`IDENT_API_KEY`, `IDENT_API_SECRET` — `.env` beside `project.hl`, never read by workers). A login needs the ident key.- `node tests/browser.mjs` — the gate: own ident (a copy without `.env`), own server + storage, headless Chrome(ports 8700 app, 8701 ident, 8702–8709 Chrome; `CALENDAR_GATE_PORT`, `CALENDAR_GATE_IDENT_PORT`, `CALENDAR_GATE_CHROME`).Second gate: `node tests/short-id-switch.mjs` (ports 8722/8723; `CALENDAR_SWITCH_IDENT_PORT`, `CALENDAR_SWITCH_PORT`).`GATE_SKIP_EVENTS=1` skips the events part (40 checks run instead of 76, ~1.5 min instead of ~4). The language checks (`languagePart`)open a tab per language with CDP `Network.setExtraHTTPHeaders` Accept-Language de / en and the browser's own language(Intl locale + navigator.language) set to the OTHER one; first page, server HTML, next/next/prev.Known flake: one run in a few times out on "next month" (a loaded machine; see STATUS 2026-09-26) — run it again.- `node tests/notify-paths.mjs [app dir]` — where a reminder fires (calendar#9): six phones (390 px, touch, Android UA), oneidentity and one Chrome each, all at once (~4 min): permission, open untouched, open touched (+ not twice), switched away(frozen), tab dropped, closed (+ opened again). `NOTIFY_GATE_PORT` (default 8700; ident +1, Chrome +2…+7),`NOTIFY_GATE_SCRATCH`, `NOTIFY_GATE_ONLY=a,b`. What needs a Hybriel piece prints `GAP` and is not counted(`NOTIFY_GATE_STRICT=1` counts it). Give an old tree as the argument to see the old behaviour.- `python3 tests/letcount.py . [-v]` — code order: must say `never reassigned 0`, root .hl files 1.- **Same output** (for a cleanup that must not change behaviour; calendar mission 001): a copy of the live tables, thenthe old tree and the new tree each answer the pages (signed in as az5b2 = users `0muh8y8myb5z`, and signed out; de/fr),the browser modules, `calLoad` for every month with a live event, the login route/faces against a fake ident, and afixed write sequence through the faces (create appointment / all-day / overnight / own reminders, 18 refusals, edit,offline queue with a `local-` id, delete, a live event changed and deleted, the defaults, logins, logout); then:```tar -C /CONTAINERS/projects/calendar.worldapi.org -cf - storage/mpackdb | ssh loreana tar -C <repo>/.scratch/realdata -xf - # on Byrodingit archive <old commit> | tar -C .scratch/old -xf - && cp -a bin plugins .scratch/old/node tests/realdata-baseline.mjs .scratch/old 8762 .scratch/base-old # app on 8762, fake ident on 8767 (port + 5)node tests/realdata-baseline.mjs . 8762 .scratch/base-newpython3 tests/realdata-compare.py .scratch/base-old .scratch/base-new -v # exit 0 = the same```It masks only source positions, `?v=` / `hl-shell-` hashes, request times, the Host port and (writes) new ids, ms stampsand login tags; browser modules count as the same when their own code and the imported functions they use are. Tworuns of the same tree compare clean. Run both trees on the same UTC day (`soon` follows the server's today). Deletethe live copy and the outputs afterwards.- `./deploy.sh` on Loreana (architect): gate → backup → rsync → `docker compose up -d --build` on Byrodin (127.0.0.1:45005).## First deploy of ticket #2 (architect)Register the app in ident with the origin `https://calendar.worldapi.org` and put `IDENT_API_KEY` / `IDENT_API_SECRET`into `.env` on Byrodin (as notes does), otherwise the login button has no key.## History and worker briefs- `LOG.md` — append-only history, one dated line per step (moved here from the antcolony LOG on 2026-10-01).- `missions/NNN-*.md` — worker briefs for this app; `reports/NNN-*.md` — their reports (same name). Numbered perproject since 2026-10-01 (antcolony#40); older text, code comments and commits use the old antcolony numbers →map: `/media/STORAGE/projects/antcolony-docs/docs/mission-map.md` (Byrodin: `/CONTAINERS/projects/antcolony/docs/mission-map.md`).
Branches
- calendar-vendor-day61
- hl-standard
- hl-standard-3
- mainmain branch
- vendor-day56
- vendor-day59
Latest commits
- b37cc1da|||PR Vendor Hybriel day59Atlas
- 05665102Merge branch 'vendor-day56' into mainAtlas
- 687296fb|||PR Vendor Hybriel day56Atlas
- a6166d4eMerge branch 'hl-standard-3' into mainAtlas
- 6d0eb3b0|||PR Calendar day add buttons only when signed in (Kunibert minor)Atlas
- add4b499|||PR Make calendar day actions keyboard accessibleAtlas
- 79e49b4dMerge branch 'hl-standard' into mainAtlas
- e9fec7bb|||PR HL-STANDARD clean-up: typed parameters, plain locals, by-reference cacheAtlas
- eff166a4Re-vendor complete Hybriel plugins and runtime to day44mre
- cef81394Wait for the DST fixture page instead of an unused socketmre
- 42434f47Check lazy-session cookies after login with a stored anonymous fixturemre
- 728e84e3Re-vendor complete Hybriel day41 plugin directoriesmre
- cbd7ff43Backup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
- 59d1da0acalendar: plain declarations instead of needless let in 9 files (calendar#17): 49 declarations that are never reassigned; reassigned ones and the timer closure's p stay letmre
- f5415cf9calendar: the Style blocks in the language's nested form (calendar#16): rules named after the View's own elements with their children nested, pseudo-classes and @media nested, merged duplicate select rule; same CSS, shots identical in Chrome at 4 sizesmre
- edb7c947calendar: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 56+4 failing → 60 passedmre
- bf8cc0fcStyles move into their components: the shell's styles into main.hl, the events and the editors into the month view's Style block; styles.hl keeps only the theme inherit, the accent and the message line; .gitignore ignores a bin symlink too; tests/styles-shots.mjs for the before/after pixel comparemre
- 5d8579d7README: login.js stays by caramboleyo's explicit rulemre
- cc759328Merge sb3-standby: calendar deploys through its standbymre
- f2fcdc6dcalendar: a standby container (port 45015, profile standby, reminder clock off) and a /health page; deploy hands over through standby-swap.sh without a gapmre