Skip to content

Commit 3ec8196

Browse files
committed
docs
1 parent f0c34ec commit 3ec8196

11 files changed

Lines changed: 616 additions & 1 deletion

.gitignore

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1-
target/
1+
# Build artifacts
2+
/target/
3+
4+
# Coverage and profiling
5+
/coverage/
6+
*.profraw
7+
*.profdata
8+
9+
# Logs and temp files
10+
*.log
11+
*.tmp
12+
*.temp
13+
14+
# Editor and OS files
15+
/.idea/
16+
/.vscode/
17+
*.swp
18+
*.swo
19+
.DS_Store
20+
Thumbs.db

docs/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# dustpkg Documentation
2+
3+
This directory contains complete Markdown documentation for `dustpkg`.
4+
5+
## Documentation Index
6+
7+
- `getting_started.md`: installation, build, and first package workflow.
8+
- `architecture.md`: workspace, crate, and execution flow.
9+
- `cli_reference.md`: command-line contract and command behavior.
10+
- `manifest_reference.md`: `Dust.toml` schema and field semantics.
11+
- `lockfile_reference.md`: `dustpkg.lock` schema and deterministic ordering model.
12+
- `resolver_and_reproducibility.md`: resolver algorithm and reproducibility guarantees.
13+
- `library_api.md`: public Rust API surface in `crates/dustpkg/src/lib.rs`.
14+
- `error_handling.md`: common failures, messages, and operational guidance.
15+
- `testing_and_ci.md`: test coverage and CI workflow.
16+
17+
## Scope
18+
19+
`dustpkg` is a deterministic package manager prototype for Dust projects. It initializes package manifests, manages direct dependencies, generates lock files with checksums, and validates manifest-lock consistency during build.
20+
21+
Current behavior focuses on deterministic dependency resolution and lockfile generation. It does not yet fetch remote registries or compile package artifacts.

docs/architecture.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Architecture
2+
3+
## Workspace Layout
4+
5+
- `Cargo.toml`: workspace root for `crates/dustpkg`.
6+
- `crates/dustpkg/src/main.rs`: CLI argument parsing and command dispatch.
7+
- `crates/dustpkg/src/lib.rs`: manifest model, lockfile model, resolver, and package operations.
8+
- `crates/dustpkg/tests/cli.rs`: integration tests for user-facing CLI behavior.
9+
10+
## Component Roles
11+
12+
## CLI Layer (`main.rs`)
13+
14+
- Parses subcommands: `init`, `add`, `update`, `build`.
15+
- Resolves current directory and `Dust.toml` path.
16+
- Enforces that `Dust.toml` exists for non-`init` commands.
17+
- Delegates all package logic to library functions.
18+
19+
## Library Layer (`lib.rs`)
20+
21+
- Defines data models:
22+
- `PackageInfo`
23+
- `Manifest`
24+
- `LockedDep`
25+
- `Lockfile`
26+
- Implements I/O:
27+
- `Manifest::load/save`
28+
- `Lockfile::load/save`
29+
- Implements operations:
30+
- `init_package`
31+
- `add_dependency`
32+
- `add_stdlib_dependencies`
33+
- `update_lock`
34+
- `build_package`
35+
- Implements deterministic resolver:
36+
- `resolve(manifest, seed)`
37+
38+
## Data Flow
39+
40+
1. Command enters CLI (`main.rs`).
41+
2. CLI validates preconditions (for example `Dust.toml` presence).
42+
3. Library reads/updates manifest.
43+
4. Library resolves dependencies into lock entries.
44+
5. Lockfile is written to `dustpkg.lock`.
45+
6. `build` verifies manifest dependency set matches lock versions.
46+
47+
## Determinism Model
48+
49+
- With `seed = None`: dependencies are sorted alphabetically.
50+
- With `seed = Some(n)`: dependencies are shuffled using `ChaCha8Rng` seeded with `n`.
51+
- Checksums are deterministic SHA-256 over `"name@version"`.

docs/cli_reference.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# CLI Reference
2+
3+
## Binary
4+
5+
`dustpkg`
6+
7+
## Global Form
8+
9+
```text
10+
dustpkg <COMMAND> [OPTIONS]
11+
```
12+
13+
## Commands
14+
15+
## `init`
16+
17+
Initialize a new package in the current directory.
18+
19+
```text
20+
dustpkg init
21+
```
22+
23+
Behavior:
24+
25+
- Creates `Dust.toml` with default package metadata.
26+
- Fails if `Dust.toml` already exists.
27+
28+
## `add`
29+
30+
Add one dependency to manifest and regenerate lockfile.
31+
32+
```text
33+
dustpkg add <name> <version> [--seed <u64>]
34+
```
35+
36+
Arguments:
37+
38+
- `name`: dependency key.
39+
- `version`: dependency version string.
40+
41+
Options:
42+
43+
- `--seed <u64>`: deterministic seed for dependency ordering.
44+
45+
Behavior:
46+
47+
- Requires `Dust.toml` to already exist.
48+
- Updates `[dependencies]` in manifest.
49+
- Rewrites `dustpkg.lock` using `resolve`.
50+
51+
## `update`
52+
53+
Regenerate lockfile from current manifest.
54+
55+
```text
56+
dustpkg update [--seed <u64>]
57+
```
58+
59+
Options:
60+
61+
- `--seed <u64>`: deterministic seed for dependency ordering.
62+
63+
Behavior:
64+
65+
- Requires `Dust.toml`.
66+
- Does not change manifest.
67+
- Rewrites `dustpkg.lock`.
68+
69+
## `build`
70+
71+
Validate manifest and lockfile consistency.
72+
73+
```text
74+
dustpkg build [--seed <u64>]
75+
```
76+
77+
Options:
78+
79+
- `--seed <u64>`: if provided, lockfile is updated first with this seed.
80+
81+
Behavior:
82+
83+
- Requires `Dust.toml`.
84+
- Calls `update_lock` before validation.
85+
- Ensures each manifest dependency exists in lockfile with matching version.
86+
- Prints success on pass.
87+
88+
## Current Exit/Failure Conditions
89+
90+
Representative failures:
91+
92+
- `Dust.toml not found in <cwd>`
93+
- `Dust.toml already exists in <dir>`
94+
- Parse/read/write failures with path context
95+
- `dependency '<name>' missing from lock file`
96+
- `version mismatch for dependency '<name>'`

docs/error_handling.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Error Handling
2+
3+
## Error Model
4+
5+
`dustpkg` uses `anyhow::Result` and attaches path/context strings for I/O and parse operations.
6+
7+
Primary error sources:
8+
9+
- Missing files
10+
- Invalid TOML format
11+
- Serialization/write failures
12+
- Manifest-lock validation failures
13+
14+
## Common User-Facing Errors
15+
16+
## Missing Manifest
17+
18+
For `add`, `update`, and `build`:
19+
20+
```text
21+
Dust.toml not found in <cwd>
22+
```
23+
24+
## Manifest Already Exists
25+
26+
For `init` in a non-empty project:
27+
28+
```text
29+
Dust.toml already exists in <dir>
30+
```
31+
32+
## Manifest/Lock Parse Failures
33+
34+
Typical context wrappers:
35+
36+
- `failed to read manifest at <path>`
37+
- `failed to parse manifest at <path>`
38+
- `failed to read lock file at <path>`
39+
- `failed to parse lock file at <path>`
40+
41+
## Consistency Failures During Build
42+
43+
- `dependency '<name>' missing from lock file`
44+
- `version mismatch for dependency '<name>': manifest <v1> vs lock <v2>`
45+
46+
## Operational Guidance
47+
48+
- Run `dustpkg update` after editing dependencies manually.
49+
- Re-run `build` to validate lockfile alignment.
50+
- Keep `Dust.toml` and `dustpkg.lock` committed together.

docs/getting_started.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Getting Started
2+
3+
## Prerequisites
4+
5+
- Rust toolchain compatible with edition 2021.
6+
- `cargo` available in PATH.
7+
- A working directory where `dustpkg` can create `Dust.toml` and `dustpkg.lock`.
8+
9+
## Build
10+
11+
From `dustpkg/`:
12+
13+
```bash
14+
cargo build --release
15+
```
16+
17+
Run the CLI with:
18+
19+
```bash
20+
cargo run -p dustpkg -- <command>
21+
```
22+
23+
## First Project Workflow
24+
25+
Create a new project directory and initialize:
26+
27+
```bash
28+
mkdir hello_dust
29+
cd hello_dust
30+
cargo run -p dustpkg -- init
31+
```
32+
33+
Expected result:
34+
35+
- `Dust.toml` is created.
36+
- Package name defaults to the current directory name.
37+
- Version defaults to `0.1.0`.
38+
- `dpl_version` defaults to `0.2`.
39+
40+
Add dependencies:
41+
42+
```bash
43+
cargo run -p dustpkg -- add serde 1.0.0
44+
cargo run -p dustpkg -- add rand 0.8.5 --seed 42
45+
```
46+
47+
Expected result:
48+
49+
- `Dust.toml` dependency map is updated.
50+
- `dustpkg.lock` is regenerated.
51+
- Checksums are recorded for each dependency.
52+
53+
Update lock file without changing manifest:
54+
55+
```bash
56+
cargo run -p dustpkg -- update
57+
```
58+
59+
Validate manifest-lock consistency:
60+
61+
```bash
62+
cargo run -p dustpkg -- build
63+
```
64+
65+
## Typical Files After Setup
66+
67+
`Dust.toml`:
68+
69+
```toml
70+
[package]
71+
name = "hello_dust"
72+
version = "0.1.0"
73+
dpl_version = "0.2"
74+
75+
[dependencies]
76+
serde = "1.0.0"
77+
rand = "0.8.5"
78+
```
79+
80+
`dustpkg.lock` includes:
81+
82+
- `package` metadata copied from manifest.
83+
- `dependencies` array with `name`, `version`, `checksum`, and `source`.
84+
- Optional `seed` when provided.

0 commit comments

Comments
 (0)