# LCS

> Peios kernel lcs documentation.

All of LCS as one markdown file: [/kernel/internals/lcs/print.md](/kernel/internals/lcs/print.md)

## Start here

- [Overview](/kernel/internals/lcs/start-here/overview.md): LCS is the kernel half of the Peios registry — where it sits, its semantic core, what is layered and what is not, and where the model diverges.

## Data model

- [Data model](/kernel/internals/lcs/data-model/overview.md): Find the Peios kernel articles about data model.
- [Hives and Routing](/kernel/internals/lcs/data-model/hives-and-routing.md): A hive is the first component of every path — the routing table that maps hive names to sources, and the two names the kernel knows itself.
- [Private Hives](/kernel/internals/lcs/data-model/private-hives.md): Hives invisible in the global namespace, reachable only through a scope GUID on the calling token — routing, lifecycle and registration rules.
- [Keys](/kernel/internals/lcs/data-model/keys.md): A key is a container of subkeys and values — its identity, its properties, volatile keys, and the rules for naming one.
- [Symlinks](/kernel/internals/lcs/data-model/symlinks.md): The two load-bearing mechanisms behind a symlink key — the structural flag and the target value — plus resolution, depth and opening the link itself.
- [Path Entries](/kernel/internals/lcs/data-model/path-entries.md): Key existence and naming are layer-qualified while key identity is not — the per-layer path entry that separates them, and hiding.
- [Values](/kernel/internals/lcs/data-model/values.md): A named, typed datum inside a key — one name with many layer entries, the type set, REG_TOMBSTONE, naming and size.
- [Tombstones](/kernel/internals/lcs/data-model/tombstones.md): An overlay that can only add is not enough — value and blanket tombstones, how they compete, and what a watcher sees.
- [Names and Case](/kernel/internals/lcs/data-model/names-and-case.md): Every string in the LCS interface is UTF-8 — length as byte count, separators, and how case folding works.
- [Deletion and Orphans](/kernel/internals/lcs/data-model/deletion-and-orphans.md): Deletion works on two levels because naming and identity are separate — layer deletion, orphaned keys, and what happens to their watches.

## Layers

- [Layers](/kernel/internals/lcs/layers/overview.md): Find the Peios kernel articles about layers.
- [The Layer Model](/kernel/internals/lcs/layers/the-layer-model.md): A named collection of registry writes managed as a unit — precedence tiers, caps, and why layers are global while entries are per-source.
- [The Base Layer](/kernel/internals/lcs/layers/the-base-layer.md): The kernel-reserved layer that exists unconditionally before any source registers — its persisted metadata and the two ways it is matched.
- [Layer Metadata](/kernel/internals/lcs/layers/layer-metadata.md): Layer metadata lives in the registry it configures — the circularity that creates, why publication is atomic, and when the refresh runs.
- [Writing Into a Layer](/kernel/internals/lcs/layers/writing-into-a-layer.md): Every mutation targeting a layer requires layer write access — the base layer before it exists, the precedence gate, and deleting a layer.
- [Private Layers](/kernel/internals/lcs/layers/private-layers.md): A disabled layer attached to a thread's credentials — how it resolves, how it is attached, and the authority retained from its creator.
- [Resolution](/kernel/internals/lcs/layers/resolution.md): Turning several per-layer entries into one effective answer — the rule, why unknown layers are latent rather than wrong, and enumeration.
- [The Sequence Counter](/kernel/internals/lcs/layers/the-sequence-counter.md): The single global monotonic counter stamped on every layer-qualified entry — allocation, initialisation, and what it is not.

## Security

- [Security](/kernel/internals/lcs/security/overview.md): Find the Peios kernel articles about security.
- [The Access Flow](/kernel/internals/lcs/security/the-access-flow.md): The registry's security model is KACS applied to keys — no traverse checking, symlink handling, and why an fd is a capability.
- [Access Rights](/kernel/internals/lcs/security/access-rights.md): Registry rights at their Windows bit positions — the convenience masks, generic mapping, and validation of what a caller asks and a source returns.
- [Inheritance and Hive Roots](/kernel/internals/lcs/security/inheritance-and-hive-roots.md): A new key's descriptor is computed from its parent by the KACS inheritance algorithm — plus hive roots and reading or writing a descriptor.
- [Audit](/kernel/internals/lcs/security/audit.md): The fifteen audit events LCS emits, which are unconditional, how registry writes are audited through a key handle's alarm mask, and what happens when emission itself fails.

## Watches

- [Watches](/kernel/internals/lcs/watches/overview.md): Find the Peios kernel articles about watches.
- [The Watch Model](/kernel/internals/lcs/watches/the-watch-model.md): A persistent subscription to changes on an open key, following inotify rather than the Windows model — what it observes, its event types and filters.
- [Event Records](/kernel/internals/lcs/watches/event-records.md): Events read from the key fd with read() — the record layout, why not every subtree record carries a path, and forward compatibility.
- [Dispatch](/kernel/internals/lcs/watches/dispatch.md): Given a mutation, which armed watches hear about it — computed from object identity and ancestry, with depth, batching and recovery.
- [Queues and Overflow](/kernel/internals/lcs/watches/queues-and-overflow.md): Each armed fd has its own bounded queue and delivery is best-effort — what a full queue does, and what a watcher does about it.

## Transactions

- [Transactions](/kernel/internals/lcs/transactions/overview.md): Find the Peios kernel articles about transactions.
- [Scope and Lifetime](/kernel/internals/lcs/transactions/scope-and-lifetime.md): Grouping registry operations so they commit together or not at all — binding, states, timeout, and sources that do not support them.
- [Isolation and the Mutation Log](/kernel/internals/lcs/transactions/isolation-and-the-mutation-log.md): Read-your-own-writes inside a transaction, implemented by the source rather than LCS — the mutation log, sequence numbers and conflicts.
- [Commit and Failure](/kernel/internals/lcs/transactions/commit-and-failure.md): What a commit triggers in order, the failures that leave a transaction open, and what happens when the watch events cannot be delivered.

## Sources

- [Sources](/kernel/internals/lcs/sources/overview.md): Find the Peios kernel articles about sources.
- [The Source Model](/kernel/internals/lcs/sources/the-source-model.md): A source is a userspace process holding registry data and answering LCS over RSI — the trust boundary, and why loregd is not special.
- [Registration and Slots](/kernel/internals/lcs/sources/registration-and-slots.md): Reaching LCS through /dev/pkm_registry — what registration validates, how source slots work, and resuming one that went Down.
- [Request Dispatch](/kernel/internals/lcs/sources/request-dispatch.md): The RSI is multiplexed — request ids and matching, the single deadline covering three waits, and requests with no caller.
- [Validation](/kernel/internals/lcs/sources/validation.md): LCS validates every response before using it — malformed data against malformed protocol, and the asymmetric extensibility between them.
- [Failure and Late Responses](/kernel/internals/lcs/sources/failure-and-late-responses.md): What happens when a source dies, and the late-response problem — a late error, a late successful read, and a late successful write.

## Backup and restore

- [Backup and restore](/kernel/internals/lcs/backup-and-restore/overview.md): Find the Peios kernel articles about backup and restore.
- [The Stream](/kernel/internals/lcs/backup-and-restore/the-stream.md): The streamable binary representation of a key and everything beneath it with full layer fidelity — what the design buys, and how it is versioned.
- [Backup](/kernel/internals/lcs/backup-and-restore/backup.md): Writing a subtree to a stream under SeBackupPrivilege with no per-key access check — the snapshot, the audit, and what is written.
- [Restore](/kernel/internals/lcs/backup-and-restore/restore.md): Restore is a replace rather than a merge — one transaction, the surviving target key, the order of operations, and the precedence gate.

## Bootstrap

- [Bootstrap](/kernel/internals/lcs/bootstrap/overview.md): Find the Peios kernel articles about bootstrap.
- [Dependencies and boot sequence](/kernel/internals/lcs/bootstrap/dependencies-and-boot-sequence.md): The registry has to configure itself — the three circular dependencies, and the three rules that break them.
- [Operational Parameters](/kernel/internals/lcs/bootstrap/operational-parameters.md): The nineteen parameters LCS reads from the registry, how they are validated, and what hot-swapping one does to in-flight operations.
- [The Self-Watch](/kernel/internals/lcs/bootstrap/the-self-watch.md): LCS watches its own configuration through the same machinery userspace uses — what it drives, how it is armed, and why the callback is not the atomicity boundary.
