Skip to content

Resolve an omitted datastore:// namespace to the backend default - #469

Merged
em3s merged 7 commits into
mainfrom
feat/issue-468-datastore-default-namespace
Jul 31, 2026
Merged

em3s merged 7 commits into
mainfrom
feat/issue-468-datastore-default-namespace

Conversation

@em3s

@em3s em3s commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The namespace in a datastore:// ref is a per-deployment config value (actionbase.hbase.namespace → ab_local, ab_prod), but acquisition passed the URI's namespace straight to TableName.valueOf. So the migrate CLI baked a concrete namespace into every rewritten ref and pinned the metadata to one environment, and the defaultNamespace the factory already captured was never read.

This implements the datastore:// scheme decision from #468: adopt Hadoop's fs.defaultFS model, where an omitted namespace (datastore:///<table>) resolves to the backend's configured default at acquisition. An explicit namespace still resolves exactly as before, so existing refs are untouched.

I amended the naming rules in #468 while writing this. Segments start with a lowercase letter like every other name, and the reserved form is the fully delimited __x__.

Closes #468

Changes

  • StorageBackend carries a defaultNamespace; getStorageTable(uri) substitutes it for an empty parsed namespace.
  • HBaseStorageBackend supplies the namespace it previously only requireNotNulld, and now rejects a blank one — blank would leave an omitted-namespace ref resolving to HBase's own default rather than the deployment's. Backends that serve one unnamed space share StorageBackend.DEFAULT_NAMESPACE.
  • DefaultHBaseCluster fills an empty namespace with its configured namespace on the data-table resolution path. Its parsing now delegates to DatastoreUri.parse — the data-table path had a private copy of the split-and-require logic, so the scheme's rules now live in one parser.
  • STORAGE_URI_PATTERN accepts the omitted form (datastore:///<table>) and holds each segment to the letter-start rule, which leaves the reserved __x__ form out of reach of user input so it can't target datastore://__sys__/metastore.
  • The migrate CLI rewrite emits the omitted form instead of baking the namespace. migrate plan reports the source namespaces it drops — counting only the storages a planned label references — and rejects a conf.tableName the scheme disallows, since legacy storage entities were never held to the name rule.
  • Tests: omitted-namespace resolution on all three backends and on DefaultHBaseCluster, a blank namespace rejected at create, the pattern's accept/reject set (including the __x__ reservation and the letter-start rule), and the migrate URI shape.

One behavior change rides along. DefaultHBaseCluster.getTable(uri) validated nothing before, so a ref with characters the scheme disallows reached TableName.valueOf; it now fails at resolution. Nothing creatable through DDL is affected, and the migrate rewrite rejects such a name in the plan phase rather than emitting it.

How to Test

./gradlew :core:test :engine:test
cd cli && go test ./internal/command/

AI Assistance

  • This PR was written largely with AI assistance.
    • Tool / model: Claude Opus 4.8

The namespace in a datastore:// ref is a per-deployment config value
(`actionbase.hbase.namespace`), but acquisition passed the URI's namespace
straight through, so the migrate CLI had to bake a concrete namespace into
every ref and pin the metadata to one environment.

Adopt Hadoop's `fs.defaultFS` model: an omitted namespace (`datastore:///<table>`)
resolves to the backend's configured default at acquisition. `StorageBackend`
now carries a `defaultNamespace`; `HBaseStorageBackend` supplies the namespace it
previously only validated, and memory/mock backends supply "default". The
`DefaultHBaseCluster` resolution path fills an empty namespace the same way.
`STORAGE_URI_PATTERN` accepts the omitted form, and the migrate rewrite emits it.

An explicit namespace still resolves as before, so existing refs are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Jul 24, 2026
em3s and others added 6 commits July 24, 2026 22:01
The data-table resolution path (DatastoreIndexedLabel,
DatastoreHashOnlyIndexedLabel) parsed datastore:// URIs with a private copy of
the split-and-require logic instead of DatastoreUri.parse, so the scheme's
rules lived in two places. Delegate to DatastoreUri.parse and keep only the
empty-namespace substitution here, leaving one parser for the whole scheme.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Allowing an omitted namespace meant relaxing STORAGE_URI_PATTERN, which
previously required a leading letter and so happened to block the reserved
`__sys__` namespace. Segments now accept a single leading underscore, but a
`__` prefix is reserved: user-supplied storage refs reject it, so a table
can't be pointed at `datastore://__sys__/metastore` and bind to the metastore.
The internal DatastoreUri parser still accepts `__` names the engine mints.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The rewrite omits the source namespace so refs resolve to the target
deployment's configured namespace. That is silent information loss: a table
that lived in a non-default namespace gets repointed. `migrate plan` now lists
the source namespaces it saw and warns when more than one appears, so the
operator can verify before applying.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The storage URI pattern accepted any lowercase alphanumeric/underscore
segment and reserved system names by a __ prefix. Every other name in the API
starts with a lowercase letter (Constants.Name.PATTERN), so the storage
segment was the lone exception, and a __ prefix admits half-delimited names
like __sys that belong to neither the user nor the engine.

Segments now start with a lowercase letter. That reserves the fully delimited
__x__ form for system namespaces without a negative lookahead: the engine
still mints datastore://__sys__/metastore through the parser, and no user
input can express it.

This drops datastore:///_expire. Nothing mints a ref like that - the
per-entity top-k work uses topk_expire_* and <name>__expire - and a table or
queue named _expire was never creatable, since those fields already validate
against Constants.Name.PATTERN.

Amends the naming decision in #468.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
requireNotNull let a blank namespace through. It used to be discarded, but it
is now the value an omitted-namespace ref resolves to, and TableName.valueOf
turns an empty namespace into HBase's own default - so a blank config value
would have quietly placed every such ref in the wrong namespace.

The resolution itself was only covered on MemoryStorageBackend. Both paths that
run in production now have a test: HBaseStorageBackend.create carries the
configured namespace as its default, and DefaultHBaseCluster substitutes its
own for an omitted namespace while leaving an explicit one alone.
parseDatastoreUri becomes internal for that, following resolveKerberosRealm in
the same class.

The two backends that serve one unnamed space now share
StorageBackend.DEFAULT_NAMESPACE instead of repeating the literal.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
storageToDatastoreURI only checked that conf.tableName was present. Legacy
HBASE storage entities were never held to the name rule, so a name like Edges
became datastore:///Edges and failed with a 400 partway through apply, after
earlier entries had already been replayed. The plan phase now rejects it,
alongside the storages that have no URI at all.

The dropped-namespace note also counted storages no label references, which
could warn about multiple source namespaces when every rewritten ref pointed at
one. It now counts only the storages a planned label actually references.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 31, 2026
@em3s

em3s commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Two notes for review.

The naming rules in #468 changed while I was finishing this. Segments now start with a lowercase letter like every other name in the API, and the reserved form is the fully delimited __x__ rather than a __ prefix. I amended the issue body before pushing so the decision record and the regex agree. Against main the pattern is still purely additive — it accepts the omitted form, and nothing that used to pass now fails.

One thing I left alone. DefaultStorageBackendFactory keeps its own defaultNamespace (properties["namespace"] ?: "default"), so two places now answer "what does an omitted namespace resolve to". Nothing in production reads the factory's copy, and with type=memory the two disagree — the factory reports the configured namespace while the backend reports default. I'd rather not churn it here: the planned follow-up that builds the storage provider from configuration drops the dependency on that global entirely and leaves the factory as test infrastructure, which is where the duplicate should go away.

@em3s

em3s commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Optimistic

@em3s
em3s merged commit af77637 into main Jul 31, 2026
2 checks passed
@em3s
em3s deleted the feat/issue-468-datastore-default-namespace branch July 31, 2026 08:07
@em3s em3s self-assigned this Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Define the datastore:// storage URI scheme

1 participant