Elffuss BraidHub

utopia-ia/elffuss-braid public

bceec3f3d91e · 3.2 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, and
27//! directories that did not change are neither listed nor compared with
28//! their trees again.
29//! - [`Workspace::commit`] records the working copy as a changeset on the
30//! base. There is no staging area; given paths, it reads only what lies at
31//! or below them.
32//! - [`Workspace::land`] puts the workspace's changesets on its branch in
33//! one short op log transaction, fast-forwarding or rebasing them with the
34//! engine; conflicts come back as data and the branch does not move.
35//! - [`Workspace::update`] brings the workspace onto the branch's head,
36//! rebasing its own changesets; conflicts are written with markers.
37//! - [`create_change`] and [`land_change`] make and land a changeset
38//! without any working copy.
39//!
40//! # Safety of checkouts
41//!
42//! Every write into a working copy goes through directory handles that
43//! never follow a symlink (see the `safe` module), through a scratch file
44//! and a rename, with modes 0644 or 0755 only. Names this platform cannot
45//! hold, and names that would collide on the workspace's file system, are
46//! refused before anything is written. Nothing found in the repository is
47//! ever run: there are no hooks, filters or attributes.
48//!
49//! New files that look like secrets (`.env*`, `*.pem`, `id_*`) or are
50//! larger than 1 MiB are not committed until [`Workspace::track`] marks
51//! them: [`Workspace::commit`] refuses while they wait, listing them with
52//! the other reasons it has (see [`Blocker`]), unless it is forced, and then
53//! leaves them out.
54
55#![forbid(unsafe_code)]
56
57mod blocker;
58mod cache;
59mod change;
60mod checkout;
61mod error;
62mod fsprobe;
63mod identity;
64mod ignores;
65mod markers;
66mod paths;
67mod rebase;
68mod safe;
69mod scan;
70mod state;
71mod status;
72mod tree;
73mod workspace;
74
75pub use blocker::Blocker;
76pub use change::{ChangeRequest, Expect, create_change, land_change};
77pub use error::Error;
78pub use fsprobe::FileSystem;
79pub use identity::Identity;
80pub use paths::workspace_path;
81pub use state::{Checkout, Rebase, RecordedConflict, State};
82pub use status::{ChangeKind, GUARD_SIZE, PathChange, Status, is_guarded};
83pub use workspace::{
84 BEHIND_LIMIT, CommitOutcome, CommitRequest, LandReport, Landed, Placed, RebaseProgress,
85 StatusReport, UpdateReport, Updated, Workspace,
86};