tools capa

tools-consolidate-worktrees

Count-and-gate engine for consolidating scattered worktrees/clones into origin/master: inventory, collision report, restore-tested backup, PASS/FAIL verify, and a cleanup that refuses unless verify passes in-process. Merging stays human-driven; this tool only counts and gates (sprint 3.28).

Count-and-gate engine for consolidating scattered worktrees/clones into origin/master: inventory, collision report, restore-tested backup, PASS/FAIL verify, and a cleanup that refuses unless verify passes in-process. Merging stays human-driven; this tool only counts and gates (sprint 3.28).

Tiertools
Roleunclassified (baselined)
Pathcrates/tools/consolidate-worktrees
Edition2021
Targetstools-consolidate-worktrees, tools_consolidate_worktrees, cli_test
Public items31 across 8 modules
Tests54

What it is for

Decidable core of the consolidation playbook: parsers, extractors, verdicts, and the cleanup gate — each a pure function of its arguments — plus gitcmd, the one process edge every git call goes through (sprint 3.28).

Capabilities

gitcmd (other)

The process edge: every git invocation in the tool goes through here —

Item
fn git(repo : & Path, args : & & str) -> Result <String>
fn base_ref(repo : & Path) -> String
fn local_branches(repo : & Path) -> Result <Vec <String>>
fn ahead_count(repo : & Path, base : & str, branch : & str) -> Result <usize>
fn patch_unmatched(repo : & Path, base : & str, branch : & str) -> Option <usize>
fn content_landed(repo : & Path, base : & str, branch : & str) -> Option <bool>

integrate (other)

The integration step the playbook used to leave to hand-run git: take a merged-ready

Item
fn overlapping_files(branch_changed : & String, base_changed : & String) -> Vec <String>

IntegrationKind

The integration step the playbook used to leave to hand-run git: take a merged-ready

Item
pub enum IntegrationKind
fn classify_integration(has_merge_base : bool, branch_in_base : bool, base_in_branch : bool,) -> IntegrationKind

MergeVerdict

Merged-ness verdict (consensus m3, hardened at Gate 4 B1): ancestry

Item
pub enum MergeVerdict
MergeVerdict :: fn is_merged(self) -> bool
fn resolve_verdict(ahead : usize, patch_unmatched : Option <usize>, content_landed : Option <bool>,) -> MergeVerdict

migrations (other)

Migration version extraction and duplicate detection. Number collisions

Item
fn parse_migration_path(path : & str) -> Option <(String, u64, String)>
fn duplicate_versions(refs : & MigrationRef) -> Vec <VersionCollision>

MigrationRef

Migration version extraction and duplicate detection. Number collisions

Item
pub struct MigrationRef

VersionCollision

Migration version extraction and duplicate detection. Number collisions

Item
pub struct VersionCollision

WorktreeEntry

Parser for git worktree list --porcelain output.

Item
pub struct WorktreeEntry
fn parse_worktree_list(porcelain : & str) -> Vec <WorktreeEntry>

Check

Verify report aggregation and the cleanup gate. The gate is pure: the

Item
pub struct Check
fn all_pass(checks : & Check) -> bool
fn render_report(checks : & Check) -> String

CleanupGate

Verify report aggregation and the cleanup gate. The gate is pure: the

Item
pub struct CleanupGate
fn cleanup_allowed(gate : & CleanupGate) -> Result <(), String>

sprints (other)

Sprint/userstory doc numbering: extraction and collision detection.

Item
fn parse_sprint_doc(path : & str) -> Option <(String, String)>
fn sprint_collisions(docs : & SprintDocRef) -> Vec <SprintCollision>

SprintCollision

Sprint/userstory doc numbering: extraction and collision detection.

Item
pub struct SprintCollision

SprintDocRef

Sprint/userstory doc numbering: extraction and collision detection.

Item
pub type SprintDocRef: (String, String, String)

status (other)

Classifier for git status --porcelain lines: what is uncommitted, and

Item
pub const JUNK_COMPONENTS: & & str
fn is_junk(path : & str) -> bool

StatusSummary

Classifier for git status --porcelain lines: what is uncommitted, and

Item
pub struct StatusSummary
fn summarize_status(porcelain : & str) -> StatusSummary

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_consolidate_worktrees

flowchart TD
  n_tools_consolidate_worktrees["tools_consolidate_worktrees"]
  n_tools_consolidate_worktrees --> n_gitcmd["gitcmd"]
  n_tools_consolidate_worktrees --> n_integrate["integrate"]
  n_tools_consolidate_worktrees --> n_merged["merged"]
  n_tools_consolidate_worktrees --> n_migrations["migrations"]
  n_tools_consolidate_worktrees --> n_porcelain["porcelain"]
  n_tools_consolidate_worktrees --> n_report["report"]
  n_tools_consolidate_worktrees --> n_sprints["sprints"]
  n_tools_consolidate_worktrees --> n_status["status"]

Public surface

`gitcmd`

ItemWhat it is
fn git(repo : & Path, args : & & str) -> Result <String>
fn base_ref(repo : & Path) -> StringThe consolidation base: origin/master when a remote-tracking ref exists (the normal case), plain master otherwise (fixtures, offline mirrors).
fn local_branches(repo : & Path) -> Result <Vec <String>>
fn ahead_count(repo : & Path, base : & str, branch : & str) -> Result <usize>Commit count on branch not reachable from base (ancestry).
fn patch_unmatched(repo : & Path, base : & str, branch : & str) -> Option <usize>Commits on branch whose patch-id is absent from basegit cherry lines starting with +
fn content_landed(repo : & Path, base : & str, branch : & str) -> Option <bool>True when every path the branch changed (vs its merge-base) is byte-identical between branch and base — the residue a multi-commit squash leaves

`integrate`

ItemWhat it is
pub enum IntegrationKindHow a branch relates to the base it would land on.
fn classify_integration(has_merge_base : bool, branch_in_base : bool, base_in_branch : bool,) -> IntegrationKindClassify the integration from three ancestry facts the caller reads out of git
fn overlapping_files(branch_changed : & String, base_changed : & String) -> Vec <String>The files a divergent merge could conflict on: those changed on BOTH sides since the merge base

`merged`

ItemWhat it is
pub enum MergeVerdict
MergeVerdict :: fn is_merged(self) -> boolOnly the two Merged verdicts satisfy the verify gate.
fn resolve_verdict(ahead : usize, patch_unmatched : Option <usize>, content_landed : Option <bool>,) -> MergeVerdictResolution chain: ancestry, then content, with patch-id only ever used as NEGATIVE evidence (unmatched > 0 confirms unmerged when content also says so)

`migrations`

ItemWhat it is
pub struct MigrationRefA migration file as seen on one source (branch or checkout).
fn parse_migration_path(path : & str) -> Option <(String, u64, String)>Extract (dir, version, file) from a repo-relative path shaped like crates/&lt;crate&gt;/migrations/012_add_col.sql
pub struct VersionCollisionSame dir + same version + more than one distinct FILE name = a number collision
fn duplicate_versions(refs : & MigrationRef) -> Vec <VersionCollision>

`porcelain`

ItemWhat it is
pub struct WorktreeEntryOne checkout as git reports it
fn parse_worktree_list(porcelain : & str) -> Vec <WorktreeEntry>Parse the porcelain format: blank-line-separated stanzas of worktree <path> / HEAD <sha> / branch refs/heads/<name> with optional bare markers like prunable or detached.

`report`

ItemWhat it is
pub struct Check
fn all_pass(checks : & Check) -> bool
fn render_report(checks : & Check) -> StringRender one line per check (PASS/FAIL, name, detail) and a final `VERIFY: PASS\
pub struct CleanupGateEverything cleanup needs to decide, gathered by the binary immediately before acting (consensus m4: the OID is pinned at verify time and must still match).
fn cleanup_allowed(gate : & CleanupGate) -> Result <(), String>Ok(()) means cleanup may proceed; Err carries the operator-readable refusal reason.

`sprints`

ItemWhat it is
fn parse_sprint_doc(path : & str) -> Option <(String, String)>Extract (number, slug) from a doc filename like docs/userstories/sprint-3.28-consolidate-worktrees-tool.md("3.28", "consolidate-worktrees-tool")
pub type SprintDocRef: (String, String, String)One sprint doc sighting: (number, slug, source branch).
pub struct SprintCollisionSame number claimed by more than one distinct slug = collision.
fn sprint_collisions(docs : & SprintDocRef) -> Vec <SprintCollision>

`status`

ItemWhat it is
pub const JUNK_COMPONENTS: & & strDirectory names that are build output, never work
fn is_junk(path : & str) -> boolTrue when any path component is a known build-output directory, or the path sits under the gitignored .claude/worktrees/ directory.
pub struct StatusSummary
fn summarize_status(porcelain : & str) -> StatusSummaryParse git status --porcelain (v1) output into the three buckets.

No pub use re-exports: every item above is declared in this crate.

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)unclassified (baselined)
Locationcrates/tools/consolidate-worktrees
Vocabulary in force (lexicon)current

Dependencies

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
anyhow^1noalways
clap^4derivenoalways

Development, in this workspace.

CrateTierOptionalOnly on
`tools-cli-conformance`toolsnoalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
tempfile^3noalways

Build. None.

Depended on by. Nothing in this workspace.

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

flowchart LR
  SELF["tools-consolidate-worktrees"]
  SELF -->|development| n_tools_cli_conformance["tools-cli-conformance"]
  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-consolidate-worktrees`src/main.rs`
libtools_consolidate_worktrees`src/lib.rs`
testcli_test`tests/cli_test.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 tests42
Integration tests12
Examples0
Doctests0

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

ModuleTestsExamplesConsumers
gitcmd600
integrate300
merged200
migrations400
porcelain200
report500
sprints400
status400

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc2331
Public modules with a //! block88
pie showData
    title Public items with rustdoc
    "Documented" : 23
    "No rustdoc detected" : 8

Metrics

MetricValue
Rust source files10
Source lines1840
Code lines1482
Public API items31
Public modules8
Tests54
Examples0
Cargo features0
Direct runtime dependencies2
Workspace reverse dependencies0
pie showData
    title Public API by kind
    "constant" : 1
    "enum" : 2
    "function" : 19
    "method" : 1
    "struct" : 7
    "type alias" : 1
pie showData
    title Rust source composition
    "Code" : 1482
    "Blank or comment" : 358

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