Skip to content

chore(scripts): add trait_generic_audit.sh — Phase 7a baseline tool (refs #287)#288

Merged
githubrobbi merged 1 commit into
mainfrom
chore/phase-7a-baseline-tool
May 19, 2026
Merged

chore(scripts): add trait_generic_audit.sh — Phase 7a baseline tool (refs #287)#288
githubrobbi merged 1 commit into
mainfrom
chore/phase-7a-baseline-tool

Conversation

@githubrobbi
Copy link
Copy Markdown
Collaborator

Phase 7a — adds the prod-only trait / generic / dispatch inventory tool for the Phase 7 refactor (issue #287).

Mirrors scripts/dev/clone_alloc_audit.sh (Phase 6a, PR #281) and scripts/dev/risk_markers_prod.sh (Phase 5a) in shape.

What it does

  • Counts per crate: pub trait / pub(crate) trait / private trait definitions, generic fn signatures, dyn Trait sites, where-clause density, impl Trait sugar.
  • Per-trait inventory: file:line, visibility, workspace-wide prod-impl count (a trait defined in crate A can be implemented by a struct in crate B — e.g. FileReader in uffs-core is implemented by DaemonFileReader in uffs-daemon).
  • Dispatch site inventory: every dyn <Trait> site with file:line for Phase 7d.
  • Sealed-trait pattern detection.
  • Annotation tally for existing #[expect(clippy::*)] against the 4 Phase-7-relevant lints.
  • Optional --with-clippy flag for clippy-JSON cross-check.

Why it ships pre-empty-finding

Like Phase 5a / Phase 6a tools, this is the prerequisite for the per-sub-phase audits. The script generates the authoritative baseline that 7b–7h consume. Zero-finding pre-validation is expected (strict-clippy is already green on main); the audit value is the per-site classification + the per-trait justification log.

Snapshot (executed locally on d2d533021)

Surface Count
pub trait (workspace) 3
pub(crate) trait (workspace) 10
Generic fn signatures (workspace) 129
dyn Trait sites (workspace) 89
where clauses (workspace) 192
impl Trait sugar (workspace) 53
Workspace prod LOC 94,173

(The Phase 7 plan §1.1 had advisory counts of pub trait=4, dyn=15; the script is the authoritative source — the deltas come from the script catching inherent methods + tokio-bound dyn Future etc. Phase 7d / 7e re-classify each.)

13 traits in the per-trait inventory match exactly the plan §1.2 candidate list.

Validation

  • Pre-push gate: ✅ lint-pre-push passed (69 s) — includes lint-fast + sec + smoke + lint-ci-windows.
  • shellcheck: 0 errors, 0 SC2295 findings (SC2016 info-level matches the precedent in clone_alloc_audit.sh).
  • File-size policy: 532 LOC < 800 LOC threshold.
  • Commit signed (GPG: 3628BD817A687030E83025A8E406D32B4736D09F).

Local-only artifacts (not in this PR, per .gitignore /docs/dev/)

  • docs/dev/architecture/code_clean/phase_7_traits_generics_dispatch_implementation_plan.md
  • docs/dev/baseline/2026-05-19/phase_7_starting_sha.txt
  • docs/dev/baseline/2026-05-19/phase_7_trait_generic_baseline.md

Next: 7b — trait justification audit per playbook §879-886 (J1/J2/J3/J4 taxonomy).

Refs: #287

…refs #287)

New script `scripts/dev/trait_generic_audit.sh` — prod-only trait /
generic / dispatch inventory for the UFFS workspace.  Mirrors
`scripts/dev/clone_alloc_audit.sh` (Phase 6a) and
`scripts/dev/risk_markers_prod.sh` (Phase 5a) in shape.

Counts per crate:

  * pub trait / pub(crate) trait / private trait definitions
  * generic fn signatures (incl. inherent methods)
  * dyn Trait sites
  * where-clause density
  * impl Trait sugar (AsRef, Iterator, Fn, …)

Per-trait inventory:

  * file:line, visibility, and prod-impl count workspace-wide
    (a trait defined in crate A can be implemented by a struct in
    crate B — e.g. FileReader in uffs-core impl-d by DaemonFileReader
    in uffs-daemon)

Dispatch site inventory:

  * every `dyn <Trait>` site with file:line for Phase 7d
    classification (D1-PLUGIN / D2-HETERO / D3-NOOP / D4-VTBL-COST)

Sealed-trait pattern detection:

  * canonical `mod private { pub trait Sealed {} }` shape for
    Phase 7e seal/open decisions

Annotation tally:

  * existing `#[expect(clippy::type_complexity)]` /
    `#[expect(clippy::too_many_arguments)]` /
    `#[expect(clippy::wrong_self_convention)]` /
    `#[expect(clippy::trait_duplication_in_bounds)]` sites for
    Phase 7f bound-rationalization

Optional `--with-clippy` flag for clippy-JSON cross-check against
the 6 Phase-7-relevant clippy lints.

Excludes the same paths as Phase 6 baseline (tests/, benches/,
examples/, build.rs, *_tests.rs, *_test.rs, test_*.rs).

Companion to (local-only):

  * docs/dev/architecture/code_clean/phase_7_traits_generics_dispatch_implementation_plan.md
  * docs/dev/baseline/2026-05-19/phase_7_trait_generic_baseline.md
  * docs/dev/baseline/2026-05-19/phase_7_starting_sha.txt

Refs: #287
@githubrobbi githubrobbi merged commit d14b838 into main May 19, 2026
18 checks passed
@githubrobbi githubrobbi deleted the chore/phase-7a-baseline-tool branch May 19, 2026 16:58
githubrobbi added a commit that referenced this pull request May 19, 2026
The Phase 7g decisions-log row in `trait_policy.md:194` read 'this PR'
at the time of authoring (when PR #290 was open).  After PR #290 merged
the placeholder needed backfilling to '#290' to match the surrounding
rows (#288/#289/#291).

Companion to Phase 8e (PR #296), which already backfilled the sibling
'TBD' placeholder on row 193 (Phase 7f -> #291).  This 1-line edit
completes the decisions-log hygiene pass for Phase 7.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant