fix(training-agent): derive media-buy health/impairments from creative status#4737
Closed
bokelley wants to merge 2 commits into
Closed
fix(training-agent): derive media-buy health/impairments from creative status#4737bokelley wants to merge 2 commits into
bokelley wants to merge 2 commits into
Conversation
…e status (unblocks dependency_impairment storyboard) The `dependency_impairment` storyboard (adcp#4677 closing #2860) exercises `impairment.coherence` on /sales by forcing a referenced creative to `rejected` and asserting the buy snapshot flips to `health: impaired`. Three pieces were missing from the training agent: - `task-handlers.ts:deriveImpairments()` walks each buy's `creativeAssignments` and surfaces `impairments[]` entries from session creative status — `resource_type: creative`, `transition: approved → rejected`, materially-scoped `package_ids[]` — wired into `handleGetMediaBuys` + `handleCreateMediaBuy` responses. Creative-track only; audience and catalog_item families remain forward-only on the spec today. - `tenants/comply.ts`: `force.creative_status` adapter added to `buildSalesComplyConfig` so storyboards can drive the creative through approved → rejected → processing without depending on real seller-side review timing. `/sales` already advertises `syncCreatives` + `listCreatives` at the platform layer, so the SDK runner can observe the offline status transition through normal task responses. - `task-handlers.ts:handleSyncCreatives`: `assignments[]` entries now fall back to walking `session.mediaBuys` when `media_buy_id` is omitted — per `sync-creatives-request.json` which marks only `creative_id` + `package_id` as required. `@adcp/sdk` bumped `^7.6.0 → ^7.7.0` for the `creative_approvals[]` extractor on the SDK runner's `impairment.coherence` buy-snapshot walk (adcontextprotocol/adcp-client#1819). Moves the official scenario from `3P / 1F / 7S` to `6P / 1F / 4S` on `/sales` (three previously-skipped steps now pass; same one failure). The remaining `get_buy_impaired` failure is blocked on adcontextprotocol/adcp-client#1846 — the v6 SalesPlatform.syncCreatives strips `assignments[]` before reaching the platform handler, so the buy never gets the creative assigned and the derivation has nothing to surface. Once #1846 lands, the scenario fully clears without further training-agent changes. Follow-up audience/catalog tracks tracked in adcp#4674. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 tasks
…task-v2 # Conflicts: # server/src/training-agent/task-handlers.ts
Contributor
Author
|
Closing — superseded by #4733 which landed yesterday and implements the same fix (concurrent work). Comparison:
#4733's approach is canonical (matches the spec's "seller MUST surface" framing where the seller actively pushes the impairment, rather than the buyer's reader inferring). The After merging main into this branch, net source delta is zero (merge commit f66943c). The branch can stay open as a worktree-cleanup; closing the PR. Cross-references preserved on follow-up:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
deriveImpairments()intask-handlers.tsthat walks each buy'screativeAssignmentsand surfacesimpairments[]entries from session creative status. Wired intohandleGetMediaBuys+handleCreateMediaBuyresponses. Creative-track only.force.creative_statusadapter tobuildSalesComplyConfigso storyboards can drive the creative throughapproved → rejected → processingviacomply_test_controlleron/sales.handleSyncCreatives:assignments[]entries now fall back to walkingsession.mediaBuyswhenmedia_buy_idis omitted — persync-creatives-request.jsonwhich marks onlycreative_id+package_idas required.@adcp/sdk ^7.6.0 → ^7.7.0for thecreative_approvals[]extractor on the SDK runner'simpairment.coherencebuy-snapshot walk (ComplyControllerConfig: add force.audience_status + force.catalog_item_status slots adcp-client#1819).Why
The official dependency-impairment storyboard (#4677 closing #2860) currently fails on
/salesat theget_buy_impairedstep because the training agent doesn't emithealth+impairments[]onget_media_buys. This PR adds the derivation.Effect
Moves the official scenario from
3P / 1F / 7Sto6P / 1F / 4Son/sales(three previously-skipped steps now pass; same one failure).Remaining gap
The one remaining
get_buy_impairedfailure is blocked on adcontextprotocol/adcp-client#1846 — the v6SalesPlatform.syncCreativesstripsassignments[]from the wire request before reaching the platform handler, so the buy never gets the creative assigned and the derivation has nothing to surface. Once #1846 lands, the scenario fully clears without further training-agent changes.The defensive
media_buy_idfallback inhandleSyncCreativesis staged for that fix — it's a no-op today (assignments never reach the handler) but kicks in immediately once the SDK pipes them through.Scope boundary
INVERSE_DEFERRED_FAMILIESstill includes them).Test plan
npx tsc --project server/tsconfig.json --noEmit— cleanTENANT_PATH=sales npx tsx server/tests/manual/run-storyboards.ts—media_buy_seller/dependency_impairment ✓ 6P / 1F / 4S(was✗ 3P / 1F / 7S)/salestenant totals: 355 passed (was 350), 19 failed, 167 skipped — net +3 unblocked, +1 unrelated failure shift, no regressionsRelated
🤖 Generated with Claude Code