Skip to content

query: express identity/organization scoping of results #36

Description

@woksin

Summary

Queries cannot express that their result set is scoped to the calling identity (or the caller's organization/tenant). authorize states who may call a query; nothing states what subset of the data the caller sees — yet "my items", "my organization's items" is one of the most common query shapes in a multi-actor application, and the distinction between All (advisor sees everything) and Mine (consultant sees their own) is precisely what a reader of the document needs in order to understand the access model.

Evidence (real application)

In Ada, at least 16 queries are identity-scoped, visible in their names and their IIdentityAccessor usage: Mine (×5), ForCurrentPartner (×6), ForCurrentCustomer (×4), ForCurrentAccess. Example:

public static ISubject<IEnumerable<Timesheet>> Mine(
    IMongoCollection<Timesheet> collection, IIdentityAccessor identityAccessor) => ...

The generated document renders these identically to unscoped queries:

query Mine => Timesheet[]
  authorize Consultant

which reads as "any consultant can query all timesheets" — the opposite of what the code does.

Suggested direction

A scoping declaration on the query (syntax open):

query Mine => Timesheet[]
  scoped to identity
  authorize Consultant

query ForCurrentPartner => PartnerEngagement[]
  scoped to identity organization

Alternatively a by $identity...-style parameter convention reusing the existing by clause. The ask is that caller-scoping is statable; the shape can follow whatever identity model Stage exposes.

Context

Found while validating a generated 5,348-line document from a production Arc application against its source (Cratis.Arc.Screenplay 20.65.0).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions