Skip to content

story(issue-78): add dgraph daggerverse module with plaintext cluster + dgo client#81

Open
Zaba505 wants to merge 3 commits into
mainfrom
worktree-issue-78
Open

story(issue-78): add dgraph daggerverse module with plaintext cluster + dgo client#81
Zaba505 wants to merge 3 commits into
mainfrom
worktree-issue-78

Conversation

@Zaba505
Copy link
Copy Markdown
Member

@Zaba505 Zaba505 commented May 21, 2026

Summary

Closes #78.

  • Adds daggerverse/dgraph/ with main.go, security.go, cluster.go, client.go, README.md, dagger.json. Spins up a single Zero + N Alpha topology from dgraph/dgraph:v24.0.4 images and exposes a pure-Go dgo-based *Client that targets either the local cluster or any reachable remote cluster.
  • Plaintext-only on every listener. TLS/mTLS, multi-Zero HA, ACL, Ratel, and RDF/delete mutations are explicit follow-ups per the story.
  • Wires the new module's tests into ci/main.go and the top-level dagger.json.

Deviations from the story spec (all documented in README)

  • +cache="session" on Dgraph.Cluster / Dgraph.Client (not "never") — chained Mutate → RunQuery loses graph state under never because each method call re-spawns the cluster. Methods on *Cluster/*Client stay +cache="never".
  • Client.Query renamed to Client.RunQuery — Dagger Go SDK codegen allocates a struct field named after the lowercase method name to cache the result, and query collides with the always-present query *querybuilder.Selection field. runQuery sidesteps the collision.
  • Client.QueryWithVars(vars map[string]string) becomes (varsJson string) — Dagger function signatures don't support Go map parameters.
  • Added odd-replicas validation in addition to the spec'd alphas % replicas == 0 rule (Dgraph's Raft consensus requires odd replica counts).
  • Added Cluster.Stop, Cluster.ZeroHosts, Cluster.AlphaHostNames helpers needed for cluster teardown and bind-aware tests.

Test plan

  • cd daggerverse/dgraph && dagger functions lists plaintext-client-security and plaintext-server-security (cluster + client are registered but filtered from the listing, matching kafka's behavior).
  • For each of the 15 acceptance-criterion tests, run dagger -m daggerverse/dgraph/tests call <name> and confirm exit 0:
    • defaults-produce-working-single-node-cluster
    • grpc-endpoints-should-not-be-cached
    • http-endpoints-should-not-be-cached
    • mutate-should-not-be-cached
    • cluster-rejects-multiple-zeros
    • cluster-rejects-invalid-alphas-replicas-ratio
    • cluster-rejects-nil-security
    • bind-zeros-resolves-from-user-container
    • multi-alpha-single-group-all-reachable
    • multi-alpha-sharded-topology
    • client-alter-schema-round-trip
    • client-mutate-then-query-round-trip
    • client-mutate-without-commit-does-not-persist
    • client-query-with-vars-round-trip
    • remote-client-can-target-existing-cluster
  • dagger -m daggerverse/dgraph/tests call all (defaults to --parallel=1 because session-cached clusters with the default shape collide across parallel tests).
  • dagger -m ci call test continues to pass.

🤖 Generated with Claude Code

@Zaba505 Zaba505 self-assigned this May 21, 2026
@Zaba505 Zaba505 added the enhancement New feature or request label May 21, 2026
@Zaba505 Zaba505 requested a review from Copilot May 21, 2026 01:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new daggerverse/dgraph module that provisions a plaintext Dgraph (Zero + N Alpha) topology and exposes a pure-Go dgo client, along with a dedicated tests/ module and CI wiring so the suite runs as part of the repo’s ci module.

Changes:

  • Introduces daggerverse/dgraph module (cluster + client + plaintext security profiles) pinned to dgraph/dgraph:v24.0.4.
  • Adds daggerverse/dgraph/tests with acceptance-style checks and an All() aggregator.
  • Wires the new tests module into ci/main.go and the root dagger.json dependencies.

Reviewed changes

Copilot reviewed 16 out of 18 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
daggerverse/dgraph/main.go Defines the module root type and user-facing module documentation.
daggerverse/dgraph/security.go Adds plaintext server/client security profile constructors.
daggerverse/dgraph/cluster.go Implements the Zero+Alpha cluster topology, endpoint helpers, binding helpers, and teardown.
daggerverse/dgraph/client.go Implements a stateless-per-call dgo-backed client targeting local or remote clusters.
daggerverse/dgraph/README.md Documents scope (plaintext-only), topology constraints, caching behavior, and follow-ups.
daggerverse/dgraph/dagger.json Declares the dgraph module and its dependency on random.
daggerverse/dgraph/go.mod Adds the module’s Go dependencies (including dgo/v240).
daggerverse/dgraph/go.sum Locks module dependency checksums.
daggerverse/dgraph/.gitignore Ignores generated Dagger Go bindings and related artifacts.
daggerverse/dgraph/.gitattributes Marks generated bindings as linguist-generated.
daggerverse/dgraph/tests/main.go Adds the dgraph module test suite and All() aggregation.
daggerverse/dgraph/tests/dagger.json Declares the tests module and depends on .. and random.
daggerverse/dgraph/tests/go.mod Adds the tests module Go dependencies.
daggerverse/dgraph/tests/go.sum Locks tests module dependency checksums.
daggerverse/dgraph/tests/.gitignore Ignores generated Dagger Go bindings and related artifacts for tests.
daggerverse/dgraph/tests/.gitattributes Marks generated bindings as linguist-generated for tests.
ci/main.go Adds a CI job to run dag.DgraphTests().All(ctx).
dagger.json Registers the new dgraph-tests module at the repo root for CI consumption.
Comments suppressed due to low confidence (1)

daggerverse/dgraph/tests/main.go:219

  • HttpEndpointsShouldNotBeCached similarly never stops the cluster and only compares list lengths, so it can’t catch a cached result. Add a Stop(ctx) between calls and validate the endpoint(s) are serving again after the restart to ensure +cache="never" is effective.
	cluster := freshCluster(ctx, 1, 1)
	eps1, err := cluster.HTTPEndpoints(ctx)
	if err != nil {
		return fmt.Errorf("endpoints 1: %w", err)
	}

Comment thread daggerverse/dgraph/tests/main.go
Comment thread daggerverse/dgraph/tests/main.go Outdated
Comment thread daggerverse/dgraph/tests/main.go Outdated
Comment thread daggerverse/dgraph/cluster.go Outdated
Comment thread daggerverse/dgraph/main.go Outdated
Zaba505 and others added 2 commits May 20, 2026 22:19
… + dgo client

Adds `daggerverse/dgraph/` end-to-end: a Zero-coordinator + N-Alpha
topology built from `dgraph/dgraph` images and a pure-Go dgo-based
Client that can target either the local cluster or any reachable
remote cluster (Dgraph Cloud, self-hosted). Plaintext-only on every
listener; TLS/mTLS, multi-Zero HA, ACL, Ratel, and RDF/delete
mutations are explicit follow-ups.

Deviations from the story spec (all documented in README):

- `+cache="session"` on `Dgraph.Cluster` / `Dgraph.Client` (not
  `"never"`). Chained `Mutate -> RunQuery` loses graph state under
  `never` because each method call re-spawns the cluster. Methods on
  *Cluster / *Client stay `+cache="never"`.
- `Client.Query` renamed to `Client.RunQuery` to avoid the Dagger Go
  SDK codegen collision with the always-present `query` querybuilder
  field on every generated object type.
- `Client.QueryWithVars(vars map[string]string)` becomes
  `(varsJson string)` because Dagger function signatures don't
  support Go map params.
- Adds odd-replicas validation (Dgraph Raft requirement).
- Adds `Cluster.Stop`, `Cluster.ZeroHosts`, `Cluster.AlphaHostNames`
  helpers needed for teardown and bind-aware tests.

All 15 acceptance-criterion tests pass individually via
`dagger -m daggerverse/dgraph/tests call <name>`. The `All()`
aggregator defaults to `--parallel=1` because session-cached clusters
with the default shape collide across parallel tests.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Zero is internal to a Dgraph cluster (Alpha↔Zero coordination and
admin/loader tools per dgraph docs); clients only talk to Alpha. The
spec does not expose admin tooling, so user containers never need
Zero reachable. The bind-zeros test was the only consumer of these
methods and conflicted with `+cache="session"` on Cluster: Dagger's
`WithServiceBinding(alias, svc)` only registers the alias for the
first consumer that lazy-starts svc, and the cluster's Alphas
already claim it.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Zaba505 Zaba505 force-pushed the worktree-issue-78 branch from 74edb02 to a0a0ce6 Compare May 21, 2026 02:21
- main.go / cluster.go: file-map and Cluster doc reference RunQuery
  (the actual exported method), not the renamed-away Query.
- tests/freshCluster: drop the misleading "defer Stop" instruction —
  Dgraph.Cluster is +cache="session", so Stop in one test would kill
  the shared cluster for any peer test still running.
- tests/Grpc|HttpEndpointsShouldNotBeCached: a length check can't
  distinguish a real re-execution from cached strings, so now Stop
  the cluster between calls and follow the second call with a real
  AlterSchema — proves start() actually ran instead of returning a
  cached endpoint list pointing at dead services.
- tests/MutateShouldNotBeCached: replace hardcoded "cache-probe"
  payload with a randName-generated value so re-runs never collide
  on a probe name across sessions.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 16 out of 18 changed files in this pull request and generated 5 comments.

Comment on lines +112 to +115
// derived from random material at construction time so distinct
// Cluster() calls within one engine session also get distinct
// service DNS, even though +cache="session" lets identical args
// share one service.
// +private
AlphaHosts []string
// +private
ClientSecurityMode string

Cluster.GrpcEndpoints(ctx) ([]string, error)
Cluster.HttpEndpoints(ctx) ([]string, error)
Cluster.AlphaHostNames(ctx) ([]string, error)
Comment on lines +105 to +113
// randName returns a short, DNS- and DQL-safe random identifier suitable
// for use as a schema-indexed value, blank-node name, or query fixture.
func randName(ctx context.Context, prefix string) (string, error) {
h, err := dag.Random().Sha256(ctx, dagger.RandomSha256Opts{N: 16})
if err != nil {
return "", err
}
return prefix + h[:12], nil
}
Comment on lines +223 to +224
// OK or the deadline passes. endpoint is the host:port pair returned
// by Service.Endpoint(ctx, port=8080).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

story(daggerverse): add dgraph module with plaintext cluster + client

2 participants