PURE · Identity · Hats, Orgs & Act-As

Hats Model & View-As Redesign

How a user wears one hat of many, switches to the hats that hat is allowed to assume, sees only the organizations that hat can reach, and acts either as a staff member beneath it or for a client on their behalf — plus the redesigned identity dropdown that makes it dynamic and DB-backed. Model locked 7/6/26.

Owner: Lane A (Shattique) · Backend: Code · Data: pure_identity_hats, pure_orgs, pure_hat_relationships, deal/party junctions · CT 7/6/26

Locked ruleset Core concepts Levels & org scope Two act-as modes Data model Resolution logic Dropdown redesign Execution plan

Locked ruleset — the decisions

Everything below was confirmed with Shattique on 7/6/26. These are the governing rules; the rest of the doc details how they are built. This same list is mirrored in the site standards doc.

1
Dropdown is staff-only. The detailed View-As dropdown renders only for identities holding ≥1 staff hat (levels 0–4). Clients, vendors (level 5) and public (level 6) never see it — they get the plain account menu.
2
Two chip rows. Row 1 = your assigned hats (highest auto-selected on login). Row 2 = organizations to narrow the target. Levels 0–3 choose an org or All orgs; level 4 is locked to its single brokerage; an agent belongs to exactly one brokerage.
3
One unified funnel — no separate Clients tab. The ROLE column lists accessible staff hats and, at the bottom, the reachable level-5 entries (Client · Vendor). Picking a staff role act as that person (borrow their hat); picking Client/Vendor act for that person (on-behalf). Distinguished only by the action verb and the acting banner.
4
Act-as is strictly downward. A target's rank must be strictly below your worn hat's rank. Never sideways, never up — even through a temporarily-granted hat.
5
ROLE is optional. No role chosen = you simply operate as your worn hat (pages + data at your own authority). Choosing an org alone (no role) = view that org through your own hat. Role + user = full act-as.
6
All orgs = filter only. It widens the search across the whole system; the moment you act as someone, scope snaps to that user's org — a global filter never becomes a global write.
7
Act-as re-scopes the whole session, including page gates. While acting, every gate reads the target's permission set; the "Exit act-as" pill stays visible everywhere.
8
Client reach is relationship-scoped. Level 5 has no parent org — clients/vendors attach to orgs through deals. "Clients you can act for" = agent own clients; broker brokerage's clients; site admin all. Same-level ties break on the is_primary org flag.
9
Poppy (level 0) is Super-Admin-only. Only a Super Admin may hold, wear, or reach the level-0 Poppy orchestrator. No other hat can be granted or act-as level 0.

1Core concepts

1
Many hats per user. A person holds a set of hats (each hat = a role in an org). Already modeled in pure_identity_hats (18 hats, 8 orgs today).
2
Default = highest hat. On login the hat with the highest authority (lowest level number) is worn automatically; is_primary breaks same-level ties.
3
Wear an accessible hat. From the worn hat, the user may switch to any hat that hat is allowed to assume — defined in the admin-managed hat-relationship graph, not hard-coded.
4
Act as / act for. Under the worn hat, impersonate a staff member beneath it (Mode A) or borrow a connected client's context to work on their behalf (Mode B). Both server-side and audited.
5
Org scope by level. Levels 0–3 reach across orgs (choose / All-orgs); level 4 is locked to its one brokerage; level 5 is a relationship graph, not a branch; level 6 is public.

2Levels & organization scope

The canonical 7-level ladder (from the org-hierarchy doc). MLS sits above Association. Levels 0–3 are cross-org; level 4 is bound to one brokerage; levels 5–6 have no hats and no dropdown.

L0Poppyorchestrator — Super Admin onlyAll orgs
L1PUREplatform — superadmin, techAll orgs
L2MLSMLS body — e.g. NTREISJurisdiction
L3Associatione.g. MetroTex — staff, committeesJurisdiction
org auto-selected & locked below this line
L4Brokeragee.g. Acquisto — broker, DB, TC, agent, ISAOwn brokerage
L5End usersclients & vendors — no hats, no dropdownRelationship graph
L6Publicnon-logged-in / guestNo identity

Example: a Designated Broker at Acquisto wears an Agent hat the org row is locked to Acquisto, and accessible hats show only roles reachable inside Acquisto. A PURE superadmin gets the org picker plus All orgs to search every user in the system.

3One funnel, two verbs

There is no separate Clients tab. Client & Vendor already exist as level-5 rows in pure_hats, so they sit at the bottom of the same ROLE column when reachable. One consistent mental model — pick a role pick a person — where the kind of role decides the verb.

Act as staff (staff role selected)

Borrow another staff member's hat / authority. Downward-only, org-scoped, targets levels 0–4. Button reads Act as; the pill says Viewing as Agent X.

Act for a client / vendor (level-5 role selected)

Borrow a level-5 identity's context to do client-side work — property search, favorites, saved searches, portal actions — with the client's capabilities, not staff powers. Button reads Act for; the pill says Acting for Client Y; audited as "Agent X acting for Client Y."

Reach scales with level: an agent reaches only their own clients (linked through a deal); a broker/brokerage admin reaches any client on the brokerage's deals; a site admin (All orgs) reaches any client. The contextual "Act for this client" button on a client/deal record opens the same flow pre-targeted — the primary entry in practice.

4Data model

One catalog table, one relationship table, the existing assignment table, and the existing deal/party junctions for client reach — all admin-editable.

TableShape & purpose
pure_orgs newid, name, level ('poppy'|'pure'|'mls'|'association'|'brokerage'), parent_id — the org tree for levels 0–4. Level 5/6 are not rows here (no parent org).
pure_hats (catalog) newid, label, level int, rank int — the staff hat types + level number that drives "highest" and scope.
pure_identity_hats existsuser_id, hat_id, org_id, is_primary — who holds which hat in which org. 18 rows today; add FKs to the two catalogs.
pure_hat_relationships newfrom_hat, can_wear_hat, org_scope ('own'|'descendants'|'all') — the delegation graph. "A Designated Broker may wear Agent / ISA / TC within its own org." The "hats relationship management" surface.
deal / party junctions existsclient deal (agent · brokerage). This is what makes act-for reach relationship-scoped — no parent_org on a client; reach = the junction rows that link a client to me or my org.

5Resolution logic

A
Assigned hats = select * from pure_identity_hats where user_id = me. No staff hat no dropdown (rule 1).
B
Default worn hat = lowest level (highest authority); is_primary breaks ties (rule 8).
C
ROLE column = accessible staff hats (can_wear_hat where from_hat = worn, ∩ selected org, strictly lower rank — rule 4) plus reachable level-5 rows (Client · Vendor) appended at the bottom.
D
Org row = worn level ≤ 3 choose org or All-orgs; level 4 locked to the one brokerage (rules 2, 6).
E
Staff role users = pure_identity_hats where org = selected and hat = selected role newest 10; search extends via DB over the whole eligible set. Action verb = Act as.
F
Client/Vendor role people = deal/party junction rows linking a client to me (agent) / my org (broker) / anyone (site admin). Search over the whole reachable set. Action verb = Act for.
G
Act = gated, audited RPC. Scope snaps to the target's org; the whole session (incl. page gates) reads the target's permissions until Exit (rules 6, 7).

6The redesigned dropdown

The two-chip context row up top, then the scoped columns. The ROLE column carries staff hats and, at the bottom, the reachable Client/Vendor entries — no separate tab. Everything below is live from the DB.

Wear a hat · Act as staff · Act for a client
Michael Acquisto — Designated Broker · live from pure_identity_hats
Row 1 — your hats (highest selected)
Designated Broker L4 Agent L4
Row 2 — organization
Acquisto Real Estate 🔒 own org

L4 hat org locked to Acquisto. An MLS/Association/PURE hat unlocks the org picker + All orgs.

AAccessible roles in Acquisto
AAgent14
IISA2
TTransaction Coordinator1
End users · act for
CClientreach
VVendorreach

Staff hats the worn hat may assume (strictly lower rank, pure_hat_relationships) + reachable level-5 rows below the divider.

BUsers · newest 10 Agent · Acquisto
AAmy Gasperini
agent · Acquisto
Act as
DDmitriy Uchitel
agent · Acquisto
Act as
HHannah Ewing
agent · Acquisto
Act as

No role chosen = just operate as your worn hat.

Selecting Client or Vendor fills the right column with your reachable people (for an agent, the clients on their own deals) and the button reads Act for instead of Act as. The contextual "Act for this client" button on a client/deal record opens this same flow pre-targeted.

7Execution plan

Phased, additive, reversible — and it dovetails with the Auth Window (RLS makes the scope a real boundary, not just a UI filter).

#PhaseOwner
1Catalog + relationships. Create pure_orgs, pure_hats, pure_hat_relationships; add FKs to pure_identity_hats; seed the hats, the 7-level orgs, and the starter delegation graph.Design Code
2Read APIs. my_hats(), accessible_hats(worn,org), org_scope(worn), users_for(org,hat,search,limit), clients_for(me,search,limit), hat_counts(org). Read-only, PostgREST-friendly.Code
3Rebuild the dropdown — two-chip context row, locked-org for L4, unified ROLE column (staff hats + reachable Client/Vendor), DB search, staff-only render gate. Falls back to current behavior if APIs absent.Design
4Hat-relationship admin surface in Admin Center to manage pure_hat_relationships — who may wear whom, per scope.Design
5Server-side Act-As / Act-For. Gated, audited RPCs enforcing rank + scope for both modes — ties into Auth Window AW-4/AW-7 so impersonation holds under RLS.Code
6Backfill. Assign every L4 user to their brokerage; give real users their true hats; wire client reach off the deal/party junctions.Mike Design
Sequencing note.

Phases 1–4 are additive UI/data work, safe to build now. Phase 5 (server-enforced Act-As/Act-For) lands with the Auth Window RLS so impersonation is a real, audited boundary — not before, or it's cosmetic and bypassable.


PURE MLS Technologies · Hats, Orgs & Act-As — Model + Redesign Plan · model locked with Shattique 7/6/26 · prepared by Lane A