aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-26 15:07:03 -0800
committerFuwn <[email protected]>2026-02-26 15:07:03 -0800
commitf1b26a68534e4299de7b5fe6b15d2b248fac40e1 (patch)
tree4003d041bc46866b7d4b7f0bfb6c6924d991cbb6 /README.md
parentfeat: initial Plutia release — verifiable high-performance PLC mirror (mirr... (diff)
downloadplutia-test-f1b26a68534e4299de7b5fe6b15d2b248fac40e1.tar.xz
plutia-test-f1b26a68534e4299de7b5fe6b15d2b248fac40e1.zip
feat: harden launch readiness with versioning, metrics, and resilience
Diffstat (limited to 'README.md')
-rw-r--r--README.md225
1 files changed, 145 insertions, 80 deletions
diff --git a/README.md b/README.md
index 2a4f6f1..ef52544 100644
--- a/README.md
+++ b/README.md
@@ -1,109 +1,174 @@
# Plutia
-Plutia is a verifiable PLC mirror for `plc.directory`, implemented in Go.
-
-It supports:
-
-- `resolver` mode: compact state-only storage.
-- `mirror` mode: full historical operation archive with compressed append-only blocks, Merkle checkpoints, and inclusion proofs.
-
-## Features
-
-- Pebble-backed KV/index store (`data/index`).
-- Mirror-mode append-only operation log (`data/ops/*.zst`) with zstd compression.
-- Deterministic JSON canonicalization (`json.Compact`) with stable operation hashing.
-- Ed25519 signature verification with configurable policy (`full`, `lazy`, `state-only`).
-- Prev-link chain validation for tamper-evident DID histories.
-- Signed checkpoints with DID and block Merkle roots.
-- HTTP API for resolution, proofs, status, and checkpoints.
-- CLI for serving, replay, DID verification, and snapshots.
-- Benchmark command with rolling throughput/CPU/RSS/disk reporting.
-
-## Project Layout
-
-- `cmd/plutia`: CLI entrypoint.
-- `internal/config`: YAML/env configuration.
-- `internal/types`: operation/state/checkpoint models + canonicalization.
-- `internal/storage`: Pebble store + zstd append-only block log.
-- `internal/verify`: signature and chain-link validation.
-- `internal/state`: state materialization and KV updates.
-- `internal/merkle`: Merkle root/proof generation.
-- `internal/checkpoint`: checkpoint creation/signing/persistence.
-- `internal/ingest`: replay/poll ingestion pipeline.
-- `internal/api`: HTTP handlers.
-- `pkg/proof`: proof response structures.
-
-## Configuration
-
-Use `config.yaml` (see included example) and/or environment variables:
-
-- `PLUTIA_MODE`
-- `PLUTIA_DATA_DIR`
-- `PLUTIA_PLC_SOURCE`
-- `PLUTIA_VERIFY`
-- `PLUTIA_ZSTD_LEVEL`
-- `PLUTIA_BLOCK_SIZE_MB`
-- `PLUTIA_CHECKPOINT_INTERVAL`
-- `PLUTIA_COMMIT_BATCH_SIZE`
-- `PLUTIA_VERIFY_WORKERS`
-- `PLUTIA_LISTEN_ADDR`
-- `PLUTIA_MIRROR_PRIVATE_KEY_PATH`
-- `PLUTIA_POLL_INTERVAL`
-
-## Mirror Key
-
-Checkpoints are signed using `mirror_private_key_path`.
-Accepted key formats:
-
-- raw ed25519 seed/private key (`base64url`, `base64`, or `hex`)
-- JSON object: `{"private_key":"..."}`
-
-## CLI
+Plutia is a deterministic, verifiable PLC mirror for `plc.directory` with signed checkpoints and a proof-serving API.
+
+## Key Capabilities
+
+- Mirror and resolver modes.
+- Pebble-backed state/index storage.
+- Compressed append-only operation blocks (`zstd`) in mirror mode.
+- Deterministic canonical operation handling and signature-chain verification.
+- Signed Merkle checkpoints and DID inclusion proof API.
+- Corruption detection and restart-safe ingestion.
+- High-density storage scaling around ~1.2KB/op in benchmarked runs.
+- ~45x faster than naive replay in benchmarked runs.
+
+## Trust Model
+
+- Plutia mirrors data from `https://plc.directory`.
+- Plutia validates operation signature chains and prev-link continuity according to configured verification policy.
+- Plutia does **not** alter PLC authority or introduce consensus.
+- Checkpoints are mirror commitments about what this mirror observed and verified, not global consensus.
+
+## Modes
+
+- `mirror`: stores full verifiable operation history (`data/ops/*.zst`) + state + proofs/checkpoints.
+- `resolver`: stores resolved DID state/index only (no op block archive).
+
+## Quick Start
+
+```bash
+go test ./...
+go build ./cmd/plutia
+./plutia serve --config=config.yaml
+```
+
+### CLI Commands
```bash
-plutia serve --config=config.yaml
-plutia replay --config=config.yaml
-plutia verify --config=config.yaml --did=did:plc:xyz
+plutia serve --config=config.yaml [--max-ops=0]
+plutia replay --config=config.yaml [--max-ops=0]
+plutia verify --config=config.yaml --did=did:plc:example
plutia snapshot --config=config.yaml
plutia bench --config=config.yaml --max-ops=200000
+plutia compare --config=config.yaml --remote=https://mirror.example.com
+plutia version
```
+## Versioning and Reproducible Builds
+
+Plutia follows semantic versioning, starting at `v0.1.0`.
+
+`plutia version` prints:
+
+- `Version` (defaults to `dev` if not injected)
+- `Commit`
+- `BuildDate` (UTC RFC3339)
+- `GoVersion`
+
+Build metadata is injected through ldflags:
+
+```bash
+go build -trimpath \
+ -ldflags "-X main.version=v0.1.0 -X main.commit=$(git rev-parse --short HEAD) -X main.buildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
+ -o ./bin/plutia ./cmd/plutia
+```
+
+`make build` provides the same pattern.
+
## HTTP API
- `GET /health`
-- `GET /metrics`
-- `GET /status`
+- `GET /metrics` (Prometheus)
+- `GET /status` (includes build/version metadata)
- `GET /did/{did}`
- `GET /did/{did}/proof`
- `GET /checkpoints/latest`
- `GET /checkpoints/{sequence}`
-`/did/{did}` returns `did_document`, `chain_tip_hash`, and latest checkpoint reference when available.
+## Metrics and Observability
-`/did/{did}/proof` returns chain-tip reference, operation sequence references, Merkle inclusion proof, and checkpoint signature metadata.
+Prometheus series exposed at `/metrics` include:
-## Ingestion Behavior
+- `ingest_ops_total`
+- `ingest_ops_per_second`
+- `ingest_lag_ops`
+- `verify_failures_total`
+- `checkpoint_duration_seconds`
+- `checkpoint_sequence`
+- `disk_bytes_total`
+- `did_count`
-- Replay from genesis via `plutia replay`.
-- Poll-based incremental ingestion in `serve` mode.
-- Resume from `meta:global_seq`.
-- Parallel DID-partitioned verification with ordered commit.
-- Configurable synced commit batching (`commit_batch_size`).
-- Safe flush on shutdown.
+Operational hardening includes:
-## Verification Policies
+- Per-IP token-bucket rate limits (stricter on proof endpoints).
+- Per-request timeout (default `10s`) with cancellation propagation.
+- Upstream ingestion retries with exponential backoff and `429` handling.
+- Graceful SIGINT/SIGTERM shutdown with flush-before-exit behavior.
-- `full`: verify all operations on ingest.
-- `lazy`: ingest without immediate signature verification.
-- `state-only`: verify latest operations per DID.
+## Running Your Own Mirror
-## Build and Test
+### System Requirements
+
+- Go 1.25+
+- SSD-backed storage recommended
+- RAM: 4GB minimum, 8GB+ recommended for larger throughput
+- CPU: multi-core recommended for parallel verification workers
+
+### Disk Projections
+
+Using benchmarked density (~1.2KB/op total):
+
+- 5,000,000 ops: ~6GB
+- 10,000,000 ops: ~12GB
+
+Always keep extra headroom for compaction, checkpoints, and operational buffers.
+
+### Example `config.yaml`
+
+See [`config.yaml`](./config.yaml). Core knobs:
+
+- `mode`
+- `verify`
+- `commit_batch_size`
+- `verify_workers`
+- `checkpoint_interval`
+- `rate_limit.*`
+- `request_timeout`
+
+### Example `docker-compose.yml`
+
+```yaml
+services:
+ plutia:
+ image: golang:1.25
+ working_dir: /app
+ command: sh -lc "go build -trimpath -o /app/bin/plutia ./cmd/plutia && /app/bin/plutia serve --config=/app/config.yaml"
+ ports:
+ - "8080:8080"
+ volumes:
+ - ./:/app
+ - ./data:/app/data
+ restart: unless-stopped
+```
+
+### Upgrade and Backup Guidance
+
+- Stop the process cleanly (`SIGTERM`) to flush pending writes.
+- Back up `data/index`, `data/ops`, and `data/checkpoints` together.
+- Keep the same `mode` per data directory across restarts.
+- Upgrade binaries first in staging, then production using the same on-disk data.
+
+## Mirror Comparison
+
+Use:
```bash
-go test ./...
-go build ./cmd/plutia
+plutia compare --config=config.yaml --remote=https://mirror.example.com
```
+The command fetches remote `/checkpoints/latest` and compares:
+
+- checkpoint sequence
+- DID Merkle root
+- signature presence
+
+Behavior:
+
+- same sequence + different root => divergence warning and non-zero exit
+- different sequences => reports which mirror is ahead and exits non-zero
+- matching sequence/root/signature presence => success
+
## License
MIT OR Apache-2.0