Elffuss BraidHub

utopia-ia/elffuss-braid public

38b3e04f7d4a · 3.0 KiBRawPermalink
1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2026 UtopiaIA
3
4//! Workspaces of elffuss-braid: working copies that many agents use at once
5//! on one repository, each landing on a branch without waiting for the
6//! others.
7//!
8//! # Layout
9//!
10//! A workspace is any directory holding a `.braid` file. The file is local
11//! and never tracked; it names the repository and the workspace (see
12//! [`braid_repo::WorkspaceLink`]). The workspace's state lives in the
13//! repository, in `.braid/ws/<name>/`:
14//!
15//! ```text
16//! state the base changeset, the branch, the directory, the file system's
17//! name rules, marks made by `braid track`, a rebase in progress
18//! stat the stat cache
19//! lock locked while a command changes the workspace
20//! ```
21//!
22//! # Operations
23//!
24//! - [`Workspace::create`] writes a tree into a new directory.
25//! - [`Workspace::status`] compares the working copy with the base, using
26//! the stat cache so that unchanged files are not read again.
27//! - [`Workspace::commit`] records the working copy as a changeset on the
28//! base. There is no staging area.
29//! - [`Workspace::land`] puts the workspace's changesets on its branch in
30//! one short op log transaction, fast-forwarding or rebasing them with the
31//! engine; conflicts come back as data and the branch does not move.
32//! - [`Workspace::update`] brings the workspace onto the branch's head,
33//! rebasing its own changesets; conflicts are written with markers.
34//! - [`create_change`] and [`land_change`] make and land a changeset
35//! without any working copy.
36//!
37//! # Safety of checkouts
38//!
39//! Every write into a working copy goes through directory handles that
40//! never follow a symlink (see the `safe` module), through a scratch file
41//! and a rename, with modes 0644 or 0755 only. Names this platform cannot
42//! hold, and names that would collide on the workspace's file system, are
43//! refused before anything is written. Nothing found in the repository is
44//! ever run: there are no hooks, filters or attributes.
45//!
46//! New files that look like secrets (`.env*`, `*.pem`, `id_*`) or are
47//! larger than 1 MiB are not committed until [`Workspace::track`] marks
48//! them: [`Workspace::commit`] refuses while they wait, listing them with
49//! the other reasons it has (see [`Blocker`]), unless it is forced, and then
50//! leaves them out.
51
52#![forbid(unsafe_code)]
53
54mod blocker;
55mod cache;
56mod change;
57mod checkout;
58mod error;
59mod fsprobe;
60mod identity;
61mod ignores;
62mod markers;
63mod paths;
64mod rebase;
65mod safe;
66mod scan;
67mod state;
68mod status;
69mod tree;
70mod workspace;
71
72pub use blocker::Blocker;
73pub use change::{ChangeRequest, Expect, create_change, land_change};
74pub use error::Error;
75pub use fsprobe::FileSystem;
76pub use identity::Identity;
77pub use paths::workspace_path;
78pub use state::{Checkout, Rebase, RecordedConflict, State};
79pub use status::{ChangeKind, GUARD_SIZE, PathChange, Status, is_guarded};
80pub use workspace::{
81 BEHIND_LIMIT, CommitOutcome, CommitRequest, LandReport, Landed, Placed, RebaseProgress,
82 StatusReport, UpdateReport, Updated, Workspace,
83};