Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
8.4 KiB
PRD — Client Portal Board Visibility Model Correction
- Slug:
client-portal-board-visibility-model-correction - Date:
2026-04-15 - Status: Draft
Summary
Correct the Client Portal Board Visibility Groups implementation to match the intended data model: visibility groups remain client-scoped, but board IDs inside those groups are tenant-scoped visibility controls rather than client-owned records. Remove the invalid boards.client_id assumption from board pickers, group validation, and visibility resolution while preserving the original product behavior for MSP staff, client portal admins, and restricted portal users.
Problem
The shipped feature and migration model visibility groups as client-scoped records containing board IDs, but current implementation paths assume boards themselves belong to a client via boards.client_id. The real schema does not contain that column. This mismatch produces intermittent 500s, false empty states like "No boards available," and risks incorrect server-side visibility enforcement.
Goals
- Align the implementation with the intended model: groups are client-scoped and boards are tenant-scoped.
- Remove all runtime dependence on
boards.client_idfor this feature. - Keep MSP and client portal admin group management working with active tenant boards.
- Preserve server-side enforcement for ticket list, detail, dashboard, and ticket creation.
- Preserve backward compatibility for unassigned contacts and existing invitation / onboarding flows.
- Clarify the effective model in plan documentation so future work does not reintroduce the same assumption.
Non-goals
- Introducing a new client-owned board schema or board-client mapping table.
- Expanding the feature beyond ticket visibility into projects, billing, assets, or documents.
- Changing one-group-per-contact behavior.
- Changing lock semantics, precedence semantics, or assignment ownership semantics.
- Redesigning portal invitation or account creation flows beyond what is needed to keep this feature compatible.
Users and Primary Flows
MSP staff
- Open a client contact in the PSA portal tab.
- Create or edit visibility groups for that contact's client.
- Choose allowed boards from all active tenant boards.
- Assign a visibility group to the contact or reset to full access.
- Expect the contact's portal visibility to update immediately.
Client portal admin
- Open client settings under the visibility groups tab.
- Create or edit visibility groups for their own client.
- Choose allowed boards from all active tenant boards.
- Assign a visibility group to contacts from their own client.
- Expect restricted users to only see tickets on allowed boards for that client.
Standard client portal user
- Sign in as usual.
- See only tickets where
ticket.client_idmatches the user's client andticket.board_idis allowed by the assigned group. - Be blocked from viewing or creating tickets on disallowed boards.
- Continue seeing full access when no group is assigned.
UX / UI Notes
- MSP and client-portal board pickers should show all active tenant boards.
No boards availableshould only render when the tenant truly has no active boards.- Existing group-management labels, assignment labels, and empty-group messaging remain unchanged unless implementation finds a mismatch.
- If a board already in a group later becomes inactive, keep the membership record but exclude that board from board pickers and new ticket creation choices.
- Existing assigned groups with inactive boards should not silently disappear from storage.
Requirements
Functional Requirements
- Board pickers for MSP and client-portal group management must load active tenant boards without requiring
boards.client_id. - Group create/update validation must accept submitted board IDs that exist in the tenant and are active.
- Group create/update validation must reject missing, cross-tenant, or inactive board IDs.
- Group assignment must continue validating client ownership through
group.client_idandcontact.client_id. - The shared portal visibility resolver must verify
group.client_id === contact.client_id. - The shared portal visibility resolver must derive visible board IDs from
client_portal_visibility_group_boardswithout requiring client-owned board rows. - Ticket list queries must continue enforcing
ticket.client_id = contact.client_idand apply board filtering only when a group is assigned. - Ticket detail and ticket-adjacent loaders must continue failing closed when a ticket is on a hidden board.
- Ticket creation must continue restricting available boards and rejecting submissions to disallowed boards.
- Dashboard ticket-backed counts and summaries must continue respecting visible board IDs.
- Unassigned contacts must remain unrestricted within their own client.
- Empty groups must still yield no visible boards and no ticket creation options.
- Existing pre-invite contact assignment behavior must remain valid.
- Deleting an assigned group must remain blocked.
Non-functional Requirements
- Enforcement must remain server-side for ticket visibility and ticket creation.
- The correction must not require schema changes or data backfills.
- Tests must include real DB-backed integration coverage for the corrected board-selection and visibility logic.
- The change must not broaden access across clients.
- The change must not reintroduce false empty states caused by invalid board ownership assumptions.
Data / API / Integrations
client_portal_visibility_groupsremains the source of client ownership.client_portal_visibility_group_boardsremains a(tenant, group_id, board_id)membership table.contacts.portal_visibility_group_idremains the assignment field.boardsshould be treated as tenant-scoped records for this feature.- Ticket enforcement should continue relying on
tickets.client_idfor client isolation. - If inactive boards need to be filtered from group resolution or ticket creation, that should be done through the existing
boards.is_inactiveflag rather than a client ownership check.
Security / Permissions
- MSP actions must continue requiring contact update permission.
- Client portal admin actions must continue requiring a client portal user whose linked contact is marked
is_client_admin. - Group CRUD and assignment must still reject cross-client access.
- Ticket list/detail/create/dashboard must still fail closed for hidden boards.
- The correction must not make it possible for a user from one client to see another client's tickets by sharing a board ID.
Observability
Normal server logs and test coverage are sufficient. If implementation uncovers ambiguous failures during smoke testing, add clear server error logging around invalid board submissions and invalid group/contact relationships, but do not expand scope into new telemetry by default.
Rollout / Migration
- No schema migration is required.
- Existing group and assignment records should continue working after the correction.
- Existing unassigned contacts retain full access.
- After rollout, smoke validation should use a seeded Emerald City scenario covering restricted, full-access, and pre-invite contacts.
Open Questions
- Whether inactive boards should still count as visible for historical ticket-detail access or only be excluded from pickers and creation. Current design preference is to keep historical membership data intact and exclude inactive boards from pickers and new ticket creation choices.
Acceptance Criteria (Definition of Done)
- MSP visibility-group management no longer queries
boards.client_idand no longer produces false "No boards available" states. - Client portal admin visibility-group management no longer queries
boards.client_idand no longer produces false empty board pickers. - Group create/update accepts active tenant board IDs and rejects invalid or inactive board IDs.
- Shared visibility resolution validates group-to-contact client ownership via
group.client_idandcontact.client_id, not viaboards.client_id. - Restricted users still only see their own client's tickets on allowed boards.
- Full-access users still retain unrestricted access within their own client.
- Ticket detail, ticket documents/comments, dashboard counts, and ticket creation all remain server-side enforced.
- No schema changes are introduced.
- Tests cover the corrected model and smoke setup can proceed against the seeded Emerald City scenario.