Phase 2 sections 2-6 and 8 of docs/SCALE-EXPANSION.md: - pkg/telemetry + pkg/metrics: OpenTelemetry trace propagation and Prometheus metrics across every service hop (CLI -> agent -> gateway -> card-issuance/tenant-registry/auth -> ledger-core), tracing added to ledger-core itself via services/ledger-core/src/telemetry.rs. - infra/: otel-collector + Prometheus + Grafana docker-compose stack, a Terraform ECS Fargate module + dev/staging/prod envs (plan-only, no apply — real AWS spend is an owner action), and a dev-only mTLS CA (infra/dev-ca) wired through pkg/mtls + services/ledger-core/src/mtls.rs. - services/audit-log (from the prior commit) gets its async mirror writer in services/ledger-core/src/audit_mirror.rs, and services/gateway gets a per-tenant token-bucket rate limiter (internal/ratelimit). - Test depth: a Rust proptest suite proving concurrent ApplyEntry never breaches the reserve floor (tests/apply_entry_proptest.rs, passing), a Go fuzz seed corpus for the policy envelope (rules_fuzz_test.go), a libFuzzer harness for the C WAL frame parser (services/wal/fuzz, deliberately not wired into `make test` per its own Makefile comment - needs a libFuzzer-bundled clang), and a real chaos test (scripts/chaos/kill-ledger-mid-write.sh) that SIGKILLs ledger-core mid-write under concurrent load and verifies via ListEntries that nothing was lost or double-applied. - docs/formal/ledger.tla: a TLA+ spec of the ledger state machine (balance >= reserve_floor safety, HOLD-eventually-resolves liveness) plus a TLC model config - not run through TLC in this pass, that's a precise documented TODO, not faked. - docs/adr/0001-0004, docs/RUNBOOK.md, docs/SLO.md, docs/THREAT-MODEL.md. Verified: `make build && make test` clean (C WAL, Rust incl. the new proptest suite, all 10 Go modules) from a cold target. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
65 lines
1.8 KiB
Makefile
65 lines
1.8 KiB
Makefile
# Builds and runs the libFuzzer harness for wal_read_next()'s frame
|
|
# parser (see fuzz_frame_parse.c for the full rationale).
|
|
#
|
|
# Not wired into the top-level `make test` — fuzzing is a separate,
|
|
# explicitly-invoked activity, not a per-commit correctness gate.
|
|
#
|
|
# Requires a clang that bundles the libFuzzer runtime
|
|
# (libclang_rt.fuzzer_osx.a / libclang_rt.fuzzer-*.a). On Linux, the
|
|
# system clang package normally includes this. On macOS, Apple's
|
|
# Command Line Tools clang does NOT bundle it — only upstream/Homebrew
|
|
# clang does. If `make build` fails with
|
|
# "library ... libclang_rt.fuzzer_osx.a not found", the fix is:
|
|
#
|
|
# brew install llvm
|
|
#
|
|
# which this Makefile then auto-detects below; no manual CC= needed.
|
|
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
ifeq ($(origin CC),default)
|
|
ifeq ($(UNAME_S),Darwin)
|
|
HOMEBREW_LLVM_CLANG := $(firstword $(wildcard /opt/homebrew/opt/llvm*/bin/clang /usr/local/opt/llvm*/bin/clang))
|
|
ifneq ($(HOMEBREW_LLVM_CLANG),)
|
|
CC := $(HOMEBREW_LLVM_CLANG)
|
|
else
|
|
CC := clang
|
|
endif
|
|
else
|
|
CC := clang
|
|
endif
|
|
endif
|
|
|
|
ifeq ($(UNAME_S),Darwin)
|
|
SDK_FLAGS := -isysroot $(shell xcrun --show-sdk-path)
|
|
endif
|
|
|
|
CFLAGS ?= -std=c11 -g -O1 -fsanitize=fuzzer,address,undefined -I.. $(SDK_FLAGS)
|
|
BIN := fuzz_frame_parse
|
|
SRCS := fuzz_frame_parse.c ../wal.c ../crc32.c
|
|
|
|
.PHONY: build fuzz smoke clean
|
|
|
|
build: $(BIN)
|
|
|
|
$(BIN): $(SRCS) ../wal.h ../frame.h ../crc32.h
|
|
$(CC) $(CFLAGS) $(SRCS) -o $(BIN)
|
|
|
|
# Short, CI-friendly run: proves the harness builds and runs clean, not
|
|
# an exhaustive fuzz campaign. Override with SECONDS=N.
|
|
SECONDS ?= 30
|
|
smoke: build
|
|
mkdir -p corpus
|
|
./$(BIN) corpus/ -max_total_time=$(SECONDS) -print_final_stats=1
|
|
|
|
# Long-running real fuzz campaign.
|
|
MINUTES ?= 60
|
|
fuzz: build
|
|
mkdir -p corpus
|
|
./$(BIN) corpus/ -max_total_time=$$(($(MINUTES) * 60)) -print_final_stats=1
|
|
|
|
clean:
|
|
rm -f $(BIN)
|
|
rm -rf $(BIN).dSYM
|
|
rm -f crash-* leak-* oom-* timeout-*
|