Dancer - Self-Modifying OCaml Services#
Dancer is an ambitious OCaml library that enables long-running services to automatically improve themselves through AI-assisted code generation, with comprehensive logging, pattern detection, and safe deployment mechanisms.
Components#
dancer-logs#
Comprehensive structured logging with SQLite backend. Features:
- Full structured logging with no truncation
- SQLite storage with FTS5 full-text search
- Pattern detection and normalization
- Eio fiber and domain tracking
- Rich context capture (sessions, requests, traces, performance metrics)
- OCaml Logs reporter integration
- Colorful CLI for log analysis
Installation#
# Install dependencies
make deps
# Build the project
make build
# Run the CLI
make run-cli
Usage#
(* Initialize logging *)
let db = Dancer_logs.init ~path:"app.db" () in
let reporter = Dancer_logs.reporter db in
Logs.set_reporter reporter;
(* Log with context *)
let ctx = Dancer_logs.Context.(
empty_context
|> with_session "session-123"
|> with_request "req-456"
) in
Dancer_logs.log db ~level:Logs.Error ~source:"MyApp"
~message:"Connection failed" ~context:ctx ()
CLI Usage#
# View recent errors
dancer-logs errors
# Search logs
dancer-logs search "connection refused"
# View patterns
dancer-logs patterns --min-count 10
# Export for Claude
dancer-logs export -f claude -o context.txt
Architecture#
See CLAUDE.md for detailed architecture and design decisions.
License#
MIT