Skip to content

fix(training-agent): unblock the S1 sandbox demonstrations (keyword buys, proposals, breakdowns, broadcast windows) - #9216

Merged
bokelley merged 10 commits into
mainfrom
fix/s1-sandbox-fixtures-9087
Nov 26, 2026
Merged

bokelley merged 10 commits into
mainfrom
fix/s1-sandbox-fixtures-9087

Conversation

@bokelley

@bokelley bokelley commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #9087

Learners in certification module S1 were blocked on required demonstrations against the /sales training 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 under static/schemas/source/** changes, and there is no changeset (training-agent-only, per the playbook).

What was wrong, and what changed

# Report Root cause Fix
1 create_media_buy with keyword_targets → UNSUPPORTED_FEATURE on packages[0].targeting_overlay.keyword_targets The seller declares keyword targeting seller-wide, but no catalog product declared it in overlay_support. Ordinary catalog buys never checked targeting. Configured offers from the 3.2 proposal flow are checked, so keyword buys on them failed. Search and retail-media products (beacon_search_standard, shopgrid_standard) declare keyword_targets and negative_keywords with broad/phrase/exact.
2 request_proposals rejected without constraint detail, even on minimal briefs An agent bug, not a missing fixture. Ordinary sessions draw proposals from a static registry whose plans name catalog product IDs. Any criterion that narrowed the catalog (offer_filters.channels, delivery_type) or reconfigured it (targeting_overlay turns each offer into a configured_* product) dropped every registry plan. The same happened to a plain "Search campaign" brief. The rejection reason was a fixed string. In non-seeded sessions, when no registry plan survives, the seller plans up to three matching offers (one currency) as a 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 existing fixture_match behavior.
3 No by_geo / device_type breakdowns on seed_mb_display_q2 Geo, device-type, and keyword breakdowns were not implemented. They were silently omitted, which the schema allows. New delivery-breakdowns.ts returns by_geo (country, region, nielsen_dma metro), by_device_type (with cursor pagination), and by_keyword when requested and declared. Rows come from the package's own targeting (for example geo_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.
4 No broadcast media buy seeded Only display and video fixtures existed, and no catalog product carries measurement windows. New read-through fixture seed_mb_broadcast_q4: a completed linear-TV flight that closed five days ago. Delivery reports measurement_window: "c3", is_final: false, and measurement_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 with status_filter: ["completed"]. A controller simulation still overrides it.
5 Reconciliation fixtures missing The reporting_core_lifecycle_probe lab works at 3.2 and 3.3 (prepare → advance to delayed → zero-row revision → prepare → omit_obligation → get_reporting_status). The likely blocker: sync_accounts returns an account_id, and comply_test_controller refuses a ref without sandbox: true with a terse message. The FORBIDDEN detail now shows how to add sandbox: true to the ref the learner already holds, for example {"account_id": "<id>", "sandbox": true}. The schema-required gate is unchanged.
+ (found while walking the rubric) s1_ex1_sc_availability_and_outcome_planning The seller advertises media_buy.availability_horizon. Catalog products answered a horizon query with their untimed forecast and no incomplete[], so a learner could not verify window coverage. Sessions without a seeded calendar answer with an open calendar: one available time 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_version 3.2 and 3.3-rc.3)

Walked end to end against a local /sales tenant at both versions:

  • s1_ex1_sc0 keyword + geo, multi-product: request_proposals with keyword + geo targeting → create_media_buy on 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, and required_overlay_support criteria) → refine_proposals finalize → accept_proposal → get_media_buys readback shows the effective targeting_overlay.keyword_targets.
  • s1_ex1_sc2: by_geo (country, DMA with truncation) and by_device_type on seed_mb_display_q2.
  • s1_ex1_sc_availability_and_outcome_planning: availability_horizon time rows; outcome_target (clicks) gives total_budget_guidance and forecast points, with and without a channel filter.
  • s1_ex1_sc_broadcast_delivery_windows: seed_mb_broadcast_q4 delivery 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_buy account, 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:

  1. Name the broadcast fixture in the S1 exercise scaffold (not criterion text). Either give the ID seed_mb_broadcast_q4 or say "get_media_buys with status_filter: ["completed"] on demo.example.com". Today Sage has no pointer to a broadcast buy.
  2. In the reporting-lab sandbox guidance, say that every comply_test_controller call needs sandbox: true on the account reference.
  3. In the keyword-targeting guidance, point at search and retail-media offers. Display, video, and audio offers do not support keyword targeting.
  4. s1_ex1_sc1 ("refines the buy using the refinement protocol") still uses 3.0 wording. On 3.2 the evidence is refine_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_cap is now bound after synthesized plans are built, so it reaches commercial_terms.frequency_cap and the accepted buy. This also repairs the pre-existing fixture_match and selected_product_plan paths, which dropped it the same way.
  • Criteria-matched plans are sized from each selected option's min_spend_per_package and stay inside offer_filters.budget_range. A cost_per target plans only offers priced in its currency. When nothing fits, the rejection names budget_range or cost_per.currency.
  • Dated reads of the broadcast fixture are prorated to the reporting period, so a period outside the flight reports zero.
  • Region and DMA slices the seller cannot partition are omitted rather than returned empty. Region tables now cover every catalog coverage country.
  • The open catalog calendar has no minimum duration, so a sub-day horizon reads available, matching purchase.
  • outcome_target cost plans clear each purchase's min_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's budget_range.max is below the minimums, the plan is dropped and the rejection says so.

Verification

  • Local /sales walkthrough at 3.2 and 3.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 $5k budget_range is rejected naming it; the EUR cost_per plan is priced in EUR.
  • New unit tests, each file run individually:
    • training-agent-delivery-breakdowns.test.ts: 23 passed
    • training-agent-s1-sandbox-fixtures.test.ts: 66 passed (3.2 and 3.3-rc.3)
    • training-agent-outcome-target.test.ts: 55 passed
    • training-agent-availability-windows.test.ts: 8 passed
    • training-agent-product-coverage.test.ts: 20 passed
    • training-agent-list-products-canonical.test.ts: 9 passed
    • comply-test-controller.test.ts: 113 passed
  • One existing availability-windows test asserted the old untimed forecast in an unseeded session. It is updated to the new open-calendar behavior; the seeded-calendar tests are unchanged.
  • Typecheck passes (pre-commit hook).
  • Storyboard matrix: the local run was stopped during a host-overload window, so hosted Training Agent Storyboards CI is the gate. The only storyboard that sends availability_horizon (availability_windows) seeds its own calendar, and no storyboard requests geo, device-type, or keyword breakdowns. The full training-agent.test.ts is left to CI for the same reason.

🤖 Generated with Claude Code

bokelley and others added 3 commits November 24, 2026 13:21
- 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>

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts wiring verified: per-package map defines product/channels/reporting/impressions/spend/clicks before the breakdown call, with correct fixtureProductReporting fallbacks 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>

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 conditional required[]; 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.

bokelley and others added 6 commits November 24, 2026 13:40
…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>

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 defaults countries to ['US'] (L251-253) and never empty.
  • task-handlers.ts: computeOutcomeTargetCostPlan minimum-spend stepping (L10285-10294) is index-aligned — percentages/minimumSpends both 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.

@bokelley
bokelley merged commit fc4b8b1 into main Nov 26, 2026
62 checks passed
@bokelley
bokelley deleted the fix/s1-sandbox-fixtures-9087 branch November 26, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(sandbox): S1 certification test agent missing exercise fixtures and capability support

1 participant