Skip to main content

Module permissions

Module permissions 

Source
Expand description

Settings/permissions scope hierarchy + the narrowing rule (R0 invariant). Settings/permissions scope hierarchy and the narrowing rule.

Adopted from the donor graphshell settings_and_permissions_spine_spec.md (per the adoption roadmap R0). This is the host-agnostic policy core: the scope vocabulary plus the resolution rule. Storage of per-scope values and the host wiring that gates surfaces/mods consume this; they are not here.

§The five scopes

SettingScope is a hierarchy from broadest to narrowest, grounded in Mere’s own structure (a persona owns sessions; a session/window hosts graphs; a graph hosts surfaces/tiles):

  1. App — installation-wide defaults.
  2. Persona — one human’s persona (work / research / throwaway).
  3. Session — a session, i.e. a graph-shaped window.
  4. Graph — a specific graph (orrery / moot) within a session.
  5. Surface — a tile / pane / surface within a graph.

The same hierarchy serves settings (where the narrower scope simply overrides) and permissions (where the narrower scope may only narrow). This module implements the permission resolution; a settings-override resolver is a future sibling that reuses SettingScope.

§The narrowing rule (the R0 invariant)

A narrower scope can only narrow a permission, never broaden it. No persona, session, graph, or surface can grant itself more than a broader scope allows. This is defense in depth: tighten centrally and trust that nothing downstream loosens it.

The rule is enforced structurally, not by convention: resolve_permission returns the most restrictive opinion across the chain (Allow < Prompt < Deny). Because resolution is a maximum over restrictiveness, a narrower scope’s Allow can never override a broader scope’s Deny — there is no code path that broadens.

This supersedes the earlier capability-gate-catalogue “first-match-wins” framing for permissions (first-match can let an earlier, broader opinion win over a stricter later one — wrong direction for security). RequireConsent from that brief is preserved as the Permission::Prompt middle state.

Structs§

ResolvedPermission
The outcome of resolve_permission.
ScopedPermission
One scope’s opinion in a resolution chain.

Enums§

Permission
A permission opinion at one scope.
SettingScope
The scope a setting or permission is declared at, broadest to narrowest. The discriminant order is the breadth order (App broadest).

Functions§

resolve_permission
Resolve a permission across a scope chain per the narrowing rule: the effective permission is the most restrictive non-Permission::Inherit opinion in the chain. default applies when every scope inherits.