tools capa

tools-crate-retarget

Moves a consumer repo's path-dependencies from a superseded estate root onto the v2 tier taxonomy, where crates were both relocated (crates/<flat-name> -> crates/<tier>/<name>) and repackaged (<flat-name> -> <tier>-<name>). Derives the crate map from file-set evidence rather than name guessing, refuses to decide an ambiguous case, and applies the decided map to manifest keys, path values, and the crate idents in Rust source. The superseded names appear only in the generated map file, never in this crate.

Moves a consumer repo's path-dependencies from a superseded estate root onto the v2 tier taxonomy, where crates were both relocated (crates/<flat-name> -> crates/<tier>/<name>) and repackaged (<flat-name> -> <tier>-<name>). Derives the crate map from file-set evidence rather than name guessing, refuses to decide an ambiguous case, and applies the decided map to manifest keys, path values, and the crate idents in Rust source. The superseded names appear only in the generated map file, never in this crate.

Tiertools
Roletooling
Pathcrates/tools/crate-retarget
Edition2021
Targetstools-crate-retarget, tools_crate_retarget
Public items27 across 0 modules
Tests21

What it is for

Pure retarget logic. Two decidable problems, both here as functions with no fs access (Gate 2.1); main.rs does the walking, reading and writing.

1. Which v2 crate is this superseded crate? similarity + decide answer it from file-set evidence. A name-stem match cannot: a superseded flat crate named <x> has two plausible homes when the v2 estate holds both application/<x> and content/<x>, and up to four for the busiest stems. An ambiguous case is reported, never guessed. 2. What edits does that imply? retarget_manifest rewrites dep keys and path values; rename_idents rewrites the crate ident in Rust source (old_waf:: becomes infrastructure_waf::).

The superseded names are data, not vocabulary: they live in the generated map file and in a consumer's own history, never in this crate's prose or fixtures.

Capabilities

crate root

Pure retarget logic. Two decidable problems, both here as functions with no

Item
fn ident(package : & str) -> String
pub const MIN_SCORE: f64
pub const MIN_MARGIN: f64
fn decide(candidates : & (String, Similarity)) -> Decision
fn break_tie_by_same_relative_dir <'a>(old_rel : & str, candidates : & 'a (String, f64),) -> Option <& 'a(String, f64)>
fn retarget_manifest(text : & str, manifest_dir : & Path, old_root : & Path, map : & RetargetMap,) -> ManifestRewrite
fn rename_inherited_deps(text : & str, key_renames : & BTreeMap <String, String>,) ->(String, usize)
fn rename_feature_refs(text : & str, key_renames : & BTreeMap <String, String>) ->(String, usize)
fn rename_idents(source : & str, renames : & BTreeMap <String, String>) ->(String, usize)
fn normalize(path : & Path) -> PathBuf

Decision

Pure retarget logic. Two decidable problems, both here as functions with no

Item
pub enum Decision

DepChange

Pure retarget logic. Two decidable problems, both here as functions with no

Item
pub struct DepChange

FileFacts

Pure retarget logic. Two decidable problems, both here as functions with no

Item
pub struct FileFacts
FileFacts :: fn new(rel : impl Into <String>, len : u64) -> Self

ManifestRewrite

Pure retarget logic. Two decidable problems, both here as functions with no

Item
pub struct ManifestRewrite

MapRow

Pure retarget logic. Two decidable problems, both here as functions with no

Item
pub struct MapRow
fn parse_map_tsv(text : & str) -> Result <Vec <MapRow>, String>

RetargetMap

Pure retarget logic. Two decidable problems, both here as functions with no

Item
pub struct RetargetMap
RetargetMap :: fn insert(& mut self, old_dir : impl Into <PathBuf>, old_package : & str, new_package : & str, new_dir : impl Into <PathBuf>,)
RetargetMap :: fn get(& self, old_dir : & Path) -> Option <& Target>
RetargetMap :: fn ident_renames(& self) -> & BTreeMap <String, String>
RetargetMap :: fn len(& self) -> usize
RetargetMap :: fn is_empty(& self) -> bool

Similarity

Pure retarget logic. Two decidable problems, both here as functions with no

Item
pub struct Similarity
Similarity :: fn score(& self) -> f64
fn similarity(old : & FileFacts, new : & FileFacts) -> Similarity

Target

Pure retarget logic. Two decidable problems, both here as functions with no

Item
pub struct Target

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

No public modules: the crate root is its whole surface.

Public surface

`crate root`

ItemWhat it is
fn ident(package : & str) -> StringA crate name as it appears in Rust source: application-cms -> application_cms.
pub struct FileFactsOne source file of a crate, as the evidence for matching it.
FileFacts :: fn new(rel : impl Into <String>, len : u64) -> Self
pub struct Similarity
Similarity :: fn score(& self) -> f64Ranking score: overlap, weighted up by how much of it is byte-identical.
fn similarity(old : & FileFacts, new : & FileFacts) -> Similarity
pub const MIN_SCORE: f64A candidate must clear this score to be a match at all.
pub const MIN_MARGIN: f64...and beat the runner-up by this much, else the case is ambiguous.
pub enum Decision
fn decide(candidates : & (String, Similarity)) -> DecisionRank candidates by evidence and refuse to pick a near-tie.
fn break_tie_by_same_relative_dir <'a>(old_rel : & str, candidates : & 'a (String, f64),) -> Option <& 'a(String, f64)>Break a near-tie the only other way there is evidence for: a candidate sitting at the same relative directory as the old crate is that crate, not a peer that happens to have the same file shape
pub struct TargetWhere an old crate went: its new package name and new absolute directory.
pub struct RetargetMapThe approved old -> new crate map, keyed on the old crate's absolute directory (the path a consumer manifest points at), which is unambiguous where names are not.
RetargetMap :: fn insert(& mut self, old_dir : impl Into <PathBuf>, old_package : & str, new_package : & str, new_dir : impl Into <PathBuf>,)
RetargetMap :: fn get(& self, old_dir : & Path) -> Option <& Target>
RetargetMap :: fn ident_renames(& self) -> & BTreeMap <String, String>Superseded ident -> v2 ident (old_waf -> infrastructure_waf), for the source pass.
RetargetMap :: fn len(& self) -> usize
RetargetMap :: fn is_empty(& self) -> bool
pub struct DepChange
pub struct ManifestRewrite
fn retarget_manifest(text : & str, manifest_dir : & Path, old_root : & Path, map : & RetargetMap,) -> ManifestRewriteRewrite every path dep that points under old_root to its mapped new crate: the key becomes the new package name (or, for an aliased dep, package = "..." does), and the path becomes a relative path to the new directory.
fn rename_inherited_deps(text : & str, key_renames : & BTreeMap <String, String>,) ->(String, usize)Propagate a dep-key rename to the member manifests that inherit it
fn rename_feature_refs(text : & str, key_renames : & BTreeMap <String, String>) ->(String, usize)Propagate a dep-key rename into features, where a dependency is named again as dep:<key>, <key>/<feature>, or bare <key>
fn rename_idents(source : & str, renames : & BTreeMap <String, String>) ->(String, usize)Rename crate idents on identifier boundaries: old_waf::Rules becomes infrastructure_waf::Rules, while my_old_waf_helper is left alone.
pub struct MapRowOne approved line of the map file
fn parse_map_tsv(text : & str) -> Result <Vec <MapRow>, String>Tab-separated: old_rel old_package new_rel new_package and anything after is a comment column
fn normalize(path : & Path) -> PathBufLexical .. resolution — no fs, so it works on paths that no longer exist.

Re-exports. Exported here, defined elsewhere.

ExportDefined in
relative_pathtools_path_dep_repair::relative_path

Boundary

Depends on no other workspace tier.

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)tooling
Locationcrates/tools/crate-retarget
Vocabulary in force (lexicon)current

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`tools-path-dep-repair`toolsnoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
anyhow^1noalways

Development. None.

Build. None.

Depended on by. Nothing in this workspace.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  SELF["tools-crate-retarget"]
  SELF -->|runtime| n_tools_path_dep_repair["tools-path-dep-repair"]
  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

KindNameSource
bintools-crate-retarget`src/main.rs`
libtools_crate_retarget`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

PropertyEvidence
async public surfacenone detected
async runtimenone detected
database accessnone detected
network I/Onone detected
unsafe codenone detected
environment variablesyes

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

VariableRead in
HOMEsrc/main.rs

No workspace crate depends on this one.

Verification

KindCount
Unit tests21
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root2000

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc1727
Public modules with a //! block00
pie showData
    title Public items with rustdoc
    "Documented" : 17
    "No rustdoc detected" : 10

Metrics

MetricValue
Rust source files2
Source lines1358
Code lines1157
Public API items27
Public modules0
Tests21
Examples0
Cargo features0
Direct runtime dependencies2
Workspace reverse dependencies0
pie showData
    title Public API by kind
    "constant" : 2
    "enum" : 1
    "function" : 10
    "method" : 7
    "struct" : 7
pie showData
    title Rust source composition
    "Code" : 1157
    "Blank or comment" : 201

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.

Todas las tools · Manual