Skip to main content

init_process_authority_stores

Function init_process_authority_stores 

Source
pub async fn init_process_authority_stores(
    ctx: &ServiceContext,
    signing_key: &SigningKey,
    hosts_policy: bool,
    defer_policy_probe: bool,
) -> Result<()>
Expand description

Initialize the process-global authority stores at startup: the credential-revocation store AND the session registry.

When this process hosts the policy service (hosts_policy), it owns both canonical stores as durable files under the deployment data dir (credential-revocations.jsonl, sessions.jsonl). Every compatibility-mode process PROBES the authority (a freshly generated random credential ID, expected not revoked; and a random session key, expected not active) before publishing the RPC client stores. In the required-native profile, the standalone Discovery process starts before Policy so its resolver can publish the bootstrap announcement; that bootstrap process publishes lazy RPC client stores without a startup probe. Other service processes retain the startup probe and therefore do not report ready when Policy is unavailable. Lazy stores still fail closed on every operation. Both stores resolve a fresh PolicyClient per operation through the production resolver, so a renewed trust-store service JWT is consumed without a process restart.

Fail-closed: any error in compatibility-mode probing — an unreadable/corrupt durable file, or an authority unreachable after [PROBE_ATTEMPTS] attempts — is propagated and MUST abort startup. Required-native Discovery clients retain the same fail-closed operation behavior while allowing the dependency-ordered Discovery → Policy bootstrap to complete. Policy- dependent services keep the probe so a standalone service cannot become ready without its authority.