1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
//! Core LoonFS namespace operations.
//!
//! `loonfs-core` is the low-level API for building directly on the LoonFS
//! metadata protocol. Most callers should start with [`NamespaceEngine`].
//!
//! A namespace is one durable filesystem history. File bytes are written to
//! object storage first, then metadata is published as a committed namespace
//! mutation. Reads rebuild or reuse a verified view of the namespace before
//! walking paths.
//!
//! # Example
//!
//! Commits are published as candidate batches through
//! [`publish::NamespaceCommitEngine`]; day-to-day reads and writes should go
//! through the `loonfs` crate's `FsReader`/`FsWriter` handles, which wrap
//! this crate with caching and batching.
//!
//! ```no_run
//! use loonfs_api::{AbsolutePath, CommitId, NamespaceId};
//! use loonfs_core::publish::{
//! FilesystemOperation, CommitRequest, NamespaceCommitEngine, CommitCandidate,
//! PublishTailOptions,
//! };
//! use loonfs_core::{BootstrapOptions, MutationContext, NamespaceEngine};
//! use loonfs_objectstore::local_fs_store::LocalFsStore;
//!
//! let store = LocalFsStore::new(std::env::temp_dir()).expect("store");
//! let namespace = NamespaceId::parse("docs").expect("valid namespace id");
//!
//! let engine = NamespaceEngine::builder(store)
//! .namespace_id(namespace.clone())
//! .writer_id("example-writer")
//! .build()
//! .expect("engine");
//! let _ = engine.bootstrap_namespace(BootstrapOptions::default());
//!
//! let publish_store = LocalFsStore::new(std::env::temp_dir()).expect("store");
//! let context = MutationContext {
//! writer_id: "example-writer".to_owned(),
//! now_ms: 0,
//! };
//! let mut publisher = NamespaceCommitEngine::new(namespace);
//! let _ = publisher.publish_batch(
//! &publish_store,
//! vec![CommitCandidate::new(CommitRequest::single(
//! CommitId::generate(),
//! None,
//! FilesystemOperation::CreateDirectory {
//! path: AbsolutePath::parse("/plans").expect("path"),
//! parents: false,
//! },
//! ))],
//! &context,
//! &PublishTailOptions::default(),
//! );
//! ```
// Sanctioned consumers of this crate's public surface, in full:
//
// - **`loonfs`** — the embedded runtime, the only production consumer. It
// wraps everything below with caching, batching, and handles, and re-exports
// what applications need. Application code depends on `loonfs`, never on
// this crate.
// - **`loonfs-core`'s own integration tests** (`tests/it`) — a white-box
// consumer that asserts on durable layout and replay directly. It is why
// `metadata` and parts of `commit` are public at all.
//
// Nothing else depends on this crate. `loonfs-grep` was extracted and reads
// filesystem state through `loonfs`; `loonfs-sim`, `loonfs-model`, and
// `loonfs-test-support` never depended on it; `loonfs-server` and `loonfs-cli`
// reach the durable control plane through `loonfs::control`.
//
// The module list below is grouped by that intent: private modules are engine
// internals, and each public one names why it is public.
// --- engine internals: private, reachable only through the seams below ---
// --- public seams ---
/// Commit planning, validation, and materialization. Consumed by the `loonfs`
/// publisher and by this crate's commit-validation integration tests.
/// Content staging and preparation-token minting. Consumed by `loonfs`'s
/// write path and its server-integration `content_tokens` seam.
/// Protocol and resource ceilings. Consumed by `loonfs` (re-exported to the
/// server for request validation) and by layout tests.
/// Durable metadata state and its row codecs. Public for this crate's
/// white-box integration tests, which compare projected state against the
/// reference model; `loonfs` reaches metadata only through the seams above.
/// Path parsing and current-state resolution. Consumed by `loonfs`'s write
/// path (`parse_mutation_path`).
/// The wall-clock boundary durable timestamps are stamped at. Consumed by
/// `loonfs`, whose mutation contexts and maintenance clock stamp from the
/// same boundary this crate's own commits do.
/// Cache types and configuration for runtime read paths. Consumed by
/// `loonfs`, which owns the runtime's cache configuration and stats, and
/// which re-exports [`cache::Recency`] for the grep index's own block cache.
/// Typed namespace control-object loaders and verified catalog state.
/// Consumed by `loonfs`'s cache and write paths, and re-exported as
/// `loonfs::control` for the white-box layout assertions the server and this
/// crate's own tests make.
/// Commit publication types for runtime integrations. Consumed by `loonfs`'s
/// publisher, and re-exported as `loonfs::publish` for the server's
/// filesystem handlers.
// Crate-root re-exports. Every name below has a named consumer: `loonfs`
// unless the comment says otherwise, or reachability through a public
// signature where noted.
// `MetadataReorganizeReport` has no caller that names it; it stays public
// because it is the return type of `NamespaceEngine::reorganize_metadata`.
pub use ;
pub use MutationContext;
pub use RuntimeReadContext;
pub use ;
// The builder pair is reachable through `NamespaceEngine::builder()` and its
// `build()`, so both stay public even though no caller names them directly.
pub use ;
pub use ;
pub use ;
pub use BootstrapNamespaceError;
pub use ;
pub use ;
// The streaming read `loonfs`'s reader handle returns, and the chunk size it
// reads in.
pub use ;