Skip to content

fix(training-agent): reject creative_assignments: [] on active/paused buys - #3286

Merged
bokelley merged 2 commits into
mainfrom
claude/issue-2835-reject-creative-clear-on-active-buy
Apr 30, 2026
Merged

bokelley merged 2 commits into
mainfrom
claude/issue-2835-reject-creative-clear-on-active-buy

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Closes #2835

update_media_buy with creative_assignments: [] on a package of an active buy caused deriveStatus to return pending_creatives (because hasCreatives === false), emitting an active → pending_creatives transition that is not in MEDIA_BUY_TRANSITIONS. The status.monotonic invariant assertion would reject this transition the moment any storyboard exercises the "buyer replaces all creatives" path.

Fix: Validation guard added in the pre-validation pass (handleUpdateMediaBuy, pre-pass loop). If the buy's derived status is active, paused, or pending_start, clearing all assignments on any package returns VALIDATION_ERROR before any mutation occurs. This is Option 2 from the issue — cleaner than the creaturesWereAttached bit (Option 1) because it keeps deriveStatus and MEDIA_BUY_TRANSITIONS untouched and produces a clear API error the agent under test can observe.

Non-breaking justification: Server-only change in task-handlers.ts; no protocol schema, task definition, or published API surface touched. Changeset --empty.

Pre-PR review:

  • code-reviewer: approved — Option 2 confirmed cleaner; guard placement in pre-pass (before any mutation) correct; comment at mutation site updated to remove the stale "may regress to pending_creatives" language; no schema impact

Triage-managed PR. This bot does not currently iterate on review comments or PR conversation threads (only on the source issue). To unblock:

  • Push fixup commits directly: gh pr checkout <num> → fix → push.
  • Or re-trigger: comment /triage execute on the source issue.

See #3121 for context.

Session: https://claude.ai/code/${CLAUDE_CODE_REMOTE_SESSION_ID}


Generated by Claude Code

@bokelley bokelley added the claude-triaged Issue has been triaged by the Claude Code triage routine. Remove to re-triage. label Apr 26, 2026
… buys

update_media_buy with an empty creative_assignments array on a live buy
caused deriveStatus to return pending_creatives (hasCreatives === false),
emitting an active → pending_creatives transition not in MEDIA_BUY_TRANSITIONS.

Guard added in the pre-validation pass: if the buy is in active, paused, or
pending_start status, clearing all assignments on any package returns
VALIDATION_ERROR before any mutation occurs. Updated the comment at the
mutation site to reflect that the empty-array case is now pre-empted.

Closes #2835

https://claude.ai/code/${CLAUDE_CODE_REMOTE_SESSION_ID}
@bokelley
bokelley force-pushed the claude/issue-2835-reject-creative-clear-on-active-buy branch from 2dd6d4a to 420e17f Compare April 30, 2026 19:51
…/paused

Updates the existing pending_start test to assert rejection (matching the new
guard in handleUpdateMediaBuy) and adds coverage for active and paused arms.
Adds a positive test confirming pending_creatives stays a no-op (guard list
correctly excludes it).

Per javascript-protocol-expert review of #3286.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@bokelley
bokelley marked this pull request as ready for review April 30, 2026 19:58
@bokelley
bokelley enabled auto-merge (squash) April 30, 2026 19:59
@bokelley
bokelley merged commit 8b613d9 into main Apr 30, 2026
16 checks passed
@bokelley
bokelley deleted the claude/issue-2835-reject-creative-clear-on-active-buy branch April 30, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude-triaged Issue has been triaged by the Claude Code triage routine. Remove to re-triage.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

training-agent: update_media_buy with empty creative_assignments emits non-monotonic active → pending_creatives

2 participants