Skip to content

Commit 0add372

Browse files
authored
docs: add developer READMEs to the major directories (#174)
Adds one short orientation README per major directory. Developer-focused: what the directory is, its key modules with real file names, how it relates to its neighbours, and the one or two commands you actually run there. ## What was added | file | covers | |---|---| | `crates/README.md` | index of the 12 workspace members + which way dependencies point | | `crates/driven-core/README.md` | the I/O-free sync engine: scanner, planner, orchestrator, state | | `crates/driven-drive/README.md` | the `RemoteStore` seam, the Google backend, the in-memory fake | | `crates/driven-crypto/README.md` | content + filename encryption, keystore, recovery phrase | | `crates/driven-net/README.md` | the production probe backend behind `driven-core::network` | | `crates/driven-tls/README.md` | shared custom-CA + proxy support; the locked trust rules | | `crates/driven-power/README.md` | AC / battery / metered / sleep-wake, normalized per OS | | `crates/driven-diskstat/README.md` | disk-saturation reader + the fail-open rule | | `crates/driven-vss/README.md` | Windows shadow-copy reads for locked files | | `crates/driven-vss-helper/README.md` | the least-privilege elevated broker | | `crates/driven-cli/README.md` | the headless auth / sync / inspect CLI | | `crates/driven-chaos/README.md` | the stress harness and its `just` entry points | | `crates/driven-test-fixtures/README.md` | the shared fakes every seam is tested against | | `scripts/README.md` | the release / deploy / coverage helpers and who invokes them | | `site-landing/README.md` | the static landing page and the whole-site-snapshot deploy rule | | `src-tauri/README.md` | the Tauri shell: boot, IPC commands, tray, updater | | `ui/README.md` | the Vue frontend: ipc / stores / views layering and its commands | ## Notes - **`telemetry-worker/` was skipped** - it already has a thorough developer-focused README, and the brief was new files only. - Every claim is derived from the crate's `lib.rs`/`main.rs` module doc, its `Cargo.toml`, the `justfile`, or `ui/package.json`. Where a README would just restate a module doc or a design doc, it gives the short version and points at the source instead. - No existing file is modified, including the root `README.md`. - Side effects checked: no crate sets `readme`/`include`/`exclude`, nothing runs `cargo publish`, `ui/` prettier and eslint only cover `src/`, and no CI path filter is affected except `deploy-landing.yml`, which triggers on `site-landing/**`. That deploy is a harmless republish - `assemble-landing.sh` copies four files by name, so the new README is never published. - `docs:` is changelog-hidden, which is correct for this change.
1 parent 5cb8e3a commit 0add372

17 files changed

Lines changed: 371 additions & 0 deletions

File tree

crates/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# `crates/` - the Rust workspace members
2+
3+
Everything Driven does that is not the Tauri shell. The split follows the
4+
thick-core / thin-shell rule in `design/DESIGN.md` s4.2: `driven-core` owns the
5+
sync engine and stays I/O-free, and every side effect sits in its own crate
6+
behind a trait, so `cargo test --workspace` runs with no real Drive, clock, or GUI.
7+
8+
- `driven-core` - scanner, planner, orchestrator, pacer, executor, SQLite state
9+
- `driven-drive` - the `RemoteStore` trait, the Google Drive backend, the in-memory fake
10+
- `driven-crypto` - content + filename encryption, keystore, BIP39 recovery phrase
11+
- `driven-net` / `driven-tls` - network probes; shared custom-CA + proxy support
12+
- `driven-power` / `driven-diskstat` - per-OS power, metered, sleep-wake, disk-busy signals
13+
- `driven-vss` / `driven-vss-helper` - Windows shadow-copy reads and the elevated broker
14+
- `driven-cli` - headless debugging CLI; `driven-chaos` - the stress harness
15+
- `driven-test-fixtures` - shared dev-dependency fakes (`tree!`, `FakeClock`, ...)
16+
17+
Dependencies point one way: `driven-tls` / `driven-crypto` are leaves, `driven-core`
18+
sits above drive / crypto / power / diskstat / vss, and `src-tauri` on top of all of
19+
them. Nothing here depends on `src-tauri`. Each crate's `src/lib.rs` module doc is
20+
the real reference - `cargo doc --open`.

crates/driven-chaos/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# `driven-chaos`
2+
3+
The stress / chaos harness. It boots the headless core directly (never `src-tauri`)
4+
and hammers it with hostile inputs and injected faults. Design and the scenario
5+
catalogue live in `design/STRESS_HARNESS.md` - this README is orientation only.
6+
7+
- `handle.rs` - `DrivenHandle`, one booted headless instance under test
8+
- `scenario.rs` + `registry.rs` + `dispatch.rs` - the `Scenario` trait, the registry
9+
the runner iterates, and the dispatch
10+
- `capabilities.rs` - the host capability probe; rows the host cannot satisfy
11+
(admin, VSS, real Drive, wrong OS) skip cleanly rather than fail
12+
- `scenarios/` - the catalogue, one module per category: `filenames`, `file_size`,
13+
`permissions`, `ntfs`, `concurrency`, `storage`, `drive_side`, `mutation`
14+
- `mutator.rs` + `runner.rs` + `reporting.rs` - the seeded fuzz mutation loop and the
15+
per-scenario verdict / run report
16+
17+
```sh
18+
just chaos # full hermetic sweep
19+
just chaos-fake-drive # the fault-injection subset CI gates on
20+
just chaos-fuzz # seeded continuous-mutation soak
21+
```

crates/driven-cli/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# `driven-cli`
2+
3+
A small headless debugging CLI: do real Drive work, and inspect the local state
4+
database, without launching the GUI. Not shipped to users.
5+
6+
- `main.rs` - the clap command tree: `auth` (PKCE loopback flow, stores the refresh
7+
token in the OS keychain), `dump-refresh-token` and `dump-client-creds` (for
8+
debugging refresh failures and minting `DRIVEN_E2E_REFRESH_TOKEN`), and `sync`
9+
(one sync cycle of a local folder to a real Drive folder)
10+
- `inspect.rs` - the read-only state-database commands: `status`, `history`, `verify`
11+
(exits non-zero when any file is in a corrupt / error state); no network access
12+
13+
Uses only the public `driven-drive` surface plus clap / tokio / anyhow / tracing - it
14+
has no HTTP or serde dependency of its own, deliberately. OAuth client credentials
15+
come from a gitignored `client_secret.json` at the repo root, `--client-id` /
16+
`--client-secret`, or the public installed-app default. See `design/SPEC.md` s4.
17+
18+
```sh
19+
cargo run --bin driven-cli -- auth --account me
20+
cargo test -p driven-cli
21+
```

crates/driven-core/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# `driven-core`
2+
3+
The I/O-free heart of Driven: the sync state machine and everything that decides
4+
*what* to back up and *when*. All real I/O (filesystem, network, clock, keychain,
5+
power) arrives through injected traits, so the whole crate is exercisable from
6+
`cargo test` with no Tauri shell, no real Drive, and no real wall clock.
7+
8+
- `scanner.rs` + `exclude.rs` - walk the source tree, apply the exclusion rules
9+
- `planner.rs` - diff scan results against state into a plan of operations
10+
- `orchestrator.rs` + `pacer.rs` + `executor.rs` - run that plan, paced by the rules
11+
- `adaptive.rs` - upload-parallelism controller (throughput + disk-busy driven)
12+
- `state/sqlite.rs` + `migrations/` - the SQLite state layer and its schema
13+
- `types.rs` - the shared `OrchestratorState` machine, event, and error types
14+
15+
The traits declared here (`Clock`, `StateRepo`, `NetworkProbe`, `SourceWatcher`,
16+
`CryptoProvider`) are implemented by the sibling crates; `src-tauri` assembles them.
17+
See `design/DESIGN.md` s5 and s11 for the engine design.
18+
19+
```sh
20+
cargo test -p driven-core
21+
just sqlx-prepare # after changing any sqlx::query! macro
22+
```

crates/driven-crypto/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# `driven-crypto`
2+
3+
Driven's authenticated-encryption format: nothing leaves the machine unencrypted,
4+
and this crate owns every byte of that. Specified in `design/DESIGN.md` s7.
5+
6+
- `content.rs` - chunked content encryption (XChaCha20-Poly1305 STREAM) and the
7+
ciphertext MD5 that Drive verifies the upload against
8+
- `filename.rs` - per path-component filename encryption with base32hex encoding,
9+
using the parent component's ciphertext as AEAD AAD
10+
- `key.rs` / `keystore.rs` - master and per-source keys, OS-keychain storage
11+
- `recovery.rs` - BIP39 encoding of the master key (the user's recovery phrase)
12+
13+
The `SourceCryptoSuite` trait in `lib.rs` is the seam `driven-core`'s executor codes
14+
against. It deliberately references no `driven-core` type - every signature is
15+
`&str` / `Bytes` / `[u8; 16]` - so the dependency graph stays one-way. This crate is
16+
a leaf. Read the `lib.rs` module doc before touching the seam; it explains why
17+
content encryption yields a per-file encryptor object rather than a one-shot call.
18+
19+
```sh
20+
cargo test -p driven-crypto
21+
```

crates/driven-diskstat/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# `driven-diskstat`
2+
3+
Answers one question for the adaptive upload-parallelism controller: *is the local
4+
disk saturated right now?* If it is, adding in-flight uploads cannot raise
5+
throughput, so the controller must not grow the pool (`design/DESIGN.md` s11.4.7,
6+
s18.2).
7+
8+
- `lib.rs` - the `DiskBusyProbe` trait, the `DiskBusy` reading, and the pure
9+
classifier (`busy_fraction_from_delta`, `SATURATION_THRESHOLD` = 80 %) that is
10+
unit-tested on every target
11+
- `linux.rs` (`/proc/diskstats`), `macos.rs` (IOKit), `windows.rs` (PDH
12+
`% Disk Time`) - exactly one `RealDiskBusyProbe` compiled per target
13+
14+
Kept a standalone crate rather than folded into `driven-core` so the PDH / IOKit FFI
15+
never reaches a foreign host's `cargo build --workspace`. The fail-open rule is
16+
load-bearing: an unreadable probe returns `Unknown`, which reads as "not saturated",
17+
because a broken reader must never pin uploads small. Tests use `FakeDiskBusyProbe`
18+
from `driven-test-fixtures`.
19+
20+
```sh
21+
cargo test -p driven-diskstat
22+
```

crates/driven-drive/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# `driven-drive`
2+
3+
The `RemoteStore` seam plus its implementations. Everything the sync engine knows
4+
about a backup destination goes through this trait, so `driven-core` never names
5+
Google Drive directly.
6+
7+
- `remote_store.rs` - the trait every backend must satisfy (list, create, upload, delete)
8+
- `google/` - the production Google Drive backend: `oauth.rs` (PKCE loopback flow),
9+
`token_store.rs` (refresh token in the OS keychain), `resumable.rs` (resumable
10+
uploads), `retry.rs`, `pagination.rs`
11+
- `fake/` - `InMemoryRemoteStore`, the backend behind the contract tests and every
12+
sync-engine test in the workspace; `fault_injection.rs` makes it fail on demand
13+
14+
Depends only on `driven-tls` (custom CA + proxy config, re-exported here so callers
15+
need no direct dependency). Consumed by `driven-core`, `driven-cli`, `driven-chaos`,
16+
and `src-tauri`. OAuth and the Drive layout are specified in `design/SPEC.md` s4.
17+
18+
```sh
19+
cargo test -p driven-drive # fake contract suite
20+
just test-e2e-real # real Drive, env-gated; see design/E2E_REAL.md
21+
```

crates/driven-net/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# `driven-net`
2+
3+
The production `Backend` behind `driven-core::network`'s `NetworkProbe` seam.
4+
`driven-core` ships only the transport-agnostic probe topology and the per-service
5+
circuit breakers and stays I/O-free; this crate supplies the real clients
6+
(`design/DESIGN.md` s5.8).
7+
8+
- `reachability.rs` - the native per-OS connectivity read (`INetworkListManager` on
9+
Windows, NetworkManager on Linux, `NWPathMonitor` on macOS) with a dual-stack TCP
10+
fallback when the native verdict is unavailable or ambiguous
11+
- `classify.rs` - turning a probe response into a `ProbeOutcome` (offline, captive
12+
portal, DNS failure, service down)
13+
- `lib.rs` - the `Backend` impl: captive-portal probe, per-service health probes with
14+
per-service timeouts, and connection-pool teardown
15+
16+
Every client is built through `driven_tls::apply_proxy` / `apply_custom_ca`, so the
17+
user's proxy and corporate-CA settings apply here too. Consumed by `driven-cli` and
18+
`src-tauri`; the tests drive the topology through `FakeNetwork` from
19+
`driven-test-fixtures`.
20+
21+
```sh
22+
cargo test -p driven-net
23+
```

crates/driven-power/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# `driven-power`
2+
3+
Battery / AC / metered-network / sleep-wake signals, normalized across OSes. The
4+
orchestrator's pause-and-resume rules (`design/SPEC.md` s10, `design/DESIGN.md` s5.7
5+
and s5.10.1) are driven entirely by what this crate reports.
6+
7+
- `lib.rs` - the `PowerSource` trait, the `PowerState` snapshot, and the
8+
`SleepWakeEvent` edge; both subscriptions are `tokio::sync::broadcast` receivers
9+
because several consumers (state machine, tray, activity log) fan out from them
10+
- `windows.rs` / `macos.rs` / `linux.rs` - exactly one is compiled per target, each
11+
exporting `RealPowerSource` (re-exported cfg-free so callers need no `cfg`)
12+
- `network.rs` - shared metered / reachability detection used by every backend
13+
14+
Steady state is a 30 s poll; sleep and wake are OS notification edges, not polls.
15+
Tests use `FakePowerSource` from `driven-test-fixtures`. `driven-diskstat` is
16+
deliberately shaped the same way.
17+
18+
```sh
19+
cargo test -p driven-power
20+
```
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# `driven-test-fixtures`
2+
3+
Shared test helpers, pulled in as a `[dev-dependencies]` entry by sibling crates and
4+
the workspace integration tests. It is what makes the injected-trait design pay off:
5+
every seam in the workspace has a deterministic fake here.
6+
7+
- `tree.rs` - the `tree!` macro for declaring a temp directory tree inline
8+
- `clock.rs` - `FakeClock` (`driven_core::time::Clock`) with `advance()` / `now_set()`
9+
- `power.rs` - `FakePowerSource` with a `set()` driver for state transitions
10+
- `diskstat.rs` - `FakeDiskBusyProbe` for the adaptive-parallelism tests
11+
- `network.rs` - `FakeNetwork`, simulating offline, captive portal, lossy links, and
12+
per-service outages
13+
- `assert.rs` - `assert_remote_eq!`, a snapshot diff over remote-store listings
14+
15+
Never a normal dependency of anything, and `publish = false`. Add a fake here rather
16+
than re-rolling one per crate.
17+
18+
```sh
19+
cargo test -p driven-test-fixtures
20+
```

0 commit comments

Comments
 (0)