Finds and clears cargo build artifacts across a set of project directories, reports space reclaimed, optionally persists the report to corpus_sourcecode (sprint 3.104).
| Tier | tools |
| Role | unclassified (baselined) |
| Path | crates/tools/target-sweep |
| Edition | 2021 |
| Targets | tools-target-sweep, tools_target_sweep |
| Public items | 8 across 1 module |
| Tests | 7 |
What it is for
Pure discovery/sizing logic for sprint 3.104's disk-cleanup tool.
Kept free of subprocess/DB calls so it's testable against real tempdir fixtures, no mocks (Gate 2 convention this repo already follows).
Capabilities
crate root
Pure discovery/sizing logic for sprint 3.104's disk-cleanup tool.
| Item |
|---|
fn discover_repos(parent : & Path) -> io::Result <Vec <PathBuf>> |
fn target_dir_size(repo : & Path) -> io::Result <u64> |
SweepReport
Pure discovery/sizing logic for sprint 3.104's disk-cleanup tool.
| Item |
|---|
pub struct SweepReport |
SweepReport :: fn reclaimed(& self) -> u64 |
SweepStatus
Pure discovery/sizing logic for sprint 3.104's disk-cleanup tool.
| Item |
|---|
pub enum SweepStatus |
persist (other)
Optional write side: persists each repo's crate::SweepReport into
| Item |
|---|
pub const MODULE_NAME: & str |
async fn apply_migrations(pool : & PgPool) -> Result <u32, application_core::MigrationError> |
async fn insert_report(pool : & PgPool, report : & SweepReport) -> Result <(), sqlx::Error> |
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
tools_target_sweep
persist
Public surface
`crate root`
| Item | What it is |
|---|---|
fn discover_repos(parent : & Path) -> io::Result <Vec <PathBuf>> | Immediate children of parent that are directories containing a Cargo.toml -- one level deep only (Gate 1.5.6 §1: bounded discovery, never a recursive repo scan) |
fn target_dir_size(repo : & Path) -> io::Result <u64> | Recursive byte sum of repo/target, never following symlinks (Gate 1.5.6 §1: no symlink-loop risk) |
pub enum SweepStatus | What happened when sweeping one repo. |
pub struct SweepReport | One repo's sweep result. |
SweepReport :: fn reclaimed(& self) -> u64 | — |
`persist`
| Item | What it is |
|---|---|
pub const MODULE_NAME: & str | This tool's own module name in forge_module_migrations (application_core::apply_module_migrations's per-module namespace) -- distinct from "tools-session-error-audit"/"org-knowledge-corpus" in the SAME shared corpus_sourcecode database. |
async fn apply_migrations(pool : & PgPool) -> Result <u32, application_core::MigrationError> | Apply this tool's own migration into pool (already the corpus_sourcecode connection) |
async fn insert_report(pool : & PgPool, report : & SweepReport) -> Result <(), sqlx::Error> | Insert one repo's sweep report as one row |
No pub use re-exports: every item above is declared in this crate.
Boundary
Reaches into application, foundation.
Shares tier tools with 84 other crates: tools-advisory-reach, tools-archive-guard, tools-artifact-scaffold, tools-ask-ai-core, tools-ask-ais, tools-ask-gemini, tools-book, tools-book-report, … (84 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | tools |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/tools/target-sweep |
| Vocabulary in force (lexicon) | current |
Tier flow. Which tiers this crate's own edges cross.
flowchart LR n_tools["tools"] --> n_application["application"] n_tools["tools"] --> n_foundation["foundation"]
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `application-core` | application | no | always |
| `foundation-bounded-io` | foundation | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
chrono | ^0.4 | serde | no | always |
clap | ^4 | derive | no | always |
serde | ^1 | derive, derive | no | always |
serde_json | ^1 | — | no | always |
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json | no | always |
thiserror | ^2 | — | no | always |
tokio | ^1 | full, macros, rt-multi-thread | no | always |
Development, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `tools-cli-conformance` | tools | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
tempfile | ^3 | — | no | always |
url | ^2 | — | no | always |
Build. None.
Depended on by. Nothing in this workspace.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR SELF["tools-target-sweep"] SELF -->|development| n_tools_cli_conformance["tools-cli-conformance"] SELF -->|runtime| n_application_core["application-core"] SELF -->|runtime| n_foundation_bounded_io["foundation-bounded-io"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| bin | tools-target-sweep | `src/main.rs` |
| lib | tools_target_sweep | `src/lib.rs` |
Error model
No public error type was detected: no public item declares a type named *Error, and no public signature returns one.
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | yes |
| async runtime | yes |
| database access | yes |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | yes |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
| Variable | Read in |
|---|---|
CORPUS_SOURCECODE_APP_DB | src/main.rs |
DATABASE_URL | src/persist.rs |
TEST_DATABASE_URL | src/persist.rs |
Related capabilities
No workspace crate depends on this one.
Verification
| Kind | Count |
|---|---|
| Unit tests | 7 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 4 | 0 | 0 |
persist | 3 | 0 | 0 |
What the tests establish, by name:
discover_repos_finds_only_immediate_children_with_cargo_toml—src/lib.rsreclaimed_is_before_minus_after—src/lib.rstarget_dir_size_missing_target_returns_zero—src/lib.rstarget_dir_size_never_follows_symlinks—src/lib.rstarget_dir_size_sums_file_bytes_recursively—src/lib.rscli_definition_conforms—src/main.rsinsert_report_round_trips_ok_and_failed_rows—src/persist.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 7 | 8 |
Public modules with a //! block | 1 | 1 |
pie showData
title Public items with rustdoc
"Documented" : 7
"No rustdoc detected" : 1
Metrics
| Metric | Value |
|---|---|
| Rust source files | 3 |
| Source lines | 557 |
| Code lines | 425 |
| Public API items | 8 |
| Public modules | 1 |
| Tests | 7 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 9 |
| Workspace reverse dependencies | 0 |
pie showData
title Public API by kind
"constant" : 1
"enum" : 1
"function" : 4
"method" : 1
"struct" : 1
pie showData
title Rust source composition
"Code" : 425
"Blank or comment" : 132
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.