Skip to content

Group commit, gRPC roles, /metrics, beastbench and security policy - #2

Merged
ChromaBeast merged 13 commits into
mainfrom
claude/db-security-usability-performance-3d83f3
Nov 12, 2026
Merged

ChromaBeast merged 13 commits into
mainfrom
claude/db-security-usability-performance-3d83f3

Conversation

@ChromaBeast

Copy link
Copy Markdown
Owner

What changed

Security, usability and performance upgrades from a review of the engine (spec: docs/upgrade-spec.md).

Performance

  • WAL group commit. Concurrent writers share one fsync; a write is still acknowledged only after its record is durable, and readers and replication never see it earlier. Fail-stop on a failed fsync.
  • Write-ahead barrier. Group commit applies a write to its page before the group's fsync, so the buffer pool now calls WAL.EnsureDurable before every dirty-page write (eviction, FlushPage, FlushAll). A failing barrier blocks the page write. Regression tests in internal/storage/wal_barrier_test.go.
  • cmd/beastbench. YCSB-style workloads A–F over gRPC with a latency histogram, --json output, a self-contained smoke mode, and docs/benchmarking.md on how to compare fairly with other databases.

Security

  • Per-method gRPC roles, deny by default: viewer (Get/Scan), writer (+Put/Delete/BatchWrite), admin, replication (StreamWAL/Ack only). Unknown methods are denied for every role. Optional token expiry; POST /api/tokens accepts expires_in_seconds and rejects unknown roles with 400.
  • Prometheus /metrics. Hand-written exposition, no new dependency. Never anonymous: admin session or a metrics/static bearer token.
  • SECURITY.md with a private vulnerability reporting policy.

Docs and housekeeping

  • Updated semantics, architecture, operator guide, benchmarks, roadmap, README and Studio docs (including the planned Studio design system and tokens).
  • Replaced the hard 200-line file limit with a "one responsibility per file, review around 400 lines" guideline (GEMINI.md, CONTRIBUTING.md, new AGENTS.md/CLAUDE.md, demo.ps1, phase docs). Split wal.go, buffer_pool.go and the beastbench runner along responsibility seams, with no behaviour change.

Why

The per-write fsync (~4 ms) and the global engine lock were the performance ceilings, gRPC authentication ignored token roles (a viewer token could write), and there was no metrics endpoint or security policy.

Things a reviewer should know

  • Operator-visible changes: viewer tokens can now only read; followers must use a replication or admin token; tokens with a role outside the four now get PERMISSION_DENIED; POST /api/tokens returns 400 for unknown roles; any gRPC method not in methodRoles is denied.
  • Merge conflict resolution: engine.go and buffer_pool.go conflicted between group commit and metrics; both sides were additive and both are kept.
  • Tests: go build, go vet and go test ./... -race pass except TestEngineSystemWorkloadBenchmark (a fixed 1000 ops/s floor), which failed in two full parallel runs on a loaded laptop. Run alone it passes (about 1,875 ops/s here vs about 1,958 on the original code, so single-writer throughput is roughly 4% lower). I did not run the original code under the same full-suite load, so I can't say whether the merge makes that test more load-sensitive.
  • Performance numbers (about 15x on a concurrent-write benchmark, 7.8 to 0.5 ms/op) come from one Apple-silicon laptop and are not a comparison with other databases. A single sequential writer does not speed up.
  • Known limits: readers and replication still wait on each group's fsync (one global lock); the barrier can add an fsync when a dirty page is evicted; StreamWAL can briefly read an appended-but-unsynced record; no encryption at rest yet.
  • Not done: handler test for expires_in_seconds, a Studio expiry field, and a real competitor benchmark. The Studio redesign is a Figma design only; studio/ is unchanged.
  • Enable private vulnerability reporting in the repo settings so SECURITY.md works as written.

🤖 Generated with Claude Code

ChromaBeast and others added 13 commits November 12, 2026 16:17
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…g guide

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Hand-written text exposition (no new deps). Authenticated by admin session or
bearer token (--api-token / BEASTDB_METRICS_TOKEN); no loopback bypass.
Adds buffer-pool hit/miss counters and checkpoint timestamps, gRPC metrics
interceptors, runbook docs with scrape config and alert rules.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
WAL gains Append (assign LSN, no fsync), WaitDurable/Sync with a shared
syncedLSN so one fsync covers all appended records, and a sticky fsync error.
Write keeps its signature and durability but now group-commits too.

Engine writes (Put/PutIfAbsent/PutIf/Delete/DeleteIf/BatchWrite[If] and
replicated apply) go through a commit queue: a committer goroutine runs a
group of writes under the engine lock (append + apply), issues one fsync,
notifies the observer in LSN order, then releases the lock and acks writers.
Reads and replication never see a write before it is durable. A failed
fsync halts the engine and fails every write in the group.

Concurrent Put benchmark: 7.82 ms/op -> 0.51 ms/op (~15x).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Group commit applies writes to pages before the group's fsync, so the buffer
pool could flush a page ahead of its WAL records. Add a WAL barrier
(WAL.EnsureDurable) called before eviction, FlushPage and FlushAll; a failing
barrier blocks the page write. Adds regression tests and the upgrade spec.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Resolved conflicts in engine.go and buffer_pool.go by keeping both the
group-commit/WAL-barrier fields and the metrics counters.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ench and Studio design

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… the 200-line limit

No behaviour change: functions moved verbatim into wal_sync.go,
wal_lifecycle.go, buffer_pool_wal.go, buffer_pool_stats.go,
runner_load.go and runner_run.go.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…guideline

About 400 lines is a prompt to ask whether a file does more than one thing,
not a gate. Generated code, tests and data are exempt. Updates GEMINI.md
(Antigravity), CONTRIBUTING.md and demo.ps1, and adds AGENTS.md (Codex) and
CLAUDE.md (imports AGENTS.md).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T11:32:03.370930Z c6b851e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ChromaBeast
ChromaBeast merged commit 43c1875 into main Nov 12, 2026
3 of 4 checks passed
@ChromaBeast
ChromaBeast deleted the claude/db-security-usability-performance-3d83f3 branch November 12, 2026 11:29

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c6b851e682

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

var chooser KeyChooser
switch {
case w.Latest:
chooser = Latest{Zipf: NewZipfian(cfg.Records, cfg.ZipfTheta), Frontier: frontier}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Decouple workload D reads from the shared insert frontier

With workload D, all workers share this frontier: reads choose keys relative to its current value, while concurrent inserts advance it in worker. Scheduler interleaving therefore changes the per-worker key sequence even with the same seed, thread count, and operation count, undermining the benchmarking guide’s reproducibility claim. Use deterministic per-worker key assignment or qualify that guarantee.

Useful? React with 👍 / 👎.

Comment thread cmd/beastbench/main.go
Comment on lines +108 to +109
rep := Report{Tool: "beastbench", GoVersion: runtime.Version(), GOOS: runtime.GOOS, GOARCH: runtime.GOARCH,
NumCPU: runtime.NumCPU(), SelfHosted: *self, Addr: co.Addr, Config: cfg}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Record the effective connection count in benchmark output

When --conns varies, Dial opens that many connections and workers distribute requests across them, but the report records only Config, which does not include the connection count. JSON results from runs with materially different connection settings therefore omit a throughput-relevant parameter and cannot reproduce or fairly compare those runs; include the effective count in the report.

Useful? React with 👍 / 👎.

ChromaBeast added a commit that referenced this pull request Nov 12, 2026
…erformance-3d83f3

Group commit, gRPC roles, /metrics, beastbench and security policy
ChromaBeast added a commit that referenced this pull request Nov 12, 2026
Fix Windows CI after #2: metrics test, single-writer commit path
ChromaBeast added a commit that referenced this pull request Nov 13, 2026
…erformance-3d83f3

Group commit, gRPC roles, /metrics, beastbench and security policy
ChromaBeast added a commit that referenced this pull request Nov 13, 2026
Fix Windows CI after #2: metrics test, single-writer commit path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant