Documentation
¶
Overview ¶
Package spaceindex is the built-in `spaceIndex` type — one derived object per space carrying the space's display metadata (name, description, icon, spaceType) as CRDT-mutable base-scope properties. Replicates to every member like any other in-space object; each device mirrors the converged state into its own account-private tech-space row.
Pattern mirrors internal/types/any: hardcoded property defs, no custom handler — writes flow through internal/properties. SystemPropertiesHandler against the per-space `objects` collection just like `any.*` writes.
Index ¶
- Constants
- Variables
- func BundleRootSeed(bundleId string) []byte
- func BundlesSchema() schema.Dataset
- func IdentityKeyOf(row *anyenc.Value) string
- func IdentityKeysSchema() schema.Dataset
- type BuiltInProperty
- type BundlesHandler
- func (BundlesHandler) BeforeCreate(_ *crdt.ChangeCtx, rec *crdt.RecordChange, _ *crdt.Sink) error
- func (BundlesHandler) BeforeDelete(_ *crdt.ChangeCtx, _ *crdt.RecordChange, _ *crdt.Sink) error
- func (BundlesHandler) BeforeModify(_ *crdt.ChangeCtx, rec *crdt.RecordChange, op *crdt.Op, _ *crdt.Sink) error
- func (BundlesHandler) Init(_ context.Context) error
- type IdentityKeysHandler
- func (IdentityKeysHandler) BeforeCreate(ctx *crdt.ChangeCtx, rec *crdt.RecordChange, _ *crdt.Sink) error
- func (IdentityKeysHandler) BeforeDelete(_ *crdt.ChangeCtx, _ *crdt.RecordChange, _ *crdt.Sink) error
- func (IdentityKeysHandler) BeforeModify(ctx *crdt.ChangeCtx, rec *crdt.RecordChange, op *crdt.Op, _ *crdt.Sink) error
- func (IdentityKeysHandler) Init(_ context.Context) error
Constants ¶
const ( // BundlesDataset is the dataset name on the spaceIndex object. // Registered on every controller (uniform handler set) but only the // spaceIndex object carries rows by convention — the typed Bundles // API always targets it. BundlesDataset = "bundles" // BundlesHandlerVersion is stamped on every bundles change. BundlesHandlerVersion = "bundles-v1" // FieldBundleName is the bundle's display name. FieldBundleName = "name" // FieldBundleRootId is the winning root object id — a plain LWW // register. Reading it answers "is this bundle installed and where // is its root"; children are derived from it (DeriveObjectOpts. // ParentId), so the one id transitively names the whole setup. FieldBundleRootId = "rootId" // FieldBundleRoots is the add-only set of every root object id ever // claimed for this bundle. $addToSet ONLY — a $set would stamp // _ver[roots] and gate out concurrent adds (the losing device's // claim must always land, or its objects become invisible garbage). // Never shrunk: losers stay listed as the audit trail; their death // is recorded by tree deletion, not by mutating this array. FieldBundleRoots = "roots" // BundleRootSeedPrefix namespaces the derivation payload of a // bundle's canonical derived root, keeping it clear of the seeds // applications choose for their own derived objects. BundleRootSeedPrefix = "builtin:bundleRoot:" )
const ( // IdentityKeysDataset is the dataset name on the spaceIndex object. // Registered on every controller (uniform handler set); only the // spaceIndex object of a one-to-one space carries rows by // convention. IdentityKeysDataset = "identityKeys" // IdentityKeysHandlerVersion is stamped on every identityKeys change. IdentityKeysHandlerVersion = "identityKeys-v1" // FieldIdentityKeySymKey is the participant's identity metadata // symkey in the string form of space.MarshalSymKey — the same // encoding the ACL join-record metadata and the inbox invite carry. // Row id is the participant's account identity. SYNCED. FieldIdentityKeySymKey = "symKey" )
const ( Name = "Space Index" Description = "Per-space metadata mirrored to every member's tech-space row" )
Display metadata for the built-in spaceIndex type.
const ( FieldName = "name" FieldDescription = "description" FieldIcon = "icon" FieldSpaceType = "spaceType" )
Field names — the property ids inside the `spaceIndex` namespace. Used by writers and the tech-space mirror to address each value.
const TypeId = "spaceIndex"
TypeId is the public type id used to namespace spaceIndex property paths (`record.spaceIndex.name` etc.). v1 uses the literal "spaceIndex" both as the namespace key in property records and as the TypeInfo.Id surfaced through Space.Types(). User-derived type ids are content-addressable and cannot collide with this reserved string.
const WellKnownDeriveSeed = "builtin:spaceIndex"
WellKnownDeriveSeed is the derivation input used to mint the same `spaceIndex` object id on every peer of a space. Every space has exactly one spaceIndex object, always derived from this seed.
Variables ¶
var Properties = []BuiltInProperty{ {Id: FieldName, Name: "Name", Kind: schema.KindString, Scope: schema.ScopeSynced, Description: "Space display name.", XFormat: map[string]any{"type": "text"}}, {Id: FieldDescription, Name: "Description", Kind: schema.KindString, Scope: schema.ScopeSynced, Description: "Space display description.", XFormat: map[string]any{"type": "longtext"}}, {Id: FieldIcon, Name: "Icon", Kind: schema.KindString, Scope: schema.ScopeSynced, Description: "Space icon CID."}, {Id: FieldSpaceType, Name: "Space type", Kind: schema.KindString, Scope: schema.ScopeSynced, Description: "Application space type; not pinned, the initial Create write wins in practice."}, }
Properties lists the spaceIndex type's hardcoded property definitions in canonical display order. All four are synced strings — `spaceType` is intentionally writable through the CRDT (first writer wins in practice via the initial Create write).
Functions ¶
func BundleRootSeed ¶
BundleRootSeed is the derivation payload of the bundle's canonical derived root: the bundle id alone, so the root id is a pure function of (space, bundle id) and every device computes it with zero communication. See docs/bundles.md § Derived roots.
func BundlesSchema ¶
BundlesSchema declares the bundles dataset.
func IdentityKeyOf ¶
IdentityKeyOf reads the symkey off an identityKeys row; "" for a nil, tombstoned or malformed row.
func IdentityKeysSchema ¶
IdentityKeysSchema declares the identityKeys dataset.
Types ¶
type BuiltInProperty ¶
type BuiltInProperty struct {
Id string
Name string
Kind schema.Kind
Scope schema.Scope
// Description and XFormat are the descriptive slice: a display
// description and the opaque descriptor bag (docs/data-structure.md § The
// `x-format` descriptor). Surfaced by Types().Properties and
// dataset discovery like a user definition's; never interpreted
// or enforced by the SDK.
Description string
XFormat map[string]any
}
BuiltInProperty is one hardcoded property definition. Same shape as anytype.BuiltInProperty so the types registry surfaces both uniformly. Scope uses the unified schema.Scope taxonomy.
type BundlesHandler ¶
type BundlesHandler struct{}
BundlesHandler validates ops on the bundles dataset. Deterministic — every replica evaluates the same rules on the same causal prefix, so the gates cover every writer, not just the typed API.
func (BundlesHandler) BeforeCreate ¶
func (BundlesHandler) BeforeCreate(_ *crdt.ChangeCtx, rec *crdt.RecordChange, _ *crdt.Sink) error
BeforeCreate runs the full per-op rules over the whole change: the apply pipeline runs ONLY BeforeCreate on a record's first change (no per-op BeforeModify), so every invariant must hold here too or it is unenforced exactly once per bundle id — and a first-change `$set roots` would stamp _ver[roots] and gate out legitimate claims forever. An invalid op drops the whole RecordChange (per-record hook), which is the right granularity for a malformed create.
func (BundlesHandler) BeforeDelete ¶
func (BundlesHandler) BeforeDelete(_ *crdt.ChangeCtx, _ *crdt.RecordChange, _ *crdt.Sink) error
BeforeDelete rejects all record deletes: the row id is the bundle's global identity and the tombstone is sticky — a delete would ban the bundle id in this space forever. Uninstall semantics, when needed, will be a field-level state, not a record delete.
func (BundlesHandler) BeforeModify ¶
func (BundlesHandler) BeforeModify(_ *crdt.ChangeCtx, rec *crdt.RecordChange, op *crdt.Op, _ *crdt.Sink) error
type IdentityKeysHandler ¶
type IdentityKeysHandler struct{}
IdentityKeysHandler validates ops on the identityKeys dataset. Deterministic — every replica evaluates the same rules on the same causal prefix, so the authorization holds against every writer, not just the typed API.
func (IdentityKeysHandler) BeforeCreate ¶
func (IdentityKeysHandler) BeforeCreate(ctx *crdt.ChangeCtx, rec *crdt.RecordChange, _ *crdt.Sink) error
BeforeCreate runs the full per-op rules over the whole change: the apply pipeline runs ONLY BeforeCreate on a record's first change (no per-op BeforeModify). An invalid op drops the whole RecordChange.
func (IdentityKeysHandler) BeforeDelete ¶
func (IdentityKeysHandler) BeforeDelete(_ *crdt.ChangeCtx, _ *crdt.RecordChange, _ *crdt.Sink) error
BeforeDelete rejects all record deletes: the row id is the participant's identity and the tombstone is sticky — a delete would ban that participant's key in this space forever.
func (IdentityKeysHandler) BeforeModify ¶
func (IdentityKeysHandler) BeforeModify(ctx *crdt.ChangeCtx, rec *crdt.RecordChange, op *crdt.Op, _ *crdt.Sink) error