Repository navigation
fix(training-agent): unblock the S1 sandbox demonstrations (keyword buys, proposals, breakdowns, broadcast windows) - #9216
Conversation
- Search and retail-media catalog products declare keyword_targets and negative_keywords overlay support, so keyword buys on configured offers from request_proposals no longer fail with UNSUPPORTED_FEATURE. - request_proposals plans the matching offers when criteria narrow or reconfigure the catalog past every pre-authored registry plan, and a rejection now names the criterion that left no offer. - get_media_buy_delivery returns by_geo, by_device_type, and by_keyword breakdowns when requested and declared; catalog products and the seeded compliance buys declare them. - Seed a completed broadcast buy (seed_mb_broadcast_q4) that reports the provisional C3 window against a C7 billing guarantee. - list_products answers availability_horizon with an open calendar for the demonstration catalog instead of an untimed forecast. - The comply_test_controller sandbox gate shows how to add sandbox: true to an account_id reference. Refs #9087 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #9087 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ads truthful Address review of the S1 sandbox fixes: - Bind criteria.media_buy_frequency_cap after synthesized request_proposals plans are built, so criteria-matched (and fixture/selected) plans carry it into commercial terms. - Size criteria-matched plans from the selected options' minimum spend, inside offer_filters.budget_range, and plan a cost_per target only on offers priced in its currency; name budget_range or cost_per.currency when nothing fits. - Prorate the broadcast fixture's delivery to a dated reporting period. - Omit region and DMA breakdowns the seller cannot partition instead of returning an empty complete slice; add region tables for every catalog coverage country. - The open catalog calendar has no minimum duration, matching purchase. Refs #9087 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — training-agent (app) PR with no blocking findings.
This PR adds deterministic geo/device/keyword delivery breakdowns, a seed_mb_broadcast_q4 provisional-C3 fixture, criteria-derived request_proposals plans with named rejections, and an open-catalog availability horizon across the training-agent server module and its unit tests (9 files, +1248/-29).
Checks performed:
- No
static/schemas/source/**,dist/**,docs/reference/**, or governance docs touched — no spec-drift, oneOf-discriminator, immutability, changeset-scope, or 3.1.x patch-eligibility concerns apply. This is an app-only change. delivery-breakdowns.ts(largest, +291):allocateByWeight(L136-149) splits totals via cumulative rounding so parts reconcile exactly to package totals (confirmed by reconciliation tests); sort/limit/cursor paths (L174-277) are safe.task-handlers.tswiring verified: per-package map defines product/channels/reporting/impressions/spend/clicks before the breakdown call, with correctfixtureProductReportingfallbacks when product is undefined.- No external I/O, workers, queue claims, or timeouts to audit. Comprehensive branch coverage across protocol versions.
Gate evaluation: no critical/high/medium findings; gated_paths false; high_risk false; no no-auto-approve team match; first review. review_decision is REVIEW_REQUIRED but since gated_paths is false, row 2 does not fire. Falls through to row 9 — approve.
Refs #9087 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — training-agent sandbox feature (adcp#9087) with no blocking or medium findings.
Checked:
delivery-breakdowns.ts(291 LOC, new): verified against published schemas.allocateByWeight(L136-149) cumulative-remainder rounding reconciles by_geo/by_device_type/by_keyword rows exactly to package totals (tests at L939-943). Geo row shapes satisfy geo-delivery-metrics.json conditionalrequired[]; pagination, keyword, and sorted_by echoes match get-media-buy-delivery-response.json.- No protocol surface touched (static/schemas/source untouched) → no changeset required, correctly absent. No schema↔docs coherence, oneOf discriminator, or released-artifact immutability concerns apply.
- Pure in-memory deterministic compute; no external I/O, workers, or timeouts introduced.
Gate checks: no no-auto-approve team match; gated_paths is false; high_risk is false; no prior decision. review_decision is REVIEW_REQUIRED but row 2 does not fire because gated_paths is false. No critical/high/medium findings, so rows 1 and 4–8 do not apply. Falls through to row 9 → approve.
…spend A cost_per plan computed its total from the target volume alone, so a plan over offers with min_spend_per_package (for example configured linear-TV offers at $25k) could quote less than each purchase's minimum and fail at accept. The total, and its guidance minimum, now clear every purchase's minimum; when the buyer's budget ceiling makes that impossible the plan is dropped and the rejection says so. Refs #9087 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #9087 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
An unequal allocation (for example 45% at a $5,000 minimum) made the required total a fractional cent, and rounding it to the nearest cent left that purchase a hair under its minimum, so accept_proposal failed. Round the required total up and step a cent at a time until every purchase's share clears its minimum. Refs #9087 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…splits Refs #9087 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ssion The minimum-spend guard computed total × (percentage / 100) while the canonical purchase budget is (total × percentage) / 100. Reassociation can put the guard a hair under an exactly satisfiable minimum (60% of $333 against a $199.80 minimum) and reject a plan inside the buyer's ceiling. Refs #9087 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ght ceiling Refs #9087 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — clean pass on training-agent delivery/plan logic.
Checked:
delivery-breakdowns.ts: DEFAULT_REGIONS extended to all catalog countries with a "whole-package-or-nothing" guard (L227); Nielsen DMA metro restricted to US-only delivery (L241), safe because geoBreakdown always defaultscountriesto ['US'] (L251-253) and never empty.task-handlers.ts: computeOutcomeTargetCostPlan minimum-spend stepping (L10285-10294) is index-aligned —percentages/minimumSpendsboth derive from proposal.allocations in order, with non-null pricing guard at L10221; cent-step loop bounded to float residue. Criteria-plan synthesis min_spend/budget-ceiling logic (L13113-13182) terminates correctly (while-loop guarded at length>1, per-product min pre-filtered ≤ ceiling).- getComplianceDeliverySimulation period/share math reconciles to fixture totals.
No changes to protocol surface (static/schemas/source/**, task defs, normative docs, dist artifacts), so no schema↔docs, changeset, oneOf, immutability, or governance gate applies. No high-risk paths, no gated paths. Prior clean approve holds.
No critical/high/medium findings → decision table falls through to row 9. No author team gate, gated_paths false, high_risk false.
Closes #9087
Learners in certification module S1 were blocked on required demonstrations against the
/salestraining seller. This PR fixes the five reported gaps and one more found while walking the full S1 rubric. All changes are in the training agent. Nothing is normative, nothing understatic/schemas/source/**changes, and there is no changeset (training-agent-only, per the playbook).What was wrong, and what changed
create_media_buywithkeyword_targets→UNSUPPORTED_FEATUREonpackages[0].targeting_overlay.keyword_targetsoverlay_support. Ordinary catalog buys never checked targeting. Configured offers from the 3.2 proposal flow are checked, so keyword buys on them failed.beacon_search_standard,shopgrid_standard) declarekeyword_targetsandnegative_keywordswithbroad/phrase/exact.request_proposalsrejected without constraint detail, even on minimal briefsoffer_filters.channels,delivery_type) or reconfigured it (targeting_overlayturns each offer into aconfigured_*product) dropped every registry plan. The same happened to a plain "Search campaign" brief. The rejection reason was a fixed string.criteria_match_*proposal. When no offer survives, the rejection names the criterion that emptied the catalog. Example:no offer satisfies criteria.targeting_overlay.keyword_targets together with the other supplied criteria. The suggestions name the same criterion. Controller-seeded sessions keep their existingfixture_matchbehavior.by_geo/device_typebreakdowns onseed_mb_display_q2delivery-breakdowns.tsreturnsby_geo(country, region,nielsen_dmametro),by_device_type(with cursor pagination), andby_keywordwhen requested and declared. Rows come from the package's own targeting (for examplegeo_countries,keyword_targets) and fall back to product coverage or channels. Rows reconcile to package totals. Catalog products and the seeded compliance buys declare the capabilities.seed_mb_broadcast_q4: a completed linear-TV flight that closed five days ago. Delivery reportsmeasurement_window: "c3",is_final: false, andmeasurement_source: "summit_measurement"against a C7 billing guarantee, at 87% of planned audience. That is maturation by design, not under-delivery. Reachable by ID or withstatus_filter: ["completed"]. A controller simulation still overrides it.reporting_core_lifecycle_probelab works at 3.2 and 3.3 (prepare → advance to delayed → zero-row revision → prepare →omit_obligation→get_reporting_status). The likely blocker:sync_accountsreturns anaccount_id, andcomply_test_controllerrefuses a ref withoutsandbox: truewith a terse message.FORBIDDENdetail now shows how to addsandbox: trueto the ref the learner already holds, for example{"account_id": "<id>", "sandbox": true}. The schema-required gate is unchanged.s1_ex1_sc_availability_and_outcome_planningmedia_buy.availability_horizon. Catalog products answered a horizon query with their untimed forecast and noincomplete[], so a learner could not verify window coverage.availabletime row per offer covering the horizon. That matches purchase validation, which never refuses a catalog flight. Seeded sessions are unchanged.S1 rubric coverage (
/sales,adcp_version3.2and3.3-rc.3)Walked end to end against a local
/salestenant at both versions:s1_ex1_sc0keyword + geo, multi-product:request_proposalswith keyword + geo targeting →create_media_buyon the configured search offer plus a display package →pending_creatives.s1_ex1_sc1,s1_ex1_sc3,s1_ex1_sc_compact_media_buy_lifecycle,s1_ex1_sc_targeting_aware_discovery:request_proposals(geo-only, channel, delivery-type, keyword, andrequired_overlay_supportcriteria) →refine_proposalsfinalize →accept_proposal→get_media_buysreadback shows the effectivetargeting_overlay.keyword_targets.s1_ex1_sc2:by_geo(country, DMA with truncation) andby_device_typeonseed_mb_display_q2.s1_ex1_sc_availability_and_outcome_planning:availability_horizontime rows;outcome_target(clicks) givestotal_budget_guidanceand forecast points, with and without a channel filter.s1_ex1_sc_broadcast_delivery_windows:seed_mb_broadcast_q4delivery as above.s1_ex1_sc_reliable_reporting_reconciliation: the full lab with{account_id, sandbox: true}.The remaining criteria (state machine, pricing options, terms negotiation,
update_media_buyaccount, agency estimate number) were not blocked and are unchanged.Curriculum follow-ups for the Academy owner (not in this PR)
None of these needs a protocol change. They are guidance and wording fixes in the S1 curriculum rows:
seed_mb_broadcast_q4or say "get_media_buyswithstatus_filter: ["completed"]ondemo.example.com". Today Sage has no pointer to a broadcast buy.comply_test_controllercall needssandbox: trueon the account reference.s1_ex1_sc1("refines the buy using the refinement protocol") still uses 3.0 wording. On 3.2 the evidence isrefine_proposals.Review fixes (8492067, 45b2707, 482015f, d385b2d)
An independent review found seven issues across two rounds. All are fixed and covered by tests:
criteria.media_buy_frequency_capis now bound after synthesized plans are built, so it reachescommercial_terms.frequency_capand the accepted buy. This also repairs the pre-existingfixture_matchandselected_product_planpaths, which dropped it the same way.min_spend_per_packageand stay insideoffer_filters.budget_range. Acost_pertarget plans only offers priced in its currency. When nothing fits, the rejection namesbudget_rangeorcost_per.currency.available, matching purchase.outcome_targetcost plans clear each purchase'smin_spend_per_package, in both the total and the guidance minimum, rounded up to the cent so an unequal split (for example 45% at a $5,000 minimum) still clears it. This repairs a pre-existing path where a small-volume cost target over min-spend offers quoted an unpurchasable total. When the buyer'sbudget_range.maxis below the minimums, the plan is dropped and the rejection says so.Verification
/saleswalkthrough at3.2and3.3-rc.3(results above). After the review fixes, in-process checks confirmed: the cap is carried; the linear-TV plan is $75k ($25k per package); a $5kbudget_rangeis rejected naming it; the EURcost_perplan is priced in EUR.training-agent-delivery-breakdowns.test.ts: 23 passedtraining-agent-s1-sandbox-fixtures.test.ts: 66 passed (3.2 and 3.3-rc.3)training-agent-outcome-target.test.ts: 55 passedtraining-agent-availability-windows.test.ts: 8 passedtraining-agent-product-coverage.test.ts: 20 passedtraining-agent-list-products-canonical.test.ts: 9 passedcomply-test-controller.test.ts: 113 passedTraining Agent StoryboardsCI is the gate. The only storyboard that sendsavailability_horizon(availability_windows) seeds its own calendar, and no storyboard requests geo, device-type, or keyword breakdowns. The fulltraining-agent.test.tsis left to CI for the same reason.🤖 Generated with Claude Code