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.
| Tier | tools |
| Role | tooling |
| Path | crates/tools/crate-retarget |
| Edition | 2021 |
| Targets | tools-crate-retarget, tools_crate_retarget |
| Public items | 27 across 0 modules |
| Tests | 21 |
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`
| Item | What it is |
|---|---|
fn ident(package : & str) -> String | A crate name as it appears in Rust source: application-cms -> application_cms. |
pub struct FileFacts | One 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) -> f64 | Ranking score: overlap, weighted up by how much of it is byte-identical. |
fn similarity(old : & FileFacts, new : & FileFacts) -> Similarity | — |
pub const MIN_SCORE: f64 | A 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)) -> Decision | Rank 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 Target | Where an old crate went: its new package name and new absolute directory. |
pub struct RetargetMap | The 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,) -> ManifestRewrite | Rewrite 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 MapRow | One 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) -> PathBuf | Lexical .. resolution — no fs, so it works on paths that no longer exist. |
Re-exports. Exported here, defined elsewhere.
| Export | Defined in |
|---|---|
relative_path | tools_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 |
| Location | crates/tools/crate-retarget |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `tools-path-dep-repair` | tools | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
anyhow | ^1 | — | no | always |
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
| Kind | Name | Source |
|---|---|---|
| bin | tools-crate-retarget | `src/main.rs` |
| lib | tools_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
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | none detected |
| database access | none detected |
| 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 |
|---|---|
HOME | src/main.rs |
Related capabilities
No workspace crate depends on this one.
Verification
| Kind | Count |
|---|---|
| Unit tests | 21 |
| 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 | 20 | 0 | 0 |
What the tests establish, by name:
a_change_carries_the_package_names_the_ident_pass_needs—src/lib.rsa_consumer_pointing_at_another_worktree_yields_no_ident_renames—src/lib.rsa_dep_declared_as_a_table_renames_its_header_too—src/lib.rsa_feature_reference_follows_the_key_rename—src/lib.rsa_map_entry_whose_name_did_not_change_adds_no_ident_rename—src/lib.rsa_same_named_sibling_with_different_files_scores_low—src/lib.rsa_tie_is_broken_by_the_candidate_at_the_same_relative_dir—src/lib.rsan_aliased_dep_keeps_its_key_and_moves_its_package—src/lib.rsan_identical_file_set_scores_a_full_match—src/lib.rsan_inherited_dep_follows_the_key_rename_in_the_workspace_root—src/lib.rsan_inherited_dep_in_table_form_follows_too—src/lib.rsan_unrelated_inherited_dep_is_untouched—src/lib.rsdecide_picks_the_candidate_the_evidence_favours—src/lib.rsdecide_refuses_a_near_tie_instead_of_guessing—src/lib.rsdecide_reports_no_match_when_nothing_is_plausible—src/lib.rsleaves_a_dep_outside_the_old_root_alone—src/lib.rsnormalize_resolves_parent_segments_lexically—src/lib.rsrenames_crate_idents_only_on_identifier_boundaries—src/lib.rsreports_an_unmapped_crate_under_the_old_root_without_touching_it—src/lib.rsretargets_the_key_and_the_path_together—src/lib.rsthe_map_file_skips_comments_and_rejects_a_short_row—src/lib.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 17 | 27 |
Public modules with a //! block | 0 | 0 |
pie showData
title Public items with rustdoc
"Documented" : 17
"No rustdoc detected" : 10
Metrics
| Metric | Value |
|---|---|
| Rust source files | 2 |
| Source lines | 1358 |
| Code lines | 1157 |
| Public API items | 27 |
| Public modules | 0 |
| Tests | 21 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 2 |
| Workspace reverse dependencies | 0 |
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.