Repository navigation
feat(leadline): a box-side helper that records what code did in development - #54
Merged
Merged
Conversation
…opment berth-leadline is Leadline's collector as a standalone helper for a box: it takes OpenTelemetry traces and logs over OTLP/HTTP, records Postgres statements through a loopback proxy, keeps both in one SQLite file, and answers a JSON API on localhost. Queries are grouped by shape with call counts, timings and an N+1 flag with the requests that show it; a trace opens as a span tree with its SQL and its logs; logs are searched; each route has its requests, latency, queries per request and database time. A statement the app and the proxy both report is counted once. Nothing installs or supervises it yet, and it is in no release: berthd and berth do not import it, and their builds are byte for byte what they were. - cmd/berth-leadline: serve and version. - internal/leadline: the attach helper the box daemon will use (the environment a dev server needs, and its database URL through the proxy). Standard library only. - internal/leadline/pgproxy, ingest: Leadline's, with their tests. - internal/leadline/store: Leadline's store rebuilt on SQLite (modernc.org/sqlite, no cgo), with its linker; kept for 72 hours and under 2 GB by default. - internal/leadline/capture, api, helper: the proxies, the HTTP API and the helper put together. - internal/leadline/API.md: every route, with real responses. - make leadline builds it for linux and darwin, amd64 and arm64. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
berth-leadline: Leadline's collector, ported into this repo as a standalone program that runs on a box next to a dev server. It records every database query by shape (with N+1 detection), request traces and logs, and serves them as JSON on loopback. Nothing user-visible yet:berthddoes not install or start it, and the UI is a separate change.berthdandberthare untouched:go list -deps ./cmd/berthd ./cmd/berth | grep leadlineprints nothing, and the agent that built this found both binaries byte-for-byte identical before and after.What's in it
cmd/berth-leadline(serve,version) andinternal/leadline/…;make leadlinebuilds linux and darwin, amd64 and arm64, withCGO_ENABLED=0(about 15 MB stripped).internal/leadline/API.md: all 22 routes with parameters and real responses; a test fails if a served route is missing from it, or the reverse.DATABASE_URLthrough the proxy. Not wired intoberthd.Left out on purpose: metrics, Redis, connect-a-database statistics, the MCP server, briefs, the desktop app, discovery and
leadline run. Also not ported: stdout-to-logs capture, so an app with no OpenTelemetry SDK shows queries but no logs.How it was checked
By the agent that built it:
gofmt,go vet ./...,go test -race ./..., both linux cross-builds, an end-to-end test (helper on port 0, OTLP in, statements through the proxy to a fake Postgres, read back through the API, asserting 5 calls not 10, the N+1 flag, the span tree and a restart), the real-server proxy tests against a throwaway Postgres 17 container, and the static arm64 binary in a bare Alpine container.Re-run by me after rebasing onto
main:go vetandgo test -race ./internal/leadline/..., both linux cross-builds, the dependency check, and a live smoke test on a spare port (health, sources, 403 for a non-loopbackHost, 403 for a POST from a foreignOrigin, files 0600). I did not read all 18,000 lines.Open before
berthdruns itberthdmust only rewrite aDATABASE_URLwhile the helper is up.🤖 Generated with Claude Code