diff --git a/.cargo/config.toml b/.cargo/config.toml index ddf5a2ef2..2388cb851 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -26,7 +26,7 @@ fuzz-pdb_edit = ["fuzz", "run", "pdb_edit", "fuzz/corpus/pdb_edit", "--", "-crea fuzz-anlz = ["fuzz", "run", "anlz", "fuzz/corpus/anlz", "crates/locallibrary/tests/fixtures/rekordcrate/demo_tracks/PIONEER/USBANLZ", "--", "-create_missing_dirs=1", "-dict=fuzz/dicts/anlz.dict"] fuzz-mysettings = ["fuzz", "run", "mysettings", "fuzz/corpus/mysettings", "crates/locallibrary/tests/fixtures/rekordcrate/settings", "--", "-create_missing_dirs=1"] fuzz-tracklist = ["fuzz", "run", "tracklist", "fuzz/corpus/tracklist", "fuzz/seeds/tracklist", "--", "-create_missing_dirs=1"] -fuzz-mp4 = ["fuzz", "run", "mp4", "fuzz/corpus/mp4", "crates/locallibrary/tests/fixtures/audio", "--", "-create_missing_dirs=1"] +fuzz-mp4 = ["fuzz", "run", "mp4", "fuzz/corpus/mp4", "fuzz/seeds/mp4", "crates/locallibrary/tests/fixtures/audio", "--", "-create_missing_dirs=1"] fuzz-wav = ["fuzz", "run", "wav", "fuzz/corpus/wav", "fuzz/seeds/wav", "--", "-create_missing_dirs=1"] fuzz-aup = ["fuzz", "run", "aup", "fuzz/corpus/aup", "fuzz/seeds/aup", "--", "-create_missing_dirs=1"] fuzz-traktor = ["fuzz", "run", "traktor", "fuzz/corpus/traktor", "fuzz/seeds/traktor", "--", "-create_missing_dirs=1"] diff --git a/.github/labeler.yml b/.github/labeler.yml index 10a451195..2e174eaf3 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -60,7 +60,7 @@ atstore: - "apps/web/src/lib/{dj,dj-schema,performers,project-form,project-migration}.*" - "apps/web/src/lib/profile-tabs/**" - "apps/web/src/lib/server/services/{projects,dj,sets,profiles,performers,performer-*,project-migration}.*" - - "apps/web/src/lib/server/{project-page,profile-page,performer-uri,locallibrary}.*" + - "apps/web/src/lib/server/{active-accounts,project-page,profile-page,performer-uri,locallibrary}.*" - "apps/web/src/lib/server/forms/{claim,project,profile}.*" - "apps/web/src/lib/components/{Project*,ClaimFields,DjSets,DjStats,LinkedSet}.svelte" - "apps/web/src/lib/components/profile.svelte.test.ts" @@ -141,7 +141,7 @@ atstore: - "apps/web/src/lib/{audit-sentences,requests,request-standing,capabilities,bug-report,verification}.*" - "apps/web/src/lib/server/services/{staff,flags,project-admin,requests,diff,bug-reports,verifications}.*" - "apps/web/src/lib/server/forms/flags.*" - - "apps/web/src/lib/server/flags/**" + - "apps/web/src/lib/{,server/}flags/**" - "flags/**" - "apps/web/src/lib/server/audit/**" - "apps/web/src/lib/components/DiffTable.svelte" @@ -170,10 +170,10 @@ atstore: "web: server": - changed-files: - any-glob-to-any-file: - - "apps/web/src/{hooks.server,app.d}.*" + - "apps/web/src/{hooks.client,hooks.server,app.d}.*" - "apps/web/src/lib/{nsid,types,space-paths}.*" - "apps/web/src/lib/server/{atproto,db,happyview,sync,testing,backup}/**" - - "apps/web/src/lib/server/{app,bootstrap,compress,config,core,edit-mode,http,logger,rate-limit}.*" + - "apps/web/src/lib/server/{app,bootstrap,compress,config,core,edit-mode,http,langs,logger,rate-limit}.*" - "apps/web/src/lib/server/{env-files,crawler-head,images,utf8,moved-pages,meta,meta-records,structured-data}.*" - "apps/web/src/lib/server/services/{shared-spaces,space-joins,space-members,manager-spaces,own-repo,held-records,services}.*" - "apps/web/src/routes/{xrpc,.well-known,media,healthz}/**" @@ -193,7 +193,7 @@ atstore: - "!apps/web/src/lib/components/profile.svelte.test.ts" - any-glob-to-any-file: - "apps/web/src/lib/{ui,assets,og}/**" - - "apps/web/src/lib/{format,nav,combobox,form-*,hotkeys,headline,hosts,meta,structured-data,home,resolved,web-url}.*" + - "apps/web/src/lib/{format,nav,combobox,form-*,hotkeys,headline,hosts,locale,test-locale,meta,structured-data,home,resolved,web-url}.*" - "apps/web/src/lib/server/og/**" - "apps/web/src/lib/server/{home,landing,social-home}.*" - "apps/web/src/routes/{+layout,+error,layout,error,heads,link-matrix,listings,stored-images,social-home}.*" diff --git a/.github/workflows/web-ci.yml b/.github/workflows/web-ci.yml index ff8d81cb7..4a58b84dd 100644 --- a/.github/workflows/web-ci.yml +++ b/.github/workflows/web-ci.yml @@ -96,6 +96,10 @@ jobs: working-directory: . run: pnpm lexicons:format --check - run: pnpm lint + # The message catalogs (messages/, project.inlang): every message in each locale, with the + # variables and plural forms English has. Words written into a migrated component instead of + # the catalog are ast-grep's no-raw-text, in repo-checks.yml. + - run: pnpm i18n:check - run: pnpm check - run: pnpm -w knip # No --with-deps, here or below: the runner has the libraries Chromium needs, and the fonts it diff --git a/Cargo.lock b/Cargo.lock index 979d98b66..f87bc3afb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1715,7 +1715,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c54e03a951783e8b327515db3f2a2fd0e3bed362a96b066f341ce66ed49b4ead" dependencies = [ "data-encoding", - "syn 3.0.9", + "syn 1.0.109", ] [[package]] @@ -2358,9 +2358,9 @@ checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" [[package]] name = "form_urlencoded" -version = "1.2.2" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +checksum = "afa489199eaffb1211795df1c6236ce1ad0d41a6fa45250add73e3b02420f06e" dependencies = [ "percent-encoding", ] @@ -9043,9 +9043,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.8" +version = "2.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +checksum = "f00cd2407bb42c0ef17be88d4cf020f5cceffd121665bac9b8b9493a369b3b1a" dependencies = [ "form_urlencoded", "idna", diff --git a/GLOSSARY.md b/GLOSSARY.md index 095d4a2ff..c804f8e15 100644 --- a/GLOSSARY.md +++ b/GLOSSARY.md @@ -53,9 +53,13 @@ The separate area where staff moderate and run the site. Only staff can see it. _Avoid_: admin dashboard, admin panel **Flag**: -A switch that turns a feature on for some people before everyone. The website and locallibrary share its key and give an account the same answer. Staff set who it's on for in the staff console. Flags are for rolling something out, not for keeping anyone out. Turning one off for everyone keeps who it was on for, ready for when it's back on. A flag can say which kinds of page it shows on, so staff can switch it from there. +A switch that turns a feature on for some people before everyone. The website and locallibrary share its key and give an account the same answer. Staff set who it's on for in the staff console. Flags are for rolling something out, not for keeping anyone out. Turning one off for everyone keeps who it was on for, ready for when it's back on. Signed-out visitors come last, through a switch of their own that waits until every account has the flag; a kill switch reaches them whenever it's on for everyone. A flag can say which kinds of page it shows on, so staff can switch it from there. _Avoid_: feature toggle, experiment, setting +**Shows on**: +The kinds of page a flag changes: the home page, profiles, acts, parties, venues, events, sets, mixes or press kits, or every page. Each flag lists its own in the catalog, and its page in the staff console shows them. +_Avoid_: contexts, placement, scope + **Flag group**: A named list of accounts a flag can be turned on for. It has nothing to do with an act, and the people in it don't know they're in it. _Avoid_: segment, cohort, group (on its own) @@ -69,7 +73,7 @@ A flag that stops something that already works while it's on. It's named for the _Avoid_: circuit breaker, pause flag **Rollout**: -The share of signed-in accounts a flag is on for. An account stays in as the share grows, and has the same chance of being in on every flag. Signed-out visitors are never counted. +The share of signed-in accounts a flag is on for. An account stays in as the share grows, and has the same chance of being in on every flag. Signed-out visitors are never counted: they get a flag all at once, and only after every account has it. _Avoid_: percentage (in copy), canary, staged release ## People and acts @@ -222,6 +226,10 @@ _Avoid_: edit, revision, review request (those go to staff) Letting one account read one press kit's private part. _Avoid_: access, approval, permission (that's staff) +**Press kit request**: +Asking to see one press kit's private part. A manager approves it, which makes a grant, or declines it. The answer stays after a grant is removed, and someone declined can't ask to see that press kit again, though a manager can still invite them. +_Avoid_: review request (that goes to staff) + ## Music **Set**: diff --git a/apps/locallibrary/docs/account.md b/apps/locallibrary/docs/account.md index fedafa7a6..b0339ce2a 100644 --- a/apps/locallibrary/docs/account.md +++ b/apps/locallibrary/docs/account.md @@ -188,7 +188,9 @@ locallibrary account flags --refresh # ask now Local Network turns new things on for some accounts first, with the same flags on the website and here. A flag is on when it's on for everyone, when it names your account or a group you're in, or when your DID falls inside its percentage, the sum the website does (`flags/README.md` in the repo). -Signed out, only flags on for everyone are on. A flag staff turned off is off for everyone. +Signed out, a flag is on only once it's on for signed-out visitors: staff turn that on last, after +every account has it, and a kill switch has it whenever it's on for everyone. A flag staff turned +off is off for everyone. Only a command that depends on a flag asks, and nothing else goes to the network because of them. The website's answer is kept in `flags.json` in the store folder for an hour, or until the next diff --git a/apps/locallibrary/tests/it/props_cli_account.rs b/apps/locallibrary/tests/it/props_cli_account.rs index 42eaf52ef..c139e54f1 100644 --- a/apps/locallibrary/tests/it/props_cli_account.rs +++ b/apps/locallibrary/tests/it/props_cli_account.rs @@ -969,10 +969,10 @@ fn a_bug_report_allowed_to_post_holds_what_was_given(tc: TestCase) { } /// Whoever's asking and whatever the website lists, `account flags` shows each flag in the -/// repository's catalog once, in order, and nothing else; a flag is on when it's on for everyone, -/// for a signed-in account's share of the rollout, or (with a session that may ask) targeted at -/// it; the text says what the JSON does, without asking again; and only a session from before the -/// scope is told to sign in again. +/// repository's catalog once, in order, and nothing else; a flag is on when it's on for everyone +/// or at 100%, for a signed-in account's share of the rollout, or (with a session that may ask) +/// targeted at it; the text says what the JSON does, without asking again; and only a session +/// from before the scope is told to sign in again. #[hegel::test(test_cases = 8, suppress_health_check = [HealthCheck::TooSlow])] fn the_flags_shown_are_the_catalogs_as_the_website_answers(tc: TestCase) { let pds = MockPds::start(); @@ -999,7 +999,7 @@ fn the_flags_shown_are_the_catalogs_as_the_website_answers(tc: TestCase) { } let on_for = |(key, everyone, percentage): &(String, bool, u32)| { let in_rollout = who > 0 && locallibrary::flags::bucket(key, DID) < *percentage; - *everyone || in_rollout || (who == 2 && targeted.contains(&key.as_str())) + *everyone || *percentage == 100 || in_rollout || (who == 2 && targeted.contains(&key.as_str())) }; let on: Vec<&str> = listed.iter().filter(|flag| on_for(flag)).map(|(key, ..)| key.as_str()).collect(); diff --git a/apps/web/.env.example b/apps/web/.env.example index 61f2afd0b..5ce92c1ac 100644 --- a/apps/web/.env.example +++ b/apps/web/.env.example @@ -41,8 +41,8 @@ HAPPYVIEW_URL=https://localnetwork.hpy.at # HAPPYVIEW_CLIENT_SECRET=hvs_... # Optional: Local Network's space on userinput.app (at:///app.userinput.space/). -# With it, signed-in people post bug reports there from their own account; without -# it, "Report a bug" opens GitHub's issue form for everyone. +# With it, signed-in people the userinputReports flag is on for post bug reports there +# from their own account; without it, "Report a bug" opens GitHub's issue form for everyone. # USERINPUT_SPACE= # Optional: Local Network's clients at the services locallibrary plugins sign in to diff --git a/apps/web/.gitignore b/apps/web/.gitignore index 855def8aa..d73b74824 100644 --- a/apps/web/.gitignore +++ b/apps/web/.gitignore @@ -28,3 +28,6 @@ test-results *storybook.log storybook-static + +# inlang writes its compile cache next to the project settings. +project.inlang/cache/ diff --git a/apps/web/README.md b/apps/web/README.md index 207c9816c..5b99fdd64 100644 --- a/apps/web/README.md +++ b/apps/web/README.md @@ -17,12 +17,12 @@ All data lives on the AT Protocol. Public profiles are ordinary atproto records; ### Dashboard - Signing in lands on `/dashboard`, where every change to what a public page shows happens: each project you manage (`/dashboard/projects/`, with its profile, shows and press kits), your inbox, booking threads and planner. Account (`/dashboard/account`) holds notification settings, your activity in plain sentences, what the root holds on your behalf with counts by type (`/dashboard/account/data`), your requests to staff, and sign out. The pages' old addresses, which emails and DMs may still link to, redirect with a 308. The first page, Overview, ends with a locallibrary card: when your playing stats and sets were last published, a link to your newest set, "Get locallibrary" while you've published neither, and a link to preview a mix export. Staff work in the staff console at `/admin`, on the same sidebar layout. -- The inbox (`/dashboard/inbox`) tells each participant in a booking thread about a new inquiry, message or status change from someone else in it, with a dot in the sidebar while anything is unread. It shows one row per thread, saying in a sentence what happened since you last read it. An item names the performer, never which of its managers wrote, and holds none of what was written. Opening a row, or its thread, marks the thread read; it doesn't change whose turn it is. Read items go after 90 days and unread ones after 180. People can also have new items emailed: the address comes from their account's host, read only after they approve it, and nothing goes to it until they open a link we email it, which works for a day. New items wait two minutes so a burst goes as one email. Anything older than six hours when it's indexed stays on the site. They can also have them sent as Bluesky DMs from the root account, a minute apart at most; when Bluesky chat says the root can't DM them yet, the settings page asks them to allow DMs from people they follow and to follow the root. The site asks chat alone, not the AppView, so it doesn't know which of the two is missing. `/dashboard/account/notifications` has a grid of inbox sections by Email and Bluesky DM that saves as you tick, and turns each of the two on and off and sends a test. +- The inbox (`/dashboard/inbox`) tells each participant in a booking thread about a new inquiry, message or status change from someone else in it, with a dot in the sidebar while anything is unread. It shows one row per thread, saying in a sentence what happened since you last read it. An item names the performer, never which of its managers wrote, and holds none of what was written. Opening a row, or its thread, marks the thread read; it doesn't change whose turn it is. Read items go after 90 days and unread ones after 180. People can also have new items emailed: the address comes from their account's host, read only after they approve it, and nothing goes to it until they open a link we email it, which works for a day. New items wait two minutes so a burst goes as one email. Anything older than six hours when it's indexed stays on the site. They can also have them sent as Bluesky DMs from the root account, a minute apart at most; when Bluesky chat says the root can't DM them yet, the settings page asks them to allow DMs from people they follow and to follow the root. The site asks chat alone, not the AppView, so it doesn't know which of the two is missing. `/dashboard/account/notifications` has a grid of inbox sections by Email and Bluesky DM that saves as you tick, and turns each of the two on and off and sends a test. Email and DMs roll out an account at a time behind the `inboxEmail` and `inboxDm` flags. Where a channel's flag is off for someone, the settings page doesn't offer it (only turning it off, if they turned it on before), and the outbox skips what would have gone to them by it: it stays in their site inbox, and turning the flag back on sends only what comes after. - People edit their profile at `/dashboard/profile`: the basics, and the DJ and promoter sections they turn on, each adding its own fields (the project form is built from the same basics and performer fields). Turning a section off asks first, since saving deletes what was in it. The profile goes to the account's own repo with its session, over the version the form opened on. A session from before profiles is offered "Sign in again" when the page opens. Someone without a profile makes one from the first step of the checklist on `/dashboard`, from their Bluesky name and picture, read once from their own repo. The sections decide the dashboard sidebar: a DJ's projects under Yours, and for a promoter a Promoter section with Book DJs (`/dashboard/promoter`: the Find DJs search, Match a show, the inquiries they sent and their planned shows) and the planner. Until there's a profile, the planner and List a project show anyway, and projects someone manages always do. Saving the profile with the promoter section newly on points to Book DJs. On a phone the sidebar's main items become tabs along the bottom, and Menu opens the rest in a sheet. - A DJ asks staff to list them in Find DJs from their profile editor, once their profile has the DJ section on: a `list` request in the moderation space that names their profile and the version they asked with. Staff review it at `/admin/requests` like any other, seeing the profile as it is now, with a note when it changed since the request and when the same account manages a solo project, which would put them in Find DJs twice. Approving writes the root's `computer.localnetwork.listing.profile` for them and has HappyView read their profile again; `/admin/listings/` (staff's Manage link on a profile) shows the listing and takes them out again. Both are audited. - Public pages only read, apart from Follow and Save. A project's managers get a Manage link to its dashboard there, and staff one to the staff console. A project that isn't public shows its managers and staff a "Not public yet" banner; everyone else gets a 404. -- Every account has a profile page at `/@`, showing its `computer.localnetwork.profile`: its basics (with the pronouns from its Bluesky profile, else the ones the profile kept from before), the performer and promoter sections it turned on, the DJ stats and sets it publishes, and the active projects it manages. A DID with a verified handle, and a handle in any other form, redirect there; an account without a verified handle has its page at `/@`. Its sections are tabs (About, Mixes, Sets, How they play, Plays in), each a file in `src/lib/profile-tabs/` that the page collects, so a new tab is a new file; a tab with nothing in it is left out, and `?tab=` opens one, without scripts too. An account without a profile record still gets a page, with its Bluesky display name when the directory keeps one (else its handle), the projects it plays in, and a line saying it hasn't set up a profile; only an address that names no account is a 404. Handles across the site link to these pages. A profile with a record has a Follow button for everyone but its owner. The owner gets a Manage link to their profile editor, and staff one to its Find DJs listing (`/admin/listings/`). A DJ Find DJs lists gets Send inquiry there, for everyone but themself, as an act's page has (Sign in to book when signed out). -- Each published set has a page at `/@/sets/`, redirected the same way: its place and date, the event it names (when HappyView keeps that event), its player and tracklist, and the mixes on its DJ's active projects that link it, each to its tracklist page when it has one. A mix's "Set:" line links there, and so does each set's name wherever sets are listed and each play on an artist's page. A set HappyView doesn't have is a 404. +- Every account has a profile page at `/@`, showing its `computer.localnetwork.profile`: its basics (with the pronouns from its Bluesky profile, else the ones the profile kept from before), the performer and promoter sections it turned on, the DJ stats and sets it publishes, and the active projects it manages. A DID with a verified handle, and a handle in any other form, redirect there; an account without a verified handle has its page at `/@`. Its sections are tabs (About, Mixes, Sets, How they play, Plays in), each a file in `src/lib/profile-tabs/` that the page collects, so a new tab is a new file; a tab with nothing in it is left out, and `?tab=` opens one, without scripts too. An account without a profile record still gets a page, with its Bluesky display name when the directory keeps one (else its handle), the projects it plays in, and a line saying it hasn't set up a profile. An address that names no account is a 404. So is an account that's deactivated, taken down or suspended, whose page says only that the account isn't active, and a deleted account's page is a 410 saying it was deleted ([ADR 0020](../../docs/adr/0020-inactive-accounts-are-asked-of-their-pds.md)). Handles across the site link to these pages. A profile with a record has a Follow button for everyone but its owner. The owner gets a Manage link to their profile editor, and staff one to its Find DJs listing (`/admin/listings/`). A DJ Find DJs lists gets Send inquiry there, for everyone but themself, as an act's page has (Sign in to book when signed out). +- Each published set has a page at `/@/sets/`, redirected the same way: its place and date, the event it names (when HappyView keeps that event), its player and tracklist, and the mixes on its DJ's active projects that link it, each to its tracklist page when it has one. A mix's "Set:" line links there, and so does each set's name wherever sets are listed and each play on an artist's page. A set HappyView doesn't have is a 404, and so is every set of an account that isn't active. ### Promoters @@ -40,13 +40,13 @@ All data lives on the AT Protocol. Public profiles are ordinary atproto records; - `/for/djs` makes the case for joining: a real listing from the directory, what promoters search on, the profile being the DJ's own, press kits, locallibrary with its captures, the month's most played tracks, the next shows, and how listing works. The listing, the shows and the charts stream in, so the page paints first. - List a new project, or claim one an admin added. Several managers per project (crews, agents). - When a project's managers change, a new manager joins its booking threads that are still being worked out or confirmed for an upcoming show, and a manager who leaves is taken out of all of them. The promoter always stays. The same step keeps the project's backstage, its press kit request space and its press kit spaces to the current managers, leaving the people granted a press kit. The app repeats this at startup, every hour, and on the System page's bootstrap, so a change that failed part way still finishes. A thread follows the project named in the root's opening record, which the promoter can't rewrite, or for a thread opened before that record named one, in its `booking.create` audit entry (written by the app, and rebuilt only from the root's copy). A thread with neither, or where the two disagree, is left as it is. -- Acts, parties and venues each get a space under the root. Their pages ship dark behind two release flags: `spacePages` for the public act, party, venue and event pages, and `peopleSpaces` for the member pages (inviting people, invite links, asking to join, people lists). A route behind one calls `requireFlag` (`src/lib/server/http.ts`), which answers 404 while the flag is off for the viewer. A performer's space also holds the root's `computer.localnetwork.performer` record, which says whether it's an act (with what its page shows) or a DJ's own space for their backstage and managers. A venue's space holds the root's `computer.localnetwork.venue` record: its name, address and coordinates, its Foursquare place once known, and whether events naming it show at once (Anyone can list) or only once confirmed (Venue approves). Names repeat ([ADR 0016](../../docs/adr/0016-names-repeat-keys-and-handles-identify.md)): an act, party or venue goes by its space key, and its page is `///` (`spacePagePath` in `src/lib/space-paths.ts`), where the name part is only there to read: any other name, or none, redirects to the current one. Anyone signed in can add a venue, which puts nobody in its space (owning one takes a confirmed claim). Adding a place that's already a venue gives back that venue, and so does adding the same name in the same city and country unless the two are different Foursquare places. Forms pick one with the venue picker (`src/lib/components/VenuePicker.svelte`): an existing venue by name, with its city on a second line to tell same-named ones apart, or a new one by its name and its city from the city search, both through `/api/venues`, which answers 404 while `spacePages` is off. A new venue's Foursquare place stays empty until staff add it. A party's space holds the root's `computer.localnetwork.party` record: its basics (name, picture, bio, area and links) and, once it's published, when. Without that it's a draft, which only its people and staff can open; everyone else gets a 404. Its page, `/party//`, is the first built in place ([docs/edit-mode.md](docs/edit-mode.md)): its people with page.edit, or staff with Edit as staff, edit its name, picture, bio, area and links where they're shown, and Publish a draft. It also shows its hosts and cohosts who haven't hidden. `/party/new` (signed in) opens the same page empty in edit mode: Save draft starts the party as a draft with its creator as host and goes on editing it at its own address, and Publish starts it published. The dashboard's sidebar offers it while `spacePages` is on. A party's events have their pages under it at `/party///`, the event's record key and then its name to read, built in place the same way (`src/lib/server/event-page.ts`): its people with events.manage edit the name, the venue, the date and times (on the venue's clock, or until there's a venue, a time zone picked with them, which a new draft takes from its party's area, else its creator's, else UTC), the lineup (each performer by handle or act page link), the ticket link, what it's about and who can see it, and outside edit mode copy or reset a private event's link and cancel a published one. Its people and staff open any of its events; anyone else opens a published public one, or a private one from its link's `?t=` token, and gets a 404 for the rest. The page says whether the venue has confirmed it or it's waiting for the venue, and never more (ADR 0014), and links the venue's page. A listed event (published, public, not Never confirmed, and under Venue approves only once confirmed) has a public copy, a `community.lexicon.calendar.event` the root keeps in its own repo under the event's record key with its name, what it's about, its times, its status, the venue's address, coordinates and page, and its ticket link and page here (`calendarCopy` in `src/lib/server/services/events.ts`), so other calendar apps can show it. Each save and the venue confirming it rewrite it, and it's deleted once the event isn't listed. What changes listing without either (the night ending while it waits for the venue, the venue's mode or blocks) is caught by `reconcileCalendarCopies`, which runs at startup, every hour, and for the venue after its settings change, and writes only where a copy differs. While it's listed, until its night is over, and unless it's cancelled, the page has Going and Interested beside its tickets, with how many said each (`src/lib/server/services/rsvps.ts`): each writes a `community.lexicon.calendar.rsvp`, the record other AT Protocol calendar apps write, to the guest's own repo, answering the public copy, and pressing the pressed one takes the answer back. They're forms, so they work without scripts; signed out, they link to sign-in and back. A private event has neither, since an RSVP in a guest's public repo would show anyone who's going. An RSVP to a copy that's since been taken down stays in the guest's repo, counted nowhere. A night ends at 6:00 the next morning on the venue's clock (`nightEnd` in `src/lib/server/venue-time.ts`), and an event still waiting for the venue then is Never confirmed: it leaves every list, and only its party's people and staff can open it, marked so. A confirmed one just becomes a past event. The party's page lists its events until their night ends, its drafts, private ones and ones never confirmed marked for its people, and `/party//new` opens an empty event page in edit mode for its people with events.manage: Save draft makes the event as a draft and Publish makes it published. A save that would move the times onto another clock (picking a venue in another time zone, another venue, or another zone for the draft) comes back asking whether to keep them as entered or at the same moments, and each answer saves again. A venue's page, `/venue//`, shows its address, an OpenStreetMap link when its coordinates are known, and the events listed there until their night ends, each with its party and marked waiting for the venue or Confirmed. It links the venue's dashboard pages for the people who can use them (claiming it for anyone else signed in) while `peopleSpaces` is on, and leaves its owners off until they can choose to show. A performer's booking details go in a separate booking details space with the same key, which only the root is in, so members can't read them from another client ([ADR 0011](../../docs/adr/0011-booking-details-stay-out-of-the-performer-space.md)). Each space's people records say who's in it, in what role, with which capabilities, and whether they're hidden from everyone outside it. The root writes every record there, for someone who holds the capability the change needs or for staff, whose changes the audit log marks with their role. Someone always has to be left who can manage its people, unless staff decide otherwise. The space's members follow its people: everyone reads, and those with a capability that writes also write. The app repeats that at startup and every hour, so a member update that failed part way still finishes. +- Acts, parties and venues each get a space under the root. Their pages ship dark behind two release flags: `spacePages` for the public act, party, venue and event pages, and `peopleSpaces` for the member pages (inviting people, invite links, asking to join, people lists). A route behind one calls `requireFlag` (`src/lib/server/http.ts`), which answers 404 while the flag is off for the viewer. A performer's space also holds the root's `computer.localnetwork.performer` record, which says whether it's an act (with what its page shows) or a DJ's own space for their backstage and managers. A venue's space holds the root's `computer.localnetwork.venue` record: its name, address and coordinates, its Foursquare place once known, and whether events naming it show at once (Anyone can list) or only once confirmed (Venue approves). Names repeat ([ADR 0016](../../docs/adr/0016-names-repeat-keys-and-handles-identify.md)): an act, party or venue goes by its space key, and its page is `///` (`spacePagePath` in `src/lib/space-paths.ts`), where the name part is only there to read: any other name, or none, redirects to the current one. Anyone signed in can add a venue, which puts nobody in its space (owning one takes a confirmed claim). Adding a place that's already a venue gives back that venue, and so does adding the same name in the same city and country unless the two are different Foursquare places. Forms pick one with the venue picker (`src/lib/components/VenuePicker.svelte`): an existing venue by name, with its city on a second line to tell same-named ones apart, or a new one by its name and its city from the city search, both through `/api/venues`, which answers 404 while `spacePages` is off. A new venue's Foursquare place stays empty until staff add it. A party's space holds the root's `computer.localnetwork.party` record: its basics (name, picture, bio, area and links) and, once it's published, when. Without that it's a draft, which only its people and staff can open; everyone else gets a 404. Its page, `/party//`, is the first built in place ([docs/edit-mode.md](docs/edit-mode.md)): its people with page.edit, or staff with Edit as staff, edit its name, picture, bio, area and links where they're shown, and Publish a draft. It also shows its hosts and cohosts who haven't hidden. `/party/new` (signed in) opens the same page empty in edit mode: Save draft starts the party as a draft with its creator as host and goes on editing it at its own address, and Publish starts it published. The dashboard's sidebar offers it while `spacePages` is on. A party's events have their pages under it at `/party///`, the event's record key and then its name to read, built in place the same way (`src/lib/server/event-page.ts`): its people with events.manage edit the name, the venue, the date and times (on the venue's clock, or until there's a venue, a time zone picked with them, which a new draft takes from its party's area, else its creator's, else UTC), the lineup (each performer by handle or act page link), the ticket link, what it's about and who can see it, and outside edit mode copy or reset a private event's link and cancel a published one. Its people and staff open any of its events; anyone else opens a published public one, or a private one from its link's `?t=` token, and gets a 404 for the rest. The page says whether the venue has confirmed it or it's waiting for the venue, and never more (ADR 0014), and links the venue's page. A listed event (published, public, not Never confirmed, and under Venue approves only once confirmed) has a public copy, a `community.lexicon.calendar.event` the root keeps in its own repo under the event's record key with its name, what it's about, its times, its status, the venue's address, coordinates and page, and its ticket link and page here (`calendarCopy` in `src/lib/server/services/events.ts`), so other calendar apps can show it. Each save and the venue confirming it rewrite it, and it's deleted once the event isn't listed. What changes listing without either (the night ending while it waits for the venue, the venue's mode or blocks) is caught by `reconcileCalendarCopies`, which runs at startup, every hour, and for the venue after its settings change, and writes only where a copy differs. While it's listed, until its night is over, and unless it's cancelled, the page has Going and Interested beside its tickets, with how many said each (`src/lib/server/services/rsvps.ts`): each writes a `community.lexicon.calendar.rsvp`, the record other AT Protocol calendar apps write, to the guest's own repo, answering the public copy, and pressing the pressed one takes the answer back. They're forms, so they work without scripts; signed out, they link to sign-in and back. A private event has neither, since an RSVP in a guest's public repo would show anyone who's going. An RSVP to a copy that's since been taken down stays in the guest's repo, counted nowhere. A night ends at 6:00 the next morning on the venue's clock (`nightEnd` in `src/lib/server/venue-time.ts`), and an event still waiting for the venue then is Never confirmed: it leaves every list, and only its party's people and staff can open it, marked so. A confirmed one just becomes a past event. The party's page lists its events until their night ends, its drafts, private ones and ones never confirmed marked for its people, and `/party//new` opens an empty event page in edit mode for its people with events.manage: Save draft makes the event as a draft and Publish makes it published. A save that would move the times onto another clock (picking a venue in another time zone, another venue, or another zone for the draft) comes back asking whether to keep them as entered or at the same moments, and each answer saves again. A venue's page, `/venue//`, shows its address, an OpenStreetMap link when its coordinates are known, and the events listed there until their night ends, each with its party and marked waiting for the venue or Confirmed. It links the venue's dashboard pages for the people who can use them (claiming it for anyone else signed in) while `peopleSpaces` is on, and leaves its owners off until they can choose to show. A performer's booking details go in a separate booking details space with the same key, which only the root is in, so members can't read them from another client ([ADR 0011](../../docs/adr/0011-booking-details-stay-out-of-the-performer-space.md)). Each space's people records say who's in it, in what role, with which capabilities, and whether they're hidden from everyone outside it. The root writes every record there, for someone who holds the capability the change needs or for staff, whose changes the audit log marks with their role. Someone always has to be left who can manage its people, unless staff decide otherwise. The space's members follow its people: everyone reads, and those with a capability that writes also write. The app repeats that at startup and every hour, so a member update that failed part way still finishes. The `pauseReconcilers` flag stops that, and every other round that writes to the root's repo to fix drift, without a deploy. The venue blocks round keeps running, since it only reads the root's blocks into the index. - People come into one by an invite to their account, an invite link, or a request to join that someone with people.manage approves, and choose then whether to be hidden. A link's token is shown once and only its hash is kept, and a link never lets anyone manage people. Invites last 30 days and links 7 unless their maker picks up to 90, someone can have 50 open in a space at once, and both go when their maker can no longer add people, unless staff made them. - When staff list one, the root writes a `computer.localnetwork.listing` record to its public repo with what its public page shows, the people in a listed role (an act's members, a party's hosts and cohosts) who haven't hidden, and an act's managers who haven't. It's rewritten only when that changes, and checked every hour. A listing points at a public page, so none is written until `spacePages` is on for everyone, and turning it off takes them down at the next hourly check. Acts, parties and venues have something to list: an act's form, basics and performer sections, a published party's basics (each avatar is a blob the root uploaded), and a venue's name, address and coordinates. A published party is public at its address before it's listed; a draft is never listed. A venue is listed as soon as it's added, since it's a public place, and a DJ's own space is never listed. HappyView keeps only the root's listings (`lua/computer/localnetwork/listing.lua`). Staff see every space and its people, hidden ones marked, at `/admin/spaces`, where they add and remove people, change roles, and list or unlist it. - Profiles cover genres, city and travel radius, set types and lengths, formats, room sizes, any number of fee levels (each a tier, with an optional label and range), links, playable SoundCloud/Mixcloud/YouTube mixes, highlights, photo. - A mix can carry a tracklist: a mix report exported from [locallibrary](../locallibrary) (`locallibrary mix … --export`), shown at `/projects//mixes/` with the waveform and track lanes, tempo, key moves on the Camelot wheel, and every transition. `/mixes/preview` renders an export locally without uploading it. - A mix can also link a set a manager published with locallibrary (`locallibrary sets publish`), picked from a list on the new-project and edit forms. The profile shows when and where it was played, and says so if the set changed after it was linked. -- Sets with a recording play on the site, with the tracklist following along and a track's start to jump to. The server picks what plays when someone presses Play (`/sets///player.json`): the set's `recording` record first (an `fm.plyr.track`, whose file comes from plyr.fm's CDN, or plyr's own player when the track is gated; or a `computer.localnetwork.dj.recording` on the DJ's PDS, streamed through `/media/audio//`), then its links (archive.org downloads play directly, SoundCloud, Mixcloud, YouTube and plyr.fm in their own players). Audio the page plays itself always wins over a platform's player. SoundCloud's and Mixcloud's widget APIs let the tracklist follow those players too. `/sets///chapters.json` serves the tracklist as Podcasting 2.0 JSON chapters. +- Sets with a recording play on the site, with the tracklist following along and a track's start to jump to. The server picks what plays when someone presses Play (`/sets///player.json`): the set's `recording` record first (an `fm.plyr.track`, whose file comes from plyr.fm's CDN, or plyr's own player when the track is gated; or a `computer.localnetwork.dj.recording` on the DJ's PDS, streamed through `/media/audio//`), then its links (archive.org downloads play directly, SoundCloud, Mixcloud, YouTube and plyr.fm in their own players). Audio the page plays itself always wins over a platform's player. While the `pauseRecordingStream` flag is on, a recording on a PDS is left out, so the links play, and `/media/audio` answers 503 without reading anything. SoundCloud's and Mixcloud's widget APIs let the tracklist follow those players too. `/sets///chapters.json` serves the tracklist as Podcasting 2.0 JSON chapters. - Private booking details (email, phone, rates, tech rider, hospitality), shown to the project's managers and staff on its pages, and to everyone else only inside a press kit they've been let into, so each look at them leaves a receipt. - The project form and the booking inquiry keep unsent changes as a draft in the browser (`localStorage`, per account), so a reload or a trip to another page doesn't lose them. Files have to be picked again, and the draft goes once the form is sent, discarded, or back to its saved values, or its account signs out (the sign-out response sets an `ln_signed_out` cookie naming the account, and the next page load drops its drafts, so it works even if Sign out was pressed before the page's scripts ran). - A project page shows how its DJs play: the playing stats and recent sets each manager publishes from locallibrary (`computer.localnetwork.dj.profile` and `dj.set`), read from HappyView when the page loads and streamed in, so a slow answer never holds the page up. The app stores none of it; a few minutes' cache in memory keeps busy pages from asking again. @@ -77,16 +77,16 @@ All data lives on the AT Protocol. Public profiles are ordinary atproto records; ### Bug reports -- "Report a bug" in the footer opens `/report`. Signed in, it posts the report from the person's own account to Local Network's space on [userinput.app](https://userinput.app) (an `app.userinput.discussion` record in their repo, tagged `bug` and `web`, with the page they came from and their browser), then links to it there. Signed out (where the link reads "Report a bug on GitHub"), or without `USERINPUT_SPACE`, it opens GitHub's website bug form with the page and browser filled in, and so does a report that fails to post, with what they wrote. +- "Report a bug" in the footer opens `/report`. Signed in, it posts the report from the person's own account to Local Network's space on [userinput.app](https://userinput.app) (an `app.userinput.discussion` record in their repo, tagged `bug` and `web`, with the page they came from and their browser), then links to it there. Signed out (where the link reads "Report a bug on GitHub"), without `USERINPUT_SPACE`, or with the `userinputReports` flag off for them, it opens GitHub's website bug form with the page and browser filled in, and so does a report that fails to post, with what they wrote. Turning `userinputReports` off for everyone sends every report to GitHub while userinput.app is down. - Posting asks for one more OAuth scope, `repo:app.userinput.discussion?action=create`, the first time someone sends a report, not at sign-in: sessions from before it keep working, and the client metadata lists it so the PDS allows the request. ### Flags -A flag turns a feature on for some people before everyone. The flags themselves are files in [`flags/catalog/`](../../flags/README.md), which locallibrary reads too. Staff set who each is on for at `/admin/flags`: everyone, a percentage of accounts, [flag groups](../../GLOSSARY.md) at `/admin/flags/groups`, or single accounts. "Off for everyone" turns a flag off and keeps all of that for when it's back on. Admins manage all of it, and on the Staff page they can give a moderator either part: flags, or flag groups. Every change is in the audit log. The list marks a flag "Ready to remove" once it's been on for everyone, or every account, for 30 days. +A flag turns a feature on for some people before everyone. The flags themselves are files in [`flags/catalog/`](../../flags/README.md), which locallibrary reads too. Staff set who each is on for at `/admin/flags`: every account, a percentage of accounts, [flag groups](../../GLOSSARY.md) at `/admin/flags/groups`, or single accounts, and then signed-out visitors. "Off for everyone" turns a flag off and keeps all of that for when it's back on. Admins manage all of it, and on the Staff page they can give a moderator either part: flags, or flag groups. Every change is in the audit log. The list marks a release flag "Ready to remove" once every account and signed-out visitors have had it for 30 days. To see a flag without changing it for anyone, staff with the flags grant can turn it on or off for their own browser from its page. The preview is a cookie signed with their session, lasts an hour, shows a banner on every page until it's cleared, and is audited. In development and tests, `FLAG_OVERRIDES=key=on,other=off` forces flags for every request instead; the app won't start with it in production ([ADR 0010](../../docs/adr/0010-flags-turn-off-and-preview-without-touching-targeting.md)). -What's set is kept as `staff.flag` and `staff.group` records in the staff space, indexed into SQLite and held in memory, so reading one on a request costs nothing. Pages read `data.flags?.key` and server code `locals.flags.key`, worked out once per request. A signed-out visitor only gets flags on for everyone. locallibrary can't read the staff space, so `computer.localnetwork.flags.getFlags` tells it the public gates and whether it's targeted ([ADR 0006](../../docs/adr/0006-locallibrary-asks-the-website-for-flags.md)). +What's set is kept as `staff.flag` and `staff.group` records in the staff space, indexed into SQLite and held in memory, so reading one on a request costs nothing. Pages read `data.flags?.key` and server code `locals.flags.key`, worked out once per request. A signed-out visitor gets a release flag only once staff turn it on for them, which waits until every account has it; an ops flag reaches them whenever it's on for everyone ([ADR 0018](../../docs/adr/0018-signed-out-visitors-come-last.md)). locallibrary can't read the staff space, so `computer.localnetwork.flags.getFlags` tells it the public gates and whether it's targeted ([ADR 0006](../../docs/adr/0006-locallibrary-asks-the-website-for-flags.md)). ### Staff @@ -222,7 +222,7 @@ A mix whose link is a plyr.fm track (`https://plyr.fm/track/`) also gets a ` ### Sync -The app is a space syncer. For each watched space it asks the space host (the authority's PDS) for a space credential with `authorizeSpaceSync`, sending a fresh delegation token from the root's PDS and the `did:key` of a new P-256 key the credential is bound to, and signs every request with that key (RFC 9421). It enumerates writers with `listWriters`, pulls each repo's oplog with `listRepoOps`, and checks the result against the repo's LtHash commit, falling back to a full download (`getRepo`, a STAR archive) when needed. A repo the listing says left the writer set (a member removed, or no longer allowed to write) keeps the records already synced from it. Commits and records aren't signed: the repo host MACs the commit or record header of each response (an HTTP message signature) with a secret shared for that one request, derived from the author's `#atproto_kem` key. When a MAC fails, the app refetches the author's DID document once, in case the key rotated. Accounts whose DID document has no KEM key can't be synced, and the system page says so. A deleted space is dropped with everything derived from it, however often the authority says so, and a space recreated under the same URI syncs from scratch. A repo that fails doesn't hold back the others: the pass carries on through the space's later pages, and the repo is retried on its own, after a minute at first and at most an hour once it keeps failing. A writer whose account is taken down, suspended, or deactivated is skipped the same way without failing the pass, and the system page shows why. A space whose authority is taken down or deactivated is only suspended, so its local copy stays. A record whose projection into the app's tables fails, such as an inquiry read while the directory is down, waits on the same schedule and shows on the system page until it goes through ([ADR 0009](../../docs/adr/0009-synced-records-queue-for-projection.md)). It also registers for each watched space's updates, and polls. Each credential request names the app's `PUBLIC_URL` and a random token the app keeps for that space; the host checks both with `confirmRegistration` before registering, and the registration lasts as long as the credential, so polling keeps it up. The host posts each update to `notifySpaceUpdate` with that token, and the app syncs the space. A notice that the space was deleted or the registration lapsed makes the app ask for a fresh credential first, and only the authority refusing it with `SpaceDeleted` drops the space. A host that can't confirm the endpoint leaves the space on polling. Records are validated against the lexicons, and authority rules are enforced: only root-authored decisions, roles, and details count, a press kit's grants count only from their space's authority (in a project's request space, only for a press kit of that project) and drafts only from the project's current managers, a booking thread's project comes from the root's opening record (or the root's audit copy of its creation) rather than the inquiry, the show announced from it only from the root's status records, booking records from non-participants are ignored, and a booking status record counts only when the thread's rules allow its author that move ([ADR 0008](../../docs/adr/0008-booking-status-follows-the-rules-not-record-dates.md)). +The app is a space syncer. For each watched space it asks the space host (the authority's PDS) for a space credential with `authorizeSpaceSync`, sending a fresh delegation token from the root's PDS and the `did:key` of a new P-256 key the credential is bound to, and signs every request with that key (RFC 9421). It enumerates writers with `listWriters`, pulls each repo's oplog with `listRepoOps`, and checks the result against the repo's LtHash commit, falling back to a full download (`getRepo`, a STAR archive, read up to 256 MiB) when needed. A record nested deeper than 32 levels is left out of the local copy, whichever way it arrives. A repo the listing says left the writer set (a member removed, or no longer allowed to write) keeps the records already synced from it. Commits and records aren't signed: the repo host MACs the commit or record header of each response (an HTTP message signature) with a secret shared for that one request, derived from the author's `#atproto_kem` key. When a MAC fails, the app refetches the author's DID document once, in case the key rotated. Accounts whose DID document has no KEM key can't be synced, and the system page says so. A deleted space is dropped with everything derived from it, however often the authority says so, and a space recreated under the same URI syncs from scratch. A repo that fails doesn't hold back the others: the pass carries on through the space's later pages, and the repo is retried on its own, after a minute at first and at most an hour once it keeps failing. A writer whose account is taken down, suspended, or deactivated is skipped the same way without failing the pass, and the system page shows why. A space whose authority is taken down or deactivated is only suspended, so its local copy stays. A record whose projection into the app's tables fails, such as an inquiry read while the directory is down, waits on the same schedule and shows on the system page until it goes through ([ADR 0009](../../docs/adr/0009-synced-records-queue-for-projection.md)). It also registers for each watched space's updates, and polls. Each credential request names the app's `PUBLIC_URL` and a random token the app keeps for that space; the host checks both with `confirmRegistration` before registering, and the registration lasts as long as the credential, so polling keeps it up. The host posts each update to `notifySpaceUpdate` with that token, and the app syncs the space. A notice that the space was deleted or the registration lapsed makes the app ask for a fresh credential first, and only the authority refusing it with `SpaceDeleted` drops the space. A host that can't confirm the endpoint leaves the space on polling. Records are validated against the lexicons, and authority rules are enforced: only root-authored decisions, roles, and details count, a press kit's grants count only from their space's authority (in a project's request space, only for a press kit of that project) and drafts only from the project's current managers, a booking thread's project comes from the root's opening record (or the root's audit copy of its creation) rather than the inquiry, the show announced from it only from the root's status records, booking records from non-participants are ignored, and a booking status record counts only when the thread's rules allow its author that move ([ADR 0008](../../docs/adr/0008-booking-status-follows-the-rules-not-record-dates.md)). ### Directory @@ -233,14 +233,15 @@ Published projects, the DJ stats, sets, press kits, shows, calendar events, foll - `dj/recording.lua` keeps every account's set recordings, which locallibrary uploads and a set's `recording` points at: the audio blob as written, how long it plays and `createdAt`, and nothing else. A recording without an audio blob isn't kept. - `profile.lua` keeps every account's Local Network profile at the key `self`, as written, when each field the site reads has the type it expects. `listing/profile.lua` keeps only the root's DJ listings, each keyed by the DID it names. - `dj/profile.lua` and `locallibrary/settings.lua` keep every account's DJ stats and rekordbox settings as written, at the key `self`. `epk.lua` keeps press kits of the root's projects: the root's own, and legacy ones by an account that manages the project they name. -- Jetstream only brings records written after HappyView started keeping them, so the app has HappyView re-read the root's and the managers' sets, recordings, stats, press kits, calendar events, profiles and Bluesky profiles from their PDS: for each of them once per version of each one's record script (one job per 500 accounts per collection, retried until all start, the version kept in the app database), and when a project gains a manager and HappyView serves it (their follows too). The same goes, once per script version, for the follows of the managers of projects whose press kits read follows, the root's verifications and DJ listings, and the bug report space. The edit form's set picker also re-reads its accounts' sets when it opens (one backfill for all of them, each account at most every ten minutes); publishing a project's first press kit that reads follows re-reads its managers' follows; and a profile or the space HappyView doesn't have yet is re-read, and waited for, when it's needed. -- locallibrary reads its account's sets, recordings, stats and settings back from HappyView before replacing them, so it first calls `computer.localnetwork.directory.requestIndex`, a procedure this app answers itself (`src/routes/xrpc/`) with inter-service auth from the account's PDS. It has HappyView re-read those four collections from the caller's repo, and only theirs, under the picker's limit (each account and collection at most every ten minutes; a call in between answers from the last re-read), and waits up to 5 seconds: `indexed` says whether it finished. +- Jetstream only brings records written after HappyView started keeping them, so the app has HappyView re-read the root's and the managers' sets, recordings, stats, press kits, calendar events, profiles and Bluesky profiles from their PDS: for each of them once per version of each one's record script (one job per 500 accounts per collection, retried until all start, the version kept in the app database), and when a project gains a manager and HappyView serves it (their follows too). The same goes, once per script version, for the follows of the managers of projects whose press kits read follows, the root's verifications and DJ listings, and the bug report space. The edit form's set picker also re-reads its accounts' sets when it opens (one backfill for all of them, each account at most every ten minutes); publishing a project's first press kit that reads follows re-reads its managers' follows; and a profile or the space HappyView doesn't have yet is re-read, and waited for, when it's needed. The `pauseBackfills` flag stops all of these without a deploy, including the ones that follow one change (a new manager, a late write, a first press kit, a DJ listing). Only the root's own performers are still re-read at boot, since the directory lists nothing without them. +- locallibrary reads its account's sets, recordings, stats and settings back from HappyView before replacing them, so it first calls `computer.localnetwork.directory.requestIndex`, a procedure this app answers itself (`src/routes/xrpc/`) with inter-service auth from the account's PDS. It has HappyView re-read those four collections from the caller's repo, and only theirs, under the picker's limit (each account and collection at most every ten minutes; a call in between answers from the last re-read), and waits up to 5 seconds: `indexed` says whether it finished. While the `pauseRequestIndex` flag is on, it answers `indexed: false` without re-reading anything. - `show.lua` keeps only shows with coordinates and an RFC 3339 start time by an account that manages the project they name, and only http(s) ticket links; `follow.lua` keeps only follows of the root's projects and of the profiles HappyView keeps, leaving out an account following its own. Jetstream sends every account's calendar events, from every calendar app, so `community/lexicon/calendar/event.lua` keeps only the root's (party events' public copies) and events by an account that manages one of the root's projects, as written. It checks the author rather than a show naming the event, so it doesn't matter which of the two HappyView hears of first. Listings read each show's own copy; the event is for the announce form, and the show's strongRef to it says when it changed since. `community/lexicon/calendar/rsvp.lua` keeps RSVPs from any calendar app to the root's calendar events, by the subject's URI, with just the event and the answer. - Other apps' records get gates too, since Jetstream sends every account's. `app/bsky/graph/verification.lua` keeps only the root's verifications. `app/bsky/actor/profile.lua` keeps every account's Bluesky profile (at the key `self`) as written: the hosted instance backfills all of them and keeps them current, so an account that becomes a manager, gets verified or makes a profile here later already has one. The site reads only the display names and pronouns: profile pages show the pronouns and verification statuses compare the names. Saving a profile has HappyView re-read that account's Bluesky profile. The profile form shows the pronouns but can't change them yet. `app/bsky/graph/follow.lua` keeps only the subject and date of follows by the managers of a project with a press kit that treats people they follow differently from anyone, since any of them following someone counts. `app/userinput/space.lua` keeps only `USERINPUT_SPACE`, whose version each bug report pins (record scripts get it beside `ROOT_DID`). Follows and profiles are busy: on 2026-10-24 Bluesky carried about 42 follow events and 1.3 profile changes a second. HappyView runs a script for each, which cost about 1.3 ms of CPU on a laptop under HappyView 2, nearly all of it HappyView's own cost per script run; the profile script now only checks the record key. The follow gate first looks up the root projects the follower manages, which ends it for nearly every follow. On the shared store a gate only hides records it has run over, so an account's raw follows show up in `listRecords` until it has; the site only reads follows by manager, for press kits that read them. HappyView 3 writes an event log row for each run only with verbose event logging on, so keep that off. - `listShows` lists upcoming shows by project, near a place, or by the projects an account follows, and checks again that each show's announcer still manages its active project. `getShows` looks shows up by URI, `getFollowStatus` counts a project's or a profile's followers and finds an account's follow, and `getRsvpStatus` counts who's going to and interested in a party event, each account once by its latest RSVP, and finds an account's RSVPs to it. Anyone can follow or RSVP, so those counts page through `happyview.db` rather than SQL keyed by account. - `searchProjects`, `matchProjects`, `getProject`, `getProjects`, and `getStats` do the search, ranking, and lookups. `searchPerformers` searches active projects and listed DJs together: a DJ counts when the root lists them and their profile has the performer section on, as a solo act, by the genres their DJ stats say they play most when the section names none. Both searches share their filters and ranking (`lua/lib/directory.lua`). Match results carry reason codes, which the app turns into text. `getProject` with `counts` also counts the project's press kits and upcoming shows, so the project's pages hold that much room for them while they stream in. `getSets` and `listSets` look up sets by URI and by account, without their tracks. - `getRecords` (up to 25 URIs) and `listRecords` (one account's records of one collection, last record key first, with a cursor) read any record HappyView keeps, as its record script stored it, the way `com.atproto.repo.getRecord` and `listRecords` read a PDS. For calendar events, the bug report space and DJ stats, a record HappyView lacks is read from the account's own PDS instead (`lua/lib/pds.lua`, through the `happyview-http` library plugin), without being stored or gated, so those don't wait for a backfill. The app's `IndexedRepo` (`src/lib/server/happyview/indexed.ts`) wraps them for the DJ stats and sets on project pages, press kits and their managers' follows, shows and their calendar events, verifications and display names, and the bug report space. A HappyView that's down reads as nothing for pages that list them, and fails a read that a change or an access decision depends on (opening one press kit, counting a project's press kits, moving legacy ones, syncing their spaces' members, a press kit's "people you follow" rule, editing a show, verifying, posting a bug report). A press kit draft and a show edit save only over the versions their form was opened on, and publishing a press kit or re-issuing a verification swaps on the version HappyView serves, so none overwrites a change the person hasn't seen: they're asked to reload. - `getCharts`, `getArtist`, and `searchArtists` count supports. They group every stored play by track and artist in SQL on each request (about a third of a second for 2,000 sets of 25 tracks on a laptop, measured on SQLite), so no counts are kept anywhere; the app reuses an answer for a minute, and the pages may be cached for as long. +- HappyView also follows Jetstream's account events. It removes the records of an account that's deleted, taken down or suspended, but keeps a deactivated account's, and a taken-down account's records come back only with a re-read. So the app asks an account's PDS whether it's active (`com.atproto.sync.getRepoStatus`) and keeps each answer in memory for half an hour (`src/lib/server/atproto/account-status.ts`, [ADR 0020](../../docs/adr/0020-inactive-accounts-are-asked-of-their-pds.md)). `searchPerformers`, `getCharts`, `getArtist`, `searchArtists`, `getSets` and `listShows` take an `inactive` list of up to 100 DIDs and leave out those accounts' sets, shows and listed profiles, along with a solo project that gives way to such a profile. The app sends the deactivated, taken-down and suspended ones among the managers and listed DJs (HappyView already dropped a deleted account's records), checked eight at a time in the background once the list is half an hour old, so pages never wait on it. After a restart, inactive accounts can show until the first check finishes, usually within seconds. An inactive answer is checked against a freshly fetched DID document, so an account that just moved PDS isn't taken for deleted or deactivated. A PDS that can't be asked leaves the account as last seen, or active. When a taken-down or suspended account is active again, the app has HappyView re-read its records. - The genre taxonomy and fee tiers are generated into the scripts from `src/lib/taxonomy/`, so TypeScript stays the source of truth. With `HAPPYVIEW_API_KEY` set, the app uploads whichever of its scripts and lexicons changed when it boots (scripts first, so the record gate is in place before ingestion starts), has HappyView track the other authorities' lexicons it needs that it doesn't yet (`POST /admin/network-lexicons`, which resolves them from the network and replaces a copy uploaded by hand), then has HappyView re-read the root's repo and waits for that to finish, and then every manager's shows in one batch. After publishing a project, a show, a follow, an RSVP, or a press kit it waits (up to 5 seconds) for HappyView to index it, so the next page shows it; when a show or its calendar event, a follow, an RSVP, or a press kit doesn't show up in time, HappyView re-reads that collection from that one account's repo. The directory queries are lexicons too, so `pnpm lexicons:publish` publishes a new one with the rest (see [Deploying](#deploying)). @@ -251,6 +252,7 @@ The app reads public records only from HappyView, never straight from a PDS (`co - Blobs in public repos: project images and profile avatars (`/media//`), tracklists and recordings (`/media/audio//`), with `com.atproto.sync.getBlob`, until HappyView serves blobs. Another account's avatar is served only when it's the one its indexed profile names, through the guarded fetch below. - The root's own projects when deciding who's in a booking thread (opening one, and the hourly manager sync), since a directory that's behind could let a removed manager back in. - DID and handle resolution, OAuth, and the root's session. +- Whether an account is active (`com.atproto.sync.getRepoStatus` on its PDS), which HappyView doesn't serve (see above). - HappyView's own re-reads of a repo (`/admin/backfill`, see above), which it makes from the account's PDS. - Tooling: the integration tests, the dev network, and `pnpm lexicons:publish`. @@ -278,6 +280,8 @@ pnpm dev `harbour.test`, `pirate.test`, and `glasshouse.test` (passwords `harbour-pass` and so on) manage Harbour Lights, Pirate Signal, and Glasshouse and have sets of their own, so `/charts` has tracks several DJs played. Every other demo project has a manager too (`velvet.test`, `tunde.test` and so on; the dev network prints them all). Each manager got there through a claim ada.test approved, and each solo project's DJ claimed it as themselves. +Inbox email and DMs go to the log locally, and bug reports to the stand-in space, once their flags (`inboxEmail`, `inboxDm`, `userinputReports`) are on for you: turn them on at `/admin/flags` as ada.test, or start with `FLAG_OVERRIDES=inboxEmail=on,inboxDm=on,userinputReports=on`. + The network is temporary; Ctrl-C stops it, and restarting resets everything (and the dev database). To restart the app without resetting the network, run `pnpm dev:network` in one terminal and `pnpm dev:app` in another. ## Scripts @@ -289,6 +293,7 @@ The network is temporary; Ctrl-C stops it, and restarting resets everything (and | `pnpm build` / `pnpm start` | Production build (adapter-node) / run it | | `pnpm check` | `svelte-check` with TypeScript 6, after `pnpm lexicons:types` | | `pnpm lint` | Oxlint with type-aware rules (tsgolint) and the anti-slop plugin, then the story check | +| `pnpm i18n:check` | `inlang check` on the message catalogs ([Translation](#translation)) | | `pnpm format` / `pnpm format:check` | Oxfmt | | `pnpm test` | Unit tests (Node) + component tests (Vitest browser mode, Chromium) | | `pnpm test:integration` | Full flows against an in-process spaces PDS and a HappyView container | @@ -357,9 +362,9 @@ See [`.env.example`](.env.example) for every option. The essentials: - `HAPPYVIEW_API_KEY`: a HappyView API key with `lexicons:read`, `lexicons:create`, `scripts:read`, `scripts:manage`, `backfill:create`, `backfill:read`, `stats:read`, `dead-letters:read`, and `metrics:read`. Optional; without it, upload the lexicons and scripts yourself, the set picker only lists sets HappyView heard about over Jetstream, and `requestIndex` answers `indexed: false` without re-reading anything. - `HAPPYVIEW_CLIENT_KEY` and `HAPPYVIEW_CLIENT_SECRET`: a HappyView API client's key and secret, sent with each directory query (`X-Client-Key`, `X-Client-Secret`) so it counts as that client's. Optional, set together; needed once the instance refuses anonymous XRPC calls. - `LOCALLIBRARY_HOST`: [locallibrary's own host](#tools-pages-and-hosts) (default `locallibrary.localnetwork.computer`). -- `USERINPUT_SPACE`: Local Network's space on [userinput.app](https://userinput.app), as `at:///app.userinput.space/`. See [Bug reports](#bug-reports). Optional; without it, "Report a bug" opens GitHub's issue form. -- `RESEND_API_KEY` (and optionally `EMAIL_FROM`, `EMAIL_PROVIDER`): sends inbox email through [Resend](https://resend.com) for people who turn it on. Optional; in production without it, email is off and the settings page says so. Outside production, email goes to the log. -- `DM_PROVIDER` (and optionally `CHAT_SERVICE_DID`): `bluesky` sends inbox DMs from the root account through Bluesky chat. Off in production until set; first check that Bluesky's relay and AppView know the root account and that it can call `chat.bsky.convo.getConvoAvailability`. Outside production, DMs go to the log. +- `USERINPUT_SPACE`: Local Network's space on [userinput.app](https://userinput.app), as `at:///app.userinput.space/`. See [Bug reports](#bug-reports). Optional; without it, "Report a bug" opens GitHub's issue form. With it, reports go there only for accounts `userinputReports` is on for. +- `RESEND_API_KEY` (and optionally `EMAIL_FROM`, `EMAIL_PROVIDER`): sends inbox email through [Resend](https://resend.com) for people who turn it on and `inboxEmail` is on for. Optional; in production without it, email is off and the settings page says so. Outside production, email goes to the log. +- `DM_PROVIDER` (and optionally `CHAT_SERVICE_DID`): `bluesky` sends inbox DMs from the root account through Bluesky chat, to accounts `inboxDm` is on for. Off in production until set; first check that Bluesky's relay and AppView know the root account and that it can call `chat.bsky.convo.getConvoAvailability`. Outside production, DMs go to the log. - `ACTOR_SEARCH`: where sign-in's account suggestions come from, `bluesky` (the default) or `none`. - `GOOGLE_CLIENT_ID` / `GOOGLE_CLIENT_SECRET`, `MIXCLOUD_CLIENT_ID` / `MIXCLOUD_CLIENT_SECRET`, `SOUNDCLOUD_CLIENT_ID` / `SOUNDCLOUD_CLIENT_SECRET`: Local Network's clients at the services locallibrary plugins sign in to through the [token exchange](#token-exchange). Optional; a service without both answers that it isn't set up yet. @@ -379,7 +384,7 @@ See [`.env.example`](.env.example) for every option. The essentials: docker run -p 3000:3000 -v localnetwork-data:/data --env-file .env localnetwork ``` To try an image first, `pnpm -C apps/web test:docker` runs the one tagged `localnetwork` against the local network with an empty volume and fetches a few pages, as CI does. -5. Run **one** instance (SQLite and in-process background jobs). Give it a bucket for [backups](#backups) of `/data`: it holds OAuth sessions, the audit outbox, and records that exist nowhere else. +5. Run **one** instance (SQLite and in-process background jobs). Give it a bucket for [backups](#backups) of `/data`: it holds OAuth sessions, the audit outbox, and records that exist nowhere else ([Where state lives](#where-state-lives)). 6. Point `locallibrary.localnetwork.computer` at the same deployment (a DNS record, plus the custom domain on your host) for [its client document](#tools-pages-and-hosts). `/healthz` reports database, root-account, HappyView, and backup status (`backup` is `stale` with no backup in two days, `off` without a bucket). It answers 200 either way. @@ -400,7 +405,7 @@ railway ssh --service localnetwork -- node scripts/db-backup.ts restore latest railway service restart --service localnetwork --yes ``` -A restore downloads the backup, checks its integrity, keeps the database it replaces as `localnetwork.db.before-restore` beside it, and writes the backup in with the same online backup, so it's safe while the app has the database open. `pnpm db:restore data/copy.db` restores to another path instead, to look at a backup locally. +A restore downloads the backup, checks its integrity, keeps the database it replaces as `localnetwork.db.before-restore` beside it, and writes the backup in with the same online backup, so it's safe while the app has the database open. Flags come back as the backup had them until the first sync reads the staff space again, and the member rounds at boot run before it. So `pauseReconcilers` holds through a restore only if it was on when the backup was taken; turn it on again from its page once the app is up. `pnpm db:restore data/copy.db` restores to another path instead, to look at a backup locally. ### Tools' pages and hosts @@ -429,7 +434,7 @@ The services are in [`src/lib/server/token-exchange/services.json`](src/lib/serv - OAuth uses DPoP-bound tokens and granular scopes: a permission set ([`permissions.json`](../../lexicons/computer/localnetwork/permissions.json), requested as `include:computer.localnetwork.permissions`) with write-only access to the user's own repos in the audit, moderation, booking, backstage, press kit request, and performer spaces and a self-authority planner space, and to the profile, shows and follows in their public repo and updates to their sets (plus deleting press kits made before the root held them, as they move), plus blob uploads limited to PNG, JPEG, and WebP avatars and JSON tracklists, and calendar events and RSVPs (`repo:community.lexicon.calendar.event` and `.rsvp`, asked for on their own since a permission set can only grant its own namespace). The PDS grants the set as the scopes it lists. The shared spaces it grants writes to are the root's only: `did:web:root.invalid` in the file stands for the root, and each network's root publishes the set with its own DID there (`pnpm lexicons:publish` for production; the dev network and the integration tests publish their own). Accounts without spaces support are asked for `atproto` plus the profile, show, follow, calendar event and RSVP writes and the blob uploads, and fall back to plain `atproto` if their PDS refuses those; they, and anyone who approves only part of the request, have the root account write their space records on their behalf. Sessions granted before the app asked for a new space or blob scope are sent back through sign-in on their next page load. Profile, show, follow, calendar event and RSVP writes, set updates, and drafts in a performer's space are asked for when they're needed instead, with a one-click "Sign in again"; a PDS that still won't grant them after that gets a plain "your account's server doesn't allow this yet". Posting bug reports to userinput.app is asked for separately, when someone first sends one, and only allows creating `app.userinput.discussion` records. Nothing lets the app read other users' data with a user's session; shared spaces are read with credentials issued to the root authority. - Browser sessions are opaque random tokens stored as SHA-256 hashes; cookies are `HttpOnly`, `SameSite=Lax`, and `Secure` on HTTPS, except `ln_signed_out`, which holds only the DIDs whose drafts to drop and is read by the page's scripts. - CSP with per-request nonces, `frame-ancestors 'none'`, `nosniff`, strict referrer policy, HSTS on HTTPS, and SvelteKit's CSRF origin checks. -- Every request to a host from a DID document goes through `@atproto-labs/fetch-node`'s safe fetch in production: no redirects, HTTPS only, and no private or loopback address, checked as it connects so DNS can't swap the address after. Resolving a DID or handle and fetching another account's avatar use the default port only, with responses up to 2 MB. Space credential calls, space sync, blob downloads and streamed recordings from a PDS, and everything the OAuth client sends (identity lookups, PDS and authorization server metadata, authorization and token requests, session requests) allow any port and have no size or time cap of their own, since callers bound what they read and how long they wait. The OAuth client sets no time limit on session requests, so the app gives each of its requests 30 seconds. The OAuth client leaves its requests to follow redirects, so the app makes them refuse redirects instead. ast-grep's [`no-unguarded-fetch`](../../tools/ast-grep/rules/no-unguarded-fetch.yml) rule fails a plain or passed-in `fetch` in any function that reads such a host. did:web hosts and handles that are IP addresses, carry a port, or use `localhost` or a reserved TLD are refused before any request, and `/@` lookups that find no account are rate-limited per IP. +- Every request to a host from a DID document goes through `@atproto-labs/fetch-node`'s safe fetch in production: no redirects, HTTPS only, and no private or loopback address, checked as it connects so DNS can't swap the address after. Resolving a DID or handle and fetching another account's avatar use the default port only, with responses up to 2 MB. Space credential calls, space sync, account status checks, blob downloads and streamed recordings from a PDS, and everything the OAuth client sends (identity lookups, PDS and authorization server metadata, authorization and token requests, session requests) allow any port and have no size or time cap of their own, since callers bound what they read and how long they wait. The OAuth client sets no time limit on session requests, so the app gives each of its requests 30 seconds. The OAuth client leaves its requests to follow redirects, so the app makes them refuse redirects instead. ast-grep's [`no-unguarded-fetch`](../../tools/ast-grep/rules/no-unguarded-fetch.yml) rule fails a plain or passed-in `fetch` in any function that reads such a host. did:web hosts and handles that are IP addresses, carry a port, or use `localhost` or a reserved TLD are refused before any request, and `/@` lookups that find no account are rate-limited per IP. - Links people wrote into their own records (profiles, sets, press kits, shows, requests) are only made clickable when they're http(s) addresses (`src/lib/web-url.ts`). - Uploaded images are type- and magic-byte-checked and capped at 1 MB for avatars and 5 MB for press kit photos. Stored images are served only if their blob's type is one their lexicon accepts (PNG, JPEG or WebP), since a PDS doesn't check, with a sandboxing CSP and `nosniff`. - `/media/audio//` streams only a blob that an indexed `computer.localnetwork.dj.recording` of an active project's manager references, as the type and size that record declares, with Range answered by the app since `getBlob` ignores it. The type and size limits are the lexicon's own (`audio/*` or `video/mp4`, at most 300 MiB); `video/mp4` is what a PDS calls an M4A it can't tell is audio, so it goes out as `audio/mp4`. It stores nothing, and sends a locked-down CSP and `nosniff`. The page CSP allows media only from the site, plyr.fm's CDN and archive.org's download hosts, images only from the site and Bluesky's avatar CDN (for sign-in's account suggestions), and scripts only from SoundCloud's and Mixcloud's widget hosts besides its own. @@ -438,10 +443,22 @@ The services are in [`src/lib/server/token-exchange/services.json`](src/lib/serv - The [token exchange](#token-exchange) only sends requests to the token endpoints `services.json` lists, and never logs what it relays. - Spaces are access control, not end-to-end encryption: the hosting PDSes and this app can read the data they handle. +## Translation + +The site is in English, and ready for a second language ([ADR 0019](../../docs/adr/0019-english-stays-unprefixed-and-records-carry-their-language.md)). Its words live in `messages/en.json`, and a component shows one by calling its message: `import { m } from '#lib/paraglide/messages.js'`, then `{m.footer_privacy()}`. [Paraglide JS](https://paraglidejs.com) compiles the catalogs (`project.inlang/`) into `src/lib/paraglide/`, which git ignores, in the dev server, builds and tests, and in `pnpm check` and `pnpm install`. So far only the root layout's footer and skip link come from the catalog. The dates and numbers `src/lib/format.ts` writes follow the same locale. + +To add a string, put it in `messages/en.json`, run `node scripts/pseudo-locale.ts` to regenerate `messages/en-XA.json`, and call `m.()`. A test fails while en-XA is out of date, `pnpm i18n:check` fails on a message a locale lacks or a variable it gets wrong, and ast-grep's `no-raw-text` rule fails on words written into the markup of a component that has moved to the catalog. Add a component to that rule's `files` once its text has moved. + +To see the pseudo-locale, run `document.cookie = 'ln_locale=en-XA; path=/'` in the browser's console and reload (`ln_locale=en` goes back). en-XA accents every letter, makes each line about a third longer and brackets each message, so plain English on the page is text that hasn't moved to the catalog, and a clipped or missing bracket is a layout that can't stretch or a message cut short. + +Tests run in en-US and UTC whatever the machine's settings: `vite.config.ts` pins Vitest's and `playwright.config.ts` the end-to-end tests'. + ## Project layout ``` lua/ HappyView scripts: the record gates and the directory queries, one file per NSID +messages/ The message catalogs: en.json, and en-XA.json generated from it (Translation) +project.inlang/ The inlang project Paraglide compiles the catalogs from, and Paraglide's config scripts/ dev-network (local atproto network), publish-lexicons, seed data, mix-fixture, db-backup scripts/lib/ Local HappyView container and Jetstream stand-in src/lib/ Shared code: matching, genre taxonomy, geo, formatting, components @@ -465,7 +482,7 @@ src/lib/server/meta.ts What each public page tells link previews and se src/lib/server/meta-records.ts The records behind a public page, written into its head as at-tags (`at:canonical`, `at:alternate`, `at:author`) src/lib/server/structured-data.ts The schema.org structured data (JSON-LD) a performer, profile, mix or artist page adds to its `meta` src/lib/og/cards/ The link-preview pictures (1200×630), one Svelte component each, with their stories -src/lib/server/og/ Draws them as PNGs for src/routes/og/, keeping recent ones in memory +src/lib/server/og/ Draws them as PNGs for src/routes/og/, keeping recent ones in memory; with `pauseOgCards` on, only the site's card is drawn and pages point to it src/routes/ SvelteKit 3 pages, form actions, and endpoints tests/integration/ Flows against an in-process spaces PDS and a HappyView container tests/e2e/ Playwright @@ -476,7 +493,7 @@ tests/e2e/ Playwright - Oxfmt doesn't format `.svelte` files yet; it formats everything else. - The spaces alpha has no relay: sync load falls on PDSes, mitigated by notifications and incremental oplog sync. -- Account deactivation/deletion events arrive on the firehose, which this app doesn't subscribe to yet. +- The app doesn't follow account events itself. It asks an account's PDS whether it's active and keeps the answer for half an hour, so a deactivated account leaves Find DJs, the charts and listings, and comes back, up to half an hour late. A taken-down or suspended account's records come back only if this server saw it go and come back, since HappyView drops them and the app has them re-read only then. - The directory scripts' SQL is written for Postgres, so the HappyView instance must use Postgres, not SQLite. - HappyView drops a Jetstream cursor older than 72 hours. The boot backfill recovers new and changed projects after a longer outage, but not deletions (nothing deletes projects today). @@ -520,7 +537,7 @@ flowchart TD App -- "daily backup" --> Bucket App -- "queries, scripts,
re-reads" --> HV App -- "root session" --> Root - App -- "OAuth sessions,
space sync" --> Pds + App -- "OAuth sessions, space sync,
account status" --> Pds Root -- "notifySpaceUpdate" --> App Root --> Jet Pds --> Jet @@ -557,7 +574,7 @@ What the server calls, and why. flowchart LR App["Local Network app"] App -- "DIDs and handles" --> Identity["PLC directory, did:web hosts,
handle resolution"] - App -- "OAuth, writes, blobs, space sync" --> Pds["PDSes"] + App -- "OAuth, writes, blobs, space sync,
account status" --> Pds["PDSes"] App -- "directory" --> HV["HappyView"] App -- "sign-in suggestions" --> Bsky["public.api.bsky.app"] App -- "city search" --> Geo["Open-Meteo or Nominatim"] @@ -568,7 +585,7 @@ flowchart LR App -- "backups" --> S3["S3 bucket"] ``` -Source: [`src/lib/server/atproto/identity.ts`](src/lib/server/atproto/identity.ts), [`src/lib/server/actor-search.ts`](src/lib/server/actor-search.ts), [`src/lib/server/geocode.ts`](src/lib/server/geocode.ts), [`src/lib/server/plyr.ts`](src/lib/server/plyr.ts), [`src/lib/server/notifications/email.ts`](src/lib/server/notifications/email.ts), [`src/lib/server/notifications/dm.ts`](src/lib/server/notifications/dm.ts), [`src/lib/server/token-exchange/services.json`](src/lib/server/token-exchange/services.json), [`src/lib/server/backup/store.ts`](src/lib/server/backup/store.ts) +Source: [`src/lib/server/atproto/identity.ts`](src/lib/server/atproto/identity.ts), [`src/lib/server/atproto/account-status.ts`](src/lib/server/atproto/account-status.ts), [`src/lib/server/actor-search.ts`](src/lib/server/actor-search.ts), [`src/lib/server/geocode.ts`](src/lib/server/geocode.ts), [`src/lib/server/plyr.ts`](src/lib/server/plyr.ts), [`src/lib/server/notifications/email.ts`](src/lib/server/notifications/email.ts), [`src/lib/server/notifications/dm.ts`](src/lib/server/notifications/dm.ts), [`src/lib/server/token-exchange/services.json`](src/lib/server/token-exchange/services.json), [`src/lib/server/backup/store.ts`](src/lib/server/backup/store.ts) ### What the browser reaches @@ -589,7 +606,7 @@ Source: [`vite.config.ts`](vite.config.ts), [`src/lib/bug-report.ts`](src/lib/bu ### Where state lives -Every place the app keeps something, and what rebuilds it. +Every place the app keeps something, and what rebuilds it. `TABLE_SOURCE` in `schema.ts` marks each SQLite table rebuilt or server-only, and `SERVER_ONLY_COLUMNS` the parts of rebuilt tables a re-sync can't bring back; a test fails when a table has neither. ```mermaid flowchart TD @@ -598,17 +615,18 @@ flowchart TD Spaces["Spaces
each writer's repo in each space"] end subgraph Server["On the server"] - Index[("SQLite, rebuilt by sync:
requests, threads, grants, people,
performers, flags and flag groups")] - Only[("SQLite, not rebuilt:
sessions, inboxes, receipts")] - Outbox[("SQLite audit log:
rebuilt from the root's copies")] + Index[("SQLite, rebuilt by sync:
requests and their answers, threads, grants,
people, performers, flags and flag groups")] + Only[("SQLite, not rebuilt:
sessions, accounts, inboxes, email settings,
receipts, the geocode cache, and columns like
deletion marks and booking status as first read")] + Outbox[("SQLite audit log:
delivered entries rebuilt from the root's copies")] Memory["Memory:
rate limits, credentials, caches"] + Config["Environment:
ADMIN_DIDS, secrets"] end subgraph Elsewhere["Elsewhere"] HV[("HappyView:
public records its gates keep")] Bucket[("Bucket: database backups")] end subgraph Client["In the browser"] - Cookies["Cookies: ln_session, ln_signed_out,
ln_flag_preview, the city picked last for shows"] + Cookies["Cookies: ln_session, ln_signed_out,
ln_flag_preview, ln_locale,
the city picked last for shows"] Local["localStorage: unsent form drafts,
the hotkeys preference"] end Repos -- "Jetstream, re-reads" --> HV @@ -619,7 +637,7 @@ flowchart TD Outbox -- "daily" --> Bucket ``` -Source: [`src/lib/server/db/schema.ts`](src/lib/server/db/schema.ts), [`src/lib/server/sync/engine.ts`](src/lib/server/sync/engine.ts), [`src/lib/form-draft.svelte.ts`](src/lib/form-draft.svelte.ts), [`src/lib/server/shows-place.ts`](src/lib/server/shows-place.ts), [`src/lib/server/flags/preview.ts`](src/lib/server/flags/preview.ts) +Source: [`src/lib/server/db/schema.ts`](src/lib/server/db/schema.ts), [`src/lib/server/sync/engine.ts`](src/lib/server/sync/engine.ts), [`src/lib/server/config.ts`](src/lib/server/config.ts), [`src/lib/form-draft.svelte.ts`](src/lib/form-draft.svelte.ts), [`src/lib/server/shows-place.ts`](src/lib/server/shows-place.ts), [`src/lib/server/flags/preview.ts`](src/lib/server/flags/preview.ts), [`project.inlang/paraglide.config.ts`](project.inlang/paraglide.config.ts) ### Local tables: bookings and press kits diff --git a/apps/web/docs/diagrams/flags.md b/apps/web/docs/diagrams/flags.md index b1427c0f9..f5d44364f 100644 --- a/apps/web/docs/diagrams/flags.md +++ b/apps/web/docs/diagrams/flags.md @@ -10,7 +10,7 @@ Deciding a flag, flags on each request, getFlags, the staff console and the flag ## Deciding a flag -Whether one flag is on for one caller. Only flags in `flags/catalog/` exist: a record for a flag that's gone from it is ignored. +Whether one flag is on for one caller. Only flags in `flags/catalog/` exist: a record for a flag that's gone from it is ignored. A caller with no DID comes last. `signedOut` is worked out as the record is read: an ops flag's is its `everyone`, and a release flag's only holds while every account has it. ```mermaid flowchart TD @@ -21,11 +21,15 @@ flowchart TD Record -- "no" --> Off Record -- "yes" --> Enabled{"enabled?"} Enabled -- "no" --> Off - Enabled -- "yes" --> Everyone{"everyone?"} + Enabled -- "yes" --> Caller{"A DID?"} + Caller -- "no" --> SignedOut{"signedOut, and everyone
or 100%?"} + SignedOut -- "yes" --> On + SignedOut -- "no" --> Off + Caller -- "yes" --> Everyone{"everyone?"} Everyone -- "yes" --> On Everyone -- "no" --> Targeted{"The DID is in its accounts
or one of its groups?"} Targeted -- "yes" --> On - Targeted -- "no" --> Bucket{"Signed in, and SHA-256 of key + DID,
mod 100, under percentage?"} + Targeted -- "no" --> Bucket{"SHA-256 of key + DID,
mod 100, under percentage?"} Bucket -- "yes" --> On Bucket -- "no" --> Off ``` @@ -75,11 +79,13 @@ Source: [`src/routes/xrpc/computer.localnetwork.flags.getFlags/+server.ts`](../. ## Changing flags -What `/admin/flags` writes. Admins hold both grants; a moderator holds what an admin gives them on `/admin/staff`. Each write is audited, and saving a flag or a group unchanged writes nothing. +What `/admin/flags` writes. Admins hold both grants; a moderator holds what an admin gives them on `/admin/staff`. Each write is audited, and saving a flag or a group unchanged writes nothing. A save writes an ops flag's `signedOut` as its `everyone`, and a release flag's as off while it's below every account. ```mermaid flowchart TD - Flag["/admin/flags/[key]"] -- "save, needs flags" --> PutFlag["Put staff.flag in the staff space,
keyed by the flag"] + Flag["/admin/flags/[key]"] -- "save, needs flags" --> Last{"Signed-out visitors ticked for a
release flag that had them off,
below every account?"} + Last -- "yes" --> TooSoon["Refused: turn it on
for every account first"] + Last -- "no" --> PutFlag["Put staff.flag in the staff space,
keyed by the flag"] Flag -- "preview on, off or clear,
needs flags" --> Preview["ln_flag_preview for an hour,
audited as flag.preview"] Groups["/admin/flags/groups"] -- "create or edit,
needs flagGroups" --> PutGroup["Put staff.group in the staff space"] Groups -- "delete, needs flagGroups" --> InUse{"A flag targets it?"} @@ -108,6 +114,7 @@ erDiagram feature_flag { text key PK integer enabled + integer signed_out integer everyone integer percentage text group_rkeys diff --git a/apps/web/docs/diagrams/jobs-and-directory.md b/apps/web/docs/diagrams/jobs-and-directory.md index 8680e4530..c337d3983 100644 --- a/apps/web/docs/diagrams/jobs-and-directory.md +++ b/apps/web/docs/diagrams/jobs-and-directory.md @@ -12,7 +12,7 @@ Startup, scheduled jobs and HappyView. The rest are listed in the [README](../.. ## Startup -What happens when the process starts. A failed start leaves the setup page up, and the next request tries again. +What happens when the process starts. A failed start leaves the setup page up, and the next request tries again. While the `pauseReconcilers` flag is on for everyone, bootstrap skips the reconcile steps that write to the root's repo and `moveKitSpaces`, logging each one it skips. `reconcileBlocks` still runs: it only reads the root's blocks into the index. On a new or restored database the member steps run before `syncAll` has read the flag's record, so they read it as the database had it: off on a fresh one, as the backup had it after a restore. ```mermaid flowchart TD @@ -35,7 +35,7 @@ Source: [`src/hooks.server.ts`](../../src/hooks.server.ts), [`src/lib/server/app ## Scheduled jobs -The jobs the app schedules, all in one process. A job still running skips its next turn. +The jobs the app schedules, all in one process. A job still running skips its next turn. While the `pauseReconcilers` flag is on for everyone, the rounds that write to the root's repo (staff-spaces, manager-spaces, shared-spaces, listings and calendar-copies) skip their turn and log that they did. venue-blocks only reads the root's blocks into the index, so it keeps running: a block index left empty would show blocked promoters as confirmed. ```mermaid flowchart LR @@ -59,7 +59,7 @@ Source: [`src/lib/server/app.ts`](../../src/lib/server/app.ts), [`src/lib/server ## Directory sync -What `syncDirectory` does with `HAPPYVIEW_API_KEY` set, at boot and from the System page. A failed upload or root re-read is kept for the System page and retried. The re-reads after it only log a failure. +What `syncDirectory` does with `HAPPYVIEW_API_KEY` set, at boot and from the System page. A failed upload or root re-read is kept for the System page and retried. The re-reads after it only log a failure. While the `pauseBackfills` flag is on for everyone, the shows and refreshRecords re-reads are skipped and logged, here and on the directory-sync round; the root's performers are still re-read, since the directory lists nothing without them. ```mermaid flowchart TD @@ -76,7 +76,7 @@ Source: [`src/lib/server/happyview/sync.ts`](../../src/lib/server/happyview/sync ## HappyView re-reads -What makes the app ask HappyView to read repos again through `/admin/backfill`, up to 500 accounts a job. Jetstream only brings new writes, so these fill the gaps; on the hosted instance's shared Network store, they run the record script over what the store holds. +What makes the app ask HappyView to read repos again through `/admin/backfill`, up to 500 accounts a job. Jetstream only brings new writes, so these fill the gaps; on the hosted instance's shared Network store, they run the record script over what the store holds. The `pauseBackfills` flag stops all of them but the root's performers at boot, which the directory needs to list anything. ```mermaid flowchart LR @@ -107,6 +107,8 @@ sequenceDiagram A->>A: Check audience,
method and signature alt Check fails A-->>L: 401 + else pauseRequestIndex is on + A-->>L: indexed: false else par sets, recordings, stats, settings, all at once A->>H: Backfill the issuer's repo,
unless done in the last 10 minutes diff --git a/apps/web/docs/diagrams/mixes-and-sets.md b/apps/web/docs/diagrams/mixes-and-sets.md index f42540fb5..d64d62fd6 100644 --- a/apps/web/docs/diagrams/mixes-and-sets.md +++ b/apps/web/docs/diagrams/mixes-and-sets.md @@ -82,8 +82,8 @@ flowchart TD HV --> Set Set --> Recording{"Its recording?"} Recording -- "fm.plyr.track" --> Plyr["api.plyr.fm: file on audio.plyr.fm,
or plyr's player if it's gated"] - Recording -- "dj.recording by an
active performer's manager" --> Stream["/media/audio/[did]/[cid]"] - Recording -- "none, or it won't resolve" --> Links["Its links: archive.org plays directly,
others in their own players"] + Recording -- "dj.recording by an active account
managing an active performer" --> Stream["/media/audio/[did]/[cid]"] + Recording -- "none, it won't resolve, or a dj.recording
while pauseRecordingStream is on" --> Links["Its links: archive.org plays directly,
others in their own players"] Stream --> Blob["getBlob from the DJ's PDS,
Range answered by the app, nothing stored"] ``` @@ -98,7 +98,10 @@ flowchart TD Visit["/@[handle]/sets/[rkey]"] --> Account{"Names an account?"} Account -- "no" --> Miss["404, counted against
the visitor's lookups"] Account -- "a DID, or another spelling
of the handle" --> Redirect["302 to /@[handle]/sets/[rkey]"] - Account -- "yes" --> Set["recordings.set: the dj.set from HappyView"] + Account -- "yes" --> Active{"Account active?
getRepoStatus, kept 30 minutes"} + Active -- "deactivated, taken
down or suspended" --> Inactive["404: the account isn't active"] + Active -- "deleted" --> Deleted["410: the account was deleted"] + Active -- "yes" --> Set["recordings.set: the dj.set from HappyView"] Set -- "none, or it won't parse" --> Gone["404"] Set --> Render["Rendered: name, date, place,
player and tracklist"] Render -.-> Event["Streamed: the event's name,
when HappyView keeps that event"] @@ -106,15 +109,16 @@ flowchart TD Mixes --> Report["Each links its tracklist page,
else its listen link"] ``` -Source: [`src/routes/@[handle]/sets/[rkey]/+page.server.ts`](../../src/routes/@[handle]/sets/[rkey]/+page.server.ts), [`src/lib/server/profile-page.ts`](../../src/lib/server/profile-page.ts), [`src/lib/server/services/recordings.ts`](../../src/lib/server/services/recordings.ts), [`src/lib/server/services/shows.ts`](../../src/lib/server/services/shows.ts) +Source: [`src/routes/@[handle]/sets/[rkey]/+page.server.ts`](../../src/routes/@[handle]/sets/[rkey]/+page.server.ts), [`src/lib/server/profile-page.ts`](../../src/lib/server/profile-page.ts), [`src/lib/server/atproto/account-status.ts`](../../src/lib/server/atproto/account-status.ts), [`src/lib/server/services/recordings.ts`](../../src/lib/server/services/recordings.ts), [`src/lib/server/services/shows.ts`](../../src/lib/server/services/shows.ts) ## Charts and artist pages -Support counts come straight from the sets HappyView keeps, and nothing stores them. A listed DJ who manages no active performer doesn't count. With HappyView down, the pages say so. +Support counts come straight from the sets HappyView keeps, and nothing stores them. A listed DJ who manages no active performer doesn't count, and neither does a DJ whose account isn't active. With HappyView down, the pages say so. ```mermaid flowchart TD - Sets["dj.set records of active performers' managers,
each named track kept by the gate"] --> Sql["Lua queries group plays in SQL"] + Sets["dj.set records of active performers' managers,
each named track kept by the gate"] --> Sql + Inactive["The app's list of deactivated,
taken-down and suspended accounts"] -- "inactive param" --> Sql["Lua queries group plays in SQL"] Sql --> Charts["getCharts"] Sql --> Artist["getArtist"] Sql --> Search["searchArtists"] @@ -126,4 +130,4 @@ flowchart TD Memo --> P3["/artists"] ``` -Source: [`src/lib/server/services/supports.ts`](../../src/lib/server/services/supports.ts), [`src/routes/charts/+page.server.ts`](../../src/routes/charts/+page.server.ts), [`lua/computer/localnetwork/directory/getCharts.lua`](../../lua/computer/localnetwork/directory/getCharts.lua), [`lua/computer/localnetwork/directory/getArtist.lua`](../../lua/computer/localnetwork/directory/getArtist.lua) +Source: [`src/lib/server/services/supports.ts`](../../src/lib/server/services/supports.ts), [`src/lib/server/atproto/account-status.ts`](../../src/lib/server/atproto/account-status.ts), [`src/routes/charts/+page.server.ts`](../../src/routes/charts/+page.server.ts), [`lua/computer/localnetwork/directory/getCharts.lua`](../../lua/computer/localnetwork/directory/getCharts.lua), [`lua/computer/localnetwork/directory/getArtist.lua`](../../lua/computer/localnetwork/directory/getArtist.lua) diff --git a/apps/web/docs/diagrams/press-kits.md b/apps/web/docs/diagrams/press-kits.md index abb63fbba..83bd2d97b 100644 --- a/apps/web/docs/diagrams/press-kits.md +++ b/apps/web/docs/diagrams/press-kits.md @@ -21,12 +21,13 @@ sequenceDiagram participant R as Root's repo participant K as Press kit's space M->>A: Save, over the version
the form opened on - A->>B: epk.draft: changed fields
and what they replace + A->>B: epk.draft: changed fields, what they
replace, and the writer's languages
when it changes words M->>A: Publish A->>A: Compare each field
with what's published now alt Another manager changed the field A-->>M: Conflict, pick a
side per field else + Note over A,K: epk and epk.content each take the draft's
languages only when it changes their words A->>R: Copy new photos,
put epk over the live CID A->>A: Wait up to 5 s
for HappyView A->>K: Root writes epk.content @@ -50,7 +51,9 @@ flowchart TD Audiences -- "review" --> Pending["epk.request in the performer's
request space, waits for a manager"] Audiences -- "auto" --> Auto["epk.request, then a grant at once
(a legacy press kit's waits for its move)"] Pending -- "manager approves" --> Grant["Root adds them to the press kit's space
and writes epk.grant to the request space"] + Pending -- "manager declines" --> Declined["Root writes epk.decision, declined,
to the request space; they can't ask again"] Auto --> Grant + Grant -- "it answered a request" --> Approved["Root writes epk.decision, approved,
which outlasts the grant"] Invite["A manager invites them"] --> Grant ``` @@ -58,7 +61,7 @@ Source: [`src/lib/epk.ts`](../../src/lib/epk.ts), [`src/lib/server/services/epk. ## Press kit grant lifecycle -Where someone stands with one press kit. Someone declined can't ask again, but a manager can still invite them. +Where someone stands with one press kit. Someone declined can't ask again, but a manager can still invite them. The root's decision record keeps a decline through a re-sync, even after the asker deletes their request. ```mermaid stateDiagram-v2 @@ -123,7 +126,7 @@ Any of the performer's managers can delete a press kit the root holds. The space flowchart TD Ask["Delete in the press kit's editor"] --> Check["A manager of the performer,
and not a legacy press kit"] Check --> Space["Root deletes the press kit's space,
which puts everyone out of it"] - Space --> Records["Root deletes the requests it wrote
for people, and the grant records"] + Space --> Records["Root deletes the requests it wrote
for people, its decisions and grant records"] Records --> Public["Root deletes the epk record"] Public --> Wait["Waits for HappyView to stop serving it"] Wait --> Index["Forgets the local rows"] diff --git a/apps/web/docs/diagrams/requests-and-routes.md b/apps/web/docs/diagrams/requests-and-routes.md index 62090acd3..0caa766f0 100644 --- a/apps/web/docs/diagrams/requests-and-routes.md +++ b/apps/web/docs/diagrams/requests-and-routes.md @@ -35,11 +35,12 @@ flowchart TD Flags --> Guard["guardArea by route"] Guard -- "/dashboard or /admin,
signed out" --> Login["303 to /login?next="] Guard -- "/admin, not staff" --> Refused["403"] - Guard --> Route["Load, action or endpoint,
page CSP with a nonce"] + Guard --> Locale["Locale from ln_locale,
English without it"] + Locale --> Route["Load, action or endpoint,
page CSP with a nonce,
the page's lang and dir"] Route --> Out["gzip, security headers,
noindex on unlisted areas,
the one log line for the request"] ``` -Source: [`src/hooks.server.ts`](../../src/hooks.server.ts), [`src/lib/server/moved-pages.ts`](../../src/lib/server/moved-pages.ts), [`src/lib/server/http.ts`](../../src/lib/server/http.ts), [`src/lib/server/services/flags.ts`](../../src/lib/server/services/flags.ts), [`src/lib/server/compress.ts`](../../src/lib/server/compress.ts), [`src/lib/server/logger.ts`](../../src/lib/server/logger.ts), [`vite.config.ts`](../../vite.config.ts) +Source: [`src/hooks.server.ts`](../../src/hooks.server.ts), [`src/lib/server/moved-pages.ts`](../../src/lib/server/moved-pages.ts), [`src/lib/server/http.ts`](../../src/lib/server/http.ts), [`src/lib/server/services/flags.ts`](../../src/lib/server/services/flags.ts), [`src/lib/server/compress.ts`](../../src/lib/server/compress.ts), [`src/lib/server/logger.ts`](../../src/lib/server/logger.ts), [`vite.config.ts`](../../vite.config.ts), [`project.inlang/paraglide.config.ts`](../../project.inlang/paraglide.config.ts) ## Page loads and form actions @@ -72,7 +73,7 @@ What each response lets a browser or a shared cache keep. Pages that show the sa ```mermaid flowchart LR Responses["Cache-Control"] - Responses -- "/charts, /artists pages: 60 s" --> Brief["cacheBriefly: public with no session
cookie, else private, Vary: Cookie;
no-store for anyone who can edit it"] + Responses -- "/charts, /artists, party, venue
and event pages: 60 s" --> Brief["cacheBriefly: public with no session
cookie, else private, Vary: Cookie;
no-store for anyone who can edit it"] Responses -- "an active performer's
mix page: 5 minutes" --> Brief Responses -- "/media, recordings, most /og cards" --> Year["public, a year, immutable"] Responses -- "/og artist cards, /og/site.png" --> Hour["public, an hour and a day"] @@ -83,10 +84,10 @@ flowchart LR Responses -- "player.json, chapters.json" --> Sets["public, 1 and 5 minutes"] Responses -- "client metadata, did.json" --> Docs["public, 10 and 5 minutes"] Responses -- "getFlags without a token" --> Flags["public, a minute,
Vary: Authorization"] - Responses -- "/healthz, token exchange, audit export,
getFlags with a token" --> Never["no-store"] + Responses -- "/healthz, token exchange, audit export,
getFlags with a token, paused cards
and recordings" --> Never["no-store"] ``` -Source: [`src/lib/server/http.ts`](../../src/lib/server/http.ts), [`src/routes/charts/+page.server.ts`](../../src/routes/charts/+page.server.ts), [`src/routes/projects/[slug]/mixes/[n]/+page.server.ts`](../../src/routes/projects/[slug]/mixes/[n]/+page.server.ts), [`src/routes/media/[did]/[cid]/+server.ts`](../../src/routes/media/[did]/[cid]/+server.ts), [`src/lib/server/og/serve.ts`](../../src/lib/server/og/serve.ts), [`src/routes/projects/[slug]/press-kits/[rkey]/photos/[cid]/+server.ts`](../../src/routes/projects/[slug]/press-kits/[rkey]/photos/[cid]/+server.ts), [`src/routes/api/places/+server.ts`](../../src/routes/api/places/+server.ts), [`src/routes/sets/[did]/[rkey]/player.json/+server.ts`](../../src/routes/sets/[did]/[rkey]/player.json/+server.ts), [`src/lib/server/flags/get-flags.ts`](../../src/lib/server/flags/get-flags.ts) +Source: [`src/lib/server/http.ts`](../../src/lib/server/http.ts), [`src/routes/charts/+page.server.ts`](../../src/routes/charts/+page.server.ts), [`src/routes/venue/[key]/[[name]]/+page.server.ts`](../../src/routes/venue/[key]/[[name]]/+page.server.ts), [`src/routes/projects/[slug]/mixes/[n]/+page.server.ts`](../../src/routes/projects/[slug]/mixes/[n]/+page.server.ts), [`src/routes/media/[did]/[cid]/+server.ts`](../../src/routes/media/[did]/[cid]/+server.ts), [`src/lib/server/og/serve.ts`](../../src/lib/server/og/serve.ts), [`src/routes/projects/[slug]/press-kits/[rkey]/photos/[cid]/+server.ts`](../../src/routes/projects/[slug]/press-kits/[rkey]/photos/[cid]/+server.ts), [`src/routes/api/places/+server.ts`](../../src/routes/api/places/+server.ts), [`src/routes/sets/[did]/[rkey]/player.json/+server.ts`](../../src/routes/sets/[did]/[rkey]/player.json/+server.ts), [`src/lib/server/flags/get-flags.ts`](../../src/lib/server/flags/get-flags.ts) ## Error paths diff --git a/apps/web/docs/diagrams/shows-and-inbox.md b/apps/web/docs/diagrams/shows-and-inbox.md index 453fffa64..e05ebffdc 100644 --- a/apps/web/docs/diagrams/shows-and-inbox.md +++ b/apps/web/docs/diagrams/shows-and-inbox.md @@ -93,7 +93,7 @@ One item on its way out by one channel. A batch keeps its items and key through ```mermaid stateDiagram-v2 [*] --> pending - pending --> skipped: read already, or channel off or paused + pending --> skipped: read already, channel off or paused, or its flag off for them pending --> sending: claimed in a batch sending --> sent: service took it sending --> pending: retryable, under 8 attempts diff --git a/apps/web/docs/diagrams/spaces.md b/apps/web/docs/diagrams/spaces.md index d1367b53f..7817c033c 100644 --- a/apps/web/docs/diagrams/spaces.md +++ b/apps/web/docs/diagrams/spaces.md @@ -93,7 +93,7 @@ flowchart TD List -- "a repo left
the writer set" --> Keep["Read past it, keep
its synced records"] List -- "authority says
it's gone" --> Drop["Drop the local copy
and what came from it"] List --> Ops["Each repo that's behind, 4 at a time
across all spaces: listRepoOps since local rev"] - List -- "never synced" --> Star["getRepo: verified STAR archive"] + List -- "never synced" --> Star["getRepo: verified STAR archive,
256 MiB at most"] Ops -- "fails, not on a MAC or credential,
or runs past 100 pages" --> Star Ops -- "writer taken down,
suspended or deactivated" --> Skip["Skip, retry on backoff"] Star -- "same errors" --> Skip @@ -103,7 +103,7 @@ flowchart TD Project --> Due["Repos and projections whose retry
is due, then save spaceRev"] ``` -Source: [`src/lib/server/sync/engine.ts`](../../src/lib/server/sync/engine.ts) +Source: [`src/lib/server/sync/engine.ts`](../../src/lib/server/sync/engine.ts), [`src/lib/server/sync/repo-archive.ts`](../../src/lib/server/sync/repo-archive.ts) ## Repo sync lifecycle @@ -177,6 +177,7 @@ flowchart LR Sync -- "project.details, root only" --> A5["project_details"] Sync -- "booking.inquiry, message, status,
participants and the root" --> A6["booking_thread, booking_event,
inbox items"] Sync -- "epk.request, and epk.grant
from the authority only" --> A7["epk_request, epk_grant"] + Sync -- "epk.decision in a request space,
root only" --> A11["the request's answer,
its row if it has none"] Sync -- "epk.draft in a backstage" --> A8["epk_draft"] Sync -- "people.*, listing.status,
performer, venue,
venue.approval, party, event,
root only" --> A9["shared space tables,
performer, venue or party,
then its listing"] Sync -- "staff.flag, staff.group,
root only" --> A10["feature_flag, flag_group"] diff --git a/apps/web/docs/diagrams/staff-and-upkeep.md b/apps/web/docs/diagrams/staff-and-upkeep.md index 6ae4cc448..ddae6dabf 100644 --- a/apps/web/docs/diagrams/staff-and-upkeep.md +++ b/apps/web/docs/diagrams/staff-and-upkeep.md @@ -160,7 +160,7 @@ Source: [`src/lib/server/services/shared-spaces.ts`](../../src/lib/server/servic ## Public listings -How a listed act, party or venue reaches the directory. Acts, published parties and venues have something to list, from the root's performer, party or venue record in their space, and a venue is listed from the moment it's added; a DJ's own space and a draft party have nothing to show, so they're never listed. A listing points at a public page, so none is written until the `spacePages` flag is on for everyone. HappyView keeps only the root's listings. +How a listed act, party or venue reaches the directory. Acts, published parties and venues have something to list, from the root's performer, party or venue record in their space, and a venue is listed from the moment it's added; a DJ's own space and a draft party have nothing to show, so they're never listed. A listing points at a public page, so none is written until the `spacePages` flag is on for signed-out visitors. HappyView keeps only the root's listings. ```mermaid flowchart TD @@ -213,9 +213,12 @@ flowchart TD Head --> Hook["Server hook swaps it for the
marker in app.html"] Meta -- "a profile's picture" --> Avatar["/media/[did]/[cid]"] Meta -- "other pages" --> Card["/og/... PNG"] + Meta -- "pauseOgCards on" --> Site["/og/site.png"] Card --> Cached{"Kept in memory?"} Cached -- "yes" --> Png["Served"] Cached -- "no" --> Draw["Drawn from a Svelte card, then kept,
or 503 when too many are waiting"] + Cached -- "no, pauseOgCards on" --> Site + Site --> Png Draw --> Png ``` diff --git a/apps/web/docs/edit-mode.md b/apps/web/docs/edit-mode.md index 2ffc8cc0f..0a38271f8 100644 --- a/apps/web/docs/edit-mode.md +++ b/apps/web/docs/edit-mode.md @@ -174,7 +174,7 @@ Inside the page the same rule holds: each field takes the box its text took, the ## Caching -`cacheBriefly` lets a signed-in viewer's browser keep a page for 60 seconds (300 on mixes). Someone who can edit a page would then see the old page after saving and reloading, so a page passes the viewer's `can` (`cacheBriefly(event, 60, can)`) and answers with `no-store` whenever it isn't empty. +`cacheBriefly` lets a signed-in viewer's browser keep a page for 60 seconds (300 on mixes). Someone who can edit a page would then see the old page after saving and reloading, so a page passes the viewer's `can` (`cacheBriefly(event, 60, can)`) and answers with `no-store` whenever it isn't empty. Party, event and venue pages pass their `pageContext`'s `can`, so anyone holding a capability in the space gets `no-store`, and so do staff. A venue's people change it from the dashboard rather than in place, but come back to the page to see it. A mix page passes `page.edit` for its project's managers and staff. ## What the server adds diff --git a/apps/web/lua/computer/localnetwork/directory/getArtist.lua b/apps/web/lua/computer/localnetwork/directory/getArtist.lua index 8b55d7e6c..be341dfa9 100644 --- a/apps/web/lua/computer/localnetwork/directory/getArtist.lua +++ b/apps/web/lua/computer/localnetwork/directory/getArtist.lua @@ -33,6 +33,7 @@ local function managed(dids) end function handle(input) + skipInactive(input) local id = text(input.mbid) and mbid(input.mbid) local wanted = text(input.name) if not (id or wanted and not input.mbid) then return { tracks = json.to_array({}), djs = json.to_array({}) } end diff --git a/apps/web/lua/computer/localnetwork/directory/getCharts.lua b/apps/web/lua/computer/localnetwork/directory/getCharts.lua index ad0b2ab06..e3e37f974 100644 --- a/apps/web/lua/computer/localnetwork/directory/getCharts.lua +++ b/apps/web/lua/computer/localnetwork/directory/getCharts.lua @@ -10,6 +10,7 @@ local function day(value) end function handle(input) + skipInactive(input) local where, args = '', {} local since, before = day(input.since), day(input.before) local city, country = text(input.city), text(input.country) diff --git a/apps/web/lua/computer/localnetwork/directory/getSets.lua b/apps/web/lua/computer/localnetwork/directory/getSets.lua index 54188dfb0..884fc5cef 100644 --- a/apps/web/lua/computer/localnetwork/directory/getSets.lua +++ b/apps/web/lua/computer/localnetwork/directory/getSets.lua @@ -3,6 +3,7 @@ local json = require('internal.json') function handle(input) + skipInactive(input) local uris = input.uris local where, values = atUris(uris, 's.') local byUri = {} diff --git a/apps/web/lua/computer/localnetwork/directory/listShows.lua b/apps/web/lua/computer/localnetwork/directory/listShows.lua index 00ffc1c6d..68ea4d8b5 100644 --- a/apps/web/lua/computer/localnetwork/directory/listShows.lua +++ b/apps/web/lua/computer/localnetwork/directory/listShows.lua @@ -6,6 +6,7 @@ local json = require('internal.json') local SOONEST = ' ORDER BY (s.record::jsonb ->> \'startsAt\')::timestamptz, s.uri COLLATE "C"' function handle(input) + skipInactive(input) local where, args = { UPCOMING }, {} local function filter(clause, values) where[#where + 1] = ' AND ' .. clause diff --git a/apps/web/lua/computer/localnetwork/directory/searchArtists.lua b/apps/web/lua/computer/localnetwork/directory/searchArtists.lua index f304d7660..ea2cd3966 100644 --- a/apps/web/lua/computer/localnetwork/directory/searchArtists.lua +++ b/apps/web/lua/computer/localnetwork/directory/searchArtists.lua @@ -3,6 +3,7 @@ local json = require('internal.json') function handle(input) + skipInactive(input) local q = text(input.q) local limit = pageSize(input.limit, 25, 50) local where, args = '', { limit } diff --git a/apps/web/lua/computer/localnetwork/directory/searchPerformers.lua b/apps/web/lua/computer/localnetwork/directory/searchPerformers.lua index 3dc582e30..b73a02098 100644 --- a/apps/web/lua/computer/localnetwork/directory/searchPerformers.lua +++ b/apps/web/lua/computer/localnetwork/directory/searchPerformers.lua @@ -80,6 +80,7 @@ local function before(a, b, sort) end function handle(input) + skipInactive(input) local projectWhere, projectArgs = { " AND record::jsonb ->> 'status' = 'active'" }, {} local profileWhere, profileArgs = {}, {} local function filter(where, args, clause, values) @@ -121,6 +122,11 @@ function handle(input) djs ) end + -- An inactive DJ's profile is left out, and their solo project still gives way to it, so neither shows. + local shown = {} + for _, did in ipairs(djs) do + if not inactive[did] then shown[#shown + 1] = did end + end if #tiers > 0 then project(inFeeTiers('record', 'profile,fees', tiers, 'profile,fee')) profile(inFeeTiers('p.record', 'performer,fees', tiers)) @@ -164,14 +170,14 @@ function handle(input) end local fromProfiles = {} - if #djs > 0 then + if #shown > 0 then local rows = query( PROFILES - .. marks(#djs) + .. marks(#shown) .. ')' .. table.concat(profileWhere) .. (order == 'name' and PROFILES_BY_NAME or PROFILES_RECENT), - append(append({ ROOT_DID, LISTING, DJ_PROFILE, PROFILE }, djs), profileArgs) + append(append({ ROOT_DID, LISTING, DJ_PROFILE, PROFILE }, shown), profileArgs) ) for _, row in ipairs(rows) do local record = json.decode(row.record) diff --git a/apps/web/lua/happyview.yml b/apps/web/lua/happyview.yml index dc2cf9179..f41b7fa9a 100644 --- a/apps/web/lua/happyview.yml +++ b/apps/web/lua/happyview.yml @@ -137,6 +137,8 @@ globals: property: read-only MIN_DJS_TO_CHART: property: read-only + inactive: + property: read-only fetchThrough: &helper args: - type: '...' @@ -147,6 +149,7 @@ globals: query: *helper append: *helper managers: *helper + skipInactive: *helper number: *helper text: *helper integer: *helper diff --git a/apps/web/lua/lib/directory.lua b/apps/web/lua/lib/directory.lua index e5ecf0a6f..55dc26d56 100644 --- a/apps/web/lua/lib/directory.lua +++ b/apps/web/lua/lib/directory.lua @@ -180,8 +180,20 @@ local function projects(where, args, order) return rows end --- The accounts that manage one of the root's projects (an active one, with `active`), each once: the accounts whose --- records the directory reads beyond the root's own. +-- The accounts the app found inactive (deactivated, taken down, suspended or deleted), as a set. HappyView keeps a +-- deactivated account's records, so the queries that read accounts' records take an `inactive` param and leave theirs +-- out. Each request runs in a fresh VM, so this starts empty every time. +local inactive = {} + +-- Reads a query's `inactive` param into `inactive`. Call it first in handle(). +local function skipInactive(input) + for _, did in ipairs(input.inactive or {}) do + inactive[did] = true + end +end + +-- The accounts that manage one of the root's projects (an active one, with `active`), each once, without inactive +-- ones: the accounts whose records the directory reads beyond the root's own. local function managers(active) local rows = query( "SELECT DISTINCT m AS did FROM happyview_records, jsonb_array_elements_text(record::jsonb -> 'managers') AS m" @@ -191,8 +203,8 @@ local function managers(active) { ROOT_DID, PROJECT } ) local out = {} - for i, row in ipairs(rows) do - out[i] = row.did + for _, row in ipairs(rows) do + if not inactive[row.did] then out[#out + 1] = row.did end end return out end diff --git a/apps/web/messages/en-XA.json b/apps/web/messages/en-XA.json new file mode 100644 index 000000000..18d7b5fb4 --- /dev/null +++ b/apps/web/messages/en-XA.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://inlang.com/schema/inlang-message-format", + "skip_to_content": "[Şķīƥ ŧǿǿ ƈǿǿƞŧḗḗƞŧ]", + "footer_how_it_works": "[Ħǿǿẇ īŧ ẇǿǿřķş]", + "footer_who_its_for": "[Ẇħǿǿ īŧ'ş ƒǿǿř]", + "footer_privacy": "[Ƥřīṽȧȧƈẏ]", + "footer_tools": "[Ŧǿǿǿǿŀş]", + "footer_report_bug": "[Řḗḗƥǿǿřŧ ȧȧ ƀŭŭɠ]", + "footer_report_bug_github": "[Řḗḗƥǿǿřŧ ȧȧ ƀŭŭɠ ǿǿƞ ƓīŧĦŭŭƀ]", + "footer_shortcuts_on": "[Ķḗḗẏƀǿǿȧȧřḓ şħǿǿřŧƈŭŭŧş: ǿǿƞ]", + "footer_shortcuts_off": "[Ķḗḗẏƀǿǿȧȧřḓ şħǿǿřŧƈŭŭŧş: ǿǿƒƒ]", + "footer_tagline": "[Řḗḗƈǿǿřḓş ǿǿƞ ŧħḗḗ ȦȦŦ Ƥřǿǿŧǿǿƈǿǿŀ · ƥřīṽȧȧŧḗḗ ḓȧȧŧȧȧ īƞ şƥȧȧƈḗḗş ǿǿƞŀẏ ŧħḗḗīř ḿḗḗḿƀḗḗřş ƈȧȧƞ řḗḗȧȧḓ]" +} diff --git a/apps/web/messages/en.json b/apps/web/messages/en.json new file mode 100644 index 000000000..d61a1d270 --- /dev/null +++ b/apps/web/messages/en.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://inlang.com/schema/inlang-message-format", + "skip_to_content": "Skip to content", + "footer_how_it_works": "How it works", + "footer_who_its_for": "Who it's for", + "footer_privacy": "Privacy", + "footer_tools": "Tools", + "footer_report_bug": "Report a bug", + "footer_report_bug_github": "Report a bug on GitHub", + "footer_shortcuts_on": "Keyboard shortcuts: on", + "footer_shortcuts_off": "Keyboard shortcuts: off", + "footer_tagline": "Records on the AT Protocol · private data in spaces only their members can read" +} diff --git a/apps/web/package.json b/apps/web/package.json index 2e3a4e5bf..7fd345b2b 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -18,11 +18,12 @@ "build": "vite build", "preview": "vite preview", "start": "node build", - "prepare": "(svelte-kit sync && node scripts/flag-keys.ts && node scripts/notification-kinds.ts && pnpm lexicons:types) || echo ''", - "check": "svelte-kit sync && node scripts/flag-keys.ts && node scripts/notification-kinds.ts && pnpm lexicons:types && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && node scripts/flag-keys.ts && node scripts/notification-kinds.ts && pnpm lexicons:types && svelte-check --tsconfig ./tsconfig.json --watch", + "prepare": "(svelte-kit sync && paraglide-js compile --silent && node scripts/flag-keys.ts && node scripts/notification-kinds.ts && pnpm lexicons:types) || echo ''", + "check": "svelte-kit sync && paraglide-js compile --silent && node scripts/flag-keys.ts && node scripts/notification-kinds.ts && pnpm lexicons:types && svelte-check --tsconfig ./tsconfig.json", + "check:watch": "svelte-kit sync && paraglide-js compile --silent && node scripts/flag-keys.ts && node scripts/notification-kinds.ts && pnpm lexicons:types && svelte-check --tsconfig ./tsconfig.json --watch", "lint": "oxlint --type-aware && node scripts/story-coverage.ts", "lint:fix": "oxlint --type-aware --fix", + "i18n:check": "inlang check --project ./project.inlang", "format": "oxfmt", "format:check": "oxfmt --check", "test": "vitest run --project server --project client", @@ -52,6 +53,7 @@ }, "dependencies": { "@atproto-labs/did-resolver": "0.0.0-spaces-alpha-20261113224550", + "@atproto-labs/fetch": "0.4.2", "@atproto-labs/fetch-node": "0.0.0-spaces-alpha-20261113224550", "@atproto-labs/handle-resolver-node": "0.0.0-spaces-alpha-20261113224550", "@atproto/api": "0.0.0-spaces-alpha-20261113224550", @@ -65,6 +67,7 @@ "@atproto/oauth-client-node": "0.0.0-spaces-alpha-20261113224550", "@atproto/oauth-scopes": "0.0.0-spaces-alpha-20261113224550", "@atproto/space": "0.0.0-spaces-alpha-20261113224550", + "@atproto/star": "0.0.0-spaces-alpha-20261113224550", "@atproto/syntax": "0.0.0-spaces-alpha-20261113224550", "@atproto/xrpc-server": "0.0.0-spaces-alpha-20261113224550", "@aws-sdk/client-s3": "^3.1159.0", @@ -92,6 +95,9 @@ "@atproto/sync": "0.0.0-spaces-alpha-20261113224550", "@axe-core/playwright": "^4.13.0", "@electric-sql/pglite": "^0.5.16", + "@inlang/cli": "^3.6.0", + "@inlang/paraglide-js": "^3.2.2", + "@inlang/plugin-message-format": "^4.6.0", "@jazzer.js/core": "^4.0.0", "@lhci/cli": "^0.16.0", "@playwright/test": "^1.63.0", @@ -126,6 +132,7 @@ "oxlint": "1.86.0", "oxlint-tsgolint": "^7.0.2003", "playwright": "^1.63.0", + "pseudo-localization": "^3.1.3", "storybook": "10.6.2", "svelte": "^5.57.1", "svelte-check": "^4.6.0", diff --git a/apps/web/playwright.config.ts b/apps/web/playwright.config.ts index f14c48a3a..4c62d15e0 100644 --- a/apps/web/playwright.config.ts +++ b/apps/web/playwright.config.ts @@ -17,7 +17,10 @@ export default defineConfig({ use: { baseURL: `http://127.0.0.1:${APP_PORT}`, trace: 'retain-on-failure', - screenshot: 'only-on-failure' + screenshot: 'only-on-failure', + // One locale and time zone, whatever the machine's, as vite.config.ts pins for Vitest. The server below too. + locale: 'en-US', + timezoneId: 'UTC' }, // Pull requests run Chromium alone (`--project chromium`); the rest run weekly (web-scheduled.yml). projects: [ @@ -44,7 +47,11 @@ export default defineConfig({ DEV_ENV_FILE: '', GEOCODER: 'none', ACTOR_SEARCH: 'none', - LOG_LEVEL: 'warn' + // The bug report tests post to the stand-in userinput.app space, which is rolled out behind this flag. + FLAG_OVERRIDES: 'userinputReports=on', + LOG_LEVEL: 'warn', + LC_ALL: 'en_US.UTF-8', + TZ: 'UTC' } } }); diff --git a/apps/web/project.inlang/paraglide.config.ts b/apps/web/project.inlang/paraglide.config.ts new file mode 100644 index 000000000..ee60dbb9d --- /dev/null +++ b/apps/web/project.inlang/paraglide.config.ts @@ -0,0 +1,17 @@ +import { defineConfig } from '@inlang/paraglide-js'; + +// Read by both the Vite plugin (dev, build, tests) and `paraglide-js compile` (`pnpm check` and `pnpm install`), so +// both write the same files. +export default defineConfig({ + outdir: './src/lib/paraglide', + // English stays at unprefixed URLs (docs/adr/0019), so the locale comes from a cookie until a second language + // brings the url strategy for its prefix. + strategy: ['cookie', 'baseLocale'], + cookieName: 'ln_locale', + cookieSameSite: 'lax', + // Files on disk rather than Vite's virtual modules: svelte-check and the tsx scripts read them without Vite. + outputStructure: 'message-modules', + emitTsDeclarations: true, + emitReadme: false, + emitPrettierIgnore: false +}); diff --git a/apps/web/project.inlang/settings.json b/apps/web/project.inlang/settings.json new file mode 100644 index 000000000..a3497e3d4 --- /dev/null +++ b/apps/web/project.inlang/settings.json @@ -0,0 +1,9 @@ +{ + "$schema": "https://inlang.com/schema/project-settings", + "baseLocale": "en", + "locales": ["en", "en-XA"], + "modules": ["./node_modules/@inlang/plugin-message-format/dist/index.js"], + "plugin.inlang.messageFormat": { + "pathPattern": "./messages/{locale}.json" + } +} diff --git a/apps/web/scripts/pseudo-locale.test.ts b/apps/web/scripts/pseudo-locale.test.ts new file mode 100644 index 000000000..2d3721e63 --- /dev/null +++ b/apps/web/scripts/pseudo-locale.test.ts @@ -0,0 +1,60 @@ +import { readFileSync } from 'node:fs'; +import * as fc from 'fast-check'; +import { describe, expect, it } from 'vitest'; +import { type Messages, pseudoFile, pseudoLocalize, SOURCE, TARGET } from './pseudo-locale.ts'; + +describe('pseudoLocalize', () => { + it('accents every letter and brackets the message', () => { + expect(pseudoLocalize({ privacy: 'Privacy' })).toEqual({ privacy: '[Ƥřīṽȧȧƈẏ]' }); + }); + + it('keeps placeholders, markup and escaped braces as written', () => { + const { greeting } = pseudoLocalize({ greeting: 'Hi {name}, see {#link}the guide{/link} \\{not a variable\\}' }); + + expect(greeting).toMatch(/^\[Ħī \{name\}, şḗḗḗḗ \{#link\}ŧħḗḗ ɠŭŭīḓḗḗ\{\/link\} \\\{.+\\\}\]$/); + }); + + it("pseudo-localizes each variant's pattern and keeps its selectors", () => { + const shows: Messages = { + shows: [ + { + declarations: ['input count', 'local n = count: plural'], + selectors: ['n'], + match: { 'n=one': '{count} show', 'n=other': '{count} shows' } + } + ] + }; + + expect(pseudoLocalize(shows)).toEqual({ + shows: [ + { + declarations: ['input count', 'local n = count: plural'], + selectors: ['n'], + match: { 'n=one': '[{count} şħǿǿẇ]', 'n=other': '[{count} şħǿǿẇş]' } + } + ] + }); + }); + + it('leaves no Latin letter outside a placeholder, so English that skipped the catalog stands out', () => { + fc.assert( + fc.property(fc.string(), fc.stringMatching(/^[a-z]\w*$/), fc.string(), (before, name, after) => { + const pattern = `${before.replace(/[{}\\]/g, '')}{${name}}${after.replace(/[{}\\]/g, '')}`; + + // SAFETY: a message given as a pattern comes back as a pattern. + const message = pseudoLocalize({ message: pattern }).message as string; + + expect(message.replace(`{${name}}`, '')).not.toMatch(/[A-Za-z]/); + }) + ); + }); +}); + +describe('messages/en-XA.json', () => { + it('is messages/en.json pseudo-localized', () => { + expect( + readFileSync(TARGET, 'utf8'), + 'messages/en-XA.json is out of date. Regenerate it with `node scripts/pseudo-locale.ts`' + ).toBe(pseudoFile(readFileSync(SOURCE, 'utf8'))); + }); +}); diff --git a/apps/web/scripts/pseudo-locale.ts b/apps/web/scripts/pseudo-locale.ts new file mode 100644 index 000000000..636d65bbf --- /dev/null +++ b/apps/web/scripts/pseudo-locale.ts @@ -0,0 +1,55 @@ +/** + * Writes messages/en-XA.json, the pseudo-locale, from messages/en.json: every letter accented, vowels doubled so lines + * run about a third longer, and each message in brackets. Viewed in en-XA, text that skipped the catalog stays plain + * English, a layout that can't stretch clips, and a message cut short or glued to another loses a bracket. + * + * node scripts/pseudo-locale.ts + * + * scripts/pseudo-locale.test.ts fails while the file is out of date. + */ +import { readFileSync, writeFileSync } from 'node:fs'; +import { pseudoLocalizeString } from 'pseudo-localization'; + +/** A message in inlang's message format: a pattern, or variants that each match a pattern. */ +type Message = string | { declarations?: string[]; selectors?: string[]; match: Record }[]; + +export type Messages = Record; + +// A pattern's `{name}` placeholders, `{#b}` markup and `\{` escapes, which the message format reads, so they stay as +// written. +const SYNTAX = /(\\.|\{[^{}]*\})/; + +const pseudoPattern = (pattern: string) => + `[${pattern + .split(SYNTAX) + .map((part, index) => (index % 2 === 1 ? part : pseudoLocalizeString(part))) + .join('')}]`; + +/** `messages` in en-XA. `$schema` and the variants' selectors stay as they are. */ +export const pseudoLocalize = (messages: Messages): Messages => + Object.fromEntries( + Object.entries(messages).map(([key, message]) => [ + key, + key === '$schema' + ? message + : Array.isArray(message) + ? message.map((variant) => ({ + ...variant, + match: Object.fromEntries( + Object.entries(variant.match).map(([when, pattern]) => [when, pseudoPattern(pattern)]) + ) + })) + : pseudoPattern(message) + ]) + ); + +export const SOURCE = new URL('../messages/en.json', import.meta.url); + +export const TARGET = new URL('../messages/en-XA.json', import.meta.url); + +/** en-XA.json's contents for en.json's. */ +export const pseudoFile = (source: string) => + // SAFETY: en.json is in inlang's message format, which `pnpm i18n:check` loads and checks. + `${JSON.stringify(pseudoLocalize(JSON.parse(source) as Messages), null, '\t')}\n`; + +if (import.meta.main) writeFileSync(TARGET, pseudoFile(readFileSync(SOURCE, 'utf8'))); diff --git a/apps/web/src/app.d.ts b/apps/web/src/app.d.ts index 25e3e35e3..83d2786d3 100644 --- a/apps/web/src/app.d.ts +++ b/apps/web/src/app.d.ts @@ -10,12 +10,14 @@ declare global { status: number; message: string; requestId?: string; + /** The error page's heading, when the status alone doesn't say what happened. */ + title?: string; } interface Locals { app: ServerApp; viewer: Viewer | null; - /** Every feature flag for this viewer, or for a signed-out visitor. Not set on XRPC requests. */ + /** Every feature flag for this viewer, or as a signed-out visitor gets them, which XRPC requests do too. */ flags: Flags; /** The flags a staff member is previewing in this browser, already in `flags`. */ flagPreview?: FlagPreview; diff --git a/apps/web/src/app.html b/apps/web/src/app.html index d40052f03..ed217e7f2 100644 --- a/apps/web/src/app.html +++ b/apps/web/src/app.html @@ -1,5 +1,5 @@ - + diff --git a/apps/web/src/hooks.client.svelte.test.ts b/apps/web/src/hooks.client.svelte.test.ts new file mode 100644 index 000000000..d0088687c --- /dev/null +++ b/apps/web/src/hooks.client.svelte.test.ts @@ -0,0 +1,29 @@ +import { afterEach, beforeEach, expect, it } from 'vitest'; +import { m } from '#lib/paraglide/messages.js'; +import { cookieName, setLocale } from '#lib/paraglide/runtime.js'; +import { init } from './hooks.client.ts'; + +const localeCookie = () => document.cookie.split('; ').find((cookie) => cookie.startsWith(`${cookieName}=`)); + +const clearLocaleCookie = () => { + document.cookie = `${cookieName}=; Max-Age=0; Path=/`; +}; + +beforeEach(async () => { + clearLocaleCookie(); + await init(); +}); + +afterEach(clearLocaleCookie); + +it("shows a first visit's page in English without writing the locale cookie", () => { + expect(m.footer_privacy()).toBe('Privacy'); + expect(localeCookie()).toBeUndefined(); +}); + +it('writes the locale cookie when someone picks a language', async () => { + await setLocale('en-XA', { reload: false }); + + expect(localeCookie()).toBe(`${cookieName}=en-XA`); + expect(m.footer_privacy()).toBe('[Ƥřīṽȧȧƈẏ]'); +}); diff --git a/apps/web/src/hooks.client.ts b/apps/web/src/hooks.client.ts new file mode 100644 index 000000000..08ad09ffe --- /dev/null +++ b/apps/web/src/hooks.client.ts @@ -0,0 +1,7 @@ +import type { ClientInit } from '@sveltejs/kit/hooks'; +import { baseLocale, extractLocaleFromCookie, overwriteGetLocale } from '#lib/paraglide/runtime.js'; + +// Paraglide's getLocale writes the locale cookie the first time it runs, so every visitor got one on their first page +// and their pages varied on it from then on. Only picking a language (setLocale) writes it, and a visitor who hasn't +// gets the English page every signed-out visitor shares (docs/adr/0018). +export const init: ClientInit = () => overwriteGetLocale(() => extractLocaleFromCookie() ?? baseLocale); diff --git a/apps/web/src/hooks.server.test.ts b/apps/web/src/hooks.server.test.ts index b231b8abe..e5ce4732a 100644 --- a/apps/web/src/hooks.server.test.ts +++ b/apps/web/src/hooks.server.test.ts @@ -10,6 +10,7 @@ import { SESSION_COOKIE, WebSessions } from '#lib/server/auth/session.ts'; import { CRAWLER_HEAD } from '#lib/server/crawler-head.ts'; import { PREVIEW_COOKIE, PREVIEW_MS, sealPreview } from '#lib/server/flags/preview.ts'; import { HappyViewError } from '#lib/server/happyview/client.ts'; +import { m } from '#lib/paraglide/messages.js'; import { requireFlag } from '#lib/server/http.ts'; import { RateLimiter } from '#lib/server/rate-limit.ts'; import { createTestServices } from '#lib/server/testing/core.ts'; @@ -194,7 +195,7 @@ it("applies a staff member's flag preview to their own requests only", async () expect(signedOut.cookies.deleted).toContain(PREVIEW_COOKIE); }); -it('lets a page behind a flag 404 until the flag is on for the viewer, a staff preview included', async () => { +it('lets a page behind a flag 404 until the flag is on for the viewer, signed-out visitors last', async () => { const s = await services({ admins: [ADMIN] }); const { handle } = hooksWith(async () => s.app); const adminToken = await s.sessions.create(ADMIN, null); @@ -225,15 +226,14 @@ it('lets a page behind a flag 404 until the flag is on for the viewer, a staff p expect(await page({ [SESSION_COOKIE]: djToken })).toBe(404); expect(await page({})).toBe(404); - await s.flags.updateFlag(await s.viewer(ADMIN), 'spacePages', { - enabled: true, - everyone: true, - percentage: 0, - groups: [], - dids: [] - }); + const everyAccount = { enabled: true, everyone: true, percentage: 0, groups: [], dids: [] }; + await s.flags.updateFlag(await s.viewer(ADMIN), 'spacePages', everyAccount); expect(await page({ [SESSION_COOKIE]: djToken })).toBe(200); + expect(await page({})).toBe(404); + + await s.flags.updateFlag(await s.viewer(ADMIN), 'spacePages', { ...everyAccount, signedOut: true }); + expect(await page({})).toBe(200); }); @@ -462,6 +462,96 @@ it("writes the page's crawler tags into the head, once, and gzips the page", asy ); }); +it("renders the page in the locale its cookie names, with the page's lang and dir to match", async () => { + const s = await services(); + const { handle } = hooksWith(async () => s.app); + + const resolve = async (_event: RequestEvent, options?: ResolveOptions) => { + const head = `${CRAWLER_HEAD}`; + const html = (await options!.transformPageChunk!({ html: head, done: false })) ?? ''; + + return new Response(`${html}${m.footer_privacy()}`); + }; + + // SvelteKit's cookies and Paraglide both read the request's Cookie header. + const page = async (locale?: string) => { + const { event } = routeEvent({ + url: '/', + headers: locale ? { cookie: `ln_locale=${locale}` } : {}, + cookies: locale ? { ln_locale: locale } : {} + }); + + // SAFETY: as above. + const response = await handle({ event: event as never, resolve }); + + return { html: await response.text(), vary: response.headers.get('vary') }; + }; + + expect(await page('en-XA')).toEqual({ + html: '[Ƥřīṽȧȧƈẏ]', + vary: 'Cookie' + }); + expect((await page()).html).toBe('Privacy'); + expect((await page('xx')).html).toBe('Privacy'); +}); + +it('leaves a first visit shareable by caches, varying on Cookie only for a request that picked a language', async () => { + // Arrange + const s = await services(); + const { handle } = hooksWith(async () => s.app); + const shared = { 'cache-control': 'public, max-age=60' }; + + // Act + const first = await handledWithLocals(handle, { url: '/artists' }, 200, shared); + + const picked = await handledWithLocals( + handle, + { url: '/artists', headers: { cookie: 'ln_locale=en-XA' }, cookies: { ln_locale: 'en-XA' } }, + 200, + shared + ); + + // Assert + const headers = ({ response }: { response: Response }) => ({ + vary: response.headers.get('vary'), + cacheControl: response.headers.get('cache-control'), + setCookie: response.headers.getSetCookie() + }); + + expect({ first: headers(first), firstCookies: [...first.cookies.options.keys()], picked: headers(picked) }).toEqual({ + first: { vary: null, cacheControl: 'public, max-age=60', setCookie: [] }, + firstCookies: [], + picked: { vary: 'Cookie', cacheControl: 'public, max-age=60', setCookie: [] } + }); +}); + +it("keeps the locale cookie out of a public immutable answer's Vary, so caches share an OG card or avatar", async () => { + // Arrange + const s = await services(); + const { handle } = hooksWith(async () => s.app); + const image = { 'content-type': 'image/png', 'cache-control': 'public, max-age=31536000, immutable' }; + const request = { url: '/og/project/3proj.png', cookies: { ln_locale: 'en' } }; + + // Act + const { response } = await handledWithLocals(handle, request, 200, image); + + const page = await handledWithLocals(handle, { ...request, url: '/artists' }, 200, { + 'cache-control': 'public, max-age=60' + }); + + const gzipped = await handledWithLocals(handle, { ...request, headers: { 'accept-encoding': 'gzip' } }, 200, { + ...image, + 'content-type': 'application/json' + }); + + // Assert + expect({ + image: response.headers.get('vary'), + page: page.response.headers.get('vary'), + gzipped: gzipped.response.headers.get('vary') + }).toEqual({ image: null, page: 'Cookie', gzipped: 'accept-encoding' }); +}); + it("preloads the scripts, styles and the two typefaces' Latin files, and nothing else", async () => { const s = await services(); const { handle } = hooksWith(async () => s.app); @@ -575,12 +665,17 @@ async function services( return { app: parts, sessions, logs, flags: t.flags, viewer: t.viewer }; } -/** Runs the handle hook on a request built from `init`, with a page that answers `status`. */ -async function handledWithLocals(handle: Hooks['handle'], request: RouteEventInit, status = 200) { +/** Runs the handle hook on a request built from `init`, with a page that answers `status` with `headers`. */ +async function handledWithLocals( + handle: Hooks['handle'], + request: RouteEventInit, + status = 200, + headers: Record = {} +) { const { event, cookies } = routeEvent(request); // The hook sets these itself, so they start out unset as SvelteKit leaves them. const locals: Partial = {}; - const resolve = async () => new Response('page', { status, headers: { 'content-type': 'text/plain' } }); + const resolve = async () => new Response('page', { status, headers: { 'content-type': 'text/plain', ...headers } }); // SAFETY: the hook reads the request, URL, route, cookies and client address, all set by routeEvent. const response = await handle({ event: { ...event, locals } as never, resolve }); diff --git a/apps/web/src/hooks.server.ts b/apps/web/src/hooks.server.ts index 41ce5f3ea..4dc23aff9 100644 --- a/apps/web/src/hooks.server.ts +++ b/apps/web/src/hooks.server.ts @@ -11,6 +11,8 @@ import { clientIp, guardArea, isUnlisted } from '#lib/server/http.ts'; import { createLogger, type Logger } from '#lib/server/logger.ts'; import { movedTo } from '#lib/server/moved-pages.ts'; import { toolSite } from '#lib/server/tools/site.ts'; +import { cookieName as LOCALE_COOKIE, getTextDirection } from '#lib/paraglide/runtime.js'; +import { paraglideMiddleware } from '#lib/paraglide/server.js'; const fallbackLogger = createLogger({ level: process.env.LOG_LEVEL ?? 'info', @@ -129,24 +131,34 @@ export function serverHooks({ let headWritten = false; + // Paraglide's middleware runs the page under the locale its cookie names, so messages and getLocale() read + // it. It's handed the request without its body, which it would otherwise clone, keeping a copy of every + // upload: the locale only comes from the headers. + const localeRequest = new Request(event.request.url, { headers: event.request.headers }); + // The two typefaces set every line and differ in width from the system fallbacks, so arriving after // the first paint they moved the whole page (Lighthouse's CLS). Their Latin files are preloaded with // the CSS; the other subsets load only for pages that need them. const response = gzipped( event.request, - await resolve(event, { - preload: ({ type, path }) => - type === 'js' || - type === 'css' || - (type === 'font' && /(instrument-sans|jetbrains-mono)-latin-wght-normal\.[\w-]+\.woff2$/.test(path)), - // The marker is in the first chunk, app.html's head. Later chunks are left alone, whatever they hold. - transformPageChunk: ({ html }) => { - if (headWritten || !html.includes(CRAWLER_HEAD)) return html; - headWritten = true; - - return withCrawlerHead(html, event.locals.crawlerHead); - } - }) + await paraglideMiddleware(localeRequest, ({ locale }) => + resolve(event, { + preload: ({ type, path }) => + type === 'js' || + type === 'css' || + (type === 'font' && /(instrument-sans|jetbrains-mono)-latin-wght-normal\.[\w-]+\.woff2$/.test(path)), + // The marker is in the first chunk, app.html's head, after the html tag's lang and dir. Later chunks are + // left alone, whatever they hold. + transformPageChunk: ({ html }) => { + if (headWritten || !html.includes(CRAWLER_HEAD)) return html; + headWritten = true; + + return withCrawlerHead(html, event.locals.crawlerHead) + .replace('%lang%', locale) + .replace('%dir%', getTextDirection(locale)); + } + }) + ) ); response.headers.set('x-request-id', requestId); @@ -155,6 +167,20 @@ export function serverHooks({ response.headers.set('permissions-policy', 'camera=(), microphone=(), geolocation=(self), payment=()'); if (isUnlisted(event.route.id)) response.headers.set('x-robots-tag', 'noindex'); + const cacheControl = response.headers.get('cache-control'); + + // Paraglide varies every answer on Cookie, for the locale cookie. Without one the page is the English everyone + // signed out gets, so caches share it (docs/adr/0018). A public immutable answer (an OG card, an avatar, a + // recording) is the same in every language, and varying it would have caches keep a copy per cookie, or none. + const isImmutable = cacheControl?.includes('public') && cacheControl.includes('immutable'); + + if (isImmutable || !event.cookies.get(LOCALE_COOKIE)) { + const fields = (response.headers.get('vary') ?? '').split(',').map((field) => field.trim()); + const kept = fields.filter((field) => field && field.toLowerCase() !== 'cookie'); + + if (kept.length) response.headers.set('vary', kept.join(', ')); + else response.headers.delete('vary'); + } if (app.config.publicUrl.startsWith('https:')) { response.headers.set('strict-transport-security', 'max-age=31536000; includeSubDomains'); diff --git a/apps/web/src/lib/components/DmSettings.stories.svelte b/apps/web/src/lib/components/DmSettings.stories.svelte index 4f313756b..9874022b9 100644 --- a/apps/web/src/lib/components/DmSettings.stories.svelte +++ b/apps/web/src/lib/components/DmSettings.stories.svelte @@ -45,6 +45,12 @@ + + + + + + | null; root: string; @@ -36,7 +40,7 @@ const id = $props.id(); const status = $derived( - !available ? 'Not set up on this site.' : !channel ? `Get your inbox as DMs from @${root} too.` : channel.status === 'paused' ? 'Paused.' : `On, from @${root}.` + !available ? (channel ? 'Paused on this site for now.' : notYet ? 'Not on for your account yet.' : 'Not set up on this site.') : !channel ? `Get your inbox as DMs from @${root} too.` : channel.status === 'paused' ? 'Paused.' : `On, from @${root}.` ); @@ -76,6 +80,7 @@ {/if} {#if !available} + {#if channel}
{/if} {:else if !channel}
{:else if channel.status === 'paused'} diff --git a/apps/web/src/lib/components/EmailSettings.stories.svelte b/apps/web/src/lib/components/EmailSettings.stories.svelte index 4334cda5d..93a590172 100644 --- a/apps/web/src/lib/components/EmailSettings.stories.svelte +++ b/apps/web/src/lib/components/EmailSettings.stories.svelte @@ -38,6 +38,12 @@ + + + + + + diff --git a/apps/web/src/lib/components/EmailSettings.svelte b/apps/web/src/lib/components/EmailSettings.svelte index 7392e73e4..d7e7bbd3b 100644 --- a/apps/web/src/lib/components/EmailSettings.svelte +++ b/apps/web/src/lib/components/EmailSettings.svelte @@ -15,17 +15,20 @@ import FormMessage from './FormMessage.svelte'; /** - * Someone's email setting for their inbox. `available` is false when the site can't send email. `returned` says how - * asking their account's host for the address just went, when it didn't go through. Turning email on (or checking - * again) is a full page POST: it goes on to their account's host, which client-side navigation can't follow. + * Someone's email setting for their inbox. `available` is false when the site can't send email, or hasn't rolled it + * out to them (`notYet` says it's the second); email they turned on before that can still be turned off. `returned` + * says how asking their account's host for the address just went, when it didn't go through. Turning email on (or + * checking again) is a full page POST: it goes on to their account's host, which client-side navigation can't follow. */ let { available, + notYet = false, channel, returned, form }: { available: boolean; + notYet?: boolean; channel: ChannelView | null; returned?: 'declined' | 'limited' | null; form?: { error?: string; success?: string } | null; @@ -39,7 +42,11 @@ const status = $derived( !available - ? 'Not set up on this site.' + ? channel + ? 'Paused on this site for now.' + : notYet + ? 'Not on for your account yet.' + : 'Not set up on this site.' : !channel ? 'Get your inbox by email too.' : channel.pausedReason === 'email_unverified' @@ -61,7 +68,8 @@ {#if returned === 'limited' && !form}

We can't send a confirmation link to that address right now. Try again tomorrow.

{/if} {#if !available} - + + {#if channel}
{/if} {:else if !channel} {#if returned === 'declined'}

You didn't allow sharing your email address, so email is still off.

{/if}
diff --git a/apps/web/src/lib/components/FlagTable.stories.svelte b/apps/web/src/lib/components/FlagTable.stories.svelte index 175f5694c..7375bdb09 100644 --- a/apps/web/src/lib/components/FlagTable.stories.svelte +++ b/apps/web/src/lib/components/FlagTable.stories.svelte @@ -10,7 +10,10 @@ const flag = (key: string, description: string, gates: Partial): FlagView => ({ key: key as FlagView['key'], description, + type: 'release', + showsOn: [], enabled: true, + signedOut: false, everyone: false, percentage: 0, groups: [], @@ -22,8 +25,9 @@ const flags = [ flag('newPlanner', 'The planner with booking notes.', { percentage: 25, groups: [{ rkey: '3lzy2ji4nms2z', name: 'Beta DJs' }], updatedAt: '2026-11-02T10:00:00Z' }), - flag('parityCanary', 'Gates nothing.', { accounts: [{ did: 'did:plc:milo', handle: 'milo.test' }], updatedAt: '2026-11-01T09:00:00Z' }), - flag('quietInbox', 'Fewer inbox emails.', { everyone: true, updatedAt: '2026-09-30T09:00:00Z', readyToRemove: true }), + flag('parityCanary', 'Gates nothing.', { type: 'ops', accounts: [{ did: 'did:plc:milo', handle: 'milo.test' }], updatedAt: '2026-11-01T09:00:00Z' }), + flag('quietInbox', 'Fewer inbox emails.', { everyone: true, signedOut: true, updatedAt: '2026-09-30T09:00:00Z', readyToRemove: true }), + flag('socialHome', 'The home page built around events near you.', { everyone: true, removeBy: '2027-02-12', updatedAt: '2026-11-10T12:00:00Z' }), flag('slowCharts', 'Charts from the new index.', { enabled: false, percentage: 40, accounts: [{ did: 'did:plc:milo', handle: 'milo.test' }], updatedAt: '2026-11-08T21:00:00Z' }), flag('tapeDecks', 'Not turned on yet.', {}) ]; diff --git a/apps/web/src/lib/components/FlagTable.svelte b/apps/web/src/lib/components/FlagTable.svelte index 464509f6c..c4f204549 100644 --- a/apps/web/src/lib/components/FlagTable.svelte +++ b/apps/web/src/lib/components/FlagTable.svelte @@ -1,5 +1,5 @@ -
+
{#if eyebrow}{eyebrow}{/if} - {#if typeof title === 'string'}{title}{:else}{@render title()}{/if} + {#if typeof title === 'string'}{title}{:else}{@render title()}{/if}
{#if lede}

{lede}

diff --git a/apps/web/src/routes/+error.svelte b/apps/web/src/routes/+error.svelte index 824a7cbad..e6a0e197e 100644 --- a/apps/web/src/routes/+error.svelte +++ b/apps/web/src/routes/+error.svelte @@ -3,16 +3,19 @@ import Button from '#lib/ui/Button.svelte'; import SectionHeader from '#lib/ui/SectionHeader.svelte'; - const title = $derived(page.status === 404 ? "We couldn't find that page" : page.status === 403 ? 'Not allowed' : page.status === 503 ? 'Directory offline' : 'Something went wrong'); + const title = $derived(page.error?.title ?? (page.status === 404 ? "We couldn't find that page" : page.status === 403 ? 'Not allowed' : page.status === 503 ? 'Directory offline' : 'Something went wrong')); + + // An error with its own heading, like an account that isn't active, isn't a fault, so no status code heads it. + const eyebrow = $derived(page.error?.title ? undefined : `Error ${page.status}`); // SvelteKit's own 404 message is just "Not Found", which the title already says. const lede = $derived(page.status === 404 && page.error?.message === 'Not Found' ? 'The link may be out of date, or the page has moved.' : page.error?.message); -{page.status} · Local Network +{page.error?.title ?? page.status} · Local Network -
- +
+ {#snippet actions()}{/snippet} diff --git a/apps/web/src/routes/+layout.server.ts b/apps/web/src/routes/+layout.server.ts index cc991eaa7..0595d9911 100644 --- a/apps/web/src/routes/+layout.server.ts +++ b/apps/web/src/routes/+layout.server.ts @@ -1,9 +1,19 @@ import { requireViewer } from '#lib/server/http.ts'; +import { postsToUserinput } from '#lib/server/services/bug-reports.ts'; import type { FlagPreview, Flags, Viewer } from '#lib/types.ts'; import type { LayoutServerLoad } from './$types'; -/** `flags` is optional so a page rendered on its own, in a test or a story, reads every flag as off. */ -type RootData = { viewer: Viewer | null; pendingRequests: number; flags?: Flags; flagPreview?: FlagPreview }; +/** + * `flags` is optional so a page rendered on its own, in a test or a story, reads every flag as off. `reportsToUserinput` + * says whether /report would post this viewer's report to userinput.app rather than send them to GitHub. + */ +type RootData = { + viewer: Viewer | null; + pendingRequests: number; + flags?: Flags; + flagPreview?: FlagPreview; + reportsToUserinput?: boolean; +}; export const load: LayoutServerLoad = async ({ locals, url }): Promise => { // Send a session that has to sign in again to the login page before anything tries to write with it. @@ -13,5 +23,11 @@ export const load: LayoutServerLoad = async ({ locals, url }): Promise if (viewer?.isStaff) pendingRequests = (await locals.app.requests.counts()).pending; - return { viewer, pendingRequests, flags: locals.flags, flagPreview: locals.flagPreview }; + return { + viewer, + pendingRequests, + flags: locals.flags, + flagPreview: locals.flagPreview, + reportsToUserinput: postsToUserinput(locals) + }; }; diff --git a/apps/web/src/routes/+layout.svelte b/apps/web/src/routes/+layout.svelte index 9a95d42ce..37898a3f9 100644 --- a/apps/web/src/routes/+layout.svelte +++ b/apps/web/src/routes/+layout.svelte @@ -10,6 +10,7 @@ import { type NavLink, siteNav } from '#lib/nav.ts'; import SiteHeader from '#lib/ui/SiteHeader.svelte'; import { hotkeys, hotkeyTarget, loadHotkeyPreference, setHotkeysEnabled } from '#lib/hotkeys.svelte.ts'; + import { m } from '#lib/paraglide/messages.js'; import type { LayoutProps } from './$types'; let { children, data }: LayoutProps = $props(); @@ -72,7 +73,7 @@ -Skip to content +{m.skip_to_content()} diff --git a/apps/web/src/routes/@[handle]/page.server.test.ts b/apps/web/src/routes/@[handle]/page.server.test.ts index 0be53af2e..b05780537 100644 --- a/apps/web/src/routes/@[handle]/page.server.test.ts +++ b/apps/web/src/routes/@[handle]/page.server.test.ts @@ -192,6 +192,39 @@ it('is a 404 for an address that names no account, and a 429 once a visitor has ).rejects.toMatchObject({ status: 429 }); }); +it("says an account isn't active, the same way whatever the reason, and that a deleted one was deleted", async () => { + const loadMara = () => callRoute(load, { app: app(), params: { handle: 'mara.test' }, url: '/@mara.test' }); + const inactive = { status: 404, body: { title: "@mara.test isn't active" } }; + + t.accountStatus.set(MARA, 'deactivated'); + await expect(loadMara()).rejects.toMatchObject(inactive); + await t.accountStatuses.refresh(); + + t.accountStatus.set(MARA, 'takendown'); + await t.accountStatuses.refresh(); + await expect(loadMara()).rejects.toMatchObject(inactive); + + t.accountStatus.set(MARA, 'deleted'); + await t.accountStatuses.refresh(); + await expect(loadMara()).rejects.toMatchObject({ status: 410, body: { title: '@mara.test was deleted' } }); +}); + +it("shows the profile again once its account is active again, and refuses to follow it while it isn't", async () => { + t.accountStatus.set(MARA, 'deactivated'); + await expect(post('follow', await t.viewer(FAN))).rejects.toMatchObject({ status: 404 }); + + t.accountStatus.set(MARA, 'active'); + await t.accountStatuses.refresh(); + + const data = await routeEvent({ + app: app(), + params: { handle: 'mara.test' }, + url: '/@mara.test' + }).loadData(load); + + expect(data).toMatchObject({ name: 'Mara Lind' }); +}); + /** The action `name` on `handle`'s page, as `viewer` posts it. */ const post = (name: keyof typeof actions, viewer: Viewer | null, handle = 'mara.test') => callRoute(actions[name], { app: app(), viewer, params: { handle }, url: `/@${handle}?/${name}`, form: {} }); diff --git a/apps/web/src/routes/admin/audit/page.server.test.ts b/apps/web/src/routes/admin/audit/page.server.test.ts index 6aafe8583..95d0ad76b 100644 --- a/apps/web/src/routes/admin/audit/page.server.test.ts +++ b/apps/web/src/routes/admin/audit/page.server.test.ts @@ -63,6 +63,23 @@ it("filters by an actor's handle, action, outcome, and text, and echoes the filt expect(data.filters).toEqual({ actor: 'admin.test', action: 'role', outcome: 'success', q: 'mod' }); }); +it("finds a flag's changes, and only that flag's, where the flag's page links to", async () => { + const admin = await t.viewer(ADMIN); + const gates = { enabled: true, everyone: true, percentage: 0, groups: [], dids: [] }; + await t.flags.updateFlag(admin, 'dashboardCalendar', gates); + await t.flags.recordPreview(admin, 'dashboardCalendar', true); + await t.flags.updateFlag(admin, 'parityCanary', gates); + await t.flags.createGroup(admin, { name: 'dashboardCalendar testers', members: [MOD] }); + await t.audit.idle(); + + const data = await audit('/admin/audit?action=flag&q=dashboardCalendar'); + + expect(data.entries.map((entry) => [entry.action, entry.subject])).toEqual([ + ['flag.preview', 'dashboardCalendar'], + ['flag.update', 'dashboardCalendar'] + ]); +}); + it("filters by the actor as typed when it isn't a handle it can resolve", async () => { expect((await audit(`/admin/audit?actor=${ADMIN}`)).entries).toHaveLength(1); expect((await audit('/admin/audit?actor=nobody.example')).entries).toEqual([]); diff --git a/apps/web/src/routes/admin/flags/+page.svelte b/apps/web/src/routes/admin/flags/+page.svelte index fdba7076f..d6a04616e 100644 --- a/apps/web/src/routes/admin/flags/+page.svelte +++ b/apps/web/src/routes/admin/flags/+page.svelte @@ -1,4 +1,5 @@ {flag.key} · Flags · Local Network
Flags - +
+ + {#if flag.readyToRemove} +

Ready to removeDelete flags/catalog/{flag.key}.json and the code it gates.

+ {/if} +
+

Shows on: {showsOn}

+ + {#if flag.removeBy}

Remove by: {formatShowDate(flag.removeBy)}

{/if} + Changes in the audit log +
+
({ update }) => update({ reset: false })}>
diff --git a/apps/web/src/routes/privacy/page.server.test.ts b/apps/web/src/routes/privacy/page.server.test.ts index 1dfdd2b00..b59377830 100644 --- a/apps/web/src/routes/privacy/page.server.test.ts +++ b/apps/web/src/routes/privacy/page.server.test.ts @@ -3,11 +3,15 @@ import { loadRoute } from '#lib/testing/route-event.ts'; import type { PageServerData } from './$types'; import { load } from './+page.server.ts'; -it('says how long press kit views are kept, under the canonical /privacy address', async () => { - const app = { epkViews: { retentionDays: 90 }, config: { publicUrl: 'https://localnetwork.computer' } }; +it('says how long press kit views and sign-ins are kept, under the canonical /privacy address', async () => { + const app = { + epkViews: { retentionDays: 90 }, + config: { publicUrl: 'https://localnetwork.computer', sessionDays: 30 } + }; const data = await loadRoute(load, { app, url: '/privacy' }); expect(data.retentionDays).toBe(90); + expect(data.sessionDays).toBe(30); expect(data.meta).toMatchObject({ title: 'Privacy', url: 'https://localnetwork.computer/privacy' }); }); diff --git a/apps/web/src/routes/projects/[slug]/mixes/[n]/+page.server.ts b/apps/web/src/routes/projects/[slug]/mixes/[n]/+page.server.ts index a652b7fc1..7b97d73b8 100644 --- a/apps/web/src/routes/projects/[slug]/mixes/[n]/+page.server.ts +++ b/apps/web/src/routes/projects/[slug]/mixes/[n]/+page.server.ts @@ -3,6 +3,7 @@ import { UserError } from '#lib/server/core.ts'; import { cacheBriefly } from '#lib/server/http.ts'; import { listed, mixMeta } from '#lib/server/meta.ts'; import { projectRecords } from '#lib/server/meta-records.ts'; +import { hideInactiveProject } from '#lib/server/project-page.ts'; import { mixRecording } from '#lib/server/structured-data.ts'; import type { PageServerLoad } from './$types'; @@ -14,8 +15,10 @@ export const load: PageServerLoad = async (event) => { if (!project) error(404, 'No project with that name'); const isManager = !!viewer && project.managers.includes(viewer.did); + const canEdit = isManager || !!viewer?.isStaff; - if (project.status !== 'active' && !isManager && !viewer?.isStaff) error(404, 'No project with that name'); + if (project.status !== 'active' && !canEdit) error(404, 'No project with that name'); + await hideInactiveProject(app, project); const n = Number(params.n); const mix = Number.isInteger(n) && n >= 1 ? project.profile.mixes?.[n - 1] : undefined; @@ -25,8 +28,9 @@ export const load: PageServerLoad = async (event) => { try { const report = await app.tracklists.published(mix.tracklist); - // The layout's data is in the page, and a signed-in visitor's viewer and flags are theirs alone. - if (project.status === 'active') cacheBriefly(event, 300); + // The layout's data is in the page, and a signed-in visitor's viewer and flags are theirs alone. Its managers and + // staff, who can change the project, get it uncached. + if (project.status === 'active') cacheBriefly(event, 300, canEdit ? ['page.edit'] : []); return { project: { slug: project.slug, name: project.profile.name, avatarUrl: project.avatarUrl, status: project.status }, @@ -34,7 +38,7 @@ export const load: PageServerLoad = async (event) => { // Streamed, so the report shows while the directory looks up the set. sets: mix.set ? app.sets.linked([mix.set]) : undefined, // What the player plays, streamed too: the mix's or its linked set's recording may be asked of plyr.fm. - source: app.recordings.forMix(mix), + source: app.recordings.forMix(mix, locals.flags), n, report, meta: await listed(locals, mixMeta(app.config.publicUrl, project, mix, n, report.plays.length), { diff --git a/apps/web/src/routes/projects/[slug]/mixes/[n]/page.server.test.ts b/apps/web/src/routes/projects/[slug]/mixes/[n]/page.server.test.ts index 3f659d880..95e26fcf7 100644 --- a/apps/web/src/routes/projects/[slug]/mixes/[n]/page.server.test.ts +++ b/apps/web/src/routes/projects/[slug]/mixes/[n]/page.server.test.ts @@ -84,6 +84,21 @@ it("keeps a signed-in viewer's page out of shared caches", async () => { expect(headers['cache-control']).toBe('private, max-age=300'); }); +it('keeps no copy for its managers and staff, who can change it', async () => { + for (const did of [DJ, ADMIN]) { + const { loadData, headers } = routeEvent({ + app: app(), + viewer: await f.t.viewer(did), + params: { slug: project.slug, n: '1' }, + url: `/projects/${project.slug}/mixes/1` + }); + + await loadData(load); + + expect(headers['cache-control']).toBe('no-store'); + } +}); + it("shows a mix's tracklist, its player and its page's head, cached for five minutes", async () => { const { loadData, headers, locals } = routeEvent({ app: app(), @@ -170,3 +185,11 @@ it('lets an unexpected failure through as it is', async () => { }) ).rejects.toBe(failing); }); + +it("hides a mix once none of the project's managers is active", async () => { + await f.managersAre('takendown', 'deactivated'); + await expect(mixPage('1')).rejects.toMatchObject({ status: 404, body: { title: "Neon Tide isn't active" } }); + + await f.managersAre('deleted', 'deleted'); + await expect(mixPage('1')).rejects.toMatchObject({ status: 410, body: { title: 'Neon Tide is gone' } }); +}); diff --git a/apps/web/src/routes/projects/[slug]/page.server.test.ts b/apps/web/src/routes/projects/[slug]/page.server.test.ts index f76adccad..73e3bce95 100644 --- a/apps/web/src/routes/projects/[slug]/page.server.test.ts +++ b/apps/web/src/routes/projects/[slug]/page.server.test.ts @@ -150,6 +150,20 @@ it('shows a hidden project to its managers, without following and kept out of se await expect(page()).rejects.toMatchObject({ status: 404 }); }); +it('hides the project once none of its managers is active, saying it was deleted when all of them were', async () => { + await f.managersAre('deactivated', 'active'); + expect((await page()).project.uri).toBe(f.project.uri); + + await f.managersAre('deactivated', 'deleted'); + await expect(page()).rejects.toMatchObject({ status: 404, body: { title: "Neon Tide isn't active" } }); + + await f.managersAre('deleted', 'deleted'); + await expect(page(await f.t.viewer(ADMIN))).rejects.toMatchObject({ + status: 410, + body: { title: 'Neon Tide is gone' } + }); +}); + it("saves the project to the viewer's planner, and takes it out again", async () => { const friend = await f.t.viewer(FRIEND); diff --git a/apps/web/src/routes/projects/[slug]/press-kits/[rkey]/page.server.test.ts b/apps/web/src/routes/projects/[slug]/press-kits/[rkey]/page.server.test.ts index 19d47dcab..8dc2bec2a 100644 --- a/apps/web/src/routes/projects/[slug]/press-kits/[rkey]/page.server.test.ts +++ b/apps/web/src/routes/projects/[slug]/press-kits/[rkey]/page.server.test.ts @@ -155,3 +155,10 @@ it("answers a press kit that isn't there with a 404", async () => { body: { message: 'Press kit not found' } }); }); + +it("hides a press kit once all of the project's managers were deleted", async () => { + const epk = await f.publish(DJ); + await f.managersAre('deleted', 'deleted'); + + await expect(pressKit(epk.rkey, null)).rejects.toMatchObject({ status: 410, body: { title: 'Neon Tide is gone' } }); +}); diff --git a/apps/web/src/routes/projects/[slug]/press-kits/[rkey]/photos/[cid]/+server.ts b/apps/web/src/routes/projects/[slug]/press-kits/[rkey]/photos/[cid]/+server.ts index ec8a70bc6..be78cae43 100644 --- a/apps/web/src/routes/projects/[slug]/press-kits/[rkey]/photos/[cid]/+server.ts +++ b/apps/web/src/routes/projects/[slug]/press-kits/[rkey]/photos/[cid]/+server.ts @@ -1,5 +1,6 @@ import { error } from '@sveltejs/kit'; import { imageResponse, PHOTO_TYPES } from '#lib/server/images.ts'; +import { hideInactiveProject } from '#lib/server/project-page.ts'; import type { RequestHandler } from './$types'; /** @@ -13,7 +14,8 @@ export const GET: RequestHandler = async ({ locals, params, url }) => { const hidden = !project || (project.status !== 'active' && !isManager && !viewer?.isStaff); const kit = hidden ? null : await app.epks.get(project, params.rkey); - if (!kit) error(404, 'Photo not found'); + if (!project || !kit) error(404, 'Photo not found'); + await hideInactiveProject(app, project); const access = viewer ? await app.epks.accessState(kit, viewer) : null; const photo = await app.epks.photo(kit.epk, params.cid, access?.kind === 'manager' || access?.kind === 'granted'); diff --git a/apps/web/src/routes/projects/[slug]/press-kits/[rkey]/photos/[cid]/server.test.ts b/apps/web/src/routes/projects/[slug]/press-kits/[rkey]/photos/[cid]/server.test.ts index 03ebc1d71..626f525a7 100644 --- a/apps/web/src/routes/projects/[slug]/press-kits/[rkey]/photos/[cid]/server.test.ts +++ b/apps/web/src/routes/projects/[slug]/press-kits/[rkey]/photos/[cid]/server.test.ts @@ -85,3 +85,10 @@ it("answers a photo of a press kit or project that isn't there with a 404", asyn await expect(get(null, '3lbnxyk5m2s2a', open)).rejects.toMatchObject({ status: 404 }); await expect(get(null, epk.rkey, open, { slug: 'nobody' })).rejects.toMatchObject({ status: 404 }); }); + +it("serves no photo once none of the project's managers is active", async () => { + const { epk, open } = await kitWithPhotos(); + await f.managersAre('deactivated', 'deactivated'); + + await expect(get(null, epk.rkey, open)).rejects.toMatchObject({ status: 404 }); +}); diff --git a/apps/web/src/routes/projects/[slug]/press-kits/page.server.test.ts b/apps/web/src/routes/projects/[slug]/press-kits/page.server.test.ts index bc4cdadb9..9f59e18f5 100644 --- a/apps/web/src/routes/projects/[slug]/press-kits/page.server.test.ts +++ b/apps/web/src/routes/projects/[slug]/press-kits/page.server.test.ts @@ -68,3 +68,9 @@ it("leaves a hidden project's list out of search, and shows it only to its manag expect(data.details).toEqual({}); expect(page.locals).not.toHaveProperty('crawlerHead'); }); + +it("hides the list once none of the project's managers is active", async () => { + await f.managersAre('suspended', 'deleted'); + + await expect(pressKits(null)).rejects.toMatchObject({ status: 404, body: { title: "Neon Tide isn't active" } }); +}); diff --git a/apps/web/src/routes/report/+page.server.ts b/apps/web/src/routes/report/+page.server.ts index a92806630..6be20d619 100644 --- a/apps/web/src/routes/report/+page.server.ts +++ b/apps/web/src/routes/report/+page.server.ts @@ -1,7 +1,7 @@ import { fail, redirect } from '@sveltejs/kit'; import { githubIssueUrl, REPORT_LIMITS, type ReportFacts, reportBody } from '#lib/bug-report.ts'; import { OptionalScopeUnsupported } from '#lib/server/atproto/oauth.ts'; -import { browserLabel } from '#lib/server/services/bug-reports.ts'; +import { browserLabel, postsToUserinput } from '#lib/server/services/bug-reports.ts'; import { requireViewer, safeNext, text } from '#lib/server/http.ts'; import type { Actions, PageServerLoad } from './$types'; @@ -16,17 +16,20 @@ export const load: PageServerLoad = async ({ locals, request, url }) => { const github = githubIssueUrl(facts); const { app, viewer } = locals; - // Signed out, or with no space to post to, a report goes to GitHub. - if (!viewer || !app.bugReports.enabled) redirect(303, github, { external: true }); + // Signed out, or with reports to userinput.app off for them, a report goes to GitHub. + if (!viewer || !postsToUserinput(locals)) redirect(303, github, { external: true }); return { github, facts, canPost: await app.bugReports.canPost(viewer.did) }; }; export const actions: Actions = { /** Sends the viewer through sign-in to approve posting to userinput.app, then back here. */ - allow: async ({ locals, url }) => { + allow: async ({ locals, request, url }) => { const viewer = requireViewer(locals, url); const from = url.searchParams.get('from'); + + if (!postsToUserinput(locals)) redirect(303, githubIssueUrl(factsOf(request, from)), { external: true }); + const next = `/report${from ? `?from=${encodeURIComponent(from)}` : ''}`; let to: URL; const account = await locals.app.accounts.get(viewer.did); @@ -52,6 +55,9 @@ export const actions: Actions = { const values = { title: text(form, 'title', REPORT_LIMITS.title), body: text(form, 'body', REPORT_LIMITS.body) }; const facts = factsOf(request, url.searchParams.get('from')); + // What they wrote goes with them. + if (!postsToUserinput(locals)) redirect(303, githubIssueUrl(facts, values), { external: true }); + if (!values.title) return fail(400, { error: 'Add a title.', values, github: githubIssueUrl(facts, values) }); try { diff --git a/apps/web/src/routes/report/page.server.test.ts b/apps/web/src/routes/report/page.server.test.ts index 31db544cb..57a2f9281 100644 --- a/apps/web/src/routes/report/page.server.test.ts +++ b/apps/web/src/routes/report/page.server.test.ts @@ -2,6 +2,7 @@ import { afterEach, beforeEach, expect, it } from 'vitest'; import { OptionalScopeUnsupported, type OptionalScope, type SignedInAccount } from '#lib/server/atproto/oauth.ts'; import { createTestServices } from '#lib/server/testing/core.ts'; import { callRoute, loadRoute } from '#lib/testing/route-event.ts'; +import type { Flags } from '#lib/types.ts'; import type { PageServerData } from './$types'; import { actions, load } from './+page.server.ts'; @@ -54,6 +55,9 @@ class FakeBugReports { } } +/** Reports to userinput.app rolled out to the DJ. */ +const ROLLED_OUT: Partial = { userinputReports: true }; + let t: Awaited>; beforeEach(async () => { @@ -72,6 +76,7 @@ it('shows the form, with what the report will say about the page and browser', a const data = await loadRoute(load, { app: app(), viewer: await t.viewer(DJ), + flags: ROLLED_OUT, url: '/report?from=/shows', headers: { 'user-agent': FIREFOX } }); @@ -87,6 +92,7 @@ it('leaves the page out when it came from somewhere else', async () => { const data = await loadRoute(load, { app: app(new FakeBugReports(true, [])), viewer: await t.viewer(DJ), + flags: ROLLED_OUT, url: '/report?from=https://evil.test' }); @@ -100,10 +106,44 @@ it('sends someone signed out, or a site with no board to post to, to GitHub', as }); await expect( - callRoute(load, { app: app(new FakeBugReports(false)), viewer: await t.viewer(DJ), url: '/report' }) + callRoute(load, { + app: app(new FakeBugReports(false)), + viewer: await t.viewer(DJ), + url: '/report', + flags: ROLLED_OUT + }) ).rejects.toMatchObject({ status: 303, location: expect.stringContaining('https://github.com/') }); }); +it("sends someone reports to userinput.app aren't rolled out to on to GitHub, posting nothing", async () => { + const bugReports = new FakeBugReports(); + const oauth = new FakeOAuth(); + const viewer = await t.viewer(DJ); + + const github = { + status: 303, + location: expect.stringContaining('https://github.com/cutenode/localnetwork/issues/new') + }; + + await expect( + callRoute(load, { app: app(bugReports, oauth), viewer, url: '/report?from=/shows' }) + ).rejects.toMatchObject(github); + await expect( + callRoute(actions.allow, { app: app(bugReports, oauth), viewer, url: '/report?/allow', form: {} }) + ).rejects.toMatchObject(github); + await expect( + callRoute(actions.send, { + app: app(bugReports, oauth), + viewer, + url: '/report?/send&from=/shows', + form: { title: 'Map is blank', body: 'Never loads.' } + }) + ).rejects.toMatchObject({ status: 303, location: expect.stringContaining('title=Map+is+blank') }); + + expect(bugReports.posts).toEqual([]); + expect(oauth.started).toEqual([]); +}); + it('sends the viewer to approve posting bug reports, then back to the report', async () => { const oauth = new FakeOAuth(); @@ -111,6 +151,7 @@ it('sends the viewer to approve posting bug reports, then back to the report', a callRoute(actions.allow, { app: app(undefined, oauth), viewer: await t.viewer(DJ), + flags: ROLLED_OUT, url: '/report?/allow&from=/shows', form: {} }) @@ -133,6 +174,7 @@ it('comes back to the bare report page when it was opened from nowhere in partic callRoute(actions.allow, { app: app(undefined, oauth), viewer: await t.viewer(DJ), + flags: ROLLED_OUT, url: '/report?/allow', form: {} }) @@ -148,6 +190,7 @@ it("says so when the viewer's server won't let apps post bug reports, or can't b await callRoute(actions.allow, { app: app(undefined, new FakeOAuth('refusesBugReports')), viewer, + flags: ROLLED_OUT, url: '/report?/allow', form: {} }) @@ -157,6 +200,7 @@ it("says so when the viewer's server won't let apps post bug reports, or can't b await callRoute(actions.allow, { app: app(undefined, new FakeOAuth('down')), viewer, + flags: ROLLED_OUT, url: '/report?/allow', form: {} }) @@ -182,6 +226,7 @@ it('posts the report with the page and browser under it', async () => { const result = await callRoute(actions.send, { app: app(bugReports), viewer: await t.viewer(DJ), + flags: ROLLED_OUT, url: '/report?/send&from=/shows', headers: { 'user-agent': FIREFOX }, form: { title: ' Map is blank ', body: 'The map on the shows page never loads.' } @@ -201,6 +246,7 @@ it('asks for a title, keeping what was typed', async () => { const result = await callRoute(actions.send, { app: app(), viewer: await t.viewer(DJ), + flags: ROLLED_OUT, url: '/report?/send', form: { title: ' ', body: 'Something broke.' } }); @@ -222,6 +268,7 @@ it("offers GitHub instead when the report can't be posted", async () => { const result = await callRoute(actions.send, { app: app(bugReports), viewer: await t.viewer(DJ), + flags: ROLLED_OUT, url: '/report?/send', form: { title: 'Map is blank', body: 'Never loads.' } }); diff --git a/apps/web/src/routes/sets/[did]/[rkey]/player.json/+server.ts b/apps/web/src/routes/sets/[did]/[rkey]/player.json/+server.ts index c3435a514..2e54d93d1 100644 --- a/apps/web/src/routes/sets/[did]/[rkey]/player.json/+server.ts +++ b/apps/web/src/routes/sets/[did]/[rkey]/player.json/+server.ts @@ -7,7 +7,7 @@ export const GET: RequestHandler = async ({ params, locals }) => { const set = await app.recordings.set(params.did, params.rkey); if (!set) error(404, 'No set here'); - const source = await app.recordings.source(set); + const source = await app.recordings.source(set, locals.flags); log.debug('set player source', { set: set.uri, source: source && (source.kind === 'audio' ? source.from : source.platform) diff --git a/apps/web/src/routes/sets/[did]/[rkey]/player.json/server.test.ts b/apps/web/src/routes/sets/[did]/[rkey]/player.json/server.test.ts index 6e7d3d64a..5309298f3 100644 --- a/apps/web/src/routes/sets/[did]/[rkey]/player.json/server.test.ts +++ b/apps/web/src/routes/sets/[did]/[rkey]/player.json/server.test.ts @@ -70,3 +70,35 @@ it('has no source for a set with nothing to play, and is a 404 for a set the dir for (const rkey of ['3kmissing', '..']) await expect(callRoute(GET, { app: app(), params: { did: DJ, rkey } })).rejects.toMatchObject({ status: 404 }); }); + +it("plays a set's links instead of its recording on the DJ's PDS while pauseRecordingStream is on", async () => { + const client = t.net.client(DJ); + const audio = await client.uploadBlob(new Uint8Array(1234), 'audio/mpeg'); + + await client.putRecord({ + collection: COLLECTION.djRecording, + rkey: '3krec', + record: { $type: COLLECTION.djRecording, audio, createdAt: '2026-09-13T00:00:00Z' } + }); + + await client.putRecord({ + collection: COLLECTION.djSet, + rkey: '3krecorded', + record: { + $type: COLLECTION.djSet, + date: '2026-09-12', + tracks: [], + recording: { uri: `at://${DJ}/${COLLECTION.djRecording}/3krec`, cid: 'bafyrec' }, + links: [{ uri: 'https://soundcloud.com/neon/tidal-hours' }], + createdAt: '2026-09-13T00:00:00Z' + } + }); + + const play = async (pauseRecordingStream: boolean) => + ( + await callRoute(GET, { app: app(), params: { did: DJ, rkey: '3krecorded' }, flags: { pauseRecordingStream } }) + ).json(); + + expect(await play(false)).toMatchObject({ source: { kind: 'audio', from: 'pds' } }); + expect(await play(true)).toMatchObject({ source: { kind: 'embed', platform: 'SoundCloud' } }); +}); diff --git a/apps/web/src/routes/venue/[key]/[[name]]/+page.server.ts b/apps/web/src/routes/venue/[key]/[[name]]/+page.server.ts index 840258404..eea9e6ffd 100644 --- a/apps/web/src/routes/venue/[key]/[[name]]/+page.server.ts +++ b/apps/web/src/routes/venue/[key]/[[name]]/+page.server.ts @@ -1,23 +1,22 @@ import { error, redirect } from '@sveltejs/kit'; -import { capabilitiesIn } from '#lib/capabilities.ts'; +import { type Capability, capabilitiesIn } from '#lib/capabilities.ts'; import type { ListedEvent } from '#lib/events.ts'; import { listedEvent } from '#lib/server/events-list.ts'; +import { pageContext } from '#lib/server/edit-mode.ts'; import { cacheBriefly, requireFlag } from '#lib/server/http.ts'; import { pageMeta } from '#lib/server/meta.ts'; import type { VenueView } from '#lib/server/services/venues.ts'; import { spacePagePath } from '#lib/space-paths.ts'; -import type { Viewer } from '#lib/types.ts'; +import type { SpacePerson, Viewer } from '#lib/types.ts'; import type { PageServerLoad } from './$types'; /** * The venue's dashboard pages the viewer can use: its events waiting for it with venue.approve, its settings with * page.edit or venue.block (staff can use both), and otherwise claiming it. */ -async function dashboardLinks(app: App.Locals['app'], venue: VenueView, viewer: Viewer) { +function dashboardLinks(venue: VenueView, viewer: Viewer, person: SpacePerson | undefined, held: Capability[]) { const base = `/dashboard/venues/${venue.skey}`; - const person = (await app.sharedSpaces.people(venue.space, viewer)).find((someone) => someone.did === viewer.did); - const held = capabilitiesIn('venue', person?.capabilities ?? []); - const can = (capability: (typeof held)[number]) => viewer.isStaff || held.includes(capability); + const can = (capability: Capability) => viewer.isStaff || held.includes(capability); return [ ...(can('venue.approve') ? [{ label: 'Events to confirm', href: `${base}/events` }] : []), @@ -46,12 +45,20 @@ export const load: PageServerLoad = async (event) => { const { name, address } = venue; const place = [address.locality, address.country].filter(Boolean).join(', '); - cacheBriefly(event, 60); + const person = viewer + ? (await app.sharedSpaces.people(venue.space, viewer)).find((someone) => someone.did === viewer.did) + : undefined; + + const held = capabilitiesIn('venue', person?.capabilities ?? []); + const { can } = pageContext(locals, 'venue', venue.space, held); + + // Its people and staff change what it shows from the dashboard, and come back to see it. + cacheBriefly(event, 60, can ?? []); return { venue: { name, address, geo: venue.geo ?? null }, events: listed.filter((shown): shown is ListedEvent => !!shown), - dashboard: flags.peopleSpaces && viewer ? await dashboardLinks(app, venue, viewer) : [], + dashboard: flags.peopleSpaces && viewer ? dashboardLinks(venue, viewer, person, held) : [], meta: pageMeta(app.config.publicUrl, { title: name, description: `${name} in ${place}: upcoming events on Local Network.`, diff --git a/apps/web/src/routes/venue/[key]/[[name]]/page.server.test.ts b/apps/web/src/routes/venue/[key]/[[name]]/page.server.test.ts index 0c7529d4b..66d54bc32 100644 --- a/apps/web/src/routes/venue/[key]/[[name]]/page.server.test.ts +++ b/apps/web/src/routes/venue/[key]/[[name]]/page.server.test.ts @@ -140,6 +140,29 @@ it('links its dashboard pages for the people who can use them, and claiming it f expect((await opened(path, { did: OWNER, flags: { spacePages: true } })).dashboard).toEqual([]); }); +it('keeps no copy for its people and staff, who can change what it shows, and lets the browser keep one for anyone else', async () => { + const cacheControl = async (did: string, flags = on) => { + const { headers, loadData } = routeEvent({ + app: app(), + viewer: await t.viewer(did), + url: `/venue/${venue.skey}/tresor`, + params: { key: venue.skey, name: 'tresor' }, + flags + }); + + await loadData(load); + + return headers['cache-control']; + }; + + expect(await cacheControl(OWNER)).toBe('no-store'); + expect(await cacheControl(BOOKER)).toBe('no-store'); + expect(await cacheControl(ADMIN)).toBe('no-store'); + // Its people change it from their dashboard, which they reach without peopleSpaces too. + expect(await cacheControl(OWNER, { spacePages: true })).toBe('no-store'); + expect(await cacheControl(STRANGER)).toBe('private, max-age=60'); +}); + it('sends any other name, or none, on to the current one, and is a 404 for an unknown venue or while spacePages is off', async () => { await expect(opened(`/venue/${venue.skey}?ref=x`)).rejects.toMatchObject({ status: 308, diff --git a/apps/web/src/routes/xrpc/computer.localnetwork.directory.requestIndex/+server.ts b/apps/web/src/routes/xrpc/computer.localnetwork.directory.requestIndex/+server.ts index b57f061ac..5d220b17c 100644 --- a/apps/web/src/routes/xrpc/computer.localnetwork.directory.requestIndex/+server.ts +++ b/apps/web/src/routes/xrpc/computer.localnetwork.directory.requestIndex/+server.ts @@ -2,10 +2,11 @@ import { requestIndex } from '#lib/server/happyview/request-index.ts'; import type { RequestHandler } from './$types'; /** locallibrary asks for its account's records to be read again, with service auth from the account's PDS. */ -export const POST: RequestHandler = ({ request, locals: { app, log } }) => +export const POST: RequestHandler = ({ request, locals: { app, flags, log } }) => requestIndex(request.headers.get('authorization'), { audience: app.config.serviceDid, getSigningKey: (did, force) => app.identity.signingKey(did, force), backfills: app.backfills, + paused: flags.pauseRequestIndex, log }); diff --git a/apps/web/src/routes/xrpc/computer.localnetwork.directory.requestIndex/server.test.ts b/apps/web/src/routes/xrpc/computer.localnetwork.directory.requestIndex/server.test.ts index d8398e942..1437d8516 100644 --- a/apps/web/src/routes/xrpc/computer.localnetwork.directory.requestIndex/server.test.ts +++ b/apps/web/src/routes/xrpc/computer.localnetwork.directory.requestIndex/server.test.ts @@ -2,10 +2,12 @@ import { Secp256k1Keypair } from '@atproto/crypto'; import { afterEach, beforeEach, expect, it } from 'vitest'; import { REQUEST_INDEX } from '#lib/nsid.ts'; import { Backfills } from '#lib/server/happyview/backfills.ts'; +import { HappyViewClient } from '#lib/server/happyview/client.ts'; import { silentLogger } from '#lib/server/logger.ts'; import { createTestServices } from '#lib/server/testing/core.ts'; import { serviceJwt } from '#lib/server/testing/service-jwt.ts'; import { callRoute } from '#lib/testing/route-event.ts'; +import type { Flags } from '#lib/types.ts'; import { POST } from './+server.ts'; const SERVICE_DID = 'did:web:localnetwork.test'; @@ -16,9 +18,13 @@ let t: Awaited>; let key: Secp256k1Keypair; +/** The backfills HappyView was asked to start. */ +let backfills: string[]; + beforeEach(async () => { t = await createTestServices(); key = await Secp256k1Keypair.create(); + backfills = []; }); afterEach(async () => { @@ -27,13 +33,27 @@ afterEach(async () => { }); /** locallibrary asks for DJ's records to be read again, with `authorization`, and gets the status and answer. */ -async function requestIndex(authorization: string) { +async function requestIndex(authorization: string, flags?: Flags) { + // The test's HappyView, watched for the backfills it's asked to start. + const directory = new HappyViewClient({ + url: 'http://happyview.test', + apiKey: 'hv_test', + fetch: async (input, init) => { + const request = new Request(input, init); + + if (new URL(request.url).pathname === '/admin/backfill') backfills.push(request.url); + + return t.happyView.fetch(request); + } + }); + const response = await callRoute(POST, { app: { config: { serviceDid: SERVICE_DID }, identity: { signingKey: async () => key.did() }, - backfills: new Backfills(t.directory, silentLogger) + backfills: new Backfills(directory, silentLogger) }, + flags, request: new Request(`https://localnetwork.test/xrpc/${REQUEST_INDEX}`, { method: 'POST', headers: { authorization } @@ -52,6 +72,25 @@ it("has HappyView re-read the caller's records", async () => { }); expect(await requestIndex(authorization)).toEqual({ status: 200, body: { indexed: true } }); + expect(backfills).not.toEqual([]); +}); + +it('says nothing was indexed, starting no backfill, while pauseRequestIndex is on', async () => { + const paused = await createTestServices({ flagOverrides: { pauseRequestIndex: true } }); + + const authorization = await serviceJwt(key, { + iss: DJ, + aud: SERVICE_DID, + lxm: REQUEST_INDEX, + exp: Math.floor(Date.now() / 1000) + 60 + }); + + expect(await requestIndex(authorization, await paused.flags.evaluate(null))).toEqual({ + status: 200, + body: { indexed: false } + }); + expect(backfills).toEqual([]); + await paused.db.destroy(); }); it('refuses a token minted for another service', async () => { diff --git a/apps/web/src/routes/xrpc/computer.localnetwork.flags.getFlags/server.test.ts b/apps/web/src/routes/xrpc/computer.localnetwork.flags.getFlags/server.test.ts index eadabf21a..a1a7bb296 100644 --- a/apps/web/src/routes/xrpc/computer.localnetwork.flags.getFlags/server.test.ts +++ b/apps/web/src/routes/xrpc/computer.localnetwork.flags.getFlags/server.test.ts @@ -54,7 +54,13 @@ async function ask(authorization?: string) { it('tells anyone the public gates, and targets nobody', async () => { expect(await ask()).toEqual({ - flags: answersWith('parityCanary', { enabled: true, everyone: false, percentage: 10, targeted: false }) + flags: answersWith('parityCanary', { + enabled: true, + signedOut: false, + everyone: false, + percentage: 10, + targeted: false + }) }); }); @@ -67,7 +73,13 @@ it('tells an account its own targeting, with a token from its server', async () }); expect(await ask(token)).toEqual({ - flags: answersWith('parityCanary', { enabled: true, everyone: false, percentage: 10, targeted: true }) + flags: answersWith('parityCanary', { + enabled: true, + signedOut: false, + everyone: false, + percentage: 10, + targeted: true + }) }); }); @@ -81,6 +93,12 @@ it('says a flag is off for everyone, with the gates it keeps for when it is back }); expect(await ask()).toEqual({ - flags: answersWith('parityCanary', { enabled: false, everyone: false, percentage: 10, targeted: false }) + flags: answersWith('parityCanary', { + enabled: false, + signedOut: false, + everyone: false, + percentage: 10, + targeted: false + }) }); }); diff --git a/apps/web/src/writing.test.ts b/apps/web/src/writing.test.ts index 887620a88..534c63771 100644 --- a/apps/web/src/writing.test.ts +++ b/apps/web/src/writing.test.ts @@ -7,11 +7,15 @@ const root = join(import.meta.dirname, '../../..'); // The site's copy, code and the lexicons it publishes are written without long dashes. const folders = ['apps/web/src', 'lexicons/computer']; +// Paraglide's compiled runtime and messages (src/lib/paraglide, git-ignored) are its code, not ours. +const PARAGLIDE = join(root, 'apps/web/src/lib/paraglide'); + // Files only: some route folders are named like files (`oauth-client-metadata.json/`). const files = folders.flatMap((folder) => readdirSync(join(root, folder), { recursive: true, withFileTypes: true }) .filter((entry) => entry.isFile() && /\.(svelte|ts|js|css|html|json)$/.test(entry.name)) .map((entry) => join(entry.parentPath, entry.name)) + .filter((file) => !file.startsWith(PARAGLIDE)) ); // Built from its code point, so this file doesn't contain one (the formatter unescapes \u escapes). diff --git a/apps/web/tests/integration/flows.test.ts b/apps/web/tests/integration/flows.test.ts index 517607162..6def83f4e 100644 --- a/apps/web/tests/integration/flows.test.ts +++ b/apps/web/tests/integration/flows.test.ts @@ -154,7 +154,7 @@ describe('Local Network on a real atproto spaces network', () => { const event = { params: { id: '1', slug: 'x', rkey: 'x' }, url, - locals: { app: net.app, viewer: pat, log: silentLogger } + locals: { app: net.app, viewer: pat, log: silentLogger, flags: flagsOff } }; for (const load of [ @@ -288,7 +288,7 @@ describe('Local Network on a real atproto spaces network', () => { params: { slug }, url, request: new Request(url, { method: 'POST', body: form }), - locals: { app: net.app, viewer: lee, log: silentLogger } + locals: { app: net.app, viewer: lee, log: silentLogger, flags: flagsOff } }) ).rejects.toMatchObject({ status: 403 }); expect(await net.app.requests.list({ requester: lee.did })).toEqual([]); @@ -366,7 +366,7 @@ describe('Local Network on a real atproto spaces network', () => { const review = await adminRequest({ params: { rkey: request.rkey }, url: new URL(`http://localhost/admin/requests/${request.rkey}`), - locals: { app: net.app, viewer: await net.viewer('ada'), log: silentLogger } + locals: { app: net.app, viewer: await net.viewer('ada'), log: silentLogger, flags: flagsOff } }); expect(review.avatar).toEqual({ type: 'image/svg+xml', shown: false }); @@ -448,7 +448,11 @@ describe('Local Network on a real atproto spaces network', () => { expect(stored?.value).toMatchObject({ profile: { mixes: [{ title: 'Closing', set: { uri, cid } }] } }); const page = async () => { - const event = { params: { slug: project.slug }, locals: { app: net.app, viewer: null, log: silentLogger } }; + const event = { + params: { slug: project.slug }, + locals: { app: net.app, viewer: null, log: silentLogger, flags: flagsOff } + }; + const data = await projectPage(event); return data && 'sets' in data ? (await data.sets)?.get(uri) : undefined; @@ -648,7 +652,7 @@ describe('Local Network on a real atproto spaces network', () => { headers: { authorization: `Bearer ${token}` } }); - const response = await requestIndex({ request, locals: { app: net.app, log: silentLogger } }); + const response = await requestIndex({ request, locals: { app: net.app, log: silentLogger, flags: flagsOff } }); return { status: response.status, body: await response.json() }; }; @@ -1015,7 +1019,7 @@ describe('Local Network on a real atproto spaces network', () => { it('brings someone who turns down sharing their email back to the settings, and anyone else to sign-in', async () => { const callback = async (url: URL) => { try { - await oauthCallback({ url, locals: { app: net.app, log: silentLogger } }); + await oauthCallback({ url, locals: { app: net.app, log: silentLogger, flags: flagsOff } }); } catch (thrown) { return isRedirect(thrown) ? thrown.location : thrown; } diff --git a/apps/web/tests/integration/held-records.test.ts b/apps/web/tests/integration/held-records.test.ts index 9c71fbc5c..b10e77f83 100644 --- a/apps/web/tests/integration/held-records.test.ts +++ b/apps/web/tests/integration/held-records.test.ts @@ -5,6 +5,7 @@ import type { HeldRecordView, Viewer } from '../../src/lib/types.ts'; import { load } from '../../src/routes/dashboard/account/data/+page.server.ts'; import { actions } from '../../src/routes/dashboard/account/data/[kind]/+page.server.ts'; import { TestNetwork } from './network.ts'; +import { flagsOff } from '../../src/lib/testing/flags.ts'; describe('deleting what the root wrote on your behalf, on a real atproto spaces network', () => { let net: TestNetwork; @@ -32,7 +33,7 @@ describe('deleting what the root wrote on your behalf, on a real atproto spaces const event = (viewer: Viewer, form?: Record) => ({ url, - locals: { app: net.app, viewer, log: silentLogger }, + locals: { app: net.app, viewer, log: silentLogger, flags: flagsOff }, request: new Request(url, { method: 'POST', body: new URLSearchParams(form) }) }); diff --git a/apps/web/tests/integration/inactive-accounts.test.ts b/apps/web/tests/integration/inactive-accounts.test.ts new file mode 100644 index 000000000..f25101e24 --- /dev/null +++ b/apps/web/tests/integration/inactive-accounts.test.ts @@ -0,0 +1,69 @@ +import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'; +import { load as profilePage } from '../../src/routes/@[handle]/+page.server.ts'; +import { callRoute } from '../../src/lib/testing/route-event.ts'; +import { TestNetwork } from './network.ts'; + +const BERLIN = { city: 'Berlin', country: 'DE', latE6: 52_520_000, lngE6: 13_405_000 }; + +/** Past the half hour an account's status is kept for, so the next check asks its PDS again. */ +const LATER_MS = 31 * 60_000; + +describe('an account that stops being active, on a real PDS', () => { + let net: TestNetwork; + + beforeAll(async () => { + net = await TestNetwork.create(['ada', 'neon'], { admins: ['ada'] }); + const neon = await net.viewer('neon'); + + await net.app.profiles.save(neon, { + basics: { name: 'Neon', location: BERLIN }, + performer: { genres: ['techno'] }, + avatar: 'keep', + swap: null + }); + await net.app.djListings.list(await net.viewer('ada'), neon.did); + }); + afterAll(async () => { + await net?.close(); + }); + + /** The DJs Find DJs lists, by DID. */ + const listed = async () => + (await net.app.performers.search({})).items.flatMap((item) => (item.kind === 'dj' ? [item.dj.profile.did] : [])); + + /** Checks the directory's accounts again as if half an hour had passed, so each one's PDS is asked. */ + const checkLater = async () => { + const now = Date.now(); + vi.spyOn(Date, 'now').mockReturnValue(now + LATER_MS); + + try { + await net.app.accountStatuses.refresh(); + } finally { + vi.restoreAllMocks(); + } + }; + + it("leaves a deactivated DJ out of Find DJs and says their page isn't active, until they come back", async () => { + const neon = net.user('neon'); + + const page = (address = neon.handle) => + callRoute(profilePage, { app: net.app, params: { handle: address }, url: `/@${address}` }); + + await neon.agent.com.atproto.server.deactivateAccount({}); + await net.app.accountStatuses.refresh(); + + expect(await listed()).toEqual([]); + // A deactivated account's PDS stops answering for its handle, so that address finds nobody; its DID still says why. + await expect(page()).rejects.toMatchObject({ status: 404 }); + await expect(page(neon.did)).rejects.toMatchObject({ + status: 404, + body: { title: expect.stringMatching(/isn't active$/) } + }); + + await neon.agent.com.atproto.server.activateAccount(); + await checkLater(); + + expect(await listed()).toEqual([neon.did]); + await expect(page()).resolves.toMatchObject({ name: 'Neon' }); + }); +}); diff --git a/apps/web/tests/integration/press-kits.test.ts b/apps/web/tests/integration/press-kits.test.ts index b06e64b61..96e379776 100644 --- a/apps/web/tests/integration/press-kits.test.ts +++ b/apps/web/tests/integration/press-kits.test.ts @@ -33,6 +33,7 @@ import { load as publicKit } from '../../src/routes/projects/[slug]/press-kits/[ import { grantKey, type PressKit } from '../../src/lib/server/services/epk.ts'; import type { ProjectView } from '../../src/lib/types.ts'; import { TestNetwork } from './network.ts'; +import { flagsOff } from '../../src/lib/testing/flags.ts'; /** A 1x1 PNG. */ const PNG = Uint8Array.from( @@ -460,7 +461,7 @@ describe('shared press kits on a real atproto spaces network', () => { const [neon, remy, pat] = [await net.viewer('neon'), await net.viewer('remy'), await net.viewer('pat')]; const night = await project('Night Shift', ['neon', 'remy']); const slug = night.slug; - const locals = (viewer: typeof neon | null) => ({ app: net.app, viewer, log: silentLogger }); + const locals = (viewer: typeof neon | null) => ({ app: net.app, viewer, log: silentLogger, flags: flagsOff }); /** A handler's result as a promise, so a redirect it throws, even synchronously, rejects it. */ const handled = async (run: () => T | Promise): Promise => run(); diff --git a/apps/web/tests/integration/shared-spaces.test.ts b/apps/web/tests/integration/shared-spaces.test.ts index fd0d966c1..695ddf399 100644 --- a/apps/web/tests/integration/shared-spaces.test.ts +++ b/apps/web/tests/integration/shared-spaces.test.ts @@ -11,6 +11,7 @@ import { } from '../../src/routes/admin/spaces/[kind]/[skey]/+page.server.ts'; import { load as spacesLoad } from '../../src/routes/admin/spaces/+page.server.ts'; import { TestNetwork } from './network.ts'; +import { flagsOff } from '../../src/lib/testing/flags.ts'; const listRecordsOutput = z.object({ records: z.array(z.object({ value: z.object({ subject: z.string() }) })) @@ -92,7 +93,7 @@ describe('shared spaces on a real atproto spaces network', () => { const staff = await net.viewer('mira'); const { kind, skey } = { kind: 'performer', skey: parseSpaceUri(space)!.skey }; const url = new URL(`http://127.0.0.1/admin/spaces/${kind}/${skey}`); - const locals = { app: net.app, viewer: staff, log: silentLogger }; + const locals = { app: net.app, viewer: staff, log: silentLogger, flags: flagsOff }; const list = await spacesLoad({ url, locals, params: {} }); expect(await list.spaces).toMatchObject([{ uri: space, kind, people: 2, listed: true }]); diff --git a/apps/web/tests/integration/sync-notify.test.ts b/apps/web/tests/integration/sync-notify.test.ts index 3a8fa07c1..d3ed1cd69 100644 --- a/apps/web/tests/integration/sync-notify.test.ts +++ b/apps/web/tests/integration/sync-notify.test.ts @@ -8,6 +8,7 @@ import { silentLogger } from '../../src/lib/server/logger.ts'; import { POST as confirmRegistration } from '../../src/routes/xrpc/com.atproto.space.confirmRegistration/+server.ts'; import { POST as notifySpaceUpdate } from '../../src/routes/xrpc/com.atproto.space.notifySpaceUpdate/+server.ts'; import { TestNetwork } from './network.ts'; +import { flagsOff } from '../../src/lib/testing/flags.ts'; const NOTE = 'computer.localnetwork.test.note'; @@ -34,7 +35,7 @@ describe("space updates from a real atproto spaces host, sent to the app's own r const response = route && net - ? await route({ request, locals: { app: net.app, log: silentLogger } }) + ? await route({ request, locals: { app: net.app, log: silentLogger, flags: flagsOff } }) : new Response(null, { status: 503 }); calls.push({ nsid, body: JSON.parse(body), status: response.status }); diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts index 6ec3fc6d7..bc875d908 100644 --- a/apps/web/vite.config.ts +++ b/apps/web/vite.config.ts @@ -1,3 +1,4 @@ +import { paraglideVitePlugin } from '@inlang/paraglide-js'; import adapter from '@sveltejs/adapter-node'; import { storybookTest } from '@storybook/addon-vitest/vitest-plugin'; import { enhancedImages } from '@sveltejs/enhanced-img'; @@ -22,9 +23,20 @@ const uncachedGlobs: Plugin = { // port (63315 and up) instead of moving on, so test runs in two checkouts at once collide. const BROWSER_TEST_SERVER = { strictPort: false }; +// Every test runs in one locale and time zone, whatever the machine's, so a date or number reads the same on a +// laptop as in CI. Node takes them from the environment it starts with, which Vitest gives each test process; the +// browser tests' Chromium takes them from its context. Playwright's e2e tests pin the same (playwright.config.ts). +const TEST_LOCALE = 'en-US'; + +const TEST_TIME_ZONE = 'UTC'; + // A media element's clock follows the audio output, and on a Mac that has stopped, a recording sitting at 0:00 while // its player says it's playing. Without audio output, Chromium keeps the time itself. -const browserTests = () => playwright({ launchOptions: { args: ['--disable-audio-output'] } }); +const browserTests = () => + playwright({ + launchOptions: { args: ['--disable-audio-output'] }, + contextOptions: { locale: TEST_LOCALE, timezoneId: TEST_TIME_ZONE } + }); const storybookProject = (name: string, options: Parameters[0] = {}) => ({ extends: './vite.config.ts', @@ -48,14 +60,18 @@ const SHARED_MODULE_SIZE = 4096; const LIB = /[\\/]src[\\/]lib[\\/]/; +const PARAGLIDE_RUNTIME = /[\\/]src[\\/]lib[\\/]paraglide[\\/]runtime\.js$/; + // The shared group brings a module's imports along with it, whatever their size, so a small // component that renders a large one puts the large one in every visitor's download (ArtistPage // brought ArtistSupport, 12 KB). So everything of ours a module imports, all the way down, has to // be small too. Lucide's index isn't counted: it re-exports every icon, and only the ones used ship. +// Nor is Paraglide's runtime, which every visitor downloads already, so a component that formats a +// date or shows a message can still be shared. const isSmall = (id: string, ctx: Rolldown.ChunkingContext, seen = new Set()): boolean => { const module = ctx.getModuleInfo(id); - if (seen.has(id) || !module || !LIB.test(id)) return true; + if (seen.has(id) || !module || !LIB.test(id) || PARAGLIDE_RUNTIME.test(id)) return true; seen.add(id); return (module.code?.length ?? 0) <= SHARED_MODULE_SIZE && module.importedIds.every((dep) => isSmall(dep, ctx, seen)); @@ -100,6 +116,8 @@ const SHARED = export default defineConfig({ plugins: [ uncachedGlobs, + // The message functions and locale runtime in src/lib/paraglide, from messages/ (project.inlang/paraglide.config.ts). + paraglideVitePlugin({ project: './project.inlang' }), tailwindcss(), // `?enhanced` images: AVIF and WebP at each width, with their size set so nothing shifts as they load. enhancedImages(), @@ -192,6 +210,7 @@ export default defineConfig({ // its 4-core runners, and locally the suites ran no slower with it. Vitest sizes one pool for projects // that run together, so the cap is set here for all of them rather than on the browser projects. maxWorkers: 3, + env: { LC_ALL: 'en_US.UTF-8', TZ: TEST_TIME_ZONE }, expect: { requireAssertions: true }, tags: [ { @@ -210,10 +229,11 @@ export default defineConfig({ 'src/lib/**/*.{ts,svelte}', 'src/routes/**/+*.server.ts', 'src/routes/**/+server.ts', + 'src/hooks.client.ts', 'src/hooks.server.ts' ], // The tests, their harness (fakes and request builders that only tests import), stories and types, the - // generated lexicon types included. + // generated lexicon types and Paraglide's generated messages and runtime included. exclude: [ 'src/lib/server/testing/**', 'src/lib/testing/**', @@ -221,7 +241,8 @@ export default defineConfig({ 'src/lib/**/*.svelte.{test,spec}.ts', 'src/lib/**/*.stories.svelte', 'src/lib/**/types.ts', - 'src/lib/lexicons/**' + 'src/lib/lexicons/**', + 'src/lib/paraglide/**' ], // CI's pull request comment reads the summary, and json for each changed file's uncovered lines. reporter: ['text', 'html', 'lcov', 'json-summary', 'json'], diff --git a/crates/locallibrary/src/atmosphere/flags/tests.rs b/crates/locallibrary/src/atmosphere/flags/tests.rs index 6e12fa535..7957693cb 100644 --- a/crates/locallibrary/src/atmosphere/flags/tests.rs +++ b/crates/locallibrary/src/atmosphere/flags/tests.rs @@ -17,7 +17,7 @@ const OTHER: &str = "did:plc:other"; const FLAG: &str = keys::PARITY_CANARY; const GET_SERVICE_AUTH: &str = "com.atproto.server.getServiceAuth"; -const NOTHING_ON: Gates = Gates { enabled: true, everyone: false, percentage: 0, targeted: false }; +const NOTHING_ON: Gates = Gates { enabled: true, signed_out: false, everyone: false, percentage: 0, targeted: false }; /// A store, and a pretend data server that's Local Network's website too. struct World { @@ -140,7 +140,7 @@ fn a_flag_turned_off_is_off_for_the_account_it_targets() { let now = Utc::now(); assert!(!check_at(w.root(), FLAG, now)); assert_eq!(w.asked(), [false, true]); - let gates = Gates { enabled: false, everyone: true, percentage: 100, targeted: true }; + let gates = Gates { enabled: false, signed_out: false, everyone: true, percentage: 100, targeted: true }; assert_eq!(Cache::load(w.root()).flags, [Flag { key: FLAG.into(), gates }]); assert!(!shown(&all_at(w.root(), false, now + TimeDelta::minutes(1)))); } @@ -152,12 +152,13 @@ fn a_check_now_reads_a_fresh_answer(tc: TestCase) { let w = world(); let gates = Gates { enabled: tc.draw(gs::booleans()), + signed_out: tc.draw(gs::booleans()), everyone: tc.draw(gs::booleans()), percentage: tc.draw(gs::sampled_from(vec![0u32, 100])), targeted: tc.draw(gs::booleans()), }; save(w.root(), &cached(None, TimeDelta::zero(), gates, Utc::now())); - let expected = gates.enabled && gates.everyone; + let expected = gates.enabled && gates.signed_out && (gates.everyone || gates.percentage == 100); assert_eq!(crate::flags::check(w.root(), FLAG), expected); let report = crate::flags::all(w.root(), false); assert_eq!((shown(&report), report.freshness), (expected, Freshness::Fresh)); @@ -169,7 +170,7 @@ fn a_check_now_reads_a_fresh_answer(tc: TestCase) { fn a_website_thats_down_leaves_the_last_answer_and_waits() { let w = world(); let now = Utc::now(); - save(w.root(), &cached(None, TimeDelta::hours(2), Gates { everyone: true, ..NOTHING_ON }, now)); + save(w.root(), &cached(None, TimeDelta::hours(2), Gates { everyone: true, signed_out: true, ..NOTHING_ON }, now)); w.pds.set_flags_answers(Some((503, json!({ "error": "Down" }))), None); assert!(check_at(w.root(), FLAG, now)); assert!(check_at(w.root(), FLAG, now + RETRY_AFTER_FAILURE - TimeDelta::seconds(1))); @@ -194,7 +195,7 @@ fn a_website_thats_down_leaves_the_last_answer_and_waits() { fn an_answer_over_two_weeks_old_is_off() { let w = world(); let now = Utc::now(); - let gates = Gates { everyone: true, ..NOTHING_ON }; + let gates = Gates { everyone: true, signed_out: true, ..NOTHING_ON }; let mut cache = cached(None, LAST_KNOWN_GOOD, gates, now); cache.last_attempt_at = Some(now); save(w.root(), &cache); @@ -222,19 +223,19 @@ fn targeting_goes_with_the_account_it_was_said_of() { assert!(w.pds.requests().is_empty()); } -/// Signed out: the public request alone, and only what's on for everyone. +/// Signed out: the public request alone, and only what's on for every account. #[test] fn signed_out_only_the_public_answer_counts() { let w = world(); let now = Utc::now(); - w.pds.set_flags(&[(FLAG, false, 100)], &[FLAG]); + w.pds.set_flags(&[(FLAG, false, 50)], &[FLAG]); assert!(!check_at(w.root(), FLAG, now)); assert_eq!(w.asked(), [false]); assert_eq!(w.tokens(), 0); assert_eq!(Cache::load(w.root()).did, None); assert!(!all_at(w.root(), false, now).needs_sign_in, "nobody's signed in"); - w.pds.set_flags(&[(FLAG, true, 0)], &[]); + w.pds.set_flags(&[(FLAG, false, 100)], &[]); assert!(check_at(w.root(), FLAG, now + FRESH)); } @@ -525,7 +526,14 @@ fn a_check_ends_as_the_cache_and_the_servers_say(tc: TestCase) { Session::Ended => sign_in_ended(root, &pds.url), } let last = age.map(|age| { - let gates = Gates { enabled: true, everyone: was.0, percentage: was.1, targeted: was.2 }; + // Signed-out callers have it once every account does, as the website answers for an ops flag like this one. + let gates = Gates { + enabled: true, + signed_out: was.0 || was.1 == 100, + everyone: was.0, + percentage: was.1, + targeted: was.2, + }; let mut cache = cached(said_of, TimeDelta::minutes(age), gates, now); cache.last_attempt_at = Some(now - TimeDelta::minutes(attempted)); cache @@ -567,7 +575,7 @@ fn a_check_ends_as_the_cache_and_the_servers_say(tc: TestCase) { } else { (false, 0, false) }; - let expected = everyone || (signed_in && (targeted || percentage == 100)); + let expected = everyone || percentage == 100 || (signed_in && targeted); let said = format!("{age:?} {attempted} {said_of:?} {was:?} {now_is:?} {session:?} {public:?} {with_token:?} {busy}"); assert_eq!(on, expected, "{said}"); diff --git a/crates/locallibrary/src/flags.rs b/crates/locallibrary/src/flags.rs index c0708a54b..61fea9ca8 100644 --- a/crates/locallibrary/src/flags.rs +++ b/crates/locallibrary/src/flags.rs @@ -46,6 +46,11 @@ pub struct Gates { /// flag off is on, and so is an answer from a website that predates it. #[serde(default = "enabled_by_default")] pub enabled: bool, + /// Signed out, it's on only with this, and only once it's on for every account: `everyone` or + /// 100%. A website from before it doesn't send it, which is off. + #[serde(default, rename = "signedOut")] + pub signed_out: bool, + /// Every signed-in account. pub everyone: bool, /// How much of the accounts it's on for, 0 to 100. pub percentage: u32, @@ -72,9 +77,16 @@ pub fn bucket(key: &str, did: &str) -> u32 { u32::from_be_bytes([hash[0], hash[1], hash[2], hash[3]]) % 100 } -/// Whether `key` is on for `did`, given its gates. Signed out, there's no DID to bucket. +/// Whether `key` is on for `did`, given its gates. Signed out, there's no DID to bucket, and the +/// flag comes last: only with `signed_out`, once every account has it. pub fn decide(gates: &Gates, key: &str, did: Option<&str>) -> bool { - gates.enabled && (gates.everyone || gates.targeted || did.is_some_and(|did| bucket(key, did) < gates.percentage)) + if !gates.enabled { + return false; + } + match did { + Some(did) => gates.everyone || gates.targeted || bucket(key, did) < gates.percentage, + None => gates.signed_out && (gates.everyone || gates.percentage >= 100), + } } /// How much an answer can be gone by. diff --git a/crates/locallibrary/src/flags/tests.rs b/crates/locallibrary/src/flags/tests.rs index 9fbba0f5e..cac2cbcf4 100644 --- a/crates/locallibrary/src/flags/tests.rs +++ b/crates/locallibrary/src/flags/tests.rs @@ -16,7 +16,7 @@ fn answered(did: Option<&str>, age: TimeDelta, gates: Gates, now: DateTime) } } -const NOTHING_ON: Gates = Gates { enabled: true, everyone: false, percentage: 0, targeted: false }; +const NOTHING_ON: Gates = Gates { enabled: true, signed_out: false, everyone: false, percentage: 0, targeted: false }; /// Both the website and this code read these, so the two can't come to disagree. #[test] @@ -74,7 +74,7 @@ fn a_damaged_cache_is_no_cache() { #[test] fn an_unknown_key_is_off() { let now = Utc::now(); - let gates = Gates { enabled: true, everyone: true, percentage: 100, targeted: true }; + let gates = Gates { enabled: true, signed_out: true, everyone: true, percentage: 100, targeted: true }; let cache = answered(Some("did:plc:abc"), TimeDelta::zero(), gates, now); assert!(cache.on(FLAG, Some("did:plc:abc"), now)); assert!(!cache.on("notAFlag", Some("did:plc:abc"), now)); @@ -96,7 +96,7 @@ fn a_build_without_the_account_has_every_flag_off() { off(dir.path()); assert!(!dir.path().join(CACHE_FILE).exists()); - let gates = Gates { enabled: true, everyone: true, percentage: 100, targeted: true }; + let gates = Gates { enabled: true, signed_out: true, everyone: true, percentage: 100, targeted: true }; let left = answered(None, TimeDelta::zero(), gates, Utc::now()); crate::fsutil::write_json_atomic(&dir.path().join(CACHE_FILE), &left).unwrap(); off(dir.path()); @@ -123,21 +123,40 @@ fn raising_a_percentage_only_adds_accounts(tc: TestCase) { assert!(!at(0) && at(100)); } -/// Signed out there's no DID: a percentage can't apply and nothing cached can target anyone, so -/// only a flag on for everyone is on, as on the website. +/// Signed out there's no DID: a percentage can't pick anyone and nothing cached can target +/// anyone, so a flag is on only for signed-out callers and once every account has it, as on the +/// website. #[hegel::test(test_cases = 100)] -fn signed_out_only_flags_on_for_everyone_are_on(tc: TestCase) { +fn signed_out_only_flags_on_for_them_and_every_account_are_on(tc: TestCase) { let now = Utc::now(); let gates = Gates { enabled: tc.draw(gs::booleans()), + signed_out: tc.draw(gs::booleans()), everyone: tc.draw(gs::booleans()), percentage: tc.draw(gs::integers::().max_value(100)), targeted: tc.draw(gs::booleans()), }; let did = tc.draw(gs::optional(gs::just("did:plc:abc"))); - let on_for_everyone = gates.enabled && gates.everyone; - assert_eq!(answered(did, TimeDelta::zero(), gates, now).on(FLAG, None, now), on_for_everyone); - assert_eq!(decide(&Gates { targeted: false, ..gates }, FLAG, None), on_for_everyone); + let on = gates.enabled && gates.signed_out && (gates.everyone || gates.percentage == 100); + assert_eq!(answered(did, TimeDelta::zero(), gates, now).on(FLAG, None, now), on); + assert_eq!(decide(&Gates { targeted: false, ..gates }, FLAG, None), on); +} + +/// Signed in, the signed-out setting changes nothing. +#[hegel::test(test_cases = 100)] +fn signed_out_changes_nothing_for_an_account(tc: TestCase) { + let gates = Gates { + enabled: tc.draw(gs::booleans()), + signed_out: tc.draw(gs::booleans()), + everyone: tc.draw(gs::booleans()), + percentage: tc.draw(gs::integers::().max_value(100)), + targeted: tc.draw(gs::booleans()), + }; + let did = tc.draw(gs::text()); + assert_eq!( + decide(&gates, FLAG, Some(&did)), + decide(&Gates { signed_out: !gates.signed_out, ..gates }, FLAG, Some(&did)) + ); } /// A flag staff turned off is off for everyone, whoever it targets or however far it's rolled out, @@ -147,6 +166,7 @@ fn a_flag_turned_off_is_off_for_everyone(tc: TestCase) { let now = Utc::now(); let on = Gates { enabled: true, + signed_out: tc.draw(gs::booleans()), everyone: tc.draw(gs::booleans()), percentage: tc.draw(gs::integers::().max_value(100)), targeted: tc.draw(gs::booleans()), @@ -156,7 +176,10 @@ fn a_flag_turned_off_is_off_for_everyone(tc: TestCase) { let said_of = tc.draw(gs::optional(gs::just("did:plc:abc"))); assert!(!decide(&off, FLAG, did)); assert!(!answered(said_of, TimeDelta::zero(), off, now).on(FLAG, did, now)); - let expected = on.everyone || on.targeted || did.is_some_and(|did| bucket(FLAG, did) < on.percentage); + let expected = match did { + Some(did) => on.everyone || on.targeted || bucket(FLAG, did) < on.percentage, + None => on.signed_out && (on.everyone || on.percentage == 100), + }; assert_eq!(decide(&on, FLAG, did), expected); } @@ -168,6 +191,20 @@ fn no_word_on_enabled_is_enabled() { assert!(!enabled(json!({ "key": FLAG, "enabled": false, "everyone": true, "percentage": 0, "targeted": false }))); } +/// A website or a cache from before signed-out visitors had their own setting says nothing about +/// it: signed out, the flag is off, and the cache keeps the field's name as the website sends it. +#[test] +fn no_word_on_signed_out_is_off() { + let signed_out = |flag: Value| serde_json::from_value::(flag).unwrap().gates.signed_out; + assert!(!signed_out(json!({ "key": FLAG, "everyone": true, "percentage": 100, "targeted": false }))); + assert!(signed_out( + json!({ "key": FLAG, "signedOut": true, "everyone": true, "percentage": 0, "targeted": false }) + )); + let gates = Gates { signed_out: true, ..NOTHING_ON }; + let kept = serde_json::to_value(Flag { key: FLAG.into(), gates }).unwrap(); + assert_eq!(kept["signedOut"], json!(true)); +} + /// An answer is fresh for an hour, stale up to 14 days and then no answer; it's asked for again /// once it isn't fresh and the last attempt is 15 minutes old. #[cfg(feature = "account")] @@ -181,7 +218,8 @@ fn an_answer_ages_as_the_design_says(tc: TestCase) { let now = Utc::now(); let minutes = tc.draw(gs::integers::().min_value(0).max_value(40_000)); let attempted = tc.draw(gs::integers::().min_value(0).max_value(40)); - let mut cache = answered(None, TimeDelta::minutes(minutes), Gates { everyone: true, ..NOTHING_ON }, now); + let gates = Gates { everyone: true, signed_out: true, ..NOTHING_ON }; + let mut cache = answered(None, TimeDelta::minutes(minutes), gates, now); cache.last_attempt_at = Some(now - TimeDelta::minutes(attempted)); let expected = match minutes { diff --git a/crates/locallibrary/tests/support/mock_pds.rs b/crates/locallibrary/tests/support/mock_pds.rs index e7a2550b3..8d748a1df 100644 --- a/crates/locallibrary/tests/support/mock_pds.rs +++ b/crates/locallibrary/tests/support/mock_pds.rs @@ -250,7 +250,8 @@ impl MockPds { } /// What `getFlags` lists from now on: each flag's key, `everyone` and `percentage`, those - /// named in `targeted` targeting a caller with a token. + /// named in `targeted` targeting a caller with a token. Signed-out callers get a flag with + /// `everyone` or 100%, as the website answers for an ops flag. pub fn set_flags(&self, flags: &[(&str, bool, u32)], targeted: &[&str]) { let mut s = self.state.lock().unwrap(); s.flags = flags.iter().map(|(key, everyone, percentage)| (key.to_string(), *everyone, *percentage)).collect(); @@ -725,7 +726,13 @@ fn answer(req: &Request, state: &Mutex, base: &str) -> Answer { } let flag = |(key, everyone, percentage): &(String, bool, u32)| { let targeted = token && s.targeted.contains(key); - json!({ "key": key, "everyone": everyone, "percentage": percentage, "targeted": targeted }) + json!({ + "key": key, + "signedOut": *everyone || *percentage == 100, + "everyone": everyone, + "percentage": percentage, + "targeted": targeted + }) }; (200, vec![], json!({ "flags": s.flags.iter().map(flag).collect::>() })) } diff --git a/crates/loclib-audio/src/mp4.rs b/crates/loclib-audio/src/mp4.rs index b53641914..6e498aac9 100644 --- a/crates/loclib-audio/src/mp4.rs +++ b/crates/loclib-audio/src/mp4.rs @@ -4,7 +4,9 @@ //! which aborts the process wherever memory isn't overcommitted (Windows, Linux with //! `vm.overcommit_memory=2`), and a tag claiming more asks for it anywhere. It reads each sample //! into a buffer of the size the file gives it, so one claiming 4 GiB asks for that for every -//! packet. An abort can't be caught, so such a file is refused here. +//! packet. symphonia-codec-alac sizes its buffers from the frame length an ALAC setup claims, so +//! one claiming 4 billion samples asks for 16 GiB a channel too. An abort can't be caught, so such +//! a file is refused here. use std::fs::File; use std::io::{self, BufReader, ErrorKind, Read, Seek, SeekFrom}; @@ -24,6 +26,11 @@ const TABLES: [(&[u8; 4], u64); 5] = [(b"stsz", 4), (b"stco", 4), (b"co64", 8), const TOO_MANY: &str = "a sample table claims more entries than the file holds"; const TOO_BIG: &str = "a sample is larger than the file"; +const TOO_LONG: &str = "an ALAC frame claims more samples than any encoder writes"; + +/// The most samples an ALAC frame may claim. Apple's encoder writes 4,096; this leaves room for +/// any other while keeping a frame's buffers to a few MiB. +const ALAC_FRAME: u32 = 1 << 16; /// Deeper than any atom symphonia reads (`moov/udta/meta/ilst//data` is 6). const DEPTH: u8 = 8; @@ -32,8 +39,8 @@ const DEPTH: u8 = 8; const PROBE_LIMIT: u64 = 1 << 20; /// Refuse `path` when it's an MP4 whose atoms claim more than the file holds: a sample table -/// whose count wouldn't fit in it, a sample larger than the file, or an atom inside another -/// running past it or the file's end. +/// whose count wouldn't fit in it, a sample larger than the file, an ALAC frame longer than +/// `ALAC_FRAME`, or an atom inside another running past it or the file's end. /// Anything else, MP4 or not, is left for the decoder to make sense of. So is what isn't a regular /// file (a FIFO): what this read of it took would be gone when the decoder opened it again, and /// its atoms can't be walked without seeking. @@ -113,9 +120,7 @@ fn walk(r: &mut dyn Source, mut at: u64, end: u64, len: u64, level: Level) -> io }; while at.saturating_add(8) <= end { r.seek(SeekFrom::Start(at))?; - let size = u64::from(read_u32(r)?); - let mut kind = [0; 4]; - r.read_exact(&mut kind)?; + let (size, kind) = (u64::from(read_u32(r)?), read_kind(r)?); let (size, header) = match size { 0 => (end - at, 8), 1 => (read_u64(r)?, 16), @@ -145,6 +150,10 @@ fn walk(r: &mut dyn Source, mut at: u64, end: u64, len: u64, level: Level) -> io } } else if let Some(why) = table(r, &kind, body, body_end, len)? { return Ok(Some(why)); + } else if &kind == b"stsd" + && let Some(why) = alac_frames(r, body, body_end)? + { + return Ok(Some(why)); } at = atom_end; } @@ -211,6 +220,63 @@ fn table(r: &mut dyn Source, kind: &[u8; 4], body: u64, body_end: u64, len: u64) Ok(None) } +/// What's wrong with the ALAC setups among the sample entries in the `stsd` body from `body` to +/// `body_end`, if anything: a frame longer than [`ALAC_FRAME`]. Each setup is an `alac` atom inside +/// an `alac` entry, after the entry's fields (28 bytes, 16 more in version 1 and 36 in version 2). +/// Entries symphonia can't read are left for it to report. +fn alac_frames(r: &mut dyn Source, body: u64, body_end: u64) -> io::Result> { + // Past the version, flags and entry count. + let mut at = body + 8; + while at.saturating_add(8) <= body_end { + r.seek(SeekFrom::Start(at))?; + let (size, kind) = (u64::from(read_u32(r)?), read_kind(r)?); + if size < 8 { + return Ok(None); + } + let entry_end = at.saturating_add(size).min(body_end); + if &kind == b"alac" { + r.seek(SeekFrom::Start(at + 16))?; + let fields = match read_u16(r)? { + 0 => 28, + 1 => 44, + 2 => 64, + _ => return Ok(None), + }; + let mut child = at + 8 + fields; + // A header, the version and flags, and the frame length. + while child.saturating_add(16) <= entry_end { + r.seek(SeekFrom::Start(child))?; + let (size, kind) = (u64::from(read_u32(r)?), read_kind(r)?); + if &kind == b"alac" { + read_u32(r)?; + if read_u32(r)? > ALAC_FRAME { + return Ok(Some(TOO_LONG)); + } + break; + } + if size < 8 { + break; + } + child = child.saturating_add(size); + } + } + at = entry_end; + } + Ok(None) +} + +fn read_kind(r: &mut (impl Read + ?Sized)) -> io::Result<[u8; 4]> { + let mut kind = [0; 4]; + r.read_exact(&mut kind)?; + Ok(kind) +} + +fn read_u16(r: &mut (impl Read + ?Sized)) -> io::Result { + let mut b = [0; 2]; + r.read_exact(&mut b)?; + Ok(u16::from_be_bytes(b)) +} + fn read_u32(r: &mut (impl Read + ?Sized)) -> io::Result { let mut b = [0; 4]; r.read_exact(&mut b)?; diff --git a/crates/loclib-audio/src/mp4/tests.rs b/crates/loclib-audio/src/mp4/tests.rs index cd12bb944..d79cd4cb9 100644 --- a/crates/loclib-audio/src/mp4/tests.rs +++ b/crates/loclib-audio/src/mp4/tests.rs @@ -83,6 +83,96 @@ fn sample_tables_claiming_more_than_the_file_holds_are_refused(tc: TestCase) { } } +/// An M4A whose ALAC setup claims any frame length: one longer than [`ALAC_FRAME`] (symphonia +/// sizes its buffers from it, 16 GiB for the 4 billion of the fuzz input in +/// `fuzz/seeds/mp4/alac-frame-length.m4a`) is refused by every way of reading it, and any other +/// passes. +#[hegel::test(test_cases = 100)] +#[hegel::explicit_test_case(frame = 0xfffa_1000u32)] +#[hegel::explicit_test_case(frame = ALAC_FRAME + 1)] +#[hegel::explicit_test_case(frame = ALAC_FRAME)] +fn alac_frames_longer_than_any_encoder_writes_are_refused(tc: TestCase) { + let frame = tc.draw(hegel::one_of!(gs::integers::().max_value(2 * ALAC_FRAME), gs::integers::())); + let mut file = m4a(8_000, &mp4_empty_tables(), &[]); + // The frame length follows the setup's header, version and flags. + let setup = file.windows(4).rposition(|w| w == b"alac").unwrap() + 8; + file[setup..setup + 4].copy_from_slice(&frame.to_be_bytes()); + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join("x.m4a"); + std::fs::write(&path, &file).unwrap(); + + match vet_container(&path) { + Ok(()) => assert!(frame <= ALAC_FRAME, "a frame of {frame} passed"), + Err(Error::Parse { message, .. }) => { + assert!(frame > ALAC_FRAME, "{frame}: {message}"); + assert_eq!(message, TOO_LONG); + for read in read_all(&path) { + assert_eq!(read.as_deref(), Some(TOO_LONG)); + } + } + Err(e) => panic!("{e}"), + } +} + +/// An M4A whose one ALAC entry is in any version of the sample entry (0 to 2 are the ones +/// symphonia reads, each with more fields before its boxes), with `before` 0 (nothing), 1 (a +/// whole box) or 2 (a box claiming less than its header) ahead of its setup, and maybe an entry +/// claiming less than its header ahead of it. The frame is checked only where the walk can trust +/// what came before: a broken box or entry, or a version it doesn't know, leaves the file for +/// symphonia to report. +#[hegel::test(test_cases = 100)] +#[hegel::explicit_test_case(version = 1u16, before = 1u8, broken_entry = false, frame = u32::MAX)] +#[hegel::explicit_test_case(version = 2u16, before = 0u8, broken_entry = false, frame = u32::MAX)] +#[hegel::explicit_test_case(version = 3u16, before = 0u8, broken_entry = false, frame = u32::MAX)] +#[hegel::explicit_test_case(version = 0u16, before = 2u8, broken_entry = false, frame = u32::MAX)] +#[hegel::explicit_test_case(version = 0u16, before = 0u8, broken_entry = true, frame = u32::MAX)] +fn alac_frames_are_found_in_any_entry_symphonia_reads(tc: TestCase) { + let version = tc.draw(gs::integers::().max_value(3)); + let before = tc.draw(gs::integers::().max_value(2)); + let broken_entry = tc.draw(gs::booleans()); + let frame = tc.draw(hegel::one_of!(gs::integers::().max_value(2 * ALAC_FRAME), gs::integers::())); + let extra = match version { + 1 => 16, + 2 => 36, + _ => 0, + }; + let fields = [be(&[0, 1, u32::from(version) << 16, 0, 2 << 16 | 16, 0, 8000 << 16]), vec![0; extra]].concat(); + let ahead = match before { + 0 => vec![], + 1 => mp4_atom(b"free", &[0; 4]), + // A size of 0, with room after it for the walk to read one more box. + _ => [be(&[0]), b"free".to_vec(), vec![0; 8]].concat(), + }; + let setup = mp4_full(b"alac", &be(&[frame, 0, 0, 0, 0, 0])); + let entry = mp4_atom(b"alac", &[fields, ahead, setup].concat()); + let broken = if broken_entry { [be(&[4]), b"junk".to_vec()].concat() } else { vec![] }; + let stsd = mp4_full(b"stsd", &[be(&[1 + u32::from(broken_entry)]), broken, entry].concat()); + let stbl = mp4_atom(b"stbl", &[stsd, mp4_empty_tables()].concat()); + let trak = mp4_atom(b"trak", &mp4_atom(b"mdia", &mp4_atom(b"minf", &stbl))); + let file = [mp4_atom(b"ftyp", b"M4A \0\0\0\0M4A isom"), mp4_atom(b"moov", &trak)].concat(); + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join("x.m4a"); + std::fs::write(&path, &file).unwrap(); + + let checked = version <= 2 && before != 2 && !broken_entry; + match vet_container(&path) { + Ok(()) => assert!(!checked || frame <= ALAC_FRAME, "a frame of {frame} passed"), + Err(Error::Parse { message, .. }) => { + assert!(checked && frame > ALAC_FRAME, "{frame} in version {version}: {message}"); + assert_eq!(message, TOO_LONG); + } + Err(e) => panic!("{e}"), + } +} + +/// The input the mp4 fuzz target crashed on: an ALAC setup claiming 4,294,578,176 samples a frame. +#[test] +fn the_fuzzers_alac_frame_length_is_refused() { + let path = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fuzz/seeds/mp4/alac-frame-length.m4a"); + let Err(Error::Parse { message, .. }) = vet_container(&path) else { panic!("it passed") }; + assert_eq!(message, TOO_LONG); +} + /// Where symphonia reads a sample's size from: `stsz` (one size for every sample, or each /// sample's), and a fragmented MP4's default (`trex`, `tfhd`) or each sample's in a run (`trun`). const SIZES: [&str; 5] = ["stsz", "stsz entry", "trex", "tfhd", "trun"]; diff --git a/docs/adr/0018-signed-out-visitors-come-last.md b/docs/adr/0018-signed-out-visitors-come-last.md new file mode 100644 index 000000000..462fbba01 --- /dev/null +++ b/docs/adr/0018-signed-out-visitors-come-last.md @@ -0,0 +1,24 @@ +# Signed-out visitors come last + +The rule that decides a flag buckets a DID, and a signed-out visitor has none. So a percentage only ever counted accounts, and turning a flag on for everyone showed it to every signed-out visitor in the same save that gave it to the last accounts. Public pages are where that matters. Most people who see an act, party, venue or event page aren't signed in, and crawlers and directory listings see what they see. + +So signed-out visitors are a switch of their own on each flag, and the last one to turn on. `computer.localnetwork.staff.flag` has an optional `signedOut` boolean, off unless staff tick Signed-out visitors on the flag's page. The website refuses it until what's saved has the flag on for every signed-in account (`everyone`, or 100%), and a save that takes the flag below that turns it off again, so the order can't be skipped or left half undone. `everyone` now means every signed-in account. A caller with no DID gets a flag when `enabled && signedOut && (everyone || percentage >= 100)`, and a caller with one is decided as before, whatever `signedOut` says. `getFlags` sends `signedOut` with the other gates, locallibrary applies the same rule when it's signed out, and `flags/vectors.json` has cases for it. + +Ops flags have no setting of their own. A kill switch has to work where there's no account: xrpc routes, the server's background rounds, crawlers and locallibrary signed out all ask with no DID. An ops flag's `signedOut` is on whenever it's on for every signed-in account, `everyone` or 100%, so a kill switch saved at 100% pauses background rounds too. Saving one writes it that way, and a record without the field reads that way. A release flag's record without it reads as off. + +Nothing about a signed-out visitor is kept in their browser, so every signed-out visitor gets the same page, and those pages stay shared-cacheable. + +## Considered options + +- A random id in a first-party cookie, bucketed like a DID, so a share of signed-out browsers could get a flag. The maintainer turned it down: signed-out visitors should only get a feature when it's switched on for them, after everyone signed in has it. It also added a cookie to the privacy page, made signed-out pages private while a percentage ran, and showed crawlers a page some of the time. +- Keeping `everyone` as signed in or not: no new field, but a release flag couldn't reach every account without reaching every visitor in the same save. +- Letting a flag's `showsOn` decide whether signed-out visitors are counted: it's a list for the staff console, and a flag that changes something signed-out visitors meet without naming a kind of page would slip past it. +- The same setting on ops flags: a kill switch turned on for everyone and not for signed-out visitors would leave everything with no account running. + +## Consequences + +- A release flag that was on for everyone before this is off for signed-out visitors until staff tick the setting. +- `spacePages` writes directory listings only once signed-out visitors have it, since a listing sends them to the page. +- The console marks a release flag "Ready to remove" only once signed-out visitors have had it for 30 days too, since deleting a flag gives it to every caller. +- `FLAG_OVERRIDES` forcing a flag on turns it on for signed-out visitors as well. +- A feature can't be tried on a share of signed-out visitors. One that needs that would need a new decision. diff --git a/docs/adr/0019-english-stays-unprefixed-and-records-carry-their-language.md b/docs/adr/0019-english-stays-unprefixed-and-records-carry-their-language.md new file mode 100644 index 000000000..b4f68330c --- /dev/null +++ b/docs/adr/0019-english-stays-unprefixed-and-records-carry-their-language.md @@ -0,0 +1,28 @@ +# English stays unprefixed, and records carry their language + +Local Network launches in English, and a second language comes when a translator commits to keeping it up. Most of what translation needs can wait until then. A few choices can't, because once people have links, records and accounts, changing them means redirects, migrations or rewriting what's in people's repos. Those are made now. + +The website's words live in message catalogs (`apps/web/messages/`) that pages reach through Paraglide JS, and locallibrary's Rust code will use Fluent when its turn comes. Besides English there's `en-XA`, a pseudo-locale generated from the English: every letter accented, each line about a third longer, each message in brackets. Viewed in en-XA, text that skipped the catalog stays plain English and a layout that can't stretch clips, long before a translator sees either. + +English pages keep their URLs, with no language prefix, for good. Each later language gets a prefix of its own (`/de/act/...`), so no URL anyone has shared ever changes, and the move to `/act//` in [0016](0016-names-repeat-keys-and-handles-identify.md) happens once. Until then the locale comes from a cookie, `ln_locale`. + +Every record that holds prose a person wrote (a bio, a description, a message, a note) has an optional `langs` field, shaped as `app.bsky.feed.post` has it: up to three BCP-47 language tags. The website fills it in from the writer's locale, which is `en` today; en-XA counts as English. With it, a reader in another language can be offered a translation and a list can filter by language. Without it, every app reading the record would have to guess the language from the text. Records hold no English the app wrote, either. The audit entry's `summary` is rendered from its action and fields when it's shown, so each reader gets it in their own language. + +The language preference lives on the account (`account.locale`) as well as in the cookie. Emails and DMs go to each recipient in their language, sent outside any request of theirs that could carry a cookie, so for someone signed in the account decides and the cookie only covers visitors. The column comes with the second language, since until then it would hold `en` for everyone. + +A page's name part is only decoration ([0016](0016-names-repeat-keys-and-handles-identify.md)), so a name written in another script keeps that script in the URL instead of being transliterated. Transliteration differs by language and loses what the name said, and the key already finds the page. Place names are stored as the place itself writes them, in its own language, with the country as an ISO 3166 code that each reader's language names. Community location objects (LOC-727) keep the same rule for their address fields, and no record stores a translated place name. + +locallibrary's sidecar takes the client's locale when it starts (`initialize`), and its schema marks each field that holds text for people to read, so a desktop app shows those as they come and never compares them. + +New CSS uses logical directions (`ms-`, `pe-`, `start-` rather than `ml-`, `pr-`, `left-`), so a right-to-left language doesn't need a pass over every layout. Every test runner pins its locale and time zone, en-US and UTC, so a date or a number reads the same on a laptop as in CI. + +## Considered options + +- A prefix for English too (`/en/...`): every link already shared would become a redirect, for the one language every page is written in. +- A subdomain per language (`de.localnetwork.computer`): another origin for the session cookie, the OAuth redirect URLs and the CSP to cover, for what a prefix already does. +- The browser's `Accept-Language` from the start: with one language there's nothing to choose. It can set a first visit's language when a second one arrives. +- Keeping the audit summary's English and translating it when shown: prose the app wrote can't be translated reliably, and the action and fields already hold everything it says. + +## Consequences + +Each message ships its en-XA text to every visitor next to the English, a few bytes a message. Once most of the site's text is in the catalog, a production build can leave en-XA out. The locale cookie is set only when someone picks a language. Until then they get the English page, which caches share like any signed-out page ([0018](0018-signed-out-visitors-come-last.md)). `src/hooks.server.ts` varies an answer on Cookie only when the request carries the locale cookie, and never a public immutable one (OG cards, avatars, recordings). Until the rest of the text moves to the catalog, en-XA shows it in plain English, which is what en-XA is for. diff --git a/docs/adr/0020-inactive-accounts-are-asked-of-their-pds.md b/docs/adr/0020-inactive-accounts-are-asked-of-their-pds.md new file mode 100644 index 000000000..9b958c1b1 --- /dev/null +++ b/docs/adr/0020-inactive-accounts-are-asked-of-their-pds.md @@ -0,0 +1,17 @@ +# Inactive accounts are asked of their PDS when a page needs to know + +An account that's deactivated, taken down, suspended or deleted shouldn't stay on the site: its profile, its listing in Find DJs, the sets the charts count, its shows. The website reads public records only through HappyView, and HappyView already follows Jetstream's `account` events: at the version production runs (3.0.0-beta.14) it removes the records of an account that's deleted, taken down or suspended and keeps a tombstone that refuses later copies ([`account_event` in src/ingest.rs](https://github.com/gamesgamesgamesgamesgames/happyview/blob/v3.0.0-beta.14/src/ingest.rs), [event logs guide](https://github.com/gamesgamesgamesgamesgames/happyview/blob/v3.0.0-beta.14/packages/docs/content/docs/guides/event-logs.md)). It keeps a deactivated account's records, though, and only logs the event, and no script or query can see an account's status. When a taken-down account comes back, its records return only with a new backfill. + +So the app asks the account's PDS, the one its DID document names, with `com.atproto.sync.getRepoStatus`. The DID resolver caches documents, and the PDS an account just moved away from answers `RepoNotFound` or deactivated, so an inactive answer is checked against a freshly fetched document and, when that names another PDS, asked again of that one. `AccountStatuses` (`src/lib/server/atproto/account-status.ts`) keeps each answer in memory for half an hour. A profile or set page asks for its one account: an inactive account's page answers 404 saying the account isn't active, whatever the reason, and a deleted one's 410. An act's page, its mix pages and its press kits ask for each of its managers and hide the same way once none of them is active: 410 when every manager was deleted, and 404 otherwise, since a manager who only deactivated can come back. An act with any active manager stays up. For Find DJs, the charts, artist pages, linked sets and show listings, it checks every account the directory reads (the managers of the root's projects and the DJs staff list), eight at a time, and passes the deactivated, taken-down and suspended ones to those queries as an `inactive` param, which takes at most 100. The queries leave out those accounts' records. Deleted accounts aren't sent, since HappyView already dropped their records. No page waits for that check: a page gets the last list while a fresh one is made in the background, so after a restart inactive accounts can show until the first check finishes, usually within seconds. + +A PDS that can't be asked leaves the account as it was last seen, or active if it was never seen, and the failure is logged: the site fails open. A deleted account is asked again every half hour like any other, since right after a move between PDSes an account can look deleted. HappyView's tombstone keeps a really deleted account's records out, so no table is kept. When an account that was taken down or suspended turns up active again, the app has HappyView re-read its records. + +The cost is one request per directory account every half hour, and only while people look at the pages, plus a fresh DID document for each account found inactive. Opening a profile or set page asks that account's PDS too, an act's pages ask each of its managers' (ten at most), and each answer is kept for 30 minutes. A deactivated account leaves the lists, and comes back, up to half an hour late. + +## Considered options + +- Jetstream's `account` events through HappyView: they already handle deletions and takedowns, but HappyView keeps a deactivated account's records and offers no hook or table that tells the app. HappyView is a hosted service we don't develop, so changing that isn't ours to do. +- A subscriber of our own to Jetstream's or the relay's account events: changes would show at once, but it's a connection to keep up, a cursor to store, and a table of statuses that's cheap to fetch again. +- Asking a relay's `getRepoStatus` instead of each PDS: one host for every account and it sees a relay's own takedowns, but it ties the site to Bluesky's relay, and the dev network and the integration tests have none. +- Filtering after each query instead of passing `inactive` in: the charts and artist pages count plays across accounts, so they can't be fixed up afterwards, and Find DJs would page wrong. +- A table of deleted accounts: HappyView's tombstone already keeps their records out, and a deleted account's PDS keeps answering `RepoNotFound`. diff --git a/docs/research/feature-flag-platforms.md b/docs/research/feature-flag-platforms.md index d24852147..2ca7e97c2 100644 --- a/docs/research/feature-flag-platforms.md +++ b/docs/research/feature-flag-platforms.md @@ -16,7 +16,7 @@ Every platform in the set evaluates a flag the same way: it checks for a kill or | Reusable audiences | Segments, cohorts, saved groups, often rule-based | Named groups of up to 5000 DIDs | No rule-based membership | No | | Exclusions | Segment `excluded` lists (LD), "none of" (Statsig), `NONE` rules (Flagsmith) | None: any matching gate turns a flag on | Can't pull one account out of a rollout | Low | | Percentage rollout | Hash of salt plus stable id into 100 to 100,000 buckets | `sha256(key + did)`, first 4 bytes, mod 100, which ADR 0006 has locallibrary apply too | Coarse 1% steps, no re-salt | No | -| Signed-out visitors | Random device keys (LD, PostHog), random fallback (Unleash), bucket on salt alone (Statsig) | Only `everyone` applies | No partial rollout to signed-out visitors | Low, by design | +| Signed-out visitors | Random device keys (LD, PostHog), random fallback (Unleash), bucket on salt alone (Statsig) | A separate switch per flag, on only once every account has it | No partial rollout to signed-out visitors | Low, by design | | Prerequisites | Flag-on-flag dependencies in LD, Statsig, FME, ConfigCat, PostHog, GrowthBook, Unleash | None | None | No | | Kill switch | A dedicated off state that keeps targeting (LD off variation, FME kill, flagd `DISABLED`, GOFF `disable`) | `enabled: false` on the record, which keeps groups, accounts and percentage | None | Done | | Server evaluation | Full ruleset in memory, no network per check | Snapshot from SQLite, reloaded after each write or sync | None | No | @@ -73,7 +73,7 @@ The properties that matter are all there. The flag key acts as a per-flag salt, Shared vectors guard against a failure the platforms have run into, where SDKs in different languages drift apart. flagd changed its hashing in v0.18.0 and now requires flagd and every provider to upgrade together ([flagd fractional](https://flagd.dev/reference/custom-operations/fractional-operation/)). GrowthBook had to ship a second hash version after v1 "had a flaw that caused bias when running experiments in parallel" and pins UTF-16 code units to keep SDKs consistent ([GrowthBook SDK spec](https://docs.growthbook.io/lib/build-your-own)). Flipt's own docs describe its hash input differently from what its v2.14.1 code does ([Flipt concepts](https://docs.flipt.io/v2/concepts) vs [evaluation.go](https://github.com/flipt-io/flipt/blob/v2.14.1/internal/server/evaluation/evaluation.go#L240-L280)). One vectors file that every evaluator must pass is the cheap version of OpenFeature's provider conformance kit. -Two hashing features are missing, and neither matters yet. LaunchDarkly, Statsig and Flagsmith keep a salt separate from the flag key, so a flag can be renamed without reshuffling anyone, and an operator can re-salt on purpose to reshuffle: "To reshuffle all users, you must resalt the gate" ([Statsig FAQ](https://docs.statsig.com/faq/); [LD salt support article](https://support.launchdarkly.com/hc/en-us/articles/36961986486811-How-to-update-the-flag-salt); [Flagsmith models.py](https://github.com/Flagsmith/flagsmith/blob/v2.290.0/api/features/models.py#L774-L781)). In Local Network, renaming a key means a new catalog file and a fresh rollout anyway, so a separate salt would buy nothing. The second is signed-out visitors. LaunchDarkly gives them a random key kept in local storage, PostHog buckets by `$device_id`, Unleash falls back to a random number with no stickiness, and Statsig buckets empty IDs on the salt alone, so every anonymous visitor gets the same answer ([LD anonymous contexts](https://launchdarkly.com/docs/home/flags/anonymous-contexts); [PostHog device bucketing](https://posthog.com/docs/feature-flags/device-bucketing); [Unleash stickiness](https://docs.getunleash.io/reference/stickiness); [Statsig evaluation](https://docs.statsig.com/sdks/how-evaluation-works)). Local Network leaves signed-out visitors out of percentages ([flags/README.md](https://github.com/cutenode/localnetwork/blob/2f9d6c93a3b8dbb68fae3b9806ab85af26398ea5/flags/README.md#L17-L24)), which avoids PostHog's documented problem of a user's bucket changing after sign-in ([PostHog creating flags](https://posthog.com/docs/feature-flags/creating-feature-flags)). That's the right default for a site where new features are aimed at signed-in DJs. +Two hashing features are missing, and neither matters yet. LaunchDarkly, Statsig and Flagsmith keep a salt separate from the flag key, so a flag can be renamed without reshuffling anyone, and an operator can re-salt on purpose to reshuffle: "To reshuffle all users, you must resalt the gate" ([Statsig FAQ](https://docs.statsig.com/faq/); [LD salt support article](https://support.launchdarkly.com/hc/en-us/articles/36961986486811-How-to-update-the-flag-salt); [Flagsmith models.py](https://github.com/Flagsmith/flagsmith/blob/v2.290.0/api/features/models.py#L774-L781)). In Local Network, renaming a key means a new catalog file and a fresh rollout anyway, so a separate salt would buy nothing. The second is signed-out visitors. LaunchDarkly gives them a random key kept in local storage, PostHog buckets by `$device_id`, Unleash falls back to a random number with no stickiness, and Statsig buckets empty IDs on the salt alone, so every anonymous visitor gets the same answer ([LD anonymous contexts](https://launchdarkly.com/docs/home/flags/anonymous-contexts); [PostHog device bucketing](https://posthog.com/docs/feature-flags/device-bucketing); [Unleash stickiness](https://docs.getunleash.io/reference/stickiness); [Statsig evaluation](https://docs.statsig.com/sdks/how-evaluation-works)). Local Network leaves signed-out visitors out of percentages ([flags/README.md](https://github.com/cutenode/localnetwork/blob/2f9d6c93a3b8dbb68fae3b9806ab85af26398ea5/flags/README.md#L17-L24)), which avoids PostHog's documented problem of a user's bucket changing after sign-in ([PostHog creating flags](https://posthog.com/docs/feature-flags/creating-feature-flags)). That's the right default for a site where new features are aimed at signed-in DJs. Public pages kept it that way on purpose: [ADR 0018](../adr/0018-signed-out-visitors-come-last.md) gives each flag a separate switch for signed-out visitors, which can only go on once every account has the flag. The time-based rollout tools are where the paid tiers live. LaunchDarkly's progressive rollouts ramp a percentage on a schedule, and its guarded rollouts watch metrics and roll back automatically on a significant regression, which needs Enterprise plus the Guardian add-on ([LD progressive](https://launchdarkly.com/docs/home/releases/progressive-rollouts); [LD guarded](https://launchdarkly.com/docs/home/releases/guarded-rollouts)). Statsig has release pipelines and rollout alerts ([Statsig release pipeline](https://docs.statsig.com/release-pipeline); [rollout alerts](https://docs.statsig.com/metrics/rollout-alerts)). PostHog schedules changes on cron ([PostHog scheduled changes](https://posthog.com/docs/feature-flags/scheduled-flag-changes)), and GO Feature Flag offers `scheduledRollout` and `progressiveRollout` for free ([GOFF internal_flag.go](https://github.com/thomaspoignant/go-feature-flag/blob/v1.58.1/modules/core/flag/internal_flag.go#L209-L262)). Guarded rollouts need a metrics pipeline Local Network doesn't have, and scheduled ramps save a few clicks spread over a week. Neither is worth building. @@ -123,7 +123,7 @@ Local Network had the hard half from the start. Deleting a catalog file breaks t Each `flags/catalog/.json` has a `type`: `release`, `experiment`, `ops` or `permission`. Release and experiment flags must have a `removeBy` date (YYYY-MM-DD), and the other types can't have one. A unit test fails once a flag is past its `removeBy`, naming the flag. `parityCanary` is `ops`. -The `/admin/flags` list marks a flag "Ready to remove" when it's enabled and either on for everyone or at 100%, and its record's `updatedAt` is 30 or more days old. That's PostHog's definition, worked out from fields already stored. Any saved change resets `updatedAt`, so editing a fully rolled-out flag starts its 30 days again. +The `/admin/flags` list marks a release flag "Ready to remove" when it's enabled, on for every account (everyone or 100%) and for signed-out visitors, and its record's `updatedAt` is 30 or more days old. That's PostHog's definition with signed-out visitors added, since deleting the flag gives it to them too, worked out from fields already stored. Any saved change resets `updatedAt`, so editing a fully rolled-out flag starts its 30 days again. Evaluation counts, the signal Unleash and LaunchDarkly lean on, would be useless here: the server hook evaluates every catalog flag on every request ([hooks.server.ts](https://github.com/cutenode/localnetwork/blob/2f9d6c93a3b8dbb68fae3b9806ab85af26398ea5/apps/web/src/hooks.server.ts#L103)), so every flag would always look in use. Exposure events and experiments, which LaunchDarkly, Statsig, FME, PostHog and GrowthBook build on top of evaluation logs ([PostHog exposures](https://posthog.com/docs/experiments/exposures); [GrowthBook results](https://docs.growthbook.io/app/experiment-results)), have no use here without an analytics pipeline, and the glossary's rollout-only scope rules them out anyway. @@ -141,18 +141,18 @@ Staff holding the `flags` grant can preview a flag from `/admin/flags/`, tu The ranking weighs how likely each gap is to bite against what it costs to close. Rows 1 and 3 to 6 are done. Row 2 is open. Rows 7 to 10 are left as designed. -| # | Gap | Status | When it matters | Fix | -| --- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | ---------------------------------------------- | ---------------------------------------------------------------------------------------------------- | -| 1 | `flags/**` was in neither the `web` nor the `locallibrary` CI path filter, so a PR that only touched the catalog or `vectors.json` ran no checks ([ci.yml web](https://github.com/cutenode/localnetwork/blob/2f9d6c93a3b8dbb68fae3b9806ab85af26398ea5/.github/workflows/ci.yml#L177-L199); [ci.yml locallibrary](https://github.com/cutenode/localnetwork/blob/2f9d6c93a3b8dbb68fae3b9806ab85af26398ea5/.github/workflows/ci.yml#L107-L124)). PR #456 promised this as a follow-up | Done | Now | `flags/**` is in both filters of `.github/workflows/ci.yml` | -| 2 | The locallibrary client isn't merged; main has ADR 0006 and the website endpoint, but no Rust code reads flags | Open | Before any locallibrary feature uses a flag | Deploy the website side, pass one live sign-in with a dev build, merge the client | -| 3 | Turning a flag off meant clearing all its targeting | Done | Before the first real rollout | Optional `enabled` on `staff.flag`, checked first, with new vectors and an "Off for everyone" switch | -| 4 | No developer or tester override | Done | Before the first real rollout | `FLAG_OVERRIDES` for development and tests; a signed preview cookie for staff | -| 5 | No type or removal date in the catalog, so nothing failed when a flag outlived its purpose | Done | Past about five flags | `type` and `removeBy` in the schema, plus a time-bomb test | -| 6 | No "fully rolled out" signal in the admin list | Done | Past about five flags | "Ready to remove" for enabled flags at `everyone` or 100% for 30+ days | -| 7 | Every catalog key reaches every browser; public gates are readable through `getFlags` | Left as designed | Only if a key name spoils a launch | Pick neutral key names | -| 8 | No per-account exclusion inside a rollout | Left as designed | If one account in a partial rollout hits a bug | A `notDids` list, only if it comes up | -| 9 | Signed-out visitors can't be in a percentage | Left as designed | Only for a rollout aimed at anonymous visitors | None | -| 10 | 1% steps, flag key as salt, no re-salt | Left as designed | Not at this scale | None | +| # | Gap | Status | When it matters | Fix | +| --- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | +| 1 | `flags/**` was in neither the `web` nor the `locallibrary` CI path filter, so a PR that only touched the catalog or `vectors.json` ran no checks ([ci.yml web](https://github.com/cutenode/localnetwork/blob/2f9d6c93a3b8dbb68fae3b9806ab85af26398ea5/.github/workflows/ci.yml#L177-L199); [ci.yml locallibrary](https://github.com/cutenode/localnetwork/blob/2f9d6c93a3b8dbb68fae3b9806ab85af26398ea5/.github/workflows/ci.yml#L107-L124)). PR #456 promised this as a follow-up | Done | Now | `flags/**` is in both filters of `.github/workflows/ci.yml` | +| 2 | The locallibrary client isn't merged; main has ADR 0006 and the website endpoint, but no Rust code reads flags | Open | Before any locallibrary feature uses a flag | Deploy the website side, pass one live sign-in with a dev build, merge the client | +| 3 | Turning a flag off meant clearing all its targeting | Done | Before the first real rollout | Optional `enabled` on `staff.flag`, checked first, with new vectors and an "Off for everyone" switch | +| 4 | No developer or tester override | Done | Before the first real rollout | `FLAG_OVERRIDES` for development and tests; a signed preview cookie for staff | +| 5 | No type or removal date in the catalog, so nothing failed when a flag outlived its purpose | Done | Past about five flags | `type` and `removeBy` in the schema, plus a time-bomb test | +| 6 | No "fully rolled out" signal in the admin list | Done | Past about five flags | "Ready to remove" for enabled release flags at `everyone` or 100%, signed-out visitors included, for 30+ days | +| 7 | Every catalog key reaches every browser; public gates are readable through `getFlags` | Left as designed | Only if a key name spoils a launch | Pick neutral key names | +| 8 | No per-account exclusion inside a rollout | Left as designed | If one account in a partial rollout hits a bug | A `notDids` list, only if it comes up | +| 9 | Signed-out visitors can't be in a percentage | Left as designed | Only for a rollout aimed at a share of anonymous visitors | None: signed-out visitors get a flag last, all at once ([ADR 0018](../adr/0018-signed-out-visitors-come-last.md)) | +| 10 | 1% steps, flag key as salt, no re-salt | Left as designed | Not at this scale | None | One smaller problem is also open. PR #456 notes that the pinned PDS doesn't enforce a space type's `collections`, so whether the production PDS accepts the staff collections hasn't been tested. If it refused them, saving a flag would fail and every flag would stay off ([PR #456](https://github.com/cutenode/localnetwork/pull/456)). That one belongs with row 2's live check, since the website deploy is a precondition anyway. diff --git a/flags/README.md b/flags/README.md index 11bfe6f12..ef8582827 100644 --- a/flags/README.md +++ b/flags/README.md @@ -6,7 +6,9 @@ Every flag has a `type`, `release` or `ops`. A `release` flag is meant to go, so A flag nobody has saved reads as off, so name a flag for the state you can switch it to. A kill switch, for something that already works, is named for the paused state, like `pauseRecordingStream`, and is `ops`: the deploy that adds it changes nothing, and turning it on stops the feature. Something that's dark today and should stay switchable after it ships, like inbox email, is named for the on state and is `ops` too, so it has no `removeBy`. Use `release` only for flags that go once the rollout is done. -Who a flag is on for lives in the staff space and is set at `/admin/flags`, not here. Every flag starts off. The list there marks a flag "Ready to remove" once it's been on for everyone, or every account, for 30 days. +A flag can list the kinds of page it changes in `showsOn`: `home`, `profile`, `act`, `party`, `venue`, `event`, `set`, `mix` or `pressKit`, or `global` for every page. An act's page is still `/projects/` until acts move. The flag's page in the staff console lists them under Shows on. Leave it out when the flag changes no public page, like a kill switch for the token exchange, something in the dashboard, or anything only signed-in accounts see. + +Who a flag is on for lives in the staff space and is set at `/admin/flags`, not here. Every flag starts off. The list there marks a release flag "Ready to remove" once every account and signed-out visitors have had it for 30 days, and its page shows when it should be gone by. ```jsonc { @@ -14,11 +16,12 @@ Who a flag is on for lives in the staff space and is set at `/admin/flags`, not "key": "newPlanner", "description": "What the flag gates, for the staff console.", "type": "release", - "removeBy": "2027-03-01" + "removeBy": "2027-03-01", + "showsOn": ["profile"] } ``` -Check a flag on the website with `locals.flags.newPlanner` on the server or `data.flags?.newPlanner` in a page. An xrpc route gets the flags a signed-out visitor does, since the website never reads the sign-in cookie there: a flag on or off for everyone works, and targeting and percentages don't. A route that has checked a service token can call `app.flags.evaluate(did)` with that token's DID to get them. +Check a flag on the website with `locals.flags.newPlanner` on the server or `data.flags?.newPlanner` in a page. An xrpc route gets the flags a signed-out visitor does, since the website never reads the sign-in cookie there: targeting and percentages don't reach it. A route that has checked a service token can call `app.flags.evaluate(did)` with that token's DID to get them. In locallibrary, use `locallibrary::flags::check(root, flags::keys::NEW_PLANNER)`. A flag in locallibrary is for rolling something out. Anything that has to be enforced belongs on the server, since anyone can change what's on their own computer. @@ -26,12 +29,15 @@ In locallibrary, use `locallibrary::flags::check(root, flags::keys::NEW_PLANNER) ```text bucket(key, did) = the first 4 bytes of sha256(key + did), big-endian, mod 100 -on = enabled && (everyone || targeted || (did is known && bucket(key, did) < percentage)) +with a DID: on = enabled && (everyone || targeted || bucket(key, did) < percentage) +with no DID: on = enabled && signedOut && (everyone || percentage >= 100) ``` -`enabled` is false once someone turns the flag off for everyone, which keeps the other gates for when it's back on. A record that doesn't say is enabled. `targeted` means the account is one of the flag's accounts or in one of its groups. Only the website can know that, since those lists are private; it says so through `computer.localnetwork.flags.getFlags`. Raising a percentage only adds accounts. Signed-out visitors have no DID, so they only get flags on for everyone. +`enabled` is false once someone turns the flag off for everyone, which keeps the other gates for when it's back on. A record that doesn't say is enabled. `everyone` means every signed-in account. `targeted` means the account is one of the flag's accounts or in one of its groups. Only the website can know that, since those lists are private; it says so through `computer.localnetwork.flags.getFlags`. Raising a percentage only adds accounts. + +A caller with no DID comes last: a signed-out visitor, an xrpc call, background work on the server, or locallibrary signed out. A release flag is on for them only once staff tick Signed-out visitors on its page, which sets `signedOut`, and only while every account has the flag. The console refuses it before then, and a save that takes the flag below every account turns it off again. A record that doesn't say has it off. An ops flag has no setting of its own: its `signedOut` is on whenever every account has it (`everyone` or 100%), so a kill switch turned on for every account also stops what runs with no account. There's no percentage of signed-out visitors and no cookie for them, so signed-out pages stay shared-cacheable. [ADR 0018](../docs/adr/0018-signed-out-visitors-come-last.md) covers why. -`vectors.json` holds computed answers. The website's and locallibrary's tests both run them, so the two can't come to disagree. A case without `enabled` is enabled. If a case has to change, the rule changed, and accounts will move in or out of every rollout. +`vectors.json` holds computed answers. The website's and locallibrary's tests both run them, so the two can't come to disagree. A case without `enabled` is enabled, and one without `signedOut` is a flag signed-out visitors don't have. If a case has to change, the rule changed, and accounts will move in or out of every rollout. ## Trying a flag diff --git a/flags/catalog/inboxDm.json b/flags/catalog/inboxDm.json new file mode 100644 index 000000000..6ed7acf64 --- /dev/null +++ b/flags/catalog/inboxDm.json @@ -0,0 +1,6 @@ +{ + "$schema": "../flag.schema.json", + "key": "inboxDm", + "description": "Inbox items as Bluesky DMs from the root account. Off for an account, its settings don't offer DMs and the outbox skips what would have gone to it, which stays in the site inbox. Roll it out slowly: a burst of DMs could get the root rate limited or reported.", + "type": "ops" +} diff --git a/flags/catalog/inboxEmail.json b/flags/catalog/inboxEmail.json new file mode 100644 index 000000000..7e8ae14ab --- /dev/null +++ b/flags/catalog/inboxEmail.json @@ -0,0 +1,6 @@ +{ + "$schema": "../flag.schema.json", + "key": "inboxEmail", + "description": "Inbox email through Resend. Off for an account, its settings don't offer email and the outbox skips what would have gone to it, which stays in the site inbox. Turning it back on sends only what comes after.", + "type": "ops" +} diff --git a/flags/catalog/pauseBackfills.json b/flags/catalog/pauseBackfills.json new file mode 100644 index 000000000..4c2bec1ef --- /dev/null +++ b/flags/catalog/pauseBackfills.json @@ -0,0 +1,6 @@ +{ + "$schema": "../flag.schema.json", + "key": "pauseBackfills", + "description": "Stops the site asking HappyView to re-read repos: refreshes, the set picker, requestIndex and re-reads after a write carry on with what HappyView has. The root's performers are still re-read at start. Turn it on for everyone.", + "type": "ops" +} diff --git a/flags/catalog/pauseOgCards.json b/flags/catalog/pauseOgCards.json new file mode 100644 index 000000000..8feefe53f --- /dev/null +++ b/flags/catalog/pauseOgCards.json @@ -0,0 +1,7 @@ +{ + "$schema": "../flag.schema.json", + "key": "pauseOgCards", + "description": "Stops drawing link-preview cards for performers, mixes, press kits and artists: pages point their preview at the site's card, and a card not already kept in memory redirects there. Turn it on for everyone: crawlers are signed out.", + "type": "ops", + "showsOn": ["profile", "act", "mix", "pressKit"] +} diff --git a/flags/catalog/pauseReconcilers.json b/flags/catalog/pauseReconcilers.json new file mode 100644 index 000000000..ee295bcac --- /dev/null +++ b/flags/catalog/pauseReconcilers.json @@ -0,0 +1,6 @@ +{ + "$schema": "../flag.schema.json", + "key": "pauseReconcilers", + "description": "Stops the rounds that write to the root's repo to fix drift (manager, staff and shared spaces, listings and calendar copies), at start and every round after. Turn it on for everyone. On a fresh database, the first rounds at start run before this is read.", + "type": "ops" +} diff --git a/flags/catalog/pauseRecordingStream.json b/flags/catalog/pauseRecordingStream.json new file mode 100644 index 000000000..3589f6ea5 --- /dev/null +++ b/flags/catalog/pauseRecordingStream.json @@ -0,0 +1,7 @@ +{ + "$schema": "../flag.schema.json", + "key": "pauseRecordingStream", + "description": "Stops the site streaming recordings from DJs' servers: the audio route answers 503 without reading anything, and set and mix players play the links instead. plyr.fm recordings still play. Turn it on for everyone: most listeners are signed out.", + "type": "ops", + "showsOn": ["set", "mix"] +} diff --git a/flags/catalog/pauseRequestIndex.json b/flags/catalog/pauseRequestIndex.json new file mode 100644 index 000000000..8365b7589 --- /dev/null +++ b/flags/catalog/pauseRequestIndex.json @@ -0,0 +1,6 @@ +{ + "$schema": "../flag.schema.json", + "key": "pauseRequestIndex", + "description": "Stops locallibrary asking HappyView to re-read an account's records: requestIndex answers that nothing was indexed, as it does without a HappyView API key. Turn it on for everyone: the request comes signed out.", + "type": "ops" +} diff --git a/flags/catalog/peopleSpaces.json b/flags/catalog/peopleSpaces.json index f17233d9f..e3ae06c2e 100644 --- a/flags/catalog/peopleSpaces.json +++ b/flags/catalog/peopleSpaces.json @@ -3,5 +3,6 @@ "key": "peopleSpaces", "description": "The member pages of acts, parties and venues: inviting people, invite links, asking to join and people lists. Off, they answer 404.", "type": "release", - "removeBy": "2027-02-12" + "removeBy": "2027-02-12", + "showsOn": ["act", "party", "venue"] } diff --git a/flags/catalog/socialHome.json b/flags/catalog/socialHome.json index ffb2d2c60..e0b27d23f 100644 --- a/flags/catalog/socialHome.json +++ b/flags/catalog/socialHome.json @@ -3,5 +3,6 @@ "key": "socialHome", "description": "The home page built around events near you and your network, in place of the one for booking DJs. Turn it on with event pages and RSVPs.", "type": "release", - "removeBy": "2027-02-12" + "removeBy": "2027-02-12", + "showsOn": ["home"] } diff --git a/flags/catalog/spacePages.json b/flags/catalog/spacePages.json index 15079b1de..40ba1f309 100644 --- a/flags/catalog/spacePages.json +++ b/flags/catalog/spacePages.json @@ -1,7 +1,8 @@ { "$schema": "../flag.schema.json", "key": "spacePages", - "description": "The public act, party, venue and event pages. Off, they answer 404, and no listing is written until it's on for everyone, since a listing points at a public page. Signed-out visitors only see it once it's on for everyone.", + "description": "The public act, party, venue and event pages. Off, they answer 404, and no listing is written until it's on for signed-out visitors, since a listing points at a public page.", "type": "release", - "removeBy": "2027-02-12" + "removeBy": "2027-02-12", + "showsOn": ["act", "party", "venue", "event"] } diff --git a/flags/catalog/userinputReports.json b/flags/catalog/userinputReports.json new file mode 100644 index 000000000..7d8f75c3d --- /dev/null +++ b/flags/catalog/userinputReports.json @@ -0,0 +1,6 @@ +{ + "$schema": "../flag.schema.json", + "key": "userinputReports", + "description": "Bug reports posted to userinput.app from the reporter's own account, once USERINPUT_SPACE is set. Off for an account, Report a bug opens GitHub's issue form instead. Turn it off for everyone to send all reports to GitHub while userinput.app is down.", + "type": "ops" +} diff --git a/flags/flag.schema.json b/flags/flag.schema.json index 8bebec29a..d078b6388 100644 --- a/flags/flag.schema.json +++ b/flags/flag.schema.json @@ -20,6 +20,15 @@ "maxLength": 300, "description": "What the flag gates, for the staff console." }, + "showsOn": { + "description": "The kinds of page the flag changes, or global for every page. act is a /projects page until acts move. The staff console lists them as Shows on.", + "minItems": 1, + "type": "array", + "items": { + "type": "string", + "enum": ["global", "home", "profile", "act", "party", "venue", "event", "set", "mix", "pressKit"] + } + }, "type": { "type": "string", "const": "release", @@ -53,6 +62,15 @@ "maxLength": 300, "description": "What the flag gates, for the staff console." }, + "showsOn": { + "description": "The kinds of page the flag changes, or global for every page. act is a /projects page until acts move. The staff console lists them as Shows on.", + "minItems": 1, + "type": "array", + "items": { + "type": "string", + "enum": ["global", "home", "profile", "act", "party", "venue", "event", "set", "mix", "pressKit"] + } + }, "type": { "type": "string", "const": "ops", diff --git a/flags/vectors.json b/flags/vectors.json index df1685f4e..a18495d64 100644 --- a/flags/vectors.json +++ b/flags/vectors.json @@ -1,5 +1,5 @@ { - "$comment": "Computed answers both the website and locallibrary test themselves against. A case without `enabled` is a record that doesn't say, which counts as true. Add cases freely; changing one means the rule changed, and every account can move.", + "$comment": "Computed answers both the website and locallibrary test themselves against. `did` is null for a caller with no account, like a signed-out visitor. A case without `enabled` is a record that doesn't say, which counts as true. A case without `signedOut` is a flag signed-out visitors don't have. Add cases freely; changing one means the rule changed, and every account can move.", "cases": [ { "key": "parityCanary", @@ -139,6 +139,7 @@ { "key": "parityCanary", "did": null, + "signedOut": true, "everyone": true, "targeted": false, "percentage": 0, @@ -292,6 +293,7 @@ { "key": "newPlanner", "did": null, + "signedOut": true, "everyone": true, "targeted": false, "percentage": 0, @@ -445,6 +447,7 @@ { "key": "a", "did": null, + "signedOut": true, "everyone": true, "targeted": false, "percentage": 0, @@ -598,6 +601,7 @@ { "key": "mixUploads2", "did": null, + "signedOut": true, "everyone": true, "targeted": false, "percentage": 0, @@ -697,6 +701,7 @@ "key": "parityCanary", "did": null, "enabled": true, + "signedOut": true, "everyone": true, "targeted": false, "percentage": 0, @@ -742,6 +747,97 @@ "percentage": 100, "bucket": null, "on": false + }, + { + "key": "parityCanary", + "did": null, + "signedOut": false, + "everyone": true, + "targeted": false, + "percentage": 0, + "bucket": null, + "on": false + }, + { + "key": "parityCanary", + "did": null, + "signedOut": true, + "everyone": false, + "targeted": false, + "percentage": 100, + "bucket": null, + "on": true + }, + { + "key": "parityCanary", + "did": null, + "signedOut": true, + "everyone": false, + "targeted": false, + "percentage": 99, + "bucket": null, + "on": false + }, + { + "key": "parityCanary", + "did": null, + "signedOut": true, + "everyone": false, + "targeted": true, + "percentage": 0, + "bucket": null, + "on": false + }, + { + "key": "parityCanary", + "did": null, + "enabled": false, + "signedOut": true, + "everyone": true, + "targeted": false, + "percentage": 100, + "bucket": null, + "on": false + }, + { + "key": "parityCanary", + "did": "did:plc:z72i7hdynmk6r22z27h6tvur", + "signedOut": true, + "everyone": false, + "targeted": false, + "percentage": 48, + "bucket": 48, + "on": false + }, + { + "key": "parityCanary", + "did": "did:plc:z72i7hdynmk6r22z27h6tvur", + "signedOut": true, + "everyone": false, + "targeted": false, + "percentage": 49, + "bucket": 48, + "on": true + }, + { + "key": "parityCanary", + "did": "did:plc:z72i7hdynmk6r22z27h6tvur", + "signedOut": true, + "everyone": false, + "targeted": false, + "percentage": 0, + "bucket": 48, + "on": false + }, + { + "key": "parityCanary", + "did": "did:plc:z72i7hdynmk6r22z27h6tvur", + "signedOut": false, + "everyone": true, + "targeted": false, + "percentage": 0, + "bucket": 48, + "on": true } ] } diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index dc3ece7eb..4c1639ece 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -939,7 +939,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c54e03a951783e8b327515db3f2a2fd0e3bed362a96b066f341ce66ed49b4ead" dependencies = [ "data-encoding", - "syn 3.0.6", + "syn 2.0.119", ] [[package]] @@ -1297,9 +1297,9 @@ checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" [[package]] name = "form_urlencoded" -version = "1.2.2" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +checksum = "afa489199eaffb1211795df1c6236ce1ad0d41a6fa45250add73e3b02420f06e" dependencies = [ "percent-encoding", ] @@ -4779,9 +4779,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.8" +version = "2.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +checksum = "f00cd2407bb42c0ef17be88d4cf020f5cceffd121665bac9b8b9493a369b3b1a" dependencies = [ "form_urlencoded", "idna", diff --git a/fuzz/seeds/mp4/alac-frame-length.m4a b/fuzz/seeds/mp4/alac-frame-length.m4a new file mode 100644 index 000000000..d4f4ea96e Binary files /dev/null and b/fuzz/seeds/mp4/alac-frame-length.m4a differ diff --git a/knip.jsonc b/knip.jsonc index 82fd470a1..d31a6c740 100644 --- a/knip.jsonc +++ b/knip.jsonc @@ -25,13 +25,15 @@ // elsewhere. // The Docker image ships scripts/db-backup.ts, for restores. The default run calls that entry // redundant (package.json's db: scripts reach it), but the production run only reads `start`. - // scripts/fuzz.ts loads the fuzz targets by name. + // scripts/fuzz.ts loads the fuzz targets by name. Paraglide's CLI and Vite plugin read its config from the + // inlang project. "entry": [ "src/lib/server/atproto/lexicon-files.ts!", "src/lib/server/notifications/kind-files.ts!", "src/lib/server/happyview/lua-files.ts!", "scripts/db-backup.ts!", - "fuzz/*.fuzz.ts" + "fuzz/*.fuzz.ts", + "project.inlang/paraglide.config.ts" ], "project": [ "**/*.{js,mjs,cjs,jsx,ts,tsx,mts,cts,mdx,svelte,css}!", @@ -48,8 +50,13 @@ "!src/lib/components/edit/EditBarFrame.svelte!", "!src/lib/components/edit/EditPageHarness.svelte!" ], - // src/lib/server/og/render.ts resolves their font files by path at runtime. - "ignoreDependencies": ["@fontsource/instrument-sans", "@fontsource/jetbrains-mono"] + // src/lib/server/og/render.ts resolves their font files by path at runtime, and project.inlang/settings.json + // loads the message format plugin by path. + "ignoreDependencies": [ + "@fontsource/instrument-sans", + "@fontsource/jetbrains-mono", + "@inlang/plugin-message-format" + ] }, "apps/localtoolbox": { // The content scripts, the main-world script that feeds content.ts, the popup's classic scripts, diff --git a/lexicons/computer/localnetwork/booking/inquiry.json b/lexicons/computer/localnetwork/booking/inquiry.json index 751bdf508..6e15d80db 100644 --- a/lexicons/computer/localnetwork/booking/inquiry.json +++ b/lexicons/computer/localnetwork/booking/inquiry.json @@ -25,6 +25,12 @@ "maxLength": 20000, "maxGraphemes": 2000 }, + "langs": { + "type": "array", + "description": "The languages the promoter wrote the message and the show's notes in.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "plannerShow": { "type": "string", "format": "at-uri", diff --git a/lexicons/computer/localnetwork/booking/message.json b/lexicons/computer/localnetwork/booking/message.json index 80e237b2f..f30fb4e35 100644 --- a/lexicons/computer/localnetwork/booking/message.json +++ b/lexicons/computer/localnetwork/booking/message.json @@ -16,6 +16,12 @@ "maxLength": 20000, "maxGraphemes": 2000 }, + "langs": { + "type": "array", + "description": "The languages the text is written in.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "onBehalfOf": { "type": "string", "format": "did", diff --git a/lexicons/computer/localnetwork/booking/status.json b/lexicons/computer/localnetwork/booking/status.json index 490213c7d..cff2c31c1 100644 --- a/lexicons/computer/localnetwork/booking/status.json +++ b/lexicons/computer/localnetwork/booking/status.json @@ -35,6 +35,12 @@ "maxLength": 5000, "maxGraphemes": 500 }, + "langs": { + "type": "array", + "description": "The languages the note is written in.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "onBehalfOf": { "type": "string", "format": "did", diff --git a/lexicons/computer/localnetwork/directory/getArtist.json b/lexicons/computer/localnetwork/directory/getArtist.json index 11a161501..46f5d2516 100644 --- a/lexicons/computer/localnetwork/directory/getArtist.json +++ b/lexicons/computer/localnetwork/directory/getArtist.json @@ -17,6 +17,12 @@ "type": "string", "maxLength": 2560, "description": "The artist's name, in any case, when there's no mbid. It finds the artist sets credit under that name: the name alone when some sets give it no MBID, otherwise the MBID sets give it." + }, + "inactive": { + "type": "array", + "maxLength": 100, + "items": { "type": "string", "format": "did" }, + "description": "Accounts that aren't active (deactivated, taken down, suspended or deleted), whose sets don't count." } } }, diff --git a/lexicons/computer/localnetwork/directory/getCharts.json b/lexicons/computer/localnetwork/directory/getCharts.json index 7362e0303..024679a94 100644 --- a/lexicons/computer/localnetwork/directory/getCharts.json +++ b/lexicons/computer/localnetwork/directory/getCharts.json @@ -37,6 +37,12 @@ "maximum": 100, "default": 50, "description": "The most tracks, and the most artists." + }, + "inactive": { + "type": "array", + "maxLength": 100, + "items": { "type": "string", "format": "did" }, + "description": "Accounts that aren't active (deactivated, taken down, suspended or deleted), whose sets don't count." } } }, diff --git a/lexicons/computer/localnetwork/directory/getSets.json b/lexicons/computer/localnetwork/directory/getSets.json index 9ed76474c..6c583b52b 100644 --- a/lexicons/computer/localnetwork/directory/getSets.json +++ b/lexicons/computer/localnetwork/directory/getSets.json @@ -9,7 +9,13 @@ "type": "params", "required": ["uris"], "properties": { - "uris": { "type": "array", "maxLength": 25, "items": { "type": "string", "format": "at-uri" } } + "uris": { "type": "array", "maxLength": 25, "items": { "type": "string", "format": "at-uri" } }, + "inactive": { + "type": "array", + "maxLength": 100, + "items": { "type": "string", "format": "did" }, + "description": "Accounts that aren't active (deactivated, taken down, suspended or deleted), whose sets are left out." + } } }, "output": { diff --git a/lexicons/computer/localnetwork/directory/listShows.json b/lexicons/computer/localnetwork/directory/listShows.json index c387c4fe9..b7a791c26 100644 --- a/lexicons/computer/localnetwork/directory/listShows.json +++ b/lexicons/computer/localnetwork/directory/listShows.json @@ -34,7 +34,13 @@ "description": "distance needs latE6 and lngE6." }, "limit": { "type": "integer", "minimum": 1, "maximum": 100, "default": 30 }, - "cursor": { "type": "string", "maxLength": 512 } + "cursor": { "type": "string", "maxLength": 512 }, + "inactive": { + "type": "array", + "maxLength": 100, + "items": { "type": "string", "format": "did" }, + "description": "Accounts that aren't active (deactivated, taken down, suspended or deleted), whose shows are left out." + } } }, "output": { diff --git a/lexicons/computer/localnetwork/directory/searchArtists.json b/lexicons/computer/localnetwork/directory/searchArtists.json index c33afb69e..45d6bfd1f 100644 --- a/lexicons/computer/localnetwork/directory/searchArtists.json +++ b/lexicons/computer/localnetwork/directory/searchArtists.json @@ -13,7 +13,13 @@ "maxLength": 100, "description": "Text to find anywhere in the artist's name, in any case. Without it, every artist." }, - "limit": { "type": "integer", "minimum": 1, "maximum": 50, "default": 25 } + "limit": { "type": "integer", "minimum": 1, "maximum": 50, "default": 25 }, + "inactive": { + "type": "array", + "maxLength": 100, + "items": { "type": "string", "format": "did" }, + "description": "Accounts that aren't active (deactivated, taken down, suspended or deleted), whose sets don't count." + } } }, "output": { diff --git a/lexicons/computer/localnetwork/directory/searchPerformers.json b/lexicons/computer/localnetwork/directory/searchPerformers.json index 63d1dcd5a..76ec56d8b 100644 --- a/lexicons/computer/localnetwork/directory/searchPerformers.json +++ b/lexicons/computer/localnetwork/directory/searchPerformers.json @@ -59,7 +59,13 @@ }, "sort": { "type": "string", "maxLength": 32, "knownValues": ["relevance", "distance", "recent", "name"] }, "limit": { "type": "integer", "minimum": 1, "maximum": 60, "default": 24 }, - "cursor": { "type": "string", "maxLength": 512 } + "cursor": { "type": "string", "maxLength": 512 }, + "inactive": { + "type": "array", + "maxLength": 100, + "items": { "type": "string", "format": "did" }, + "description": "Accounts that aren't active (deactivated, taken down, suspended or deleted). A listed DJ among them is left out, and so is a solo project they alone manage." + } } }, "output": { diff --git a/lexicons/computer/localnetwork/epk.json b/lexicons/computer/localnetwork/epk.json index 67fbaa5ae..4e34ebc37 100644 --- a/lexicons/computer/localnetwork/epk.json +++ b/lexicons/computer/localnetwork/epk.json @@ -29,6 +29,12 @@ "maxGraphemes": 1000, "description": "A short bio anyone can read." }, + "langs": { + "type": "array", + "description": "The languages the headline and bio are written in.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "mixes": { "type": "array", "maxLength": 12, diff --git a/lexicons/computer/localnetwork/epk/content.json b/lexicons/computer/localnetwork/epk/content.json index 25fa2afa0..83b628f35 100644 --- a/lexicons/computer/localnetwork/epk/content.json +++ b/lexicons/computer/localnetwork/epk/content.json @@ -29,6 +29,12 @@ }, "contact": { "type": "ref", "ref": "computer.localnetwork.epk.defs#contact" }, "techRider": { "type": "string", "maxLength": 20000, "maxGraphemes": 2000 }, + "langs": { + "type": "array", + "description": "The languages its text is written in: the bio, tech rider and contact note. Quotes are in whatever language their sources wrote them.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "updatedAt": { "type": "string", "format": "datetime" } } } diff --git a/lexicons/computer/localnetwork/epk/decision.json b/lexicons/computer/localnetwork/epk/decision.json new file mode 100644 index 000000000..e6aa7b838 --- /dev/null +++ b/lexicons/computer/localnetwork/epk/decision.json @@ -0,0 +1,35 @@ +{ + "lexicon": 1, + "id": "computer.localnetwork.epk.decision", + "defs": { + "main": { + "type": "record", + "key": "tid", + "description": "A manager's answer to a request to see the private part of a press kit. Written only by the Local Network root account, into the project's computer.localnetwork.space.epkRequests space beside the request. Someone declined can't ask to see that press kit again.", + "record": { + "type": "object", + "required": ["request", "requester", "epk", "outcome", "decidedBy", "createdAt"], + "properties": { + "request": { + "type": "string", + "format": "at-uri", + "description": "The computer.localnetwork.epk.request record." + }, + "requester": { "type": "string", "format": "did" }, + "epk": { + "type": "string", + "format": "at-uri", + "description": "The computer.localnetwork.epk record it asked to see." + }, + "outcome": { "type": "string", "maxLength": 32, "knownValues": ["approved", "declined"] }, + "decidedBy": { + "type": "string", + "format": "did", + "description": "The manager who answered, or the root account when the press kit's rules approved the request." + }, + "createdAt": { "type": "string", "format": "datetime" } + } + } + } + } +} diff --git a/lexicons/computer/localnetwork/epk/draft.json b/lexicons/computer/localnetwork/epk/draft.json index 7263e801f..22b10e3f9 100644 --- a/lexicons/computer/localnetwork/epk/draft.json +++ b/lexicons/computer/localnetwork/epk/draft.json @@ -25,6 +25,12 @@ "ref": "#fields", "description": "What each changed field held in the published press kit when the draft changed it; a changed field missing here was empty. Publishing compares these with the current values to find fields someone else published since. Absent for a press kit that isn't published yet." }, + "langs": { + "type": "array", + "description": "The languages of the text this draft changes. Publishing gives them to whichever of the press kit's records it changes the text of.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "onBehalfOf": { "type": "string", "format": "did", diff --git a/lexicons/computer/localnetwork/epk/request.json b/lexicons/computer/localnetwork/epk/request.json index fff16eaa2..919b2627d 100644 --- a/lexicons/computer/localnetwork/epk/request.json +++ b/lexicons/computer/localnetwork/epk/request.json @@ -12,6 +12,12 @@ "properties": { "epk": { "type": "string", "format": "at-uri", "description": "The computer.localnetwork.epk record." }, "message": { "type": "string", "maxLength": 10000, "maxGraphemes": 1000 }, + "langs": { + "type": "array", + "description": "The languages the message is written in.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "onBehalfOf": { "type": "string", "format": "did", diff --git a/lexicons/computer/localnetwork/event.json b/lexicons/computer/localnetwork/event.json index e64c42984..e5b8e5489 100644 --- a/lexicons/computer/localnetwork/event.json +++ b/lexicons/computer/localnetwork/event.json @@ -12,6 +12,12 @@ "properties": { "name": { "type": "string", "minLength": 1, "maxLength": 1200, "maxGraphemes": 120 }, "description": { "type": "string", "maxLength": 30000, "maxGraphemes": 3000 }, + "langs": { + "type": "array", + "description": "The languages the description is written in.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "startsAt": { "type": "string", "format": "datetime", diff --git a/lexicons/computer/localnetwork/flags/getFlags.json b/lexicons/computer/localnetwork/flags/getFlags.json index cf4f7bddf..24bc44910 100644 --- a/lexicons/computer/localnetwork/flags/getFlags.json +++ b/lexicons/computer/localnetwork/flags/getFlags.json @@ -4,7 +4,7 @@ "defs": { "main": { "type": "query", - "description": "Every feature flag's public gates, and whether the caller is targeted by account or group. Inter-service auth is optional: without it, nothing is targeted. A flag is on for a caller when it's enabled and it's on for everyone, targets them, or their DID falls inside the percentage. Group names and member lists aren't exposed.", + "description": "Every feature flag's public gates, and whether the caller is targeted by account or group. Inter-service auth is optional: without it, nothing is targeted. A flag is on for a signed-in caller when it's enabled and it's on for everyone, targets them, or their DID falls inside the percentage. With no account, it's on when it's enabled, signedOut is true, and it's on for everyone or 100%. Group names and member lists aren't exposed.", "output": { "encoding": "application/json", "schema": { @@ -32,7 +32,11 @@ "type": "boolean", "description": "False means off for every caller, whatever the other gates say." }, - "everyone": { "type": "boolean" }, + "signedOut": { + "type": "boolean", + "description": "Callers with no account have it too, once it's on for everyone or 100%. Missing means false." + }, + "everyone": { "type": "boolean", "description": "On for every signed-in account." }, "percentage": { "type": "integer", "minimum": 0, "maximum": 100 }, "targeted": { "type": "boolean", diff --git a/lexicons/computer/localnetwork/listing.json b/lexicons/computer/localnetwork/listing.json index a2920bc23..55708f804 100644 --- a/lexicons/computer/localnetwork/listing.json +++ b/lexicons/computer/localnetwork/listing.json @@ -13,6 +13,12 @@ "kind": { "type": "string", "maxLength": 32, "knownValues": ["act", "party", "venue"] }, "name": { "type": "string", "minLength": 1, "maxLength": 640, "maxGraphemes": 64 }, "slug": { "type": "string", "minLength": 2, "maxLength": 64 }, + "langs": { + "type": "array", + "description": "The languages of the text in fields, as the space's own record names them.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "people": { "type": "array", "maxLength": 50, diff --git a/lexicons/computer/localnetwork/moderation/decision.json b/lexicons/computer/localnetwork/moderation/decision.json index 956a7f866..a67ca5215 100644 --- a/lexicons/computer/localnetwork/moderation/decision.json +++ b/lexicons/computer/localnetwork/moderation/decision.json @@ -15,6 +15,12 @@ "requester": { "type": "string", "format": "did" }, "outcome": { "type": "string", "maxLength": 32, "knownValues": ["approved", "rejected", "changesRequested"] }, "reason": { "type": "string", "maxLength": 10000, "maxGraphemes": 1000 }, + "langs": { + "type": "array", + "description": "The languages the reason is written in.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "decidedBy": { "type": "string", "format": "did" }, "project": { "type": "string", "format": "at-uri" }, "projectRevision": { "type": "integer", "minimum": 1 }, diff --git a/lexicons/computer/localnetwork/moderation/request.json b/lexicons/computer/localnetwork/moderation/request.json index 067b912c2..73082d89f 100644 --- a/lexicons/computer/localnetwork/moderation/request.json +++ b/lexicons/computer/localnetwork/moderation/request.json @@ -23,6 +23,12 @@ "claim": { "type": "ref", "ref": "#claim" }, "listing": { "type": "ref", "ref": "#listingSubject" }, "message": { "type": "string", "maxLength": 20000, "maxGraphemes": 2000 }, + "langs": { + "type": "array", + "description": "The languages the requester wrote in: the message, the claim's evidence, and the profile's and details' text.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "onBehalfOf": { "type": "string", "format": "did", diff --git a/lexicons/computer/localnetwork/party.json b/lexicons/computer/localnetwork/party.json index e561e5a37..d0a15df5c 100644 --- a/lexicons/computer/localnetwork/party.json +++ b/lexicons/computer/localnetwork/party.json @@ -11,6 +11,12 @@ "required": ["basics", "createdAt", "updatedAt"], "properties": { "basics": { "type": "ref", "ref": "computer.localnetwork.section.defs#basics" }, + "langs": { + "type": "array", + "description": "The languages the party's text is written in, like its bio.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "publishedAt": { "type": "string", "format": "datetime", diff --git a/lexicons/computer/localnetwork/people/invite.json b/lexicons/computer/localnetwork/people/invite.json index d5e871197..6f16ded7d 100644 --- a/lexicons/computer/localnetwork/people/invite.json +++ b/lexicons/computer/localnetwork/people/invite.json @@ -19,6 +19,12 @@ "description": "Set when staff made it. It works whoever is in the space. One made by someone in the space stops working once they can't add people." }, "message": { "type": "string", "maxLength": 3000, "maxGraphemes": 300 }, + "langs": { + "type": "array", + "description": "The languages the message is written in.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "createdAt": { "type": "string", "format": "datetime" }, "expiresAt": { "type": "string", "format": "datetime" } } diff --git a/lexicons/computer/localnetwork/people/request.json b/lexicons/computer/localnetwork/people/request.json index 8c260d9f9..7dd188677 100644 --- a/lexicons/computer/localnetwork/people/request.json +++ b/lexicons/computer/localnetwork/people/request.json @@ -12,6 +12,12 @@ "properties": { "subject": { "type": "string", "format": "did" }, "message": { "type": "string", "maxLength": 3000, "maxGraphemes": 300 }, + "langs": { + "type": "array", + "description": "The languages the message is written in.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "hidden": { "type": "boolean", "description": "Whether they want to be hidden from everyone outside the space once they're in." diff --git a/lexicons/computer/localnetwork/performer.json b/lexicons/computer/localnetwork/performer.json index 79d8e612b..1a34aed1c 100644 --- a/lexicons/computer/localnetwork/performer.json +++ b/lexicons/computer/localnetwork/performer.json @@ -16,6 +16,12 @@ "closed": false, "description": "An act, with what its page shows, or the DJ whose backstage and managers the space holds." }, + "langs": { + "type": "array", + "description": "The languages an act's text is written in, like its bio. A DJ's has none: their page is their profile.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "formerly": { "type": "array", "maxLength": 20, diff --git a/lexicons/computer/localnetwork/performer/details.json b/lexicons/computer/localnetwork/performer/details.json index 385a3942e..e2c3c3f37 100644 --- a/lexicons/computer/localnetwork/performer/details.json +++ b/lexicons/computer/localnetwork/performer/details.json @@ -11,6 +11,12 @@ "required": ["details", "updatedAt"], "properties": { "details": { "type": "ref", "ref": "computer.localnetwork.defs#projectDetails" }, + "langs": { + "type": "array", + "description": "The languages the rate notes, tech rider and hospitality are written in.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "updatedAt": { "type": "string", "format": "datetime" } } } diff --git a/lexicons/computer/localnetwork/planner/save.json b/lexicons/computer/localnetwork/planner/save.json index a79ac4588..09b058d45 100644 --- a/lexicons/computer/localnetwork/planner/save.json +++ b/lexicons/computer/localnetwork/planner/save.json @@ -12,6 +12,12 @@ "properties": { "project": { "type": "string", "format": "at-uri" }, "note": { "type": "string", "maxLength": 5000, "maxGraphemes": 500 }, + "langs": { + "type": "array", + "description": "The languages the note is written in.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "createdAt": { "type": "string", "format": "datetime" } } } diff --git a/lexicons/computer/localnetwork/planner/show.json b/lexicons/computer/localnetwork/planner/show.json index adb6fe17d..6d25fbd23 100644 --- a/lexicons/computer/localnetwork/planner/show.json +++ b/lexicons/computer/localnetwork/planner/show.json @@ -11,6 +11,12 @@ "required": ["details", "lineup", "createdAt"], "properties": { "details": { "type": "ref", "ref": "computer.localnetwork.defs#showDetails" }, + "langs": { + "type": "array", + "description": "The languages the show's notes are written in.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "lineup": { "type": "array", "maxLength": 40, "items": { "type": "ref", "ref": "#slot" } }, "createdAt": { "type": "string", "format": "datetime" }, "updatedAt": { "type": "string", "format": "datetime" } diff --git a/lexicons/computer/localnetwork/profile.json b/lexicons/computer/localnetwork/profile.json index 89e35295e..07151a57b 100644 --- a/lexicons/computer/localnetwork/profile.json +++ b/lexicons/computer/localnetwork/profile.json @@ -13,6 +13,12 @@ "basics": { "type": "ref", "ref": "computer.localnetwork.section.defs#basics" }, "performer": { "type": "ref", "ref": "computer.localnetwork.section.defs#performer" }, "promoter": { "type": "ref", "ref": "computer.localnetwork.section.defs#promoter" }, + "langs": { + "type": "array", + "description": "The languages the profile's text is written in, like its bio.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "takesInquiries": { "type": "boolean", "description": "Whether promoters can send this DJ booking inquiries on Local Network. Off unless true, and only counts while the performer section is on." diff --git a/lexicons/computer/localnetwork/project.json b/lexicons/computer/localnetwork/project.json index 038f582da..203a94ca4 100644 --- a/lexicons/computer/localnetwork/project.json +++ b/lexicons/computer/localnetwork/project.json @@ -12,6 +12,12 @@ "properties": { "slug": { "type": "string", "minLength": 2, "maxLength": 64 }, "profile": { "type": "ref", "ref": "computer.localnetwork.defs#projectProfile" }, + "langs": { + "type": "array", + "description": "The languages the profile's text is written in, like its bio: the request's it was published from, or the admin's who wrote it.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "managers": { "type": "array", "maxLength": 10, diff --git a/lexicons/computer/localnetwork/project/details.json b/lexicons/computer/localnetwork/project/details.json index 7afb80f28..824301f50 100644 --- a/lexicons/computer/localnetwork/project/details.json +++ b/lexicons/computer/localnetwork/project/details.json @@ -12,6 +12,12 @@ "properties": { "project": { "type": "string", "format": "at-uri" }, "details": { "type": "ref", "ref": "computer.localnetwork.defs#projectDetails" }, + "langs": { + "type": "array", + "description": "The languages the rate notes, tech rider and hospitality are written in.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "updatedAt": { "type": "string", "format": "datetime" } } } diff --git a/lexicons/computer/localnetwork/space/epkRequests.json b/lexicons/computer/localnetwork/space/epkRequests.json index 13d6e42f2..e39a133e9 100644 --- a/lexicons/computer/localnetwork/space/epkRequests.json +++ b/lexicons/computer/localnetwork/space/epkRequests.json @@ -4,10 +4,14 @@ "defs": { "main": { "type": "space", - "description": "Requests to see a project's press kits, and the grants that answer them. Owned by the Local Network root account, one space per project, keyed by the project record's key. Anyone signed in can write a request into it, and only the root writes grants; only its members (the project's current managers) can read it, so the people asking, and those granted access, never see each other's requests or grants.", + "description": "Requests to see a project's press kits, and the decisions and grants that answer them. Owned by the Local Network root account, one space per project, keyed by the project record's key. Anyone signed in can write a request into it, and only the root writes decisions and grants; only its members (the project's current managers) can read it, so the people asking, and those granted access, never see each other's requests or grants.", "key": "tid", "title": "Local Network press kit requests", - "collections": ["computer.localnetwork.epk.request", "computer.localnetwork.epk.grant"] + "collections": [ + "computer.localnetwork.epk.request", + "computer.localnetwork.epk.decision", + "computer.localnetwork.epk.grant" + ] } } } diff --git a/lexicons/computer/localnetwork/staff/flag.json b/lexicons/computer/localnetwork/staff/flag.json index ac2b1df6c..641a6faa6 100644 --- a/lexicons/computer/localnetwork/staff/flag.json +++ b/lexicons/computer/localnetwork/staff/flag.json @@ -15,7 +15,11 @@ "type": "boolean", "description": "False turns it off for everyone and keeps the gates below for when it's back on. Missing means true." }, - "everyone": { "type": "boolean", "description": "On for every visitor, signed in or not." }, + "signedOut": { + "type": "boolean", + "description": "Signed-out visitors have it too. Only counts while it's on for every account, so it's turned on last. Missing means false for a release flag. An ops flag has it whenever it's on for every account." + }, + "everyone": { "type": "boolean", "description": "On for every signed-in account." }, "percentage": { "type": "integer", "minimum": 0, diff --git a/lexicons/computer/localnetwork/staff/group.json b/lexicons/computer/localnetwork/staff/group.json index 99d5e2345..80892756a 100644 --- a/lexicons/computer/localnetwork/staff/group.json +++ b/lexicons/computer/localnetwork/staff/group.json @@ -12,6 +12,12 @@ "properties": { "name": { "type": "string", "maxLength": 640, "maxGraphemes": 64 }, "description": { "type": "string", "maxLength": 3000, "maxGraphemes": 300 }, + "langs": { + "type": "array", + "description": "The languages the description is written in.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "members": { "type": "array", "maxLength": 5000, diff --git a/lexicons/computer/localnetwork/staff/role.json b/lexicons/computer/localnetwork/staff/role.json index c654ee240..158f8de32 100644 --- a/lexicons/computer/localnetwork/staff/role.json +++ b/lexicons/computer/localnetwork/staff/role.json @@ -20,6 +20,12 @@ "items": { "type": "string", "maxLength": 32, "knownValues": ["flags", "flagGroups"] } }, "note": { "type": "string", "maxLength": 3000, "maxGraphemes": 300 }, + "langs": { + "type": "array", + "description": "The languages the note is written in.", + "maxLength": 3, + "items": { "type": "string", "format": "language" } + }, "createdAt": { "type": "string", "format": "datetime" } } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b9e2a9d7e..91be859c0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -399,6 +399,9 @@ importers: '@atproto-labs/did-resolver': specifier: 0.0.0-spaces-alpha-20261113224550 version: 0.0.0-spaces-alpha-20261113224550 + '@atproto-labs/fetch': + specifier: 0.4.2 + version: 0.4.2 '@atproto-labs/fetch-node': specifier: 0.0.0-spaces-alpha-20261113224550 version: 0.0.0-spaces-alpha-20261113224550 @@ -438,6 +441,9 @@ importers: '@atproto/space': specifier: 0.0.0-spaces-alpha-20261113224550 version: 0.0.0-spaces-alpha-20261113224550 + '@atproto/star': + specifier: 0.0.0-spaces-alpha-20261113224550 + version: 0.0.0-spaces-alpha-20261113224550 '@atproto/syntax': specifier: 0.0.0-spaces-alpha-20261113224550 version: 0.0.0-spaces-alpha-20261113224550 @@ -514,6 +520,15 @@ importers: '@electric-sql/pglite': specifier: ^0.5.16 version: 0.5.16 + '@inlang/cli': + specifier: ^3.6.0 + version: 3.6.0 + '@inlang/paraglide-js': + specifier: ^3.2.2 + version: 3.2.2(eslint@10.14.0(jiti@2.7.0)(supports-color@5.5.0))(typescript@6.0.3)(vite@8.3.4(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1)) + '@inlang/plugin-message-format': + specifier: ^4.6.0 + version: 4.6.0 '@jazzer.js/core': specifier: ^4.0.0 version: 4.0.0(supports-color@5.5.0) @@ -616,6 +631,9 @@ importers: playwright: specifier: ^1.63.0 version: 1.64.1 + pseudo-localization: + specifier: ^3.1.3 + version: 3.1.3 storybook: specifier: 10.6.2 version: 10.6.2(@types/react@19.3.0)(prettier@3.9.9)(react@19.3.0) @@ -1359,6 +1377,74 @@ packages: '@bufbuild/protobuf@1.10.1': resolution: {integrity: sha512-wJ8ReQbHxsAfXhrf9ixl0aYbZorRuOWpBNzm8pL8ftmSxQx/wnJD5Eg861NwJU/czy2VXFIebCeZnZrI9rktIQ==} + '@bytecodealliance/jco-node-fs-darwin-arm64@0.3.2': + resolution: {integrity: sha512-WXQq1tRVUWhbK+ImH0G8Kni2AR0sdokLf/KyXRw5P6n4A9ZbgMHOuPfN/PEsYgw4eosuTAonutK0xILk/hA81A==} + engines: {node: '>=20'} + cpu: [arm64] + os: [darwin] + + '@bytecodealliance/jco-node-fs-darwin-x64@0.3.2': + resolution: {integrity: sha512-Fy/OjHnto7hNE5ksewVkmAMXG/uXyj+RAKFZWQFTzFkp73UyT5vuPjKq3nvx9KolUGWBG37BudEMb4ZAoD9TbQ==} + engines: {node: '>=20'} + cpu: [x64] + os: [darwin] + + '@bytecodealliance/jco-node-fs-linux-arm64-gnu@0.3.2': + resolution: {integrity: sha512-OafRtRu3tfOFQARfkia/LDEqSo2R3yAL1xPwzf4RcRW6JqkOY7qKWsUS5+LPVo/aFaSkMX7F7bdFGpFPmcoZJg==} + engines: {node: '>=20'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@bytecodealliance/jco-node-fs-linux-arm64-musl@0.3.2': + resolution: {integrity: sha512-JblDiwD7+Y+w0d/tjaNDX4QdGvh5lyuDc+S/jDeT7sYA1caA9yiwIjLa8PC/lm2xudqSxD+Cuy4AosXvl+qI0g==} + engines: {node: '>=20'} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@bytecodealliance/jco-node-fs-linux-x64-gnu@0.3.2': + resolution: {integrity: sha512-6FzmHoLOsa6b4X9AuFLsvlpNF66Dt4sRRftZHaT1I1pYzCWrJkkpgNJhRXxf67ZPmOwBZJT4dan/g752Rx4xRw==} + engines: {node: '>=20'} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@bytecodealliance/jco-node-fs-linux-x64-musl@0.3.2': + resolution: {integrity: sha512-SbAJG2PDV8YAHBESHU9sVSckOitJyvlezdF4CGP5/mOp01JnijVkLVXzGK62yVSfa5TpAybbSd1rk+v36NAW/Q==} + engines: {node: '>=20'} + cpu: [x64] + os: [linux] + libc: [musl] + + '@bytecodealliance/jco-node-fs-win32-arm64-msvc@0.3.2': + resolution: {integrity: sha512-nUWYdFysRQJGsIOCk0KAYN2smkNYiHG7rZ7m+0ZXqP+5wqWxKEjkDsORwXiBjdaWFLVww0anZ3SBxrju6P7hXQ==} + engines: {node: '>=20'} + cpu: [arm64] + os: [win32] + + '@bytecodealliance/jco-node-fs-win32-x64-msvc@0.3.2': + resolution: {integrity: sha512-RsPj2t8TvltsMWK7/Z7JcVC/IWPMi07/AJkNLiNTCuGTdT/sseqTThJJwhuz3sjFw7dJdxA+bSGT+23y/KT0fw==} + engines: {node: '>=20'} + cpu: [x64] + os: [win32] + + '@bytecodealliance/jco-node-fs@0.3.2': + resolution: {integrity: sha512-yxvqQreNcOQdMsEKZomkSqThtkxrAz3f1Cmy8BsV0UHi9saa2/D1KDB14IAXPYwDq/maS6lCzS+MuMQx6QkUgA==} + engines: {node: '>=20'} + + '@bytecodealliance/jco-transpile@0.13.0': + resolution: {integrity: sha512-9hZ2GMqOlYP1Bf7qQ8v3sCsmkFoXGbgi0HtjHipzrgyk+9GGDzvvbehTGe0oM54rcbKJacvyjpPDn7wtpgzwYA==} + + '@bytecodealliance/preview2-shim@0.24.1': + resolution: {integrity: sha512-QGZsKD5M76xBhwu3BzLWqYDEpaMX90QWrrfhkQPn2pN9t378koumtdAVH4lr25mqGCZt10YNXkWvyWkw/vJbLQ==} + + '@bytecodealliance/preview2-shim@0.25.0': + resolution: {integrity: sha512-6ZSDRJ8hJc/febZepzd68z3KzLcOXyCOKtRm8LB2rgAU88xV7ykq6dMb5I4a+sBh1cuV2Yb1159gDzI1q8UsoQ==} + + '@bytecodealliance/preview3-shim@0.6.1': + resolution: {integrity: sha512-61mEfjfgGmZhEMA0H3waawPKvYd3za9y0vJ7pmQz/9yvm4FR6Ef+cmqhnxDE7ezsM07MY1btP92ymmgsgFwxmg==} + '@cacheable/memory@2.2.0': resolution: {integrity: sha512-CTLKqLItRCEixEAewD3/j9DB3/o96gpTPD4eJ1v+DGOlxZRZncRQkGYqqnAGCscYd6RNeXfGeiuCphsPtqyIfQ==} @@ -1536,6 +1622,9 @@ packages: '@emnapi/core@1.11.0': resolution: {integrity: sha512-l9Oo58x0HOP5znGzVhYW9U3e5wVuA4LAZU2AGezTmkhO1CgQRFDhDg4nneHsu/t3WniXg9QrG2nIXL/ZS8ln8Q==} + '@emnapi/core@1.11.1': + resolution: {integrity: sha512-RSvbQmHzdKzNsLYa/wHrbc3KN4sYLKAdPZxqiM2HATqv/SBk2/ENSHpvXGaLOMcsAyz0poEGqkmmKYG3OWiJEQ==} + '@emnapi/core@1.11.2': resolution: {integrity: sha512-TC8MkTuZUtcTSiFeuC0ksCh9QIJ5+F21MvZ4Wn4ORfYaFJ/0dsiudv5tVkejgwZlwQ39jL9WWDe2lz8x0WglOA==} @@ -1545,6 +1634,9 @@ packages: '@emnapi/runtime@1.11.0': resolution: {integrity: sha512-55coeOFKHv1ywEcUXJtWU5f+Jr/W5tZDvZig8DLKSwUN1JpROQ4rk/SNOQiFWmaR/VKF4zuFyW1B8JduOSv6Pg==} + '@emnapi/runtime@1.11.1': + resolution: {integrity: sha512-vgj7R3y3Wgx24IQaGPA/R6YFXLHVMOZ0uVEyIQPaWs+rd1AzfEMXlAC22FYwO1XkKR6NPsq7mUandH8oIRdZFw==} + '@emnapi/runtime@1.11.2': resolution: {integrity: sha512-kyOl3X0DuTiT1h2ft8r2fYO8JYtU9a9Xis/zBSiGArNaagCOWx90N1k2wxp18czFDH+OgcWGb5ZP/XMt3dcyPA==} @@ -2138,6 +2230,33 @@ packages: cpu: [x64] os: [win32] + '@inlang/cli@3.6.0': + resolution: {integrity: sha512-IQdki7NAXkA//RMEndIWu2bybQl1rAmtY1O+RPI26KJdRolDPauBfCPnmn39S1pQWBFJ68+oyLaj1mqqSswxuQ==} + engines: {node: '>=18.0.0'} + hasBin: true + + '@inlang/paraglide-js@3.2.2': + resolution: {integrity: sha512-YoQ2aHmzSgC+yfUgKwcJew3F0lFfwLJsriGCbwQHiJfjKGNjhQnbRr0OXoxsy2ulY2/gK8vYpiphuTv2J0wf5Q==} + hasBin: true + peerDependencies: + eslint: ^9.0.0 || ^10.0.0 + vite: '>=5.0.0' + peerDependenciesMeta: + eslint: + optional: true + vite: + optional: true + + '@inlang/plugin-message-format@4.6.0': + resolution: {integrity: sha512-DK2GZvypDygLchnUaFK/RdCIm2baiRlQftOiesGNKDtjNqioqWHnnu0zg6NKNlo3kD42h5xlRCke7zEjBFzZrg==} + + '@inlang/recommend-sherlock@0.2.1': + resolution: {integrity: sha512-ckv8HvHy/iTqaVAEKrr+gnl+p3XFNwe5D2+6w6wJk2ORV2XkcRkKOJ/XsTUJbPSiyi4PI+p+T3bqbmNx/rDUlg==} + + '@inlang/sdk@4.2.0': + resolution: {integrity: sha512-Cmaqvn34wsxiF27318Zw2rg+017HHNJWV5MH8rfyVKVANZNpzlztxzRbFienE/gASMLD8oluYHHolIb/p6Egrw==} + engines: {node: '>=20.0.0'} + '@inquirer/ansi@2.0.9': resolution: {integrity: sha512-0Ywt3S8tqM6TWUcsRlBFQ1x+X3/o8kktX0ZiKAnByYb9GFDknnOhse1PVtfiD2BXPI8ar+BWx9PV9R0lQIcygw==} engines: {node: '>=23.5.0 || ^22.13.0 || ^20.17.0'} @@ -2371,6 +2490,9 @@ packages: resolution: {integrity: sha512-jTvAYsCFnRKmbs+qEyCXnXmxf85kBDAaGhvyEah7zT7AjLJc8XqPTKhALT9i31Kxm7rQAQnRx58NNRiGYjGY5Q==} engines: {node: '>=22.19.0'} + '@lix-js/sdk@0.20.1': + resolution: {integrity: sha512-oscOFP8Cr1My6Wh2KVYC9+aJ1mHs+d7vnD+7PPJaA4L+Y1FR37Sm99SrFGfvUizaj/XtRi2GlDF2IOFt9iXMNQ==} + '@lucide/svelte@1.59.0': resolution: {integrity: sha512-ga9IrEsFJBkt/34VnRFcQ2HLs8eOpOovXZ62XzwfC7f0zBfo4y116FBIDroZkD0gInYYY2hSSAcsQEm/Vm+AoA==} peerDependencies: @@ -2876,6 +2998,133 @@ packages: peerDependencies: '@opentelemetry/api': ^1.10.0 + '@oxc-minify/binding-android-arm-eabi@0.136.0': + resolution: {integrity: sha512-gk1jzky1vLeOcK7w9Ib2RT/UooZ7O21s8YSeXCsy4tzsmguKb3Cbsv/Ra2fKhMp4mKeKCzvC1Xa41OfSBWfWdQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + + '@oxc-minify/binding-android-arm64@0.136.0': + resolution: {integrity: sha512-5GIYanqud/ohXEcg2dsdn0+eSKXqclw5qlRUkvSM1sKEa4ZQ7hqOk8XPJBNPh3LXXw+Qw85B6jkmOFLKsCHp5w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@oxc-minify/binding-darwin-arm64@0.136.0': + resolution: {integrity: sha512-QAMpHKXWOoMCTenSZjQjVT5YmMooujlCKAf1T3PHFl2LuaA6ukQFXba0bgSLgAxRrAeX/itkwi4lzVQXtYmnRg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@oxc-minify/binding-darwin-x64@0.136.0': + resolution: {integrity: sha512-rDnoPj8hztiU8C1VNKuzujh7SgTJlgiUvUCiWQjTnVSLsABsLW9ZWd1l1Ji0VN3UW39wGpptgvahIWTrHnGH/A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@oxc-minify/binding-freebsd-x64@0.136.0': + resolution: {integrity: sha512-9fGSgP7uyPLCTjMx9z3AUV4UjnfOVoGTH5JzamLegPwGLJ97Gr1jht1437CRk8ZNabGmxQR6qNn3e+Tox2lswg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@oxc-minify/binding-linux-arm-gnueabihf@0.136.0': + resolution: {integrity: sha512-k0QvZS+x6ROI4O5Ikqn9dDU2dmkEJ46Yh6baZJI/eUk/a1k1GOs9/vyXItLZrKlwYrSgdEx2BFXbKgyd1NyRPw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@oxc-minify/binding-linux-arm-musleabihf@0.136.0': + resolution: {integrity: sha512-iRFxUc8ubotVfuyq3e4LPGbHrjvWd1/B3499a55GueMLc1EDJ0fHzNXJiCx2eMQGfzHtHodjmvrJ2BSvSXBNhQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@oxc-minify/binding-linux-arm64-gnu@0.136.0': + resolution: {integrity: sha512-hbKxNCXJsULrb6EyG5SumzJKuPfP8Y0UQ/TElRgXVUhyyPf6cBPlF8HMq+MAylF98ACBzV8jBp2Mm62lJyTo+w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@oxc-minify/binding-linux-arm64-musl@0.136.0': + resolution: {integrity: sha512-T+u/CGKW0UXemJeVux4ix6rK+ug3bQCUEbu5hFlX9K61KQNd44rOcrM15mDK99L7USaXwmiwHeIkEDvmmyDMSA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@oxc-minify/binding-linux-ppc64-gnu@0.136.0': + resolution: {integrity: sha512-WNPTN2F448tb49BoqjV9IMRzZWa0WB8GHzrB+bnxKQPOyzz07T6rmDKrr4Hjl81ADGjDYSsr1fgXcjyLQFdMdw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@oxc-minify/binding-linux-riscv64-gnu@0.136.0': + resolution: {integrity: sha512-MvcCfu8OeabrmNN9wqhh8Gqizg68RQ3iOvXBJmlLMy5p1PC6az9bAwqOk98lsCmKI4I5LpULekOlfxRYh3o5Kw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@oxc-minify/binding-linux-riscv64-musl@0.136.0': + resolution: {integrity: sha512-rwJXFUFFA0egAULtOOgfW8YhhLhtWrr2qFxftvZ7/U6Xtxiev8i+eCwSNW1RpHiX74QMsJVpRE3ykoefqb1MtQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + libc: [musl] + + '@oxc-minify/binding-linux-s390x-gnu@0.136.0': + resolution: {integrity: sha512-qizAxHmj7VHm5/D5qiIlvzxAS2tlmadDOJ5XFI7zx/wfnk/+fdk5iVaHOv+C4tDE/4wLQyMoBYVIs6R1LeN91w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@oxc-minify/binding-linux-x64-gnu@0.136.0': + resolution: {integrity: sha512-gcyLAad0UblkEhGjVfx5Mwq63OSx8r04IbcfwzpZYpHisO/vioMsrs4GkDsQZ2Ejc8cdUk6YMIrf9FwNBzh+Dw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@oxc-minify/binding-linux-x64-musl@0.136.0': + resolution: {integrity: sha512-QAK6kwBjljX6luYzeppVdRP3gTaFNFfp9iS/V0cCvU43wUZay5xFXBgmzBHYrzZV2MhzURNnXfEZRo9poAxyvA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@oxc-minify/binding-openharmony-arm64@0.136.0': + resolution: {integrity: sha512-nIGxkTOnN9GwslmooxbZ3Ti2RgbX9QLHy0X9uO0pslOT+4dsNVUawBU/6r4M5cWM+ZdRD2tOF4V+n0l8tS59nQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@oxc-minify/binding-wasm32-wasi@0.136.0': + resolution: {integrity: sha512-YB3G8AHT6PpDS8/DfjlJrQjywj+/6gCkNBcAJdYzcYbQRIZE6SaTNowiGuZPR1m1jOl1WjcjefniKSmVxzhvRA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [wasm32] + + '@oxc-minify/binding-win32-arm64-msvc@0.136.0': + resolution: {integrity: sha512-UVRH3BlNc2rmla+sbSd5xTF/u+esCqZS6VSWPolZybcBh3TlVe1Sf5MOuHQWUaFoyv5uFOvee4hOfS/14nPvZw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@oxc-minify/binding-win32-ia32-msvc@0.136.0': + resolution: {integrity: sha512-zFGkUd82jci0E+isc2O36lVmmXVUDXyEMN2RYIyez+MBNqhdjPLIGx62FCsrJtLKeuiPf/8XkFv977aUtndUng==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ia32] + os: [win32] + + '@oxc-minify/binding-win32-x64-msvc@0.136.0': + resolution: {integrity: sha512-VHgPwd5xibC9UYxBeq7nURTjY+wxhdumllij6JaCIUVfD9IRcrA66SVlJ5fPNoUXcRp8ZXhJfoIZwVz9wAEGJw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + '@oxc-parser/binding-android-arm-eabi@0.127.0': resolution: {integrity: sha512-0LC7ye4hvqbIKxAzThzvswgHLFu2AURKzYLeSVvLdu2TBOYWQDmHnTqPLeA597BcUCxiLqLsS4CJ5uoI5WYWCQ==} engines: {node: ^20.19.0 || >=22.12.0} @@ -3970,6 +4219,9 @@ packages: resolution: {integrity: sha512-fCTuZK4QBa+39Oz9l4OGfJfz+GpwCp3AqO7Zch3to99xHPgstVsRFpeQ8LNd2o1Gv8raL2mCFwiaHh7bFSp5DQ==} engines: {node: '>=22'} + '@sinclair/typebox@0.31.30': + resolution: {integrity: sha512-MGsM7bVmHg3sUKCphlu3SGQ+T+5JTbygZWYArfKQCW5anJeACHeqLhcnf+R7XlCWZ+QR3C8JTBx3kCKJTN69ow==} + '@sindresorhus/is@4.6.0': resolution: {integrity: sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==} engines: {node: '>=10'} @@ -4846,6 +5098,9 @@ packages: array-flatten@1.1.1: resolution: {integrity: sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==} + array-timsort@1.0.3: + resolution: {integrity: sha512-/+3GRL7dDAGEfM6TseQk/U+mi18TU2Ms9I3UlLdUMhz2hbvGNTKdj9xniwXfUqgYhHxRx0+8UnKkvlNwVU+cWQ==} + asciinema-player@3.18.0: resolution: {integrity: sha512-5gpt2ipFcy4NKmgkv+c/QXnJ9zMicxqWROCOuJqgwwtiYKM8Qe9hnDOvfqke5bW6M2DW/seO3uQYkQ0xeUUVtw==} @@ -4921,6 +5176,10 @@ packages: bignumber.js@9.3.1: resolution: {integrity: sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==} + binaryen@130.0.0: + resolution: {integrity: sha512-XDrb+zql0RbFPKgj7MuH9zOc78R3Fa/P/VSGnnpdwYsvNZPWjcMYMdAkKCOQEL2A7yqgjSMTDRFp6gfSDW+/QQ==} + hasBin: true + bindings@1.5.0: resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==} @@ -5170,6 +5429,10 @@ packages: resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} engines: {node: '>= 0.8'} + commander@11.1.0: + resolution: {integrity: sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==} + engines: {node: '>=16'} + commander@14.0.3: resolution: {integrity: sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==} engines: {node: '>=20'} @@ -5182,6 +5445,10 @@ packages: resolution: {integrity: sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==} engines: {node: '>= 10'} + comment-json@4.6.2: + resolution: {integrity: sha512-R2rze/hDX30uul4NZoIZ76ImSJLFxn/1/ZxtKC1L77y2X1k+yYu1joKbAtMA2Fg3hZrTOiw0I5mwVMo0cf250w==} + engines: {node: '>= 6'} + compressible@2.0.18: resolution: {integrity: sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg==} engines: {node: '>= 0.6'} @@ -5197,6 +5464,10 @@ packages: resolution: {integrity: sha512-U51WPZg+o6FDFhBCV6yYFEspGMCoHvCgJSGFw9AwsW2u75gYBPoDlYca5XfDs4TdMUu3/y0R6FFdvvgyH31mKQ==} engines: {node: '>=20'} + consola@3.4.0: + resolution: {integrity: sha512-EiPU8G6dQG0GFHNR8ljnZFki/8a+cQwEQ+7wpxdChl02Q8HXlwEZWD5lqAF8vC2sEC3Tehr8hy7vErz88LHyUA==} + engines: {node: ^14.18.0 || >=16.10.0} + consola@3.4.2: resolution: {integrity: sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==} engines: {node: ^14.18.0 || >=16.10.0} @@ -5731,6 +6002,11 @@ packages: es-toolkit@1.52.0: resolution: {integrity: sha512-XTNEJQh1tY1ZJVcf6ayP/2n4ZPyaHlW2FWs7xvw5ddPuhUVjLD3olQVQS7kf58JbAB48iL0uL/jerTrjtV3lDA==} + esbuild-wasm@0.19.12: + resolution: {integrity: sha512-Zmc4hk6FibJZBcTx5/8K/4jT3/oG1vkGTEeKJUQFCUQKimD6Q7+adp/bdVQyYJFolMKaXkQnVZdV4O5ZaTYmyQ==} + engines: {node: '>=12'} + hasBin: true + esbuild@0.28.2: resolution: {integrity: sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==} engines: {node: '>=18'} @@ -6625,6 +6901,10 @@ packages: resolution: {integrity: sha512-TH+b56pVXQq0tsyooYLeNfV11j6ih7D50dyN8tkM0e7ndiUH28Nziojiog3qRFlmEj9XePYdZUrNJ2079Qjdow==} engines: {node: '>=14.0.0'} + kysely@0.28.20: + resolution: {integrity: sha512-D7rXCs0Psxq2hqjg15PGzk/k2bsWY1ohT9o/Xzl8SzgWExT6GiHCz4Z0NP1z5uOE3WBG7gJ46kYdgLYCOlaLoA==} + engines: {node: '>=20.0.0'} + kysely@0.29.9: resolution: {integrity: sha512-K48ErswC3MlIcBqR0pYIIEl+n9rIgwxgzaM1FxKHMXn7egxr1NHj7bCeF98mXl9A3/QoL5I7mo5S/mLXgeDgGA==} engines: {node: '>=22.0.0'} @@ -7256,6 +7536,10 @@ packages: resolution: {integrity: sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==} engines: {node: '>=10'} + oxc-minify@0.136.0: + resolution: {integrity: sha512-u9UvPFTYVwQ/i1kpp/c20S/SbvLaLV0Ngzyhgi0YV4B1SlxM7RgnnePl4vY9N3Z9sTRcozL1MRStI3PlUN9RFA==} + engines: {node: ^20.19.0 || >=22.12.0} + oxc-parser@0.127.0: resolution: {integrity: sha512-bkgD4qHlN7WxLdX8bLXdaU54TtQtAIg/ZBAfm0aje/mo3MRDo3P0hZSgr4U7O3xfX+fQmR5AP04JS/TGcZLcFA==} engines: {node: ^20.19.0 || >=22.12.0} @@ -7624,6 +7908,11 @@ packages: resolution: {integrity: sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==} engines: {node: '>=10'} + pseudo-localization@3.1.3: + resolution: {integrity: sha512-CUfwat30M5OPGWitLw2egrEc+pyHqBOfsLXY/F1YxqjSYNno0Xf8GYYgYq8/uDQRykeQOi23bWK+uWIl8KUqvA==} + engines: {node: '>=22'} + hasBin: true + pump@3.0.4: resolution: {integrity: sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==} @@ -8442,6 +8731,9 @@ packages: url-join@4.0.1: resolution: {integrity: sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==} + urlpattern-polyfill@10.1.0: + resolution: {integrity: sha512-IGjKp/o0NL3Bso1PymYURCJxMPNAf/ILOpendP9f5B6e1rTJgdgiOvgfoT8VxCAdY+Wisb9uhGaJJf3yZ2V9nw==} + use-sync-external-store@1.7.0: resolution: {integrity: sha512-6L+EeigHMQhdaIPNIFUKwfWJSwWFQ8gJbJ2DLOs5sDIegTwR9fRxvnM3uciHKjIZhFz+KAv2emhWMRvDmMcY8A==} peerDependencies: @@ -8461,6 +8753,14 @@ packages: resolution: {integrity: sha512-Sc5u1VVln93y1Xnz4R+CunOZc7R9LUcTmhj7Rc7Eg3HVcf7rVn2FOoa812fe0W8p3jD7xeoGSYbfqCGGH2B6xw==} hasBin: true + valibot@1.5.0: + resolution: {integrity: sha512-nil6AkP2TChWL43Z5uJ6GTxX01CUA+g8LWUM+N/rB9NBbkUMaUsi9PUNzlUPgoKASgmx9f7eGOYpJ04/fSa6FQ==} + peerDependencies: + typescript: '>=5' + peerDependenciesMeta: + typescript: + optional: true + varint@6.0.0: resolution: {integrity: sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg==} @@ -10042,6 +10342,61 @@ snapshots: '@bufbuild/protobuf@1.10.1': {} + '@bytecodealliance/jco-node-fs-darwin-arm64@0.3.2': + optional: true + + '@bytecodealliance/jco-node-fs-darwin-x64@0.3.2': + optional: true + + '@bytecodealliance/jco-node-fs-linux-arm64-gnu@0.3.2': + optional: true + + '@bytecodealliance/jco-node-fs-linux-arm64-musl@0.3.2': + optional: true + + '@bytecodealliance/jco-node-fs-linux-x64-gnu@0.3.2': + optional: true + + '@bytecodealliance/jco-node-fs-linux-x64-musl@0.3.2': + optional: true + + '@bytecodealliance/jco-node-fs-win32-arm64-msvc@0.3.2': + optional: true + + '@bytecodealliance/jco-node-fs-win32-x64-msvc@0.3.2': + optional: true + + '@bytecodealliance/jco-node-fs@0.3.2': + optionalDependencies: + '@bytecodealliance/jco-node-fs-darwin-arm64': 0.3.2 + '@bytecodealliance/jco-node-fs-darwin-x64': 0.3.2 + '@bytecodealliance/jco-node-fs-linux-arm64-gnu': 0.3.2 + '@bytecodealliance/jco-node-fs-linux-arm64-musl': 0.3.2 + '@bytecodealliance/jco-node-fs-linux-x64-gnu': 0.3.2 + '@bytecodealliance/jco-node-fs-linux-x64-musl': 0.3.2 + '@bytecodealliance/jco-node-fs-win32-arm64-msvc': 0.3.2 + '@bytecodealliance/jco-node-fs-win32-x64-msvc': 0.3.2 + + '@bytecodealliance/jco-transpile@0.13.0': + dependencies: + '@bytecodealliance/preview2-shim': 0.24.1 + '@bytecodealliance/preview3-shim': 0.6.1 + binaryen: 130.0.0 + oxc-minify: 0.136.0 + + '@bytecodealliance/preview2-shim@0.24.1': + dependencies: + '@bytecodealliance/jco-node-fs': 0.3.2 + + '@bytecodealliance/preview2-shim@0.25.0': + dependencies: + '@bytecodealliance/jco-node-fs': 0.3.2 + + '@bytecodealliance/preview3-shim@0.6.1': + dependencies: + '@bytecodealliance/jco-node-fs': 0.3.2 + '@bytecodealliance/preview2-shim': 0.25.0 + '@cacheable/memory@2.2.0': dependencies: '@cacheable/utils': 2.5.0 @@ -10280,6 +10635,12 @@ snapshots: tslib: 2.8.1 optional: true + '@emnapi/core@1.11.1': + dependencies: + '@emnapi/wasi-threads': 1.2.2 + tslib: 2.8.1 + optional: true + '@emnapi/core@1.11.2': dependencies: '@emnapi/wasi-threads': 1.2.2 @@ -10297,6 +10658,11 @@ snapshots: tslib: 2.8.1 optional: true + '@emnapi/runtime@1.11.1': + dependencies: + tslib: 2.8.1 + optional: true + '@emnapi/runtime@1.11.2': dependencies: tslib: 2.8.1 @@ -10732,6 +11098,45 @@ snapshots: '@img/sharp-win32-x64@0.35.5': optional: true + '@inlang/cli@3.6.0': + dependencies: + '@inlang/sdk': 4.2.0 + esbuild-wasm: 0.19.12 + + '@inlang/paraglide-js@3.2.2(eslint@10.14.0(jiti@2.7.0)(supports-color@5.5.0))(typescript@6.0.3)(vite@8.3.4(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))': + dependencies: + '@inlang/recommend-sherlock': 0.2.1 + '@inlang/sdk': 4.2.0 + commander: 11.1.0 + consola: 3.4.0 + jiti: 2.7.0 + json5: 2.2.3 + magic-string: 0.30.21 + unplugin: 2.3.11 + urlpattern-polyfill: 10.1.0 + valibot: 1.5.0(typescript@6.0.3) + optionalDependencies: + eslint: 10.14.0(jiti@2.7.0)(supports-color@5.5.0) + vite: 8.3.4(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1) + transitivePeerDependencies: + - typescript + + '@inlang/plugin-message-format@4.6.0': + dependencies: + '@inlang/sdk': 4.2.0 + '@sinclair/typebox': 0.31.30 + + '@inlang/recommend-sherlock@0.2.1': + dependencies: + comment-json: 4.6.2 + + '@inlang/sdk@4.2.0': + dependencies: + '@lix-js/sdk': 0.20.1 + '@sinclair/typebox': 0.31.30 + kysely: 0.28.20 + uuid: 14.0.3 + '@inquirer/ansi@2.0.9': {} '@inquirer/checkbox@5.2.6(@types/node@24.19.2)': @@ -11020,6 +11425,12 @@ snapshots: - webpack - yauzl + '@lix-js/sdk@0.20.1': + dependencies: + '@bytecodealliance/jco-transpile': 0.13.0 + binaryen: 130.0.0 + fflate: 0.8.3 + '@lucide/svelte@1.59.0(svelte@5.57.2(@typescript-eslint/types@8.72.1))': dependencies: svelte: 5.57.2(@typescript-eslint/types@8.72.1) @@ -11041,6 +11452,13 @@ snapshots: '@tybys/wasm-util': 0.10.4 optional: true + '@napi-rs/wasm-runtime@1.2.4(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1)': + dependencies: + '@emnapi/core': 1.11.1 + '@emnapi/runtime': 1.11.1 + '@tybys/wasm-util': 0.10.4 + optional: true + '@napi-rs/wasm-runtime@1.2.4(@emnapi/core@1.11.2)(@emnapi/runtime@1.11.2)': dependencies: '@emnapi/core': 1.11.2 @@ -11722,6 +12140,70 @@ snapshots: '@opentelemetry/api': 1.10.0 '@opentelemetry/core': 3.1.1(@opentelemetry/api@1.10.0) + '@oxc-minify/binding-android-arm-eabi@0.136.0': + optional: true + + '@oxc-minify/binding-android-arm64@0.136.0': + optional: true + + '@oxc-minify/binding-darwin-arm64@0.136.0': + optional: true + + '@oxc-minify/binding-darwin-x64@0.136.0': + optional: true + + '@oxc-minify/binding-freebsd-x64@0.136.0': + optional: true + + '@oxc-minify/binding-linux-arm-gnueabihf@0.136.0': + optional: true + + '@oxc-minify/binding-linux-arm-musleabihf@0.136.0': + optional: true + + '@oxc-minify/binding-linux-arm64-gnu@0.136.0': + optional: true + + '@oxc-minify/binding-linux-arm64-musl@0.136.0': + optional: true + + '@oxc-minify/binding-linux-ppc64-gnu@0.136.0': + optional: true + + '@oxc-minify/binding-linux-riscv64-gnu@0.136.0': + optional: true + + '@oxc-minify/binding-linux-riscv64-musl@0.136.0': + optional: true + + '@oxc-minify/binding-linux-s390x-gnu@0.136.0': + optional: true + + '@oxc-minify/binding-linux-x64-gnu@0.136.0': + optional: true + + '@oxc-minify/binding-linux-x64-musl@0.136.0': + optional: true + + '@oxc-minify/binding-openharmony-arm64@0.136.0': + optional: true + + '@oxc-minify/binding-wasm32-wasi@0.136.0': + dependencies: + '@emnapi/core': 1.11.1 + '@emnapi/runtime': 1.11.1 + '@napi-rs/wasm-runtime': 1.2.4(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1) + optional: true + + '@oxc-minify/binding-win32-arm64-msvc@0.136.0': + optional: true + + '@oxc-minify/binding-win32-ia32-msvc@0.136.0': + optional: true + + '@oxc-minify/binding-win32-x64-msvc@0.136.0': + optional: true + '@oxc-parser/binding-android-arm-eabi@0.127.0': optional: true @@ -12323,6 +12805,8 @@ snapshots: '@simple-libs/stream-utils@2.0.0': {} + '@sinclair/typebox@0.31.30': {} + '@sindresorhus/is@4.6.0': {} '@sindresorhus/merge-streams@4.0.0': {} @@ -13275,6 +13759,8 @@ snapshots: array-flatten@1.1.1: {} + array-timsort@1.0.3: {} + asciinema-player@3.18.0: dependencies: solid-js: 1.9.19 @@ -13343,6 +13829,8 @@ snapshots: bignumber.js@9.3.1: {} + binaryen@130.0.0: {} + bindings@1.5.0: dependencies: file-uri-to-path: 1.0.0 @@ -13631,12 +14119,19 @@ snapshots: dependencies: delayed-stream: 1.0.0 + commander@11.1.0: {} + commander@14.0.3: {} commander@15.0.0: {} commander@7.2.0: {} + comment-json@4.6.2: + dependencies: + array-timsort: 1.0.3 + esprima: 4.0.1 + compressible@2.0.18: dependencies: mime-db: 1.54.0 @@ -13664,6 +14159,8 @@ snapshots: is-safe-filename: 0.1.1 xdg-basedir: 5.1.0 + consola@3.4.0: {} + consola@3.4.2: {} content-disposition@0.5.4: @@ -14149,6 +14646,8 @@ snapshots: es-toolkit@1.52.0: {} + esbuild-wasm@0.19.12: {} + esbuild@0.28.2: optionalDependencies: '@esbuild/aix-ppc64': 0.28.2 @@ -15086,6 +15585,8 @@ snapshots: kysely@0.23.5: {} + kysely@0.28.20: {} + kysely@0.29.9: {} lande@1.0.10: @@ -15635,6 +16136,29 @@ snapshots: strip-ansi: 6.0.1 wcwidth: 1.0.1 + oxc-minify@0.136.0: + optionalDependencies: + '@oxc-minify/binding-android-arm-eabi': 0.136.0 + '@oxc-minify/binding-android-arm64': 0.136.0 + '@oxc-minify/binding-darwin-arm64': 0.136.0 + '@oxc-minify/binding-darwin-x64': 0.136.0 + '@oxc-minify/binding-freebsd-x64': 0.136.0 + '@oxc-minify/binding-linux-arm-gnueabihf': 0.136.0 + '@oxc-minify/binding-linux-arm-musleabihf': 0.136.0 + '@oxc-minify/binding-linux-arm64-gnu': 0.136.0 + '@oxc-minify/binding-linux-arm64-musl': 0.136.0 + '@oxc-minify/binding-linux-ppc64-gnu': 0.136.0 + '@oxc-minify/binding-linux-riscv64-gnu': 0.136.0 + '@oxc-minify/binding-linux-riscv64-musl': 0.136.0 + '@oxc-minify/binding-linux-s390x-gnu': 0.136.0 + '@oxc-minify/binding-linux-x64-gnu': 0.136.0 + '@oxc-minify/binding-linux-x64-musl': 0.136.0 + '@oxc-minify/binding-openharmony-arm64': 0.136.0 + '@oxc-minify/binding-wasm32-wasi': 0.136.0 + '@oxc-minify/binding-win32-arm64-msvc': 0.136.0 + '@oxc-minify/binding-win32-ia32-msvc': 0.136.0 + '@oxc-minify/binding-win32-x64-msvc': 0.136.0 + oxc-parser@0.127.0: dependencies: '@oxc-project/types': 0.127.0 @@ -16152,6 +16676,8 @@ snapshots: proxy-from-env@2.1.0: {} + pseudo-localization@3.1.3: {} + pump@3.0.4: dependencies: end-of-stream: 1.4.5 @@ -17050,6 +17576,8 @@ snapshots: url-join@4.0.1: {} + urlpattern-polyfill@10.1.0: {} + use-sync-external-store@1.7.0(react@19.3.0): dependencies: react: 19.3.0 @@ -17062,6 +17590,10 @@ snapshots: uuid@14.0.3: {} + valibot@1.5.0(typescript@6.0.3): + optionalDependencies: + typescript: 6.0.3 + varint@6.0.0: {} vary@1.1.2: {} diff --git a/tools/ast-grep/rules/no-raw-text.yml b/tools/ast-grep/rules/no-raw-text.yml new file mode 100644 index 000000000..d47011eba --- /dev/null +++ b/tools/ast-grep/rules/no-raw-text.yml @@ -0,0 +1,28 @@ +# Text a page shows comes from the message catalog (apps/web/messages/en.json, through `m`), so a +# translation can replace it and the en-XA pseudo-locale shows what's left. This finds words written +# straight into a component's markup: its text, and the attributes a screen reader or a tooltip reads +# out. It can't see a string literal inside `{...}`, which en-XA still shows. `files` lists the +# components whose text has moved to the catalog; add each one as it moves. +id: no-raw-text +language: Html +severity: error +message: This writes words into the page instead of taking them from the message catalog. +note: Add the words to apps/web/messages/en.json, run `node scripts/pseudo-locale.ts` in apps/web, and use the message, like `{m.footer_privacy()}`. +files: + - 'apps/web/src/routes/+layout.svelte' +rule: + any: + # A letter outside any `{...}`. An HTML entity like ` ` doesn't count. The HTML parser ends a + # tag at an arrow function's `>`, which puts the rest of the expression in the text (and can lose + # the element's own text), so a run of text that reaches a `}` is code. + - kind: text + regex: '(?:^|\})[^{}&]*\p{L}[^{}]*(?:\{|$)' + - kind: attribute_value + regex: '^[^{]*\p{L}' + inside: + kind: quoted_attribute_value + inside: + kind: attribute + has: + kind: attribute_name + regex: '^(aria-label|aria-description|title|alt|placeholder)$' diff --git a/tools/ast-grep/tests/no-raw-text-test.yml b/tools/ast-grep/tests/no-raw-text-test.yml new file mode 100644 index 000000000..8a85bb4d9 --- /dev/null +++ b/tools/ast-grep/tests/no-raw-text-test.yml @@ -0,0 +1,28 @@ +id: no-raw-text +valid: + - | + {m.footer_privacy()} + - | + + - | + {count} · {m.shows()} + - | + + {m.report()} + - | + + - | + +invalid: + - | + Privacy + - | + Records on {protocol} · private data + - | + + - | + + - | + Mixer