IF Commons GitHub

logical/authorize

Written to: 5 requirements: 5 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-tenancy FR-001, 0002-tenancy FR-002, 0002-tenancy FR-003, 0002-tenancy FR-004, 0002-tenancy FR-007

Who may do what to which tenant (0002-tenancy FR-001 to FR-004, FR-007): deny by default; a grant counts only while it is live, only for a principal of a party that may hold it (the client itself, or an operator with a live engagement with the client), and only for the actions of its role. A portfolio shows a principal the tenants they may read and totals over those alone, so that what a principal may not see is neither listed nor counted. The decision names its reason, and everything is a pure function of the model and the instant.

import { decide } from "./authorize.ts";
decide({ parties: [], principals: [], engagements: [], grants: [] }, "x", "t", "read", "2026-11-21T00:00:00Z").allow; // false

Source: commons/tenancy/src/logical/authorize.ts

4 of 14 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

logical.Decisiontypeno test imports it
type Decision = { readonly allow: boolean; readonly reason: string; readonly role?: Role };

A decision: whether, and why.

logical.problemsOffunctionno test imports it
function problemsOf(m: Model): readonly string[]

The rules the model must keep, as problems (none where it keeps them): grants and engagements name known parties, a grant is held by the client itself or by an operator engaged with it, and a validity ends after it begins.

logical.decidefunctionno test imports it
function decide(m: Model, principalId: string, tenant: string, action: "administer" | "approve-change" | "determine" | "export" | "read" | "record-evidence", now: string): Decision

Whether a principal may do an action to a tenant at an instant.

logical.visibleTenantsfunctionno test imports it
function visibleTenants(m: Model, principalId: string, now: string): readonly string[]

The tenants a principal may read at an instant, in order.

logical.TenantSummarytypeno test imports it
type TenantSummary = { readonly tenant: string; readonly asOf: string; readonly rollups: Readonly<Record<string, number>>; readonly findings: Readonly<Record<string, number>> };

What a tenant shows of itself to a portfolio: counts only, no evidence and no names of assets.

logical.Portfoliotypeno test imports it
type Portfolio = { readonly tenants: readonly TenantSummary[]; readonly total: { readonly rollups: Readonly<Record<string, number>>; readonly findings: Readonly<Record<string, number>> } };

A principal's view of a portfolio.

logical.portfoliofunctionno test imports it
function portfolio(m: Model, summaries: readonly TenantSummary[], principalId: string, now: string): Portfolio

The portfolio a principal may see: the summaries of the tenants they may read, and totals over those alone.

Decisiontypeno test imports it
type Decision = { readonly allow: boolean; readonly reason: string; readonly role?: Role };

A decision: whether, and why.

problemsOffunction
function problemsOf(m: Model): readonly string[]

The rules the model must keep, as problems (none where it keeps them): grants and engagements name known parties, a grant is held by the client itself or by an operator engaged with it, and a validity ends after it begins.

Imported by 6 tests of the run (6 passed, 0 failed): the library's results

decidefunction
function decide(m: Model, principalId: string, tenant: string, action: "administer" | "approve-change" | "determine" | "export" | "read" | "record-evidence", now: string): Decision

Whether a principal may do an action to a tenant at an instant.

Imported by 6 tests of the run (6 passed, 0 failed): the library's results

visibleTenantsfunction
function visibleTenants(m: Model, principalId: string, now: string): readonly string[]

The tenants a principal may read at an instant, in order.

Imported by 6 tests of the run (6 passed, 0 failed): the library's results

TenantSummarytypeno test imports it
type TenantSummary = { readonly tenant: string; readonly asOf: string; readonly rollups: Readonly<Record<string, number>>; readonly findings: Readonly<Record<string, number>> };

What a tenant shows of itself to a portfolio: counts only, no evidence and no names of assets.

Portfoliotypeno test imports it
type Portfolio = { readonly tenants: readonly TenantSummary[]; readonly total: { readonly rollups: Readonly<Record<string, number>>; readonly findings: Readonly<Record<string, number>> } };

A principal's view of a portfolio.

portfoliofunction
function portfolio(m: Model, summaries: readonly TenantSummary[], principalId: string, now: string): Portfolio

The portfolio a principal may see: the summaries of the tenants they may read, and totals over those alone.

Imported by 6 tests of the run (6 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.