Skip to content

ADR-0094: portalr's commands: its admin's reads, and the tenant and member it makes

Status: Accepted Date: 2026-11-01 Deciders: Alex Nodeland Implements: lattice RFC-0014's portalr catalog (phase 1, #916); on lattice ADR-0041

Context

RFC-0014 gives each package a static catalog of commands. portr, portalr's client and the parity test read it without a database. RFC-0014 gives portalr's catalog "its reads (telemetry, spend, usage, deployment), invites, tenants", and makes grantr:create_tenant portalr's command rather than grantr's.

portalr's routes ask three actions of its own (portalr.actions):

  • portalr:read_telemetry, for a tenant's traces, logs, metrics, scores, feedback and adoption;
  • portalr:read_spend, for its spend and usage;
  • portalr:read_deployment, an operator's, for every tenant and the deep links into the stack's tools.

portalr also creates a tenant and invites a member through Supabase Auth, after asking grantr's grantr:create_tenant and grantr:add_member. Its other routes are its UI's own, gated by no action:

  • a person's analytics consent and session;
  • the names of people;
  • the models a turn may use, which artifactr:use_model gates in artifactr's catalog.

Decision

  • portalr.commands imports pydantic, lattice-core's capabilities and commands, portalr.actions and the readers' query models. It imports no web framework and no HTTP client, which a test holds it to, and CATALOG reads no tool.
  • 14 commands, portalr.<name>, version 1.0.0, all in the admin toolset, each routed to its page in portalr's admin.
    • Twelve reads, each read with reads_private, gated by the action its route asks. Each read takes its route's query, the readers' own model (TraceQuery, LogQuery, MetricQuery, Window, FeedbackQuery, UsageQuery, AdoptionQuery), so a client asks what the admin asks.
      • The telemetry reads: portalr.list_traces, read_trace, read_logs, read_log_line, read_metrics, read_scores, read_feedback and read_adoption.
      • The spend reads: portalr.read_spend and read_usage.
      • The deployment reads: portalr.list_deployment_tenants and deployment_links. A link made is still recorded, as the route records it.
    • portalr.create_tenant, gated by grantr:create_tenant, and portalr.invite_member, gated by grantr:add_member. Each is write, compensable, and sends_out: each has Supabase email someone outside the tenant. So the taint policy can refuse a run that read untrusted content from inviting an address it was handed.
  • Every one of portalr's actions is a gate, so LISTED is empty. A test holds the grantr actions to the strings portalr's routes ask.
  • Not commands: the UI's own routes above. RFC-0014's x-lattice-command on every operation, which the parity test reads, will mark them as the UI's.
  • Published as schemas/portalr.commands.json, regenerated by portalr:schema and checked for drift.

Options considered

Option A: A read's arguments are its route's query model (chosen)

Pros: one schema for the route and the command, as RFC-0014 asks: "generated from the pydantic models the REST ... surfaces already validate". Cons: the catalog imports the readers' modules, which also hold their HTTP clients, though it calls none.

Option B: Arguments declared again in the catalog

Cons: two schemas for one read, which drift.

Option C: The invite and tenant commands in grantr's catalog

Cons: RFC-0014 makes creating a tenant portalr's, and both go through Supabase Auth, which only portalr knows.

Consequences

  • Easier: the parity test, portalr's CommandName and portr's tools read portalr's commands with every other catalog's. A client can read a tenant's traces, logs and spend where an operator could.
  • Harder: a new route of portalr's needs a command, or a reason it is the UI's own.
  • Harder: portalr no longer imports at lattice-core-ai 0.2.0, the newest on PyPI, which lacks capabilities and commands. scripts/lowest_direct.py expects that until its floor rises with the next lattice-core release.

Action items

  1. portalr.commands and its schema, tested against portalr's actions and routes.
  2. x-lattice-command on every operation, and the UI's own routes marked so (the parity test, #916).
  3. The bound provider, with portr (#917).