stack-ids
Shared identity, scope, trace, and digest primitives for the local-first AI systems stack.
stack-ids is the identity foundation used by the stack's memory, bridge,
verification, runtime, kernel, governance, and evidence crates. It provides
opaque ID newtypes, scope partition keys, W3C-compatible trace context helpers,
canonical BLAKE3 content digests, and shared status/citation structs.
This crate intentionally owns type contracts only. It does not own the rows, files, envelopes, policies, schemas, or runtime behavior that those identifiers point to.
Contents
- What it provides
- Current package status
- Install
- Quick start
- Identity newtypes
- Scope keys
- Trace context
- Content digests
- Status and citations
- Authority boundary
- Serialization and schemas
- Operational notes
- Minimum supported Rust version
- License
What it provides
- Opaque string-backed ID newtypes for stack artifacts.
- UUID v4 generation for every ID type.
- Transparent serde serialization for wire and storage contracts.
- JSON Schema derivation through
schemars. ScopeandScopeKeyfor namespace/domain/workspace/repository partitioning.- Legacy namespace conversion helpers for migration paths.
TraceCtxwith W3Ctraceparentparsing/formatting.- Bounded trace baggage with explicit validation errors.
- Deterministic conversion from legacy trace IDs to W3C trace IDs.
ContentDigestfor canonical BLAKE3 digests over bytes, strings, and JSON.DigestBuilderfor incremental multi-field digest domains.- Shared surface-status and constitution-citation types.
Current package status
| Property | Value |
|---|---|
| Crate | stack-ids |
| Current local version | 0.1.1 |
| Rust edition | 2021 |
| MSRV | Rust 1.75 |
| License | Apache-2.0 |
| Storage | None |
| Network | None |
| Primary dependency role | Foundation crate |
Install
[]
= "0.1.1"
Quick start
use ;
let entity_id = generate;
assert!;
let scope = new
.with_domain
.with_workspace
.with_repo;
let scope_key: ScopeKey = scope.key;
assert_eq!;
let trace = generate;
let child = trace.child;
let traceparent = child.to_traceparent?;
let parsed = from_traceparent?;
assert_eq!;
let digest = compute_str;
assert_eq!;
# Ok::
Identity newtypes
ID types are opaque wrappers around strings. They exist to prevent accidental cross-use of semantically different identifiers that happen to have the same runtime representation.
Each ID type supports:
new(value)generate()using UUID v4as_str()is_empty()DisplayFromStrFrom<String>From<&str>AsRef<str>SerializeandDeserializeJsonSchemaDebug,Clone,PartialEq,Eq,Hash,PartialOrd, andOrd
Representative ID families include:
| Family | Examples |
|---|---|
| Core truth | EnvelopeId, ClaimId, ClaimVersionId, EntityId, EpisodeId |
| Projection | ProjectionId, RelationId, RelationVersionId, ImportBatchId |
| Execution | AttemptId, TrialId, KernelRunId, ExecutionPermitId |
| Kernel | ConstraintId, HyperedgeId, ResidualId, SyndromeId, WitnessId, CertificateId |
| Verification | VerificationCaseId, CheckPlanId, ControlReceiptId, PolicyDecisionId |
| Governance | ApprovalGrantId, PromotionDecisionId, RollbackPlanId, CalibrationSnapshotId |
| Semantics | SemanticsProfileId, ClaimStateId, SemanticDiffId, SupportSetId |
| Experiment | InterventionId, ExperimentCaseId, CohortContractId, DecisionTraceId |
| Attestation | AttestationEnvelopeId, TrustRootSetId, TransparencyReceiptId |
| Effect | EffectIntentId, EffectWindowId, EffectCommitDecisionId, CompensationPlanId |
| Authority | CapabilityClassId, AuthorityLeaseId, DelegationBundleId, BreakGlassGrantId |
| Release and safety | DeploymentProfileId, AssuranceCaseId, HazardRegisterId, CertificationBundleId |
Scope keys
Scope is the builder-style input shape. ScopeKey is the compact partition key
used by storage, import, and query contracts.
use ;
let scope = new
.with_domain
.with_workspace
.with_repo;
let key = scope.key;
assert_eq!;
assert_eq!;
Display format:
namespace[/domain][@workspace_id][#repo_id]
Examples:
prodprod/codeprod/code@workspace-1prod/code@workspace-1#repo-1
Legacy namespace helpers:
ScopeKey::namespace_only(ns)ScopeKey::from_legacy_namespace(ns)scope_key.to_legacy_namespace()scope_key.is_namespace_only()
Trace context
TraceCtx is the stack's shared trace-correlation shape. It is compatible with
W3C trace context, while still supporting deterministic migration from legacy
trace IDs.
use TraceCtx;
let trace = generate
.with_parent
.add_baggage?;
let header = trace.to_traceparent?;
let parsed = from_traceparent?;
assert_eq!;
# Ok::
Baggage limits are enforced:
- maximum 16 entries,
- maximum 256 bytes per key,
- maximum 256 bytes per value.
Legacy trace IDs can be converted without losing determinism:
let trace = from_legacy_trace_id;
assert_eq!;
Content digests
ContentDigest is a canonical BLAKE3 hex digest wrapper.
use ;
use json;
let bytes_digest = compute;
let text_digest = compute_str;
let json_digest = compute_json?;
let composed = new
.update_str
.separator
.update_str
.finalize;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
# Ok::
JSON digesting normalizes object keys recursively so equivalent JSON objects hash consistently across map-order differences.
Status and citations
The crate also exports small shared structs/enums used across stack contracts:
PhaseStatusSurfaceStatusV25ConstitutionCitation
These are lightweight data contracts, not policy engines.
Authority boundary
stack-ids is authoritative for:
- typed ID shapes,
- scope shape and display format,
- trace context shape,
- digest wrapper semantics.
stack-ids is not authoritative for:
- what an ID points to,
- whether an artifact exists,
- whether an artifact is valid,
- how rows are stored,
- how runtime policy is enforced,
- how memory retrieval is ranked.
Those responsibilities belong to the consuming domain crates.
Serialization and schemas
All public ID wrappers are serde-transparent. This means a JSON field such as
ClaimId serializes as a string, not an object:
Types derive JsonSchema where appropriate so higher-level crates can generate
schema bundles without redefining identity primitives.
Operational notes
- The crate performs no I/O.
- The crate has no network behavior.
- Generated IDs are UUID v4 strings.
- Empty strings are representable because some import and migration paths need to validate legacy data explicitly.
- Prefer typed IDs at API boundaries instead of raw
String. - Use
ScopeKeyinstead of packing scope into ad hoc namespace strings for new integrations.
Minimum supported Rust version
stack-ids declares rust-version = "1.75.0" and uses Rust 2021.
License
Apache-2.0. See LICENSE.