Skip to main content
Several Contacts modules used to answer every non-happy path with notFound(). That hid the three situations an operator can actually act on, and it hid a plain bug: pages 404’d personal workspaces even though the sidebar links them and the underlying APIs normalize personal into a real workspace id. Those pages now resolve one of four states through resolveWorkspaceFeatureAccess.

Gate states

The order matters: an unresolved workspace is reported before a permission denial, and a permission denial before the toggle, so a member never learns a module’s configuration from a page they cannot open.

Modules and toggles

Shared workspaces keep whatever each module defaulted to before the gate existed, so no workspace loses a module. Personal workspaces start opted out and opt in from the page itself, which is what replaces the old hard 404.
Approvals has no module toggle of its own: ENABLE_POST_APPROVAL and ENABLE_REPORT_APPROVAL already govern approval behavior, and a third switch would be ambiguous. Approvals also stays unavailable in personal workspaces by product decision — it renders an explanation, not a 404.

Writing a toggle from Contacts

Config toggles go through the Contacts-owned route PUT /api/v1/workspaces/{wsId}/settings/{configId}, which is satellite-session aware. Reading a toggle needs only the module’s view permission; writing needs manage_workspace_settings. Topic announcements is a workspace secret, not a config, and the platform secrets endpoint authenticates through the Supabase cookie — which resolves anonymous on a satellite domain, so every write from Contacts 401s there. PUT /api/v1/workspaces/{wsId}/settings/feature-secrets/{secretName} exists for exactly that case. It is deliberately not a general secrets endpoint:
  • only names in CONTACTS_FEATURE_SECRET_NAMES are addressable;
  • only the literal values true and false are accepted;
  • the caller needs manage_workspace_secrets or manage_workspace_roles in the root workspace, and ENABLE_REPORT_EMAIL_SENDING also needs send_user_group_report_emails in the target workspace;
  • it never reads a secret back.

Product decision: platform-controlled module secrets

Scope: ENABLE_TOPIC_ANNOUNCEMENTS, ENABLE_TOPIC_TEACHER_ASSIGNMENTS and ENABLE_REPORT_EMAIL_SENDING, plus every other workspace_secrets name. These switches are platform entitlements, default Off, and only Tuturuuu platform admins (root manage_workspace_secrets or manage_workspace_roles) change them. A workspace-level manage_workspace_secrets grant is never enough: workspace creators and admin members imply it for their own workspace, so it would let any owner self-enable a module that sends platform email. Affected surfaces: the Contacts feature-secret route and the topic announcements Disabled gate (its Enable button shows only for platform admins; workspace owners ask Tuturuuu support), the report schedule canConfigureReportEmailGate capability, the web and workspace Settings → Secrets routes, and the storage provider migrate and rollout-state routes. All of them match the root-only RLS policy on public.workspace_secrets. Exceptions: none. A future runtime flag can give one key a workspace-admin controller through a separate product decision. Regression coverage: packages/users-core/src/routes/settings/feature-secrets/platform-controller.test.ts, packages/users-core/src/routes/users/reports/schedules-route.test.ts, apps/contacts/src/app/[locale]/[wsId]/users/topic-announcements/layout.test.tsx, apps/web/src/legacy-api-routes/workspaces/[wsId]/secrets/access.test.ts and apps/web/src/legacy-api-routes/v1/workspaces/[wsId]/storage/platform-controller.test.ts.
workspace_secrets has no unique index on (ws_id, name), and the platform endpoint inserts without checking, so a workspace can hold duplicate rows for one name. The feature-secret route updates every matching row before falling back to an insert, which also repairs those duplicates. Do not switch it to an upsert with a conflict target until that index exists.

Creating group score indicators

The indicator name is required before creation is enabled. Indicator and metric category dialogs keep their action footer inside the viewport and scroll the form body, including long category lists. Failed creation keeps the draft open and shows an inline error so the user can retry. Repeated taps during a pending save submit once. Creation still requires create_user_groups_scores; members with that permission use the same path as administrators.

Topic announcement list and preview admission

Contacts owns the collection GET and preview POST locally. Both resolve the verified Contacts app-session actor and workspace membership before reading topic content, then require ENABLE_TOPIC_ANNOUNCEMENTS to equal true, a non-personal workspace, and manage_users. The module remains off by default; listing or previewing does not enable it or send email. Preview uses only contacts in the requested workspace that are not archived. Web accepts its normal Supabase sessions and verified Contacts app sessions, then checks workspace membership using that verified actor. App-session tokens for other satellites or the CLI are rejected before workspace lookup; real-verifier coverage lives in apps/web/src/lib/topic-announcements-audience.test.ts. The topic master flag remains an exact true check in the API. Both apps use the same users-core query, payload validation, recipient verification status, attachment filename normalization, and preview renderer. Contacts forwards collection mutations to Web after its existing session and API edge guards. All nested topic API paths also forward explicitly to Web, except the local preview POST. Contacts, templates, create and send retain their existing manager permissions when teacher assignments are off. Schedule APIs and the sidebar schedule child require ENABLE_TOPIC_TEACHER_ASSIGNMENTS=true; the flag defaults off. Personal workspaces remain denied by the API. Teacher access still requires the per-route capability and assignment scope. Synthetic route regressions cover Contacts and Templates GET, Add Contact POST, the enabled monthly schedule with GVCN, and denied identity, membership, permissions, flags and personal workspaces in apps/web/src/lib/topic-announcements-satellite.test.ts. Proxy and sidebar regressions live in Contacts. These checks do not establish live deployment or provider-delivery readiness. Regression coverage exercises the local Contacts routes with the actual workspace access helper, denied sessions and membership/capabilities, shared recipient serialization, and exact-method forwarding. Web route and renderer regressions preserve its existing behavior. These adapter-level checks require exact-app CI build and authenticated runtime verification before delivery is confirmed. Before dispatch preparation, the topic sender rechecks the current workspace ENABLE_TOPIC_ANNOUNCEMENTS secret. Missing or non-true values deny sending. Every linked recipient must still exist, belong to that workspace, and be active; a missing, archived, or moved recipient blocks the entire intended batch. It does not silently send to fewer recipients. Database read errors remain failures. This prerequisite does not change announcement history, statuses, or queue leases. Provider acceptance, durable receipt publication, and safe recovery from ambiguous processing remain separate delivery requirements.

Reusing an existing topic contact

The Add Contact dialog in Contacts can search this workspace’s existing topic announcement contacts by name or email through the manager-only contacts lookup, which excludes archived contacts. Options show the name with the email, so repeated names stay distinguishable. Picking one fills its stored email, tags and linked user read-only and keeps its exact contact ID; confirming closes the dialog without a create request. The default stays “Create a new contact”, and manual entry is unchanged. A choice outside the current workspace results, an archived contact, or one without an email is rejected with an inline message. Reuse never creates, links or assigns a teacher, and it does not change verification status or the send gates above. Regression coverage lives in Contacts contact-form.test.tsx and existing-contact-selection.test.ts.

Inert topic delivery ledger

The private delivery-attempt foundation reserves a parent revision and an immutable attempt snapshot. It has no service write API, no sender integration, and no historical backfill. Readiness explicitly reports activationEnabled: false. Existing announcement, recipient, attachment, queue, and feature-toggle behavior stays unchanged; the topic feature remains off by default. This foundation alone does not repair uncertain delivery or prevent replay by the existing queue. The topic-delivery-foundation-contract.yaml workflow applies the complete schema, runs strict pgTAP and real two-connection ownership/snapshot contention, and generates actual schema types for the exact commit. Local source checks are not SQL or provider-delivery proof. Browser roles cannot access the new private ledger, and its service role receives read access only. Activation requires a separate reviewed atomic caller conversion, current feature and actor-permission admission, and an accepted/rejected/unknown provider-outcome contract. No uncertain attempt may be treated as a safe automatic retry or discarded history.

Attendance edits during saving

Contacts and shared group attendance rosters keep edits made while a save is in flight. Success acknowledges only the submitted draft entries in their original workspace, group, date, and session. Later edits remain visible and available for an explicit subsequent save, including an edit back to the original text. Drafts stay pending until saved or explicitly reset; changing attendance scope starts a new draft. The submitted transport still includes the complete status and note. A rejected save reports the error, keeps the draft visible, and leaves retry to the user; it does not clear the draft or refresh it from stale server data. The deferred-save component regressions in apps/contacts/src/__tests__/attendance-note-save.test.tsx cover later edits, reverting text during a save, rejected saves and explicit retries, status-only changes, explicit empty notes and reloads, and older saves completing after workspace, group, date, or session navigation. This rule does not change explicit attendance clearing or post-check reset semantics, and does not recover historical notes.

Class-post dialog updates

Contacts class-post dialogs update only fields changed since that dialog opened. Saving a title or content edit leaves untouched class-post notes on the server, including notes saved by another editor. Explicit empty or null notes still clear the field. Creation sends the complete title, content and notes payload. Create fields are locked while submission is pending so later edits cannot create a duplicate post. Failed saves retain the draft. A completed save closes only its submitted draft; newer edits or a different workspace, group or post stay open. This protects local edits and untouched fields, but concurrent edits to the same field still use the server’s last write. It does not apply to attendance or recipient check notes and does not recover previously lost content. Regression coverage: Contacts use-posts.test.tsx exercises the real dialog hooks and source API transport for stale snapshots, explicit clears, failed saves, newer edits, target changes and full creation payloads.

Recipient remarks with completion changes

On Contacts class-post recipient cards, Complete and Incomplete save the current remark together with the completion state when that card has local remark edits. An untouched remark is omitted so a stale card cannot overwrite a newer server remark. Explicit empty text clears the remark. The separate Save action remains available; typing alone does not save or create a navigation-safe draft. A successful request acknowledges only its submitted remark revision. Later edits, including a revert while saving, remain pending for the next action. Rejected saves retain the draft for an explicit retry. Each card writes only its recipient; existing approval and delivery behavior and explicit Reset remain unchanged. This rule does not recover previously lost remarks. Regression coverage: recipient-note-completion.test.tsx mounts real cards with source API serialization and persistent synthetic HTTP storage, then remounts from stored rows. It covers multiple recipients, completion and explicit Save, pristine concurrent server updates, later edits/reverts, rejected saves/retries and explicit clearing. The synthetic store does not certify deployed database triggers.

Group data and workspace member controls

Linked-product creation in Contacts and Inventory, and linked-product edits in Contacts, require the product, warehouse and unit to belong to the authorized workspace and to form an existing inventory combination. Reads also exclude pre-existing links to another workspace’s product catalogue. Periodic report export, history and delivery diagnostics follow the same group access as the report list: readers need view_user_groups_reports and access to the report’s group. manage_users permits workspace-wide group access. Both the report subject and group must belong to the authorized workspace. Delivery previews and the preview, test, send, retry and cancel actions apply the same rules on top of send_user_group_report_emails: a report outside the workspace or outside a group-limited sender’s groups returns 404 with no preview and no queued email. Teach course member lists retain student names but mask email unless the reader has view_users_private_info. Workspace role assignment through Web or the CMS team adapter accepts only existing workspace members. Batch onboarding invitations require manage_workspace_members and honor the workspace’s DISABLE_INVITE setting, matching individual invitations. Existing seat checks still apply. Regression coverage: packages/users-core/tests/routes/group-scope-boundaries.test.ts, packages/users-core/src/routes/users/reports/delivery-group-scope.test.ts and apps/web/src/__tests__/member-access-boundaries.test.ts.