Skip to content

codemod: auto-apply mode for mechanically-rewritable findings #512

@bokelley

Description

@bokelley

From the salesagent v3.12 → 4.x migration. Of 141 codemod findings, ~78% are mechanically rewritable; today the codemod refuses to rewrite any of them in --apply mode.

Adopter quote (SDK_FEEDBACK.md, items #6, #7, and the aggregate ask):

Of the 141 findings:

  • 83 flag_private with public-surface aliases → auto-rewritable
  • 27 flag_numbered Assets with documented semantic aliases → auto-rewritable
  • 31 flag_removed (Pricing, BrandManifest, etc.) → genuinely needs human review

A --auto-apply mode that rewrites the safe 78% and flags the rest would have shaved most of an afternoon off this migration.

Proposal

Extend python -m adcp.migrate v3-to-v4 --apply (or add a new --auto-apply) that:

  • Auto-rewrites flag_private findings whose target symbol is verifiable via hasattr(adcp.types, Symbol). Flag the rest.
  • Auto-applies the numbered-Assets renaming table (Assets5 → VideoFormatAsset, etc.) — the codemod already knows the mapping.
  • Leaves flag_removed cases as flag-only (genuine semantic decisions).

Adopter wrote a 30-line helper that does roughly this for flag_private. The verifier logic belongs in the codemod itself.

Acceptance

  • The reference adopter (salesagent) can run --auto-apply against a clean v3 checkout and have its flag_private+flag_numbered cases rewritten without manual intervention.
  • The unsafe flag_removed cases remain flagged with the same diagnostic shape as today.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions