Skip to main content
JSON Envelope Schemas define the structural contracts for data exchange between Palyra components and external systems. These schemas ensure consistency across the protocol-first architecture by enforcing versioning, strict property validation, and payload size constraints.

Schema Design Principles

Palyra utilizes a “Strict Envelope” pattern for all JSON-based communication. This pattern is characterized by several key constraints:
  • Versioning: Every envelope must contain a v field (integer) representing the schema version crates/palyra-common/src/lib.rs#31-32.
  • Strictness: Schemas are defined with additionalProperties: false to prevent silent data degradation and ensure forward compatibility is handled explicitly.
  • Payload Caps: Hard limits are enforced on the size of payloads and the number of entities (e.g., files) touched in a single operation to prevent resource exhaustion crates/palyra-common/src/workspace_patch.rs#23-39.

Canonical Versions

The system currently tracks two primary version constants:
  • CANONICAL_PROTOCOL_MAJOR: 1
  • CANONICAL_JSON_ENVELOPE_VERSION: 1
Sources: crates/palyra-common/src/lib.rs#31-33

Webhook Envelopes (webhook-envelope.v1.json)

The Webhook system uses the WebhookEnvelope to wrap external event data. It provides cryptographic verification and replay protection.

Implementation Details

The WebhookEnvelope structure and its associated logic are implemented in palyra-common.
ComponentCode EntityRole
Data StructureWebhookEnvelopeThe root JSON object containing v, payload, and signature.
VerificationWebhookSignatureVerifierValidates Ed25519 or HMAC signatures against the payload.
Replay GuardReplayNonceStoreTracks nonces to prevent duplicate event processing.
Parsingparse_webhook_payloadValidates the JSON structure against the versioned schema.

Webhook Data Flow

This diagram illustrates the transition from an incoming HTTP request to a validated internal event. Webhook Validation Pipeline Sources: crates/palyra-common/src/webhook.rs#26-29, crates/palyra-common/src/lib.rs#12

Agent-to-User Interface (a2ui-envelope.v1.json)

The A2UI system enables agents to render rich UI components (charts, forms, tables) in the Web Console. The envelope supports incremental updates via JSON Patch.

Key Components


Workspace Patching (message-envelope.v1.json)

Workspace patches are used to communicate filesystem changes within the palyrad daemon. These envelopes are subject to strict safety limits to prevent “zip bomb” style attacks or unauthorized directory traversal.

Workspace Patch Limits

The system enforces WorkspacePatchLimits before any filesystem mutation occurs:
LimitDefault ValueDescription
max_patch_bytes256 KBMaximum size of the incoming JSON patch string.
max_files_touched64Maximum number of files a single patch can modify.
max_file_bytes2 MBMaximum size allowed for any single file after patching.
max_preview_bytes16 KBMaximum size of the redacted preview returned to the UI.

Patch Execution Logic

The apply_workspace_patch function implements a fail-closed, atomic update mechanism. Workspace Patch Execution Flow Sources: crates/palyra-common/src/workspace_patch.rs#23-39, crates/palyra-common/src/workspace_patch.rs#207-213

Configuration Schemas (config-export/import.v1.json)

The daemon configuration is governed by daemon_config_schema. The CLI provides a config validate command to ensure local palyra.toml files adhere to the expected JSON/TOML schema.

Validation Rules

Sources: crates/palyra-common/src/daemon_config_schema.rs#5, crates/palyra-cli/tests/config_validate.rs#1-170

Identity & Certificate Schemas

While identity management primarily uses mTLS, the exchange of pairing proofs and certificates is facilitated by JSON envelopes within the palyra-identity crate.

Issued Certificate Structure

The IssuedCertificate schema includes metadata required for the pairing handshake:

Stored CA Schema

The StoredCertificateAuthority envelope persists the Root CA state: Sources: crates/palyra-identity/src/ca.rs#17-32, crates/palyra-identity/src/error.rs#4-41