Convention: saved-query discoverability follows Status — Approved is canon, Pending is a draft

Aperta Adatta ai principianti
#6,746 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
sql
Ambito
backend

Direzione di ricerca

Leggi la convenzione e la tabella delle superfici in questa issue insieme ai percorsi citati query-browser-resource.component.ts, search-query-catalog.action.ts e MentionAutocomplete.ts. Verifica i filtri di stato e le eccezioni indicate rispetto al codice attuale, quindi mantieni accurati la regola documentata e l’inventario delle superfici. Il lavoro è completato quando le nuove superfici di elencazione delle query possono seguire la convenzione Approved versus Pending e gli approcci ai permessi rifiutati sono registrati chiaramente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

Agents and users can now save queries from a conversation (#6743: a list made in chat saves its SQL as a query so the list can refresh). That makes MJ: Queries a table ordinary users write to, which it wasn't before, and MJ has no written rule about which saved queries are offered to whom.

This issue records the rule we adopted and the three mechanisms that are not the answer, so the next surface that lists queries stays in line.

The convention

Approved means MJ canon; Pending means a draft that belongs to whoever saved it.

  • Approved queries are discoverable by agents, composable into other queries, and surfaced in search and pickers.
  • Pending queries run — a list refreshes from one, and RunQuery only warns on a non-Approved status — but are not offered on shared surfaces.
  • Approval is the owner's act, and it is what promotes a draft into canon.

This matches what already shipped elsewhere: SkillSmith persists AI Skills as Pending for review, and Search Query Catalog is approvedOnly by default.

It is a discovery boundary, not access control. A Pending query is still runnable by anyone who can read the entities it reads (MJQueryEntityExtended.UserCanRun falls through to entity CanRead when a query has no permission rows), and every run is bounded by that user's own field-level security. Nothing about this hides data; it keeps other people's drafts out of lists, pickers and agent context.

Surfaces that must honour it

Checked on next at 1f821e2:

Surface State
Query Browser tree Already defaults 'Pending': false (query-browser-resource.component.ts:179)
Search Query Catalog action Already approvedOnly by default (search-query-catalog.action.ts:44)
Research Agent AVAILABLE_QUERIES Already Status = 'Approved'
Model Development APPROVED_QUERIES Already Status = 'Approved'
Query Strategist REUSABLE_QUERIES Already Reusable = 1 AND Status = 'Approved'
Query Builder ALL_QUERIES Status = 'Approved' OR Status = 'Pending', with SQL — the one exception; narrowed in #6743
#query mention autocomplete No status test at all (MentionAutocomplete.ts:191) — fixed in #6743

Anything new that lists saved queries belongs in this table.

What is not the answer, and why

  • MJ: Query Permissions — role-only (QueryPermissionProvider.SupportedGranteeTypes = ['Role']), and a role list overrides the entity read checks (stored-procedure semantics, MJQueryEntityExtended.UserCanRun step 2). Adding rows to make a query private widens access instead.
  • RLS on MJ: Queries — UserExemptFromRowLevelSecurity (entityInfo.ts:5581) means a user holding any role with an unfiltered Read grant gets no filter at all, so this only works if the unfiltered grant is stripped from every role in every installation. It also wouldn't restrict execution, since server-side query resolution runs as the system user by design.
  • A visibility column on MJ: Query Categories — UserID there is "created by" and NOT NULL, so it can't be repurposed, and a bespoke column would be a third mechanism beside MJ: Resource Permissions (where Queries is already a registered resource type) and the MJ: Search Scope Permissions shape.

If we want real per-principal query permissions

Do it once, as its own piece of work, in the MJ: Search Scope Permissions / proposed MJ: Graph Permissions shape from #6723: a UserID-or-RoleID principal with a PermissionLevel that includes an explicit None deny. That would need an owner column on MJ: Queries (today the entity has only ApprovedByUserID), and it is also the prerequisite for letting a gated action save a draft on a user's behalf — without it, such a query is unattributed in Record Changes and its owner can neither edit, delete nor approve it.

Related

  • #6743 — lists from queries and conversations (first consumer; narrows ALL_QUERIES and the mention list)
  • #6642 — list refresh from a saved view or query
  • #3485 — least-privilege filtering of client-shipped metadata; its item 4 is saved-query SQL. Partly stale: LoadQueryMetadata now defaults off and the provider sends 1=0 item filters for the whole query family (providerBase.ts:1071), so query SQL no longer rides the MJ_Metadata dataset by default
  • #6723 — per-graph permissions; the reference shape for per-principal resource permissions
Lingua principale
TSQL
Stelle
32
Fork
7
Merge medio
1g 16h
PR unite (30g)
504

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di MemberJunction/MJ

Tutte le issue di MemberJunction/MJ

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.