# Capabilities

> Grants a page scoped access to the filesystem.

Per-origin, per-operation filesystem capabilities for renderer code.

Every `fs.*` call is subject to three independent checks:

1. Command: The command ACL permits the `fs.*` capability surface but
   neither grants nor revokes filesystem access.
2. Operation: Each command performs one operation and requires the
   corresponding [`FsAccess`] bit in the origin's grants.
3. Resource: The path must lie beneath an allow root carrying that bit
   and outside every deny rule held by the origin. The opened object's real
   location is checked again before use.

Nothing is reachable without a grant. Links are never traversed.
Denials never disclose request contents.

The public surface is [`Filesystem`], which defines scopes and grants and
is passed to [`App::filesystem`](https://kurogane-rs.org/docs/api/app/app.md#method.filesystem) to install the
`fs.*` commands. [`Filesystem::authorize`] produces the exact authority
granted to an origin for tests and headless checks.

Modules:
- `policy`: capability bits and the `fs.*` command set.
- `fold`: how each platform's filesystems compare names and the inverse
  glob classes match through.
- `path`: validated names, request parsing and comparison keys.
- `scope`: allow roots and deny rules.
- `safe`: platform-specific kernel-confined opening.
- `authorized`: filesystem configuration and per-origin authority.
- `commands`: IPC handlers.
- `audit`: cross-layer invariants (tests only).

[crate::App::filesystem]: https://kurogane-rs.org/docs/api/app/app.md#method.filesystem
[`Filesystem::authorize`]: https://kurogane-rs.org/docs/api/capabilities/filesystem.md#method.authorize
[`Filesystem`]: https://kurogane-rs.org/docs/api/capabilities/filesystem.md
[`FsAccess`]: https://kurogane-rs.org/docs/api/capabilities/fsaccess.md

- [`AuthorizedFs`](https://kurogane-rs.org/docs/api/capabilities/authorizedfs.md) (struct): The authority of one origin. Every operation runs the decision rules in the module documentation; nothing else reaches the filesystem for a renderer.
- [`DirEntry`](https://kurogane-rs.org/docs/api/capabilities/direntry.md) (struct): One entry of a listed directory. Links and reparse points are never listed.
- [`Filesystem`](https://kurogane-rs.org/docs/api/capabilities/filesystem.md) (struct): Filesystem capability configuration of named scopes and the grants that bind origins to them.
- [`FilesystemBuilder`](https://kurogane-rs.org/docs/api/capabilities/filesystembuilder.md) (struct): Builder for `Filesystem`.
- [`FsAccess`](https://kurogane-rs.org/docs/api/capabilities/fsaccess.md) (struct): A set of operational filesystem capabilities.
- [`ScopeBuilder`](https://kurogane-rs.org/docs/api/capabilities/scopebuilder.md) (struct): Declares one scope inside [`FilesystemBuilder::scope`](https://kurogane-rs.org/docs/api/capabilities/filesystembuilder.md#method.scope).
- [`ScopeId`](https://kurogane-rs.org/docs/api/capabilities/scopeid.md) (struct): Handle to a scope declared on a `FilesystemBuilder`. Grants name scopes by handle. A grant cannot reference a scope that was never declared.
- [`Denial`](https://kurogane-rs.org/docs/api/capabilities/denial.md) (enum): Why an in-grant request was refused. Each variant renders one fixed, class-level message.
- [`EntryKind`](https://kurogane-rs.org/docs/api/capabilities/entrykind.md) (enum): The kind of a directory entry.
- [`FsConfigError`](https://kurogane-rs.org/docs/api/capabilities/fsconfigerror.md) (enum): A `Filesystem` configuration that cannot be built. These are developer-facing and may name paths; they never reach a renderer.
- [`FsError`](https://kurogane-rs.org/docs/api/capabilities/fserror.md) (enum): Failure of one filesystem operation performed for an origin.
