Skip to main content
The palyra-common crate provides the shared foundation for the Palyra ecosystem. It contains core logic for configuration management, sensitive data redaction, filesystem workspace patching, and shared protocol constants used across the daemon, CLI, and desktop applications.

Configuration System (config_system)

The configuration system handles the lifecycle of TOML-based configuration files, including versioning, atomic updates, and automated backups.

TOML Migration & Versioning

All configuration files are versioned. The system currently supports CONFIG_VERSION_V1 crates/palyra-common/src/config_system.rs#14-14.

Path-Based Mutation

The system allows getting, setting, or unsetting values using dot-notation paths (e.g., daemon.port).

Atomic File Operations & Backups

The ConfigPersistence trait (and its implementations) provides safe disk writes:
  1. Backup Rotation: Before writing, existing files are rotated through a configurable number of backups (default 5) using .bak.N extensions crates/palyra-common/src/config_system.rs#15-15.
  2. Atomic Write: New configuration is written to a .tmp file and then renamed to the target path to ensure atomicity crates/palyra-common/src/config_system.rs#202-204.
  3. Permissions: On Unix systems, the system attempts to preserve existing file permissions (e.g., 0o600 for secrets) during updates crates/palyra-cli/tests/config_mutation.rs#107-146.
Configuration Data Flow Title: Configuration Lifecycle Sources: crates/palyra-common/src/config_system.rs#1-204, crates/palyra-cli/tests/config_mutation.rs#19-56

Redaction Utilities

The redaction module provides shared logic for identifying and masking sensitive information in logs, UI previews, and HTTP headers.

Sensitive Key Identification

The system maintains a list of SENSITIVE_KEY_MARKERS including api_key, authorization, bearer, password, and token crates/palyra-common/src/redaction.rs#5-22. The is_sensitive_key function normalizes input strings to check for these markers crates/palyra-common/src/redaction.rs#25-28.

Specialized Redaction Routines

Sources: crates/palyra-common/src/redaction.rs#1-130

Workspace Patching (workspace_patch)

The workspace_patch module implements a fail-closed mechanism for applying multi-file text changes to a local filesystem. This is primarily used by agents to modify codebases.

Execution Guardrails

The system enforces WorkspacePatchLimits to prevent resource exhaustion or runaway processes:

Security & Sandboxing

Patch Operations

The system supports three primary operations crates/palyra-common/src/workspace_patch.rs#159-163:
  1. Add: Creates a new file with specified content.
  2. Update: Modifies an existing file using “hunks” (context lines, additions, and removals).
  3. Delete: Removes a file from the workspace.
Patch Execution Logic Title: Workspace Patch Flow Sources: crates/palyra-common/src/workspace_patch.rs#19-163, crates/palyra-common/src/workspace_patch.rs#207-212

Process Runner Input (process_runner_input)

This utility handles the serialization and parsing of inputs for sandboxed process execution. It ensures that environment variables, arguments, and working directories are safely passed between the daemon and the sandbox runner. Key entities include: Sources: crates/palyra-common/src/lib.rs#10-10

Windows Security (windows_security)

On Windows platforms, palyra-common provides wrappers for the Data Protection API (DPAPI) to secure secrets at rest without requiring a master password from the user. This is used by the palyra-vault crate when the WindowsDpapi backend is selected crates/palyra-vault/src/backend.rs#15-16. Sources: crates/palyra-common/src/lib.rs#13-14, crates/palyra-vault/src/backend.rs#47-49

Shared Constants & Schemas

The crate defines several monorepo-wide constants and schemas: Sources: crates/palyra-common/src/lib.rs#1-32