Skip to content

x,edgraph,worker: add a reserved-namespace plugin registry#9749

Open
matthewmcneely wants to merge 1 commit into
oss-alter-noauthfrom
oss-reserved-namespace-registry
Open

x,edgraph,worker: add a reserved-namespace plugin registry#9749
matthewmcneely wants to merge 1 commit into
oss-alter-noauthfrom
oss-reserved-namespace-registry

Conversation

@matthewmcneely

Copy link
Copy Markdown
Contributor

What

Adds x.RegisterReservedNamespace: a plugin can claim ownership of a sub-namespace under the reserved dgraph. prefix — a dynamic predicate prefix and/or an exact predicate/type allowlist — so its names can be created at runtime via Alter even though they aren't part of the pre-defined initial schema, and optionally value-lock a subset of its predicates to a trusted in-process writer.

The three reserved-namespace enforcement points consult the registry:

  • parseSchemaFromAlterOperation — a registered predicate/type passes the reserved-but-not-pre-defined check (IsRegisteredReservedPredicate / IsRegisteredReservedType).
  • worker.proposeAndWait — a registered predicate may be mutated before its schema exists.
  • the mutation value guard (newReservedPredicateGuard) — a write to a value-locked predicate is rejected unless the request context carries the namespace's TrustMarker (ReservedPredicateValueLock).

Why

There is currently no way for a downstream consumer to own names under dgraph. — the prefix is all-or-nothing reserved. This adds a narrow, explicit extension point rather than a broad carve-out.

Safety

With no registration the registry is empty and every check reports false, so a stock build keeps the pristine behavior: nothing under dgraph. may be created except the pre-defined names, and the GraphQL reserved-value path (IsGraphql / IsOtherReservedPredicate) is unchanged.

Notes for review

Tests

x/reserved_namespace_test.go covers dynamic-prefix and exact membership, the predicate/type split, and value-lock lookup against a dummy registered namespace.

Introduce x.RegisterReservedNamespace, letting a plugin claim ownership of a sub-namespace under the reserved `dgraph.` prefix so its predicates and types can be created at runtime via Alter even though they are not part of the pre-defined initial schema, and optionally value-lock a subset of those predicates to a trusted in-process writer.

The three reserved-namespace enforcement points now consult the registry: parseSchemaFromAlterOperation allows a registered predicate/type through the reserved-but-not-pre-defined check (IsRegisteredReservedPredicate / IsRegisteredReservedType); worker.proposeAndWait allows a registered predicate to be mutated before its schema exists; and the mutation value guard rejects writes to a value-locked predicate unless the request context carries the namespace's TrustMarker (ReservedPredicateValueLock).

With no registration the registry is empty and every check reports false, so a stock build keeps the pristine behavior: nothing under `dgraph.` may be created except the pre-defined names, and the GraphQL reserved-value path is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@matthewmcneely matthewmcneely requested a review from a team as a code owner June 17, 2026 18:53
@matthewmcneely matthewmcneely requested a review from mlwelles June 17, 2026 21:08
@amalistari amalistari requested a review from shiva-istari June 18, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant