| 1 | # π€ Calendar |
| 2 | |
| 3 | A calendar for one team, on one instance. Alongside `oficina/docs` and |
| 4 | `oficina/sheets`, on the same platform, in the same shape. |
| 5 | |
| 6 | This file is binding. Where it disagrees with a general skill, this file |
| 7 | wins. Where it disagrees with the design spec, the spec wins and this |
| 8 | file is wrong β fix it in the same commit. |
| 9 | |
| 10 | **The design:** `docs/superpowers/specs/2026-09-02-calendar-design.md`. |
| 11 | The raw material it came from, including the rejected alternatives, is |
| 12 | `docs/superpowers/brainstorms/2026-09-02-calendar-brainstorm.md`. |
| 13 | |
| 14 | --- |
| 15 | |
| 16 | ## The one rule |
| 17 | |
| 18 | > **An event's contents are sealed at rest. The bucket never holds a |
| 19 | > plaintext title, place or note.** |
| 20 | |
| 21 | The falsifiable form: **publish this database in full and the worst |
| 22 | anyone learns is the shape of the team's time** β when they are busy, |
| 23 | for how long, how often, and in which zones β **and who is on the team. |
| 24 | Never what any event is, where it is, or what was written about it.** |
| 25 | |
| 26 | `TestTheDatabaseNeverHoldsAPlaintextTitle` enforces it from the first |
| 27 | commit, and it greps the raw SQLite bytes and the WAL rather than |
| 28 | asking SQLite: a column that was never sealed looks identical through |
| 29 | Go and completely different on disk. It checkpoints first, or it would |
| 30 | pass by reading a file the data has not reached. |
| 31 | |
| 32 | ### What this rule does NOT cover, said here so it is never read as covering it |
| 33 | |
| 34 | 1. **Times are plaintext, and free/busy is a real leak.** Every view is |
| 35 | a range query, `NextDue` reads `MIN(due_at)` before any request, and |
| 36 | the platform's own timer registry holds reminder instants anyway. |
| 37 | Sealing the instants would claim a property the estate does not |
| 38 | have. A published database gives up the team's whole free/busy. |
| 39 | 2. **A reminder email carries the title** through the relay and into a |
| 40 | mailbox. That is delivery, not storage, and it is the product |
| 41 | working β but the relay's logs are not ours. |
| 42 | 3. **A subscription feed puts plaintext in whoever's account it was |
| 43 | pasted into.** The share page says so before the button, not after. |
| 44 | 4. **A compromised live host reads everything.** We never claim "we |
| 45 | cannot read your data." |
| 46 | 5. **A PUBLISHED booking page is a live free/busy oracle for that host, |
| 47 | to anyone, without the database.** Every calendar the host can see |
| 48 | shapes the answer. This is a NEW disclosure, not the one above, and |
| 49 | the Publish button says so in a sentence before it is pressed. |
| 50 | |
| 51 | --- |
| 52 | |
| 53 | ## Settled decisions |
| 54 | |
| 55 | | # | Ruling | Rejected | Who, when | |
| 56 | |---|---|---|---| |
| 57 | | 1 | **Store what the person said**: wall-clock time plus IANA zone is the record; the UTC columns are a derived index | Storing the instant as truth β a tzdata update then moves a meeting and nobody can say what was meant | This session, 2026-09-02 | |
| 58 | | 2 | *(Superseded 2026-09-29: the suite's theme is estilo's Calma β estilo AGENTS.md row 8 β so Calendar now serves `theme.ForApp("calendar")`, written to static/theme.css by scripts/writeestilo and pinned by TestThemeIsEstilosForCalendar.)* Pin rastrillo v0.23.0 and take theme `day` directly from `ui.ThemeCSS` | Consuming `estilo`, which is `day` byte-for-byte today and pins v0.22.0 β adopting it buys nothing and drags us back a release ("the two-pins trap", estilo's own AGENTS.md) | This session, 2026-09-02 | |
| 59 | | 3 | This app's own components take `cal-` | `rst-` is the framework's and a future release may claim a name; `estilo-` is the suite's, and a month grid is not a suite component until a second app copies one | This session, 2026-09-02 | |
| 60 | | 4 | The recurrence subset is the six a picker offers; anything else is stored verbatim, flagged, and not expanded | Refusing a rule we cannot expand β an importer that eats a rule it does not understand eats data | This session, 2026-09-02 | |
| 61 | | 5 | Reminders are per PERSON, not per event | Per-event reminders β two people on one meeting want different warnings, and the fix needs a person column anyway | This session, 2026-09-02 | |
| 62 | | 6 | Delivery is at-least-once; every ambiguous case resolves towards sending | At-most-once β a reminder that never arrives is worse than one that arrives twice | This session, 2026-09-02 | |
| 63 | | 7 | Local sign-in is a magic link, with no passkey second factor | Passkeys β `passkey.Config` derives its relying party from this instance's host, so one person in three team instances enrols three credentials. Same ruling docs made | This session, 2026-09-02 | |
| 64 | | 7a | Local sign-in uses Keymail for an address whose domain runs Keymail, and the magic link for every other address β chosen by the domain alone, never by the allowlist (an oracle otherwise). The Keymail hop is a continuation page (since the smart door, the door's own `/signin?continue=` state), never a 303 out of the form POST (Safari applies form-action to it) | Forcing every address to a magic link | Paul, 2026-10-06 ("I do want it to use keymail") | |
| 65 | | 8 | A new event defaults to the person's PERSONAL calendar | Defaulting to the team calendar β the cost of forgetting to change a dropdown should fall on the side of privacy | This session, 2026-09-02 | |
| 66 | | H1 | **Optional Home sign-in connects to an existing person after fresh local proof and explicit confirmation; local sign-in remains available** | Treating the Home subject as an email or allocating a new person | User-approved suite connection, 2026-09-10 | |
| 67 | | T1 | **Team mode (`CALENDAR_TEAM_*`): Home's roster decides standing on every request**; a roster Member with no account here gets an addressless Home-only person through connect's `Unlinked` hook (H1 holds outside team mode) | The allowlist deciding a team instance; storing an address for a Home-only member (a new address column: its own privacy review, Fable on oficina/home #98) | Home team-members.md Part B (Fable #92), Paul's port order 2026-10-27; spec Β§7 "Roster team mode" | |
| 68 | | T2 | **In-app reminders**: a reminder channel `inapp` (and `both`) whose delivery writes a reference-only notice (event, occurrence, person) in Calendar's own database; Home-only members get it by default and only it; people with an address choose on Settings | Option (b), an opt-in typed address stored sealed (a new address column, its own privacy review); option (c), reminders only through linked local accounts | Paul, 2026-11-01; Fable's recommendation on oficina/calendar #35; spec Β§7 "In-app reminders" | |
| 69 | | B1 | A booking is confirmed by a BUTTON on the page the mailed link opens β a same-origin POST β never on submit and never on GET | Instant confirmation; confirming on the GET, which every link-scanning mail gateway would press | Booking spec Β§1, 2026-09-07 | |
| 70 | | B2 | Everything the host can see is busy β every calendar they hold a grant on | Personal only | Booking spec Β§1, 2026-09-07 | |
| 71 | | B4 | The public identifier is a chosen plaintext `handle` plus a GENERATED page code | A chosen slug β prose joined to events | Booking spec Β§1, 2026-09-07 | |
| 72 | | B5 | Booking mail is the ONE outbound to a non-team address, and only to an address the recipient typed in order to receive it | Emailing quick-add attendees "while we're at it" | Booking spec Β§1, 2026-09-07 | |
| 73 | | B8 | A held slot is a tentative EVENT | A holds table the slot query consults | Booking spec Β§1, 2026-09-07 | |
| 74 | | B11 | The EVENT's `sequence` is the one revision counter, bumped as `sequence + 1`; every booking-side write names the revision it expects | A booking sequence; a stale-read `+1` | Booking spec Β§1, 2026-09-07 | |
| 75 | | B12 | Hold and reschedule serialise on a process mutex AND take SQLite's write lock before the final busy read, inside the transaction that inserts | The mutex alone; a busy read before `BEGIN` | Booking spec Β§1, 2026-09-07 | |
| 76 | | B13 | Mail is a queue table, one row per (booking, kind, recipient, revision), claimed with an identity and a lease, acknowledged conditionally on that identity | A marker column | Booking spec Β§1, 2026-09-07 | |
| 77 | | B14 | The management token is 32 random bytes, hex, stored SEALED as well as hashed | Hash only, as feeds do | Booking spec Β§1, 2026-09-07 | |
| 78 | | B15 | A hold expires at the EARLIER of thirty minutes and the meeting's start; confirmation requires now < start | Thirty minutes flat | Booking spec Β§1, 2026-09-07 | |
| 79 | | B16 | No sender error is "definite"; nothing is freed because a send failed | Marking holds failed | Booking spec Β§1, 2026-09-07 | |
| 80 | | B17 | A slot is the same length on the wall clock and the elapsed clock, or it is not offered | Round-tripping the start only | Booking spec Β§1, 2026-09-07 | |
| 81 | | B18 | A booked event's scheduling β start, end, tz, all_day, kind, rrule β belongs to the booking flow; the host's form shows them disabled and a save that changes any is refused | Invariant checks on host-supplied times | Booking spec Β§1, 2026-09-07 | |
| 82 | | B19 | Mail says the CURRENT state; a transition deletes every unsent row the new state makes false | Historical snapshots per row | Booking spec Β§1, 2026-09-07 | |
| 83 | | B20 | The booker sees the page's title and description AS THEY WERE at hold time, snapshotted sealed onto the booking | Live page text | Booking spec Β§1, 2026-09-07 | |
| 84 | | B21 | Reschedule writes `tz` = the host's current zone atomically with both local strings and both UTC columns | Leaving `tz` as it was | Booking spec Β§1, 2026-09-07 | |
| 85 | | B22 | Both queues carry a random `claim_id`; every completion mutation is conditional on it and built from the row the claim returned; reminders retry through `retry_at`, never `due_at`; `ErrMailBusy` defers without counting an attempt | Claim by timestamp; retry written into `due_at` | Booking spec Β§1, 2026-09-07 | |
| 86 | | B23 | Availability FAILS CLOSED: a busy series that could not be expanded to completion, or whose rule this app cannot parse, is a 503, never "free" | Trusting `Expand`'s slice | Booking spec Β§1, 2026-09-07 | |
| 87 | | B24 | Reschedule repairs the event's reminder queue rows INSIDE its transaction | After commit | Booking spec Β§1, 2026-09-07 | |
| 88 | | B25 | A booked event's form carries its scheduling snapshot as hidden inputs, including the event's own `tz`, with the controls disabled | Disabled controls alone, which submit nothing | Booking spec Β§1, 2026-09-07 | |
| 89 | | B26 | Reschedule enumerates the event's reminder RULES and upserts a queue row for each | Rebuilding the rows that exist | Booking spec Β§1, 2026-09-07 | |
| 90 | |
| 91 | Don't relitigate one in a drive-by. |
| 92 | |
| 93 | --- |
| 94 | |
| 95 | ## Mechanical rules |
| 96 | |
| 97 | Rules here are enforced by tests, not by memory. If you find yourself |
| 98 | relying on remembering one, make it a test instead. |
| 99 | |
| 100 | **Time** |
| 101 | - **The record is `start_local` + `tz`. The UTC columns are an index.** |
| 102 | Anything that writes a UTC column without deriving it from the local |
| 103 | pair is a bug. |
| 104 | - **DST has no correct answer and Go does not promise one.** `clock.go` |
| 105 | documents what actually happens and `clock_test.go` pins it to real |
| 106 | unix numbers. The gap and the fold resolve DIFFERENTLY β the gap takes |
| 107 | the pre-transition offset, the fold takes the second occurrence. Do |
| 108 | not reason about one from the other. |
| 109 | - **A day is 23, 24 or 25 hours.** Use `DayBounds`, never `Add(24h)`. |
| 110 | - **`Zone()` takes bounded input on public routes:** `CommonZones` plus |
| 111 | the host's own zone. Its cache holds successes only. |
| 112 | - **A booking slot is the same length on the wall clock and the elapsed |
| 113 | clock, or it is not offered.** Both ends round-trip through `ToUTC`. |
| 114 | - **Every range is half-open.** An inclusive end is how a one-day event |
| 115 | shows on two days and how a week query double-counts its boundary. |
| 116 | - **All-day events are DATES.** Never a datetime at UTC midnight, which |
| 117 | puts a birthday on the wrong day west of Greenwich. |
| 118 | |
| 119 | **Recurrence** |
| 120 | - **COUNT counts GENERATED occurrences; EXDATE removes afterwards.** |
| 121 | - **`Expand` may stop early.** Anything that decides FREE time reads |
| 122 | `EventsInRangeStrict` and fails closed on `ErrIncompleteExpansion`. |
| 123 | - **A day span is a difference of CIVIL dates, never elapsed hours over |
| 124 | 24.** And advancement carries the series' ORIGINAL clock onto each |
| 125 | new date β never the previous occurrence's resolved time. |
| 126 | - **A named date a month does not have is NO occurrence** β never |
| 127 | clamped. The 31st, 29 February, the fifth Friday. |
| 128 | - **Overrides are keyed by the occurrence's ORIGINAL local time and |
| 129 | rendered at their new one.** The range query is two passes because of |
| 130 | it. Skip the second and a moved occurrence vanishes; skip the dedupe |
| 131 | and it appears twice. |
| 132 | - Expansion iterates in **wall clock**. Stepping a UTC instant moves a |
| 133 | 09:00 standup by an hour for half the year. |
| 134 | |
| 135 | **Data** |
| 136 | - Every scoped read goes through a grant join. **A row that isn't yours |
| 137 | 404s, never 403s** β including for a write, so status codes cannot |
| 138 | enumerate the team's calendars. |
| 139 | - **Booker name, address, note and TOKEN are sealed; the address has |
| 140 | the keyed fingerprint. A page's public code is generated, never a |
| 141 | chosen slug β a slug is prose. Booking windows are plaintext: |
| 142 | shape-of-time.** |
| 143 | - **Every booking transition is a conditional UPDATE naming the state |
| 144 | and revision it expects, checking RowsAffected.** Zero rows is |
| 145 | "someone moved it first", never a retry. |
| 146 | - **A booked event's start, end, tz, all_day, kind and rrule belong to |
| 147 | the booking flow.** A host edit that changes any of them is refused; |
| 148 | the form shows them disabled with the stored values hidden beneath. |
| 149 | - **Never bind a request body onto a model.** Updates take an explicit |
| 150 | column allowlist; the columns absent from it (`calendar_id`, |
| 151 | `created_by`, `series_id`) are exactly the ones a hidden field must |
| 152 | not move. |
| 153 | - **Never `sessions.UserID`** β under the magic-link plugin the Subject |
| 154 | is an address, so it returns `(0, false)` and every query silently |
| 155 | scopes to person 0: a calendar that looks empty rather than broken. |
| 156 | Use `auth.From(r)`, and `requirePerson` for the id. |
| 157 | - **A Home session subject is opaque.** Resolve its explicitly linked person ID |
| 158 | before any grant lookup. Never pass it to `EnsurePersonSetup` or use it as an |
| 159 | address. Recheck current admission and retain AUTOINCREMENT person IDs without |
| 160 | reuse or reassignment. Home proof storage uses a separate stable connection key. |
| 161 | - Migrations are additive-only. Never edit one that has shipped. |
| 162 | |
| 163 | **Ticks** |
| 164 | - **A `time.Ticker` is not a scheduler.** The instance hibernates. |
| 165 | - **`NextDue` is the earliest CLAIMABLE instant** across reminders, hold |
| 166 | expiries, owed booking mail and IP-forgets. New scheduled work goes |
| 167 | here, never in a goroutine. Cheap work runs before delivery; |
| 168 | reminders get the first half of the delivery budget. |
| 169 | - **Every queue row has a random `claim_id`;** every completion |
| 170 | mutation is conditional on it and checks RowsAffected, and a payload |
| 171 | is built from the row the claim returned, never from the candidate |
| 172 | read. A reminder's `due_at` is the occurrence minus the offset and is |
| 173 | never written by a retry β `retry_at` is. Booking mail's `due_at` is |
| 174 | retry eligibility only. |
| 175 | - **No sender error is definite.** Never free a resource because a send |
| 176 | "failed". Every send goes through `boundedSender`; `ErrMailBusy` is a |
| 177 | deferral, not an attempt. |
| 178 | - **A reschedule repairs the event's queue rows in the same transaction |
| 179 | as the move.** |
| 180 | - **The tick route is mounted OUTSIDE `csrf.Protect`.** `csrf.Protect` |
| 181 | refuses any POST with no `Sec-Fetch-Site`, `Origin` or `Referer`, and |
| 182 | the scheduler sends none; inside the protected router a tick 403s |
| 183 | forever and the platform reads 4xx as "do not retry". It fails |
| 184 | silently and permanently. `TestTheTickRouteIsNotBehindCSRF` stands in |
| 185 | front of it and asserts WHICH refusal answered. |
| 186 | - **Work inside the request.** 202-plus-a-goroutine is a reliable way to |
| 187 | be hibernated mid-send. |
| 188 | - **Ticks are expensive.** `CARLOS_HIBERNATE_IDLE` defaults to 15 |
| 189 | minutes, so each tick buys a quarter hour of billed residency. The |
| 190 | declared schedule is 6h and the precision comes from `NextDue`. |
| 191 | |
| 192 | **Frontend** |
| 193 | - Write the **`rst-*` attribute grammar** (`rst-btn="primary"`), never |
| 194 | the class spelling. Adopt per screen, never per element. |
| 195 | - This app's own components take **`cal-`**. |
| 196 | - **No affordance may require script.** The scriptless page is the |
| 197 | product; `datetime.js` and any later enhancement sit on top of a |
| 198 | working floor. |
| 199 | - **Colour never carries meaning alone.** Every chip prints its own |
| 200 | time and title; cancelled says "Cancelled"; past is written in the |
| 201 | past tense; today has three signals. |
| 202 | - Light/dark is three states and **auto is the ABSENCE of |
| 203 | `data-theme`**. The attribute takes the light/dark SCHEME, never |
| 204 | rastrillo's theme NAME. |
| 205 | - **Quick add has ONE parser and it is the Go one.** The live pane is a |
| 206 | fetch to `/events/quick/parse`. Never add a second parser in |
| 207 | JavaScript: two readings of "next Tuesday at half three" means the |
| 208 | time shown is not the time saved. |
| 209 | - **Attendees are recorded, never invited.** Nothing emails them, every |
| 210 | surface that names one says so, and their addresses are sealed with a |
| 211 | KEYED fingerprint for lookup β an unkeyed hash of an address is that |
| 212 | address in a different alphabet. |
| 213 | - **Except a BOOKER, who typed their address to be mailed.** Booking |
| 214 | mail is the one outbound to a non-team address. |
| 215 | |
| 216 | **Browser** |
| 217 | - `make browser` is the painted-output gate: Playwright, run from |
| 218 | `TestQuickAddInARealBrowser`. It is NOT in `make ci` β the one gate |
| 219 | everybody runs must not need a toolchain the app does not use. |
| 220 | - It runs the feature twice, the second time with **JavaScript |
| 221 | disabled**. That pass is the only proof the scriptless floor is real. |
| 222 | - `make browser` also runs `TestNoZoomOnTap`, through chromedp: every |
| 223 | text control on a touch screen is 16px or more, or iOS zooms the page |
| 224 | on tap. chromedp drives when `RASTRILLO_CHROME` names a Chromium (the |
| 225 | Makefile finds the Playwright cache's on a Mac); it parked at |
| 226 | `about:blank` without one. `TestBrowserWalk` drives now, but fails |
| 227 | at its first sign-in (no link is mailed after its form submit), and |
| 228 | is not in `make browser`; do not assume it ran. |
| 229 | - `make browser` also runs `TestEveryScreenKeepsTheRhythm`: Fiesta's |
| 230 | rhythm audit over every screen at 1280 and 390px, through the |
| 231 | production stack, reading around the calendar grids. Every page but |
| 232 | the four views is Fiesta's stack (`<main rst-stack>`, layout.html): |
| 233 | a page adds no margins between its blocks, and its button rows are |
| 234 | `rst-actions`. `make spacing` (in `make ci`) holds every margin, |
| 235 | padding and gap in Calendar's CSS to `var(--rst-sp-N)` or a |
| 236 | `/* spacing-allow: why */`. |
| 237 | - **A control styled with `font: inherit` under a selector heavier than |
| 238 | a bare `input`** loses tokens.css's 16px-on-touch rule. Restate |
| 239 | `font-size: max(1rem, 1em)` for it under `(pointer: coarse)`, as |
| 240 | calendar.css does for the quick-add box. |
| 241 | |
| 242 | **rastrillo** |
| 243 | - **rastrillo is `amadan.net/rastrillo/rastrillo`.** The old path, |
| 244 | `github.com/carlosframework/rastrillo`, stops at v0.23.0: code |
| 245 | importing it gets no fix, and its own checks cannot tell (Calendar |
| 246 | zoomed iOS on every tap for a month that way). `TestNoPreMoveRastrillo` |
| 247 | allows one import of it, native.go's bridge to rastrillo/native's |
| 248 | server, until that server moves; `native_exchange_test.go` proves the |
| 249 | bridge. The CLI is pinned as a `tool` in go.mod: `go tool rastrillo β¦`, |
| 250 | never a `rastrillo` from PATH. |
| 251 | - **Run `go tool rastrillo doctor` on every rastrillo upgrade**, and |
| 252 | `--fix` to re-copy what drifted (tokens.css, select.js, datetime.js). |
| 253 | It leaves `vendoredIsMine` alone: rastrillo.js (estilo's shim, without |
| 254 | the old busy rule) and theme.css come from estilo through |
| 255 | `go run ./scripts/writeestilo`, and calendar.js is Calendar's OWN |
| 256 | script, not rastrillo's month-grid overlay of the same name. If |
| 257 | `--fix` ever writes rastrillo.js, re-run writeestilo: the old shim |
| 258 | must never load beside busy.js (TestBusyFilesAreEstilos). busy.js is |
| 259 | estilo's too, and shell.css/shell.js are rastrillo's console shell, |
| 260 | which Calendar does not draw. **While go.mod still requires the old |
| 261 | path, doctor compares nothing and `--fix` refuses**: copy the drifted |
| 262 | files out of the new module's `ui/` by hand, and |
| 263 | TestVendoredAssetsMatchTheLibrary says which. That is how v0.42.0 came |
| 264 | in (smart door, 2026-11-22: tokens.css, select.js, datetime.js), and |
| 265 | v0.45.0 (the spacing rollout, 2026-11-22: tokens.css, which carries |
| 266 | Fiesta's stack). |
| 267 | - **From v0.45.0 an unlisted Keymail server is dialed only at a public |
| 268 | address**, by a client rastrillo clones from `http.DefaultTransport`. |
| 269 | The tests' in-process Keymail fixtures (`keymailtest`) wrap that |
| 270 | transport, so the test mains list their servers with |
| 271 | `SetKeymailServersForTest` and auth reaches them through its |
| 272 | listed-servers guard. Deployments leave `KeymailServers` nil. The door |
| 273 | never names Keymail from v0.45.0: its words are rastrillo's. The |
| 274 | library's newer scripts (fiesta.js, live.js, anchor.js, light.js, |
| 275 | transition.js, copy.js) are not linked by the layout and are listed in |
| 276 | `vendoredIsMine` as deliberately absent. doctor's template checks are |
| 277 | blind meanwhile; read each release's markup notes yourself. |
| 278 | - **rastrillo needs its English pack linked** (serving.go's |
| 279 | `_ ".../locales/en"`): from v0.29 a language with no pack is refused at |
| 280 | start, by Serve and Handler alike, and the door's words come from it. |
| 281 | - **An emailed link confirms before it is spent.** GET /auth/verify draws |
| 282 | the door with one Sign in button (`App.renderConfirm`) and spends |
| 283 | nothing, so a mail scanner cannot burn it; the POST redeems. Both are |
| 284 | mounted in both modes. A test that signs in opens the link, reads the |
| 285 | token off the door and POSTs it (`SignInForTest`, `openLink`/`postLink`). |
| 286 | - **Inline style attributes need the CSP's `'unsafe-inline'`.** |
| 287 | rastrillo's default style-src refuses them; the day and week grids |
| 288 | place chips and slots with them and every chip carries `--cal-hue`, so |
| 289 | `ContentSecurityPolicy` (serving.go) widens style-src alone. |
| 290 | `TestProductionCSPIsTheDefaultBarStyles` keeps every other directive |
| 291 | at rastrillo's default, and `TestPlacedChipsSurviveTheProductionCSP` |
| 292 | (`make browser`) is the one browser check that sees the real policy. |
| 293 | A CONSTANT style belongs in calendar.css, never in an attribute. |
| 294 | |
| 295 | **The sign-in door** (Home spec 2026-11-19-smart-door.md, step 6; |
| 296 | home/connect MIGRATING.md) |
| 297 | - **rastrillo's screen in estilo's door**: `SigninScreen` and |
| 298 | `SigninOneWay` on, `SigninPath` `/signin` in both modes, drawn by |
| 299 | `estilo-signin-screen` (signin.go). Its words are rastrillo's approved |
| 300 | copy; only the refusal and team mode's removal are Calendar's. The tab |
| 301 | title is rastrillo's for the state ("Sign in to Calendar"). |
| 302 | - **With Home, three routes**: `/signin` (connect's SigninDoor, Continue |
| 303 | with Oficina ID first), `/signin/local` (email only, where connect sends |
| 304 | people Oficina ID cannot help) and `/signin/oficina`. All three sit |
| 305 | behind `admittedOnly`, which runs requirePerson on a probe: a session it |
| 306 | refuses is ended on that response and shown the refusal (or the |
| 307 | removal), with a remembered Oficina ID forgotten; any 5xx is undecided |
| 308 | and refuses nothing. The probe ends nothing itself (offboard skips its |
| 309 | sign-out under it), and judges only the three methods requirePerson |
| 310 | speaks for (`doorJudges`): a native or guest session is never refused |
| 311 | by the web door. |
| 312 | - **The refusal is on the plain door only**: `?ways=` and `?way=` are how |
| 313 | a refused person reaches another way in. It is never read from the |
| 314 | query; the removal is, as it always was. |
| 315 | - **Oficina ID is remembered in MintHomeSession**, with the resolved |
| 316 | person's address (none for a Home-only member), only for a session the |
| 317 | probe admits strictly, never carried over (`rememberOficina`). |
| 318 | - **The return memory** (signin_return.go, Home only): a sealed ten-minute |
| 319 | cookie, because every local sign-in must land on /auth/local/complete |
| 320 | first. A plain `/signin/local` never overwrites it; a post without |
| 321 | `return_to` resets it; Begin never sees `return_to`, parsed or not; |
| 322 | `/signed-out` reads as `/`; Forget and Sign out clear it. |
| 323 | - **Signed out offers Forget**; with Home it chains on to |
| 324 | `{issuer}/forget?return=<origin>/signed-out`. |
| 325 | - **Team mode passes connect's `Admit`** (`teamAdmit`): a roster Member |
| 326 | with no account here gets connect's choose page |
| 327 | (`/account/home/choose`), in connect's own English. |
| 328 | |
| 329 | **Logs** |
| 330 | - **No title, place, note or address in any log line, error string or |
| 331 | metric label.** `carlos logs` is platform-held storage we cannot grep |
| 332 | afterwards. Errors carry a stage name and a code. |
| 333 | |
| 334 | **Deploys** |
| 335 | - One binary, `CGO_ENABLED=0`, cgo-free SQLite. |
| 336 | - **`carlos deploy`, never `carlos ship` alone.** `ship` leaves the |
| 337 | release unpromoted and nothing serving it. **Until `carlos deploy` |
| 338 | takes `--mail`, the exception is mail submission:** ship with `--mail |
| 339 | submit`, then promote (README, Deploying), because every instance of a |
| 340 | switched app must run a build shipped with the flag. |
| 341 | - **`make release`, never a bare `go build`** β it stamps |
| 342 | `rastrillo.BuildVersion` and refuses a dirty tree. |
| 343 | - **A 200 is not verification, and neither is `X-Carlos-Version`.** That |
| 344 | header is the router's adopted release. `GET /api/version` is served |
| 345 | by the process. Measured here at ~110 seconds behind the promote. |
| 346 | - **`stable` needs a passkey step-up in the console**, and so does |
| 347 | moving an instance between `stable` and `edge`. This app runs on |
| 348 | `edge`, like docs. Create an instance on the channel you want. |
| 349 | |
| 350 | ## Team mode (roster, `CALENDAR_TEAM_*`) |
| 351 | |
| 352 | Spec Β§7 "Roster team mode" is the whole of it; Home |
| 353 | `implementation/teammode-package.md` Β§7.3 and `team-members.md` Part B are |
| 354 | its design. With the five `CALENDAR_TEAM_*` variables set (all or none, |
| 355 | only beside `CALENDAR_HOME_*`), Home's roster decides standing on every |
| 356 | request and `CALENDAR_ALLOWED_ADDRESSES` only admits local sign-in (empty |
| 357 | admits nobody, in every Env). Without them nothing in `team_*.go` runs and |
| 358 | every rule above stands; the one difference is `GET /api/team` answering |
| 359 | `{"team_mode":false}`. |
| 360 | |
| 361 | - **Configuration, marker, runtime and probe are `home/teammode`'s** |
| 362 | (`team_config.go`). The marker is read before anything migrates; a team |
| 363 | database stays a team database. Do not "fix" a refused boot by deleting |
| 364 | the marker (its triggers refuse that anyway). |
| 365 | - **Every grant is the team rung** (`team_reach.go`): Calendar has no |
| 366 | shares, so a scoped read joins through a grant only while the context's |
| 367 | standing is Member, decided once, before the query. A new scoped read |
| 368 | uses `grantJoin` with `s.reaches(ctx)`; a raw `JOIN grants` is a leak. |
| 369 | - **Standing per request** (`team_access.go`, `team_standing.go`): |
| 370 | NotMember is signed out to `/signin?err=removed`; an unlinked local |
| 371 | account is sent to `/account/home`; under Unknown the views are the empty |
| 372 | partial list with the notice and everything else is a retryable no-store |
| 373 | 503 β including a 404 or 500 a lapse caused part-way |
| 374 | (`errorPage`, `fail`). New routes in the session group go under |
| 375 | `memberRoutes` unless they are a view. |
| 376 | - **Every person's write is guarded inside its transaction** |
| 377 | (`team_guard.go`: `s.guarded`, or `s.guard` inside an existing |
| 378 | `Transaction`). `TestTeamEveryWriteRouteRefusesALapseBeforeCommit` lists |
| 379 | every write route and reads the database back; add yours to it. |
| 380 | - **Things that read on somebody else's standing**: a feed on its minter's |
| 381 | (`team_feed.go`: Unknown is a 503, never a short calendar), a booking |
| 382 | page on its host's (`team_booking.go`), a reminder or host mail on its |
| 383 | recipient's (`team_jobs.go`). The drain itself is the system's and |
| 384 | unguarded; what it delivers is decided on the person's standing. A |
| 385 | removed member's reminder rules go dormant (claim `team:dormant`) and |
| 386 | wake on their next request as a Member. |
| 387 | - **Home-only people have no address** (`team_home_only.go`, |
| 388 | `teamstate/`): their `people.address` is a `home-only:` placeholder the |
| 389 | triggers keep that way. Never mail it, show it, or treat it as an |
| 390 | address: `teamstate.Addressless`, `Person.shownAddress`. They publish |
| 391 | no booking page, and their reminders are in-app only (row T2). |
| 392 | - **In-app reminders mark, never send** (`store_reminder_notice.go`, |
| 393 | spec Β§7 "In-app reminders"): a rule's channel is `email`, `inapp` or |
| 394 | `both`; the drain decides on the recipient's standing exactly as for |
| 395 | email, then writes a reference-only `reminder_notices` row under the |
| 396 | claim. No title, no address in it. `/reminders` is a view (partial under |
| 397 | Unknown); dismissing is a guarded member write. A person who never chose |
| 398 | in-app sees every page byte-identical except Settings. |
| 399 | |
| 400 | --- |
| 401 | |
| 402 | ## Shipping cadence |
| 403 | |
| 404 | Worktree per piece of work, branch per piece of work, never on `main`. |
| 405 | Squash-merge only when the work is done, it is approved, and CI is |
| 406 | actually green β checked, not assumed. Review on a deployed canary, |
| 407 | never localhost. |
| 408 | |
| 409 | `make ci` is the one gate: vet, gofmt, the spacing check, tests, |
| 410 | migration check. The same definition CI runs. Run it before every push. |
| 411 | |
| 412 | ## Review |
| 413 | |
| 414 | Every spec and every branch is reviewed by the highest-capability model |
| 415 | available, discovered rather than hardcoded. Record which model |
| 416 | reviewed. A review by a weaker model than the author is not a review. |
| 417 | |
| 418 | ## Authorship |
| 419 | |
| 420 | π€ / π¨ markers, `Co-Authored-By:` trailers. AI is a guest with a name |
| 421 | tag: opt-in, disclosed, and every path works with it switched off. |
| 422 | |
| 423 | Startup verifies the configured data key against `meta.sealed_key_check_v1`, or existing encrypted calendar names on first adoption. A refusal requires restoring the correct key/database pair. Never delete or replace the sentinel to make an unreadable database start. |
| 424 | |
| 425 | ## Work in a worktree, and catch main up first |
| 426 | |
| 427 | Take a worktree for the work. Do not work in the shared checkout. |
| 428 | |
| 429 | git -C <repo> fetch origin |
| 430 | git -C <repo> worktree add ../<repo>-<task> -b <branch> origin/main |
| 431 | |
| 432 | Both halves matter, for different reasons. |
| 433 | |
| 434 | **The worktree**, because several sessions share this machine and some |
| 435 | share this repository, and a checkout has one HEAD, one index and one |
| 436 | working tree between all of them. A branch switch under somebody else's |
| 437 | uncommitted work destroys it with nothing on screen to say so, and two |
| 438 | sessions editing the same paths disagree quietly instead of conflicting |
| 439 | loudly. A worktree gives the work its own HEAD and its own files, and |
| 440 | costs a directory. |
| 441 | |
| 442 | **From `origin/main`, after a fetch** β not from whatever the checkout |
| 443 | happens to be sitting on. A branch cut from a stale main is a merge |
| 444 | conflict scheduled for later, against files somebody else has renamed in |
| 445 | the meantime. A branch cut from another task's branch is worse: it |
| 446 | carries that task's commits into yours, where they are reviewed as |
| 447 | though you wrote them, and the two can only be separated by hand. |
| 448 | |
| 449 | Remove it when the work has landed β `git worktree remove` β so that |
| 450 | `git worktree list` keeps saying something true. |
| 451 | |
| 452 | Written down because of 2026-09-17, in `meet`. The shared checkout was |
| 453 | sitting on one task's branch while holding a *different* task's feature |
| 454 | uncommitted on disk β some four hundred lines, a new migration among |
| 455 | them β put there by a session nobody else knew was working in that tree. |
| 456 | Two other sessions were meanwhile coordinating over the same checkout by |
| 457 | asking each other not to touch it, which is the arrangement a worktree |
| 458 | makes unnecessary. Nothing was lost. Nothing about the arrangement would |
| 459 | have said so if it had been, and by then the same feature existed twice, |
| 460 | once on each side of a rename, because the two sessions had branched |
| 461 | from different starting points. |
| 462 | |