Compile-tested examples · v1.0.1

See each BatchWeaver layer in runnable Go

The repository examples cover declarative contracts, concrete client bindings, compiler transformations, adaptive controls, fairness, overload handling, recursive batching, operation waves, and editor workflows. The Go examples run in the mandatory test suite.

Run locally

Clone and test the complete example suite

git clone https://github.com/Voskan/BatchWeaver.git
cd BatchWeaver
git checkout v1.0.1
go test ./examples/... -count=1

The three editor fixtures are standalone modules and are exercised through editor/LSP checks rather than the root module test command.

Foundations

Declarations and configuration

Public API

Typed declarations

Connect a scalar method and native batch method through an immutable, statically discoverable declaration.

go test ./examples/declarations/basic
Open declaration example →
SQL compiler

Composite key + bounded join

Generate ordered PostgreSQL SQL from two key components and one explicit at-most-one join, then validate the content-addressed plan.

go test ./examples/composite-join-sql
Open SQL example →
Configuration

Equivalent YAML and JSON

Validate two strict configuration documents that produce the same semantic digest and operation catalog.

batchweaver config validate --file \
  examples/configuration/batchweaver.yaml
Open configuration examples →
Integrations

Concrete client bindings

Compile pgx v5, go-redis v9, gqlgen, and grpc-go integrations and run their hermetic client suites.

go test ./examples/client-bindings
go test ./adapters/...
Open client bindings →

Compiler

Proof-gated static prefetch

Transform an N+1 loop without mutating source

The fixture contains a scalar repository call in a loop, a compatible batch provider, equivalence tests, and the expected static prefetch behavior.

  • Preserves result order and duplicates
  • Uses a proven transformation strategy
  • Builds and tests through an overlay
  • Keeps materialization separate and explicit
Open static-prefetch example →
batchweaver scan ./examples/static-prefetch/...
batchweaver prove ./examples/static-prefetch/...
batchweaver transform diff ./examples/static-prefetch/...
batchweaver test -- -race ./examples/static-prefetch/...

Adaptive runtime

Profiles, decisions, fairness, and overload

Tuning

Adaptive runtime

Profile a synthetic workload and produce a bounded shadow-mode tuning recommendation.

go test ./examples/adaptive-runtime
Open example →
Scheduling

Fairness and overload

Exercise weighted fair scheduling across anonymized classes and explicit overload admission decisions.

go test ./examples/fairness-overload
Open example →
Orchestration

Multi-operation waves

Build a dependency DAG, co-schedule independent operations, and identify the critical path.

go test ./examples/multi-operation-wave
Open example →
Graphs

Recursive batching

Load a tree breadth-first, issuing one proven batched call per frontier with explicit cycle and limit policies.

go test ./examples/recursive-batching
Open example →

Editors

Diagnostics, previews, and gopls composition

LSP

Live diagnostics

Open a standalone Go module containing an N+1 loop and inspect the live opportunity diagnostic and code lens.

Open editor-diagnostics →
Preview

Transformation preview

Open a read-only virtual diff from the editor. Applying changes remains a separate explicit CLI operation.

Open editor-transform-preview →
Proxy

gopls proxy

Run BatchWeaver as the language server while delegating standard Go language features to the user's gopls.

batchweaver lsp --stdio --proxy-gopls
Open editor-proxy →

Next step

Move from examples to your own workspace

Start with a non-production clone, declare explicit providers, review every proof and diff, and retain scalar rollback.