Peios Learn
Documentation

Peios

Peios Peios Kernel Universal Directory Project

Developer Tools

Trail Acta Provium clackatoo CAF GCSL Pekit

Applications

Framewright

Standards and Conventions

Standards and Conventions Peios Specifications
Universal Directory

Concepts

Single-page view · as markdown

Objects and Identity

Universal Directory / Concepts

Every entry in the directory; an OU, a user, a schema definition; is an object. UD's object model rests on one distinction it never blurs: identity versus address.

Identity: the GUID #

An object's identity is a GUID, assigned at creation and immutable for the object's entire life.

Everything that needs to point at an object stores that GUID, never a name or a path: a group's member values, a facet's attribute list, a class's composition. Renames and moves therefore never break references. Deleting an object leaves any remaining references visibly dangling at the dead GUID, rather than silently rebinding to whatever later takes the name.

Address: derived, never stored #

Internally the store is inode-shaped: a flat table of objects keyed by GUID, where each object records only its parent's GUID and its own bare name (Sales, Jack). The tree is an index over that table.

Both address forms are computed on demand:

  • The distinguished name; leaf-first with typed components, CN=Jack,OU=Sales, where each prefix comes from the object's class (dnPrefix) and values are escaped per RFC 4514;
  • The native path; root-first and untyped, /Sales/Jack, used by the console, the JSON API's path resolution, and anywhere a human types an address. Path lookup is case-insensitive.

Because addresses are derived, renaming an OU is a single-object change. Every descendant's DN and path change logically, with zero writes, and nothing that references those descendants notices at all.

The tree has a single root object; empty name, class domainRoot; which never appears in DNs and cannot be renamed, moved, or deleted.

Names and sibling uniqueness #

Within one parent, names are unique under two deliberately strict rules.

Caseless, case-preserving. Names compare under Unicode canonical caseless matching, so Jack, jack, and a decomposed Jack are all the same name. The spelling you create is the spelling you see; the folding governs comparison and conflict only. See naming rules for the exact function.

Type-blind. Uniqueness ignores class entirely. An OU named Sales and a group named sales cannot be siblings. One container, one meaning per name.

Names cannot be empty or contain /, control characters, or surrounding whitespace. Strict rules can be safely loosened later; a loose rule can never be tightened without breaking existing data.

Rename and move #

Rename and reparent are one operation, in the shape of LDAP's ModifyDN: change the name, the parent, or both, atomically.

The engine refuses:

  • Moves that would create a cycle, placing an object under itself or its own descendant;
  • A destination where the caseless, type-blind name is already taken;
  • Any rename or move of the root, of system objects, or of schema objects; definitions are add and delete only; and any move into the schema subtree.

A case-only rename, jack → Jack, is always legal. It is the same caseless name, so it conflicts with nothing.

Delete: the three-stage lifecycle #

Deletion is soft and subtree-wide. Deleting an object tombstones it and every descendant in place, each with its own stamped existence transition.

A tombstone leaves the effective tree immediately; its name is free at once; but the full record survives, and every tombstoned object is individually restorable. Restoring is top-down: the parent must be alive and the name must still be free. It is an ordinary write, and a restore into a conflict refuses.

Beyond Deleted sit two harder states.

Shredded is security erasure, reachable directly from alive or as an escalation of a soft delete. The payload and even the name are destroyed; only a skeleton; GUID, parent GUID, stamps; remains. Every reference to the shredded GUID is physically scrubbed out of every holder, because erasure that leaves the object's GUID lingering in group member lists would fail its own purpose. The persistence scheduler rewrites affected files with a two-minute target. Failed or stalled I/O can prevent that deadline from being met; the storage view reports outstanding work. Shredding cannot be undone through directory restoration.

Purged means the tombstone is gone entirely. This is never manual: purge happens automatically once a tombstone's age passes maxTimeApart.

Aging is computed, not written #

Two domain-wide knobs, stored as attributes on /Configuration with defaults of 30 and 180 days, drive the automatic transitions. Past timeUntilShred a soft-deleted record hardens: the restore window closes and the flesh is scrubbed to a skeleton. Past maxTimeApart the skeleton purges.

Aging is a pure function of the object's existence stamp, the config windows, and the clock. Every node evaluates a tombstone's effective stage the same way, so nodes never race stamps about it. Local garbage collection merely catches physical storage up with what the aging function already answers.

The root and system objects are permanently protected, and schema definitions add their own unused-delete rules. Because references store GUIDs, deleting a referenced object never edits the referrers: their values dangle visibly at the tombstone until the target is shredded, at which point they are scrubbed.

System objects #

Objects created at domain creation carry a system flag: the root, /Configuration, /Configuration/Schema, /LostAndFound, /Domain Controllers, and every base schema definition.

System objects refuse renames, moves, and deletion; they are the fixed points the rest of the directory is built around; but their attributes are writable. The replication knobs live as attributes on /Configuration, and a description on the root is legal. Schema definitions are the exception, fully immutable through the schema-subtree rule.

Structural repairs are derived, never written #

Replication will merge writes that were each legal at their origin but collide when combined. UD repairs these as a view: the stored records stay exactly as written, and every node derives the same effective tree from the same atoms. No repair writes, no repair replication traffic.

Three rules, all favoring the earliest claim; the first legal write stands, because the later write is the one that caused the violation:

  • Name conflicts. Two live siblings whose names fold equal: the earliest placement claim keeps the name, and the later one displays as name CNF:<guid>. It remains resolvable and renameable, and its stored name is untouched.
  • Orphans. A live object whose stored parent is dead or missing derives into /LostAndFound. Restoring the parent snaps it back automatically.
  • Cycles. Concurrent moves that form a loop break at the newest placement: the latest mover derives into /LostAndFound, and the earlier move survives intact.

Admin operations target the effective view; rename the CNF loser, move the orphan out, as ordinary writes; and the repair dissolves the moment the underlying violation is gone.

Objects whose class definition has not arrived yet are ghosts: visible in the debugger, holding their sibling name, but refusing every originating write until the schema converges.

Replication stamps #

Every replicated fact about an object decomposes into merge atoms:

  • Its existence; creation, with class and the system flag riding along;
  • Its placement; (parent, name) as one atom, so rename and move contend as a unit;
  • Each attribute value.

Every atom carries a stamp: a version, an originating time, and an originating invocation id. Together these decide conflicts deterministically; higher version wins, then later timestamp, then origin; and a transfer certificate drives change enumeration. Removing a value leaves a stamped absence atom rather than a hole, so the removal itself can win merges.

For how those atoms travel and merge, read Replication.

The Schema Model

Universal Directory / Concepts

UD's schema is compositional. There is no class inheritance anywhere in the model, in the current model. The schema is built from three layers, each referencing the one below by GUID, with flat set-union as the only combining operation.

The three layers #

Attributes are defined globally. One definition per attribute; surname, member, expiry; carrying:

  • Its syntax: string, integer, boolean, timestamp, reference, endpoint, or publicKey;
  • Whether it is single- or multi-valued;
  • Its matching rule, caseless or exact, governing comparisons between values;
  • The meta-attributes its values can carry (legalMeta, below);
  • An aliases slot recording alternative wire names.

Facets reference attributes; they never define them. So two facets that both want description agree by construction, because there is only one description.

A facet is a named set of attribute references; the smallest unit of composition. securityPrincipal carries sid; person carries givenName, surname, email; membership carries member. Each reference in a facet can be flagged required, shown in the console as *. Facets cannot include other facets: composition is flat, so it is order-free and collision-free.

A class is a named set of facet references plus nominal properties. user is described + person + securityPrincipal, plus a dnPrefix of CN supplying its DN component type.

Classes carry zero attributes directly; a class needing unique attributes gets its own facet. A class is nominal: an object is a user, queryably and permanently, since class is immutable at birth, but its attribute surface comes entirely from facets.

An object's surface #

Which attributes an object can hold; its surface; is the union of three facet sets:

  1. Its class's facets;
  2. Facets grafted onto its class by class extensions, covered in modifying the schema;
  3. Its own attached facets; facets added to this one instance.

Setting an attribute outside the surface is refused. The console renders the entire surface, set and unset attributes alike, grouped by the facet that provides them, so the surface is always visible rather than discovered by trial and error.

Attached facets are ordinary data: the engine-level attachedFacets attribute holds facet references on the object itself. Attaching a facet immediately widens the surface. Detaching is refused while any attribute only that facet provides still holds values; clear the values first, explicitly. Nothing is ever silently destroyed.

Values and per-value metadata #

Attributes are natively multi-valued: an attribute holds an ordered set of values, unique under the attribute's matching rule.

Each value can carry metadata: a generic map of meta-attribute name to values, with nothing hardcoded. Which meta keys are legal on which attribute is itself schema data; an attribute's legalMeta lists other attribute definitions, so meta values are typed and validated by the same machinery as everything else.

Two invariants hold:

Meta never forks identity. The value itself is the set key. member cannot contain the same GUID twice with different metadata; changing a value's meta is an update to that value, not a new value.

Meta is validated, not yet interpreted. The canonical example; a group membership with an expiry; is supported and validated: member permits the expiry meta key, a timestamp. Engine semantics for expiry, filtering expired values at read, are not yet active.

Self-hosting #

The schema is not a config file. It is objects in the directory, flat under /Configuration/Schema, one per attribute, facet, and class, browsable and inspectable through the same console and API as everything else. CN=surname,OU=Schema,OU=Configuration is a real DN.

The recursion grounds out cleanly: attributeDefinition, facetDefinition, and classDefinition are themselves classes, composed of facets like attributeSchema; and classDefinition is an instance of itself. The engine works from a cache compiled off these objects, but the objects are the truth.

The complete contents of the base schema; 26 attributes, 11 facets, 11 classes; are tabulated in the base schema reference.

Modifying the Schema

Universal Directory / Concepts

UD's schema can be extended at runtime. Namespaces separate application definitions from the base schema. Creation validates the complete definition; deletion checks whether other objects still depend on it.

Namespaces #

All new definitions live in a namespace: a schemaNamespace OU created directly under /Configuration/Schema.

The flat set of unprefixed base definitions is reserved forever. Even the local organization extends the schema through its own namespace; /Configuration/Schema/Homelab/, /Configuration/Schema/Acme/. Namespaces hold definitions only; they cannot nest.

Namespace names can be dotted, and reverse-DNS (com.acme.tools) is the convention for anything redistributable, which makes vendor collisions structurally unlikely rather than merely hoped against. Short names remain fine for org-internal extensions. gip and ud are permanently reserved, being GIP's service namespaces.

A namespaced definition's wire name is Namespace-name. A facet badging in the Acme namespace is addressed everywhere; API, console, attribute lookups; as Acme-badging. The hyphen is structural: it is the namespace separator, which is exactly why native definition names cannot contain one. See naming rules. Collisions between namespaces are therefore structurally impossible, not conventionally unlikely.

Create complete definitions #

A definition is created complete, in one atomic call; object and attributes together. The API's create accepts an attributes map; the console's create modal generates a field per attribute of the chosen class. The engine fills in lifecycle: active and system: false itself.

Every schema write then passes a trial recompile of the whole schema. An attribute definition missing its syntax, an extension whose target is not a class, a dangling facet reference; any incoherence rejects the write atomically, with the compiler's message, as if it never happened.

Once created, a definition is immutable and immovable: no attribute edits, no renames, no moves. Add and delete are the only verbs. To fix a definition, delete it and recreate it.

The recreated definition is a new definition with a new GUID, so anything that referenced the old one dangles visibly rather than silently rebinding. This is the no-resurrection guarantee: a deleted definition's name can be reused, but its identity can never be impersonated.

The unused-delete rule #

A definition can be deleted only when provably unused.

KindBlocked while…
attributeany object holds values for it, any value uses it as a meta key, any attribute lists it in legalMeta, or any facet references it
facetany class composes it, any extension grafts it, or any object has it attached
classany instance exists; including restorable soft-deleted ones; shredded skeletons do not count; or any extension targets it
class extensionany instance of the target class holds values in attributes the extension exclusively provides

Refusals enumerate their blockers by name: attribute still has values on: /Sales/Jack, facet is used by class Acme-badgeHolder. Teardown is a matter of reading the error.

Two shapes of teardown work:

  • Dependency order; clear values, remove the extension, then the facet, then the attribute, then the namespace.
  • Wholesale; deleting a namespace takes its entire contents down in one atomic subtree delete, and usage between the dying definitions themselves does not count. Only usage from outside the namespace blocks.

Definition deletion is the same soft delete as everywhere else. A deleted definition sits restorably in the morgue; restoring it recompiles the schema and revives its wire name, refused if the name has been retaken; then hardens to a skeleton when the restore window closes. Values stored under a definition die at its shred: data whose meaning can never return is not kept.

Class extensions #

A class extension grafts facets onto a class its author does not own. It is the mechanism for "an app needs a tracking number on every user" without touching the user class.

An extension is a definition of class classExtension, living in the extender's namespace, declaring a targetClass and the facets to add. From the moment it exists, every instance of the target class carries those facets in its surface. Delete the extension and the surface shrinks back; refused, per the table above, while instances still hold values only the extension permits.

The target class object is never modified. The extension is entirely the extender's property, living in their namespace, removable with their namespace.

Add badge colors to users #

Use the JSON API to create an attribute, attach it to a facet, and extend the user class with that facet. These requests were checked against version 0.1.0. Each create returns an object whose id supplies the next request's GUID placeholder.

Before you start, resolve /Configuration/Schema and an existing user's path through GET /api/path/<path>. Resolve /Configuration/Schema/user for the base class GUID. The console's create dialog can also perform these steps.

  1. Create the namespace under the schema OU:

    POST /api/objects/<schema-ou-guid>/children
    { "name": "Acme", "class": "schemaNamespace" }
    
  2. Create the complete attribute definition under the namespace:

    POST /api/objects/<acme-guid>/children
    { "name": "badgeColor", "class": "attributeDefinition", "attributes": {
        "syntax":       [{ "value": "string" }],
        "singleValued": [{ "value": "true" }],
        "matching":     [{ "value": "caseless" }]
    } }
    
  3. Create a facet referencing that attribute's GUID:

    POST /api/objects/<acme-guid>/children
    { "name": "badging", "class": "facetDefinition", "attributes": {
        "attributes": [{ "value": "<badge-color-guid>" }]
    } }
    
  4. Extend the base user class with the facet:

    POST /api/objects/<acme-guid>/children
    { "name": "userBadging", "class": "classExtension", "attributes": {
        "targetClass": [{ "value": "<user-class-guid>" }],
        "facets":      [{ "value": "<badging-guid>" }]
    } }
    

    User objects now include Acme-badging in their effective facet surface.

  5. Set a user's badge color:

    PUT /api/objects/<user-guid>/attributes/Acme-badgeColor
    { "values": [{ "value": "red" }] }
    

The stored attribute uses the namespaced wire name Acme-badgeColor. Reference values in these requests are GUIDs; the console also accepts paths and resolves them before submitting a request.

Replication

Universal Directory / Concepts

UD's replication engine lets each node accept writes and merge updates from other nodes. Nodes with the same updates derive the same directory view, regardless of the order in which those updates arrive.

In version 0.1.0, this protocol runs between nodes in the test harness. The daemon does not exchange directory updates over GIP. GIP links and the ud/msgs service are separate from directory replication. The console shows local replication metadata, but it does not connect daemons into a replicated domain.

Node identities and update coordinates #

A node has a permanent node ID and an invocation ID identifying one incarnation of its database. Each update receives a local update sequence number (USN). The pair (invocationId, usn) identifies that update's position in the originating stream.

Changing the invocation ID prevents a recovered database from presenting new updates as positions in an older stream. The local counter continues; the new invocation supplies a distinct coordinate space.

Merging updates #

Replication transfers merge atoms: existence, placement, individual attribute values, and the shred latch. Each ordinary atom carries a stamp, ordered by version, timestamp, then origin. The atom with the greater stamp wins.

An identical value and stamp produce no write. An identical value with a stronger stamp updates the stamp, so later comparisons agree across nodes. Replicated writes bypass local schema validation: a definition needed by an incoming object might arrive later. The derived view handles those incomplete states.

An incoming record with the same GUID but a different class or system flag is rejected. The journal records the mismatch and the sync cursor stops at that record. The engine does not choose between inconsistent identities.

Pulling updates #

A node pulls updates above a partner-specific high watermark, expressed in that partner's USN space. It also sends an up-to-dateness vector recording which coordinates it holds from each originating invocation. The sender uses that vector to omit updates already received through other partners.

Responses arrive in chunks. Even an empty chunk can advance the watermark. Vector coverage advances only when a stream completes; a partial transfer must not claim that missing updates were received.

Initial synchronization starts with a zero watermark and an empty vector. The node discovers the root from incoming records. Incomplete schema components remain quarantined, and objects whose classes have not arrived remain ghosts. Those objects reject local writes until their definitions arrive. A pull between nodes with different root GUIDs is rejected because the nodes belong to different domains.

Deriving a consistent view #

Independently valid writes can conflict after merging. UD resolves these conflicts in the derived view without generating repair writes:

  • Colliding sibling names retain the earliest claim; later claims receive a conflict name (CNF).
  • Objects with missing parents and objects involved in move cycles appear under /LostAndFound.
  • Incomplete schema definitions remain quarantined.

The same stored atoms produce the same repairs on each node. A repair ceases to apply when an ordinary update removes the conflict.

Replicating deletion #

The deletion lifecycle uses stamped existence transitions for soft deletion and restoration. Shredding additionally sets an irreversible latch, so a concurrent edit or restore cannot recover shredded data through replication.

Restore and purge deadlines derive from timestamps and replicated configuration. A partner whose watermark is older than retained deletion knowledge receives a full-resynchronization requirement. Incremental sync cannot safely omit deletions that have already been purged.

Detecting rollback #

A restored node can retain an old invocation ID while losing some updates from that invocation. A partner's vector or watermark can expose this: it claims coordinates from the restored node's stream beyond the node's own counter. Both pull requests and responses carry evidence used by this check.

On detecting rollback, the engine changes invocation ID, assigns its holdings to the new stream, suspends originating writes, and records an alarm. With persistence, it publishes a salvage snapshot. A completed healing pull clears the suspension.

Detection does not increase claimed coverage of the old invocation. The local counter might already have advanced after restoration, so it cannot prove which old updates remain. The healing pull supplies that evidence.

Zero-record probes check partners before the node applies or originates updates. This preserves the opportunity to detect rollback before new local USNs obscure the difference between the restored counter and partner evidence.

Observing and testing replication #

The console exposes local identity, counters, vectors, and journal entries. The in-process scenario and simulation tests exercise synchronization, partitions, clock skew, power loss, and restored storage. They check convergence using the persistence implementation. These tests do not qualify network replication, which the daemon does not implement.

Persistence

Universal Directory / Concepts

Universal Directory keeps its working state in memory. Snapshots and write-ahead logs preserve that state across restarts. Reads use the live store; recovery reconstructs it from the durable files.

Generations and recovery #

Each generation has a snapshot, a write-ahead log, or both. A snapshot records complete state; log frames record changed state rather than re-running original requests. Headers identify the format, node, and generation. Checksums detect incomplete or damaged records.

Recovery reads a valid snapshot and the later log chain, then reconstructs derived indexes and schema. It can truncate an incomplete tail in the active log. Damage in a sealed generation, or valid records after damaged bytes, causes refusal rather than speculative recovery.

Acknowledgment and durability #

A persistent mutating API request waits for its log data to be synchronized before returning success. Concurrent callers can share a flush. A failed synchronization stops the daemon rather than acknowledging state it cannot promise to recover.

Local reads can see an in-memory change before its flush completes. Replication's advertised progress is separately durability-gated. These are different provides: a readable value is not itself evidence that a crash will preserve it. In ephemeral mode there is no durable disk storage.

Compaction and erasure #

Rotation seals the active log and opens its successor. A background rebuild replays sealed files into a replacement snapshot. The snapshot is published and synchronized before superseded generations are removed. Rollback salvage has a separate path because its corrected state initially exists only in memory.

Destructive changes record an erasure debt until compaction removes the older files that contain their payloads. The current two-minute target is reported through the storage view. It is not a guarantee against stalled I/O or failed compaction; inspect outstanding debt and rebuild failures. Deletion concerns directory files, not physical remnants in freed storage, external backups, or filesystem snapshots.

Operating boundary #

The daemon takes an exclusive, nonblocking directory lock before accessing storage. Another daemon opening that directory fails immediately. The lock remains held while storage writers exist and is released when they close; process termination also releases it. This is an advisory lock, so it does not protect against programs that bypass the locking protocol. Do not remove or replace a running daemon's data directory.

Preserve all generations and the machine key when backing up or moving a stopped development instance. The repository's fault-injection tests cover interrupted writes, flush failures, crash recovery, and restored snapshots; they do not qualify every filesystem, device, or backup procedure.

Peios Learn — documentation for Peios software.

Built with Trail.