Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ADR 0010: policy leaf module

Context

config parses environment variables into vocabularies: the OAuth scope catalogue, the redirect-URI pattern grammar, the log format and the size limits. When those types live in a higher layer (oauth, logging, tools), every dependency between that layer and config runs both ways.

Decision

  • crate::policy holds pure, I/O-free vocabularies.
  • Nothing under src/policy/ imports from crate::.
  • config imports no crate module other than policy.
  • transport::stdio imports nothing from tools, oauth or logging.
  • tests/module_layering.rs enforces these rules textually; it skips comment lines and does not check super:: paths.
  • Layering order: policy → config → client → transport → identity → file store → tools → output → exposure → ops.

Consequences

  • Changing the scope list, the redirect grammar or the upload budget means editing policy only.
  • policy::limits, policy::log_format and policy::redirect are public API; policy::scopes is crate-private. RedirectPolicy can be named outside the crate.
  • A new vocabulary that config needs from a higher layer moves into policy first.
  • The rmcp allowed_hosts restatement stays in config, because it describes an external crate’s behaviour.