Skip to main content
The Palyra diagnostic and onboarding system provides a robust pipeline for environment validation, initial bootstrapping, and safe reconfiguration. This system is primarily implemented within the palyra-cli crate, leveraging a unified wizard engine to guide users through complex setup tasks while ensuring system integrity through the “Doctor” diagnostic suite.

1. Doctor Diagnostic Pipeline

The doctor command serves as the primary diagnostic and repair tool for Palyra installations. It evaluates the health of the toolchain, connectivity, permissions, and security configurations.

1.1 Diagnostic Logic and Execution

The core logic resides in crates/palyra-cli/src/commands/doctor/recovery.rs. The doctor executes in several modes defined by DoctorExecutionMode: Diagnostics, RepairPreview, RepairApply, RollbackPreview, and RollbackApply crates/palyra-cli/src/commands/doctor/recovery.rs#68-74. Key diagnostic areas include:

1.2 Automated Repair & Rollback

When run with the --repair flag, the doctor generates a DoctorRepairPlan crates/palyra-cli/src/commands/doctor/recovery.rs#172-176. This plan consists of multiple DoctorRepairStep objects that describe the problem, the impact, and the proposed fix crates/palyra-cli/src/commands/doctor/recovery.rs#105-118. To ensure safety, every repair operation that modifies the filesystem creates a backup entry in a DoctorRecoveryManifest crates/palyra-cli/src/commands/doctor/recovery.rs#141-155. This allows the user to trigger a rollback using a specific run_id if a repair causes regressions crates/palyra-cli/src/commands/doctor/recovery.rs#130-138. Doctor Execution Flow Sources: crates/palyra-cli/src/commands/doctor.rs#8-10, crates/palyra-cli/src/commands/doctor/recovery.rs#77-83, crates/palyra-cli/src/commands/doctor/recovery.rs#141-169.

2. Setup & Onboarding Wizard

The setup (aliased as init) command is the entry point for new users. It handles the initial generation of configuration files, identity stores, and vault initialization.

2.1 Onboarding Flows

The wizard supports three primary flows defined in OnboardingFlowArg crates/palyra-cli/src/args/onboarding.rs#6-10:
  1. Quickstart: A streamlined path for local evaluation, defaulting to gpt-4o-mini or claude-3-5-sonnet-latest crates/palyra-cli/src/commands/operator_wizard.rs#18-21.
  2. Manual: Allows granular control over ports, TLS certificates, and bind profiles (e.g., LoopbackOnly vs PublicTls) crates/palyra-cli/src/args/onboarding.rs#21-24.
  3. Remote: Configures the CLI to connect to an existing remote gateway, including server certificate pinning and SSH tunnel setup crates/palyra-cli/src/commands/operator_wizard.rs#68-70.

2.2 Implementation Details

The onboarding process is driven by run_onboarding_wizard, which consumes an OnboardingWizardRequest crates/palyra-cli/src/commands/operator_wizard.rs#24-30. It generates an OnboardingMutationPlan that tracks intended changes to the system crates/palyra-cli/src/commands/operator_wizard.rs#169-195. The wizard uses a WizardBackend trait to support both InteractiveWizardBackend (TTY-based prompts) and NonInteractiveWizardBackend (automated via CLI flags) crates/palyra-cli/src/commands/operator_wizard.rs#10-13. Onboarding Data Flow Sources: crates/palyra-cli/src/commands/operator_wizard.rs#240-248, crates/palyra-cli/src/args/onboarding.rs#34-89, crates/palyra-cli/src/commands/operator_wizard.rs#169-195.

3. Configuration Wizard (configure)

The configure command provides a safe way to modify an existing installation by reusing the onboarding wizard’s logic. It targets specific ConfigureSectionArg areas like workspace, auth-model, gateway, or skills crates/palyra-cli/tests/help_snapshots/configure-help.txt#8-9.

3.1 Safety and Backups

Unlike direct manual edits to palyra.toml, the configure command:

3.2 Configuration Summary Structure

FieldDescription
changed_sectionsList of TOML tables modified during the session.
restart_requiredBoolean flag indicating if palyrad must be restarted to apply changes.
follow_up_checksSpecific doctor checks recommended after the update.
warningsNon-fatal issues (e.g., deprecated keys).
Sources: crates/palyra-cli/src/commands/operator_wizard.rs#33-62, crates/palyra-cli/src/commands/operator_wizard.rs#219-238.

4. Integration with Console API

The Palyra Daemon (palyrad) exposes endpoints to monitor and manage recovery jobs via the Web Console. These are defined in the Axum transport layer. The daemon-side jobs are synchronized with the CLI’s recovery manifests to provide a unified view of system health across TUI and Web interfaces. Sources: crates/palyra-daemon/src/transport/http/handlers/console/doctor.rs#3-46.