hubuum-storage-core Rust API Policy¶
Status: experimental public API in the storage SDK 0.4 release train.
Purpose and Callers¶
hubuum-storage-core is the complete backend-neutral storage extension
contract. It exposes capability traits, private-field DTOs, the bounded
StorageError taxonomy, and the aggregate StorageBackend compile-time check.
Backend crates may live outside this workspace and depend on the supported SDK
graph without linking the server.
Hubuum uses static Cargo composition; this is not a dynamic plugin ABI and has
no runtime contract version handshake.
The normative semantics of that Rust surface are documented in the storage contract. The Rust declarations, semantic coverage inventory, and contract documentation must change together.
The crate also exposes the mandatory TransactionStorage unit of work.
Applications compose safe lifecycle semantics through the crate-owned
operation types returned by StorageTransaction; native connections and query
interfaces remain private to each adapter.
HistoryStorage::list_object_history_by_name is a mandatory SDK addition.
Adapters consume StorageObjectHistoryNameQuery, match exact retained class/name
coordinates across object identities, and apply visibility before counting and
paging. Live identities require both current and historical collection access;
a class change does not make an identity deleted. Truly missing identities are included only when the application's deleted-history gate
sets include_deleted. External adapters must implement this method before
upgrading; a default empty result is not a compatible implementation. Existing
adapters must check live existence by object ID independently of its current class.
HistoryStorage::list_class_objects_as_of is a mandatory SDK addition.
Adapters must implement the complete historical-population contract using
StorageClassObjectsAsOfQuery, including current and historical authorization,
effective-version selection, bounded pagination and optional exact counts.
Update external adapters before upgrading; returning an empty fallback would
misrepresent retained history.
HistoryStorage::get_computed_field_history is a mandatory SDK addition.
Implement it before upgrading: return the complete shared set selected by
StorageComputedFieldHistoryQuery, including an observed empty set, or None
when its interval is unavailable. StorageHistoricalComputedFields proves the
class and selected instant. Retain definition IDs/revisions, enablement and
versioned evaluation semantics, never personal definitions or actor metadata.
The complete backup contract adds ComputedFieldHistory; restore must preserve
retained intervals and establish missing current sets at the restore boundary.
Run the shared historical-computation and restore conformance tests.
HistoryStorage::list_relation_history is a mandatory SDK addition. Implement
StorageRelationHistoryQuery for both class and object endpoints, changes and
half-open as-of selection, bounded history-ID pages, and optional candidate
totals. Return StorageRelationHistoryEntry with endpoint context from the same
instant; preserve missing history instead of filling it from live state. The
application authorizes candidates before exposing rows, totals and cursors.
External adapters must implement this method before upgrading.
Login issuance requires StorageLogin evidence carried by
StorageTokenCreate::for_login. Adapters must recheck it atomically against the
current user while fencing credential changes. Authentication retains the original
StorageUser snapshot through issuance; StorageSyncedHuman converts losslessly
into that snapshot without discarding its validated identity or timestamps. External refresh bookkeeping uses
record_external_sync_failure with StorageExternalSyncFailure; rejection must
invalidate cached authority, pending login evidence, and active tokens. See the
transaction contract.
Ordinary resource mutations require EventContext and return
StorageMutationOutcome. A committed outcome includes a non-empty set of
non-sensitive StorageAuditReceipt values for the durable events written atomically
with the state change; a genuine no-op returns Unchanged. Imports and
restores use explicit ImportStorage and RestoreStorage capabilities and do
not weaken ordinary mutation signatures.
Backup snapshots validate revision and temporal-history consistency at their
fallible constructor. Restore documents consume that validated source and
prepare a complete replacement, including fresh current temporal snapshots
for a history-free source. StorageRestoreDocument::new retains its existing
signature; at_restore_boundary accepts an explicit boundary timestamp.
Adapters must persist the prepared history even when source_includes_history
is false.
Endpoint-set relation queries expose an optional max_results() bound.
Adapters must apply that bound before materializing rows, after endpoint
selection and visibility; zero requests no rows. new and into_parts retain
their signatures, so read the bound before consuming the query. External
adapters must implement the added bound before serving delegated traversal.
Task queries now optionally carry StorageTaskSearch through searching and
search. The constructor and into_parts signatures remain compatible, but
external adapters must read and apply the search before consuming the query.
This is a behavioral contract change for adapters: ignoring the new predicates
produces incorrect task rows and counts. TaskTimeRange validates
half-open timestamp intervals; lifecycle sets and terminal restrictions are
validated before storage access. No database migration is required for these
lifecycle predicates.
Application composition supplies StorageObserver, keeping metrics exporters
and global registries out of adapter-neutral contracts.
The root hubuum crate remains an internal application composition crate.
HTTP clients should use Hubuum's versioned API instead of this storage API.
Compatibility¶
The crate follows the lockstep versioning, exact dependency, MSRV, deprecation, aggregate evolution, and adapter upgrade rules in the Storage Adapter SDK Compatibility policy. The release-train MSRV is Rust 1.88.
There are no feature flags. DTOs are in-memory Rust contracts, not durable or
wire formats unless their documentation explicitly says otherwise. Backend
implementations are expected to implement every supertrait of StorageBackend;
focused test doubles may implement only the traits under test.
Lifecycle operations, record metadata, principal projections, and revision
preconditions use hubuum-domain IDs and ResourceRevision. Revision targets
are a closed semantic enum rather than adapter-formatted owner keys. Query
methods accept validated hubuum-query values, and errors use storage-domain
classifications rather than HTTP status or database-driver names. Native table,
row, connection, query, and ETag representations are adapter or application
concerns.
Computed-field create and import operations accept validated
hubuum-computed-fields::Definition values. Adapters flatten a definition only
at their persistence boundary and reconstruct it fallibly when reading stored
rows; they must not expose an unvalidated parallel definition representation.
Task execution uses distinct active and terminal update types. Claims validate active status, lease presence, and task identity; completion construction validates the documented task-kind/artifact matrix before an adapter receives the request. Adapters must still compare the declared completion kind with the claimed persisted task.
Errors, Runtime, and Cancellation¶
Backend-specific errors must be classified into StorageError before returning
through a storage trait. Applications translate StorageError into their own
transport errors. Caller input must return an error rather than panic.
Async methods require a Send-capable executor but do not prescribe Tokio or an
I/O driver. Dropping a returned future requests cancellation; a backend must
document and test any operation that can continue or commit after cancellation.
Multi-step writes that promise atomicity must use the backend's transaction
mechanism. A TransactionStorage implementation commits when its callback
returns Ok and rolls back when it returns Err. Transaction-scoped mutations
inherit one required event context, and adapters must commit or roll back state
and audit side effects together.
Security and Observability¶
Private fields and validating constructors preserve boundary invariants.
Implementations must enforce visibility and permission inputs rather than treat
them as hints. Debug implementations must remain bounded and redact identifiers,
credentials, payloads, filters, and tokens where documented. Application
composition wraps logical entrypoints with StorageObserver. Adapters may
accept separate application-supplied native observers for implementation-level
telemetry; both observer layers must use bounded capability and operation
labels.
Ownership and Verification¶
Hubuum maintainers own the crate. The PostgreSQL adapter is the
reference implementation, and shared compatibility tests exercise every
statically registered backend. The
experimental public hubuum-storage-conformance harness certifies durable
receipts, no-op behavior, rollback, outbox-to-sink delivery, telemetry, exact
revision conflicts, retention retry identity, delivery recovery, restore
coordination rollback, and lease-loss finalization, while each backend owns
native query, transaction, migration, connection-loss, and failure tests.
External-crate integration tests implement all 44 complete-backend traits,
compile every one of their 250 methods, exercise every transaction port, and
name public construction paths for all current adapter-returned values. CI also
packages the crate, builds rustdoc with warnings denied, and compares it with
the latest crates.io release when a baseline exists.
Task discovery adds a storage SDK obligation: preserve the private-fielded,
versioned StorageTaskMetadata on creation, completion, redaction and backup
round trips. Validate persisted JSON once with from_persisted. Preserve unknown
historical facts and update output summaries in the fenced finalization
transaction. Artifact purge must not erase them.
Apply TaskDiscoverySearch predicates before counting and pagination, using its
single captured evaluation timestamp. Project StorageTaskDiscoveryState from
retained schema-work kind/status and artifact existence in bounded queries;
never assemble schema reports during task polling. The PostgreSQL adapter
requires migration 2026-09-18-000001_task_discovery.
Task authorization enrichment uses AuthorizationDataStorage::load_authorization_resources
with a deduplicated StorageAuthorizationResourcesQuery. Adapters return lightweight
StorageAuthorizationResource facts for all seven reference kinds, omit missing
resources and relation endpoints, and bound queries by resource kind rather than
page size. Preserve names and both relation endpoints for delegated policy checks;
do not load template contents or remote transport/credential settings. Permission
decisions remain with the configured authorization backend.
authorize_local_collection_batch returns one decision per input, in input order,
using only the requested principals and collections. Preserve the single-check
semantics: all requested permissions must occur in one group grant for that
collection. Do not combine partial grants from different groups. Local permission
batches use this operation for both endpoints of relations, including non-admin
callers, without per-resource database calls.
History Navigation¶
HistoryStorage::list_history_markers consumes a validated
StorageHistoryNavigationQuery and projects metadata without object JSON or
class schemas. StorageHistoryResource binds the resource kind and identity;
objects also carry their class identity. StorageHistoryWindow validates the
half-open timestamp window. StorageHistorySelection distinguishes exact entry
lookup, timestamp seeks, and strict entry-position seeks without conflating them.
Adapters must use full-precision UTC (valid_from, history_id) ordering in the
requested direction, apply historical collection visibility and selection before
counts/pagination, and honor opaque or internal continuation cursors. A count is
optional and independent of the cursor; when requested it shares the page's read
snapshot. Return InvalidInput for malformed cursors. Metadata reads must not
hydrate snapshot JSON or compute diffs.
get_history_entry consumes StorageHistoryEntryQuery, constraining the history
ID by table, resource ID, and the object's historical class. It returns the typed
class/object entry, including tombstones, or None. Application callers authorize
historical attributes through metadata before loading the full entry. Do not infer an expiry
reason from a missing row or from the oldest retained timestamp.
Adding these two required methods is a breaking pre-1.0 SDK change. Adapter implementations must add both methods and run the shared history-navigation conformance coverage. Existing full-row history and as-of methods are unchanged.