Cross-campaign migration (a report moves from campaign A to a different existing campaign B on re-analyze) never decremented A's report_count, leaving it permanently stale. The same abandonment happens on the signal-diverged create-new fall-through added for CR-03 (Task 1) — landing on a brand-new campaign instead of an existing sibling's, but the same class of staleness. Add a shared decrementOriginCampaign() helper and call it in both locations, guarded so it only fires when there is a real origin (ownReport.campaign_id non-null) and the match doesn't resolve back to the report's own campaign (the existing same-campaign no-op guard is unchanged). D-08 sibling upgrades (never-grouped report -> sibling campaign) increment the destination only, with no origin to decrement. - Test E: cross-campaign migration decrements origin, increments destination - Test F: D-08 upgrade with no prior campaign increments destination only - Test G (renamed from existing 18-04 test): same-campaign re-match remains zero mutations - Test H: signal-diverged create-new also decrements the abandoned origin (plan-checker-flagged case) Tests E and H failed against the pre-fix code (confirmed during RED). |
||
|---|---|---|
| .. | ||
| hooks | ||
| services | ||
| types | ||
| utils | ||
| auth-client.ts | ||
| auth-utils.ts | ||
| auth.ts | ||
| bootstrap.ts | ||
| permissions.test.ts | ||
| permissions.ts | ||
| status-registry.ts | ||
| utils.ts | ||