Skip to main content
This section details the Palyra CLI’s management systems for connection profiles and the comprehensive diagnostic engine used for system health, repair, and recovery. These systems ensure that the CLI can maintain consistent connectivity to local or remote daemons while providing a safety net for configuration corruption and environment drift.

Profile Management System

The profile system allows users to manage multiple daemon connections, environment-specific configurations, and security postures. Profiles are stored in a central registry located at cli/profiles.toml within the state root crates/palyra-cli/src/app/mod.rs#26-27.

Profile Data Model

Each profile is represented by the CliConnectionProfile struct, which encapsulates connection metadata, local path overrides, and security metadata crates/palyra-cli/src/app/mod.rs#93-113.
FieldDescription
modeExecution context: local, remote, or custom crates/palyra-cli/src/args/profile.rs#24-28.
risk_levelSensitivity tier: low, elevated, high, or critical crates/palyra-cli/src/args/profile.rs#32-37.
strict_modeWhen enabled, requires explicit flags for destructive or sensitive actions crates/palyra-cli/src/app/mod.rs#108.
state_rootIsolated directory for logs, caches, and identity for this specific profile crates/palyra-cli/src/app/mod.rs#95.
config_pathPath to the palyra.toml daemon configuration associated with this profile crates/palyra-cli/src/app/mod.rs#94.

Profile Lifecycle and Portability

The CLI supports advanced cloning and migration workflows to facilitate environment promotion (e.g., moving a tested configuration from staging to prod).

Profile Resolution Logic

The CLI resolves the active profile through a tiered priority system:
  1. Global flag: --profile <name>
  2. Environment variable: PALYRA_CLI_PROFILE crates/palyra-cli/src/app/mod.rs#24
  3. Registry default: default_profile field in profiles.toml crates/palyra-cli/src/app/mod.rs#86
Sources: crates/palyra-cli/src/app/mod.rs, crates/palyra-cli/src/commands/profile.rs, crates/palyra-cli/src/args/profile.rs

Doctor Diagnostics Engine

The doctor command is the primary diagnostic tool for the Palyra ecosystem. It executes a suite of DoctorCheck routines categorized by system domain to identify misconfigurations, connectivity issues, and security vulnerabilities.

Diagnostic Categories

Diagnostics are implemented in crates/palyra-cli/src/commands/doctor/recovery.rs. Key check areas include:

Implementation: Doctor Execution Flow

The run_doctor function orchestrates the diagnostic process, optionally moving into a repair phase if the --repair flag is provided.

Doctor Diagnostic Data Flow

This diagram illustrates how system state is ingested by the Doctor engine to produce an execution report. Sources: crates/palyra-cli/src/commands/doctor.rs, crates/palyra-cli/src/commands/doctor/recovery.rs

Repair and Rollback Recovery

When the Doctor identifies “Fixable” issues, it generates a DoctorRepairPlan. Repairs are treated as atomic transactions where possible, creating backups before modification.

Repair Flow

  1. Plan Generation: The engine identifies steps like InitializeMissingConfig, NormalizeAuthRegistry, or BackfillAccessRegistry crates/palyra-cli/src/commands/doctor/recovery.rs#178-236.
  2. Backup Creation: Files targeted for modification are backed up to a unique recovery run directory: recovery/runs/<ULID>/ crates/palyra-cli/src/commands/doctor/recovery.rs#23.
  3. Manifest Recording: A DoctorRecoveryManifest is written, tracking the before_sha256 and after_sha256 of every changed object crates/palyra-cli/src/commands/doctor/recovery.rs#141-155.

Rollback Mechanism

Users can revert any repair operation using the run_id (ULID) generated during the repair.

Entity Mapping: Recovery System

This diagram bridges the recovery concepts to the internal structures used to track changes. Sources: crates/palyra-cli/src/commands/doctor/recovery.rs, crates/palyra-cli/src/commands/doctor.rs

Security Auditing

The palyra security audit command leverages the Doctor engine to perform a security-specific evaluation crates/palyra-cli/src/commands/security.rs#70-72. It combines Doctor checks with a SecretAuditPayload to identify: Sources: crates/palyra-cli/src/commands/security.rs, crates/palyra-cli/src/commands/doctor/recovery.rs