logical.Decisiontypeno test imports ittype Decision = { readonly allow: boolean; readonly reason: string; readonly role?: Role };A decision: whether, and why.
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; // falselogical.Decisiontypeno test imports ittype Decision = { readonly allow: boolean; readonly reason: string; readonly role?: Role };A decision: whether, and why.
logical.problemsOffunctionno test imports itfunction 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 itfunction decide(m: Model, principalId: string, tenant: string, action: "administer" | "approve-change" | "determine" | "export" | "read" | "record-evidence", now: string): DecisionWhether a principal may do an action to a tenant at an instant.
logical.visibleTenantsfunctionno test imports itfunction visibleTenants(m: Model, principalId: string, now: string): readonly string[]The tenants a principal may read at an instant, in order.
logical.TenantSummarytypeno test imports ittype 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 ittype 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 itfunction portfolio(m: Model, summaries: readonly TenantSummary[], principalId: string, now: string): PortfolioThe portfolio a principal may see: the summaries of the tenants they may read, and totals over those alone.
Decisiontypeno test imports ittype Decision = { readonly allow: boolean; readonly reason: string; readonly role?: Role };A decision: whether, and why.
problemsOffunctionfunction 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.
decidefunctionfunction decide(m: Model, principalId: string, tenant: string, action: "administer" | "approve-change" | "determine" | "export" | "read" | "record-evidence", now: string): DecisionWhether a principal may do an action to a tenant at an instant.
visibleTenantsfunctionfunction visibleTenants(m: Model, principalId: string, now: string): readonly string[]The tenants a principal may read at an instant, in order.
TenantSummarytypeno test imports ittype 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 ittype 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.
portfoliofunctionfunction portfolio(m: Model, summaries: readonly TenantSummary[], principalId: string, now: string): PortfolioThe portfolio a principal may see: the summaries of the tenants they may read, and totals over those alone.