WeaveDocs
Locus

Metadata and Permissions

Metadata and permissions in Locus — typed metadata, permission modes, and capability bindings on every entry.

Purpose

File and directory model with metadata, mounts, streams, watchers, journals, permission modes, and governance.

This page follows the real source shape for Locus and explains the workflow a developer is likely to use first.

Trust contract

Document which keys authorize the operation, what is signed, what is encrypted, what is deliberately public, and which policy hook can deny the call. Security examples should use deterministic test vectors where possible.

Warning

Locus permissions are enforced locally. A peer with replication access can read the underlying Strand directly and bypass the metadata-permission model. For confidentiality across peers, encrypt at the Strand layer (Strand::with_encryption()), not at the Locus permission layer.

Primary types to know

  • AllowAllLocusPolicy — models/locus/src/policy.rs
  • CreateOptions — models/locus/src/ops.rs
  • FileEntry — models/locus/src/entry.rs
  • FileMetadata — models/locus/src/entry.rs
  • JournalRecord — models/locus/src/journal.rs
  • JournalStore — models/locus/src/journal.rs
  • Locus — models/locus/src/locus.rs
  • LocusConfig — models/locus/src/config.rs
  • MountOptions — models/locus/src/config.rs
  • MountPoint — models/locus/src/mount.rs
  • MountTable — models/locus/src/mount.rs
  • OpenOptions — models/locus/src/ops.rs

Example shape

use locus::{EntryType, FileMetadata, PermissionMode};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // FileMetadata models a file, directory, or symlink. Each constructor seeds
    // creation/modified/accessed timestamps and a version starting at 1.
    let dir_meta = FileMetadata::new_directory(0o755);
    let file_meta = FileMetadata::new_file(1024, 0o640, [0u8; 32]);
    let link_meta = FileMetadata::new_symlink("/etc/hosts".to_string(), 0o777);

    assert_eq!(dir_meta.entry_type, EntryType::Directory);
    assert!(file_meta.is_file());
    assert!(link_meta.is_symlink());

    // PermissionMode masks the raw u32 to the 9 POSIX rwxrwxrwx bits and offers
    // typed predicates so callers don't bit-twiddle constants at the call site.
    let mode = PermissionMode::new(file_meta.mode);
    assert!(mode.owner_can_read());
    assert!(mode.owner_can_write());
    assert!(!mode.other_can_write());

    println!(
        "dir mode={:o} file size={} blob_id_set={} link target={:?}",
        dir_meta.mode,
        file_meta.size,
        file_meta.blob_id.is_some(),
        link_meta.symlink_target,
    );
    Ok(())
}