Skip to content

Commit 657cc95

Browse files
bokelleyclaude
andcommitted
fixup(migrate): wire migration anchor + add doc section for pending_activation
Per review on #523: - REMOVED_ENUM_VALUES gains the (hint, anchor) tuple shape so findings carry a migration_anchor like REMOVED_TYPES do. - New MIGRATION_v3_to_v4.md § ``MediaBuyStatus.pending_activation`` → split with the cause-to-replacement mapping and a code example, matching the anchor the codemod now emits. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c006882 commit 657cc95

2 files changed

Lines changed: 40 additions & 4 deletions

File tree

MIGRATION_v3_to_v4.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,40 @@ if package.status == PackageStatus.active: ...
211211
if media_buy.status == MediaBuyStatus.active: ...
212212
```
213213

214+
### `MediaBuyStatus.pending_activation` → split
215+
216+
The single `pending_activation` enum value was split into two distinct
217+
states based on cause. The codemod flags every reference; the correct
218+
replacement is per-call-site.
219+
220+
| Cause | Replacement |
221+
| --- | --- |
222+
| Buy is scheduled and waiting for its start time | `MediaBuyStatus.pending_start` |
223+
| Buy is waiting on creative approval / asset processing | `MediaBuyStatus.pending_creatives` |
224+
225+
**Before (v3.x):**
226+
```python
227+
if media_buy.status == MediaBuyStatus.pending_activation:
228+
notify_trafficker(media_buy)
229+
```
230+
231+
**After (v4.0):**
232+
```python
233+
if media_buy.status in (
234+
MediaBuyStatus.pending_start,
235+
MediaBuyStatus.pending_creatives,
236+
):
237+
notify_trafficker(media_buy)
238+
```
239+
240+
When the original branch only fired for one cause, narrow to the right
241+
state (e.g. only `pending_creatives` for creative-review notifications).
242+
A blanket replacement to either single value is almost always wrong —
243+
the spec split was driven by adopters needing distinct behaviour for
244+
the two cases. The wire enum still accepts `pending` as a legacy alias
245+
for `pending_start`, so existing buyer clients reading older payloads
246+
keep working without code changes.
247+
214248
### `ResolvedBrand.brand_manifest` field removed
215249

216250
`RegistryClient.lookup_brand()` returns a `ResolvedBrand` whose

src/adcp/migrate/v3_to_v4.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,12 @@
108108

109109
# Enum values removed or split between v3 and v4. Flagged (not rewritten)
110110
# because the correct replacement depends on call-site semantics.
111-
REMOVED_ENUM_VALUES: dict[str, str] = {
111+
REMOVED_ENUM_VALUES: dict[str, tuple[str, str]] = {
112112
"MediaBuyStatus.pending_activation": (
113113
"`pending_activation` split in v4: use `pending_start` if the buy hasn't reached "
114114
"its scheduled start date, or `pending_creatives` if creatives haven't been "
115-
"submitted. Check `valid_actions` on the MediaBuy response to confirm which applies."
115+
"submitted. Check `valid_actions` on the MediaBuy response to confirm which applies.",
116+
"mediabuystatuspending_activation--split",
116117
),
117118
}
118119

@@ -422,7 +423,7 @@ def scan_file(path: Path, *, apply_changes: bool) -> tuple[list[Finding], str |
422423
# class-qualified form is anchored tightly enough that false positives
423424
# are unlikely; trailing word boundary prevents suffix matches like
424425
# ``MediaBuyStatus.pending_activation_v2``.
425-
for enum_val, hint in REMOVED_ENUM_VALUES.items():
426+
for enum_val, (enum_hint, enum_anchor) in REMOVED_ENUM_VALUES.items():
426427
for match in _REMOVED_ENUM_VALUE_PATTERNS[enum_val].finditer(line):
427428
findings.append(
428429
Finding(
@@ -431,7 +432,8 @@ def scan_file(path: Path, *, apply_changes: bool) -> tuple[list[Finding], str |
431432
line=lineno,
432433
column=match.start() + 1,
433434
before=enum_val,
434-
hint=hint,
435+
hint=enum_hint,
436+
migration_anchor=enum_anchor,
435437
)
436438
)
437439

0 commit comments

Comments
 (0)